Tout_MZ

Client MountyZilla

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

  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.8
  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.8 29/04/2017",
  37. " Correction Bonus/Malus cas +0\+10 (AE)",
  38. " Correction portée IdC",
  39. " Prise en compte du bonus de portée PM dans le calcul tactique",
  40. "V1.2.17.7 26/04/2017",
  41. " Version compatible hors GreaseMonkey",
  42. "V1.2.17.6 23/04/2017",
  43. " Correction gestion des missions en cas de réinstallation",
  44. "V1.2.17.5 20/04/2017",
  45. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  46. "V1.2.17.4 08/04/2017",
  47. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  48. " Adaptation de la diplomacie à une modification de la page MH",
  49. "V1.2.17.3 04/04/2017",
  50. " Messages console en cas de cadre d'erreur",
  51. " Trolls de l'IT mais pas dans le vue en orange",
  52. "V1.2.17.2 20/03/2017",
  53. " Correction des PV restants",
  54. "V1.2.17.1 20/03/2017",
  55. " Blocage des PV restants en attendant résolution de bug",
  56. "V1.2.17 19/03/2017",
  57. " Refonte de l'envoi des CdM",
  58. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  59. "V1.2.16.4 08/03/2017",
  60. " correction ID de troll en envoi de PX/MP",
  61. "V1.2.16.3 27/02/2017",
  62. " correction bonus/malus FP",
  63. "V1.2.16.2 24/02/2017",
  64. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  65. "V1.2.16.1 21/02/2017",
  66. " corrige bug sur Fx 38.8 ESR",
  67. "V1.2.16 21/02/2017",
  68. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  69. " possibilité de masquer les Gowaps Sauvages dans la vue",
  70. " calcul des caractéristiques du siphon des âmes",
  71. "V1.2.15.2 02/02/2017",
  72. " adaptation décumul VlC (page des bonus/malus)",
  73. "V1.2.15.1 29/01/2017",
  74. " carte sur la page de description du lieu TP",
  75. "V1.2.15 25/01/2017",
  76. " mise en place des nouvelles cartes (suivants, TP)",
  77. "V1.2.14.3 25/01/2017",
  78. " résumé dans l'export des données Trõlligion",
  79. "V1.2.14.2 20/01/2017",
  80. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  81. "V1.2.14.1 20/01/2017",
  82. " réécriture filtrage des monstres par niveau dans la vue",
  83. " Changelog dans la page des news MZ",
  84. "V1.2.14 20/01/2017",
  85. " Ajout de l'export des données Trõlligion",
  86. "V1.2.13.7 10/01/2017",
  87. " Exclusion Bricoll'troll dans l'entête GM",
  88. "V1.2.13.6 08/01/2017",
  89. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  90. "V1.2.13.5 07/01/2017",
  91. " Correction bug qui se manisfestait sous LINUX",
  92. "V1.2.13.4 07/01/2017",
  93. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  94. "V1.2.13.3 07/01/2017",
  95. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  96. "V1.2.13.2 07/01/2017",
  97. " Correction missions, recherche troogle (familles et types de monstres)",
  98. "V1.2.13.1 06/01/2017",
  99. " Suppression oldSchoolProfile qui n'existe plus",
  100. " Ajout du 'refresh' du cadre de gauche",
  101. "V1.2.13 01/01/2017",
  102. " homogénéisation des messages d'erreur",
  103. " Ajout du lien Troogle sur les étapes de mission monstre",
  104. "V1.2.12.2 30/12/2016",
  105. " retour en mode normal (http si jeu en http)",
  106. "V1.2.12.1 27/12/2016",
  107. " Correction mode IP",
  108. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  109. "V1.2.12 24/12/2016",
  110. " Nettoyage des URL",
  111. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  112. " Interface bricoll'Troll en https",
  113. " Remise en marche des cartes des trajets des gowaps",
  114. "V1.2.11.5 à 7 20 & 21/12/2016",
  115. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  116. "V1.2.11.4 19/12/2016",
  117. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  118. "V1.2.11.3 19/12/2016",
  119. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  120. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  121. "V1.2.11.2 18/12/2016",
  122. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  123. "V1.2.11.1 17/12/2016",
  124. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  125. "V1.2.11 13/12/2016",
  126. " Passage sur BdD Raistlin \\o/",
  127. "V1.2.10.4 12/12/2016",
  128. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  129. "V1.2.10.3 09/12/2016",
  130. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  131. "V1.2.10.2 09/12/2016",
  132. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  133. "V1.2.10.1 08/12/2016",
  134. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  135. "V1.2.10 07/12/2016",
  136. " correction décumul des bonus/malus",
  137. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  138. "V1.2.9 16/11/2016",
  139. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  140. "V1.2.8 10/11/2016",
  141. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  142. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  143. "V1.2.7 07/11/2016",
  144. " remise en route de l'interface avec l'IT bricol'Troll",
  145. "V1.2.6 19/10/2016",
  146. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  147. " stockage idguilde et nomguilde",
  148. "V1.2.5 17/10/2016",
  149. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  150. " remise en route de la gestion des options avec intégration md5 dans ce script",
  151. "V1.2.4 14/10/2016",
  152. " utilisation du relai raistlin pour l'envoi des CdM",
  153. "V1.2.3 :",
  154. " suppression ancien profil",
  155. " nettoyage doublon sur getPortee",
  156. " adaptation portee TP basée sur les PI",
  157. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  158. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  159. "V1.2.1 :",
  160. " include des URLs MH alternatives",
  161. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  162. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  163. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  164. "V1.1 : regroupement en un gros paquet sale",
  165. ];
  166.  
  167. /**********************************************************
  168. À faire / propositions d'évolutions
  169.  
  170. breizhou13 20/12/2016
  171. envoyer les données à l'IT (Bricol'Trolls) aussi
  172. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  173. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  174. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  175. Akkila le boeuf le 26-03-2017 à 15:56
  176. - bouton pour rafraîchir les infos des trolls de son groupe
  177. Roule'
  178. Vérifier bonus double AE
  179. *urgent* corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  180. Réactiver les jubilaires
  181. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  182. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  183. - voir l'intérêt de refaire fonctionner
  184. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  185. Prévision des DLA de monstre
  186. Niveau des monstres à la méthode Roule'
  187. Raistlin
  188. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  189. Les cibles de mission ont disparu dans la vue (remonté par Hera)
  190. 80117 - Héra
  191. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  192. FAIT 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)
  193. ?
  194. Tenir compte de la distance pour le PM (calculatrice de combat)
  195. **********************************************************/
  196.  
  197. /**********************************************************
  198. **** Début de zone à déplacer dans une bibli commune ******
  199. **********************************************************/
  200.  
  201. // URL de base serveur MZ
  202. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  203. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  204. //var URL_MZ = 'http://192.99.225.92/mz';
  205.  
  206. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  207. // à supprimer
  208. const newCarte = true;
  209. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  210.  
  211. // URLs externes redirection (pas de souci CORS)
  212. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  213. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  214. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  215. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  216. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  217. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  218. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  219. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  220. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  221.  
  222. // URLs de test HTTPS
  223. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  224. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  225.  
  226. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  227. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  228. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  229.  
  230. // x~x Libs
  231.  
  232. /* ancien TODO
  233. * - revoir la gestion des CdM --> nott armure magique
  234. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  235. * - vérfier la gestion des enchants
  236. */
  237.  
  238. // Roule 04/09/2016 switch extern URLs to https if available
  239. var isHTTPS = false;
  240. if (window.location.protocol.indexOf('https') === 0) {
  241. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  242. URL_bricol = URL_bricol_https;
  243. isHTTPS = true;
  244. }
  245.  
  246. // Roule 23/12/2016 mode dev
  247. var isDEV = false;
  248. if (window.localStorage.getItem('MZ_dev') || window.location.href.indexOf('rouletabille.mh.free.fr') > 0) {
  249. URL_MZ = URL_MZ.replace(/$/, 'dev');
  250. isDEV = true;
  251. }
  252.  
  253. // Images (pas de souci CORS)
  254. var URL_MZimg = URL_MZ + '/img/';
  255. // URLs externes ajax (CORS OK)
  256. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  257. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  258.  
  259. // liens externes déduits
  260. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  261. var MHicons = '/mountyhall/Images/Icones/';
  262. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  263. var MY_DEBUG = false;
  264.  
  265. if (GM_getValue === undefined) { // éviter le blocage si pas sous GM
  266. window.console.log('*** warning *** GM_getValue n\'est pas défini (c\'est normal en test de compilation)');
  267. var GM_getValue = function(key) {};
  268. var GM_setValue = function(key, val) {};
  269. var GM_deleteValue = function(key) {};
  270. var GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  271. }
  272.  
  273. /* Utilisation de la gestion de l'enregistrement des données de
  274. GreaseMonkey, avec partage entre scripts via le localStorage, par
  275. Vapulabehemot (82169) 07/02/2017 */
  276. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  277. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  278. function MY_getValue(key) {
  279. var v = window.localStorage.getItem(key);
  280. vGM = GM_getValue(key);
  281. if ((vGM == null)
  282. || (v != null && v != vGM)){
  283. GM_setValue(key, v);
  284. } else if (v == null && vGM != null) {
  285. v = vGM;
  286. window.localStorage[key] = vGM;
  287. }
  288. return v;
  289. }
  290. function MY_removeValue(key) {
  291. GM_deleteValue(key);
  292. window.localStorage.removeItem(key);
  293. }
  294. function MY_setValue(key, val) {
  295. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  296. val = 1;
  297. else if (val === false)
  298. val = 0;
  299. GM_setValue(key, val);
  300. window.localStorage[key] = val;
  301. }
  302.  
  303. /*---------------- mise à jour de variables globales utiles ------------------*/
  304. // utilisé pour accès bdd (un peu partout) :
  305. var numTroll = MY_getValue('NUM_TROLL');
  306. // utilisé dans vue pour PX :
  307. var nivTroll = MY_getValue('NIV_TROLL');
  308. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  309. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  310. // utilisés dans actions et vue (calculs SR) :
  311. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  312. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  313. var currentURL = window.location.href;
  314.  
  315. /*-[functions]------------ Fonctions durée de script -------------------------*/
  316. var date_debut = null;
  317.  
  318. function start_script(nbJours_exp) {
  319. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  320. if(date_debut) return;
  321. date_debut = new Date();
  322. // Créé la variable expdate si demandé
  323. if(nbJours_exp) {
  324. expdate = new Date();
  325. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  326. }
  327. }
  328.  
  329. function displayScriptTime() {
  330. var footerNode = document.getElementById('footer2');
  331. if(!footerNode) return;
  332. try{
  333. var node = document.evaluate(
  334. ".//text()[contains(.,'Page générée en')]/../br",
  335. footerNode,null,9,null).singleNodeValue;
  336. }
  337. catch(e){return;}
  338. insertText(node,
  339. ' - [Script exécuté en '
  340. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  341. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  342. }
  343.  
  344. function traceStack(e, sModule) {
  345. var version = '';
  346. if (GM_info && GM_info.script && GM_info.script.version)
  347. version = ' ' + GM_info.script.version;
  348. sRet = '[MZ' + version + ']'
  349. if (sModule) sRet += ' {' + sModule + '}';
  350. if (e.message) sRet += ' ' + e.message;
  351. if (e.stack) {
  352. var sStack = e.stack;
  353. // enlever les infos confidentielles
  354. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  355. }
  356. return sRet;
  357. }
  358.  
  359. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  360.  
  361. function debugMZ(str){
  362. if(MY_DEBUG){
  363. window.console.debug('[MZ_DEBUG] '+str);
  364. if(typeof str === "object"){
  365. window.console.debug(str);
  366. }
  367. }
  368. }
  369.  
  370. function FF_XMLHttpRequest(MY_XHR_Ob) {
  371. var request = new XMLHttpRequest();
  372. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  373. for(var head in MY_XHR_Ob.headers) {
  374. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  375. }
  376. request.onreadystatechange = function() {
  377. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  378. if(request.readyState!=4) { return; }
  379. if(request.error) {
  380. if(MY_XHR_Ob.onerror) {
  381. MY_XHR_Ob.onerror(request);
  382. }
  383. }
  384. else if(MY_XHR_Ob.onload) {
  385. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  386. MY_XHR_Ob.onload(request);
  387. }
  388. };
  389. request.send(MY_XHR_Ob.data);
  390. }
  391.  
  392.  
  393. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  394.  
  395. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  396. function copyTextToClipboard(text) {
  397. var textArea = document.createElement("textarea");
  398.  
  399. //
  400. // *** This styling is an extra step which is likely not required. ***
  401. //
  402. // Why is it here? To ensure:
  403. // 1. the element is able to have focus and selection.
  404. // 2. if element was to flash render it has minimal visual impact.
  405. // 3. less flakyness with selection and copying which **might** occur if
  406. // the textarea element is not visible.
  407. //
  408. // The likelihood is the element won't even render, not even a flash,
  409. // so some of these are just precautions. However in IE the element
  410. // is visible whilst the popup box asking the user for permission for
  411. // the web page to copy to the clipboard.
  412. //
  413.  
  414. // Place in top-left corner of screen regardless of scroll position.
  415. textArea.style.position = 'fixed';
  416. textArea.style.top = 0;
  417. textArea.style.left = 0;
  418.  
  419. // Ensure it has a small width and height. Setting to 1px / 1em
  420. // doesn't work as this gives a negative w/h on some browsers.
  421. textArea.style.width = '2em';
  422. textArea.style.height = '2em';
  423.  
  424. // We don't need padding, reducing the size if it does flash render.
  425. textArea.style.padding = 0;
  426.  
  427. // Clean up any borders.
  428. textArea.style.border = 'none';
  429. textArea.style.outline = 'none';
  430. textArea.style.boxShadow = 'none';
  431.  
  432. // Avoid flash of white box if rendered for any reason.
  433. textArea.style.background = 'transparent';
  434.  
  435. textArea.value = text;
  436.  
  437. document.body.appendChild(textArea);
  438.  
  439. textArea.select();
  440.  
  441. var successful = document.execCommand('copy');
  442.  
  443. document.body.removeChild(textArea);
  444. return successful;
  445. }
  446.  
  447. function avertissement(txt,duree) {
  448. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  449. if(!duree) duree = 15000;
  450. var div = document.createElement('div');
  451. // On numérote les avertissements pour destruction sélective
  452. var num = document.getElementsByName('avertissement').length;
  453. div.num = num;
  454. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  455. div.setAttribute('name','avertissement');
  456. div.className = 'mh_textbox';
  457. div.style.position = 'fixed';
  458. div.style.top = (10+15*num)+'px';
  459. div.style.left = (10+5*num)+'px';
  460. div.style.border = '5px solid red';
  461. div.style.zIndex = 2+num;
  462. div.style.cursor = 'pointer';
  463. div.style.fontSize = 'large';
  464. div.innerHTML = txt;
  465. div.onclick=function(){ tueAvertissement(this.num) };
  466.  
  467. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  468. var divcroix = document.createElement('div');
  469. divcroix.style.position = 'absolute';
  470. divcroix.style.top = 0;
  471. divcroix.style.right = 0;
  472. divcroix.style.color = 'black';
  473. divcroix.style.fontSize = 'inherit';
  474. divcroix.style.cursor = 'pointer'
  475. divcroix.style.zIndex = 2+num;
  476. divcroix.innerHTML = "X";
  477. div.appendChild(divcroix);
  478.  
  479. document.body.appendChild(div);
  480. // Destruction automatique de l'avertissement après "un certain temps"
  481. window.setTimeout(function(){ tueAvertissement(num) },duree);
  482. }
  483.  
  484. function tueAvertissement(num) {
  485. var divs = document.getElementsByName('avertissement');
  486. if(divs.length==0) { return; }
  487. for(var i=0 ; i<divs.length ; i++) {
  488. if(divs[i].num==num) {
  489. divs[i].parentNode.removeChild(divs[i]);
  490. return;
  491. }
  492. }
  493. }
  494.  
  495.  
  496. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  497.  
  498. function insertBefore(next,el) {
  499. next.parentNode.insertBefore(el,next);
  500. }
  501.  
  502. function appendTr(tbody,clas) {
  503. var tr = document.createElement('tr');
  504. if(clas) tr.className = clas;
  505. tbody.appendChild(tr);
  506. return tr;
  507. }
  508.  
  509. function insertTr(next,clas) {
  510. var tr = document.createElement('tr');
  511. if(clas) tr.className = clas;
  512. insertBefore(next,tr);
  513. return tr;
  514. }
  515.  
  516. function appendTd(tr) {
  517. var td = document.createElement('td');
  518. if(tr) tr.appendChild(td);
  519. return td;
  520. }
  521.  
  522. function insertTd(next) {
  523. var td = document.createElement('td');
  524. insertBefore(next,td);
  525. return td;
  526. }
  527.  
  528. function appendTdCenter(tr,colspan) {
  529. var td = appendTd(tr);
  530. td.align = 'center'; // WARNING - Obsolete
  531. if(colspan) td.colSpan = colspan;
  532. return td;
  533. }
  534.  
  535. function insertTdElement(next,el) {
  536. var td = insertTd(next);
  537. if(el) td.appendChild(el);
  538. return td;
  539. }
  540.  
  541. function appendA(paren,href,cssClass,text) {
  542. var a = document.createElement('a');
  543. if (href) a.href = href;
  544. if (cssClass) a.className = cssClass;
  545. if (text) a.appendChild(document.createTextNode(text));
  546. paren.appendChild(a);
  547. }
  548.  
  549. function appendText(paren,text,bold) {
  550. if(bold) {
  551. var b = document.createElement('b');
  552. b.appendChild(document.createTextNode(text));
  553. paren.appendChild(b);
  554. }
  555. else
  556. paren.appendChild(document.createTextNode(text));
  557. }
  558.  
  559. function insertText(next,text,bold) {
  560. if(bold) {
  561. var b = document.createElement('b');
  562. appendText(b,text);
  563. insertBefore(next,b);
  564. }
  565. else
  566. insertBefore(next,document.createTextNode(text));
  567. }
  568.  
  569. function appendTdText(tr,text,bold) {
  570. var td = appendTd(tr);
  571. appendText(td,text,bold);
  572. return td;
  573. }
  574.  
  575. function insertTdText(next,text,bold) {
  576. var td = insertTd(next);
  577. appendText(td,text,bold);
  578. return td;
  579. }
  580.  
  581. function appendBr(paren) {
  582. paren.appendChild(document.createElement('br'));
  583. }
  584.  
  585. function insertBr(next) {
  586. insertBefore(next,document.createElement('br'));
  587. }
  588.  
  589. function appendLI(ul,text) {
  590. // uniquement utilisé dans les options (crédits)
  591. var li = document.createElement('li');
  592. appendText(li,text);
  593. ul.appendChild(li);
  594. return li;
  595. }
  596.  
  597. function appendTextbox(paren,type,nam,size,maxlength,value) {
  598. var input = document.createElement('input');
  599. input.className = 'TextboxV2';
  600. input.type = type;
  601. input.name = nam;
  602. input.id = nam;
  603. input.size = size;
  604. input.maxLength = maxlength;
  605. if(value) input.value = value;
  606. paren.appendChild(input);
  607. return input;
  608. }
  609.  
  610. function appendCheckBox(paren,nam,checked,onClick) {
  611. var input = document.createElement('input');
  612. input.type = 'checkbox';
  613. input.name = nam;
  614. input.id = nam;
  615. if(checked) input.checked = true;
  616. if(onClick) input.onclick = onClick;
  617. paren.appendChild(input);
  618. return input;
  619. }
  620.  
  621. function appendNobr(paren,id,delgg,text) {
  622. var nobr = document.createElement('nobr');
  623. appendCheckBox(nobr,id,null,delgg);
  624. appendText(nobr,text);
  625. paren.appendChild(nobr);
  626. appendText(paren,' ');
  627. return nobr;
  628. }
  629.  
  630. function appendCheckBoxSpan(paren,id,onClick,text) {
  631. var span = document.createElement('span');
  632. span.style.whiteSpace = 'nowrap';
  633. appendCheckBox(span,id,false,onClick);
  634. var label = document.createElement('label');
  635. appendText(label,text);
  636. label.htmlFor = id;
  637. label.style.marginLeft = '-5px';
  638. span.appendChild(label);
  639. span.style.marginRight = '3px';
  640. paren.appendChild(span);
  641. appendText(paren, ' ');
  642. return span;
  643. }
  644.  
  645. function appendOption(select,value,text) {
  646. var option = document.createElement('option');
  647. option.value = value;
  648. appendText(option,text);
  649. select.appendChild(option);
  650. return option;
  651. }
  652.  
  653. function appendHidden(form,nam,value) {
  654. var input = document.createElement('input');
  655. input.type = 'hidden';
  656. input.name = nam;
  657. input.id = nam;
  658. input.value = value;
  659. form.appendChild(input);
  660. }
  661.  
  662. function appendButton(paren,value,onClick) {
  663. var input = document.createElement('input');
  664. input.type = 'button';
  665. input.className = 'mh_form_submit';
  666. input.value = value;
  667. input.onmouseover = function(){this.style.cursor='pointer';};
  668. if(onClick) input.onclick = onClick;
  669. paren.appendChild(input);
  670. return input;
  671. }
  672.  
  673. function insertButton(next,value,onClick) {
  674. var input = document.createElement('input');
  675. input.type = 'button';
  676. input.className = 'mh_form_submit';
  677. input.value = value;
  678. input.onmouseover = function(){this.style.cursor='pointer';};
  679. input.onclick = onClick;
  680. insertBefore(next,input);
  681. return input;
  682. }
  683.  
  684. function appendSubmit(paren,value,onClick) {
  685. var input = document.createElement('input');
  686. input.type = 'submit';
  687. input.className = 'mh_form_submit';
  688. input.value = value;
  689. input.onmouseover = function(){this.style.cursor='pointer';};
  690. if(onClick) input.onclick = onClick;
  691. paren.appendChild(input);
  692. return input;
  693. }
  694.  
  695. function createImage(url,title,style) {
  696. var img = document.createElement('img');
  697. img.src = url;
  698. img.title = title;
  699. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  700. if (style) img.style = style;
  701. return img;
  702. }
  703.  
  704. function createAltImage(url,alt,title) {
  705. var img = document.createElement('img');
  706. img.src = url;
  707. img.alt = alt;
  708. if (title) img.title = title;
  709. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  710. return img;
  711. }
  712.  
  713. function createImageSpan(url,alt,title,text,bold) {
  714. var span = document.createElement('span');
  715. span.title = title;
  716. var img = document.createElement('img');
  717. img.src = url;
  718. img.alt = alt;
  719. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  720. span.appendChild(img);
  721. appendText(span,text,bold);
  722. return span;
  723. }
  724.  
  725. function createCase(titre,table,width) {
  726. if(!width) width=120;
  727. var tr = appendTr(table,'mh_tdpage');
  728. var td = appendTdText(tr,titre,true);
  729. td.className = 'mh_tdtitre';
  730. td.width = width;
  731. td = appendTdText(tr,'');
  732. td.className = 'mh_tdpage';
  733. return td;
  734. }
  735.  
  736. function getMyID(e) {
  737. var parent = e.parentNode;
  738. for(var i=0 ; i<parent.childNodes.length ; i++) {
  739. if(e==parent.childNodes[i])
  740. return i;
  741. }
  742. return -1;
  743. }
  744.  
  745. function insertAfter(elt,newElt) {
  746. var id = getMyID(elt);
  747. if(id==-1) return;
  748. if(id<elt.parentNode.childNodes.length-1)
  749. insertBefore(elt.nextSibling,newElt);
  750. else
  751. elt.parentNode.appendChild(newElt);
  752. }
  753.  
  754.  
  755. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  756.  
  757. function aff(nb) {
  758. return (nb>=0) ? '+'+nb : nb;
  759. }
  760.  
  761. function getNumber(str) {
  762. var nbr = str.match(/\d+/);
  763. return nbr ? Number(nbr[0]) : Number.NaN;
  764. }
  765.  
  766. function getNumbers(str) {
  767. var nbrs = str.match(/-?\d+/g);
  768. if (!nbrs) return [];
  769. for(var i=0 ; i<nbrs.length ; i++)
  770. nbrs[i] = Number(nbrs[i]);
  771. return nbrs;
  772. }
  773.  
  774. function trim(str) {
  775. return str.replace(/(^\s*)|(\s*$)/g,'');
  776. }
  777.  
  778. String.prototype.trim = function() {
  779. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  780. }
  781.  
  782. function epure(texte) {
  783. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  784. .replace(/[ç]/g,'c')
  785. .replace(/[éêèë]/g,'e')
  786. .replace(/[ïî]/g,'i')
  787. .replace(/[ôöõ]/g,'o')
  788. .replace(/[ùûü]/g,'u');
  789. }
  790.  
  791. String.prototype.epure = function () {
  792. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  793. .replace(/[ç]/g,'c')
  794. .replace(/[éêèë]/g,'e')
  795. .replace(/[ïî]/g,'i')
  796. .replace(/[ôöõ]/g,'o')
  797. .replace(/[ùûü]/g,'u');
  798. }
  799.  
  800. function bbcode(texte) {
  801. return texte.replace(/&/g,'&amp;')
  802. .replace(/"/g,'&quot;')
  803. .replace(/</g,'&lt;')
  804. .replace(/>/g,'&gt;')
  805. .replace(/'/g,'&#146;')
  806. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  807. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  808. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  809. }
  810.  
  811.  
  812. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  813.  
  814. function addZero(i) {
  815. return (i<10) ? '0'+i : i;
  816. }
  817.  
  818. function DateToString(date) {
  819. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  820. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  821. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  822. }
  823.  
  824. function StringToDate(str) {
  825. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  826. }
  827.  
  828. // fonctionne aussi avec datetime
  829. function SQLDateToFrench(str) {
  830. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  831. }
  832.  
  833. // ... et ajoute un "à" du plus bel effet
  834. function SQLDateToFrenchTime(str) {
  835. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  836. }
  837.  
  838. // SQLDate vers objet date Javascript
  839. function SQLDateToObject(str) {
  840. var t = str.split(/[- :]/);
  841. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  842. }
  843.  
  844. var mz_ie = (window.attachEvent)? true:false;
  845. if ("function" !== typeof addEvent) {
  846. if (mz_ie) {
  847. function addEvent(obj, typ, fn, sens) {
  848. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  849. obj["e"+typ+fn]( window.event );
  850. }
  851. obj.attachEvent("on"+typ, obj[typ+fn] );
  852. }
  853. }
  854. else {
  855. function addEvent(obj, typ, fn, sens) {
  856. obj.addEventListener(typ, fn, sens);
  857. }
  858. }
  859. }
  860.  
  861. /**********************
  862. * glissière en mode objet
  863. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  864. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  865. *
  866. * Usage:
  867. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  868. * ref : utilisé pour diversifier les IDs HTML
  869. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  870. * target : peut être de 3 types
  871. * - élément HTML : l'élément HTML à zoomer
  872. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  873. * - function : callback quand le curseur bouge
  874. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  875. * dans le mode dynamique, la callback est appelée sur mouseMove
  876. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  877. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  878. * autres méthodes
  879. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  880. **********************/
  881.  
  882. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  883. try {
  884. var mouseDown = false;
  885. var div_gliss = document.createElement("div"); // la DIV mère
  886. div_gliss.id = "MZ_gliss_"+ref;
  887. var div_label = document.createElement("span"); // le label
  888. div_label.innerHTML = labelHTML;
  889. div_gliss.appendChild(div_label);
  890. div_gliss.className = "choix_zoom";
  891. var dessin = document.createElement("canvas"); // le dessin lui-même
  892. dessin.id = "MZ_gliss_dessin_"+ref;
  893. dessin.style.cursor = "pointer";
  894. dessin.width = 104;
  895. dessin.height = 12;
  896. dessin.style.marginLeft = '2px';
  897. dessin.style.marginRight = '2px';
  898. div_gliss.appendChild(dessin);
  899. var pourcent = document.createElement("span"); // le pourcentage
  900. pourcent.id = "MZ_gliss_pourcent_"+ref;
  901. var pourcent_text = document.createTextNode('');
  902. var previousVal;
  903. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  904.  
  905. // alignement vertical
  906. dessin.style.verticalAlign = 'middle';
  907. div_label.style.verticalAlign = 'middle';
  908. pourcent.style.verticalAlign = 'middle';
  909.  
  910. pourcent.appendChild(pourcent_text);
  911. div_gliss.appendChild(pourcent);
  912.  
  913. var bulle_pourcent = document.createElement("div"); // la bulle
  914. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  915. bulle_pourcent.style.display = 'block';
  916. bulle_pourcent.style.visibility = 'hidden';
  917. bulle_pourcent.style.position = 'absolute';
  918. bulle_pourcent.style.zIndex = 3500;
  919. bulle_pourcent.style.border = '1px solid #a1927f';
  920. var bulle_pourcent_text = document.createTextNode('');
  921. bulle_pourcent.appendChild(bulle_pourcent_text);
  922. document.body.appendChild(bulle_pourcent);
  923.  
  924. this.getElt = function() {return div_gliss;};
  925.  
  926. ////////////////////////////////////
  927. // dessine et redessine le curseur
  928. ////////////////////////////////////
  929. var dessine_glissiere = function(val) {
  930. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  931. var ctx = dessin.getContext('2d');
  932. ctx.clearRect(0, 0,104, 12);
  933. ctx.fillStyle = "rgb(0,0,0)";
  934. ctx.fillRect(0,0,2,12);
  935. ctx.fillRect(102,0,2,12);
  936. ctx.fillRect(0,5,104,2);
  937.  
  938. ctx.fillStyle = "rgb(80,80,80)";
  939. ctx.fillRect(pos_0_100,0,5,12);
  940. ctx.fillStyle = "rgb(200,200,200)";
  941. ctx.fillRect(pos_0_100+1,1,3,10);
  942. pourcent_text.nodeValue = val+'%';
  943. previousVal = parseInt(val);
  944. };
  945.  
  946. ////////////////////////////////////
  947. // action sur mousedown et mousemove
  948. // stocker la nouvelle valeur
  949. // redessiner
  950. // afficher la nouvelle valeur
  951. // action selon ce qui a été demandé
  952. ////////////////////////////////////
  953. var doCallback_glissiere = function (evt) {
  954. try {
  955. if (evt.type === 'mousedown') mouseDown = true;
  956. if (evt.offsetX) {
  957. var xsouris = evt.offsetX;
  958. var xpos = evt.clientX;
  959. var ypos = evt.clientY + document.body.scrollTop;
  960. }
  961. else {
  962. var xsouris = evt.layerX;
  963. var xpos = evt.pageX;
  964. var ypos = evt.pageY;
  965. }
  966. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  967. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  968. // afficher la nouvelle valeur dans la bulle
  969. bulle_pourcent_text.nodeValue = val + '%';
  970. bulle_pourcent.style.top = (ypos+3)+'px';
  971. bulle_pourcent.style.left = (xpos+16)+'px';
  972. if (evt.buttons === undefined) {
  973. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  974. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  975. } else {
  976. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  977. }
  978. // stocker la nouvelle valeur
  979. MY_setValue("MZ_glissiere_" + ref, val);
  980. // redessiner la glissière avec le curseur où il faut
  981. dessine_glissiere(val);
  982. // action selon ce qui a été demandé
  983. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  984. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  985. if (typeof paramTarget === 'object') {
  986. var elt = paramTarget;
  987. } else if (typeof paramTarget === 'string') {
  988. var elt = document.getElementById(paramTarget);
  989. } else if (typeof paramTarget === 'function') {
  990. paramTarget(val);
  991. return;
  992. }
  993. if (elt.setZoom != undefined) elt.setZoom(val);
  994. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  995. };
  996.  
  997. ////////////////////////////////////
  998. // event mousedown et mousemove : redessiner et callback
  999. ////////////////////////////////////
  1000. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1001. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1002. ////////////////////////////////////
  1003. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1004. ////////////////////////////////////
  1005. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1006. ////////////////////////////////////
  1007. // event mouseout & mouseover : afficher/cacher la bulle
  1008. ////////////////////////////////////
  1009. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1010. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1011.  
  1012. ////////////////////////////////////
  1013. // dessiner la première fois
  1014. ////////////////////////////////////
  1015. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1016. if (val_init === undefined) val_init = valDef;
  1017. dessine_glissiere(val_init);
  1018. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1019. }
  1020.  
  1021. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1022. // reçoit 2 objets avec des propriétés x et y
  1023. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1024. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1025. var deltaX = locArrivee.x - locDepart.x;
  1026. if (deltaX == 0) return; // pas de point intermédiaire
  1027. var deltaY = locArrivee.y - locDepart.y;
  1028. if (deltaY == 0) return; // pas de point intermédiaire
  1029. var absDeltaX = Math.abs(deltaX);
  1030. var absDeltaY = Math.abs(deltaY);
  1031. if (absDeltaX > absDeltaY) {
  1032. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1033. } else if (absDeltaY > absDeltaX) {
  1034. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1035. } else {
  1036. return; // égalité, pas de point intermédiaire
  1037. }
  1038. }
  1039.  
  1040. /**********************
  1041. * carte en mode objet
  1042. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1043. *
  1044. * Usage:
  1045. * carte = new carte_MZ(ref, tabDepl);
  1046. * ref : utilisé pour diversifier les IDs HTML
  1047. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1048. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1049. * autres méthodes
  1050. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1051. **********************/
  1052.  
  1053. function carte_MZ(ref, tabDepl) {
  1054. try {
  1055. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1056. div1_carte.id = "MZ_carte_"+ref;
  1057. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1058. div1_carte.style.backgroundImage = 'none';
  1059. div1_carte.style.backgroundColor = 'transparent';
  1060. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1061. div2_carte.className = "carte_MZ";
  1062. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1063. var dessin = document.createElement("canvas"); // le dessin lui-même
  1064. dessin.id = "MZ_carte_dessin_"+ref;
  1065. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1066. div1_carte.appendChild(div2_carte);
  1067. div2_carte.appendChild(dessin);
  1068.  
  1069. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1070. , [-66.5, -37.5, 2, 1.5, -69]
  1071. , [-63.5, 8.5, 2, 1.5, -69]
  1072. , [-59.5, -32.5, 2, 1.5, -69]
  1073. , [-52, 57, 0.25, 0.8, -59]
  1074. , [-50.5, -22.5, 2, 1.5, -69]
  1075. , [-35.5, -51.5, 2, 1.5, -69]
  1076. , [-34.5, 14.5, 2, 1.5, -69]
  1077. , [-34.5, 64.5, 2, 1.5, -69]
  1078. , [-11.5, 72.5, 2, 1.5, -69]
  1079. , [5.5, -49.5, 2, 1.5, -69]
  1080. , [5.5, 31.5, 2, 1.5, -69]
  1081. , [10.5, 63.5, 2, 1.5, -69]
  1082. , [12, -15, 0.25, 0.8, -59]
  1083. , [21.5, 35.5, 2, 1.5, -69]
  1084. , [30, -52, 0.25, 0.8, -59]
  1085. , [46.5, 51.5, 2, 1.5, -69]
  1086. , [48, -39, 0.25, 0.8, -59]
  1087. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1088. , [56.5, 23.5, 75, 8.7, -99]
  1089. , [64, 70, 0.25, 0.8, -59]
  1090. , [74.5, 31.5, 2, 1.5, -69]];
  1091.  
  1092. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1093. var couleur_cible = 'rgba(0,0,0,0.5)';
  1094. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1095. var couleur_trou = 'rgb(200,0,0)';
  1096.  
  1097. var coord_x = function(val) {
  1098. return decalh+coeff*(val+100);
  1099. };
  1100. var coord_y = function(val) {
  1101. return decalv+coeff*(100-val);
  1102. };
  1103.  
  1104. var ctx = dessin.getContext('2d');
  1105. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1106. if (coeff) coeff /= 50;
  1107. else coeff = 2;
  1108. var decalv=30, decalh=30;
  1109.  
  1110. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1111. //var res = false
  1112. var x0 = pos0.x;
  1113. var y0 = pos0.x;
  1114. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1115. var px = Math.sign(pos1.x - pos0.x);
  1116. var py = Math.sign(pos1.y - pos0.y);
  1117. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1118. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1119.  
  1120. for(var k in position_trous_MZ) {
  1121. a = parseFloat(px*px+py*py);
  1122. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1123. 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]);
  1124. delta = b*b-a*c
  1125. if(delta >= 0) {
  1126. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1127. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1128. if(t0 <= tmax && t1 >= 0) {
  1129. // 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
  1130. //res = true;
  1131. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1132. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1133. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1134. // Roule : pas utile pour nous
  1135. //res = true;
  1136. //chute.push([x0+l*px, y0+l*py]);
  1137. return true;
  1138. }
  1139. }
  1140. }
  1141. }
  1142. //return res;
  1143. return false;
  1144. };
  1145.  
  1146. var dessine_carte = function () {
  1147. dessin.width = 200*coeff+2*decalh;
  1148. dessin.height = 200*coeff+2*decalv;
  1149.  
  1150. //repere
  1151. ctx.beginPath();
  1152. ctx.moveTo(coord_x(0), coord_y(100));
  1153. ctx.lineTo(coord_x(0), coord_y(-100));
  1154. ctx.moveTo(coord_x(-100), coord_y(0));
  1155. ctx.lineTo(coord_x(100), coord_y(0));
  1156. ctx.stroke();
  1157. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1158.  
  1159. //trous
  1160. ctx.fillStyle = couleur_trou;
  1161. for(var i in position_trous_MZ) {
  1162. ctx.beginPath();
  1163. 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);
  1164. ctx.fill();
  1165. }
  1166. // trajets
  1167. ctx.lineCap = "round";
  1168. ctx.lineJoin = "round";
  1169. for (var iSuivant in tabDepl) {
  1170. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1171. var tabDeplOneSuivant = tabDepl[iSuivant];
  1172. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1173. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1174. // La "cible" au départ
  1175. var typeDepart = tabDeplOneSuivant[0].typ;
  1176. switch (typeDepart) {
  1177. case 'tp':
  1178. ctx.beginPath();
  1179. ctx.lineWidth = 2;
  1180. ctx.strokeStyle = couleur_cible;
  1181. ctx.fillStyle = couleur_cible;
  1182. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1183. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1184. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1185. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1186. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1187. ctx.moveTo(x0 + coeff * 3, y0);
  1188. ctx.lineTo(x0 - coeff * 3, y0);
  1189. ctx.moveTo(x0, y0 + coeff * 3);
  1190. ctx.lineTo(x0, y0 - coeff * 3);
  1191. ctx.stroke();
  1192. break;
  1193. default:
  1194. ctx.beginPath();
  1195. ctx.lineWidth = 1;
  1196. ctx.strokeStyle = couleur_cible;
  1197. ctx.fillStyle = couleur_cible;
  1198. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1199. ctx.moveTo(x0 + coeff * 4, y0);
  1200. ctx.lineTo(x0 - coeff * 4, y0);
  1201. ctx.moveTo(x0, y0 + coeff * 4);
  1202. ctx.lineTo(x0, y0 - coeff * 4);
  1203. ctx.stroke();
  1204. break;
  1205. }
  1206. // les segments
  1207. var nb_pts = tabDeplOneSuivant.length;
  1208. var pointPrecedent = tabDeplOneSuivant[0];
  1209. for (var i=1; i<nb_pts; i++) {
  1210. ctx.beginPath();
  1211. ctx.lineWidth = coeff;
  1212. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1213. ctx.strokeStyle = couleur_depl_normal;
  1214. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1215. if (pointIntermediaire === undefined) {
  1216. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1217. ctx.strokeStyle = couleur_depl_collision_trou;
  1218. else
  1219. ctx.strokeStyle = couleur_depl_normal;
  1220. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1221. } else {
  1222. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1223. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1224. ctx.strokeStyle = couleur_depl_collision_trou;
  1225. else
  1226. ctx.strokeStyle = couleur_depl_normal;
  1227. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1228. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1229. }
  1230. pointPrecedent = tabDeplOneSuivant[i];
  1231. ctx.stroke();
  1232. }
  1233. // Les points à chaque étape
  1234. ctx.fillStyle = couleur_depl_normal;
  1235. for (var i=1; i<nb_pts; i++) {
  1236. ctx.beginPath();
  1237. var x = coord_x(tabDeplOneSuivant[i].x);
  1238. var y = coord_y(tabDeplOneSuivant[i].y);
  1239. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1240. ctx.fill();
  1241. }
  1242. }
  1243. }
  1244.  
  1245. this.setZoom = function (val) {
  1246. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1247. coeff = val / 50;
  1248. dessine_carte();
  1249. }
  1250.  
  1251. // glissiere
  1252. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1253. var eGliss = gliss.getElt();
  1254. eGliss.style.position = 'absolute';
  1255. eGliss.style.top = (coeff * 2) + 'px';
  1256. eGliss.style.left = decalh + 'px';
  1257. dessin.style.position = 'relative';
  1258. div2_carte.style.position = 'relative';
  1259. eGliss.style.zIndex = 9000;
  1260. div2_carte.appendChild(eGliss);
  1261.  
  1262. // affichage au survol de la souris
  1263. var bulle = document.createElement('div');
  1264. bulle.style.visibility = 'hidden';
  1265. bulle.style.position = 'absolute';
  1266. bulle.style.zIndex = 3100;
  1267. bulle.style.border = 'solid 1px #a1927f';
  1268. bulle.className = 'mh_tdpage';
  1269. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1270. var bulleHaut = document.createElement('div');
  1271. bulleHaut.style.display = 'block';
  1272. bulleHaut.style.paddingRight = '3px';
  1273. bulleHaut.className = 'mh_tdtitre';
  1274. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1275. bulle.appendChild(bulleHaut);
  1276. var bulleBas = document.createElement('div');
  1277. bulleBas.style.display = 'block';
  1278. bulleBas.style.whiteSpace = "nowrap";
  1279. bulleBas.style.paddingRight = '3px';
  1280.  
  1281. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1282. bulle.appendChild(bulleBas);
  1283. div2_carte.appendChild(bulle);
  1284. var affichePosition = function(evt) {
  1285. if (evt.offsetX) {
  1286. var xsouris = evt.offsetX;
  1287. var ysouris = evt.offsetY;
  1288. var xpos = evt.clientX;
  1289. var ypos = evt.clientY + document.body.scrollTop;
  1290. }
  1291. else {
  1292. var xsouris = evt.layerX;
  1293. var ysouris = evt.layerY;
  1294. var xpos = evt.pageX;
  1295. var ypos = evt.pageY;
  1296. }
  1297. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1298. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1299. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1300. var tabHTMLbas = [];
  1301. // message pour les trous
  1302. for (var i in position_trous_MZ) {
  1303. var ceTrou = position_trous_MZ[i];
  1304. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1305. if(dist <= 0) {
  1306. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1307. break;
  1308. }
  1309. }
  1310. // messages pour les suivants
  1311. for (var i in tabDepl) {
  1312. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1313. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1314. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1315. }
  1316. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1317. bulle.style.top = (ysouris+8) + 'px';
  1318. bulle.style.left = (xsouris+16) + 'px';
  1319. };
  1320. addEvent(dessin, "mousemove", affichePosition, true);
  1321. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1322. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1323.  
  1324. // dessin initial
  1325. dessine_carte();
  1326.  
  1327. this.getElt = function() {return div1_carte;};
  1328.  
  1329. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1330. }
  1331.  
  1332.  
  1333. /**********************************************************
  1334. **** Fin de zone à déplacer dans une bibli commune ********
  1335. **********************************************************/
  1336.  
  1337. /* DEBUG: NETTOYAGE TAGS */
  1338. if(MY_getValue(numTroll+'.TAGSURL')) {
  1339. MY_removeValue(numTroll+'.TAGSURL');
  1340. }
  1341.  
  1342. // Alerte si mode dev
  1343. if (isDEV) {
  1344. var divpopup = document.createElement('div');
  1345. divpopup.id = 'divDEV';
  1346. divpopup.style =
  1347. 'position: fixed;'+
  1348. 'border: 15px solid red;'+
  1349. 'top: 10px;right: 10px;'+
  1350. 'background-color: white;'+
  1351. 'color: black;'+
  1352. 'font-size: large;'+
  1353. 'padding: 5px'+
  1354. 'z-index: 200;';
  1355. appendText(divpopup, '[MZ] Mode DEV');
  1356. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1357. document.body.appendChild(divpopup);
  1358. }
  1359.  
  1360. /*---------- regroupement des getPortee() ------------------------------------*/
  1361. // issu des script profil et profil2
  1362. function getPortee__Profil(param) {
  1363. param = Math.max(0,Number(param));
  1364. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1365. // ça devrait être floor, +10.25, -2.5
  1366. }
  1367.  
  1368. // issu du script vue
  1369. function getPortee__Vue(param) {
  1370. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1371. }
  1372.  
  1373.  
  1374. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1375.  
  1376. function getPXKill(niv) {
  1377. return Math.max(0,10+3*niv-2*nivTroll);
  1378. }
  1379.  
  1380. function getPXDeath(niv) {
  1381. return Math.max(0,10+3*nivTroll-2*niv);
  1382. }
  1383.  
  1384. function analysePX(niv) {
  1385. niv = niv+'';
  1386. var i = niv.indexOf('+');
  1387. if(i!=-1) // si niv = 'XX+' ??
  1388. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1389. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1390. if(i!=-1) {
  1391. var max = getPXKill(niv.slice(i+2));
  1392. if(max==0)
  1393. return ' --> <b>0</b> PX';
  1394. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1395. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1396. }
  1397. i = niv.indexOf('='); // ???
  1398. if(i!=-1) {
  1399. var max = getPXKill(niv.slice(i+1));
  1400. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1401. }
  1402. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1403. }
  1404.  
  1405. function analysePXTroll(niv) {
  1406. var str = analysePX(niv);
  1407. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1408. return str;
  1409. }
  1410.  
  1411.  
  1412. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1413. // Refonte totale du code de Zorya
  1414.  
  1415. // Elements à implémenter en dur dans MZ2.0
  1416. var numQualite = {
  1417. 'Très Mauvaise':1,
  1418. 'Mauvaise':2,
  1419. 'Moyenne':3,
  1420. 'Bonne':4,
  1421. 'Très Bonne':5
  1422. };
  1423.  
  1424. var qualiteNum = [
  1425. '_dummy_',
  1426. 'Très Mauvaise',
  1427. 'Mauvaise',
  1428. 'Moyenne',
  1429. 'Bonne',
  1430. 'Très Bonne'
  1431. ];
  1432.  
  1433. var nival = {
  1434. 'Abishaii Bleu':19,
  1435. 'Abishaii Noir':10,
  1436. 'Abishaii Rouge':23,
  1437. 'Abishaii Vert':15,
  1438. 'Ame-en-peine':8,
  1439. 'Amibe Geante':9,
  1440. 'Anaconda des Catacombes':8,
  1441. 'Ankheg':10,
  1442. 'Anoploure Purpurin':36,
  1443. 'Araignee Geante':2,
  1444. 'Ashashin':35,
  1445. 'Balrog':50,
  1446. 'Banshee':16,
  1447. 'Barghest':36,
  1448. 'Basilisk':11,
  1449. 'Behemoth':34,
  1450. 'Behir':14,
  1451. 'Beholder':50,
  1452. 'Boggart':3,
  1453. 'Bondin':9,
  1454. "Bouj'Dla Placide":37,
  1455. "Bouj'Dla":19,
  1456. 'Bulette':19,
  1457. 'Caillouteux':1,
  1458. 'Capitan':35,
  1459. 'Carnosaure':25,
  1460. 'Champi-Glouton':3,
  1461. 'Chauve-Souris Geante':4,
  1462. 'Cheval a Dents de Sabre':23,
  1463. 'Chevalier du Chaos':20,
  1464. 'Chimere':13,
  1465. 'Chonchon':24,
  1466. 'Coccicruelle':22,
  1467. 'Cockatrice':5,
  1468. 'Crasc Medius':17,
  1469. 'Crasc Maexus':25,
  1470. 'Crasc':10,
  1471. 'Croquemitaine':6,
  1472. 'Cube Gelatineux':32,
  1473. 'Daemonite':27,
  1474. 'Diablotin':5,
  1475. 'Dindon du Chaos':1,
  1476. 'Djinn':29,
  1477. 'Ectoplasme':18,
  1478. 'Effrit':27,
  1479. "Elementaire d'Air":23,
  1480. "Elementaire d'Eau":17,
  1481. 'Elementaire de Feu':21,
  1482. 'Elementaire de Terre':21,
  1483. 'Elementaire du Chaos':26,
  1484. 'Erinyes':7,
  1485. 'Esprit-Follet':16,
  1486. 'Essaim Craterien':30,
  1487. 'Essaim Sanguinaire':25,
  1488. 'Ettin':8,
  1489. 'Familier':1,
  1490. 'Fantome':24,
  1491. 'Feu Follet':20,
  1492. 'Flagelleur Mental':33,
  1493. 'Foudroyeur':38,
  1494. 'Fumeux':22,
  1495. 'Fungus Geant':9,
  1496. 'Fungus Violet':4,
  1497. 'Furgolin':10,
  1498. 'Gargouille':3,
  1499. 'Geant de Pierre':13,
  1500. 'Geant des Gouffres':22,
  1501. "Geck'oo Majestueux":40,
  1502. "Geck'oo":15,
  1503. 'Glouton':20,
  1504. 'Gnoll':5,
  1505. 'Gnu Domestique':1,
  1506. 'Gnu Sauvage':1,
  1507. 'Goblin':4,
  1508. 'Goblours':4,
  1509. "Golem d'Argile":15,
  1510. 'Golem de cuir':1,
  1511. 'Golem de Chair':8,
  1512. 'Golem de Fer':31,
  1513. 'Golem de mithril':1,
  1514. 'Golem de metal':1,
  1515. 'Golem de papier':1,
  1516. 'Golem de Pierre':23,
  1517. 'Gorgone':11,
  1518. 'Goule':4,
  1519. 'Gowap Apprivoise':1,
  1520. 'Gowap Sauvage':1,
  1521. 'Gremlins':3,
  1522. 'Gritche':39,
  1523. 'Grouilleux':4,
  1524. 'Grylle':31,
  1525. 'Harpie':4,
  1526. 'Hellrot':18,
  1527. 'Homme-Lezard':4,
  1528. 'Hurleur':8,
  1529. 'Hydre':50,
  1530. 'Incube':13,
  1531. 'Kobold':2,
  1532. 'Labeilleux':26,
  1533. 'Lezard Geant':5,
  1534. 'Liche':50,
  1535. 'Limace Geante':10,
  1536. 'Loup-Garou':8,
  1537. 'Lutin':4,
  1538. 'Mante Fulcreuse':30,
  1539. 'Manticore':9,
  1540. 'Marilith':33,
  1541. 'Meduse':6,
  1542. 'Megacephale':38,
  1543. 'Mille-Pattes Geant':14,
  1544. 'Mimique':6,
  1545. 'Minotaure':7,
  1546. 'Molosse Satanique':8,
  1547. 'Momie':4,
  1548. 'Monstre Rouilleur':3,
  1549. "Mouch'oo Domestique":14,
  1550. "Mouch'oo Majestueux Sauvage":33,
  1551. "Mouch'oo Sauvage":14,
  1552. 'Na-Haniym-Heee':0,
  1553. 'Necrochore':37,
  1554. 'Necromant':39,
  1555. 'Necrophage':8,
  1556. 'Naga':10,
  1557. 'Nuee de Vermine':13,
  1558. "Nuage d'Insectes":7,
  1559. 'Ogre':7,
  1560. 'Ombre de Roches':13,
  1561. 'Ombre':2,
  1562. 'Orque':3,
  1563. 'Ours-Garou':18,
  1564. 'Palefroi Infernal':29,
  1565. 'Phoenix':32,
  1566. 'Pititabeille':0,
  1567. 'Plante Carnivore':4,
  1568. 'Pseudo-Dragon':5,
  1569. 'Rat Geant':2,
  1570. 'Rat-Garou':3,
  1571. 'Rocketeux':5,
  1572. 'Sagouin':3,
  1573. 'Scarabee Geant':4,
  1574. 'Scorpion Geant':10,
  1575. 'Shai':28,
  1576. 'Sirene':8,
  1577. 'Slaad':5,
  1578. 'Sorciere':17,
  1579. 'Spectre':14,
  1580. 'Sphinx':30,
  1581. 'Squelette':1,
  1582. 'Strige':2,
  1583. 'Succube':13,
  1584. 'Tertre Errant':20,
  1585. 'Thri-kreen':10,
  1586. 'Tigre-Garou':12,
  1587. 'Titan':26,
  1588. 'Trancheur':35,
  1589. 'Tubercule Tueur':14,
  1590. 'Tutoki':4,
  1591. 'Vampire':29,
  1592. 'Ver Carnivore Geant':12,
  1593. 'Ver Carnivore':11,
  1594. 'Veskan Du Chaos':14,
  1595. 'Vouivre':33,
  1596. 'Worg':5,
  1597. 'Xorn':14,
  1598. 'Yeti':8,
  1599. 'Yuan-ti':15,
  1600. 'Zombie':2
  1601. }
  1602.  
  1603. var tabEM = {
  1604. //Monstre: [Compo exact, Sort, Position, Localisation]
  1605. // AA
  1606. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1607. // AE
  1608. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1609. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1610. // AdA
  1611. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1612. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1613. // AdE
  1614. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1615. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1616. // AdD
  1617. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1618. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1619. // BAM
  1620. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1621. // BuM
  1622. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1623. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1624. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1625. // Explo
  1626. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1627. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1628. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1629. // FP
  1630. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1631. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1632. // FA
  1633. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1634. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1635. // Glue
  1636. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1637. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1638. // GdS
  1639. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1640. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1641. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1642. // Invi
  1643. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1644. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1645. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1646. // Lévitation
  1647. // ???
  1648. // PréM :
  1649. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1650. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1651. // Proj
  1652. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1653. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1654. // PuM :
  1655. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1656. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1657. // Sacro
  1658. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1659. // Télék
  1660. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1661. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1662. // TP
  1663. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1664. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1665. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1666. // VA
  1667. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1668. // VL
  1669. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1670. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1671. // VlC
  1672. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1673. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1674. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1675. // VT
  1676. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1677. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1678. // Variables
  1679. 'Rat':["d'un"],
  1680. 'Rat Géant':["d'un"],
  1681. 'Dindon':["d'un"],
  1682. 'Goblin':["d'un"],
  1683. 'Limace':["d'une"],
  1684. 'Limace Géante':["d'une"],
  1685. 'Ver':["d'un"],
  1686. 'Ver Carnivore':["d'un"],
  1687. 'Ver Carnivore Géant':["d'un"],
  1688. 'Fungus':["d'un"],
  1689. 'Vouivre':["d'une"],
  1690. 'Gnu':["d'un"],
  1691. 'Scarabée':["d'un"]
  1692. };
  1693.  
  1694. var mundiChampi = {
  1695. 'Préscientus Reguis':'du Phoenix',
  1696. 'Amanite Trolloïde':'de la Mouche',
  1697. 'Girolle Sanglante':'du Dindon',
  1698. 'Horreur Des Prés':'du Gobelin',
  1699. 'Bolet Péteur':'du Démon',
  1700. 'Pied Jaune':'de la Limace',
  1701. 'Agaric Sous-Terrain':'du Rat',
  1702. 'Suinte Cadavre':"de l'Hydre",
  1703. 'Cèpe Lumineux':'du Ver',
  1704. 'Fungus Rampant':'du Fungus',
  1705. 'Nez Noir':'de la Vouivre',
  1706. 'Pleurote Pleureuse':'du Gnu',
  1707. 'Phytomassus Xilénique':'du Scarabée'
  1708. };
  1709.  
  1710. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1711. appendText(node,' ');
  1712. var urlImg = URL_MZimg
  1713. +'Competences/melangeMagique.png';
  1714. var text = ' [-'+(niv+effetQ)+' %]';
  1715. var str = '';
  1716. switch(mob[0]) {
  1717. case 'A':
  1718. case 'E':
  1719. case 'I':
  1720. case 'O':
  1721. case 'U':
  1722. str = "Compo d'";
  1723. break;
  1724. default:
  1725. str = 'Compo de ';
  1726. }
  1727. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1728. var span = createImageSpan(urlImg,'MM:',title,text);
  1729. node.appendChild(span);
  1730. }
  1731. function addInfoEM(node,mob,compo,qualite,localisation) {
  1732. if(!tabEM[mob]) return;
  1733. var title = 'Composant variable', texte = 'Variable';
  1734. var bold = false;
  1735. if(tabEM[mob].length>1) {
  1736. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1737. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1738. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1739. if(pc<-20) return;
  1740. if(pc>=0) bold = true;
  1741. texte = aff(pc)+'%';
  1742. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1743. }
  1744. var urlImg = URL_MZimg
  1745. +'Competences/ecritureMagique.png';
  1746. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1747. node.appendChild(span);
  1748. }
  1749.  
  1750. function insererInfosEM(tbody) {
  1751. // lancé par equip, equipgowap
  1752. var trCompos = document.evaluate(
  1753. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1754. tbody,null,7,null);
  1755. var strCompos = '';
  1756. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1757. var node = trCompos.snapshotItem(i).childNodes[7];
  1758. var str = node.firstChild.textContent;
  1759. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1760. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1761. // Si non-EM on stoppe le traitement
  1762. if(!tabEM[mob]) continue;
  1763. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1764. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1765. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1766. addInfoEM(node,mob,compo,qualite,localisation);
  1767. }
  1768. }
  1769.  
  1770. function getQualite(qualite) {
  1771. var nb = numQualite[qualite];
  1772. return nb ? nb-1 : -1;
  1773. }
  1774.  
  1775. function getEM(nom) {
  1776. if(nom.indexOf('[')!=-1)
  1777. nom = trim(nom.substring(0,nom.indexOf('[')));
  1778. if(tabEM[nom]) return nom;
  1779. return '';
  1780. }
  1781.  
  1782. // DEBUG ex-fonction composantEM
  1783. function compoMobEM(mob) {
  1784. if(!tabEM[mob]) return '';
  1785. if(tabEM[mob].length==1)
  1786. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1787. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1788. +") pour l'écriture de "+tabEM[mob][1];
  1789. }
  1790.  
  1791. // DEBUG ex-fonction compoEM
  1792. function titreCompoEM(mob,compo,localisation,qualite) {
  1793. if(!tabEM[mob]) return '';
  1794. if(tabEM[mob].length==1) return 'Composant variable';
  1795. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1796. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1797. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1798. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1799. return '';
  1800. }
  1801.  
  1802. // DEBUG - rétrocompatibilité
  1803. function compoEM(mob) {
  1804. // appelé dans libs, vue
  1805. return compoMobEM(mob);
  1806. }
  1807. function composantEM(mob,compo,localisation,qualite) {
  1808. // appelé dans libs, tancompo
  1809. return titreCompoEM(mob,compo,localisation,qualite);
  1810. }
  1811. //
  1812.  
  1813.  
  1814. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1815.  
  1816. arrayTalents = {
  1817. /* Compétences */
  1818. 'Acceleration du Metabolisme':'AM',
  1819. 'Attaque Precise':'AP',
  1820. 'Balayage':'Balayage',
  1821. //'Balluchonnage':'Ballu',
  1822. 'Baroufle':'Baroufle',
  1823. 'Bidouille':'Bidouille',
  1824. 'Botte Secrete':'BS',
  1825. 'Camouflage':'Camou',
  1826. 'Charger':'Charger',
  1827. 'Connaissance des Monstres':'CdM',
  1828. 'Construire un Piege':'Piege',
  1829. 'Piege a Feu':'PiegeFeu',
  1830. 'Piege a Glue':'PiegeGlue',
  1831. 'Contre-Attaquer':'CA',
  1832. 'Coup de Butoir':'CdB',
  1833. 'Course':'Course',
  1834. 'Deplacement Eclair':'DE',
  1835. 'Dressage':'Dressage',
  1836. 'Ecriture Magique':'EM',
  1837. 'Frenesie':'Frenesie',
  1838. 'Golemologie':'Golemo',
  1839. 'Golem de cuir':'GolemCuir',
  1840. 'Golem de metal':'GolemMetal',
  1841. 'Golem de mithril':'GolemMithril',
  1842. 'Golem de papier':'GolemPapier',
  1843. 'Grattage':'Grattage',
  1844. 'Hurlement Effrayant':'HE',
  1845. 'Identification des Champignons':'IdC',
  1846. 'Insultes':'Insultes',
  1847. 'Lancer de Potions':'LdP',
  1848. 'Marquage':'Marquage',
  1849. 'Melange Magique':'Melange',
  1850. 'Miner':'Miner',
  1851. 'Necromancie':'Necro',
  1852. 'Painthure de Guerre':'PG',
  1853. 'Parer':'Parer',
  1854. 'Pistage':'Pistage',
  1855. 'Planter un Champignon':'PuC',
  1856. 'Regeneration Accrue':'RA',
  1857. 'Reparation':'Reparation',
  1858. 'Retraite':'Retraite',
  1859. 'Rotobaffe':'RB',
  1860. 'Shamaner':'Shamaner',
  1861. "S'interposer":'SInterposer',
  1862. 'Tailler':'Tailler',
  1863. //'Vol':'Vol',
  1864. /* Sortilèges */
  1865. 'Analyse Anatomique':'AA',
  1866. 'Armure Etheree':'AE',
  1867. 'Augmentation de l´Attaque':'AdA',
  1868. 'Augmentation de l´Esquive':'AdE',
  1869. 'Augmentation des Degats':'AdD',
  1870. 'Bulle Anti-Magie':'BAM',
  1871. 'Bulle Magique':'BuM',
  1872. 'Explosion':'Explo',
  1873. 'Faiblesse Passagere':'FP',
  1874. 'Flash Aveuglant':'FA',
  1875. 'Glue':'Glue',
  1876. 'Griffe du Sorcier':'GdS',
  1877. 'Hypnotisme':'Hypno',
  1878. 'Identification des tresors':'IdT',
  1879. 'Invisibilite':'Invi',
  1880. 'Levitation':'Levitation',
  1881. 'Precision Magique':'PreM',
  1882. 'Projectile Magique':'Projo',
  1883. 'Projection':'Proj',
  1884. 'Puissance Magique':'PuM',
  1885. 'Rafale Psychique':'Rafale',
  1886. 'Sacrifice':'Sacro',
  1887. 'Siphon des ames':'Siphon',
  1888. 'Telekinesie':'Telek',
  1889. 'Teleportation':'TP',
  1890. 'Vampirisme':'Vampi',
  1891. 'Vision Accrue':'VA',
  1892. 'Vision lointaine':'VL',
  1893. 'Voir le Cache':'VlC',
  1894. 'Vue Troublee':'VT'
  1895. //'':''
  1896. }
  1897.  
  1898. // DEBUG - Pour rétrocompatibilité
  1899. function getSortComp(nom,niveau) {
  1900. return getTalent(nom,niveau);
  1901. }
  1902. //
  1903.  
  1904. function getTalent(nom,niveau) {
  1905. var nomEnBase = arrayTalents[epure(nom)];
  1906. if(!nomEnBase) return 0;
  1907. if(!niveau) var niveau = '';
  1908. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1909. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1910. return 0;
  1911. }
  1912.  
  1913. function removeAllTalents() {
  1914. for(var talent in arrayTalents) {
  1915. var nomEnBase = arrayTalents[talent];
  1916. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1917. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1918. continue;
  1919. }
  1920. var niveau = 1;
  1921. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1922. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1923. niveau++;
  1924. }
  1925. }
  1926. }
  1927.  
  1928. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1929. var att = MY_getValue(numTroll+'.caracs.attaque');
  1930. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1931. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1932. var mm = MY_getValue(numTroll+'.caracs.mm');
  1933. var deg = MY_getValue(numTroll+'.caracs.degats');
  1934. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1935. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1936. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1937. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1938. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1939. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1940. return false;
  1941. return true;
  1942. }
  1943.  
  1944.  
  1945. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1946.  
  1947. function getPVsRestants(pv,bless,vue) {
  1948. bless = Number(bless.match(/\d+/)[0]);
  1949. if(bless==0) return null;
  1950. var pvminmax = pv.match(/\d+/g);
  1951. if(bless==95) {
  1952. var pvb = 1;
  1953. var pvh = Math.floor( pvminmax[1]/20 );
  1954. }
  1955. else if(bless==5) {
  1956. var pvb = Math.floor( pvminmax[0]*19/20 );
  1957. var pvh = pvminmax[1];
  1958. }
  1959. else {
  1960. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1961. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1962. }
  1963. return vue ? ' ('+pvb+'-'+pvh+')' :
  1964. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1965. }
  1966.  
  1967. function insertButtonCdm(nextName,onClick,texte) {
  1968. if(texte==null) texte = 'Participer au bestiaire';
  1969. var nextNode = document.getElementsByName(nextName)[0];
  1970.  
  1971. var espace = document.createTextNode('\t');
  1972. insertBefore(nextNode,espace);
  1973.  
  1974. var button = document.createElement('input');
  1975. button.type = 'button';
  1976. button.className = 'mh_form_submit';
  1977. button.value = texte;
  1978. button.onmouseover = function(){this.style.cursor='pointer';};
  1979. if(onClick) button.onclick = onClick;
  1980. insertBefore(espace,button);
  1981. return button;
  1982. }
  1983.  
  1984. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1985. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1986. 'Capacité spéciale','Résistance Magique','Autres'];
  1987.  
  1988. /* appelé par
  1989. createCDMTable (dans le popup DcM)
  1990. computeTactique (à coté du nom des monstres dans la vue et dans la page de détail des monstres)
  1991. */
  1992. function createImageTactique(url,id,nom) {
  1993. var img = document.createElement('img');
  1994. img.src = url;
  1995. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1996. img.id = id;
  1997. img.nom = nom;
  1998. img.onmouseover = showPopupTactique;
  1999. img.onmouseout = hidePopup;
  2000. return img;
  2001. }
  2002.  
  2003. function createCDMTable(id,nom,donneesMonstre) {
  2004. try {
  2005. var urlImg = URL_MZimg;
  2006. var table = document.createElement('table');
  2007. var profilActif = isProfilActif();
  2008. table.className = 'mh_tdborder';
  2009. table.border = 0;
  2010. table.cellSpacing = 1;
  2011. table.cellPadding = 4;
  2012. var thead = document.createElement('thead');
  2013. var tr = appendTr(thead,'mh_tdtitre');
  2014. var td = appendTdText(tr,
  2015. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  2016. true
  2017. );
  2018. td.colSpan = 2;
  2019. table.appendChild(thead);
  2020. var tbody = document.createElement('tbody');
  2021. table.appendChild(tbody);
  2022. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  2023. createCase(listeTitres[i],tbody,80);
  2024. }
  2025. var TypeMonstre = getEM(nom);
  2026. var infosCompo='';
  2027. if(TypeMonstre!='') {
  2028. infosCompo = compoEM(TypeMonstre);
  2029. }
  2030. var nodes = tbody.childNodes;
  2031. nodes[0].childNodes[1].innerHTML =
  2032. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  2033. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  2034. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  2035. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  2036. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  2037. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  2038. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  2039. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  2040. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  2041. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  2042. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  2043. td = createCase(listeTitres[10],tbody);
  2044. td.innerHTML = bbcode(donneesMonstre[10]);
  2045. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2046. td.appendChild(document.createTextNode(" "));
  2047. if(donneesMonstre[16] == "De zone")
  2048. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2049. else if(donneesMonstre[16] == "Automatique")
  2050. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2051. else if(donneesMonstre[16] == "Au toucher")
  2052. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2053. }
  2054. }
  2055. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2056. {
  2057. td = createCase(listeTitres[11],tbody);
  2058. td.innerHTML = bbcode(donneesMonstre[9]);
  2059. // seuil de résistance du monstre
  2060. var lb = td.getElementsByTagName('b');
  2061. if(lb.length == 1) {
  2062. var mrm = lb[0].firstChild.nodeValue * 1;
  2063. var v = (mrm / mmTroll);
  2064. lb[0].firstChild.nodeValue += " ("
  2065. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2066. }
  2067. }
  2068. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2069. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2070. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2071. {
  2072. td = createCase(listeTitres[12],tbody);
  2073. if(donneesMonstre[12]==1)
  2074. {
  2075. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2076. }
  2077. if(donneesMonstre[13]==1)
  2078. {
  2079. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2080. }
  2081. else if(donneesMonstre[13]==0)
  2082. {
  2083. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2084. }
  2085. if(donneesMonstre[14]==1)
  2086. {
  2087. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2088. }
  2089. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2090. {
  2091. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2092. }
  2093. else if(donneesMonstre[14]>6)
  2094. {
  2095. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2096. }
  2097. if(donneesMonstre[15]=="Lente")
  2098. {
  2099. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2100. }
  2101. else if(donneesMonstre[15]=="Normale")
  2102. {
  2103. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2104. }
  2105. else if(donneesMonstre[15]=="Rapide")
  2106. {
  2107. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2108. }
  2109. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2110. {
  2111. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2112. }
  2113. if(infosCompo.length>0)
  2114. {
  2115. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2116. }
  2117. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2118. {
  2119. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2120. }
  2121. }
  2122. // pourcentage de blessure
  2123. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2124. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2125. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2126. if(pvs)
  2127. lb[0].firstChild.nodeValue += pvs;
  2128. }
  2129. return table;
  2130. }
  2131. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2132. }
  2133.  
  2134.  
  2135. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2136.  
  2137. var listeMonstreEnchantement = null,
  2138. listeEquipementEnchantement = null,
  2139. listeInfoEnchantement = null;
  2140.  
  2141. function computeCompoEnchantement()
  2142. {
  2143. listeMonstreEnchantement = new Array();
  2144. listeInfoEnchantement = new Array();
  2145. listeEquipementEnchantement = new Array();
  2146. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2147. for(var i=0;i<liste.length;i++)
  2148. {
  2149. var idEquipement = liste[i]*1;
  2150. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2151. continue;
  2152. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2153. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2154. var texteGlobal='';
  2155. for(var j=0;j<3;j++)
  2156. {
  2157. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  2158. listeMonstreEnchantement[infoComposant[2]] = 1;
  2159. var array = new Array();
  2160. array[0]=infoComposant[0].replace("Ril","Œil");
  2161. array[1]=infoComposant[1];
  2162. array[2]=infoComposant[2];
  2163. array[3]=getQualite(infoComposant[3]);
  2164. var texte = infoComposant[4].replace("Ril","Œil");
  2165. for(var k=5;k<infoComposant.length;k++)
  2166. {
  2167. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2168. }
  2169. texteGlobal+=texte+'\n';
  2170. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2171. array[4]=texte;
  2172. listeInfoEnchantement.push(array);
  2173. }
  2174. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2175. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2176. }
  2177. }
  2178.  
  2179. function isEnchant(nom) {
  2180. var monstreEnchant = '';
  2181. for(j in listeInfoEnchantement) {
  2182. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2183. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2184. monstreEnchant=monstre;
  2185. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2186. }
  2187. }
  2188. return trim(monstreEnchant);
  2189. }
  2190.  
  2191. function getInfoEnchantementFromMonstre(nom)
  2192. {
  2193. try
  2194. {
  2195. if(!listeMonstreEnchantement)
  2196. {
  2197. computeCompoEnchantement();
  2198. }
  2199. var infosEnchant = '';
  2200. for(j in listeInfoEnchantement) {
  2201. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2202. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2203. if(infosEnchant=='')
  2204. infosEnchant=listeInfoEnchantement[j][4];
  2205. else
  2206. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2207. }
  2208. }
  2209. return trim(infosEnchant);
  2210. }
  2211. catch(e)
  2212. {
  2213. window.alert(e);
  2214. }
  2215. }
  2216.  
  2217. function composantEnchant(Monstre,composant,localisation,qualite) {
  2218. var compo='';
  2219. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2220. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2221. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2222. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2223. listeInfoEnchantement[i][3]<=qualite
  2224. ) {
  2225. return listeInfoEnchantement[i][4];
  2226. }
  2227. }
  2228. return compo;
  2229. }
  2230.  
  2231. function insertEnchantInfos(tbody) {
  2232. try
  2233. {
  2234. if(!listeMonstreEnchantement)
  2235. computeCompoEnchantement();
  2236. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2237. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2238. if(nodes.snapshotLength == 0)
  2239. return false;
  2240. var urlImg = URL_MZimg + 'enchant.png';
  2241. for(var i = 0; i < nodes.snapshotLength; i++) {
  2242. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2243. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2244. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2245. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2246. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2247. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2248. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2249. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2250. if(isEnchant(nomMonstre).length>0)
  2251. {
  2252. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2253. if(infos.length>0)
  2254. {
  2255. if(link.parentNode == link.nextSibling.parentNode)
  2256. {
  2257. var tmp = link.nextSibling;
  2258. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2259. }
  2260. else
  2261. {
  2262. link.parentNode.appendChild(createImage(urlImg,infos));
  2263. }
  2264. }
  2265. }
  2266. }
  2267. }
  2268. catch(e)
  2269. {
  2270. window.alert(e);
  2271. }
  2272. }
  2273.  
  2274. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2275. {
  2276. try
  2277. {
  2278. if(!listeMonstreEnchantement)
  2279. computeCompoEnchantement();
  2280. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2281. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2282. if(nodes.snapshotLength == 0)
  2283. return false;
  2284. var urlImg = URL_MZimg + 'enchant.png';
  2285. for(var i = 0; i < nodes.snapshotLength; i++)
  2286. {
  2287. var link = nodes.snapshotItem(i);
  2288. var idEquipement = link.getAttribute('href');
  2289. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2290. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2291. var nomEquipement = trim(link.firstChild.nodeValue);
  2292. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2293. if(!enchanteur || enchanteur == '')
  2294. continue;
  2295. var infos = listeEquipementEnchantement[idEquipement];
  2296. infos=formateTexte(infos);
  2297. if(infos.length>0)
  2298. {
  2299. if(link.parentNode == link.nextSibling.parentNode)
  2300. {
  2301. var tmp = link.nextSibling;
  2302. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2303. }
  2304. else
  2305. {
  2306. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2307. }
  2308. }
  2309. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2310. }
  2311. }
  2312. catch(e)
  2313. {
  2314. window.alert(e);
  2315. }
  2316. }
  2317.  
  2318. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2319.  
  2320.  
  2321. // Les % de toucher
  2322. var c = new Array();
  2323.  
  2324. // coefficients binomiaux
  2325. function cnp(n,k)
  2326. {
  2327. if(c[n] != null && c[n][k] != null)
  2328. return c[n][k];
  2329. if(c[n] == null)
  2330. c[n] = new Array();
  2331. if(k==0)
  2332. {
  2333. c[n][k] = 1;
  2334. return 1;
  2335. }
  2336. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2337. c[n][k] = result;
  2338. // Roule debug
  2339. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2340. return result;
  2341. }
  2342.  
  2343. // by Dab, à comparer
  2344. function binom(n,p) {
  2345. if(p<0 || p>n) return 0;
  2346. if(c[n])
  2347. if(c[n][p]) return c[n][p];
  2348. else {
  2349. c[n]=[1];
  2350. c[n][n]=1;
  2351. if(p==0 || p==n) return 1;
  2352. }
  2353. if(2*p>n)
  2354. c[n][p]=binom(n,n-p);
  2355. else
  2356. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2357. return c[n][p];
  2358. }
  2359.  
  2360. var coeff = new Array();
  2361.  
  2362. function coef(n,p)
  2363. {
  2364. if(n==0 && p==0)
  2365. return 1;
  2366. if(p>n*3.5)
  2367. p = 7*n-p
  2368. // roule désactive cache
  2369. if(coeff[n] != null && coeff[n][p] !=null)
  2370. return coeff[n][p];
  2371. if(coeff[n] == null)
  2372. coeff[n] = new Array();
  2373. var kmax = Math.floor((p-n)/6);
  2374. var x=0;
  2375. for(var k=0;k<=kmax;k++)
  2376. {
  2377. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2378. }
  2379. coeff[n][p] = x;
  2380. // Roule debug
  2381. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2382. return x;
  2383. }
  2384.  
  2385. function chanceEsquiveParfaite(a,d,ba,bd)
  2386. {
  2387. var win = 0;
  2388. var los = 0;
  2389. if(ba==null)
  2390. ba=0;
  2391. if(bd==null)
  2392. bd=0;
  2393. /* if(6*a+ba<2*(d+bd))
  2394. return 100;
  2395. if(a+ba>2*(6*d+bd))
  2396. return 0;*/
  2397. for(var ds=d;ds<=6*d;ds++)
  2398. {
  2399. var cd = coef(d,ds);
  2400. for(var as=a;as<=6*a;as++)
  2401. {
  2402. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2403. win += cd * coef(a,as);
  2404. else
  2405. los += cd * coef(a,as);
  2406. }
  2407. }
  2408. // roule debug
  2409. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2410. return Math.round(100*win/(win+los));
  2411. }
  2412.  
  2413. function chanceTouche(a,d,ba,bd)
  2414. {
  2415. var win = 0;
  2416. var los = 0;
  2417. if(ba==null)
  2418. ba=0;
  2419. if(bd==null)
  2420. bd=0;
  2421. if(a+ba>6*d+bd)
  2422. return 100;
  2423. if(6*a+ba<d+bd)
  2424. return 0;
  2425. for(var ds=d;ds<=6*d;ds++)
  2426. {
  2427. var cd = coef(d,ds);
  2428. for(var as=a;as<=6*a;as++)
  2429. {
  2430. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2431. win += cd * coef(a,as);
  2432. else
  2433. los += cd * coef(a,as);
  2434. }
  2435. }
  2436. return Math.round(100*win/(win+los));
  2437. }
  2438.  
  2439. function chanceCritique(a,d,ba,bd)
  2440. {
  2441. var win = 0;
  2442. var los = 0;
  2443. if(ba==null)
  2444. ba=0;
  2445. if(bd==null)
  2446. bd=0;
  2447. if(a+ba>2*(6*d+bd))
  2448. return 100;
  2449. if(6*a+ba<2*(d+bd))
  2450. return 0;
  2451. for(var ds=d;ds<=6*d;ds++)
  2452. {
  2453. var cd = coef(d,ds);
  2454. for(var as=a;as<=6*a;as++)
  2455. {
  2456. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2457. win += cd * coef(a,as);
  2458. else
  2459. los += cd * coef(a,as);
  2460. }
  2461. }
  2462. return Math.round(100*win/(win+los));
  2463. }
  2464.  
  2465. /***********************************************
  2466. Analyse tactique
  2467. ***********************************************/
  2468.  
  2469. function getTexteAnalyse(modificateur,chiffre)
  2470. {
  2471. if(chiffre==0)
  2472. return chiffre;
  2473. return modificateur+chiffre;
  2474. }
  2475.  
  2476. // rend le HTML pour le tableau de la "calculette"
  2477. function getAnalyseTactique(id,nom)
  2478. {
  2479. var donneesMonstre = listeCDM[id];
  2480. var needAutres=false;
  2481. var i;
  2482. if(donneesMonstre == null)
  2483. return;
  2484. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2485. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2486. if(array==null)
  2487. return "";
  2488. 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>";
  2489. for(i=0;i<array.length;i++)
  2490. {
  2491. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2492. {
  2493. needAutres=true;
  2494. break;
  2495. }
  2496. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2497. 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>";
  2498. else if(i==0) // attaque du monstre sur le Trõll => italique
  2499. 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>";
  2500. else // autre, pas de décoration
  2501. 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>";
  2502. }
  2503. if(needAutres)
  2504. {
  2505. if(i==array.length-1)
  2506. 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>";
  2507. else if(i==1)
  2508. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2509. else
  2510. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2511. }
  2512. return str+"</table>";
  2513. }
  2514.  
  2515. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2516. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2517. function analyseTactique(donneesMonstre,nom) {
  2518. try
  2519. {
  2520. var listeAttaques = [];
  2521. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2522. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2523. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2524. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2525. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2526. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2527. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2528. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2529. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2530. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2531. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2532. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2533. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2534. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2535. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2536. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2537. var modificateurEsquive = '';
  2538. var modificateurArmure = '';
  2539. var modificateurMagie = '';
  2540. var modificateurEsquiveM = '';
  2541. var modificateurArmureM = '';
  2542. var pasDeSR=false;
  2543. var esqM,attM,armM,degM;
  2544. 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)
  2545. return null;
  2546. var td = document.createElement('td')
  2547. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2548. var esqM = 0;
  2549. try
  2550. {
  2551. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2552. }
  2553. catch(e)
  2554. {
  2555. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  2556. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2557. modificateurEsquive = '<';
  2558. modificateurArmure = '<';
  2559. modificateurMagie = '<';
  2560. }
  2561. td.innerHTML = bbcode(donneesMonstre[3]);
  2562. var attM = 0;
  2563. try
  2564. {
  2565. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2566. }
  2567. catch(e)
  2568. {
  2569. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  2570. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2571. modificateurEsquiveM = '>';
  2572. modificateurArmureM = '>';
  2573. }
  2574. td.innerHTML = bbcode(donneesMonstre[5]);
  2575. var degM = 0;
  2576. try
  2577. {
  2578. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2579. }
  2580. catch(e)
  2581. {
  2582. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  2583. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2584. modificateurArmureM = '>';
  2585. }
  2586. td.innerHTML = bbcode(donneesMonstre[7]);
  2587. var armM = 0;
  2588. try
  2589. {
  2590. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2591. }
  2592. catch(e)
  2593. {
  2594. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  2595. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2596. modificateurArmure = '<';
  2597. }
  2598. var coeffSeuil = 0.95;
  2599. try
  2600. {
  2601. td.innerHTML = bbcode(donneesMonstre[9]);
  2602. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  2603. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2604. var v = (rm / mm);
  2605. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2606. coeffSeuil = (200-seuil)/200;
  2607. }
  2608. catch(e)
  2609. {
  2610. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  2611. modificateurMagie = '<';
  2612. pasDeSR = true;
  2613. }
  2614. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2615. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2616. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2617. // roule debug
  2618. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2619. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2620. 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);
  2621. //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);
  2622. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2623. if(getSortComp("Vampirisme")>0)
  2624. {
  2625. var pour = getSortComp("Vampirisme");
  2626. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2627. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2628. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2629. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2630. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2631. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2632. }
  2633. if(getSortComp("Siphon des âmes")>0)
  2634. {
  2635. var pour = getSortComp("Siphon des âmes");
  2636. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2637. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2638. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2639. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2640. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2641. }
  2642. if(getSortComp("Botte Secrète")>0)
  2643. {
  2644. var pour = getSortComp("Botte Secrète");
  2645. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2646. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2647. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2648. 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;
  2649. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2650. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2651. }
  2652. if(getSortComp("Rafale Psychique")>0)
  2653. {
  2654. var pour = getSortComp("Rafale Psychique");
  2655. chanceDEsquiveParfaite = 0;
  2656. chanceDeTouche = Math.round(100*pour/100);
  2657. chanceDeCritique = Math.round(0*pour/100);
  2658. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2659. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2660. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2661. }
  2662. if(getSortComp("Explosion")>0)
  2663. {
  2664. var pour = getSortComp("Explosion");
  2665. chanceDEsquiveParfaite = 0;
  2666. chanceDeTouche = Math.round(100*pour/100);
  2667. chanceDeCritique = Math.round(0*pour/100);
  2668. 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;
  2669. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2670. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2671. }
  2672. if(getSortComp("Projectile Magique")>0)
  2673. {
  2674. var pour = getSortComp("Projectile Magique");
  2675. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2676. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2677. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2678. // distance troll - monstre
  2679. 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;
  2680. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2681. if (donneesMonstre['iTR'] !== undefined) {
  2682. var dist = getMonstreDistance(donneesMonstre['iTR']+1);
  2683. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  2684. var portee = getPortee__Profil(vue+vue_bm);
  2685. if (dist <= portee) {
  2686. degats += 2 * (portee-dist);
  2687. } else {
  2688. degats += ' (plus bonus de portée)';
  2689. }
  2690. debugMZ('analyseTactique, iTR= ' + donneesMonstre['iTR'] + ', dist=' + dist + ', porteePM=' + portee);
  2691. } else {
  2692. degats += ' (plus bonus de portée)';
  2693. }
  2694. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2695. }
  2696. if(getSortComp("Frénésie")>0)
  2697. {
  2698. var pour = getSortComp("Frénésie");
  2699. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2700. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2701. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2702. 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;
  2703. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2704. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2705. }
  2706. if(getSortComp("Charger")>0)
  2707. {
  2708. var pour = getSortComp("Charger");
  2709. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2710. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2711. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2712. 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;
  2713. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2714. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2715. }
  2716. if(getSortComp("Griffe du Sorcier")>0)
  2717. {
  2718. var pour = getSortComp("Griffe du Sorcier");
  2719. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2720. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2721. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2722. 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;
  2723. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2724. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2725. }
  2726. if(getSortComp("Attaque Précise",1)>0)
  2727. {
  2728. var niveau = 5;
  2729. var oldPour = 0;
  2730. var chanceDEsquiveParfaite = 0;
  2731. var chanceDeTouche = 0;
  2732. var chanceDeCritique = 0;
  2733. degats = 0;
  2734. while(niveau>0)
  2735. {
  2736. var pour = getSortComp("Attaque Précise",niveau);
  2737. if(pour>oldPour)
  2738. {
  2739. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2740. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2741. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2742. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2743. chanceDeTouche += chanceDeToucheNiveau;
  2744. chanceDeCritique += chanceDeCritiqueNiveau;
  2745. 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);
  2746. oldPour = pour;
  2747. }
  2748. niveau--;
  2749. }
  2750. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2751. 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));
  2752. }
  2753. if(getSortComp("Coup de Butoir",1)>0)
  2754. {
  2755. var niveau = 5;
  2756. var oldPour =0;
  2757. var chanceDEsquiveParfaite = 0;
  2758. var chanceDeTouche=0;
  2759. var chanceDeCritique=0;
  2760. degats=0;
  2761. while(niveau>0)
  2762. {
  2763. var pour = getSortComp("Coup de Butoir",niveau);
  2764. if(pour>oldPour)
  2765. {
  2766. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2767. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2768. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2769. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2770. chanceDeTouche += chanceDeToucheNiveau;
  2771. chanceDeCritique += chanceDeCritiqueNiveau;
  2772. 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);
  2773. oldPour = pour;
  2774. }
  2775. niveau--;
  2776. }
  2777. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2778. 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));
  2779. }
  2780. 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;});
  2781. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2782. {
  2783. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2784. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2785. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2786. }
  2787. else
  2788. {
  2789. chanceDEsquiveParfaite = 0;
  2790. chanceDeTouche = 100;
  2791. chanceDeCritique = 0;
  2792. }
  2793. 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;
  2794.  
  2795. 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));
  2796. return listeAttaques;
  2797. }
  2798. catch(e) { window.alert(e);}
  2799. }
  2800.  
  2801. // x~~x marque pour s'y retrouver sous l'éditeur
  2802.  
  2803. /*
  2804. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2805. * published under GNU License v2.
  2806. *
  2807. * Patch :
  2808. * gestion des missions terminées
  2809. */
  2810. // x~x mission_liste
  2811.  
  2812. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2813. try {
  2814. var titresMimis = document.evaluate(
  2815. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2816. document, null, 7, null
  2817. );
  2818. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2819. } catch(e) {
  2820. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2821. return;
  2822. }
  2823. var enCours = {};
  2824. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2825. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2826. enCours[num] = true;
  2827. }
  2828. for(var numMimi in obMissions) {
  2829. if(!enCours[numMimi]) {
  2830. delete obMissions[numMimi];
  2831. }
  2832. }
  2833. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2834. }
  2835.  
  2836. function do_mission_liste() {
  2837. checkLesMimis();
  2838. }
  2839.  
  2840. /*******************************************************************************
  2841. * This file is part of Mountyzilla. *
  2842. * *
  2843. * Mountyzilla is free software; you can redistribute it and/or modify *
  2844. * it under the terms of the GNU General Public License as published by *
  2845. * the Free Software Foundation; either version 2 of the License, or *
  2846. * (at your option) any later version. *
  2847. * *
  2848. * Mountyzilla is distributed in the hope that it will be useful, *
  2849. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2850. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2851. * GNU General Public License for more details. *
  2852. * *
  2853. * You should have received a copy of the GNU General Public License *
  2854. * along with Mountyzilla; if not, write to the Free Software *
  2855. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2856. *******************************************************************************/
  2857.  
  2858. // x~x actions
  2859.  
  2860. /* TODO
  2861. * getLvl pour Explo, Rotobaffe et cie
  2862. */
  2863.  
  2864.  
  2865.  
  2866. /* Page de combat */
  2867.  
  2868. function getLevel() {
  2869. var divList = document.getElementsByTagName('div');
  2870. if(divList.length <= 2)
  2871. return;
  2872. // On essaie de voir si cette action était une attaque
  2873. var pList = document.getElementsByTagName('p');
  2874. var nomM = '';
  2875. // Modification pour Frénésie by TetDure
  2876. var numAtt = 0;
  2877. for (var i = 0; i < pList.length; i++) {
  2878. if(pList[i].firstChild) {
  2879. nomM = pList[i].firstChild.nodeValue;
  2880. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2881. numAtt++;
  2882. }
  2883. }
  2884. if(nomM == '')
  2885. return;
  2886. // Si c'est une attaque normale, un seul PX
  2887. var comPX = 1;
  2888. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2889. comPX++;
  2890.  
  2891. // Extraction des infos du monstre attaqué
  2892. var idM;
  2893. var male;
  2894. if(nomM.slice(20, 21) == 'e') {
  2895. male = false;
  2896. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2897. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2898. }
  2899. else {
  2900. male = true;
  2901. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2902. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2903. }
  2904. if(idM == '')
  2905. return;
  2906. var bList = document.getElementsByTagName('b');
  2907. var niveau = '';
  2908. for (var i = 0; i < bList.length; i++) {
  2909. var b = bList[i];
  2910. if(b.childNodes[0].nodeValue != "TUÉ")
  2911. continue;
  2912. var nbPX = "";
  2913. for (i++; i < bList.length; i++) {
  2914. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2915. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2916. return;
  2917. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2918. nbPX = bList[i].childNodes[0].nodeValue;
  2919. break;
  2920. }
  2921. }
  2922. if(nbPX == '')
  2923. return;
  2924. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2925. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2926. if(!nbPX)
  2927. nbPX = 0;
  2928. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2929. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2930. if(comPX > nbPX) {
  2931. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2932. niveau = "";
  2933. } else if(Math.floor(niveau) == niveau) {
  2934. chaine += niveau + ".";
  2935. } else {
  2936. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2937. niveau = "";
  2938. }
  2939. insertBr(b.nextSibling.nextSibling.nextSibling);
  2940. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2941. }
  2942.  
  2943. if(niveau != '') {
  2944. var button = insertButtonCdm('as_Action');
  2945. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2946. + escape(nomM) + "&niveau=" + escape(niveau)
  2947. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2948. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2949. }
  2950. }
  2951.  
  2952.  
  2953. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2954.  
  2955. function insertInfoMagie(node, intitule, magie) {
  2956. if(node.nextSibling) {
  2957. node = node.nextSibling;
  2958. insertBr(node);
  2959. insertText(node, intitule);
  2960. insertText(node, magie, true);
  2961. } else {
  2962. node = node.parentNode;
  2963. appendBr(node);
  2964. appendText(node, intitule);
  2965. appendText(node, magie, true);
  2966. }
  2967. }
  2968.  
  2969. function getMM(sr) {
  2970. if(rmTroll<=0) {
  2971. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2972. }
  2973. sr = Number(sr.match(/\d+/)[0]);
  2974. if(sr==10) {
  2975. return '\u2265 '+5*rmTroll;
  2976. }
  2977. if(sr<=50) {
  2978. return Math.round(50*rmTroll/sr);
  2979. }
  2980. if(sr<90) {
  2981. return Math.round((100-sr)*rmTroll/50);
  2982. }
  2983. return '\u2264 '+Math.round(rmTroll/5);
  2984. }
  2985.  
  2986. function traiteMM() {
  2987. var node = document.evaluate(
  2988. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2989. document, null, 9, null).singleNodeValue;
  2990. if(node) {
  2991. var mm = getMM(node.nodeValue);
  2992. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2993. } else {
  2994. var node = document.evaluate(
  2995. "//p/text()[contains(., 'Seuil de Résistance')]",
  2996. document, null, 9, null).singleNodeValue;
  2997. if(!node) {
  2998. return;
  2999. }
  3000. var mm = getMM(node.nodeValue);
  3001. node = node.nextSibling.nextSibling;
  3002. }
  3003. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3004. }
  3005.  
  3006. function getRM(sr) {
  3007. if(mmTroll<=0) {
  3008. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3009. }
  3010. sr = Number(sr.match(/\d+/)[0]);
  3011. if(sr==10) {
  3012. return '\u2264 '+Math.round(mmTroll/5);
  3013. }
  3014. if(sr<=50) {
  3015. return Math.round(sr*mmTroll/50);
  3016. }
  3017. if(sr<90) {
  3018. return Math.round(50*mmTroll/(100-sr));
  3019. }
  3020. return '\u2265 '+5*mmTroll;
  3021. }
  3022.  
  3023. function traiteRM() {
  3024. var nodes = document.evaluate(
  3025. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3026. document, null, 7, null);
  3027. if(nodes.snapshotLength==0) {
  3028. return;
  3029. }
  3030. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3031. var node = nodes.snapshotItem(i);
  3032. var rm = getRM(node.nodeValue);
  3033. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3034. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3035. }
  3036. }
  3037.  
  3038.  
  3039. /* Fonction stats IdT par Raistlin */
  3040. /*function getIdt() {
  3041. if(MY_getValue("SEND_IDT") == "non")
  3042. return false;
  3043. var regExpBeginning = /^\s+/;
  3044. var regExpEnd = /\s+$/;
  3045.  
  3046. var nomIdt = document.evaluate(
  3047. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3048. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3049. if(!nomIdt)
  3050. return false;
  3051.  
  3052. var caracIdt;
  3053. if(nomIdt.indexOf("Malédiction !") != -1) {
  3054. caracIdt = "";
  3055. nomIdt = "Mission maudite";
  3056. } else {
  3057. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3058. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3059. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3060. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3061. }
  3062. FF_XMLHttpRequest({
  3063. method: 'GET',
  3064. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3065. headers : {
  3066. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3067. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3068. }
  3069. });
  3070. return true;
  3071. }*/
  3072.  
  3073.  
  3074. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3075.  
  3076. function confirmeDecalage() {
  3077. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3078. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3079. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3080. var newDLA = new Date( oldDLA );
  3081. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3082. return window.confirm(
  3083. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3084. +'\nConfirmez-vous ce décalage ?'
  3085. );
  3086. }
  3087.  
  3088. function newsubmitDLA(evt) {
  3089. evt.stopPropagation();
  3090. evt.preventDefault();
  3091. if(confirmeDecalage()) {
  3092. this.submit();
  3093. }
  3094. }
  3095.  
  3096. function changeActionDecalage() {
  3097. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3098. return;
  3099. }
  3100. try {
  3101. // On récupère le contenu du script JS MH de calcul du décalage
  3102. var scriptTxt = document.evaluate(
  3103. ".//script[ not(@src) ]",
  3104. document, null, 9, null
  3105. ).singleNodeValue.textContent;
  3106. // On en extrait la DLA courante
  3107. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3108. scriptTxt = scriptTxt.split('\n')[0];
  3109. var nbs = scriptTxt.match(/\d+/g);
  3110. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3111. } catch(e) {
  3112. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3113. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3114. return;
  3115. }
  3116. var form = document.getElementsByName('ActionForm')[0];
  3117. if(form) {
  3118. form.addEventListener('submit', newsubmitDLA, true);
  3119. } else {
  3120. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3121. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3122. }
  3123. }
  3124.  
  3125. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3126.  
  3127. function prochainMundi() {
  3128. try {
  3129. var node = document.evaluate(
  3130. "//div[@class='dateAction']/b",
  3131. document, null, 9, null
  3132. ).singleNodeValue;
  3133. } catch(e) {
  3134. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3135. return;
  3136. }
  3137. if(!node) { return; }
  3138.  
  3139. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3140. var jour = longueurMois+1-getNumber(node.textContent);
  3141. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3142. var txt = '[Prochain Mundidey ';
  3143. if(jour>1) {
  3144. txt += 'dans '+jour+' jours]';
  3145. } else {
  3146. txt += 'demain]';
  3147. }
  3148. insertText(node.parentNode.nextSibling,txt,true);
  3149. }
  3150.  
  3151.  
  3152. /* Fonction principale */
  3153.  
  3154. function dispatch() {
  3155. if(isPage('MH_Play/Play_action')) {
  3156. prochainMundi();
  3157. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3158. var oldDLA;
  3159. changeActionDecalage();
  3160. } else if(isPage('MH_Play/Actions')) {
  3161. if(document.evaluate(
  3162. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3163. document, null, 2, null
  3164. ).stringValue) {
  3165. traiteMM();
  3166. } else if(document.evaluate(
  3167. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3168. document, null, 2, null
  3169. ).stringValue) {
  3170. //getIdt();
  3171. traiteRM();
  3172. } /*else {
  3173. // Est censé se lancer sur quoi *précisément* ?
  3174. traiteRM();
  3175. getLevel();
  3176. }*/
  3177. } else {
  3178. /* Traitement des messages du bot */
  3179. var messageTitle = document.evaluate(
  3180. "//form/table/tbody/tr[1]/td[1]/"
  3181. +"descendant::text()[contains(.,'[MountyHall]')]",
  3182. document, null, 2, null
  3183. ).stringValue;
  3184. if(messageTitle.indexOf('Attaquant') != -1 &&
  3185. messageTitle.indexOf('sur') != -1) {
  3186. getLevel();
  3187. traiteRM();
  3188. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3189. messageTitle.indexOf('Défenseur') != -1) {
  3190. traiteMM();
  3191. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3192. // à replacer avec Attaque après révision getLvl :
  3193. messageTitle.indexOf('Explosion') != -1 ||
  3194. messageTitle.indexOf('Insulte') != -1) {
  3195. traiteRM();
  3196. }
  3197. }
  3198. }
  3199.  
  3200. function do_actions() {
  3201. start_script(31);
  3202. dispatch();
  3203. displayScriptTime();
  3204. }
  3205.  
  3206. /*********************************************************************************
  3207. * This file is part of Mountyzilla. *
  3208. * *
  3209. * Mountyzilla is free software; you can redistribute it and/or modify *
  3210. * it under the terms of the GNU General Public License as published by *
  3211. * the Free Software Foundation; either version 2 of the License, or *
  3212. * (at your option) any later version. *
  3213. * *
  3214. * Mountyzilla is distributed in the hope that it will be useful, *
  3215. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3216. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3217. * GNU General Public License for more details. *
  3218. * *
  3219. * You should have received a copy of the GNU General Public License *
  3220. * along with Mountyzilla; if not, write to the Free Software *
  3221. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3222. *********************************************************************************/
  3223.  
  3224. // x~x pre-enchant
  3225.  
  3226. /* 2013-08-19 : correction auto syntaxe alert */
  3227.  
  3228. var combobox=null;
  3229.  
  3230. function changeObject()
  3231. {
  3232. if(!combobox)
  3233. return ;
  3234. var id = combobox.options[combobox.selectedIndex].value;
  3235. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3236. if(!id || id=="")
  3237. {
  3238. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3239. return;
  3240. }
  3241. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3242. }
  3243.  
  3244. function treatePreEnchantement() {
  3245. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3246. if(!input || input.getAttribute("type")=="hidden")
  3247. {
  3248. return false;
  3249. }
  3250. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3251. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3252. if(!combobox)
  3253. {
  3254. return true;
  3255. }
  3256. combobox.addEventListener('change', changeObject, true);
  3257. return true;
  3258. }
  3259.  
  3260. function treateEnchantement() {
  3261. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3262. if(!input || input.getAttribute("type")!="hidden")
  3263. {
  3264. return false;
  3265. }
  3266. var idEquipement = input.getAttribute("value");
  3267. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3268. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3269. if(enchanteur && enchanteur != null)
  3270. return true;
  3271. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3272. if(!input || input.getAttribute("type")!="hidden")
  3273. {
  3274. return false;
  3275. }
  3276. var idEnchanteur = input.getAttribute("value");
  3277. var nodes = document.evaluate(
  3278. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3279. if (nodes.snapshotLength != 3)
  3280. return;
  3281. for(var i=0;i<3;i++)
  3282. {
  3283. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3284. texte = texte.replace(" d'une "," d'un ");
  3285. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3286. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3287. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3288. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3289. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3290. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3291. }
  3292. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3293. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3294. var liste = MY_getValue(numTroll+".enchantement.liste");
  3295. if(!liste || liste=="")
  3296. {
  3297. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3298. }
  3299. else
  3300. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3301. }
  3302.  
  3303. function do_pre_enchant() {
  3304. start_script(60);
  3305. if(!treatePreEnchantement())
  3306. treateEnchantement();
  3307. displayScriptTime();
  3308. }
  3309.  
  3310. /*********************************************************************************
  3311. * This file is part of Mountyzilla. *
  3312. * *
  3313. * Mountyzilla is free software; you can redistribute it and/or modify *
  3314. * it under the terms of the GNU General Public License as published by *
  3315. * the Free Software Foundation; either version 2 of the License, or *
  3316. * (at your option) any later version. *
  3317. * *
  3318. * Mountyzilla is distributed in the hope that it will be useful, *
  3319. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3320. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3321. * GNU General Public License for more details. *
  3322. * *
  3323. * You should have received a copy of the GNU General Public License *
  3324. * along with Mountyzilla; if not, write to the Free Software *
  3325. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3326. *********************************************************************************/
  3327.  
  3328. // x~x enchant
  3329.  
  3330. /* 2013-08-19 : correction auto syntaxe alert */
  3331.  
  3332. function treateEnchantement() {
  3333. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3334. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3335. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3336. return;
  3337. var tab = infoEquipement.split(";");
  3338. if(tab.length<2)
  3339. return;
  3340. var idEquipement = tab[0];
  3341. var nomEquipement = tab[1];
  3342. for(var i=2;i<tab.length;i++)
  3343. nomEquipement += ";"+tab[i];
  3344. var nodes = document.evaluate(
  3345. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3346. if (nodes.snapshotLength != 3)
  3347. return;
  3348. for(var i=0;i<3;i++)
  3349. {
  3350. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3351. texte = texte.replace(" d'une "," d'un ");
  3352. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3353. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3354. monstre = monstre.replace(/ Géante?/,"");
  3355. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3356. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3357. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3358. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3359. }
  3360. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3361. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3362. var liste = MY_getValue(numTroll+".enchantement.liste");
  3363. if(!liste || liste=="")
  3364. {
  3365. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3366. }
  3367. else
  3368. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3369. }
  3370.  
  3371. function do_enchant() {
  3372. start_script(60);
  3373.  
  3374. treateEnchantement();
  3375. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3376. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3377. displayScriptTime();
  3378. }
  3379.  
  3380. /*********************************************************************************
  3381. * This file is part of Mountyzilla. *
  3382. * *
  3383. * Mountyzilla is free software; you can redistribute it and/or modify *
  3384. * it under the terms of the GNU General Public License as published by *
  3385. * the Free Software Foundation; either version 2 of the License, or *
  3386. * (at your option) any later version. *
  3387. * *
  3388. * Mountyzilla is distributed in the hope that it will be useful, *
  3389. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3390. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3391. * GNU General Public License for more details. *
  3392. * *
  3393. * You should have received a copy of the GNU General Public License *
  3394. * along with Mountyzilla; if not, write to the Free Software *
  3395. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3396. *********************************************************************************/
  3397.  
  3398. // x~x myevent
  3399.  
  3400. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3401. function do_myevent() {
  3402. }
  3403.  
  3404. /*********************************************************************************
  3405. * This file is part of Mountyzilla. *
  3406. * *
  3407. * Mountyzilla is free software; you can redistribute it and/or modify *
  3408. * it under the terms of the GNU General Public License as published by *
  3409. * the Free Software Foundation; either version 2 of the License, or *
  3410. * (at your option) any later version. *
  3411. * *
  3412. * Mountyzilla is distributed in the hope that it will be useful, *
  3413. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3414. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3415. * GNU General Public License for more details. *
  3416. * *
  3417. * You should have received a copy of the GNU General Public License *
  3418. * along with Mountyzilla; if not, write to the Free Software *
  3419. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3420. *********************************************************************************/
  3421.  
  3422. // x~x malus
  3423.  
  3424. /* v1.4 - 2014-01-06
  3425. * - Gestion des sorts double composante
  3426. * v1.4.1 - 2014-01-22
  3427. * - Correction décumul
  3428. * TODO
  3429. * - Identifier la position de "PV" dans l'ordre MH
  3430. */
  3431.  
  3432. var listeBM;
  3433.  
  3434.  
  3435. /* [functions] Utilitaires */
  3436.  
  3437. function decumul(bmt,nbr) {
  3438. var bmr;
  3439. if(!nbr || nbr<2) bmr = bmt;
  3440. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3441. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3442. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3443. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3444. else bmr = parseInt(0.1*bmt);
  3445. if(bmt<0) return Math.min(-1,bmr);
  3446. return Math.max(1,bmr);
  3447. }
  3448.  
  3449. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3450. // Roule 23/11/2016 ajout PV
  3451. switch( a ) {
  3452. case 'ATT':
  3453. return -1;
  3454. case 'ESQ':
  3455. if(b=='ATT') return 1;
  3456. return -1;
  3457. case 'DEG':
  3458. switch( b ) {
  3459. case 'ATT':
  3460. case 'ESQ':
  3461. return 1;
  3462. default:
  3463. return -1;
  3464. }
  3465. case 'REG':
  3466. switch( b ) {
  3467. case 'ATT':
  3468. case 'ESQ':
  3469. case 'DEG':
  3470. return 1;
  3471. default:
  3472. return -1;
  3473. }
  3474. case 'Vue':
  3475. switch( b ) {
  3476. case 'ATT':
  3477. case 'ESQ':
  3478. case 'DEG':
  3479. case 'REG':
  3480. return 1;
  3481. default:
  3482. return -1;
  3483. }
  3484. case 'TOUR':
  3485. switch( b ) {
  3486. case 'ATT':
  3487. case 'ESQ':
  3488. case 'DEG':
  3489. case 'REG':
  3490. case 'Vue':
  3491. return 1;
  3492. default:
  3493. return -1;
  3494. }
  3495. case 'PV':
  3496. switch( b ) {
  3497. case 'ATT':
  3498. case 'ESQ':
  3499. case 'DEG':
  3500. case 'REG':
  3501. case 'Vue':
  3502. case 'TOUR':
  3503. return 1;
  3504. default:
  3505. return -1;
  3506. }
  3507. case 'Armure':
  3508. switch( b ) {
  3509. case 'ATT':
  3510. case 'ESQ':
  3511. case 'DEG':
  3512. case 'REG':
  3513. case 'Vue':
  3514. case 'TOUR':
  3515. case 'PV':
  3516. return 1;
  3517. default:
  3518. return -1;
  3519. }
  3520. case 'RM':
  3521. switch( b ) {
  3522. case 'ATT':
  3523. case 'ESQ':
  3524. case 'DEG':
  3525. case 'REG':
  3526. case 'Vue':
  3527. case 'TOUR':
  3528. case 'PV':
  3529. case 'Armure':
  3530. return 1;
  3531. default:
  3532. return -1;
  3533. }
  3534. case 'MM':
  3535. switch( b ) {
  3536. case 'ATT':
  3537. case 'ESQ':
  3538. case 'DEG':
  3539. case 'REG':
  3540. case 'Vue':
  3541. case 'TOUR':
  3542. case 'PV':
  3543. case 'Armure':
  3544. case 'RM':
  3545. return 1;
  3546. default:
  3547. return -1;
  3548. }
  3549. case 'Concentration':
  3550. switch( b ) {
  3551. case 'ATT':
  3552. case 'ESQ':
  3553. case 'DEG':
  3554. case 'REG':
  3555. case 'Vue':
  3556. case 'TOUR':
  3557. case 'PV':
  3558. case 'Armure':
  3559. case 'RM':
  3560. case 'MM':
  3561. return 1;
  3562. default:
  3563. return -1;
  3564. }
  3565. case 'Fatigue':
  3566. switch( b ) {
  3567. case 'ATT':
  3568. case 'ESQ':
  3569. case 'DEG':
  3570. case 'REG':
  3571. case 'Vue':
  3572. case 'TOUR':
  3573. case 'PV':
  3574. case 'Armure':
  3575. case 'RM':
  3576. case 'MM':
  3577. case 'Concentration':
  3578. return 1;
  3579. default:
  3580. return -1;
  3581. }
  3582. case "Dés d'attaque":
  3583. switch( b ) {
  3584. case 'ATT':
  3585. case 'ESQ':
  3586. case 'DEG':
  3587. case 'REG':
  3588. case 'Vue':
  3589. case 'TOUR':
  3590. case 'PV':
  3591. case 'Armure':
  3592. case 'RM':
  3593. case 'MM':
  3594. case 'Concentration':
  3595. case 'Fatigue':
  3596. return 1;
  3597. default:
  3598. return -1;
  3599. }
  3600. case 'Dés de dégâts':
  3601. switch( b ) {
  3602. case 'ATT':
  3603. case 'ESQ':
  3604. case 'DEG':
  3605. case 'REG':
  3606. case 'Vue':
  3607. case 'TOUR':
  3608. case 'PV':
  3609. case 'Armure':
  3610. case 'RM':
  3611. case 'MM':
  3612. case 'Concentration':
  3613. case 'Fatigue':
  3614. case "Dés d'attaque":
  3615. return 1;
  3616. default:
  3617. return -1;
  3618. }
  3619. default :
  3620. switch( b ) {
  3621. case 'ATT':
  3622. case 'ESQ':
  3623. case 'DEG':
  3624. case 'REG':
  3625. case 'Vue':
  3626. case 'TOUR':
  3627. case 'PV':
  3628. case 'Armure':
  3629. case 'RM':
  3630. case 'MM':
  3631. case 'Concentration':
  3632. case 'Fatigue':
  3633. case "Dés d'attaque":
  3634. case 'Dés de dégâts':
  3635. return 1;
  3636. default:
  3637. return -1;
  3638. }
  3639. }
  3640. }
  3641.  
  3642.  
  3643. /* [functions] Fonctions hide / display */
  3644.  
  3645. function toggleDetailsBM() {
  3646. if(MY_getValue('BMDETAIL')!='false') {
  3647. MY_setValue('BMDETAIL','false');
  3648. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3649. for(var i=0 ; i<trlist.length ; i++)
  3650. trlist[i].style.display = 'none';
  3651. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3652. for(var i=0 ; i<trlist.length ; i++)
  3653. trlist[i].style = '';
  3654. }
  3655. else {
  3656. MY_setValue('BMDETAIL','true');
  3657. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3658. for(var i=0 ; i<trlist.length ; i++)
  3659. trlist[i].style.display = 'none';
  3660. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3661. for(var i=0 ; i<trlist.length ; i++)
  3662. trlist[i].style = '';
  3663. }
  3664. }
  3665.  
  3666. function toggleBMList() {
  3667. if(MY_getValue('BMHIDELIST')=='true') {
  3668. MY_setValue('BMHIDELIST','false');
  3669. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3670. listeBM.snapshotItem(i).style = '';
  3671. document.getElementsByTagName('thead')[0].style = '';
  3672. document.getElementById('trhelp').style = '';
  3673. }
  3674. else {
  3675. MY_setValue('BMHIDELIST','true');
  3676. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3677. listeBM.snapshotItem(i).style.display = 'none';
  3678. document.getElementsByTagName('thead')[0].style.display = 'none';
  3679. document.getElementById('trhelp').style.display = 'none';
  3680. }
  3681. }
  3682.  
  3683. function setDisplayBM() {
  3684. if(!listeBM) return;
  3685. var titre = document.getElementById('titre2');
  3686. if(titre) {
  3687. titre.style.cursor = 'pointer';
  3688. titre.onclick = toggleBMList;
  3689. }
  3690. var tfoot = document.getElementsByTagName('tfoot')[0];
  3691. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3692. tfoot, null, 9, null).singleNodeValue;
  3693. tr.id = 'trhelp';
  3694. if(MY_getValue('BMHIDELIST')=='true') {
  3695. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3696. listeBM.snapshotItem(i).style.display = 'none';
  3697. document.getElementsByTagName('thead')[0].style.display = 'none';
  3698. tr.style.display = 'none';
  3699. }
  3700. }
  3701.  
  3702.  
  3703. /* [functions] Fonction principale */
  3704.  
  3705. function traiteMalus() {
  3706. var mainTab = document.getElementsByTagName('table')[0];
  3707. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3708. if(listeBM.snapshotLength==0) return;
  3709. /* Suppression des BM de fatigue stockés */
  3710. if(MY_getValue(numTroll+'.bm.fatigue'))
  3711. MY_removeValue(numTroll+'.bm.fatigue');
  3712. /* Extraction des données */
  3713. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3714. var nb = 0;
  3715. while(nb<listeBM.snapshotLength) {
  3716. tr = listeBM.snapshotItem(nb); nb++;
  3717. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3718. var phymag = tr.childNodes[9].textContent;
  3719. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3720. var type = tr.childNodes[3].textContent, nom;
  3721. // si c'est un type à décumul
  3722. /*
  3723. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3724. switch(type) {
  3725. case 'Potion':
  3726. case 'Parchemin':
  3727. case 'Sortilège':
  3728. case 'Capacité Spéciale':
  3729. nom = tr.childNodes[1].textContent+phymag;
  3730. break;
  3731. default:
  3732. nom = 'pasdedecumul';
  3733. }
  3734. */
  3735. nom = tr.childNodes[1].textContent+phymag;
  3736. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3737. nom = 'pasdedecumul';
  3738. uniListe[nb] = {
  3739. 'duree':duree,
  3740. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3741. 'caracs':{}
  3742. }
  3743. for(var i=0 ; i<effetsT.length ; i++) {
  3744. if(effetsT[i].indexOf(':')==-1) continue;
  3745. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3746. // nom = 'pasdedecumul' si pas de décumul
  3747. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3748. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3749. uniListe[nb]['type'] = phymag;
  3750. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3751. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  3752. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  3753. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  3754. uniListe[nb]['caracs'][carac] = bm;
  3755. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  3756. listeDurees[duree] = true;
  3757. }
  3758. } // fin boucle sur les lignes de bonus/malus
  3759. /* Gestion des décumuls et cumuls des durées */
  3760. var toursGeres = [];
  3761. for(var d in listeDurees) toursGeres.push(d);
  3762. toursGeres.sort( function (a,b){return b-a;} );
  3763. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  3764. // pour sauvegarder les bm de fatigue
  3765. var strfat = '';
  3766. // Pour affichage & adpatation à footable.js (statique)
  3767. var thead = document.getElementsByTagName('thead')[0];
  3768. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3769. thead, null, 7, null).snapshotLength;
  3770. var tfoot = document.getElementsByTagName('tfoot')[0];
  3771. for(var i=0 ; i<toursGeres.length ; i++) {
  3772. var tour = toursGeres[i];
  3773. var effetsCeTour = {}; decumulsCeTour = {};
  3774. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3775. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3776. continue;
  3777. var nom = uniListe[nb]['nom'];
  3778. if(nom!='pasdedecumul') {
  3779. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3780. decumulsCeTour[nom]++;
  3781. }
  3782. for(var carac in uniListe[nb]['caracs']) {
  3783. var bm = uniListe[nb]['caracs'][carac];
  3784. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3785. var type = uniListe[nb]['type'];
  3786. if(!effetsCeTour[carac])
  3787. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3788. var thisBm;
  3789. if(nom=='pasdedecumul')
  3790. thisBm = bm;
  3791. else
  3792. thisBm = decumul(bm,decumulsCeTour[nom]);
  3793. effetsCeTour[carac][type] += thisBm;
  3794. 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]);
  3795. } else {
  3796. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3797. var thisBm;
  3798. if(nom=='pasdedecumul' || carac=='Fatigue')
  3799. thisBm = bm;
  3800. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3801. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3802. else
  3803. thisBm = decumul(bm,decumulsCeTour[nom]);
  3804. effetsCeTour[carac] += thisBm;
  3805. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3806. }
  3807. } // fin boucle sur les caractéristiques
  3808. } // fin boucle sur les bonus/malus
  3809. /* Création du bilan du tour */
  3810. var texteD = '', texteS = '';
  3811. var caracGerees = [];
  3812. for(var k in effetsCeTour) caracGerees.push(k);
  3813. caracGerees.sort( triecaracs );
  3814. for(var j=0 ; j<caracGerees.length ; j++) {
  3815. var carac = caracGerees[j], str = '';
  3816. switch( carac ) {
  3817. case 'ATT':
  3818. case 'DEG':
  3819. case 'Armure':
  3820. var phy = effetsCeTour[carac]['Physique'];
  3821. var mag = effetsCeTour[carac]['Magie'];
  3822. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3823. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3824. break;
  3825. case 'TOUR':
  3826. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3827. break;
  3828. case 'Fatigue':
  3829. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3830. case 'PV':
  3831. case 'ESQ':
  3832. case 'REG':
  3833. case 'Vue':
  3834. case 'Voir le Caché':
  3835. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3836. break;
  3837. default:
  3838. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3839. }
  3840. if(str) {
  3841. texteD += str;
  3842. texteS += str;
  3843. }
  3844. } // fin boucle sur les caractéristiques
  3845. /* Affichage */
  3846. // Si rien à afficher on passe
  3847. if(!texteD) continue;
  3848. // Si BMM+BMP=0
  3849. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3850. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3851. if(MY_getValue('BMDETAIL')=='false')
  3852. tr.style.display = 'none';
  3853. var td = appendTdText(tr,texteD.substring(3));
  3854. td.colSpan = 5-nbHidden;
  3855. var txttour = toursGeres[i]+' Tour';
  3856. if(toursGeres[i]>1) txttour += 's';
  3857. appendTdText(tr,txttour);
  3858. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3859. if(MY_getValue('BMDETAIL')!='false')
  3860. tr.style.display = 'none';
  3861. td = appendTdText(tr,texteS);
  3862. td.colSpan = 5-nbHidden;
  3863. appendTdText(tr,txttour);
  3864. } // fin boucle sur les tours générés
  3865. /* mise en place toggleDetails */
  3866. tfoot.style.cursor = 'pointer';
  3867. tfoot.onclick = toggleDetailsBM;
  3868. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3869. if(strfat)
  3870. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3871. }
  3872.  
  3873. function do_malus() {
  3874. try {
  3875. start_script();
  3876. traiteMalus();
  3877. setDisplayBM();
  3878. displayScriptTime();
  3879. }
  3880. catch(e) {window.alert(e)};
  3881. }
  3882.  
  3883. /*******************************************************************************
  3884. * This file is part of Mountyzilla. *
  3885. * *
  3886. * Mountyzilla is free software; you can redistribute it and/or modify *
  3887. * it under the terms of the GNU General Public License as published by *
  3888. * the Free Software Foundation; either version 2 of the License, or *
  3889. * (at your option) any later version. *
  3890. * *
  3891. * Mountyzilla is distributed in the hope that it will be useful, *
  3892. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3893. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3894. * GNU General Public License for more details. *
  3895. * *
  3896. * You should have received a copy of the GNU General Public License *
  3897. * along with Mountyzilla; if not, write to the Free Software *
  3898. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3899. *******************************************************************************/
  3900.  
  3901. // x~x mouches
  3902.  
  3903. var mainTab, tr_mouches;
  3904.  
  3905. function initialiseMouches() {
  3906. // Lanceur global
  3907. try {
  3908. mainTab = document.getElementById('mouches');
  3909. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3910. } catch(e) {
  3911. avertissement('Erreur MZ:<br />Consulter la console.');
  3912. window.console.error(traceStack(e, 'mouches'));
  3913. return;
  3914. }
  3915. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3916. setDisplayMouches();
  3917. traiteMouches();
  3918. }
  3919.  
  3920. function setDisplayMouches() {
  3921. // Initialise l'affichage / l'effacement du détail des mouches
  3922. var titre = document.getElementById('titre2');
  3923. if(titre) {
  3924. titre.style.cursor = 'pointer';
  3925. titre.onclick = toggleMouches;
  3926. }
  3927. var tfoot = document.getElementsByTagName('tfoot')[0];
  3928. if(tfoot) {
  3929. tfoot.style.cursor = 'pointer';
  3930. tfoot.onclick = toggleMouches;
  3931. }
  3932. if(MY_getValue('HIDEMOUCHES')=='true') {
  3933. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3934. tr_mouches.snapshotItem(i).style.display = 'none';
  3935. }
  3936. document.getElementsByTagName('thead')[0].style.display = 'none';
  3937. }
  3938. }
  3939.  
  3940. function toggleMouches() {
  3941. // Handler pour afficher / masquer les détasil
  3942. if(MY_getValue('HIDEMOUCHES')=='true') {
  3943. MY_setValue('HIDEMOUCHES','false');
  3944. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3945. tr_mouches.snapshotItem(i).style.display = '';
  3946. }
  3947. document.getElementsByTagName('thead')[0].style.display = '';
  3948. } else {
  3949. MY_setValue('HIDEMOUCHES','true');
  3950. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3951. tr_mouches.snapshotItem(i).style.display = 'none';
  3952. }
  3953. document.getElementsByTagName('thead')[0].style.display = 'none';
  3954. }
  3955. }
  3956.  
  3957. function traiteMouches() {
  3958. // Traitement complet: présence et effets des mouches
  3959. var listeTypes = {}, effetsActifs = {};
  3960. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3961. var tr = tr_mouches.snapshotItem(i);
  3962. // La mouche est-elle présente?
  3963. var etat = document.evaluate(
  3964. './img',
  3965. tr.cells[6], null, 9, null
  3966. ).singleNodeValue.alt;
  3967. if(etat!='La Mouche est là') { continue; }
  3968. // Extraction du type de mouche
  3969. var type = trim(tr.cells[3].textContent);
  3970. if(!listeTypes[type]) {
  3971. listeTypes[type] = 1;
  3972. } else {
  3973. listeTypes[type]++;
  3974. }
  3975. // La mouche a-t-elle un effet?
  3976. var effet = trim(tr.cells[2].textContent);
  3977. if(etat!='La Mouche est là' || !effet) { continue; }
  3978. // Si oui, extraction des effets (multiples pour pogées)
  3979. var caracs = effet.split(' | ');
  3980. for(var j=0 ; j<caracs.length ; j++) {
  3981. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3982. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3983. if(effetsActifs[carac]===void(0)) {
  3984. effetsActifs[carac] = valeur;
  3985. } else {
  3986. effetsActifs[carac] += valeur;
  3987. }
  3988. }
  3989. }
  3990. // Extraction Effet total et affichage des différences à la normale
  3991. var tfoot = document.getElementsByTagName('tfoot')[0];
  3992. if(!tfoot) { return; }
  3993. var nodeTotal = document.evaluate(
  3994. ".//b[contains(./text(),'Effet total')]",
  3995. tfoot, null, 9, null
  3996. ).singleNodeValue.nextSibling;
  3997. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3998. var texte = ' ';
  3999. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4000. if(texte.length>1) { texte += ' | '; }
  4001. var carac = trim(
  4002. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4003. );
  4004. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4005. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4006. texte += effetsTheoriques[i];
  4007. } else {
  4008. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4009. if(carac=='TOUR') { texte += ' min'; }
  4010. texte += '</b>';
  4011. }
  4012. }
  4013. var span = document.createElement('span');
  4014. span.innerHTML = texte;
  4015. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4016. // Affichage des différences du nombre de mouches de chaque type
  4017. var mouchesParType = document.evaluate(
  4018. "./tr/td/ul/li/text()",
  4019. tfoot, null, 7, null
  4020. );
  4021. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4022. var node = mouchesParType.snapshotItem(i);
  4023. var mots = node.nodeValue.split(' ');
  4024. var type = mots.pop();
  4025. if(!listeTypes[type]) {
  4026. node.nodeValue += ' (0 présente)';
  4027. } else if(mots[0]!=listeTypes[type]) {
  4028. if(listeTypes[type]==1) {
  4029. node.nodeValue += ' (1 présente)';
  4030. } else {
  4031. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4032. }
  4033. }
  4034. }
  4035. }
  4036.  
  4037. function do_mouches() {
  4038. start_script();
  4039. initialiseMouches();
  4040. displayScriptTime();
  4041. }
  4042.  
  4043. /*********************************************************************************
  4044. * This file is part of Mountyzilla. *
  4045. * *
  4046. * Mountyzilla is free software; you can redistribute it and/or modify *
  4047. * it under the terms of the GNU General Public License as published by *
  4048. * the Free Software Foundation; either version 2 of the License, or *
  4049. * (at your option) any later version. *
  4050. * *
  4051. * Mountyzilla is distributed in the hope that it will be useful, *
  4052. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4053. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4054. * GNU General Public License for more details. *
  4055. * *
  4056. * You should have received a copy of the GNU General Public License *
  4057. * along with Mountyzilla; if not, write to the Free Software *
  4058. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4059. *********************************************************************************/
  4060.  
  4061. // x~x equipgowap
  4062.  
  4063. var popup;
  4064.  
  4065. function initPopupEquipgowap() {
  4066. popup = document.createElement('div');
  4067. popup.setAttribute('id', 'popup');
  4068. popup.setAttribute('class', 'mh_textbox');
  4069. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4070. 'display: inline; z-index: 3; max-width: 400px;');
  4071. document.body.appendChild(popup);
  4072. }
  4073.  
  4074. function showPopupEquipgowap(evt) {
  4075. var texte = this.getAttribute("texteinfo");
  4076. popup.innerHTML = texte;
  4077. popup.style.left = evt.pageX + 15 + 'px';
  4078. popup.style.top = evt.pageY + 'px';
  4079. popup.style.visibility = "visible";
  4080. }
  4081.  
  4082. function hidePopup() {
  4083. popup.style.visibility = "hidden";
  4084. }
  4085.  
  4086. function createPopupImage(url, text)
  4087. {
  4088. var img = document.createElement('img');
  4089. img.setAttribute('src',url);
  4090. img.setAttribute('align','ABSMIDDLE');
  4091. img.setAttribute("texteinfo",text);
  4092. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4093. img.addEventListener("mouseout", hidePopup,true);
  4094. return img;
  4095. }
  4096.  
  4097. function formateTexte(texte)
  4098. {
  4099. texte = texte.replace(/\n/g,"<br/>");
  4100. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4101. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4102. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4103. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4104. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4105. return texte;
  4106. }
  4107.  
  4108.  
  4109. function treateGowaps() {
  4110. //On récupère les gowaps possédants des composants
  4111. var tbodys = document.evaluate(
  4112. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4113. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4114. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4115. var tbody = tbodys.snapshotItem(j);
  4116. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4117. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4118. if(MY_getValue("NOINFOEM") != "true")
  4119. insertEMInfos(tbody);
  4120. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4121. insertEnchantInfos(tbody);
  4122. }
  4123. }
  4124.  
  4125. function treateChampi() {
  4126. if(MY_getValue("NOINFOEM") == "true")
  4127. return false;
  4128. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4129. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4130. if (nodes.snapshotLength == 0)
  4131. return false;
  4132.  
  4133. for (var i = 0; i < nodes.snapshotLength; i++) {
  4134. var node = nodes.snapshotItem(i);
  4135. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4136. if(texte.indexOf("*")!=-1)
  4137. texte = texte.substring(0,texte.lastIndexOf(" "));
  4138. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4139. if(moisChampi[nomChampi])
  4140. {
  4141. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4142. }
  4143. }
  4144. }
  4145.  
  4146. function do_equipgowap() {
  4147. start_script();
  4148.  
  4149. treateGowaps();
  4150. treateChampi();
  4151. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4152. {
  4153. initPopupEquipgowap();
  4154. computeEnchantementEquipement(createPopupImage,formateTexte);
  4155. }
  4156.  
  4157. displayScriptTime();
  4158. }
  4159.  
  4160. /*********************************************************************************
  4161. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4162. *********************************************************************************/
  4163.  
  4164. // x~x ordresgowap
  4165.  
  4166. // version Roule' janvier 2017
  4167. function MZ_setCarteUnGogoHTML5() {
  4168. // fabriquer la liste des positions successives
  4169. var listeDepl = []; // ce sera un tableau d'objets
  4170. // position courrante
  4171. var eTitle = document.getElementById('titre2');
  4172. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4173. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4174. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4175. , y: parseInt(tabPos[1])
  4176. , n: parseInt(tabPos[2])
  4177. , nom: tabNomID[2]
  4178. , id: tabNomID[1]});
  4179. // déplacements
  4180. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4181. for(var i=0 ; i<lignes.length ; i++) {
  4182. if(lignes[i].className == 'mh_tdpage_fo') {
  4183. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4184. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4185. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4186. }
  4187. }
  4188. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4189. }
  4190.  
  4191. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4192. function MZ_showCarteBottom(listeSuiv) {
  4193. // générer la carte
  4194. var carte = new carte_MZ('cartegogo', listeSuiv);
  4195. // positionner la carte
  4196. var eCarte = carte.getElt();
  4197. eCarte.style.textAlign = 'left';
  4198. eCarte.style.marginTop = '2px';
  4199. var footer = document.getElementById('footer1');
  4200. // Lieu_Teleport.php n'a pas de footer1 :(
  4201. if (!footer) footer = document.getElementById('footer2');
  4202. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4203. else document.body.appendChild(eCarte);
  4204. }
  4205.  
  4206. function MZ_setCarteTousGogoHTML5() {
  4207. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4208. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4209. var suivants = [];
  4210. for (var i=0;i<ligne.length;i++) {
  4211. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4212. var cas = ligne[i].getElementsByTagName("td")[0];
  4213. //if (cas.className == "mh_tdtitre") {
  4214. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4215. var oGogo = {};
  4216. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4217. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4218. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4219. oGogo.x = parseInt(point[1]);
  4220. oGogo.y = parseInt(point[2]);
  4221. oGogo.n = parseInt(point[3]);
  4222. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4223. }
  4224. }
  4225. if (suivants.length == 0) return;
  4226. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4227. }
  4228.  
  4229. function MZ_setCarteTP() {
  4230. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4231. 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);
  4232. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4233. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4234. }
  4235.  
  4236. /* v0.2 by Dab - 2013-08-31
  4237. * - correction acquisition posale initiale
  4238. * - correction tare et affichage mire
  4239. */
  4240.  
  4241. function setCarteGogo() {
  4242. try {
  4243. //var pars = document.getElementsByTagName('p');
  4244. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4245. var eTitle = document.getElementById('titre2');
  4246. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4247. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4248. var serv_img_cible = URL_MZimg + "rep.png";
  4249.  
  4250. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4251. //var lignes = pars[0].getElementsByTagName('tr');
  4252. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4253. var nbpt = 0;
  4254. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4255. for(var i=0 ; i<lignes.length ; i++) {
  4256. if(lignes[i].className == 'mh_tdpage_fo') {
  4257. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4258. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4259. if(point) {
  4260. nbpt++;
  4261. trajet += point[1]+','+point[2]+','+point[3]+',';
  4262. }
  4263. }
  4264. }
  4265. }
  4266. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4267. 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'/>";
  4268. var base = [-229,-5];
  4269. if (nbpt>0) {
  4270. base = [-684,-5];
  4271. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4272. }
  4273. 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;'/>";
  4274.  
  4275. 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>';
  4276.  
  4277. var nvspan = document.createElement('div');
  4278. nvspan.align = 'center';
  4279. nvspan.id = 'mz_mapdiv';
  4280. nvspan.valign = 'top';
  4281. nvspan.innerHTML = nvdiv;
  4282. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4283. var footer = document.getElementById('footer1');
  4284. footer.parentNode.insertBefore(nvspan,footer);
  4285. }
  4286.  
  4287. function testeGlissiere() {
  4288. try {
  4289. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4290. var footer = document.getElementById('footer1');
  4291. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4292. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4293. }
  4294.  
  4295. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4296. if (x0 !== undefined) {
  4297. // ouais, récursif une fois
  4298. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4299. if (PtInterm === undefined)
  4300. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4301. else
  4302. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4303. return;
  4304. }
  4305. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4306. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4307. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4308. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4309. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4310. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4311. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4312. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4313. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4314. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4315. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4316. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4317. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4318. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4319. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4320. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4321. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4322. }
  4323.  
  4324. function do_ordresgowap() {
  4325. if (newCarte) {
  4326. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4327. //testeGlissiere();
  4328. //MZ_testsUnitairesCalculIntermediaire();
  4329. } else {
  4330. setCarteGogo(); // Via script des trouillots
  4331. }
  4332. }
  4333.  
  4334. function do_listegowap() {
  4335. if (!newCarte) return;
  4336. MZ_setCarteTousGogoHTML5();
  4337. }
  4338.  
  4339. function do_lieuDescription() {
  4340. if (!newCarte) return;
  4341. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4342. MZ_setCarteTP();
  4343. }
  4344.  
  4345. function do_lieuTeleport() {
  4346. changeButtonValidate();
  4347. if (!newCarte) return;
  4348. MZ_setCarteTP();
  4349. }
  4350.  
  4351. /*********************************************************************************
  4352. * This file is part of Mountyzilla. *
  4353. * *
  4354. * Mountyzilla is free software; you can redistribute it and/or modify *
  4355. * it under the terms of the GNU General Public License as published by *
  4356. * the Free Software Foundation; either version 2 of the License, or *
  4357. * (at your option) any later version. *
  4358. * *
  4359. * Mountyzilla is distributed in the hope that it will be useful, *
  4360. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4361. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4362. * GNU General Public License for more details. *
  4363. * *
  4364. * You should have received a copy of the GNU General Public License *
  4365. * along with Mountyzilla; if not, write to the Free Software *
  4366. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4367. *********************************************************************************/
  4368.  
  4369. // x~x attaque
  4370.  
  4371. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4372.  
  4373. function do_attaque() {
  4374. }
  4375.  
  4376. /*******************************************************************************
  4377. * This file is part of Mountyzilla. *
  4378. * *
  4379. * Mountyzilla is free software; you can redistribute it and/or modify *
  4380. * it under the terms of the GNU General Public License as published by *
  4381. * the Free Software Foundation; either version 2 of the License, or *
  4382. * (at your option) any later version. *
  4383. * *
  4384. * Mountyzilla is distributed in the hope that it will be useful, *
  4385. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4386. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4387. * GNU General Public License for more details. *
  4388. * *
  4389. * You should have received a copy of the GNU General Public License *
  4390. * along with Mountyzilla; if not, write to the Free Software *
  4391. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4392. *******************************************************************************/
  4393.  
  4394. // x~x infomonstre
  4395.  
  4396. // DEBUG
  4397. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4398. // À corriger, évidemment.
  4399. var listeCDM = {};
  4400. var nomMonstre='';
  4401. var idMonstre=-1;
  4402. var tbody;
  4403. var popup;
  4404.  
  4405. function traiteMonstre() {
  4406. try {
  4407. var nodeTitre = document.evaluate(
  4408. "//div[@class='titre2' and contains(text(),'(')]",
  4409. document, null, 9, null
  4410. ).singleNodeValue;
  4411. var texte = nodeTitre.firstChild.nodeValue;
  4412. } catch(e) {
  4413. window.console.log(traceStack(e, 'traiteMonstre'));
  4414. return;
  4415. }
  4416. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4417. if(nomMonstre.indexOf(']')!=-1) {
  4418. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4419. }
  4420. idMonstre = texte.match(/\d+/)[0];
  4421. FF_XMLHttpRequest({
  4422. method: 'GET',
  4423. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4424. +MY_getValue('CDMID')
  4425. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4426. headers : {
  4427. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4428. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4429. },
  4430. onload: function(responseDetails) {
  4431. try {
  4432. var texte = responseDetails.responseText;
  4433. var lines = texte.split("\n");
  4434. if(lines.length>=1) {
  4435. var infos = lines[0].split(";");
  4436. if(infos.length<4) { return; }
  4437. var idMonstre = infos[0];
  4438. infos=infos.slice(3);
  4439. listeCDM[idMonstre]=infos;
  4440. computeMissionInfomonstre();
  4441. }
  4442. } catch(e) {
  4443. window.alert(e);
  4444. }
  4445. }
  4446. });
  4447. }
  4448.  
  4449. function initPopupInfomonstre() {
  4450. // Initialise le popup tactique (calculs att/deg)
  4451. popup = document.createElement('div');
  4452. popup.id = 'popup';
  4453. popup.className = 'mh_textbox';
  4454. popup.style =
  4455. 'position: absolute;'+
  4456. 'border: 1px solid #000000;'+
  4457. 'visibility: hidden;'+
  4458. 'display: inline;'+
  4459. 'z-index: 3;'+
  4460. 'max-width: 400px;';
  4461. document.body.appendChild(popup);
  4462. }
  4463.  
  4464. function showPopupTactique(evt) {
  4465. try {
  4466. var id = this.id;
  4467. var nom = this.nom;
  4468. var texte = getAnalyseTactique(id,nom);
  4469. if(texte=='') { return; }
  4470. popup.innerHTML = texte;
  4471. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4472. if(isPage("View/MonsterView")) {
  4473. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4474. } else {
  4475. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4476. }
  4477. popup.style.top = evt.pageY+15+'px';
  4478. popup.style.visibility = 'visible';
  4479. } catch(e) {
  4480. window.alert(e);
  4481. }
  4482. }
  4483.  
  4484. // roule 16/03/2016, existe déjà ailleurs
  4485. // function hidePopup() {
  4486. // popup.style.visibility = 'hidden';
  4487. // }
  4488.  
  4489. function toggleTableau() {
  4490. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4491. }
  4492.  
  4493. function computeMissionInfomonstre() {
  4494. // C'est quoi ce titre de fonction ? (O_o)
  4495. try {
  4496. var nodeInsert = document.evaluate(
  4497. "//div[@class = 'titre3']",
  4498. document, null, 9, null
  4499. ).singleNodeValue;
  4500. } catch(e) {
  4501. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4502. return;
  4503. }
  4504. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4505. table.align = 'center';
  4506. tbody = table.childNodes[1];
  4507. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4508. table.firstChild.firstChild.onmouseover = function() {
  4509. this.style.cursor = 'pointer';
  4510. this.className = 'mh_tdpage';
  4511. };
  4512. table.firstChild.firstChild.onmouseout = function() {
  4513. this.className = 'mh_tdtitre';
  4514. };
  4515. tbody.style.display = 'none';
  4516. table.style.width = '350px';
  4517. insertBefore(nodeInsert,table);
  4518. }
  4519.  
  4520. function do_infomonstre() {
  4521. start_script();
  4522. try {
  4523. initPopupInfomonstre();
  4524. traiteMonstre();
  4525. } catch(e) {
  4526. window.alert('Erreur infoMonstre:\n'+e);
  4527. }
  4528. displayScriptTime();
  4529. }
  4530.  
  4531. /*******************************************************************************
  4532. * This file is part of Mountyzilla. *
  4533. * *
  4534. * Mountyzilla is free software; you can redistribute it and/or modify *
  4535. * it under the terms of the GNU General Public License as published by *
  4536. * the Free Software Foundation; either version 2 of the License, or *
  4537. * (at your option) any later version. *
  4538. * *
  4539. * Mountyzilla is distributed in the hope that it will be useful, *
  4540. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4541. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4542. * GNU General Public License for more details. *
  4543. * *
  4544. * You should have received a copy of the GNU General Public License *
  4545. * along with Mountyzilla; if not, write to the Free Software *
  4546. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4547. *******************************************************************************/
  4548.  
  4549. // x~x mission
  4550.  
  4551. /* TODO
  4552. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  4553. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  4554. *
  4555. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  4556. */
  4557.  
  4558. function saveMission(num,obEtape) {
  4559. var obMissions = [];
  4560. if(MY_getValue(numTroll+'.MISSIONS')) {
  4561. try {
  4562. window.console.log('JSON MISSION = ' + MY_getValue(numTroll+'.MISSIONS'));
  4563. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  4564. } catch(e) {
  4565. window.console.error(traceStack(e, 'Mission parsage'));
  4566. return;
  4567. }
  4568. }
  4569. if (obMissions == undefined) obMissions = []; // protection
  4570. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  4571. if(obEtape) {
  4572. obMissions[num] = obEtape;
  4573. } else if(obMissions[num]) {
  4574. delete obMissions[num];
  4575. }
  4576. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  4577. }
  4578.  
  4579. function addtroogle(tdLibelle, sRestrict) {
  4580. var img = document.createElement('img');
  4581. img.src = URL_MZimg + 'troogle.ico';
  4582. img.alt = 'Troogle logo';
  4583. var a = document.createElement('a');
  4584. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  4585. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  4586. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  4587. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  4588. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  4589. a.href = url;
  4590. a.title = 'Chercher sur Troogle';
  4591. a.target = 'troogle';
  4592. a.appendChild(img);
  4593. tdLibelle.appendChild(a);
  4594. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  4595. }
  4596.  
  4597. function traiteMission() {
  4598. try {
  4599. var titreMission = document.getElementsByClassName('titre2')[0];
  4600. var numMission = titreMission.textContent.match(/\d+/)[0];
  4601. var missionForm = document.getElementsByName('ActionForm')[0];
  4602. var tdLibelle = document.evaluate(
  4603. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  4604. missionForm, null, 9, null).singleNodeValue;
  4605. } catch(e) {
  4606. window.console.error(traceStack(e, 'récupération mission'));
  4607. return;
  4608. }
  4609. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  4610. try {
  4611. if(!tdLibelle) {
  4612. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  4613. debugMZ('traiteMission, la mission semble terminée');
  4614. saveMission(numMission,false);
  4615. return;
  4616. }
  4617.  
  4618. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4619. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4620. // debug Roule'
  4621. if (MY_DEBUG) {
  4622. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4623. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4624. }
  4625. if(libelle.indexOf('niveau égal à')!=-1) {
  4626. var nbKills = 1, niveau, mod;
  4627. // exemples :
  4628. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  4629. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  4630. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  4631. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  4632. if (tdLibelle.childNodes.length == 1) {
  4633. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  4634. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  4635. if (m) {
  4636. niveau = Number(m[1]);
  4637. mod = 'plus'
  4638. } else {
  4639. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  4640. if (m) {
  4641. niveau = Number(m[1]);
  4642. mod = Number(m[2]);
  4643. } else {
  4644. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  4645. return;
  4646. }
  4647. }
  4648. } else {
  4649. // ancienne méthode (multi childnode)
  4650. // à supprimer un jour peut-être
  4651. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4652. // Étape de kill multiple de niveau donné
  4653. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4654. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4655. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4656. niveau = Number(mod[0]);
  4657. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4658. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4659. } else {
  4660. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4661. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4662. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4663. mod = mod ? Number(mod[0]) : 'plus';
  4664. }
  4665. } else {
  4666. // Étape de kill unique de niveau donné
  4667. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4668. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4669. mod = mod ? Number(mod[0]) : 'plus';
  4670. }
  4671. }
  4672. // debug Roule'
  4673. if (MY_DEBUG) {
  4674. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4675. }
  4676. saveMission(numMission,{
  4677. type: 'Niveau',
  4678. niveau: niveau,
  4679. mod: mod,
  4680. mundidey: siMundidey,
  4681. libelle: libelle
  4682. });
  4683. if (mod == 'plus')
  4684. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4685. else
  4686. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4687. } else if(libelle.indexOf('de la race')!=-1) {
  4688. var nbKills = 1, race;
  4689. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4690. // Étape de kill multiple de race donnée
  4691. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4692. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4693. } else {
  4694. // Étape de kill unique de race donnée
  4695. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4696. }
  4697. race = race.replace(/\"/g,'');
  4698. saveMission(numMission,{
  4699. type: 'Race',
  4700. race: race,
  4701. mundidey: siMundidey,
  4702. libelle: libelle
  4703. });
  4704. addtroogle(tdLibelle, '@monstre ' + race);
  4705. } else if(libelle.indexOf('de la famille')!=-1) {
  4706. var nbKills = 1, famille;
  4707. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4708. // Étape de kill multiple de famille donnée
  4709. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4710. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4711. } else {
  4712. // Étape de kill unique de famille donnée
  4713. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4714. }
  4715. famille = famille.replace(/\"/g,'');
  4716. saveMission(numMission,{
  4717. type: 'Famille',
  4718. famille: famille,
  4719. mundidey: siMundidey,
  4720. libelle: libelle
  4721. });
  4722. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4723. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4724. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4725. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4726. debugMZ('traiteMission étape capacité spéciale');
  4727. saveMission(numMission,{
  4728. type: 'Pouvoir',
  4729. pouvoir: pouvoir,
  4730. libelle: libelle
  4731. });
  4732. } else {
  4733. debugMZ('traiteMission étape pas pour troogle');
  4734. saveMission(numMission,false);
  4735. }
  4736. } catch(e) {
  4737. window.console.error(traceStack(e, 'récupération étape mission'));
  4738. return;
  4739. }
  4740. }
  4741.  
  4742. function do_mission() {
  4743. start_script(60);
  4744.  
  4745. traiteMission();
  4746.  
  4747. displayScriptTime();
  4748. }
  4749.  
  4750. /*******************************************************************************
  4751. * This file is part of Mountyzilla. *
  4752. * *
  4753. * Mountyzilla is free software; you can redistribute it and/or modify *
  4754. * it under the terms of the GNU General Public License as published by *
  4755. * the Free Software Foundation; either version 2 of the License, or *
  4756. * (at your option) any later version. *
  4757. * *
  4758. * Mountyzilla is distributed in the hope that it will be useful, *
  4759. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4760. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4761. * GNU General Public License for more details. *
  4762. * *
  4763. * You should have received a copy of the GNU General Public License *
  4764. * along with Mountyzilla; if not, write to the Free Software *
  4765. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4766. *******************************************************************************/
  4767.  
  4768. // x~x move
  4769.  
  4770. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4771.  
  4772. var petitsTrous = {
  4773. '-52;57': true,
  4774. '55;70': true,
  4775. '64;70': true,
  4776. '12;-15': true,
  4777. '30;-52': true,
  4778. '48;-39': true
  4779. };
  4780.  
  4781. var grosTrous = {
  4782. '-35;65': true,
  4783. '-13;73': true,
  4784. '-64;9': true,
  4785. '-35;15': true,
  4786. '5;32': true,
  4787. '10;64': true,
  4788. '21;36': true,
  4789. '46;52': true,
  4790. '74;32': true,
  4791. '-71;-7': true,
  4792. '-67;-37': true,
  4793. '-60;-32': true,
  4794. '-51;-22': true,
  4795. '-36;-51': true,
  4796. '5;-49': true
  4797. };
  4798.  
  4799. var centreCarmine_X = 56.5;
  4800. var centreCarmine_Y = 23.5;
  4801. var rayonCarmine = 8.7;
  4802.  
  4803. function isTrou(x,y,n) {
  4804. if(petitsTrous[x+';'+y]) {
  4805. return n<0 && n>-60;
  4806. }
  4807. if(grosTrous[x+';'+y]
  4808. || grosTrous[x-1+';'+y]
  4809. || grosTrous[x+';'+y+1]
  4810. || grosTrous[x-1+';'+y+1]) {
  4811. return n<0 && n>-70;
  4812. }
  4813. if(Math.sqrt(
  4814. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4815. )<=rayonCarmine) {
  4816. return n<0 && n>-100;
  4817. }
  4818. return false;
  4819. }
  4820.  
  4821. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4822.  
  4823. function validateDestination() {
  4824. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4825. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4826. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4827. var form = document.getElementsByName('ActionForm')[0];
  4828. if(form) {
  4829. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4830. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4831. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4832. }
  4833. }
  4834. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4835. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4836. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4837. }
  4838. }
  4839. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4840. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4841. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4842. }
  4843. }
  4844. if(isTrou(x,y,n)) {
  4845. return window.confirm(
  4846. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4847. +'Vous allez tomber dans un trou de météorite.\n'
  4848. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4849. );
  4850. }
  4851. }
  4852. return true;
  4853. }
  4854.  
  4855. function newsubmitDE(event) {
  4856. event.stopPropagation();
  4857. event.preventDefault();
  4858. if(validateDestination()) {
  4859. this.submit();
  4860. }
  4861. }
  4862.  
  4863. function changeValidation() {
  4864. var form = document.getElementsByName('ActionForm')[0];
  4865. if(form) {
  4866. form.addEventListener('submit', newsubmitDE, true);
  4867. }
  4868. }
  4869.  
  4870.  
  4871. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4872.  
  4873. function validateTPDestination() {
  4874. try {
  4875. var text = document.getElementsByTagName('B')[0];
  4876. var a = text.firstChild.nodeValue.split('|');
  4877. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4878. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4879. var pos_n = a[2].substring(5, a[2].length) * 1;
  4880.  
  4881. var nbtrous = 0;
  4882. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4883. for(var x=0 ; x<=2 ; x++) {
  4884. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4885. for(var y=0 ; y<=2 ; y++) {
  4886. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4887. for(var n = 0 ; n <= 1 ; n++) {
  4888. if(isTrou(
  4889. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4890. )) {
  4891. nbtrous++;
  4892. }
  4893. }
  4894. }
  4895. }
  4896. }
  4897. }
  4898. }
  4899. if(nbtrous>0 && nbtrous<72) {
  4900. return window.confirm(
  4901. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4902. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4903. +'% de risque de tomber dans un trou de météorite.\n'
  4904. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4905. );
  4906. }
  4907. else if(nbtrous>=72) {
  4908. return window.confirm(
  4909. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4910. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4911. +'% de risque de tomber dans un trou de météorite !\n'
  4912. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4913. );
  4914. }
  4915. return true;
  4916. }
  4917. catch(e) {
  4918. window.alert(e)
  4919. }
  4920. }
  4921.  
  4922. function newsubmitTP(event) {
  4923. event.stopPropagation();
  4924. event.preventDefault();
  4925. if(validateTPDestination()) {
  4926. this.submit();
  4927. }
  4928. }
  4929.  
  4930. function changeButtonValidate() {
  4931. var form = document.getElementsByName('Formulaire')[0];
  4932. if(form) {
  4933. if(!form.getAttribute('onsubmit')) {
  4934. form.setAttribute('onsubmit','return true;');
  4935. }
  4936. form.addEventListener('submit', newsubmitTP, true);
  4937. }
  4938. }
  4939.  
  4940.  
  4941. /*-[functions]---------------- Partie Principale -----------------------------*/
  4942.  
  4943. function do_move() {
  4944. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  4945. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4946. changeValidation();
  4947. //}
  4948. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4949. // changeButtonValidate();
  4950. //}
  4951. }
  4952.  
  4953. /*******************************************************************************
  4954. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4955. * Mountyzilla is free software; provided under the GNU General Public License *
  4956. *******************************************************************************/
  4957.  
  4958. // x~x news
  4959.  
  4960. // Nombre de news à afficher & nb max de caractères par news:
  4961. const nbItems = 5;
  4962. const maxCarDescription = 300;
  4963.  
  4964. /*-[functions]------------------- Utilitaires --------------------------------*/
  4965.  
  4966. // Ne semble avoir strictement aucun effet:
  4967. String.prototype.epureDescription = function() {
  4968. return this.replace(/\\(.)/g,"$1");
  4969. }
  4970.  
  4971. function appendTitledTable(node,titre,description) {
  4972. // Crée les tables contenant les infos (avec titre)
  4973. var table = document.createElement('table');
  4974. table.border = 0;
  4975. table.className = 'mh_tdborder';
  4976. table.cellSpacing = 1;
  4977. table.cellPadding = 1;
  4978. table.style.maxWidth = '98%';
  4979. table.style.marginLeft = 'auto';
  4980. table.style.marginRight = 'auto';
  4981. var tbody = document.createElement('tbody');
  4982. table.appendChild(tbody);
  4983. var tr = appendTr(tbody,'mh_tdtitre');
  4984. var td = appendTdCenter(tr,2);
  4985. var span = document.createElement('span');
  4986. appendText(span,titre,true);
  4987. if(description) {
  4988. span.title = description;
  4989. }
  4990. td.appendChild(span);
  4991. node.appendChild(table);
  4992. return tbody;
  4993. }
  4994.  
  4995. function testCertif(paramURL, callbackOnError) {
  4996. try {
  4997. FF_XMLHttpRequest({
  4998. method: 'GET',
  4999. url: paramURL,
  5000. onload: function(responseDetails) {
  5001. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  5002. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  5003. }
  5004. });
  5005. } catch(e) {
  5006. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  5007. callbackOnError();
  5008. }
  5009. }
  5010.  
  5011. function createOrGetGrandCadre() {
  5012. var grandCadre = document.getElementById('grandCadre');
  5013. if (grandCadre) return grandCadre;
  5014. try {
  5015. var rappels = document.evaluate(
  5016. "//p[contains(a/text(),'messagerie')]",
  5017. document, null, 9, null).singleNodeValue;
  5018. }
  5019. catch(e) {
  5020. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  5021. grandCadre = document.createElement('div');
  5022. return grandCadre;
  5023. }
  5024. grandCadre = document.createElement('div');
  5025. grandCadre.id = 'grandCadre';
  5026. var sousCadre = document.createElement('div');
  5027. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  5028. sousCadre.style.textAlign = 'center';
  5029. sousCadre.style.fontSize = 'xx-large';
  5030. grandCadre.appendChild(sousCadre);
  5031.  
  5032. grandCadre.style.border = 'solid 5px red';
  5033. grandCadre.style.width = 'auto';
  5034. insertBefore(rappels,grandCadre);
  5035. return grandCadre;
  5036. }
  5037.  
  5038. function showHttpsErrorCadre1() {
  5039. window.console.log('[MZ] showHttpsErrorCadre1');
  5040. var grandCadre = createOrGetGrandCadre();
  5041. var sousCadre = document.createElement('div');
  5042. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  5043. + '<br />Cela empêchera Moutyzilla de fonctionner'
  5044. + '<br /><a style="color:blue;font-size: inherits;" href="'
  5045. + URL_CertifRaistlin1
  5046. + '" target="raistlin">clique ici</a>'
  5047. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5048. + ' « Confirmer l\'exception de sécurité »'
  5049. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5050. sousCadre.style.width = 'auto';
  5051. sousCadre.style.fontSize = 'large';
  5052. sousCadre.style.border = 'solid 1px black';
  5053. sousCadre.style.backgroundColor = 'red';
  5054. grandCadre.appendChild(sousCadre);
  5055. }
  5056.  
  5057. function showHttpsErrorCadre2() {
  5058. window.console.log('[MZ] showHttpsErrorCadre2');
  5059. var grandCadre = createOrGetGrandCadre();
  5060. var sousCadre = document.createElement('div');
  5061. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  5062. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  5063. + '<a style="color:blue;font-size: inherits;" href="'
  5064. + URL_CertifRaistlin2
  5065. + '" target="raistlin">clique ici</a>'
  5066. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5067. + ' « Confirmer l\'exception de sécurité »'
  5068. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  5069. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5070. sousCadre.style.width = 'auto';
  5071. sousCadre.style.fontSize = 'large';
  5072. sousCadre.style.border = 'solid 1px black';
  5073. sousCadre.style.backgroundColor = 'red';
  5074. grandCadre.appendChild(sousCadre);
  5075. }
  5076.  
  5077. function showHttpsErrorContenuMixte() {
  5078. window.console.log('[MZ] showHttpsErrorContenuMixte');
  5079. var grandCadre = createOrGetGrandCadre();
  5080. var sousCadre = document.createElement('div');
  5081. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5082. + '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)'
  5083. + '<ul>'
  5084. + '<li>Interface Bricol\'Troll</li>'
  5085. + '<li>Nouveautés de Mountyzilla</li>'
  5086. + '</ul>'
  5087. + '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 />'
  5088. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5089. sousCadre.style.width = 'auto';
  5090. sousCadre.style.fontSize = 'large';
  5091. sousCadre.style.border = 'solid 1px black';
  5092. grandCadre.appendChild(sousCadre);
  5093. }
  5094.  
  5095. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5096.  
  5097. function traiterJubilaires() {
  5098. // à faire
  5099. }
  5100.  
  5101. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5102. try {
  5103. FF_XMLHttpRequest({
  5104. method: 'GET',
  5105. url: URL_anniv,
  5106. headers: {
  5107. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5108. 'Accept': 'application/xml,text/xml',
  5109. },
  5110. onload: function(responseDetails) {
  5111. if ((responseDetails.status == 0) && isHTTPS) {
  5112. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5113. showHttpsErrorContenuMixte();
  5114. return;
  5115. }
  5116. var listeTrolls = responseDetails.responseText.split('\n');
  5117. if(!listeTrolls || listeTrolls.length==0) {
  5118. return;
  5119. }
  5120. afficherJubilaires(listeTrolls);
  5121. },
  5122. });
  5123. }
  5124. catch(e) {
  5125. if (isHTTPS) {
  5126. window.console.log(traceStack(e, 'appel jubilaires'));
  5127. showHttpsErrorContenuMixte();
  5128. } else {
  5129. window.alert('Erreur Jubilaires:\n'+e);
  5130. }
  5131. }
  5132. }
  5133.  
  5134. function afficherJubilaires(listeTrolls) {
  5135. try {
  5136. var rappels = document.evaluate(
  5137. "//p[contains(a/text(),'messagerie')]",
  5138. document, null, 9, null).singleNodeValue;
  5139. }
  5140. catch(e) {
  5141. return;
  5142. }
  5143. var p = document.createElement('p');
  5144. var tbody = appendTitledTable(p,
  5145. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5146. 'Envoyez leur un message ou un cadeau !'
  5147. );
  5148. tr = appendTr(tbody,'mh_tdpage');
  5149. td = appendTdCenter(tr);
  5150. var small = document.createElement('small');
  5151. td.appendChild(small);
  5152. var first = true;
  5153. for(var i=0 ; i<listeTrolls.length ; i++) {
  5154. var infos = listeTrolls[i].split(';');
  5155. if(infos.length!=3 || infos[2]==='0') {
  5156. continue;
  5157. }
  5158. if(first) {
  5159. first = false;
  5160. }
  5161. else {
  5162. appendText(small,', ');
  5163. }
  5164. var a = document.createElement('a');
  5165. a.href = 'javascript:EPV('+infos[0]+')';
  5166. appendText(a,infos[1]);
  5167. small.appendChild(a);
  5168. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5169. }
  5170. insertBefore(rappels,p);
  5171. }
  5172.  
  5173.  
  5174. /*-[functions]--------------------- News MZ ----------------------------------*/
  5175.  
  5176. function traiterNouvelles() {
  5177. var news = new Array;
  5178. 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 ;).']);
  5179. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5180. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5181. 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']);
  5182. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5183. afficherNouvelles(news);
  5184. }
  5185.  
  5186. function afficherNouvelles(items) {
  5187. var footer = document.getElementById('footer1');
  5188. if(!footer) {
  5189. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5190. return;
  5191. }
  5192. var p = document.createElement('p');
  5193. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5194. var div = document.createElement('div');
  5195. div.style.position = 'absolute';
  5196. div.style.right = 0;
  5197. div.style.top = 0;
  5198. div.style.paddingRight = '3px';
  5199. div.style.whiteSpace = 'nowrap';
  5200. appendText(div, '(version ' + GM_info.script.version + ')');
  5201. tbody.rows[0].cells[0].style.position = 'relative';
  5202. tbody.rows[0].cells[0].appendChild(div);
  5203. for(var i=0 ; i<items.length ; i++) {
  5204. var tr = appendTr(tbody,'mh_tdpage');
  5205. var td = appendTdCenter(tr);
  5206. td.style.verticalAlign = 'top'; // semble sans effet
  5207. appendText(td,items[i][0],true);
  5208. td = appendTd(tr);
  5209. td.innerHTML = items[i][1];
  5210. }
  5211. insertBefore(footer,p);
  5212.  
  5213. // changelog
  5214. var p = document.createElement('p');
  5215. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5216. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5217. tbody.rows[0].cells[0].onclick = function() {
  5218. try {
  5219. tbody.rows[0].cells[0].onclick = undefined;
  5220. tbody.rows[0].cells[0].style.cursor = '';
  5221. var tr = appendTr(tbody,'mh_tdpage');
  5222. var td = appendTd(tr);
  5223. td.colSpan = 2;
  5224. var pre = document.createElement('pre');
  5225. appendText(pre,MZ_changeLog.join("\n"));
  5226. td.appendChild(pre);
  5227. } catch (e) {
  5228. window.console.log('[MZ] affichage changeLog', e);
  5229. }
  5230. };
  5231. insertBefore(footer,p);
  5232.  
  5233. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5234. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5235. if (isHTTPS) {
  5236. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5237. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5238. } else {
  5239. window.console.log('[MZ test] début switch to https');
  5240. window.sessionStorage.setItem('xxx', "test session trans https");
  5241. window.parent.xxx = "autre test";
  5242. var url = document.location.href;
  5243. window.console.log('[MZ test] url=' + url);
  5244. url = url.replace(/http:\/\//i, 'https://')
  5245. window.console.log('[MZ test] switched url=' + url);
  5246. document.location.href = url;
  5247. }
  5248. }
  5249. if (false) { // version par utilisation d'un IFrame en https
  5250. if (isHTTPS) {
  5251. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5252. //window.console.log('[MZ test] window.name=' + window.name);
  5253. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5254. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5255. var txt = window.name;
  5256. var tabtxt = txt.split(/µ/);
  5257. for (var i = 0; i < tabtxt.length; i++) {
  5258. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5259. }
  5260. } else {
  5261. var txt = '';
  5262. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5263. var k = localStorage.key(i);
  5264. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5265. txt += k + "£" + localStorage.getItem(k) + "µ";
  5266. }
  5267. var iframe = document.createElement('iframe');
  5268. var url = document.location.href;
  5269. //window.console.log('[MZ test] url=' + url);
  5270. url = url.replace(/http:\/\//i, 'https://')
  5271. //window.console.log('[MZ test] switched url=' + url);
  5272. //iframe.xxx = "truc en plume";
  5273. iframe.name = txt;
  5274. //window.xxx = "machin";
  5275. iframe.src = url;
  5276. //iframe.document.xxx = "truc en plume";
  5277. document.body.appendChild(iframe);
  5278. iframe.style.display = 'none';
  5279. }
  5280. }
  5281. }
  5282. }
  5283.  
  5284.  
  5285. /*---------------------------------- Main ------------------------------------*/
  5286.  
  5287. function do_news() {
  5288. start_script();
  5289.  
  5290. traiterJubilaires();
  5291. traiterNouvelles();
  5292.  
  5293. if (isHTTPS) {
  5294. // test si les certificats raistlin ont été acceptés
  5295. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5296. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5297. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5298. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5299. }
  5300. }
  5301.  
  5302. displayScriptTime();
  5303. }
  5304.  
  5305. /*********************************************************************************
  5306. * This file is part of Mountyzilla. *
  5307. * *
  5308. * Mountyzilla is free software; you can redistribute it and/or modify *
  5309. * it under the terms of the GNU General Public License as published by *
  5310. * the Free Software Foundation; either version 2 of the License, or *
  5311. * (at your option) any later version. *
  5312. * *
  5313. * Mountyzilla is distributed in the hope that it will be useful, *
  5314. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5315. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5316. * GNU General Public License for more details. *
  5317. * *
  5318. * You should have received a copy of the GNU General Public License *
  5319. * along with Mountyzilla; if not, write to the Free Software *
  5320. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5321. *********************************************************************************/
  5322.  
  5323. // x~x tabcompo
  5324.  
  5325. var popup;
  5326.  
  5327. function initPopupTabcompo() {
  5328. popup = document.createElement('div');
  5329. popup.setAttribute('id', 'popup');
  5330. popup.setAttribute('class', 'mh_textbox');
  5331. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5332. + 'display: inline; z-index: 3; max-width: 400px;');
  5333. document.body.appendChild(popup);
  5334. }
  5335.  
  5336. function showPopup(evt) {
  5337. var texte = this.getAttribute("texteinfo");
  5338. popup.innerHTML = texte;
  5339. popup.style.left = evt.pageX + 15 + 'px';
  5340. popup.style.top = evt.pageY + 'px';
  5341. popup.style.visibility = "visible";
  5342. }
  5343.  
  5344. // roule 16/03/2016, existe déjà ailleurs
  5345. // function hidePopup() {
  5346. // popup.style.visibility = 'hidden';
  5347. // }
  5348.  
  5349. function createPopupImage(url, text)
  5350. {
  5351. var img = document.createElement('img');
  5352. img.setAttribute('src',url);
  5353. img.setAttribute('align','ABSMIDDLE');
  5354. img.setAttribute("texteinfo",text);
  5355. img.addEventListener("mouseover", showPopup,true);
  5356. img.addEventListener("mouseout", hidePopup,true);
  5357. return img;
  5358. }
  5359.  
  5360. function formateTexte(texte)
  5361. {
  5362. texte = texte.replace(/\n/g,"<br/>");
  5363. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5364. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5365. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5366. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5367. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5368. return texte;
  5369. }
  5370.  
  5371. function arrondi(x) {
  5372. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5373. }
  5374.  
  5375. function traiteMinerai() {
  5376. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5377. try {
  5378. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5379. +" and contains(./tr/th/text(),'Minerai')]",
  5380. document, null, 9, null).singleNodeValue;
  5381. node = node.nextSibling.nextSibling;
  5382. }
  5383. catch(e) {return;}
  5384. var trlist = document.evaluate('./tr', node, null, 7, null);
  5385. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5386. var node = trlist.snapshotItem(i);
  5387. var nature = node.childNodes[5].textContent;
  5388. var caracs = node.childNodes[7].textContent;
  5389. var taille = caracs.match(/\d+/)[0];
  5390. var coef = 1;
  5391. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5392. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5393. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5394. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5395. if (nature.indexOf('Mithril')!=-1) {
  5396. coef = 0.2*coef;
  5397. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5398. }
  5399. else {
  5400. coef = 0.75*coef+1.25;
  5401. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5402. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5403. }
  5404. }
  5405. }
  5406.  
  5407. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5408. function treateComposants() {
  5409. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5410. //On récupère les composants
  5411. var nodes = document.evaluate(
  5412. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5413. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5414. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5415. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5416. if (nodes.snapshotLength == 0) {
  5417. //window.console.log('[MZ] treateComposants DOWN');
  5418. return;
  5419. }
  5420. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5421.  
  5422. var texte = "";
  5423. for (var i = 0; i < nodes.snapshotLength; i++) {
  5424. var n1 = nodes.snapshotItem(i).childNodes[1];
  5425. var n3 = nodes.snapshotItem(i).childNodes[3];
  5426. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5427. var prix = n3.childNodes[0].nodeValue;
  5428. if (!prix)
  5429. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5430. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5431. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5432. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5433. + prix.replace(/\n/g, '') + "\n";
  5434. }
  5435.  
  5436. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5437. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5438. var id_taniere = c.snapshotItem(0).nodeValue;
  5439. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5440.  
  5441. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5442. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5443. if (form)
  5444. {
  5445. if(document.getElementsByTagName('form').length>0)
  5446. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5447. else
  5448. {
  5449. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5450. insertBefore(thisP, form);
  5451. }
  5452. }
  5453. }
  5454.  
  5455. function treateAllComposants() {
  5456. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5457. //On récupère les composants
  5458. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5459. document, null, 0, null ).numberValue;
  5460. var c = (categ == 0 ? 3 : 4);
  5461. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5462. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5463. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5464. + "td["+c+"]/text()[1] = '\240-\240' "
  5465. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5466. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5467. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5468. + "and td[1]/img/@alt = 'Identifié']",
  5469. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5470. if (nodes.snapshotLength == 0) {
  5471. // window.alert('treateAllComposants DOWN');
  5472. return;
  5473. }
  5474.  
  5475. var texte = "";
  5476. for (var i = 0; i < nodes.snapshotLength; i++) {
  5477. var n1 = nodes.snapshotItem(i).childNodes[1];
  5478. var n3 = nodes.snapshotItem(i).childNodes[3];
  5479. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5480. var prix = n3.childNodes[0].nodeValue;
  5481. if (!prix)
  5482. {
  5483. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5484. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5485. }
  5486. else
  5487. {
  5488. prix= prix.replace(/[\240 ]/g, "");
  5489. if(prix=="-")
  5490. prix=null;
  5491. }
  5492. if(prix)
  5493. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5494. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5495. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5496. + prix.replace(/\n/g, '') + "\n";
  5497. else
  5498. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5499. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5500. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5501. }
  5502.  
  5503. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5504. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5505. var id_taniere = c.snapshotItem(0).nodeValue;
  5506. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5507.  
  5508. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5509. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5510. if (form)
  5511. {
  5512. if(document.getElementsByTagName('form').length>0)
  5513. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5514. else
  5515. {
  5516. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5517. insertBefore(thisP, form);
  5518. }
  5519. }
  5520. }
  5521.  
  5522. function treateEM()
  5523. {
  5524. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  5525. if(currentURL.indexOf("as_type=Compo")==-1)
  5526. return false;
  5527. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  5528. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  5529. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5530. if (nodes.snapshotLength == 0)
  5531. return false;
  5532. for (var i = 0; i < nodes.snapshotLength; i++) {
  5533. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  5534. var link = desc[2].firstChild ;
  5535. var nomCompoTotal = desc[2].textContent ;
  5536. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5537. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5538. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  5539. var locqual = desc[3].textContent ;
  5540. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  5541. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  5542. if(isEM(nomMonstre).length>0)
  5543. {
  5544. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  5545. if(infos.length>0)
  5546. {
  5547. var shortDescr = "Variable";
  5548. var bold = 0;
  5549. if(infos != "Composant variable")
  5550. {
  5551. shortDescr = infos.substring(0,infos.indexOf(" "));
  5552. if(parseInt(shortDescr)>=0)
  5553. bold=1;
  5554. }
  5555. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  5556. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  5557. }
  5558. }
  5559. }
  5560. }
  5561.  
  5562. function treateChampi() {
  5563. if (currentURL.indexOf('as_type=Champi')==-1)
  5564. return false;
  5565. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  5566. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5567. if (nodes.snapshotLength == 0)
  5568. return false;
  5569.  
  5570. for (var i = 0; i < nodes.snapshotLength; i++) {
  5571. var node = nodes.snapshotItem(i);
  5572. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  5573. if (moisChampi[nomChampi])
  5574. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  5575. }
  5576. }
  5577.  
  5578. function treateEnchant()
  5579. {
  5580. if(currentURL.indexOf("as_type=Compo")==-1)
  5581. return false;
  5582. try
  5583. {
  5584. if(!listeMonstreEnchantement)
  5585. computeCompoEnchantement();
  5586. var nodes = document.evaluate(
  5587. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5588. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5589. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5590. if (nodes.snapshotLength == 0)
  5591. return false;
  5592. var urlImg = URL_MZimg + "enchant.png";
  5593. for (var i = 0; i < nodes.snapshotLength; i++) {
  5594. var link = nodes.snapshotItem(i);
  5595. var nomCompoTotal = link.firstChild.nodeValue;
  5596. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5597. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5598. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  5599. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  5600. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  5601. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  5602. if(isEnchant(nomMonstre).length>0)
  5603. {
  5604. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  5605. if(infos.length>0)
  5606. {
  5607. link.parentNode.appendChild(createImage(urlImg,infos));
  5608. }
  5609. }
  5610. }
  5611. }
  5612. catch(e)
  5613. {
  5614. window.alert(e);
  5615. }
  5616. }
  5617.  
  5618. function treateEquipEnchant()
  5619. {
  5620. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  5621. return false;
  5622. initPopupTabcompo();
  5623. computeEnchantementEquipement(createPopupImage,formateTexte);
  5624. }
  5625.  
  5626. function do_tancompo() {
  5627. start_script();
  5628.  
  5629. treateAllComposants();
  5630. treateComposants();
  5631. traiteMinerai();
  5632. if (MY_getValue('NOINFOEM')!='true') {
  5633. treateChampi();
  5634. treateEM();
  5635. }
  5636. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  5637. treateEnchant();
  5638. treateEquipEnchant();
  5639. }
  5640.  
  5641. displayScriptTime();
  5642. }
  5643.  
  5644. /*******************************************************************************
  5645. * This file is part of Mountyzilla. *
  5646. * *
  5647. * Mountyzilla is free software; you can redistribute it and/or modify *
  5648. * it under the terms of the GNU General Public License as published by *
  5649. * the Free Software Foundation; either version 2 of the License, or *
  5650. * (at your option) any later version. *
  5651. * *
  5652. * Mountyzilla is distributed in the hope that it will be useful, *
  5653. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5654. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5655. * GNU General Public License for more details. *
  5656. * *
  5657. * You should have received a copy of the GNU General Public License *
  5658. * along with Mountyzilla; if not, write to the Free Software *
  5659. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5660. *******************************************************************************/
  5661.  
  5662. // x~x pjview
  5663.  
  5664. /* TODO
  5665. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  5666. */
  5667.  
  5668. // Bulle d'infos
  5669. var DivInfo;
  5670. // Booléen stockant l'état de freezing de la bulle
  5671. var freezed = false;
  5672.  
  5673. // liste du matos
  5674. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  5675. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5676. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  5677. var mh_caracs = {
  5678. 'anneau de protection':
  5679. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  5680. "armure d'anneaux":
  5681. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  5682. 'armure de bois':
  5683. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  5684. 'armure de cuir':
  5685. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  5686. 'armure de peaux':
  5687. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  5688. 'armure de pierre':
  5689. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  5690. 'armure de plates':
  5691. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  5692. 'baton lesté':
  5693. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5694. 'bâtons de parade':
  5695. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5696. 'bottes':
  5697. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5698. 'bouclier à pointes':
  5699. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5700. 'boulet et chaîne':
  5701. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5702. 'cagoule':
  5703. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  5704. 'casque à cornes':
  5705. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5706. 'casque à pointes':
  5707. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  5708. 'casque en cuir':
  5709. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  5710. 'casque en métal':
  5711. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5712. 'chaîne cloutée':
  5713. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5714. 'chapeau pointu':
  5715. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  5716. 'collier de dents':
  5717. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  5718. 'collier de pierre':
  5719. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5720. 'collier à pointes':
  5721. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5722. 'cotte de mailles':
  5723. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5724. 'couronne de cristal':
  5725. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5726. "couronne d'obsidienne":
  5727. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5728. "coutelas d'obsidienne":
  5729. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5730. 'coutelas en os':
  5731. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5732. 'crochet':
  5733. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5734. 'cuir bouilli':
  5735. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5736. "cuirasse d'ossements":
  5737. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5738. "cuirasse d'écailles":
  5739. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5740. 'culotte en cuir':
  5741. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5742. 'dague':
  5743. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5744. 'epée courte':
  5745. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5746. 'epée longue':
  5747. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5748. 'espadon':
  5749. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5750. 'fouet':
  5751. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5752. 'fourrures':
  5753. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5754. 'gantelet':
  5755. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5756. 'gorgeron en cuir':
  5757. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5758. 'gorgeron en métal':
  5759. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5760. 'gourdin':
  5761. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5762. 'gourdin clouté':
  5763. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5764. 'grimoire':
  5765. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5766. "gros'porte":
  5767. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5768. 'grosse racine':
  5769. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5770. 'grosse stalagmite':
  5771. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5772. 'hache de bataille':
  5773. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5774. 'hache de guerre en os':
  5775. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5776. 'hache de guerre en pierre':
  5777. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5778. "hache à deux mains d'obsidienne":
  5779. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5780. 'hallebarde':
  5781. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5782. "haubert d'écailles":
  5783. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5784. 'haubert de mailles':
  5785. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5786. 'heaume':
  5787. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5788. 'jambières en cuir':
  5789. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5790. 'jambières en fourrure':
  5791. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5792. 'jambières en maille':
  5793. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5794. 'jambières en métal':
  5795. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5796. 'jambières en os':
  5797. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5798. "lame d'obsidienne":
  5799. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5800. 'lame en os':
  5801. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5802. 'lame en pierre':
  5803. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5804. 'lorgnons':
  5805. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5806. 'machette':
  5807. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5808. "masse d'arme":
  5809. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5810. 'pagne de mailles':
  5811. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5812. 'pagne en cuir':
  5813. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5814. 'robe de mage':
  5815. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5816. 'rondache en bois':
  5817. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5818. 'rondache en métal':
  5819. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5820. 'sandales':
  5821. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5822. 'souliers dorés':
  5823. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5824. "talisman d'obsidienne":
  5825. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5826. 'talisman de pierre':
  5827. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5828. 'targe':
  5829. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5830. 'torche':
  5831. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5832. 'torque de pierre':
  5833. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5834. 'tunique':
  5835. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5836. "tunique d'écailles":
  5837. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5838. 'turban':
  5839. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5840. }
  5841.  
  5842. // liste des templates
  5843. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5844. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5845. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5846. var mh_templates = {
  5847. 'de Feu':
  5848. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5849. 'de Résistance':
  5850. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5851. "de l'Aigle":
  5852. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5853. 'de la Salamandre':
  5854. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5855. 'des Cyclopes':
  5856. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5857. 'des Enragés':
  5858. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5859. 'des Tortues':
  5860. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5861. 'des Vampires':
  5862. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5863. 'du Glacier':
  5864. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5865. 'du Rat':
  5866. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5867. 'du Roc':
  5868. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5869. 'du Temps':
  5870. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5871. 'du Vent':
  5872. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5873. 'en Mithril':
  5874. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5875. 'des Anciens':
  5876. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5877. 'des Champions':
  5878. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5879. 'des Duellistes':
  5880. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5881. 'de la Terre':
  5882. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5883. "de l'Orage":
  5884. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5885. "de l'Ours":
  5886. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5887. 'des Béhémoths':
  5888. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5889. 'des Mages':
  5890. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5891. 'du Pic':
  5892. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5893. 'du Sable':
  5894. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5895. 'acéré':
  5896. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5897. 'acérée':
  5898. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5899. 'équilibré':
  5900. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5901. 'équilibrée':
  5902. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5903. 'léger':
  5904. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5905. 'légère':
  5906. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5907. 'renforcé':
  5908. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5909. 'renforcée':
  5910. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5911. 'robuste':
  5912. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5913. }
  5914.  
  5915. function clone(arr) {
  5916. // Clonage rapide
  5917. return arr.slice(0);
  5918. }
  5919.  
  5920. function addArray(arr1,arr2) {
  5921. // Somme matricielle
  5922. var res = clone(arr1);
  5923. for(i=res.length-1 ; i>=0 ; i--) {
  5924. res[i] += arr2[i];
  5925. }
  5926. return res;
  5927. }
  5928.  
  5929. function getTemplates(nomItem) {
  5930. // Déstructure le nom de l'item en array [nom, template1, ...]
  5931. var tempFound = true;
  5932. var str = nomItem.trim();
  5933. var arr = [];
  5934. while(tempFound) {
  5935. tempFound = false;
  5936. for(var temp in mh_templates) {
  5937. // on teste la fin du nom contre chaque template
  5938. if(str.slice(-temp.length)!=temp) { continue; }
  5939. tempFound = true;
  5940. str = str.slice(0,-temp.length-1);
  5941. arr.unshift(temp);
  5942. if(str.slice(-3)==' et') {
  5943. str = str.slice(0,-3);
  5944. }
  5945. }
  5946. }
  5947. arr.unshift(str);
  5948. return arr;
  5949. }
  5950.  
  5951. function addMithril(arrayCaracs,typeItem) {
  5952. // Ajoute l'effet du Mithril sur les caracs
  5953. if(typeItem=='arme') {
  5954. if(arrayCaracs[0]<0) {
  5955. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5956. }
  5957. }
  5958. else {
  5959. if(arrayCaracs[4]<0) {
  5960. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5961. }
  5962. }
  5963. arrayCaracs[15] /= 2;
  5964. arrayCaracs[16] /= 2;
  5965. return arrayCaracs;
  5966. }
  5967.  
  5968. function addRenfort(arrayCaracs,template) {
  5969. // Ajoute l'effet des pseudo-templates sur les caracs
  5970. // S'applique APRÈS le mithril
  5971. // WARNING - Cette formule n'a rien d'officiel, gare !
  5972. var coef = 0;
  5973. if(/^lég[e,è]re?$/.test(template)) {
  5974. coef = -1;
  5975. }
  5976. else if(/^renforcée?$/.test(template)
  5977. || template==='robuste') {
  5978. coef = 1;
  5979. }
  5980. if(coef) {
  5981. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5982. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5983. }
  5984. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5985. return arrayCaracs;
  5986. }
  5987.  
  5988. function getCaracs(item) {
  5989. // Calcule les caractéristiques de l'item
  5990. var templates = getTemplates(item);
  5991. if(!mh_caracs[templates[0]]) {
  5992. // Si l'item est inconnu
  5993. return [];
  5994. }
  5995. var caracs = clone(mh_caracs[templates[0]]);
  5996. var typeItem = caracs[0];
  5997. caracs.shift();
  5998. templates.shift();
  5999. if(templates[templates.length-1]=='en Mithril') {
  6000. caracs = addMithril(caracs,typeItem);
  6001. templates.pop();
  6002. }
  6003. if(/^acérée?$/.test(templates[0])
  6004. || /^équilibrée?$/.test(templates[0])
  6005. || /^lég[e,è]re?$/.test(templates[0])
  6006. || /^renforcée?$/.test(templates[0])
  6007. || templates[0]=='robuste') {
  6008. caracs = addRenfort(caracs,templates[0]);
  6009. templates.shift();
  6010. }
  6011. for(var i=templates.length-1 ; i>=0 ; i--) {
  6012. caracs = addArray(caracs,mh_templates[templates[i]]);
  6013. }
  6014. return caracs;
  6015. }
  6016.  
  6017. function getLine(tab) {
  6018. // Préparation de la ligne à afficher lors d'un mouseover
  6019. var str = '';
  6020. if(tab[0]!=0 || tab[1]!=0) {
  6021. str += '<b>Att : </b>'+aff(tab[0]);
  6022. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  6023. str += ' | ';
  6024. }
  6025. if(tab[4]!=0) {
  6026. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  6027. }
  6028. if(tab[2]!=0 || tab[3]!=0) {
  6029. str += '<b>Deg : </b>'+aff(tab[2]);
  6030. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  6031. str += ' | ';
  6032. }
  6033. if(tab[8]!=0) {
  6034. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  6035. }
  6036. if(tab[7]!=0) {
  6037. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  6038. }
  6039. if(tab[5]!=0 || tab[6]!=0) {
  6040. str += '<b>Arm : </b>'+aff(tab[5]);
  6041. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  6042. str += ' | ';
  6043. }
  6044. if(tab[9]!=0 || tab[10]!=0) {
  6045. str += '<b>RM : </b>'+aff(tab[9])+'%';
  6046. if(tab[9]!=tab[10]) {
  6047. str += '/'+aff(tab[10])+'%';
  6048. }
  6049. str += ' | ';
  6050. }
  6051. if(tab[11]!=0 || tab[12]!=0) {
  6052. str += '<b>MM : </b>'+aff(tab[11])+'%';
  6053. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  6054. str += ' | ';
  6055. }
  6056. if(tab[13]!=0) {
  6057. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  6058. }
  6059. if(tab[14]!=0) {
  6060. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  6061. }
  6062. str += '<b>Poids : </b>'+tab[15]+' min';
  6063. if(tab[15]!=tab[16]) {
  6064. str += ' / '+tab[16]+' min';
  6065. }
  6066. return str;
  6067. }
  6068.  
  6069. function toolTipInit() {
  6070. DivInfo = document.createElement('div');
  6071. DivInfo.id = 'infosVue';
  6072. DivInfo.className = 'mh_textbox';
  6073. DivInfo.style =
  6074. 'position: absolute;'
  6075. +'border: 1px solid #000000;'
  6076. +'visibility:hidden;'
  6077. +'display:inline;'
  6078. +'z-index:99;';
  6079. document.body.appendChild(DivInfo);
  6080. document.onmousemove = getXY;
  6081. document.onclick = changeFreezeStatus;
  6082. }
  6083.  
  6084. function getXY(evt) {
  6085. if(!freezed && DivInfo.style.visibility=='visible') {
  6086. DivInfo.style.left = evt.pageX+'px';
  6087. DivInfo.style.top = evt.pageY+10+'px';
  6088. }
  6089. }
  6090.  
  6091. function changeFreezeStatus() {
  6092. if(DivInfo.style.visibility=='visible') {
  6093. freezed = !freezed;
  6094. if(!freezed) { hideInfos(); }
  6095. }
  6096. }
  6097.  
  6098. function showInfos() {
  6099. if(freezed) { return; }
  6100. var currentInfos = this.infos;
  6101. DivInfo.innerHTML = currentInfos;
  6102. DivInfo.style.visibility = 'visible';
  6103. }
  6104.  
  6105. function hideInfos() {
  6106. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6107. }
  6108.  
  6109. function treateEquipement() {
  6110. // Extrait les données du matos et réinjecte les infos déduites
  6111. if(MY_getValue('INFOCARAC')=='false') { return; }
  6112. var faireLigne = false;
  6113. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6114. var nodes = document.evaluate(
  6115. "//td/b[text()='Equipement Utilisé']/../../"
  6116. +"td[2]/img[contains(@src,bullet)]",
  6117. document, null, 7, null);
  6118. if(nodes.snapshotLength>0) {
  6119. // Si CSS de base
  6120. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6121. var node = nodes.snapshotItem(i);
  6122. var next = node.nextSibling;
  6123. var nnext = next.nextSibling;
  6124. var nom = next.nodeValue.toLowerCase();
  6125. if(nnext.childNodes.length==1) {
  6126. nom += nnext.firstChild.nodeValue;
  6127. }
  6128. nom = nom.trim();
  6129. // gestion winpostrophe
  6130. var c = String.fromCharCode(180);
  6131. while(nom.indexOf(c)!=-1) {
  6132. nom = nom.replace(c,"'");
  6133. }
  6134. var arr = getCaracs(nom);
  6135. if(arr.length>0) {
  6136. faireLigne = true;
  6137. caracs = addArray(caracs,arr);
  6138. var span = document.createElement('span');
  6139. span.appendChild(next);
  6140. span.appendChild(nnext);
  6141. span.infos = getLine(arr);
  6142. span.onmouseover = showInfos;
  6143. span.onmouseout = hideInfos;
  6144. insertBefore(node.nextSibling,span);
  6145. }
  6146. }
  6147. if(faireLigne) {
  6148. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6149. document, null, 9, null).singleNodeValue;
  6150. node.infos = getLine(caracs);
  6151. node.onmouseover = showInfos;
  6152. node.onmouseout = hideInfos;
  6153. }
  6154. }
  6155. else {
  6156. // Si CSS avancée
  6157. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6158. document, null, 7, null);
  6159. if(nodes.snapshotLength>0) {
  6160. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6161. var node = nodes.snapshotItem(i);
  6162. var nom = node.firstChild.nodeValue.toLowerCase();
  6163. if(node.childNodes.length>1) {
  6164. nom += node.childNodes[1].firstChild.nodeValue;
  6165. }
  6166. nom = nom.trim();
  6167. // gestion winpostrophe
  6168. var c = String.fromCharCode(180);
  6169. while(nom.indexOf(c)!=-1) {
  6170. nom = nom.replace(c,"'");
  6171. }
  6172. var arr = getCaracs(nom);
  6173. if(arr.length!=0) {
  6174. caracs = addArray(caracs,arr);
  6175. node.infos = getLine(arr);
  6176. node.onmouseover = showInfos;
  6177. node.onmouseout = hideInfos;
  6178. }
  6179. }
  6180. var nodes = document.evaluate("//dt[@class='equipement']",
  6181. document, null, 7, null);
  6182. var node = nodes.snapshotItem(0);
  6183. node.infos = getLine(caracs);
  6184. node.onmouseover = showInfos;
  6185. node.onmouseout = hideInfos;
  6186. }
  6187. }
  6188. }
  6189.  
  6190. function do_pjview() {
  6191. treateEquipement();
  6192. toolTipInit();
  6193. }
  6194.  
  6195. /*******************************************************************************
  6196. * This file is part of Mountyzilla. *
  6197. * *
  6198. * Mountyzilla is free software; you can redistribute it and/or modify *
  6199. * it under the terms of the GNU General Public License as published by *
  6200. * the Free Software Foundation; either version 2 of the License, or *
  6201. * (at your option) any later version. *
  6202. * *
  6203. * Mountyzilla is distributed in the hope that it will be useful, *
  6204. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6205. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6206. * GNU General Public License for more details. *
  6207. * *
  6208. * You should have received a copy of the GNU General Public License *
  6209. * along with Mountyzilla; if not, write to the Free Software *
  6210. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6211. *******************************************************************************/
  6212.  
  6213. // x~x option
  6214.  
  6215. /* TODO
  6216. * Passer le HTML injecté aux conventions HTML5
  6217. */
  6218.  
  6219.  
  6220. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6221.  
  6222. function saveITData() {
  6223. var IT = document.getElementById('itSelect').value;
  6224. if(IT=='bricol') {
  6225. var system = document.getElementById('urlbricol').value;
  6226. var login = document.getElementById('loginbricol').value;
  6227. var pass = document.getElementById('passbricol').value;
  6228. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6229. if(system && login) {
  6230. if (pass) {
  6231. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6232. MY_setValue(numTroll+'.INFOSIT', v);
  6233. //window.console.log('v=' + v);
  6234. } else {
  6235. // vérif que rien n'a changé
  6236. var str = MY_getValue(numTroll+'.INFOSIT');
  6237. if(str) {
  6238. var arr = str.split('$');
  6239. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6240. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  6241. }
  6242. }
  6243. }
  6244. }
  6245. }
  6246. else {
  6247. MY_removeValue(numTroll+'.INFOSIT');
  6248. }
  6249. }
  6250.  
  6251. function saveLinks() {
  6252. var numLinks = document.getElementById('linksBody').childNodes.length;
  6253. var data=[ [] ];
  6254. /* Récupération et tri des liens */
  6255. for(var i=1 ; i<=numLinks ; i++) {
  6256. MY_removeValue('URL'+i);
  6257. MY_removeValue('URL'+i+'.nom');
  6258. MY_removeValue('URL'+i+'.ico');
  6259. var url = document.getElementById('url'+i).value;
  6260. var nom = document.getElementById('nom'+i).value;
  6261. var ico = document.getElementById('ico'+i).value;
  6262. if(url && (nom || ico) ) {
  6263. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6264. }
  6265. }
  6266. /* Sauvegarde */
  6267. for(var i=1 ; i<data.length ; i++) {
  6268. MY_setValue('URL'+i,data[i][0]);
  6269. MY_setValue('URL'+i+'.nom',data[i][1]);
  6270. MY_setValue('URL'+i+'.ico',data[i][2]);
  6271. }
  6272. }
  6273.  
  6274. function saveAll() {
  6275. var urlIco = document.getElementById('icoMenuIco').value;
  6276. if(urlIco) {
  6277. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6278. }
  6279. else {
  6280. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6281. document.getElementById('icoMenuIco').value = '';
  6282. }
  6283. saveLinks();
  6284. refreshLinks();
  6285. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6286. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6287. if(maxcdm) {
  6288. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6289. }
  6290. else {
  6291. MY_removeValue(numTroll+'.MAXCDM');
  6292. document.getElementById('maxcdm').value = '';
  6293. }
  6294.  
  6295. MY_setValue('NOINFOEM',
  6296. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6297. // Pourquoi Tilk stockait-il tout en str ?
  6298. // -> parce que les booléens c'est foireux (vérifié)
  6299. MY_setValue(numTroll+'.USECSS',
  6300. document.getElementById('usecss').checked ? 'true':'false');
  6301. MY_setValue('INFOCARAC',
  6302. document.getElementById('infocarac').checked ? 'true' : 'false');
  6303. //MY_setValue(numTroll+'.SEND_IDT',
  6304. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6305. // Fonctionnalité désactivée
  6306.  
  6307. MY_setValue(numTroll+'.AUTOCDM',
  6308. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6309. MY_setValue('VUECARAC',
  6310. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6311. MY_setValue('CONFIRMEDECALAGE',
  6312. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6313.  
  6314. saveITData();
  6315. var bouton = document.getElementById('saveAll');
  6316. bouton.value = (bouton.value=='Sauvegardé !') ?
  6317. 'Re-sauvegardé !' : 'Sauvegardé !';
  6318. }
  6319.  
  6320.  
  6321. /*-[functions]----------------- EventListeners -------------------------------*/
  6322.  
  6323. function onChangeIT() {
  6324. var IT = document.getElementById('itSelect').value;
  6325. var itBody = document.getElementById('itBody');
  6326. itBody.innerHTML = '';
  6327. if(IT=='bricol') {
  6328. var tr = appendTr(itBody,'mh_tdpage')
  6329. var td = appendTd(tr);
  6330. var str = MY_getValue(numTroll+'.INFOSIT');
  6331. //window.console.log('onChangeIT str=' + str);
  6332. if(str) {
  6333. var arr = str.split('$');
  6334. var system = arr[1];
  6335. var login = arr[2];
  6336. var affhv = arr[4];
  6337. }
  6338. appendText(td,'Nom du système : ');
  6339. appendTextbox(td,'text','urlbricol',20,50,system);
  6340. td = appendTd(tr);
  6341. appendText(td,'Login du compte : ');
  6342. appendTextbox(td,'text','loginbricol',20,50,login);
  6343. td = appendTd(tr);
  6344. appendText(td,'Mot de passe du compte : ');
  6345. appendTextbox(td,'password','passbricol',20,50);
  6346. td = appendTd(tr);
  6347. appendText(td,'Affichage des Trõlls hors vue : ');
  6348. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  6349. appendCheckBox(td,'affhvbricol', (affhv>0));
  6350. }
  6351. }
  6352.  
  6353. function refreshLinks() {
  6354. document.getElementById('linksBody').innerHTML = '';
  6355. var anotherURL = MY_getValue('URL1');
  6356. if(!anotherURL) { addLinkField(); }
  6357. var i=1;
  6358. while(anotherURL && i<99) {
  6359. addLinkField(i,anotherURL,
  6360. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6361. i++;
  6362. anotherURL = MY_getValue('URL'+i);
  6363. }
  6364. }
  6365.  
  6366. function addLinkField(i,url,nom,ico) {
  6367. var linksBody = document.getElementById('linksBody');
  6368. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6369. var tr = appendTr(linksBody);
  6370. var td = appendTdCenter(tr);
  6371. appendText(td,'Lien '+i+' : ');
  6372. appendTextbox(td,'text','url'+i,40,150,url);
  6373. td = appendTdCenter(tr);
  6374. appendText(td,'Nom : ');
  6375. appendTextbox(td,'text','nom'+i,20,150,nom);
  6376. td = appendTdCenter(tr);
  6377. appendText(td,'Icône : ');
  6378. appendTextbox(td,'text','ico'+i,40,150,ico);
  6379. }
  6380.  
  6381. function removeLinkField() {
  6382. var linksBody = document.getElementById('linksBody');
  6383. var i = linksBody.childNodes.length;
  6384. MY_removeValue('URL'+i);
  6385. MY_removeValue('URL'+i+'.nom');
  6386. MY_removeValue('URL'+i+'.ico');
  6387. linksBody.removeChild(linksBody.lastChild);
  6388. if(linksBody.childNodes.length==0) { addLinkField(); }
  6389. }
  6390.  
  6391. function resetMainIco() {
  6392. document.getElementById('icoMenuIco').value=
  6393. URL_MZimg + 'mz_logo_small.png';
  6394. }
  6395.  
  6396.  
  6397. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6398.  
  6399. function insertTitle(next,txt) {
  6400. var div = document.createElement('div');
  6401. div.className = 'titre2';
  6402. appendText(div,txt);
  6403. insertBefore(next,div);
  6404. return div;
  6405. }
  6406.  
  6407. function insertMainTable(next) {
  6408. var table = document.createElement('table');
  6409. table.width = '98%';
  6410. table.border = 0;
  6411. table.align = 'center';
  6412. table.cellPadding = 2;
  6413. table.cellSpacing = 1;
  6414. table.className = 'mh_tdborder';
  6415. var tbody = document.createElement('tbody');
  6416. table.appendChild(tbody);
  6417. insertBefore(next,table);
  6418. return tbody;
  6419. }
  6420.  
  6421. function appendSubTable(node) {
  6422. var table = document.createElement('table');
  6423. table.width = '100%';
  6424. var tbody = document.createElement('tbody');
  6425. table.appendChild(tbody);
  6426. node.appendChild(table);
  6427. return tbody;
  6428. }
  6429.  
  6430. function insertOptionTable(insertPt) {
  6431. var mainBody = insertMainTable(insertPt);
  6432. /* Liens dans le Menu */
  6433. var tr = appendTr(mainBody,'mh_tdtitre');
  6434. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6435. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6436. appendText(td,'Icône du Menu: ');
  6437. var url = MY_getValue(numTroll+'.ICOMENU');
  6438. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6439. url = URL_MZimg + 'mz_logo_small.png';
  6440. }
  6441. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6442. appendButton(td,'Réinitialiser',resetMainIco);
  6443. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6444. var tbody = appendSubTable(td);
  6445. tbody.id = 'linksBody';
  6446. refreshLinks();
  6447. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6448. appendButton(td,'Ajouter',addLinkField);
  6449. appendButton(td,'Supprimer',removeLinkField);
  6450. /* Options de la Vue : vue externe, nb de CdM, etc */
  6451. tr = appendTr(mainBody,'mh_tdtitre');
  6452. appendTdText(tr,'Options de la Vue :',true);
  6453. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6454. tbody = appendSubTable(td);
  6455. tr = appendTr(tbody);
  6456. td = appendTdText(tr,'Vue externe : ');
  6457. var select = document.createElement('select');
  6458. select.id = 'vueext';
  6459. td.appendChild(select);
  6460. var listeVues2D = [
  6461. 'Bricol\' Vue',
  6462. 'Vue du CCM',
  6463. 'Vue Gloumfs 2D',
  6464. 'Vue Gloumfs 3D',
  6465. 'Grouky Vue!'
  6466. ];
  6467. for(var i=0 ; i<listeVues2D.length ; i++) {
  6468. appendOption(select,listeVues2D[i],listeVues2D[i]);
  6469. }
  6470. if(MY_getValue('VUEEXT')) {
  6471. select.value = MY_getValue('VUEEXT');
  6472. }
  6473. td = appendTd(tr);
  6474. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  6475. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  6476. tr = appendTr(tbody);
  6477. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  6478. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  6479. td = appendTd(tr);
  6480. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  6481. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  6482. /* Interface Tactique */
  6483. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6484. appendText(td,'Interface Tactique : ',true);
  6485. select = document.createElement('select');
  6486. select.id = 'itSelect';
  6487. appendOption(select,'none','Aucune');
  6488. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  6489. // seule interface supportée !
  6490. td.appendChild(select);
  6491. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6492. tbody = appendSubTable(td);
  6493. tbody.id = 'itBody';
  6494. select.onchange = onChangeIT;
  6495. var str = MY_getValue(numTroll+'.INFOSIT');
  6496. if(str) {
  6497. select.value = str.slice(0,str.indexOf('$'));
  6498. onChangeIT();
  6499. }
  6500. /* Options diverses */
  6501. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6502. appendText(td,'Options diverses :',true);
  6503. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6504. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  6505. appendText(td,
  6506. ' Afficher les caractéristiques des équipements des autres Trõlls');
  6507. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6508. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  6509. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  6510. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6511. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  6512. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  6513. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6514. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  6515. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  6516. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6517. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  6518. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  6519. /* Bouton SaveAll */
  6520. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  6521. input = appendButton(td,'Sauvegarder',saveAll);
  6522. input.id = 'saveAll';
  6523. }
  6524.  
  6525. function insertCreditsTable(insertPt) {
  6526. var tbody = insertMainTable(insertPt);
  6527. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  6528. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  6529. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  6530.  
  6531. var ul = document.createElement('ul');
  6532. td.appendChild(ul);
  6533. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  6534. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  6535. appendLI(ul,'Reivax (4234) pour les infos bulles');
  6536. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  6537. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  6538. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  6539. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  6540. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  6541. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  6542. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  6543. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  6544. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  6545. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  6546. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  6547. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  6548. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  6549. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  6550. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  6551. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  6552. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  6553. }
  6554.  
  6555.  
  6556. /* [functions] Obsolètes */
  6557. function deleteEnchantement()
  6558. {
  6559. try
  6560. {
  6561. var idEquipement = this.getAttribute('name');
  6562. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  6563. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  6564. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  6565. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  6566. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  6567. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6568. var string = "";
  6569. for(var i=0;i<listeEquipement.length;i++)
  6570. {
  6571. if(listeEquipement[i]!=idEquipement)
  6572. if(string=="")
  6573. string = listeEquipement[i];
  6574. else
  6575. string += ";"+listeEquipement[i];
  6576. }
  6577. if(string=="")
  6578. {
  6579. MY_removeValue(numTroll+".enchantement.liste");
  6580. var table = this.parentNode.parentNode.parentNode.parentNode;
  6581. var parent = table.parentNode;
  6582. for(var i=0;i<parent.childNodes.length;i++)
  6583. {
  6584. if(parent.childNodes[i]==table)
  6585. {
  6586. parent.removeChild(parent.childNodes[i-1]);
  6587. parent.removeChild(parent.childNodes[i-1]);
  6588. parent.removeChild(parent.childNodes[i-1]);
  6589. break;
  6590. }
  6591. }
  6592. }
  6593. else
  6594. {
  6595. MY_getValue(numTroll+".enchantement.liste",string);
  6596. this.parentNode.parentNode.parentNode
  6597. .removeChild(this.parentNode.parentNode);
  6598. }
  6599. }
  6600. catch(e)
  6601. {
  6602. window.alert(e);
  6603. }
  6604. }
  6605. /* [functions] fin Obsolètes */
  6606.  
  6607. /*-[functions]---------------- Partie principale -----------------------------*/
  6608.  
  6609. function do_option() {
  6610. start_script(712);
  6611. var insertPoint = document.getElementById('footer1');
  6612. insertBefore(insertPoint,document.createElement('p'));
  6613. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  6614. ti.onclick = function (e) {
  6615. var evt = e || window.event;
  6616. if (!evt.shiftKey) return;
  6617. var txt = '';
  6618. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6619. var k = localStorage.key(i);
  6620. if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6621. txt += k + "\t" + localStorage.getItem(k) + "\n";
  6622. }
  6623. copyTextToClipboard(txt);
  6624. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  6625. }
  6626. ti.title = 'Version ' + GM_info.script.version;
  6627. insertOptionTable(insertPoint);
  6628. /* insertion enchantements ici
  6629. if(...)
  6630. insertEnchantementTable();
  6631. */
  6632. insertBefore(insertPoint,document.createElement('p'));
  6633. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  6634. ti.onclick = function (e) {
  6635. var evt = e || window.event;
  6636. if (!evt.shiftKey) return;
  6637. var oldDev = MY_getValue('MZ_dev');
  6638. if (oldDev) {
  6639. MY_removeValue('MZ_dev');
  6640. } else {
  6641. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  6642. MY_setValue('MZ_dev', 1);
  6643. }
  6644. document.location.href = document.location.href;
  6645. }
  6646. insertCreditsTable(insertPoint);
  6647. insertBefore(insertPoint,document.createElement('p'));
  6648.  
  6649. /* [zone] Obsolète ?? */
  6650. if(MY_getValue(numTroll+".enchantement.liste")
  6651. && MY_getValue(numTroll+".enchantement.liste")!="" )
  6652. {
  6653. insertTitle(insertPoint, 'Les Enchantements en cours');
  6654. table = document.createElement('table');
  6655. table.setAttribute('width', '98%');
  6656. table.setAttribute('border', '0');
  6657. table.setAttribute('align', 'center');
  6658. table.setAttribute('cellpadding', '2');
  6659. table.setAttribute('cellspacing', '1');
  6660. table.setAttribute('class', 'mh_tdborder');
  6661.  
  6662. tbody = document.createElement('tbody');
  6663. table.appendChild(tbody);
  6664. tr = appendTr(tbody, 'mh_tdtitre');
  6665. appendTdText(tr, 'Equipement',1);
  6666. appendTdText(tr, 'Composants',1);
  6667. appendTdText(tr, 'Enchanteur',1);
  6668. appendTdText(tr, 'Action',1);
  6669. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6670. for(var i=0;i<listeEquipement.length;i++)
  6671. {
  6672. try
  6673. {
  6674. var idEquipement = listeEquipement[i];
  6675. var nomEquipement = MY_getValue(numTroll+".enchantement."
  6676. +idEquipement+".objet");
  6677. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  6678. +idEquipement+".enchanteur").split(";");
  6679. var ul = document.createElement('UL');
  6680. for(var j=0;j<3;j++)
  6681. {
  6682. var infoComposant = MY_getValue(numTroll+".enchantement."
  6683. +idEquipement+".composant."+j).split(";");
  6684. var texte = infoComposant[4].replace("Ril ","Œil ");
  6685. for(var k=5;k<infoComposant.length;k++)
  6686. {
  6687. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  6688. }
  6689. li = appendLI(ul,texte);
  6690. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  6691. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  6692. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  6693. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  6694. string+= '<input type="hidden" name="q" value="min" />';
  6695. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  6696. 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>';
  6697.  
  6698. string+= '</form>';
  6699. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  6700. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  6701. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  6702. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  6703. li.innerHTML += string;
  6704. }
  6705. tr = appendTr(tbody, 'mh_tdpage');
  6706. td = appendTdText(tr, nomEquipement);
  6707. td.setAttribute('valign', 'center');
  6708. td = document.createElement('td');
  6709. td.appendChild(ul);
  6710. tr.appendChild(td);
  6711. td.setAttribute('valign', 'center');
  6712. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  6713. td.setAttribute('valign', 'center');
  6714. td = document.createElement('td');
  6715. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  6716. input.setAttribute('name', idEquipement);
  6717. tr.appendChild(td);
  6718. td.setAttribute('valign', 'center');
  6719. }
  6720. catch(e)
  6721. {
  6722. }
  6723. }
  6724. insertBefore(insertPoint, table);
  6725. insertBefore(insertPoint, document.createElement('p'));
  6726. }
  6727. /* [zone] fin Obsolète ?? */
  6728.  
  6729.  
  6730. displayScriptTime();
  6731. }
  6732.  
  6733. /*******************************************************************************
  6734. * This file is part of Mountyzilla. *
  6735. * *
  6736. * Mountyzilla is free software; you can redistribute it and/or modify *
  6737. * it under the terms of the GNU General Public License as published by *
  6738. * the Free Software Foundation; either version 2 of the License, or *
  6739. * (at your option) any later version. *
  6740. * *
  6741. * Mountyzilla is distributed in the hope that it will be useful, *
  6742. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6743. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6744. * GNU General Public License for more details. *
  6745. * *
  6746. * You should have received a copy of the GNU General Public License *
  6747. * along with Mountyzilla; if not, write to the Free Software *
  6748. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6749. *******************************************************************************/
  6750.  
  6751. // x~x equip
  6752.  
  6753. /**
  6754. * 2014-02-08 - v2.0a (from scratch)
  6755. * 2014-02-18 - v2.0a0
  6756. * - ajout calcul Carats / UM des minerais + totaux
  6757. * 2014-03-06 - v2.0a1
  6758. * - retour Infos EM des Champis
  6759. * TODO
  6760. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6761. */
  6762.  
  6763. function traiteChampis() {
  6764. try{
  6765. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6766. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6767. }
  6768. catch(e){return;}
  6769. if(trlist.length<=0) return;
  6770. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6771. var node = trlist.snapshotItem(i).childNodes[7];
  6772. var str = node.textContent.trim();
  6773. var type = str.slice(0,str.lastIndexOf(' '));
  6774. var mundi = mundiChampi[type];
  6775. if(!mundi) continue;
  6776. var urlImg = URL_MZimg
  6777. +'Competences/ecritureMagique.png';
  6778. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6779. appendText(node,' ');
  6780. node.appendChild(img);
  6781. }
  6782. }
  6783.  
  6784. function traiteCompos() {
  6785. try {
  6786. var tr = document.getElementById('mh_objet_hidden_Composant');
  6787. var tbody = document.evaluate("./td/table/tbody",
  6788. tr, null, 9, null).singleNodeValue;
  6789. }
  6790. catch(e) {return;}
  6791. insererInfosEM(tbody);
  6792. }
  6793.  
  6794. function traiteMinerai() {
  6795. try{
  6796. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6797. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6798. }
  6799. catch(e){return;}
  6800. if(trlist.length<=0) return;
  6801. var totaux = {};
  6802. var str;
  6803. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6804. var node = trlist.snapshotItem(i);
  6805. var nature = node.childNodes[7].textContent,
  6806. caracs = node.childNodes[9].textContent;
  6807. var taille = Number(caracs.match(/\d+/)[0]);
  6808. var coef = 1;
  6809. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6810. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6811. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6812. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6813. if(nature.indexOf('Mithril')!=-1) {
  6814. coef = 0.2*coef;
  6815. str = ' | UM: ';
  6816. }
  6817. else {
  6818. coef = 0.75*coef+1.25;
  6819. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6820. str = ' | Carats: ';
  6821. }
  6822. var carats = Math.round(taille*coef)
  6823. appendText(node.childNodes[9], str+carats );
  6824. if(!totaux[nature]) {
  6825. totaux[nature] = [taille,carats];
  6826. }
  6827. else {
  6828. totaux[nature][0] += taille;
  6829. totaux[nature][1] += carats;
  6830. }
  6831. }
  6832. str = 'Total : ';
  6833. for(var nature in totaux) {
  6834. if(str.length>8) str += ', ';
  6835. if(nature.indexOf('Mithril')!=-1) {
  6836. str += nature+totaux[nature][1]+' UM';
  6837. }
  6838. else {
  6839. str += nature+totaux[nature][0]+'U/'
  6840. +totaux[nature][1]+'c';
  6841. }
  6842. }
  6843. /*var node = document.getElementById('mh_plus_Minerai');
  6844. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6845. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6846. if(!titre) return;*/
  6847. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6848. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6849. td.colSpan = 7;
  6850. }
  6851.  
  6852. function do_equip() {
  6853. start_script();
  6854.  
  6855. traiteChampis();
  6856. traiteCompos();
  6857. traiteMinerai();
  6858.  
  6859. displayScriptTime();
  6860. }
  6861.  
  6862. /*******************************************************************************
  6863. * This file is part of Mountyzilla. *
  6864. * *
  6865. * Mountyzilla is free software; you can redistribute it and/or modify *
  6866. * it under the terms of the GNU General Public License as published by *
  6867. * the Free Software Foundation; either version 2 of the License, or *
  6868. * (at your option) any later version. *
  6869. * *
  6870. * Mountyzilla is distributed in the hope that it will be useful, *
  6871. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6872. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6873. * GNU General Public License for more details. *
  6874. * *
  6875. * You should have received a copy of the GNU General Public License *
  6876. * along with Mountyzilla; if not, write to the Free Software *
  6877. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6878. *******************************************************************************/
  6879.  
  6880. // x~x diplo
  6881.  
  6882. /*
  6883. TODO:
  6884. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6885. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6886. V Étape 3: Ajout de la diplo perso
  6887. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6888. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6889. Options Globales:
  6890. Actuelles:
  6891. numTroll.USECSS,
  6892. numTroll.NODIPLO
  6893. NOMYTH
  6894. Nouvelles:
  6895. TODO numTroll.USECSS
  6896. numTroll.diplo.off (remplace NODIPLO)
  6897. numTroll.diplo.guilde
  6898. numTroll.diplo.perso
  6899. Structure de diplo.guilde:
  6900. isOn: 'true' ou 'false'
  6901. isDetailOn: 'true' ou 'false'
  6902. guilde
  6903. > id
  6904. > couleur
  6905. AllAmis,AllEnnemis: couleur
  6906. Amis0,...,Ennemis5
  6907. > Troll: idTroll1;...;
  6908. > Guilde: idGuilde1;...;
  6909. > titre
  6910. > couleur
  6911. Structure de diplo.perso:
  6912. isOn: 'true' ou 'false'
  6913. mythiques: couleur
  6914. Troll,Guilde,Monstre:
  6915. > id
  6916. > couleur
  6917. > description
  6918. */
  6919.  
  6920. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6921.  
  6922. function couleurAleatoire() {
  6923. var alph = '0123456789ABCDEF'.split('');
  6924. var clr = '#';
  6925. for (var i=0; i<6; i++) {
  6926. clr+=alph[ Math.floor(16*Math.random()) ];
  6927. }
  6928. return clr;
  6929. }
  6930.  
  6931. function isCouleur(str) {
  6932. return /^#[0-9A-F]{6}$/i.test(str);
  6933. }
  6934.  
  6935. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6936.  
  6937. function appendChoixCouleur(node,id) {
  6938. var span = document.createElement('span');
  6939. span.id = 'span'+id;
  6940. if(isDetailOn) {
  6941. span.style.display = 'none';
  6942. }
  6943. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6944. if(diploGuilde[id]) {
  6945. couleur = diploGuilde[id];
  6946. }
  6947. appendText(span,' - Couleur HTML: ');
  6948. var input = appendTextbox(span,'text',id,7,7,couleur);
  6949. input.onkeyup = previewCouleur;
  6950. input.onchange = previewCouleur;
  6951. input.onkeyup();
  6952. node.appendChild(span);
  6953. }
  6954.  
  6955. function insertChoixCouleur(node,id) {
  6956. var span = document.createElement('span');
  6957. span.id = 'span'+id;
  6958. // La couleur détaillée passera à une valeur aléatoire
  6959. // si toggle vers isDetailOn
  6960. var couleur = couleurAleatoire();
  6961. if(!isDetailOn) {
  6962. span.style.display = 'none';
  6963. } else if(diploGuilde[id]) {
  6964. couleur = diploGuilde[id].couleur;
  6965. }
  6966. appendText(span,' - Couleur HTML: ');
  6967. var input = appendTextbox(span,'text',id,7,7,couleur);
  6968. input.onkeyup = previewCouleur;
  6969. input.onchange = previewCouleur;
  6970. input.onkeyup();
  6971. insertBefore(node,span);
  6972. }
  6973.  
  6974. function setChoixCouleurs() {
  6975. try {
  6976. //var form = document.getElementsByName('ActionForm')[0];
  6977. var form = document.getElementById('mhPlay');
  6978. var nodesAE = document.evaluate(
  6979. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  6980. "./table/tbody/tr/th[@class='mh_tdtitre']",
  6981. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  6982. form, null, 7, null
  6983. );
  6984. var nodes = document.evaluate(
  6985. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6986. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  6987. form, null, 7, null
  6988. );
  6989. } catch(e) {
  6990. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6991. return false;
  6992. };
  6993. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6994. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6995. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6996. for(var i=0 ; i<5 ; i++) {
  6997. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6998. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6999. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  7000. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  7001. }
  7002. return true;
  7003. }
  7004.  
  7005. function fetchDiploGuilde() {
  7006. try {
  7007. for(var AE in {Amis:0,Ennemis:0}) {
  7008. for(var i=0 ; i<5 ; i++) {
  7009. /* Récup des A/E de rang i */
  7010. var td = document.getElementById('td'+AE+i);
  7011. var ligne = td.getElementsByTagName('table')[0].rows;
  7012. var titre = trim(td.firstChild.textContent);
  7013. // On laisse la gestion des couleurs à setChoixCouleurs:
  7014. var couleur = document.getElementById(AE+i).value;
  7015. diploGuilde[AE+i] = {
  7016. Troll:'',
  7017. Guilde:'',
  7018. titre: titre,
  7019. couleur: couleur
  7020. };
  7021. for(var j=1 ; j<ligne.length ; j++) {
  7022. var str = trim(ligne[j].cells[0].textContent);
  7023. var idx = str.lastIndexOf('(');
  7024. var num = str.slice(idx+1,-1);
  7025. var type = trim(ligne[j].cells[1].textContent);
  7026. diploGuilde[AE+i][type] += num+';';
  7027. }
  7028. }
  7029. }
  7030. } catch(e) {
  7031. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  7032. return false;
  7033. }
  7034. return true;
  7035. }
  7036.  
  7037.  
  7038. /*-[functions]--------------------- Handlers ---------------------------------*/
  7039.  
  7040. function toggleDetails() {
  7041. isDetailOn = !isDetailOn;
  7042. for(var AE in {Amis:0,Ennemis:0}) {
  7043. document.getElementById('spanAll'+AE).style.display =
  7044. (isDetailOn?'none':'');
  7045. for(var i=0 ; i<5 ; i++) {
  7046. document.getElementById('span'+AE+i).style.display =
  7047. (isDetailOn?'':'none');
  7048. }
  7049. }
  7050. }
  7051.  
  7052. function toggleMythiques() {
  7053. isMythiquesOn = !isMythiquesOn;
  7054. document.getElementById('spanMythiques').style.display =
  7055. (isMythiquesOn?'':'none');
  7056. }
  7057.  
  7058. function previewCouleur() {
  7059. var value = this.value;
  7060. if(isCouleur(value)) {
  7061. this.style.backgroundColor = value;
  7062. this.title = '';
  7063. } else {
  7064. this.style.backgroundColor = '';
  7065. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  7066. }
  7067. }
  7068.  
  7069. function appendMenuType(node,duType) {
  7070. var select = document.createElement('select');
  7071. select.className = 'SelectboxV2';
  7072. var type = ['Guilde','Troll','Monstre'];
  7073. for(var i=0 ; i<3 ; i++) {
  7074. appendOption(select,type[i],type[i]);
  7075. if(type[i]==duType) { select.selectedIndex=i; }
  7076. }
  7077. node.appendChild(select);
  7078. }
  7079.  
  7080. function ajouteChamp(type,num,couleur,descr) {
  7081. var champs = document.getElementById('diploPerso');
  7082. var nb = champs.rows.length;
  7083. var tr = champs.insertRow(-1);
  7084. var td = appendTd(tr);
  7085. appendMenuType(td,type);
  7086. td = appendTd(tr);
  7087. appendText(td,' n°');
  7088. appendTextbox(td,'text','num'+nb,6,15,num);
  7089. td = appendTd(tr);
  7090. appendText(td,' couleur HTML:');
  7091. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7092. input.onkeyup = previewCouleur;
  7093. input.onchange = previewCouleur;
  7094. input.onkeyup();
  7095. td = appendTd(tr);
  7096. appendText(td,' Description:');
  7097. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7098. td = appendTd(tr);
  7099. var span = document.createElement('span');
  7100. appendText(span,'[ok!]',true);
  7101. span.style.visibility = 'hidden';
  7102. td.appendChild(span);
  7103. td = appendTd(tr);
  7104. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7105. }
  7106.  
  7107. function retireCeChamp() {
  7108. var thisTr = this.parentNode.parentNode;
  7109. thisTr.parentNode.removeChild(thisTr);
  7110. var champs = document.getElementById('diploPerso');
  7111. if(champs.rows.length==0) { ajouteChamp(); }
  7112. }
  7113.  
  7114. function valideChamp(champ) {
  7115. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7116. isCouleur(champ.cells[2].childNodes[1].value);
  7117. if(isValide) {
  7118. champ.cells[4].firstChild.style.visibility = 'visible';
  7119. } else {
  7120. champ.cells[4].firstChild.style.visibility = 'hidden';
  7121. }
  7122. return isValide;
  7123. }
  7124.  
  7125. function sauvegarderTout() {
  7126. /* Diplo de guilde */
  7127. diploGuilde.isOn =
  7128. document.getElementById('isGuildeOn').checked?'true':'false';
  7129. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7130. var numGuilde = Number(document.getElementById('numGuilde').value);
  7131. var couleur = document.getElementById('couleurGuilde').value;
  7132. if(numGuilde) {
  7133. diploGuilde.guilde = {
  7134. id: numGuilde,
  7135. couleur: couleur
  7136. };
  7137. } else {
  7138. delete diploGuilde.guilde;
  7139. }
  7140. for(var AE in {Amis:0,Ennemis:0}) {
  7141. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7142. for(var i=0 ; i<5 ; i++) {
  7143. if(isDetailOn) {
  7144. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7145. } else {
  7146. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7147. }
  7148. }
  7149. }
  7150. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7151. /* Diplo personnelle (ex-fonction saveChamps) */
  7152. var champs = document.getElementById('diploPerso');
  7153. diploPerso = {
  7154. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7155. Guilde: {},
  7156. Troll: {},
  7157. Monstre: {}
  7158. };
  7159. if(isMythiquesOn &&
  7160. isCouleur(document.getElementById('couleurMythiques').value)) {
  7161. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7162. }
  7163. for(var i=0 ; i<champs.rows.length ; i++) {
  7164. if(valideChamp(champs.rows[i])) {
  7165. var type = champs.rows[i].cells[0].firstChild.value;
  7166. var num = champs.rows[i].cells[1].childNodes[1].value;
  7167. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7168. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7169. diploPerso[type][num] = {
  7170. couleur: couleur
  7171. };
  7172. if(descr) {
  7173. diploPerso[type][num].titre = descr;
  7174. }
  7175. }
  7176. }
  7177. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7178.  
  7179. avertissement('Données sauvegardées');
  7180. }
  7181.  
  7182.  
  7183. /*-[functions]------------- Modifications de la page -------------------------*/
  7184.  
  7185. function creeTablePrincipale() {
  7186. var insertPt = document.getElementById('insertPt');
  7187. /* Titre + bouton de Sauvegarde */
  7188. var tr = insertTr(insertPt,'mh_tdtitre');
  7189. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7190. appendButton(td,'Sauvegarder',sauvegarderTout);
  7191. /* Options fixes */
  7192. tr = insertTr(insertPt,'mh_tdpage');
  7193. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7194. appendBr(td);
  7195. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7196. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7197. appendBr(td);
  7198. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7199. appendText(td,'Utiliser des couleurs détaillées (10)');
  7200. /* Diplo personnelle */
  7201. tr = insertTr(insertPt,'mh_tdpage');
  7202. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7203. appendBr(td);
  7204. // Diplo Mythiques
  7205. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7206. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7207. var span = document.createElement('span');
  7208. span.id = 'spanMythiques';
  7209. if(!isMythiquesOn) {
  7210. span.style.display = 'none';
  7211. }
  7212. var couleur = '#FFAAAA';
  7213. if(diploPerso.mythiques) {
  7214. couleur = diploPerso.mythiques;
  7215. }
  7216. appendText(span,' - couleur HTML:');
  7217. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7218. input.onkeyup = previewCouleur;
  7219. input.onchange = previewCouleur;
  7220. input.onkeyup();
  7221. td.appendChild(span);
  7222. appendBr(td);
  7223. // Diplo éditable
  7224. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7225. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7226. appendBr(td);
  7227. var table = document.createElement('table');
  7228. table.id = 'diploPerso'
  7229. td.appendChild(table);
  7230. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7231. for(var num in diploPerso[type]) {
  7232. ajouteChamp(
  7233. type,
  7234. num,
  7235. diploPerso[type][num].couleur,
  7236. diploPerso[type][num].titre
  7237. );
  7238. }
  7239. }
  7240. if(table.rows.length==0) {
  7241. ajouteChamp();
  7242. }
  7243. appendButton(td,'Ajouter',ajouteChamp)
  7244. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7245. appendText(td,' ');
  7246. appendButton(td,
  7247. 'Exemples de couleur',
  7248. function() {
  7249. var fenetre = window.open(
  7250. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7251. 'Divers',
  7252. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7253. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7254. );
  7255. fenetre.focus();
  7256. }
  7257. );
  7258. /* Couleur de Guilde */
  7259. tr = insertTr(insertPt,'mh_tdtitre');
  7260. td = appendTdText(tr,'GUILDE',true);
  7261. appendText(td,' - n°');
  7262. appendTextbox(td,'text','numGuilde',5,10,
  7263. diploGuilde.guilde && diploGuilde.guilde.id ?
  7264. diploGuilde.guilde.id : ''
  7265. );
  7266. appendText(td,' - Couleur HTML: ');
  7267. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7268. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7269. diploGuilde.guilde.couleur : '#BBBBFF'
  7270. );
  7271. input.onkeyup = previewCouleur;
  7272. input.onchange = previewCouleur;
  7273. input.onkeyup();
  7274. }
  7275.  
  7276.  
  7277. /*-[functions]----------------------- Main -----------------------------------*/
  7278.  
  7279. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  7280. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  7281. var isDetailOn = diploGuilde.isDetailOn=='true';
  7282. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  7283. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  7284. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7285.  
  7286. function do_diplo() {
  7287. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7288. creeTablePrincipale();
  7289. }
  7290. }
  7291.  
  7292. /*******************************************************************************
  7293. * This file is part of Mountyzilla. *
  7294. * *
  7295. * Mountyzilla is free software; you can redistribute it and/or modify *
  7296. * it under the terms of the GNU General Public License as published by *
  7297. * the Free Software Foundation; either version 2 of the License, or *
  7298. * (at your option) any later version. *
  7299. * *
  7300. * Mountyzilla is distributed in the hope that it will be useful, *
  7301. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7302. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7303. * GNU General Public License for more details. *
  7304. * *
  7305. * You should have received a copy of the GNU General Public License *
  7306. * along with Mountyzilla; if not, write to the Free Software *
  7307. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7308. *******************************************************************************/
  7309.  
  7310. // x~x cdmcomp
  7311.  
  7312. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  7313.  
  7314. function getNonNegInts(str) {
  7315. var nbrs = str.match(/\d+/g);
  7316. for(var i=0 ; i<nbrs.length ; i++) {
  7317. nbrs[i] = Number(nbrs[i]);
  7318. }
  7319. return nbrs;
  7320. }
  7321.  
  7322. function traiteCdMcomp() {
  7323. try {
  7324. var msgEffet = document.getElementById('msgEffet');
  7325. } catch(e) {
  7326. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  7327. return;
  7328. }
  7329.  
  7330. // Teste si ce message du bot est un message de CdM
  7331. if(!document.evaluate(
  7332. "./p/text()[contains(.,'fait partie')]",
  7333. msgEffet, null, 9, null
  7334. ).singleNodeValue) {
  7335. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  7336. return;
  7337. }
  7338. // Début de récupération de la CdM
  7339. /*
  7340. Roule 10/03/2017 j'ai grandement simplifié ☺ ☺ ☺
  7341. zone à supprimer
  7342. traitement Armure Physique/Magique reporté en php
  7343.  
  7344. cdm = document.evaluate(
  7345. "./p/text()[contains(.,'fait partie')]",
  7346. msgEffet, null, 9, null
  7347. ).singleNodeValue.nodeValue+'\n';
  7348. var tbody = document.evaluate(
  7349. "descendant::table/tbody",
  7350. msgEffet, null, 9, null
  7351. ).singleNodeValue;
  7352. var nomStat = document.evaluate(
  7353. "./tr/td[1]/b/text()",
  7354. tbody, null, 7, null
  7355. );
  7356. var valStat = document.evaluate(
  7357. "./tr/td[2]/descendant::text()",
  7358. tbody, null, 7, null
  7359. );
  7360. var i=0;
  7361. while(i<nomStat.snapshotLength) {
  7362. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7363. cdm += 'Armure : ';
  7364. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7365. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7366. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7367. armp = [0,armp[0]];
  7368. }
  7369. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7370. armm = [0,armm[0]];
  7371. }
  7372. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7373. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7374. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7375. } else {
  7376. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7377. }
  7378. cdm += ')\n';
  7379. i++;
  7380. } else {
  7381. cdm += nomStat.snapshotItem(i).nodeValue+
  7382. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7383. }
  7384. i++;
  7385. }
  7386. */
  7387. //cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  7388. //if (MY_DEBUG) window.console.log('cmd=' + cdm);
  7389.  
  7390. // envoi au serveur (PHP) d'un objet avec
  7391. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  7392. // tstamp: l'horodatage
  7393. var tabCdM = new Array();
  7394. var etimestamp = document.getElementById('hserveur');
  7395. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  7396. var txtBlessure;
  7397. var txtPv;
  7398. for (var eHTML of msgEffet.childNodes) {
  7399. switch (eHTML.nodeName) {
  7400. case '#text':
  7401. var s = eHTML.nodeValue.trim();
  7402. if (s != '') tabCdM.push(s);
  7403. break;
  7404. case 'P':
  7405. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7406. s = s.trim();
  7407. if (s != '') tabCdM.push(s);
  7408. break;
  7409. case 'TABLE':
  7410. var s = 'table';
  7411. for (var eTr of eHTML.rows) {
  7412. var tabTd = new Array();
  7413. for (var eTd of eTr.cells) {
  7414. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  7415. s = s.trim();
  7416. tabTd.push(s);
  7417. }
  7418. if (tabTd.length >= 2) {
  7419. if (tabTd[0].match(/Blessure/i)) {
  7420. txtBlessure = tabTd[1]
  7421. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  7422. txtPv = tabTd[1]
  7423. }
  7424. }
  7425. tabCdM.push(tabTd);
  7426. }
  7427. break;
  7428. default:
  7429. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  7430. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7431. if (s != '') tabCdM.push(s);
  7432. break;
  7433. }
  7434. }
  7435. var oData = {};
  7436. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  7437. oData.idTroll = numTroll;
  7438. oData.tabCdM = tabCdM;
  7439. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  7440.  
  7441. // envoi d'une CdM issue de compte-rendu de compétence
  7442. // fonction définie ici pour avoir vue sur la variable tabCdM
  7443. var sendInfoCDM = function () {
  7444. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  7445. var buttonCDM = this;
  7446. var texte = '';
  7447. FF_XMLHttpRequest({
  7448. method: 'POST',
  7449. url: URL_pageDispatcherV2,
  7450. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7451. headers : {
  7452. /* inutile, à supprimer
  7453. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7454. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7455. */
  7456. 'Content-type':'application/x-www-form-urlencoded',
  7457. },
  7458. onload: function(responseDetails) {
  7459. texte = responseDetails.responseText;
  7460. buttonCDM.value = texte;
  7461. if (!isDEV) buttonCDM.disabled = true;
  7462. }
  7463. });
  7464. }
  7465.  
  7466. // Envoi auto ou insertion bouton envoi (suivant option)
  7467. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  7468. sendInfoCDM();
  7469. var p = document.createElement('p');
  7470. p.style.color = 'green';
  7471. appendText(p,'CdM envoyée vers la base MountyZilla !');
  7472. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  7473. } else {
  7474. insertButtonCdm('as_Action', sendInfoCDM);
  7475. }
  7476.  
  7477. // Insertion de l'estimation des PV restants
  7478. /*
  7479. var pv = valStat.snapshotItem(1).nodeValue;
  7480. if(pv.indexOf("entre")==-1) {
  7481. return;
  7482. }
  7483. var trPv = document.evaluate(
  7484. "//tr[contains(td/b/text(),'Points de Vie')]",
  7485. msgEffet, null, 9, null).singleNodeValue;
  7486. tdPv = trPv.cells[1];
  7487. txtPv = tdPv.innerText || tdPv.textContent;
  7488. if (MY_DEBUG) window.console.log('txtPv=' + txtPv);
  7489. if(0) { //pv) { // bloqué en attendant correction
  7490. */
  7491. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  7492. if (txtBlessure !== undefined && txtPv !== undefined) {
  7493. var pv = getPVsRestants(txtPv,txtBlessure);
  7494. if (MY_DEBUG) window.console.log('pv=' + pv);
  7495. if (pv) { // pv null si le monstre n'est pas blessé
  7496. var trBless = document.evaluate(
  7497. "//tr[contains(td/b/text(),'Blessure')]",
  7498. msgEffet, null, 9, null).singleNodeValue;
  7499. var tr = document.createElement('tr');
  7500. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  7501. appendTr(trBless);
  7502. appendTdText(tr, pv[0], true);
  7503. appendTdText(tr, pv[1], true);
  7504. }
  7505. }
  7506. }
  7507.  
  7508. function do_cdmcomp() {
  7509. start_script(31);
  7510. traiteCdMcomp();
  7511. displayScriptTime();
  7512. }
  7513.  
  7514. /*********************************************************************************
  7515. * This file is part of Mountyzilla. *
  7516. * *
  7517. * Mountyzilla is free software; you can redistribute it and/or modify *
  7518. * it under the terms of the GNU General Public License as published by *
  7519. * the Free Software Foundation; either version 2 of the License, or *
  7520. * (at your option) any later version. *
  7521. * *
  7522. * Mountyzilla is distributed in the hope that it will be useful, *
  7523. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7524. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7525. * GNU General Public License for more details. *
  7526. * *
  7527. * You should have received a copy of the GNU General Public License *
  7528. * along with Mountyzilla; if not, write to the Free Software *
  7529. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7530. *********************************************************************************/
  7531.  
  7532. // x~x cmdbot
  7533.  
  7534. /* v0.2 by Dab - 2013-08-20
  7535. * - patch dégueu pour gérer la décomposition P/M de l'armure
  7536. */
  7537.  
  7538. var buttonCDM;
  7539.  
  7540. /*******************************************************************************************
  7541. CDM :
  7542. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  7543.  
  7544. Il ne vous est pas possible d'améliorer cette compétence.
  7545.  
  7546. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  7547. Niveau : Inimaginable (entre 49 et 51)
  7548. Points de Vie : Surtrollesque (entre 450 et 470)
  7549. Blessure (Approximatif) : 0 %
  7550. Dés d'Attaque : Impressionnant (entre 30 et 32)
  7551. Dés d'Esquive : Impressionnant (entre 28 et 30)
  7552. Dés de Dégat : Très Fort (entre 18 et 20)
  7553. Dés de Régénération : Excellent (égal à 13)
  7554. Armure Physique : Moyen (entre 10 et 12)
  7555. Armure Magique : Faible (inférieur à 6)
  7556. Vue : Moyen (entre 9 et 11)
  7557. Maitrise Magique : Inimaginable (supérieur à 6000)
  7558. Résistance Magique : Inimaginable (supérieur à 6000)
  7559. Nombre d'attaques : 1
  7560. Vitesse de Déplacement : Normale
  7561. Voir le Caché : Oui
  7562. Attaque à distance : Non
  7563. Attaque magique : Oui
  7564. Vole : Non
  7565. Sang froid : Inexistant
  7566. DLA : Milieu
  7567. Durée Tour : Remarquable (entre 9 et 11)
  7568. Chargement : Vide
  7569. Bonus Malus : Aucun
  7570.  
  7571. Vous avez également gagné 1 PX pour la réussite.
  7572. *******************************************************************************************
  7573. BOT :
  7574. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  7575.  
  7576. Le Monstre ciblé fait partie des : Mort-Vivant
  7577.  
  7578. Niveau : Incroyable (entre 36 et 38)
  7579. *******************************************************************************************/
  7580.  
  7581. function getNNInt(str) {
  7582. var nbrs = str.match(/\d+/g);
  7583. for (var i=0 ; i<nbrs.length ; i++)
  7584. nbrs[i] = parseInt(nbrs[i]);
  7585. return nbrs;
  7586. }
  7587.  
  7588. // envoi d'une CdM issue d'un message du BOT
  7589. function sendCDM() {
  7590. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  7591. document, null, 9, null).singleNodeValue;
  7592. /* ancienne version à supprimer
  7593. cdm = td.innerHTML;
  7594. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  7595. "$3$4 ($1 - N°$2)<br>");
  7596. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  7597. 'Blessure : XX % (approximativement)');
  7598. // Supprime la décomposition P/M de l'Armure
  7599. var bgn = cdm.indexOf('Armure Physique');
  7600. if (bgn!=-1) {
  7601. var end = cdm.indexOf('Vue')-2;
  7602. var lines = cdm.substring(bgn,end).split('<br>');
  7603. var armp = getNNInt(lines[0]);
  7604. var armm = getNNInt(lines[1]);
  7605. if (lines[0].indexOf('(inf')!=-1)
  7606. armp = [0,armp[0]];
  7607. if (lines[1].indexOf('(inf')!=-1)
  7608. armm = [0,armm[0]];
  7609. var insrt = 'Armure : ';
  7610. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  7611. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  7612. else
  7613. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7614. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  7615. }
  7616. cdm = cdm.replace(/<br>/g,'\n');
  7617. */
  7618.  
  7619. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  7620. //window.console.log(tdTxt);
  7621. var oData = {};
  7622. oData.tabCdM = tdTxt.split(/\n/);
  7623. // nettoyage entête : enlève le premier élément tant que
  7624. // - suite de *
  7625. // - "MOUNTYHALL - La Terre des Trõlls"
  7626. // - ligne vide (la première expression régulière matche les lignes vides)
  7627. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  7628. // 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
  7629. var iLigneNonVide;
  7630. for (var i = 0; i < oData.tabCdM.length; i++) {
  7631. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  7632. if (iLigneNonVide === undefined)
  7633. oData.tabCdM.splice(i);
  7634. else
  7635. oData.tabCdM.splice(iLigneNonVide+1);
  7636. break;
  7637. }
  7638. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  7639. }
  7640. //window.console.log(JSON.stringify(oData));
  7641.  
  7642. FF_XMLHttpRequest({
  7643. method: 'POST',
  7644. url: URL_pageDispatcherV2,
  7645. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7646. headers : {
  7647. /* inutile, à supprimer
  7648. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7649. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7650. */
  7651. 'Content-type':'application/x-www-form-urlencoded',
  7652. },
  7653. onload: function(responseDetails) {
  7654. buttonCDM.value=responseDetails.responseText;
  7655. buttonCDM.disabled = true;
  7656. }
  7657. });
  7658. }
  7659.  
  7660. function traiteCdMmsg() {
  7661. // Teste si ce message du bot est un message de CdM
  7662. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7663. document, null, 9, null).singleNodeValue;
  7664. if (!td) return false;
  7665. cdm = td.innerHTML;
  7666. // Insertion de l'estimation des PV restants
  7667. var des = cdm.indexOf('Dés');
  7668. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  7669. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  7670. if(pv)
  7671. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  7672.  
  7673. // Insertion bouton envoi + espace
  7674. buttonCDM = insertButtonCdm('bClose',sendCDM);
  7675. }
  7676.  
  7677. /*function traitePouvoir() {
  7678. // Teste si ce message du bot est un message de CdM
  7679. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  7680. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  7681. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7682. if (!td)
  7683. return false;
  7684. var infos = td.innerHTML;
  7685. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  7686. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  7687. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  7688. var date = /alors : ([^<]+)\./.exec(infos)[1];
  7689. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  7690. var effetPouvoir="";
  7691. var full=false;
  7692. if(infos.indexOf("REDUIT")!=-1) {
  7693. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  7694. }
  7695. else {
  7696. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  7697. full=true;
  7698. }
  7699. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  7700. // On insère le bouton et un espace
  7701. //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));
  7702. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  7703. if(!MY_getValue('AUTOSENDPOUV'))
  7704. {
  7705. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  7706. button.setAttribute("onClick", "window.open('" + url
  7707. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  7708. + "this.value='Merci de votre participation'; this.disabled = true;");
  7709. }
  7710. else
  7711. {
  7712. FF_XMLHttpRequest({
  7713. method: 'GET',
  7714. url: url,
  7715. headers : {
  7716. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7717. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7718. }});
  7719. }
  7720. }*/
  7721.  
  7722. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  7723. traiteCdMmsg();
  7724. }
  7725. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  7726.  
  7727. /*******************************************************************************
  7728. * This file is part of Mountyzilla. *
  7729. * *
  7730. * Mountyzilla is free software; you can redistribute it and/or modify *
  7731. * it under the terms of the GNU General Public License as published by *
  7732. * the Free Software Foundation; either version 2 of the License, or *
  7733. * (at your option) any later version. *
  7734. * *
  7735. * Mountyzilla is distributed in the hope that it will be useful, *
  7736. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7737. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7738. * GNU General Public License for more details. *
  7739. * *
  7740. * You should have received a copy of the GNU General Public License *
  7741. * along with Mountyzilla; if not, write to the Free Software *
  7742. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7743. *******************************************************************************/
  7744.  
  7745. // x~x menu
  7746. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  7747.  
  7748. var menuRac, mainIco;
  7749.  
  7750. // met à jour les carac sauvegardées (position, DLA, etc.)
  7751. function updateData() {
  7752. var inputs = document.getElementsByTagName('input');
  7753. var divs = document.getElementsByTagName('div');
  7754.  
  7755. //window.console.log('inputs=' + JSON.stringify(inputs));
  7756. if (inputs && inputs.length > 0) {
  7757. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  7758. numTroll = inputs[0].value;
  7759. MY_setValue('NUM_TROLL', numTroll);
  7760. MY_setValue('NIV_TROLL',inputs[1].value);
  7761. if(!MY_getValue(numTroll+'.caracs.rm')) {
  7762. MY_setValue(numTroll+'.caracs.rm',0);
  7763. // assure l'init des 4 var de libs
  7764. }
  7765. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  7766. } else {
  7767. // onclick="EnterPJView(91305,750,550)"
  7768. var tabA = document.getElementsByTagName('a');
  7769. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  7770. var s = tabA[0].onclick.toString();;
  7771. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  7772. var m = s.match(/\((\d+) *,/);
  7773. //window.console.log('m=' + JSON.stringify(m));
  7774. numTroll = parseInt(m[1]);
  7775. MY_setValue('NUM_TROLL', numTroll);
  7776. }
  7777. }
  7778.  
  7779. var DLA = new Date(
  7780. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  7781. );
  7782. if(MY_getValue(numTroll+'.DLA.encours')) {
  7783. var DLAstockee = new Date(
  7784. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  7785. );
  7786. if(DLA>DLAstockee) {
  7787. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  7788. // Pose un pb en cas de décalage de DLA
  7789. }
  7790. }
  7791. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  7792.  
  7793. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  7794. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  7795. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  7796. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  7797. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  7798. }
  7799.  
  7800. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7801. function initRaccourcis() {
  7802. var anotherURL = MY_getValue('URL1');
  7803. if(!anotherURL) { return; }
  7804. /* Création de l'icône faisant apparaître le menu */
  7805. mainIco = document.createElement('img');
  7806. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  7807. if(!urlIco) {
  7808. urlIco =
  7809. URL_MZimg + 'mz_logo_small.png';
  7810. }
  7811. mainIco.src = urlIco;
  7812. mainIco.alt = 'MZ';
  7813. mainIco.style = 'position:fixed; top:0px; left:0px';
  7814. mainIco.onmouseover = afficheMenu;
  7815. document.body.appendChild(mainIco);
  7816. /* Création du menu des Raccourcis */
  7817. menuRac = document.createElement('div');
  7818. menuRac.className = 'mh_textbox';
  7819. menuRac.style =
  7820. 'position:fixed; top:10px; left:10px;'+
  7821. 'max-width:190px;'+
  7822. 'border-radius: 4px; padding: 4px;'+
  7823. 'z-index: 500;'+
  7824. 'visibility: hidden;';
  7825. document.body.appendChild(menuRac);
  7826. document.addEventListener('mousemove',cacheMenu,false);
  7827. var i=1;
  7828. while(anotherURL) {
  7829. var a = document.createElement('a');
  7830. var url = MY_getValue('URL'+i);
  7831. var nom = MY_getValue('URL'+i+'.nom');
  7832. var ico = MY_getValue('URL'+i+'.ico');
  7833. a.href = url;
  7834. a.target = '_blank';
  7835. if(ico) {
  7836. var txt = nom ? nom : '';
  7837. var img = createImage(ico,txt);
  7838. a.appendChild(img);
  7839. }
  7840. else {
  7841. appendText(a,'['+nom+']');
  7842. }
  7843. menuRac.appendChild(a);
  7844. appendBr(menuRac);
  7845. i++;
  7846. anotherURL = MY_getValue('URL'+i);
  7847. }
  7848. }
  7849.  
  7850. function afficheMenu() {
  7851. menuRac.style.visibility = 'visible';
  7852. }
  7853.  
  7854. function cacheMenu(e) {
  7855. if(menuRac.style.visibility=='hidden') { return; }
  7856. // Position souris
  7857. var ptX = e.clientX;
  7858. var ptY = e.clientY;
  7859. // On recalcule en live les BoundingBox pour mainIco et menuRac
  7860. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  7861. var menuRect = menuRac.getBoundingClientRect();
  7862. var icoRect = mainIco.getBoundingClientRect();
  7863. if((ptX>icoRect.width || ptY>icoRect.height) &&
  7864. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  7865. menuRac.style.visibility = 'hidden';
  7866. }
  7867. }
  7868.  
  7869. // ajout de l'icône, branchée sur un refresh
  7870. function initUpdateCoordGauche() {
  7871. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7872. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  7873. var img = document.createElement('img');
  7874. img.src = URL_MZimg + 'recycl.png'
  7875. img.onclick = function(evt) {
  7876. document.location.href = document.location.href;
  7877. };
  7878. img.title = 'Mise à jour de la localisation';
  7879. img.style.cursor = 'pointer';
  7880. img.style.position = 'absolute';
  7881. img.style.bottom = 0;
  7882. img.style.left = 0;
  7883. div.appendChild(img);
  7884. }
  7885.  
  7886. function do_menu() {
  7887. // met à jour les carac sauvegardées (position, DLA, etc.)
  7888. updateData();
  7889. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7890. initRaccourcis();
  7891. // Ajout bouton de mise à jour coordonnées
  7892. initUpdateCoordGauche();
  7893. }
  7894.  
  7895. /*******************************************************************************
  7896. * This file is part of Mountyzilla. *
  7897. * *
  7898. * Mountyzilla is free software; you can redistribute it and/or modify *
  7899. * it under the terms of the GNU General Public License as published by *
  7900. * the Free Software Foundation; either version 2 of the License, or *
  7901. * (at your option) any later version. *
  7902. * *
  7903. * Mountyzilla is distributed in the hope that it will be useful, *
  7904. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7905. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7906. * GNU General Public License for more details. *
  7907. * *
  7908. * You should have received a copy of the GNU General Public License *
  7909. * along with Mountyzilla; if not, write to the Free Software *
  7910. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7911. *******************************************************************************/
  7912.  
  7913. // x~x vue
  7914.  
  7915. /* TODO
  7916. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7917. * prévoir fix ("delete infos")
  7918. */
  7919.  
  7920. /*--------------------------- Variables Globales -----------------------------*/
  7921.  
  7922. // Infos remplies par des scripts extérieurs
  7923. var listeCDM = [], listeLevels = [];
  7924.  
  7925. // Position actuelle
  7926. var currentPosition=[0,0,0];
  7927.  
  7928. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7929. var porteeVue=[0,0,0,0];
  7930.  
  7931. // Fenêtres déplaçables
  7932. var winCurr = null;
  7933. var offsetX, offsetY;
  7934.  
  7935. // Diplomatie
  7936. var Diplo = {
  7937. Guilde: {},
  7938. Troll: {},
  7939. Monstre: {}
  7940. // .mythiques: uniquement si option activée
  7941. };
  7942. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7943.  
  7944. // Infos tactiques
  7945. var popup;
  7946.  
  7947. // Gère l'affichage en cascade des popups de CdM
  7948. var nbCDM = 0;
  7949.  
  7950. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7951.  
  7952. // Utilisé pour supprimer les monstres "engagés"
  7953. var listeEngages = {};
  7954. var isEngagesComputed = false;
  7955. var cursorOnLink = false; // DEBUG: wtf ?
  7956.  
  7957. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7958. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7959.  
  7960. // Checkboxes de filtrage
  7961. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7962. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7963. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  7964. comboBoxNiveauMin, comboBoxNiveauMax;
  7965.  
  7966. /* Acquisition & Stockage des données de DB */
  7967. const typesAFetcher = {
  7968. 'monstres':1,
  7969. 'trolls':1,
  7970. 'tresors':1,
  7971. 'champignons':1,
  7972. 'lieux':1
  7973. }
  7974. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7975. tr_champignons = {}, tr_lieux = {};
  7976. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7977. nbChampignons = 0, nbLieux = 0;
  7978.  
  7979. function fetchData(type) {
  7980. try {
  7981. var node = document.getElementById('mh_vue_hidden_'+type);
  7982. // this = MZ.global = sandBox de travail de MZ
  7983. // On définit donc des variables MZ-globales
  7984. this['tr_'+type] = node.getElementsByTagName('tr');
  7985. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7986. } catch(e) {
  7987. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7988. }
  7989. }
  7990.  
  7991.  
  7992. /*---------------------------------- DEBUG -----------------------------------*/
  7993. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7994. var x_monstres = tr_monstres;
  7995. var x_trolls = tr_trolls;
  7996. var x_tresors = tr_tresors;
  7997. var x_champis = tr_champignons;
  7998. var x_lieux = tr_lieux;
  7999. /*-------------------------------- FIN DEBUG ---------------------------------*/
  8000.  
  8001.  
  8002. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8003.  
  8004. function positionToString(arr) {
  8005. return arr.join(';');
  8006. }
  8007.  
  8008. function savePosition() {
  8009. // Stocke la position (à jour) de la vue pour les autres scripts
  8010. // DEBUG: Lesquels et pourquoi?
  8011. var pos = getPosition();
  8012. MY_setValue(numTroll+'.position.X',pos[0]);
  8013. MY_setValue(numTroll+'.position.Y',pos[1]);
  8014. MY_setValue(numTroll+'.position.N',pos[2]);
  8015. }
  8016.  
  8017.  
  8018. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  8019. /* INFOS :
  8020. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  8021. * sont identifiables via leur Name
  8022. * les tables-listings sont identifiables via l'ID du tr conteneur
  8023. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  8024. */
  8025.  
  8026. /* [functions] Récup données Utilisateur */
  8027. function getPosition() {
  8028. // Pour rétrocompatibilité
  8029. return currentPosition;
  8030. }
  8031.  
  8032. function getPorteVue() {
  8033. // Pour rétrocompatibilité
  8034. return porteeVue;
  8035. }
  8036.  
  8037. function getVue() {
  8038. // Retourne [vueHpure, vueVpure]
  8039. var vues = getPorteVue();
  8040. return [ vues[0], vues[1] ];
  8041. }
  8042.  
  8043. // Roule 11/03/2016
  8044. /* [functions] Récup données monstres, trolls, etc. */
  8045. function getXxxDistance(xxx, i) {
  8046. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  8047. }
  8048. function getXxxPosition(xxx, i) {
  8049. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  8050. var l = tds.length;
  8051. return [
  8052. parseInt(tds[l-3].textContent),
  8053. parseInt(tds[l-2].textContent),
  8054. parseInt(tds[l-1].textContent)
  8055. ];
  8056. }
  8057.  
  8058.  
  8059. /* [functions] Récup données monstres */
  8060. function getMonstreDistance(i) {
  8061. return parseInt(tr_monstres[i].cells[0].textContent);
  8062. }
  8063.  
  8064. function getMonstreID(i) {
  8065. return tr_monstres[i].cells[2].firstChild.nodeValue;
  8066. }
  8067.  
  8068. function getMonstreIDByTR(tr) {
  8069. return tr.cells[2].firstChild.nodeValue;
  8070. }
  8071.  
  8072. function getMonstreLevelNode(i) {
  8073. return tr_monstres[i].cells[3];
  8074. }
  8075.  
  8076. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  8077. // function getMonstreLevel(i) {
  8078. // if(!isCDMsRetrieved) return -1;
  8079. // var donneesMonstre = listeCDM[getMonstreID(i)];
  8080. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  8081. // }
  8082.  
  8083. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  8084. if(!isCDMsRetrieved) return false;
  8085. var donneesMonstre = listeCDM[getMonstreID(i)];
  8086. if (!donneesMonstre) return false;
  8087. var nivTxt = donneesMonstre[0];
  8088. // calcul min/max du monstre
  8089. var monstreMin, monstreMax, iPos;
  8090. if (nivTxt.substring(0, 2) == '<=') {
  8091. monstreMin = 0;
  8092. monstreMax = parseInt(nivTxt.substring(2, 99));
  8093. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  8094. monstreMin = parseInt(nivTxt.substring(0, iPos));
  8095. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  8096. } else {
  8097. monstreMin = monstreMax = parseInt(nivTxt);
  8098. }
  8099. if (limitMin > 0 && monstreMax < limitMin) return true;
  8100. if (limitMax > 0 && monstreMin > limitMax) return true;
  8101. return false;
  8102. }
  8103.  
  8104. function getMonstreNomNode(i) {
  8105. try {
  8106. var td = document.evaluate(
  8107. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  8108. tr_monstres[i], null, 9, null
  8109. ).singleNodeValue;
  8110. return td;
  8111. } catch(e) {
  8112. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  8113. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  8114. }
  8115. }
  8116.  
  8117. function getMonstreNom(i) {
  8118. return getMonstreNomByTR(tr_monstres[i]);
  8119. }
  8120.  
  8121. function getMonstreNomByTR(tr) {
  8122. try {
  8123. var nom = document.evaluate(
  8124. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  8125. tr, null, 2, null
  8126. ).stringValue;
  8127. return nom;
  8128. } catch(e) {
  8129. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  8130. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  8131. }
  8132. }
  8133.  
  8134. function getMonstrePosition(i) {
  8135. var tds = tr_monstres[i].childNodes;
  8136. var l = tds.length;
  8137. return [
  8138. parseInt(tds[l-3].textContent),
  8139. parseInt(tds[l-2].textContent),
  8140. parseInt(tds[l-1].textContent)
  8141. ];
  8142. }
  8143.  
  8144. function appendMonstres(txt) {
  8145. for(var i=1; i<=nbMonstres ; i++)
  8146. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  8147. return txt;
  8148. }
  8149.  
  8150. function getMonstres() {
  8151. var vue = getVue();
  8152. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8153. }
  8154.  
  8155. function bddMonstres(start,stop) {
  8156. if(!start) { var start = 1; }
  8157. if(!stop) { var stop = nbMonstres; }
  8158. stop = Math.min(nbMonstres,stop);
  8159. var txt='';
  8160. for(var i=start ; i<=stop ; i++) {
  8161. txt += getMonstreID(i)+';'+
  8162. getMonstreNom(i)+';'+
  8163. positionToString(getMonstrePosition(i))+'\n';
  8164. }
  8165. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  8166. }
  8167.  
  8168. /* [functions] Récup données Trolls */
  8169. function getTrollDistance(i) {
  8170. return parseInt(tr_trolls[i].cells[0].textContent);
  8171. }
  8172.  
  8173. var MZ_cache_col_TrollID;
  8174. function getTrollID(i) {
  8175. // 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
  8176. if (MZ_cache_col_TrollID === undefined) {
  8177. if (tr_trolls[0].cells[1].textContent.toLowerCase().substring(0, 3) == 'réf') {
  8178. MZ_cache_col_TrollID = 1;
  8179. } else if (tr_trolls[0].cells[2].textContent.toLowerCase().substring(0, 3) == 'réf') {
  8180. MZ_cache_col_TrollID = 2;
  8181. } else {
  8182. 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);
  8183. MZ_cache_col_TrollID = 2;
  8184. }
  8185. }
  8186. // Roule 08/03/2017 protection
  8187. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  8188. if (isNaN(iTroll)) return;
  8189. if (iTroll == 0) return;
  8190. return iTroll;
  8191. }
  8192.  
  8193. function getTrollNomNode(i) {
  8194. var isEnvoiOn =
  8195. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  8196. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  8197. }
  8198.  
  8199. function getTrollNivNode(i) {
  8200. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  8201. return tr_trolls[i].cells[4];
  8202. }
  8203.  
  8204. function getTrollGuilde(i) {
  8205. return trim(tr_trolls[i].cells[6].textContent);
  8206. }
  8207.  
  8208. function getTrollGuildeID(i) {
  8209. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  8210. var href;
  8211. try {
  8212. 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"
  8213. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  8214. } catch(e) { // debug pb remonté par Marsak
  8215. window.console.error(traceStack(e, 'getTrollGuildeID')
  8216. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  8217. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  8218. return -1;
  8219. }
  8220. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  8221. }
  8222. return -1;
  8223. }
  8224.  
  8225. function getTrollPosition(i) {
  8226. var tds = tr_trolls[i].childNodes;
  8227. var l = tds.length;
  8228. return [
  8229. parseInt(tds[l-3].textContent),
  8230. parseInt(tds[l-2].textContent),
  8231. parseInt(tds[l-1].textContent)
  8232. ];
  8233. }
  8234.  
  8235. function bddTrolls() {
  8236. var txt='#DEBUT TROLLS\n'+
  8237. numTroll+';'+positionToString(getPosition())+'\n';
  8238. for(var i=1 ; i<=nbTrolls ; i++) {
  8239. txt += getTrollID(i)+';'+
  8240. positionToString(getTrollPosition(i))+'\n';
  8241. }
  8242. return txt+'#FIN TROLLS';
  8243. }
  8244.  
  8245. /* [functions] Récup données Trésors */
  8246. function getTresorDistance(i) {
  8247. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8248. }
  8249.  
  8250. function getTresorID(i) {
  8251. return trim(tr_tresors[i].cells[2].textContent);
  8252. }
  8253.  
  8254. function getTresorNom(i) {
  8255. // Utilisation de textContent pour régler le "bug de Pollux"
  8256. return trim(tr_tresors[i].cells[3].textContent);
  8257. }
  8258.  
  8259. function getTresorPosition(i) {
  8260. var tds = tr_tresors[i].childNodes;
  8261. var l = tds.length;
  8262. return [
  8263. parseInt(tds[l-3].textContent),
  8264. parseInt(tds[l-2].textContent),
  8265. parseInt(tds[l-1].textContent),
  8266. ];
  8267. }
  8268.  
  8269. function bddTresors(dmin,start,stop) {
  8270. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8271. if(!dmin) { var dmin = 0; }
  8272. if(!start) { var start = 1; }
  8273. if(!stop) { var stop = nbTresors; }
  8274. stop = Math.min(nbTresors,stop);
  8275. var txt='';
  8276. for(var i=start ; i<=stop ; i++) {
  8277. if(getTresorDistance(i)>=dmin) {
  8278. txt += getTresorID(i)+';'+
  8279. getTresorNom(i)+';'+
  8280. positionToString(getTresorPosition(i))+'\n';
  8281. }
  8282. }
  8283. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8284. }
  8285.  
  8286. /* [functions] Récup données Champignons */
  8287. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8288. function getChampignonNom(i) {
  8289. return trim(tr_champignons[i].cells[2].textContent);
  8290. }
  8291.  
  8292. function getChampignonPosition(i) {
  8293. var tds = tr_champignons[i].childNodes;
  8294. var l = tds.length;
  8295. return [
  8296. parseInt(tds[l-3].textContent),
  8297. parseInt(tds[l-2].textContent),
  8298. parseInt(tds[l-1].textContent)
  8299. ];
  8300. }
  8301.  
  8302. function bddChampignons() {
  8303. var txt='';
  8304. for(var i=1 ; i<=nbChampignons ; i++) {
  8305. txt += ';'+ // Les champis n'ont pas de Référence
  8306. getChampignonNom(i)+';'+
  8307. positionToString(getChampignonPosition(i))+'\n';
  8308. }
  8309. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8310. }
  8311.  
  8312. /* [functions] Récup données Lieux */
  8313. function getLieuDistance(i) {
  8314. return parseInt(tr_lieux[i].cells[0].textContent);
  8315. }
  8316.  
  8317. function getLieuID(i) {
  8318. return parseInt(tr_lieux[i].cells[2].textContent);
  8319. }
  8320.  
  8321. function getLieuNom(i) {
  8322. // Conversion ASCII pour éviter les bugs des Vues externes
  8323. return trim(tr_lieux[i].cells[3].textContent);
  8324. }
  8325.  
  8326. function getLieuPosition(i) {
  8327. var tds = tr_lieux[i].childNodes;
  8328. var l = tds.length;
  8329. return [
  8330. parseInt(tds[l-3].textContent),
  8331. parseInt(tds[l-2].textContent),
  8332. parseInt(tds[l-1].textContent)
  8333. ];
  8334. }
  8335.  
  8336. function appendLieux(txt) {
  8337. for(var i = 1; i < nbLieux+1; i++) {
  8338. var tds = x_lieux[i].childNodes;
  8339. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8340. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8341. }
  8342. return txt;
  8343. }
  8344.  
  8345. function getLieux() {
  8346. var vue = getVue();
  8347. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8348. }
  8349.  
  8350. function bddLieux(start,stop) {
  8351. if(!start) { var start = 1; }
  8352. if(!stop) { var stop = nbLieux; }
  8353. stop = Math.min(nbLieux,stop);
  8354. var txt='';
  8355. for(var i=start ; i<=stop ; i++) {
  8356. txt += getLieuID(i)+';'+
  8357. epure(getLieuNom(i))+';'+
  8358. positionToString(getLieuPosition(i))+'\n';
  8359. }
  8360. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8361. }
  8362.  
  8363.  
  8364. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8365.  
  8366. function saveCheckBox(chkbo, pref) {
  8367. // Enregistre et retourne l'état d'une CheckBox
  8368. var etat = chkbo.checked;
  8369. MY_setValue(pref, etat ? 'true' : 'false' );
  8370. return etat;
  8371. }
  8372.  
  8373. function recallCheckBox(chkbox, pref) {
  8374. // Restitue l'état d'une CheckBox
  8375. chkbox.checked = (MY_getValue(pref)=='true');
  8376. }
  8377.  
  8378. function saveComboBox(cbb, pref) {
  8379. // Enregistre et retourne l'état d'une ComboBox
  8380. var etat = cbb.selectedIndex;
  8381. MY_setValue(pref, etat);
  8382. return etat;
  8383. }
  8384.  
  8385. function recallComboBox(cbb, pref) {
  8386. // Restitue l'état d'une ComboBox
  8387. var nb = MY_getValue(pref);
  8388. if(nb) cbb.value = nb;
  8389. return nb;
  8390. }
  8391.  
  8392. function synchroniseFiltres() {
  8393. // Récupération de toutes les options de la vue
  8394. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8395. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8396. if(numBool) {
  8397. debutFiltrage('Monstres');
  8398. }
  8399. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  8400. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  8401. recallCheckBox(checkBoxMythiques,'NOMYTH');
  8402. recallCheckBox(checkBoxEngages,'NOENGAGE');
  8403. recallCheckBox(checkBoxLevels,'NOLEVEL');
  8404. recallCheckBox(checkBoxIntangibles,'NOINT');
  8405. recallCheckBox(checkBoxGG,'NOGG');
  8406. recallCheckBox(checkBoxCompos,'NOCOMP');
  8407. recallCheckBox(checkBoxBidouilles,'NOBID');
  8408. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  8409. recallCheckBox(checkBoxTrou,'NOTROU');
  8410. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8411. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  8412. if(MY_getValue('NOINFOEM')!='true')
  8413. recallCheckBox(checkBoxEM,'NOEM');
  8414. }
  8415.  
  8416.  
  8417. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  8418.  
  8419. function getVueScript() {
  8420. try {
  8421. var txt = bddTrolls()+
  8422. bddMonstres()+
  8423. bddChampignons()+
  8424. bddTresors()+
  8425. bddLieux()+
  8426. '#DEBUT ORIGINE\n'+
  8427. getPorteVue()[2]+';'+positionToString(getPosition())+
  8428. '\n#FIN ORIGINE\n';
  8429. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  8430. return txt;
  8431. } catch(e) {
  8432. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  8433. window.console.error(traceStack(e, 'getVueScript'))
  8434. }
  8435. }
  8436.  
  8437. /* [functions] Menu Vue 2D */
  8438. var vue2Ddata = {
  8439. 'Bricol\' Vue': {
  8440. url: URL_bricol_mountyhall + 'vue_form.php',
  8441. paramid: 'vue',
  8442. func: getVueScript,
  8443. extra_params: {
  8444. 'mode': 'vue_SP_Vue2',
  8445. 'screen_width': window.screen.width
  8446. }
  8447. },
  8448. 'Vue du CCM': {
  8449. url: URL_vue_CCM,
  8450. paramid: 'vue',
  8451. func: getVueScript,
  8452. extra_params: {
  8453. 'id': numTroll+';'+positionToString(getPosition())
  8454. }
  8455. },
  8456. 'Vue Gloumfs 2D': {
  8457. url: URL_vue_Gloumfs2D,
  8458. paramid: 'vue_mountyzilla',
  8459. func: getVueScript,
  8460. extra_params: {}
  8461. },
  8462. 'Vue Gloumfs 3D': {
  8463. url: URL_vue_Gloumfs3D,
  8464. paramid: 'vue_mountyzilla',
  8465. func: getVueScript,
  8466. extra_params: {}
  8467. },
  8468. 'Grouky Vue!': {
  8469. url: URL_vue_Grouky,
  8470. paramid: 'vue',
  8471. func: getVueScript,
  8472. extra_params: {
  8473. 'type_vue': 'V5b1'
  8474. }
  8475. },
  8476. /*'DEBUG': {
  8477. url: 'http://weblocal/testeur.php',
  8478. paramid: 'vue',
  8479. func: getVueScript,
  8480. extra_params: {}
  8481. }*/
  8482. };
  8483.  
  8484. function refresh2DViewButton() {
  8485. // = EventListener menu+bouton vue 2D
  8486. var vueext = document.getElementById('selectVue2D').value;
  8487. MY_setValue('VUEEXT',vueext);
  8488. var form = document.getElementById('viewForm');
  8489. form.innerHTML = '';
  8490. form.method = 'post';
  8491. form.action = vue2Ddata[vueext].url;
  8492. form.target = '_blank';
  8493. appendHidden(form, vue2Ddata[vueext].paramid, '');
  8494. for(var key in vue2Ddata[vueext].extra_params) {
  8495. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  8496. }
  8497. appendSubmit(form, 'Voir',
  8498. function() {
  8499. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  8500. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  8501. vue2Ddata[vueext].func();
  8502. }
  8503. );
  8504. }
  8505.  
  8506. function set2DViewSystem() {
  8507. // Initialise le système de vue 2D
  8508. // Recherche du point d'insertion
  8509. try {
  8510. var center = document.evaluate(
  8511. "//h2[@id='titre2']/following-sibling::center",
  8512. document, null, 9, null
  8513. ).singleNodeValue;
  8514. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  8515. if (!center) center = document.evaluate(
  8516. "//h2[@id='titre2']/following-sibling::div",
  8517. document, null, 9, null
  8518. ).singleNodeValue;
  8519. } catch(e) {
  8520. avertissement("Erreur d'initialisation du système de vue 2D");
  8521. window.console.error(traceStack(e, 'set2DViewSystem'));
  8522. return;
  8523. }
  8524. // Récupération de la dernière vue utilisée
  8525. var vueext = MY_getValue('VUEEXT');
  8526. if(!vueext || !vue2Ddata[vueext]) {
  8527. // sinon, la vue Bricol'Trolls est employée par défaut
  8528. vueext = 'Bricol\' Vue';
  8529. }
  8530. try {
  8531. // Création du sélecteur de vue externe
  8532. selectVue2D = document.createElement('select');
  8533. selectVue2D.id = 'selectVue2D';
  8534. selectVue2D.className = 'SelectboxV2';
  8535. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  8536. for(var view in vue2Ddata) {
  8537. appendOption(selectVue2D, view, view);
  8538. }
  8539. selectVue2D.value = vueext;
  8540. selectVue2D.onchange = refresh2DViewButton;
  8541. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  8542. var form = document.createElement('form');
  8543. form.id = 'viewForm';
  8544. // Insertion du système de vue
  8545. var table = document.createElement('table');
  8546. var tr = appendTr(table);
  8547. var td = appendTd(tr);
  8548. td.appendChild(selectVue2D);
  8549. td = appendTd(tr);
  8550. td.style.fontSize = '0px'; // gère le bug de l'extra character
  8551. td.appendChild(form);
  8552. center.insertBefore(table,center.firstChild);
  8553. insertBr(center.childNodes[1]);
  8554. // Appelle le handler pour initialiser le bouton de submit
  8555. refresh2DViewButton();
  8556. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  8557. } catch(e) {
  8558. avertissement("Erreur de traitement du système de vue 2D");
  8559. window.console.error(traceStack(e, 'set2DViewSystem'));
  8560. }
  8561. }
  8562.  
  8563. /* [functions] Tableau d'Infos */
  8564. function initialiseInfos() {
  8565. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  8566. var
  8567. infoTab = document.getElementsByName('LimitViewForm')[0].
  8568. getElementsByTagName('table')[0],
  8569. tbody = infoTab.tBodies[0],
  8570. thead = infoTab.createTHead(),
  8571. tr = appendTr(thead,'mh_tdtitre'),
  8572. td = appendTdText(tr,'INFORMATIONS',true),
  8573. span = document.createElement('span');
  8574. // Récupération de la position du joueur
  8575. try {
  8576. var strPos = document.evaluate(
  8577. ".//li/b/text()[contains(.,'X = ')]",
  8578. infoTab, null, 9, null
  8579. ).singleNodeValue.nodeValue;
  8580. // ***INIT GLOBALE*** currentPosition
  8581. currentPosition = getNumbers(strPos);
  8582. debugMZ("retrievePosition(): "+currentPosition);
  8583. } catch(e) {
  8584. // Si on ne trouve pas le "X ="
  8585. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  8586. }
  8587. // Récupération des portées (max et limitée) de la vue
  8588. try {
  8589. var
  8590. nodes = document.evaluate(
  8591. ".//li/b/text()[contains(.,'horizontalement') "+
  8592. "or contains(.,'verticalement')]",
  8593. infoTab, null, 7, null
  8594. ),
  8595. array = [];
  8596. for(var i=0 ; i<4 ; i++) {
  8597. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  8598. }
  8599. // ***INIT GLOBALE*** porteeVue
  8600. porteeVue = array;
  8601. } catch(e) {
  8602. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  8603. }
  8604.  
  8605. infoTab.id = 'infoTab'; // Pour scripts externes
  8606. tbody.id = 'corpsInfoTab';
  8607. tbody.rows[0].cells[0].colSpan = 2;
  8608. td.colSpan = 3;
  8609. td.onmouseover = function() {
  8610. this.style.cursor = 'pointer';
  8611. this.className = 'mh_tdpage';
  8612. };
  8613. td.onmouseout = function() {
  8614. this.className = 'mh_tdtitre';
  8615. };
  8616. td.onclick = function() {
  8617. toggleTableauInfos(false);
  8618. };
  8619. span.id = 'msgInfoTab';
  8620. span.style.display = 'none';
  8621. appendText(
  8622. span,
  8623. ' => Position : X = '+currentPosition[0]+
  8624. ', Y = '+currentPosition[1]+
  8625. ', N = '+currentPosition[2]+
  8626. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  8627. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  8628. true
  8629. );
  8630. td.appendChild(span);
  8631. tr = appendTr(tbody,'mh_tdpage');
  8632. td = appendTdText(tr,'EFFACER : ',true);
  8633. td.align = 'center';
  8634. td.className = 'mh_tdtitre';
  8635. td.width = 100;
  8636. td = appendTdCenter(tr,2);
  8637. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  8638. checkBoxGG = appendCheckBoxSpan(
  8639. td,'delgg',filtreTresors," Les GG'"
  8640. ).firstChild;
  8641. checkBoxCompos = appendCheckBoxSpan(
  8642. td,'delcomp',filtreTresors,' Les Compos'
  8643. ).firstChild;
  8644. checkBoxBidouilles = appendCheckBoxSpan(
  8645. td,'delbid',filtreTresors,' Les Bidouilles'
  8646. ).firstChild;
  8647. checkBoxIntangibles = appendCheckBoxSpan(
  8648. td,'delint',filtreTrolls,' Les Intangibles'
  8649. ).firstChild;
  8650. checkBoxGowapsA = appendCheckBoxSpan(
  8651. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  8652. ).firstChild;
  8653. checkBoxGowapsS = appendCheckBoxSpan(
  8654. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  8655. ).firstChild;
  8656. checkBoxEngages = appendCheckBoxSpan(
  8657. td,'delengage',filtreMonstres,' Les Engagés'
  8658. ).firstChild;
  8659. checkBoxLevels = appendCheckBoxSpan(
  8660. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  8661. ).firstChild;
  8662. checkBoxDiplo = appendCheckBoxSpan(
  8663. td,'delDiplo',refreshDiplo,' La Diplomatie'
  8664. ).firstChild;
  8665. checkBoxTrou = appendCheckBoxSpan(
  8666. td,'deltrou',filtreLieux,' Les Trous'
  8667. ).firstChild;
  8668. checkBoxMythiques = appendCheckBoxSpan(
  8669. td,'delmyth',filtreMonstres,' Les Mythiques'
  8670. ).firstChild;
  8671. if(MY_getValue('NOINFOEM')!='true') {
  8672. checkBoxEM = appendCheckBoxSpan(
  8673. td,'delem',filtreMonstres,' Les Composants EM'
  8674. ).firstChild;
  8675. }
  8676. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  8677. td,'deltres',filtreTresors,' Les Trésors non libres'
  8678. ).firstChild;
  8679. checkBoxTactique = appendCheckBoxSpan(
  8680. td,'deltactique',updateTactique,' Les Infos tactiques'
  8681. ).firstChild;
  8682. if(MY_getValue('INFOPLIE')) {
  8683. toggleTableauInfos(true);
  8684. }
  8685. }
  8686.  
  8687. function toggleTableauInfos(firstRun) {
  8688. var
  8689. msg = document.getElementById('msgInfoTab'),
  8690. corps = document.getElementById('corpsInfoTab'),
  8691. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8692. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  8693. if(!firstRun) {
  8694. infoplie = !infoplie;
  8695. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8696. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  8697. }
  8698. if(infoplie) {
  8699. msg.style.display = '';
  8700. corps.style.display = 'none';
  8701. } else {
  8702. msg.style.display = 'none';
  8703. corps.style.display = '';
  8704. }
  8705. }
  8706.  
  8707. /* [functions] Filtres */
  8708. function prepareFiltrage(ref,width) {
  8709. // = Initialise le filtre 'ref'
  8710. try {
  8711. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  8712. } catch(e) {
  8713. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  8714. return false;
  8715. }
  8716. if(width) { tdTitre.width = width; }
  8717. // Ajout du tr de Filtrage (masqué)
  8718. var tbody = tdTitre.parentNode.parentNode;
  8719. var tr = appendTr(tbody,'mh_tdpage');
  8720. tr.style.display = 'none';
  8721. tr.id = 'trFiltre'+ref;
  8722. var td = appendTd(tr);
  8723. td.colSpan = 5;
  8724. // Ajout du bouton de gestion de Filtrage
  8725. var tdBtn = insertTd(tdTitre.nextSibling);
  8726. tdBtn.id = 'tdInsert'+ref;
  8727. var btn = appendButton(tdBtn,'Filtrer');
  8728. btn.id = 'btnFiltre'+ref;
  8729. btn.onclick = function() {
  8730. debutFiltrage(ref)
  8731. };
  8732. return td;
  8733. }
  8734.  
  8735. function debutFiltrage(ref) {
  8736. // = Handler de début de filtrage (filtre 'ref')
  8737. document.getElementById('trFiltre'+ref).style.display = '';
  8738. var btn = document.getElementById('btnFiltre'+ref);
  8739. btn.value = 'Annuler Filtre';
  8740. btn.onclick = function() {
  8741. finFiltrage(ref);
  8742. };
  8743. }
  8744.  
  8745. function finFiltrage(ref) {
  8746. // = Handler de fin de filtrage (filtre 'ref')
  8747. /* On réassigne le bouton 'Filtrer' */
  8748. document.getElementById('trFiltre'+ref).style.display = 'none';
  8749. var btn = document.getElementById('btnFiltre'+ref);
  8750. btn.value = 'Filtrer';
  8751. btn.onclick = function() {
  8752. debutFiltrage(ref);
  8753. };
  8754. /* Réinitialisation filtres */
  8755. document.getElementById('str'+ref).value = '';
  8756. switch(ref) {
  8757. case 'Monstres':
  8758. document.getElementById('nivMinMonstres').value = 0;
  8759. document.getElementById('nivMaxMonstres').value = 0;
  8760. break;
  8761. case 'Trolls':
  8762. document.getElementById('strGuildes').value = '';
  8763. }
  8764. /* Nettoyage (=lance le filtre) */
  8765. // Ici this = MZ.global = sandBox de travail de MZ
  8766. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  8767. //this['filtre'+ref]();
  8768. switch (ref) {
  8769. case 'Monstres':
  8770. filtreMonstres();
  8771. break;
  8772. case 'Trolls':
  8773. filtreTrolls();
  8774. break;
  8775. case 'Tresors':
  8776. filtreTresors();
  8777. break;
  8778. case 'Lieux':
  8779. filtreLieux();
  8780. break;
  8781. default:
  8782. window.console.log('cas incongru dans finFiltrage : ' + ref);
  8783. break;
  8784. }
  8785. }
  8786.  
  8787. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  8788. var bouton = appendButton(td,nomBouton,onClick);
  8789. appendText(td,'\u00a0');
  8790. var textbox = appendTextbox(td,'text',id,15,30);
  8791. textbox.onkeypress = function(event) {
  8792. try {
  8793. if(event.keyCode==13) {
  8794. event.preventDefault();
  8795. bouton.click();
  8796. }
  8797. }
  8798. catch(e){
  8799. window.alert(e)
  8800. }
  8801. };
  8802. }
  8803.  
  8804. function ajoutFiltreMenu(tr,id,onChange) {
  8805. var select = document.createElement('select');
  8806. select.id = id;
  8807. select.onchange = onChange;
  8808. appendOption(select,0,'Aucun');
  8809. for(var i=1 ; i<=60 ; i++) {
  8810. appendOption(select,i,i);
  8811. }
  8812. tr.appendChild(select);
  8813. return select;
  8814. }
  8815.  
  8816. function ajoutDesFiltres() {
  8817. /* Monstres */
  8818. var td = prepareFiltrage('Monstres',120);
  8819. if(td) {
  8820. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  8821. appendText(td,'\u00a0\u00a0\u00a0');
  8822. appendText(td,'Niveau Min: ');
  8823. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  8824. appendText(td,'\u00a0');
  8825. appendText(td,'Niveau Max: ');
  8826. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  8827. }
  8828. /* Trõlls */
  8829. td = prepareFiltrage('Trolls',50);
  8830. if(td) {
  8831. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  8832. appendText(td,'\u00a0\u00a0\u00a0');
  8833. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  8834. }
  8835. /* Trésors */
  8836. td = prepareFiltrage('Tresors',55);
  8837. if(td) {
  8838. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  8839. }
  8840. /* Lieux */
  8841. td = prepareFiltrage('Lieux',40);
  8842. if(td) {
  8843. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  8844. }
  8845. }
  8846.  
  8847. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  8848.  
  8849. /* [functions] Affichage de la colonne des niveaux */
  8850. function insertLevelColumn() {
  8851. // Déclenché si bascule vers affichage des niveaux des mobs
  8852. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8853. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  8854. td.width = 25;
  8855. for(var i=1 ; i<=nbMonstres ; i++) {
  8856. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8857. td = insertTdText(getMonstreLevelNode(i), '-');
  8858. td.onclick = function() {
  8859. basculeCDM(
  8860. getMonstreNomByTR(this.parentNode),
  8861. getMonstreIDByTR(this.parentNode)
  8862. );
  8863. };
  8864. td.onmouseover = function() {
  8865. this.style.cursor = 'pointer';
  8866. this.className = 'mh_tdtitre';
  8867. };
  8868. td.onmouseout = function() {
  8869. if(this.parentNode.diploActive=='oui') {
  8870. this.className = '';
  8871. } else {
  8872. this.className = 'mh_tdpage';
  8873. }
  8874. };
  8875. td.style = 'font-weight:bold;text-align:center;';
  8876. if(isCDMsRetrieved) {
  8877. // Rappel des niveaux si mémorisés
  8878. td.innerHTML = listeLevels[i];
  8879. }
  8880. }
  8881. }
  8882.  
  8883. function toggleLevelColumn() {
  8884. // = Handler checkBox noLevel
  8885. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  8886. insertLevelColumn();
  8887. if(!isCDMsRetrieved) { retrieveCDMs(); }
  8888. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  8889. for(var i=0 ; i<=nbMonstres ; i++) {
  8890. if(isCDMsRetrieved) {
  8891. // Mémorisation des niveaux pour rappel éventuel
  8892. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  8893. }
  8894. // Suppression du td Niveau
  8895. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  8896. }
  8897. }
  8898. }
  8899.  
  8900. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  8901. function basculeCDM(nom,id) {
  8902. // = Bascule l'affichage des popups CdM
  8903. if(listeCDM[id]) {
  8904. if(!document.getElementById('popupCDM'+id)) {
  8905. afficherCDM(nom, id);
  8906. } else {
  8907. cacherPopupCDM('popupCDM'+id);
  8908. }
  8909. }
  8910. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  8911. }
  8912.  
  8913. function cacherPopupCDM(titre) {
  8914. var popup = document.getElementById(titre);
  8915. popup.parentNode.removeChild(popup);
  8916. }
  8917.  
  8918. /* DEBUG: Section à mettre à jour */
  8919. var selectionFunction;
  8920.  
  8921. function startDrag(evt) {
  8922. winCurr = this.parentNode;
  8923. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  8924. offsetX = evt.pageX - parseInt( winCurr.style.left );
  8925. offsetY = evt.pageY - parseInt( winCurr.style.top );
  8926. selectionFunction = document.body.style.MozUserSelect;
  8927. document.body.style.MozUserSelect = 'none';
  8928. winCurr.style.MozUserSelect = 'none';
  8929. return false;
  8930. }
  8931.  
  8932. function stopDrag(evt) {
  8933. winCurr.style.MozUserSelect = selectionFunction;
  8934. document.body.style.MozUserSelect = selectionFunction;
  8935. winCurr = null;
  8936. }
  8937.  
  8938. function drag(evt) {
  8939. if(winCurr==null) { return; }
  8940. evt = evt || window.event;
  8941. winCurr.style.left = (evt.pageX - offsetX)+'px';
  8942. winCurr.style.top = (evt.pageY - offsetY)+'px';
  8943. return false;
  8944. }
  8945. /* FIN DEBUG */
  8946. document.onmousemove = drag;
  8947.  
  8948. function afficherCDM(nom,id) {
  8949. // Crée la table de CdM du mob n° id
  8950. var donneesMonstre = listeCDM[id];
  8951. /* Début création table */
  8952. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8953. table.id = 'popupCDM'+id;
  8954. table.style =
  8955. 'position:fixed;'+
  8956. 'z-index:1;'+
  8957. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8958. 'left:'+(window.innerWidth-365)+'px;'+
  8959. 'width:300px;'+
  8960. 'height:200px;';
  8961. /* Ajout du titre avec gestion Drag & Drop */
  8962. var tr = table.firstChild;
  8963. tr.style.cursor = 'move';
  8964. tr.onmousedown = startDrag;
  8965. tr.onmouseup = stopDrag;
  8966. /* Ajout du bouton "Fermer" */
  8967. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8968. tr.onmouseover = function() {
  8969. this.style.cursor = 'pointer';
  8970. this.className = 'mh_tdpage';
  8971. };
  8972. tr.onmouseout = function() {
  8973. this.className = 'mh_tdtitre';
  8974. };
  8975. tr.idcdm = id;
  8976. tr.onclick = function() {
  8977. cacherPopupCDM('popupCDM'+this.idcdm);
  8978. this.className = 'mh_tdtitre';
  8979. };
  8980. td = appendTdText(tr,'Fermer',true);
  8981. td.colSpan = 2;
  8982. td.style = 'text-align:center;';
  8983. nbCDM++;
  8984. /* Fin création table & Affichage */
  8985. document.body.appendChild(table);
  8986. }
  8987.  
  8988. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8989. function initPopupVue() {
  8990. popup = document.createElement('div');
  8991. popup.id = 'popup';
  8992. popup.className = 'mh_textbox';
  8993. popup.style =
  8994. 'position: absolute;'+
  8995. 'border: 1px solid #000000;'+
  8996. 'visibility: hidden;'+
  8997. 'display: inline;'+
  8998. 'z-index: 3;'+
  8999. 'max-width: 400px;';
  9000. document.body.appendChild(popup);
  9001. }
  9002.  
  9003. /* [functions] Récupération / Computation des Infos Tactiques */
  9004. // TODO à revoir
  9005. function retireMarquage(nom) {
  9006. var i = nom.indexOf(']');
  9007. switch(i) {
  9008. case -1:
  9009. case nom.length-1:
  9010. return nom;
  9011. default:
  9012. return nom.slice(0,i+1);
  9013. }
  9014. }
  9015.  
  9016. function showPopupError(sHTML) {
  9017. window.console.log('[MZ] affichage PopupError ' + sHTML);
  9018. var divpopup = document.createElement('div');
  9019. divpopup.id = 'divpopup';
  9020. divpopup.style =
  9021. 'position: fixed;'+
  9022. 'border: 3px solid #000000;'+
  9023. 'top: 300px;left: 10px;'+
  9024. 'background-color: red;'+
  9025. 'color: white;'+
  9026. 'font-size: xx-large;'+
  9027. 'z-index: 200;';
  9028. divpopup.innerHTML = sHTML;
  9029. var divcroix = document.createElement('div');
  9030. divcroix.style =
  9031. 'position: absolute;'+
  9032. 'top: 0;right: 0;'+
  9033. 'color: inherit;'+
  9034. 'font-size: inherit;'+
  9035. 'cursor: pointer;'+
  9036. 'z-index: 201;';
  9037. divcroix.innerHTML = "X";
  9038. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  9039. document.body.appendChild(divpopup);
  9040. divpopup.appendChild(divcroix);
  9041. }
  9042.  
  9043. function retrieveCDMs() {
  9044. // Récupère les CdM disponibles dans la BDD
  9045. // Lancé uniquement sur toggleLevelColumn
  9046. if(checkBoxLevels.checked) { return; }
  9047. var str = '';
  9048. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  9049. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  9050. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  9051. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  9052. for(var i=1 ; i<=cdmMax ; i++) {
  9053. var nomMonstre = retireMarquage(getMonstreNom(i));
  9054. if(nomMonstre.indexOf(']') != -1) {
  9055. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  9056. }
  9057. // *** WARNING : PROXY RATIBUS ***
  9058. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  9059. str += 'nom[]='+escape(nomMonstre)+'$'+(
  9060. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  9061. )+'&';
  9062. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  9063. FF_XMLHttpRequest({
  9064. method: 'POST',
  9065. url: URL_MZinfoMonstre,
  9066. headers : {
  9067. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9068. 'Accept': 'application/atom+xml,application/xml,text/xml',
  9069. 'Content-type':'application/x-www-form-urlencoded'
  9070. },
  9071. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  9072. onload: function(responseDetails) {
  9073. try {
  9074. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9075. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  9076. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  9077. '" target="raistlin">Mountyzilla - https<br />'+
  9078. 'Tu dois accepter le certificat de Raistlin<br />'+
  9079. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  9080. ' « Confirmer l\'exception de sécurité »</a>');
  9081. return;
  9082. }
  9083. var texte = responseDetails.responseText;
  9084. var lines = texte.split('\n');
  9085. if(lines.length==0) { return; }
  9086. var begin2, end2, index;
  9087. for(var j=0 ; j<lines.length ; j++) {
  9088. var infos = lines[j].split(';');
  9089. if(infos.length<4) { continue; }
  9090. var idMonstre=infos[0];
  9091. var isCDM = infos[1];
  9092. index = parseInt(infos[2]);
  9093. var level = infos[3];
  9094. infos = infos.slice(3);
  9095. infos['iTR'] = j; // Roule 29/04/2017 permet de récupérer la position du monstres dans analyseTactique (pour calcul de distance pour le PM)
  9096. if(begin2==null) { begin2 = index; }
  9097. end2 = index;
  9098. listeCDM[idMonstre] = infos;
  9099. if(isCDM==1) {
  9100. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9101. } else {
  9102. getMonstreLevelNode(index).innerHTML = level;
  9103. }
  9104. }
  9105. computeMission(begin2,end2);
  9106. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9107. } catch(e) {
  9108. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9109. }
  9110. }
  9111. });
  9112. str = '';
  9113. begin = i+1;
  9114. }
  9115. }
  9116. isCDMsRetrieved=true;
  9117. }
  9118.  
  9119. function computeMission(begin,end) {
  9120. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  9121. computeVLC(begin,end);
  9122. if(!begin) begin=1;
  9123. if(!end) end=nbMonstres;
  9124. var str = MY_getValue(numTroll+'.MISSIONS');
  9125. if(!str) { return; }
  9126. var urlImg = URL_MZimg+'mission.png';
  9127. var obMissions = JSON.parse(str);
  9128. for(var i=end ; i>=begin ; i--) {
  9129. var mess = '';
  9130. for(var num in obMissions) {
  9131. var mobMission = false;
  9132. switch(obMissions[num].type) {
  9133. case 'Race':
  9134. var race = epure(obMissions[num].race.toLowerCase());
  9135. var nom = epure(getMonstreNom(i).toLowerCase());
  9136. if(nom.indexOf(race)!=-1) {
  9137. mobMission = true;
  9138. }
  9139. break;
  9140. case 'Niveau':
  9141. var donneesMonstre = listeCDM[getMonstreID(i)];
  9142. if(donneesMonstre) {
  9143. var nivMob = Number(donneesMonstre[0]);
  9144. var nivMimi = Number(obMissions[num].niveau),
  9145. mod = obMissions[num].mod;
  9146. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  9147. || (isNaN(mod) && nivMob>=nivMimi)) {
  9148. mobMission = true;
  9149. }
  9150. }
  9151. break;
  9152. case 'Famille':
  9153. var donneesMonstre = listeCDM[getMonstreID(i)];
  9154. if(donneesMonstre) {
  9155. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  9156. var familleMob = epure(donneesMonstre[1].toLowerCase());
  9157. if(familleMob.indexOf(familleMimi)!=-1) {
  9158. mobMission = true;
  9159. }
  9160. }
  9161. break;
  9162. case 'Pouvoir':
  9163. var donneesMonstre = listeCDM[getMonstreID(i)];
  9164. if(donneesMonstre) {
  9165. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  9166. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  9167. if(pvrMob.indexOf(pvrMimi)!=-1) {
  9168. mobMission = true;
  9169. }
  9170. }
  9171. }
  9172. if(mobMission) {
  9173. mess += mess ? '\n\n' : '';
  9174. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  9175. }
  9176. }
  9177. if(mess) {
  9178. var td = getMonstreNomNode(i);
  9179. appendText(td,' ');
  9180. td.appendChild(createImage(urlImg,mess));
  9181. }
  9182. }
  9183. }
  9184.  
  9185. function computeVLC(begin,end) {
  9186. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  9187. computeTactique(begin,end);
  9188. if(!begin) begin=1;
  9189. if(!end) end=nbMonstres;
  9190. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  9191. if(!cache)
  9192. return false;
  9193. var urlImg = URL_MZimg + "oeil.png";
  9194. for(var i = end; i >= begin;i--)
  9195. {
  9196. var id = getMonstreID(i);
  9197. var donneesMonstre = listeCDM[id];
  9198. if(donneesMonstre && donneesMonstre.length>12)
  9199. {
  9200. if(donneesMonstre[12]==1)
  9201. {
  9202. var td = getMonstreNomNode(i);
  9203. td.appendChild(document.createTextNode(" "));
  9204. td.appendChild(createImage(urlImg, "Voit le caché"));
  9205. }
  9206. }
  9207. }
  9208. }
  9209.  
  9210. /* appelé
  9211. par updateTactique
  9212. par initialiseInfos
  9213. par do_vue
  9214. par computeVLC
  9215. par computeMission
  9216. par filtreMonstres
  9217. par retrieveCDMs
  9218. */
  9219. function computeTactique(begin, end) {
  9220. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  9221. try {
  9222. if(!begin) begin = 1;
  9223. if(!end) end = nbMonstres;
  9224. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9225. if(noTactique || !isProfilActif()) return;
  9226. for(var j=end ; j>=begin ; j--) {
  9227. var id = getMonstreID(j);
  9228. var nom = getMonstreNom(j);
  9229. var donneesMonstre = listeCDM[id];
  9230. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  9231. var td = getMonstreNomNode(j);
  9232. appendText(td,' ');
  9233. td.appendChild(
  9234. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  9235. );
  9236. }
  9237. }
  9238. }
  9239. catch(e) {
  9240. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  9241. }
  9242. filtreMonstres();
  9243. }
  9244.  
  9245. function updateTactique() {
  9246. // = Handler checkBox noTactique
  9247. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9248. if(!isCDMsRetrieved) return;
  9249. if(noTactique) {
  9250. for(var i=nbMonstres ; i>0 ; i--) {
  9251. var tr = getMonstreNomNode(i);
  9252. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9253. tr, null, 9, null).singleNodeValue;
  9254. if(img) {
  9255. img.parentNode.removeChild(img.previousSibling);
  9256. img.parentNode.removeChild(img);
  9257. }
  9258. }
  9259. }
  9260. else
  9261. computeTactique();
  9262. }
  9263.  
  9264. function filtreMonstres() {
  9265. // = Handler universel pour les fonctions liées aux monstres
  9266. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9267. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9268. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9269. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9270. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9271. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9272. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9273. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9274. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9275. // old/new : détermine s'il faut ou non nettoyer les tr
  9276. var oldNOEM = true, noEM = true;
  9277. if(MY_getValue('NOINFOEM')!='true') {
  9278. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9279. }
  9280. // Filtrage par nom
  9281. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9282. // Génère la liste des mobs engagés (si filtrés)
  9283. if(noEngages && !isEngagesComputed) {
  9284. for(var i=nbTrolls ; i>0 ; i--) {
  9285. var pos = getTrollPosition(i);
  9286. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  9287. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  9288. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  9289. }
  9290. isEngagesComputed = true;
  9291. }
  9292. /*** FILTRAGE ***/
  9293. /* À computer :
  9294. * - EM (nom suffit)
  9295. * - Enchant (nom suffit)
  9296. * - Mission (nécessite CdM)
  9297. * - mob VlC (nécessite CdM)
  9298. * Sans computation :
  9299. * - Gowap ? engagé ?
  9300. */
  9301. for(var i=nbMonstres ; i>0 ; i--) {
  9302. var pos = getMonstrePosition(i);
  9303. var nom = getMonstreNom(i).toLowerCase();
  9304. if(noEM!=oldNOEM) {
  9305. if(noEM) {
  9306. // Si noEM passe de false à true, on nettoie les td "Nom"
  9307. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  9308. var tr = getMonstreNomNode(i);
  9309. while(tr.childNodes.length>1) {
  9310. tr.removeChild(tr.childNodes[1]);
  9311. }
  9312. } else {
  9313. var tr = getMonstreNomNode(i);
  9314. var TypeMonstre=getEM(nom);
  9315. if(TypeMonstre!='') {
  9316. var infosCompo=compoMobEM(TypeMonstre);
  9317. if(infosCompo.length>0) {
  9318. tr.appendChild(document.createTextNode(' '));
  9319. tr.appendChild(createImage(urlImg, infosCompo));
  9320. }
  9321. }
  9322. }
  9323. }
  9324. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  9325. var texte = getInfoEnchantementFromMonstre(nom);
  9326. if(texte!='') {
  9327. var td = getMonstreNomNode(i);
  9328. td.appendChild(document.createTextNode(' '));
  9329. td.appendChild(createImage(urlEnchantImg, texte));
  9330. }
  9331. }
  9332. tr_monstres[i].style.display = (
  9333. noGowapsS &&
  9334. nom.indexOf('gowap sauvage')!=-1 &&
  9335. getMonstreDistance(i)>1
  9336. ) || (
  9337. noGowapsA &&
  9338. nom.indexOf('gowap apprivoisé')!=-1 &&
  9339. getMonstreDistance(i)>1
  9340. ) || (
  9341. noEngages &&
  9342. getMonstreDistance(i)!=0 &&
  9343. listeEngages[pos[0]] &&
  9344. listeEngages[pos[0]][pos[1]] &&
  9345. listeEngages[pos[0]][pos[1]][pos[2]]
  9346. ) || (
  9347. strMonstre!='' &&
  9348. nom.indexOf(strMonstre)==-1
  9349. ) || (
  9350. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  9351. getMonstreDistance(i)>1 &&
  9352. nom.toLowerCase().indexOf("kilamo")==-1
  9353. ) ? 'none' : '';
  9354. }
  9355. if(MY_getValue('NOINFOEM')!='true') {
  9356. if(noEM != oldNOEM) {
  9357. if(noEM && isCDMsRetrieved) computeMission();
  9358. }
  9359. oldNOEM = noEM;
  9360. }
  9361. needComputeEnchantement = false;
  9362. }
  9363.  
  9364.  
  9365. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  9366.  
  9367. function filtreTrolls() {
  9368. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  9369. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  9370. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  9371. for(var i=1 ; i<=nbTrolls ; i++) {
  9372. tr_trolls[i].style.display = (
  9373. noIntangibles &&
  9374. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  9375. ) || (
  9376. strTroll!='' &&
  9377. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  9378. ) || (
  9379. strGuilde!='' &&
  9380. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  9381. ) ? 'none' : '';
  9382. }
  9383. }
  9384.  
  9385. /* [functions] Bulle PX Trolls */
  9386. var bulle;
  9387.  
  9388. function initPXTroll() {
  9389. bulle = document.createElement('div');
  9390. bulle.id = 'bulle';
  9391. bulle.className = 'mh_textbox';
  9392. bulle.style =
  9393. 'position: absolute;'+
  9394. 'border: 1px solid #000000;'+
  9395. 'visibility: hidden;'+
  9396. 'display: inline;'+
  9397. 'z-index: 2;';
  9398. document.body.appendChild(bulle);
  9399.  
  9400. for(var i=nbTrolls ; i>0 ; i--) {
  9401. var td_niv = getTrollNivNode(i);
  9402. td_niv.onmouseover = showPXTroll;
  9403. td_niv.onmouseout = hidePXTroll;
  9404. }
  9405. }
  9406.  
  9407. function showPXTroll(evt) {
  9408. var lvl = this.firstChild.nodeValue;
  9409. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  9410. bulle.style.left = evt.pageX+15+'px';
  9411. bulle.style.top = evt.pageY+'px';
  9412. bulle.style.visibility = 'visible';
  9413. }
  9414.  
  9415. function hidePXTroll() {
  9416. bulle.style.visibility = 'hidden';
  9417. }
  9418.  
  9419. /* [functions] Envoi PX / MP */
  9420. function putBoutonPXMP() {
  9421. // Bouton d'initialisation du mode Envoi
  9422. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  9423. var td = document.getElementById('tdInsertTrolls');
  9424. if(!td) { return; }
  9425. td.width = 100;
  9426. td = insertTd(td.nextSibling);
  9427. td.style.verticalAlign = 'top';
  9428. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  9429. bouton.id = 'btnEnvoi';
  9430. }
  9431.  
  9432. function prepareEnvoi() {
  9433. // = 1er Handler du bouton d'envoi
  9434. /* Ajout de la colonne des CheckBoxes */
  9435. var td = insertTdText(getTrollNomNode(0),'');
  9436. td.width = 5;
  9437. for(var i=nbTrolls ; i>0 ; i--) {
  9438. td = insertTd(getTrollNomNode(i));
  9439. appendCheckBox(td,'envoi'+i);
  9440. }
  9441. /* Ajout du radio de choix PX ou MP */
  9442. var btnEnvoi = document.getElementById('btnEnvoi');
  9443. if(!btnEnvoi) { return; }
  9444. var tdEnvoi = btnEnvoi.parentNode;
  9445. appendText(tdEnvoi,' ');
  9446. var span = document.createElement('span');
  9447. span.style.whiteSpace = 'nowrap';
  9448. var radioElt = document.createElement('input');
  9449. radioElt.type = 'radio';
  9450. radioElt.name = 'envoiPXMP';
  9451. radioElt.id = 'radioPX';
  9452. span.appendChild(radioElt);
  9453. appendText(span,' des PX ');
  9454. radioElt = document.createElement('input');
  9455. radioElt.type = 'radio';
  9456. radioElt.name = 'envoiPXMP';
  9457. radioElt.checked = true;
  9458. span.appendChild(radioElt);
  9459. appendText(span,' un MP');
  9460. tdEnvoi.appendChild(span);
  9461. /* Insertion du bouton Annuler */
  9462. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  9463. /* Modification de l'effet du bouton Envoi */
  9464. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  9465. }
  9466.  
  9467. function annuleEnvoi() {
  9468. // = Handler bouton Annuler
  9469. /* Nettoyage du td du bouton Envoi */
  9470. var btnEnvoi = document.getElementById('btnEnvoi');
  9471. var tdEnvoi = btnEnvoi.parentNode;
  9472. while(tdEnvoi.firstChild) {
  9473. tdEnvoi.removeChild(tdEnvoi.firstChild);
  9474. }
  9475. /* Retour à l'effet de base du bouton Envoi */
  9476. btnEnvoi.onclick = prepareEnvoi;
  9477. tdEnvoi.appendChild(btnEnvoi);
  9478. /* Suppression CheckBoxes */
  9479. for(var i=nbTrolls ; i>=0 ; i--) {
  9480. var td = getTrollNomNode(i);
  9481. td.parentNode.removeChild(td);
  9482. }
  9483. }
  9484.  
  9485. function effectueEnvoi() {
  9486. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  9487. var str='';
  9488. var errID = false;
  9489. for(var i=nbTrolls ; i>0 ; i--) {
  9490. var chb = document.getElementById('envoi'+i);
  9491. if(chb.checked) {
  9492. var idTroll = getTrollID(i);
  9493. if (idTroll == undefined) {
  9494. errID = true;
  9495. } else {
  9496. str += (str ? ',' : '') + idTroll;
  9497. }
  9498. }
  9499. }
  9500. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  9501. var PXchecked = document.getElementById('radioPX').checked;
  9502. if(PXchecked) {
  9503. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  9504. } else {
  9505. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  9506. }
  9507. }
  9508.  
  9509. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  9510.  
  9511. function filtreTresors() {
  9512. // += Handler checkboxes : gg, compos, bidouilles, non libres
  9513. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  9514. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  9515. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  9516. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9517. if(noEngages && !isEngagesComputed) {
  9518. for(var i=nbTrolls ; i>0 ; i--) {
  9519. var pos = getTrollPosition(i);
  9520. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  9521. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  9522. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  9523. }
  9524. isEngagesComputed = true;
  9525. }
  9526. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  9527. for(var i=nbTresors ; i>0 ; i--) {
  9528. var nom = getTresorNom(i);
  9529. var pos = getTresorPosition(i);
  9530. tr_tresors[i].style.display = (
  9531. noGG &&
  9532. nom.indexOf('Gigots de Gob')!=-1
  9533. ) || (
  9534. noCompos &&
  9535. nom.indexOf('Composant')!=-1
  9536. ) || (
  9537. noEngages &&
  9538. listeEngages[pos[2]] &&
  9539. listeEngages[pos[2]][pos[1]] &&
  9540. listeEngages[pos[2]][pos[1]][pos[0]] &&
  9541. getTresorDistance(i)>0
  9542. ) || (
  9543. strTresor!='' &&
  9544. nom.toLowerCase().indexOf(strTresor)==-1
  9545. ) || (
  9546. noBidouilles &&
  9547. nom.indexOf('Bidouille')!=-1
  9548. ) ? 'none' : '';
  9549. }
  9550. }
  9551.  
  9552.  
  9553. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  9554.  
  9555. function filtreLieux() {
  9556. // += Handler checkbox trous
  9557. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  9558. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  9559. for(var i=nbLieux ; i>0 ; i--) {
  9560. tr_lieux[i].style.display = (
  9561. strLieu &&
  9562. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  9563. ) || (
  9564. noTrou &&
  9565. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  9566. getLieuDistance(i)>1
  9567. ) ? 'none' : '';
  9568. }
  9569. }
  9570.  
  9571.  
  9572. /*-[functions]-------------------- Diplomatie --------------------------------*/
  9573.  
  9574. function refreshDiplo() {
  9575. MY_setValue(numTroll+'.diplo.off',
  9576. checkBoxDiplo.checked?'true':'false'
  9577. );
  9578. if(isDiploRaw) { computeDiplo(); }
  9579. appliqueDiplo();
  9580. }
  9581.  
  9582. function computeDiplo() {
  9583. // On extrait les données de couleur et on les stocke par id
  9584. // Ordre de préséance :
  9585. // source Guilde < source Perso
  9586. // guilde cible < troll cible
  9587. /* Diplo de Guilde */
  9588. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  9589. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  9590. if(diploGuilde && diploGuilde.isOn=='true') {
  9591. // Guilde perso
  9592. if(diploGuilde.guilde) {
  9593. Diplo.Guilde[diploGuilde.guilde.id] = {
  9594. couleur: diploGuilde.guilde.couleur,
  9595. titre: 'Ma Guilde'
  9596. };
  9597. }
  9598. // Guildes/Trolls A/E
  9599. for(var AE in {Amis:0,Ennemis:0}) {
  9600. for(var i=0 ; i<5 ; i++) {
  9601. if(diploGuilde[AE+i]) {
  9602. for(var type in {Guilde:0,Troll:0}) {
  9603. var liste = diploGuilde[AE+i][type].split(';');
  9604. for(var j=liste.length-2 ; j>=0 ; j--) {
  9605. Diplo[type][liste[j]] = {
  9606. couleur: diploGuilde[AE+i].couleur,
  9607. titre: diploGuilde[AE+i].titre
  9608. };
  9609. }
  9610. }
  9611. }
  9612. }
  9613. }
  9614. }
  9615. /* Diplo Perso */
  9616. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  9617. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  9618. if(diploPerso && diploPerso.isOn=='true') {
  9619. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  9620. for(var id in diploPerso[type]) {
  9621. Diplo[type][id] = diploPerso[type][id];
  9622. }
  9623. }
  9624. }
  9625. if(diploPerso.mythiques) {
  9626. Diplo.mythiques = diploPerso.mythiques;
  9627. }
  9628. isDiploRaw = false;
  9629. }
  9630.  
  9631. function appliqueDiplo() {
  9632. var aAppliquer = Diplo;
  9633. if(checkBoxDiplo.checked) {
  9634. // Pour retour à l'affichage basique sur désactivation de la diplo
  9635. aAppliquer = {
  9636. Guilde: {},
  9637. Troll: {},
  9638. Monstre: {}
  9639. };
  9640. }
  9641. /* On applique "aAppliquer" */
  9642. // Diplo Trõlls
  9643. for(var i=nbTrolls ; i>0 ; i--) {
  9644. var idG = getTrollGuildeID(i);
  9645. var idT = getTrollID(i);
  9646. var tr = tr_trolls[i];
  9647. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  9648. if(aAppliquer.Troll[idT]) {
  9649. tr.className = '';
  9650. var descr = aAppliquer.Troll[idT].titre;
  9651. if(descr) {
  9652. getTrollNomNode(i).title = descr
  9653. }
  9654. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  9655. } else if(aAppliquer.Guilde[idG]) {
  9656. tr.className = '';
  9657. var descr = aAppliquer.Guilde[idG].titre;
  9658. if(descr) {
  9659. getTrollNomNode(i).title = descr
  9660. }
  9661. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  9662. } else {
  9663. tr.className = 'mh_tdpage';
  9664. getTrollNomNode(i).title = '';
  9665. }
  9666. }
  9667. // Diplo Monstres
  9668. for(var i=nbMonstres ; i>0 ; i--) {
  9669. var id = getMonstreID(i);
  9670. var nom = getMonstreNom(i).toLowerCase();
  9671. if(aAppliquer.Monstre[id]) {
  9672. tr_monstres[i].className = '';
  9673. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  9674. tr_monstres[i].diploActive = 'oui';
  9675. var descr = aAppliquer.Monstre[id].titre;
  9676. if(descr) {
  9677. getMonstreNomNode(i).title = descr;
  9678. }
  9679. } else if(aAppliquer.mythiques &&
  9680. (nom.indexOf('liche')==0 ||
  9681. nom.indexOf('hydre')==0 ||
  9682. nom.indexOf('balrog')==0 ||
  9683. nom.indexOf('beholder')==0)) {
  9684. tr_monstres[i].className = '';
  9685. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  9686. tr_monstres[i].diploActive = 'oui';
  9687. getMonstreNomNode(i).title = 'Monstre Mythique';
  9688. } else {
  9689. tr_monstres[i].className = 'mh_tdpage';
  9690. tr_monstres[i].diploActive = '';
  9691. }
  9692. }
  9693. }
  9694.  
  9695.  
  9696. /*-[functions]---------------- Actions à distance ----------------------------*/
  9697.  
  9698. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  9699. var monN = parseInt(getPosition()[2]);
  9700. for(var type in keltypes) {
  9701. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  9702. for(var i=this['nb'+type] ; i>0 ; i--) {
  9703. var tr = this['tr_'+type.toLowerCase()][i];
  9704. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  9705. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  9706. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  9707. var sonN = getXxxPosition(type, i)[2];
  9708. var d = getXxxDistance(type, i);
  9709. if(sonN==monN && d>=dmin && d<=dmax) {
  9710. var iconeAction = document.evaluate(
  9711. "./descendant::img[@alt='"+alt+"']",
  9712. tr, null, 9, null
  9713. ).singleNodeValue;
  9714. if(iconeAction) {
  9715. if(iconeAction.title) {
  9716. iconeAction.title += "\n"+message;
  9717. } else {
  9718. iconeAction.title = message;
  9719. }
  9720. iconeAction.src = urlIcon;
  9721. } else {
  9722. var tdAction = tr.getElementsByTagName('td')[1];
  9723. var icon = document.createElement('img');
  9724. icon.src = urlIcon;
  9725. icon.height = 20;
  9726. icon.alt = alt;
  9727. icon.title = message;
  9728. tdAction.appendChild(icon);
  9729. }
  9730. }
  9731. }
  9732. }
  9733. }
  9734.  
  9735. function computeCharge() {
  9736. computeActionDistante(1,
  9737. getPortee__Vue(
  9738. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  9739. MY_getValue(numTroll+".caracs.regeneration")
  9740. ),
  9741. {'Monstres':1, 'Trolls':1},
  9742. 'Attaquer',
  9743. MHicons+'E_Metal09.png',
  9744. 'Cible à portée de Charge'
  9745. );
  9746. }
  9747.  
  9748. function computeProjo() {
  9749. computeActionDistante(0,
  9750. getPortee__Vue(
  9751. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9752. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9753. ),
  9754. {'Monstres':1, 'Trolls':1},
  9755. 'Attaquer',
  9756. MHicons+'S_Fire05.png',
  9757. 'Cible à portée de Projo'
  9758. );
  9759. }
  9760.  
  9761. function computeTelek() {
  9762. computeActionDistante(0,
  9763. Math.floor((
  9764. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9765. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9766. )/2),
  9767. {'Tresors':1},
  9768. 'Telek',
  9769. MHicons+'S_Magic04.png',
  9770. 'Trésor à portée de Télékinésie'
  9771. );
  9772. }
  9773.  
  9774. function computeLdP() {
  9775. computeActionDistante(0,
  9776. 2+Math.floor((
  9777. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9778. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9779. )/5),
  9780. {'Monstres':1, 'Trolls':1},
  9781. 'self',
  9782. MHicons+'P_Red01.png',
  9783. 'Cible à portée de Lancer de Potions'
  9784. );
  9785. }
  9786.  
  9787.  
  9788. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  9789.  
  9790. function putScriptExterne() {
  9791. var infoit = MY_getValue(numTroll+'.INFOSIT');
  9792. if(!infoit || infoit=='') return;
  9793.  
  9794. var nomit = infoit.slice(0,infoit.indexOf('$'));
  9795. if(nomit=='bricol') {
  9796. var data = infoit.split('$');
  9797. try {
  9798. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  9799. // appendNewScript(URL_bricol+data[1]
  9800. // +'/mz.php?login='+data[2]
  9801. // +'&password='+data[3]
  9802. // );
  9803. FF_XMLHttpRequest({
  9804. method: 'GET',
  9805. url: URL_bricol+data[1]
  9806. +'/mz_json.php?login='+data[2]
  9807. +'&password='+data[3],
  9808. onload: function(responseDetails) {
  9809. try {
  9810. if (responseDetails.status == 0) {
  9811. window.console.log('status=0 à l\'appel bricol\'troll');
  9812. if (isHTTPS) {
  9813. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  9814. } else {
  9815. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  9816. }
  9817. return;
  9818. }
  9819. var ratibusData;
  9820. try {
  9821. ratibusData = JSON.parse(responseDetails.responseText);
  9822. } catch(e) {}
  9823. if (ratibusData === undefined) {
  9824. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  9825. return;
  9826. }
  9827. if (ratibusData.error) {
  9828. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  9829. } else {
  9830. putInfosTrolls(ratibusData.data.trolls);
  9831. }
  9832. } catch(e) {
  9833. window.console.log(traceStack(e, 'retour bricol\'troll'));
  9834. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  9835. }
  9836. }
  9837. });
  9838. } catch(e) {
  9839. if (isHTTPS) {
  9840. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  9841. } else {
  9842. window.console.log(traceStack(e, 'appel bricol\'troll'));
  9843. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  9844. }
  9845. }
  9846. }
  9847. }
  9848.  
  9849. /* Le script mz.php de Ratibus renvoie :
  9850. + infosTrolls = new Array();
  9851. + infosTrolls[numdutroll] =
  9852. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  9853. + etc ...
  9854. + putInfosTrolls();
  9855. *
  9856. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  9857. * Roule 07/11/2016, on utilise mz_json qui envoie
  9858. {
  9859. "data": {
  9860. "trolls": {
  9861. "59424": {
  9862. "id": 59424,
  9863. "pv": xx,
  9864. "pv_max": xx,
  9865. "updated_at": "2016-10-31 07:28:40",
  9866. "dla": "2016-10-05 07:28:04",
  9867. "pa": 0
  9868. },
  9869. }
  9870. }
  9871. }
  9872. */
  9873.  
  9874. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  9875. function corrigeBricolTrolls(infosTrolls) {
  9876. for(var i in infosTrolls) {
  9877. var pv = infosTrolls[i][0];
  9878. var pvmax = infosTrolls[i][1];
  9879. var pvmem = MY_getValue(i+'.caracs.pv.max');
  9880. if(pvmem && pvmem>pvmax) {
  9881. infosTrolls[i][1] = pvmem;
  9882. pvmax = pvmem;
  9883. }
  9884. if(pv>pvmax) {
  9885. var newpvmax = 5*Math.ceil(pv/5);
  9886. MY_setValue(i+'.caracs.pv.max',newpvmax);
  9887. infosTrolls[i][1] = newpvmax;
  9888. }
  9889. }
  9890. }
  9891.  
  9892. // insère 2 TD avant nextTD avec les infos venant de l'IT
  9893. function addTdInfosTroll(infos, TR) {
  9894. /* cadre barre PV */
  9895. var tab = document.createElement('div');
  9896. /* ancienne méthode par img, à supprimer
  9897. tab.width = 100;
  9898. tab.style.width = 100;
  9899. tab.height = 10;
  9900. tab.style.background = '#FFFFFF';
  9901. tab.style.border = 1;
  9902. */
  9903. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  9904. /* barre PV */
  9905. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  9906. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  9907. .vieContainer {
  9908. background-color: #CCC;
  9909. width: 50px;
  9910. height: 6px;
  9911. border: 1px solid #000;
  9912. text-align: left;
  9913. }
  9914. */
  9915. tab.style.width = '100px';
  9916. tab.style.height = '10px';
  9917. tab.style.border = '1px solid #000';
  9918. tab.style.textAlign = 'left';
  9919. var div2 = document.createElement('div');
  9920. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  9921. var dateLimite = new Date();
  9922. dateLimite.setDate(dateLimite.getDate() - 7);
  9923. if (infos.oUpdatedAt < dateLimite) {
  9924. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  9925. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  9926. } else if (pourcentVie > 66) {
  9927. div2.style.backgroundColor = '#77EE77';
  9928. } else if (pourcentVie > 33) {
  9929. div2.style.backgroundColor = '#EEEE77';
  9930. } else {
  9931. div2.style.backgroundColor = '#FF0000';
  9932. }
  9933. div2.style.width = pourcentVie + '%';
  9934. div2.style.height = '10px';
  9935. tab.appendChild(div2);
  9936. /* ancienne méthode par img, à supprimer
  9937. var img = document.createElement('img');
  9938. img.src = '../Images/Interface/milieu.gif';
  9939. img.height = 10;
  9940. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  9941. tab.appendChild(img);
  9942. */
  9943.  
  9944. var tdNom = TR.childNodes[3]
  9945. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  9946. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  9947.  
  9948. /* lien vers l'IT */
  9949. var lien = document.createElement('a');
  9950. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9951. lien.href = URL_bricol+nomit+'/index.php';
  9952. lien.target = '_blank';
  9953. lien.appendChild(tab);
  9954. var tdGuilde = TR.childNodes[6];
  9955. insertTdElement(tdGuilde,lien);
  9956. /* PAs dispos */
  9957. var span = document.createElement('span');
  9958. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9959. appendText(span, infos.pa +' PA' );
  9960. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9961. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9962. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9963. span.style.backgroundColor = 'B8EEB8';
  9964. }
  9965. insertTdElement(tdGuilde, span);
  9966. }
  9967.  
  9968. function putInfosTrolls(infosTrolls) {
  9969. try {
  9970. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9971. // supression des infos trop vieilles (un mois)
  9972. var IDs = Object.keys(infosTrolls);
  9973. var dateLimite = new Date();
  9974. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9975. for (var i = 0; i < IDs.length; i++) {
  9976. var idTroll = IDs[i];
  9977. var infos = infosTrolls[idTroll];
  9978. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9979. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9980. }
  9981. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9982. td.width = 40;
  9983. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9984. td.width = 105;
  9985.  
  9986. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9987. //corrigeBricolTrolls(infosTrolls);
  9988.  
  9989. for(i=nbTrolls ; i>0 ; i--) {
  9990. var infos = infosTrolls[getTrollID(i)];
  9991. if(infos && (!infos.bIgnore)) {
  9992. addTdInfosTroll(infos, tr_trolls[i]);
  9993. infos.done = true;
  9994. } else {
  9995. insertTd(tr_trolls[i].childNodes[6]);
  9996. insertTd(tr_trolls[i].childNodes[6]);
  9997. }
  9998. }
  9999. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  10000. var str = MY_getValue(numTroll+'.INFOSIT');
  10001. if(!str) return;
  10002. var arr = str.split('$');
  10003. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  10004.  
  10005. //window.console.log('nb Troll IT : ' + IDs.length);
  10006. var tBody = tr_trolls[0].parentNode;
  10007. if (tr_trolls[1] === undefined)
  10008. tBody = tr_trolls[0].parentNode;
  10009. else
  10010. tBody = tr_trolls[1].parentNode;
  10011. var pos = getPosition();
  10012. for (i = 0; i < IDs.length; i++) {
  10013. var idTroll = IDs[i];
  10014. infos = infosTrolls[idTroll];
  10015. if (infos.done) continue; // déjà vu
  10016. if (infos.bIgnore) continue; // trop vieux
  10017. if (idTroll == numTroll) continue; // pas nous-même
  10018. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  10019. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  10020. // trouver où insérer ce Troll
  10021. var next = undefined;
  10022. for(var j=0 ; j<tr_trolls.length ; j++) {
  10023. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  10024. if (thisDist > distance) {
  10025. next = tr_trolls[j]
  10026. break;
  10027. }
  10028. }
  10029. var tr;
  10030. if (next !== undefined) {
  10031. tr = insertTr(next,'mh_tdpage')
  10032. } else {
  10033. tr = appendTr(tBody,'mh_tdpage');
  10034. }
  10035. tr.style.color = 'orange';
  10036. var td = appendTd(tr); // distance
  10037. appendText(td, distance);
  10038. td = appendTd(tr); // actions
  10039. td = appendTd(tr); // ID
  10040. appendText(td, idTroll);
  10041. td = appendTd(tr); // Nom
  10042. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  10043. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  10044. // info camou/invi transféré dans addTdInfosTroll
  10045. // if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  10046. // if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  10047. td = appendTd(tr); // Niveau
  10048. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  10049. td.align = 'center';
  10050. td = appendTd(tr); // Race
  10051. if (infos.race) appendText(td, infos.race);
  10052. // PV et PA ajoutés par addTdInfosTroll
  10053. td = appendTd(tr); // Guilde
  10054. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  10055. td = appendTd(tr); // X
  10056. td.align = 'center';
  10057. if (infos.x !== undefined) appendText(td, infos.x);
  10058. td = appendTd(tr); // Y
  10059. td.align = 'center';
  10060. if (infos.y !== undefined) appendText(td, infos.y);
  10061. td = appendTd(tr); // N
  10062. td.align = 'center';
  10063. if (infos.n !== undefined) appendText(td, infos.n);
  10064. addTdInfosTroll(infos, tr);
  10065. }
  10066. } catch(e) {
  10067. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  10068. }
  10069. }
  10070.  
  10071.  
  10072. /* Mode Tétalanvert! ---------------------------------------------------------*/
  10073.  
  10074. function calculeDistance(maPos,posArr) {
  10075. return Math.max(
  10076. Math.abs(maPos[0]-posArr[0]),
  10077. Math.abs(maPos[1]-posArr[1]),
  10078. Math.abs(maPos[2]-posArr[2])
  10079. );
  10080. }
  10081.  
  10082. function inversionCoord() {
  10083. var maPos = getPosition();
  10084. var listeOffsets = {
  10085. 'monstres':checkBoxLevels.checked?4:3,
  10086. 'trolls':6,
  10087. };
  10088. for(var type in listeOffsets) {
  10089. var trList = this['tr_'+type];
  10090. var offset = listeOffsets[type];
  10091. for(var i=trList.length-1 ; i>0 ; i--) {
  10092. var oldX = parseInt(trList[i].cells[offset].textContent);
  10093. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  10094. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  10095. trList[i].cells[offset].innerHTML = oldY;
  10096. trList[i].cells[offset+1].innerHTML = oldX;
  10097. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  10098. }
  10099. }
  10100. }
  10101.  
  10102.  
  10103. /* Partie principale */
  10104. function do_vue() {
  10105. for(var type in typesAFetcher) {
  10106. fetchData(type);
  10107. }
  10108.  
  10109. // roule' 11/03/2016
  10110. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  10111. // je fais une recopie :(
  10112. tr_monstres = this['tr_monstres'];
  10113. tr_trolls = this['tr_trolls'];
  10114. tr_tresors = this['tr_tresors'];
  10115. tr_champignons = this['tr_champignons'];
  10116. tr_lieux = this['tr_lieux'];
  10117.  
  10118. nbMonstres = this['nbMonstres'];
  10119. nbTrolls = this['nbTrolls'];
  10120. nbTresors = this['nbTresors'];
  10121. nbChampignons = this['nbChampignons'];
  10122. nbLieux = this['nbLieux'];
  10123.  
  10124. try {
  10125. start_script(31);
  10126. initialiseInfos();
  10127. savePosition();
  10128.  
  10129. // Fonctionnalité "Têtalenvert" cachée, en test :
  10130. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  10131. inversionCoord();
  10132. }
  10133. ajoutDesFiltres();
  10134. set2DViewSystem();
  10135. //putBoutonTroogle();
  10136. putBoutonPXMP();
  10137. synchroniseFiltres();
  10138. toggleLevelColumn();
  10139.  
  10140. refreshDiplo();
  10141. //400 ms
  10142. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  10143. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  10144. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  10145. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  10146. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  10147. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  10148. var noTresorsEngages =
  10149. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  10150. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  10151. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  10152. filtreMonstres();
  10153. if(noIntangibles) {
  10154. filtreTrolls();
  10155. }
  10156. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  10157. filtreTresors();
  10158. }
  10159. if(noTrou) {
  10160. filtreLieux();
  10161. }
  10162.  
  10163. initPopupVue();
  10164. initPXTroll();
  10165.  
  10166. if(getTalent("Projectile Magique")!=0) {
  10167. computeProjo();
  10168. }
  10169. if(getTalent("Charger")!=0) {
  10170. computeCharge();
  10171. }
  10172. if(getTalent("Télékinésie")!=0) {
  10173. computeTelek();
  10174. }
  10175. if(getTalent("Lancer de Potions")!=0) {
  10176. computeLdP();
  10177. }
  10178. putScriptExterne();
  10179. displayScriptTime();
  10180. } catch(e) {
  10181. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10182. window.console.error(traceStack(e, 'vue'));
  10183. }
  10184. }
  10185.  
  10186.  
  10187.  
  10188. /*******************************************************************************
  10189. * This file is part of Mountyzilla. *
  10190. * *
  10191. * Mountyzilla is free software; you can redistribute it and/or modify *
  10192. * it under the terms of the GNU General Public License as published by *
  10193. * the Free Software Foundation; either version 2 of the License, or *
  10194. * (at your option) any later version. *
  10195. * *
  10196. * Mountyzilla is distributed in the hope that it will be useful, *
  10197. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10198. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10199. * GNU General Public License for more details. *
  10200. * *
  10201. * You should have received a copy of the GNU General Public License *
  10202. * along with Mountyzilla; if not, write to the Free Software *
  10203. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10204. *******************************************************************************/
  10205.  
  10206. // x~x profil2
  10207.  
  10208. /*---------------------------- Variables globales ----------------------------*/
  10209.  
  10210. var
  10211. // Anatrolliseur
  10212. urlAnatrolliseur,
  10213. // Infobulles talents
  10214. hauteur = 50, bulleStyle = null,
  10215. // Caracteristiques
  10216. // Infos troll
  10217. race, niv, idtroll, datecrea,
  10218. idguilde, nomguilde,
  10219. // Etats du troll
  10220. fatigue, bmfatigue,
  10221.  
  10222. // Experience, Pi, ...
  10223. pxdistribuables, pxperso,
  10224. piutilisable, pitotal,
  10225. nbmeurtres, nbmorts,
  10226. // utilisee pour les moyennes MM/jour, kill/jour, etc
  10227. NBjours,
  10228. // calcul des DLA suivantes
  10229. DLA, DLAsuiv, HeureServeur,
  10230. // details duree du tour (calcul pvdispo) :
  10231. dtb, pdm, bmt, adb, dpt,
  10232. //posale
  10233. posX, posY, posN,
  10234. // caracs physiques
  10235. vue, vuebp, vuebm, vuetotale,
  10236. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  10237. reg, regbp, regbm, regmoy,
  10238. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  10239. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  10240. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  10241. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  10242. rm, rmbp, rmbm, rmtotale,
  10243. mm, mmbp, mmbm, mmtotale,
  10244.  
  10245. // Variables speciales Kastars
  10246. pvActuelKastar, minParPV, overDLA,
  10247. // id pour edition manuelle de lastDLA :
  10248. inJour, inMois, inAn, inHr, inMin, inSec,
  10249. // id pour auto-refresh lastDLA :
  10250. lastDLAZone, maxAMZone, cumulZone,
  10251. lastDLA, DLAaccel;
  10252.  
  10253.  
  10254. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  10255.  
  10256. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10257. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10258. function getUniqueValueBySelector(selector, defaultValue){
  10259. var valNode = document.querySelector(selector);
  10260. if(valNode!=null){
  10261. if(valNode.hasChildNodes()) {
  10262. return valNode.childNodes[0].nodeValue;
  10263. }else{
  10264. return defaultValue;
  10265. }
  10266. } else{
  10267. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10268. return defaultValue;
  10269. }
  10270. }
  10271. function getUniqueStringValueBySelector(selector){
  10272. return getUniqueValueBySelector(selector,"");
  10273. }
  10274. function getUniqueIntValueBySelector(selector){
  10275. var ret = getUniqueValueBySelector(selector,0);
  10276. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10277. ret = 0;
  10278. }
  10279. return parseInt(ret);
  10280. }
  10281. function getUniqueFloatValueBySelector(selector){
  10282. var ret = getUniqueValueBySelector(selector,0.0);
  10283. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10284. ret = 0.0;
  10285. }
  10286. return parseFloat(ret);
  10287. }
  10288.  
  10289.  
  10290. function resiste(Ddeg,bm) {
  10291. // version naive mais compréhensible ^^
  10292. // DEBUG: à revoir
  10293. if(!bm) {
  10294. return 2*Math.floor(Ddeg/2);
  10295. }
  10296. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  10297. }
  10298.  
  10299. function retourAZero(fatig) {
  10300. var fat = fatig, raz = 0;
  10301. while(fat>0) {
  10302. raz++;
  10303. fat = Math.floor(fat/1.25);
  10304. }
  10305. return raz;
  10306. }
  10307.  
  10308. function decumulPumPrem(bonus) {
  10309. switch(bonus) {
  10310. case 20: return 33;
  10311. case 33: return 41;
  10312. case 41: return 46;
  10313. case 46: return 49;
  10314. case 49: return 51;
  10315. default: return 20;
  10316. }
  10317. }
  10318.  
  10319. function coefDecumul(i) {
  10320. switch(i) {
  10321. case 2: return 0.67;
  10322. case 3: return 0.4;
  10323. case 4: return 0.25;
  10324. case 5: return 0.15;
  10325. default: return 0.1;
  10326. }
  10327. }
  10328.  
  10329. function dureeHM(dmin) {
  10330. var ret = "";
  10331. dmin = Math.floor(dmin);
  10332. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  10333. var mins = dmin%60;
  10334. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  10335. return (ret) ? ret : "-";
  10336. }
  10337.  
  10338. // extraction d'une durée
  10339. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  10340. // c'est protégé (rend 0 si l'élément est absent)
  10341. // Roule' 24/12/2016
  10342. function extractionDuree(selecteur) {
  10343. var s = getUniqueStringValueBySelector(selecteur);
  10344. if (!s) return 0;
  10345. var tabN = getNumbers(s);
  10346. if (tabN.length < 2) return 0;
  10347. return tabN[0] * 60 + tabN[1];
  10348. }
  10349.  
  10350. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  10351.  
  10352. function extractionDonnees() {
  10353. // Variables temporaires
  10354. var Nbrs = {};
  10355.  
  10356. // *********************
  10357. // Cadre "Description"
  10358. // *********************
  10359. race = getUniqueStringValueBySelector('#descr #race');
  10360. debugMZ("Race : " + race);
  10361. idtroll = getUniqueStringValueBySelector('#descr #id');
  10362. debugMZ("Id troll : " + idtroll);
  10363. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  10364. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  10365. datecrea = new Date(StringToDate(strDateCrea));
  10366. debugMZ("Date creation : " + datecrea);
  10367. // Guilde
  10368. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  10369. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  10370. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  10371.  
  10372. // *******************
  10373. // Cadre "Experience"
  10374. // *******************
  10375. // Niveau de troll
  10376. niv = getUniqueIntValueBySelector('#exp #niv');
  10377. nivTroll = niv;
  10378. debugMZ("Niveau : " + niv);
  10379. // PX
  10380. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  10381. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  10382. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  10383. // PI
  10384. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  10385. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  10386. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  10387. // Meutres/Morts
  10388. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  10389. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  10390. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  10391.  
  10392. // *********************
  10393. // Cadre "Tour de Jeu"
  10394. // *********************
  10395. // DLA
  10396. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  10397. DLA = new Date(StringToDate(Nbrs["dla"]));
  10398. debugMZ("DLA: " + DLA);
  10399. // DLA suivante
  10400. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  10401. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  10402. debugMZ("DLAsuiv: " + DLAsuiv);
  10403. // Duree normale de mon Tour
  10404. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  10405. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  10406. dtb = extractionDuree("#dla #tour");
  10407. debugMZ("Duree normale de mon Tour : " + dtb);
  10408. // Bonus/Malus sur la duree
  10409. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  10410. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  10411. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  10412. debugMZ("Bonus/Malus sur la duree : " + bmt);
  10413. // Augmentation due aux blessures
  10414. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  10415. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  10416. adb = extractionDuree("#dla #blessure");
  10417. debugMZ("Augmentation due aux blessures : " + adb);
  10418. // Poids de l'equipement
  10419. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  10420. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  10421. pdm = extractionDuree("#dla #poids");
  10422. debugMZ("Poids de l'equipement : " + pdm);
  10423. // Duree de mon prochain Tour
  10424. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  10425. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  10426. dpt = extractionDuree("#dla #duree>b");
  10427. debugMZ('Duree de mon prochain Tour : ' + dpt);
  10428.  
  10429. // ****************
  10430. // Cadre "Etats"
  10431. // ****************
  10432. // Position du troll :
  10433. posX = getUniqueIntValueBySelector('#pos #x');
  10434. posY = getUniqueIntValueBySelector('#pos #y');
  10435. posN = getUniqueIntValueBySelector('#pos #n');
  10436. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  10437. // PV actuel
  10438. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  10439. pvActuelKastar = pvcourant;
  10440. debugMZ("PV actuel : " + pvcourant)
  10441. // Fatigue
  10442. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  10443. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  10444. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  10445.  
  10446. // **************************
  10447. // Cadre "Caracteristiques"
  10448. // **************************
  10449. // Attaque
  10450. att = getUniqueIntValueBySelector('#carac #att');
  10451. attbp = getUniqueIntValueBySelector('#carac #att_p');
  10452. attbm = getUniqueIntValueBySelector('#carac #att_m');
  10453. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  10454. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  10455. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  10456. attmoy = 3.5*att + attbp + attbm;
  10457. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10458. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  10459. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  10460. // Esquive
  10461. esq = getUniqueIntValueBySelector('#carac #esq');
  10462. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  10463. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  10464. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  10465. esqmoy = 3.5*esq + esqbp+esqbm;
  10466. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  10467. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  10468. // Degat
  10469. deg = getUniqueIntValueBySelector('#carac #deg');
  10470. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  10471. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  10472. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  10473. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  10474. degmoy = 2*deg + degbp+degbm;
  10475. degmoycrit = 3*deg + degbp+degbm;
  10476. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10477. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  10478. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  10479. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  10480. // PV
  10481. pvbase = getUniqueIntValueBySelector('#carac #pv');
  10482. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  10483. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  10484. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  10485. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  10486. // Regeneration
  10487. reg = getUniqueIntValueBySelector('#carac #reg');
  10488. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  10489. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  10490. regmoy = 2 * reg + regbp + regbm; // D3
  10491. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  10492. // Armure
  10493. arm = getUniqueIntValueBySelector('#carac #arm');
  10494. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  10495. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  10496. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  10497. armmoy = 2*arm + armbp+armbm;
  10498. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  10499. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  10500. // TODO : D d'armure non active
  10501. // Vue
  10502. vue = getUniqueIntValueBySelector('#carac #vue');
  10503. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  10504. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  10505. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  10506. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  10507. // RM
  10508. rm = getUniqueIntValueBySelector('#carac #rm');
  10509. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  10510. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  10511. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  10512. rmTroll = rmtotale;
  10513. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  10514. // MM
  10515. mm = getUniqueIntValueBySelector('#carac #mm');
  10516. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  10517. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  10518. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  10519. mmTroll = mmtotale;
  10520. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  10521.  
  10522. // Heure Serveur
  10523. try {
  10524. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  10525. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  10526. HeureServeur = new Date(StringToDate(heureServeurSTR));
  10527. } catch (e) {
  10528. window.console.warn(
  10529. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  10530. );
  10531. HeureServeur = new Date();
  10532. }
  10533. debugMZ("HeureServeur: " + HeureServeur);
  10534.  
  10535. // ***INIT GLOBALE*** NBjours
  10536. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  10537.  
  10538. // Calcul debut lien anatroliseur avec les caracteristiques connues
  10539. var amelio_dtb = function(dtb) {
  10540. if(dtb>555) {
  10541. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  10542. }
  10543. return 10+Math.ceil((555-dtb)/2.5);
  10544. },
  10545. amelio_pv = Math.floor(pvbase/10)-3,
  10546. amelio_vue = vue-3,
  10547. amelio_att = att-3,
  10548. amelio_esq = esq-3,
  10549. amelio_deg = deg-3,
  10550. amelio_reg = reg-1,
  10551. amelio_arm = arm-1;
  10552. if(race==="Darkling"){amelio_reg--; }
  10553. if(race==="Durakuir"){amelio_pv-- ; }
  10554. if(race==="Kastar") {amelio_deg--; }
  10555. if(race==="Skrim") {amelio_att--; }
  10556. if(race==="Tomawak") {amelio_vue--; }
  10557.  
  10558. urlAnatrolliseur = URL_AnatrolDispas
  10559. +"outils_anatrolliseur.php?anatrolliseur=v8"
  10560. +"|r="+race.toLowerCase()
  10561. +"|dla="+amelio_dtb(dtb)
  10562. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  10563. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  10564. +"|att="+amelio_att+","+attbp+","+attbm
  10565. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  10566. +"|deg="+amelio_deg+","+degbp+","+degbm
  10567. +"|reg="+amelio_reg+","+regbp+","+regbm
  10568. +"|arm="+amelio_arm+","+armbp+","+armbm
  10569. +"|mm="+mmtotale
  10570. +"|rm="+rmtotale+"|";
  10571. }
  10572.  
  10573. function saveProfil() {
  10574. MY_setValue(idtroll+'.caracs.attaque',att);
  10575. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  10576. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  10577. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  10578. if(atttourD||atttourP||atttourM) {
  10579. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10580. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  10581. }
  10582. MY_setValue(idtroll+'.caracs.esquive',esq);
  10583. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  10584. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  10585. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  10586. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  10587. MY_setValue(idtroll+'.caracs.degats',deg);
  10588. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  10589. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  10590. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  10591. if(degtourP||degtourM){
  10592. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10593. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  10594. }
  10595. MY_setValue(idtroll+'.caracs.regeneration',reg);
  10596. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  10597. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  10598. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  10599. MY_setValue(idtroll+'.caracs.vue',vue);
  10600. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  10601. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  10602. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  10603. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  10604. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  10605. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  10606. MY_setValue(idtroll+'.caracs.rm',rm);
  10607. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  10608. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  10609. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  10610. MY_setValue(idtroll+'.caracs.mm',mm);
  10611. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  10612. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  10613. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  10614. MY_setValue(idtroll+'.caracs.armure',arm);
  10615. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  10616. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  10617. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  10618. MY_setValue(idtroll+'.position.X',posX);
  10619. MY_setValue(idtroll+'.position.Y',posY);
  10620. MY_setValue(idtroll+'.position.N',posN);
  10621. MY_setValue(idtroll+'.race',race);
  10622. MY_setValue(idtroll+'.niveau',niv);
  10623. MY_setValue(idtroll+'.idguilde',idguilde);
  10624. MY_setValue(idtroll+'.nomguilde',nomguilde);
  10625. }
  10626.  
  10627.  
  10628. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  10629.  
  10630. function setInfosCaracteristiques() {
  10631. // Modification de l'entete
  10632. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  10633. thTotal.innerHTML+='|<i>Moyenne</i>';
  10634. thTotal.title="Moyenne (Moyenne ce tour)";
  10635.  
  10636. // Ajout des informations calculees
  10637. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  10638. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  10639. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  10640.  
  10641. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  10642. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  10643. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  10644.  
  10645. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  10646. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  10647. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  10648.  
  10649. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  10650. var tdRegTotal = trRegeneration.children[5];
  10651. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  10652. // Temps recupere par reg (propale R')
  10653. var regmoyTemp = Math.max(0, regmoy);
  10654. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  10655. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  10656. if (sec != 0) {
  10657. regTitle += " " + sec + " sec";
  10658. }
  10659. trRegeneration.title = regTitle;
  10660.  
  10661. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  10662. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  10663. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  10664.  
  10665. var trRM=document.querySelector("table#caracs #rm").parentElement;
  10666. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  10667. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  10668.  
  10669.  
  10670. var trMM=document.querySelector("table#caracs #mm").parentElement;
  10671. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  10672. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  10673.  
  10674. var tdRefl=document.querySelector("#refl");
  10675. // TODO : prendre en compte bonus/malus D esq du tour ?
  10676. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  10677. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  10678. }
  10679.  
  10680. function setLienAnatrolliseur(){
  10681. var pTableAmelio = document.querySelector("#carac>div>p");
  10682. pTableAmelio.innerHTML+=" - ";
  10683. var aElt = document.createElement("a");
  10684. aElt.setAttribute("href",urlAnatrolliseur);
  10685. aElt.setAttribute("target","_blank");
  10686. aElt.className="AllLinks";
  10687. aElt.innerHTML="Anatrolliser";
  10688. pTableAmelio.appendChild(aElt);
  10689. }
  10690. function setInfoDescription() {
  10691. var txtDateCrea = (NBjours!=1) ?
  10692. " ("+NBjours+" jours dans le hall)" :
  10693. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  10694. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  10695. }
  10696.  
  10697. function setInfosEtatLieux() {
  10698. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  10699. '?search=position&orderBy=distance&posx='+
  10700. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  10701. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  10702. appendBr(tdPosition);
  10703. var aElt = document.createElement("a");
  10704. aElt.setAttribute("href",urlBricol);
  10705. aElt.setAttribute("target","_blank");
  10706. aElt.className="AllLinks";
  10707. aElt.innerHTML="Lieux à proximité";
  10708. tdPosition.appendChild(aElt);
  10709. }
  10710.  
  10711. function setInfosEtatPV() { // pour AM et Sacro
  10712. var
  10713. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  10714. sec = Math.floor(15000/pvtotal)%60,
  10715. lifebar = document.querySelector("#pos .barre-vie");
  10716. if(sec!=0) { txt += " "+sec+" sec"; }
  10717. if(lifebar) { lifebar.title = txt; }
  10718. if(pvcourant<=0) { return; }
  10719. // Difference PV p/r a equilibre de temps (propale R')
  10720. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  10721. // ***INIT GLOBALE*** pvdispo
  10722. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10723. var span = document.createElement("span");
  10724. span.title = txt;
  10725. span.style.fontStyle = "italic";
  10726. if(bmt+pdm>=0) {
  10727. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  10728. } else if(pvdispo>0) {
  10729. txt = "Vous pouvez encore perdre "+
  10730. Math.min(pvdispo,pvcourant)+
  10731. " PV sans malus de temps.";
  10732. } else if(pvdispo<0) {
  10733. txt = "Il vous manque "
  10734. +(-pvdispo)
  10735. +" PV pour ne plus avoir de malus de temps.";
  10736. } else {
  10737. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  10738. }
  10739. appendText(span,txt);
  10740. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  10741. }
  10742.  
  10743. // Complete le cadre "Experience"
  10744. function setInfosExp() {
  10745. var tdNiv = document.querySelector("#exp #niv");
  10746.  
  10747. // Calcul niveau monstre/troll min pour gain PX
  10748. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  10749. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  10750.  
  10751. // Calcul PX restant
  10752. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  10753. if (pxRestant >= 0) {
  10754. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  10755. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  10756. }
  10757.  
  10758. // Calul pi/jour
  10759. var
  10760. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  10761. tdPi = document.querySelector("#exp #pi").parentElement;
  10762. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  10763. tdPi.title = tdPiTotal.title;
  10764.  
  10765. // Rapports meurtres,morts
  10766. var tdKill = document.querySelector("#exp #kill");
  10767. tdKill.setAttribute("colspan", 1);
  10768. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  10769.  
  10770. var tdMort = document.querySelector("#exp #mort");
  10771. tdMort.setAttribute("colspan", 1);
  10772. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  10773.  
  10774. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  10775. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  10776. }
  10777.  
  10778.  
  10779. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  10780.  
  10781. function minParPVsac(fat,bm) {
  10782. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  10783. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  10784. var out = [];
  10785. out[0] = (fat>4) ?
  10786. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  10787. 30;
  10788. if(bm && bm>0) {
  10789. var totalfat=fat+bm;
  10790. out[1] = (totalfat>4) ?
  10791. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  10792. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  10793. }
  10794. return out;
  10795. }
  10796.  
  10797. function toInt(str) {
  10798. str = parseInt(str);
  10799. return (str) ? str : 0;
  10800. }
  10801.  
  10802. function saveLastDLA() {
  10803. // pour les calculs d'AM max
  10804. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  10805. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  10806. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  10807. lastDLA = new Date( StringToDate(str) );
  10808. MY_setValue(numTroll+'.DLA.ancienne',str);
  10809. lastDLAZone.innerHTML = '';
  10810. var b = document.createElement('b');
  10811. b.addEventListener('click',inputMode,false);
  10812. appendText(b,str);
  10813. lastDLAZone.appendChild(b);
  10814. refreshAccel();
  10815. }
  10816.  
  10817. function inputMode() {
  10818. // Edition manuelle lastDLA
  10819. var date;
  10820. if(lastDLA)
  10821. date = new Date( lastDLA );
  10822. else
  10823. date = new Date( DLAaccel );
  10824. lastDLAZone.innerHTML = '';
  10825. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  10826. appendText(lastDLAZone,'/');
  10827. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  10828. appendText(lastDLAZone,'/');
  10829. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  10830. appendText(lastDLAZone,' - ');
  10831. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  10832. appendText(lastDLAZone,':');
  10833. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  10834. appendText(lastDLAZone,':');
  10835. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  10836. appendText(lastDLAZone,' - ');
  10837. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  10838. }
  10839.  
  10840. function setAccel() {
  10841. var
  10842. BMfrais=false,
  10843. fat=fatigue, listeBmFat=[],
  10844. tr, th, insertPt;
  10845.  
  10846. // Creation ligne speciale pour AM dans le cadre "Etat"
  10847. tr = document.createElement('tr');
  10848. th = document.createElement('th');
  10849. appendText(th,'Fatigue et AM',true);
  10850. tr.appendChild(th);
  10851. insertPt = document.createElement('td');
  10852. tr.appendChild(insertPt);
  10853. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  10854.  
  10855. // Est-on en over-DLA ?
  10856. // ***INIT GLOBALE*** overDLA
  10857. overDLA = (HeureServeur>DLA.getTime()+3e5);
  10858. if(overDLA) {
  10859. fat=Math.floor(fatigue/1.25);
  10860. }
  10861.  
  10862. // Gestion des BM de fatigue
  10863. if(bmfatigue>0) {
  10864. // On tente de recuperer les BM de fatigue de la page des BM
  10865. if(MY_getValue(numTroll+'.bm.fatigue')) {
  10866. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  10867. BMmemoire.pop();
  10868. var tour = 0;
  10869. for(var i=0 ; i<BMmemoire.length ; i++) {
  10870. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  10871. while(tour<=parseInt(nbrs[0])) {
  10872. listeBmFat[tour]=parseInt(nbrs[1]);
  10873. tour++;
  10874. }
  10875. }
  10876. }
  10877. if(listeBmFat[0]==bmfatigue) {
  10878. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  10879. BMfrais = true;
  10880. MY_removeValue(numTroll+".bm.fatigue");
  10881. }
  10882. } else {
  10883. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  10884. BMfrais = true;
  10885. }
  10886. if(!BMfrais && bmfatigue>0) {
  10887. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  10888. if(bmfatigue==15) {
  10889. listeBmFat = [15,15,15];
  10890. } else {
  10891. listeBmFat = [30,30,15];
  10892. }
  10893. }
  10894. if(overDLA) {
  10895. // Si on est en over-DLA, on decale les bm d'un tour
  10896. listeBmFat.shift();
  10897. }
  10898. // Tableau des fatigues et accel futures
  10899. var
  10900. minppv = minParPVsac(fat,listeBmFat[0]),
  10901. table, tbody,
  10902. ligneTour, ligneFat, ligneMin,
  10903. col;
  10904. // ***INIT GLOBALE*** minParPV
  10905. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  10906. if(fat>0 || listeBmFat[0]>0) {
  10907. table = document.createElement('table');
  10908. table.className = 'mh_tdborder';
  10909. table.border = 0;
  10910. table.cellSpacing = 1;
  10911. table.cellPadding = 1;
  10912. table.style.textAlign = "center";
  10913. tbody = document.createElement('tbody');
  10914. table.appendChild(tbody);
  10915. insertPt.appendChild(table);
  10916. ligneTour = appendTr(tbody,'mh_tdtitre');
  10917. ligneTour.style.fontWeight = "bold";
  10918. var td = appendTdText(ligneTour,'Tour :',true);
  10919. td.align = 'left';
  10920. ligneFat = appendTr(tbody,'mh_tdpage');
  10921. td = appendTdText(ligneFat,'Fatigue :',true);
  10922. td.className = 'mh_tdtitre';
  10923. td.align = 'left';
  10924. ligneMin = appendTr(tbody,'mh_tdpage');
  10925. td = appendTdText(ligneMin,'1 PV =',true);
  10926. td.className = 'mh_tdtitre';
  10927. td.align = 'left';
  10928. col=0;
  10929. while(col<9 && (fat>0 || listeBmFat[col])) {
  10930. if(col==0) {
  10931. if(overDLA) {
  10932. var i = document.createElement('i');
  10933. appendText(i,'A activer');
  10934. ligneTour.appendChild(i);
  10935. } else {
  10936. appendTdText(ligneTour,'En cours');
  10937. }
  10938. } else {
  10939. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10940. }
  10941. if(listeBmFat[col]) {
  10942. if(BMfrais || (!overDLA && col==0)) {
  10943. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  10944. appendTdText(ligneMin,minppv[1]+'\'');
  10945. } else {
  10946. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  10947. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  10948. }
  10949. } else {
  10950. appendTdText(ligneFat,fat);
  10951. appendTdText(ligneMin,minppv[0]+'\'');
  10952. }
  10953. col++;
  10954. fat = Math.floor(fat / 1.25);
  10955. minppv = minParPVsac(fat,listeBmFat[col]);
  10956. }
  10957. if(fat>1 || (fat==1 && !overDLA)) {
  10958. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10959. appendTdText(ligneFat,'-');
  10960. appendTdText(ligneMin,'-');
  10961. }
  10962. col = (overDLA) ?
  10963. Math.max(retourAZero(fatigue)-1,col) :
  10964. Math.max(retourAZero(fatigue),col);
  10965. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10966. appendTdText(ligneFat,'0');
  10967. appendTdText(ligneMin,'30\'');
  10968. if(!BMfrais && bmfatigue) {
  10969. // si les BM n'ont pas ete rafraichis, on signale:
  10970. appendText(
  10971. insertPt,
  10972. '/!\\ Visitez la page des Bonus/Malus '+
  10973. 'pour mettre à jour votre fatigue. /!\\',
  10974. true
  10975. );
  10976. appendBr(insertPt);
  10977. }
  10978. appendBr(insertPt);
  10979. }
  10980. if(pvcourant<=0) {
  10981. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10982. return;
  10983. }
  10984. if(fatigue>30) {
  10985. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10986. return;
  10987. }
  10988. // Setup lastDLAZone
  10989. if(overDLA) {
  10990. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10991. DLAaccel = new Date( DLAsuiv );
  10992. lastDLA = new Date( DLA );
  10993. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10994. // ***INIT GLOBALE*** pvActuelKastar
  10995. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10996. appendText(
  10997. insertPt,
  10998. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10999. true
  11000. );
  11001. appendBr(insertPt);
  11002. } else {
  11003. DLAaccel = new Date( DLA );
  11004. pvActuelKastar = pvcourant;
  11005. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  11006. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  11007. } else {
  11008. lastDLA = false;
  11009. }
  11010. }
  11011. appendText(insertPt,'Dernière DLA enregistrée : ');
  11012. lastDLAZone = document.createElement('span');
  11013. lastDLAZone.style.cursor = 'pointer';
  11014. var b = document.createElement('b');
  11015. b.onclick = inputMode;
  11016. lastDLAZone.appendChild(b);
  11017. insertPt.appendChild(lastDLAZone);
  11018. if(lastDLA) {
  11019. appendText(b,DateToString(lastDLA));
  11020. } else {
  11021. appendText(b,'aucune');
  11022. }
  11023. appendBr(insertPt);
  11024. // Setup maxAMZone et cumulZone
  11025. appendText(insertPt,'Accélération maximale possible : ');
  11026. maxAMZone = document.createElement('b');
  11027. insertPt.appendChild(maxAMZone);
  11028. appendBr(insertPt);
  11029. cumulZone = document.createElement('span');
  11030. insertPt.appendChild(cumulZone);
  11031. refreshAccel();
  11032. }
  11033.  
  11034. function refreshAccel() {
  11035. var pvs, pvsmax;
  11036. // Acceleration pour cumul instantane
  11037. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  11038. if(lastDLA) {
  11039. pvsmax = Math.min(
  11040. pvActuelKastar-1,
  11041. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  11042. );
  11043. maxAMZone.innerHTML = pvsmax+" PV";
  11044. } else {
  11045. pvsmax = pvActuelKastar-1;
  11046. maxAMZone.innerHTML = "inconnue";
  11047. }
  11048. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  11049. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  11050. cumulZone.innerHTML = '';
  11051. if(pvs<=pvsmax) {
  11052. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  11053. appendText(cumulZone,pvs+' PV', true);
  11054. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  11055. if(pvs!=1) {
  11056. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  11057. -(pvs-1)*60*minParPV;
  11058. appendText(
  11059. cumulZone,
  11060. ' ('+(pvs-1)+' PV dans '+
  11061. Math.floor(gainSec/60)+'min'+
  11062. addZero(gainSec%60)+'s)'
  11063. );
  11064. }
  11065. } else {
  11066. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  11067. appendText(
  11068. cumulZone,
  11069. 'Après votre accélération maximale, il vous faudra encore attendre '+
  11070. dureeHM(avantDLA/6e4)+
  11071. ' avant de réactiver.'
  11072. );
  11073. }
  11074. }
  11075.  
  11076.  
  11077. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  11078.  
  11079. function traitementTalents() {
  11080. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  11081. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  11082. removeAllTalents();
  11083. var totalComp = injecteInfosBulles(trCompetence,'competences');
  11084. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  11085. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  11086. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  11087. }
  11088.  
  11089. function injecteInfosBulles(liste,fonction) {
  11090. var totalpc = 0;
  11091. // on parse la liste des talents du type 'fonction'
  11092. for(var i=0 ; i<liste.length ; i++) {
  11093. var
  11094. trTalent=liste[i],
  11095. node=trTalent.cells[1].querySelector('a'),
  11096. nomTalent=epure(trim(node.textContent)),
  11097. indiceTDniveaux=7,
  11098. indiceTDSousCompetence=2,
  11099. sousCompetences=undefined;
  11100. if(fonction=="competences"){
  11101. // un TD en plus pour des information complementaire liees a la comp
  11102. indiceTDniveaux++;
  11103. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  11104. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  11105. for (var j=0; j < sousCompetences.length; j++) {
  11106. sousCompetences[j] = sousCompetences[j].epure().trim();
  11107. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  11108. }
  11109. }
  11110. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  11111. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  11112. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  11113. totalpc += niveauxMaitrisesTalentArray[1];
  11114.  
  11115. // stockage des niveaux inferieurs du talent si presents
  11116. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  11117. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  11118. totalpc+=niveauxMaitrisesTalentArray[j+1];
  11119. }
  11120. }
  11121. return totalpc;
  11122. }
  11123.  
  11124. function setInfos(node,nom,fonction,niveau) {
  11125. node.nom = nom;
  11126. node.fonction = fonction;
  11127. node.niveau = niveau;
  11128. node.onmouseover = setBulle;
  11129. node.onmouseout = cacherBulle;
  11130. }
  11131.  
  11132. var arrayModifAnatroll = {
  11133. 'Glue':'Glu',
  11134. 'PuM':'PuiM',
  11135. 'HE':'Hurlement',
  11136. //'Insultes':'Insu',
  11137. 'Pistage':'Pist',
  11138. 'PuC':'Planter'
  11139. }
  11140.  
  11141. function setTalent(nom,pc,niveau,sousCompetences) {
  11142. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  11143. // (et pas les % dont osf) ne serait pas plus rentable
  11144. var nomEnBase = arrayTalents[epure(nom)];
  11145. if(!nomEnBase) { return; }
  11146. if(!niveau) { niveau = 1; }
  11147. switch(nomEnBase) {
  11148. case 'Insultes':
  11149. urlAnatrolliseur += 'Insu'+niveau+'|';
  11150. case 'IdT':
  11151. nomEnBase += niveau;
  11152. break;
  11153. case 'Golemo':
  11154. case 'Piege':
  11155. for (var i=0 ; i < sousCompetences.length ; i++) {
  11156. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  11157. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  11158. }
  11159. break;
  11160. case 'AP':
  11161. case 'Baroufle':
  11162. case 'CdB':
  11163. case 'CdM':
  11164. case 'Parer':
  11165. case 'Retraite':
  11166. case 'RB':
  11167. case 'SInterposer':
  11168. nomEnBase += niveau;
  11169. default:
  11170. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  11171. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  11172. }
  11173. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  11174. }
  11175.  
  11176. function creerBulleVide() {
  11177. var table = document.createElement('table');
  11178. table.id = 'bulle';
  11179. table.className = 'mh_tdborder';
  11180. table.width = 300;
  11181. table.border = 0;
  11182. table.cellPadding = 5;
  11183. table.cellSpacing = 1;
  11184. table.style =
  11185. 'position:absolute;'
  11186. +'visibility:hidden;'
  11187. +'z-index:800;'
  11188. +'height:auto;';
  11189. var tr = appendTr(table,'mh_tdtitre');
  11190. appendTdText(tr,'Titre');
  11191. tr = appendTr(table,'mh_tdpage');
  11192. appendTdText(tr,'Contenu');
  11193. var aList = document.getElementsByTagName('a');
  11194. aList[aList.length-1].parentNode.appendChild(table);
  11195. }
  11196.  
  11197. function cacherBulle() {
  11198. if(bulleStyle)
  11199. bulleStyle.visibility = 'hidden';
  11200. }
  11201.  
  11202. function setBulle(evt) {
  11203. var nom = this.nom;
  11204. var fonction = this.fonction;
  11205. var niveau = parseInt(this.niveau);
  11206. var str='';
  11207. if(fonction=='competences'){
  11208. str=competences(nom,niveau);
  11209. } else if(fonction=='sortileges') {
  11210. str=sortileges(nom,true);
  11211. }
  11212. if(str=='') return;
  11213. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  11214. var xfenetre, yfenetre, xpage, ypage, element = null;
  11215. var offset = 15;
  11216. var bulleWidth = 300;
  11217. if(!hauteur) hauteur = 50;
  11218. element = document.getElementById('bulle');
  11219. xfenetre = evt.clientX;
  11220. yfenetre = evt.clientY;
  11221. xpage = xfenetre;
  11222. ypage = yfenetre;
  11223. if(evt.pageX) xpage = evt.pageX;
  11224. if(evt.pageY) ypage = evt.pageY;
  11225. if(element) {
  11226. bulleStyle = element.style;
  11227. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  11228. element.childNodes[1].firstChild.innerHTML = str;
  11229. }
  11230. if(bulleStyle) {
  11231. if(xfenetre>bulleWidth+offset)
  11232. xpage -= bulleWidth+offset;
  11233. else
  11234. xpage += offset;
  11235. if(yfenetre>hauteur+offset)
  11236. ypage -= hauteur + offset;
  11237. bulleStyle.width = bulleWidth;
  11238. bulleStyle.left = xpage + 'px';
  11239. bulleStyle.top = ypage + 'px';
  11240. bulleStyle.visibility = 'visible';
  11241. }
  11242. }
  11243.  
  11244.  
  11245. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  11246.  
  11247. function competences(comp,niveau) {
  11248. var texte = '';
  11249. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  11250. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  11251. if(minParPV>1) texte += 's';
  11252. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  11253. }
  11254. else if(comp.indexOf('Attaque Precise')!=-1) {
  11255. var pc, lastmax=0, espatt=0;
  11256. var notMaxedOut = false;
  11257. for(var i=niveau ; i>0 ; i--) {
  11258. pc = getTalent(comp,i);
  11259. if(lastmax!=0 && pc<=lastmax) continue;
  11260. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  11261. attbp+attbm;
  11262. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11263. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  11264. ' => <b>'+jetatt+'</b><br/>';
  11265. espatt += (pc-lastmax)*jetatt;
  11266. lastmax = pc;
  11267. if(i<niveau) notMaxedOut = true;
  11268. }
  11269. if(notMaxedOut) {
  11270. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  11271. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  11272. }
  11273. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  11274. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11275. }
  11276. else if(comp.indexOf('Balayage')!=-1)
  11277. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  11278. +' => <b>'+attmoy+'</b><br/>'
  11279. +'Effet : <b>Met à terre l\'adversaire</b>';
  11280. else if(comp.indexOf('Bidouille')!=-1)
  11281. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  11282. +'de votre inventaire avec le texte de votre choix.';
  11283. else if(comp.indexOf('Baroufle')!=-1){
  11284. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  11285. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  11286. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  11287. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  11288. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  11289. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  11290. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  11291. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  11292. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  11293. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  11294. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  11295. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  11296. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  11297. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  11298. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  11299. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  11300. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  11301. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  11302. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  11303. '</tbody></table>';
  11304. }
  11305. else if(comp.indexOf('Botte Secrete')!=-1){
  11306. texte = 'Attaque : <b>'
  11307. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11308. +' => <b>'
  11309. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  11310. +'</b><br/>Dégâts : <b>'
  11311. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  11312. +' => <b>'
  11313. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  11314. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  11315. +'</b>';
  11316. }
  11317. else if(comp.indexOf('Camouflage')!=-1) {
  11318. var camou = getTalent('Camouflage');
  11319. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  11320. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  11321. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  11322. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  11323. }
  11324. else if(comp.indexOf('Charger')!=-1) {
  11325. if(pvcourant<=0)
  11326. return '<i>On ne peut charger personne quand on est mort !</i>';
  11327. var portee = Math.min(
  11328. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  11329. vuetotale);
  11330. if(portee<1)
  11331. return '<b>Impossible de charger</b>';
  11332. else {
  11333. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11334. +' => <b>'+attmoy+'</b><br/>'
  11335. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11336. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  11337. +'<br/>Portée : <b>'+portee+'</b> case';
  11338. if(portee>1) texte += 's';
  11339. }
  11340. }
  11341. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  11342. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  11343. if(vuetotale>1) texte += 's';
  11344. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11345. if(vuetotale>2) texte += 's';
  11346. }
  11347. else if(comp.indexOf('Piege')!=-1) {
  11348. if(comp.indexOf('Glue')!=-1)
  11349. texte = 'Et si vous colliez vos adversaires au sol ?';
  11350. if(comp.indexOf('Feu')!=-1) {
  11351. if(texte){
  11352. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  11353. }
  11354. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  11355. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  11356. }
  11357. }
  11358. else if(comp.indexOf('Contre-Attaquer')!=-1){
  11359. texte = 'Attaque : <b>'
  11360. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11361. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11362. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11363. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11364. }
  11365. else if(comp.indexOf('Coup de Butoir')!=-1) {
  11366. var pc, lastmax=0, espdeg=0;
  11367. var notMaxedOut = false;
  11368. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11369. +' => <b>'+attmoy+'</b>';
  11370. for(var i=niveau ; i>0 ; i--) {
  11371. pc = getTalent(comp,i);
  11372. if(lastmax!=0 && pc<=lastmax) continue;
  11373. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  11374. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11375. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  11376. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  11377. espdeg += (pc-lastmax)*jetdeg;
  11378. lastmax = pc;
  11379. if(i<niveau) notMaxedOut = true;
  11380. }
  11381. if(notMaxedOut) {
  11382. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  11383. Math.floor(10*espdeg/lastmax)/10+'/'+
  11384. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  11385. }
  11386. }
  11387. else if(comp.indexOf('Course')!=-1)
  11388. texte = 'Déplacement gratuit : <b>'
  11389. +Math.floor(getTalent('Course')/2)
  11390. +' %</b> de chance';
  11391. else if(comp.indexOf('Deplacement Eclair')!=-1)
  11392. texte = 'Permet d\'économiser <b>1</b> PA '
  11393. +'par rapport au déplacement classique';
  11394. else if(comp.indexOf('Dressage')!=-1)
  11395. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  11396. +'ou un gnu sauvage.';
  11397. else if(comp.indexOf('Ecriture Magique')!=-1)
  11398. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  11399. +'la formule nécessite de réunir les composants de cette formule, '
  11400. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  11401. +'un champignon adéquat pour confectionner l\'encre.';
  11402. else if(comp.indexOf('Frenesie')!=-1) {
  11403. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11404. +' => <b>'+attmoy+'</b><br/>'
  11405. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11406. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11407. }
  11408. else if(comp.indexOf('Golem')!=-1)
  11409. texte = 'Animez votre golem en assemblant divers matériaux '
  11410. +'autour d\'un cerveau minéral.'
  11411. else if(comp.indexOf('Grattage')!=-1) {
  11412. texte = 'Permet de confectionner un Parchemin Vierge '
  11413. +'à partir de composants et de Gigots de Gob\'.';
  11414. }
  11415. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  11416. texte = 'Fait fuir un monstre si tout se passe bien.'
  11417. +'<br/>Lui donne de gros bonus sinon...';
  11418. else if(comp.indexOf('Identification des Champignons')!=-1) {
  11419. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  11420. if(vuetotale>2) texte += 's';
  11421. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  11422. if(vuetotale>4) texte += 's';
  11423. }
  11424. else if(comp.indexOf('Insultes')!=-1)
  11425. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  11426. else if(comp.indexOf('interposer')!=-1)
  11427. texte = 'Jet de réflexe : <b>'
  11428. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  11429. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  11430. else if(comp.indexOf('Lancer de Potions') != -1)
  11431. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  11432. else if(comp.indexOf('Marquage')!=-1)
  11433. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  11434. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  11435. +'se trouver dans la même caverne que le monstre pour le marquer.';
  11436. else if(comp.indexOf('Melange Magique')!=-1)
  11437. texte = 'Cette Compétence permet de combiner deux Potions pour '
  11438. +'en réaliser une nouvelle dont l\'effet est la somme '
  11439. +'des effets des potions initiales.';
  11440. else if(comp.indexOf('Miner')!=-1)
  11441. texte = 'Portée horizontale (officieuse) : <b>'
  11442. +2*vuetotale+'</b> cases<br/>'
  11443. +'Portée verticale (officieuse) : <b>'
  11444. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11445. else if(comp.indexOf('Necromancie')!=-1)
  11446. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  11447. +'de faire "revivre" ce monstre.';
  11448. else if(comp.indexOf('Painthure de Guerre')!=-1)
  11449. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  11450. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  11451. +'pour s\'inspirer, et laissez parler votre créativité.'
  11452. else if(comp.indexOf('Parer')!=-1)
  11453. texte = 'Jet de parade : <b>'
  11454. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  11455. +' => <b>'
  11456. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11457. +'</b><hr><i>Equivalent esquive : <b>'
  11458. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  11459. +' => <b>'
  11460. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  11461. +'</b></i>';
  11462. else if(comp.indexOf('Pistage')!=-1)
  11463. texte = 'Portée horizontale : <b>'
  11464. +2*vuetotale+'</b> cases<br/>'
  11465. +'Portée verticale : <b>'
  11466. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11467. else if(comp.indexOf('Planter un Champignon')!=-1)
  11468. texte = 'Planter un Champignon est une compétence qui vous permet de '
  11469. +'créer des colonies d\'une variété donnée de champignon à partir de '
  11470. +'quelques exemplaires préalablement enterrés.';
  11471. else if(comp.indexOf('Regeneration Accrue')!=-1)
  11472. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  11473. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  11474. else if(comp.indexOf('Reparation')!=-1)
  11475. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  11476. +'et réparez vous-même votre matériel !';
  11477. else if(comp.indexOf('Retraite')!=-1)
  11478. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  11479. +'préférable de préparer un repli stratégique pour déconcerter '
  11480. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  11481. +'Quelle intelligence démoniaque.';
  11482. else if(comp.indexOf('Rotobaffe')!=-1) {
  11483. var Datt = att, vattbm = attbp+attbm;
  11484. var Ddeg = deg, vdegbm = degbp+degbm;
  11485. for(var i=1 ; i<niveau+2 ; i++) {
  11486. texte += '<b>Attaque n°'+i+' :</b><br/>'
  11487. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  11488. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  11489. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  11490. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  11491. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  11492. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  11493. if(i<niveau+1) texte += '<hr>';
  11494. }
  11495. }
  11496. else if(comp.indexOf('Shamaner')!=-1)
  11497. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  11498. +'des monstres en utilisant des champignons (de 1 à 3).';
  11499. else if(comp.indexOf('Tailler')!=-1){
  11500. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  11501. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  11502. }
  11503. return texte;
  11504. }
  11505.  
  11506. function decumul_buff(nom,str,buff) {
  11507. // Decumul des sorts de buff
  11508. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  11509. var dec = buff, total = buff, i=1;
  11510. while(i<6) {
  11511. i++;
  11512. dec = Math.floor(coefDecumul(i)*buff);
  11513. if(dec<=1 || i==6) break;
  11514. total += dec;
  11515. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  11516. +str+' +'+dec+' (+'+total+')</i>';
  11517. }
  11518. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  11519. return ret;
  11520. }
  11521.  
  11522.  
  11523. function sortileges(sort,mainCall,pcA,pcD) {
  11524. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  11525. var texte = '';
  11526. if (mainCall) {
  11527. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  11528. pcA = (atttourP+atttourM);
  11529. pcD = (degtourP+degtourM);
  11530. }
  11531. if (sort.indexOf('Analyse Anatomique') != -1) {
  11532. texte = 'Portée horizontale : <b>'
  11533. + Math.floor(vuetotale / 2) + '</b> case';
  11534. if (vuetotale > 3){ texte += 's'; }
  11535. texte += '<br/>Portée verticale : <b>'
  11536. + Math.floor((vuetotale+1)/4)+'</b> case';
  11537. if (vuetotale > 7){ texte += 's'; }
  11538. }
  11539. else if (sort.indexOf('Armure Etheree') != -1){
  11540. texte = decumul_buff('AE', 'Armure magique', reg);
  11541. }
  11542. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  11543. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  11544. }
  11545. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  11546. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  11547. }
  11548. else if (sort.indexOf('Augmentation des Degats') != -1){
  11549. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  11550. }
  11551. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  11552. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  11553. }
  11554. else if(sort.indexOf('Bulle Magique')!=-1){
  11555. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  11556. }
  11557. else if(sort.indexOf('Explosion')!=-1){
  11558. texte = 'Dégâts : <b>'
  11559. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  11560. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  11561. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  11562. }
  11563. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  11564. if(pvcourant<=0)
  11565. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  11566. texte = 'Portée horizontale : <b>'
  11567. +Math.min(1,vuetotale)+'</b> case<br/>'
  11568. +'Dégâts physiques : <b>-'
  11569. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  11570. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  11571. +'Dégâts magiques : <b>-'
  11572. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  11573. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  11574. }
  11575. else if(sort.indexOf('Flash Aveuglant')!=-1){
  11576. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  11577. }
  11578. else if(sort.indexOf('Glue')!=-1) {
  11579. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  11580. if(vuetotale>2) texte += 's';
  11581. }
  11582. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  11583. /* Frappe */
  11584. var modD = 0;
  11585. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11586. if(pcA!=0){
  11587. modD = parseInt(att*pcA/100);
  11588. texte += '<i>'+aff(modD)+'D6</i> ';
  11589. }
  11590. texte += aff(attbm)
  11591. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  11592. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  11593. if(pcD!=0) {
  11594. modD = parseInt(Math.floor(deg/2)*pcD/100);
  11595. texte += '<i>'+aff(modD)+'D3</i> ';
  11596. }else
  11597. modD = 0;
  11598. texte += aff(degbm)+' => <b>'
  11599. +(2*(Math.floor(deg/2)+modD)+degbm)
  11600. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  11601. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  11602. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  11603. +')</b>';
  11604. if(!mainCall) return texte;
  11605. /* Venins */
  11606. function addVenin(type,effet,duree) {
  11607. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  11608. +' pendant <b>'+duree+'</b> tour';
  11609. if(duree>1) ret += 's';
  11610. var dred = Math.max(Math.floor(duree/2),1);
  11611. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  11612. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  11613. }
  11614. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  11615. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  11616. effet = Math.floor(1.5*effet);
  11617. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  11618. }
  11619. else if(sort.indexOf('Hypnotisme')!=-1)
  11620. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  11621. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  11622. else if(sort.indexOf('Identification des tresors')!=-1)
  11623. texte = 'Permet de connaitre les caractéristiques et effets précis '
  11624. +'d\'un trésor.';
  11625. else if(sort.indexOf('Invisibilite')!=-1)
  11626. texte = 'Un troll invisible est indétectable même quand on se trouve '
  11627. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  11628. +'fait disparaître l\'invisibilité.';
  11629. else if(sort.indexOf('Levitation')!=-1)
  11630. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  11631. +'Comme les pièges ou les trous par exemple...';
  11632. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  11633. var eps = 1,
  11634. pc = 20;
  11635. var str = 'PréM';
  11636. var newSort;
  11637. var sortAtt = [
  11638. 'Projectile Magique',
  11639. 'Rafale Psychique',
  11640. 'Siphon des Ames',
  11641. 'Vampirisme',
  11642. 'Griffe du Sorcier'
  11643. ];
  11644. if(sort.indexOf('Puissance')!=-1) {
  11645. eps = -1; str='PuM';
  11646. }
  11647. for(var i=1 ; i<4 ; i++) {
  11648. if(texte) { texte += '<hr>'; }
  11649. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  11650. newSort = false;
  11651. for(var j=0 ; j<sortAtt.length ; j++) {
  11652. if(getTalent(sortAtt[j])) {
  11653. if(newSort) { texte += '<br/><br/>'; }
  11654. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  11655. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  11656. newSort = true;
  11657. }
  11658. }
  11659. pc = decumulPumPrem(pc);
  11660. }
  11661. }
  11662. else if(sort.indexOf('Projectile Magique')!=-1) {
  11663. var modD = 0;
  11664. var portee = getPortee__Profil(vuetotale);
  11665. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  11666. if(pcA!=0) {
  11667. modD = parseInt(vue*pcA/100);
  11668. texte += '<i>'+aff(modD)+'D6</i> ';
  11669. }
  11670. texte += aff(attbm)
  11671. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  11672. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  11673. if(pcD!=0) {
  11674. modD = parseInt(Math.floor(vue/2)+pcD);
  11675. texte += '<i>'+aff(modD)+'D3</i> ';
  11676. }else
  11677. modD = 0;
  11678. texte += aff(degbm)
  11679. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  11680. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  11681. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  11682. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+') (+ 1D3 par bonus de portée)</b>';
  11683. if(!mainCall) return texte;
  11684. texte += '<br/>Portée : <b>'+portee+'</b> case';
  11685. if(portee>1) texte += 's';
  11686. }
  11687. else if(sort.indexOf('Projection')!=-1) {
  11688. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  11689. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  11690. +'Si le jet de résistance de la victime est réussi:<br/>'
  11691. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  11692. }
  11693. else if(sort.indexOf('Rafale Psychique')!=-1) {
  11694. var modD = 0;
  11695. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  11696. if(pcD!=0) {
  11697. modD = parseInt(deg*pcD/100);
  11698. texte += '<i>'+aff(modD)+'D3</i> ';
  11699. }
  11700. texte += aff(degbm)
  11701. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  11702. if(!mainCall) return texte;
  11703. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  11704. }
  11705. else if(sort.indexOf('Sacrifice')!=-1) {
  11706. if(pvcourant<=0)
  11707. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  11708.  
  11709. function perteSacro(sac) {
  11710. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  11711. }
  11712.  
  11713. var sac = Math.floor((pvcourant-1)/2);
  11714. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11715. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  11716. /* Sacros max et optimal sans malus (propale R') */
  11717. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11718. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  11719. if(sac>0)
  11720. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  11721. else
  11722. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  11723. /*if(sac>3) {
  11724. sac = 5*Math.floor((sac+1)/5)-1;
  11725. texte += '<br/>Soin optimal sans malus de temps : <b>'
  11726. +sac+'</b> PV'+perteSacro(sac);
  11727. }*/
  11728. }
  11729. else if(sort.indexOf('Siphon')!=-1) {
  11730. var modD = 0;
  11731. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11732. if(pcA!=0) {
  11733. modD = parseInt(att*pcA/100);
  11734. texte += '<i>'+aff(modD)+'D6</i> ';
  11735. }
  11736. texte += aff(attbm)
  11737. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  11738. +'Dégâts : <b>'+reg+'</b> D3 ';
  11739. if(pcD!=0) {
  11740. modD = parseInt(reg*pcD/100);
  11741. texte += '<i>'+aff(modD)+'D3</i> ';
  11742. }else
  11743. modD = 0;
  11744. texte += aff(degbm)
  11745. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  11746. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  11747. if(!mainCall) return texte;
  11748. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  11749. }
  11750. else if(sort.indexOf('Telekinesie')!=-1) {
  11751. texte = 'Portée horizontale :';
  11752. var vt = Math.floor(vuetotale/2)+2;
  11753. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  11754. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  11755. for(var i=0 ; i<5 ; i++) {
  11756. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  11757. if(vt>1) texte += 's';
  11758. vt=Math.max(0,vt-1);
  11759. }
  11760. }
  11761. else if(sort.indexOf('Teleportation')!=-1) {
  11762. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  11763. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  11764. var pmh = (20+vue+portee);
  11765. var pmv = 3+Math.floor(portee/3);
  11766. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  11767. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  11768. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  11769. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  11770. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  11771. }
  11772. else if(sort.indexOf('Vampirisme')!=-1) {
  11773. var modD = 0;
  11774. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  11775. if(pcA!=0) {
  11776. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  11777. texte += '<i>'+aff(modD)+'D6</i> ';
  11778. }
  11779. texte += aff(attbm)
  11780. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  11781. +'Dégâts : <b>'+deg+'</b> D3 ';
  11782. if(pcD!=0) {
  11783. modD = parseInt(deg*pcD/100);
  11784. texte += '<i>'+aff(modD)+'D3</i> ';
  11785. }else
  11786. modD = 0;
  11787. texte += aff(degbm)
  11788. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  11789. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  11790. }
  11791. else if(sort.indexOf('Vision Accrue')!=-1)
  11792. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  11793. else if(sort.indexOf('Vision lointaine')!=-1)
  11794. texte = 'En ciblant une zone située n\'importe où dans le '
  11795. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  11796. else if(sort.indexOf('Voir le Cache')!=-1)
  11797. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  11798. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  11799. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  11800. +getPortee__Profil(vuetotale)+'</b> cases';
  11801. else if(sort.indexOf('Vue Troublee')!=-1)
  11802. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11803. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  11804. return texte;
  11805. }
  11806.  
  11807.  
  11808. /*---------------------------------- Main ------------------------------------*/
  11809.  
  11810. function do_profil2()
  11811. {
  11812. try {
  11813. start_script(31);
  11814.  
  11815. extractionDonnees();
  11816. setInfosCaracteristiques();
  11817. setInfoDescription();
  11818. setInfosEtatLieux();
  11819. setInfosEtatPV();
  11820. setInfosExp();
  11821.  
  11822. creerBulleVide();
  11823. traitementTalents();
  11824. setLienAnatrolliseur();
  11825.  
  11826. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  11827. if(race=='Kastar'){ setAccel(); }
  11828. saveProfil();
  11829. displayScriptTime();
  11830. } catch(e) {
  11831. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  11832. window.console.error(traceStack(e, 'profil2'));
  11833. }
  11834. }
  11835.  
  11836. /*******************************************************************************
  11837. * This file is part of Mountyzilla. *
  11838. * *
  11839. * Mountyzilla is free software; you can redistribute it and/or modify *
  11840. * it under the terms of the GNU General Public License as published by *
  11841. * the Free Software Foundation; either version 2 of the License, or *
  11842. * (at your option) any later version. *
  11843. * *
  11844. * Mountyzilla is distributed in the hope that it will be useful, *
  11845. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11846. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11847. * GNU General Public License for more details. *
  11848. * *
  11849. * You should have received a copy of the GNU General Public License *
  11850. * along with Mountyzilla; if not, write to the Free Software *
  11851. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11852. *******************************************************************************/
  11853.  
  11854. // x~x script_principal
  11855.  
  11856. function isPage(url) {
  11857. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  11858. }
  11859.  
  11860. // x~x md5.js
  11861. /*
  11862. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  11863. * Digest Algorithm, as defined in RFC 1321.
  11864. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  11865. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  11866. * Distributed under the BSD License
  11867. * See http://pajhome.org.uk/crypt/md5 for more info.
  11868. */
  11869.  
  11870. /*
  11871. * Configurable variables. You may need to tweak these to be compatible with
  11872. * the server-side, but the defaults work in most cases.
  11873. */
  11874. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  11875. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  11876. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  11877.  
  11878. /*
  11879. * These are the functions you'll usually want to call
  11880. * They take string arguments and return either hex or base-64 encoded strings
  11881. */
  11882. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  11883. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  11884. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  11885. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  11886. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  11887. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  11888.  
  11889. /*
  11890. * Perform a simple self-test to see if the VM is working
  11891. */
  11892. function md5_vm_test()
  11893. {
  11894. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11895. }
  11896.  
  11897. /*
  11898. * Calculate the MD5 of an array of little-endian words, and a bit length
  11899. */
  11900. function core_md5(x, len)
  11901. {
  11902. /* append padding */
  11903. x[len >> 5] |= 0x80 << ((len) % 32);
  11904. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11905.  
  11906. var a = 1732584193;
  11907. var b = -271733879;
  11908. var c = -1732584194;
  11909. var d = 271733878;
  11910.  
  11911. for(var i = 0; i < x.length; i += 16)
  11912. {
  11913. var olda = a;
  11914. var oldb = b;
  11915. var oldc = c;
  11916. var oldd = d;
  11917.  
  11918. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11919. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11920. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11921. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11922. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11923. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11924. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11925. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11926. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11927. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11928. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11929. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11930. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11931. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11932. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11933. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11934.  
  11935. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11936. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11937. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11938. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11939. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11940. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11941. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11942. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11943. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11944. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11945. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11946. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11947. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11948. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11949. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11950. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11951.  
  11952. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11953. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11954. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11955. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11956. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11957. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11958. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11959. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11960. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11961. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11962. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11963. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11964. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11965. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11966. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11967. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11968.  
  11969. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11970. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11971. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11972. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11973. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11974. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11975. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11976. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11977. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11978. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11979. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11980. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11981. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11982. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11983. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11984. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11985.  
  11986. a = safe_add(a, olda);
  11987. b = safe_add(b, oldb);
  11988. c = safe_add(c, oldc);
  11989. d = safe_add(d, oldd);
  11990. }
  11991. return Array(a, b, c, d);
  11992.  
  11993. }
  11994.  
  11995. /*
  11996. * These functions implement the four basic operations the algorithm uses.
  11997. */
  11998. function md5_cmn(q, a, b, x, s, t)
  11999. {
  12000. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  12001. }
  12002. function md5_ff(a, b, c, d, x, s, t)
  12003. {
  12004. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  12005. }
  12006. function md5_gg(a, b, c, d, x, s, t)
  12007. {
  12008. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  12009. }
  12010. function md5_hh(a, b, c, d, x, s, t)
  12011. {
  12012. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  12013. }
  12014. function md5_ii(a, b, c, d, x, s, t)
  12015. {
  12016. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  12017. }
  12018.  
  12019. /*
  12020. * Calculate the HMAC-MD5, of a key and some data
  12021. */
  12022. function core_hmac_md5(key, data)
  12023. {
  12024. var bkey = str2binl(key);
  12025. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  12026.  
  12027. var ipad = Array(16), opad = Array(16);
  12028. for(var i = 0; i < 16; i++)
  12029. {
  12030. ipad[i] = bkey[i] ^ 0x36363636;
  12031. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  12032. }
  12033.  
  12034. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  12035. return core_md5(opad.concat(hash), 512 + 128);
  12036. }
  12037.  
  12038. /*
  12039. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  12040. * to work around bugs in some JS interpreters.
  12041. */
  12042. function safe_add(x, y)
  12043. {
  12044. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  12045. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  12046. return (msw << 16) | (lsw & 0xFFFF);
  12047. }
  12048.  
  12049. /*
  12050. * Bitwise rotate a 32-bit number to the left.
  12051. */
  12052. function bit_rol(num, cnt)
  12053. {
  12054. return (num << cnt) | (num >>> (32 - cnt));
  12055. }
  12056.  
  12057. /*
  12058. * Convert a string to an array of little-endian words
  12059. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  12060. */
  12061. function str2binl(str)
  12062. {
  12063. var bin = Array();
  12064. var mask = (1 << chrsz) - 1;
  12065. for(var i = 0; i < str.length * chrsz; i += chrsz)
  12066. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  12067. return bin;
  12068. }
  12069.  
  12070. /*
  12071. * Convert an array of little-endian words to a string
  12072. */
  12073. function binl2str(bin)
  12074. {
  12075. var str = "";
  12076. var mask = (1 << chrsz) - 1;
  12077. for(var i = 0; i < bin.length * 32; i += chrsz)
  12078. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  12079. return str;
  12080. }
  12081.  
  12082. /*
  12083. * Convert an array of little-endian words to a hex string.
  12084. */
  12085. function binl2hex(binarray)
  12086. {
  12087. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  12088. var str = "";
  12089. for(var i = 0; i < binarray.length * 4; i++)
  12090. {
  12091. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  12092. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  12093. }
  12094. return str;
  12095. }
  12096.  
  12097. /*
  12098. * Convert an array of little-endian words to a base-64 string
  12099. */
  12100. function binl2b64(binarray)
  12101. {
  12102. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  12103. var str = "";
  12104. for(var i = 0; i < binarray.length * 4; i += 3)
  12105. {
  12106. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  12107. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  12108. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  12109. for(var j = 0; j < 4; j++)
  12110. {
  12111. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  12112. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  12113. }
  12114. }
  12115. return str;
  12116. }
  12117.  
  12118. ///////////////////////////////////////////
  12119. // debug cartes capitan Roule 07/12/2016
  12120. ///////////////////////////////////
  12121. // essais : objet
  12122. // .mode : description
  12123. // .essais : tableau d'objets essai
  12124. // .mode : description
  12125. // .essais : tableau de cartes
  12126. // .noCarte : id de la carte
  12127. // .essais : tableau d'essais, [x, y, n, nb]
  12128. function AfficheEssais(essais, sMode) {
  12129. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  12130. if (!eBigDiv) {
  12131. var insertPoint = document.getElementById('footer1');
  12132. eBigDiv = document.createElement('table');
  12133. eBigDiv.id = 'ListeEssaiCapitan';
  12134. insertBefore(insertPoint, document.createElement('p'));
  12135. insertTitle(insertPoint,'Capitan : Liste des essais');
  12136. insertBefore(insertPoint, eBigDiv);
  12137. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  12138. }
  12139. if (!essais) {
  12140. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  12141. return;
  12142. }
  12143. var carte;
  12144. for (carte in essais) {
  12145. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  12146. }
  12147. if (carte === undefined) {
  12148. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  12149. }
  12150. }
  12151.  
  12152. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  12153. var tr = appendTr(eTable);
  12154. var td = appendTd(tr);
  12155. appendText(td, sMode, bBold);
  12156. td = appendTd(tr);
  12157. appendText(td, sCarte, bBold);
  12158. td = appendTd(tr);
  12159. appendText(td, sText, bBold);
  12160. }
  12161.  
  12162. function getEssaiV1_0() {
  12163. try {
  12164. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  12165. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  12166. var tabK, nK;
  12167. prefs.getChildList('', nK, tabK);
  12168. window.console.log('getEssaiV1_0, nb key : ' + nK);
  12169. //window.console.log('getEssaiV1_0, ' + nK);
  12170. return;
  12171. //return r;
  12172. } catch (e) {
  12173. window.console.log(traceStack(e, 'getEssaiV1_0'));
  12174. }
  12175. }
  12176.  
  12177. function getEssaiV1_1() {
  12178. var locSto = window.localStorage;
  12179. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  12180. var r = [];
  12181. for (var i = 0; i < locSto.length; i++) {
  12182. var k = locSto.key(i);
  12183. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  12184. var t = k.split(/\./);
  12185. if (t[0] !== 'capitan') continue;
  12186. if (t[2] !== 'essai') continue;
  12187. var carte = 'carte n°' + t[1];
  12188. if (r[carte]) r[carte]++;
  12189. else r[carte] = 1;
  12190. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  12191. }
  12192. return r;
  12193. }
  12194.  
  12195. function showEssaiCartes() {
  12196. window.console.log('début showEssai Tout_MZ');
  12197. var essais = getEssaiV1_0();
  12198. AfficheEssais(essais, 'V1.0');
  12199. essais = getEssaiV1_1();
  12200. AfficheEssais(essais, 'V1.1');
  12201. window.console.log('fin showEssai Tout_MZ');
  12202. }
  12203.  
  12204. function testBoolLocalStorage() {
  12205. var b = true;
  12206. var key = 'MZ_essai_bool';
  12207. GM_setValue(key, b);
  12208. window.localStorage[key] = b;
  12209. var v = GM_getValue(key);
  12210. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  12211. var v = window.localStorage.getItem(key);
  12212. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  12213.  
  12214. var b = false;
  12215. GM_setValue(key, b);
  12216. window.localStorage[key] = b;
  12217. var v = GM_getValue(key);
  12218. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  12219. var v = window.localStorage.getItem(key);
  12220. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  12221.  
  12222. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  12223. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  12224. var y = GM_getValue('654654897894654654');
  12225. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  12226. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  12227. }
  12228.  
  12229. /*--------------------------------- Création liste trolligion ---------------------------------*/
  12230. function export_trolligion() {
  12231. try {
  12232. var tabDl = document.getElementsByTagName('dl');
  12233. if ((!tabDl) || !tabDl[0]) {
  12234. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  12235. return;
  12236. }
  12237. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  12238. // nom : string
  12239. // rayonnement : entier
  12240. // grades : table d'objets (une occurence par grade)
  12241. // nom : string
  12242. // trolls : table d'objets (un par Trõll)
  12243. // id
  12244. // nom
  12245. // idguilde
  12246. // guilde
  12247. // race
  12248. // niveau
  12249. // ferveur
  12250. var currentDieu;
  12251. var currentGrade;
  12252. for (var iChild1 in tabDl[0].children) {
  12253. var eChild1 = tabDl[0].children[iChild1];
  12254. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  12255. case 'dd': // Trõll
  12256. var oTroll = {};
  12257. var tabFigcaption = eChild1.getElementsByTagName('figcaption');
  12258. if ((!tabFigcaption) || !tabFigcaption[0]) {
  12259. window.console.log('[MZ ' + GM_info.script.version + '] ignore dd sans figcaption ' + eChild1.innerHTML);
  12260. break;
  12261. }
  12262. for (var iChild2 in tabFigcaption[0].childNodes) { // childNodes pour obtenir les éléments texte aussi
  12263. var eChild2 = tabFigcaption[0].childNodes[iChild2];
  12264. if (eChild2.nodeType === undefined) continue; // properties
  12265. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  12266. switch (eChild2.nodeType) {
  12267. case 1: //ELEMENT_NODE:
  12268. switch (eChild2.nodeName.toLowerCase()) {
  12269. case 'a':
  12270. var m;
  12271. if (!eChild2.href) {
  12272. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  12273. break;
  12274. }
  12275. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  12276. if (m) {
  12277. oTroll.id = parseInt(m[1]);
  12278. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  12279. break;
  12280. }
  12281. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  12282. if (m) {
  12283. var idGuilde = parseInt(m[1]);
  12284. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  12285. oTroll.idguilde = parseInt(m[1]);
  12286. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  12287. }
  12288. break;
  12289. }
  12290. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  12291. break;
  12292. case 'br': // ignore
  12293. case 'style': // ignore
  12294. break;
  12295. case 'div': // barre de vie
  12296. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  12297. eChild3 = eChild2.children[0];
  12298. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  12299. var eChild4 = eChild3.children[0];
  12300. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  12301. break;
  12302. }
  12303. }
  12304. // pas de break pour bénéficier du log ci-dessous
  12305. default:
  12306. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  12307. break;
  12308. }
  12309. break;
  12310. case 3: //TEXT_NODE:
  12311. var txt = eChild2.nodeValue.trim();
  12312. if (txt === '') break;
  12313. var m = txt.match(/(.*) *\((\d+)\)/);
  12314. if (m) {
  12315. oTroll.race = m[1].trim();
  12316. oTroll.niveau = parseInt(m[2]);
  12317. } else {
  12318. oTroll.race = txt;
  12319. }
  12320. break;
  12321. default: // ne devrait pas arriver
  12322. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  12323. break;
  12324. }
  12325. }
  12326. currentGrade.trolls.push(oTroll);
  12327. break;
  12328. case 'dt':
  12329. var tabH3 = eChild1.getElementsByTagName('h3');
  12330. if (tabH3 && tabH3[0]) { // changement de dieu
  12331. currentDieu = {
  12332. nom: tabH3[0].innerText || tabH3[0].textContent
  12333. , grades: []};
  12334. var txt = eChild1.innerText || eChild1.textContent;
  12335. var m = txt.match(/yon*ement *:* *(\d+)/);
  12336. if (m) currentDieu.rayonnement = parseInt(m[1]);
  12337. currentGrade = undefined;
  12338. tabDieux.push(currentDieu);
  12339. break;
  12340. }
  12341. var tabH4 = eChild1.getElementsByTagName('h4');
  12342. if (tabH4 && tabH4[0]) { // changement de grade
  12343. var grade;
  12344. var txt = tabH4[0].innerText || tabH4[0].textContent;
  12345. tabI = tabH4[0].getElementsByTagName('i');
  12346. if (tabI && tabI[0]) {
  12347. grade = tabI[0].innerText || tabI[0].textContent;
  12348. grade = grade.replace(/"/g, '');
  12349. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  12350. if (m) grade += ' (' + m[1] + ')';
  12351. } else {
  12352. grade = txt.replace(/"/g, '');
  12353. }
  12354. currentGrade = {nom: grade, trolls: []};
  12355. currentDieu.grades.push(currentGrade);
  12356. break;
  12357. }
  12358. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  12359. break;
  12360. default:
  12361. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  12362. }
  12363. }
  12364.  
  12365. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  12366. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  12367. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  12368. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  12369. for (var iDieu in tabDieux) {
  12370. var oDieu = tabDieux[iDieu];
  12371. for (var iGrade in oDieu.grades) {
  12372. var oGrade = oDieu.grades[iGrade];
  12373. for (var iTroll in oGrade.trolls) {
  12374. var oTroll = oGrade.trolls[iTroll];
  12375. var t = [oDieu.nom, oDieu.rayonnement
  12376. , oGrade.nom
  12377. , oTroll.id, oTroll.nom
  12378. , oTroll.idguilde, oTroll.guilde
  12379. , oTroll.race, oTroll.niveau
  12380. , oTroll.ferveur];
  12381. for (var iParam in t) {
  12382. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12383. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12384. }
  12385. txt += t.join("\t") + "\n";
  12386. }
  12387. }
  12388. var t = [oDieu.nom, oDieu.rayonnement];
  12389. for (var iParam in t) {
  12390. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12391. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12392. }
  12393. txt2 += t.join("\t") + "\n";
  12394. }
  12395. txt += "\n" + txt2;
  12396. } catch (e) {
  12397. window.alert("Échec à l'extraction\n" + e);
  12398. }
  12399. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  12400. try {
  12401. if (copyTextToClipboard(txt)) {
  12402. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  12403. + "Collez dans Calc\n"
  12404. + "ou, au pire, dans EXCEL®");
  12405. } else {
  12406. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  12407. }
  12408. } catch(e) {
  12409. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  12410. }
  12411. }
  12412.  
  12413. function do_trolligion() {
  12414. var divpopup = document.createElement('div');
  12415. divpopup.id = 'MZ_divCopier';
  12416. divpopup.style.position = 'fixed';
  12417. divpopup.style.top = '2px';
  12418. divpopup.style.left = '2px;';
  12419. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  12420. divpopup.style.cursor = 'pointer';
  12421. divpopup.style.zIndex = 200;
  12422. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  12423. divpopup.onclick = export_trolligion;
  12424. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  12425. divpopup.appendChild(img);
  12426. document.body.appendChild(divpopup);
  12427. }
  12428.  
  12429. /*--------------------------------- Dispatch ---------------------------------*/
  12430.  
  12431. //chargerScriptDev("libs");
  12432. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  12433. //if (isDEV) testBoolLocalStorage();
  12434.  
  12435. // Détection de la page à traiter
  12436. if(isPage("Messagerie/ViewMessageBot")) {
  12437. do_cdmbot();
  12438. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  12439. do_cdmcomp();
  12440. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  12441. do_cdmcomp();
  12442. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  12443. do_cdmcomp();
  12444. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  12445. do_diplo();
  12446. } else if(isPage("MH_Play/Play_equipement")) {
  12447. do_equip();
  12448. } else if(isPage("MH_Play/Play_menu")) {
  12449. do_menu();
  12450. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  12451. do_option();
  12452. //showEssaiCartes();
  12453. } else if(isPage("View/PJView")) {
  12454. do_pjview();
  12455. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  12456. do_profil();
  12457. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  12458. do_tancompo();
  12459. } else if(isPage("MH_Play/Play_vue")) {
  12460. do_vue();
  12461. } else if(isPage("MH_Play/Play_news")) {
  12462. do_news();
  12463. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  12464. do_move();
  12465. } else if(isPage("MH_Missions/Mission_Etape")) {
  12466. do_mission();
  12467. } else if(isPage("View/MonsterView")) {
  12468. do_infomonstre();
  12469. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  12470. do_attaque();
  12471. } else if(isPage("MH_Play/Play_e_follo.php")) {
  12472. do_listegowap();
  12473. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  12474. do_lieuDescription();
  12475. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  12476. do_lieuTeleport();
  12477. } else if(isPage("MH_Follower/FO_Ordres")) {
  12478. do_ordresgowap();
  12479. } else if(isPage("MH_Follower/FO_Equipement")) {
  12480. do_equipgowap();
  12481. } else if(isPage("MH_Play/Play_mouche")) {
  12482. do_mouches();
  12483. } else if(isPage("MH_Play/Play_BM")) {
  12484. do_malus();
  12485. } else if(isPage("MH_Play/Play_evenement")) {
  12486. do_myevent();
  12487. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  12488. do_enchant();
  12489. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  12490. do_pre_enchant();
  12491. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  12492. do_actions();
  12493. } 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')) {
  12494. do_mission_liste();
  12495. } else if(isPage('MH_Play/Play_action')) {
  12496. do_actions();
  12497. } else if(isPage('MH_Play/Play_profil2')) {
  12498. do_profil2();
  12499. } else if(isPage('View/TrolligionView.php')) {
  12500. do_trolligion();
  12501. }
  12502. } catch(e) {
  12503. try {
  12504. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  12505. } catch(e2) {
  12506. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  12507. }
  12508. }