Tout_MZ

Client MountyZilla

当前为 2017-10-01 提交的版本,查看 最新版本

  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. // @exclude *mh2.mh.raistlin.fr*
  9. // @exclude *mzdev.mh.raistlin.fr*
  10. // @version 1.2.18.03
  11. // ==/UserScript==
  12.  
  13. // vérif UTF-8 ş
  14.  
  15. // 01/09/2017 Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16
  16. // @grant GM_getValue
  17. // @grant GM_deleteValue
  18. // @grant GM_setValue
  19.  
  20.  
  21. /*******************************************************************************
  22. * This file is part of Mountyzilla. *
  23. * *
  24. * Mountyzilla is free software; you can redistribute it and/or modify *
  25. * it under the terms of the GNU General Public License as published by *
  26. * the Free Software Foundation; either version 2 of the License, or *
  27. * (at your option) any later version. *
  28. * *
  29. * Mountyzilla is distributed in the hope that it will be useful, *
  30. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  31. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  32. * GNU General Public License for more details. *
  33. * *
  34. * You should have received a copy of the GNU General Public License *
  35. * along with Mountyzilla; if not, write to the Free Software *
  36. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  37. *******************************************************************************/
  38.  
  39. try {
  40. const MZ_changeLog = [
  41. "V1.2.18.03 01/09/2017",
  42. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  43. "V1.2.18.02 26/08/2017",
  44. " correction boulette sur le compos d'enchantement",
  45. "V1.2.18.01 25/08/2017",
  46. " Suppression des messages sur les certificats en https",
  47. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  48. "V1.2.17.19 23/08/2017",
  49. " Possibilité de plusieurs IT Bricol'Troll",
  50. "V1.2.17.18 22/08/2017",
  51. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  52. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  53. "V1.2.17.17 16/07/2017",
  54. " modification du mécanisme de filtrage pour contourner un pb",
  55. "V1.2.17.16 16/07/2017",
  56. " Ajout de messages de debug sur les retours AJAX",
  57. "V1.2.17.15 15/07/2017",
  58. " modification du mécanisme de filtrage pour contourner un pb",
  59. "V1.2.17.14 14/07/2017",
  60. " correction dans la gestion des étapes de mission",
  61. "V1.2.17.13 12/07/2017",
  62. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  63. "V1.2.17.12 16/06/2017",
  64. " Correction mauvais compte de PX quand on change de Trõll",
  65. "V1.2.17.11 01/05/2017",
  66. " Travail sur le fonctionnement hors Greasemonkey",
  67. "V1.2.17.10 30/04/2017",
  68. " Protection dans la récupération d'erreur",
  69. "V1.2.17.9 30/04/2017",
  70. " Correction récupération d'erreur IT Bricol'Troll",
  71. "V1.2.17.8 29/04/2017",
  72. " Correction Bonus/Malus cas +0\+10 (AE)",
  73. " Correction portée IdC",
  74. " Prise en compte du bonus de portée PM dans le calcul tactique",
  75. "V1.2.17.7 26/04/2017",
  76. " Version compatible hors GreaseMonkey",
  77. "V1.2.17.6 23/04/2017",
  78. " Correction gestion des missions en cas de réinstallation",
  79. "V1.2.17.5 20/04/2017",
  80. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  81. "V1.2.17.4 08/04/2017",
  82. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  83. " Adaptation de la diplomatie à une modification de la page MH",
  84. "V1.2.17.3 04/04/2017",
  85. " Messages console en cas de cadre d'erreur",
  86. " Trolls de l'IT mais pas dans le vue en orange",
  87. "V1.2.17.2 20/03/2017",
  88. " Correction des PV restants",
  89. "V1.2.17.1 20/03/2017",
  90. " Blocage des PV restants en attendant résolution de bug",
  91. "V1.2.17 19/03/2017",
  92. " Refonte de l'envoi des CdM",
  93. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  94. "V1.2.16.4 08/03/2017",
  95. " correction ID de troll en envoi de PX/MP",
  96. "V1.2.16.3 27/02/2017",
  97. " correction bonus/malus FP",
  98. "V1.2.16.2 24/02/2017",
  99. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  100. "V1.2.16.1 21/02/2017",
  101. " corrige bug sur Fx 38.8 ESR",
  102. "V1.2.16 21/02/2017",
  103. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  104. " possibilité de masquer les Gowaps Sauvages dans la vue",
  105. " calcul des caractéristiques du siphon des âmes",
  106. "V1.2.15.2 02/02/2017",
  107. " adaptation décumul VlC (page des bonus/malus)",
  108. "V1.2.15.1 29/01/2017",
  109. " carte sur la page de description du lieu TP",
  110. "V1.2.15 25/01/2017",
  111. " mise en place des nouvelles cartes (suivants, TP)",
  112. "V1.2.14.3 25/01/2017",
  113. " résumé dans l'export des données Trõlligion",
  114. "V1.2.14.2 20/01/2017",
  115. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  116. "V1.2.14.1 20/01/2017",
  117. " réécriture filtrage des monstres par niveau dans la vue",
  118. " Changelog dans la page des news MZ",
  119. "V1.2.14 20/01/2017",
  120. " Ajout de l'export des données Trõlligion",
  121. "V1.2.13.7 10/01/2017",
  122. " Exclusion Bricoll'troll dans l'entête GM",
  123. "V1.2.13.6 08/01/2017",
  124. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  125. "V1.2.13.5 07/01/2017",
  126. " Correction bug qui se manisfestait sous LINUX",
  127. "V1.2.13.4 07/01/2017",
  128. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  129. "V1.2.13.3 07/01/2017",
  130. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  131. "V1.2.13.2 07/01/2017",
  132. " Correction missions, recherche troogle (familles et types de monstres)",
  133. "V1.2.13.1 06/01/2017",
  134. " Suppression oldSchoolProfile qui n'existe plus",
  135. " Ajout du 'refresh' du cadre de gauche",
  136. "V1.2.13 01/01/2017",
  137. " homogénéisation des messages d'erreur",
  138. " Ajout du lien Troogle sur les étapes de mission monstre",
  139. "V1.2.12.2 30/12/2016",
  140. " retour en mode normal (http si jeu en http)",
  141. "V1.2.12.1 27/12/2016",
  142. " Correction mode IP",
  143. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  144. "V1.2.12 24/12/2016",
  145. " Nettoyage des URL",
  146. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  147. " Interface bricoll'Troll en https",
  148. " Remise en marche des cartes des trajets des gowaps",
  149. "V1.2.11.5 à 7 20 & 21/12/2016",
  150. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  151. "V1.2.11.4 19/12/2016",
  152. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  153. "V1.2.11.3 19/12/2016",
  154. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  155. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  156. "V1.2.11.2 18/12/2016",
  157. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  158. "V1.2.11.1 17/12/2016",
  159. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  160. "V1.2.11 13/12/2016",
  161. " Passage sur BdD Raistlin \\o/",
  162. "V1.2.10.4 12/12/2016",
  163. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  164. "V1.2.10.3 09/12/2016",
  165. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  166. "V1.2.10.2 09/12/2016",
  167. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  168. "V1.2.10.1 08/12/2016",
  169. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  170. "V1.2.10 07/12/2016",
  171. " correction décumul des bonus/malus",
  172. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  173. "V1.2.9 16/11/2016",
  174. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  175. "V1.2.8 10/11/2016",
  176. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  177. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  178. "V1.2.7 07/11/2016",
  179. " remise en route de l'interface avec l'IT bricol'Troll",
  180. "V1.2.6 19/10/2016",
  181. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  182. " stockage idguilde et nomguilde",
  183. "V1.2.5 17/10/2016",
  184. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  185. " remise en route de la gestion des options avec intégration md5 dans ce script",
  186. "V1.2.4 14/10/2016",
  187. " utilisation du relai raistlin pour l'envoi des CdM",
  188. "V1.2.3 :",
  189. " suppression ancien profil",
  190. " nettoyage doublon sur getPortee",
  191. " adaptation portee TP basée sur les PI",
  192. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  193. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  194. "V1.2.1 :",
  195. " include des URLs MH alternatives",
  196. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  197. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  198. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  199. "V1.1 : regroupement en un gros paquet sale",
  200. ];
  201.  
  202. /**********************************************************
  203. À faire / propositions d'évolutions
  204.  
  205. breizhou13 20/12/2016
  206. envoyer les données à l'IT (Bricol'Trolls) aussi
  207. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  208. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  209. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  210. Akkila le boeuf le 26-03-2017 à 15:56
  211. - bouton pour rafraîchir les infos des trolls de son groupe
  212. Roule'
  213. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  214. Réactiver les jubilaires
  215. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  216. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  217. - voir l'intérêt de refaire fonctionner
  218. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  219. Prévision des DLA de monstre
  220. Niveau des monstres à la méthode Roule'
  221. Raistlin
  222. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  223. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  224. 80117 - Héra
  225. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  226. 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)
  227. FAIT Possibilité de plusieurs systèmes Bricol'troll
  228. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  229. ?
  230. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  231. Alanae/Gnu
  232. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  233. Kali
  234. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  235. **********************************************************/
  236.  
  237. /**********************************************************
  238. **** Début de zone à déplacer dans une bibli commune ******
  239. **********************************************************/
  240.  
  241. // URL de base serveur MZ
  242. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  243. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  244. //var URL_MZ = 'http://192.99.225.92/mz';
  245.  
  246. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  247. // à supprimer
  248. const newCarte = true;
  249. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  250.  
  251. // URLs externes redirection (pas de souci CORS)
  252. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  253. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  254. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  255. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  256. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  257. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  258. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  259. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  260. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  261.  
  262. // URLs de test HTTPS
  263. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  264. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  265.  
  266. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  267. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  268. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  269.  
  270. // x~x Libs
  271.  
  272. /* ancien TODO
  273. * - revoir la gestion des CdM --> nott armure magique
  274. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  275. * - vérfier la gestion des enchants
  276. */
  277.  
  278. // Roule 04/09/2016 switch extern URLs to https if available
  279. var isHTTPS = false;
  280. if (window.location.protocol.indexOf('https') === 0) {
  281. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  282. URL_bricol = URL_bricol_https;
  283. isHTTPS = true;
  284. }
  285.  
  286. // Roule 23/12/2016 mode dev
  287. var isDEV = false;
  288. if (window.localStorage.getItem('MZ_dev')
  289. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  290. || window.location.href.indexOf('mzdev.mh') >= 0) {
  291. URL_MZ = URL_MZ.replace(/$/, 'dev');
  292. isDEV = true;
  293. }
  294.  
  295. // Images (pas de souci CORS)
  296. var URL_MZimg = URL_MZ + '/img/';
  297. // URLs externes ajax (CORS OK)
  298. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  299. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  300. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  301.  
  302. // liens externes déduits
  303. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  304. var MHicons = '/mountyhall/Images/Icones/';
  305. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  306. var MY_DEBUG = false;
  307.  
  308. if (GM_info === undefined) { // éviter le blocage si pas sous GM
  309. window.console.log('Fonctionnement hors Greasemonkey');
  310. var GM_getValue = function(key) {};
  311. var GM_setValue = function(key, val) {};
  312. var GM_deleteValue = function(key) {};
  313. var GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  314. }
  315.  
  316. /* Utilisation de la gestion de l'enregistrement des données de
  317. GreaseMonkey, avec partage entre scripts via le localStorage, par
  318. Vapulabehemot (82169) 07/02/2017 */
  319. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  320. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  321. function MY_getValue(key) {
  322. var v = window.localStorage.getItem(key);
  323. // 01/09/2017 Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16
  324. var vGM = null; //GM_getValue(key);
  325. if ((vGM == null)
  326. || (v != null && v != vGM)){
  327. // 01/09/2017 Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16
  328. //GM_setValue(key, v);
  329. } else if (v == null && vGM != null) {
  330. v = vGM;
  331. window.localStorage[key] = vGM;
  332. }
  333. return v;
  334. }
  335. function MY_removeValue(key) {
  336. // 01/09/2017 Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16
  337. //GM_deleteValue(key);
  338. window.localStorage.removeItem(key);
  339. }
  340. function MY_setValue(key, val) {
  341. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  342. val = 1;
  343. else if (val === false)
  344. val = 0;
  345. try {
  346. // 01/09/2017 Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16
  347. //GM_setValue(key, val);
  348. } catch(e) {
  349. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  350. }
  351. try {
  352. window.localStorage[key] = val;
  353. } catch(e) {
  354. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  355. }
  356. }
  357.  
  358. /*---------------- mise à jour de variables globales utiles ------------------*/
  359. // utilisé pour accès bdd (un peu partout) :
  360. var numTroll = MY_getValue('NUM_TROLL');
  361. // utilisé dans vue pour PX :
  362. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  363. var nivTroll; // = MY_getValue('NIV_TROLL');
  364. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  365. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  366. // utilisés dans actions et vue (calculs SR) :
  367. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  368. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  369. var currentURL = window.location.href;
  370.  
  371. /*-[functions]------------ Fonctions durée de script -------------------------*/
  372. var date_debut = null;
  373.  
  374. function start_script(nbJours_exp) {
  375. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  376. if(date_debut) return;
  377. date_debut = new Date();
  378. // Créé la variable expdate si demandé
  379. if(nbJours_exp) {
  380. expdate = new Date();
  381. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  382. }
  383. }
  384.  
  385. function displayScriptTime() {
  386. var footerNode = document.getElementById('footer2');
  387. if(!footerNode) return;
  388. try{
  389. var node = document.evaluate(
  390. ".//text()[contains(.,'Page générée en')]/../br",
  391. footerNode,null,9,null).singleNodeValue;
  392. }
  393. catch(e){return;}
  394. insertText(node,
  395. ' - [Script MZ exécuté en '
  396. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  397. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  398. }
  399.  
  400. function traceStack(e, sModule) {
  401. var version = '';
  402. if (GM_info && GM_info.script && GM_info.script.version)
  403. version = ' ' + GM_info.script.version;
  404. sRet = '[MZ' + version + ']'
  405. if (sModule) sRet += ' {' + sModule + '}';
  406. try {
  407. if (e.message) sRet += ' ' + e.message;
  408. } catch (e2) {
  409. sRet += ' <exception acces message>';//+ e2.message;
  410. }
  411. try {
  412. if (e.stack) {
  413. var sStack = e.stack;
  414. // enlever les infos confidentielles
  415. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  416. }
  417. } catch (e2) {
  418. sRet += ' <exception acces stack>'; // + e2.message;
  419. }
  420. return sRet;
  421. }
  422.  
  423. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  424.  
  425. function debugMZ(str){
  426. if(MY_DEBUG){
  427. window.console.debug('[MZ_DEBUG] '+str);
  428. if(typeof str === "object"){
  429. window.console.debug(str);
  430. }
  431. }
  432. }
  433.  
  434. function FF_XMLHttpRequest(MY_XHR_Ob) {
  435. var request = new XMLHttpRequest();
  436. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  437. for(var head in MY_XHR_Ob.headers) {
  438. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  439. }
  440. request.onreadystatechange = function() {
  441. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  442. if(request.readyState!=4) { return; }
  443. if(request.error) {
  444. if(MY_XHR_Ob.onerror) {
  445. MY_XHR_Ob.onerror(request);
  446. }
  447. return;
  448. }
  449. if ((request.status == 0)) {
  450. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  451. if (isDEV) {
  452. var grandCadre = createOrGetGrandCadre();
  453. var sousCadre = document.createElement('div');
  454. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  455. sousCadre.style.width = 'auto';
  456. sousCadre.style.fontSize = 'large';
  457. sousCadre.style.border = 'solid 1px black';
  458. grandCadre.appendChild(sousCadre);
  459. }
  460. //showHttpsErrorContenuMixte();
  461. return;
  462. }
  463. if(MY_XHR_Ob.onload) {
  464. var version;
  465. if (MY_XHR_Ob.trace) {
  466. version = '';
  467. if (GM_info && GM_info.script && GM_info.script.version)
  468. version = ' ' + GM_info.script.version;
  469. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  470. }
  471. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  472. MY_XHR_Ob.onload(request);
  473. if (MY_XHR_Ob.trace)
  474. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  475. }
  476. };
  477. request.send(MY_XHR_Ob.data);
  478. }
  479.  
  480. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  481. function MZ_formatDateMS(d) {
  482. if (d === undefined) d = new Date();
  483. var day = d.getDate();
  484. var month = d.getMonth()+1;
  485. var year = d.getFullYear();
  486. var hours = d.getHours();
  487. var minutes = d.getMinutes();
  488. var seconds = d.getSeconds();
  489. var ms = d.getMilliseconds();
  490. if (day < 10) {day = "0"+day;}
  491. if (month < 10) {month = "0"+month;}
  492. if (hours < 10) {hours = "0"+hours;}
  493. if (hours < 10) {hours = "0"+hours;}
  494. if (minutes < 10) {minutes = "0"+minutes;}
  495. if (seconds < 10) {seconds = "0"+seconds;}
  496. ms = ('000' + ms).substr(-3, 3);
  497. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  498. }
  499.  
  500. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  501.  
  502. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  503. function copyTextToClipboard(text) {
  504. var textArea = document.createElement("textarea");
  505.  
  506. //
  507. // *** This styling is an extra step which is likely not required. ***
  508. //
  509. // Why is it here? To ensure:
  510. // 1. the element is able to have focus and selection.
  511. // 2. if element was to flash render it has minimal visual impact.
  512. // 3. less flakyness with selection and copying which **might** occur if
  513. // the textarea element is not visible.
  514. //
  515. // The likelihood is the element won't even render, not even a flash,
  516. // so some of these are just precautions. However in IE the element
  517. // is visible whilst the popup box asking the user for permission for
  518. // the web page to copy to the clipboard.
  519. //
  520.  
  521. // Place in top-left corner of screen regardless of scroll position.
  522. textArea.style.position = 'fixed';
  523. textArea.style.top = 0;
  524. textArea.style.left = 0;
  525.  
  526. // Ensure it has a small width and height. Setting to 1px / 1em
  527. // doesn't work as this gives a negative w/h on some browsers.
  528. textArea.style.width = '2em';
  529. textArea.style.height = '2em';
  530.  
  531. // We don't need padding, reducing the size if it does flash render.
  532. textArea.style.padding = 0;
  533.  
  534. // Clean up any borders.
  535. textArea.style.border = 'none';
  536. textArea.style.outline = 'none';
  537. textArea.style.boxShadow = 'none';
  538.  
  539. // Avoid flash of white box if rendered for any reason.
  540. textArea.style.background = 'transparent';
  541.  
  542. textArea.value = text;
  543.  
  544. document.body.appendChild(textArea);
  545.  
  546. textArea.select();
  547.  
  548. var successful = document.execCommand('copy');
  549.  
  550. document.body.removeChild(textArea);
  551. return successful;
  552. }
  553.  
  554. function avertissement(txt,duree) {
  555. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  556. if(!duree) duree = 15000;
  557. var div = document.createElement('div');
  558. // On numérote les avertissements pour destruction sélective
  559. var num = document.getElementsByName('avertissement').length;
  560. div.num = num;
  561. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  562. div.setAttribute('name','avertissement');
  563. div.className = 'mh_textbox';
  564. div.style.position = 'fixed';
  565. div.style.top = (10+15*num)+'px';
  566. div.style.left = (10+5*num)+'px';
  567. div.style.border = '5px solid red';
  568. div.style.zIndex = 2+num;
  569. div.style.cursor = 'pointer';
  570. div.style.fontSize = 'large';
  571. div.innerHTML = txt;
  572. div.onclick=function(){ tueAvertissement(this.num) };
  573.  
  574. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  575. var divcroix = document.createElement('div');
  576. divcroix.style.position = 'absolute';
  577. divcroix.style.top = 0;
  578. divcroix.style.right = 0;
  579. divcroix.style.color = 'black';
  580. divcroix.style.fontSize = 'inherit';
  581. divcroix.style.cursor = 'pointer'
  582. divcroix.style.zIndex = 2+num;
  583. divcroix.innerHTML = "X";
  584. div.appendChild(divcroix);
  585.  
  586. document.body.appendChild(div);
  587. // Destruction automatique de l'avertissement après "un certain temps"
  588. window.setTimeout(function(){ tueAvertissement(num) },duree);
  589. }
  590.  
  591. function tueAvertissement(num) {
  592. var divs = document.getElementsByName('avertissement');
  593. if(divs.length==0) { return; }
  594. for(var i=0 ; i<divs.length ; i++) {
  595. if(divs[i].num==num) {
  596. divs[i].parentNode.removeChild(divs[i]);
  597. return;
  598. }
  599. }
  600. }
  601.  
  602.  
  603. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  604.  
  605. function insertBefore(next,el) {
  606. next.parentNode.insertBefore(el,next);
  607. }
  608.  
  609. function appendTr(tbody,clas) {
  610. var tr = document.createElement('tr');
  611. if(clas) tr.className = clas;
  612. tbody.appendChild(tr);
  613. return tr;
  614. }
  615.  
  616. function insertTr(next,clas) {
  617. var tr = document.createElement('tr');
  618. if(clas) tr.className = clas;
  619. insertBefore(next,tr);
  620. return tr;
  621. }
  622.  
  623. function appendTd(tr) {
  624. var td = document.createElement('td');
  625. if(tr) tr.appendChild(td);
  626. return td;
  627. }
  628.  
  629. function insertTd(next) {
  630. var td = document.createElement('td');
  631. insertBefore(next,td);
  632. return td;
  633. }
  634.  
  635. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  636. function insertAfterTd(eTd) {
  637. var newTd = document.createElement('td');
  638. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  639. return newTd;
  640. }
  641.  
  642. function appendTdCenter(tr,colspan) {
  643. var td = appendTd(tr);
  644. td.align = 'center'; // WARNING - Obsolete
  645. if(colspan) td.colSpan = colspan;
  646. return td;
  647. }
  648.  
  649. function insertTdElement(next,el) {
  650. var td = insertTd(next);
  651. if(el) td.appendChild(el);
  652. return td;
  653. }
  654.  
  655. function appendA(paren,href,cssClass,text) {
  656. var a = document.createElement('a');
  657. if (href) a.href = href;
  658. if (cssClass) a.className = cssClass;
  659. if (text) a.appendChild(document.createTextNode(text));
  660. paren.appendChild(a);
  661. }
  662.  
  663. function appendText(paren,text,bold) {
  664. if(bold) {
  665. var b = document.createElement('b');
  666. b.appendChild(document.createTextNode(text));
  667. paren.appendChild(b);
  668. }
  669. else
  670. paren.appendChild(document.createTextNode(text));
  671. }
  672.  
  673. function insertText(next,text,bold) {
  674. if(bold) {
  675. var b = document.createElement('b');
  676. appendText(b,text);
  677. insertBefore(next,b);
  678. }
  679. else
  680. insertBefore(next,document.createTextNode(text));
  681. }
  682.  
  683. function appendTdText(tr,text,bold) {
  684. var td = appendTd(tr);
  685. appendText(td,text,bold);
  686. return td;
  687. }
  688.  
  689. function insertTdText(next,text,bold) {
  690. var td = insertTd(next);
  691. appendText(td,text,bold);
  692. return td;
  693. }
  694.  
  695. function appendBr(paren) {
  696. paren.appendChild(document.createElement('br'));
  697. }
  698.  
  699. function insertBr(next) {
  700. insertBefore(next,document.createElement('br'));
  701. }
  702.  
  703. function appendLI(ul,text) {
  704. // uniquement utilisé dans les options (crédits)
  705. var li = document.createElement('li');
  706. appendText(li,text);
  707. ul.appendChild(li);
  708. return li;
  709. }
  710.  
  711. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  712. var input = document.createElement('input');
  713. input.className = 'TextboxV2';
  714. input.type = type;
  715. input.name = nam;
  716. if (sId === undefined) input.id = nam;
  717. else input.id = sId;
  718. input.size = size;
  719. input.maxLength = maxlength;
  720. if(value) input.value = value;
  721. paren.appendChild(input);
  722. return input;
  723. }
  724.  
  725. function appendCheckBox(paren,nam,checked,onClick) {
  726. var input = document.createElement('input');
  727. input.type = 'checkbox';
  728. input.name = nam;
  729. input.id = nam;
  730. if(checked) input.checked = true;
  731. if(onClick) input.onclick = onClick;
  732. paren.appendChild(input);
  733. return input;
  734. }
  735.  
  736. function appendNobr(paren,id,delgg,text) {
  737. var nobr = document.createElement('nobr');
  738. appendCheckBox(nobr,id,null,delgg);
  739. appendText(nobr,text);
  740. paren.appendChild(nobr);
  741. appendText(paren,' ');
  742. return nobr;
  743. }
  744.  
  745. function appendCheckBoxSpan(paren,id,onClick,text) {
  746. var span = document.createElement('span');
  747. span.style.whiteSpace = 'nowrap';
  748. appendCheckBox(span,id,false,onClick);
  749. var label = document.createElement('label');
  750. appendText(label,text);
  751. label.htmlFor = id;
  752. label.style.marginLeft = '-5px';
  753. span.appendChild(label);
  754. span.style.marginRight = '3px';
  755. paren.appendChild(span);
  756. appendText(paren, ' ');
  757. return span;
  758. }
  759.  
  760. function appendOption(select,value,text) {
  761. var option = document.createElement('option');
  762. option.value = value;
  763. appendText(option,text);
  764. select.appendChild(option);
  765. return option;
  766. }
  767.  
  768. function appendHidden(form,nam,value) {
  769. var input = document.createElement('input');
  770. input.type = 'hidden';
  771. input.name = nam;
  772. input.id = nam;
  773. input.value = value;
  774. form.appendChild(input);
  775. }
  776.  
  777. function appendButton(paren,value,onClick) {
  778. var input = document.createElement('input');
  779. input.type = 'button';
  780. input.className = 'mh_form_submit';
  781. input.value = value;
  782. input.onmouseover = function(){this.style.cursor='pointer';};
  783. if(onClick) input.onclick = onClick;
  784. paren.appendChild(input);
  785. return input;
  786. }
  787.  
  788. function insertButton(next,value,onClick) {
  789. var input = document.createElement('input');
  790. input.type = 'button';
  791. input.className = 'mh_form_submit';
  792. input.value = value;
  793. input.onmouseover = function(){this.style.cursor='pointer';};
  794. input.onclick = onClick;
  795. insertBefore(next,input);
  796. return input;
  797. }
  798.  
  799. function appendSubmit(paren,value,onClick) {
  800. var input = document.createElement('input');
  801. input.type = 'submit';
  802. input.className = 'mh_form_submit';
  803. input.value = value;
  804. input.onmouseover = function(){this.style.cursor='pointer';};
  805. if(onClick) input.onclick = onClick;
  806. paren.appendChild(input);
  807. return input;
  808. }
  809.  
  810. function createImage(url,title,style) {
  811. var img = document.createElement('img');
  812. img.src = url;
  813. img.title = title;
  814. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  815. if (style) img.style = style;
  816. return img;
  817. }
  818.  
  819. function createAltImage(url,alt,title) {
  820. var img = document.createElement('img');
  821. img.src = url;
  822. img.alt = alt;
  823. if (title) img.title = title;
  824. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  825. return img;
  826. }
  827.  
  828. function createImageSpan(url,alt,title,text,bold) {
  829. var span = document.createElement('span');
  830. span.title = title;
  831. var img = document.createElement('img');
  832. img.src = url;
  833. img.alt = alt;
  834. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  835. span.appendChild(img);
  836. appendText(span,text,bold);
  837. return span;
  838. }
  839.  
  840. function createCase(titre,table,width) {
  841. if(!width) width=120;
  842. var tr = appendTr(table,'mh_tdpage');
  843. var td = appendTdText(tr,titre,true);
  844. td.className = 'mh_tdtitre';
  845. td.width = width;
  846. td = appendTdText(tr,'');
  847. td.className = 'mh_tdpage';
  848. return td;
  849. }
  850.  
  851. function getMyID(e) {
  852. var parent = e.parentNode;
  853. for(var i=0 ; i<parent.childNodes.length ; i++) {
  854. if(e==parent.childNodes[i])
  855. return i;
  856. }
  857. return -1;
  858. }
  859.  
  860. function insertAfter(elt,newElt) {
  861. var id = getMyID(elt);
  862. if(id==-1) return;
  863. if(id<elt.parentNode.childNodes.length-1)
  864. insertBefore(elt.nextSibling,newElt);
  865. else
  866. elt.parentNode.appendChild(newElt);
  867. }
  868.  
  869.  
  870. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  871.  
  872. function aff(nb) {
  873. return (nb>=0) ? '+'+nb : nb;
  874. }
  875.  
  876. function getNumber(str) {
  877. var nbr = str.match(/\d+/);
  878. return nbr ? Number(nbr[0]) : Number.NaN;
  879. }
  880.  
  881. function getNumbers(str) {
  882. var nbrs = str.match(/-?\d+/g);
  883. if (!nbrs) return [];
  884. for(var i=0 ; i<nbrs.length ; i++)
  885. nbrs[i] = Number(nbrs[i]);
  886. return nbrs;
  887. }
  888.  
  889. function trim(str) {
  890. return str.replace(/(^\s*)|(\s*$)/g,'');
  891. }
  892.  
  893. String.prototype.trim = function() {
  894. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  895. }
  896.  
  897. function epure(texte) {
  898. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  899. .replace(/[ç]/g,'c')
  900. .replace(/[éêèë]/g,'e')
  901. .replace(/[ïî]/g,'i')
  902. .replace(/[ôöõ]/g,'o')
  903. .replace(/[ùûü]/g,'u');
  904. }
  905.  
  906. String.prototype.epure = function () {
  907. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  908. .replace(/[ç]/g,'c')
  909. .replace(/[éêèë]/g,'e')
  910. .replace(/[ïî]/g,'i')
  911. .replace(/[ôöõ]/g,'o')
  912. .replace(/[ùûü]/g,'u');
  913. }
  914.  
  915. function bbcode(texte) {
  916. return texte.replace(/&/g,'&amp;')
  917. .replace(/"/g,'&quot;')
  918. .replace(/</g,'&lt;')
  919. .replace(/>/g,'&gt;')
  920. .replace(/'/g,'&#146;')
  921. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  922. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  923. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  924. }
  925.  
  926.  
  927. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  928.  
  929. function addZero(i) {
  930. return (i<10) ? '0'+i : i;
  931. }
  932.  
  933. function DateToString(date) {
  934. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  935. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  936. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  937. }
  938.  
  939. function StringToDate(str) {
  940. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  941. }
  942.  
  943. // fonctionne aussi avec datetime
  944. function SQLDateToFrench(str) {
  945. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  946. }
  947.  
  948. // ... et ajoute un "à" du plus bel effet
  949. function SQLDateToFrenchTime(str) {
  950. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  951. }
  952.  
  953. // SQLDate vers objet date Javascript
  954. function SQLDateToObject(str) {
  955. var t = str.split(/[- :]/);
  956. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  957. }
  958.  
  959. var mz_ie = (window.attachEvent)? true:false;
  960. if ("function" !== typeof addEvent) {
  961. if (mz_ie) {
  962. function addEvent(obj, typ, fn, sens) {
  963. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  964. obj["e"+typ+fn]( window.event );
  965. }
  966. obj.attachEvent("on"+typ, obj[typ+fn] );
  967. }
  968. }
  969. else {
  970. function addEvent(obj, typ, fn, sens) {
  971. obj.addEventListener(typ, fn, sens);
  972. }
  973. }
  974. }
  975.  
  976. /**********************
  977. * glissière en mode objet
  978. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  979. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  980. *
  981. * Usage:
  982. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  983. * ref : utilisé pour diversifier les IDs HTML
  984. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  985. * target : peut être de 3 types
  986. * - élément HTML : l'élément HTML à zoomer
  987. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  988. * - function : callback quand le curseur bouge
  989. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  990. * dans le mode dynamique, la callback est appelée sur mouseMove
  991. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  992. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  993. * autres méthodes
  994. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  995. **********************/
  996.  
  997. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  998. try {
  999. var mouseDown = false;
  1000. var div_gliss = document.createElement("div"); // la DIV mère
  1001. div_gliss.id = "MZ_gliss_"+ref;
  1002. var div_label = document.createElement("span"); // le label
  1003. div_label.innerHTML = labelHTML;
  1004. div_gliss.appendChild(div_label);
  1005. div_gliss.className = "choix_zoom";
  1006. var dessin = document.createElement("canvas"); // le dessin lui-même
  1007. dessin.id = "MZ_gliss_dessin_"+ref;
  1008. dessin.style.cursor = "pointer";
  1009. dessin.width = 104;
  1010. dessin.height = 12;
  1011. dessin.style.marginLeft = '2px';
  1012. dessin.style.marginRight = '2px';
  1013. div_gliss.appendChild(dessin);
  1014. var pourcent = document.createElement("span"); // le pourcentage
  1015. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1016. var pourcent_text = document.createTextNode('');
  1017. var previousVal;
  1018. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1019.  
  1020. // alignement vertical
  1021. dessin.style.verticalAlign = 'middle';
  1022. div_label.style.verticalAlign = 'middle';
  1023. pourcent.style.verticalAlign = 'middle';
  1024.  
  1025. pourcent.appendChild(pourcent_text);
  1026. div_gliss.appendChild(pourcent);
  1027.  
  1028. var bulle_pourcent = document.createElement("div"); // la bulle
  1029. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1030. bulle_pourcent.style.display = 'block';
  1031. bulle_pourcent.style.visibility = 'hidden';
  1032. bulle_pourcent.style.position = 'absolute';
  1033. bulle_pourcent.style.zIndex = 3500;
  1034. bulle_pourcent.style.border = '1px solid #a1927f';
  1035. var bulle_pourcent_text = document.createTextNode('');
  1036. bulle_pourcent.appendChild(bulle_pourcent_text);
  1037. document.body.appendChild(bulle_pourcent);
  1038.  
  1039. this.getElt = function() {return div_gliss;};
  1040.  
  1041. ////////////////////////////////////
  1042. // dessine et redessine le curseur
  1043. ////////////////////////////////////
  1044. var dessine_glissiere = function(val) {
  1045. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1046. var ctx = dessin.getContext('2d');
  1047. ctx.clearRect(0, 0,104, 12);
  1048. ctx.fillStyle = "rgb(0,0,0)";
  1049. ctx.fillRect(0,0,2,12);
  1050. ctx.fillRect(102,0,2,12);
  1051. ctx.fillRect(0,5,104,2);
  1052.  
  1053. ctx.fillStyle = "rgb(80,80,80)";
  1054. ctx.fillRect(pos_0_100,0,5,12);
  1055. ctx.fillStyle = "rgb(200,200,200)";
  1056. ctx.fillRect(pos_0_100+1,1,3,10);
  1057. pourcent_text.nodeValue = val+'%';
  1058. previousVal = parseInt(val);
  1059. };
  1060.  
  1061. ////////////////////////////////////
  1062. // action sur mousedown et mousemove
  1063. // stocker la nouvelle valeur
  1064. // redessiner
  1065. // afficher la nouvelle valeur
  1066. // action selon ce qui a été demandé
  1067. ////////////////////////////////////
  1068. var doCallback_glissiere = function (evt) {
  1069. try {
  1070. if (evt.type === 'mousedown') mouseDown = true;
  1071. if (evt.offsetX) {
  1072. var xsouris = evt.offsetX;
  1073. var xpos = evt.clientX;
  1074. var ypos = evt.clientY + document.body.scrollTop;
  1075. }
  1076. else {
  1077. var xsouris = evt.layerX;
  1078. var xpos = evt.pageX;
  1079. var ypos = evt.pageY;
  1080. }
  1081. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1082. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1083. // afficher la nouvelle valeur dans la bulle
  1084. bulle_pourcent_text.nodeValue = val + '%';
  1085. bulle_pourcent.style.top = (ypos+3)+'px';
  1086. bulle_pourcent.style.left = (xpos+16)+'px';
  1087. if (evt.buttons === undefined) {
  1088. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1089. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1090. } else {
  1091. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1092. }
  1093. // stocker la nouvelle valeur
  1094. MY_setValue("MZ_glissiere_" + ref, val);
  1095. // redessiner la glissière avec le curseur où il faut
  1096. dessine_glissiere(val);
  1097. // action selon ce qui a été demandé
  1098. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1099. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1100. if (typeof paramTarget === 'object') {
  1101. var elt = paramTarget;
  1102. } else if (typeof paramTarget === 'string') {
  1103. var elt = document.getElementById(paramTarget);
  1104. } else if (typeof paramTarget === 'function') {
  1105. paramTarget(val);
  1106. return;
  1107. }
  1108. if (elt.setZoom != undefined) elt.setZoom(val);
  1109. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1110. };
  1111.  
  1112. ////////////////////////////////////
  1113. // event mousedown et mousemove : redessiner et callback
  1114. ////////////////////////////////////
  1115. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1116. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1117. ////////////////////////////////////
  1118. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1119. ////////////////////////////////////
  1120. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1121. ////////////////////////////////////
  1122. // event mouseout & mouseover : afficher/cacher la bulle
  1123. ////////////////////////////////////
  1124. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1125. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1126.  
  1127. ////////////////////////////////////
  1128. // dessiner la première fois
  1129. ////////////////////////////////////
  1130. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1131. if (val_init === undefined) val_init = valDef;
  1132. dessine_glissiere(val_init);
  1133. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1134. }
  1135.  
  1136. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1137. // reçoit 2 objets avec des propriétés x et y
  1138. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1139. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1140. var deltaX = locArrivee.x - locDepart.x;
  1141. if (deltaX == 0) return; // pas de point intermédiaire
  1142. var deltaY = locArrivee.y - locDepart.y;
  1143. if (deltaY == 0) return; // pas de point intermédiaire
  1144. var absDeltaX = Math.abs(deltaX);
  1145. var absDeltaY = Math.abs(deltaY);
  1146. if (absDeltaX > absDeltaY) {
  1147. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1148. } else if (absDeltaY > absDeltaX) {
  1149. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1150. } else {
  1151. return; // égalité, pas de point intermédiaire
  1152. }
  1153. }
  1154.  
  1155. /**********************
  1156. * carte en mode objet
  1157. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1158. *
  1159. * Usage:
  1160. * carte = new carte_MZ(ref, tabDepl);
  1161. * ref : utilisé pour diversifier les IDs HTML
  1162. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1163. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1164. * autres méthodes
  1165. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1166. **********************/
  1167.  
  1168. function carte_MZ(ref, tabDepl) {
  1169. try {
  1170. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1171. div1_carte.id = "MZ_carte_"+ref;
  1172. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1173. div1_carte.style.backgroundImage = 'none';
  1174. div1_carte.style.backgroundColor = 'transparent';
  1175. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1176. div2_carte.className = "carte_MZ";
  1177. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1178. var dessin = document.createElement("canvas"); // le dessin lui-même
  1179. dessin.id = "MZ_carte_dessin_"+ref;
  1180. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1181. div1_carte.appendChild(div2_carte);
  1182. div2_carte.appendChild(dessin);
  1183.  
  1184. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1185. , [-66.5, -37.5, 2, 1.5, -69]
  1186. , [-63.5, 8.5, 2, 1.5, -69]
  1187. , [-59.5, -32.5, 2, 1.5, -69]
  1188. , [-52, 57, 0.25, 0.8, -59]
  1189. , [-50.5, -22.5, 2, 1.5, -69]
  1190. , [-35.5, -51.5, 2, 1.5, -69]
  1191. , [-34.5, 14.5, 2, 1.5, -69]
  1192. , [-34.5, 64.5, 2, 1.5, -69]
  1193. , [-11.5, 72.5, 2, 1.5, -69]
  1194. , [5.5, -49.5, 2, 1.5, -69]
  1195. , [5.5, 31.5, 2, 1.5, -69]
  1196. , [10.5, 63.5, 2, 1.5, -69]
  1197. , [12, -15, 0.25, 0.8, -59]
  1198. , [21.5, 35.5, 2, 1.5, -69]
  1199. , [30, -52, 0.25, 0.8, -59]
  1200. , [46.5, 51.5, 2, 1.5, -69]
  1201. , [48, -39, 0.25, 0.8, -59]
  1202. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1203. , [56.5, 23.5, 75, 8.7, -99]
  1204. , [64, 70, 0.25, 0.8, -59]
  1205. , [74.5, 31.5, 2, 1.5, -69]];
  1206.  
  1207. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1208. var couleur_cible = 'rgba(0,0,0,0.5)';
  1209. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1210. var couleur_trou = 'rgb(200,0,0)';
  1211.  
  1212. var coord_x = function(val) {
  1213. return decalh+coeff*(val+100);
  1214. };
  1215. var coord_y = function(val) {
  1216. return decalv+coeff*(100-val);
  1217. };
  1218.  
  1219. var ctx = dessin.getContext('2d');
  1220. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1221. if (coeff) coeff /= 50;
  1222. else coeff = 2;
  1223. var decalv=30, decalh=30;
  1224.  
  1225. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1226. //var res = false
  1227. var x0 = pos0.x;
  1228. var y0 = pos0.x;
  1229. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1230. var px = Math.sign(pos1.x - pos0.x);
  1231. var py = Math.sign(pos1.y - pos0.y);
  1232. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1233. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1234.  
  1235. for(var k in position_trous_MZ) {
  1236. a = parseFloat(px*px+py*py);
  1237. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1238. 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]);
  1239. delta = b*b-a*c
  1240. if(delta >= 0) {
  1241. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1242. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1243. if(t0 <= tmax && t1 >= 0) {
  1244. // 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
  1245. //res = true;
  1246. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1247. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1248. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1249. // Roule : pas utile pour nous
  1250. //res = true;
  1251. //chute.push([x0+l*px, y0+l*py]);
  1252. return true;
  1253. }
  1254. }
  1255. }
  1256. }
  1257. //return res;
  1258. return false;
  1259. };
  1260.  
  1261. var dessine_carte = function () {
  1262. dessin.width = 200*coeff+2*decalh;
  1263. dessin.height = 200*coeff+2*decalv;
  1264.  
  1265. //repere
  1266. ctx.beginPath();
  1267. ctx.moveTo(coord_x(0), coord_y(100));
  1268. ctx.lineTo(coord_x(0), coord_y(-100));
  1269. ctx.moveTo(coord_x(-100), coord_y(0));
  1270. ctx.lineTo(coord_x(100), coord_y(0));
  1271. ctx.stroke();
  1272. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1273.  
  1274. //trous
  1275. ctx.fillStyle = couleur_trou;
  1276. for(var i in position_trous_MZ) {
  1277. ctx.beginPath();
  1278. 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);
  1279. ctx.fill();
  1280. }
  1281. // trajets
  1282. ctx.lineCap = "round";
  1283. ctx.lineJoin = "round";
  1284. for (var iSuivant in tabDepl) {
  1285. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1286. var tabDeplOneSuivant = tabDepl[iSuivant];
  1287. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1288. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1289. // La "cible" au départ
  1290. var typeDepart = tabDeplOneSuivant[0].typ;
  1291. switch (typeDepart) {
  1292. case 'tp':
  1293. ctx.beginPath();
  1294. ctx.lineWidth = 2;
  1295. ctx.strokeStyle = couleur_cible;
  1296. ctx.fillStyle = couleur_cible;
  1297. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1298. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1299. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1300. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1301. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1302. ctx.moveTo(x0 + coeff * 3, y0);
  1303. ctx.lineTo(x0 - coeff * 3, y0);
  1304. ctx.moveTo(x0, y0 + coeff * 3);
  1305. ctx.lineTo(x0, y0 - coeff * 3);
  1306. ctx.stroke();
  1307. break;
  1308. default:
  1309. ctx.beginPath();
  1310. ctx.lineWidth = 1;
  1311. ctx.strokeStyle = couleur_cible;
  1312. ctx.fillStyle = couleur_cible;
  1313. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1314. ctx.moveTo(x0 + coeff * 4, y0);
  1315. ctx.lineTo(x0 - coeff * 4, y0);
  1316. ctx.moveTo(x0, y0 + coeff * 4);
  1317. ctx.lineTo(x0, y0 - coeff * 4);
  1318. ctx.stroke();
  1319. break;
  1320. }
  1321. // les segments
  1322. var nb_pts = tabDeplOneSuivant.length;
  1323. var pointPrecedent = tabDeplOneSuivant[0];
  1324. for (var i=1; i<nb_pts; i++) {
  1325. ctx.beginPath();
  1326. ctx.lineWidth = coeff;
  1327. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1328. ctx.strokeStyle = couleur_depl_normal;
  1329. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1330. if (pointIntermediaire === undefined) {
  1331. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1332. ctx.strokeStyle = couleur_depl_collision_trou;
  1333. else
  1334. ctx.strokeStyle = couleur_depl_normal;
  1335. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1336. } else {
  1337. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1338. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1339. ctx.strokeStyle = couleur_depl_collision_trou;
  1340. else
  1341. ctx.strokeStyle = couleur_depl_normal;
  1342. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1343. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1344. }
  1345. pointPrecedent = tabDeplOneSuivant[i];
  1346. ctx.stroke();
  1347. }
  1348. // Les points à chaque étape
  1349. ctx.fillStyle = couleur_depl_normal;
  1350. for (var i=1; i<nb_pts; i++) {
  1351. ctx.beginPath();
  1352. var x = coord_x(tabDeplOneSuivant[i].x);
  1353. var y = coord_y(tabDeplOneSuivant[i].y);
  1354. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1355. ctx.fill();
  1356. }
  1357. }
  1358. }
  1359.  
  1360. this.setZoom = function (val) {
  1361. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1362. coeff = val / 50;
  1363. dessine_carte();
  1364. }
  1365.  
  1366. // glissiere
  1367. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1368. var eGliss = gliss.getElt();
  1369. eGliss.style.position = 'absolute';
  1370. eGliss.style.top = (coeff * 2) + 'px';
  1371. eGliss.style.left = decalh + 'px';
  1372. dessin.style.position = 'relative';
  1373. div2_carte.style.position = 'relative';
  1374. eGliss.style.zIndex = 9000;
  1375. div2_carte.appendChild(eGliss);
  1376.  
  1377. // affichage au survol de la souris
  1378. var bulle = document.createElement('div');
  1379. bulle.style.visibility = 'hidden';
  1380. bulle.style.position = 'absolute';
  1381. bulle.style.zIndex = 3100;
  1382. bulle.style.border = 'solid 1px #a1927f';
  1383. bulle.className = 'mh_tdpage';
  1384. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1385. var bulleHaut = document.createElement('div');
  1386. bulleHaut.style.display = 'block';
  1387. bulleHaut.style.paddingRight = '3px';
  1388. bulleHaut.className = 'mh_tdtitre';
  1389. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1390. bulle.appendChild(bulleHaut);
  1391. var bulleBas = document.createElement('div');
  1392. bulleBas.style.display = 'block';
  1393. bulleBas.style.whiteSpace = "nowrap";
  1394. bulleBas.style.paddingRight = '3px';
  1395.  
  1396. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1397. bulle.appendChild(bulleBas);
  1398. div2_carte.appendChild(bulle);
  1399. var affichePosition = function(evt) {
  1400. if (evt.offsetX) {
  1401. var xsouris = evt.offsetX;
  1402. var ysouris = evt.offsetY;
  1403. var xpos = evt.clientX;
  1404. var ypos = evt.clientY + document.body.scrollTop;
  1405. }
  1406. else {
  1407. var xsouris = evt.layerX;
  1408. var ysouris = evt.layerY;
  1409. var xpos = evt.pageX;
  1410. var ypos = evt.pageY;
  1411. }
  1412. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1413. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1414. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1415. var tabHTMLbas = [];
  1416. // message pour les trous
  1417. for (var i in position_trous_MZ) {
  1418. var ceTrou = position_trous_MZ[i];
  1419. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1420. if(dist <= 0) {
  1421. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1422. break;
  1423. }
  1424. }
  1425. // messages pour les suivants
  1426. for (var i in tabDepl) {
  1427. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1428. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1429. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1430. }
  1431. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1432. bulle.style.top = (ysouris+8) + 'px';
  1433. bulle.style.left = (xsouris+16) + 'px';
  1434. };
  1435. addEvent(dessin, "mousemove", affichePosition, true);
  1436. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1437. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1438.  
  1439. // dessin initial
  1440. dessine_carte();
  1441.  
  1442. this.getElt = function() {return div1_carte;};
  1443.  
  1444. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1445. }
  1446.  
  1447.  
  1448. /**********************************************************
  1449. **** Fin de zone à déplacer dans une bibli commune ********
  1450. **********************************************************/
  1451.  
  1452. /* DEBUG: NETTOYAGE TAGS */
  1453. if(MY_getValue(numTroll+'.TAGSURL')) {
  1454. MY_removeValue(numTroll+'.TAGSURL');
  1455. }
  1456.  
  1457. // Alerte si mode dev
  1458. if (isDEV) {
  1459. var divpopup = document.createElement('div');
  1460. divpopup.id = 'divDEV';
  1461. divpopup.style =
  1462. 'position: fixed;'+
  1463. 'border: 15px solid red;'+
  1464. 'top: 10px;right: 10px;'+
  1465. 'background-color: white;'+
  1466. 'color: black;'+
  1467. 'font-size: large;'+
  1468. 'padding: 5px'+
  1469. 'z-index: 200;';
  1470. appendText(divpopup, '[MZ] Mode DEV');
  1471. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1472. document.body.appendChild(divpopup);
  1473. }
  1474.  
  1475. /*---------- regroupement des getPortee() ------------------------------------*/
  1476. // issu des script profil et profil2
  1477. function getPortee__Profil(param) {
  1478. param = Math.max(0,Number(param));
  1479. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1480. // ça devrait être floor, +10.25, -2.5
  1481. }
  1482.  
  1483. // issu du script vue
  1484. function getPortee__Vue(param) {
  1485. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1486. }
  1487.  
  1488.  
  1489. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1490.  
  1491. function getPXKill(niv) {
  1492. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1493. return Math.max(0,10+3*niv-2*nivTroll);
  1494. }
  1495.  
  1496. function getPXDeath(niv) {
  1497. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1498. return Math.max(0,10+3*nivTroll-2*niv);
  1499. }
  1500.  
  1501. function analysePX(niv) {
  1502. niv = niv+'';
  1503. var i = niv.indexOf('+');
  1504. if(i!=-1) // si niv = 'XX+' ??
  1505. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1506. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1507. if(i!=-1) {
  1508. var max = getPXKill(niv.slice(i+2));
  1509. if(max==0)
  1510. return ' --> <b>0</b> PX';
  1511. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1512. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1513. }
  1514. i = niv.indexOf('='); // ???
  1515. if(i!=-1) {
  1516. var max = getPXKill(niv.slice(i+1));
  1517. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1518. }
  1519. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1520. }
  1521.  
  1522. function analysePXTroll(niv) {
  1523. var str = analysePX(niv);
  1524. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1525. return str;
  1526. }
  1527.  
  1528.  
  1529. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1530. // Refonte totale du code de Zorya
  1531.  
  1532. // Elements à implémenter en dur dans MZ2.0
  1533. var numQualite = {
  1534. 'Très Mauvaise':1,
  1535. 'Mauvaise':2,
  1536. 'Moyenne':3,
  1537. 'Bonne':4,
  1538. 'Très Bonne':5
  1539. };
  1540.  
  1541. var qualiteNum = [
  1542. '_dummy_',
  1543. 'Très Mauvaise',
  1544. 'Mauvaise',
  1545. 'Moyenne',
  1546. 'Bonne',
  1547. 'Très Bonne'
  1548. ];
  1549.  
  1550. var nival = {
  1551. 'Abishaii Bleu':19,
  1552. 'Abishaii Noir':10,
  1553. 'Abishaii Rouge':23,
  1554. 'Abishaii Vert':15,
  1555. 'Ame-en-peine':8,
  1556. 'Amibe Geante':9,
  1557. 'Anaconda des Catacombes':8,
  1558. 'Ankheg':10,
  1559. 'Anoploure Purpurin':36,
  1560. 'Araignee Geante':2,
  1561. 'Ashashin':35,
  1562. 'Balrog':50,
  1563. 'Banshee':16,
  1564. 'Barghest':36,
  1565. 'Basilisk':11,
  1566. 'Behemoth':34,
  1567. 'Behir':14,
  1568. 'Beholder':50,
  1569. 'Boggart':3,
  1570. 'Bondin':9,
  1571. "Bouj'Dla Placide":37,
  1572. "Bouj'Dla":19,
  1573. 'Bulette':19,
  1574. 'Caillouteux':1,
  1575. 'Capitan':35,
  1576. 'Carnosaure':25,
  1577. 'Champi-Glouton':3,
  1578. 'Chauve-Souris Geante':4,
  1579. 'Cheval a Dents de Sabre':23,
  1580. 'Chevalier du Chaos':20,
  1581. 'Chimere':13,
  1582. 'Chonchon':24,
  1583. 'Coccicruelle':22,
  1584. 'Cockatrice':5,
  1585. 'Crasc Medius':17,
  1586. 'Crasc Maexus':25,
  1587. 'Crasc':10,
  1588. 'Croquemitaine':6,
  1589. 'Cube Gelatineux':32,
  1590. 'Daemonite':27,
  1591. 'Diablotin':5,
  1592. 'Dindon du Chaos':1,
  1593. 'Djinn':29,
  1594. 'Ectoplasme':18,
  1595. 'Effrit':27,
  1596. "Elementaire d'Air":23,
  1597. "Elementaire d'Eau":17,
  1598. 'Elementaire de Feu':21,
  1599. 'Elementaire de Terre':21,
  1600. 'Elementaire du Chaos':26,
  1601. 'Erinyes':7,
  1602. 'Esprit-Follet':16,
  1603. 'Essaim Craterien':30,
  1604. 'Essaim Sanguinaire':25,
  1605. 'Ettin':8,
  1606. 'Familier':1,
  1607. 'Fantome':24,
  1608. 'Feu Follet':20,
  1609. 'Flagelleur Mental':33,
  1610. 'Foudroyeur':38,
  1611. 'Fumeux':22,
  1612. 'Fungus Geant':9,
  1613. 'Fungus Violet':4,
  1614. 'Furgolin':10,
  1615. 'Gargouille':3,
  1616. 'Geant de Pierre':13,
  1617. 'Geant des Gouffres':22,
  1618. "Geck'oo Majestueux":40,
  1619. "Geck'oo":15,
  1620. 'Glouton':20,
  1621. 'Gnoll':5,
  1622. 'Gnu Domestique':1,
  1623. 'Gnu Sauvage':1,
  1624. 'Goblin':4,
  1625. 'Goblours':4,
  1626. "Golem d'Argile":15,
  1627. 'Golem de cuir':1,
  1628. 'Golem de Chair':8,
  1629. 'Golem de Fer':31,
  1630. 'Golem de mithril':1,
  1631. 'Golem de metal':1,
  1632. 'Golem de papier':1,
  1633. 'Golem de Pierre':23,
  1634. 'Gorgone':11,
  1635. 'Goule':4,
  1636. 'Gowap Apprivoise':1,
  1637. 'Gowap Sauvage':1,
  1638. 'Gremlins':3,
  1639. 'Gritche':39,
  1640. 'Grouilleux':4,
  1641. 'Grylle':31,
  1642. 'Harpie':4,
  1643. 'Hellrot':18,
  1644. 'Homme-Lezard':4,
  1645. 'Hurleur':8,
  1646. 'Hydre':50,
  1647. 'Incube':13,
  1648. 'Kobold':2,
  1649. 'Labeilleux':26,
  1650. 'Lezard Geant':5,
  1651. 'Liche':50,
  1652. 'Limace Geante':10,
  1653. 'Loup-Garou':8,
  1654. 'Lutin':4,
  1655. 'Mante Fulcreuse':30,
  1656. 'Manticore':9,
  1657. 'Marilith':33,
  1658. 'Meduse':6,
  1659. 'Megacephale':38,
  1660. 'Mille-Pattes Geant':14,
  1661. 'Mimique':6,
  1662. 'Minotaure':7,
  1663. 'Molosse Satanique':8,
  1664. 'Momie':4,
  1665. 'Monstre Rouilleur':3,
  1666. "Mouch'oo Domestique":14,
  1667. "Mouch'oo Majestueux Sauvage":33,
  1668. "Mouch'oo Sauvage":14,
  1669. 'Na-Haniym-Heee':0,
  1670. 'Necrochore':37,
  1671. 'Necromant':39,
  1672. 'Necrophage':8,
  1673. 'Naga':10,
  1674. 'Nuee de Vermine':13,
  1675. "Nuage d'Insectes":7,
  1676. 'Ogre':7,
  1677. 'Ombre de Roches':13,
  1678. 'Ombre':2,
  1679. 'Orque':3,
  1680. 'Ours-Garou':18,
  1681. 'Palefroi Infernal':29,
  1682. 'Phoenix':32,
  1683. 'Pititabeille':0,
  1684. 'Plante Carnivore':4,
  1685. 'Pseudo-Dragon':5,
  1686. 'Rat Geant':2,
  1687. 'Rat-Garou':3,
  1688. 'Rocketeux':5,
  1689. 'Sagouin':3,
  1690. 'Scarabee Geant':4,
  1691. 'Scorpion Geant':10,
  1692. 'Shai':28,
  1693. 'Sirene':8,
  1694. 'Slaad':5,
  1695. 'Sorciere':17,
  1696. 'Spectre':14,
  1697. 'Sphinx':30,
  1698. 'Squelette':1,
  1699. 'Strige':2,
  1700. 'Succube':13,
  1701. 'Tertre Errant':20,
  1702. 'Thri-kreen':10,
  1703. 'Tigre-Garou':12,
  1704. 'Titan':26,
  1705. 'Trancheur':35,
  1706. 'Tubercule Tueur':14,
  1707. 'Tutoki':4,
  1708. 'Vampire':29,
  1709. 'Ver Carnivore Geant':12,
  1710. 'Ver Carnivore':11,
  1711. 'Veskan Du Chaos':14,
  1712. 'Vouivre':33,
  1713. 'Worg':5,
  1714. 'Xorn':14,
  1715. 'Yeti':8,
  1716. 'Yuan-ti':15,
  1717. 'Zombie':2
  1718. }
  1719.  
  1720. var tabEM = {
  1721. //Monstre: [Compo exact, Sort, Position, Localisation]
  1722. // AA
  1723. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1724. // AE
  1725. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1726. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1727. // AdA
  1728. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1729. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1730. // AdE
  1731. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1732. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1733. // AdD
  1734. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1735. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1736. // BAM
  1737. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1738. // BuM
  1739. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1740. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1741. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1742. // Explo
  1743. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1744. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1745. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1746. // FP
  1747. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1748. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1749. // FA
  1750. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1751. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1752. // Glue
  1753. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1754. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1755. // GdS
  1756. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1757. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1758. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1759. // Invi
  1760. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1761. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1762. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1763. // Lévitation
  1764. // ???
  1765. // PréM :
  1766. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1767. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1768. // Proj
  1769. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1770. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1771. // PuM :
  1772. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1773. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1774. // Sacro
  1775. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1776. // Télék
  1777. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1778. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1779. // TP
  1780. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1781. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1782. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1783. // VA
  1784. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1785. // VL
  1786. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1787. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1788. // VlC
  1789. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1790. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1791. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1792. // VT
  1793. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1794. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1795. // Variables
  1796. 'Rat':["d'un"],
  1797. 'Rat Géant':["d'un"],
  1798. 'Dindon':["d'un"],
  1799. 'Goblin':["d'un"],
  1800. 'Limace':["d'une"],
  1801. 'Limace Géante':["d'une"],
  1802. 'Ver':["d'un"],
  1803. 'Ver Carnivore':["d'un"],
  1804. 'Ver Carnivore Géant':["d'un"],
  1805. 'Fungus':["d'un"],
  1806. 'Vouivre':["d'une"],
  1807. 'Gnu':["d'un"],
  1808. 'Scarabée':["d'un"]
  1809. };
  1810.  
  1811. var mundiChampi = {
  1812. 'Préscientus Reguis':'du Phoenix',
  1813. 'Amanite Trolloïde':'de la Mouche',
  1814. 'Girolle Sanglante':'du Dindon',
  1815. 'Horreur Des Prés':'du Gobelin',
  1816. 'Bolet Péteur':'du Démon',
  1817. 'Pied Jaune':'de la Limace',
  1818. 'Agaric Sous-Terrain':'du Rat',
  1819. 'Suinte Cadavre':"de l'Hydre",
  1820. 'Cèpe Lumineux':'du Ver',
  1821. 'Fungus Rampant':'du Fungus',
  1822. 'Nez Noir':'de la Vouivre',
  1823. 'Pleurote Pleureuse':'du Gnu',
  1824. 'Phytomassus Xilénique':'du Scarabée'
  1825. };
  1826.  
  1827. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1828. appendText(node,' ');
  1829. var urlImg = URL_MZimg
  1830. +'Competences/melangeMagique.png';
  1831. var text = ' [-'+(niv+effetQ)+' %]';
  1832. var str = '';
  1833. switch(mob[0]) {
  1834. case 'A':
  1835. case 'E':
  1836. case 'I':
  1837. case 'O':
  1838. case 'U':
  1839. str = "Compo d'";
  1840. break;
  1841. default:
  1842. str = 'Compo de ';
  1843. }
  1844. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1845. var span = createImageSpan(urlImg,'MM:',title,text);
  1846. node.appendChild(span);
  1847. }
  1848. function addInfoEM(node,mob,compo,qualite,localisation) {
  1849. if(!tabEM[mob]) return;
  1850. var title = 'Composant variable', texte = 'Variable';
  1851. var bold = false;
  1852. if(tabEM[mob].length>1) {
  1853. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1854. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1855. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1856. if(pc<-20) return;
  1857. if(pc>=0) bold = true;
  1858. texte = aff(pc)+'%';
  1859. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1860. }
  1861. var urlImg = URL_MZimg
  1862. +'Competences/ecritureMagique.png';
  1863. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1864. node.appendChild(span);
  1865. }
  1866.  
  1867. function insererInfosEM(tbody) {
  1868. // lancé par equip, equipgowap
  1869. var trCompos = document.evaluate(
  1870. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1871. tbody,null,7,null);
  1872. var strCompos = '';
  1873. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1874. var node = trCompos.snapshotItem(i).childNodes[7];
  1875. var str = node.firstChild.textContent;
  1876. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1877. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1878. // Si non-EM on stoppe le traitement
  1879. if(!tabEM[mob]) continue;
  1880. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1881. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1882. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1883. addInfoEM(node,mob,compo,qualite,localisation);
  1884. }
  1885. }
  1886.  
  1887. function getQualite(qualite) {
  1888. var nb = numQualite[qualite];
  1889. return nb ? nb-1 : -1;
  1890. }
  1891.  
  1892. function getEM(nom) {
  1893. if(nom.indexOf('[')!=-1)
  1894. nom = trim(nom.substring(0,nom.indexOf('[')));
  1895. if(tabEM[nom]) return nom;
  1896. return '';
  1897. }
  1898.  
  1899. // DEBUG ex-fonction composantEM
  1900. function compoMobEM(mob) {
  1901. if(!tabEM[mob]) return '';
  1902. if(tabEM[mob].length==1)
  1903. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1904. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1905. +") pour l'écriture de "+tabEM[mob][1];
  1906. }
  1907.  
  1908. // DEBUG ex-fonction compoEM
  1909. function titreCompoEM(mob,compo,localisation,qualite) {
  1910. if(!tabEM[mob]) return '';
  1911. if(tabEM[mob].length==1) return 'Composant variable';
  1912. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1913. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1914. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1915. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1916. return '';
  1917. }
  1918.  
  1919. // DEBUG - rétrocompatibilité
  1920. function compoEM(mob) {
  1921. // appelé dans libs, vue
  1922. return compoMobEM(mob);
  1923. }
  1924. function composantEM(mob,compo,localisation,qualite) {
  1925. // appelé dans libs, tancompo
  1926. return titreCompoEM(mob,compo,localisation,qualite);
  1927. }
  1928. //
  1929.  
  1930.  
  1931. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1932.  
  1933. arrayTalents = {
  1934. /* Compétences */
  1935. 'Acceleration du Metabolisme':'AM',
  1936. 'Attaque Precise':'AP',
  1937. 'Balayage':'Balayage',
  1938. //'Balluchonnage':'Ballu',
  1939. 'Baroufle':'Baroufle',
  1940. 'Bidouille':'Bidouille',
  1941. 'Botte Secrete':'BS',
  1942. 'Camouflage':'Camou',
  1943. 'Charger':'Charger',
  1944. 'Connaissance des Monstres':'CdM',
  1945. 'Construire un Piege':'Piege',
  1946. 'Piege a Feu':'PiegeFeu',
  1947. 'Piege a Glue':'PiegeGlue',
  1948. 'Contre-Attaquer':'CA',
  1949. 'Coup de Butoir':'CdB',
  1950. 'Course':'Course',
  1951. 'Deplacement Eclair':'DE',
  1952. 'Dressage':'Dressage',
  1953. 'Ecriture Magique':'EM',
  1954. 'Frenesie':'Frenesie',
  1955. 'Golemologie':'Golemo',
  1956. 'Golem de cuir':'GolemCuir',
  1957. 'Golem de metal':'GolemMetal',
  1958. 'Golem de mithril':'GolemMithril',
  1959. 'Golem de papier':'GolemPapier',
  1960. 'Grattage':'Grattage',
  1961. 'Hurlement Effrayant':'HE',
  1962. 'Identification des Champignons':'IdC',
  1963. 'Insultes':'Insultes',
  1964. 'Lancer de Potions':'LdP',
  1965. 'Marquage':'Marquage',
  1966. 'Melange Magique':'Melange',
  1967. 'Miner':'Miner',
  1968. 'Travail de la pierre':'Pierre',
  1969. 'Necromancie':'Necro',
  1970. 'Painthure de Guerre':'PG',
  1971. 'Parer':'Parer',
  1972. 'Pistage':'Pistage',
  1973. 'Planter un Champignon':'PuC',
  1974. 'Regeneration Accrue':'RA',
  1975. 'Reparation':'Reparation',
  1976. 'Retraite':'Retraite',
  1977. 'Rotobaffe':'RB',
  1978. 'Shamaner':'Shamaner',
  1979. "S'interposer":'SInterposer',
  1980. 'Tailler':'Tailler',
  1981. //'Vol':'Vol',
  1982. /* Sortilèges */
  1983. 'Analyse Anatomique':'AA',
  1984. 'Armure Etheree':'AE',
  1985. 'Augmentation de l´Attaque':'AdA',
  1986. 'Augmentation de l´Esquive':'AdE',
  1987. 'Augmentation des Degats':'AdD',
  1988. 'Bulle Anti-Magie':'BAM',
  1989. 'Bulle Magique':'BuM',
  1990. 'Explosion':'Explo',
  1991. 'Faiblesse Passagere':'FP',
  1992. 'Flash Aveuglant':'FA',
  1993. 'Glue':'Glue',
  1994. 'Griffe du Sorcier':'GdS',
  1995. 'Hypnotisme':'Hypno',
  1996. 'Identification des tresors':'IdT',
  1997. 'Invisibilite':'Invi',
  1998. 'Levitation':'Levitation',
  1999. 'Precision Magique':'PreM',
  2000. 'Projectile Magique':'Projo',
  2001. 'Projection':'Proj',
  2002. 'Puissance Magique':'PuM',
  2003. 'Rafale Psychique':'Rafale',
  2004. 'Sacrifice':'Sacro',
  2005. 'Siphon des ames':'Siphon',
  2006. 'Telekinesie':'Telek',
  2007. 'Teleportation':'TP',
  2008. 'Vampirisme':'Vampi',
  2009. 'Vision Accrue':'VA',
  2010. 'Vision lointaine':'VL',
  2011. 'Voir le Cache':'VlC',
  2012. 'Vue Troublee':'VT'
  2013. //'':''
  2014. }
  2015.  
  2016. // DEBUG - Pour rétrocompatibilité
  2017. function getSortComp(nom,niveau) {
  2018. return getTalent(nom,niveau);
  2019. }
  2020. //
  2021.  
  2022. function getTalent(nom,niveau) {
  2023. var nomEnBase = arrayTalents[epure(nom)];
  2024. if(!nomEnBase) return 0;
  2025. if(!niveau) var niveau = '';
  2026. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2027. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  2028. return 0;
  2029. }
  2030.  
  2031. function removeAllTalents() {
  2032. for(var talent in arrayTalents) {
  2033. var nomEnBase = arrayTalents[talent];
  2034. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2035. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2036. continue;
  2037. }
  2038. var niveau = 1;
  2039. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2040. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2041. niveau++;
  2042. }
  2043. }
  2044. }
  2045.  
  2046. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2047. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2048. var att = MY_getValue(numTroll+'.caracs.attaque');
  2049. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2050. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2051. var mm = MY_getValue(numTroll+'.caracs.mm');
  2052. var deg = MY_getValue(numTroll+'.caracs.degats');
  2053. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2054. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2055. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2056. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2057. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2058. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2059. return false;
  2060. return true;
  2061. } catch(e) {
  2062. return false;
  2063. }
  2064. }
  2065.  
  2066.  
  2067. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2068.  
  2069. function getPVsRestants(pv,bless,vue) {
  2070. bless = Number(bless.match(/\d+/)[0]);
  2071. if(bless==0) return null;
  2072. var pvminmax = pv.match(/\d+/g);
  2073. if(bless==95) {
  2074. var pvb = 1;
  2075. var pvh = Math.floor( pvminmax[1]/20 );
  2076. }
  2077. else if(bless==5) {
  2078. var pvb = Math.floor( pvminmax[0]*19/20 );
  2079. var pvh = pvminmax[1];
  2080. }
  2081. else {
  2082. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2083. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2084. }
  2085. return vue ? ' ('+pvb+'-'+pvh+')' :
  2086. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2087. }
  2088.  
  2089. function insertButtonCdm(nextName,onClick,texte) {
  2090. if(texte==null) texte = 'Participer au bestiaire';
  2091. var nextNode = document.getElementsByName(nextName)[0];
  2092.  
  2093. var espace = document.createTextNode('\t');
  2094. insertBefore(nextNode,espace);
  2095.  
  2096. var button = document.createElement('input');
  2097. button.type = 'button';
  2098. button.className = 'mh_form_submit';
  2099. button.value = texte;
  2100. button.onmouseover = function(){this.style.cursor='pointer';};
  2101. if(onClick) button.onclick = onClick;
  2102. insertBefore(espace,button);
  2103. return button;
  2104. }
  2105.  
  2106. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  2107. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  2108. 'Capacité spéciale','Résistance Magique','Autres'];
  2109.  
  2110. /* appelé par
  2111. createCDMTable (dans le popup DcM)
  2112. computeTactique (à coté du nom des monstres dans la vue et dans la page de détail des monstres)
  2113. */
  2114. function createImageTactique(url,id,nom) {
  2115. var img = document.createElement('img');
  2116. img.src = url;
  2117. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  2118. img.id = id;
  2119. img.nom = nom;
  2120. img.onmouseover = showPopupTactique;
  2121. img.onmouseout = hidePopup;
  2122. return img;
  2123. }
  2124.  
  2125. function createCDMTable(id,nom,donneesMonstre) {
  2126. try {
  2127. var urlImg = URL_MZimg;
  2128. var table = document.createElement('table');
  2129. var profilActif = isProfilActif();
  2130. table.className = 'mh_tdborder';
  2131. table.border = 0;
  2132. table.cellSpacing = 1;
  2133. table.cellPadding = 4;
  2134. var thead = document.createElement('thead');
  2135. var tr = appendTr(thead,'mh_tdtitre');
  2136. var td = appendTdText(tr,
  2137. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  2138. true
  2139. );
  2140. td.colSpan = 2;
  2141. table.appendChild(thead);
  2142. var tbody = document.createElement('tbody');
  2143. table.appendChild(tbody);
  2144. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  2145. createCase(listeTitres[i],tbody,80);
  2146. }
  2147. var TypeMonstre = getEM(nom);
  2148. var infosCompo='';
  2149. if(TypeMonstre!='') {
  2150. infosCompo = compoEM(TypeMonstre);
  2151. }
  2152. var nodes = tbody.childNodes;
  2153. nodes[0].childNodes[1].innerHTML =
  2154. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  2155. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  2156. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  2157. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  2158. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  2159. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  2160. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  2161. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  2162. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  2163. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  2164. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  2165. td = createCase(listeTitres[10],tbody);
  2166. td.innerHTML = bbcode(donneesMonstre[10]);
  2167. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2168. td.appendChild(document.createTextNode(" "));
  2169. if(donneesMonstre[16] == "De zone")
  2170. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2171. else if(donneesMonstre[16] == "Automatique")
  2172. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2173. else if(donneesMonstre[16] == "Au toucher")
  2174. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2175. }
  2176. }
  2177. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2178. {
  2179. td = createCase(listeTitres[11],tbody);
  2180. td.innerHTML = bbcode(donneesMonstre[9]);
  2181. // seuil de résistance du monstre
  2182. var lb = td.getElementsByTagName('b');
  2183. if(lb.length == 1) {
  2184. var mrm = lb[0].firstChild.nodeValue * 1;
  2185. var v = (mrm / mmTroll);
  2186. lb[0].firstChild.nodeValue += " ("
  2187. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2188. }
  2189. }
  2190. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2191. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2192. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2193. {
  2194. td = createCase(listeTitres[12],tbody);
  2195. if(donneesMonstre[12]==1)
  2196. {
  2197. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2198. }
  2199. if(donneesMonstre[13]==1)
  2200. {
  2201. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2202. }
  2203. else if(donneesMonstre[13]==0)
  2204. {
  2205. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2206. }
  2207. if(donneesMonstre[14]==1)
  2208. {
  2209. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2210. }
  2211. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2212. {
  2213. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2214. }
  2215. else if(donneesMonstre[14]>6)
  2216. {
  2217. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2218. }
  2219. if(donneesMonstre[15]=="Lente")
  2220. {
  2221. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2222. }
  2223. else if(donneesMonstre[15]=="Normale")
  2224. {
  2225. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2226. }
  2227. else if(donneesMonstre[15]=="Rapide")
  2228. {
  2229. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2230. }
  2231. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2232. {
  2233. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2234. }
  2235. if(infosCompo.length>0)
  2236. {
  2237. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2238. }
  2239. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2240. {
  2241. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2242. }
  2243. }
  2244. // pourcentage de blessure
  2245. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2246. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2247. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2248. if(pvs)
  2249. lb[0].firstChild.nodeValue += pvs;
  2250. }
  2251. return table;
  2252. }
  2253. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2254. }
  2255.  
  2256.  
  2257. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2258.  
  2259. var listeMonstreEnchantement = null,
  2260. listeEquipementEnchantement = null,
  2261. listeInfoEnchantement = null;
  2262.  
  2263. function computeCompoEnchantement()
  2264. {
  2265. listeMonstreEnchantement = new Array();
  2266. listeInfoEnchantement = new Array();
  2267. listeEquipementEnchantement = new Array();
  2268. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2269. for(var i=0;i<liste.length;i++)
  2270. {
  2271. var idEquipement = liste[i]*1;
  2272. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2273. continue;
  2274. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2275. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2276. var texteGlobal='';
  2277. for(var j=0;j<3;j++)
  2278. {
  2279. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2280. var v = MY_getValue(k);
  2281. var infoComposant = MY_getValue().split(';');
  2282. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2283. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2284. continue;
  2285. }
  2286. listeMonstreEnchantement[infoComposant[2]] = 1;
  2287. var array = new Array();
  2288. array[0]=infoComposant[0].replace("Ril","Œil");
  2289. array[1]=infoComposant[1];
  2290. array[2]=infoComposant[2];
  2291. array[3]=getQualite(infoComposant[3]);
  2292. var texte = infoComposant[4].replace("Ril","Œil");
  2293. for(var k=5;k<infoComposant.length;k++)
  2294. {
  2295. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2296. }
  2297. texteGlobal+=texte+'\n';
  2298. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2299. array[4]=texte;
  2300. listeInfoEnchantement.push(array);
  2301. }
  2302. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2303. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2304. }
  2305. }
  2306.  
  2307. function isEnchant(nom) {
  2308. var monstreEnchant = '';
  2309. for(j in listeInfoEnchantement) {
  2310. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2311. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2312. monstreEnchant=monstre;
  2313. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2314. }
  2315. }
  2316. return trim(monstreEnchant);
  2317. }
  2318.  
  2319. function getInfoEnchantementFromMonstre(nom)
  2320. {
  2321. try
  2322. {
  2323. if(!listeMonstreEnchantement)
  2324. {
  2325. computeCompoEnchantement();
  2326. }
  2327. var infosEnchant = '';
  2328. for(j in listeInfoEnchantement) {
  2329. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2330. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2331. if(infosEnchant=='')
  2332. infosEnchant=listeInfoEnchantement[j][4];
  2333. else
  2334. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2335. }
  2336. }
  2337. return trim(infosEnchant);
  2338. }
  2339. catch(e)
  2340. {
  2341. window.alert(e);
  2342. }
  2343. }
  2344.  
  2345. function composantEnchant(Monstre,composant,localisation,qualite) {
  2346. var compo='';
  2347. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2348. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2349. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2350. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2351. listeInfoEnchantement[i][3]<=qualite
  2352. ) {
  2353. return listeInfoEnchantement[i][4];
  2354. }
  2355. }
  2356. return compo;
  2357. }
  2358.  
  2359. function insertEnchantInfos(tbody) {
  2360. try
  2361. {
  2362. if(!listeMonstreEnchantement)
  2363. computeCompoEnchantement();
  2364. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2365. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2366. if(nodes.snapshotLength == 0)
  2367. return false;
  2368. var urlImg = URL_MZimg + 'enchant.png';
  2369. for(var i = 0; i < nodes.snapshotLength; i++) {
  2370. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2371. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2372. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2373. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2374. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2375. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2376. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2377. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2378. if(isEnchant(nomMonstre).length>0)
  2379. {
  2380. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2381. if(infos.length>0)
  2382. {
  2383. if(link.parentNode == link.nextSibling.parentNode)
  2384. {
  2385. var tmp = link.nextSibling;
  2386. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2387. }
  2388. else
  2389. {
  2390. link.parentNode.appendChild(createImage(urlImg,infos));
  2391. }
  2392. }
  2393. }
  2394. }
  2395. }
  2396. catch(e)
  2397. {
  2398. window.alert(e);
  2399. }
  2400. }
  2401.  
  2402. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2403. {
  2404. try
  2405. {
  2406. if(!listeMonstreEnchantement)
  2407. computeCompoEnchantement();
  2408. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2409. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2410. if(nodes.snapshotLength == 0)
  2411. return false;
  2412. var urlImg = URL_MZimg + 'enchant.png';
  2413. for(var i = 0; i < nodes.snapshotLength; i++)
  2414. {
  2415. var link = nodes.snapshotItem(i);
  2416. var idEquipement = link.getAttribute('href');
  2417. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2418. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2419. var nomEquipement = trim(link.firstChild.nodeValue);
  2420. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2421. if(!enchanteur || enchanteur == '')
  2422. continue;
  2423. var infos = listeEquipementEnchantement[idEquipement];
  2424. infos=formateTexte(infos);
  2425. if(infos.length>0)
  2426. {
  2427. if(link.parentNode == link.nextSibling.parentNode)
  2428. {
  2429. var tmp = link.nextSibling;
  2430. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2431. }
  2432. else
  2433. {
  2434. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2435. }
  2436. }
  2437. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2438. }
  2439. }
  2440. catch(e)
  2441. {
  2442. window.alert(e);
  2443. }
  2444. }
  2445.  
  2446. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2447.  
  2448.  
  2449. // Les % de toucher
  2450. var c = new Array();
  2451.  
  2452. // coefficients binomiaux
  2453. function cnp(n,k)
  2454. {
  2455. if(c[n] != null && c[n][k] != null)
  2456. return c[n][k];
  2457. if(c[n] == null)
  2458. c[n] = new Array();
  2459. if(k==0)
  2460. {
  2461. c[n][k] = 1;
  2462. return 1;
  2463. }
  2464. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2465. c[n][k] = result;
  2466. // Roule debug
  2467. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2468. return result;
  2469. }
  2470.  
  2471. // by Dab, à comparer
  2472. function binom(n,p) {
  2473. if(p<0 || p>n) return 0;
  2474. if(c[n])
  2475. if(c[n][p]) return c[n][p];
  2476. else {
  2477. c[n]=[1];
  2478. c[n][n]=1;
  2479. if(p==0 || p==n) return 1;
  2480. }
  2481. if(2*p>n)
  2482. c[n][p]=binom(n,n-p);
  2483. else
  2484. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2485. return c[n][p];
  2486. }
  2487.  
  2488. var coeff = new Array();
  2489.  
  2490. function coef(n,p)
  2491. {
  2492. if(n==0 && p==0)
  2493. return 1;
  2494. if(p>n*3.5)
  2495. p = 7*n-p
  2496. // roule désactive cache
  2497. if(coeff[n] != null && coeff[n][p] !=null)
  2498. return coeff[n][p];
  2499. if(coeff[n] == null)
  2500. coeff[n] = new Array();
  2501. var kmax = Math.floor((p-n)/6);
  2502. var x=0;
  2503. for(var k=0;k<=kmax;k++)
  2504. {
  2505. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2506. }
  2507. coeff[n][p] = x;
  2508. // Roule debug
  2509. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2510. return x;
  2511. }
  2512.  
  2513. function chanceEsquiveParfaite(a,d,ba,bd)
  2514. {
  2515. var win = 0;
  2516. var los = 0;
  2517. if(ba==null)
  2518. ba=0;
  2519. if(bd==null)
  2520. bd=0;
  2521. /* if(6*a+ba<2*(d+bd))
  2522. return 100;
  2523. if(a+ba>2*(6*d+bd))
  2524. return 0;*/
  2525. for(var ds=d;ds<=6*d;ds++)
  2526. {
  2527. var cd = coef(d,ds);
  2528. for(var as=a;as<=6*a;as++)
  2529. {
  2530. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2531. win += cd * coef(a,as);
  2532. else
  2533. los += cd * coef(a,as);
  2534. }
  2535. }
  2536. // roule debug
  2537. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2538. return Math.round(100*win/(win+los));
  2539. }
  2540.  
  2541. function chanceTouche(a,d,ba,bd)
  2542. {
  2543. var win = 0;
  2544. var los = 0;
  2545. if(ba==null)
  2546. ba=0;
  2547. if(bd==null)
  2548. bd=0;
  2549. if(a+ba>6*d+bd)
  2550. return 100;
  2551. if(6*a+ba<d+bd)
  2552. return 0;
  2553. for(var ds=d;ds<=6*d;ds++)
  2554. {
  2555. var cd = coef(d,ds);
  2556. for(var as=a;as<=6*a;as++)
  2557. {
  2558. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2559. win += cd * coef(a,as);
  2560. else
  2561. los += cd * coef(a,as);
  2562. }
  2563. }
  2564. return Math.round(100*win/(win+los));
  2565. }
  2566.  
  2567. function chanceCritique(a,d,ba,bd)
  2568. {
  2569. var win = 0;
  2570. var los = 0;
  2571. if(ba==null)
  2572. ba=0;
  2573. if(bd==null)
  2574. bd=0;
  2575. if(a+ba>2*(6*d+bd))
  2576. return 100;
  2577. if(6*a+ba<2*(d+bd))
  2578. return 0;
  2579. for(var ds=d;ds<=6*d;ds++)
  2580. {
  2581. var cd = coef(d,ds);
  2582. for(var as=a;as<=6*a;as++)
  2583. {
  2584. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2585. win += cd * coef(a,as);
  2586. else
  2587. los += cd * coef(a,as);
  2588. }
  2589. }
  2590. return Math.round(100*win/(win+los));
  2591. }
  2592.  
  2593. /***********************************************
  2594. Analyse tactique
  2595. ***********************************************/
  2596.  
  2597. function getTexteAnalyse(modificateur,chiffre)
  2598. {
  2599. if(chiffre==0)
  2600. return chiffre;
  2601. return modificateur+chiffre;
  2602. }
  2603.  
  2604. // rend le HTML pour le tableau de la "calculette"
  2605. function getAnalyseTactique(id,nom)
  2606. {
  2607. var donneesMonstre = listeCDM[id];
  2608. var needAutres=false;
  2609. var i;
  2610. if(donneesMonstre == null)
  2611. return;
  2612. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2613. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2614. if(array==null)
  2615. return "";
  2616. 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>";
  2617. for(i=0;i<array.length;i++)
  2618. {
  2619. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2620. {
  2621. needAutres=true;
  2622. break;
  2623. }
  2624. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2625. 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>";
  2626. else if(i==0) // attaque du monstre sur le Trõll => italique
  2627. 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>";
  2628. else // autre, pas de décoration
  2629. 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>";
  2630. }
  2631. if(needAutres)
  2632. {
  2633. if(i==array.length-1)
  2634. 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>";
  2635. else if(i==1)
  2636. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2637. else
  2638. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2639. }
  2640. return str+"</table>";
  2641. }
  2642.  
  2643. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2644. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2645. function analyseTactique(donneesMonstre,nom) {
  2646. try
  2647. {
  2648. var listeAttaques = [];
  2649. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2650. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2651. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2652. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2653. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2654. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2655. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2656. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2657. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2658. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2659. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2660. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2661. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2662. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2663. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2664. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2665. var modificateurEsquive = '';
  2666. var modificateurArmure = '';
  2667. var modificateurMagie = '';
  2668. var modificateurEsquiveM = '';
  2669. var modificateurArmureM = '';
  2670. var pasDeSR=false;
  2671. var esqM,attM,armM,degM;
  2672. 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)
  2673. return null;
  2674. var td = document.createElement('td')
  2675. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2676. var esqM = 0;
  2677. try
  2678. {
  2679. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2680. }
  2681. catch(e)
  2682. {
  2683. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  2684. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2685. modificateurEsquive = '<';
  2686. modificateurArmure = '<';
  2687. modificateurMagie = '<';
  2688. }
  2689. td.innerHTML = bbcode(donneesMonstre[3]);
  2690. var attM = 0;
  2691. try
  2692. {
  2693. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2694. }
  2695. catch(e)
  2696. {
  2697. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  2698. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2699. modificateurEsquiveM = '>';
  2700. modificateurArmureM = '>';
  2701. }
  2702. td.innerHTML = bbcode(donneesMonstre[5]);
  2703. var degM = 0;
  2704. try
  2705. {
  2706. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2707. }
  2708. catch(e)
  2709. {
  2710. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  2711. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2712. modificateurArmureM = '>';
  2713. }
  2714. td.innerHTML = bbcode(donneesMonstre[7]);
  2715. var armM = 0;
  2716. try
  2717. {
  2718. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2719. }
  2720. catch(e)
  2721. {
  2722. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  2723. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2724. modificateurArmure = '<';
  2725. }
  2726. var coeffSeuil = 0.95;
  2727. try
  2728. {
  2729. td.innerHTML = bbcode(donneesMonstre[9]);
  2730. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  2731. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2732. var v = (rm / mm);
  2733. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2734. coeffSeuil = (200-seuil)/200;
  2735. }
  2736. catch(e)
  2737. {
  2738. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  2739. modificateurMagie = '<';
  2740. pasDeSR = true;
  2741. }
  2742. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2743. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2744. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2745. // roule debug
  2746. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2747. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2748. 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);
  2749. //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);
  2750. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2751. if(getSortComp("Vampirisme")>0)
  2752. {
  2753. var pour = getSortComp("Vampirisme");
  2754. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2755. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2756. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2757. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2758. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2759. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2760. }
  2761. if(getSortComp("Siphon des âmes")>0)
  2762. {
  2763. var pour = getSortComp("Siphon des âmes");
  2764. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2765. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2766. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2767. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2768. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2769. }
  2770. if(getSortComp("Botte Secrète")>0)
  2771. {
  2772. var pour = getSortComp("Botte Secrète");
  2773. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2774. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2775. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2776. 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;
  2777. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2778. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2779. }
  2780. if(getSortComp("Rafale Psychique")>0)
  2781. {
  2782. var pour = getSortComp("Rafale Psychique");
  2783. chanceDEsquiveParfaite = 0;
  2784. chanceDeTouche = Math.round(100*pour/100);
  2785. chanceDeCritique = Math.round(0*pour/100);
  2786. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2787. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2788. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2789. }
  2790. if(getSortComp("Explosion")>0)
  2791. {
  2792. var pour = getSortComp("Explosion");
  2793. chanceDEsquiveParfaite = 0;
  2794. chanceDeTouche = Math.round(100*pour/100);
  2795. chanceDeCritique = Math.round(0*pour/100);
  2796. 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;
  2797. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2798. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2799. }
  2800. if(getSortComp("Projectile Magique")>0)
  2801. {
  2802. var pour = getSortComp("Projectile Magique");
  2803. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2804. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2805. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2806. // distance troll - monstre
  2807. 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;
  2808. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2809. if (donneesMonstre['iTR'] !== undefined) {
  2810. var dist = getMonstreDistance(donneesMonstre['iTR']+1);
  2811. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  2812. var portee = getPortee__Profil(vue+vue_bm);
  2813. if (dist <= portee) {
  2814. degats += 2 * (portee-dist);
  2815. } else {
  2816. degats += ' (plus bonus de portée)';
  2817. }
  2818. debugMZ('analyseTactique, iTR= ' + donneesMonstre['iTR'] + ', dist=' + dist + ', porteePM=' + portee);
  2819. } else {
  2820. degats += ' (plus bonus de portée)';
  2821. }
  2822. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2823. }
  2824. if(getSortComp("Frénésie")>0)
  2825. {
  2826. var pour = getSortComp("Frénésie");
  2827. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2828. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2829. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2830. 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;
  2831. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2832. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2833. }
  2834. if(getSortComp("Charger")>0)
  2835. {
  2836. var pour = getSortComp("Charger");
  2837. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2838. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2839. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2840. 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;
  2841. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2842. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2843. }
  2844. if(getSortComp("Griffe du Sorcier")>0)
  2845. {
  2846. var pour = getSortComp("Griffe du Sorcier");
  2847. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2848. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2849. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2850. 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;
  2851. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2852. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2853. }
  2854. if(getSortComp("Attaque Précise",1)>0)
  2855. {
  2856. var niveau = 5;
  2857. var oldPour = 0;
  2858. var chanceDEsquiveParfaite = 0;
  2859. var chanceDeTouche = 0;
  2860. var chanceDeCritique = 0;
  2861. degats = 0;
  2862. while(niveau>0)
  2863. {
  2864. var pour = getSortComp("Attaque Précise",niveau);
  2865. if(pour>oldPour)
  2866. {
  2867. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2868. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2869. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2870. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2871. chanceDeTouche += chanceDeToucheNiveau;
  2872. chanceDeCritique += chanceDeCritiqueNiveau;
  2873. 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);
  2874. oldPour = pour;
  2875. }
  2876. niveau--;
  2877. }
  2878. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2879. 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));
  2880. }
  2881. if(getSortComp("Coup de Butoir",1)>0)
  2882. {
  2883. var niveau = 5;
  2884. var oldPour =0;
  2885. var chanceDEsquiveParfaite = 0;
  2886. var chanceDeTouche=0;
  2887. var chanceDeCritique=0;
  2888. degats=0;
  2889. while(niveau>0)
  2890. {
  2891. var pour = getSortComp("Coup de Butoir",niveau);
  2892. if(pour>oldPour)
  2893. {
  2894. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2895. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2896. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2897. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2898. chanceDeTouche += chanceDeToucheNiveau;
  2899. chanceDeCritique += chanceDeCritiqueNiveau;
  2900. 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);
  2901. oldPour = pour;
  2902. }
  2903. niveau--;
  2904. }
  2905. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2906. 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));
  2907. }
  2908. 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;});
  2909. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2910. {
  2911. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2912. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2913. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2914. }
  2915. else
  2916. {
  2917. chanceDEsquiveParfaite = 0;
  2918. chanceDeTouche = 100;
  2919. chanceDeCritique = 0;
  2920. }
  2921. 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;
  2922.  
  2923. 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));
  2924. return listeAttaques;
  2925. }
  2926. catch(e) { window.alert(e);}
  2927. }
  2928.  
  2929. // x~~x marque pour s'y retrouver sous l'éditeur
  2930.  
  2931. /*
  2932. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2933. * published under GNU License v2.
  2934. *
  2935. * Patch :
  2936. * gestion des missions terminées
  2937. */
  2938. // x~x mission_liste
  2939.  
  2940. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2941. try {
  2942. var titresMimis = document.evaluate(
  2943. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2944. document, null, 7, null
  2945. );
  2946. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2947. } catch(e) {
  2948. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2949. return;
  2950. }
  2951. var enCours = {};
  2952. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2953. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2954. enCours[num] = true;
  2955. }
  2956. for(var numMimi in obMissions) {
  2957. if(!enCours[numMimi]) {
  2958. delete obMissions[numMimi];
  2959. }
  2960. }
  2961. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2962. }
  2963.  
  2964. function do_mission_liste() {
  2965. checkLesMimis();
  2966. }
  2967.  
  2968. /*******************************************************************************
  2969. * This file is part of Mountyzilla. *
  2970. * *
  2971. * Mountyzilla is free software; you can redistribute it and/or modify *
  2972. * it under the terms of the GNU General Public License as published by *
  2973. * the Free Software Foundation; either version 2 of the License, or *
  2974. * (at your option) any later version. *
  2975. * *
  2976. * Mountyzilla is distributed in the hope that it will be useful, *
  2977. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2978. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2979. * GNU General Public License for more details. *
  2980. * *
  2981. * You should have received a copy of the GNU General Public License *
  2982. * along with Mountyzilla; if not, write to the Free Software *
  2983. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2984. *******************************************************************************/
  2985.  
  2986. // x~x actions
  2987.  
  2988. /* TODO
  2989. * getLvl pour Explo, Rotobaffe et cie
  2990. */
  2991.  
  2992.  
  2993.  
  2994. /* Page de combat */
  2995.  
  2996. function getLevel() {
  2997. var divList = document.getElementsByTagName('div');
  2998. if(divList.length <= 2)
  2999. return;
  3000. // On essaie de voir si cette action était une attaque
  3001. var pList = document.getElementsByTagName('p');
  3002. var nomM = '';
  3003. // Modification pour Frénésie by TetDure
  3004. var numAtt = 0;
  3005. for (var i = 0; i < pList.length; i++) {
  3006. if(pList[i].firstChild) {
  3007. nomM = pList[i].firstChild.nodeValue;
  3008. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3009. numAtt++;
  3010. }
  3011. }
  3012. if(nomM == '')
  3013. return;
  3014. // Si c'est une attaque normale, un seul PX
  3015. var comPX = 1;
  3016. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3017. comPX++;
  3018.  
  3019. // Extraction des infos du monstre attaqué
  3020. var idM;
  3021. var male;
  3022. if(nomM.slice(20, 21) == 'e') {
  3023. male = false;
  3024. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3025. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3026. }
  3027. else {
  3028. male = true;
  3029. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3030. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3031. }
  3032. if(idM == '')
  3033. return;
  3034. var bList = document.getElementsByTagName('b');
  3035. var niveau = '';
  3036. for (var i = 0; i < bList.length; i++) {
  3037. var b = bList[i];
  3038. if(b.childNodes[0].nodeValue != "TUÉ")
  3039. continue;
  3040. var nbPX = "";
  3041. for (i++; i < bList.length; i++) {
  3042. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3043. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3044. return;
  3045. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3046. nbPX = bList[i].childNodes[0].nodeValue;
  3047. break;
  3048. }
  3049. }
  3050. if(nbPX == '')
  3051. return;
  3052. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3053. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3054. if(!nbPX)
  3055. nbPX = 0;
  3056. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3057. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3058. if(comPX > nbPX) {
  3059. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3060. niveau = "";
  3061. } else if(Math.floor(niveau) == niveau) {
  3062. chaine += niveau + ".";
  3063. } else {
  3064. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3065. niveau = "";
  3066. }
  3067. insertBr(b.nextSibling.nextSibling.nextSibling);
  3068. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3069. }
  3070.  
  3071. if(niveau != '') {
  3072. var button = insertButtonCdm('as_Action');
  3073. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3074. + escape(nomM) + "&niveau=" + escape(niveau)
  3075. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3076. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3077. }
  3078. }
  3079.  
  3080.  
  3081. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3082.  
  3083. function insertInfoMagie(node, intitule, magie) {
  3084. if(node.nextSibling) {
  3085. node = node.nextSibling;
  3086. insertBr(node);
  3087. insertText(node, intitule);
  3088. insertText(node, magie, true);
  3089. } else {
  3090. node = node.parentNode;
  3091. appendBr(node);
  3092. appendText(node, intitule);
  3093. appendText(node, magie, true);
  3094. }
  3095. }
  3096.  
  3097. function getMM(sr) {
  3098. if(rmTroll<=0) {
  3099. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3100. }
  3101. sr = Number(sr.match(/\d+/)[0]);
  3102. if(sr==10) {
  3103. return '\u2265 '+5*rmTroll;
  3104. }
  3105. if(sr<=50) {
  3106. return Math.round(50*rmTroll/sr);
  3107. }
  3108. if(sr<90) {
  3109. return Math.round((100-sr)*rmTroll/50);
  3110. }
  3111. return '\u2264 '+Math.round(rmTroll/5);
  3112. }
  3113.  
  3114. function traiteMM() {
  3115. var node = document.evaluate(
  3116. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3117. document, null, 9, null).singleNodeValue;
  3118. if(node) {
  3119. var mm = getMM(node.nodeValue);
  3120. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3121. } else {
  3122. var node = document.evaluate(
  3123. "//p/text()[contains(., 'Seuil de Résistance')]",
  3124. document, null, 9, null).singleNodeValue;
  3125. if(!node) {
  3126. return;
  3127. }
  3128. var mm = getMM(node.nodeValue);
  3129. node = node.nextSibling.nextSibling;
  3130. }
  3131. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3132. }
  3133.  
  3134. function getRM(sr) {
  3135. if(mmTroll<=0) {
  3136. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3137. }
  3138. sr = Number(sr.match(/\d+/)[0]);
  3139. if(sr==10) {
  3140. return '\u2264 '+Math.round(mmTroll/5);
  3141. }
  3142. if(sr<=50) {
  3143. return Math.round(sr*mmTroll/50);
  3144. }
  3145. if(sr<90) {
  3146. return Math.round(50*mmTroll/(100-sr));
  3147. }
  3148. return '\u2265 '+5*mmTroll;
  3149. }
  3150.  
  3151. function traiteRM() {
  3152. var nodes = document.evaluate(
  3153. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3154. document, null, 7, null);
  3155. if(nodes.snapshotLength==0) {
  3156. return;
  3157. }
  3158. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3159. var node = nodes.snapshotItem(i);
  3160. var rm = getRM(node.nodeValue);
  3161. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3162. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3163. }
  3164. }
  3165.  
  3166.  
  3167. /* Fonction stats IdT par Raistlin */
  3168. /*function getIdt() {
  3169. if(MY_getValue("SEND_IDT") == "non")
  3170. return false;
  3171. var regExpBeginning = /^\s+/;
  3172. var regExpEnd = /\s+$/;
  3173.  
  3174. var nomIdt = document.evaluate(
  3175. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3176. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3177. if(!nomIdt)
  3178. return false;
  3179.  
  3180. var caracIdt;
  3181. if(nomIdt.indexOf("Malédiction !") != -1) {
  3182. caracIdt = "";
  3183. nomIdt = "Mission maudite";
  3184. } else {
  3185. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3186. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3187. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3188. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3189. }
  3190. FF_XMLHttpRequest({
  3191. method: 'GET',
  3192. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3193. headers : {
  3194. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3195. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3196. }
  3197. });
  3198. return true;
  3199. }*/
  3200.  
  3201.  
  3202. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3203.  
  3204. function confirmeDecalage() {
  3205. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3206. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3207. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3208. var newDLA = new Date( oldDLA );
  3209. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3210. return window.confirm(
  3211. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3212. +'\nConfirmez-vous ce décalage ?'
  3213. );
  3214. }
  3215.  
  3216. function newsubmitDLA(evt) {
  3217. evt.stopPropagation();
  3218. evt.preventDefault();
  3219. if(confirmeDecalage()) {
  3220. this.submit();
  3221. }
  3222. }
  3223.  
  3224. function changeActionDecalage() {
  3225. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3226. return;
  3227. }
  3228. try {
  3229. // On récupère le contenu du script JS MH de calcul du décalage
  3230. var scriptTxt = document.evaluate(
  3231. ".//script[ not(@src) ]",
  3232. document, null, 9, null
  3233. ).singleNodeValue.textContent;
  3234. // On en extrait la DLA courante
  3235. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3236. scriptTxt = scriptTxt.split('\n')[0];
  3237. var nbs = scriptTxt.match(/\d+/g);
  3238. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3239. } catch(e) {
  3240. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3241. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3242. return;
  3243. }
  3244. var form = document.getElementsByName('ActionForm')[0];
  3245. if(form) {
  3246. form.addEventListener('submit', newsubmitDLA, true);
  3247. } else {
  3248. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3249. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3250. }
  3251. }
  3252.  
  3253. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3254.  
  3255. function prochainMundi() {
  3256. try {
  3257. var node;
  3258. node = document.evaluate(
  3259. "//div[@class='dateAction']/b",
  3260. document, null, 9, null
  3261. ).singleNodeValue;
  3262. if (document.evaluate) {
  3263. } else { // repli en JQuery
  3264. //node = $(
  3265. }
  3266. } catch(e) {
  3267. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3268. return;
  3269. }
  3270. if(!node) { return; }
  3271.  
  3272. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3273. var jour = longueurMois+1-getNumber(node.textContent);
  3274. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3275. var txt = '[Prochain Mundidey ';
  3276. if(jour>1) {
  3277. txt += 'dans '+jour+' jours]';
  3278. } else {
  3279. txt += 'demain]';
  3280. }
  3281. insertText(node.parentNode.nextSibling,txt,true);
  3282. }
  3283.  
  3284.  
  3285. /* Fonction principale */
  3286.  
  3287. function dispatch() {
  3288. if(isPage('MH_Play/Play_action')) {
  3289. prochainMundi();
  3290. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3291. var oldDLA;
  3292. changeActionDecalage();
  3293. } else if(isPage('MH_Play/Actions')) {
  3294. if(document.evaluate(
  3295. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3296. document, null, 2, null
  3297. ).stringValue) {
  3298. traiteMM();
  3299. } else if(document.evaluate(
  3300. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3301. document, null, 2, null
  3302. ).stringValue) {
  3303. //getIdt();
  3304. traiteRM();
  3305. } /*else {
  3306. // Est censé se lancer sur quoi *précisément* ?
  3307. traiteRM();
  3308. getLevel();
  3309. }*/
  3310. } else {
  3311. /* Traitement des messages du bot */
  3312. var messageTitle = document.evaluate(
  3313. "//form/table/tbody/tr[1]/td[1]/"
  3314. +"descendant::text()[contains(.,'[MountyHall]')]",
  3315. document, null, 2, null
  3316. ).stringValue;
  3317. if(messageTitle.indexOf('Attaquant') != -1 &&
  3318. messageTitle.indexOf('sur') != -1) {
  3319. getLevel();
  3320. traiteRM();
  3321. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3322. messageTitle.indexOf('Défenseur') != -1) {
  3323. traiteMM();
  3324. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3325. // à replacer avec Attaque après révision getLvl :
  3326. messageTitle.indexOf('Explosion') != -1 ||
  3327. messageTitle.indexOf('Insulte') != -1) {
  3328. traiteRM();
  3329. }
  3330. }
  3331. }
  3332.  
  3333. function do_actions() {
  3334. start_script(31);
  3335. dispatch();
  3336. displayScriptTime();
  3337. }
  3338.  
  3339. /*********************************************************************************
  3340. * This file is part of Mountyzilla. *
  3341. * *
  3342. * Mountyzilla is free software; you can redistribute it and/or modify *
  3343. * it under the terms of the GNU General Public License as published by *
  3344. * the Free Software Foundation; either version 2 of the License, or *
  3345. * (at your option) any later version. *
  3346. * *
  3347. * Mountyzilla is distributed in the hope that it will be useful, *
  3348. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3349. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3350. * GNU General Public License for more details. *
  3351. * *
  3352. * You should have received a copy of the GNU General Public License *
  3353. * along with Mountyzilla; if not, write to the Free Software *
  3354. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3355. *********************************************************************************/
  3356.  
  3357. // x~x pre-enchant
  3358.  
  3359. /* 2013-08-19 : correction auto syntaxe alert */
  3360.  
  3361. var combobox=null;
  3362.  
  3363. function changeObject()
  3364. {
  3365. if(!combobox)
  3366. return ;
  3367. var id = combobox.options[combobox.selectedIndex].value;
  3368. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3369. if(!id || id=="")
  3370. {
  3371. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3372. return;
  3373. }
  3374. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3375. }
  3376.  
  3377. function treatePreEnchantement() {
  3378. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3379. if(!input || input.getAttribute("type")=="hidden")
  3380. {
  3381. return false;
  3382. }
  3383. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3384. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3385. if(!combobox)
  3386. {
  3387. return true;
  3388. }
  3389. combobox.addEventListener('change', changeObject, true);
  3390. return true;
  3391. }
  3392.  
  3393. function treateEnchantement() {
  3394. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3395. if(!input || input.getAttribute("type")!="hidden")
  3396. {
  3397. return false;
  3398. }
  3399. var idEquipement = input.getAttribute("value");
  3400. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3401. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3402. if(enchanteur && enchanteur != null)
  3403. return true;
  3404. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3405. if(!input || input.getAttribute("type")!="hidden")
  3406. {
  3407. return false;
  3408. }
  3409. var idEnchanteur = input.getAttribute("value");
  3410. var nodes = document.evaluate(
  3411. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3412. if (nodes.snapshotLength != 3)
  3413. return;
  3414. for(var i=0;i<3;i++)
  3415. {
  3416. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3417. texte = texte.replace(" d'une "," d'un ");
  3418. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3419. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3420. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3421. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3422. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3423. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3424. }
  3425. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3426. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3427. var liste = MY_getValue(numTroll+".enchantement.liste");
  3428. if(!liste || liste=="")
  3429. {
  3430. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3431. }
  3432. else
  3433. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3434. }
  3435.  
  3436. function do_pre_enchant() {
  3437. start_script(60);
  3438. if(!treatePreEnchantement())
  3439. treateEnchantement();
  3440. displayScriptTime();
  3441. }
  3442.  
  3443. /*********************************************************************************
  3444. * This file is part of Mountyzilla. *
  3445. * *
  3446. * Mountyzilla is free software; you can redistribute it and/or modify *
  3447. * it under the terms of the GNU General Public License as published by *
  3448. * the Free Software Foundation; either version 2 of the License, or *
  3449. * (at your option) any later version. *
  3450. * *
  3451. * Mountyzilla is distributed in the hope that it will be useful, *
  3452. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3453. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3454. * GNU General Public License for more details. *
  3455. * *
  3456. * You should have received a copy of the GNU General Public License *
  3457. * along with Mountyzilla; if not, write to the Free Software *
  3458. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3459. *********************************************************************************/
  3460.  
  3461. // x~x enchant
  3462.  
  3463. /* 2013-08-19 : correction auto syntaxe alert */
  3464.  
  3465. function treateEnchantement() {
  3466. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3467. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3468. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3469. return;
  3470. var tab = infoEquipement.split(";");
  3471. if(tab.length<2)
  3472. return;
  3473. var idEquipement = tab[0];
  3474. var nomEquipement = tab[1];
  3475. for(var i=2;i<tab.length;i++)
  3476. nomEquipement += ";"+tab[i];
  3477. var nodes = document.evaluate(
  3478. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3479. if (nodes.snapshotLength != 3)
  3480. return;
  3481. for(var i=0;i<3;i++)
  3482. {
  3483. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3484. texte = texte.replace(" d'une "," d'un ");
  3485. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3486. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3487. monstre = monstre.replace(/ Géante?/,"");
  3488. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3489. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3490. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3491. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3492. }
  3493. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3494. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3495. var liste = MY_getValue(numTroll+".enchantement.liste");
  3496. if(!liste || liste=="")
  3497. {
  3498. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3499. }
  3500. else
  3501. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3502. }
  3503.  
  3504. function do_enchant() {
  3505. start_script(60);
  3506.  
  3507. treateEnchantement();
  3508. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3509. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3510. displayScriptTime();
  3511. }
  3512.  
  3513. /*********************************************************************************
  3514. * This file is part of Mountyzilla. *
  3515. * *
  3516. * Mountyzilla is free software; you can redistribute it and/or modify *
  3517. * it under the terms of the GNU General Public License as published by *
  3518. * the Free Software Foundation; either version 2 of the License, or *
  3519. * (at your option) any later version. *
  3520. * *
  3521. * Mountyzilla is distributed in the hope that it will be useful, *
  3522. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3523. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3524. * GNU General Public License for more details. *
  3525. * *
  3526. * You should have received a copy of the GNU General Public License *
  3527. * along with Mountyzilla; if not, write to the Free Software *
  3528. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3529. *********************************************************************************/
  3530.  
  3531. // x~x myevent
  3532.  
  3533. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3534. function do_myevent() {
  3535. }
  3536.  
  3537. /*********************************************************************************
  3538. * This file is part of Mountyzilla. *
  3539. * *
  3540. * Mountyzilla is free software; you can redistribute it and/or modify *
  3541. * it under the terms of the GNU General Public License as published by *
  3542. * the Free Software Foundation; either version 2 of the License, or *
  3543. * (at your option) any later version. *
  3544. * *
  3545. * Mountyzilla is distributed in the hope that it will be useful, *
  3546. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3547. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3548. * GNU General Public License for more details. *
  3549. * *
  3550. * You should have received a copy of the GNU General Public License *
  3551. * along with Mountyzilla; if not, write to the Free Software *
  3552. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3553. *********************************************************************************/
  3554.  
  3555. // x~x malus
  3556.  
  3557. /* v1.4 - 2014-01-06
  3558. * - Gestion des sorts double composante
  3559. * v1.4.1 - 2014-01-22
  3560. * - Correction décumul
  3561. * TODO
  3562. * - Identifier la position de "PV" dans l'ordre MH
  3563. */
  3564.  
  3565. var listeBM;
  3566.  
  3567.  
  3568. /* [functions] Utilitaires */
  3569.  
  3570. function decumul(bmt,nbr) {
  3571. var bmr;
  3572. if(!nbr || nbr<2) bmr = bmt;
  3573. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3574. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3575. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3576. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3577. else bmr = parseInt(0.1*bmt);
  3578. if(bmt<0) return Math.min(-1,bmr);
  3579. return Math.max(1,bmr);
  3580. }
  3581.  
  3582. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3583. // Roule 23/11/2016 ajout PV
  3584. switch( a ) {
  3585. case 'ATT':
  3586. return -1;
  3587. case 'ESQ':
  3588. if(b=='ATT') return 1;
  3589. return -1;
  3590. case 'DEG':
  3591. switch( b ) {
  3592. case 'ATT':
  3593. case 'ESQ':
  3594. return 1;
  3595. default:
  3596. return -1;
  3597. }
  3598. case 'REG':
  3599. switch( b ) {
  3600. case 'ATT':
  3601. case 'ESQ':
  3602. case 'DEG':
  3603. return 1;
  3604. default:
  3605. return -1;
  3606. }
  3607. case 'Vue':
  3608. switch( b ) {
  3609. case 'ATT':
  3610. case 'ESQ':
  3611. case 'DEG':
  3612. case 'REG':
  3613. return 1;
  3614. default:
  3615. return -1;
  3616. }
  3617. case 'TOUR':
  3618. switch( b ) {
  3619. case 'ATT':
  3620. case 'ESQ':
  3621. case 'DEG':
  3622. case 'REG':
  3623. case 'Vue':
  3624. return 1;
  3625. default:
  3626. return -1;
  3627. }
  3628. case 'PV':
  3629. switch( b ) {
  3630. case 'ATT':
  3631. case 'ESQ':
  3632. case 'DEG':
  3633. case 'REG':
  3634. case 'Vue':
  3635. case 'TOUR':
  3636. return 1;
  3637. default:
  3638. return -1;
  3639. }
  3640. case 'Armure':
  3641. switch( b ) {
  3642. case 'ATT':
  3643. case 'ESQ':
  3644. case 'DEG':
  3645. case 'REG':
  3646. case 'Vue':
  3647. case 'TOUR':
  3648. case 'PV':
  3649. return 1;
  3650. default:
  3651. return -1;
  3652. }
  3653. case 'RM':
  3654. switch( b ) {
  3655. case 'ATT':
  3656. case 'ESQ':
  3657. case 'DEG':
  3658. case 'REG':
  3659. case 'Vue':
  3660. case 'TOUR':
  3661. case 'PV':
  3662. case 'Armure':
  3663. return 1;
  3664. default:
  3665. return -1;
  3666. }
  3667. case 'MM':
  3668. switch( b ) {
  3669. case 'ATT':
  3670. case 'ESQ':
  3671. case 'DEG':
  3672. case 'REG':
  3673. case 'Vue':
  3674. case 'TOUR':
  3675. case 'PV':
  3676. case 'Armure':
  3677. case 'RM':
  3678. return 1;
  3679. default:
  3680. return -1;
  3681. }
  3682. case 'Concentration':
  3683. switch( b ) {
  3684. case 'ATT':
  3685. case 'ESQ':
  3686. case 'DEG':
  3687. case 'REG':
  3688. case 'Vue':
  3689. case 'TOUR':
  3690. case 'PV':
  3691. case 'Armure':
  3692. case 'RM':
  3693. case 'MM':
  3694. return 1;
  3695. default:
  3696. return -1;
  3697. }
  3698. case 'Fatigue':
  3699. switch( b ) {
  3700. case 'ATT':
  3701. case 'ESQ':
  3702. case 'DEG':
  3703. case 'REG':
  3704. case 'Vue':
  3705. case 'TOUR':
  3706. case 'PV':
  3707. case 'Armure':
  3708. case 'RM':
  3709. case 'MM':
  3710. case 'Concentration':
  3711. return 1;
  3712. default:
  3713. return -1;
  3714. }
  3715. case "Dés d'attaque":
  3716. switch( b ) {
  3717. case 'ATT':
  3718. case 'ESQ':
  3719. case 'DEG':
  3720. case 'REG':
  3721. case 'Vue':
  3722. case 'TOUR':
  3723. case 'PV':
  3724. case 'Armure':
  3725. case 'RM':
  3726. case 'MM':
  3727. case 'Concentration':
  3728. case 'Fatigue':
  3729. return 1;
  3730. default:
  3731. return -1;
  3732. }
  3733. case 'Dés de dégâts':
  3734. switch( b ) {
  3735. case 'ATT':
  3736. case 'ESQ':
  3737. case 'DEG':
  3738. case 'REG':
  3739. case 'Vue':
  3740. case 'TOUR':
  3741. case 'PV':
  3742. case 'Armure':
  3743. case 'RM':
  3744. case 'MM':
  3745. case 'Concentration':
  3746. case 'Fatigue':
  3747. case "Dés d'attaque":
  3748. return 1;
  3749. default:
  3750. return -1;
  3751. }
  3752. default :
  3753. switch( b ) {
  3754. case 'ATT':
  3755. case 'ESQ':
  3756. case 'DEG':
  3757. case 'REG':
  3758. case 'Vue':
  3759. case 'TOUR':
  3760. case 'PV':
  3761. case 'Armure':
  3762. case 'RM':
  3763. case 'MM':
  3764. case 'Concentration':
  3765. case 'Fatigue':
  3766. case "Dés d'attaque":
  3767. case 'Dés de dégâts':
  3768. return 1;
  3769. default:
  3770. return -1;
  3771. }
  3772. }
  3773. }
  3774.  
  3775.  
  3776. /* [functions] Fonctions hide / display */
  3777.  
  3778. function toggleDetailsBM() {
  3779. if(MY_getValue('BMDETAIL')!='false') {
  3780. MY_setValue('BMDETAIL','false');
  3781. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3782. for(var i=0 ; i<trlist.length ; i++)
  3783. trlist[i].style.display = 'none';
  3784. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3785. for(var i=0 ; i<trlist.length ; i++)
  3786. trlist[i].style = '';
  3787. }
  3788. else {
  3789. MY_setValue('BMDETAIL','true');
  3790. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3791. for(var i=0 ; i<trlist.length ; i++)
  3792. trlist[i].style.display = 'none';
  3793. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3794. for(var i=0 ; i<trlist.length ; i++)
  3795. trlist[i].style = '';
  3796. }
  3797. }
  3798.  
  3799. function toggleBMList() {
  3800. if(MY_getValue('BMHIDELIST')=='true') {
  3801. MY_setValue('BMHIDELIST','false');
  3802. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3803. listeBM.snapshotItem(i).style = '';
  3804. document.getElementsByTagName('thead')[0].style = '';
  3805. document.getElementById('trhelp').style = '';
  3806. }
  3807. else {
  3808. MY_setValue('BMHIDELIST','true');
  3809. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3810. listeBM.snapshotItem(i).style.display = 'none';
  3811. document.getElementsByTagName('thead')[0].style.display = 'none';
  3812. document.getElementById('trhelp').style.display = 'none';
  3813. }
  3814. }
  3815.  
  3816. function setDisplayBM() {
  3817. if(!listeBM) return;
  3818. var titre = document.getElementById('titre2');
  3819. if(titre) {
  3820. titre.style.cursor = 'pointer';
  3821. titre.onclick = toggleBMList;
  3822. }
  3823. var tfoot = document.getElementsByTagName('tfoot')[0];
  3824. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3825. tfoot, null, 9, null).singleNodeValue;
  3826. tr.id = 'trhelp';
  3827. if(MY_getValue('BMHIDELIST')=='true') {
  3828. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3829. listeBM.snapshotItem(i).style.display = 'none';
  3830. document.getElementsByTagName('thead')[0].style.display = 'none';
  3831. tr.style.display = 'none';
  3832. }
  3833. }
  3834.  
  3835.  
  3836. /* [functions] Fonction principale */
  3837.  
  3838. function traiteMalus() {
  3839. var mainTab = document.getElementsByTagName('table')[0];
  3840. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3841. if(listeBM.snapshotLength==0) return;
  3842. /* Suppression des BM de fatigue stockés */
  3843. if(MY_getValue(numTroll+'.bm.fatigue'))
  3844. MY_removeValue(numTroll+'.bm.fatigue');
  3845. /* Extraction des données */
  3846. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3847. var nb = 0;
  3848. while(nb<listeBM.snapshotLength) {
  3849. tr = listeBM.snapshotItem(nb); nb++;
  3850. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3851. var phymag = tr.childNodes[9].textContent;
  3852. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3853. var type = tr.childNodes[3].textContent, nom;
  3854. // si c'est un type à décumul
  3855. /*
  3856. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3857. switch(type) {
  3858. case 'Potion':
  3859. case 'Parchemin':
  3860. case 'Sortilège':
  3861. case 'Capacité Spéciale':
  3862. nom = tr.childNodes[1].textContent+phymag;
  3863. break;
  3864. default:
  3865. nom = 'pasdedecumul';
  3866. }
  3867. */
  3868. nom = tr.childNodes[1].textContent+phymag;
  3869. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3870. nom = 'pasdedecumul';
  3871. uniListe[nb] = {
  3872. 'duree':duree,
  3873. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3874. 'caracs':{}
  3875. }
  3876. for(var i=0 ; i<effetsT.length ; i++) {
  3877. if(effetsT[i].indexOf(':')==-1) continue;
  3878. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3879. // nom = 'pasdedecumul' si pas de décumul
  3880. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3881. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3882. uniListe[nb]['type'] = phymag;
  3883. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3884. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  3885. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  3886. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  3887. uniListe[nb]['caracs'][carac] = bm;
  3888. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  3889. listeDurees[duree] = true;
  3890. }
  3891. } // fin boucle sur les lignes de bonus/malus
  3892. /* Gestion des décumuls et cumuls des durées */
  3893. var toursGeres = [];
  3894. for(var d in listeDurees) toursGeres.push(d);
  3895. toursGeres.sort( function (a,b){return b-a;} );
  3896. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  3897. // pour sauvegarder les bm de fatigue
  3898. var strfat = '';
  3899. // Pour affichage & adpatation à footable.js (statique)
  3900. var thead = document.getElementsByTagName('thead')[0];
  3901. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3902. thead, null, 7, null).snapshotLength;
  3903. var tfoot = document.getElementsByTagName('tfoot')[0];
  3904. for(var i=0 ; i<toursGeres.length ; i++) {
  3905. var tour = toursGeres[i];
  3906. var effetsCeTour = {}; decumulsCeTour = {};
  3907. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3908. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3909. continue;
  3910. var nom = uniListe[nb]['nom'];
  3911. if(nom!='pasdedecumul') {
  3912. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3913. decumulsCeTour[nom]++;
  3914. }
  3915. for(var carac in uniListe[nb]['caracs']) {
  3916. var bm = uniListe[nb]['caracs'][carac];
  3917. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3918. var type = uniListe[nb]['type'];
  3919. if(!effetsCeTour[carac])
  3920. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3921. var thisBm;
  3922. if(nom=='pasdedecumul')
  3923. thisBm = bm;
  3924. else
  3925. thisBm = decumul(bm,decumulsCeTour[nom]);
  3926. effetsCeTour[carac][type] += thisBm;
  3927. 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]);
  3928. } else {
  3929. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3930. var thisBm;
  3931. if(nom=='pasdedecumul' || carac=='Fatigue')
  3932. thisBm = bm;
  3933. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3934. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3935. else
  3936. thisBm = decumul(bm,decumulsCeTour[nom]);
  3937. effetsCeTour[carac] += thisBm;
  3938. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3939. }
  3940. } // fin boucle sur les caractéristiques
  3941. } // fin boucle sur les bonus/malus
  3942. /* Création du bilan du tour */
  3943. var texteD = '', texteS = '';
  3944. var caracGerees = [];
  3945. for(var k in effetsCeTour) caracGerees.push(k);
  3946. caracGerees.sort( triecaracs );
  3947. for(var j=0 ; j<caracGerees.length ; j++) {
  3948. var carac = caracGerees[j], str = '';
  3949. switch( carac ) {
  3950. case 'ATT':
  3951. case 'DEG':
  3952. case 'Armure':
  3953. var phy = effetsCeTour[carac]['Physique'];
  3954. var mag = effetsCeTour[carac]['Magie'];
  3955. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3956. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3957. break;
  3958. case 'TOUR':
  3959. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3960. break;
  3961. case 'Fatigue':
  3962. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3963. case 'PV':
  3964. case 'ESQ':
  3965. case 'REG':
  3966. case 'Vue':
  3967. case 'Voir le Caché':
  3968. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3969. break;
  3970. default:
  3971. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3972. }
  3973. if(str) {
  3974. texteD += str;
  3975. texteS += str;
  3976. }
  3977. } // fin boucle sur les caractéristiques
  3978. /* Affichage */
  3979. // Si rien à afficher on passe
  3980. if(!texteD) continue;
  3981. // Si BMM+BMP=0
  3982. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3983. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3984. if(MY_getValue('BMDETAIL')=='false')
  3985. tr.style.display = 'none';
  3986. var td = appendTdText(tr,texteD.substring(3));
  3987. td.colSpan = 5-nbHidden;
  3988. var txttour = toursGeres[i]+' Tour';
  3989. if(toursGeres[i]>1) txttour += 's';
  3990. appendTdText(tr,txttour);
  3991. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3992. if(MY_getValue('BMDETAIL')!='false')
  3993. tr.style.display = 'none';
  3994. td = appendTdText(tr,texteS);
  3995. td.colSpan = 5-nbHidden;
  3996. appendTdText(tr,txttour);
  3997. } // fin boucle sur les tours générés
  3998. /* mise en place toggleDetails */
  3999. tfoot.style.cursor = 'pointer';
  4000. tfoot.onclick = toggleDetailsBM;
  4001. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4002. if(strfat)
  4003. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4004. }
  4005.  
  4006. function do_malus() {
  4007. try {
  4008. start_script();
  4009. traiteMalus();
  4010. setDisplayBM();
  4011. displayScriptTime();
  4012. }
  4013. catch(e) {window.alert(e)};
  4014. }
  4015.  
  4016. /*******************************************************************************
  4017. * This file is part of Mountyzilla. *
  4018. * *
  4019. * Mountyzilla is free software; you can redistribute it and/or modify *
  4020. * it under the terms of the GNU General Public License as published by *
  4021. * the Free Software Foundation; either version 2 of the License, or *
  4022. * (at your option) any later version. *
  4023. * *
  4024. * Mountyzilla is distributed in the hope that it will be useful, *
  4025. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4026. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4027. * GNU General Public License for more details. *
  4028. * *
  4029. * You should have received a copy of the GNU General Public License *
  4030. * along with Mountyzilla; if not, write to the Free Software *
  4031. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4032. *******************************************************************************/
  4033.  
  4034. // x~x mouches
  4035.  
  4036. var mainTab, tr_mouches;
  4037.  
  4038. function initialiseMouches() {
  4039. // Lanceur global
  4040. try {
  4041. mainTab = document.getElementById('mouches');
  4042. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4043. } catch(e) {
  4044. avertissement('Erreur MZ:<br />Consulter la console.');
  4045. window.console.error(traceStack(e, 'mouches'));
  4046. return;
  4047. }
  4048. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4049. setDisplayMouches();
  4050. traiteMouches();
  4051. }
  4052.  
  4053. function setDisplayMouches() {
  4054. // Initialise l'affichage / l'effacement du détail des mouches
  4055. var titre = document.getElementById('titre2');
  4056. if(titre) {
  4057. titre.style.cursor = 'pointer';
  4058. titre.onclick = toggleMouches;
  4059. }
  4060. var tfoot = document.getElementsByTagName('tfoot')[0];
  4061. if(tfoot) {
  4062. tfoot.style.cursor = 'pointer';
  4063. tfoot.onclick = toggleMouches;
  4064. }
  4065. if(MY_getValue('HIDEMOUCHES')=='true') {
  4066. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4067. tr_mouches.snapshotItem(i).style.display = 'none';
  4068. }
  4069. document.getElementsByTagName('thead')[0].style.display = 'none';
  4070. }
  4071. }
  4072.  
  4073. function toggleMouches() {
  4074. // Handler pour afficher / masquer les détasil
  4075. if(MY_getValue('HIDEMOUCHES')=='true') {
  4076. MY_setValue('HIDEMOUCHES','false');
  4077. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4078. tr_mouches.snapshotItem(i).style.display = '';
  4079. }
  4080. document.getElementsByTagName('thead')[0].style.display = '';
  4081. } else {
  4082. MY_setValue('HIDEMOUCHES','true');
  4083. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4084. tr_mouches.snapshotItem(i).style.display = 'none';
  4085. }
  4086. document.getElementsByTagName('thead')[0].style.display = 'none';
  4087. }
  4088. }
  4089.  
  4090. function traiteMouches() {
  4091. // Traitement complet: présence et effets des mouches
  4092. var listeTypes = {}, effetsActifs = {};
  4093. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4094. var tr = tr_mouches.snapshotItem(i);
  4095. // La mouche est-elle présente?
  4096. var etat = document.evaluate(
  4097. './img',
  4098. tr.cells[6], null, 9, null
  4099. ).singleNodeValue.alt;
  4100. if(etat!='La Mouche est là') { continue; }
  4101. // Extraction du type de mouche
  4102. var type = trim(tr.cells[3].textContent);
  4103. if(!listeTypes[type]) {
  4104. listeTypes[type] = 1;
  4105. } else {
  4106. listeTypes[type]++;
  4107. }
  4108. // La mouche a-t-elle un effet?
  4109. var effet = trim(tr.cells[2].textContent);
  4110. if(etat!='La Mouche est là' || !effet) { continue; }
  4111. // Si oui, extraction des effets (multiples pour pogées)
  4112. var caracs = effet.split(' | ');
  4113. for(var j=0 ; j<caracs.length ; j++) {
  4114. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4115. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4116. if(effetsActifs[carac]===void(0)) {
  4117. effetsActifs[carac] = valeur;
  4118. } else {
  4119. effetsActifs[carac] += valeur;
  4120. }
  4121. }
  4122. }
  4123. // Extraction Effet total et affichage des différences à la normale
  4124. var tfoot = document.getElementsByTagName('tfoot')[0];
  4125. if(!tfoot) { return; }
  4126. var nodeTotal = document.evaluate(
  4127. ".//b[contains(./text(),'Effet total')]",
  4128. tfoot, null, 9, null
  4129. ).singleNodeValue.nextSibling;
  4130. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4131. var texte = ' ';
  4132. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4133. if(texte.length>1) { texte += ' | '; }
  4134. var carac = trim(
  4135. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4136. );
  4137. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4138. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4139. texte += effetsTheoriques[i];
  4140. } else {
  4141. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4142. if(carac=='TOUR') { texte += ' min'; }
  4143. texte += '</b>';
  4144. }
  4145. }
  4146. var span = document.createElement('span');
  4147. span.innerHTML = texte;
  4148. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4149. // Affichage des différences du nombre de mouches de chaque type
  4150. var mouchesParType = document.evaluate(
  4151. "./tr/td/ul/li/text()",
  4152. tfoot, null, 7, null
  4153. );
  4154. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4155. var node = mouchesParType.snapshotItem(i);
  4156. var mots = node.nodeValue.split(' ');
  4157. var type = mots.pop();
  4158. if(!listeTypes[type]) {
  4159. node.nodeValue += ' (0 présente)';
  4160. } else if(mots[0]!=listeTypes[type]) {
  4161. if(listeTypes[type]==1) {
  4162. node.nodeValue += ' (1 présente)';
  4163. } else {
  4164. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4165. }
  4166. }
  4167. }
  4168. }
  4169.  
  4170. function do_mouches() {
  4171. start_script();
  4172. initialiseMouches();
  4173. displayScriptTime();
  4174. }
  4175.  
  4176. /*********************************************************************************
  4177. * This file is part of Mountyzilla. *
  4178. * *
  4179. * Mountyzilla is free software; you can redistribute it and/or modify *
  4180. * it under the terms of the GNU General Public License as published by *
  4181. * the Free Software Foundation; either version 2 of the License, or *
  4182. * (at your option) any later version. *
  4183. * *
  4184. * Mountyzilla is distributed in the hope that it will be useful, *
  4185. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4186. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4187. * GNU General Public License for more details. *
  4188. * *
  4189. * You should have received a copy of the GNU General Public License *
  4190. * along with Mountyzilla; if not, write to the Free Software *
  4191. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4192. *********************************************************************************/
  4193.  
  4194. // x~x equipgowap
  4195.  
  4196. var popup;
  4197.  
  4198. function initPopupEquipgowap() {
  4199. popup = document.createElement('div');
  4200. popup.setAttribute('id', 'popup');
  4201. popup.setAttribute('class', 'mh_textbox');
  4202. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4203. 'display: inline; z-index: 3; max-width: 400px;');
  4204. document.body.appendChild(popup);
  4205. }
  4206.  
  4207. function showPopupEquipgowap(evt) {
  4208. var texte = this.getAttribute("texteinfo");
  4209. popup.innerHTML = texte;
  4210. popup.style.left = evt.pageX + 15 + 'px';
  4211. popup.style.top = evt.pageY + 'px';
  4212. popup.style.visibility = "visible";
  4213. }
  4214.  
  4215. function hidePopup() {
  4216. popup.style.visibility = "hidden";
  4217. }
  4218.  
  4219. function createPopupImage(url, text)
  4220. {
  4221. var img = document.createElement('img');
  4222. img.setAttribute('src',url);
  4223. img.setAttribute('align','ABSMIDDLE');
  4224. img.setAttribute("texteinfo",text);
  4225. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4226. img.addEventListener("mouseout", hidePopup,true);
  4227. return img;
  4228. }
  4229.  
  4230. function formateTexte(texte)
  4231. {
  4232. texte = texte.replace(/\n/g,"<br/>");
  4233. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4234. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4235. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4236. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4237. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4238. return texte;
  4239. }
  4240.  
  4241.  
  4242. function treateGowaps() {
  4243. //On récupère les gowaps possédants des composants
  4244. var tbodys = document.evaluate(
  4245. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4246. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4247. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4248. var tbody = tbodys.snapshotItem(j);
  4249. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4250. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4251. if(MY_getValue("NOINFOEM") != "true")
  4252. insertEMInfos(tbody);
  4253. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4254. insertEnchantInfos(tbody);
  4255. }
  4256. }
  4257.  
  4258. function treateChampi() {
  4259. if(MY_getValue("NOINFOEM") == "true")
  4260. return false;
  4261. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4262. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4263. if (nodes.snapshotLength == 0)
  4264. return false;
  4265.  
  4266. for (var i = 0; i < nodes.snapshotLength; i++) {
  4267. var node = nodes.snapshotItem(i);
  4268. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4269. if(texte.indexOf("*")!=-1)
  4270. texte = texte.substring(0,texte.lastIndexOf(" "));
  4271. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4272. if(moisChampi[nomChampi])
  4273. {
  4274. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4275. }
  4276. }
  4277. }
  4278.  
  4279. function do_equipgowap() {
  4280. start_script();
  4281.  
  4282. treateGowaps();
  4283. treateChampi();
  4284. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4285. {
  4286. initPopupEquipgowap();
  4287. computeEnchantementEquipement(createPopupImage,formateTexte);
  4288. }
  4289.  
  4290. displayScriptTime();
  4291. }
  4292.  
  4293. /*********************************************************************************
  4294. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4295. *********************************************************************************/
  4296.  
  4297. // x~x ordresgowap
  4298.  
  4299. // version Roule' janvier 2017
  4300. function MZ_setCarteUnGogoHTML5() {
  4301. // fabriquer la liste des positions successives
  4302. var listeDepl = []; // ce sera un tableau d'objets
  4303. // position courrante
  4304. var eTitle = document.getElementById('titre2');
  4305. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4306. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4307. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4308. , y: parseInt(tabPos[1])
  4309. , n: parseInt(tabPos[2])
  4310. , nom: tabNomID[2]
  4311. , id: tabNomID[1]});
  4312. // déplacements
  4313. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4314. for(var i=0 ; i<lignes.length ; i++) {
  4315. if(lignes[i].className == 'mh_tdpage_fo') {
  4316. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4317. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4318. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4319. }
  4320. }
  4321. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4322. }
  4323.  
  4324. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4325. function MZ_showCarteBottom(listeSuiv) {
  4326. // générer la carte
  4327. var carte = new carte_MZ('cartegogo', listeSuiv);
  4328. // positionner la carte
  4329. var eCarte = carte.getElt();
  4330. eCarte.style.textAlign = 'left';
  4331. eCarte.style.marginTop = '2px';
  4332. var footer = document.getElementById('footer1');
  4333. // Lieu_Teleport.php n'a pas de footer1 :(
  4334. if (!footer) footer = document.getElementById('footer2');
  4335. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4336. else document.body.appendChild(eCarte);
  4337. }
  4338.  
  4339. function MZ_setCarteTousGogoHTML5() {
  4340. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4341. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4342. var suivants = [];
  4343. for (var i=0;i<ligne.length;i++) {
  4344. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4345. var cas = ligne[i].getElementsByTagName("td")[0];
  4346. //if (cas.className == "mh_tdtitre") {
  4347. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4348. var oGogo = {};
  4349. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4350. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4351. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4352. oGogo.x = parseInt(point[1]);
  4353. oGogo.y = parseInt(point[2]);
  4354. oGogo.n = parseInt(point[3]);
  4355. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4356. }
  4357. }
  4358. if (suivants.length == 0) return;
  4359. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4360. }
  4361.  
  4362. function MZ_setCarteTP() {
  4363. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4364. 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);
  4365. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4366. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4367. }
  4368.  
  4369. /* v0.2 by Dab - 2013-08-31
  4370. * - correction acquisition posale initiale
  4371. * - correction tare et affichage mire
  4372. */
  4373.  
  4374. function setCarteGogo() {
  4375. try {
  4376. //var pars = document.getElementsByTagName('p');
  4377. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4378. var eTitle = document.getElementById('titre2');
  4379. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4380. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4381. var serv_img_cible = URL_MZimg + "rep.png";
  4382.  
  4383. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4384. //var lignes = pars[0].getElementsByTagName('tr');
  4385. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4386. var nbpt = 0;
  4387. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4388. for(var i=0 ; i<lignes.length ; i++) {
  4389. if(lignes[i].className == 'mh_tdpage_fo') {
  4390. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4391. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4392. if(point) {
  4393. nbpt++;
  4394. trajet += point[1]+','+point[2]+','+point[3]+',';
  4395. }
  4396. }
  4397. }
  4398. }
  4399. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4400. 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'/>";
  4401. var base = [-229,-5];
  4402. if (nbpt>0) {
  4403. base = [-684,-5];
  4404. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4405. }
  4406. 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;'/>";
  4407.  
  4408. 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>';
  4409.  
  4410. var nvspan = document.createElement('div');
  4411. nvspan.align = 'center';
  4412. nvspan.id = 'mz_mapdiv';
  4413. nvspan.valign = 'top';
  4414. nvspan.innerHTML = nvdiv;
  4415. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4416. var footer = document.getElementById('footer1');
  4417. footer.parentNode.insertBefore(nvspan,footer);
  4418. }
  4419.  
  4420. function testeGlissiere() {
  4421. try {
  4422. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4423. var footer = document.getElementById('footer1');
  4424. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4425. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4426. }
  4427.  
  4428. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4429. if (x0 !== undefined) {
  4430. // ouais, récursif une fois
  4431. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4432. if (PtInterm === undefined)
  4433. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4434. else
  4435. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4436. return;
  4437. }
  4438. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4439. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4440. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4441. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4442. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4443. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4444. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4445. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4446. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4447. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4448. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4449. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4450. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4451. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4452. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4453. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4454. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4455. }
  4456.  
  4457. function do_ordresgowap() {
  4458. if (newCarte) {
  4459. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4460. //testeGlissiere();
  4461. //MZ_testsUnitairesCalculIntermediaire();
  4462. } else {
  4463. setCarteGogo(); // Via script des trouillots
  4464. }
  4465. }
  4466.  
  4467. function do_listegowap() {
  4468. if (!newCarte) return;
  4469. MZ_setCarteTousGogoHTML5();
  4470. }
  4471.  
  4472. function do_lieuDescription() {
  4473. if (!newCarte) return;
  4474. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4475. MZ_setCarteTP();
  4476. }
  4477.  
  4478. function do_lieuTeleport() {
  4479. changeButtonValidate();
  4480. if (!newCarte) return;
  4481. MZ_setCarteTP();
  4482. }
  4483.  
  4484. /*********************************************************************************
  4485. * This file is part of Mountyzilla. *
  4486. * *
  4487. * Mountyzilla is free software; you can redistribute it and/or modify *
  4488. * it under the terms of the GNU General Public License as published by *
  4489. * the Free Software Foundation; either version 2 of the License, or *
  4490. * (at your option) any later version. *
  4491. * *
  4492. * Mountyzilla is distributed in the hope that it will be useful, *
  4493. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4494. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4495. * GNU General Public License for more details. *
  4496. * *
  4497. * You should have received a copy of the GNU General Public License *
  4498. * along with Mountyzilla; if not, write to the Free Software *
  4499. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4500. *********************************************************************************/
  4501.  
  4502. // x~x attaque
  4503.  
  4504. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4505.  
  4506. function do_attaque() {
  4507. }
  4508.  
  4509. /*******************************************************************************
  4510. * This file is part of Mountyzilla. *
  4511. * *
  4512. * Mountyzilla is free software; you can redistribute it and/or modify *
  4513. * it under the terms of the GNU General Public License as published by *
  4514. * the Free Software Foundation; either version 2 of the License, or *
  4515. * (at your option) any later version. *
  4516. * *
  4517. * Mountyzilla is distributed in the hope that it will be useful, *
  4518. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4519. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4520. * GNU General Public License for more details. *
  4521. * *
  4522. * You should have received a copy of the GNU General Public License *
  4523. * along with Mountyzilla; if not, write to the Free Software *
  4524. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4525. *******************************************************************************/
  4526.  
  4527. // x~x infomonstre
  4528.  
  4529. // DEBUG
  4530. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4531. // À corriger, évidemment.
  4532. var listeCDM = {};
  4533. var nomMonstre='';
  4534. var idMonstre=-1;
  4535. var tbody;
  4536. var popup;
  4537.  
  4538. function traiteMonstre() {
  4539. try {
  4540. var nodeTitre = document.evaluate(
  4541. "//div[@class='titre2' and contains(text(),'(')]",
  4542. document, null, 9, null
  4543. ).singleNodeValue;
  4544. var texte = nodeTitre.firstChild.nodeValue;
  4545. } catch(e) {
  4546. window.console.log(traceStack(e, 'traiteMonstre'));
  4547. return;
  4548. }
  4549. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4550. if(nomMonstre.indexOf(']')!=-1) {
  4551. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4552. }
  4553. idMonstre = texte.match(/\d+/)[0];
  4554. FF_XMLHttpRequest({
  4555. method: 'GET',
  4556. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4557. +MY_getValue('CDMID')
  4558. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4559. headers : {
  4560. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4561. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4562. },
  4563. trace: 'info monstre ' + nomMonstre,
  4564. onload: function(responseDetails) {
  4565. try {
  4566. var texte = responseDetails.responseText;
  4567. var lines = texte.split("\n");
  4568. if(lines.length>=1) {
  4569. var infos = lines[0].split(";");
  4570. if(infos.length<4) { return; }
  4571. var idMonstre = infos[0];
  4572. infos=infos.slice(3);
  4573. listeCDM[idMonstre]=infos;
  4574. computeMissionInfomonstre();
  4575. }
  4576. } catch(e) {
  4577. window.alert(e);
  4578. }
  4579. }
  4580. });
  4581. }
  4582.  
  4583. function initPopupInfomonstre() {
  4584. // Initialise le popup tactique (calculs att/deg)
  4585. popup = document.createElement('div');
  4586. popup.id = 'popup';
  4587. popup.className = 'mh_textbox';
  4588. popup.style =
  4589. 'position: absolute;'+
  4590. 'border: 1px solid #000000;'+
  4591. 'visibility: hidden;'+
  4592. 'display: inline;'+
  4593. 'z-index: 3;'+
  4594. 'max-width: 400px;';
  4595. document.body.appendChild(popup);
  4596. }
  4597.  
  4598. function showPopupTactique(evt) {
  4599. try {
  4600. var id = this.id;
  4601. var nom = this.nom;
  4602. var texte = getAnalyseTactique(id,nom);
  4603. if(texte=='') { return; }
  4604. popup.innerHTML = texte;
  4605. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4606. if(isPage("View/MonsterView")) {
  4607. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4608. } else {
  4609. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4610. }
  4611. popup.style.top = evt.pageY+15+'px';
  4612. popup.style.visibility = 'visible';
  4613. } catch(e) {
  4614. window.alert(e);
  4615. }
  4616. }
  4617.  
  4618. // roule 16/03/2016, existe déjà ailleurs
  4619. // function hidePopup() {
  4620. // popup.style.visibility = 'hidden';
  4621. // }
  4622.  
  4623. function toggleTableau() {
  4624. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4625. }
  4626.  
  4627. function computeMissionInfomonstre() {
  4628. // C'est quoi ce titre de fonction ? (O_o)
  4629. try {
  4630. var nodeInsert = document.evaluate(
  4631. "//div[@class = 'titre3']",
  4632. document, null, 9, null
  4633. ).singleNodeValue;
  4634. } catch(e) {
  4635. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4636. return;
  4637. }
  4638. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4639. table.align = 'center';
  4640. tbody = table.childNodes[1];
  4641. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4642. table.firstChild.firstChild.onmouseover = function() {
  4643. this.style.cursor = 'pointer';
  4644. this.className = 'mh_tdpage';
  4645. };
  4646. table.firstChild.firstChild.onmouseout = function() {
  4647. this.className = 'mh_tdtitre';
  4648. };
  4649. tbody.style.display = 'none';
  4650. table.style.width = '350px';
  4651. insertBefore(nodeInsert,table);
  4652. }
  4653.  
  4654. function do_infomonstre() {
  4655. start_script();
  4656. try {
  4657. initPopupInfomonstre();
  4658. traiteMonstre();
  4659. } catch(e) {
  4660. window.alert('Erreur infoMonstre:\n'+e);
  4661. }
  4662. displayScriptTime();
  4663. }
  4664.  
  4665. /*******************************************************************************
  4666. * This file is part of Mountyzilla. *
  4667. * *
  4668. * Mountyzilla is free software; you can redistribute it and/or modify *
  4669. * it under the terms of the GNU General Public License as published by *
  4670. * the Free Software Foundation; either version 2 of the License, or *
  4671. * (at your option) any later version. *
  4672. * *
  4673. * Mountyzilla is distributed in the hope that it will be useful, *
  4674. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4675. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4676. * GNU General Public License for more details. *
  4677. * *
  4678. * You should have received a copy of the GNU General Public License *
  4679. * along with Mountyzilla; if not, write to the Free Software *
  4680. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4681. *******************************************************************************/
  4682.  
  4683. // x~x mission
  4684.  
  4685. /* TODO
  4686. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  4687. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  4688. *
  4689. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  4690. */
  4691. function isArray(a) {
  4692. return (!!a) && (a.constructor === Array);
  4693. }
  4694.  
  4695. function saveMission(num,obEtape) {
  4696. var obMissions;
  4697. if(MY_getValue(numTroll+'.MISSIONS')) {
  4698. try {
  4699. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  4700. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  4701. } catch(e) {
  4702. window.console.error(traceStack(e, 'Mission parsage'));
  4703. return;
  4704. }
  4705. }
  4706. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  4707. if (obMissions == undefined) obMissions = new Object(); // protection
  4708. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  4709. if(obEtape) {
  4710. obMissions[num] = obEtape;
  4711. } else if(obMissions[num]) {
  4712. delete obMissions[num];
  4713. }
  4714. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  4715. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  4716. }
  4717.  
  4718. function addtroogle(tdLibelle, sRestrict) {
  4719. var img = document.createElement('img');
  4720. img.src = URL_MZimg + 'troogle.ico';
  4721. img.alt = 'Troogle logo';
  4722. var a = document.createElement('a');
  4723. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  4724. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  4725. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  4726. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  4727. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  4728. a.href = url;
  4729. a.title = 'Chercher sur Troogle';
  4730. a.target = 'troogle';
  4731. a.appendChild(img);
  4732. tdLibelle.appendChild(a);
  4733. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  4734. }
  4735.  
  4736. function traiteMission() {
  4737. try {
  4738. var titreMission = document.getElementsByClassName('titre2')[0];
  4739. var numMission = titreMission.textContent.match(/\d+/)[0];
  4740. var missionForm = document.getElementsByName('ActionForm')[0];
  4741. var tdLibelle = document.evaluate(
  4742. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  4743. missionForm, null, 9, null).singleNodeValue;
  4744. } catch(e) {
  4745. window.console.error(traceStack(e, 'récupération mission'));
  4746. return;
  4747. }
  4748. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  4749. try {
  4750. if(!tdLibelle) {
  4751. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  4752. debugMZ('traiteMission, la mission semble terminée');
  4753. saveMission(numMission,false);
  4754. return;
  4755. }
  4756.  
  4757. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4758. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4759. // debug Roule'
  4760. if (MY_DEBUG) {
  4761. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4762. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4763. }
  4764. if(libelle.indexOf('niveau égal à')!=-1) {
  4765. var nbKills = 1, niveau, mod;
  4766. // exemples :
  4767. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  4768. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  4769. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  4770. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  4771. if (tdLibelle.childNodes.length == 1) {
  4772. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  4773. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  4774. if (m) {
  4775. niveau = Number(m[1]);
  4776. mod = 'plus'
  4777. } else {
  4778. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  4779. if (m) {
  4780. niveau = Number(m[1]);
  4781. mod = Number(m[2]);
  4782. } else {
  4783. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  4784. return;
  4785. }
  4786. }
  4787. } else {
  4788. // ancienne méthode (multi childnode)
  4789. // à supprimer un jour peut-être
  4790. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4791. // Étape de kill multiple de niveau donné
  4792. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4793. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4794. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4795. niveau = Number(mod[0]);
  4796. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4797. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4798. } else {
  4799. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4800. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4801. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4802. mod = mod ? Number(mod[0]) : 'plus';
  4803. }
  4804. } else {
  4805. // Étape de kill unique de niveau donné
  4806. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4807. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4808. mod = mod ? Number(mod[0]) : 'plus';
  4809. }
  4810. }
  4811. // debug Roule'
  4812. if (MY_DEBUG) {
  4813. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4814. }
  4815. saveMission(numMission,{
  4816. type: 'Niveau',
  4817. niveau: niveau,
  4818. mod: mod,
  4819. mundidey: siMundidey,
  4820. libelle: libelle
  4821. });
  4822. if (mod == 'plus')
  4823. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4824. else
  4825. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4826. } else if(libelle.indexOf('de la race')!=-1) {
  4827. var nbKills = 1, race;
  4828. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4829. // Étape de kill multiple de race donnée
  4830. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4831. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4832. } else {
  4833. // Étape de kill unique de race donnée
  4834. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4835. }
  4836. race = race.replace(/\"/g,'');
  4837. saveMission(numMission,{
  4838. type: 'Race',
  4839. race: race,
  4840. mundidey: siMundidey,
  4841. libelle: libelle
  4842. });
  4843. addtroogle(tdLibelle, '@monstre ' + race);
  4844. } else if(libelle.indexOf('de la famille')!=-1) {
  4845. var nbKills = 1, famille;
  4846. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4847. // Étape de kill multiple de famille donnée
  4848. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4849. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4850. } else {
  4851. // Étape de kill unique de famille donnée
  4852. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4853. }
  4854. famille = famille.replace(/\"/g,'');
  4855. saveMission(numMission,{
  4856. type: 'Famille',
  4857. famille: famille,
  4858. mundidey: siMundidey,
  4859. libelle: libelle
  4860. });
  4861. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4862. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4863. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4864. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4865. debugMZ('traiteMission étape capacité spéciale');
  4866. saveMission(numMission,{
  4867. type: 'Pouvoir',
  4868. pouvoir: pouvoir,
  4869. libelle: libelle
  4870. });
  4871. } else {
  4872. debugMZ('traiteMission étape pas pour troogle');
  4873. saveMission(numMission,false);
  4874. }
  4875. } catch(e) {
  4876. window.console.error(traceStack(e, 'récupération étape mission'));
  4877. return;
  4878. }
  4879. }
  4880.  
  4881. function do_mission() {
  4882. start_script(60);
  4883.  
  4884. traiteMission();
  4885.  
  4886. displayScriptTime();
  4887. }
  4888.  
  4889. /*******************************************************************************
  4890. * This file is part of Mountyzilla. *
  4891. * *
  4892. * Mountyzilla is free software; you can redistribute it and/or modify *
  4893. * it under the terms of the GNU General Public License as published by *
  4894. * the Free Software Foundation; either version 2 of the License, or *
  4895. * (at your option) any later version. *
  4896. * *
  4897. * Mountyzilla is distributed in the hope that it will be useful, *
  4898. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4899. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4900. * GNU General Public License for more details. *
  4901. * *
  4902. * You should have received a copy of the GNU General Public License *
  4903. * along with Mountyzilla; if not, write to the Free Software *
  4904. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4905. *******************************************************************************/
  4906.  
  4907. // x~x move
  4908.  
  4909. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4910.  
  4911. var petitsTrous = {
  4912. '-52;57': true,
  4913. '55;70': true,
  4914. '64;70': true,
  4915. '12;-15': true,
  4916. '30;-52': true,
  4917. '48;-39': true
  4918. };
  4919.  
  4920. var grosTrous = {
  4921. '-35;65': true,
  4922. '-13;73': true,
  4923. '-64;9': true,
  4924. '-35;15': true,
  4925. '5;32': true,
  4926. '10;64': true,
  4927. '21;36': true,
  4928. '46;52': true,
  4929. '74;32': true,
  4930. '-71;-7': true,
  4931. '-67;-37': true,
  4932. '-60;-32': true,
  4933. '-51;-22': true,
  4934. '-36;-51': true,
  4935. '5;-49': true
  4936. };
  4937.  
  4938. var centreCarmine_X = 56.5;
  4939. var centreCarmine_Y = 23.5;
  4940. var rayonCarmine = 8.7;
  4941.  
  4942. function isTrou(x,y,n) {
  4943. if(petitsTrous[x+';'+y]) {
  4944. return n<0 && n>-60;
  4945. }
  4946. if(grosTrous[x+';'+y]
  4947. || grosTrous[x-1+';'+y]
  4948. || grosTrous[x+';'+y+1]
  4949. || grosTrous[x-1+';'+y+1]) {
  4950. return n<0 && n>-70;
  4951. }
  4952. if(Math.sqrt(
  4953. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4954. )<=rayonCarmine) {
  4955. return n<0 && n>-100;
  4956. }
  4957. return false;
  4958. }
  4959.  
  4960. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4961.  
  4962. function validateDestination() {
  4963. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4964. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4965. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4966. var form = document.getElementsByName('ActionForm')[0];
  4967. if(form) {
  4968. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4969. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4970. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4971. }
  4972. }
  4973. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4974. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4975. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4976. }
  4977. }
  4978. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4979. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4980. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4981. }
  4982. }
  4983. if(isTrou(x,y,n)) {
  4984. return window.confirm(
  4985. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4986. +'Vous allez tomber dans un trou de météorite.\n'
  4987. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4988. );
  4989. }
  4990. }
  4991. return true;
  4992. }
  4993.  
  4994. function newsubmitDE(event) {
  4995. event.stopPropagation();
  4996. event.preventDefault();
  4997. if(validateDestination()) {
  4998. this.submit();
  4999. }
  5000. }
  5001.  
  5002. function changeValidation() {
  5003. var form = document.getElementsByName('ActionForm')[0];
  5004. if(form) {
  5005. form.addEventListener('submit', newsubmitDE, true);
  5006. }
  5007. }
  5008.  
  5009.  
  5010. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  5011.  
  5012. function validateTPDestination() {
  5013. try {
  5014. var text = document.getElementsByTagName('B')[0];
  5015. var a = text.firstChild.nodeValue.split('|');
  5016. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  5017. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  5018. var pos_n = a[2].substring(5, a[2].length) * 1;
  5019.  
  5020. var nbtrous = 0;
  5021. for(var signX=-1 ; signX<=1 ; signX+=2) {
  5022. for(var x=0 ; x<=2 ; x++) {
  5023. for(var signY=-1 ; signY<=1 ; signY+=2) {
  5024. for(var y=0 ; y<=2 ; y++) {
  5025. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  5026. for(var n = 0 ; n <= 1 ; n++) {
  5027. if(isTrou(
  5028. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  5029. )) {
  5030. nbtrous++;
  5031. }
  5032. }
  5033. }
  5034. }
  5035. }
  5036. }
  5037. }
  5038. if(nbtrous>0 && nbtrous<72) {
  5039. return window.confirm(
  5040. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5041. +'Vous avez '+Math.floor((100*nbtrous)/144)
  5042. +'% de risque de tomber dans un trou de météorite.\n'
  5043. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  5044. );
  5045. }
  5046. else if(nbtrous>=72) {
  5047. return window.confirm(
  5048. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  5049. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  5050. +'% de risque de tomber dans un trou de météorite !\n'
  5051. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  5052. );
  5053. }
  5054. return true;
  5055. }
  5056. catch(e) {
  5057. window.alert(e)
  5058. }
  5059. }
  5060.  
  5061. function newsubmitTP(event) {
  5062. event.stopPropagation();
  5063. event.preventDefault();
  5064. if(validateTPDestination()) {
  5065. this.submit();
  5066. }
  5067. }
  5068.  
  5069. function changeButtonValidate() {
  5070. var form = document.getElementsByName('Formulaire')[0];
  5071. if(form) {
  5072. if(!form.getAttribute('onsubmit')) {
  5073. form.setAttribute('onsubmit','return true;');
  5074. }
  5075. form.addEventListener('submit', newsubmitTP, true);
  5076. }
  5077. }
  5078.  
  5079.  
  5080. /*-[functions]---------------- Partie Principale -----------------------------*/
  5081.  
  5082. function do_move() {
  5083. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  5084. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  5085. changeValidation();
  5086. //}
  5087. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  5088. // changeButtonValidate();
  5089. //}
  5090. }
  5091.  
  5092. /*******************************************************************************
  5093. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  5094. * Mountyzilla is free software; provided under the GNU General Public License *
  5095. *******************************************************************************/
  5096.  
  5097. // x~x news
  5098.  
  5099. // Nombre de news à afficher & nb max de caractères par news:
  5100. const nbItems = 5;
  5101. const maxCarDescription = 300;
  5102.  
  5103. /*-[functions]------------------- Utilitaires --------------------------------*/
  5104.  
  5105. // Ne semble avoir strictement aucun effet:
  5106. String.prototype.epureDescription = function() {
  5107. return this.replace(/\\(.)/g,"$1");
  5108. }
  5109.  
  5110. function appendTitledTable(node,titre,description) {
  5111. // Crée les tables contenant les infos (avec titre)
  5112. var table = document.createElement('table');
  5113. table.border = 0;
  5114. table.className = 'mh_tdborder';
  5115. table.cellSpacing = 1;
  5116. table.cellPadding = 1;
  5117. table.style.maxWidth = '98%';
  5118. table.style.marginLeft = 'auto';
  5119. table.style.marginRight = 'auto';
  5120. var tbody = document.createElement('tbody');
  5121. table.appendChild(tbody);
  5122. var tr = appendTr(tbody,'mh_tdtitre');
  5123. var td = appendTdCenter(tr,2);
  5124. var span = document.createElement('span');
  5125. appendText(span,titre,true);
  5126. if(description) {
  5127. span.title = description;
  5128. }
  5129. td.appendChild(span);
  5130. node.appendChild(table);
  5131. return tbody;
  5132. }
  5133.  
  5134. function testCertif(paramURL, callbackOnError) {
  5135. try {
  5136. FF_XMLHttpRequest({
  5137. method: 'GET',
  5138. url: paramURL,
  5139. onload: function(responseDetails) {
  5140. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  5141. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  5142. }
  5143. });
  5144. } catch(e) {
  5145. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  5146. callbackOnError();
  5147. }
  5148. }
  5149.  
  5150. function createOrGetGrandCadre() {
  5151. var grandCadre = document.getElementById('grandCadre');
  5152. if (grandCadre) return grandCadre;
  5153. try {
  5154. var rappels = document.evaluate(
  5155. "//p[contains(a/text(),'messagerie')]",
  5156. document, null, 9, null).singleNodeValue;
  5157. }
  5158. catch(e) {
  5159. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  5160. grandCadre = document.createElement('div');
  5161. return grandCadre;
  5162. }
  5163. grandCadre = document.createElement('div');
  5164. grandCadre.id = 'grandCadre';
  5165. var sousCadre = document.createElement('div');
  5166. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  5167. sousCadre.style.textAlign = 'center';
  5168. sousCadre.style.fontSize = 'xx-large';
  5169. grandCadre.appendChild(sousCadre);
  5170.  
  5171. grandCadre.style.border = 'solid 5px red';
  5172. grandCadre.style.width = 'auto';
  5173. insertBefore(rappels,grandCadre);
  5174. return grandCadre;
  5175. }
  5176.  
  5177. function showHttpsErrorCadre1() {
  5178. window.console.log('[MZ] showHttpsErrorCadre1');
  5179. var grandCadre = createOrGetGrandCadre();
  5180. var sousCadre = document.createElement('div');
  5181. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  5182. + '<br />Cela empêchera Moutyzilla de fonctionner'
  5183. + '<br /><a style="color:blue;font-size: inherits;" href="'
  5184. + URL_CertifRaistlin1
  5185. + '" target="raistlin">clique ici</a>'
  5186. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5187. + ' « Confirmer l\'exception de sécurité »'
  5188. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5189. sousCadre.style.width = 'auto';
  5190. sousCadre.style.fontSize = 'large';
  5191. sousCadre.style.border = 'solid 1px black';
  5192. sousCadre.style.backgroundColor = 'red';
  5193. grandCadre.appendChild(sousCadre);
  5194. }
  5195.  
  5196. function showHttpsErrorCadre2() {
  5197. window.console.log('[MZ] showHttpsErrorCadre2');
  5198. var grandCadre = createOrGetGrandCadre();
  5199. var sousCadre = document.createElement('div');
  5200. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  5201. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  5202. + '<a style="color:blue;font-size: inherits;" href="'
  5203. + URL_CertifRaistlin2
  5204. + '" target="raistlin">clique ici</a>'
  5205. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5206. + ' « Confirmer l\'exception de sécurité »'
  5207. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  5208. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5209. sousCadre.style.width = 'auto';
  5210. sousCadre.style.fontSize = 'large';
  5211. sousCadre.style.border = 'solid 1px black';
  5212. sousCadre.style.backgroundColor = 'red';
  5213. grandCadre.appendChild(sousCadre);
  5214. }
  5215.  
  5216. function showHttpsErrorContenuMixte() {
  5217. window.console.log('[MZ] showHttpsErrorContenuMixte');
  5218. var grandCadre = createOrGetGrandCadre();
  5219. var sousCadre = document.createElement('div');
  5220. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5221. + '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)'
  5222. + '<ul>'
  5223. + '<li>Interface Bricol\'Troll</li>'
  5224. + '<li>Nouveautés de Mountyzilla</li>'
  5225. + '</ul>'
  5226. + '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 />'
  5227. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5228. sousCadre.style.width = 'auto';
  5229. sousCadre.style.fontSize = 'large';
  5230. sousCadre.style.border = 'solid 1px black';
  5231. grandCadre.appendChild(sousCadre);
  5232. }
  5233.  
  5234. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5235.  
  5236. function traiterJubilaires() {
  5237. // à faire
  5238. }
  5239.  
  5240. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5241. try {
  5242. FF_XMLHttpRequest({
  5243. method: 'GET',
  5244. url: URL_anniv,
  5245. headers: {
  5246. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5247. 'Accept': 'application/xml,text/xml',
  5248. },
  5249. onload: function(responseDetails) {
  5250. if ((responseDetails.status == 0) && isHTTPS) {
  5251. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5252. //showHttpsErrorContenuMixte();
  5253. return;
  5254. }
  5255. var listeTrolls = responseDetails.responseText.split('\n');
  5256. if(!listeTrolls || listeTrolls.length==0) {
  5257. return;
  5258. }
  5259. afficherJubilaires(listeTrolls);
  5260. },
  5261. });
  5262. }
  5263. catch(e) {
  5264. if (isHTTPS) {
  5265. window.console.log(traceStack(e, 'appel jubilaires'));
  5266. showHttpsErrorContenuMixte();
  5267. } else {
  5268. window.alert('Erreur Jubilaires:\n'+e);
  5269. }
  5270. }
  5271. }
  5272.  
  5273. function afficherJubilaires(listeTrolls) {
  5274. try {
  5275. var rappels = document.evaluate(
  5276. "//p[contains(a/text(),'messagerie')]",
  5277. document, null, 9, null).singleNodeValue;
  5278. }
  5279. catch(e) {
  5280. return;
  5281. }
  5282. var p = document.createElement('p');
  5283. var tbody = appendTitledTable(p,
  5284. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5285. 'Envoyez leur un message ou un cadeau !'
  5286. );
  5287. tr = appendTr(tbody,'mh_tdpage');
  5288. td = appendTdCenter(tr);
  5289. var small = document.createElement('small');
  5290. td.appendChild(small);
  5291. var first = true;
  5292. for(var i=0 ; i<listeTrolls.length ; i++) {
  5293. var infos = listeTrolls[i].split(';');
  5294. if(infos.length!=3 || infos[2]==='0') {
  5295. continue;
  5296. }
  5297. if(first) {
  5298. first = false;
  5299. }
  5300. else {
  5301. appendText(small,', ');
  5302. }
  5303. var a = document.createElement('a');
  5304. a.href = 'javascript:EPV('+infos[0]+')';
  5305. appendText(a,infos[1]);
  5306. small.appendChild(a);
  5307. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5308. }
  5309. insertBefore(rappels,p);
  5310. }
  5311.  
  5312.  
  5313. /*-[functions]--------------------- News MZ ----------------------------------*/
  5314.  
  5315. function traiterNouvelles() {
  5316. var news = new Array;
  5317. news.push(['25/08/2017', 'Possibilité d\'afficher les caractéristiques de Trõlls venant de plusieurs IT Bricol\'Troll (utiliser le petit +, à gauche dans la liste)']);
  5318. 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 ;).']);
  5319. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5320. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5321. 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']);
  5322. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5323. afficherNouvelles(news);
  5324. }
  5325.  
  5326. function afficherNouvelles(items) {
  5327. var footer = document.getElementById('footer1');
  5328. if(!footer) {
  5329. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5330. return;
  5331. }
  5332. var p = document.createElement('p');
  5333. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5334. var div = document.createElement('div');
  5335. div.style.position = 'absolute';
  5336. div.style.right = 0;
  5337. div.style.top = 0;
  5338. div.style.paddingRight = '3px';
  5339. div.style.whiteSpace = 'nowrap';
  5340. appendText(div, '(version ' + GM_info.script.version + ')');
  5341. tbody.rows[0].cells[0].style.position = 'relative';
  5342. tbody.rows[0].cells[0].appendChild(div);
  5343. for(var i=0 ; i<items.length ; i++) {
  5344. var tr = appendTr(tbody,'mh_tdpage');
  5345. var td = appendTdCenter(tr);
  5346. td.style.verticalAlign = 'top'; // semble sans effet
  5347. appendText(td,items[i][0],true);
  5348. td = appendTd(tr);
  5349. td.innerHTML = items[i][1];
  5350. }
  5351. insertBefore(footer,p);
  5352.  
  5353. // changelog
  5354. var p = document.createElement('p');
  5355. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5356. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5357. tbody.rows[0].cells[0].onclick = function() {
  5358. try {
  5359. tbody.rows[0].cells[0].onclick = undefined;
  5360. tbody.rows[0].cells[0].style.cursor = '';
  5361. var tr = appendTr(tbody,'mh_tdpage');
  5362. var td = appendTd(tr);
  5363. td.colSpan = 2;
  5364. var pre = document.createElement('pre');
  5365. appendText(pre,MZ_changeLog.join("\n"));
  5366. td.appendChild(pre);
  5367. } catch (e) {
  5368. window.console.log('[MZ] affichage changeLog', e);
  5369. }
  5370. };
  5371. insertBefore(footer,p);
  5372.  
  5373. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5374. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5375. if (isHTTPS) {
  5376. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5377. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5378. } else {
  5379. window.console.log('[MZ test] début switch to https');
  5380. window.sessionStorage.setItem('xxx', "test session trans https");
  5381. window.parent.xxx = "autre test";
  5382. var url = document.location.href;
  5383. window.console.log('[MZ test] url=' + url);
  5384. url = url.replace(/http:\/\//i, 'https://')
  5385. window.console.log('[MZ test] switched url=' + url);
  5386. document.location.href = url;
  5387. }
  5388. }
  5389. if (false) { // version par utilisation d'un IFrame en https
  5390. if (isHTTPS) {
  5391. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5392. //window.console.log('[MZ test] window.name=' + window.name);
  5393. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5394. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5395. var txt = window.name;
  5396. var tabtxt = txt.split(/µ/);
  5397. for (var i = 0; i < tabtxt.length; i++) {
  5398. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5399. }
  5400. } else {
  5401. var txt = '';
  5402. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5403. var k = localStorage.key(i);
  5404. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5405. txt += k + "£" + localStorage.getItem(k) + "µ";
  5406. }
  5407. var iframe = document.createElement('iframe');
  5408. var url = document.location.href;
  5409. //window.console.log('[MZ test] url=' + url);
  5410. url = url.replace(/http:\/\//i, 'https://')
  5411. //window.console.log('[MZ test] switched url=' + url);
  5412. //iframe.xxx = "truc en plume";
  5413. iframe.name = txt;
  5414. //window.xxx = "machin";
  5415. iframe.src = url;
  5416. //iframe.document.xxx = "truc en plume";
  5417. document.body.appendChild(iframe);
  5418. iframe.style.display = 'none';
  5419. }
  5420. }
  5421. }
  5422. }
  5423.  
  5424.  
  5425. /*---------------------------------- Main ------------------------------------*/
  5426.  
  5427. function do_news() {
  5428. start_script();
  5429.  
  5430. traiterJubilaires();
  5431. traiterNouvelles();
  5432.  
  5433. /* plus besoin, le certificat est "officiel"
  5434. if (isHTTPS) {
  5435. // test si les certificats raistlin ont été acceptés
  5436. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5437. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5438. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5439. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5440. }
  5441. }
  5442. */
  5443.  
  5444. displayScriptTime();
  5445. }
  5446.  
  5447. /*********************************************************************************
  5448. * This file is part of Mountyzilla. *
  5449. * *
  5450. * Mountyzilla is free software; you can redistribute it and/or modify *
  5451. * it under the terms of the GNU General Public License as published by *
  5452. * the Free Software Foundation; either version 2 of the License, or *
  5453. * (at your option) any later version. *
  5454. * *
  5455. * Mountyzilla is distributed in the hope that it will be useful, *
  5456. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5457. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5458. * GNU General Public License for more details. *
  5459. * *
  5460. * You should have received a copy of the GNU General Public License *
  5461. * along with Mountyzilla; if not, write to the Free Software *
  5462. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5463. *********************************************************************************/
  5464.  
  5465. // x~x tabcompo
  5466.  
  5467. var popup;
  5468.  
  5469. function initPopupTabcompo() {
  5470. popup = document.createElement('div');
  5471. popup.setAttribute('id', 'popup');
  5472. popup.setAttribute('class', 'mh_textbox');
  5473. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5474. + 'display: inline; z-index: 3; max-width: 400px;');
  5475. document.body.appendChild(popup);
  5476. }
  5477.  
  5478. function showPopup(evt) {
  5479. var texte = this.getAttribute("texteinfo");
  5480. popup.innerHTML = texte;
  5481. popup.style.left = evt.pageX + 15 + 'px';
  5482. popup.style.top = evt.pageY + 'px';
  5483. popup.style.visibility = "visible";
  5484. }
  5485.  
  5486. // roule 16/03/2016, existe déjà ailleurs
  5487. // function hidePopup() {
  5488. // popup.style.visibility = 'hidden';
  5489. // }
  5490.  
  5491. function createPopupImage(url, text)
  5492. {
  5493. var img = document.createElement('img');
  5494. img.setAttribute('src',url);
  5495. img.setAttribute('align','ABSMIDDLE');
  5496. img.setAttribute("texteinfo",text);
  5497. img.addEventListener("mouseover", showPopup,true);
  5498. img.addEventListener("mouseout", hidePopup,true);
  5499. return img;
  5500. }
  5501.  
  5502. function formateTexte(texte)
  5503. {
  5504. texte = texte.replace(/\n/g,"<br/>");
  5505. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5506. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5507. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5508. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5509. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5510. return texte;
  5511. }
  5512.  
  5513. function arrondi(x) {
  5514. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5515. }
  5516.  
  5517. function traiteMinerai() {
  5518. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5519. try {
  5520. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5521. +" and contains(./tr/th/text(),'Minerai')]",
  5522. document, null, 9, null).singleNodeValue;
  5523. node = node.nextSibling.nextSibling;
  5524. }
  5525. catch(e) {return;}
  5526. var trlist = document.evaluate('./tr', node, null, 7, null);
  5527. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5528. var node = trlist.snapshotItem(i);
  5529. var nature = node.childNodes[5].textContent;
  5530. var caracs = node.childNodes[7].textContent;
  5531. var taille = caracs.match(/\d+/)[0];
  5532. var coef = 1;
  5533. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5534. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5535. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5536. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5537. if (nature.indexOf('Mithril')!=-1) {
  5538. coef = 0.2*coef;
  5539. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5540. }
  5541. else {
  5542. coef = 0.75*coef+1.25;
  5543. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5544. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5545. }
  5546. }
  5547. }
  5548.  
  5549. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5550. function treateComposants() {
  5551. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5552. //On récupère les composants
  5553. var nodes = document.evaluate(
  5554. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5555. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5556. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5557. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5558. if (nodes.snapshotLength == 0) {
  5559. //window.console.log('[MZ] treateComposants DOWN');
  5560. return;
  5561. }
  5562. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5563.  
  5564. var texte = "";
  5565. for (var i = 0; i < nodes.snapshotLength; i++) {
  5566. var n1 = nodes.snapshotItem(i).childNodes[1];
  5567. var n3 = nodes.snapshotItem(i).childNodes[3];
  5568. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5569. var prix = n3.childNodes[0].nodeValue;
  5570. if (!prix)
  5571. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5572. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5573. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5574. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5575. + prix.replace(/\n/g, '') + "\n";
  5576. }
  5577.  
  5578. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5579. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5580. var id_taniere = c.snapshotItem(0).nodeValue;
  5581. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5582.  
  5583. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5584. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5585. if (form)
  5586. {
  5587. if(document.getElementsByTagName('form').length>0)
  5588. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5589. else
  5590. {
  5591. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5592. insertBefore(thisP, form);
  5593. }
  5594. }
  5595. }
  5596.  
  5597. function treateAllComposants() {
  5598. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5599. //On récupère les composants
  5600. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5601. document, null, 0, null ).numberValue;
  5602. var c = (categ == 0 ? 3 : 4);
  5603. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5604. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5605. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5606. + "td["+c+"]/text()[1] = '\240-\240' "
  5607. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5608. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5609. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5610. + "and td[1]/img/@alt = 'Identifié']",
  5611. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5612. if (nodes.snapshotLength == 0) {
  5613. // window.alert('treateAllComposants DOWN');
  5614. return;
  5615. }
  5616.  
  5617. var texte = "";
  5618. for (var i = 0; i < nodes.snapshotLength; i++) {
  5619. var n1 = nodes.snapshotItem(i).childNodes[1];
  5620. var n3 = nodes.snapshotItem(i).childNodes[3];
  5621. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5622. var prix = n3.childNodes[0].nodeValue;
  5623. if (!prix)
  5624. {
  5625. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5626. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5627. }
  5628. else
  5629. {
  5630. prix= prix.replace(/[\240 ]/g, "");
  5631. if(prix=="-")
  5632. prix=null;
  5633. }
  5634. if(prix)
  5635. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5636. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5637. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5638. + prix.replace(/\n/g, '') + "\n";
  5639. else
  5640. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5641. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5642. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5643. }
  5644.  
  5645. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5646. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5647. var id_taniere = c.snapshotItem(0).nodeValue;
  5648. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5649.  
  5650. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5651. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5652. if (form)
  5653. {
  5654. if(document.getElementsByTagName('form').length>0)
  5655. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5656. else
  5657. {
  5658. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5659. insertBefore(thisP, form);
  5660. }
  5661. }
  5662. }
  5663.  
  5664. function treateEM()
  5665. {
  5666. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  5667. if(currentURL.indexOf("as_type=Compo")==-1)
  5668. return false;
  5669. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  5670. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  5671. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5672. if (nodes.snapshotLength == 0)
  5673. return false;
  5674. for (var i = 0; i < nodes.snapshotLength; i++) {
  5675. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  5676. var link = desc[2].firstChild ;
  5677. var nomCompoTotal = desc[2].textContent ;
  5678. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5679. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5680. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  5681. var locqual = desc[3].textContent ;
  5682. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  5683. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  5684. if(isEM(nomMonstre).length>0)
  5685. {
  5686. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  5687. if(infos.length>0)
  5688. {
  5689. var shortDescr = "Variable";
  5690. var bold = 0;
  5691. if(infos != "Composant variable")
  5692. {
  5693. shortDescr = infos.substring(0,infos.indexOf(" "));
  5694. if(parseInt(shortDescr)>=0)
  5695. bold=1;
  5696. }
  5697. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  5698. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  5699. }
  5700. }
  5701. }
  5702. }
  5703.  
  5704. function treateChampi() {
  5705. if (currentURL.indexOf('as_type=Champi')==-1)
  5706. return false;
  5707. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  5708. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5709. if (nodes.snapshotLength == 0)
  5710. return false;
  5711.  
  5712. for (var i = 0; i < nodes.snapshotLength; i++) {
  5713. var node = nodes.snapshotItem(i);
  5714. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  5715. if (moisChampi[nomChampi])
  5716. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  5717. }
  5718. }
  5719.  
  5720. function treateEnchant()
  5721. {
  5722. if(currentURL.indexOf("as_type=Compo")==-1)
  5723. return false;
  5724. try
  5725. {
  5726. if(!listeMonstreEnchantement)
  5727. computeCompoEnchantement();
  5728. var nodes = document.evaluate(
  5729. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5730. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5731. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5732. if (nodes.snapshotLength == 0)
  5733. return false;
  5734. var urlImg = URL_MZimg + "enchant.png";
  5735. for (var i = 0; i < nodes.snapshotLength; i++) {
  5736. var link = nodes.snapshotItem(i);
  5737. var nomCompoTotal = link.firstChild.nodeValue;
  5738. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5739. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5740. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  5741. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  5742. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  5743. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  5744. if(isEnchant(nomMonstre).length>0)
  5745. {
  5746. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  5747. if(infos.length>0)
  5748. {
  5749. link.parentNode.appendChild(createImage(urlImg,infos));
  5750. }
  5751. }
  5752. }
  5753. }
  5754. catch(e)
  5755. {
  5756. window.alert(e);
  5757. }
  5758. }
  5759.  
  5760. function treateEquipEnchant()
  5761. {
  5762. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  5763. return false;
  5764. initPopupTabcompo();
  5765. computeEnchantementEquipement(createPopupImage,formateTexte);
  5766. }
  5767.  
  5768. function do_tancompo() {
  5769. start_script();
  5770.  
  5771. treateAllComposants();
  5772. treateComposants();
  5773. traiteMinerai();
  5774. if (MY_getValue('NOINFOEM')!='true') {
  5775. treateChampi();
  5776. treateEM();
  5777. }
  5778. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  5779. treateEnchant();
  5780. treateEquipEnchant();
  5781. }
  5782.  
  5783. displayScriptTime();
  5784. }
  5785.  
  5786. /*******************************************************************************
  5787. * This file is part of Mountyzilla. *
  5788. * *
  5789. * Mountyzilla is free software; you can redistribute it and/or modify *
  5790. * it under the terms of the GNU General Public License as published by *
  5791. * the Free Software Foundation; either version 2 of the License, or *
  5792. * (at your option) any later version. *
  5793. * *
  5794. * Mountyzilla is distributed in the hope that it will be useful, *
  5795. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5796. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5797. * GNU General Public License for more details. *
  5798. * *
  5799. * You should have received a copy of the GNU General Public License *
  5800. * along with Mountyzilla; if not, write to the Free Software *
  5801. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5802. *******************************************************************************/
  5803.  
  5804. // x~x pjview
  5805.  
  5806. /* TODO
  5807. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  5808. */
  5809.  
  5810. // Bulle d'infos
  5811. var DivInfo;
  5812. // Booléen stockant l'état de freezing de la bulle
  5813. var freezed = false;
  5814.  
  5815. // liste du matos
  5816. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  5817. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5818. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  5819. var mh_caracs = {
  5820. 'anneau de protection':
  5821. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  5822. "armure d'anneaux":
  5823. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  5824. 'armure de bois':
  5825. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  5826. 'armure de cuir':
  5827. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  5828. 'armure de peaux':
  5829. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  5830. 'armure de pierre':
  5831. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  5832. 'armure de plates':
  5833. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  5834. 'baton lesté':
  5835. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5836. 'bâtons de parade':
  5837. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5838. 'bottes':
  5839. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5840. 'bouclier à pointes':
  5841. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5842. 'boulet et chaîne':
  5843. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5844. 'cagoule':
  5845. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  5846. 'casque à cornes':
  5847. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5848. 'casque à pointes':
  5849. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  5850. 'casque en cuir':
  5851. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  5852. 'casque en métal':
  5853. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5854. 'chaîne cloutée':
  5855. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5856. 'chapeau pointu':
  5857. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  5858. 'collier de dents':
  5859. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  5860. 'collier de pierre':
  5861. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5862. 'collier à pointes':
  5863. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5864. 'cotte de mailles':
  5865. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5866. 'couronne de cristal':
  5867. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5868. "couronne d'obsidienne":
  5869. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5870. "coutelas d'obsidienne":
  5871. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5872. 'coutelas en os':
  5873. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5874. 'crochet':
  5875. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5876. 'cuir bouilli':
  5877. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5878. "cuirasse d'ossements":
  5879. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5880. "cuirasse d'écailles":
  5881. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5882. 'culotte en cuir':
  5883. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5884. 'dague':
  5885. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5886. 'epée courte':
  5887. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5888. 'epée longue':
  5889. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5890. 'espadon':
  5891. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5892. 'fouet':
  5893. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5894. 'fourrures':
  5895. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5896. 'gantelet':
  5897. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5898. 'gorgeron en cuir':
  5899. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5900. 'gorgeron en métal':
  5901. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5902. 'gourdin':
  5903. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5904. 'gourdin clouté':
  5905. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5906. 'grimoire':
  5907. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5908. "gros'porte":
  5909. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5910. 'grosse racine':
  5911. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5912. 'grosse stalagmite':
  5913. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5914. 'hache de bataille':
  5915. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5916. 'hache de guerre en os':
  5917. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5918. 'hache de guerre en pierre':
  5919. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5920. "hache à deux mains d'obsidienne":
  5921. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5922. 'hallebarde':
  5923. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5924. "haubert d'écailles":
  5925. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5926. 'haubert de mailles':
  5927. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5928. 'heaume':
  5929. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5930. 'jambières en cuir':
  5931. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5932. 'jambières en fourrure':
  5933. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5934. 'jambières en maille':
  5935. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5936. 'jambières en métal':
  5937. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5938. 'jambières en os':
  5939. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5940. "lame d'obsidienne":
  5941. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5942. 'lame en os':
  5943. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5944. 'lame en pierre':
  5945. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5946. 'lorgnons':
  5947. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5948. 'machette':
  5949. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5950. "masse d'arme":
  5951. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5952. 'pagne de mailles':
  5953. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5954. 'pagne en cuir':
  5955. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5956. 'robe de mage':
  5957. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5958. 'rondache en bois':
  5959. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5960. 'rondache en métal':
  5961. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5962. 'sandales':
  5963. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5964. 'souliers dorés':
  5965. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5966. "talisman d'obsidienne":
  5967. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5968. 'talisman de pierre':
  5969. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5970. 'targe':
  5971. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5972. 'torche':
  5973. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5974. 'torque de pierre':
  5975. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5976. 'tunique':
  5977. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5978. "tunique d'écailles":
  5979. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5980. 'turban':
  5981. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5982. }
  5983.  
  5984. // liste des templates
  5985. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5986. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5987. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5988. var mh_templates = {
  5989. 'de Feu':
  5990. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5991. 'de Résistance':
  5992. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5993. "de l'Aigle":
  5994. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5995. 'de la Salamandre':
  5996. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5997. 'des Cyclopes':
  5998. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5999. 'des Enragés':
  6000. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  6001. 'des Tortues':
  6002. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  6003. 'des Vampires':
  6004. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6005. 'du Glacier':
  6006. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  6007. 'du Rat':
  6008. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6009. 'du Roc':
  6010. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  6011. 'du Temps':
  6012. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  6013. 'du Vent':
  6014. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6015. 'en Mithril':
  6016. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6017. 'des Anciens':
  6018. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6019. 'des Champions':
  6020. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6021. 'des Duellistes':
  6022. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6023. 'de la Terre':
  6024. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  6025. "de l'Orage":
  6026. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  6027. "de l'Ours":
  6028. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  6029. 'des Béhémoths':
  6030. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  6031. 'des Mages':
  6032. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  6033. 'du Pic':
  6034. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  6035. 'du Sable':
  6036. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  6037. 'acéré':
  6038. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6039. 'acérée':
  6040. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6041. 'équilibré':
  6042. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6043. 'équilibrée':
  6044. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6045. 'léger':
  6046. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  6047. 'légère':
  6048. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  6049. 'renforcé':
  6050. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  6051. 'renforcée':
  6052. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  6053. 'robuste':
  6054. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  6055. }
  6056.  
  6057. function clone(arr) {
  6058. // Clonage rapide
  6059. return arr.slice(0);
  6060. }
  6061.  
  6062. function addArray(arr1,arr2) {
  6063. // Somme matricielle
  6064. var res = clone(arr1);
  6065. for(i=res.length-1 ; i>=0 ; i--) {
  6066. res[i] += arr2[i];
  6067. }
  6068. return res;
  6069. }
  6070.  
  6071. function getTemplates(nomItem) {
  6072. // Déstructure le nom de l'item en array [nom, template1, ...]
  6073. var tempFound = true;
  6074. var str = nomItem.trim();
  6075. var arr = [];
  6076. while(tempFound) {
  6077. tempFound = false;
  6078. for(var temp in mh_templates) {
  6079. // on teste la fin du nom contre chaque template
  6080. if(str.slice(-temp.length)!=temp) { continue; }
  6081. tempFound = true;
  6082. str = str.slice(0,-temp.length-1);
  6083. arr.unshift(temp);
  6084. if(str.slice(-3)==' et') {
  6085. str = str.slice(0,-3);
  6086. }
  6087. }
  6088. }
  6089. arr.unshift(str);
  6090. return arr;
  6091. }
  6092.  
  6093. function addMithril(arrayCaracs,typeItem) {
  6094. // Ajoute l'effet du Mithril sur les caracs
  6095. if(typeItem=='arme') {
  6096. if(arrayCaracs[0]<0) {
  6097. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  6098. }
  6099. }
  6100. else {
  6101. if(arrayCaracs[4]<0) {
  6102. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  6103. }
  6104. }
  6105. arrayCaracs[15] /= 2;
  6106. arrayCaracs[16] /= 2;
  6107. return arrayCaracs;
  6108. }
  6109.  
  6110. function addRenfort(arrayCaracs,template) {
  6111. // Ajoute l'effet des pseudo-templates sur les caracs
  6112. // S'applique APRÈS le mithril
  6113. // WARNING - Cette formule n'a rien d'officiel, gare !
  6114. var coef = 0;
  6115. if(/^lég[e,è]re?$/.test(template)) {
  6116. coef = -1;
  6117. }
  6118. else if(/^renforcée?$/.test(template)
  6119. || template==='robuste') {
  6120. coef = 1;
  6121. }
  6122. if(coef) {
  6123. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  6124. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  6125. }
  6126. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  6127. return arrayCaracs;
  6128. }
  6129.  
  6130. function getCaracs(item) {
  6131. // Calcule les caractéristiques de l'item
  6132. var templates = getTemplates(item);
  6133. if(!mh_caracs[templates[0]]) {
  6134. // Si l'item est inconnu
  6135. return [];
  6136. }
  6137. var caracs = clone(mh_caracs[templates[0]]);
  6138. var typeItem = caracs[0];
  6139. caracs.shift();
  6140. templates.shift();
  6141. if(templates[templates.length-1]=='en Mithril') {
  6142. caracs = addMithril(caracs,typeItem);
  6143. templates.pop();
  6144. }
  6145. if(/^acérée?$/.test(templates[0])
  6146. || /^équilibrée?$/.test(templates[0])
  6147. || /^lég[e,è]re?$/.test(templates[0])
  6148. || /^renforcée?$/.test(templates[0])
  6149. || templates[0]=='robuste') {
  6150. caracs = addRenfort(caracs,templates[0]);
  6151. templates.shift();
  6152. }
  6153. for(var i=templates.length-1 ; i>=0 ; i--) {
  6154. caracs = addArray(caracs,mh_templates[templates[i]]);
  6155. }
  6156. return caracs;
  6157. }
  6158.  
  6159. function getLine(tab) {
  6160. // Préparation de la ligne à afficher lors d'un mouseover
  6161. var str = '';
  6162. if(tab[0]!=0 || tab[1]!=0) {
  6163. str += '<b>Att : </b>'+aff(tab[0]);
  6164. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  6165. str += ' | ';
  6166. }
  6167. if(tab[4]!=0) {
  6168. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  6169. }
  6170. if(tab[2]!=0 || tab[3]!=0) {
  6171. str += '<b>Deg : </b>'+aff(tab[2]);
  6172. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  6173. str += ' | ';
  6174. }
  6175. if(tab[8]!=0) {
  6176. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  6177. }
  6178. if(tab[7]!=0) {
  6179. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  6180. }
  6181. if(tab[5]!=0 || tab[6]!=0) {
  6182. str += '<b>Arm : </b>'+aff(tab[5]);
  6183. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  6184. str += ' | ';
  6185. }
  6186. if(tab[9]!=0 || tab[10]!=0) {
  6187. str += '<b>RM : </b>'+aff(tab[9])+'%';
  6188. if(tab[9]!=tab[10]) {
  6189. str += '/'+aff(tab[10])+'%';
  6190. }
  6191. str += ' | ';
  6192. }
  6193. if(tab[11]!=0 || tab[12]!=0) {
  6194. str += '<b>MM : </b>'+aff(tab[11])+'%';
  6195. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  6196. str += ' | ';
  6197. }
  6198. if(tab[13]!=0) {
  6199. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  6200. }
  6201. if(tab[14]!=0) {
  6202. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  6203. }
  6204. str += '<b>Poids : </b>'+tab[15]+' min';
  6205. if(tab[15]!=tab[16]) {
  6206. str += ' / '+tab[16]+' min';
  6207. }
  6208. return str;
  6209. }
  6210.  
  6211. function toolTipInit() {
  6212. DivInfo = document.createElement('div');
  6213. DivInfo.id = 'infosVue';
  6214. DivInfo.className = 'mh_textbox';
  6215. DivInfo.style =
  6216. 'position: absolute;'
  6217. +'border: 1px solid #000000;'
  6218. +'visibility:hidden;'
  6219. +'display:inline;'
  6220. +'z-index:99;';
  6221. document.body.appendChild(DivInfo);
  6222. document.onmousemove = getXY;
  6223. document.onclick = changeFreezeStatus;
  6224. }
  6225.  
  6226. function getXY(evt) {
  6227. if(!freezed && DivInfo.style.visibility=='visible') {
  6228. DivInfo.style.left = evt.pageX+'px';
  6229. DivInfo.style.top = evt.pageY+10+'px';
  6230. }
  6231. }
  6232.  
  6233. function changeFreezeStatus() {
  6234. if(DivInfo.style.visibility=='visible') {
  6235. freezed = !freezed;
  6236. if(!freezed) { hideInfos(); }
  6237. }
  6238. }
  6239.  
  6240. function showInfos() {
  6241. if(freezed) { return; }
  6242. var currentInfos = this.infos;
  6243. DivInfo.innerHTML = currentInfos;
  6244. DivInfo.style.visibility = 'visible';
  6245. }
  6246.  
  6247. function hideInfos() {
  6248. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6249. }
  6250.  
  6251. function treateEquipement() {
  6252. // Extrait les données du matos et réinjecte les infos déduites
  6253. if(MY_getValue('INFOCARAC')=='false') { return; }
  6254. var faireLigne = false;
  6255. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6256. var nodes = document.evaluate(
  6257. "//td/b[text()='Equipement Utilisé']/../../"
  6258. +"td[2]/img[contains(@src,bullet)]",
  6259. document, null, 7, null);
  6260. if(nodes.snapshotLength>0) {
  6261. // Si CSS de base
  6262. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6263. var node = nodes.snapshotItem(i);
  6264. var next = node.nextSibling;
  6265. var nnext = next.nextSibling;
  6266. var nom = next.nodeValue.toLowerCase();
  6267. if(nnext.childNodes.length==1) {
  6268. nom += nnext.firstChild.nodeValue;
  6269. }
  6270. nom = nom.trim();
  6271. // gestion winpostrophe
  6272. var c = String.fromCharCode(180);
  6273. while(nom.indexOf(c)!=-1) {
  6274. nom = nom.replace(c,"'");
  6275. }
  6276. var arr = getCaracs(nom);
  6277. if(arr.length>0) {
  6278. faireLigne = true;
  6279. caracs = addArray(caracs,arr);
  6280. var span = document.createElement('span');
  6281. span.appendChild(next);
  6282. span.appendChild(nnext);
  6283. span.infos = getLine(arr);
  6284. span.onmouseover = showInfos;
  6285. span.onmouseout = hideInfos;
  6286. insertBefore(node.nextSibling,span);
  6287. }
  6288. }
  6289. if(faireLigne) {
  6290. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6291. document, null, 9, null).singleNodeValue;
  6292. node.infos = getLine(caracs);
  6293. node.onmouseover = showInfos;
  6294. node.onmouseout = hideInfos;
  6295. }
  6296. }
  6297. else {
  6298. // Si CSS avancée
  6299. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6300. document, null, 7, null);
  6301. if(nodes.snapshotLength>0) {
  6302. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6303. var node = nodes.snapshotItem(i);
  6304. var nom = node.firstChild.nodeValue.toLowerCase();
  6305. if(node.childNodes.length>1) {
  6306. nom += node.childNodes[1].firstChild.nodeValue;
  6307. }
  6308. nom = nom.trim();
  6309. // gestion winpostrophe
  6310. var c = String.fromCharCode(180);
  6311. while(nom.indexOf(c)!=-1) {
  6312. nom = nom.replace(c,"'");
  6313. }
  6314. var arr = getCaracs(nom);
  6315. if(arr.length!=0) {
  6316. caracs = addArray(caracs,arr);
  6317. node.infos = getLine(arr);
  6318. node.onmouseover = showInfos;
  6319. node.onmouseout = hideInfos;
  6320. }
  6321. }
  6322. var nodes = document.evaluate("//dt[@class='equipement']",
  6323. document, null, 7, null);
  6324. var node = nodes.snapshotItem(0);
  6325. node.infos = getLine(caracs);
  6326. node.onmouseover = showInfos;
  6327. node.onmouseout = hideInfos;
  6328. }
  6329. }
  6330. }
  6331.  
  6332. function do_pjview() {
  6333. treateEquipement();
  6334. toolTipInit();
  6335. }
  6336.  
  6337. /*******************************************************************************
  6338. * This file is part of Mountyzilla. *
  6339. * *
  6340. * Mountyzilla is free software; you can redistribute it and/or modify *
  6341. * it under the terms of the GNU General Public License as published by *
  6342. * the Free Software Foundation; either version 2 of the License, or *
  6343. * (at your option) any later version. *
  6344. * *
  6345. * Mountyzilla is distributed in the hope that it will be useful, *
  6346. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6347. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6348. * GNU General Public License for more details. *
  6349. * *
  6350. * You should have received a copy of the GNU General Public License *
  6351. * along with Mountyzilla; if not, write to the Free Software *
  6352. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6353. *******************************************************************************/
  6354.  
  6355. // x~x option
  6356.  
  6357. /* TODO
  6358. * Passer le HTML injecté aux conventions HTML5
  6359. */
  6360.  
  6361.  
  6362. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6363.  
  6364. function saveITData() {
  6365. var IT = document.getElementById('itSelect').value;
  6366. if(IT=='bricol') {
  6367. var nBricol = 1;
  6368. for (var iBricol = 0; ; iBricol++) {
  6369. var extClef = nBricol == 1 ? '' : nBricol;
  6370. var eltSystem = document.getElementById('urlbricol'+iBricol);
  6371. if (eltSystem == undefined) break;
  6372. var system = eltSystem.value;
  6373. window.console.log("[MZ] saveITData system=" + system);
  6374. var login = document.getElementById('loginbricol'+iBricol).value;
  6375. var pass = document.getElementById('passbricol'+iBricol).value;
  6376. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6377. if(system && login) {
  6378. if (pass) {
  6379. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6380. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  6381. //window.console.log('v=' + v);
  6382. } else {
  6383. // vérif que rien n'a changé
  6384. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  6385. if(str) {
  6386. var arr = str.split('$');
  6387. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6388. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  6389. }
  6390. }
  6391. }
  6392. nBricol++;
  6393. }
  6394. }
  6395. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  6396. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  6397. }
  6398. else {
  6399. MY_removeValue(numTroll+'.INFOSIT');
  6400. }
  6401. }
  6402.  
  6403. function saveLinks() {
  6404. var numLinks = document.getElementById('linksBody').childNodes.length;
  6405. var data=[ [] ];
  6406. /* Récupération et tri des liens */
  6407. for(var i=1 ; i<=numLinks ; i++) {
  6408. MY_removeValue('URL'+i);
  6409. MY_removeValue('URL'+i+'.nom');
  6410. MY_removeValue('URL'+i+'.ico');
  6411. var url = document.getElementById('url'+i).value;
  6412. var nom = document.getElementById('nom'+i).value;
  6413. var ico = document.getElementById('ico'+i).value;
  6414. if(url && (nom || ico) ) {
  6415. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6416. }
  6417. }
  6418. /* Sauvegarde */
  6419. for(var i=1 ; i<data.length ; i++) {
  6420. MY_setValue('URL'+i,data[i][0]);
  6421. MY_setValue('URL'+i+'.nom',data[i][1]);
  6422. MY_setValue('URL'+i+'.ico',data[i][2]);
  6423. }
  6424. }
  6425.  
  6426. function saveAll() {
  6427. try {
  6428. var urlIco = document.getElementById('icoMenuIco').value;
  6429. if(urlIco) {
  6430. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6431. }
  6432. else {
  6433. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6434. document.getElementById('icoMenuIco').value = '';
  6435. }
  6436. saveLinks();
  6437. refreshLinks();
  6438. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6439. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6440. if(maxcdm) {
  6441. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6442. }
  6443. else {
  6444. MY_removeValue(numTroll+'.MAXCDM');
  6445. document.getElementById('maxcdm').value = '';
  6446. }
  6447.  
  6448. MY_setValue('NOINFOEM',
  6449. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6450. // Pourquoi Tilk stockait-il tout en str ?
  6451. // -> parce que les booléens c'est foireux (vérifié)
  6452. MY_setValue(numTroll+'.USECSS',
  6453. document.getElementById('usecss').checked ? 'true':'false');
  6454. MY_setValue('INFOCARAC',
  6455. document.getElementById('infocarac').checked ? 'true' : 'false');
  6456. //MY_setValue(numTroll+'.SEND_IDT',
  6457. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6458. // Fonctionnalité désactivée
  6459.  
  6460. MY_setValue(numTroll+'.AUTOCDM',
  6461. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6462. MY_setValue('VUECARAC',
  6463. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6464. MY_setValue('CONFIRMEDECALAGE',
  6465. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6466.  
  6467. saveITData();
  6468. } catch (e) {
  6469. var bouton = document.getElementById('saveAll');
  6470. window.console.log(e);
  6471. bouton.value = "il y a eu une erreur";
  6472. return;
  6473. }
  6474.  
  6475. var bouton = document.getElementById('saveAll');
  6476. bouton.value = (bouton.value=='Sauvegardé !') ?
  6477. 'Re-sauvegardé !' : 'Sauvegardé !';
  6478. }
  6479.  
  6480.  
  6481. /*-[functions]----------------- EventListeners -------------------------------*/
  6482.  
  6483. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  6484. var itBody = document.getElementById('itBody');
  6485. var nTr = itBody.rows.length;
  6486. // enlever tous les "+" des lignes précédentes
  6487. for (iTr = 0; iTr < nTr; iTr++) {
  6488. var td = itBody.rows[iTr].cells[0];
  6489. td.innerHTML = '';
  6490. td.title = '';
  6491. td.style.cursor = 'default';
  6492. }
  6493. // ajouter une ligne
  6494. var tr = appendTr(itBody,'mh_tdpage')
  6495. var td = appendTd(tr);
  6496. if (bLast) {
  6497. td.style.whiteSpace = 'nowrap';
  6498. appendText(td, '+');
  6499. td.style.cursor = 'pointer';
  6500. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  6501. td.onclick = function (e) {
  6502. addBricolIT(undefined, undefined, undefined, false, true);
  6503. }
  6504. }
  6505. var td = appendTd(tr);
  6506. td.style.whiteSpace = 'nowrap';
  6507. appendText(td,'Nom du système : ');
  6508. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  6509. td = appendTd(tr);
  6510. td.style.whiteSpace = 'nowrap';
  6511. appendText(td,'Login du compte : ');
  6512. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  6513. td = appendTd(tr);
  6514. td.style.whiteSpace = 'nowrap';
  6515. appendText(td,'Mot de passe du compte : ');
  6516. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  6517. td = appendTd(tr);
  6518. if (bFirst) {
  6519. td.style.whiteSpace = 'nowrap';
  6520. appendText(td,'Affichage des Trõlls hors vue : ');
  6521. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  6522. }
  6523. }
  6524.  
  6525. function onChangeIT() {
  6526. var IT = document.getElementById('itSelect').value;
  6527. var itBody = document.getElementById('itBody');
  6528. itBody.innerHTML = '';
  6529. var tabStr = new Array();
  6530. if(IT=='bricol') {
  6531. for (var iBricol = 1; ; iBricol++) {
  6532. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  6533. //window.console.log('onChangeIT str=' + str);
  6534. if(str) {
  6535. tabStr.push(str);
  6536. } else {
  6537. break;
  6538. }
  6539. }
  6540. if (tabStr.length == 0) {
  6541. addBricolIT('', '', 0, true, true)
  6542. } else {
  6543. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  6544. var arr = tabStr[iBricol].split('$');
  6545. var system = arr[1];
  6546. var login = arr[2];
  6547. var affhv = arr[4];
  6548. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  6549. }
  6550. }
  6551. }
  6552. }
  6553.  
  6554. function refreshLinks() {
  6555. document.getElementById('linksBody').innerHTML = '';
  6556. var anotherURL = MY_getValue('URL1');
  6557. if(!anotherURL) { addLinkField(); }
  6558. var i=1;
  6559. while(anotherURL && i<99) {
  6560. addLinkField(i,anotherURL,
  6561. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6562. i++;
  6563. anotherURL = MY_getValue('URL'+i);
  6564. }
  6565. }
  6566.  
  6567. function addLinkField(i,url,nom,ico) {
  6568. var linksBody = document.getElementById('linksBody');
  6569. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6570. var tr = appendTr(linksBody);
  6571. var td = appendTdCenter(tr);
  6572. appendText(td,'Lien '+i+' : ');
  6573. appendTextbox(td,'text','url'+i,40,150,url);
  6574. td = appendTdCenter(tr);
  6575. appendText(td,'Nom : ');
  6576. appendTextbox(td,'text','nom'+i,20,150,nom);
  6577. td = appendTdCenter(tr);
  6578. appendText(td,'Icône : ');
  6579. appendTextbox(td,'text','ico'+i,40,150,ico);
  6580. }
  6581.  
  6582. function removeLinkField() {
  6583. var linksBody = document.getElementById('linksBody');
  6584. var i = linksBody.childNodes.length;
  6585. MY_removeValue('URL'+i);
  6586. MY_removeValue('URL'+i+'.nom');
  6587. MY_removeValue('URL'+i+'.ico');
  6588. linksBody.removeChild(linksBody.lastChild);
  6589. if(linksBody.childNodes.length==0) { addLinkField(); }
  6590. }
  6591.  
  6592. function resetMainIco() {
  6593. document.getElementById('icoMenuIco').value=
  6594. URL_MZimg + 'mz_logo_small.png';
  6595. }
  6596.  
  6597.  
  6598. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6599.  
  6600. function insertTitle(next,txt) {
  6601. var div = document.createElement('div');
  6602. div.className = 'titre2';
  6603. appendText(div,txt);
  6604. insertBefore(next,div);
  6605. return div;
  6606. }
  6607.  
  6608. function insertMainTable(next) {
  6609. var table = document.createElement('table');
  6610. table.width = '98%';
  6611. table.border = 0;
  6612. table.align = 'center';
  6613. table.cellPadding = 2;
  6614. table.cellSpacing = 1;
  6615. table.className = 'mh_tdborder';
  6616. var tbody = document.createElement('tbody');
  6617. table.appendChild(tbody);
  6618. insertBefore(next,table);
  6619. return tbody;
  6620. }
  6621.  
  6622. function appendSubTable(node) {
  6623. var table = document.createElement('table');
  6624. table.width = '100%';
  6625. var tbody = document.createElement('tbody');
  6626. table.appendChild(tbody);
  6627. node.appendChild(table);
  6628. return tbody;
  6629. }
  6630.  
  6631. function insertOptionTable(insertPt) {
  6632. var mainBody = insertMainTable(insertPt);
  6633. /* Liens dans le Menu */
  6634. var tr = appendTr(mainBody,'mh_tdtitre');
  6635. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6636. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6637. appendText(td,'Icône du Menu: ');
  6638. var url = MY_getValue(numTroll+'.ICOMENU');
  6639. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6640. url = URL_MZimg + 'mz_logo_small.png';
  6641. }
  6642. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6643. appendButton(td,'Réinitialiser',resetMainIco);
  6644. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6645. var tbody = appendSubTable(td);
  6646. tbody.id = 'linksBody';
  6647. refreshLinks();
  6648. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6649. appendButton(td,'Ajouter',addLinkField);
  6650. appendButton(td,'Supprimer',removeLinkField);
  6651. /* Options de la Vue : vue externe, nb de CdM, etc */
  6652. tr = appendTr(mainBody,'mh_tdtitre');
  6653. appendTdText(tr,'Options de la Vue :',true);
  6654. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6655. tbody = appendSubTable(td);
  6656. tr = appendTr(tbody);
  6657. td = appendTdText(tr,'Vue externe : ');
  6658. var select = document.createElement('select');
  6659. select.id = 'vueext';
  6660. td.appendChild(select);
  6661. var listeVues2D = [
  6662. 'Bricol\' Vue',
  6663. 'Vue du CCM',
  6664. 'Vue Gloumfs 2D',
  6665. 'Vue Gloumfs 3D',
  6666. 'Grouky Vue!'
  6667. ];
  6668. for(var i=0 ; i<listeVues2D.length ; i++) {
  6669. appendOption(select,listeVues2D[i],listeVues2D[i]);
  6670. }
  6671. if(MY_getValue('VUEEXT')) {
  6672. select.value = MY_getValue('VUEEXT');
  6673. }
  6674. td = appendTd(tr);
  6675. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  6676. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  6677. tr = appendTr(tbody);
  6678. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  6679. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  6680. td = appendTd(tr);
  6681. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  6682. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  6683. /* Interface Tactique */
  6684. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6685. appendText(td,'Interface Tactique : ',true);
  6686. select = document.createElement('select');
  6687. select.id = 'itSelect';
  6688. appendOption(select,'none','Aucune');
  6689. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  6690. // seule interface supportée !
  6691. td.appendChild(select);
  6692. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6693. tbody = appendSubTable(td);
  6694. tbody.id = 'itBody';
  6695. select.onchange = onChangeIT;
  6696. var str = MY_getValue(numTroll+'.INFOSIT');
  6697. if(str) {
  6698. select.value = str.slice(0,str.indexOf('$'));
  6699. onChangeIT();
  6700. }
  6701. /* Options diverses */
  6702. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6703. appendText(td,'Options diverses :',true);
  6704. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6705. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  6706. appendText(td,
  6707. ' Afficher les caractéristiques des équipements des autres Trõlls');
  6708. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6709. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  6710. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  6711. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6712. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  6713. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  6714. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6715. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  6716. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  6717. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6718. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  6719. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  6720. /* Bouton SaveAll */
  6721. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  6722. input = appendButton(td,'Sauvegarder',saveAll);
  6723. input.id = 'saveAll';
  6724. }
  6725.  
  6726. function insertCreditsTable(insertPt) {
  6727. var tbody = insertMainTable(insertPt);
  6728. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  6729. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  6730. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  6731.  
  6732. var ul = document.createElement('ul');
  6733. td.appendChild(ul);
  6734. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  6735. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  6736. appendLI(ul,'Reivax (4234) pour les infos bulles');
  6737. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  6738. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  6739. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  6740. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  6741. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  6742. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  6743. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  6744. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  6745. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  6746. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  6747. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  6748. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  6749. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  6750. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  6751. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  6752. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  6753. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  6754. }
  6755.  
  6756.  
  6757. /* [functions] Obsolètes */
  6758. function deleteEnchantement()
  6759. {
  6760. try
  6761. {
  6762. var idEquipement = this.getAttribute('name');
  6763. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  6764. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  6765. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  6766. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  6767. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  6768. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6769. var string = "";
  6770. for(var i=0;i<listeEquipement.length;i++)
  6771. {
  6772. if(listeEquipement[i]!=idEquipement)
  6773. if(string=="")
  6774. string = listeEquipement[i];
  6775. else
  6776. string += ";"+listeEquipement[i];
  6777. }
  6778. if(string=="")
  6779. {
  6780. MY_removeValue(numTroll+".enchantement.liste");
  6781. var table = this.parentNode.parentNode.parentNode.parentNode;
  6782. var parent = table.parentNode;
  6783. for(var i=0;i<parent.childNodes.length;i++)
  6784. {
  6785. if(parent.childNodes[i]==table)
  6786. {
  6787. parent.removeChild(parent.childNodes[i-1]);
  6788. parent.removeChild(parent.childNodes[i-1]);
  6789. parent.removeChild(parent.childNodes[i-1]);
  6790. break;
  6791. }
  6792. }
  6793. }
  6794. else
  6795. {
  6796. MY_getValue(numTroll+".enchantement.liste",string);
  6797. this.parentNode.parentNode.parentNode
  6798. .removeChild(this.parentNode.parentNode);
  6799. }
  6800. }
  6801. catch(e)
  6802. {
  6803. window.alert(e);
  6804. }
  6805. }
  6806. /* [functions] fin Obsolètes */
  6807.  
  6808. /*-[functions]---------------- Partie principale -----------------------------*/
  6809.  
  6810. function do_option() {
  6811. start_script(712);
  6812. var insertPoint = document.getElementById('footer1');
  6813. insertBefore(insertPoint,document.createElement('p'));
  6814. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  6815. ti.onclick = function (e) {
  6816. var evt = e || window.event;
  6817. if (evt.shiftKey) {
  6818. var txt = '';
  6819. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6820. var k = localStorage.key(i);
  6821. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  6822. txt += k + "\t" + localStorage.getItem(k) + "\n";
  6823. }
  6824. copyTextToClipboard(txt);
  6825. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  6826. } else if (evt.ctrlKey) {
  6827. var tabK= [];
  6828. var sMatch = numTroll + '.';
  6829. var lMatch = sMatch.length;
  6830. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  6831. var k = localStorage.key(i);
  6832. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  6833. }
  6834. for (var i = 0; i < tabK.length; ++i ) {
  6835. MY_removeValue(tabK[i]);
  6836. }
  6837. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  6838. }
  6839. }
  6840. ti.title = 'Version ' + GM_info.script.version;
  6841. insertOptionTable(insertPoint);
  6842. /* insertion enchantements ici
  6843. if(...)
  6844. insertEnchantementTable();
  6845. */
  6846. insertBefore(insertPoint,document.createElement('p'));
  6847. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  6848. ti.onclick = function (e) {
  6849. var evt = e || window.event;
  6850. if (!evt.shiftKey) return;
  6851. var oldDev = MY_getValue('MZ_dev');
  6852. if (oldDev) {
  6853. MY_removeValue('MZ_dev');
  6854. } else {
  6855. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  6856. MY_setValue('MZ_dev', 1);
  6857. }
  6858. document.location.href = document.location.href;
  6859. }
  6860. insertCreditsTable(insertPoint);
  6861. insertBefore(insertPoint,document.createElement('p'));
  6862.  
  6863. /* [zone] Obsolète ?? */
  6864. if(MY_getValue(numTroll+".enchantement.liste")
  6865. && MY_getValue(numTroll+".enchantement.liste")!="" )
  6866. {
  6867. insertTitle(insertPoint, 'Les Enchantements en cours');
  6868. table = document.createElement('table');
  6869. table.setAttribute('width', '98%');
  6870. table.setAttribute('border', '0');
  6871. table.setAttribute('align', 'center');
  6872. table.setAttribute('cellpadding', '2');
  6873. table.setAttribute('cellspacing', '1');
  6874. table.setAttribute('class', 'mh_tdborder');
  6875.  
  6876. tbody = document.createElement('tbody');
  6877. table.appendChild(tbody);
  6878. tr = appendTr(tbody, 'mh_tdtitre');
  6879. appendTdText(tr, 'Equipement',1);
  6880. appendTdText(tr, 'Composants',1);
  6881. appendTdText(tr, 'Enchanteur',1);
  6882. appendTdText(tr, 'Action',1);
  6883. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6884. for(var i=0;i<listeEquipement.length;i++)
  6885. {
  6886. try
  6887. {
  6888. var idEquipement = listeEquipement[i];
  6889. var nomEquipement = MY_getValue(numTroll+".enchantement."
  6890. +idEquipement+".objet");
  6891. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  6892. +idEquipement+".enchanteur").split(";");
  6893. var ul = document.createElement('UL');
  6894. for(var j=0;j<3;j++)
  6895. {
  6896. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  6897. var v = MY_getValue(k);
  6898. if (v == null) { // protection Roule 26/08/2017
  6899. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  6900. continue;
  6901. }
  6902. var infoComposant = v.split(';');
  6903. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  6904. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  6905. continue;
  6906. }
  6907. var texte = infoComposant[4].replace("Ril ","Œil ");
  6908. for(var k=5;k<infoComposant.length;k++)
  6909. {
  6910. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  6911. }
  6912. li = appendLI(ul,texte);
  6913. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  6914. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  6915. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  6916. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  6917. string+= '<input type="hidden" name="q" value="min" />';
  6918. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  6919. 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>';
  6920.  
  6921. string+= '</form>';
  6922. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  6923. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  6924. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  6925. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  6926. li.innerHTML += string;
  6927. }
  6928. tr = appendTr(tbody, 'mh_tdpage');
  6929. td = appendTdText(tr, nomEquipement);
  6930. td.setAttribute('valign', 'center');
  6931. td = document.createElement('td');
  6932. td.appendChild(ul);
  6933. tr.appendChild(td);
  6934. td.setAttribute('valign', 'center');
  6935. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  6936. td.setAttribute('valign', 'center');
  6937. td = document.createElement('td');
  6938. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  6939. input.setAttribute('name', idEquipement);
  6940. tr.appendChild(td);
  6941. td.setAttribute('valign', 'center');
  6942. }
  6943. catch(e)
  6944. {
  6945. }
  6946. }
  6947. insertBefore(insertPoint, table);
  6948. insertBefore(insertPoint, document.createElement('p'));
  6949. }
  6950. /* [zone] fin Obsolète ?? */
  6951.  
  6952.  
  6953. displayScriptTime();
  6954. }
  6955.  
  6956. /*******************************************************************************
  6957. * This file is part of Mountyzilla. *
  6958. * *
  6959. * Mountyzilla is free software; you can redistribute it and/or modify *
  6960. * it under the terms of the GNU General Public License as published by *
  6961. * the Free Software Foundation; either version 2 of the License, or *
  6962. * (at your option) any later version. *
  6963. * *
  6964. * Mountyzilla is distributed in the hope that it will be useful, *
  6965. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6966. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6967. * GNU General Public License for more details. *
  6968. * *
  6969. * You should have received a copy of the GNU General Public License *
  6970. * along with Mountyzilla; if not, write to the Free Software *
  6971. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6972. *******************************************************************************/
  6973.  
  6974. // x~x equip
  6975.  
  6976. /**
  6977. * 2014-02-08 - v2.0a (from scratch)
  6978. * 2014-02-18 - v2.0a0
  6979. * - ajout calcul Carats / UM des minerais + totaux
  6980. * 2014-03-06 - v2.0a1
  6981. * - retour Infos EM des Champis
  6982. * TODO
  6983. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6984. */
  6985.  
  6986. function traiteChampis() {
  6987. try{
  6988. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6989. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6990. }
  6991. catch(e){return;}
  6992. if(trlist.length<=0) return;
  6993. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6994. var node = trlist.snapshotItem(i).childNodes[7];
  6995. var str = node.textContent.trim();
  6996. var type = str.slice(0,str.lastIndexOf(' '));
  6997. var mundi = mundiChampi[type];
  6998. if(!mundi) continue;
  6999. var urlImg = URL_MZimg
  7000. +'Competences/ecritureMagique.png';
  7001. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  7002. appendText(node,' ');
  7003. node.appendChild(img);
  7004. }
  7005. }
  7006.  
  7007. function traiteCompos() {
  7008. try {
  7009. var tr = document.getElementById('mh_objet_hidden_Composant');
  7010. var tbody = document.evaluate("./td/table/tbody",
  7011. tr, null, 9, null).singleNodeValue;
  7012. }
  7013. catch(e) {return;}
  7014. insererInfosEM(tbody);
  7015. }
  7016.  
  7017. function traiteMinerai() {
  7018. try{
  7019. var tr = document.getElementById('mh_objet_hidden_Minerai');
  7020. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  7021. }
  7022. catch(e){return;}
  7023. if(trlist.length<=0) return;
  7024. var totaux = {};
  7025. var str;
  7026. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  7027. var node = trlist.snapshotItem(i);
  7028. var nature = node.childNodes[7].textContent,
  7029. caracs = node.childNodes[9].textContent;
  7030. var taille = Number(caracs.match(/\d+/)[0]);
  7031. var coef = 1;
  7032. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  7033. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  7034. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  7035. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  7036. if(nature.indexOf('Mithril')!=-1) {
  7037. coef = 0.2*coef;
  7038. str = ' | UM: ';
  7039. }
  7040. else {
  7041. coef = 0.75*coef+1.25;
  7042. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  7043. str = ' | Carats: ';
  7044. }
  7045. var carats = Math.round(taille*coef)
  7046. appendText(node.childNodes[9], str+carats );
  7047. if(!totaux[nature]) {
  7048. totaux[nature] = [taille,carats];
  7049. }
  7050. else {
  7051. totaux[nature][0] += taille;
  7052. totaux[nature][1] += carats;
  7053. }
  7054. }
  7055. str = 'Total : ';
  7056. for(var nature in totaux) {
  7057. if(str.length>8) str += ', ';
  7058. if(nature.indexOf('Mithril')!=-1) {
  7059. str += nature+totaux[nature][1]+' UM';
  7060. }
  7061. else {
  7062. str += nature+totaux[nature][0]+'U/'
  7063. +totaux[nature][1]+'c';
  7064. }
  7065. }
  7066. /*var node = document.getElementById('mh_plus_Minerai');
  7067. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  7068. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  7069. if(!titre) return;*/
  7070. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  7071. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  7072. td.colSpan = 7;
  7073. }
  7074.  
  7075. function do_equip() {
  7076. start_script();
  7077.  
  7078. traiteChampis();
  7079. traiteCompos();
  7080. traiteMinerai();
  7081.  
  7082. displayScriptTime();
  7083. }
  7084.  
  7085. /*******************************************************************************
  7086. * This file is part of Mountyzilla. *
  7087. * *
  7088. * Mountyzilla is free software; you can redistribute it and/or modify *
  7089. * it under the terms of the GNU General Public License as published by *
  7090. * the Free Software Foundation; either version 2 of the License, or *
  7091. * (at your option) any later version. *
  7092. * *
  7093. * Mountyzilla is distributed in the hope that it will be useful, *
  7094. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7095. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7096. * GNU General Public License for more details. *
  7097. * *
  7098. * You should have received a copy of the GNU General Public License *
  7099. * along with Mountyzilla; if not, write to the Free Software *
  7100. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7101. *******************************************************************************/
  7102.  
  7103. // x~x diplo
  7104.  
  7105. /*
  7106. TODO:
  7107. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  7108. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  7109. V Étape 3: Ajout de la diplo perso
  7110. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  7111. V Étape 5: Ajout des fioritures (preview de la couleur...)
  7112. Options Globales:
  7113. Actuelles:
  7114. numTroll.USECSS,
  7115. numTroll.NODIPLO
  7116. NOMYTH
  7117. Nouvelles:
  7118. TODO numTroll.USECSS
  7119. numTroll.diplo.off (remplace NODIPLO)
  7120. numTroll.diplo.guilde
  7121. numTroll.diplo.perso
  7122. Structure de diplo.guilde:
  7123. isOn: 'true' ou 'false'
  7124. isDetailOn: 'true' ou 'false'
  7125. guilde
  7126. > id
  7127. > couleur
  7128. AllAmis,AllEnnemis: couleur
  7129. Amis0,...,Ennemis5
  7130. > Troll: idTroll1;...;
  7131. > Guilde: idGuilde1;...;
  7132. > titre
  7133. > couleur
  7134. Structure de diplo.perso:
  7135. isOn: 'true' ou 'false'
  7136. mythiques: couleur
  7137. Troll,Guilde,Monstre:
  7138. > id
  7139. > couleur
  7140. > description
  7141. */
  7142.  
  7143. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7144.  
  7145. function couleurAleatoire() {
  7146. var alph = '0123456789ABCDEF'.split('');
  7147. var clr = '#';
  7148. for (var i=0; i<6; i++) {
  7149. clr+=alph[ Math.floor(16*Math.random()) ];
  7150. }
  7151. return clr;
  7152. }
  7153.  
  7154. function isCouleur(str) {
  7155. return /^#[0-9A-F]{6}$/i.test(str);
  7156. }
  7157.  
  7158. /*-[functions]---------------- Analyse de la page ----------------------------*/
  7159.  
  7160. function appendChoixCouleur(node,id) {
  7161. var span = document.createElement('span');
  7162. span.id = 'span'+id;
  7163. if(isDetailOn) {
  7164. span.style.display = 'none';
  7165. }
  7166. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  7167. if(diploGuilde[id]) {
  7168. couleur = diploGuilde[id];
  7169. }
  7170. appendText(span,' - Couleur HTML: ');
  7171. var input = appendTextbox(span,'text',id,7,7,couleur);
  7172. input.onkeyup = previewCouleur;
  7173. input.onchange = previewCouleur;
  7174. input.onkeyup();
  7175. node.appendChild(span);
  7176. }
  7177.  
  7178. function insertChoixCouleur(node,id) {
  7179. var span = document.createElement('span');
  7180. span.id = 'span'+id;
  7181. // La couleur détaillée passera à une valeur aléatoire
  7182. // si toggle vers isDetailOn
  7183. var couleur = couleurAleatoire();
  7184. if(!isDetailOn) {
  7185. span.style.display = 'none';
  7186. } else if(diploGuilde[id]) {
  7187. couleur = diploGuilde[id].couleur;
  7188. }
  7189. appendText(span,' - Couleur HTML: ');
  7190. var input = appendTextbox(span,'text',id,7,7,couleur);
  7191. input.onkeyup = previewCouleur;
  7192. input.onchange = previewCouleur;
  7193. input.onkeyup();
  7194. insertBefore(node,span);
  7195. }
  7196.  
  7197. function setChoixCouleurs() {
  7198. try {
  7199. //var form = document.getElementsByName('ActionForm')[0];
  7200. var form = document.getElementById('mhPlay');
  7201. var nodesAE = document.evaluate(
  7202. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  7203. "./table/tbody/tr/th[@class='mh_tdtitre']",
  7204. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  7205. form, null, 7, null
  7206. );
  7207. var nodes = document.evaluate(
  7208. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  7209. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  7210. form, null, 7, null
  7211. );
  7212. } catch(e) {
  7213. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  7214. return false;
  7215. };
  7216. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  7217. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  7218. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  7219. for(var i=0 ; i<5 ; i++) {
  7220. nodes.snapshotItem(i).id = 'tdAmis'+i;
  7221. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  7222. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  7223. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  7224. }
  7225. return true;
  7226. }
  7227.  
  7228. function fetchDiploGuilde() {
  7229. try {
  7230. for(var AE in {Amis:0,Ennemis:0}) {
  7231. for(var i=0 ; i<5 ; i++) {
  7232. /* Récup des A/E de rang i */
  7233. var td = document.getElementById('td'+AE+i);
  7234. var ligne = td.getElementsByTagName('table')[0].rows;
  7235. var titre = trim(td.firstChild.textContent);
  7236. // On laisse la gestion des couleurs à setChoixCouleurs:
  7237. var couleur = document.getElementById(AE+i).value;
  7238. diploGuilde[AE+i] = {
  7239. Troll:'',
  7240. Guilde:'',
  7241. titre: titre,
  7242. couleur: couleur
  7243. };
  7244. for(var j=1 ; j<ligne.length ; j++) {
  7245. var str = trim(ligne[j].cells[0].textContent);
  7246. var idx = str.lastIndexOf('(');
  7247. var num = str.slice(idx+1,-1);
  7248. var type = trim(ligne[j].cells[1].textContent);
  7249. diploGuilde[AE+i][type] += num+';';
  7250. }
  7251. }
  7252. }
  7253. } catch(e) {
  7254. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  7255. return false;
  7256. }
  7257. return true;
  7258. }
  7259.  
  7260.  
  7261. /*-[functions]--------------------- Handlers ---------------------------------*/
  7262.  
  7263. function toggleDetails() {
  7264. isDetailOn = !isDetailOn;
  7265. for(var AE in {Amis:0,Ennemis:0}) {
  7266. document.getElementById('spanAll'+AE).style.display =
  7267. (isDetailOn?'none':'');
  7268. for(var i=0 ; i<5 ; i++) {
  7269. document.getElementById('span'+AE+i).style.display =
  7270. (isDetailOn?'':'none');
  7271. }
  7272. }
  7273. }
  7274.  
  7275. function toggleMythiques() {
  7276. isMythiquesOn = !isMythiquesOn;
  7277. document.getElementById('spanMythiques').style.display =
  7278. (isMythiquesOn?'':'none');
  7279. }
  7280.  
  7281. function previewCouleur() {
  7282. var value = this.value;
  7283. if(isCouleur(value)) {
  7284. this.style.backgroundColor = value;
  7285. this.title = '';
  7286. } else {
  7287. this.style.backgroundColor = '';
  7288. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  7289. }
  7290. }
  7291.  
  7292. function appendMenuType(node,duType) {
  7293. var select = document.createElement('select');
  7294. select.className = 'SelectboxV2';
  7295. var type = ['Guilde','Troll','Monstre'];
  7296. for(var i=0 ; i<3 ; i++) {
  7297. appendOption(select,type[i],type[i]);
  7298. if(type[i]==duType) { select.selectedIndex=i; }
  7299. }
  7300. node.appendChild(select);
  7301. }
  7302.  
  7303. function ajouteChamp(type,num,couleur,descr) {
  7304. var champs = document.getElementById('diploPerso');
  7305. var nb = champs.rows.length;
  7306. var tr = champs.insertRow(-1);
  7307. var td = appendTd(tr);
  7308. appendMenuType(td,type);
  7309. td = appendTd(tr);
  7310. appendText(td,' n°');
  7311. appendTextbox(td,'text','num'+nb,6,15,num);
  7312. td = appendTd(tr);
  7313. appendText(td,' couleur HTML:');
  7314. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7315. input.onkeyup = previewCouleur;
  7316. input.onchange = previewCouleur;
  7317. input.onkeyup();
  7318. td = appendTd(tr);
  7319. appendText(td,' Description:');
  7320. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7321. td = appendTd(tr);
  7322. var span = document.createElement('span');
  7323. appendText(span,'[ok!]',true);
  7324. span.style.visibility = 'hidden';
  7325. td.appendChild(span);
  7326. td = appendTd(tr);
  7327. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7328. }
  7329.  
  7330. function retireCeChamp() {
  7331. var thisTr = this.parentNode.parentNode;
  7332. thisTr.parentNode.removeChild(thisTr);
  7333. var champs = document.getElementById('diploPerso');
  7334. if(champs.rows.length==0) { ajouteChamp(); }
  7335. }
  7336.  
  7337. function valideChamp(champ) {
  7338. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7339. isCouleur(champ.cells[2].childNodes[1].value);
  7340. if(isValide) {
  7341. champ.cells[4].firstChild.style.visibility = 'visible';
  7342. } else {
  7343. champ.cells[4].firstChild.style.visibility = 'hidden';
  7344. }
  7345. return isValide;
  7346. }
  7347.  
  7348. function sauvegarderTout() {
  7349. /* Diplo de guilde */
  7350. diploGuilde.isOn =
  7351. document.getElementById('isGuildeOn').checked?'true':'false';
  7352. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7353. var numGuilde = Number(document.getElementById('numGuilde').value);
  7354. var couleur = document.getElementById('couleurGuilde').value;
  7355. if(numGuilde) {
  7356. diploGuilde.guilde = {
  7357. id: numGuilde,
  7358. couleur: couleur
  7359. };
  7360. } else {
  7361. delete diploGuilde.guilde;
  7362. }
  7363. for(var AE in {Amis:0,Ennemis:0}) {
  7364. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7365. for(var i=0 ; i<5 ; i++) {
  7366. if(isDetailOn) {
  7367. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7368. } else {
  7369. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7370. }
  7371. }
  7372. }
  7373. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7374. /* Diplo personnelle (ex-fonction saveChamps) */
  7375. var champs = document.getElementById('diploPerso');
  7376. diploPerso = {
  7377. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7378. Guilde: {},
  7379. Troll: {},
  7380. Monstre: {}
  7381. };
  7382. if(isMythiquesOn &&
  7383. isCouleur(document.getElementById('couleurMythiques').value)) {
  7384. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7385. }
  7386. for(var i=0 ; i<champs.rows.length ; i++) {
  7387. if(valideChamp(champs.rows[i])) {
  7388. var type = champs.rows[i].cells[0].firstChild.value;
  7389. var num = champs.rows[i].cells[1].childNodes[1].value;
  7390. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7391. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7392. diploPerso[type][num] = {
  7393. couleur: couleur
  7394. };
  7395. if(descr) {
  7396. diploPerso[type][num].titre = descr;
  7397. }
  7398. }
  7399. }
  7400. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7401.  
  7402. avertissement('Données sauvegardées');
  7403. }
  7404.  
  7405.  
  7406. /*-[functions]------------- Modifications de la page -------------------------*/
  7407.  
  7408. function creeTablePrincipale() {
  7409. var insertPt = document.getElementById('insertPt');
  7410. /* Titre + bouton de Sauvegarde */
  7411. var tr = insertTr(insertPt,'mh_tdtitre');
  7412. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7413. appendButton(td,'Sauvegarder',sauvegarderTout);
  7414. /* Options fixes */
  7415. tr = insertTr(insertPt,'mh_tdpage');
  7416. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7417. appendBr(td);
  7418. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7419. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7420. appendBr(td);
  7421. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7422. appendText(td,'Utiliser des couleurs détaillées (10)');
  7423. /* Diplo personnelle */
  7424. tr = insertTr(insertPt,'mh_tdpage');
  7425. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7426. appendBr(td);
  7427. // Diplo Mythiques
  7428. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7429. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7430. var span = document.createElement('span');
  7431. span.id = 'spanMythiques';
  7432. if(!isMythiquesOn) {
  7433. span.style.display = 'none';
  7434. }
  7435. var couleur = '#FFAAAA';
  7436. if(diploPerso.mythiques) {
  7437. couleur = diploPerso.mythiques;
  7438. }
  7439. appendText(span,' - couleur HTML:');
  7440. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7441. input.onkeyup = previewCouleur;
  7442. input.onchange = previewCouleur;
  7443. input.onkeyup();
  7444. td.appendChild(span);
  7445. appendBr(td);
  7446. // Diplo éditable
  7447. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7448. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7449. appendBr(td);
  7450. var table = document.createElement('table');
  7451. table.id = 'diploPerso'
  7452. td.appendChild(table);
  7453. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7454. for(var num in diploPerso[type]) {
  7455. ajouteChamp(
  7456. type,
  7457. num,
  7458. diploPerso[type][num].couleur,
  7459. diploPerso[type][num].titre
  7460. );
  7461. }
  7462. }
  7463. if(table.rows.length==0) {
  7464. ajouteChamp();
  7465. }
  7466. appendButton(td,'Ajouter',ajouteChamp)
  7467. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7468. appendText(td,' ');
  7469. appendButton(td,
  7470. 'Exemples de couleur',
  7471. function() {
  7472. var fenetre = window.open(
  7473. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7474. 'Divers',
  7475. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7476. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7477. );
  7478. fenetre.focus();
  7479. }
  7480. );
  7481. /* Couleur de Guilde */
  7482. tr = insertTr(insertPt,'mh_tdtitre');
  7483. td = appendTdText(tr,'GUILDE',true);
  7484. appendText(td,' - n°');
  7485. appendTextbox(td,'text','numGuilde',5,10,
  7486. diploGuilde.guilde && diploGuilde.guilde.id ?
  7487. diploGuilde.guilde.id : ''
  7488. );
  7489. appendText(td,' - Couleur HTML: ');
  7490. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7491. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7492. diploGuilde.guilde.couleur : '#BBBBFF'
  7493. );
  7494. input.onkeyup = previewCouleur;
  7495. input.onchange = previewCouleur;
  7496. input.onkeyup();
  7497. }
  7498.  
  7499.  
  7500. /*-[functions]----------------------- Main -----------------------------------*/
  7501.  
  7502. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  7503. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  7504. var isDetailOn = diploGuilde.isDetailOn=='true';
  7505. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  7506. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  7507. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7508.  
  7509. function do_diplo() {
  7510. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7511. creeTablePrincipale();
  7512. }
  7513. }
  7514.  
  7515. /*******************************************************************************
  7516. * This file is part of Mountyzilla. *
  7517. * *
  7518. * Mountyzilla is free software; you can redistribute it and/or modify *
  7519. * it under the terms of the GNU General Public License as published by *
  7520. * the Free Software Foundation; either version 2 of the License, or *
  7521. * (at your option) any later version. *
  7522. * *
  7523. * Mountyzilla is distributed in the hope that it will be useful, *
  7524. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7525. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7526. * GNU General Public License for more details. *
  7527. * *
  7528. * You should have received a copy of the GNU General Public License *
  7529. * along with Mountyzilla; if not, write to the Free Software *
  7530. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7531. *******************************************************************************/
  7532.  
  7533. // x~x cdmcomp
  7534.  
  7535. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  7536.  
  7537. function getNonNegInts(str) {
  7538. var nbrs = str.match(/\d+/g);
  7539. for(var i=0 ; i<nbrs.length ; i++) {
  7540. nbrs[i] = Number(nbrs[i]);
  7541. }
  7542. return nbrs;
  7543. }
  7544.  
  7545. function traiteCdMcomp() {
  7546. try {
  7547. var msgEffet = document.getElementById('msgEffet');
  7548. } catch(e) {
  7549. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  7550. return;
  7551. }
  7552.  
  7553. // Teste si ce message du bot est un message de CdM
  7554. if(!document.evaluate(
  7555. "./p/text()[contains(.,'fait partie')]",
  7556. msgEffet, null, 9, null
  7557. ).singleNodeValue) {
  7558. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  7559. return;
  7560. }
  7561. // Début de récupération de la CdM
  7562. /*
  7563. Roule 10/03/2017 j'ai grandement simplifié ☺ ☺ ☺
  7564. zone à supprimer
  7565. traitement Armure Physique/Magique reporté en php
  7566.  
  7567. cdm = document.evaluate(
  7568. "./p/text()[contains(.,'fait partie')]",
  7569. msgEffet, null, 9, null
  7570. ).singleNodeValue.nodeValue+'\n';
  7571. var tbody = document.evaluate(
  7572. "descendant::table/tbody",
  7573. msgEffet, null, 9, null
  7574. ).singleNodeValue;
  7575. var nomStat = document.evaluate(
  7576. "./tr/td[1]/b/text()",
  7577. tbody, null, 7, null
  7578. );
  7579. var valStat = document.evaluate(
  7580. "./tr/td[2]/descendant::text()",
  7581. tbody, null, 7, null
  7582. );
  7583. var i=0;
  7584. while(i<nomStat.snapshotLength) {
  7585. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7586. cdm += 'Armure : ';
  7587. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7588. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7589. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7590. armp = [0,armp[0]];
  7591. }
  7592. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7593. armm = [0,armm[0]];
  7594. }
  7595. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7596. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7597. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7598. } else {
  7599. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7600. }
  7601. cdm += ')\n';
  7602. i++;
  7603. } else {
  7604. cdm += nomStat.snapshotItem(i).nodeValue+
  7605. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7606. }
  7607. i++;
  7608. }
  7609. */
  7610. //cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  7611. //if (MY_DEBUG) window.console.log('cmd=' + cdm);
  7612.  
  7613. // envoi au serveur (PHP) d'un objet avec
  7614. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  7615. // tstamp: l'horodatage
  7616. var tabCdM = new Array();
  7617. var etimestamp = document.getElementById('hserveur');
  7618. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  7619. var txtBlessure;
  7620. var txtPv;
  7621. for (var iElt = 0; iElt < msgEffet.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  7622. var eHTML = msgEffet.childNodes[iElt];
  7623. switch (eHTML.nodeName) {
  7624. case '#text':
  7625. var s = eHTML.nodeValue.trim();
  7626. if (s != '') tabCdM.push(s);
  7627. break;
  7628. case 'P':
  7629. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7630. s = s.trim();
  7631. if (s != '') tabCdM.push(s);
  7632. break;
  7633. case 'TABLE':
  7634. var s = 'table';
  7635. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  7636. var eTr = eHTML.rows[iTr];
  7637. var tabTd = new Array();
  7638. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  7639. var eTd = eTr.cells[iTd];
  7640. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  7641. s = s.trim();
  7642. tabTd.push(s);
  7643. }
  7644. if (tabTd.length >= 2) {
  7645. if (tabTd[0].match(/Blessure/i)) {
  7646. txtBlessure = tabTd[1]
  7647. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  7648. txtPv = tabTd[1]
  7649. }
  7650. }
  7651. tabCdM.push(tabTd);
  7652. }
  7653. break;
  7654. default:
  7655. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  7656. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7657. if (s != '') tabCdM.push(s);
  7658. break;
  7659. }
  7660. }
  7661. var oData = {};
  7662. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  7663. oData.idTroll = numTroll;
  7664. oData.tabCdM = tabCdM;
  7665. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  7666.  
  7667. // envoi d'une CdM issue de compte-rendu de compétence
  7668. // fonction définie ici pour avoir vue sur la variable tabCdM
  7669. var sendInfoCDM = function () {
  7670. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  7671. var buttonCDM = this;
  7672. var texte = '';
  7673. FF_XMLHttpRequest({
  7674. method: 'POST',
  7675. url: URL_pageDispatcherV2,
  7676. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7677. headers : {
  7678. /* inutile, à supprimer
  7679. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7680. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7681. */
  7682. 'Content-type':'application/x-www-form-urlencoded',
  7683. },
  7684. trace: 'envoi CdM',
  7685. onload: function(responseDetails) {
  7686. texte = responseDetails.responseText;
  7687. buttonCDM.value = texte;
  7688. if (!isDEV) buttonCDM.disabled = true;
  7689. }
  7690. });
  7691. }
  7692.  
  7693. // Envoi auto ou insertion bouton envoi (suivant option)
  7694. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  7695. sendInfoCDM();
  7696. var p = document.createElement('p');
  7697. p.style.color = 'green';
  7698. appendText(p,'CdM envoyée vers la base MountyZilla !');
  7699. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  7700. } else {
  7701. insertButtonCdm('as_Action', sendInfoCDM);
  7702. }
  7703.  
  7704. // Insertion de l'estimation des PV restants
  7705. /*
  7706. var pv = valStat.snapshotItem(1).nodeValue;
  7707. if(pv.indexOf("entre")==-1) {
  7708. return;
  7709. }
  7710. var trPv = document.evaluate(
  7711. "//tr[contains(td/b/text(),'Points de Vie')]",
  7712. msgEffet, null, 9, null).singleNodeValue;
  7713. tdPv = trPv.cells[1];
  7714. txtPv = tdPv.innerText || tdPv.textContent;
  7715. if (MY_DEBUG) window.console.log('txtPv=' + txtPv);
  7716. if(0) { //pv) { // bloqué en attendant correction
  7717. */
  7718. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  7719. if (txtBlessure !== undefined && txtPv !== undefined) {
  7720. var pv = getPVsRestants(txtPv,txtBlessure);
  7721. if (MY_DEBUG) window.console.log('pv=' + pv);
  7722. if (pv) { // pv null si le monstre n'est pas blessé
  7723. var trBless = document.evaluate(
  7724. "//tr[contains(td/b/text(),'Blessure')]",
  7725. msgEffet, null, 9, null).singleNodeValue;
  7726. var tr = document.createElement('tr');
  7727. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  7728. appendTr(trBless);
  7729. appendTdText(tr, pv[0], true);
  7730. appendTdText(tr, pv[1], true);
  7731. }
  7732. }
  7733. }
  7734.  
  7735. function do_cdmcomp() {
  7736. start_script(31);
  7737. traiteCdMcomp();
  7738. displayScriptTime();
  7739. }
  7740.  
  7741. /*********************************************************************************
  7742. * This file is part of Mountyzilla. *
  7743. * *
  7744. * Mountyzilla is free software; you can redistribute it and/or modify *
  7745. * it under the terms of the GNU General Public License as published by *
  7746. * the Free Software Foundation; either version 2 of the License, or *
  7747. * (at your option) any later version. *
  7748. * *
  7749. * Mountyzilla is distributed in the hope that it will be useful, *
  7750. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7751. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7752. * GNU General Public License for more details. *
  7753. * *
  7754. * You should have received a copy of the GNU General Public License *
  7755. * along with Mountyzilla; if not, write to the Free Software *
  7756. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7757. *********************************************************************************/
  7758.  
  7759. // x~x cmdbot
  7760.  
  7761. /* v0.2 by Dab - 2013-08-20
  7762. * - patch dégueu pour gérer la décomposition P/M de l'armure
  7763. */
  7764.  
  7765. var buttonCDM;
  7766.  
  7767. /*******************************************************************************************
  7768. CDM :
  7769. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  7770.  
  7771. Il ne vous est pas possible d'améliorer cette compétence.
  7772.  
  7773. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  7774. Niveau : Inimaginable (entre 49 et 51)
  7775. Points de Vie : Surtrollesque (entre 450 et 470)
  7776. Blessure (Approximatif) : 0 %
  7777. Dés d'Attaque : Impressionnant (entre 30 et 32)
  7778. Dés d'Esquive : Impressionnant (entre 28 et 30)
  7779. Dés de Dégat : Très Fort (entre 18 et 20)
  7780. Dés de Régénération : Excellent (égal à 13)
  7781. Armure Physique : Moyen (entre 10 et 12)
  7782. Armure Magique : Faible (inférieur à 6)
  7783. Vue : Moyen (entre 9 et 11)
  7784. Maitrise Magique : Inimaginable (supérieur à 6000)
  7785. Résistance Magique : Inimaginable (supérieur à 6000)
  7786. Nombre d'attaques : 1
  7787. Vitesse de Déplacement : Normale
  7788. Voir le Caché : Oui
  7789. Attaque à distance : Non
  7790. Attaque magique : Oui
  7791. Vole : Non
  7792. Sang froid : Inexistant
  7793. DLA : Milieu
  7794. Durée Tour : Remarquable (entre 9 et 11)
  7795. Chargement : Vide
  7796. Bonus Malus : Aucun
  7797.  
  7798. Vous avez également gagné 1 PX pour la réussite.
  7799. *******************************************************************************************
  7800. BOT :
  7801. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  7802.  
  7803. Le Monstre ciblé fait partie des : Mort-Vivant
  7804.  
  7805. Niveau : Incroyable (entre 36 et 38)
  7806. *******************************************************************************************/
  7807.  
  7808. function getNNInt(str) {
  7809. var nbrs = str.match(/\d+/g);
  7810. for (var i=0 ; i<nbrs.length ; i++)
  7811. nbrs[i] = parseInt(nbrs[i]);
  7812. return nbrs;
  7813. }
  7814.  
  7815. // envoi d'une CdM issue d'un message du BOT
  7816. function sendCDM() {
  7817. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  7818. document, null, 9, null).singleNodeValue;
  7819. /* ancienne version à supprimer
  7820. cdm = td.innerHTML;
  7821. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  7822. "$3$4 ($1 - N°$2)<br>");
  7823. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  7824. 'Blessure : XX % (approximativement)');
  7825. // Supprime la décomposition P/M de l'Armure
  7826. var bgn = cdm.indexOf('Armure Physique');
  7827. if (bgn!=-1) {
  7828. var end = cdm.indexOf('Vue')-2;
  7829. var lines = cdm.substring(bgn,end).split('<br>');
  7830. var armp = getNNInt(lines[0]);
  7831. var armm = getNNInt(lines[1]);
  7832. if (lines[0].indexOf('(inf')!=-1)
  7833. armp = [0,armp[0]];
  7834. if (lines[1].indexOf('(inf')!=-1)
  7835. armm = [0,armm[0]];
  7836. var insrt = 'Armure : ';
  7837. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  7838. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  7839. else
  7840. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7841. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  7842. }
  7843. cdm = cdm.replace(/<br>/g,'\n');
  7844. */
  7845.  
  7846. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  7847. //window.console.log(tdTxt);
  7848. var oData = {};
  7849. oData.tabCdM = tdTxt.split(/\n/);
  7850. // nettoyage entête : enlève le premier élément tant que
  7851. // - suite de *
  7852. // - "MOUNTYHALL - La Terre des Trõlls"
  7853. // - ligne vide (la première expression régulière matche les lignes vides)
  7854. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  7855. // 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
  7856. var iLigneNonVide;
  7857. for (var i = 0; i < oData.tabCdM.length; i++) {
  7858. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  7859. if (iLigneNonVide === undefined)
  7860. oData.tabCdM.splice(i);
  7861. else
  7862. oData.tabCdM.splice(iLigneNonVide+1);
  7863. break;
  7864. }
  7865. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  7866. }
  7867. //window.console.log(JSON.stringify(oData));
  7868.  
  7869. FF_XMLHttpRequest({
  7870. method: 'POST',
  7871. url: URL_pageDispatcherV2,
  7872. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7873. headers : {
  7874. /* inutile, à supprimer
  7875. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7876. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7877. */
  7878. 'Content-type':'application/x-www-form-urlencoded',
  7879. },
  7880. trace: 'envoi CdM msg du bot',
  7881. onload: function(responseDetails) {
  7882. buttonCDM.value=responseDetails.responseText;
  7883. buttonCDM.disabled = true;
  7884. }
  7885. });
  7886. }
  7887.  
  7888. function traiteCdMmsg() {
  7889. // Teste si ce message du bot est un message de CdM
  7890. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7891. document, null, 9, null).singleNodeValue;
  7892. if (!td) return false;
  7893. cdm = td.innerHTML;
  7894. // Insertion de l'estimation des PV restants
  7895. var des = cdm.indexOf('Dés');
  7896. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  7897. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  7898. if(pv)
  7899. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  7900.  
  7901. // Insertion bouton envoi + espace
  7902. buttonCDM = insertButtonCdm('bClose',sendCDM);
  7903. }
  7904.  
  7905. /*function traitePouvoir() {
  7906. // Teste si ce message du bot est un message de CdM
  7907. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  7908. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  7909. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7910. if (!td)
  7911. return false;
  7912. var infos = td.innerHTML;
  7913. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  7914. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  7915. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  7916. var date = /alors : ([^<]+)\./.exec(infos)[1];
  7917. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  7918. var effetPouvoir="";
  7919. var full=false;
  7920. if(infos.indexOf("REDUIT")!=-1) {
  7921. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  7922. }
  7923. else {
  7924. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  7925. full=true;
  7926. }
  7927. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  7928. // On insère le bouton et un espace
  7929. //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));
  7930. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  7931. if(!MY_getValue('AUTOSENDPOUV'))
  7932. {
  7933. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  7934. button.setAttribute("onClick", "window.open('" + url
  7935. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  7936. + "this.value='Merci de votre participation'; this.disabled = true;");
  7937. }
  7938. else
  7939. {
  7940. FF_XMLHttpRequest({
  7941. method: 'GET',
  7942. url: url,
  7943. headers : {
  7944. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7945. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7946. }});
  7947. }
  7948. }*/
  7949.  
  7950. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  7951. traiteCdMmsg();
  7952. }
  7953. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  7954.  
  7955. /*******************************************************************************
  7956. * This file is part of Mountyzilla. *
  7957. * *
  7958. * Mountyzilla is free software; you can redistribute it and/or modify *
  7959. * it under the terms of the GNU General Public License as published by *
  7960. * the Free Software Foundation; either version 2 of the License, or *
  7961. * (at your option) any later version. *
  7962. * *
  7963. * Mountyzilla is distributed in the hope that it will be useful, *
  7964. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7965. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7966. * GNU General Public License for more details. *
  7967. * *
  7968. * You should have received a copy of the GNU General Public License *
  7969. * along with Mountyzilla; if not, write to the Free Software *
  7970. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7971. *******************************************************************************/
  7972.  
  7973. // x~x menu
  7974. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  7975.  
  7976. var menuRac, mainIco;
  7977.  
  7978. // met à jour les carac sauvegardées (position, DLA, etc.)
  7979. function updateData() {
  7980. var inputs = document.getElementsByTagName('input');
  7981. var divs = document.getElementsByTagName('div');
  7982.  
  7983. //window.console.log('inputs=' + JSON.stringify(inputs));
  7984. if (inputs && inputs.length > 0) {
  7985. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  7986. numTroll = inputs[0].value;
  7987. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  7988. MY_setValue('NUM_TROLL', numTroll);
  7989. MY_setValue('NIV_TROLL',inputs[1].value);
  7990. if(!MY_getValue(numTroll+'.caracs.rm')) {
  7991. MY_setValue(numTroll+'.caracs.rm',0);
  7992. // assure l'init des 4 var de libs
  7993. }
  7994. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  7995. } else {
  7996. // onclick="EnterPJView(91305,750,550)"
  7997. var tabA = document.getElementsByTagName('a');
  7998. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  7999. var s = tabA[0].onclick.toString();;
  8000. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  8001. var m = s.match(/\((\d+) *,/);
  8002. //window.console.log('m=' + JSON.stringify(m));
  8003. numTroll = parseInt(m[1]);
  8004. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  8005. MY_setValue('NUM_TROLL', numTroll);
  8006. } else {
  8007. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  8008. }
  8009. }
  8010.  
  8011. var DLA = new Date(
  8012. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  8013. );
  8014. if(MY_getValue(numTroll+'.DLA.encours')) {
  8015. var DLAstockee = new Date(
  8016. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  8017. );
  8018. if(DLA>DLAstockee) {
  8019. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  8020. // Pose un pb en cas de décalage de DLA
  8021. }
  8022. }
  8023. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  8024.  
  8025. try {
  8026. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  8027. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  8028. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  8029. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  8030. } catch(e) {
  8031. window.console.log('[MZ] erreur {' + e + '} à la récupération des coord. div[1] contient ' + divs[1].outerHTML.replace(/</g, '‹') + ', div[0] contient ' + divs[0].outerHTML.replace(/</g, '‹'));
  8032. }
  8033. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  8034. }
  8035.  
  8036. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  8037. function initRaccourcis() {
  8038. var anotherURL = MY_getValue('URL1');
  8039. if(!anotherURL) { return; }
  8040.  
  8041. /* Création de l'icône faisant apparaître le menu */
  8042. mainIco = document.createElement('img');
  8043. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  8044. if(!urlIco) {
  8045. urlIco =
  8046. URL_MZimg + 'mz_logo_small.png';
  8047. }
  8048. mainIco.src = urlIco;
  8049. mainIco.alt = 'MZ';
  8050. mainIco.style = 'position:fixed; top:0px; left:0px';
  8051. mainIco.onmouseover = afficheMenu;
  8052. document.body.appendChild(mainIco);
  8053. /* Création du menu des Raccourcis */
  8054. menuRac = document.createElement('div');
  8055. menuRac.className = 'mh_textbox';
  8056. menuRac.style =
  8057. 'position:fixed; top:10px; left:10px;'+
  8058. 'max-width:190px;'+
  8059. 'border-radius: 4px; padding: 4px;'+
  8060. 'z-index: 500;'+
  8061. 'visibility: hidden;';
  8062. document.body.appendChild(menuRac);
  8063. document.addEventListener('mousemove',cacheMenu,false);
  8064. var i=1;
  8065. while(anotherURL) {
  8066. var a = document.createElement('a');
  8067. var url = MY_getValue('URL'+i);
  8068. var nom = MY_getValue('URL'+i+'.nom');
  8069. var ico = MY_getValue('URL'+i+'.ico');
  8070. a.href = url;
  8071. a.target = '_blank';
  8072. if(ico) {
  8073. var txt = nom ? nom : '';
  8074. var img = createImage(ico,txt);
  8075. a.appendChild(img);
  8076. }
  8077. else {
  8078. appendText(a,'['+nom+']');
  8079. }
  8080. menuRac.appendChild(a);
  8081. appendBr(menuRac);
  8082. i++;
  8083. anotherURL = MY_getValue('URL'+i);
  8084. }
  8085. }
  8086.  
  8087. function afficheMenu() {
  8088. menuRac.style.visibility = 'visible';
  8089. }
  8090.  
  8091. function cacheMenu(e) {
  8092. if(menuRac.style.visibility=='hidden') { return; }
  8093. // Position souris
  8094. var ptX = e.clientX;
  8095. var ptY = e.clientY;
  8096. // On recalcule en live les BoundingBox pour mainIco et menuRac
  8097. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  8098. var menuRect = menuRac.getBoundingClientRect();
  8099. var icoRect = mainIco.getBoundingClientRect();
  8100. if((ptX>icoRect.width || ptY>icoRect.height) &&
  8101. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  8102. menuRac.style.visibility = 'hidden';
  8103. }
  8104. }
  8105.  
  8106. // ajout de l'icône, branchée sur un refresh
  8107. function initUpdateCoordGauche() {
  8108. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8109. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  8110. var img = document.createElement('img');
  8111. img.src = URL_MZimg + 'recycl.png'
  8112. img.onclick = function(evt) {
  8113. document.location.href = document.location.href;
  8114. };
  8115. img.title = 'Mise à jour de la localisation';
  8116. img.style.cursor = 'pointer';
  8117. img.style.position = 'absolute';
  8118. img.style.bottom = 0;
  8119. img.style.left = 0;
  8120. div.appendChild(img);
  8121. }
  8122.  
  8123. function do_menu() {
  8124. // met à jour les carac sauvegardées (position, DLA, etc.)
  8125. updateData();
  8126. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  8127. initRaccourcis();
  8128. // Ajout bouton de mise à jour coordonnées
  8129. initUpdateCoordGauche();
  8130. }
  8131.  
  8132. /*******************************************************************************
  8133. * This file is part of Mountyzilla. *
  8134. * *
  8135. * Mountyzilla is free software; you can redistribute it and/or modify *
  8136. * it under the terms of the GNU General Public License as published by *
  8137. * the Free Software Foundation; either version 2 of the License, or *
  8138. * (at your option) any later version. *
  8139. * *
  8140. * Mountyzilla is distributed in the hope that it will be useful, *
  8141. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8142. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8143. * GNU General Public License for more details. *
  8144. * *
  8145. * You should have received a copy of the GNU General Public License *
  8146. * along with Mountyzilla; if not, write to the Free Software *
  8147. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8148. *******************************************************************************/
  8149.  
  8150. // x~x vue
  8151.  
  8152. /* TODO
  8153. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  8154. * prévoir fix ("delete infos")
  8155. */
  8156.  
  8157. /*--------------------------- Variables Globales -----------------------------*/
  8158.  
  8159. // Infos remplies par des scripts extérieurs
  8160. var listeCDM = [], listeLevels = [];
  8161.  
  8162. // Position actuelle
  8163. var currentPosition=[0,0,0];
  8164.  
  8165. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  8166. var porteeVue=[0,0,0,0];
  8167.  
  8168. // Fenêtres déplaçables
  8169. var winCurr = null;
  8170. var offsetX, offsetY;
  8171.  
  8172. // Diplomatie
  8173. var Diplo = {
  8174. Guilde: {},
  8175. Troll: {},
  8176. Monstre: {}
  8177. // .mythiques: uniquement si option activée
  8178. };
  8179. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  8180.  
  8181. // Infos tactiques
  8182. var popup;
  8183.  
  8184. // Gère l'affichage en cascade des popups de CdM
  8185. var nbCDM = 0;
  8186.  
  8187. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  8188.  
  8189. // Utilisé pour supprimer les monstres "engagés"
  8190. var listeEngages = {};
  8191. var isEngagesComputed = false;
  8192. var cursorOnLink = false; // DEBUG: wtf ?
  8193.  
  8194. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  8195. && MY_getValue(numTroll+'.enchantement.liste')!='';
  8196.  
  8197. // Checkboxes de filtrage
  8198. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  8199. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  8200. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  8201. comboBoxNiveauMin, comboBoxNiveauMax;
  8202.  
  8203. /* Acquisition & Stockage des données de DB */
  8204. const typesAFetcher = {
  8205. 'monstres':1,
  8206. 'trolls':1,
  8207. 'tresors':1,
  8208. 'champignons':1,
  8209. 'lieux':1
  8210. }
  8211. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  8212. tr_champignons = {}, tr_lieux = {};
  8213. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  8214. nbChampignons = 0, nbLieux = 0;
  8215.  
  8216. function fetchData(type) {
  8217. try {
  8218. var node = document.getElementById('mh_vue_hidden_'+type);
  8219. // this = MZ.global = sandBox de travail de MZ
  8220. // On définit donc des variables MZ-globales
  8221. this['tr_'+type] = node.getElementsByTagName('tr');
  8222. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  8223. } catch(e) {
  8224. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  8225. }
  8226. }
  8227.  
  8228.  
  8229. /*---------------------------------- DEBUG -----------------------------------*/
  8230. var mainTabs = document.getElementsByClassName('mh_tdborder');
  8231. var x_monstres = tr_monstres;
  8232. var x_trolls = tr_trolls;
  8233. var x_tresors = tr_tresors;
  8234. var x_champis = tr_champignons;
  8235. var x_lieux = tr_lieux;
  8236. /*-------------------------------- FIN DEBUG ---------------------------------*/
  8237.  
  8238.  
  8239. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8240.  
  8241. function positionToString(arr) {
  8242. return arr.join(';');
  8243. }
  8244.  
  8245. function savePosition() {
  8246. // Stocke la position (à jour) de la vue pour les autres scripts
  8247. // DEBUG: Lesquels et pourquoi?
  8248. var pos = getPosition();
  8249. MY_setValue(numTroll+'.position.X',pos[0]);
  8250. MY_setValue(numTroll+'.position.Y',pos[1]);
  8251. MY_setValue(numTroll+'.position.N',pos[2]);
  8252. }
  8253.  
  8254.  
  8255. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  8256. /* INFOS :
  8257. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  8258. * sont identifiables via leur Name
  8259. * les tables-listings sont identifiables via l'ID du tr conteneur
  8260. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  8261. */
  8262.  
  8263. /* [functions] Récup données Utilisateur */
  8264. function getPosition() {
  8265. // Pour rétrocompatibilité
  8266. return currentPosition;
  8267. }
  8268.  
  8269. function getPorteVue() {
  8270. // Pour rétrocompatibilité
  8271. return porteeVue;
  8272. }
  8273.  
  8274. function getVue() {
  8275. // Retourne [vueHpure, vueVpure]
  8276. var vues = getPorteVue();
  8277. return [ vues[0], vues[1] ];
  8278. }
  8279.  
  8280. // Roule 11/03/2016
  8281. /* [functions] Récup données monstres, trolls, etc. */
  8282. function getXxxDistance(xxx, i) {
  8283. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  8284. }
  8285. function getXxxPosition(xxx, i) {
  8286. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  8287. var l = tds.length;
  8288. return [
  8289. parseInt(tds[l-3].textContent),
  8290. parseInt(tds[l-2].textContent),
  8291. parseInt(tds[l-1].textContent)
  8292. ];
  8293. }
  8294.  
  8295.  
  8296. /* [functions] Récup données monstres */
  8297. function getMonstreDistance(i) {
  8298. return parseInt(tr_monstres[i].cells[0].textContent);
  8299. }
  8300.  
  8301. function getMonstreID(i) {
  8302. return tr_monstres[i].cells[2].firstChild.nodeValue;
  8303. }
  8304.  
  8305. function getMonstreIDByTR(tr) {
  8306. return tr.cells[2].firstChild.nodeValue;
  8307. }
  8308.  
  8309. function getMonstreLevelNode(i) {
  8310. return tr_monstres[i].cells[3];
  8311. }
  8312.  
  8313. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  8314. // function getMonstreLevel(i) {
  8315. // if(!isCDMsRetrieved) return -1;
  8316. // var donneesMonstre = listeCDM[getMonstreID(i)];
  8317. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  8318. // }
  8319.  
  8320. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  8321. if(!isCDMsRetrieved) return false;
  8322. var donneesMonstre = listeCDM[getMonstreID(i)];
  8323. if (!donneesMonstre) return false;
  8324. var nivTxt = donneesMonstre[0];
  8325. // calcul min/max du monstre
  8326. var monstreMin, monstreMax, iPos;
  8327. if (nivTxt.substring(0, 2) == '<=') {
  8328. monstreMin = 0;
  8329. monstreMax = parseInt(nivTxt.substring(2, 99));
  8330. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  8331. monstreMin = parseInt(nivTxt.substring(0, iPos));
  8332. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  8333. } else {
  8334. monstreMin = monstreMax = parseInt(nivTxt);
  8335. }
  8336. if (limitMin > 0 && monstreMax < limitMin) return true;
  8337. if (limitMax > 0 && monstreMin > limitMax) return true;
  8338. return false;
  8339. }
  8340.  
  8341. function getMonstreNomNode(i) {
  8342. try {
  8343. var td = document.evaluate(
  8344. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  8345. tr_monstres[i], null, 9, null
  8346. ).singleNodeValue;
  8347. return td;
  8348. } catch(e) {
  8349. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  8350. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  8351. }
  8352. }
  8353.  
  8354. function getMonstreNom(i) {
  8355. return getMonstreNomByTR(tr_monstres[i]);
  8356. }
  8357.  
  8358. function getMonstreNomByTR(tr) {
  8359. try {
  8360. var nom = document.evaluate(
  8361. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  8362. tr, null, 2, null
  8363. ).stringValue;
  8364. return nom;
  8365. } catch(e) {
  8366. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  8367. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  8368. }
  8369. }
  8370.  
  8371. function getMonstrePosition(i) {
  8372. var tds = tr_monstres[i].childNodes;
  8373. var l = tds.length;
  8374. return [
  8375. parseInt(tds[l-3].textContent),
  8376. parseInt(tds[l-2].textContent),
  8377. parseInt(tds[l-1].textContent)
  8378. ];
  8379. }
  8380.  
  8381. function appendMonstres(txt) {
  8382. for(var i=1; i<=nbMonstres ; i++)
  8383. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  8384. return txt;
  8385. }
  8386.  
  8387. function getMonstres() {
  8388. var vue = getVue();
  8389. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8390. }
  8391.  
  8392. function bddMonstres(start,stop) {
  8393. if(!start) { var start = 1; }
  8394. if(!stop) { var stop = nbMonstres; }
  8395. stop = Math.min(nbMonstres,stop);
  8396. var txt='';
  8397. for(var i=start ; i<=stop ; i++) {
  8398. txt += getMonstreID(i)+';'+
  8399. getMonstreNom(i)+';'+
  8400. positionToString(getMonstrePosition(i))+'\n';
  8401. }
  8402. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  8403. }
  8404.  
  8405. /* [functions] Récup données Trolls */
  8406.  
  8407. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  8408. const COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  8409.  
  8410. function getTrollDistance(i) {
  8411. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  8412. }
  8413.  
  8414. var MZ_cache_col_TrollID;
  8415. var MZ_cache_col_TrollNOM;
  8416. var MZ_cache_col_TrollGUILDE;
  8417. var MZ_cache_col_TrollNIV;
  8418.  
  8419. function MZ_find_col_titre(trs, titre) {
  8420. var l = titre.length;
  8421. for (var i=0; i < trs[0].cells.length; i++)
  8422. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  8423. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  8424. return 0;
  8425. }
  8426.  
  8427. function getTrollID(i) {
  8428. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  8429. // Roule 08/03/2017 protection
  8430. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  8431. if (isNaN(iTroll)) return;
  8432. if (iTroll == 0) return;
  8433. return iTroll;
  8434. }
  8435.  
  8436. function getTrollNomNode(i) {
  8437. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  8438. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  8439. }
  8440.  
  8441. function getTrollNivNode(i) {
  8442. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  8443. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  8444. }
  8445.  
  8446. function getTrollGuilde(i) {
  8447. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  8448. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  8449. }
  8450.  
  8451. function getTrollGuildeID(i) {
  8452. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  8453. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  8454. var href;
  8455. try {
  8456. if ((!tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild) || (!tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute)) return -1; // Roule 21/12/2016 protection conte le "bug Marsak"
  8457. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  8458. } catch(e) { // debug pb remonté par Marsak
  8459. window.console.error(traceStack(e, 'getTrollGuildeID')
  8460. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  8461. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  8462. return -1;
  8463. }
  8464. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  8465. }
  8466. return -1;
  8467. }
  8468.  
  8469. function getTrollPosition(i) {
  8470. var tds = tr_trolls[i].childNodes;
  8471. var l = tds.length;
  8472. return [
  8473. parseInt(tds[l-3].textContent),
  8474. parseInt(tds[l-2].textContent),
  8475. parseInt(tds[l-1].textContent)
  8476. ];
  8477. }
  8478.  
  8479. function bddTrolls() {
  8480. var txt='#DEBUT TROLLS\n'+
  8481. numTroll+';'+positionToString(getPosition())+'\n';
  8482. for(var i=1 ; i<=nbTrolls ; i++) {
  8483. txt += getTrollID(i)+';'+
  8484. positionToString(getTrollPosition(i))+'\n';
  8485. }
  8486. return txt+'#FIN TROLLS';
  8487. }
  8488.  
  8489. /* [functions] Récup données Trésors */
  8490. function getTresorDistance(i) {
  8491. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8492. }
  8493.  
  8494. function getTresorID(i) {
  8495. return trim(tr_tresors[i].cells[2].textContent);
  8496. }
  8497.  
  8498. function getTresorNom(i) {
  8499. // Utilisation de textContent pour régler le "bug de Pollux"
  8500. return trim(tr_tresors[i].cells[3].textContent);
  8501. }
  8502.  
  8503. function getTresorPosition(i) {
  8504. var tds = tr_tresors[i].childNodes;
  8505. var l = tds.length;
  8506. return [
  8507. parseInt(tds[l-3].textContent),
  8508. parseInt(tds[l-2].textContent),
  8509. parseInt(tds[l-1].textContent),
  8510. ];
  8511. }
  8512.  
  8513. function bddTresors(dmin,start,stop) {
  8514. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8515. if(!dmin) { var dmin = 0; }
  8516. if(!start) { var start = 1; }
  8517. if(!stop) { var stop = nbTresors; }
  8518. stop = Math.min(nbTresors,stop);
  8519. var txt='';
  8520. for(var i=start ; i<=stop ; i++) {
  8521. if(getTresorDistance(i)>=dmin) {
  8522. txt += getTresorID(i)+';'+
  8523. getTresorNom(i)+';'+
  8524. positionToString(getTresorPosition(i))+'\n';
  8525. }
  8526. }
  8527. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8528. }
  8529.  
  8530. /* [functions] Récup données Champignons */
  8531. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8532. function getChampignonNom(i) {
  8533. return trim(tr_champignons[i].cells[2].textContent);
  8534. }
  8535.  
  8536. function getChampignonPosition(i) {
  8537. var tds = tr_champignons[i].childNodes;
  8538. var l = tds.length;
  8539. return [
  8540. parseInt(tds[l-3].textContent),
  8541. parseInt(tds[l-2].textContent),
  8542. parseInt(tds[l-1].textContent)
  8543. ];
  8544. }
  8545.  
  8546. function bddChampignons() {
  8547. var txt='';
  8548. for(var i=1 ; i<=nbChampignons ; i++) {
  8549. txt += ';'+ // Les champis n'ont pas de Référence
  8550. getChampignonNom(i)+';'+
  8551. positionToString(getChampignonPosition(i))+'\n';
  8552. }
  8553. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8554. }
  8555.  
  8556. /* [functions] Récup données Lieux */
  8557. function getLieuDistance(i) {
  8558. return parseInt(tr_lieux[i].cells[0].textContent);
  8559. }
  8560.  
  8561. function getLieuID(i) {
  8562. return parseInt(tr_lieux[i].cells[2].textContent);
  8563. }
  8564.  
  8565. function getLieuNom(i) {
  8566. // Conversion ASCII pour éviter les bugs des Vues externes
  8567. return trim(tr_lieux[i].cells[3].textContent);
  8568. }
  8569.  
  8570. function getLieuPosition(i) {
  8571. var tds = tr_lieux[i].childNodes;
  8572. var l = tds.length;
  8573. return [
  8574. parseInt(tds[l-3].textContent),
  8575. parseInt(tds[l-2].textContent),
  8576. parseInt(tds[l-1].textContent)
  8577. ];
  8578. }
  8579.  
  8580. function appendLieux(txt) {
  8581. for(var i = 1; i < nbLieux+1; i++) {
  8582. var tds = x_lieux[i].childNodes;
  8583. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8584. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8585. }
  8586. return txt;
  8587. }
  8588.  
  8589. function getLieux() {
  8590. var vue = getVue();
  8591. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8592. }
  8593.  
  8594. function bddLieux(start,stop) {
  8595. if(!start) { var start = 1; }
  8596. if(!stop) { var stop = nbLieux; }
  8597. stop = Math.min(nbLieux,stop);
  8598. var txt='';
  8599. for(var i=start ; i<=stop ; i++) {
  8600. txt += getLieuID(i)+';'+
  8601. epure(getLieuNom(i))+';'+
  8602. positionToString(getLieuPosition(i))+'\n';
  8603. }
  8604. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8605. }
  8606.  
  8607.  
  8608. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8609.  
  8610. function saveCheckBox(chkbo, pref) {
  8611. // Enregistre et retourne l'état d'une CheckBox
  8612. var etat = chkbo.checked;
  8613. MY_setValue(pref, etat ? 'true' : 'false' );
  8614. return etat;
  8615. }
  8616.  
  8617. function recallCheckBox(chkbox, pref) {
  8618. // Restitue l'état d'une CheckBox
  8619. chkbox.checked = (MY_getValue(pref)=='true');
  8620. }
  8621.  
  8622. function saveComboBox(cbb, pref) {
  8623. // Enregistre et retourne l'état d'une ComboBox
  8624. var etat = cbb.selectedIndex;
  8625. MY_setValue(pref, etat);
  8626. return etat;
  8627. }
  8628.  
  8629. function recallComboBox(cbb, pref) {
  8630. // Restitue l'état d'une ComboBox
  8631. var nb = MY_getValue(pref);
  8632. if(nb) cbb.value = nb;
  8633. return nb;
  8634. }
  8635.  
  8636. function synchroniseFiltres() {
  8637. // Récupération de toutes les options de la vue
  8638. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8639. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8640. if(numBool) {
  8641. debutFiltrage('Monstres');
  8642. }
  8643. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  8644. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  8645. recallCheckBox(checkBoxMythiques,'NOMYTH');
  8646. recallCheckBox(checkBoxEngages,'NOENGAGE');
  8647. recallCheckBox(checkBoxLevels,'NOLEVEL');
  8648. recallCheckBox(checkBoxIntangibles,'NOINT');
  8649. recallCheckBox(checkBoxGG,'NOGG');
  8650. recallCheckBox(checkBoxCompos,'NOCOMP');
  8651. recallCheckBox(checkBoxBidouilles,'NOBID');
  8652. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  8653. recallCheckBox(checkBoxTrou,'NOTROU');
  8654. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8655. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  8656. if(MY_getValue('NOINFOEM')!='true')
  8657. recallCheckBox(checkBoxEM,'NOEM');
  8658. }
  8659.  
  8660.  
  8661. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  8662.  
  8663. function getVueScript() {
  8664. try {
  8665. var txt = bddTrolls()+
  8666. bddMonstres()+
  8667. bddChampignons()+
  8668. bddTresors()+
  8669. bddLieux()+
  8670. '#DEBUT ORIGINE\n'+
  8671. getPorteVue()[2]+';'+positionToString(getPosition())+
  8672. '\n#FIN ORIGINE\n';
  8673. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  8674. return txt;
  8675. } catch(e) {
  8676. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  8677. window.console.error(traceStack(e, 'getVueScript'))
  8678. }
  8679. }
  8680.  
  8681. /* [functions] Menu Vue 2D */
  8682. var vue2Ddata = {
  8683. 'Bricol\' Vue': {
  8684. url: URL_bricol_mountyhall + 'vue_form.php',
  8685. paramid: 'vue',
  8686. func: getVueScript,
  8687. extra_params: {
  8688. 'mode': 'vue_SP_Vue2',
  8689. 'screen_width': window.screen.width
  8690. }
  8691. },
  8692. 'Vue du CCM': {
  8693. url: URL_vue_CCM,
  8694. paramid: 'vue',
  8695. func: getVueScript,
  8696. extra_params: {
  8697. 'id': numTroll+';'+positionToString(getPosition())
  8698. }
  8699. },
  8700. 'Vue Gloumfs 2D': {
  8701. url: URL_vue_Gloumfs2D,
  8702. paramid: 'vue_mountyzilla',
  8703. func: getVueScript,
  8704. extra_params: {}
  8705. },
  8706. 'Vue Gloumfs 3D': {
  8707. url: URL_vue_Gloumfs3D,
  8708. paramid: 'vue_mountyzilla',
  8709. func: getVueScript,
  8710. extra_params: {}
  8711. },
  8712. 'Grouky Vue!': {
  8713. url: URL_vue_Grouky,
  8714. paramid: 'vue',
  8715. func: getVueScript,
  8716. extra_params: {
  8717. 'type_vue': 'V5b1'
  8718. }
  8719. },
  8720. /*'DEBUG': {
  8721. url: 'http://weblocal/testeur.php',
  8722. paramid: 'vue',
  8723. func: getVueScript,
  8724. extra_params: {}
  8725. }*/
  8726. };
  8727.  
  8728. function refresh2DViewButton() {
  8729. // = EventListener menu+bouton vue 2D
  8730. var vueext = document.getElementById('selectVue2D').value;
  8731. MY_setValue('VUEEXT',vueext);
  8732. var form = document.getElementById('viewForm');
  8733. form.innerHTML = '';
  8734. form.method = 'post';
  8735. form.action = vue2Ddata[vueext].url;
  8736. form.target = '_blank';
  8737. appendHidden(form, vue2Ddata[vueext].paramid, '');
  8738. for(var key in vue2Ddata[vueext].extra_params) {
  8739. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  8740. }
  8741. appendSubmit(form, 'Voir',
  8742. function() {
  8743. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  8744. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  8745. vue2Ddata[vueext].func();
  8746. }
  8747. );
  8748. }
  8749.  
  8750. function set2DViewSystem() {
  8751. // Initialise le système de vue 2D
  8752. // Recherche du point d'insertion
  8753. try {
  8754. var center = document.evaluate(
  8755. "//h2[@id='titre2']/following-sibling::center",
  8756. document, null, 9, null
  8757. ).singleNodeValue;
  8758. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  8759. if (!center) center = document.evaluate(
  8760. "//h2[@id='titre2']/following-sibling::div",
  8761. document, null, 9, null
  8762. ).singleNodeValue;
  8763. } catch(e) {
  8764. avertissement("Erreur d'initialisation du système de vue 2D");
  8765. window.console.error(traceStack(e, 'set2DViewSystem'));
  8766. return;
  8767. }
  8768. // Récupération de la dernière vue utilisée
  8769. var vueext = MY_getValue('VUEEXT');
  8770. if(!vueext || !vue2Ddata[vueext]) {
  8771. // sinon, la vue Bricol'Trolls est employée par défaut
  8772. vueext = 'Bricol\' Vue';
  8773. }
  8774. try {
  8775. // Création du sélecteur de vue externe
  8776. selectVue2D = document.createElement('select');
  8777. selectVue2D.id = 'selectVue2D';
  8778. selectVue2D.className = 'SelectboxV2';
  8779. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  8780. for(var view in vue2Ddata) {
  8781. appendOption(selectVue2D, view, view);
  8782. }
  8783. selectVue2D.value = vueext;
  8784. selectVue2D.onchange = refresh2DViewButton;
  8785. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  8786. var form = document.createElement('form');
  8787. form.id = 'viewForm';
  8788. // Insertion du système de vue
  8789. var table = document.createElement('table');
  8790. var tr = appendTr(table);
  8791. var td = appendTd(tr);
  8792. td.appendChild(selectVue2D);
  8793. td = appendTd(tr);
  8794. td.style.fontSize = '0px'; // gère le bug de l'extra character
  8795. td.appendChild(form);
  8796. center.insertBefore(table,center.firstChild);
  8797. insertBr(center.childNodes[1]);
  8798. // Appelle le handler pour initialiser le bouton de submit
  8799. refresh2DViewButton();
  8800. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  8801. } catch(e) {
  8802. avertissement("Erreur de traitement du système de vue 2D");
  8803. window.console.error(traceStack(e, 'set2DViewSystem'));
  8804. }
  8805. }
  8806.  
  8807. /* [functions] Tableau d'Infos */
  8808. function initialiseInfos() {
  8809. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  8810. var
  8811. infoTab = document.getElementsByName('LimitViewForm')[0].
  8812. getElementsByTagName('table')[0],
  8813. tbody = infoTab.tBodies[0],
  8814. thead = infoTab.createTHead(),
  8815. tr = appendTr(thead,'mh_tdtitre'),
  8816. td = appendTdText(tr,'INFORMATIONS',true),
  8817. span = document.createElement('span');
  8818. // Récupération de la position du joueur
  8819. try {
  8820. var strPos = document.evaluate(
  8821. ".//li/b/text()[contains(.,'X = ')]",
  8822. infoTab, null, 9, null
  8823. ).singleNodeValue.nodeValue;
  8824. // ***INIT GLOBALE*** currentPosition
  8825. currentPosition = getNumbers(strPos);
  8826. debugMZ("retrievePosition(): "+currentPosition);
  8827. } catch(e) {
  8828. // Si on ne trouve pas le "X ="
  8829. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  8830. }
  8831. // Récupération des portées (max et limitée) de la vue
  8832. try {
  8833. var
  8834. nodes = document.evaluate(
  8835. ".//li/b/text()[contains(.,'horizontalement') "+
  8836. "or contains(.,'verticalement')]",
  8837. infoTab, null, 7, null
  8838. ),
  8839. array = [];
  8840. for(var i=0 ; i<4 ; i++) {
  8841. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  8842. }
  8843. // ***INIT GLOBALE*** porteeVue
  8844. porteeVue = array;
  8845. } catch(e) {
  8846. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  8847. }
  8848.  
  8849. infoTab.id = 'infoTab'; // Pour scripts externes
  8850. tbody.id = 'corpsInfoTab';
  8851. tbody.rows[0].cells[0].colSpan = 2;
  8852. td.colSpan = 3;
  8853. td.onmouseover = function() {
  8854. this.style.cursor = 'pointer';
  8855. this.className = 'mh_tdpage';
  8856. };
  8857. td.onmouseout = function() {
  8858. this.className = 'mh_tdtitre';
  8859. };
  8860. td.onclick = function() {
  8861. toggleTableauInfos(false);
  8862. };
  8863. span.id = 'msgInfoTab';
  8864. span.style.display = 'none';
  8865. appendText(
  8866. span,
  8867. ' => Position : X = '+currentPosition[0]+
  8868. ', Y = '+currentPosition[1]+
  8869. ', N = '+currentPosition[2]+
  8870. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  8871. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  8872. true
  8873. );
  8874. td.appendChild(span);
  8875. tr = appendTr(tbody,'mh_tdpage');
  8876. td = appendTdText(tr,'EFFACER : ',true);
  8877. td.align = 'center';
  8878. td.className = 'mh_tdtitre';
  8879. td.width = 100;
  8880. td = appendTdCenter(tr,2);
  8881. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  8882. checkBoxGG = appendCheckBoxSpan(
  8883. td,'delgg',filtreTresors," Les GG'"
  8884. ).firstChild;
  8885. checkBoxCompos = appendCheckBoxSpan(
  8886. td,'delcomp',filtreTresors,' Les Compos'
  8887. ).firstChild;
  8888. checkBoxBidouilles = appendCheckBoxSpan(
  8889. td,'delbid',filtreTresors,' Les Bidouilles'
  8890. ).firstChild;
  8891. checkBoxIntangibles = appendCheckBoxSpan(
  8892. td,'delint',filtreTrolls,' Les Intangibles'
  8893. ).firstChild;
  8894. checkBoxGowapsA = appendCheckBoxSpan(
  8895. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  8896. ).firstChild;
  8897. checkBoxGowapsS = appendCheckBoxSpan(
  8898. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  8899. ).firstChild;
  8900. checkBoxEngages = appendCheckBoxSpan(
  8901. td,'delengage',filtreMonstres,' Les Engagés'
  8902. ).firstChild;
  8903. checkBoxLevels = appendCheckBoxSpan(
  8904. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  8905. ).firstChild;
  8906. checkBoxDiplo = appendCheckBoxSpan(
  8907. td,'delDiplo',refreshDiplo,' La Diplomatie'
  8908. ).firstChild;
  8909. checkBoxTrou = appendCheckBoxSpan(
  8910. td,'deltrou',filtreLieux,' Les Trous'
  8911. ).firstChild;
  8912. checkBoxMythiques = appendCheckBoxSpan(
  8913. td,'delmyth',filtreMonstres,' Les Mythiques'
  8914. ).firstChild;
  8915. if(MY_getValue('NOINFOEM')!='true') {
  8916. checkBoxEM = appendCheckBoxSpan(
  8917. td,'delem',filtreMonstres,' Les Composants EM'
  8918. ).firstChild;
  8919. }
  8920. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  8921. td,'deltres',filtreTresors,' Les Trésors non libres'
  8922. ).firstChild;
  8923. checkBoxTactique = appendCheckBoxSpan(
  8924. td,'deltactique',updateTactique,' Les Infos tactiques'
  8925. ).firstChild;
  8926. if(MY_getValue('INFOPLIE')) {
  8927. toggleTableauInfos(true);
  8928. }
  8929. }
  8930.  
  8931. function toggleTableauInfos(firstRun) {
  8932. var
  8933. msg = document.getElementById('msgInfoTab'),
  8934. corps = document.getElementById('corpsInfoTab'),
  8935. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8936. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  8937. if(!firstRun) {
  8938. infoplie = !infoplie;
  8939. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8940. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  8941. }
  8942. if(infoplie) {
  8943. msg.style.display = '';
  8944. corps.style.display = 'none';
  8945. } else {
  8946. msg.style.display = 'none';
  8947. corps.style.display = '';
  8948. }
  8949. }
  8950.  
  8951. /* [functions] Filtres */
  8952. function prepareFiltrage(ref,width) {
  8953. // = Initialise le filtre 'ref'
  8954. try {
  8955. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  8956. } catch(e) {
  8957. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  8958. return false;
  8959. }
  8960. if(width) { tdTitre.width = width; }
  8961. // Ajout du tr de Filtrage (masqué)
  8962. var tbody = tdTitre.parentNode.parentNode;
  8963. var tr = appendTr(tbody,'mh_tdpage');
  8964. tr.style.display = 'none';
  8965. tr.id = 'trFiltre'+ref;
  8966. var td = appendTd(tr);
  8967. td.colSpan = 5;
  8968. // Ajout du bouton de gestion de Filtrage
  8969. var tdBtn = insertAfterTd(tdTitre);
  8970. tdBtn.id = 'tdInsert'+ref;
  8971. var btn = appendButton(tdBtn,'Filtrer');
  8972. btn.id = 'btnFiltre'+ref;
  8973. btn.onclick = function() {
  8974. debutFiltrage(ref)
  8975. };
  8976. return td;
  8977. }
  8978.  
  8979. function debutFiltrage(ref) {
  8980. // = Handler de début de filtrage (filtre 'ref')
  8981. document.getElementById('trFiltre'+ref).style.display = '';
  8982. var btn = document.getElementById('btnFiltre'+ref);
  8983. btn.value = 'Annuler Filtre';
  8984. btn.onclick = function() {
  8985. finFiltrage(ref);
  8986. };
  8987. }
  8988.  
  8989. function finFiltrage(ref) {
  8990. // = Handler de fin de filtrage (filtre 'ref')
  8991. /* On réassigne le bouton 'Filtrer' */
  8992. document.getElementById('trFiltre'+ref).style.display = 'none';
  8993. var btn = document.getElementById('btnFiltre'+ref);
  8994. btn.value = 'Filtrer';
  8995. btn.onclick = function() {
  8996. debutFiltrage(ref);
  8997. };
  8998. /* Réinitialisation filtres */
  8999. document.getElementById('str'+ref).value = '';
  9000. switch(ref) {
  9001. case 'Monstres':
  9002. document.getElementById('nivMinMonstres').value = 0;
  9003. document.getElementById('nivMaxMonstres').value = 0;
  9004. break;
  9005. case 'Trolls':
  9006. document.getElementById('strGuildes').value = '';
  9007. }
  9008. /* Nettoyage (=lance le filtre) */
  9009. // Ici this = MZ.global = sandBox de travail de MZ
  9010. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  9011. //this['filtre'+ref]();
  9012. switch (ref) {
  9013. case 'Monstres':
  9014. filtreMonstres();
  9015. break;
  9016. case 'Trolls':
  9017. filtreTrolls();
  9018. break;
  9019. case 'Tresors':
  9020. filtreTresors();
  9021. break;
  9022. case 'Lieux':
  9023. filtreLieux();
  9024. break;
  9025. default:
  9026. window.console.log('cas incongru dans finFiltrage : ' + ref);
  9027. break;
  9028. }
  9029. }
  9030.  
  9031. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  9032. var bouton = appendButton(td,nomBouton,onClick);
  9033. appendText(td,'\u00a0');
  9034. var textbox = appendTextbox(td,'text',id,15,30);
  9035. textbox.onkeypress = function(event) {
  9036. try {
  9037. if(event.keyCode==13) {
  9038. event.preventDefault();
  9039. bouton.click();
  9040. }
  9041. }
  9042. catch(e){
  9043. window.alert(e)
  9044. }
  9045. };
  9046. }
  9047.  
  9048. function ajoutFiltreMenu(tr,id,onChange) {
  9049. var select = document.createElement('select');
  9050. select.id = id;
  9051. select.onchange = onChange;
  9052. appendOption(select,0,'Aucun');
  9053. for(var i=1 ; i<=60 ; i++) {
  9054. appendOption(select,i,i);
  9055. }
  9056. tr.appendChild(select);
  9057. return select;
  9058. }
  9059.  
  9060. function ajoutDesFiltres() {
  9061. /* Monstres */
  9062. var td = prepareFiltrage('Monstres',120);
  9063. if(td) {
  9064. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  9065. appendText(td,'\u00a0\u00a0\u00a0');
  9066. appendText(td,'Niveau Min: ');
  9067. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  9068. appendText(td,'\u00a0');
  9069. appendText(td,'Niveau Max: ');
  9070. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  9071. }
  9072. /* Trõlls */
  9073. td = prepareFiltrage('Trolls',50);
  9074. if(td) {
  9075. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  9076. appendText(td,'\u00a0\u00a0\u00a0');
  9077. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  9078. }
  9079. /* Trésors */
  9080. td = prepareFiltrage('Tresors',55);
  9081. if(td) {
  9082. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  9083. }
  9084. /* Lieux */
  9085. td = prepareFiltrage('Lieux',40);
  9086. if(td) {
  9087. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  9088. }
  9089. }
  9090.  
  9091. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  9092.  
  9093. /* [functions] Affichage de la colonne des niveaux */
  9094. function insertLevelColumn() {
  9095. // Déclenché si bascule vers affichage des niveaux des mobs
  9096. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  9097. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  9098. td.width = 25;
  9099. for(var i=1 ; i<=nbMonstres ; i++) {
  9100. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  9101. td = insertTdText(getMonstreLevelNode(i), '-');
  9102. td.onclick = function() {
  9103. basculeCDM(
  9104. getMonstreNomByTR(this.parentNode),
  9105. getMonstreIDByTR(this.parentNode)
  9106. );
  9107. };
  9108. td.onmouseover = function() {
  9109. this.style.cursor = 'pointer';
  9110. this.className = 'mh_tdtitre';
  9111. };
  9112. td.onmouseout = function() {
  9113. if(this.parentNode.diploActive=='oui') {
  9114. this.className = '';
  9115. } else {
  9116. this.className = 'mh_tdpage';
  9117. }
  9118. };
  9119. td.style = 'font-weight:bold;text-align:center;';
  9120. if(isCDMsRetrieved) {
  9121. // Rappel des niveaux si mémorisés
  9122. td.innerHTML = listeLevels[i];
  9123. }
  9124. }
  9125. }
  9126.  
  9127. function toggleLevelColumn() {
  9128. // = Handler checkBox noLevel
  9129. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  9130. insertLevelColumn();
  9131. if(!isCDMsRetrieved) { retrieveCDMs(); }
  9132. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  9133. for(var i=0 ; i<=nbMonstres ; i++) {
  9134. if(isCDMsRetrieved) {
  9135. // Mémorisation des niveaux pour rappel éventuel
  9136. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  9137. }
  9138. // Suppression du td Niveau
  9139. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  9140. }
  9141. }
  9142. }
  9143.  
  9144. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  9145. function basculeCDM(nom,id) {
  9146. // = Bascule l'affichage des popups CdM
  9147. if(listeCDM[id]) {
  9148. if(!document.getElementById('popupCDM'+id)) {
  9149. afficherCDM(nom, id);
  9150. } else {
  9151. cacherPopupCDM('popupCDM'+id);
  9152. }
  9153. }
  9154. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  9155. }
  9156.  
  9157. function cacherPopupCDM(titre) {
  9158. var popup = document.getElementById(titre);
  9159. popup.parentNode.removeChild(popup);
  9160. }
  9161.  
  9162. /* DEBUG: Section à mettre à jour */
  9163. var selectionFunction;
  9164.  
  9165. function startDrag(evt) {
  9166. winCurr = this.parentNode;
  9167. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  9168. offsetX = evt.pageX - parseInt( winCurr.style.left );
  9169. offsetY = evt.pageY - parseInt( winCurr.style.top );
  9170. selectionFunction = document.body.style.MozUserSelect;
  9171. document.body.style.MozUserSelect = 'none';
  9172. winCurr.style.MozUserSelect = 'none';
  9173. return false;
  9174. }
  9175.  
  9176. function stopDrag(evt) {
  9177. winCurr.style.MozUserSelect = selectionFunction;
  9178. document.body.style.MozUserSelect = selectionFunction;
  9179. winCurr = null;
  9180. }
  9181.  
  9182. function drag(evt) {
  9183. if(winCurr==null) { return; }
  9184. evt = evt || window.event;
  9185. winCurr.style.left = (evt.pageX - offsetX)+'px';
  9186. winCurr.style.top = (evt.pageY - offsetY)+'px';
  9187. return false;
  9188. }
  9189. /* FIN DEBUG */
  9190. document.onmousemove = drag;
  9191.  
  9192. function afficherCDM(nom,id) {
  9193. // Crée la table de CdM du mob n° id
  9194. var donneesMonstre = listeCDM[id];
  9195. /* Début création table */
  9196. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  9197. table.id = 'popupCDM'+id;
  9198. table.style =
  9199. 'position:fixed;'+
  9200. 'z-index:1;'+
  9201. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  9202. 'left:'+(window.innerWidth-365)+'px;'+
  9203. 'width:300px;'+
  9204. 'height:200px;';
  9205. /* Ajout du titre avec gestion Drag & Drop */
  9206. var tr = table.firstChild;
  9207. tr.style.cursor = 'move';
  9208. tr.onmousedown = startDrag;
  9209. tr.onmouseup = stopDrag;
  9210. /* Ajout du bouton "Fermer" */
  9211. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  9212. tr.onmouseover = function() {
  9213. this.style.cursor = 'pointer';
  9214. this.className = 'mh_tdpage';
  9215. };
  9216. tr.onmouseout = function() {
  9217. this.className = 'mh_tdtitre';
  9218. };
  9219. tr.idcdm = id;
  9220. tr.onclick = function() {
  9221. cacherPopupCDM('popupCDM'+this.idcdm);
  9222. this.className = 'mh_tdtitre';
  9223. };
  9224. td = appendTdText(tr,'Fermer',true);
  9225. td.colSpan = 2;
  9226. td.style = 'text-align:center;';
  9227. nbCDM++;
  9228. /* Fin création table & Affichage */
  9229. document.body.appendChild(table);
  9230. }
  9231.  
  9232. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  9233. function initPopupVue() {
  9234. popup = document.createElement('div');
  9235. popup.id = 'popup';
  9236. popup.className = 'mh_textbox';
  9237. popup.style =
  9238. 'position: absolute;'+
  9239. 'border: 1px solid #000000;'+
  9240. 'visibility: hidden;'+
  9241. 'display: inline;'+
  9242. 'z-index: 3;'+
  9243. 'max-width: 400px;';
  9244. document.body.appendChild(popup);
  9245. }
  9246.  
  9247. /* [functions] Récupération / Computation des Infos Tactiques */
  9248. // TODO à revoir
  9249. function retireMarquage(nom) {
  9250. var i = nom.indexOf(']');
  9251. switch(i) {
  9252. case -1:
  9253. case nom.length-1:
  9254. return nom;
  9255. default:
  9256. return nom.slice(0,i+1);
  9257. }
  9258. }
  9259.  
  9260. function showPopupError(sHTML) {
  9261. window.console.log('[MZ] affichage PopupError ' + sHTML);
  9262. var divpopup = document.createElement('div');
  9263. divpopup.id = 'divpopup';
  9264. divpopup.style =
  9265. 'position: fixed;'+
  9266. 'border: 3px solid #000000;'+
  9267. 'top: 300px;left: 10px;'+
  9268. 'background-color: red;'+
  9269. 'color: white;'+
  9270. 'font-size: xx-large;'+
  9271. 'z-index: 200;';
  9272. divpopup.innerHTML = sHTML;
  9273. var divcroix = document.createElement('div');
  9274. divcroix.style =
  9275. 'position: absolute;'+
  9276. 'top: 0;right: 0;'+
  9277. 'color: inherit;'+
  9278. 'font-size: inherit;'+
  9279. 'cursor: pointer;'+
  9280. 'z-index: 201;';
  9281. divcroix.innerHTML = "X";
  9282. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  9283. document.body.appendChild(divpopup);
  9284. divpopup.appendChild(divcroix);
  9285. }
  9286.  
  9287. function retrieveCDMs() {
  9288. if (isDEV) return retrieveCDMsNew();
  9289. else return retrieveCDMsOld();
  9290. }
  9291.  
  9292. function retrieveCDMsNew() {
  9293. // Récupère les CdM disponibles dans la BDD
  9294. // Lancé uniquement sur toggleLevelColumn
  9295. if(checkBoxLevels.checked) return;
  9296. if (nbMonstres < 1) return;
  9297.  
  9298. var tReq = [];
  9299. for (var i=1 ; i<=nbMonstres ; i++) {
  9300. tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  9301. }
  9302.  
  9303. FF_XMLHttpRequest({
  9304. method: 'POST',
  9305. url: URL_MZgetCaracMonstre,
  9306. headers : {
  9307. 'Content-type':'application/x-www-form-urlencoded'
  9308. },
  9309. data: 'l=' + tReq.join("\n"),
  9310. trace: 'demande niveaux monstres V2',
  9311. onload: function(responseDetails) {
  9312. try {
  9313. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9314. if (responseDetails.status == 0) return;
  9315. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  9316. var texte = responseDetails.responseText;
  9317. var lines = texte.split('\n');
  9318. if(lines.length==0) return;
  9319. var begin2, end2, index;
  9320. for(var j=0 ; j<lines.length ; j++) {
  9321. var infos = lines[j].split("\t");
  9322. if(infos.length<3) { continue; }
  9323. var index = infos[0]
  9324. var idMonstre=infos[1];
  9325. var level = infos[2];
  9326. // 3 cas
  9327. // il y a des infos, infos[] a plus de 3 valeurs
  9328. // il n'y a pas d'info pour ce monstre, infos[] a 4 valeur, la 4e est "-"
  9329. // les infos n'ont pas été récupérées (après le 50e monstre), il n'y a que 3 valeurs
  9330. if (infos.length == 3) {
  9331. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9332. } else if (infos.length > 4) {
  9333. infos = infos.slice(3);
  9334. 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)
  9335. listeCDM[idMonstre] = infos;
  9336. getMonstreLevelNode(index).innerHTML = '<b>'+level+'</b>';
  9337. } else {
  9338. getMonstreLevelNode(index).innerHTML = level;
  9339. }
  9340. }
  9341. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  9342. computeMission(1, nbMonstres);
  9343. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  9344. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9345. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  9346. } catch(e) {
  9347. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9348. }
  9349. isCDMsRetrieved=true;
  9350. },
  9351. });
  9352. //str = '';
  9353. //begin = i+1;
  9354. //isCDMsRetrieved=true;
  9355. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  9356. }
  9357.  
  9358. function retrieveCDMsOld() {
  9359. // Récupère les CdM disponibles dans la BDD
  9360. // Lancé uniquement sur toggleLevelColumn
  9361. if(checkBoxLevels.checked) { return; }
  9362. var str = '';
  9363. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  9364. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  9365. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  9366. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  9367. for(var i=1 ; i<=cdmMax ; i++) {
  9368. var nomMonstre = retireMarquage(getMonstreNom(i));
  9369. if(nomMonstre.indexOf(']') != -1) {
  9370. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  9371. }
  9372. // *** WARNING : PROXY RATIBUS ***
  9373. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  9374. str += 'nom[]='+escape(nomMonstre)+'$'+(
  9375. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  9376. )+'&';
  9377. }
  9378.  
  9379. // Roule 31/07/2017 suppression du saucissonnage : inutile et complique les choses ensuite
  9380. //if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  9381. FF_XMLHttpRequest({
  9382. method: 'POST',
  9383. url: URL_MZinfoMonstre,
  9384. headers : {
  9385. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9386. 'Accept': 'application/atom+xml,application/xml,text/xml',
  9387. 'Content-type':'application/x-www-form-urlencoded'
  9388. },
  9389. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  9390. trace: 'demande niveaux monstres',
  9391. onload: function(responseDetails) {
  9392. try {
  9393. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9394. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  9395. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  9396. '" target="raistlin">Mountyzilla - https<br />'+
  9397. 'Tu dois accepter le certificat de Raistlin<br />'+
  9398. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  9399. ' « Confirmer l\'exception de sécurité »</a>');
  9400. return;
  9401. }
  9402. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  9403. var texte = responseDetails.responseText;
  9404. var lines = texte.split('\n');
  9405. if(lines.length==0) { return; }
  9406. var begin2, end2, index;
  9407. for(var j=0 ; j<lines.length ; j++) {
  9408. var infos = lines[j].split(';');
  9409. if(infos.length<4) { continue; }
  9410. var idMonstre=infos[0];
  9411. var isCDM = infos[1];
  9412. index = parseInt(infos[2]);
  9413. var level = infos[3];
  9414. infos = infos.slice(3);
  9415. 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)
  9416. if(begin2==null) { begin2 = index; }
  9417. end2 = index;
  9418. listeCDM[idMonstre] = infos;
  9419. if(isCDM==1) {
  9420. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9421. } else {
  9422. getMonstreLevelNode(index).innerHTML = level;
  9423. }
  9424. }
  9425. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres avant computeMission');
  9426. computeMission(begin2,end2);
  9427. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres avant filtreMonstres');
  9428. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9429. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres fin');
  9430. } catch(e) {
  9431. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9432. }
  9433. isCDMsRetrieved=true;
  9434. },
  9435. });
  9436. //str = '';
  9437. //begin = i+1;
  9438. //isCDMsRetrieved=true;
  9439. //window.console.log('[MZd] ' + (+new Date) + ' requête ajax partie pour ' + cdmMax + ' monstres');
  9440. }
  9441.  
  9442. function computeMission(begin,end) {
  9443. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  9444. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  9445. computeVLC(begin,end);
  9446. //+++window.console.log('computeMission, après computeVLC');
  9447. if(!begin) begin=1;
  9448. if(!end) end=nbMonstres;
  9449. var str = MY_getValue(numTroll+'.MISSIONS');
  9450. if(!str) { return; }
  9451. var urlImg = URL_MZimg+'mission.png';
  9452. var obMissions = JSON.parse(str);
  9453. for(var i=end ; i>=begin ; i--) {
  9454. var mess = '';
  9455. for(var num in obMissions) {
  9456. var mobMission = false;
  9457. switch(obMissions[num].type) {
  9458. case 'Race':
  9459. var race = epure(obMissions[num].race.toLowerCase());
  9460. var nom = epure(getMonstreNom(i).toLowerCase());
  9461. if(nom.indexOf(race)!=-1) {
  9462. mobMission = true;
  9463. }
  9464. break;
  9465. case 'Niveau':
  9466. var donneesMonstre = listeCDM[getMonstreID(i)];
  9467. if(donneesMonstre) {
  9468. var nivMob = Number(donneesMonstre[0]);
  9469. var nivMimi = Number(obMissions[num].niveau),
  9470. mod = obMissions[num].mod;
  9471. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  9472. || (isNaN(mod) && nivMob>=nivMimi)) {
  9473. mobMission = true;
  9474. }
  9475. }
  9476. break;
  9477. case 'Famille':
  9478. var donneesMonstre = listeCDM[getMonstreID(i)];
  9479. if(donneesMonstre) {
  9480. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  9481. var familleMob = epure(donneesMonstre[1].toLowerCase());
  9482. if(familleMob.indexOf(familleMimi)!=-1) {
  9483. mobMission = true;
  9484. }
  9485. }
  9486. break;
  9487. case 'Pouvoir':
  9488. var donneesMonstre = listeCDM[getMonstreID(i)];
  9489. if(donneesMonstre) {
  9490. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  9491. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  9492. if(pvrMob.indexOf(pvrMimi)!=-1) {
  9493. mobMission = true;
  9494. }
  9495. }
  9496. }
  9497. if(mobMission) {
  9498. mess += mess ? '\n\n' : '';
  9499. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  9500. }
  9501. }
  9502. if(mess) {
  9503. var td = getMonstreNomNode(i);
  9504. appendText(td,' ');
  9505. td.appendChild(createImage(urlImg,mess));
  9506. }
  9507. }
  9508. }
  9509.  
  9510. function computeVLC(begin,end) {
  9511. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  9512. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  9513. computeTactique(begin,end);
  9514. //+++window.console.log('computeVLC, après computeTactique');
  9515. if(!begin) begin=1;
  9516. if(!end) end=nbMonstres;
  9517. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  9518. if(!cache)
  9519. return false;
  9520. var urlImg = URL_MZimg + "oeil.png";
  9521. for(var i = end; i >= begin;i--)
  9522. {
  9523. var id = getMonstreID(i);
  9524. var donneesMonstre = listeCDM[id];
  9525. if(donneesMonstre && donneesMonstre.length>12)
  9526. {
  9527. if(donneesMonstre[12]==1)
  9528. {
  9529. var td = getMonstreNomNode(i);
  9530. td.appendChild(document.createTextNode(" "));
  9531. td.appendChild(createImage(urlImg, "Voit le caché"));
  9532. }
  9533. }
  9534. }
  9535. }
  9536.  
  9537. /* appelé
  9538. par updateTactique
  9539. par initialiseInfos
  9540. par do_vue
  9541. par computeVLC
  9542. par computeMission
  9543. par filtreMonstres
  9544. par retrieveCDMs
  9545. */
  9546. function computeTactique(begin, end) {
  9547. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  9548. try {
  9549. if(!begin) begin = 1;
  9550. if(!end) end = nbMonstres;
  9551. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  9552. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9553. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  9554. if(noTactique || !isProfilActif()) return;
  9555. //+++window.console.log('computeTactique, après isProfilActif');
  9556.  
  9557. for(var j=end ; j>=begin ; j--) {
  9558. var id = getMonstreID(j);
  9559. var nom = getMonstreNom(j);
  9560. var donneesMonstre = listeCDM[id];
  9561. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  9562. var td = getMonstreNomNode(j);
  9563. appendText(td,' ');
  9564. td.appendChild(
  9565. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  9566. );
  9567. }
  9568. }
  9569. }
  9570. catch(e) {
  9571. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  9572. }
  9573. filtreMonstres();
  9574. }
  9575.  
  9576. function updateTactique() {
  9577. // = Handler checkBox noTactique
  9578. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9579. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  9580. if(!isCDMsRetrieved) return;
  9581. //+++window.console.log('updateTactique, isCDMsRetrieved=' + isCDMsRetrieved);
  9582.  
  9583. if(noTactique) {
  9584. for(var i=nbMonstres ; i>0 ; i--) {
  9585. var tr = getMonstreNomNode(i);
  9586. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9587. tr, null, 9, null).singleNodeValue;
  9588. if(img) {
  9589. img.parentNode.removeChild(img.previousSibling);
  9590. img.parentNode.removeChild(img);
  9591. }
  9592. }
  9593. }
  9594. else
  9595. computeTactique();
  9596. }
  9597.  
  9598. function filtreMonstres() {
  9599. // = Handler universel pour les fonctions liées aux monstres
  9600. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9601. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9602. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9603. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9604. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9605. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9606. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9607. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9608. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9609. // old/new : détermine s'il faut ou non nettoyer les tr
  9610. var oldNOEM = true, noEM = true;
  9611. if(MY_getValue('NOINFOEM')!='true') {
  9612. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9613. }
  9614. // Filtrage par nom
  9615. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9616. // Génère la liste des mobs engagés (si filtrés)
  9617. if(noEngages && !isEngagesComputed) {
  9618. for(var i=nbTrolls ; i>0 ; i--) {
  9619. var pos = getTrollPosition(i);
  9620. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  9621. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  9622. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  9623. }
  9624. isEngagesComputed = true;
  9625. }
  9626. /*** FILTRAGE ***/
  9627. /* À computer :
  9628. * - EM (nom suffit)
  9629. * - Enchant (nom suffit)
  9630. * - Mission (nécessite CdM)
  9631. * - mob VlC (nécessite CdM)
  9632. * Sans computation :
  9633. * - Gowap ? engagé ?
  9634. */
  9635. for(var i=nbMonstres ; i>0 ; i--) {
  9636. var pos = getMonstrePosition(i);
  9637. var nom = getMonstreNom(i).toLowerCase();
  9638. if(noEM!=oldNOEM) {
  9639. if(noEM) {
  9640. // Si noEM passe de false à true, on nettoie les td "Nom"
  9641. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  9642. var tr = getMonstreNomNode(i);
  9643. while(tr.childNodes.length>1) {
  9644. tr.removeChild(tr.childNodes[1]);
  9645. }
  9646. } else {
  9647. var tr = getMonstreNomNode(i);
  9648. var TypeMonstre=getEM(nom);
  9649. if(TypeMonstre!='') {
  9650. var infosCompo=compoMobEM(TypeMonstre);
  9651. if(infosCompo.length>0) {
  9652. tr.appendChild(document.createTextNode(' '));
  9653. tr.appendChild(createImage(urlImg, infosCompo));
  9654. }
  9655. }
  9656. }
  9657. }
  9658. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  9659. var texte = getInfoEnchantementFromMonstre(nom);
  9660. if(texte!='') {
  9661. var td = getMonstreNomNode(i);
  9662. td.appendChild(document.createTextNode(' '));
  9663. td.appendChild(createImage(urlEnchantImg, texte));
  9664. }
  9665. }
  9666. tr_monstres[i].style.display = (
  9667. noGowapsS &&
  9668. nom.indexOf('gowap sauvage')!=-1 &&
  9669. getMonstreDistance(i)>1
  9670. ) || (
  9671. noGowapsA &&
  9672. nom.indexOf('gowap apprivoisé')!=-1 &&
  9673. getMonstreDistance(i)>1
  9674. ) || (
  9675. noEngages &&
  9676. getMonstreDistance(i)!=0 &&
  9677. listeEngages[pos[0]] &&
  9678. listeEngages[pos[0]][pos[1]] &&
  9679. listeEngages[pos[0]][pos[1]][pos[2]]
  9680. ) || (
  9681. strMonstre!='' &&
  9682. nom.indexOf(strMonstre)==-1
  9683. ) || (
  9684. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  9685. getMonstreDistance(i)>1 &&
  9686. nom.toLowerCase().indexOf("kilamo")==-1
  9687. ) ? 'none' : '';
  9688. }
  9689. if(MY_getValue('NOINFOEM')!='true') {
  9690. if(noEM != oldNOEM) {
  9691. if(noEM && isCDMsRetrieved) computeMission();
  9692. }
  9693. oldNOEM = noEM;
  9694. }
  9695. needComputeEnchantement = false;
  9696. }
  9697.  
  9698.  
  9699. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  9700.  
  9701. function filtreTrolls() {
  9702. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  9703. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  9704. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  9705. for(var i=1 ; i<=nbTrolls ; i++) {
  9706. tr_trolls[i].style.display = (
  9707. noIntangibles &&
  9708. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  9709. ) || (
  9710. strTroll!='' &&
  9711. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  9712. ) || (
  9713. strGuilde!='' &&
  9714. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  9715. ) ? 'none' : '';
  9716. }
  9717. }
  9718.  
  9719. /* [functions] Bulle PX Trolls */
  9720. var bulle;
  9721.  
  9722. function initPXTroll() {
  9723. bulle = document.createElement('div');
  9724. bulle.id = 'bulle';
  9725. bulle.className = 'mh_textbox';
  9726. bulle.style =
  9727. 'position: absolute;'+
  9728. 'border: 1px solid #000000;'+
  9729. 'visibility: hidden;'+
  9730. 'display: inline;'+
  9731. 'z-index: 2;';
  9732. document.body.appendChild(bulle);
  9733.  
  9734. for(var i=nbTrolls ; i>0 ; i--) {
  9735. var td_niv = getTrollNivNode(i);
  9736. td_niv.onmouseover = showPXTroll;
  9737. td_niv.onmouseout = hidePXTroll;
  9738. }
  9739. }
  9740.  
  9741. function showPXTroll(evt) {
  9742. var lvl = this.firstChild.nodeValue;
  9743. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  9744. bulle.style.left = evt.pageX+15+'px';
  9745. bulle.style.top = evt.pageY+'px';
  9746. bulle.style.visibility = 'visible';
  9747. }
  9748.  
  9749. function hidePXTroll() {
  9750. bulle.style.visibility = 'hidden';
  9751. }
  9752.  
  9753. /* [functions] Envoi PX / MP */
  9754. function putBoutonPXMP() {
  9755. // Bouton d'initialisation du mode Envoi
  9756. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  9757. var td = document.getElementById('tdInsertTrolls');
  9758. if(!td) { return; }
  9759. td.width = 100;
  9760. td = insertAfterTd(td);
  9761. td.style.verticalAlign = 'top';
  9762. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  9763. bouton.id = 'btnEnvoi';
  9764. }
  9765.  
  9766. function prepareEnvoi() {
  9767. // = 1er Handler du bouton d'envoi
  9768. /* Ajout de la colonne des CheckBoxes */
  9769. var td = insertTdText(getTrollNomNode(0),'');
  9770. td.width = 5;
  9771. for(var i=nbTrolls ; i>0 ; i--) {
  9772. td = insertTd(getTrollNomNode(i));
  9773. appendCheckBox(td,'envoi'+i);
  9774. }
  9775. /* Ajout du radio de choix PX ou MP */
  9776. var btnEnvoi = document.getElementById('btnEnvoi');
  9777. if(!btnEnvoi) { return; }
  9778. var tdEnvoi = btnEnvoi.parentNode;
  9779. appendText(tdEnvoi,' ');
  9780. var span = document.createElement('span');
  9781. span.style.whiteSpace = 'nowrap';
  9782. var radioElt = document.createElement('input');
  9783. radioElt.type = 'radio';
  9784. radioElt.name = 'envoiPXMP';
  9785. radioElt.id = 'radioPX';
  9786. span.appendChild(radioElt);
  9787. appendText(span,' des PX ');
  9788. radioElt = document.createElement('input');
  9789. radioElt.type = 'radio';
  9790. radioElt.name = 'envoiPXMP';
  9791. radioElt.checked = true;
  9792. span.appendChild(radioElt);
  9793. appendText(span,' un MP');
  9794. tdEnvoi.appendChild(span);
  9795. /* Insertion du bouton Annuler */
  9796. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  9797. /* Modification de l'effet du bouton Envoi */
  9798. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  9799. }
  9800.  
  9801. function annuleEnvoi() {
  9802. // = Handler bouton Annuler
  9803. /* Nettoyage du td du bouton Envoi */
  9804. var btnEnvoi = document.getElementById('btnEnvoi');
  9805. var tdEnvoi = btnEnvoi.parentNode;
  9806. while(tdEnvoi.firstChild) {
  9807. tdEnvoi.removeChild(tdEnvoi.firstChild);
  9808. }
  9809. /* Retour à l'effet de base du bouton Envoi */
  9810. btnEnvoi.onclick = prepareEnvoi;
  9811. tdEnvoi.appendChild(btnEnvoi);
  9812. /* Suppression CheckBoxes */
  9813. for(var i=nbTrolls ; i>=0 ; i--) {
  9814. var td = getTrollNomNode(i);
  9815. td.parentNode.removeChild(td);
  9816. }
  9817. }
  9818.  
  9819. function effectueEnvoi() {
  9820. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  9821. var str='';
  9822. var errID = false;
  9823. for(var i=nbTrolls ; i>0 ; i--) {
  9824. var chb = document.getElementById('envoi'+i);
  9825. if(chb.checked) {
  9826. var idTroll = getTrollID(i);
  9827. if (idTroll == undefined) {
  9828. errID = true;
  9829. } else {
  9830. str += (str ? ',' : '') + idTroll;
  9831. }
  9832. }
  9833. }
  9834. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  9835. var PXchecked = document.getElementById('radioPX').checked;
  9836. if(PXchecked) {
  9837. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  9838. } else {
  9839. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  9840. }
  9841. }
  9842.  
  9843. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  9844.  
  9845. function filtreTresors() {
  9846. // += Handler checkboxes : gg, compos, bidouilles, non libres
  9847. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  9848. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  9849. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  9850. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9851. if(noEngages && !isEngagesComputed) {
  9852. for(var i=nbTrolls ; i>0 ; i--) {
  9853. var pos = getTrollPosition(i);
  9854. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  9855. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  9856. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  9857. }
  9858. isEngagesComputed = true;
  9859. }
  9860. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  9861. for(var i=nbTresors ; i>0 ; i--) {
  9862. var nom = getTresorNom(i);
  9863. var pos = getTresorPosition(i);
  9864. tr_tresors[i].style.display = (
  9865. noGG &&
  9866. nom.indexOf('Gigots de Gob')!=-1
  9867. ) || (
  9868. noCompos &&
  9869. nom.indexOf('Composant')!=-1
  9870. ) || (
  9871. noEngages &&
  9872. listeEngages[pos[2]] &&
  9873. listeEngages[pos[2]][pos[1]] &&
  9874. listeEngages[pos[2]][pos[1]][pos[0]] &&
  9875. getTresorDistance(i)>0
  9876. ) || (
  9877. strTresor!='' &&
  9878. nom.toLowerCase().indexOf(strTresor)==-1
  9879. ) || (
  9880. noBidouilles &&
  9881. nom.indexOf('Bidouille')!=-1
  9882. ) ? 'none' : '';
  9883. }
  9884. }
  9885.  
  9886.  
  9887. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  9888.  
  9889. function filtreLieux() {
  9890. // += Handler checkbox trous
  9891. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  9892. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  9893. for(var i=nbLieux ; i>0 ; i--) {
  9894. tr_lieux[i].style.display = (
  9895. strLieu &&
  9896. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  9897. ) || (
  9898. noTrou &&
  9899. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  9900. getLieuDistance(i)>1
  9901. ) ? 'none' : '';
  9902. }
  9903. }
  9904.  
  9905.  
  9906. /*-[functions]-------------------- Diplomatie --------------------------------*/
  9907.  
  9908. function refreshDiplo() {
  9909. MY_setValue(numTroll+'.diplo.off',
  9910. checkBoxDiplo.checked?'true':'false'
  9911. );
  9912. if(isDiploRaw) { computeDiplo(); }
  9913. appliqueDiplo();
  9914. }
  9915.  
  9916. function computeDiplo() {
  9917. // On extrait les données de couleur et on les stocke par id
  9918. // Ordre de préséance :
  9919. // source Guilde < source Perso
  9920. // guilde cible < troll cible
  9921. /* Diplo de Guilde */
  9922. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  9923. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  9924. if(diploGuilde && diploGuilde.isOn=='true') {
  9925. // Guilde perso
  9926. if(diploGuilde.guilde) {
  9927. Diplo.Guilde[diploGuilde.guilde.id] = {
  9928. couleur: diploGuilde.guilde.couleur,
  9929. titre: 'Ma Guilde'
  9930. };
  9931. }
  9932. // Guildes/Trolls A/E
  9933. for(var AE in {Amis:0,Ennemis:0}) {
  9934. for(var i=0 ; i<5 ; i++) {
  9935. if(diploGuilde[AE+i]) {
  9936. for(var type in {Guilde:0,Troll:0}) {
  9937. var liste = diploGuilde[AE+i][type].split(';');
  9938. for(var j=liste.length-2 ; j>=0 ; j--) {
  9939. Diplo[type][liste[j]] = {
  9940. couleur: diploGuilde[AE+i].couleur,
  9941. titre: diploGuilde[AE+i].titre
  9942. };
  9943. }
  9944. }
  9945. }
  9946. }
  9947. }
  9948. }
  9949. /* Diplo Perso */
  9950. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  9951. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  9952. if(diploPerso && diploPerso.isOn=='true') {
  9953. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  9954. for(var id in diploPerso[type]) {
  9955. Diplo[type][id] = diploPerso[type][id];
  9956. }
  9957. }
  9958. }
  9959. if(diploPerso.mythiques) {
  9960. Diplo.mythiques = diploPerso.mythiques;
  9961. }
  9962. isDiploRaw = false;
  9963. }
  9964.  
  9965. function appliqueDiplo() {
  9966. var aAppliquer = Diplo;
  9967. if(checkBoxDiplo.checked) {
  9968. // Pour retour à l'affichage basique sur désactivation de la diplo
  9969. aAppliquer = {
  9970. Guilde: {},
  9971. Troll: {},
  9972. Monstre: {}
  9973. };
  9974. }
  9975. /* On applique "aAppliquer" */
  9976. // Diplo Trõlls
  9977. for(var i=nbTrolls ; i>0 ; i--) {
  9978. var idG = getTrollGuildeID(i);
  9979. var idT = getTrollID(i);
  9980. var tr = tr_trolls[i];
  9981. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  9982. if(aAppliquer.Troll[idT]) {
  9983. tr.className = '';
  9984. var descr = aAppliquer.Troll[idT].titre;
  9985. if(descr) {
  9986. getTrollNomNode(i).title = descr
  9987. }
  9988. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  9989. } else if(aAppliquer.Guilde[idG]) {
  9990. tr.className = '';
  9991. var descr = aAppliquer.Guilde[idG].titre;
  9992. if(descr) {
  9993. getTrollNomNode(i).title = descr
  9994. }
  9995. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  9996. } else {
  9997. tr.className = 'mh_tdpage';
  9998. getTrollNomNode(i).title = '';
  9999. }
  10000. }
  10001. // Diplo Monstres
  10002. for(var i=nbMonstres ; i>0 ; i--) {
  10003. var id = getMonstreID(i);
  10004. var nom = getMonstreNom(i).toLowerCase();
  10005. if(aAppliquer.Monstre[id]) {
  10006. tr_monstres[i].className = '';
  10007. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  10008. tr_monstres[i].diploActive = 'oui';
  10009. var descr = aAppliquer.Monstre[id].titre;
  10010. if(descr) {
  10011. getMonstreNomNode(i).title = descr;
  10012. }
  10013. } else if(aAppliquer.mythiques &&
  10014. (nom.indexOf('liche')==0 ||
  10015. nom.indexOf('hydre')==0 ||
  10016. nom.indexOf('balrog')==0 ||
  10017. nom.indexOf('beholder')==0)) {
  10018. tr_monstres[i].className = '';
  10019. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  10020. tr_monstres[i].diploActive = 'oui';
  10021. getMonstreNomNode(i).title = 'Monstre Mythique';
  10022. } else {
  10023. tr_monstres[i].className = 'mh_tdpage';
  10024. tr_monstres[i].diploActive = '';
  10025. }
  10026. }
  10027. }
  10028.  
  10029.  
  10030. /*-[functions]---------------- Actions à distance ----------------------------*/
  10031.  
  10032. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  10033. var monN = parseInt(getPosition()[2]);
  10034. for(var type in keltypes) {
  10035. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  10036. for(var i=this['nb'+type] ; i>0 ; i--) {
  10037. var tr = this['tr_'+type.toLowerCase()][i];
  10038. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  10039. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  10040. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  10041. var sonN = getXxxPosition(type, i)[2];
  10042. var d = getXxxDistance(type, i);
  10043. if(sonN==monN && d>=dmin && d<=dmax) {
  10044. var iconeAction = document.evaluate(
  10045. "./descendant::img[@alt='"+alt+"']",
  10046. tr, null, 9, null
  10047. ).singleNodeValue;
  10048. if(iconeAction) {
  10049. if(iconeAction.title) {
  10050. iconeAction.title += "\n"+message;
  10051. } else {
  10052. iconeAction.title = message;
  10053. }
  10054. iconeAction.src = urlIcon;
  10055. } else {
  10056. var tdAction = tr.getElementsByTagName('td')[1];
  10057. var icon = document.createElement('img');
  10058. icon.src = urlIcon;
  10059. icon.height = 20;
  10060. icon.alt = alt;
  10061. icon.title = message;
  10062. tdAction.appendChild(icon);
  10063. }
  10064. }
  10065. }
  10066. }
  10067. }
  10068.  
  10069. function computeCharge() {
  10070. computeActionDistante(1,
  10071. getPortee__Vue(
  10072. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  10073. MY_getValue(numTroll+".caracs.regeneration")
  10074. ),
  10075. {'Monstres':1, 'Trolls':1},
  10076. 'Attaquer',
  10077. MHicons+'E_Metal09.png',
  10078. 'Cible à portée de Charge'
  10079. );
  10080. }
  10081.  
  10082. function computeProjo() {
  10083. computeActionDistante(0,
  10084. getPortee__Vue(
  10085. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10086. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10087. ),
  10088. {'Monstres':1, 'Trolls':1},
  10089. 'Attaquer',
  10090. MHicons+'S_Fire05.png',
  10091. 'Cible à portée de Projo'
  10092. );
  10093. }
  10094.  
  10095. function computeTelek() {
  10096. computeActionDistante(0,
  10097. Math.floor((
  10098. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10099. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10100. )/2),
  10101. {'Tresors':1},
  10102. 'Telek',
  10103. MHicons+'S_Magic04.png',
  10104. 'Trésor à portée de Télékinésie'
  10105. );
  10106. }
  10107.  
  10108. function computeLdP() {
  10109. computeActionDistante(0,
  10110. 2+Math.floor((
  10111. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10112. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10113. )/5),
  10114. {'Monstres':1, 'Trolls':1},
  10115. 'self',
  10116. MHicons+'P_Red01.png',
  10117. 'Cible à portée de Lancer de Potions'
  10118. );
  10119. }
  10120.  
  10121.  
  10122. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  10123.  
  10124. function putScriptExterne(sInfo) {
  10125. for (var iBricol = 1; ; iBricol++) {
  10126. var extClef = iBricol == 1 ? '' : iBricol;
  10127. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  10128. if (!sInfo) break;
  10129. putScriptExterneOneIT(sInfo);
  10130. }
  10131. }
  10132.  
  10133. function putScriptExterneOneIT(sInfo) {
  10134. if(!sInfo || sInfo=='') return;
  10135.  
  10136. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  10137. if(nomit=='bricol') {
  10138. var data = sInfo.split('$');
  10139. try {
  10140. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  10141. // appendNewScript(URL_bricol+data[1]
  10142. // +'/mz.php?login='+data[2]
  10143. // +'&password='+data[3]
  10144. // );
  10145. FF_XMLHttpRequest({
  10146. method: 'GET',
  10147. url: URL_bricol+data[1]
  10148. +'/mz_json.php?login='+data[2]
  10149. +'&password='+data[3],
  10150. trace: 'bricolTroll',
  10151. onload: function(responseDetails) {
  10152. try {
  10153. if (responseDetails.status == 0) {
  10154. window.console.log('status=0 à l\'appel bricol\'troll');
  10155. if (isHTTPS) {
  10156. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  10157. } else {
  10158. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  10159. }
  10160. return;
  10161. }
  10162. var ratibusData;
  10163. try {
  10164. ratibusData = JSON.parse(responseDetails.responseText);
  10165. } catch(e) {}
  10166. if (ratibusData === undefined) {
  10167. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  10168. return;
  10169. }
  10170. if (ratibusData.error) {
  10171. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  10172. } else {
  10173. putInfosTrolls(ratibusData.data.trolls, data[1]);
  10174. }
  10175. } catch(e) {
  10176. window.console.log(traceStack(e, 'retour bricol\'troll'));
  10177. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  10178. }
  10179. }
  10180. });
  10181. } catch(e) {
  10182. if (isHTTPS) {
  10183. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  10184. } else {
  10185. window.console.log(traceStack(e, 'appel bricol\'troll'));
  10186. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  10187. }
  10188. }
  10189. }
  10190. }
  10191.  
  10192. /*
  10193. * Roule 07/11/2016, on utilise mz_json qui envoie
  10194. {
  10195. "data": {
  10196. "trolls": {
  10197. "59424": {
  10198. "id": 59424,
  10199. "pv": xx,
  10200. "pv_max": xx,
  10201. "updated_at": "2016-10-31 07:28:40",
  10202. "dla": "2016-10-05 07:28:04",
  10203. "pa": 0
  10204. },
  10205. }
  10206. }
  10207. }
  10208. */
  10209.  
  10210. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  10211. function corrigeBricolTrolls(infosTrolls) {
  10212. for(var i in infosTrolls) {
  10213. var pv = infosTrolls[i][0];
  10214. var pvmax = infosTrolls[i][1];
  10215. var pvmem = MY_getValue(i+'.caracs.pv.max');
  10216. if(pvmem && pvmem>pvmax) {
  10217. infosTrolls[i][1] = pvmem;
  10218. pvmax = pvmem;
  10219. }
  10220. if(pv>pvmax) {
  10221. var newpvmax = 5*Math.ceil(pv/5);
  10222. MY_setValue(i+'.caracs.pv.max',newpvmax);
  10223. infosTrolls[i][1] = newpvmax;
  10224. }
  10225. }
  10226. }
  10227.  
  10228. // insère 2 TD avant nextTD avec les infos venant de l'IT
  10229. function addTdInfosTroll(infos, TR, itName) {
  10230. /* cadre barre PV */
  10231. var tab = document.createElement('div');
  10232. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  10233. /* barre PV */
  10234. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  10235. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  10236. .vieContainer {
  10237. background-color: #CCC;
  10238. width: 50px;
  10239. height: 6px;
  10240. border: 1px solid #000;
  10241. text-align: left;
  10242. }
  10243. */
  10244. tab.style.width = '100px';
  10245. tab.style.height = '10px';
  10246. tab.style.border = '1px solid #000';
  10247. tab.style.textAlign = 'left';
  10248. var div2 = document.createElement('div');
  10249. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  10250. var dateLimite = new Date();
  10251. dateLimite.setDate(dateLimite.getDate() - 7);
  10252. if (infos.oUpdatedAt < dateLimite) {
  10253. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  10254. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  10255. } else if (pourcentVie > 66) {
  10256. div2.style.backgroundColor = '#77EE77';
  10257. } else if (pourcentVie > 33) {
  10258. div2.style.backgroundColor = '#EEEE77';
  10259. } else {
  10260. div2.style.backgroundColor = '#FF0000';
  10261. }
  10262. div2.style.width = pourcentVie + '%';
  10263. div2.style.height = '10px';
  10264. tab.appendChild(div2);
  10265. /* ancienne méthode par img, à supprimer
  10266. var img = document.createElement('img');
  10267. img.src = '../Images/Interface/milieu.gif';
  10268. img.height = 10;
  10269. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  10270. tab.appendChild(img);
  10271. */
  10272.  
  10273. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  10274. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  10275. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  10276. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  10277.  
  10278. /* lien vers l'IT */
  10279. var lien = document.createElement('a');
  10280. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  10281. lien.href = URL_bricol+itName+'/index.php';
  10282. lien.target = '_blank';
  10283. lien.appendChild(tab);
  10284. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  10285. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  10286. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  10287. //insertTdElement(tdGuilde,lien);
  10288. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  10289. /* PAs dispos */
  10290. var span = document.createElement('span');
  10291. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  10292. appendText(span, infos.pa +' PA' );
  10293. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  10294. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  10295. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  10296. span.style.backgroundColor = 'B8EEB8';
  10297. }
  10298. //insertTdElement(tdGuilde, span);
  10299. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  10300. }
  10301.  
  10302. var MZ_tabTrTrollById;
  10303. function putInfosTrolls(infosTrolls, itName) {
  10304. try {
  10305. if (MZ_tabTrTrollById === undefined) {
  10306. MZ_tabTrTrollById = new Array;
  10307. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  10308. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  10309. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  10310. td.width = 40;
  10311. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  10312. td.width = 105;
  10313. for(i=nbTrolls ; i>0 ; i--) {
  10314. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  10315. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  10316. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  10317. }
  10318. }
  10319.  
  10320.  
  10321. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  10322. //corrigeBricolTrolls(infosTrolls);
  10323.  
  10324. // supression des infos trop vieilles (un mois)
  10325. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  10326. var dateLimite = new Date();
  10327. dateLimite.setMonth(dateLimite.getMonth() - 1);
  10328.  
  10329. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  10330. var str = MY_getValue(numTroll+'.INFOSIT');
  10331. var bAjoutTrollInvi = false;
  10332. if (str) {
  10333. var arr = str.split('$');
  10334. bAjoutTrollInvi = arr[4]>0;
  10335. }
  10336.  
  10337. var tBody = tr_trolls[0].parentNode;
  10338. if (tr_trolls[1] !== undefined)
  10339. tBody = tr_trolls[1].parentNode;
  10340.  
  10341. //window.console.log('nb Troll IT : ' + IDs.length);
  10342. var pos = getPosition();
  10343.  
  10344. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  10345. for (var idTroll in infosTrolls) {
  10346. var infos = infosTrolls[idTroll];
  10347. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  10348. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  10349. if (idTroll == numTroll) continue; // pas nous-même
  10350. var tr;
  10351. if (idTroll in MZ_tabTrTrollById) {
  10352. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  10353. tr = MZ_tabTrTrollById[idTroll];
  10354. } else {
  10355. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  10356. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  10357. // trouver où insérer ce Troll
  10358. var next = undefined;
  10359. for(var j=0 ; j<tr_trolls.length ; j++) {
  10360. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  10361. if (thisDist > distance) {
  10362. next = tr_trolls[j]
  10363. break;
  10364. }
  10365. }
  10366. if (next !== undefined) {
  10367. tr = insertTr(next,'mh_tdpage')
  10368. } else {
  10369. tr = appendTr(tBody,'mh_tdpage');
  10370. }
  10371. tr.style.color = 'orange';
  10372. var td = appendTd(tr); // distance
  10373. appendText(td, distance);
  10374. td = appendTd(tr); // actions
  10375. td = appendTd(tr); // ID
  10376. appendText(td, idTroll);
  10377. td = appendTd(tr); // Nom
  10378. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  10379. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  10380. td = appendTd(tr); // PV
  10381. td = appendTd(tr); // PA
  10382. td = appendTd(tr); // Guilde
  10383. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  10384. td = appendTd(tr); // Niveau
  10385. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  10386. td.align = 'center';
  10387. td = appendTd(tr); // Race
  10388. if (infos.race) appendText(td, infos.race);
  10389. td = appendTd(tr); // X
  10390. td.align = 'center';
  10391. if (infos.x !== undefined) appendText(td, infos.x);
  10392. td = appendTd(tr); // Y
  10393. td.align = 'center';
  10394. if (infos.y !== undefined) appendText(td, infos.y);
  10395. td = appendTd(tr); // N
  10396. td.align = 'center';
  10397. if (infos.n !== undefined) appendText(td, infos.n);
  10398. MZ_tabTrTrollById[idTroll] = tr;
  10399. }
  10400. if (!tr.done) {
  10401. addTdInfosTroll(infos, tr, itName);
  10402. tr.done = true;
  10403. }
  10404. }
  10405. } catch(e) {
  10406. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  10407. window.console.error(traceStack(e, 'putInfosTrolls'));
  10408. }
  10409. }
  10410.  
  10411.  
  10412. /* Mode Tétalanvert! ---------------------------------------------------------*/
  10413.  
  10414. function calculeDistance(maPos,posArr) {
  10415. return Math.max(
  10416. Math.abs(maPos[0]-posArr[0]),
  10417. Math.abs(maPos[1]-posArr[1]),
  10418. Math.abs(maPos[2]-posArr[2])
  10419. );
  10420. }
  10421.  
  10422. function inversionCoord() {
  10423. var maPos = getPosition();
  10424. var listeOffsets = {
  10425. 'monstres':checkBoxLevels.checked?4:3,
  10426. 'trolls':6,
  10427. };
  10428. for(var type in listeOffsets) {
  10429. var trList = this['tr_'+type];
  10430. var offset = listeOffsets[type];
  10431. for(var i=trList.length-1 ; i>0 ; i--) {
  10432. var oldX = parseInt(trList[i].cells[offset].textContent);
  10433. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  10434. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  10435. trList[i].cells[offset].innerHTML = oldY;
  10436. trList[i].cells[offset+1].innerHTML = oldX;
  10437. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  10438. }
  10439. }
  10440. }
  10441.  
  10442.  
  10443. /* Partie principale */
  10444. function do_vue() {
  10445. for(var type in typesAFetcher) {
  10446. fetchData(type);
  10447. }
  10448.  
  10449. // roule' 11/03/2016
  10450. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  10451. // je fais une recopie :(
  10452. tr_monstres = this['tr_monstres'];
  10453. tr_trolls = this['tr_trolls'];
  10454. tr_tresors = this['tr_tresors'];
  10455. tr_champignons = this['tr_champignons'];
  10456. tr_lieux = this['tr_lieux'];
  10457.  
  10458. nbMonstres = this['nbMonstres'];
  10459. nbTrolls = this['nbTrolls'];
  10460. nbTresors = this['nbTresors'];
  10461. nbChampignons = this['nbChampignons'];
  10462. nbLieux = this['nbLieux'];
  10463.  
  10464. try {
  10465. start_script(31);
  10466. initialiseInfos();
  10467. savePosition();
  10468.  
  10469. // Fonctionnalité "Têtalenvert" cachée, en test :
  10470. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  10471. inversionCoord();
  10472. }
  10473. ajoutDesFiltres();
  10474. set2DViewSystem();
  10475. //putBoutonTroogle();
  10476. putBoutonPXMP();
  10477. synchroniseFiltres();
  10478. toggleLevelColumn();
  10479.  
  10480. refreshDiplo();
  10481. //400 ms
  10482. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  10483. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  10484. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  10485. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  10486. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  10487. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  10488. var noTresorsEngages =
  10489. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  10490. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  10491. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  10492. filtreMonstres();
  10493. if(noIntangibles) {
  10494. filtreTrolls();
  10495. }
  10496. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  10497. filtreTresors();
  10498. }
  10499. if(noTrou) {
  10500. filtreLieux();
  10501. }
  10502.  
  10503. initPopupVue();
  10504. initPXTroll();
  10505.  
  10506. if(getTalent("Projectile Magique")!=0) {
  10507. computeProjo();
  10508. }
  10509. if(getTalent("Charger")!=0) {
  10510. computeCharge();
  10511. }
  10512. if(getTalent("Télékinésie")!=0) {
  10513. computeTelek();
  10514. }
  10515. if(getTalent("Lancer de Potions")!=0) {
  10516. computeLdP();
  10517. }
  10518. putScriptExterne();
  10519. displayScriptTime();
  10520. } catch(e) {
  10521. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10522. window.console.error(traceStack(e, 'vue'));
  10523. }
  10524. }
  10525.  
  10526.  
  10527.  
  10528. /*******************************************************************************
  10529. * This file is part of Mountyzilla. *
  10530. * *
  10531. * Mountyzilla is free software; you can redistribute it and/or modify *
  10532. * it under the terms of the GNU General Public License as published by *
  10533. * the Free Software Foundation; either version 2 of the License, or *
  10534. * (at your option) any later version. *
  10535. * *
  10536. * Mountyzilla is distributed in the hope that it will be useful, *
  10537. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10538. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10539. * GNU General Public License for more details. *
  10540. * *
  10541. * You should have received a copy of the GNU General Public License *
  10542. * along with Mountyzilla; if not, write to the Free Software *
  10543. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10544. *******************************************************************************/
  10545.  
  10546. // x~x profil2
  10547.  
  10548. /*---------------------------- Variables globales ----------------------------*/
  10549.  
  10550. var
  10551. // Anatrolliseur
  10552. urlAnatrolliseur,
  10553. // Infobulles talents
  10554. hauteur = 50, bulleStyle = null,
  10555. // Caracteristiques
  10556. // Infos troll
  10557. race, niv, idtroll, datecrea,
  10558. idguilde, nomguilde,
  10559. // Etats du troll
  10560. fatigue, bmfatigue,
  10561.  
  10562. // Experience, Pi, ...
  10563. pxdistribuables, pxperso,
  10564. piutilisable, pitotal,
  10565. nbmeurtres, nbmorts,
  10566. // utilisee pour les moyennes MM/jour, kill/jour, etc
  10567. NBjours,
  10568. // calcul des DLA suivantes
  10569. DLA, DLAsuiv, HeureServeur,
  10570. // details duree du tour (calcul pvdispo) :
  10571. dtb, pdm, bmt, adb, dpt,
  10572. //posale
  10573. posX, posY, posN,
  10574. // caracs physiques
  10575. vue, vuebp, vuebm, vuetotale,
  10576. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  10577. reg, regbp, regbm, regmoy,
  10578. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  10579. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  10580. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  10581. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  10582. rm, rmbp, rmbm, rmtotale,
  10583. mm, mmbp, mmbm, mmtotale,
  10584.  
  10585. // Variables speciales Kastars
  10586. pvActuelKastar, minParPV, overDLA,
  10587. // id pour edition manuelle de lastDLA :
  10588. inJour, inMois, inAn, inHr, inMin, inSec,
  10589. // id pour auto-refresh lastDLA :
  10590. lastDLAZone, maxAMZone, cumulZone,
  10591. lastDLA, DLAaccel;
  10592.  
  10593.  
  10594. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  10595.  
  10596. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10597. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10598. function getUniqueValueBySelector(selector, defaultValue){
  10599. var valNode = document.querySelector(selector);
  10600. if(valNode!=null){
  10601. if(valNode.hasChildNodes()) {
  10602. return valNode.childNodes[0].nodeValue;
  10603. }else{
  10604. return defaultValue;
  10605. }
  10606. } else{
  10607. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10608. return defaultValue;
  10609. }
  10610. }
  10611. function getUniqueStringValueBySelector(selector){
  10612. return getUniqueValueBySelector(selector,"");
  10613. }
  10614. function getUniqueIntValueBySelector(selector){
  10615. var ret = getUniqueValueBySelector(selector,0);
  10616. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10617. ret = 0;
  10618. }
  10619. return parseInt(ret);
  10620. }
  10621. function getUniqueFloatValueBySelector(selector){
  10622. var ret = getUniqueValueBySelector(selector,0.0);
  10623. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10624. ret = 0.0;
  10625. }
  10626. return parseFloat(ret);
  10627. }
  10628.  
  10629.  
  10630. function resiste(Ddeg,bm) {
  10631. // version naive mais compréhensible ^^
  10632. // DEBUG: à revoir
  10633. if(!bm) {
  10634. return 2*Math.floor(Ddeg/2);
  10635. }
  10636. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  10637. }
  10638.  
  10639. function retourAZero(fatig) {
  10640. var fat = fatig, raz = 0;
  10641. while(fat>0) {
  10642. raz++;
  10643. fat = Math.floor(fat/1.25);
  10644. }
  10645. return raz;
  10646. }
  10647.  
  10648. function decumulPumPrem(bonus) {
  10649. switch(bonus) {
  10650. case 20: return 33;
  10651. case 33: return 41;
  10652. case 41: return 46;
  10653. case 46: return 49;
  10654. case 49: return 51;
  10655. default: return 20;
  10656. }
  10657. }
  10658.  
  10659. function coefDecumul(i) {
  10660. switch(i) {
  10661. case 2: return 0.67;
  10662. case 3: return 0.4;
  10663. case 4: return 0.25;
  10664. case 5: return 0.15;
  10665. default: return 0.1;
  10666. }
  10667. }
  10668.  
  10669. function dureeHM(dmin) {
  10670. var ret = "";
  10671. dmin = Math.floor(dmin);
  10672. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  10673. var mins = dmin%60;
  10674. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  10675. return (ret) ? ret : "-";
  10676. }
  10677.  
  10678. // extraction d'une durée
  10679. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  10680. // c'est protégé (rend 0 si l'élément est absent)
  10681. // Roule' 24/12/2016
  10682. function extractionDuree(selecteur) {
  10683. var s = getUniqueStringValueBySelector(selecteur);
  10684. if (!s) return 0;
  10685. var tabN = getNumbers(s);
  10686. if (tabN.length < 2) return 0;
  10687. return tabN[0] * 60 + tabN[1];
  10688. }
  10689.  
  10690. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  10691.  
  10692. function extractionDonnees() {
  10693. // Variables temporaires
  10694. var Nbrs = {};
  10695.  
  10696. // *********************
  10697. // Cadre "Description"
  10698. // *********************
  10699. race = getUniqueStringValueBySelector('#descr #race');
  10700. debugMZ("Race : " + race);
  10701. idtroll = getUniqueStringValueBySelector('#descr #id');
  10702. debugMZ("Id troll : " + idtroll);
  10703. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  10704. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  10705. datecrea = new Date(StringToDate(strDateCrea));
  10706. debugMZ("Date creation : " + datecrea);
  10707. // Guilde
  10708. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  10709. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  10710. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  10711.  
  10712. // *******************
  10713. // Cadre "Experience"
  10714. // *******************
  10715. // Niveau de troll
  10716. niv = getUniqueIntValueBySelector('#exp #niv');
  10717. nivTroll = niv;
  10718. debugMZ("Niveau : " + niv);
  10719. // PX
  10720. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  10721. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  10722. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  10723. // PI
  10724. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  10725. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  10726. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  10727. // Meutres/Morts
  10728. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  10729. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  10730. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  10731.  
  10732. // *********************
  10733. // Cadre "Tour de Jeu"
  10734. // *********************
  10735. // DLA
  10736. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  10737. DLA = new Date(StringToDate(Nbrs["dla"]));
  10738. debugMZ("DLA: " + DLA);
  10739. // DLA suivante
  10740. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  10741. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  10742. debugMZ("DLAsuiv: " + DLAsuiv);
  10743. // Duree normale de mon Tour
  10744. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  10745. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  10746. dtb = extractionDuree("#dla #tour");
  10747. debugMZ("Duree normale de mon Tour : " + dtb);
  10748. // Bonus/Malus sur la duree
  10749. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  10750. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  10751. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  10752. debugMZ("Bonus/Malus sur la duree : " + bmt);
  10753. // Augmentation due aux blessures
  10754. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  10755. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  10756. adb = extractionDuree("#dla #blessure");
  10757. debugMZ("Augmentation due aux blessures : " + adb);
  10758. // Poids de l'equipement
  10759. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  10760. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  10761. pdm = extractionDuree("#dla #poids");
  10762. debugMZ("Poids de l'equipement : " + pdm);
  10763. // Duree de mon prochain Tour
  10764. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  10765. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  10766. dpt = extractionDuree("#dla #duree>b");
  10767. debugMZ('Duree de mon prochain Tour : ' + dpt);
  10768.  
  10769. // ****************
  10770. // Cadre "Etats"
  10771. // ****************
  10772. // Position du troll :
  10773. posX = getUniqueIntValueBySelector('#pos #x');
  10774. posY = getUniqueIntValueBySelector('#pos #y');
  10775. posN = getUniqueIntValueBySelector('#pos #n');
  10776. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  10777. // PV actuel
  10778. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  10779. pvActuelKastar = pvcourant;
  10780. debugMZ("PV actuel : " + pvcourant)
  10781. // Fatigue
  10782. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  10783. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  10784. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  10785.  
  10786. // **************************
  10787. // Cadre "Caracteristiques"
  10788. // **************************
  10789. // Attaque
  10790. att = getUniqueIntValueBySelector('#carac #att');
  10791. attbp = getUniqueIntValueBySelector('#carac #att_p');
  10792. attbm = getUniqueIntValueBySelector('#carac #att_m');
  10793. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  10794. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  10795. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  10796. attmoy = 3.5*att + attbp + attbm;
  10797. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10798. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  10799. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  10800. // Esquive
  10801. esq = getUniqueIntValueBySelector('#carac #esq');
  10802. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  10803. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  10804. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  10805. esqmoy = 3.5*esq + esqbp+esqbm;
  10806. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  10807. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  10808. // Degat
  10809. deg = getUniqueIntValueBySelector('#carac #deg');
  10810. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  10811. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  10812. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  10813. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  10814. degmoy = 2*deg + degbp+degbm;
  10815. degmoycrit = 3*deg + degbp+degbm;
  10816. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10817. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  10818. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  10819. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  10820. // PV
  10821. pvbase = getUniqueIntValueBySelector('#carac #pv');
  10822. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  10823. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  10824. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  10825. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  10826. // Regeneration
  10827. reg = getUniqueIntValueBySelector('#carac #reg');
  10828. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  10829. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  10830. regmoy = 2 * reg + regbp + regbm; // D3
  10831. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  10832. // Armure
  10833. arm = getUniqueIntValueBySelector('#carac #arm');
  10834. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  10835. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  10836. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  10837. armmoy = 2*arm + armbp+armbm;
  10838. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  10839. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  10840. // TODO : D d'armure non active
  10841. // Vue
  10842. vue = getUniqueIntValueBySelector('#carac #vue');
  10843. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  10844. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  10845. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  10846. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  10847. // RM
  10848. rm = getUniqueIntValueBySelector('#carac #rm');
  10849. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  10850. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  10851. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  10852. rmTroll = rmtotale;
  10853. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  10854. // MM
  10855. mm = getUniqueIntValueBySelector('#carac #mm');
  10856. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  10857. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  10858. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  10859. mmTroll = mmtotale;
  10860. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  10861.  
  10862. // Heure Serveur
  10863. try {
  10864. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  10865. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  10866. HeureServeur = new Date(StringToDate(heureServeurSTR));
  10867. } catch (e) {
  10868. window.console.warn(
  10869. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  10870. );
  10871. HeureServeur = new Date();
  10872. }
  10873. debugMZ("HeureServeur: " + HeureServeur);
  10874.  
  10875. // ***INIT GLOBALE*** NBjours
  10876. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  10877.  
  10878. // Calcul debut lien anatroliseur avec les caracteristiques connues
  10879. var amelio_dtb = function(dtb) {
  10880. if(dtb>555) {
  10881. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  10882. }
  10883. return 10+Math.ceil((555-dtb)/2.5);
  10884. },
  10885. amelio_pv = Math.floor(pvbase/10)-3,
  10886. amelio_vue = vue-3,
  10887. amelio_att = att-3,
  10888. amelio_esq = esq-3,
  10889. amelio_deg = deg-3,
  10890. amelio_reg = reg-1,
  10891. amelio_arm = arm-1;
  10892. if(race==="Darkling"){amelio_reg--; }
  10893. if(race==="Durakuir"){amelio_pv-- ; }
  10894. if(race==="Kastar") {amelio_deg--; }
  10895. if(race==="Skrim") {amelio_att--; }
  10896. if(race==="Tomawak") {amelio_vue--; }
  10897.  
  10898. urlAnatrolliseur = URL_AnatrolDispas
  10899. +"outils_anatrolliseur.php?anatrolliseur=v8"
  10900. +"|r="+race.toLowerCase()
  10901. +"|dla="+amelio_dtb(dtb)
  10902. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  10903. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  10904. +"|att="+amelio_att+","+attbp+","+attbm
  10905. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  10906. +"|deg="+amelio_deg+","+degbp+","+degbm
  10907. +"|reg="+amelio_reg+","+regbp+","+regbm
  10908. +"|arm="+amelio_arm+","+armbp+","+armbm
  10909. +"|mm="+mmtotale
  10910. +"|rm="+rmtotale+"|";
  10911. }
  10912.  
  10913. function saveProfil() {
  10914. MY_setValue(idtroll+'.caracs.attaque',att);
  10915. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  10916. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  10917. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  10918. if(atttourD||atttourP||atttourM) {
  10919. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10920. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  10921. }
  10922. MY_setValue(idtroll+'.caracs.esquive',esq);
  10923. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  10924. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  10925. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  10926. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  10927. MY_setValue(idtroll+'.caracs.degats',deg);
  10928. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  10929. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  10930. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  10931. if(degtourP||degtourM){
  10932. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10933. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  10934. }
  10935. MY_setValue(idtroll+'.caracs.regeneration',reg);
  10936. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  10937. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  10938. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  10939. MY_setValue(idtroll+'.caracs.vue',vue);
  10940. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  10941. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  10942. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  10943. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  10944. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  10945. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  10946. MY_setValue(idtroll+'.caracs.rm',rm);
  10947. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  10948. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  10949. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  10950. MY_setValue(idtroll+'.caracs.mm',mm);
  10951. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  10952. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  10953. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  10954. MY_setValue(idtroll+'.caracs.armure',arm);
  10955. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  10956. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  10957. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  10958. MY_setValue(idtroll+'.position.X',posX);
  10959. MY_setValue(idtroll+'.position.Y',posY);
  10960. MY_setValue(idtroll+'.position.N',posN);
  10961. MY_setValue(idtroll+'.race',race);
  10962. MY_setValue(idtroll+'.niveau',niv);
  10963. MY_setValue(idtroll+'.idguilde',idguilde);
  10964. MY_setValue(idtroll+'.nomguilde',nomguilde);
  10965. }
  10966.  
  10967.  
  10968. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  10969.  
  10970. function setInfosCaracteristiques() {
  10971. // Modification de l'entete
  10972. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  10973. thTotal.innerHTML+='|<i>Moyenne</i>';
  10974. thTotal.title="Moyenne (Moyenne ce tour)";
  10975.  
  10976. // Ajout des informations calculees
  10977. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  10978. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  10979. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  10980.  
  10981. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  10982. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  10983. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  10984.  
  10985. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  10986. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  10987. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  10988.  
  10989. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  10990. var tdRegTotal = trRegeneration.children[5];
  10991. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  10992. // Temps recupere par reg (propale R')
  10993. var regmoyTemp = Math.max(0, regmoy);
  10994. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  10995. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  10996. if (sec != 0) {
  10997. regTitle += " " + sec + " sec";
  10998. }
  10999. trRegeneration.title = regTitle;
  11000.  
  11001. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  11002. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  11003. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  11004.  
  11005. var trRM=document.querySelector("table#caracs #rm").parentElement;
  11006. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  11007. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  11008.  
  11009.  
  11010. var trMM=document.querySelector("table#caracs #mm").parentElement;
  11011. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  11012. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  11013.  
  11014. var tdRefl=document.querySelector("#refl");
  11015. // TODO : prendre en compte bonus/malus D esq du tour ?
  11016. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  11017. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  11018. }
  11019.  
  11020. function setLienAnatrolliseur(){
  11021. var pTableAmelio = document.querySelector("#carac>div>p");
  11022. pTableAmelio.innerHTML+=" - ";
  11023. var aElt = document.createElement("a");
  11024. aElt.setAttribute("href",urlAnatrolliseur);
  11025. aElt.setAttribute("target","_blank");
  11026. aElt.className="AllLinks";
  11027. aElt.innerHTML="Anatrolliser";
  11028. pTableAmelio.appendChild(aElt);
  11029. }
  11030. function setInfoDescription() {
  11031. var txtDateCrea = (NBjours!=1) ?
  11032. " ("+NBjours+" jours dans le hall)" :
  11033. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  11034. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  11035. }
  11036.  
  11037. function setInfosEtatLieux() {
  11038. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  11039. '?search=position&orderBy=distance&posx='+
  11040. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  11041. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  11042. appendBr(tdPosition);
  11043. var aElt = document.createElement("a");
  11044. aElt.setAttribute("href",urlBricol);
  11045. aElt.setAttribute("target","_blank");
  11046. aElt.className="AllLinks";
  11047. aElt.innerHTML="Lieux à proximité";
  11048. tdPosition.appendChild(aElt);
  11049. }
  11050.  
  11051. function setInfosEtatPV() { // pour AM et Sacro
  11052. var
  11053. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  11054. sec = Math.floor(15000/pvtotal)%60,
  11055. lifebar = document.querySelector("#pos .barre-vie");
  11056. if(sec!=0) { txt += " "+sec+" sec"; }
  11057. if(lifebar) { lifebar.title = txt; }
  11058. if(pvcourant<=0) { return; }
  11059. // Difference PV p/r a equilibre de temps (propale R')
  11060. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  11061. // ***INIT GLOBALE*** pvdispo
  11062. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11063. var span = document.createElement("span");
  11064. span.title = txt;
  11065. span.style.fontStyle = "italic";
  11066. if(bmt+pdm>=0) {
  11067. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  11068. } else if(pvdispo>0) {
  11069. txt = "Vous pouvez encore perdre "+
  11070. Math.min(pvdispo,pvcourant)+
  11071. " PV sans malus de temps.";
  11072. } else if(pvdispo<0) {
  11073. txt = "Il vous manque "
  11074. +(-pvdispo)
  11075. +" PV pour ne plus avoir de malus de temps.";
  11076. } else {
  11077. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  11078. }
  11079. appendText(span,txt);
  11080. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  11081. }
  11082.  
  11083. // Complete le cadre "Experience"
  11084. function setInfosExp() {
  11085. var tdNiv = document.querySelector("#exp #niv");
  11086.  
  11087. // Calcul niveau monstre/troll min pour gain PX
  11088. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  11089. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  11090.  
  11091. // Calcul PX restant
  11092. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  11093. if (pxRestant >= 0) {
  11094. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  11095. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  11096. }
  11097.  
  11098. // Calul pi/jour
  11099. var
  11100. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  11101. tdPi = document.querySelector("#exp #pi").parentElement;
  11102. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  11103. tdPi.title = tdPiTotal.title;
  11104.  
  11105. // Rapports meurtres,morts
  11106. var tdKill = document.querySelector("#exp #kill");
  11107. tdKill.setAttribute("colspan", 1);
  11108. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  11109.  
  11110. var tdMort = document.querySelector("#exp #mort");
  11111. tdMort.setAttribute("colspan", 1);
  11112. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  11113.  
  11114. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  11115. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  11116. }
  11117.  
  11118.  
  11119. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  11120.  
  11121. function minParPVsac(fat,bm) {
  11122. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  11123. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  11124. var out = [];
  11125. out[0] = (fat>4) ?
  11126. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  11127. 30;
  11128. if(bm && bm>0) {
  11129. var totalfat=fat+bm;
  11130. out[1] = (totalfat>4) ?
  11131. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  11132. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  11133. }
  11134. return out;
  11135. }
  11136.  
  11137. function toInt(str) {
  11138. str = parseInt(str);
  11139. return (str) ? str : 0;
  11140. }
  11141.  
  11142. function saveLastDLA() {
  11143. // pour les calculs d'AM max
  11144. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  11145. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  11146. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  11147. lastDLA = new Date( StringToDate(str) );
  11148. MY_setValue(numTroll+'.DLA.ancienne',str);
  11149. lastDLAZone.innerHTML = '';
  11150. var b = document.createElement('b');
  11151. b.addEventListener('click',inputMode,false);
  11152. appendText(b,str);
  11153. lastDLAZone.appendChild(b);
  11154. refreshAccel();
  11155. }
  11156.  
  11157. function inputMode() {
  11158. // Edition manuelle lastDLA
  11159. var date;
  11160. if(lastDLA)
  11161. date = new Date( lastDLA );
  11162. else
  11163. date = new Date( DLAaccel );
  11164. lastDLAZone.innerHTML = '';
  11165. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  11166. appendText(lastDLAZone,'/');
  11167. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  11168. appendText(lastDLAZone,'/');
  11169. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  11170. appendText(lastDLAZone,' - ');
  11171. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  11172. appendText(lastDLAZone,':');
  11173. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  11174. appendText(lastDLAZone,':');
  11175. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  11176. appendText(lastDLAZone,' - ');
  11177. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  11178. }
  11179.  
  11180. function setAccel() {
  11181. var
  11182. BMfrais=false,
  11183. fat=fatigue, listeBmFat=[],
  11184. tr, th, insertPt;
  11185.  
  11186. // Creation ligne speciale pour AM dans le cadre "Etat"
  11187. tr = document.createElement('tr');
  11188. th = document.createElement('th');
  11189. appendText(th,'Fatigue et AM',true);
  11190. tr.appendChild(th);
  11191. insertPt = document.createElement('td');
  11192. tr.appendChild(insertPt);
  11193. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  11194.  
  11195. // Est-on en over-DLA ?
  11196. // ***INIT GLOBALE*** overDLA
  11197. overDLA = (HeureServeur>DLA.getTime()+3e5);
  11198. if(overDLA) {
  11199. fat=Math.floor(fatigue/1.25);
  11200. }
  11201.  
  11202. // Gestion des BM de fatigue
  11203. if(bmfatigue>0) {
  11204. // On tente de recuperer les BM de fatigue de la page des BM
  11205. if(MY_getValue(numTroll+'.bm.fatigue')) {
  11206. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  11207. BMmemoire.pop();
  11208. var tour = 0;
  11209. for(var i=0 ; i<BMmemoire.length ; i++) {
  11210. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  11211. while(tour<=parseInt(nbrs[0])) {
  11212. listeBmFat[tour]=parseInt(nbrs[1]);
  11213. tour++;
  11214. }
  11215. }
  11216. }
  11217. if(listeBmFat[0]==bmfatigue) {
  11218. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  11219. BMfrais = true;
  11220. MY_removeValue(numTroll+".bm.fatigue");
  11221. }
  11222. } else {
  11223. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  11224. BMfrais = true;
  11225. }
  11226. if(!BMfrais && bmfatigue>0) {
  11227. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  11228. if(bmfatigue==15) {
  11229. listeBmFat = [15,15,15];
  11230. } else {
  11231. listeBmFat = [30,30,15];
  11232. }
  11233. }
  11234. if(overDLA) {
  11235. // Si on est en over-DLA, on decale les bm d'un tour
  11236. listeBmFat.shift();
  11237. }
  11238. // Tableau des fatigues et accel futures
  11239. var
  11240. minppv = minParPVsac(fat,listeBmFat[0]),
  11241. table, tbody,
  11242. ligneTour, ligneFat, ligneMin,
  11243. col;
  11244. // ***INIT GLOBALE*** minParPV
  11245. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  11246. if(fat>0 || listeBmFat[0]>0) {
  11247. table = document.createElement('table');
  11248. table.className = 'mh_tdborder';
  11249. table.border = 0;
  11250. table.cellSpacing = 1;
  11251. table.cellPadding = 1;
  11252. table.style.textAlign = "center";
  11253. tbody = document.createElement('tbody');
  11254. table.appendChild(tbody);
  11255. insertPt.appendChild(table);
  11256. ligneTour = appendTr(tbody,'mh_tdtitre');
  11257. ligneTour.style.fontWeight = "bold";
  11258. var td = appendTdText(ligneTour,'Tour :',true);
  11259. td.align = 'left';
  11260. ligneFat = appendTr(tbody,'mh_tdpage');
  11261. td = appendTdText(ligneFat,'Fatigue :',true);
  11262. td.className = 'mh_tdtitre';
  11263. td.align = 'left';
  11264. ligneMin = appendTr(tbody,'mh_tdpage');
  11265. td = appendTdText(ligneMin,'1 PV =',true);
  11266. td.className = 'mh_tdtitre';
  11267. td.align = 'left';
  11268. col=0;
  11269. while(col<9 && (fat>0 || listeBmFat[col])) {
  11270. if(col==0) {
  11271. if(overDLA) {
  11272. var i = document.createElement('i');
  11273. appendText(i,'A activer');
  11274. ligneTour.appendChild(i);
  11275. } else {
  11276. appendTdText(ligneTour,'En cours');
  11277. }
  11278. } else {
  11279. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  11280. }
  11281. if(listeBmFat[col]) {
  11282. if(BMfrais || (!overDLA && col==0)) {
  11283. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  11284. appendTdText(ligneMin,minppv[1]+'\'');
  11285. } else {
  11286. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  11287. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  11288. }
  11289. } else {
  11290. appendTdText(ligneFat,fat);
  11291. appendTdText(ligneMin,minppv[0]+'\'');
  11292. }
  11293. col++;
  11294. fat = Math.floor(fat / 1.25);
  11295. minppv = minParPVsac(fat,listeBmFat[col]);
  11296. }
  11297. if(fat>1 || (fat==1 && !overDLA)) {
  11298. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  11299. appendTdText(ligneFat,'-');
  11300. appendTdText(ligneMin,'-');
  11301. }
  11302. col = (overDLA) ?
  11303. Math.max(retourAZero(fatigue)-1,col) :
  11304. Math.max(retourAZero(fatigue),col);
  11305. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  11306. appendTdText(ligneFat,'0');
  11307. appendTdText(ligneMin,'30\'');
  11308. if(!BMfrais && bmfatigue) {
  11309. // si les BM n'ont pas ete rafraichis, on signale:
  11310. appendText(
  11311. insertPt,
  11312. '/!\\ Visitez la page des Bonus/Malus '+
  11313. 'pour mettre à jour votre fatigue. /!\\',
  11314. true
  11315. );
  11316. appendBr(insertPt);
  11317. }
  11318. appendBr(insertPt);
  11319. }
  11320. if(pvcourant<=0) {
  11321. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  11322. return;
  11323. }
  11324. if(fatigue>30) {
  11325. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  11326. return;
  11327. }
  11328. // Setup lastDLAZone
  11329. if(overDLA) {
  11330. // bypass des infos de "menu_FF.js" en cas d'overDLA
  11331. DLAaccel = new Date( DLAsuiv );
  11332. lastDLA = new Date( DLA );
  11333. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  11334. // ***INIT GLOBALE*** pvActuelKastar
  11335. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  11336. appendText(
  11337. insertPt,
  11338. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  11339. true
  11340. );
  11341. appendBr(insertPt);
  11342. } else {
  11343. DLAaccel = new Date( DLA );
  11344. pvActuelKastar = pvcourant;
  11345. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  11346. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  11347. } else {
  11348. lastDLA = false;
  11349. }
  11350. }
  11351. appendText(insertPt,'Dernière DLA enregistrée : ');
  11352. lastDLAZone = document.createElement('span');
  11353. lastDLAZone.style.cursor = 'pointer';
  11354. var b = document.createElement('b');
  11355. b.onclick = inputMode;
  11356. lastDLAZone.appendChild(b);
  11357. insertPt.appendChild(lastDLAZone);
  11358. if(lastDLA) {
  11359. appendText(b,DateToString(lastDLA));
  11360. } else {
  11361. appendText(b,'aucune');
  11362. }
  11363. appendBr(insertPt);
  11364. // Setup maxAMZone et cumulZone
  11365. appendText(insertPt,'Accélération maximale possible : ');
  11366. maxAMZone = document.createElement('b');
  11367. insertPt.appendChild(maxAMZone);
  11368. appendBr(insertPt);
  11369. cumulZone = document.createElement('span');
  11370. insertPt.appendChild(cumulZone);
  11371. refreshAccel();
  11372. }
  11373.  
  11374. function refreshAccel() {
  11375. var pvs, pvsmax;
  11376. // Acceleration pour cumul instantane
  11377. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  11378. if(lastDLA) {
  11379. pvsmax = Math.min(
  11380. pvActuelKastar-1,
  11381. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  11382. );
  11383. maxAMZone.innerHTML = pvsmax+" PV";
  11384. } else {
  11385. pvsmax = pvActuelKastar-1;
  11386. maxAMZone.innerHTML = "inconnue";
  11387. }
  11388. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  11389. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  11390. cumulZone.innerHTML = '';
  11391. if(pvs<=pvsmax) {
  11392. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  11393. appendText(cumulZone,pvs+' PV', true);
  11394. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  11395. if(pvs!=1) {
  11396. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  11397. -(pvs-1)*60*minParPV;
  11398. appendText(
  11399. cumulZone,
  11400. ' ('+(pvs-1)+' PV dans '+
  11401. Math.floor(gainSec/60)+'min'+
  11402. addZero(gainSec%60)+'s)'
  11403. );
  11404. }
  11405. } else {
  11406. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  11407. appendText(
  11408. cumulZone,
  11409. 'Après votre accélération maximale, il vous faudra encore attendre '+
  11410. dureeHM(avantDLA/6e4)+
  11411. ' avant de réactiver.'
  11412. );
  11413. }
  11414. }
  11415.  
  11416.  
  11417. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  11418.  
  11419. function traitementTalents() {
  11420. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  11421. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  11422. removeAllTalents();
  11423. var totalComp = injecteInfosBulles(trCompetence,'competences');
  11424. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  11425. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  11426. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  11427. }
  11428.  
  11429. function injecteInfosBulles(liste,fonction) {
  11430. var totalpc = 0;
  11431. // on parse la liste des talents du type 'fonction'
  11432. for(var i=0 ; i<liste.length ; i++) {
  11433. var
  11434. trTalent=liste[i],
  11435. node=trTalent.cells[1].querySelector('a'),
  11436. nomTalent=epure(trim(node.textContent)),
  11437. indiceTDniveaux=7,
  11438. indiceTDSousCompetence=2,
  11439. sousCompetences=undefined;
  11440. if(fonction=="competences"){
  11441. // un TD en plus pour des information complementaire liees a la comp
  11442. indiceTDniveaux++;
  11443. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  11444. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  11445. for (var j=0; j < sousCompetences.length; j++) {
  11446. sousCompetences[j] = sousCompetences[j].epure().trim();
  11447. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  11448. }
  11449. }
  11450. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  11451. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  11452. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  11453. totalpc += niveauxMaitrisesTalentArray[1];
  11454.  
  11455. // stockage des niveaux inferieurs du talent si presents
  11456. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  11457. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  11458. totalpc+=niveauxMaitrisesTalentArray[j+1];
  11459. }
  11460. }
  11461. return totalpc;
  11462. }
  11463.  
  11464. function setInfos(node,nom,fonction,niveau) {
  11465. node.nom = nom;
  11466. node.fonction = fonction;
  11467. node.niveau = niveau;
  11468. node.onmouseover = setBulle;
  11469. node.onmouseout = cacherBulle;
  11470. }
  11471.  
  11472. var arrayModifAnatroll = {
  11473. 'Glue':'Glu',
  11474. 'PuM':'PuiM',
  11475. 'HE':'Hurlement',
  11476. //'Insultes':'Insu',
  11477. 'Pistage':'Pist',
  11478. 'PuC':'Planter'
  11479. }
  11480.  
  11481. function setTalent(nom,pc,niveau,sousCompetences) {
  11482. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  11483. // (et pas les % dont osf) ne serait pas plus rentable
  11484. var nomEnBase = arrayTalents[epure(nom)];
  11485. if(!nomEnBase) { return; }
  11486. if(!niveau) { niveau = 1; }
  11487. switch(nomEnBase) {
  11488. case 'Insultes':
  11489. urlAnatrolliseur += 'Insu'+niveau+'|';
  11490. case 'IdT':
  11491. nomEnBase += niveau;
  11492. break;
  11493. case 'Golemo':
  11494. case 'Piege':
  11495. for (var i=0 ; i < sousCompetences.length ; i++) {
  11496. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  11497. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  11498. }
  11499. break;
  11500. case 'AP':
  11501. case 'Baroufle':
  11502. case 'CdB':
  11503. case 'CdM':
  11504. case 'Parer':
  11505. case 'Retraite':
  11506. case 'RB':
  11507. case 'SInterposer':
  11508. nomEnBase += niveau;
  11509. default:
  11510. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  11511. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  11512. }
  11513. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  11514. }
  11515.  
  11516. function creerBulleVide() {
  11517. var table = document.createElement('table');
  11518. table.id = 'bulle';
  11519. table.className = 'mh_tdborder';
  11520. table.width = 300;
  11521. table.border = 0;
  11522. table.cellPadding = 5;
  11523. table.cellSpacing = 1;
  11524. table.style =
  11525. 'position:absolute;'
  11526. +'visibility:hidden;'
  11527. +'z-index:800;'
  11528. +'height:auto;';
  11529. var tr = appendTr(table,'mh_tdtitre');
  11530. appendTdText(tr,'Titre');
  11531. tr = appendTr(table,'mh_tdpage');
  11532. appendTdText(tr,'Contenu');
  11533. var aList = document.getElementsByTagName('a');
  11534. aList[aList.length-1].parentNode.appendChild(table);
  11535. }
  11536.  
  11537. function cacherBulle() {
  11538. if(bulleStyle)
  11539. bulleStyle.visibility = 'hidden';
  11540. }
  11541.  
  11542. function setBulle(evt) {
  11543. var nom = this.nom;
  11544. var fonction = this.fonction;
  11545. var niveau = parseInt(this.niveau);
  11546. var str='';
  11547. if(fonction=='competences'){
  11548. str=competences(nom,niveau);
  11549. } else if(fonction=='sortileges') {
  11550. str=sortileges(nom,true);
  11551. }
  11552. if(str=='') return;
  11553. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  11554. var xfenetre, yfenetre, xpage, ypage, element = null;
  11555. var offset = 15;
  11556. var bulleWidth = 300;
  11557. if(!hauteur) hauteur = 50;
  11558. element = document.getElementById('bulle');
  11559. xfenetre = evt.clientX;
  11560. yfenetre = evt.clientY;
  11561. xpage = xfenetre;
  11562. ypage = yfenetre;
  11563. if(evt.pageX) xpage = evt.pageX;
  11564. if(evt.pageY) ypage = evt.pageY;
  11565. if(element) {
  11566. bulleStyle = element.style;
  11567. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  11568. element.childNodes[1].firstChild.innerHTML = str;
  11569. }
  11570. if(bulleStyle) {
  11571. if(xfenetre>bulleWidth+offset)
  11572. xpage -= bulleWidth+offset;
  11573. else
  11574. xpage += offset;
  11575. if(yfenetre>hauteur+offset)
  11576. ypage -= hauteur + offset;
  11577. bulleStyle.width = bulleWidth;
  11578. bulleStyle.left = xpage + 'px';
  11579. bulleStyle.top = ypage + 'px';
  11580. bulleStyle.visibility = 'visible';
  11581. }
  11582. }
  11583.  
  11584.  
  11585. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  11586.  
  11587. function competences(comp,niveau) {
  11588. var texte = '';
  11589. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  11590. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  11591. if(minParPV>1) texte += 's';
  11592. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  11593. }
  11594. else if(comp.indexOf('Attaque Precise')!=-1) {
  11595. var pc, lastmax=0, espatt=0;
  11596. var notMaxedOut = false;
  11597. for(var i=niveau ; i>0 ; i--) {
  11598. pc = getTalent(comp,i);
  11599. if(lastmax!=0 && pc<=lastmax) continue;
  11600. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  11601. attbp+attbm;
  11602. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11603. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  11604. ' => <b>'+jetatt+'</b><br/>';
  11605. espatt += (pc-lastmax)*jetatt;
  11606. lastmax = pc;
  11607. if(i<niveau) notMaxedOut = true;
  11608. }
  11609. if(notMaxedOut) {
  11610. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  11611. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  11612. }
  11613. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  11614. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11615. }
  11616. else if(comp.indexOf('Balayage')!=-1)
  11617. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  11618. +' => <b>'+attmoy+'</b><br/>'
  11619. +'Effet : <b>Met à terre l\'adversaire</b>';
  11620. else if(comp.indexOf('Bidouille')!=-1)
  11621. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  11622. +'de votre inventaire avec le texte de votre choix.';
  11623. else if(comp.indexOf('Baroufle')!=-1){
  11624. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  11625. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  11626. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  11627. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  11628. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  11629. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  11630. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  11631. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  11632. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  11633. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  11634. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  11635. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  11636. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  11637. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  11638. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  11639. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  11640. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  11641. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  11642. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  11643. '</tbody></table>';
  11644. }
  11645. else if(comp.indexOf('Botte Secrete')!=-1){
  11646. texte = 'Attaque : <b>'
  11647. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11648. +' => <b>'
  11649. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  11650. +'</b><br/>Dégâts : <b>'
  11651. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  11652. +' => <b>'
  11653. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  11654. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  11655. +'</b>';
  11656. }
  11657. else if(comp.indexOf('Camouflage')!=-1) {
  11658. var camou = getTalent('Camouflage');
  11659. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  11660. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  11661. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  11662. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  11663. }
  11664. else if(comp.indexOf('Charger')!=-1) {
  11665. if(pvcourant<=0)
  11666. return '<i>On ne peut charger personne quand on est mort !</i>';
  11667. var portee = Math.min(
  11668. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  11669. vuetotale);
  11670. if(portee<1)
  11671. return '<b>Impossible de charger</b>';
  11672. else {
  11673. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11674. +' => <b>'+attmoy+'</b><br/>'
  11675. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11676. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  11677. +'<br/>Portée : <b>'+portee+'</b> case';
  11678. if(portee>1) texte += 's';
  11679. }
  11680. }
  11681. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  11682. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  11683. if(vuetotale>1) texte += 's';
  11684. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11685. if(vuetotale>2) texte += 's';
  11686. }
  11687. else if(comp.indexOf('Piege')!=-1) {
  11688. if(comp.indexOf('Glue')!=-1)
  11689. texte = 'Et si vous colliez vos adversaires au sol ?';
  11690. if(comp.indexOf('Feu')!=-1) {
  11691. if(texte){
  11692. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  11693. }
  11694. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  11695. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  11696. }
  11697. }
  11698. else if(comp.indexOf('Contre-Attaquer')!=-1){
  11699. texte = 'Attaque : <b>'
  11700. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11701. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11702. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11703. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11704. }
  11705. else if(comp.indexOf('Coup de Butoir')!=-1) {
  11706. var pc, lastmax=0, espdeg=0;
  11707. var notMaxedOut = false;
  11708. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11709. +' => <b>'+attmoy+'</b>';
  11710. for(var i=niveau ; i>0 ; i--) {
  11711. pc = getTalent(comp,i);
  11712. if(lastmax!=0 && pc<=lastmax) continue;
  11713. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  11714. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11715. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  11716. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  11717. espdeg += (pc-lastmax)*jetdeg;
  11718. lastmax = pc;
  11719. if(i<niveau) notMaxedOut = true;
  11720. }
  11721. if(notMaxedOut) {
  11722. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  11723. Math.floor(10*espdeg/lastmax)/10+'/'+
  11724. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  11725. }
  11726. }
  11727. else if(comp.indexOf('Course')!=-1)
  11728. texte = 'Déplacement gratuit : <b>'
  11729. +Math.floor(getTalent('Course')/2)
  11730. +' %</b> de chance';
  11731. else if(comp.indexOf('Deplacement Eclair')!=-1)
  11732. texte = 'Permet d\'économiser <b>1</b> PA '
  11733. +'par rapport au déplacement classique';
  11734. else if(comp.indexOf('Dressage')!=-1)
  11735. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  11736. +'ou un gnu sauvage.';
  11737. else if(comp.indexOf('Ecriture Magique')!=-1)
  11738. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  11739. +'la formule nécessite de réunir les composants de cette formule, '
  11740. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  11741. +'un champignon adéquat pour confectionner l\'encre.';
  11742. else if(comp.indexOf('Frenesie')!=-1) {
  11743. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11744. +' => <b>'+attmoy+'</b><br/>'
  11745. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11746. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11747. }
  11748. else if(comp.indexOf('Golem')!=-1)
  11749. texte = 'Animez votre golem en assemblant divers matériaux '
  11750. +'autour d\'un cerveau minéral.'
  11751. else if(comp.indexOf('Grattage')!=-1) {
  11752. texte = 'Permet de confectionner un Parchemin Vierge '
  11753. +'à partir de composants et de Gigots de Gob\'.';
  11754. }
  11755. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  11756. texte = 'Fait fuir un monstre si tout se passe bien.'
  11757. +'<br/>Lui donne de gros bonus sinon...';
  11758. else if(comp.indexOf('Identification des Champignons')!=-1) {
  11759. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  11760. if(vuetotale>2) texte += 's';
  11761. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  11762. if(vuetotale>4) texte += 's';
  11763. }
  11764. else if(comp.indexOf('Insultes')!=-1)
  11765. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  11766. else if(comp.indexOf('interposer')!=-1)
  11767. texte = 'Jet de réflexe : <b>'
  11768. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  11769. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  11770. else if(comp.indexOf('Lancer de Potions') != -1)
  11771. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  11772. else if(comp.indexOf('Marquage')!=-1)
  11773. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  11774. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  11775. +'se trouver dans la même caverne que le monstre pour le marquer.';
  11776. else if(comp.indexOf('Melange Magique')!=-1)
  11777. texte = 'Cette Compétence permet de combiner deux Potions pour '
  11778. +'en réaliser une nouvelle dont l\'effet est la somme '
  11779. +'des effets des potions initiales.';
  11780. else if(comp.indexOf('Miner')!=-1) // obsolète
  11781. texte = 'Portée horizontale (officieuse) : <b>'
  11782. +2*vuetotale+'</b> cases<br/>'
  11783. +'Portée verticale (officieuse) : <b>'
  11784. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11785. else if(comp.indexOf('Travail de la pierre')!=-1)
  11786. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  11787. +2*vuetotale+'</b> cases</li>'
  11788. +'<li>Portée verticale (officieuse) : <b>'
  11789. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  11790. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  11791. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  11792. else if(comp.indexOf('Necromancie')!=-1)
  11793. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  11794. +'de faire "revivre" ce monstre.';
  11795. else if(comp.indexOf('Painthure de Guerre')!=-1)
  11796. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  11797. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  11798. +'pour s\'inspirer, et laissez parler votre créativité.'
  11799. else if(comp.indexOf('Parer')!=-1)
  11800. texte = 'Jet de parade : <b>'
  11801. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  11802. +' => <b>'
  11803. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11804. +'</b><hr><i>Equivalent esquive : <b>'
  11805. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  11806. +' => <b>'
  11807. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  11808. +'</b></i>';
  11809. else if(comp.indexOf('Pistage')!=-1)
  11810. texte = 'Portée horizontale : <b>'
  11811. +2*vuetotale+'</b> cases<br/>'
  11812. +'Portée verticale : <b>'
  11813. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11814. else if(comp.indexOf('Planter un Champignon')!=-1)
  11815. texte = 'Planter un Champignon est une compétence qui vous permet de '
  11816. +'créer des colonies d\'une variété donnée de champignon à partir de '
  11817. +'quelques exemplaires préalablement enterrés.';
  11818. else if(comp.indexOf('Regeneration Accrue')!=-1)
  11819. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  11820. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  11821. else if(comp.indexOf('Reparation')!=-1)
  11822. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  11823. +'et réparez vous-même votre matériel !';
  11824. else if(comp.indexOf('Retraite')!=-1)
  11825. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  11826. +'préférable de préparer un repli stratégique pour déconcerter '
  11827. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  11828. +'Quelle intelligence démoniaque.';
  11829. else if(comp.indexOf('Rotobaffe')!=-1) {
  11830. var Datt = att, vattbm = attbp+attbm;
  11831. var Ddeg = deg, vdegbm = degbp+degbm;
  11832. for(var i=1 ; i<niveau+2 ; i++) {
  11833. texte += '<b>Attaque n°'+i+' :</b><br/>'
  11834. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  11835. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  11836. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  11837. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  11838. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  11839. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  11840. if(i<niveau+1) texte += '<hr>';
  11841. }
  11842. }
  11843. else if(comp.indexOf('Shamaner')!=-1)
  11844. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  11845. +'des monstres en utilisant des champignons (de 1 à 3).';
  11846. else if(comp.indexOf('Tailler')!=-1){ // obsolète
  11847. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  11848. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  11849. }
  11850. return texte;
  11851. }
  11852.  
  11853. function decumul_buff(nom,str,buff) {
  11854. // Decumul des sorts de buff
  11855. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  11856. var dec = buff, total = buff, i=1;
  11857. while(i<6) {
  11858. i++;
  11859. dec = Math.floor(coefDecumul(i)*buff);
  11860. if(dec<=1 || i==6) break;
  11861. total += dec;
  11862. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  11863. +str+' +'+dec+' (+'+total+')</i>';
  11864. }
  11865. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  11866. return ret;
  11867. }
  11868.  
  11869.  
  11870. function sortileges(sort,mainCall,pcA,pcD) {
  11871. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  11872. var texte = '';
  11873. if (mainCall) {
  11874. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  11875. pcA = (atttourP+atttourM);
  11876. pcD = (degtourP+degtourM);
  11877. }
  11878. if (sort.indexOf('Analyse Anatomique') != -1) {
  11879. texte = 'Portée horizontale : <b>'
  11880. + Math.floor(vuetotale / 2) + '</b> case';
  11881. if (vuetotale > 3){ texte += 's'; }
  11882. texte += '<br/>Portée verticale : <b>'
  11883. + Math.floor((vuetotale+1)/4)+'</b> case';
  11884. if (vuetotale > 7){ texte += 's'; }
  11885. }
  11886. else if (sort.indexOf('Armure Etheree') != -1){
  11887. texte = decumul_buff('AE', 'Armure magique', reg);
  11888. }
  11889. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  11890. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  11891. }
  11892. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  11893. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  11894. }
  11895. else if (sort.indexOf('Augmentation des Degats') != -1){
  11896. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  11897. }
  11898. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  11899. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  11900. }
  11901. else if(sort.indexOf('Bulle Magique')!=-1){
  11902. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  11903. }
  11904. else if(sort.indexOf('Explosion')!=-1){
  11905. texte = 'Dégâts : <b>'
  11906. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  11907. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  11908. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  11909. }
  11910. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  11911. if(pvcourant<=0)
  11912. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  11913. texte = 'Portée horizontale : <b>'
  11914. +Math.min(1,vuetotale)+'</b> case<br/>'
  11915. +'Dégâts physiques : <b>-'
  11916. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  11917. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  11918. +'Dégâts magiques : <b>-'
  11919. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  11920. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  11921. }
  11922. else if(sort.indexOf('Flash Aveuglant')!=-1){
  11923. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  11924. }
  11925. else if(sort.indexOf('Glue')!=-1) {
  11926. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  11927. if(vuetotale>2) texte += 's';
  11928. }
  11929. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  11930. /* Frappe */
  11931. var modD = 0;
  11932. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11933. if(pcA!=0){
  11934. modD = parseInt(att*pcA/100);
  11935. texte += '<i>'+aff(modD)+'D6</i> ';
  11936. }
  11937. texte += aff(attbm)
  11938. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  11939. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  11940. if(pcD!=0) {
  11941. modD = parseInt(Math.floor(deg/2)*pcD/100);
  11942. texte += '<i>'+aff(modD)+'D3</i> ';
  11943. }else
  11944. modD = 0;
  11945. texte += aff(degbm)+' => <b>'
  11946. +(2*(Math.floor(deg/2)+modD)+degbm)
  11947. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  11948. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  11949. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  11950. +')</b>';
  11951. if(!mainCall) return texte;
  11952. /* Venins */
  11953. function addVenin(type,effet,duree) {
  11954. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  11955. +' pendant <b>'+duree+'</b> tour';
  11956. if(duree>1) ret += 's';
  11957. var dred = Math.max(Math.floor(duree/2),1);
  11958. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  11959. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  11960. }
  11961. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  11962. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  11963. effet = Math.floor(1.5*effet);
  11964. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  11965. }
  11966. else if(sort.indexOf('Hypnotisme')!=-1)
  11967. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  11968. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  11969. else if(sort.indexOf('Identification des tresors')!=-1)
  11970. texte = 'Permet de connaitre les caractéristiques et effets précis '
  11971. +'d\'un trésor.';
  11972. else if(sort.indexOf('Invisibilite')!=-1)
  11973. texte = 'Un troll invisible est indétectable même quand on se trouve '
  11974. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  11975. +'fait disparaître l\'invisibilité.';
  11976. else if(sort.indexOf('Levitation')!=-1)
  11977. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  11978. +'Comme les pièges ou les trous par exemple...';
  11979. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  11980. var eps = 1,
  11981. pc = 20;
  11982. var str = 'PréM';
  11983. var newSort;
  11984. var sortAtt = [
  11985. 'Projectile Magique',
  11986. 'Rafale Psychique',
  11987. 'Siphon des Ames',
  11988. 'Vampirisme',
  11989. 'Griffe du Sorcier'
  11990. ];
  11991. if(sort.indexOf('Puissance')!=-1) {
  11992. eps = -1; str='PuM';
  11993. }
  11994. for(var i=1 ; i<4 ; i++) {
  11995. if(texte) { texte += '<hr>'; }
  11996. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  11997. newSort = false;
  11998. for(var j=0 ; j<sortAtt.length ; j++) {
  11999. if(getTalent(sortAtt[j])) {
  12000. if(newSort) { texte += '<br/><br/>'; }
  12001. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  12002. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  12003. newSort = true;
  12004. }
  12005. }
  12006. pc = decumulPumPrem(pc);
  12007. }
  12008. }
  12009. else if(sort.indexOf('Projectile Magique')!=-1) {
  12010. var modD = 0;
  12011. var portee = getPortee__Profil(vuetotale);
  12012. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  12013. if(pcA!=0) {
  12014. modD = parseInt(vue*pcA/100);
  12015. texte += '<i>'+aff(modD)+'D6</i> ';
  12016. }
  12017. texte += aff(attbm)
  12018. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  12019. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  12020. if(pcD!=0) {
  12021. modD = parseInt(Math.floor(vue/2)+pcD);
  12022. texte += '<i>'+aff(modD)+'D3</i> ';
  12023. }else
  12024. modD = 0;
  12025. texte += aff(degbm)
  12026. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  12027. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  12028. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  12029. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+') (+ 1D3 par bonus de portée)</b>';
  12030. if(!mainCall) return texte;
  12031. texte += '<br/>Portée : <b>'+portee+'</b> case';
  12032. if(portee>1) texte += 's';
  12033. }
  12034. else if(sort.indexOf('Projection')!=-1) {
  12035. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  12036. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  12037. +'Si le jet de résistance de la victime est réussi:<br/>'
  12038. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  12039. }
  12040. else if(sort.indexOf('Rafale Psychique')!=-1) {
  12041. var modD = 0;
  12042. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  12043. if(pcD!=0) {
  12044. modD = parseInt(deg*pcD/100);
  12045. texte += '<i>'+aff(modD)+'D3</i> ';
  12046. }
  12047. texte += aff(degbm)
  12048. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  12049. if(!mainCall) return texte;
  12050. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  12051. }
  12052. else if(sort.indexOf('Sacrifice')!=-1) {
  12053. if(pvcourant<=0)
  12054. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  12055.  
  12056. function perteSacro(sac) {
  12057. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  12058. }
  12059.  
  12060. var sac = Math.floor((pvcourant-1)/2);
  12061. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  12062. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  12063. /* Sacros max et optimal sans malus (propale R') */
  12064. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  12065. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  12066. if(sac>0)
  12067. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  12068. else
  12069. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  12070. /*if(sac>3) {
  12071. sac = 5*Math.floor((sac+1)/5)-1;
  12072. texte += '<br/>Soin optimal sans malus de temps : <b>'
  12073. +sac+'</b> PV'+perteSacro(sac);
  12074. }*/
  12075. }
  12076. else if(sort.indexOf('Siphon')!=-1) {
  12077. var modD = 0;
  12078. texte = 'Attaque : <b>'+att+'</b> D6 ';
  12079. if(pcA!=0) {
  12080. modD = parseInt(att*pcA/100);
  12081. texte += '<i>'+aff(modD)+'D6</i> ';
  12082. }
  12083. texte += aff(attbm)
  12084. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  12085. +'Dégâts : <b>'+reg+'</b> D3 ';
  12086. if(pcD!=0) {
  12087. modD = parseInt(reg*pcD/100);
  12088. texte += '<i>'+aff(modD)+'D3</i> ';
  12089. }else
  12090. modD = 0;
  12091. texte += aff(degbm)
  12092. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  12093. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  12094. if(!mainCall) return texte;
  12095. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  12096. }
  12097. else if(sort.indexOf('Telekinesie')!=-1) {
  12098. texte = 'Portée horizontale :';
  12099. var vt = Math.floor(vuetotale/2)+2;
  12100. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  12101. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  12102. for(var i=0 ; i<5 ; i++) {
  12103. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  12104. if(vt>1) texte += 's';
  12105. vt=Math.max(0,vt-1);
  12106. }
  12107. }
  12108. else if(sort.indexOf('Teleportation')!=-1) {
  12109. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  12110. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  12111. var pmh = (20+vue+portee);
  12112. var pmv = 3+Math.floor(portee/3);
  12113. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  12114. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  12115. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  12116. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  12117. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  12118. }
  12119. else if(sort.indexOf('Vampirisme')!=-1) {
  12120. var modD = 0;
  12121. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  12122. if(pcA!=0) {
  12123. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  12124. texte += '<i>'+aff(modD)+'D6</i> ';
  12125. }
  12126. texte += aff(attbm)
  12127. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  12128. +'Dégâts : <b>'+deg+'</b> D3 ';
  12129. if(pcD!=0) {
  12130. modD = parseInt(deg*pcD/100);
  12131. texte += '<i>'+aff(modD)+'D3</i> ';
  12132. }else
  12133. modD = 0;
  12134. texte += aff(degbm)
  12135. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  12136. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  12137. }
  12138. else if(sort.indexOf('Vision Accrue')!=-1)
  12139. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  12140. else if(sort.indexOf('Vision lointaine')!=-1)
  12141. texte = 'En ciblant une zone située n\'importe où dans le '
  12142. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  12143. else if(sort.indexOf('Voir le Cache')!=-1)
  12144. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  12145. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  12146. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  12147. +getPortee__Profil(vuetotale)+'</b> cases';
  12148. else if(sort.indexOf('Vue Troublee')!=-1)
  12149. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  12150. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  12151. return texte;
  12152. }
  12153.  
  12154.  
  12155. /*---------------------------------- Main ------------------------------------*/
  12156.  
  12157. function do_profil2()
  12158. {
  12159. try {
  12160. start_script(31);
  12161.  
  12162. extractionDonnees();
  12163. setInfosCaracteristiques();
  12164. setInfoDescription();
  12165. setInfosEtatLieux();
  12166. setInfosEtatPV();
  12167. setInfosExp();
  12168.  
  12169. creerBulleVide();
  12170. traitementTalents();
  12171. setLienAnatrolliseur();
  12172.  
  12173. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  12174. if(race=='Kastar'){ setAccel(); }
  12175. saveProfil();
  12176. displayScriptTime();
  12177. } catch(e) {
  12178. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  12179. window.console.error(traceStack(e, 'profil2'));
  12180. }
  12181. }
  12182.  
  12183. /*******************************************************************************
  12184. * This file is part of Mountyzilla. *
  12185. * *
  12186. * Mountyzilla is free software; you can redistribute it and/or modify *
  12187. * it under the terms of the GNU General Public License as published by *
  12188. * the Free Software Foundation; either version 2 of the License, or *
  12189. * (at your option) any later version. *
  12190. * *
  12191. * Mountyzilla is distributed in the hope that it will be useful, *
  12192. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12193. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12194. * GNU General Public License for more details. *
  12195. * *
  12196. * You should have received a copy of the GNU General Public License *
  12197. * along with Mountyzilla; if not, write to the Free Software *
  12198. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  12199. *******************************************************************************/
  12200.  
  12201. // x~x script_principal
  12202.  
  12203. function isPage(url) {
  12204. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  12205. }
  12206.  
  12207. // x~x md5.js
  12208. /*
  12209. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  12210. * Digest Algorithm, as defined in RFC 1321.
  12211. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  12212. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  12213. * Distributed under the BSD License
  12214. * See http://pajhome.org.uk/crypt/md5 for more info.
  12215. */
  12216.  
  12217. /*
  12218. * Configurable variables. You may need to tweak these to be compatible with
  12219. * the server-side, but the defaults work in most cases.
  12220. */
  12221. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  12222. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  12223. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  12224.  
  12225. /*
  12226. * These are the functions you'll usually want to call
  12227. * They take string arguments and return either hex or base-64 encoded strings
  12228. */
  12229. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  12230. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  12231. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  12232. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  12233. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  12234. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  12235.  
  12236. /*
  12237. * Perform a simple self-test to see if the VM is working
  12238. */
  12239. function md5_vm_test()
  12240. {
  12241. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  12242. }
  12243.  
  12244. /*
  12245. * Calculate the MD5 of an array of little-endian words, and a bit length
  12246. */
  12247. function core_md5(x, len)
  12248. {
  12249. /* append padding */
  12250. x[len >> 5] |= 0x80 << ((len) % 32);
  12251. x[(((len + 64) >>> 9) << 4) + 14] = len;
  12252.  
  12253. var a = 1732584193;
  12254. var b = -271733879;
  12255. var c = -1732584194;
  12256. var d = 271733878;
  12257.  
  12258. for(var i = 0; i < x.length; i += 16)
  12259. {
  12260. var olda = a;
  12261. var oldb = b;
  12262. var oldc = c;
  12263. var oldd = d;
  12264.  
  12265. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  12266. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  12267. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  12268. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  12269. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  12270. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  12271. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  12272. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  12273. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  12274. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  12275. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  12276. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  12277. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  12278. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  12279. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  12280. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  12281.  
  12282. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  12283. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  12284. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  12285. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  12286. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  12287. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  12288. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  12289. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  12290. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  12291. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  12292. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  12293. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  12294. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  12295. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  12296. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  12297. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  12298.  
  12299. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  12300. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  12301. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  12302. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  12303. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  12304. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  12305. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  12306. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  12307. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  12308. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  12309. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  12310. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  12311. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  12312. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  12313. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  12314. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  12315.  
  12316. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  12317. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  12318. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  12319. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  12320. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  12321. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  12322. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  12323. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  12324. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  12325. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  12326. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  12327. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  12328. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  12329. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  12330. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  12331. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  12332.  
  12333. a = safe_add(a, olda);
  12334. b = safe_add(b, oldb);
  12335. c = safe_add(c, oldc);
  12336. d = safe_add(d, oldd);
  12337. }
  12338. return Array(a, b, c, d);
  12339.  
  12340. }
  12341.  
  12342. /*
  12343. * These functions implement the four basic operations the algorithm uses.
  12344. */
  12345. function md5_cmn(q, a, b, x, s, t)
  12346. {
  12347. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  12348. }
  12349. function md5_ff(a, b, c, d, x, s, t)
  12350. {
  12351. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  12352. }
  12353. function md5_gg(a, b, c, d, x, s, t)
  12354. {
  12355. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  12356. }
  12357. function md5_hh(a, b, c, d, x, s, t)
  12358. {
  12359. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  12360. }
  12361. function md5_ii(a, b, c, d, x, s, t)
  12362. {
  12363. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  12364. }
  12365.  
  12366. /*
  12367. * Calculate the HMAC-MD5, of a key and some data
  12368. */
  12369. function core_hmac_md5(key, data)
  12370. {
  12371. var bkey = str2binl(key);
  12372. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  12373.  
  12374. var ipad = Array(16), opad = Array(16);
  12375. for(var i = 0; i < 16; i++)
  12376. {
  12377. ipad[i] = bkey[i] ^ 0x36363636;
  12378. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  12379. }
  12380.  
  12381. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  12382. return core_md5(opad.concat(hash), 512 + 128);
  12383. }
  12384.  
  12385. /*
  12386. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  12387. * to work around bugs in some JS interpreters.
  12388. */
  12389. function safe_add(x, y)
  12390. {
  12391. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  12392. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  12393. return (msw << 16) | (lsw & 0xFFFF);
  12394. }
  12395.  
  12396. /*
  12397. * Bitwise rotate a 32-bit number to the left.
  12398. */
  12399. function bit_rol(num, cnt)
  12400. {
  12401. return (num << cnt) | (num >>> (32 - cnt));
  12402. }
  12403.  
  12404. /*
  12405. * Convert a string to an array of little-endian words
  12406. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  12407. */
  12408. function str2binl(str)
  12409. {
  12410. var bin = Array();
  12411. var mask = (1 << chrsz) - 1;
  12412. for(var i = 0; i < str.length * chrsz; i += chrsz)
  12413. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  12414. return bin;
  12415. }
  12416.  
  12417. /*
  12418. * Convert an array of little-endian words to a string
  12419. */
  12420. function binl2str(bin)
  12421. {
  12422. var str = "";
  12423. var mask = (1 << chrsz) - 1;
  12424. for(var i = 0; i < bin.length * 32; i += chrsz)
  12425. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  12426. return str;
  12427. }
  12428.  
  12429. /*
  12430. * Convert an array of little-endian words to a hex string.
  12431. */
  12432. function binl2hex(binarray)
  12433. {
  12434. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  12435. var str = "";
  12436. for(var i = 0; i < binarray.length * 4; i++)
  12437. {
  12438. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  12439. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  12440. }
  12441. return str;
  12442. }
  12443.  
  12444. /*
  12445. * Convert an array of little-endian words to a base-64 string
  12446. */
  12447. function binl2b64(binarray)
  12448. {
  12449. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  12450. var str = "";
  12451. for(var i = 0; i < binarray.length * 4; i += 3)
  12452. {
  12453. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  12454. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  12455. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  12456. for(var j = 0; j < 4; j++)
  12457. {
  12458. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  12459. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  12460. }
  12461. }
  12462. return str;
  12463. }
  12464.  
  12465. ///////////////////////////////////////////
  12466. // debug cartes capitan Roule 07/12/2016
  12467. ///////////////////////////////////
  12468. // essais : objet
  12469. // .mode : description
  12470. // .essais : tableau d'objets essai
  12471. // .mode : description
  12472. // .essais : tableau de cartes
  12473. // .noCarte : id de la carte
  12474. // .essais : tableau d'essais, [x, y, n, nb]
  12475. function AfficheEssais(essais, sMode) {
  12476. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  12477. if (!eBigDiv) {
  12478. var insertPoint = document.getElementById('footer1');
  12479. eBigDiv = document.createElement('table');
  12480. eBigDiv.id = 'ListeEssaiCapitan';
  12481. insertBefore(insertPoint, document.createElement('p'));
  12482. insertTitle(insertPoint,'Capitan : Liste des essais');
  12483. insertBefore(insertPoint, eBigDiv);
  12484. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  12485. }
  12486. if (!essais) {
  12487. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  12488. return;
  12489. }
  12490. var carte;
  12491. for (carte in essais) {
  12492. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  12493. }
  12494. if (carte === undefined) {
  12495. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  12496. }
  12497. }
  12498.  
  12499. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  12500. var tr = appendTr(eTable);
  12501. var td = appendTd(tr);
  12502. appendText(td, sMode, bBold);
  12503. td = appendTd(tr);
  12504. appendText(td, sCarte, bBold);
  12505. td = appendTd(tr);
  12506. appendText(td, sText, bBold);
  12507. }
  12508.  
  12509. function getEssaiV1_0() {
  12510. try {
  12511. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  12512. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  12513. var tabK, nK;
  12514. prefs.getChildList('', nK, tabK);
  12515. window.console.log('getEssaiV1_0, nb key : ' + nK);
  12516. //window.console.log('getEssaiV1_0, ' + nK);
  12517. return;
  12518. //return r;
  12519. } catch (e) {
  12520. window.console.log(traceStack(e, 'getEssaiV1_0'));
  12521. }
  12522. }
  12523.  
  12524. function getEssaiV1_1() {
  12525. var locSto = window.localStorage;
  12526. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  12527. var r = [];
  12528. for (var i = 0; i < locSto.length; i++) {
  12529. var k = locSto.key(i);
  12530. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  12531. var t = k.split(/\./);
  12532. if (t[0] !== 'capitan') continue;
  12533. if (t[2] !== 'essai') continue;
  12534. var carte = 'carte n°' + t[1];
  12535. if (r[carte]) r[carte]++;
  12536. else r[carte] = 1;
  12537. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  12538. }
  12539. return r;
  12540. }
  12541.  
  12542. function showEssaiCartes() {
  12543. window.console.log('début showEssai Tout_MZ');
  12544. var essais = getEssaiV1_0();
  12545. AfficheEssais(essais, 'V1.0');
  12546. essais = getEssaiV1_1();
  12547. AfficheEssais(essais, 'V1.1');
  12548. window.console.log('fin showEssai Tout_MZ');
  12549. }
  12550.  
  12551. function testBoolLocalStorage() {
  12552. var b = true;
  12553. var key = 'MZ_essai_bool';
  12554. GM_setValue(key, b);
  12555. window.localStorage[key] = b;
  12556. var v = GM_getValue(key);
  12557. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  12558. var v = window.localStorage.getItem(key);
  12559. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  12560.  
  12561. var b = false;
  12562. GM_setValue(key, b);
  12563. window.localStorage[key] = b;
  12564. var v = GM_getValue(key);
  12565. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  12566. var v = window.localStorage.getItem(key);
  12567. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  12568.  
  12569. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  12570. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  12571. var y = GM_getValue('654654897894654654');
  12572. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  12573. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  12574. }
  12575.  
  12576. /*--------------------------------- Création liste trolligion ---------------------------------*/
  12577. function export_trolligion() {
  12578. try {
  12579. var tabDl = document.getElementsByTagName('dl');
  12580. if ((!tabDl) || !tabDl[0]) {
  12581. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  12582. return;
  12583. }
  12584. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  12585. // nom : string
  12586. // rayonnement : entier
  12587. // grades : table d'objets (une occurence par grade)
  12588. // nom : string
  12589. // trolls : table d'objets (un par Trõll)
  12590. // id
  12591. // nom
  12592. // idguilde
  12593. // guilde
  12594. // race
  12595. // niveau
  12596. // ferveur
  12597. var currentDieu;
  12598. var currentGrade;
  12599. for (var iChild1 in tabDl[0].children) {
  12600. var eChild1 = tabDl[0].children[iChild1];
  12601. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  12602. case 'dd': // Trõll
  12603. var oTroll = {};
  12604. export_trolligion_analyse(oTroll, eChild1);
  12605. currentGrade.trolls.push(oTroll);
  12606. break;
  12607. case 'dt':
  12608. var tabH3 = eChild1.getElementsByTagName('h3');
  12609. if (tabH3 && tabH3[0]) { // changement de dieu
  12610. currentDieu = {
  12611. nom: tabH3[0].innerText || tabH3[0].textContent
  12612. , grades: []};
  12613. var txt = eChild1.innerText || eChild1.textContent;
  12614. var m = txt.match(/yon*ement *:* *(\d+)/);
  12615. if (m) currentDieu.rayonnement = parseInt(m[1]);
  12616. currentGrade = undefined;
  12617. tabDieux.push(currentDieu);
  12618. break;
  12619. }
  12620. var tabH4 = eChild1.getElementsByTagName('h4');
  12621. if (tabH4 && tabH4[0]) { // changement de grade
  12622. var grade;
  12623. var txt = tabH4[0].innerText || tabH4[0].textContent;
  12624. tabI = tabH4[0].getElementsByTagName('i');
  12625. if (tabI && tabI[0]) {
  12626. grade = tabI[0].innerText || tabI[0].textContent;
  12627. grade = grade.replace(/"/g, '');
  12628. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  12629. if (m) grade += ' (' + m[1] + ')';
  12630. } else {
  12631. grade = txt.replace(/"/g, '');
  12632. }
  12633. currentGrade = {nom: grade, trolls: []};
  12634. currentDieu.grades.push(currentGrade);
  12635. break;
  12636. }
  12637. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  12638. break;
  12639. default:
  12640. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  12641. }
  12642. }
  12643.  
  12644. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  12645. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  12646. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  12647. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  12648. for (var iDieu in tabDieux) {
  12649. var oDieu = tabDieux[iDieu];
  12650. for (var iGrade in oDieu.grades) {
  12651. var oGrade = oDieu.grades[iGrade];
  12652. for (var iTroll in oGrade.trolls) {
  12653. var oTroll = oGrade.trolls[iTroll];
  12654. var t = [oDieu.nom, oDieu.rayonnement
  12655. , oGrade.nom
  12656. , oTroll.id, oTroll.nom
  12657. , oTroll.idguilde, oTroll.guilde
  12658. , oTroll.race, oTroll.niveau
  12659. , oTroll.ferveur];
  12660. for (var iParam in t) {
  12661. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12662. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12663. }
  12664. txt += t.join("\t") + "\n";
  12665. }
  12666. }
  12667. var t = [oDieu.nom, oDieu.rayonnement];
  12668. for (var iParam in t) {
  12669. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12670. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12671. }
  12672. txt2 += t.join("\t") + "\n";
  12673. }
  12674. txt += "\n" + txt2;
  12675. } catch (e) {
  12676. window.alert("Échec à l'extraction\n" + e);
  12677. }
  12678. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  12679. try {
  12680. if (copyTextToClipboard(txt)) {
  12681. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  12682. + "Collez dans Calc\n"
  12683. + "ou, au pire, dans EXCEL®");
  12684. } else {
  12685. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  12686. }
  12687. } catch(e) {
  12688. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  12689. }
  12690. }
  12691.  
  12692. function export_trolligion_analyse(oTroll, eChild1) {
  12693. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  12694. var eChild2 = eChild1.childNodes[iChild2];
  12695. if (eChild2.nodeType === undefined) continue; // properties
  12696. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  12697. switch (eChild2.nodeType) {
  12698. case 1: //ELEMENT_NODE:
  12699. switch (eChild2.nodeName.toLowerCase()) {
  12700. case 'a':
  12701. var m;
  12702. if (!eChild2.href) {
  12703. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  12704. break;
  12705. }
  12706. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  12707. if (m) {
  12708. oTroll.id = parseInt(m[1]);
  12709. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  12710. break;
  12711. }
  12712. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  12713. if (m) {
  12714. var idGuilde = parseInt(m[1]);
  12715. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  12716. oTroll.idguilde = parseInt(m[1]);
  12717. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  12718. }
  12719. break;
  12720. }
  12721. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  12722. break;
  12723. case 'br': // ignore
  12724. case 'style': // ignore
  12725. case 'img': // ignore
  12726. break;
  12727. case 'div': // barre de vie
  12728. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  12729. eChild3 = eChild2.children[0];
  12730. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  12731. var eChild4 = eChild3.children[0];
  12732. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  12733. break;
  12734. }
  12735. }
  12736. //window.console.log(eChild2.innerHTML);
  12737. export_trolligion_analyse(oTroll, eChild2);
  12738. break;
  12739. default:
  12740. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  12741. break;
  12742. }
  12743. break;
  12744. case 3: //TEXT_NODE:
  12745. var txt = eChild2.nodeValue.trim();
  12746. if (txt === '') break;
  12747. var m = txt.match(/(.*) *\((\d+)\)/);
  12748. if (m) {
  12749. oTroll.race = m[1].trim();
  12750. oTroll.niveau = parseInt(m[2]);
  12751. } else {
  12752. oTroll.race = txt;
  12753. }
  12754. break;
  12755. default: // ne devrait pas arriver
  12756. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  12757. break;
  12758. }
  12759. }
  12760. }
  12761.  
  12762. function do_trolligion() {
  12763. var divpopup = document.createElement('div');
  12764. divpopup.id = 'MZ_divCopier';
  12765. divpopup.style.position = 'fixed';
  12766. divpopup.style.top = '2px';
  12767. divpopup.style.left = '2px;';
  12768. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  12769. divpopup.style.cursor = 'pointer';
  12770. divpopup.style.zIndex = 200;
  12771. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  12772. divpopup.onclick = export_trolligion;
  12773. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  12774. divpopup.appendChild(img);
  12775. document.body.appendChild(divpopup);
  12776. }
  12777.  
  12778. /*--------------------------------- Dispatch ---------------------------------*/
  12779.  
  12780. //chargerScriptDev("libs");
  12781. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  12782. //if (isDEV) testBoolLocalStorage();
  12783.  
  12784. // Détection de la page à traiter
  12785. if(isPage("Messagerie/ViewMessageBot")) {
  12786. do_cdmbot();
  12787. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  12788. do_cdmcomp();
  12789. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  12790. do_cdmcomp();
  12791. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  12792. do_cdmcomp();
  12793. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  12794. do_diplo();
  12795. } else if(isPage("MH_Play/Play_equipement")) {
  12796. do_equip();
  12797. } else if(isPage("MH_Play/Play_menu")) {
  12798. do_menu();
  12799. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  12800. do_option();
  12801. //showEssaiCartes();
  12802. } else if(isPage("View/PJView")) {
  12803. do_pjview();
  12804. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  12805. do_profil();
  12806. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  12807. do_tancompo();
  12808. } else if(isPage("MH_Play/Play_vue")) {
  12809. do_vue();
  12810. } else if(isPage("MH_Play/Play_news")) {
  12811. do_news();
  12812. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  12813. do_move();
  12814. } else if(isPage("MH_Missions/Mission_Etape")) {
  12815. do_mission();
  12816. } else if(isPage("View/MonsterView")) {
  12817. do_infomonstre();
  12818. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  12819. do_attaque();
  12820. } else if(isPage("MH_Play/Play_e_follo.php")) {
  12821. do_listegowap();
  12822. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  12823. do_lieuDescription();
  12824. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  12825. do_lieuTeleport();
  12826. } else if(isPage("MH_Follower/FO_Ordres")) {
  12827. do_ordresgowap();
  12828. } else if(isPage("MH_Follower/FO_Equipement")) {
  12829. do_equipgowap();
  12830. } else if(isPage("MH_Play/Play_mouche")) {
  12831. do_mouches();
  12832. } else if(isPage("MH_Play/Play_BM")) {
  12833. do_malus();
  12834. } else if(isPage("MH_Play/Play_evenement")) {
  12835. do_myevent();
  12836. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  12837. do_enchant();
  12838. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  12839. do_pre_enchant();
  12840. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  12841. do_actions();
  12842. } 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')) {
  12843. do_mission_liste();
  12844. } else if(isPage('MH_Play/Play_action')) {
  12845. do_actions();
  12846. } else if(isPage('MH_Play/Play_profil2')) {
  12847. do_profil2();
  12848. } else if(isPage('View/TrolligionView.php')) {
  12849. do_trolligion();
  12850. }
  12851. } catch(e) {
  12852. try {
  12853. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  12854. } catch(e2) {
  12855. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  12856. }
  12857. }