Tout_MZ

Client MountyZilla

当前为 2018-12-23 提交的版本,查看 最新版本

  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.12
  11. // @grant GM_getValue
  12. // @grant GM_deleteValue
  13. // @grant GM_setValue
  14. // ==/UserScript==
  15.  
  16. // vérif UTF-8 ş
  17.  
  18. /*******************************************************************************
  19. * This file is part of Mountyzilla. *
  20. * *
  21. * Mountyzilla is free software; you can redistribute it and/or modify *
  22. * it under the terms of the GNU General Public License as published by *
  23. * the Free Software Foundation; either version 2 of the License, or *
  24. * (at your option) any later version. *
  25. * *
  26. * Mountyzilla is distributed in the hope that it will be useful, *
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  29. * GNU General Public License for more details. *
  30. * *
  31. * You should have received a copy of the GNU General Public License *
  32. * along with Mountyzilla; if not, write to the Free Software *
  33. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  34. *******************************************************************************/
  35.  
  36. try {
  37. const MZ_changeLog = [
  38. "V1.2.18.12 23/12/2018",
  39. " Message si \"Menu d'actions contextuelles\" est décoché",
  40. "V1.2.18.11 21/11/2018",
  41. " Correction it bricol'troll, login avec accent",
  42. "V1.2.18.10 08/08/2018",
  43. " Correction boulette sDiplo",
  44. "V1.2.18.09 04/08/2018",
  45. " Protection contre diplomatie mal initialisée",
  46. "V1.2.18.08 11/07/2018",
  47. " Correction pour fonctionnement hors GM",
  48. "V1.2.18.07 18/05/2018",
  49. " prise en compte bonus magique d'esquive dans le profil, correction gestion de la souris dans la page d'équipement [Dabihul, welcome back]",
  50. "V1.2.18.06 28/01/2018",
  51. " Protection malus Crasc sans durée",
  52. "V1.2.18.05 18/11/2017",
  53. " Désactivation MZ V2 en mode dev pour les tests d'adaptation violentmonkey",
  54. "V1.2.18.04 04/09/2017",
  55. " retour version 1.2.18.02 avec GM 3.17",
  56. "V1.2.18.03 01/09/2017",
  57. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  58. "V1.2.18.02 26/08/2017",
  59. " correction boulette sur le compos d'enchantement",
  60. "V1.2.18.01 25/08/2017",
  61. " Suppression des messages sur les certificats en https",
  62. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  63. "V1.2.17.19 23/08/2017",
  64. " Possibilité de plusieurs IT Bricol'Troll",
  65. "V1.2.17.18 22/08/2017",
  66. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  67. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  68. "V1.2.17.17 16/07/2017",
  69. " modification du mécanisme de filtrage pour contourner un pb",
  70. "V1.2.17.16 16/07/2017",
  71. " Ajout de messages de debug sur les retours AJAX",
  72. "V1.2.17.15 15/07/2017",
  73. " modification du mécanisme de filtrage pour contourner un pb",
  74. "V1.2.17.14 14/07/2017",
  75. " correction dans la gestion des étapes de mission",
  76. "V1.2.17.13 12/07/2017",
  77. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  78. "V1.2.17.12 16/06/2017",
  79. " Correction mauvais compte de PX quand on change de Trõll",
  80. "V1.2.17.11 01/05/2017",
  81. " Travail sur le fonctionnement hors Greasemonkey",
  82. "V1.2.17.10 30/04/2017",
  83. " Protection dans la récupération d'erreur",
  84. "V1.2.17.9 30/04/2017",
  85. " Correction récupération d'erreur IT Bricol'Troll",
  86. "V1.2.17.8 29/04/2017",
  87. " Correction Bonus/Malus cas +0\+10 (AE)",
  88. " Correction portée IdC",
  89. " Prise en compte du bonus de portée PM dans le calcul tactique",
  90. "V1.2.17.7 26/04/2017",
  91. " Version compatible hors GreaseMonkey",
  92. "V1.2.17.6 23/04/2017",
  93. " Correction gestion des missions en cas de réinstallation",
  94. "V1.2.17.5 20/04/2017",
  95. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  96. "V1.2.17.4 08/04/2017",
  97. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  98. " Adaptation de la diplomatie à une modification de la page MH",
  99. "V1.2.17.3 04/04/2017",
  100. " Messages console en cas de cadre d'erreur",
  101. " Trolls de l'IT mais pas dans le vue en orange",
  102. "V1.2.17.2 20/03/2017",
  103. " Correction des PV restants",
  104. "V1.2.17.1 20/03/2017",
  105. " Blocage des PV restants en attendant résolution de bug",
  106. "V1.2.17 19/03/2017",
  107. " Refonte de l'envoi des CdM",
  108. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  109. "V1.2.16.4 08/03/2017",
  110. " correction ID de troll en envoi de PX/MP",
  111. "V1.2.16.3 27/02/2017",
  112. " correction bonus/malus FP",
  113. "V1.2.16.2 24/02/2017",
  114. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  115. "V1.2.16.1 21/02/2017",
  116. " corrige bug sur Fx 38.8 ESR",
  117. "V1.2.16 21/02/2017",
  118. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  119. " possibilité de masquer les Gowaps Sauvages dans la vue",
  120. " calcul des caractéristiques du siphon des âmes",
  121. "V1.2.15.2 02/02/2017",
  122. " adaptation décumul VlC (page des bonus/malus)",
  123. "V1.2.15.1 29/01/2017",
  124. " carte sur la page de description du lieu TP",
  125. "V1.2.15 25/01/2017",
  126. " mise en place des nouvelles cartes (suivants, TP)",
  127. "V1.2.14.3 25/01/2017",
  128. " résumé dans l'export des données Trõlligion",
  129. "V1.2.14.2 20/01/2017",
  130. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  131. "V1.2.14.1 20/01/2017",
  132. " réécriture filtrage des monstres par niveau dans la vue",
  133. " Changelog dans la page des news MZ",
  134. "V1.2.14 20/01/2017",
  135. " Ajout de l'export des données Trõlligion",
  136. "V1.2.13.7 10/01/2017",
  137. " Exclusion Bricoll'troll dans l'entête GM",
  138. "V1.2.13.6 08/01/2017",
  139. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  140. "V1.2.13.5 07/01/2017",
  141. " Correction bug qui se manisfestait sous LINUX",
  142. "V1.2.13.4 07/01/2017",
  143. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  144. "V1.2.13.3 07/01/2017",
  145. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  146. "V1.2.13.2 07/01/2017",
  147. " Correction missions, recherche troogle (familles et types de monstres)",
  148. "V1.2.13.1 06/01/2017",
  149. " Suppression oldSchoolProfile qui n'existe plus",
  150. " Ajout du 'refresh' du cadre de gauche",
  151. "V1.2.13 01/01/2017",
  152. " homogénéisation des messages d'erreur",
  153. " Ajout du lien Troogle sur les étapes de mission monstre",
  154. "V1.2.12.2 30/12/2016",
  155. " retour en mode normal (http si jeu en http)",
  156. "V1.2.12.1 27/12/2016",
  157. " Correction mode IP",
  158. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  159. "V1.2.12 24/12/2016",
  160. " Nettoyage des URL",
  161. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  162. " Interface bricoll'Troll en https",
  163. " Remise en marche des cartes des trajets des gowaps",
  164. "V1.2.11.5 à 7 20 & 21/12/2016",
  165. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  166. "V1.2.11.4 19/12/2016",
  167. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  168. "V1.2.11.3 19/12/2016",
  169. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  170. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  171. "V1.2.11.2 18/12/2016",
  172. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  173. "V1.2.11.1 17/12/2016",
  174. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  175. "V1.2.11 13/12/2016",
  176. " Passage sur BdD Raistlin \\o/",
  177. "V1.2.10.4 12/12/2016",
  178. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  179. "V1.2.10.3 09/12/2016",
  180. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  181. "V1.2.10.2 09/12/2016",
  182. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  183. "V1.2.10.1 08/12/2016",
  184. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  185. "V1.2.10 07/12/2016",
  186. " correction décumul des bonus/malus",
  187. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  188. "V1.2.9 16/11/2016",
  189. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  190. "V1.2.8 10/11/2016",
  191. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  192. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  193. "V1.2.7 07/11/2016",
  194. " remise en route de l'interface avec l'IT bricol'Troll",
  195. "V1.2.6 19/10/2016",
  196. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  197. " stockage idguilde et nomguilde",
  198. "V1.2.5 17/10/2016",
  199. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  200. " remise en route de la gestion des options avec intégration md5 dans ce script",
  201. "V1.2.4 14/10/2016",
  202. " utilisation du relai raistlin pour l'envoi des CdM",
  203. "V1.2.3 :",
  204. " suppression ancien profil",
  205. " nettoyage doublon sur getPortee",
  206. " adaptation portee TP basée sur les PI",
  207. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  208. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  209. "V1.2.1 :",
  210. " include des URLs MH alternatives",
  211. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  212. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  213. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  214. "V1.1 : regroupement en un gros paquet sale",
  215. ];
  216.  
  217. /**********************************************************
  218. À faire / propositions d'évolutions
  219.  
  220. Bireli-Gravos 08/12/2018
  221. FAIT faire un warning si l'utilisateur a désactivé la case "Menu d'actions contextuelles" dans la fenêtre "limiter la vue"
  222. breizhou13 20/12/2016
  223. envoyer les données à l'IT (Bricol'Trolls) aussi
  224. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  225. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  226. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  227. Akkila le boeuf le 26-03-2017 à 15:56
  228. - bouton pour rafraîchir les infos des trolls de son groupe
  229. Roule'
  230. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  231. Réactiver les jubilaires
  232. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  233. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  234. - voir l'intérêt de refaire fonctionner
  235. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  236. Prévision des DLA de monstre
  237. Niveau des monstres à la méthode Roule'
  238. Raistlin
  239. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  240. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  241. 80117 - Héra
  242. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  243. 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)
  244. FAIT Possibilité de plusieurs systèmes Bricol'troll
  245. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  246. ?
  247. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  248. Alanae/Gnu
  249. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  250. Kali
  251. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  252. **********************************************************/
  253.  
  254. /**********************************************************
  255. **** Début de zone à déplacer dans une bibli commune ******
  256. **********************************************************/
  257.  
  258. // URL de base serveur MZ
  259. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  260. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  261. //var URL_MZ = 'http://192.99.225.92/mz';
  262.  
  263. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  264. // à supprimer
  265. const newCarte = true;
  266. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  267.  
  268. // URLs externes redirection (pas de souci CORS)
  269. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  270. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  271. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  272. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  273. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  274. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  275. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  276. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  277. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  278.  
  279. // URLs de test HTTPS
  280. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  281. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  282.  
  283. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  284. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  285. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  286.  
  287. // x~x Libs
  288.  
  289. /* ancien TODO
  290. * - revoir la gestion des CdM --> nott armure magique
  291. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  292. * - vérfier la gestion des enchants
  293. */
  294.  
  295. // Roule 04/09/2016 switch extern URLs to https if available
  296. var isHTTPS = false;
  297. if (window.location.protocol.indexOf('https') === 0) {
  298. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  299. URL_bricol = URL_bricol_https;
  300. isHTTPS = true;
  301. }
  302.  
  303. // Roule 23/12/2016 mode dev
  304. var isDEV = false;
  305. if (window.localStorage.getItem('MZ_dev')
  306. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  307. || window.location.href.indexOf('mzdev.mh') >= 0) {
  308. URL_MZ = URL_MZ.replace(/$/, 'dev');
  309. isDEV = true;
  310. }
  311.  
  312. // Images (pas de souci CORS)
  313. var URL_MZimg = URL_MZ + '/img/';
  314. // URLs externes ajax (CORS OK)
  315. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  316. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  317. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  318.  
  319. // liens externes déduits
  320. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  321. var MHicons = '/mountyhall/Images/Icones/';
  322. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  323. var MY_DEBUG = false;
  324.  
  325. var horsGM = false;
  326. try { // à partir du 11/07/2018, (GM_getValue === undefined) provoque une exception
  327. horsGM = (GM_getValue === undefined);
  328. } catch (e2) {
  329. horsGM = true;
  330. //window.console.log('test GM_getValue, exception=' + e2);
  331. }
  332. if (horsGM) { // éviter le blocage si pas sous GM
  333. window.console.log('Fonctionnement hors Greasemonkey');
  334. // Roule 18/11/2017 il ne faut pas de "var" dans les ligne précédente. Ça fonctionnait sous Greasemonkey mais plus sous Violentmonkey
  335. GM_getValue = function(key) {};
  336. GM_setValue = function(key, val) {};
  337. GM_deleteValue = function(key) {};
  338. GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  339. }
  340.  
  341. /* Utilisation de la gestion de l'enregistrement des données de
  342. GreaseMonkey, avec partage entre scripts via le localStorage, par
  343. Vapulabehemot (82169) 07/02/2017 */
  344. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  345. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  346. function MY_getValue(key) {
  347. var v = window.localStorage.getItem(key);
  348. vGM = GM_getValue(key);
  349. if ((vGM == null)
  350. || (v != null && v != vGM)){
  351. GM_setValue(key, v);
  352. } else if (v == null && vGM != null) {
  353. v = vGM;
  354. window.localStorage[key] = vGM;
  355. }
  356. return v;
  357. }
  358. function MY_removeValue(key) {
  359. GM_deleteValue(key);
  360. window.localStorage.removeItem(key);
  361. }
  362. function MY_setValue(key, val) {
  363. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  364. val = 1;
  365. else if (val === false)
  366. val = 0;
  367. try {
  368. GM_setValue(key, val);
  369. } catch(e) {
  370. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  371. }
  372. try {
  373. window.localStorage[key] = val;
  374. } catch(e) {
  375. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  376. }
  377. }
  378.  
  379. /*---------------- mise à jour de variables globales utiles ------------------*/
  380. // utilisé pour accès bdd (un peu partout) :
  381. var numTroll = MY_getValue('NUM_TROLL');
  382. // utilisé dans vue pour PX :
  383. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  384. var nivTroll; // = MY_getValue('NIV_TROLL');
  385. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  386. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  387. // utilisés dans actions et vue (calculs SR) :
  388. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  389. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  390. var currentURL = window.location.href;
  391.  
  392. /*-[functions]------------ Fonctions durée de script -------------------------*/
  393. var date_debut = null;
  394.  
  395. function start_script(nbJours_exp) {
  396. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  397. if(date_debut) return;
  398. date_debut = new Date();
  399. // Créé la variable expdate si demandé
  400. if(nbJours_exp) {
  401. expdate = new Date();
  402. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  403. }
  404. }
  405.  
  406. function displayScriptTime() {
  407. var footerNode = document.getElementById('footer2');
  408. if(!footerNode) return;
  409. try{
  410. var node = document.evaluate(
  411. ".//text()[contains(.,'Page générée en')]/../br",
  412. footerNode,null,9,null).singleNodeValue;
  413. }
  414. catch(e){return;}
  415. insertText(node,
  416. ' - [Script MZ exécuté en '
  417. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  418. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  419. }
  420.  
  421. function traceStack(e, sModule) {
  422. var version = '';
  423. if (GM_info && GM_info.script && GM_info.script.version)
  424. version = ' ' + GM_info.script.version;
  425. sRet = '[MZ' + version + ']'
  426. if (sModule) sRet += ' {' + sModule + '}';
  427. try {
  428. if (e.message) sRet += ' ' + e.message;
  429. } catch (e2) {
  430. sRet += ' <exception acces message>';//+ e2.message;
  431. }
  432. try {
  433. if (e.stack) {
  434. var sStack = e.stack;
  435. // enlever les infos confidentielles
  436. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  437. }
  438. } catch (e2) {
  439. sRet += ' <exception acces stack>'; // + e2.message;
  440. }
  441. return sRet;
  442. }
  443.  
  444. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  445.  
  446. function debugMZ(str){
  447. if(MY_DEBUG){
  448. window.console.debug('[MZ_DEBUG] '+str);
  449. if(typeof str === "object"){
  450. window.console.debug(str);
  451. }
  452. }
  453. }
  454.  
  455. function FF_XMLHttpRequest(MY_XHR_Ob) {
  456. var request = new XMLHttpRequest();
  457. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  458. for(var head in MY_XHR_Ob.headers) {
  459. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  460. }
  461. request.onreadystatechange = function() {
  462. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  463. if(request.readyState!=4) { return; }
  464. if(request.error) {
  465. if(MY_XHR_Ob.onerror) {
  466. MY_XHR_Ob.onerror(request);
  467. }
  468. return;
  469. }
  470. if ((request.status == 0)) {
  471. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  472. if (isDEV) {
  473. var grandCadre = createOrGetGrandCadre();
  474. var sousCadre = document.createElement('div');
  475. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  476. sousCadre.style.width = 'auto';
  477. sousCadre.style.fontSize = 'large';
  478. sousCadre.style.border = 'solid 1px black';
  479. grandCadre.appendChild(sousCadre);
  480. }
  481. //showHttpsErrorContenuMixte();
  482. return;
  483. }
  484. if(MY_XHR_Ob.onload) {
  485. var version;
  486. if (MY_XHR_Ob.trace) {
  487. version = '';
  488. if (GM_info && GM_info.script && GM_info.script.version)
  489. version = ' ' + GM_info.script.version;
  490. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  491. }
  492. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  493. MY_XHR_Ob.onload(request);
  494. if (MY_XHR_Ob.trace)
  495. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  496. }
  497. };
  498. request.send(MY_XHR_Ob.data);
  499. }
  500.  
  501. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  502. function MZ_formatDateMS(d) {
  503. if (d === undefined) d = new Date();
  504. var day = d.getDate();
  505. var month = d.getMonth()+1;
  506. var year = d.getFullYear();
  507. var hours = d.getHours();
  508. var minutes = d.getMinutes();
  509. var seconds = d.getSeconds();
  510. var ms = d.getMilliseconds();
  511. if (day < 10) {day = "0"+day;}
  512. if (month < 10) {month = "0"+month;}
  513. if (hours < 10) {hours = "0"+hours;}
  514. if (hours < 10) {hours = "0"+hours;}
  515. if (minutes < 10) {minutes = "0"+minutes;}
  516. if (seconds < 10) {seconds = "0"+seconds;}
  517. ms = ('000' + ms).substr(-3, 3);
  518. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  519. }
  520.  
  521. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  522.  
  523. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  524. function copyTextToClipboard(text) {
  525. var textArea = document.createElement("textarea");
  526.  
  527. //
  528. // *** This styling is an extra step which is likely not required. ***
  529. //
  530. // Why is it here? To ensure:
  531. // 1. the element is able to have focus and selection.
  532. // 2. if element was to flash render it has minimal visual impact.
  533. // 3. less flakyness with selection and copying which **might** occur if
  534. // the textarea element is not visible.
  535. //
  536. // The likelihood is the element won't even render, not even a flash,
  537. // so some of these are just precautions. However in IE the element
  538. // is visible whilst the popup box asking the user for permission for
  539. // the web page to copy to the clipboard.
  540. //
  541.  
  542. // Place in top-left corner of screen regardless of scroll position.
  543. textArea.style.position = 'fixed';
  544. textArea.style.top = 0;
  545. textArea.style.left = 0;
  546.  
  547. // Ensure it has a small width and height. Setting to 1px / 1em
  548. // doesn't work as this gives a negative w/h on some browsers.
  549. textArea.style.width = '2em';
  550. textArea.style.height = '2em';
  551.  
  552. // We don't need padding, reducing the size if it does flash render.
  553. textArea.style.padding = 0;
  554.  
  555. // Clean up any borders.
  556. textArea.style.border = 'none';
  557. textArea.style.outline = 'none';
  558. textArea.style.boxShadow = 'none';
  559.  
  560. // Avoid flash of white box if rendered for any reason.
  561. textArea.style.background = 'transparent';
  562.  
  563. textArea.value = text;
  564.  
  565. document.body.appendChild(textArea);
  566.  
  567. textArea.select();
  568.  
  569. var successful = document.execCommand('copy');
  570.  
  571. document.body.removeChild(textArea);
  572. return successful;
  573. }
  574.  
  575. function avertissement(txt,duree) {
  576. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  577. if(!duree) duree = 15000;
  578. var div = document.createElement('div');
  579. // On numérote les avertissements pour destruction sélective
  580. var num = document.getElementsByName('avertissement').length;
  581. div.num = num;
  582. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  583. div.setAttribute('name','avertissement');
  584. div.className = 'mh_textbox';
  585. div.style.position = 'fixed';
  586. div.style.top = (10+15*num)+'px';
  587. div.style.left = (10+5*num)+'px';
  588. div.style.border = '5px solid red';
  589. div.style.zIndex = 2+num;
  590. div.style.cursor = 'pointer';
  591. div.style.fontSize = 'large';
  592. div.innerHTML = txt;
  593. div.onclick=function(){ tueAvertissement(this.num) };
  594.  
  595. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  596. var divcroix = document.createElement('div');
  597. divcroix.style.position = 'absolute';
  598. divcroix.style.top = 0;
  599. divcroix.style.right = 0;
  600. divcroix.style.color = 'black';
  601. divcroix.style.fontSize = 'inherit';
  602. divcroix.style.cursor = 'pointer'
  603. divcroix.style.zIndex = 2+num;
  604. divcroix.innerHTML = "X";
  605. div.appendChild(divcroix);
  606.  
  607. document.body.appendChild(div);
  608. // Destruction automatique de l'avertissement après "un certain temps"
  609. window.setTimeout(function(){ tueAvertissement(num) },duree);
  610. }
  611.  
  612. function tueAvertissement(num) {
  613. var divs = document.getElementsByName('avertissement');
  614. if(divs.length==0) { return; }
  615. for(var i=0 ; i<divs.length ; i++) {
  616. if(divs[i].num==num) {
  617. divs[i].parentNode.removeChild(divs[i]);
  618. return;
  619. }
  620. }
  621. }
  622.  
  623.  
  624. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  625.  
  626. function insertBefore(next,el) {
  627. next.parentNode.insertBefore(el,next);
  628. }
  629.  
  630. function appendTr(tbody,clas) {
  631. var tr = document.createElement('tr');
  632. if(clas) tr.className = clas;
  633. tbody.appendChild(tr);
  634. return tr;
  635. }
  636.  
  637. function insertTr(next,clas) {
  638. var tr = document.createElement('tr');
  639. if(clas) tr.className = clas;
  640. insertBefore(next,tr);
  641. return tr;
  642. }
  643.  
  644. function appendTd(tr) {
  645. var td = document.createElement('td');
  646. if(tr) tr.appendChild(td);
  647. return td;
  648. }
  649.  
  650. function insertTd(next) {
  651. var td = document.createElement('td');
  652. insertBefore(next,td);
  653. return td;
  654. }
  655.  
  656. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  657. function insertAfterTd(eTd) {
  658. var newTd = document.createElement('td');
  659. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  660. return newTd;
  661. }
  662.  
  663. function appendTdCenter(tr,colspan) {
  664. var td = appendTd(tr);
  665. td.align = 'center'; // WARNING - Obsolete
  666. if(colspan) td.colSpan = colspan;
  667. return td;
  668. }
  669.  
  670. function insertTdElement(next,el) {
  671. var td = insertTd(next);
  672. if(el) td.appendChild(el);
  673. return td;
  674. }
  675.  
  676. function appendA(paren,href,cssClass,text) {
  677. var a = document.createElement('a');
  678. if (href) a.href = href;
  679. if (cssClass) a.className = cssClass;
  680. if (text) a.appendChild(document.createTextNode(text));
  681. paren.appendChild(a);
  682. }
  683.  
  684. function appendText(paren,text,bold) {
  685. if(bold) {
  686. var b = document.createElement('b');
  687. b.appendChild(document.createTextNode(text));
  688. paren.appendChild(b);
  689. }
  690. else
  691. paren.appendChild(document.createTextNode(text));
  692. }
  693.  
  694. function insertText(next,text,bold) {
  695. if(bold) {
  696. var b = document.createElement('b');
  697. appendText(b,text);
  698. insertBefore(next,b);
  699. }
  700. else
  701. insertBefore(next,document.createTextNode(text));
  702. }
  703.  
  704. function appendTdText(tr,text,bold) {
  705. var td = appendTd(tr);
  706. appendText(td,text,bold);
  707. return td;
  708. }
  709.  
  710. function insertTdText(next,text,bold) {
  711. var td = insertTd(next);
  712. appendText(td,text,bold);
  713. return td;
  714. }
  715.  
  716. function appendBr(paren) {
  717. paren.appendChild(document.createElement('br'));
  718. }
  719.  
  720. function insertBr(next) {
  721. insertBefore(next,document.createElement('br'));
  722. }
  723.  
  724. function appendLI(ul,text) {
  725. // uniquement utilisé dans les options (crédits)
  726. var li = document.createElement('li');
  727. appendText(li,text);
  728. ul.appendChild(li);
  729. return li;
  730. }
  731.  
  732. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  733. var input = document.createElement('input');
  734. input.className = 'TextboxV2';
  735. input.type = type;
  736. input.name = nam;
  737. if (sId === undefined) input.id = nam;
  738. else input.id = sId;
  739. input.size = size;
  740. input.maxLength = maxlength;
  741. if(value) input.value = value;
  742. paren.appendChild(input);
  743. return input;
  744. }
  745.  
  746. function appendCheckBox(paren,nam,checked,onClick) {
  747. var input = document.createElement('input');
  748. input.type = 'checkbox';
  749. input.name = nam;
  750. input.id = nam;
  751. if(checked) input.checked = true;
  752. if(onClick) input.onclick = onClick;
  753. paren.appendChild(input);
  754. return input;
  755. }
  756.  
  757. function appendNobr(paren,id,delgg,text) {
  758. var nobr = document.createElement('nobr');
  759. appendCheckBox(nobr,id,null,delgg);
  760. appendText(nobr,text);
  761. paren.appendChild(nobr);
  762. appendText(paren,' ');
  763. return nobr;
  764. }
  765.  
  766. function appendCheckBoxSpan(paren,id,onClick,text) {
  767. var span = document.createElement('span');
  768. span.style.whiteSpace = 'nowrap';
  769. appendCheckBox(span,id,false,onClick);
  770. var label = document.createElement('label');
  771. appendText(label,text);
  772. label.htmlFor = id;
  773. label.style.marginLeft = '-5px';
  774. span.appendChild(label);
  775. span.style.marginRight = '3px';
  776. paren.appendChild(span);
  777. appendText(paren, ' ');
  778. return span;
  779. }
  780.  
  781. function appendOption(select,value,text) {
  782. var option = document.createElement('option');
  783. option.value = value;
  784. appendText(option,text);
  785. select.appendChild(option);
  786. return option;
  787. }
  788.  
  789. function appendHidden(form,nam,value) {
  790. var input = document.createElement('input');
  791. input.type = 'hidden';
  792. input.name = nam;
  793. input.id = nam;
  794. input.value = value;
  795. form.appendChild(input);
  796. }
  797.  
  798. function appendButton(paren,value,onClick) {
  799. var input = document.createElement('input');
  800. input.type = 'button';
  801. input.className = 'mh_form_submit';
  802. input.value = value;
  803. input.onmouseover = function(){this.style.cursor='pointer';};
  804. if(onClick) input.onclick = onClick;
  805. paren.appendChild(input);
  806. return input;
  807. }
  808.  
  809. function insertButton(next,value,onClick) {
  810. var input = document.createElement('input');
  811. input.type = 'button';
  812. input.className = 'mh_form_submit';
  813. input.value = value;
  814. input.onmouseover = function(){this.style.cursor='pointer';};
  815. input.onclick = onClick;
  816. insertBefore(next,input);
  817. return input;
  818. }
  819.  
  820. function appendSubmit(paren,value,onClick) {
  821. var input = document.createElement('input');
  822. input.type = 'submit';
  823. input.className = 'mh_form_submit';
  824. input.value = value;
  825. input.onmouseover = function(){this.style.cursor='pointer';};
  826. if(onClick) input.onclick = onClick;
  827. paren.appendChild(input);
  828. return input;
  829. }
  830.  
  831. function createImage(url,title,style) {
  832. var img = document.createElement('img');
  833. img.src = url;
  834. img.title = title;
  835. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  836. if (style) img.style = style;
  837. return img;
  838. }
  839.  
  840. function createAltImage(url,alt,title) {
  841. var img = document.createElement('img');
  842. img.src = url;
  843. img.alt = alt;
  844. if (title) img.title = title;
  845. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  846. return img;
  847. }
  848.  
  849. function createImageSpan(url,alt,title,text,bold) {
  850. var span = document.createElement('span');
  851. span.title = title;
  852. var img = document.createElement('img');
  853. img.src = url;
  854. img.alt = alt;
  855. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  856. span.appendChild(img);
  857. appendText(span,text,bold);
  858. return span;
  859. }
  860.  
  861. function createCase(titre,table,width) {
  862. if(!width) width=120;
  863. var tr = appendTr(table,'mh_tdpage');
  864. var td = appendTdText(tr,titre,true);
  865. td.className = 'mh_tdtitre';
  866. td.width = width;
  867. td = appendTdText(tr,'');
  868. td.className = 'mh_tdpage';
  869. return td;
  870. }
  871.  
  872. function getMyID(e) {
  873. var parent = e.parentNode;
  874. for(var i=0 ; i<parent.childNodes.length ; i++) {
  875. if(e==parent.childNodes[i])
  876. return i;
  877. }
  878. return -1;
  879. }
  880.  
  881. function insertAfter(elt,newElt) {
  882. var id = getMyID(elt);
  883. if(id==-1) return;
  884. if(id<elt.parentNode.childNodes.length-1)
  885. insertBefore(elt.nextSibling,newElt);
  886. else
  887. elt.parentNode.appendChild(newElt);
  888. }
  889.  
  890.  
  891. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  892.  
  893. function aff(nb) {
  894. return (nb>=0) ? '+'+nb : nb;
  895. }
  896.  
  897. function getNumber(str) {
  898. var nbr = str.match(/\d+/);
  899. return nbr ? Number(nbr[0]) : Number.NaN;
  900. }
  901.  
  902. function getNumbers(str) {
  903. var nbrs = str.match(/-?\d+/g);
  904. if (!nbrs) return [];
  905. for(var i=0 ; i<nbrs.length ; i++)
  906. nbrs[i] = Number(nbrs[i]);
  907. return nbrs;
  908. }
  909.  
  910. function trim(str) {
  911. return str.replace(/(^\s*)|(\s*$)/g,'');
  912. }
  913.  
  914. String.prototype.trim = function() {
  915. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  916. }
  917.  
  918. function epure(texte) {
  919. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  920. .replace(/[ç]/g,'c')
  921. .replace(/[éêèë]/g,'e')
  922. .replace(/[ïî]/g,'i')
  923. .replace(/[ôöõ]/g,'o')
  924. .replace(/[ùûü]/g,'u');
  925. }
  926.  
  927. String.prototype.epure = function () {
  928. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  929. .replace(/[ç]/g,'c')
  930. .replace(/[éêèë]/g,'e')
  931. .replace(/[ïî]/g,'i')
  932. .replace(/[ôöõ]/g,'o')
  933. .replace(/[ùûü]/g,'u');
  934. }
  935.  
  936. function bbcode(texte) {
  937. return texte.replace(/&/g,'&amp;')
  938. .replace(/"/g,'&quot;')
  939. .replace(/</g,'&lt;')
  940. .replace(/>/g,'&gt;')
  941. .replace(/'/g,'&#146;')
  942. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  943. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  944. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  945. }
  946.  
  947.  
  948. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  949.  
  950. function addZero(i) {
  951. return (i<10) ? '0'+i : i;
  952. }
  953.  
  954. function DateToString(date) {
  955. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  956. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  957. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  958. }
  959.  
  960. function StringToDate(str) {
  961. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  962. }
  963.  
  964. // fonctionne aussi avec datetime
  965. function SQLDateToFrench(str) {
  966. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  967. }
  968.  
  969. // ... et ajoute un "à" du plus bel effet
  970. function SQLDateToFrenchTime(str) {
  971. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  972. }
  973.  
  974. // SQLDate vers objet date Javascript
  975. function SQLDateToObject(str) {
  976. var t = str.split(/[- :]/);
  977. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  978. }
  979.  
  980. var mz_ie = (window.attachEvent)? true:false;
  981. if ("function" !== typeof addEvent) {
  982. if (mz_ie) {
  983. function addEvent(obj, typ, fn, sens) {
  984. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  985. obj["e"+typ+fn]( window.event );
  986. }
  987. obj.attachEvent("on"+typ, obj[typ+fn] );
  988. }
  989. }
  990. else {
  991. function addEvent(obj, typ, fn, sens) {
  992. obj.addEventListener(typ, fn, sens);
  993. }
  994. }
  995. }
  996.  
  997. /**********************
  998. * glissière en mode objet
  999. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  1000. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  1001. *
  1002. * Usage:
  1003. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  1004. * ref : utilisé pour diversifier les IDs HTML
  1005. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  1006. * target : peut être de 3 types
  1007. * - élément HTML : l'élément HTML à zoomer
  1008. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  1009. * - function : callback quand le curseur bouge
  1010. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  1011. * dans le mode dynamique, la callback est appelée sur mouseMove
  1012. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  1013. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  1014. * autres méthodes
  1015. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  1016. **********************/
  1017.  
  1018. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  1019. try {
  1020. var mouseDown = false;
  1021. var div_gliss = document.createElement("div"); // la DIV mère
  1022. div_gliss.id = "MZ_gliss_"+ref;
  1023. var div_label = document.createElement("span"); // le label
  1024. div_label.innerHTML = labelHTML;
  1025. div_gliss.appendChild(div_label);
  1026. div_gliss.className = "choix_zoom";
  1027. var dessin = document.createElement("canvas"); // le dessin lui-même
  1028. dessin.id = "MZ_gliss_dessin_"+ref;
  1029. dessin.style.cursor = "pointer";
  1030. dessin.width = 104;
  1031. dessin.height = 12;
  1032. dessin.style.marginLeft = '2px';
  1033. dessin.style.marginRight = '2px';
  1034. div_gliss.appendChild(dessin);
  1035. var pourcent = document.createElement("span"); // le pourcentage
  1036. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1037. var pourcent_text = document.createTextNode('');
  1038. var previousVal;
  1039. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1040.  
  1041. // alignement vertical
  1042. dessin.style.verticalAlign = 'middle';
  1043. div_label.style.verticalAlign = 'middle';
  1044. pourcent.style.verticalAlign = 'middle';
  1045.  
  1046. pourcent.appendChild(pourcent_text);
  1047. div_gliss.appendChild(pourcent);
  1048.  
  1049. var bulle_pourcent = document.createElement("div"); // la bulle
  1050. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1051. bulle_pourcent.style.display = 'block';
  1052. bulle_pourcent.style.visibility = 'hidden';
  1053. bulle_pourcent.style.position = 'absolute';
  1054. bulle_pourcent.style.zIndex = 3500;
  1055. bulle_pourcent.style.border = '1px solid #a1927f';
  1056. var bulle_pourcent_text = document.createTextNode('');
  1057. bulle_pourcent.appendChild(bulle_pourcent_text);
  1058. document.body.appendChild(bulle_pourcent);
  1059.  
  1060. this.getElt = function() {return div_gliss;};
  1061.  
  1062. ////////////////////////////////////
  1063. // dessine et redessine le curseur
  1064. ////////////////////////////////////
  1065. var dessine_glissiere = function(val) {
  1066. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1067. var ctx = dessin.getContext('2d');
  1068. ctx.clearRect(0, 0,104, 12);
  1069. ctx.fillStyle = "rgb(0,0,0)";
  1070. ctx.fillRect(0,0,2,12);
  1071. ctx.fillRect(102,0,2,12);
  1072. ctx.fillRect(0,5,104,2);
  1073.  
  1074. ctx.fillStyle = "rgb(80,80,80)";
  1075. ctx.fillRect(pos_0_100,0,5,12);
  1076. ctx.fillStyle = "rgb(200,200,200)";
  1077. ctx.fillRect(pos_0_100+1,1,3,10);
  1078. pourcent_text.nodeValue = val+'%';
  1079. previousVal = parseInt(val);
  1080. };
  1081.  
  1082. ////////////////////////////////////
  1083. // action sur mousedown et mousemove
  1084. // stocker la nouvelle valeur
  1085. // redessiner
  1086. // afficher la nouvelle valeur
  1087. // action selon ce qui a été demandé
  1088. ////////////////////////////////////
  1089. var doCallback_glissiere = function (evt) {
  1090. try {
  1091. if (evt.type === 'mousedown') mouseDown = true;
  1092. if (evt.offsetX) {
  1093. var xsouris = evt.offsetX;
  1094. var xpos = evt.clientX;
  1095. var ypos = evt.clientY + document.body.scrollTop;
  1096. }
  1097. else {
  1098. var xsouris = evt.layerX;
  1099. var xpos = evt.pageX;
  1100. var ypos = evt.pageY;
  1101. }
  1102. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1103. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1104. // afficher la nouvelle valeur dans la bulle
  1105. bulle_pourcent_text.nodeValue = val + '%';
  1106. bulle_pourcent.style.top = (ypos+3)+'px';
  1107. bulle_pourcent.style.left = (xpos+16)+'px';
  1108. if (evt.buttons === undefined) {
  1109. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1110. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1111. } else {
  1112. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1113. }
  1114. // stocker la nouvelle valeur
  1115. MY_setValue("MZ_glissiere_" + ref, val);
  1116. // redessiner la glissière avec le curseur où il faut
  1117. dessine_glissiere(val);
  1118. // action selon ce qui a été demandé
  1119. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1120. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1121. if (typeof paramTarget === 'object') {
  1122. var elt = paramTarget;
  1123. } else if (typeof paramTarget === 'string') {
  1124. var elt = document.getElementById(paramTarget);
  1125. } else if (typeof paramTarget === 'function') {
  1126. paramTarget(val);
  1127. return;
  1128. }
  1129. if (elt.setZoom != undefined) elt.setZoom(val);
  1130. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1131. };
  1132.  
  1133. ////////////////////////////////////
  1134. // event mousedown et mousemove : redessiner et callback
  1135. ////////////////////////////////////
  1136. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1137. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1138. ////////////////////////////////////
  1139. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1140. ////////////////////////////////////
  1141. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1142. ////////////////////////////////////
  1143. // event mouseout & mouseover : afficher/cacher la bulle
  1144. ////////////////////////////////////
  1145. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1146. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1147.  
  1148. ////////////////////////////////////
  1149. // dessiner la première fois
  1150. ////////////////////////////////////
  1151. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1152. if (val_init === undefined) val_init = valDef;
  1153. dessine_glissiere(val_init);
  1154. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1155. }
  1156.  
  1157. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1158. // reçoit 2 objets avec des propriétés x et y
  1159. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1160. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1161. var deltaX = locArrivee.x - locDepart.x;
  1162. if (deltaX == 0) return; // pas de point intermédiaire
  1163. var deltaY = locArrivee.y - locDepart.y;
  1164. if (deltaY == 0) return; // pas de point intermédiaire
  1165. var absDeltaX = Math.abs(deltaX);
  1166. var absDeltaY = Math.abs(deltaY);
  1167. if (absDeltaX > absDeltaY) {
  1168. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1169. } else if (absDeltaY > absDeltaX) {
  1170. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1171. } else {
  1172. return; // égalité, pas de point intermédiaire
  1173. }
  1174. }
  1175.  
  1176. /**********************
  1177. * carte en mode objet
  1178. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1179. *
  1180. * Usage:
  1181. * carte = new carte_MZ(ref, tabDepl);
  1182. * ref : utilisé pour diversifier les IDs HTML
  1183. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1184. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1185. * autres méthodes
  1186. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1187. **********************/
  1188.  
  1189. function carte_MZ(ref, tabDepl) {
  1190. try {
  1191. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1192. div1_carte.id = "MZ_carte_"+ref;
  1193. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1194. div1_carte.style.backgroundImage = 'none';
  1195. div1_carte.style.backgroundColor = 'transparent';
  1196. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1197. div2_carte.className = "carte_MZ";
  1198. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1199. var dessin = document.createElement("canvas"); // le dessin lui-même
  1200. dessin.id = "MZ_carte_dessin_"+ref;
  1201. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1202. div1_carte.appendChild(div2_carte);
  1203. div2_carte.appendChild(dessin);
  1204.  
  1205. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1206. , [-66.5, -37.5, 2, 1.5, -69]
  1207. , [-63.5, 8.5, 2, 1.5, -69]
  1208. , [-59.5, -32.5, 2, 1.5, -69]
  1209. , [-52, 57, 0.25, 0.8, -59]
  1210. , [-50.5, -22.5, 2, 1.5, -69]
  1211. , [-35.5, -51.5, 2, 1.5, -69]
  1212. , [-34.5, 14.5, 2, 1.5, -69]
  1213. , [-34.5, 64.5, 2, 1.5, -69]
  1214. , [-11.5, 72.5, 2, 1.5, -69]
  1215. , [5.5, -49.5, 2, 1.5, -69]
  1216. , [5.5, 31.5, 2, 1.5, -69]
  1217. , [10.5, 63.5, 2, 1.5, -69]
  1218. , [12, -15, 0.25, 0.8, -59]
  1219. , [21.5, 35.5, 2, 1.5, -69]
  1220. , [30, -52, 0.25, 0.8, -59]
  1221. , [46.5, 51.5, 2, 1.5, -69]
  1222. , [48, -39, 0.25, 0.8, -59]
  1223. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1224. , [56.5, 23.5, 75, 8.7, -99]
  1225. , [64, 70, 0.25, 0.8, -59]
  1226. , [74.5, 31.5, 2, 1.5, -69]];
  1227.  
  1228. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1229. var couleur_cible = 'rgba(0,0,0,0.5)';
  1230. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1231. var couleur_trou = 'rgb(200,0,0)';
  1232.  
  1233. var coord_x = function(val) {
  1234. return decalh+coeff*(val+100);
  1235. };
  1236. var coord_y = function(val) {
  1237. return decalv+coeff*(100-val);
  1238. };
  1239.  
  1240. var ctx = dessin.getContext('2d');
  1241. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1242. if (coeff) coeff /= 50;
  1243. else coeff = 2;
  1244. var decalv=30, decalh=30;
  1245.  
  1246. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1247. //var res = false
  1248. var x0 = pos0.x;
  1249. var y0 = pos0.x;
  1250. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1251. var px = Math.sign(pos1.x - pos0.x);
  1252. var py = Math.sign(pos1.y - pos0.y);
  1253. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1254. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1255.  
  1256. for(var k in position_trous_MZ) {
  1257. a = parseFloat(px*px+py*py);
  1258. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1259. 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]);
  1260. delta = b*b-a*c
  1261. if(delta >= 0) {
  1262. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1263. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1264. if(t0 <= tmax && t1 >= 0) {
  1265. // 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
  1266. //res = true;
  1267. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1268. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1269. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1270. // Roule : pas utile pour nous
  1271. //res = true;
  1272. //chute.push([x0+l*px, y0+l*py]);
  1273. return true;
  1274. }
  1275. }
  1276. }
  1277. }
  1278. //return res;
  1279. return false;
  1280. };
  1281.  
  1282. var dessine_carte = function () {
  1283. dessin.width = 200*coeff+2*decalh;
  1284. dessin.height = 200*coeff+2*decalv;
  1285.  
  1286. //repere
  1287. ctx.beginPath();
  1288. ctx.moveTo(coord_x(0), coord_y(100));
  1289. ctx.lineTo(coord_x(0), coord_y(-100));
  1290. ctx.moveTo(coord_x(-100), coord_y(0));
  1291. ctx.lineTo(coord_x(100), coord_y(0));
  1292. ctx.stroke();
  1293. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1294.  
  1295. //trous
  1296. ctx.fillStyle = couleur_trou;
  1297. for(var i in position_trous_MZ) {
  1298. ctx.beginPath();
  1299. 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);
  1300. ctx.fill();
  1301. }
  1302. // trajets
  1303. ctx.lineCap = "round";
  1304. ctx.lineJoin = "round";
  1305. for (var iSuivant in tabDepl) {
  1306. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1307. var tabDeplOneSuivant = tabDepl[iSuivant];
  1308. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1309. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1310. // La "cible" au départ
  1311. var typeDepart = tabDeplOneSuivant[0].typ;
  1312. switch (typeDepart) {
  1313. case 'tp':
  1314. ctx.beginPath();
  1315. ctx.lineWidth = 2;
  1316. ctx.strokeStyle = couleur_cible;
  1317. ctx.fillStyle = couleur_cible;
  1318. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1319. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1320. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1321. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1322. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1323. ctx.moveTo(x0 + coeff * 3, y0);
  1324. ctx.lineTo(x0 - coeff * 3, y0);
  1325. ctx.moveTo(x0, y0 + coeff * 3);
  1326. ctx.lineTo(x0, y0 - coeff * 3);
  1327. ctx.stroke();
  1328. break;
  1329. default:
  1330. ctx.beginPath();
  1331. ctx.lineWidth = 1;
  1332. ctx.strokeStyle = couleur_cible;
  1333. ctx.fillStyle = couleur_cible;
  1334. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1335. ctx.moveTo(x0 + coeff * 4, y0);
  1336. ctx.lineTo(x0 - coeff * 4, y0);
  1337. ctx.moveTo(x0, y0 + coeff * 4);
  1338. ctx.lineTo(x0, y0 - coeff * 4);
  1339. ctx.stroke();
  1340. break;
  1341. }
  1342. // les segments
  1343. var nb_pts = tabDeplOneSuivant.length;
  1344. var pointPrecedent = tabDeplOneSuivant[0];
  1345. for (var i=1; i<nb_pts; i++) {
  1346. ctx.beginPath();
  1347. ctx.lineWidth = coeff;
  1348. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1349. ctx.strokeStyle = couleur_depl_normal;
  1350. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1351. if (pointIntermediaire === undefined) {
  1352. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1353. ctx.strokeStyle = couleur_depl_collision_trou;
  1354. else
  1355. ctx.strokeStyle = couleur_depl_normal;
  1356. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1357. } else {
  1358. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1359. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1360. ctx.strokeStyle = couleur_depl_collision_trou;
  1361. else
  1362. ctx.strokeStyle = couleur_depl_normal;
  1363. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1364. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1365. }
  1366. pointPrecedent = tabDeplOneSuivant[i];
  1367. ctx.stroke();
  1368. }
  1369. // Les points à chaque étape
  1370. ctx.fillStyle = couleur_depl_normal;
  1371. for (var i=1; i<nb_pts; i++) {
  1372. ctx.beginPath();
  1373. var x = coord_x(tabDeplOneSuivant[i].x);
  1374. var y = coord_y(tabDeplOneSuivant[i].y);
  1375. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1376. ctx.fill();
  1377. }
  1378. }
  1379. }
  1380.  
  1381. this.setZoom = function (val) {
  1382. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1383. coeff = val / 50;
  1384. dessine_carte();
  1385. }
  1386.  
  1387. // glissiere
  1388. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1389. var eGliss = gliss.getElt();
  1390. eGliss.style.position = 'absolute';
  1391. eGliss.style.top = (coeff * 2) + 'px';
  1392. eGliss.style.left = decalh + 'px';
  1393. dessin.style.position = 'relative';
  1394. div2_carte.style.position = 'relative';
  1395. eGliss.style.zIndex = 9000;
  1396. div2_carte.appendChild(eGliss);
  1397.  
  1398. // affichage au survol de la souris
  1399. var bulle = document.createElement('div');
  1400. bulle.style.visibility = 'hidden';
  1401. bulle.style.position = 'absolute';
  1402. bulle.style.zIndex = 3100;
  1403. bulle.style.border = 'solid 1px #a1927f';
  1404. bulle.className = 'mh_tdpage';
  1405. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1406. var bulleHaut = document.createElement('div');
  1407. bulleHaut.style.display = 'block';
  1408. bulleHaut.style.paddingRight = '3px';
  1409. bulleHaut.className = 'mh_tdtitre';
  1410. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1411. bulle.appendChild(bulleHaut);
  1412. var bulleBas = document.createElement('div');
  1413. bulleBas.style.display = 'block';
  1414. bulleBas.style.whiteSpace = "nowrap";
  1415. bulleBas.style.paddingRight = '3px';
  1416.  
  1417. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1418. bulle.appendChild(bulleBas);
  1419. div2_carte.appendChild(bulle);
  1420. var affichePosition = function(evt) {
  1421. if (evt.offsetX) {
  1422. var xsouris = evt.offsetX;
  1423. var ysouris = evt.offsetY;
  1424. var xpos = evt.clientX;
  1425. var ypos = evt.clientY + document.body.scrollTop;
  1426. }
  1427. else {
  1428. var xsouris = evt.layerX;
  1429. var ysouris = evt.layerY;
  1430. var xpos = evt.pageX;
  1431. var ypos = evt.pageY;
  1432. }
  1433. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1434. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1435. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1436. var tabHTMLbas = [];
  1437. // message pour les trous
  1438. for (var i in position_trous_MZ) {
  1439. var ceTrou = position_trous_MZ[i];
  1440. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1441. if(dist <= 0) {
  1442. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1443. break;
  1444. }
  1445. }
  1446. // messages pour les suivants
  1447. for (var i in tabDepl) {
  1448. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1449. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1450. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1451. }
  1452. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1453. bulle.style.top = (ysouris+8) + 'px';
  1454. bulle.style.left = (xsouris+16) + 'px';
  1455. };
  1456. addEvent(dessin, "mousemove", affichePosition, true);
  1457. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1458. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1459.  
  1460. // dessin initial
  1461. dessine_carte();
  1462.  
  1463. this.getElt = function() {return div1_carte;};
  1464.  
  1465. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1466. }
  1467.  
  1468.  
  1469. /**********************************************************
  1470. **** Fin de zone à déplacer dans une bibli commune ********
  1471. **********************************************************/
  1472.  
  1473. /* DEBUG: NETTOYAGE TAGS */
  1474. if(MY_getValue(numTroll+'.TAGSURL')) {
  1475. MY_removeValue(numTroll+'.TAGSURL');
  1476. }
  1477.  
  1478. // Alerte si mode dev
  1479. if (isDEV) {
  1480. var divpopup = document.createElement('div');
  1481. divpopup.id = 'divDEV';
  1482. divpopup.style =
  1483. 'position: fixed;'+
  1484. 'border: 15px solid red;'+
  1485. 'top: 10px;right: 10px;'+
  1486. 'background-color: white;'+
  1487. 'color: black;'+
  1488. 'font-size: large;'+
  1489. 'padding: 5px'+
  1490. 'z-index: 200;';
  1491. appendText(divpopup, '[MZ] Mode DEV');
  1492. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1493. document.body.appendChild(divpopup);
  1494. }
  1495.  
  1496. /*---------- regroupement des getPortee() ------------------------------------*/
  1497. // issu des script profil et profil2
  1498. function getPortee__Profil(param) {
  1499. param = Math.max(0,Number(param));
  1500. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1501. // ça devrait être floor, +10.25, -2.5
  1502. }
  1503.  
  1504. // issu du script vue
  1505. function getPortee__Vue(param) {
  1506. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1507. }
  1508.  
  1509.  
  1510. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1511.  
  1512. function getPXKill(niv) {
  1513. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1514. return Math.max(0,10+3*niv-2*nivTroll);
  1515. }
  1516.  
  1517. function getPXDeath(niv) {
  1518. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1519. return Math.max(0,10+3*nivTroll-2*niv);
  1520. }
  1521.  
  1522. function analysePX(niv) {
  1523. niv = niv+'';
  1524. var i = niv.indexOf('+');
  1525. if(i!=-1) // si niv = 'XX+' ??
  1526. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1527. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1528. if(i!=-1) {
  1529. var max = getPXKill(niv.slice(i+2));
  1530. if(max==0)
  1531. return ' --> <b>0</b> PX';
  1532. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1533. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1534. }
  1535. i = niv.indexOf('='); // ???
  1536. if(i!=-1) {
  1537. var max = getPXKill(niv.slice(i+1));
  1538. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1539. }
  1540. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1541. }
  1542.  
  1543. function analysePXTroll(niv) {
  1544. var str = analysePX(niv);
  1545. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1546. return str;
  1547. }
  1548.  
  1549.  
  1550. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1551. // Refonte totale du code de Zorya
  1552.  
  1553. // Elements à implémenter en dur dans MZ2.0
  1554. var numQualite = {
  1555. 'Très Mauvaise':1,
  1556. 'Mauvaise':2,
  1557. 'Moyenne':3,
  1558. 'Bonne':4,
  1559. 'Très Bonne':5
  1560. };
  1561.  
  1562. var qualiteNum = [
  1563. '_dummy_',
  1564. 'Très Mauvaise',
  1565. 'Mauvaise',
  1566. 'Moyenne',
  1567. 'Bonne',
  1568. 'Très Bonne'
  1569. ];
  1570.  
  1571. var nival = {
  1572. 'Abishaii Bleu':19,
  1573. 'Abishaii Noir':10,
  1574. 'Abishaii Rouge':23,
  1575. 'Abishaii Vert':15,
  1576. 'Ame-en-peine':8,
  1577. 'Amibe Geante':9,
  1578. 'Anaconda des Catacombes':8,
  1579. 'Ankheg':10,
  1580. 'Anoploure Purpurin':36,
  1581. 'Araignee Geante':2,
  1582. 'Ashashin':35,
  1583. 'Balrog':50,
  1584. 'Banshee':16,
  1585. 'Barghest':36,
  1586. 'Basilisk':11,
  1587. 'Behemoth':34,
  1588. 'Behir':14,
  1589. 'Beholder':50,
  1590. 'Boggart':3,
  1591. 'Bondin':9,
  1592. "Bouj'Dla Placide":37,
  1593. "Bouj'Dla":19,
  1594. 'Bulette':19,
  1595. 'Caillouteux':1,
  1596. 'Capitan':35,
  1597. 'Carnosaure':25,
  1598. 'Champi-Glouton':3,
  1599. 'Chauve-Souris Geante':4,
  1600. 'Cheval a Dents de Sabre':23,
  1601. 'Chevalier du Chaos':20,
  1602. 'Chimere':13,
  1603. 'Chonchon':24,
  1604. 'Coccicruelle':22,
  1605. 'Cockatrice':5,
  1606. 'Crasc Medius':17,
  1607. 'Crasc Maexus':25,
  1608. 'Crasc':10,
  1609. 'Croquemitaine':6,
  1610. 'Cube Gelatineux':32,
  1611. 'Daemonite':27,
  1612. 'Diablotin':5,
  1613. 'Dindon du Chaos':1,
  1614. 'Djinn':29,
  1615. 'Ectoplasme':18,
  1616. 'Effrit':27,
  1617. "Elementaire d'Air":23,
  1618. "Elementaire d'Eau":17,
  1619. 'Elementaire de Feu':21,
  1620. 'Elementaire de Terre':21,
  1621. 'Elementaire du Chaos':26,
  1622. 'Erinyes':7,
  1623. 'Esprit-Follet':16,
  1624. 'Essaim Craterien':30,
  1625. 'Essaim Sanguinaire':25,
  1626. 'Ettin':8,
  1627. 'Familier':1,
  1628. 'Fantome':24,
  1629. 'Feu Follet':20,
  1630. 'Flagelleur Mental':33,
  1631. 'Foudroyeur':38,
  1632. 'Fumeux':22,
  1633. 'Fungus Geant':9,
  1634. 'Fungus Violet':4,
  1635. 'Furgolin':10,
  1636. 'Gargouille':3,
  1637. 'Geant de Pierre':13,
  1638. 'Geant des Gouffres':22,
  1639. "Geck'oo Majestueux":40,
  1640. "Geck'oo":15,
  1641. 'Glouton':20,
  1642. 'Gnoll':5,
  1643. 'Gnu Domestique':1,
  1644. 'Gnu Sauvage':1,
  1645. 'Goblin':4,
  1646. 'Goblours':4,
  1647. "Golem d'Argile":15,
  1648. 'Golem de cuir':1,
  1649. 'Golem de Chair':8,
  1650. 'Golem de Fer':31,
  1651. 'Golem de mithril':1,
  1652. 'Golem de metal':1,
  1653. 'Golem de papier':1,
  1654. 'Golem de Pierre':23,
  1655. 'Gorgone':11,
  1656. 'Goule':4,
  1657. 'Gowap Apprivoise':1,
  1658. 'Gowap Sauvage':1,
  1659. 'Gremlins':3,
  1660. 'Gritche':39,
  1661. 'Grouilleux':4,
  1662. 'Grylle':31,
  1663. 'Harpie':4,
  1664. 'Hellrot':18,
  1665. 'Homme-Lezard':4,
  1666. 'Hurleur':8,
  1667. 'Hydre':50,
  1668. 'Incube':13,
  1669. 'Kobold':2,
  1670. 'Labeilleux':26,
  1671. 'Lezard Geant':5,
  1672. 'Liche':50,
  1673. 'Limace Geante':10,
  1674. 'Loup-Garou':8,
  1675. 'Lutin':4,
  1676. 'Mante Fulcreuse':30,
  1677. 'Manticore':9,
  1678. 'Marilith':33,
  1679. 'Meduse':6,
  1680. 'Megacephale':38,
  1681. 'Mille-Pattes Geant':14,
  1682. 'Mimique':6,
  1683. 'Minotaure':7,
  1684. 'Molosse Satanique':8,
  1685. 'Momie':4,
  1686. 'Monstre Rouilleur':3,
  1687. "Mouch'oo Domestique":14,
  1688. "Mouch'oo Majestueux Sauvage":33,
  1689. "Mouch'oo Sauvage":14,
  1690. 'Na-Haniym-Heee':0,
  1691. 'Necrochore':37,
  1692. 'Necromant':39,
  1693. 'Necrophage':8,
  1694. 'Naga':10,
  1695. 'Nuee de Vermine':13,
  1696. "Nuage d'Insectes":7,
  1697. 'Ogre':7,
  1698. 'Ombre de Roches':13,
  1699. 'Ombre':2,
  1700. 'Orque':3,
  1701. 'Ours-Garou':18,
  1702. 'Palefroi Infernal':29,
  1703. 'Phoenix':32,
  1704. 'Pititabeille':0,
  1705. 'Plante Carnivore':4,
  1706. 'Pseudo-Dragon':5,
  1707. 'Rat Geant':2,
  1708. 'Rat-Garou':3,
  1709. 'Rocketeux':5,
  1710. 'Sagouin':3,
  1711. 'Scarabee Geant':4,
  1712. 'Scorpion Geant':10,
  1713. 'Shai':28,
  1714. 'Sirene':8,
  1715. 'Slaad':5,
  1716. 'Sorciere':17,
  1717. 'Spectre':14,
  1718. 'Sphinx':30,
  1719. 'Squelette':1,
  1720. 'Strige':2,
  1721. 'Succube':13,
  1722. 'Tertre Errant':20,
  1723. 'Thri-kreen':10,
  1724. 'Tigre-Garou':12,
  1725. 'Titan':26,
  1726. 'Trancheur':35,
  1727. 'Tubercule Tueur':14,
  1728. 'Tutoki':4,
  1729. 'Vampire':29,
  1730. 'Ver Carnivore Geant':12,
  1731. 'Ver Carnivore':11,
  1732. 'Veskan Du Chaos':14,
  1733. 'Vouivre':33,
  1734. 'Worg':5,
  1735. 'Xorn':14,
  1736. 'Yeti':8,
  1737. 'Yuan-ti':15,
  1738. 'Zombie':2
  1739. }
  1740.  
  1741. var tabEM = {
  1742. //Monstre: [Compo exact, Sort, Position, Localisation]
  1743. // AA
  1744. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1745. // AE
  1746. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1747. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1748. // AdA
  1749. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1750. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1751. // AdE
  1752. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1753. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1754. // AdD
  1755. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1756. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1757. // BAM
  1758. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1759. // BuM
  1760. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1761. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1762. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1763. // Explo
  1764. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1765. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1766. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1767. // FP
  1768. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1769. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1770. // FA
  1771. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1772. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1773. // Glue
  1774. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1775. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1776. // GdS
  1777. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1778. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1779. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1780. // Invi
  1781. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1782. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1783. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1784. // Lévitation
  1785. // ???
  1786. // PréM :
  1787. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1788. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1789. // Proj
  1790. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1791. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1792. // PuM :
  1793. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1794. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1795. // Sacro
  1796. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1797. // Télék
  1798. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1799. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1800. // TP
  1801. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1802. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1803. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1804. // VA
  1805. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1806. // VL
  1807. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1808. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1809. // VlC
  1810. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1811. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1812. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1813. // VT
  1814. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1815. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1816. // Variables
  1817. 'Rat':["d'un"],
  1818. 'Rat Géant':["d'un"],
  1819. 'Dindon':["d'un"],
  1820. 'Goblin':["d'un"],
  1821. 'Limace':["d'une"],
  1822. 'Limace Géante':["d'une"],
  1823. 'Ver':["d'un"],
  1824. 'Ver Carnivore':["d'un"],
  1825. 'Ver Carnivore Géant':["d'un"],
  1826. 'Fungus':["d'un"],
  1827. 'Vouivre':["d'une"],
  1828. 'Gnu':["d'un"],
  1829. 'Scarabée':["d'un"]
  1830. };
  1831.  
  1832. var mundiChampi = {
  1833. 'Préscientus Reguis':'du Phoenix',
  1834. 'Amanite Trolloïde':'de la Mouche',
  1835. 'Girolle Sanglante':'du Dindon',
  1836. 'Horreur Des Prés':'du Gobelin',
  1837. 'Bolet Péteur':'du Démon',
  1838. 'Pied Jaune':'de la Limace',
  1839. 'Agaric Sous-Terrain':'du Rat',
  1840. 'Suinte Cadavre':"de l'Hydre",
  1841. 'Cèpe Lumineux':'du Ver',
  1842. 'Fungus Rampant':'du Fungus',
  1843. 'Nez Noir':'de la Vouivre',
  1844. 'Pleurote Pleureuse':'du Gnu',
  1845. 'Phytomassus Xilénique':'du Scarabée'
  1846. };
  1847.  
  1848. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1849. appendText(node,' ');
  1850. var urlImg = URL_MZimg
  1851. +'Competences/melangeMagique.png';
  1852. var text = ' [-'+(niv+effetQ)+' %]';
  1853. var str = '';
  1854. switch(mob[0]) {
  1855. case 'A':
  1856. case 'E':
  1857. case 'I':
  1858. case 'O':
  1859. case 'U':
  1860. str = "Compo d'";
  1861. break;
  1862. default:
  1863. str = 'Compo de ';
  1864. }
  1865. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1866. var span = createImageSpan(urlImg,'MM:',title,text);
  1867. node.appendChild(span);
  1868. }
  1869. function addInfoEM(node,mob,compo,qualite,localisation) {
  1870. if(!tabEM[mob]) return;
  1871. var title = 'Composant variable', texte = 'Variable';
  1872. var bold = false;
  1873. if(tabEM[mob].length>1) {
  1874. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1875. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1876. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1877. if(pc<-20) return;
  1878. if(pc>=0) bold = true;
  1879. texte = aff(pc)+'%';
  1880. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1881. }
  1882. var urlImg = URL_MZimg
  1883. +'Competences/ecritureMagique.png';
  1884. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1885. node.appendChild(span);
  1886. }
  1887.  
  1888. function insererInfosEM(tbody) {
  1889. // lancé par equip, equipgowap
  1890. var trCompos = document.evaluate(
  1891. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1892. tbody,null,7,null);
  1893. var strCompos = '';
  1894. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1895. var node = trCompos.snapshotItem(i).childNodes[7];
  1896. var str = node.firstChild.textContent;
  1897. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1898. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1899. // Si non-EM on stoppe le traitement
  1900. if(!tabEM[mob]) continue;
  1901. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1902. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1903. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1904. addInfoEM(node,mob,compo,qualite,localisation);
  1905. }
  1906. }
  1907.  
  1908. function getQualite(qualite) {
  1909. var nb = numQualite[qualite];
  1910. return nb ? nb-1 : -1;
  1911. }
  1912.  
  1913. function getEM(nom) {
  1914. if(nom.indexOf('[')!=-1)
  1915. nom = trim(nom.substring(0,nom.indexOf('[')));
  1916. if(tabEM[nom]) return nom;
  1917. return '';
  1918. }
  1919.  
  1920. // DEBUG ex-fonction composantEM
  1921. function compoMobEM(mob) {
  1922. if(!tabEM[mob]) return '';
  1923. if(tabEM[mob].length==1)
  1924. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1925. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1926. +") pour l'écriture de "+tabEM[mob][1];
  1927. }
  1928.  
  1929. // DEBUG ex-fonction compoEM
  1930. function titreCompoEM(mob,compo,localisation,qualite) {
  1931. if(!tabEM[mob]) return '';
  1932. if(tabEM[mob].length==1) return 'Composant variable';
  1933. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1934. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1935. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1936. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1937. return '';
  1938. }
  1939.  
  1940. // DEBUG - rétrocompatibilité
  1941. function compoEM(mob) {
  1942. // appelé dans libs, vue
  1943. return compoMobEM(mob);
  1944. }
  1945. function composantEM(mob,compo,localisation,qualite) {
  1946. // appelé dans libs, tancompo
  1947. return titreCompoEM(mob,compo,localisation,qualite);
  1948. }
  1949. //
  1950.  
  1951.  
  1952. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1953.  
  1954. arrayTalents = {
  1955. /* Compétences */
  1956. 'Acceleration du Metabolisme':'AM',
  1957. 'Attaque Precise':'AP',
  1958. 'Balayage':'Balayage',
  1959. //'Balluchonnage':'Ballu',
  1960. 'Baroufle':'Baroufle',
  1961. 'Bidouille':'Bidouille',
  1962. 'Botte Secrete':'BS',
  1963. 'Camouflage':'Camou',
  1964. 'Charger':'Charger',
  1965. 'Connaissance des Monstres':'CdM',
  1966. 'Construire un Piege':'Piege',
  1967. 'Piege a Feu':'PiegeFeu',
  1968. 'Piege a Glue':'PiegeGlue',
  1969. 'Contre-Attaquer':'CA',
  1970. 'Coup de Butoir':'CdB',
  1971. 'Course':'Course',
  1972. 'Deplacement Eclair':'DE',
  1973. 'Dressage':'Dressage',
  1974. 'Ecriture Magique':'EM',
  1975. 'Frenesie':'Frenesie',
  1976. 'Golemologie':'Golemo',
  1977. 'Golem de cuir':'GolemCuir',
  1978. 'Golem de metal':'GolemMetal',
  1979. 'Golem de mithril':'GolemMithril',
  1980. 'Golem de papier':'GolemPapier',
  1981. 'Grattage':'Grattage',
  1982. 'Hurlement Effrayant':'HE',
  1983. 'Identification des Champignons':'IdC',
  1984. 'Insultes':'Insultes',
  1985. 'Lancer de Potions':'LdP',
  1986. 'Marquage':'Marquage',
  1987. 'Melange Magique':'Melange',
  1988. 'Miner':'Miner',
  1989. 'Travail de la pierre':'Pierre',
  1990. 'Necromancie':'Necro',
  1991. 'Painthure de Guerre':'PG',
  1992. 'Parer':'Parer',
  1993. 'Pistage':'Pistage',
  1994. 'Planter un Champignon':'PuC',
  1995. 'Regeneration Accrue':'RA',
  1996. 'Reparation':'Reparation',
  1997. 'Retraite':'Retraite',
  1998. 'Rotobaffe':'RB',
  1999. 'Shamaner':'Shamaner',
  2000. "S'interposer":'SInterposer',
  2001. 'Tailler':'Tailler',
  2002. //'Vol':'Vol',
  2003. /* Sortilèges */
  2004. 'Analyse Anatomique':'AA',
  2005. 'Armure Etheree':'AE',
  2006. 'Augmentation de l´Attaque':'AdA',
  2007. 'Augmentation de l´Esquive':'AdE',
  2008. 'Augmentation des Degats':'AdD',
  2009. 'Bulle Anti-Magie':'BAM',
  2010. 'Bulle Magique':'BuM',
  2011. 'Explosion':'Explo',
  2012. 'Faiblesse Passagere':'FP',
  2013. 'Flash Aveuglant':'FA',
  2014. 'Glue':'Glue',
  2015. 'Griffe du Sorcier':'GdS',
  2016. 'Hypnotisme':'Hypno',
  2017. 'Identification des tresors':'IdT',
  2018. 'Invisibilite':'Invi',
  2019. 'Levitation':'Levitation',
  2020. 'Precision Magique':'PreM',
  2021. 'Projectile Magique':'Projo',
  2022. 'Projection':'Proj',
  2023. 'Puissance Magique':'PuM',
  2024. 'Rafale Psychique':'Rafale',
  2025. 'Sacrifice':'Sacro',
  2026. 'Siphon des ames':'Siphon',
  2027. 'Telekinesie':'Telek',
  2028. 'Teleportation':'TP',
  2029. 'Vampirisme':'Vampi',
  2030. 'Vision Accrue':'VA',
  2031. 'Vision lointaine':'VL',
  2032. 'Voir le Cache':'VlC',
  2033. 'Vue Troublee':'VT'
  2034. //'':''
  2035. }
  2036.  
  2037. // DEBUG - Pour rétrocompatibilité
  2038. function getSortComp(nom,niveau) {
  2039. return getTalent(nom,niveau);
  2040. }
  2041. //
  2042.  
  2043. function getTalent(nom,niveau) {
  2044. var nomEnBase = arrayTalents[epure(nom)];
  2045. if(!nomEnBase) return 0;
  2046. if(!niveau) var niveau = '';
  2047. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2048. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  2049. return 0;
  2050. }
  2051.  
  2052. function removeAllTalents() {
  2053. for(var talent in arrayTalents) {
  2054. var nomEnBase = arrayTalents[talent];
  2055. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2056. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2057. continue;
  2058. }
  2059. var niveau = 1;
  2060. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2061. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2062. niveau++;
  2063. }
  2064. }
  2065. }
  2066.  
  2067. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2068. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2069. var att = MY_getValue(numTroll+'.caracs.attaque');
  2070. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2071. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2072. var mm = MY_getValue(numTroll+'.caracs.mm');
  2073. var deg = MY_getValue(numTroll+'.caracs.degats');
  2074. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2075. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2076. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2077. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2078. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2079. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2080. return false;
  2081. return true;
  2082. } catch(e) {
  2083. return false;
  2084. }
  2085. }
  2086.  
  2087.  
  2088. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2089.  
  2090. function getPVsRestants(pv,bless,vue) {
  2091. bless = Number(bless.match(/\d+/)[0]);
  2092. if(bless==0) return null;
  2093. var pvminmax = pv.match(/\d+/g);
  2094. if(bless==95) {
  2095. var pvb = 1;
  2096. var pvh = Math.floor( pvminmax[1]/20 );
  2097. }
  2098. else if(bless==5) {
  2099. var pvb = Math.floor( pvminmax[0]*19/20 );
  2100. var pvh = pvminmax[1];
  2101. }
  2102. else {
  2103. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2104. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2105. }
  2106. return vue ? ' ('+pvb+'-'+pvh+')' :
  2107. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2108. }
  2109.  
  2110. function insertButtonCdm(nextName,onClick,texte) {
  2111. if(texte==null) texte = 'Participer au bestiaire';
  2112. var nextNode = document.getElementsByName(nextName)[0];
  2113.  
  2114. var espace = document.createTextNode('\t');
  2115. insertBefore(nextNode,espace);
  2116.  
  2117. var button = document.createElement('input');
  2118. button.type = 'button';
  2119. button.className = 'mh_form_submit';
  2120. button.value = texte;
  2121. button.onmouseover = function(){this.style.cursor='pointer';};
  2122. if(onClick) button.onclick = onClick;
  2123. insertBefore(espace,button);
  2124. return button;
  2125. }
  2126.  
  2127. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  2128. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  2129. 'Capacité spéciale','Résistance Magique','Autres'];
  2130.  
  2131. /* appelé par
  2132. createCDMTable (dans le popup DcM)
  2133. computeTactique (à coté du nom des monstres dans la vue et dans la page de détail des monstres)
  2134. */
  2135. function createImageTactique(url,id,nom) {
  2136. var img = document.createElement('img');
  2137. img.src = url;
  2138. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  2139. img.id = id;
  2140. img.nom = nom;
  2141. img.onmouseover = showPopupTactique;
  2142. img.onmouseout = hidePopup;
  2143. return img;
  2144. }
  2145.  
  2146. function createCDMTable(id,nom,donneesMonstre) {
  2147. try {
  2148. var urlImg = URL_MZimg;
  2149. var table = document.createElement('table');
  2150. var profilActif = isProfilActif();
  2151. table.className = 'mh_tdborder';
  2152. table.border = 0;
  2153. table.cellSpacing = 1;
  2154. table.cellPadding = 4;
  2155. var thead = document.createElement('thead');
  2156. var tr = appendTr(thead,'mh_tdtitre');
  2157. var td = appendTdText(tr,
  2158. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  2159. true
  2160. );
  2161. td.colSpan = 2;
  2162. table.appendChild(thead);
  2163. var tbody = document.createElement('tbody');
  2164. table.appendChild(tbody);
  2165. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  2166. createCase(listeTitres[i],tbody,80);
  2167. }
  2168. var TypeMonstre = getEM(nom);
  2169. var infosCompo='';
  2170. if(TypeMonstre!='') {
  2171. infosCompo = compoEM(TypeMonstre);
  2172. }
  2173. var nodes = tbody.childNodes;
  2174. nodes[0].childNodes[1].innerHTML =
  2175. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  2176. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  2177. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  2178. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  2179. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  2180. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  2181. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  2182. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  2183. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  2184. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  2185. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  2186. td = createCase(listeTitres[10],tbody);
  2187. td.innerHTML = bbcode(donneesMonstre[10]);
  2188. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2189. td.appendChild(document.createTextNode(" "));
  2190. if(donneesMonstre[16] == "De zone")
  2191. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2192. else if(donneesMonstre[16] == "Automatique")
  2193. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2194. else if(donneesMonstre[16] == "Au toucher")
  2195. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2196. }
  2197. }
  2198. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2199. {
  2200. td = createCase(listeTitres[11],tbody);
  2201. td.innerHTML = bbcode(donneesMonstre[9]);
  2202. // seuil de résistance du monstre
  2203. var lb = td.getElementsByTagName('b');
  2204. if(lb.length == 1) {
  2205. var mrm = lb[0].firstChild.nodeValue * 1;
  2206. var v = (mrm / mmTroll);
  2207. lb[0].firstChild.nodeValue += " ("
  2208. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2209. }
  2210. }
  2211. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2212. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2213. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2214. {
  2215. td = createCase(listeTitres[12],tbody);
  2216. if(donneesMonstre[12]==1)
  2217. {
  2218. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2219. }
  2220. if(donneesMonstre[13]==1)
  2221. {
  2222. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2223. }
  2224. else if(donneesMonstre[13]==0)
  2225. {
  2226. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2227. }
  2228. if(donneesMonstre[14]==1)
  2229. {
  2230. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2231. }
  2232. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2233. {
  2234. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2235. }
  2236. else if(donneesMonstre[14]>6)
  2237. {
  2238. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2239. }
  2240. if(donneesMonstre[15]=="Lente")
  2241. {
  2242. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2243. }
  2244. else if(donneesMonstre[15]=="Normale")
  2245. {
  2246. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2247. }
  2248. else if(donneesMonstre[15]=="Rapide")
  2249. {
  2250. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2251. }
  2252. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2253. {
  2254. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2255. }
  2256. if(infosCompo.length>0)
  2257. {
  2258. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2259. }
  2260. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2261. {
  2262. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2263. }
  2264. }
  2265. // pourcentage de blessure
  2266. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2267. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2268. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2269. if(pvs)
  2270. lb[0].firstChild.nodeValue += pvs;
  2271. }
  2272. return table;
  2273. }
  2274. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2275. }
  2276.  
  2277.  
  2278. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2279.  
  2280. var listeMonstreEnchantement = null,
  2281. listeEquipementEnchantement = null,
  2282. listeInfoEnchantement = null;
  2283.  
  2284. function computeCompoEnchantement()
  2285. {
  2286. listeMonstreEnchantement = new Array();
  2287. listeInfoEnchantement = new Array();
  2288. listeEquipementEnchantement = new Array();
  2289. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2290. for(var i=0;i<liste.length;i++)
  2291. {
  2292. var idEquipement = liste[i]*1;
  2293. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2294. continue;
  2295. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2296. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2297. var texteGlobal='';
  2298. for(var j=0;j<3;j++)
  2299. {
  2300. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2301. var v = MY_getValue(k);
  2302. var infoComposant = MY_getValue().split(';');
  2303. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2304. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2305. continue;
  2306. }
  2307. listeMonstreEnchantement[infoComposant[2]] = 1;
  2308. var array = new Array();
  2309. array[0]=infoComposant[0].replace("Ril","Œil");
  2310. array[1]=infoComposant[1];
  2311. array[2]=infoComposant[2];
  2312. array[3]=getQualite(infoComposant[3]);
  2313. var texte = infoComposant[4].replace("Ril","Œil");
  2314. for(var k=5;k<infoComposant.length;k++)
  2315. {
  2316. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2317. }
  2318. texteGlobal+=texte+'\n';
  2319. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2320. array[4]=texte;
  2321. listeInfoEnchantement.push(array);
  2322. }
  2323. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2324. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2325. }
  2326. }
  2327.  
  2328. function isEnchant(nom) {
  2329. var monstreEnchant = '';
  2330. for(j in listeInfoEnchantement) {
  2331. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2332. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2333. monstreEnchant=monstre;
  2334. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2335. }
  2336. }
  2337. return trim(monstreEnchant);
  2338. }
  2339.  
  2340. function getInfoEnchantementFromMonstre(nom)
  2341. {
  2342. try
  2343. {
  2344. if(!listeMonstreEnchantement)
  2345. {
  2346. computeCompoEnchantement();
  2347. }
  2348. var infosEnchant = '';
  2349. for(j in listeInfoEnchantement) {
  2350. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2351. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2352. if(infosEnchant=='')
  2353. infosEnchant=listeInfoEnchantement[j][4];
  2354. else
  2355. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2356. }
  2357. }
  2358. return trim(infosEnchant);
  2359. }
  2360. catch(e)
  2361. {
  2362. window.alert(e);
  2363. }
  2364. }
  2365.  
  2366. function composantEnchant(Monstre,composant,localisation,qualite) {
  2367. var compo='';
  2368. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2369. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2370. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2371. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2372. listeInfoEnchantement[i][3]<=qualite
  2373. ) {
  2374. return listeInfoEnchantement[i][4];
  2375. }
  2376. }
  2377. return compo;
  2378. }
  2379.  
  2380. function insertEnchantInfos(tbody) {
  2381. try
  2382. {
  2383. if(!listeMonstreEnchantement)
  2384. computeCompoEnchantement();
  2385. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2386. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2387. if(nodes.snapshotLength == 0)
  2388. return false;
  2389. var urlImg = URL_MZimg + 'enchant.png';
  2390. for(var i = 0; i < nodes.snapshotLength; i++) {
  2391. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2392. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2393. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2394. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2395. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2396. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2397. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2398. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2399. if(isEnchant(nomMonstre).length>0)
  2400. {
  2401. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2402. if(infos.length>0)
  2403. {
  2404. if(link.parentNode == link.nextSibling.parentNode)
  2405. {
  2406. var tmp = link.nextSibling;
  2407. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2408. }
  2409. else
  2410. {
  2411. link.parentNode.appendChild(createImage(urlImg,infos));
  2412. }
  2413. }
  2414. }
  2415. }
  2416. }
  2417. catch(e)
  2418. {
  2419. window.alert(e);
  2420. }
  2421. }
  2422.  
  2423. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2424. {
  2425. try
  2426. {
  2427. if(!listeMonstreEnchantement)
  2428. computeCompoEnchantement();
  2429. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2430. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2431. if(nodes.snapshotLength == 0)
  2432. return false;
  2433. var urlImg = URL_MZimg + 'enchant.png';
  2434. for(var i = 0; i < nodes.snapshotLength; i++)
  2435. {
  2436. var link = nodes.snapshotItem(i);
  2437. var idEquipement = link.getAttribute('href');
  2438. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2439. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2440. var nomEquipement = trim(link.firstChild.nodeValue);
  2441. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2442. if(!enchanteur || enchanteur == '')
  2443. continue;
  2444. var infos = listeEquipementEnchantement[idEquipement];
  2445. infos=formateTexte(infos);
  2446. if(infos.length>0)
  2447. {
  2448. if(link.parentNode == link.nextSibling.parentNode)
  2449. {
  2450. var tmp = link.nextSibling;
  2451. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2452. }
  2453. else
  2454. {
  2455. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2456. }
  2457. }
  2458. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2459. }
  2460. }
  2461. catch(e)
  2462. {
  2463. window.alert(e);
  2464. }
  2465. }
  2466.  
  2467. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2468.  
  2469.  
  2470. // Les % de toucher
  2471. var c = new Array();
  2472.  
  2473. // coefficients binomiaux
  2474. function cnp(n,k)
  2475. {
  2476. if(c[n] != null && c[n][k] != null)
  2477. return c[n][k];
  2478. if(c[n] == null)
  2479. c[n] = new Array();
  2480. if(k==0)
  2481. {
  2482. c[n][k] = 1;
  2483. return 1;
  2484. }
  2485. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2486. c[n][k] = result;
  2487. // Roule debug
  2488. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2489. return result;
  2490. }
  2491.  
  2492. // by Dab, à comparer
  2493. function binom(n,p) {
  2494. if(p<0 || p>n) return 0;
  2495. if(c[n])
  2496. if(c[n][p]) return c[n][p];
  2497. else {
  2498. c[n]=[1];
  2499. c[n][n]=1;
  2500. if(p==0 || p==n) return 1;
  2501. }
  2502. if(2*p>n)
  2503. c[n][p]=binom(n,n-p);
  2504. else
  2505. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2506. return c[n][p];
  2507. }
  2508.  
  2509. var coeff = new Array();
  2510.  
  2511. function coef(n,p)
  2512. {
  2513. if(n==0 && p==0)
  2514. return 1;
  2515. if(p>n*3.5)
  2516. p = 7*n-p
  2517. // roule désactive cache
  2518. if(coeff[n] != null && coeff[n][p] !=null)
  2519. return coeff[n][p];
  2520. if(coeff[n] == null)
  2521. coeff[n] = new Array();
  2522. var kmax = Math.floor((p-n)/6);
  2523. var x=0;
  2524. for(var k=0;k<=kmax;k++)
  2525. {
  2526. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2527. }
  2528. coeff[n][p] = x;
  2529. // Roule debug
  2530. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2531. return x;
  2532. }
  2533.  
  2534. function chanceEsquiveParfaite(a,d,ba,bd)
  2535. {
  2536. var win = 0;
  2537. var los = 0;
  2538. if(ba==null)
  2539. ba=0;
  2540. if(bd==null)
  2541. bd=0;
  2542. /* if(6*a+ba<2*(d+bd))
  2543. return 100;
  2544. if(a+ba>2*(6*d+bd))
  2545. return 0;*/
  2546. for(var ds=d;ds<=6*d;ds++)
  2547. {
  2548. var cd = coef(d,ds);
  2549. for(var as=a;as<=6*a;as++)
  2550. {
  2551. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2552. win += cd * coef(a,as);
  2553. else
  2554. los += cd * coef(a,as);
  2555. }
  2556. }
  2557. // roule debug
  2558. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2559. return Math.round(100*win/(win+los));
  2560. }
  2561.  
  2562. function chanceTouche(a,d,ba,bd)
  2563. {
  2564. var win = 0;
  2565. var los = 0;
  2566. if(ba==null)
  2567. ba=0;
  2568. if(bd==null)
  2569. bd=0;
  2570. if(a+ba>6*d+bd)
  2571. return 100;
  2572. if(6*a+ba<d+bd)
  2573. return 0;
  2574. for(var ds=d;ds<=6*d;ds++)
  2575. {
  2576. var cd = coef(d,ds);
  2577. for(var as=a;as<=6*a;as++)
  2578. {
  2579. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2580. win += cd * coef(a,as);
  2581. else
  2582. los += cd * coef(a,as);
  2583. }
  2584. }
  2585. return Math.round(100*win/(win+los));
  2586. }
  2587.  
  2588. function chanceCritique(a,d,ba,bd)
  2589. {
  2590. var win = 0;
  2591. var los = 0;
  2592. if(ba==null)
  2593. ba=0;
  2594. if(bd==null)
  2595. bd=0;
  2596. if(a+ba>2*(6*d+bd))
  2597. return 100;
  2598. if(6*a+ba<2*(d+bd))
  2599. return 0;
  2600. for(var ds=d;ds<=6*d;ds++)
  2601. {
  2602. var cd = coef(d,ds);
  2603. for(var as=a;as<=6*a;as++)
  2604. {
  2605. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2606. win += cd * coef(a,as);
  2607. else
  2608. los += cd * coef(a,as);
  2609. }
  2610. }
  2611. return Math.round(100*win/(win+los));
  2612. }
  2613.  
  2614. /***********************************************
  2615. Analyse tactique
  2616. ***********************************************/
  2617.  
  2618. function getTexteAnalyse(modificateur,chiffre)
  2619. {
  2620. if(chiffre==0)
  2621. return chiffre;
  2622. return modificateur+chiffre;
  2623. }
  2624.  
  2625. // rend le HTML pour le tableau de la "calculette"
  2626. function getAnalyseTactique(id,nom)
  2627. {
  2628. var donneesMonstre = listeCDM[id];
  2629. var needAutres=false;
  2630. var i;
  2631. if(donneesMonstre == null)
  2632. return;
  2633. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2634. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2635. if(array==null)
  2636. return "";
  2637. 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>";
  2638. for(i=0;i<array.length;i++)
  2639. {
  2640. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2641. {
  2642. needAutres=true;
  2643. break;
  2644. }
  2645. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2646. 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>";
  2647. else if(i==0) // attaque du monstre sur le Trõll => italique
  2648. 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>";
  2649. else // autre, pas de décoration
  2650. 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>";
  2651. }
  2652. if(needAutres)
  2653. {
  2654. if(i==array.length-1)
  2655. 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>";
  2656. else if(i==1)
  2657. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2658. else
  2659. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2660. }
  2661. return str+"</table>";
  2662. }
  2663.  
  2664. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2665. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2666. function analyseTactique(donneesMonstre,nom) {
  2667. try
  2668. {
  2669. var listeAttaques = [];
  2670. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2671. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2672. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2673. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2674. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2675. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2676. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2677. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2678. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2679. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2680. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2681. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2682. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2683. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2684. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2685. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2686. var modificateurEsquive = '';
  2687. var modificateurArmure = '';
  2688. var modificateurMagie = '';
  2689. var modificateurEsquiveM = '';
  2690. var modificateurArmureM = '';
  2691. var pasDeSR=false;
  2692. var esqM,attM,armM,degM;
  2693. 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)
  2694. return null;
  2695. var td = document.createElement('td')
  2696. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2697. var esqM = 0;
  2698. try
  2699. {
  2700. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2701. }
  2702. catch(e)
  2703. {
  2704. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  2705. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2706. modificateurEsquive = '<';
  2707. modificateurArmure = '<';
  2708. modificateurMagie = '<';
  2709. }
  2710. td.innerHTML = bbcode(donneesMonstre[3]);
  2711. var attM = 0;
  2712. try
  2713. {
  2714. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2715. }
  2716. catch(e)
  2717. {
  2718. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  2719. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2720. modificateurEsquiveM = '>';
  2721. modificateurArmureM = '>';
  2722. }
  2723. td.innerHTML = bbcode(donneesMonstre[5]);
  2724. var degM = 0;
  2725. try
  2726. {
  2727. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2728. }
  2729. catch(e)
  2730. {
  2731. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  2732. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2733. modificateurArmureM = '>';
  2734. }
  2735. td.innerHTML = bbcode(donneesMonstre[7]);
  2736. var armM = 0;
  2737. try
  2738. {
  2739. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2740. }
  2741. catch(e)
  2742. {
  2743. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  2744. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2745. modificateurArmure = '<';
  2746. }
  2747. var coeffSeuil = 0.95;
  2748. try
  2749. {
  2750. td.innerHTML = bbcode(donneesMonstre[9]);
  2751. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  2752. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2753. var v = (rm / mm);
  2754. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2755. coeffSeuil = (200-seuil)/200;
  2756. }
  2757. catch(e)
  2758. {
  2759. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  2760. modificateurMagie = '<';
  2761. pasDeSR = true;
  2762. }
  2763. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2764. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2765. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2766. // roule debug
  2767. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2768. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2769. 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);
  2770. //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);
  2771. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2772. if(getSortComp("Vampirisme")>0)
  2773. {
  2774. var pour = getSortComp("Vampirisme");
  2775. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2776. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2777. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2778. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2779. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2780. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2781. }
  2782. if(getSortComp("Siphon des âmes")>0)
  2783. {
  2784. var pour = getSortComp("Siphon des âmes");
  2785. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2786. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2787. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2788. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2789. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2790. }
  2791. if(getSortComp("Botte Secrète")>0)
  2792. {
  2793. var pour = getSortComp("Botte Secrète");
  2794. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2795. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2796. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2797. 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;
  2798. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2799. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2800. }
  2801. if(getSortComp("Rafale Psychique")>0)
  2802. {
  2803. var pour = getSortComp("Rafale Psychique");
  2804. chanceDEsquiveParfaite = 0;
  2805. chanceDeTouche = Math.round(100*pour/100);
  2806. chanceDeCritique = Math.round(0*pour/100);
  2807. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2808. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2809. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2810. }
  2811. if(getSortComp("Explosion")>0)
  2812. {
  2813. var pour = getSortComp("Explosion");
  2814. chanceDEsquiveParfaite = 0;
  2815. chanceDeTouche = Math.round(100*pour/100);
  2816. chanceDeCritique = Math.round(0*pour/100);
  2817. 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;
  2818. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2819. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2820. }
  2821. if(getSortComp("Projectile Magique")>0)
  2822. {
  2823. var pour = getSortComp("Projectile Magique");
  2824. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2825. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2826. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2827. // distance troll - monstre
  2828. 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;
  2829. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2830. if (donneesMonstre['iTR'] !== undefined) {
  2831. var dist = getMonstreDistance(donneesMonstre['iTR']+1);
  2832. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  2833. var portee = getPortee__Profil(vue+vue_bm);
  2834. if (dist <= portee) {
  2835. degats += 2 * (portee-dist);
  2836. } else {
  2837. degats += ' (plus bonus de portée)';
  2838. }
  2839. debugMZ('analyseTactique, iTR= ' + donneesMonstre['iTR'] + ', dist=' + dist + ', porteePM=' + portee);
  2840. } else {
  2841. degats += ' (plus bonus de portée)';
  2842. }
  2843. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2844. }
  2845. if(getSortComp("Frénésie")>0)
  2846. {
  2847. var pour = getSortComp("Frénésie");
  2848. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2849. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2850. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2851. 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;
  2852. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2853. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2854. }
  2855. if(getSortComp("Charger")>0)
  2856. {
  2857. var pour = getSortComp("Charger");
  2858. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2859. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2860. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2861. 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;
  2862. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2863. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2864. }
  2865. if(getSortComp("Griffe du Sorcier")>0)
  2866. {
  2867. var pour = getSortComp("Griffe du Sorcier");
  2868. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2869. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2870. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2871. 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;
  2872. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2873. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2874. }
  2875. if(getSortComp("Attaque Précise",1)>0)
  2876. {
  2877. var niveau = 5;
  2878. var oldPour = 0;
  2879. var chanceDEsquiveParfaite = 0;
  2880. var chanceDeTouche = 0;
  2881. var chanceDeCritique = 0;
  2882. degats = 0;
  2883. while(niveau>0)
  2884. {
  2885. var pour = getSortComp("Attaque Précise",niveau);
  2886. if(pour>oldPour)
  2887. {
  2888. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2889. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2890. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2891. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2892. chanceDeTouche += chanceDeToucheNiveau;
  2893. chanceDeCritique += chanceDeCritiqueNiveau;
  2894. 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);
  2895. oldPour = pour;
  2896. }
  2897. niveau--;
  2898. }
  2899. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2900. 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));
  2901. }
  2902. if(getSortComp("Coup de Butoir",1)>0)
  2903. {
  2904. var niveau = 5;
  2905. var oldPour =0;
  2906. var chanceDEsquiveParfaite = 0;
  2907. var chanceDeTouche=0;
  2908. var chanceDeCritique=0;
  2909. degats=0;
  2910. while(niveau>0)
  2911. {
  2912. var pour = getSortComp("Coup de Butoir",niveau);
  2913. if(pour>oldPour)
  2914. {
  2915. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2916. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2917. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2918. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2919. chanceDeTouche += chanceDeToucheNiveau;
  2920. chanceDeCritique += chanceDeCritiqueNiveau;
  2921. 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);
  2922. oldPour = pour;
  2923. }
  2924. niveau--;
  2925. }
  2926. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2927. 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));
  2928. }
  2929. 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;});
  2930. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2931. {
  2932. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2933. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2934. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2935. }
  2936. else
  2937. {
  2938. chanceDEsquiveParfaite = 0;
  2939. chanceDeTouche = 100;
  2940. chanceDeCritique = 0;
  2941. }
  2942. 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;
  2943.  
  2944. 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));
  2945. return listeAttaques;
  2946. }
  2947. catch(e) { window.alert(e);}
  2948. }
  2949.  
  2950. // x~~x marque pour s'y retrouver sous l'éditeur
  2951.  
  2952. /*
  2953. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2954. * published under GNU License v2.
  2955. *
  2956. * Patch :
  2957. * gestion des missions terminées
  2958. */
  2959. // x~x mission_liste
  2960.  
  2961. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2962. try {
  2963. var titresMimis = document.evaluate(
  2964. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2965. document, null, 7, null
  2966. );
  2967. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2968. } catch(e) {
  2969. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2970. return;
  2971. }
  2972. var enCours = {};
  2973. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2974. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2975. enCours[num] = true;
  2976. }
  2977. for(var numMimi in obMissions) {
  2978. if(!enCours[numMimi]) {
  2979. delete obMissions[numMimi];
  2980. }
  2981. }
  2982. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2983. }
  2984.  
  2985. function do_mission_liste() {
  2986. checkLesMimis();
  2987. }
  2988.  
  2989. /*******************************************************************************
  2990. * This file is part of Mountyzilla. *
  2991. * *
  2992. * Mountyzilla is free software; you can redistribute it and/or modify *
  2993. * it under the terms of the GNU General Public License as published by *
  2994. * the Free Software Foundation; either version 2 of the License, or *
  2995. * (at your option) any later version. *
  2996. * *
  2997. * Mountyzilla is distributed in the hope that it will be useful, *
  2998. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2999. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3000. * GNU General Public License for more details. *
  3001. * *
  3002. * You should have received a copy of the GNU General Public License *
  3003. * along with Mountyzilla; if not, write to the Free Software *
  3004. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3005. *******************************************************************************/
  3006.  
  3007. // x~x actions
  3008.  
  3009. /* TODO
  3010. * getLvl pour Explo, Rotobaffe et cie
  3011. */
  3012.  
  3013.  
  3014.  
  3015. /* Page de combat */
  3016.  
  3017. function getLevel() {
  3018. var divList = document.getElementsByTagName('div');
  3019. if(divList.length <= 2)
  3020. return;
  3021. // On essaie de voir si cette action était une attaque
  3022. var pList = document.getElementsByTagName('p');
  3023. var nomM = '';
  3024. // Modification pour Frénésie by TetDure
  3025. var numAtt = 0;
  3026. for (var i = 0; i < pList.length; i++) {
  3027. if(pList[i].firstChild) {
  3028. nomM = pList[i].firstChild.nodeValue;
  3029. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3030. numAtt++;
  3031. }
  3032. }
  3033. if(nomM == '')
  3034. return;
  3035. // Si c'est une attaque normale, un seul PX
  3036. var comPX = 1;
  3037. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3038. comPX++;
  3039.  
  3040. // Extraction des infos du monstre attaqué
  3041. var idM;
  3042. var male;
  3043. if(nomM.slice(20, 21) == 'e') {
  3044. male = false;
  3045. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3046. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3047. }
  3048. else {
  3049. male = true;
  3050. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3051. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3052. }
  3053. if(idM == '')
  3054. return;
  3055. var bList = document.getElementsByTagName('b');
  3056. var niveau = '';
  3057. for (var i = 0; i < bList.length; i++) {
  3058. var b = bList[i];
  3059. if(b.childNodes[0].nodeValue != "TUÉ")
  3060. continue;
  3061. var nbPX = "";
  3062. for (i++; i < bList.length; i++) {
  3063. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3064. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3065. return;
  3066. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3067. nbPX = bList[i].childNodes[0].nodeValue;
  3068. break;
  3069. }
  3070. }
  3071. if(nbPX == '')
  3072. return;
  3073. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3074. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3075. if(!nbPX)
  3076. nbPX = 0;
  3077. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3078. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3079. if(comPX > nbPX) {
  3080. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3081. niveau = "";
  3082. } else if(Math.floor(niveau) == niveau) {
  3083. chaine += niveau + ".";
  3084. } else {
  3085. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3086. niveau = "";
  3087. }
  3088. insertBr(b.nextSibling.nextSibling.nextSibling);
  3089. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3090. }
  3091.  
  3092. if(niveau != '') {
  3093. var button = insertButtonCdm('as_Action');
  3094. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3095. + escape(nomM) + "&niveau=" + escape(niveau)
  3096. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3097. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3098. }
  3099. }
  3100.  
  3101.  
  3102. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3103.  
  3104. function insertInfoMagie(node, intitule, magie) {
  3105. if(node.nextSibling) {
  3106. node = node.nextSibling;
  3107. insertBr(node);
  3108. insertText(node, intitule);
  3109. insertText(node, magie, true);
  3110. } else {
  3111. node = node.parentNode;
  3112. appendBr(node);
  3113. appendText(node, intitule);
  3114. appendText(node, magie, true);
  3115. }
  3116. }
  3117.  
  3118. function getMM(sr) {
  3119. if(rmTroll<=0) {
  3120. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3121. }
  3122. sr = Number(sr.match(/\d+/)[0]);
  3123. if(sr==10) {
  3124. return '\u2265 '+5*rmTroll;
  3125. }
  3126. if(sr<=50) {
  3127. return Math.round(50*rmTroll/sr);
  3128. }
  3129. if(sr<90) {
  3130. return Math.round((100-sr)*rmTroll/50);
  3131. }
  3132. return '\u2264 '+Math.round(rmTroll/5);
  3133. }
  3134.  
  3135. function traiteMM() {
  3136. var node = document.evaluate(
  3137. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3138. document, null, 9, null).singleNodeValue;
  3139. if(node) {
  3140. var mm = getMM(node.nodeValue);
  3141. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3142. } else {
  3143. var node = document.evaluate(
  3144. "//p/text()[contains(., 'Seuil de Résistance')]",
  3145. document, null, 9, null).singleNodeValue;
  3146. if(!node) {
  3147. return;
  3148. }
  3149. var mm = getMM(node.nodeValue);
  3150. node = node.nextSibling.nextSibling;
  3151. }
  3152. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3153. }
  3154.  
  3155. function getRM(sr) {
  3156. if(mmTroll<=0) {
  3157. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3158. }
  3159. sr = Number(sr.match(/\d+/)[0]);
  3160. if(sr==10) {
  3161. return '\u2264 '+Math.round(mmTroll/5);
  3162. }
  3163. if(sr<=50) {
  3164. return Math.round(sr*mmTroll/50);
  3165. }
  3166. if(sr<90) {
  3167. return Math.round(50*mmTroll/(100-sr));
  3168. }
  3169. return '\u2265 '+5*mmTroll;
  3170. }
  3171.  
  3172. function traiteRM() {
  3173. var nodes = document.evaluate(
  3174. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3175. document, null, 7, null);
  3176. if(nodes.snapshotLength==0) {
  3177. return;
  3178. }
  3179. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3180. var node = nodes.snapshotItem(i);
  3181. var rm = getRM(node.nodeValue);
  3182. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3183. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3184. }
  3185. }
  3186.  
  3187.  
  3188. /* Fonction stats IdT par Raistlin */
  3189. /*function getIdt() {
  3190. if(MY_getValue("SEND_IDT") == "non")
  3191. return false;
  3192. var regExpBeginning = /^\s+/;
  3193. var regExpEnd = /\s+$/;
  3194.  
  3195. var nomIdt = document.evaluate(
  3196. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3197. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3198. if(!nomIdt)
  3199. return false;
  3200.  
  3201. var caracIdt;
  3202. if(nomIdt.indexOf("Malédiction !") != -1) {
  3203. caracIdt = "";
  3204. nomIdt = "Mission maudite";
  3205. } else {
  3206. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3207. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3208. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3209. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3210. }
  3211. FF_XMLHttpRequest({
  3212. method: 'GET',
  3213. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3214. headers : {
  3215. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3216. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3217. }
  3218. });
  3219. return true;
  3220. }*/
  3221.  
  3222.  
  3223. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3224.  
  3225. function confirmeDecalage() {
  3226. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3227. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3228. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3229. var newDLA = new Date( oldDLA );
  3230. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3231. return window.confirm(
  3232. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3233. +'\nConfirmez-vous ce décalage ?'
  3234. );
  3235. }
  3236.  
  3237. function newsubmitDLA(evt) {
  3238. evt.stopPropagation();
  3239. evt.preventDefault();
  3240. if(confirmeDecalage()) {
  3241. this.submit();
  3242. }
  3243. }
  3244.  
  3245. function changeActionDecalage() {
  3246. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3247. return;
  3248. }
  3249. try {
  3250. // On récupère le contenu du script JS MH de calcul du décalage
  3251. var scriptTxt = document.evaluate(
  3252. ".//script[ not(@src) ]",
  3253. document, null, 9, null
  3254. ).singleNodeValue.textContent;
  3255. // On en extrait la DLA courante
  3256. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3257. scriptTxt = scriptTxt.split('\n')[0];
  3258. var nbs = scriptTxt.match(/\d+/g);
  3259. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3260. } catch(e) {
  3261. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3262. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3263. return;
  3264. }
  3265. var form = document.getElementsByName('ActionForm')[0];
  3266. if(form) {
  3267. form.addEventListener('submit', newsubmitDLA, true);
  3268. } else {
  3269. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3270. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3271. }
  3272. }
  3273.  
  3274. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3275.  
  3276. function prochainMundi() {
  3277. try {
  3278. var node;
  3279. node = document.evaluate(
  3280. "//div[@class='dateAction']/b",
  3281. document, null, 9, null
  3282. ).singleNodeValue;
  3283. if (document.evaluate) {
  3284. } else { // repli en JQuery
  3285. //node = $(
  3286. }
  3287. } catch(e) {
  3288. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3289. return;
  3290. }
  3291. if(!node) { return; }
  3292.  
  3293. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3294. var jour = longueurMois+1-getNumber(node.textContent);
  3295. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3296. var txt = '[Prochain Mundidey ';
  3297. if(jour>1) {
  3298. txt += 'dans '+jour+' jours]';
  3299. } else {
  3300. txt += 'demain]';
  3301. }
  3302. insertText(node.parentNode.nextSibling,txt,true);
  3303. }
  3304.  
  3305.  
  3306. /* Fonction principale */
  3307.  
  3308. function dispatch() {
  3309. if(isPage('MH_Play/Play_action')) {
  3310. prochainMundi();
  3311. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3312. var oldDLA;
  3313. changeActionDecalage();
  3314. } else if(isPage('MH_Play/Actions')) {
  3315. if(document.evaluate(
  3316. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3317. document, null, 2, null
  3318. ).stringValue) {
  3319. traiteMM();
  3320. } else if(document.evaluate(
  3321. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3322. document, null, 2, null
  3323. ).stringValue) {
  3324. //getIdt();
  3325. traiteRM();
  3326. } /*else {
  3327. // Est censé se lancer sur quoi *précisément* ?
  3328. traiteRM();
  3329. getLevel();
  3330. }*/
  3331. } else {
  3332. /* Traitement des messages du bot */
  3333. var messageTitle = document.evaluate(
  3334. "//form/table/tbody/tr[1]/td[1]/"
  3335. +"descendant::text()[contains(.,'[MountyHall]')]",
  3336. document, null, 2, null
  3337. ).stringValue;
  3338. if(messageTitle.indexOf('Attaquant') != -1 &&
  3339. messageTitle.indexOf('sur') != -1) {
  3340. getLevel();
  3341. traiteRM();
  3342. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3343. messageTitle.indexOf('Défenseur') != -1) {
  3344. traiteMM();
  3345. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3346. // à replacer avec Attaque après révision getLvl :
  3347. messageTitle.indexOf('Explosion') != -1 ||
  3348. messageTitle.indexOf('Insulte') != -1) {
  3349. traiteRM();
  3350. }
  3351. }
  3352. }
  3353.  
  3354. function do_actions() {
  3355. start_script(31);
  3356. dispatch();
  3357. displayScriptTime();
  3358. }
  3359.  
  3360. /*********************************************************************************
  3361. * This file is part of Mountyzilla. *
  3362. * *
  3363. * Mountyzilla is free software; you can redistribute it and/or modify *
  3364. * it under the terms of the GNU General Public License as published by *
  3365. * the Free Software Foundation; either version 2 of the License, or *
  3366. * (at your option) any later version. *
  3367. * *
  3368. * Mountyzilla is distributed in the hope that it will be useful, *
  3369. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3370. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3371. * GNU General Public License for more details. *
  3372. * *
  3373. * You should have received a copy of the GNU General Public License *
  3374. * along with Mountyzilla; if not, write to the Free Software *
  3375. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3376. *********************************************************************************/
  3377.  
  3378. // x~x pre-enchant
  3379.  
  3380. /* 2013-08-19 : correction auto syntaxe alert */
  3381.  
  3382. var combobox=null;
  3383.  
  3384. function changeObject()
  3385. {
  3386. if(!combobox)
  3387. return ;
  3388. var id = combobox.options[combobox.selectedIndex].value;
  3389. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3390. if(!id || id=="")
  3391. {
  3392. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3393. return;
  3394. }
  3395. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3396. }
  3397.  
  3398. function treatePreEnchantement() {
  3399. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3400. if(!input || input.getAttribute("type")=="hidden")
  3401. {
  3402. return false;
  3403. }
  3404. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3405. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3406. if(!combobox)
  3407. {
  3408. return true;
  3409. }
  3410. combobox.addEventListener('change', changeObject, true);
  3411. return true;
  3412. }
  3413.  
  3414. function treateEnchantement() {
  3415. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3416. if(!input || input.getAttribute("type")!="hidden")
  3417. {
  3418. return false;
  3419. }
  3420. var idEquipement = input.getAttribute("value");
  3421. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3422. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3423. if(enchanteur && enchanteur != null)
  3424. return true;
  3425. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3426. if(!input || input.getAttribute("type")!="hidden")
  3427. {
  3428. return false;
  3429. }
  3430. var idEnchanteur = input.getAttribute("value");
  3431. var nodes = document.evaluate(
  3432. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3433. if (nodes.snapshotLength != 3)
  3434. return;
  3435. for(var i=0;i<3;i++)
  3436. {
  3437. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3438. texte = texte.replace(" d'une "," d'un ");
  3439. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3440. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3441. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3442. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3443. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3444. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3445. }
  3446. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3447. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3448. var liste = MY_getValue(numTroll+".enchantement.liste");
  3449. if(!liste || liste=="")
  3450. {
  3451. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3452. }
  3453. else
  3454. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3455. }
  3456.  
  3457. function do_pre_enchant() {
  3458. start_script(60);
  3459. if(!treatePreEnchantement())
  3460. treateEnchantement();
  3461. displayScriptTime();
  3462. }
  3463.  
  3464. /*********************************************************************************
  3465. * This file is part of Mountyzilla. *
  3466. * *
  3467. * Mountyzilla is free software; you can redistribute it and/or modify *
  3468. * it under the terms of the GNU General Public License as published by *
  3469. * the Free Software Foundation; either version 2 of the License, or *
  3470. * (at your option) any later version. *
  3471. * *
  3472. * Mountyzilla is distributed in the hope that it will be useful, *
  3473. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3474. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3475. * GNU General Public License for more details. *
  3476. * *
  3477. * You should have received a copy of the GNU General Public License *
  3478. * along with Mountyzilla; if not, write to the Free Software *
  3479. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3480. *********************************************************************************/
  3481.  
  3482. // x~x enchant
  3483.  
  3484. /* 2013-08-19 : correction auto syntaxe alert */
  3485.  
  3486. function treateEnchantement() {
  3487. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3488. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3489. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3490. return;
  3491. var tab = infoEquipement.split(";");
  3492. if(tab.length<2)
  3493. return;
  3494. var idEquipement = tab[0];
  3495. var nomEquipement = tab[1];
  3496. for(var i=2;i<tab.length;i++)
  3497. nomEquipement += ";"+tab[i];
  3498. var nodes = document.evaluate(
  3499. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3500. if (nodes.snapshotLength != 3)
  3501. return;
  3502. for(var i=0;i<3;i++)
  3503. {
  3504. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3505. texte = texte.replace(" d'une "," d'un ");
  3506. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3507. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3508. monstre = monstre.replace(/ Géante?/,"");
  3509. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3510. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3511. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3512. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3513. }
  3514. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3515. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3516. var liste = MY_getValue(numTroll+".enchantement.liste");
  3517. if(!liste || liste=="")
  3518. {
  3519. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3520. }
  3521. else
  3522. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3523. }
  3524.  
  3525. function do_enchant() {
  3526. start_script(60);
  3527.  
  3528. treateEnchantement();
  3529. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3530. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3531. displayScriptTime();
  3532. }
  3533.  
  3534. /*********************************************************************************
  3535. * This file is part of Mountyzilla. *
  3536. * *
  3537. * Mountyzilla is free software; you can redistribute it and/or modify *
  3538. * it under the terms of the GNU General Public License as published by *
  3539. * the Free Software Foundation; either version 2 of the License, or *
  3540. * (at your option) any later version. *
  3541. * *
  3542. * Mountyzilla is distributed in the hope that it will be useful, *
  3543. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3544. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3545. * GNU General Public License for more details. *
  3546. * *
  3547. * You should have received a copy of the GNU General Public License *
  3548. * along with Mountyzilla; if not, write to the Free Software *
  3549. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3550. *********************************************************************************/
  3551.  
  3552. // x~x myevent
  3553.  
  3554. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3555. function do_myevent() {
  3556. }
  3557.  
  3558. /*********************************************************************************
  3559. * This file is part of Mountyzilla. *
  3560. * *
  3561. * Mountyzilla is free software; you can redistribute it and/or modify *
  3562. * it under the terms of the GNU General Public License as published by *
  3563. * the Free Software Foundation; either version 2 of the License, or *
  3564. * (at your option) any later version. *
  3565. * *
  3566. * Mountyzilla is distributed in the hope that it will be useful, *
  3567. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3568. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3569. * GNU General Public License for more details. *
  3570. * *
  3571. * You should have received a copy of the GNU General Public License *
  3572. * along with Mountyzilla; if not, write to the Free Software *
  3573. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3574. *********************************************************************************/
  3575.  
  3576. // x~x malus
  3577.  
  3578. /* v1.4 - 2014-01-06
  3579. * - Gestion des sorts double composante
  3580. * v1.4.1 - 2014-01-22
  3581. * - Correction décumul
  3582. * TODO
  3583. * - Identifier la position de "PV" dans l'ordre MH
  3584. */
  3585.  
  3586. var listeBM;
  3587.  
  3588.  
  3589. /* [functions] Utilitaires */
  3590.  
  3591. function decumul(bmt,nbr) {
  3592. var bmr;
  3593. if(!nbr || nbr<2) bmr = bmt;
  3594. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3595. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3596. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3597. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3598. else bmr = parseInt(0.1*bmt);
  3599. if(bmt<0) return Math.min(-1,bmr);
  3600. return Math.max(1,bmr);
  3601. }
  3602.  
  3603. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3604. // Roule 23/11/2016 ajout PV
  3605. switch( a ) {
  3606. case 'ATT':
  3607. return -1;
  3608. case 'ESQ':
  3609. if(b=='ATT') return 1;
  3610. return -1;
  3611. case 'DEG':
  3612. switch( b ) {
  3613. case 'ATT':
  3614. case 'ESQ':
  3615. return 1;
  3616. default:
  3617. return -1;
  3618. }
  3619. case 'REG':
  3620. switch( b ) {
  3621. case 'ATT':
  3622. case 'ESQ':
  3623. case 'DEG':
  3624. return 1;
  3625. default:
  3626. return -1;
  3627. }
  3628. case 'Vue':
  3629. switch( b ) {
  3630. case 'ATT':
  3631. case 'ESQ':
  3632. case 'DEG':
  3633. case 'REG':
  3634. return 1;
  3635. default:
  3636. return -1;
  3637. }
  3638. case 'TOUR':
  3639. switch( b ) {
  3640. case 'ATT':
  3641. case 'ESQ':
  3642. case 'DEG':
  3643. case 'REG':
  3644. case 'Vue':
  3645. return 1;
  3646. default:
  3647. return -1;
  3648. }
  3649. case 'PV':
  3650. switch( b ) {
  3651. case 'ATT':
  3652. case 'ESQ':
  3653. case 'DEG':
  3654. case 'REG':
  3655. case 'Vue':
  3656. case 'TOUR':
  3657. return 1;
  3658. default:
  3659. return -1;
  3660. }
  3661. case 'Armure':
  3662. switch( b ) {
  3663. case 'ATT':
  3664. case 'ESQ':
  3665. case 'DEG':
  3666. case 'REG':
  3667. case 'Vue':
  3668. case 'TOUR':
  3669. case 'PV':
  3670. return 1;
  3671. default:
  3672. return -1;
  3673. }
  3674. case 'RM':
  3675. switch( b ) {
  3676. case 'ATT':
  3677. case 'ESQ':
  3678. case 'DEG':
  3679. case 'REG':
  3680. case 'Vue':
  3681. case 'TOUR':
  3682. case 'PV':
  3683. case 'Armure':
  3684. return 1;
  3685. default:
  3686. return -1;
  3687. }
  3688. case 'MM':
  3689. switch( b ) {
  3690. case 'ATT':
  3691. case 'ESQ':
  3692. case 'DEG':
  3693. case 'REG':
  3694. case 'Vue':
  3695. case 'TOUR':
  3696. case 'PV':
  3697. case 'Armure':
  3698. case 'RM':
  3699. return 1;
  3700. default:
  3701. return -1;
  3702. }
  3703. case 'Concentration':
  3704. switch( b ) {
  3705. case 'ATT':
  3706. case 'ESQ':
  3707. case 'DEG':
  3708. case 'REG':
  3709. case 'Vue':
  3710. case 'TOUR':
  3711. case 'PV':
  3712. case 'Armure':
  3713. case 'RM':
  3714. case 'MM':
  3715. return 1;
  3716. default:
  3717. return -1;
  3718. }
  3719. case 'Fatigue':
  3720. switch( b ) {
  3721. case 'ATT':
  3722. case 'ESQ':
  3723. case 'DEG':
  3724. case 'REG':
  3725. case 'Vue':
  3726. case 'TOUR':
  3727. case 'PV':
  3728. case 'Armure':
  3729. case 'RM':
  3730. case 'MM':
  3731. case 'Concentration':
  3732. return 1;
  3733. default:
  3734. return -1;
  3735. }
  3736. case "Dés d'attaque":
  3737. switch( b ) {
  3738. case 'ATT':
  3739. case 'ESQ':
  3740. case 'DEG':
  3741. case 'REG':
  3742. case 'Vue':
  3743. case 'TOUR':
  3744. case 'PV':
  3745. case 'Armure':
  3746. case 'RM':
  3747. case 'MM':
  3748. case 'Concentration':
  3749. case 'Fatigue':
  3750. return 1;
  3751. default:
  3752. return -1;
  3753. }
  3754. case 'Dés de dégâts':
  3755. switch( b ) {
  3756. case 'ATT':
  3757. case 'ESQ':
  3758. case 'DEG':
  3759. case 'REG':
  3760. case 'Vue':
  3761. case 'TOUR':
  3762. case 'PV':
  3763. case 'Armure':
  3764. case 'RM':
  3765. case 'MM':
  3766. case 'Concentration':
  3767. case 'Fatigue':
  3768. case "Dés d'attaque":
  3769. return 1;
  3770. default:
  3771. return -1;
  3772. }
  3773. default :
  3774. switch( b ) {
  3775. case 'ATT':
  3776. case 'ESQ':
  3777. case 'DEG':
  3778. case 'REG':
  3779. case 'Vue':
  3780. case 'TOUR':
  3781. case 'PV':
  3782. case 'Armure':
  3783. case 'RM':
  3784. case 'MM':
  3785. case 'Concentration':
  3786. case 'Fatigue':
  3787. case "Dés d'attaque":
  3788. case 'Dés de dégâts':
  3789. return 1;
  3790. default:
  3791. return -1;
  3792. }
  3793. }
  3794. }
  3795.  
  3796.  
  3797. /* [functions] Fonctions hide / display */
  3798.  
  3799. function toggleDetailsBM() {
  3800. if(MY_getValue('BMDETAIL')!='false') {
  3801. MY_setValue('BMDETAIL','false');
  3802. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3803. for(var i=0 ; i<trlist.length ; i++)
  3804. trlist[i].style.display = 'none';
  3805. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3806. for(var i=0 ; i<trlist.length ; i++)
  3807. trlist[i].style = '';
  3808. }
  3809. else {
  3810. MY_setValue('BMDETAIL','true');
  3811. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3812. for(var i=0 ; i<trlist.length ; i++)
  3813. trlist[i].style.display = 'none';
  3814. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3815. for(var i=0 ; i<trlist.length ; i++)
  3816. trlist[i].style = '';
  3817. }
  3818. }
  3819.  
  3820. function toggleBMList() {
  3821. if(MY_getValue('BMHIDELIST')=='true') {
  3822. MY_setValue('BMHIDELIST','false');
  3823. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3824. listeBM.snapshotItem(i).style = '';
  3825. document.getElementsByTagName('thead')[0].style = '';
  3826. document.getElementById('trhelp').style = '';
  3827. }
  3828. else {
  3829. MY_setValue('BMHIDELIST','true');
  3830. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3831. listeBM.snapshotItem(i).style.display = 'none';
  3832. document.getElementsByTagName('thead')[0].style.display = 'none';
  3833. document.getElementById('trhelp').style.display = 'none';
  3834. }
  3835. }
  3836.  
  3837. function setDisplayBM() {
  3838. if(!listeBM) return;
  3839. var titre = document.getElementById('titre2');
  3840. if(titre) {
  3841. titre.style.cursor = 'pointer';
  3842. titre.onclick = toggleBMList;
  3843. }
  3844. var tfoot = document.getElementsByTagName('tfoot')[0];
  3845. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3846. tfoot, null, 9, null).singleNodeValue;
  3847. tr.id = 'trhelp';
  3848. if(MY_getValue('BMHIDELIST')=='true') {
  3849. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3850. listeBM.snapshotItem(i).style.display = 'none';
  3851. document.getElementsByTagName('thead')[0].style.display = 'none';
  3852. tr.style.display = 'none';
  3853. }
  3854. }
  3855.  
  3856.  
  3857. /* [functions] Fonction principale */
  3858.  
  3859. function traiteMalus() {
  3860. var mainTab = document.getElementsByTagName('table')[0];
  3861. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3862. if(listeBM.snapshotLength==0) return;
  3863. /* Suppression des BM de fatigue stockés */
  3864. if(MY_getValue(numTroll+'.bm.fatigue'))
  3865. MY_removeValue(numTroll+'.bm.fatigue');
  3866. /* Extraction des données */
  3867. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3868. var nb = 0;
  3869. while(nb<listeBM.snapshotLength) {
  3870. tr = listeBM.snapshotItem(nb); nb++;
  3871. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3872. var phymag = tr.childNodes[9].textContent;
  3873. var duree = tr.childNodes[11].textContent.match(/\d+/);
  3874. if (duree == null) { // Roule 28/01/2018 protection malus Crasc sans durée
  3875. duree = 1;
  3876. } else {
  3877. duree = Number(duree[0]);
  3878. }
  3879. var type = tr.childNodes[3].textContent, nom;
  3880. // si c'est un type à décumul
  3881. /*
  3882. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3883. switch(type) {
  3884. case 'Potion':
  3885. case 'Parchemin':
  3886. case 'Sortilège':
  3887. case 'Capacité Spéciale':
  3888. nom = tr.childNodes[1].textContent+phymag;
  3889. break;
  3890. default:
  3891. nom = 'pasdedecumul';
  3892. }
  3893. */
  3894. nom = tr.childNodes[1].textContent+phymag;
  3895. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3896. nom = 'pasdedecumul';
  3897. uniListe[nb] = {
  3898. 'duree':duree,
  3899. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3900. 'caracs':{}
  3901. }
  3902. for(var i=0 ; i<effetsT.length ; i++) {
  3903. if(effetsT[i].indexOf(':')==-1) continue;
  3904. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3905. // nom = 'pasdedecumul' si pas de décumul
  3906. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3907. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3908. uniListe[nb]['type'] = phymag;
  3909. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3910. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  3911. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  3912. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  3913. uniListe[nb]['caracs'][carac] = bm;
  3914. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  3915. listeDurees[duree] = true;
  3916. }
  3917. } // fin boucle sur les lignes de bonus/malus
  3918. /* Gestion des décumuls et cumuls des durées */
  3919. var toursGeres = [];
  3920. for(var d in listeDurees) toursGeres.push(d);
  3921. toursGeres.sort( function (a,b){return b-a;} );
  3922. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  3923. // pour sauvegarder les bm de fatigue
  3924. var strfat = '';
  3925. // Pour affichage & adpatation à footable.js (statique)
  3926. var thead = document.getElementsByTagName('thead')[0];
  3927. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3928. thead, null, 7, null).snapshotLength;
  3929. var tfoot = document.getElementsByTagName('tfoot')[0];
  3930. for(var i=0 ; i<toursGeres.length ; i++) {
  3931. var tour = toursGeres[i];
  3932. var effetsCeTour = {}; decumulsCeTour = {};
  3933. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3934. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3935. continue;
  3936. var nom = uniListe[nb]['nom'];
  3937. if(nom!='pasdedecumul') {
  3938. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3939. decumulsCeTour[nom]++;
  3940. }
  3941. for(var carac in uniListe[nb]['caracs']) {
  3942. var bm = uniListe[nb]['caracs'][carac];
  3943. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3944. var type = uniListe[nb]['type'];
  3945. if(!effetsCeTour[carac])
  3946. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3947. var thisBm;
  3948. if(nom=='pasdedecumul')
  3949. thisBm = bm;
  3950. else
  3951. thisBm = decumul(bm,decumulsCeTour[nom]);
  3952. effetsCeTour[carac][type] += thisBm;
  3953. 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]);
  3954. } else {
  3955. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3956. var thisBm;
  3957. if(nom=='pasdedecumul' || carac=='Fatigue')
  3958. thisBm = bm;
  3959. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3960. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3961. else
  3962. thisBm = decumul(bm,decumulsCeTour[nom]);
  3963. effetsCeTour[carac] += thisBm;
  3964. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3965. }
  3966. } // fin boucle sur les caractéristiques
  3967. } // fin boucle sur les bonus/malus
  3968. /* Création du bilan du tour */
  3969. var texteD = '', texteS = '';
  3970. var caracGerees = [];
  3971. for(var k in effetsCeTour) caracGerees.push(k);
  3972. caracGerees.sort( triecaracs );
  3973. for(var j=0 ; j<caracGerees.length ; j++) {
  3974. var carac = caracGerees[j], str = '';
  3975. switch( carac ) {
  3976. case 'ATT':
  3977. case 'DEG':
  3978. case 'Armure':
  3979. var phy = effetsCeTour[carac]['Physique'];
  3980. var mag = effetsCeTour[carac]['Magie'];
  3981. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3982. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3983. break;
  3984. case 'TOUR':
  3985. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3986. break;
  3987. case 'Fatigue':
  3988. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3989. case 'PV':
  3990. case 'ESQ':
  3991. case 'REG':
  3992. case 'Vue':
  3993. case 'Voir le Caché':
  3994. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3995. break;
  3996. default:
  3997. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3998. }
  3999. if(str) {
  4000. texteD += str;
  4001. texteS += str;
  4002. }
  4003. } // fin boucle sur les caractéristiques
  4004. /* Affichage */
  4005. // Si rien à afficher on passe
  4006. if(!texteD) continue;
  4007. // Si BMM+BMP=0
  4008. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  4009. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  4010. if(MY_getValue('BMDETAIL')=='false')
  4011. tr.style.display = 'none';
  4012. var td = appendTdText(tr,texteD.substring(3));
  4013. td.colSpan = 5-nbHidden;
  4014. var txttour = toursGeres[i]+' Tour';
  4015. if(toursGeres[i]>1) txttour += 's';
  4016. appendTdText(tr,txttour);
  4017. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  4018. if(MY_getValue('BMDETAIL')!='false')
  4019. tr.style.display = 'none';
  4020. td = appendTdText(tr,texteS);
  4021. td.colSpan = 5-nbHidden;
  4022. appendTdText(tr,txttour);
  4023. } // fin boucle sur les tours générés
  4024. /* mise en place toggleDetails */
  4025. tfoot.style.cursor = 'pointer';
  4026. tfoot.onclick = toggleDetailsBM;
  4027. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4028. if(strfat)
  4029. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4030. }
  4031.  
  4032. function do_malus() {
  4033. try {
  4034. start_script();
  4035. traiteMalus();
  4036. setDisplayBM();
  4037. displayScriptTime();
  4038. }
  4039. catch(e) {window.alert(e)};
  4040. }
  4041.  
  4042. /*******************************************************************************
  4043. * This file is part of Mountyzilla. *
  4044. * *
  4045. * Mountyzilla is free software; you can redistribute it and/or modify *
  4046. * it under the terms of the GNU General Public License as published by *
  4047. * the Free Software Foundation; either version 2 of the License, or *
  4048. * (at your option) any later version. *
  4049. * *
  4050. * Mountyzilla is distributed in the hope that it will be useful, *
  4051. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4052. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4053. * GNU General Public License for more details. *
  4054. * *
  4055. * You should have received a copy of the GNU General Public License *
  4056. * along with Mountyzilla; if not, write to the Free Software *
  4057. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4058. *******************************************************************************/
  4059.  
  4060. // x~x mouches
  4061.  
  4062. var mainTab, tr_mouches;
  4063.  
  4064. function initialiseMouches() {
  4065. // Lanceur global
  4066. try {
  4067. mainTab = document.getElementById('mouches');
  4068. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4069. } catch(e) {
  4070. avertissement('Erreur MZ:<br />Consulter la console.');
  4071. window.console.error(traceStack(e, 'mouches'));
  4072. return;
  4073. }
  4074. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4075. setDisplayMouches();
  4076. traiteMouches();
  4077. }
  4078.  
  4079. function setDisplayMouches() {
  4080. // Initialise l'affichage / l'effacement du détail des mouches
  4081. var titre = document.getElementById('titre2');
  4082. if(titre) {
  4083. titre.style.cursor = 'pointer';
  4084. titre.onclick = toggleMouches;
  4085. }
  4086. var tfoot = document.getElementsByTagName('tfoot')[0];
  4087. if(tfoot) {
  4088. tfoot.style.cursor = 'pointer';
  4089. tfoot.onclick = toggleMouches;
  4090. }
  4091. if(MY_getValue('HIDEMOUCHES')=='true') {
  4092. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4093. tr_mouches.snapshotItem(i).style.display = 'none';
  4094. }
  4095. document.getElementsByTagName('thead')[0].style.display = 'none';
  4096. }
  4097. }
  4098.  
  4099. function toggleMouches() {
  4100. // Handler pour afficher / masquer les détasil
  4101. if(MY_getValue('HIDEMOUCHES')=='true') {
  4102. MY_setValue('HIDEMOUCHES','false');
  4103. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4104. tr_mouches.snapshotItem(i).style.display = '';
  4105. }
  4106. document.getElementsByTagName('thead')[0].style.display = '';
  4107. } else {
  4108. MY_setValue('HIDEMOUCHES','true');
  4109. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4110. tr_mouches.snapshotItem(i).style.display = 'none';
  4111. }
  4112. document.getElementsByTagName('thead')[0].style.display = 'none';
  4113. }
  4114. }
  4115.  
  4116. function traiteMouches() {
  4117. // Traitement complet: présence et effets des mouches
  4118. var listeTypes = {}, effetsActifs = {};
  4119. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4120. var tr = tr_mouches.snapshotItem(i);
  4121. // La mouche est-elle présente?
  4122. var etat = document.evaluate(
  4123. './img',
  4124. tr.cells[6], null, 9, null
  4125. ).singleNodeValue.alt;
  4126. if(etat!='La Mouche est là') { continue; }
  4127. // Extraction du type de mouche
  4128. var type = trim(tr.cells[3].textContent);
  4129. if(!listeTypes[type]) {
  4130. listeTypes[type] = 1;
  4131. } else {
  4132. listeTypes[type]++;
  4133. }
  4134. // La mouche a-t-elle un effet?
  4135. var effet = trim(tr.cells[2].textContent);
  4136. if(etat!='La Mouche est là' || !effet) { continue; }
  4137. // Si oui, extraction des effets (multiples pour pogées)
  4138. var caracs = effet.split(' | ');
  4139. for(var j=0 ; j<caracs.length ; j++) {
  4140. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4141. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4142. if(effetsActifs[carac]===void(0)) {
  4143. effetsActifs[carac] = valeur;
  4144. } else {
  4145. effetsActifs[carac] += valeur;
  4146. }
  4147. }
  4148. }
  4149. // Extraction Effet total et affichage des différences à la normale
  4150. var tfoot = document.getElementsByTagName('tfoot')[0];
  4151. if(!tfoot) { return; }
  4152. var nodeTotal = document.evaluate(
  4153. ".//b[contains(./text(),'Effet total')]",
  4154. tfoot, null, 9, null
  4155. ).singleNodeValue.nextSibling;
  4156. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4157. var texte = ' ';
  4158. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4159. if(texte.length>1) { texte += ' | '; }
  4160. var carac = trim(
  4161. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4162. );
  4163. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4164. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4165. texte += effetsTheoriques[i];
  4166. } else {
  4167. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4168. if(carac=='TOUR') { texte += ' min'; }
  4169. texte += '</b>';
  4170. }
  4171. }
  4172. var span = document.createElement('span');
  4173. span.innerHTML = texte;
  4174. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4175. // Affichage des différences du nombre de mouches de chaque type
  4176. var mouchesParType = document.evaluate(
  4177. "./tr/td/ul/li/text()",
  4178. tfoot, null, 7, null
  4179. );
  4180. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4181. var node = mouchesParType.snapshotItem(i);
  4182. var mots = node.nodeValue.split(' ');
  4183. var type = mots.pop();
  4184. if(!listeTypes[type]) {
  4185. node.nodeValue += ' (0 présente)';
  4186. } else if(mots[0]!=listeTypes[type]) {
  4187. if(listeTypes[type]==1) {
  4188. node.nodeValue += ' (1 présente)';
  4189. } else {
  4190. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4191. }
  4192. }
  4193. }
  4194. }
  4195.  
  4196. function do_mouches() {
  4197. start_script();
  4198. initialiseMouches();
  4199. displayScriptTime();
  4200. }
  4201.  
  4202. /*********************************************************************************
  4203. * This file is part of Mountyzilla. *
  4204. * *
  4205. * Mountyzilla is free software; you can redistribute it and/or modify *
  4206. * it under the terms of the GNU General Public License as published by *
  4207. * the Free Software Foundation; either version 2 of the License, or *
  4208. * (at your option) any later version. *
  4209. * *
  4210. * Mountyzilla is distributed in the hope that it will be useful, *
  4211. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4212. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4213. * GNU General Public License for more details. *
  4214. * *
  4215. * You should have received a copy of the GNU General Public License *
  4216. * along with Mountyzilla; if not, write to the Free Software *
  4217. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4218. *********************************************************************************/
  4219.  
  4220. // x~x equipgowap
  4221.  
  4222. var popup;
  4223.  
  4224. function initPopupEquipgowap() {
  4225. popup = document.createElement('div');
  4226. popup.setAttribute('id', 'popup');
  4227. popup.setAttribute('class', 'mh_textbox');
  4228. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4229. 'display: inline; z-index: 3; max-width: 400px;');
  4230. document.body.appendChild(popup);
  4231. }
  4232.  
  4233. function showPopupEquipgowap(evt) {
  4234. var texte = this.getAttribute("texteinfo");
  4235. popup.innerHTML = texte;
  4236. popup.style.left = evt.pageX + 15 + 'px';
  4237. popup.style.top = evt.pageY + 'px';
  4238. popup.style.visibility = "visible";
  4239. }
  4240.  
  4241. function hidePopup() {
  4242. popup.style.visibility = "hidden";
  4243. }
  4244.  
  4245. function createPopupImage(url, text)
  4246. {
  4247. var img = document.createElement('img');
  4248. img.setAttribute('src',url);
  4249. img.setAttribute('align','ABSMIDDLE');
  4250. img.setAttribute("texteinfo",text);
  4251. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4252. img.addEventListener("mouseout", hidePopup,true);
  4253. return img;
  4254. }
  4255.  
  4256. function formateTexte(texte)
  4257. {
  4258. texte = texte.replace(/\n/g,"<br/>");
  4259. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4260. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4261. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4262. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4263. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4264. return texte;
  4265. }
  4266.  
  4267.  
  4268. function treateGowaps() {
  4269. //On récupère les gowaps possédants des composants
  4270. var tbodys = document.evaluate(
  4271. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4272. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4273. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4274. var tbody = tbodys.snapshotItem(j);
  4275. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4276. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4277. if(MY_getValue("NOINFOEM") != "true")
  4278. insertEMInfos(tbody);
  4279. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4280. insertEnchantInfos(tbody);
  4281. }
  4282. }
  4283.  
  4284. function treateChampi() {
  4285. if(MY_getValue("NOINFOEM") == "true")
  4286. return false;
  4287. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4288. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4289. if (nodes.snapshotLength == 0)
  4290. return false;
  4291.  
  4292. for (var i = 0; i < nodes.snapshotLength; i++) {
  4293. var node = nodes.snapshotItem(i);
  4294. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4295. if(texte.indexOf("*")!=-1)
  4296. texte = texte.substring(0,texte.lastIndexOf(" "));
  4297. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4298. if(moisChampi[nomChampi])
  4299. {
  4300. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4301. }
  4302. }
  4303. }
  4304.  
  4305. function do_equipgowap() {
  4306. start_script();
  4307.  
  4308. treateGowaps();
  4309. treateChampi();
  4310. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4311. {
  4312. initPopupEquipgowap();
  4313. computeEnchantementEquipement(createPopupImage,formateTexte);
  4314. }
  4315.  
  4316. displayScriptTime();
  4317. }
  4318.  
  4319. /*********************************************************************************
  4320. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4321. *********************************************************************************/
  4322.  
  4323. // x~x ordresgowap
  4324.  
  4325. // version Roule' janvier 2017
  4326. function MZ_setCarteUnGogoHTML5() {
  4327. // fabriquer la liste des positions successives
  4328. var listeDepl = []; // ce sera un tableau d'objets
  4329. // position courrante
  4330. var eTitle = document.getElementById('titre2');
  4331. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4332. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4333. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4334. , y: parseInt(tabPos[1])
  4335. , n: parseInt(tabPos[2])
  4336. , nom: tabNomID[2]
  4337. , id: tabNomID[1]});
  4338. // déplacements
  4339. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4340. for(var i=0 ; i<lignes.length ; i++) {
  4341. if(lignes[i].className == 'mh_tdpage_fo') {
  4342. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4343. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4344. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4345. }
  4346. }
  4347. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4348. }
  4349.  
  4350. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4351. function MZ_showCarteBottom(listeSuiv) {
  4352. // générer la carte
  4353. var carte = new carte_MZ('cartegogo', listeSuiv);
  4354. // positionner la carte
  4355. var eCarte = carte.getElt();
  4356. eCarte.style.textAlign = 'left';
  4357. eCarte.style.marginTop = '2px';
  4358. var footer = document.getElementById('footer1');
  4359. // Lieu_Teleport.php n'a pas de footer1 :(
  4360. if (!footer) footer = document.getElementById('footer2');
  4361. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4362. else document.body.appendChild(eCarte);
  4363. }
  4364.  
  4365. function MZ_setCarteTousGogoHTML5() {
  4366. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4367. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4368. var suivants = [];
  4369. for (var i=0;i<ligne.length;i++) {
  4370. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4371. var cas = ligne[i].getElementsByTagName("td")[0];
  4372. //if (cas.className == "mh_tdtitre") {
  4373. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4374. var oGogo = {};
  4375. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4376. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4377. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4378. oGogo.x = parseInt(point[1]);
  4379. oGogo.y = parseInt(point[2]);
  4380. oGogo.n = parseInt(point[3]);
  4381. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4382. }
  4383. }
  4384. if (suivants.length == 0) return;
  4385. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4386. }
  4387.  
  4388. function MZ_setCarteTP() {
  4389. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4390. 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);
  4391. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4392. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4393. }
  4394.  
  4395. /* v0.2 by Dab - 2013-08-31
  4396. * - correction acquisition posale initiale
  4397. * - correction tare et affichage mire
  4398. */
  4399.  
  4400. function setCarteGogo() {
  4401. try {
  4402. //var pars = document.getElementsByTagName('p');
  4403. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4404. var eTitle = document.getElementById('titre2');
  4405. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4406. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4407. var serv_img_cible = URL_MZimg + "rep.png";
  4408.  
  4409. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4410. //var lignes = pars[0].getElementsByTagName('tr');
  4411. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4412. var nbpt = 0;
  4413. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4414. for(var i=0 ; i<lignes.length ; i++) {
  4415. if(lignes[i].className == 'mh_tdpage_fo') {
  4416. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4417. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4418. if(point) {
  4419. nbpt++;
  4420. trajet += point[1]+','+point[2]+','+point[3]+',';
  4421. }
  4422. }
  4423. }
  4424. }
  4425. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4426. 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'/>";
  4427. var base = [-229,-5];
  4428. if (nbpt>0) {
  4429. base = [-684,-5];
  4430. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4431. }
  4432. 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;'/>";
  4433.  
  4434. nvdiv += '<map name="coord_trou">'+
  4435. '<area shape="circle" href="#" coords="260,333,3" title="X=5, Y=-49" >'+
  4436. '<area shape="circle" href="#" coords="262,335,3" title="X=6, Y=-50" >'+
  4437. '<area shape="circle" href="#" coords="260,335,3" title="X=5, Y=-50" >'+
  4438. '<area shape="circle" href="#" coords="262,333,3" title="X=6, Y=-49" >'+
  4439. '<area shape="circle" href="#" coords="294,163,3" title="X=22, Y=36" >'+
  4440. '<area shape="circle" href="#" coords="292,163,3" title="X=21, Y=36" >'+
  4441. '<area shape="circle" href="#" coords="294,165,3" title="X=22, Y=35" >'+
  4442. '<area shape="circle" href="#" coords="292,165,3" title="X=21, Y=35" >'+
  4443. '<area shape="circle" href="#" coords="124,217,3" title="X=-63, Y=9" >'+
  4444. '<area shape="circle" href="#" coords="122,217,3" title="X=-64, Y=9" >'+
  4445. '<area shape="circle" href="#" coords="124,219,3" title="X=-63, Y=8" >'+
  4446. '<area shape="circle" href="#" coords="122,219,3" title="X=-64, Y=8" >'+
  4447. '<area shape="circle" href="#" coords="378,95,3" title="X=64, Y=70" >'+
  4448. '<area shape="circle" href="#" coords="146,121,3" title="X=-52, Y=57" >'+
  4449. '<area shape="circle" href="#" coords="346,313,3" title="X=48, Y=-39" >'+
  4450. '<area shape="circle" href="#" coords="310,339,3" title="X=30, Y=-52" >'+
  4451. '<area shape="circle" href="#" coords="274,265,3" title="X=12, Y=-15" >'+
  4452. '<area shape="circle" href="#" coords="360,95,3" title="X=55, Y=70" >'+
  4453. '<area shape="circle" href="#" coords="224,91,3" title="X=-13, Y=72" >'+
  4454. '<area shape="circle" href="#" coords="226,91,3" title="X=-12, Y=72" >'+
  4455. '<area shape="circle" href="#" coords="224,89,3" title="X=-13, Y=73" >'+
  4456. '<area shape="circle" href="#" coords="226,89,3" title="X=-12, Y=73" >'+
  4457. '<area shape="circle" href="#" coords="148,281,3" title="X=-51, Y=-23" >'+
  4458. '<area shape="circle" href="#" coords="150,281,3" title="X=-50, Y=-23" >'+
  4459. '<area shape="circle" href="#" coords="148,279,3" title="X=-51, Y=-22" >'+
  4460. '<area shape="circle" href="#" coords="150,279,3" title="X=-50, Y=-22" >'+
  4461. '<area shape="circle" href="#" coords="130,301,3" title="X=-60, Y=-33" >'+
  4462. '<area shape="circle" href="#" coords="132,301,3" title="X=-59, Y=-33" >'+
  4463. '<area shape="circle" href="#" coords="130,299,3" title="X=-60, Y=-32" >'+
  4464. '<area shape="circle" href="#" coords="132,299,3" title="X=-59, Y=-32" >'+
  4465. '<area shape="circle" href="#" coords="116,311,3" title="X=-67, Y=-38" >'+
  4466. '<area shape="circle" href="#" coords="118,311,3" title="X=-66, Y=-38" >'+
  4467. '<area shape="circle" href="#" coords="116,309,3" title="X=-67, Y=-37" >'+
  4468. '<area shape="circle" href="#" coords="118,309,3" title="X=-66, Y=-37" >'+
  4469. '<area shape="circle" href="#" coords="260,173,3" title="X=5, Y=31" >'+
  4470. '<area shape="circle" href="#" coords="262,173,3" title="X=6, Y=31" >'+
  4471. '<area shape="circle" href="#" coords="260,171,3" title="X=5, Y=32" >'+
  4472. '<area shape="circle" href="#" coords="262,171,3" title="X=6, Y=32" >'+
  4473. '<area shape="circle" href="#" coords="178,339,3" title="X=-36, Y=-52" >'+
  4474. '<area shape="circle" href="#" coords="180,339,3" title="X=-35, Y=-52" >'+
  4475. '<area shape="circle" href="#" coords="178,337,3" title="X=-36, Y=-51" >'+
  4476. '<area shape="circle" href="#" coords="180,337,3" title="X=-35, Y=-51" >'+
  4477. '<area shape="circle" href="#" coords="182,107,3" title="X=-34, Y=64" >'+
  4478. '<area shape="circle" href="#" coords="182,105,3" title="X=-34, Y=65" >'+
  4479. '<area shape="circle" href="#" coords="270,109,3" title="X=10, Y=63" >'+
  4480. '<area shape="circle" href="#" coords="272,109,3" title="X=11, Y=63" >'+
  4481. '<area shape="circle" href="#" coords="270,107,3" title="X=10, Y=64" >'+
  4482. '<area shape="circle" href="#" coords="272,107,3" title="X=11, Y=64" >'+
  4483. '<area shape="circle" href="#" coords="180,207,3" title="X=-35, Y=14" >'+
  4484. '<area shape="circle" href="#" coords="182,207,3" title="X=-34, Y=14" >'+
  4485. '<area shape="circle" href="#" coords="180,205,3" title="X=-35, Y=15" >'+
  4486. '<area shape="circle" href="#" coords="182,205,3" title="X=-34, Y=15" >'+
  4487. '<area shape="circle" href="#" coords="398,173,3" title="X=74, Y=31" >'+
  4488. '<area shape="circle" href="#" coords="400,173,3" title="X=75, Y=31" >'+
  4489. '<area shape="circle" href="#" coords="398,171,3" title="X=74, Y=32" >'+
  4490. '<area shape="circle" href="#" coords="400,171,3" title="X=75, Y=32" >'+
  4491. '<area shape="circle" href="#" coords="342,133,3" title="X=46, Y=51" >'+
  4492. '<area shape="circle" href="#" coords="344,133,3" title="X=47, Y=51" >'+
  4493. '<area shape="circle" href="#" coords="342,131,3" title="X=46, Y=52" >'+
  4494. '<area shape="circle" href="#" coords="344,131,3" title="X=47, Y=52" >'+
  4495. '<area shape="circle" href="#" coords="180,107,3" title="X=-35, Y=64" >'+
  4496. '<area shape="circle" href="#" coords="180,105,3" title="X=-35, Y=65" >'+
  4497. '<area shape="circle" href="#" coords="108,251,3" title="X=-71, Y=-8" >'+
  4498. '<area shape="circle" href="#" coords="110,251,3" title="X=-70, Y=-8" >'+
  4499. '<area shape="circle" href="#" coords="108,249,3" title="X=-71, Y=-7" >'+
  4500. '<area shape="circle" href="#" coords="110,249,3" title="X=-70, Y=-7" >'+
  4501. '<area shape="circle" href="#" coords="346,191,3" title="X=48, Y=22" >'+
  4502. '<area shape="circle" href="#" coords="346,189,3" title="X=48, Y=23" >'+
  4503. '<area shape="circle" href="#" coords="346,187,3" title="X=48, Y=24" >'+
  4504. '<area shape="circle" href="#" coords="346,185,3" title="X=48, Y=25" >'+
  4505. '<area shape="circle" href="#" coords="348,195,3" title="X=49, Y=20" >'+
  4506. '<area shape="circle" href="#" coords="348,193,3" title="X=49, Y=21" >'+
  4507. '<area shape="circle" href="#" coords="348,191,3" title="X=49, Y=22" >'+
  4508. '<area shape="circle" href="#" coords="348,189,3" title="X=49, Y=23" >'+
  4509. '<area shape="circle" href="#" coords="348,187,3" title="X=49, Y=24" >'+
  4510. '<area shape="circle" href="#" coords="348,185,3" title="X=49, Y=25" >'+
  4511. '<area shape="circle" href="#" coords="348,183,3" title="X=49, Y=26" >'+
  4512. '<area shape="circle" href="#" coords="348,181,3" title="X=49, Y=27" >'+
  4513. '<area shape="circle" href="#" coords="350,199,3" title="X=50, Y=18" >'+
  4514. '<area shape="circle" href="#" coords="350,197,3" title="X=50, Y=19" >'+
  4515. '<area shape="circle" href="#" coords="350,195,3" title="X=50, Y=20" >'+
  4516. '<area shape="circle" href="#" coords="350,193,3" title="X=50, Y=21" >'+
  4517. '<area shape="circle" href="#" coords="350,191,3" title="X=50, Y=22" >'+
  4518. '<area shape="circle" href="#" coords="350,189,3" title="X=50, Y=23" >'+
  4519. '<area shape="circle" href="#" coords="350,187,3" title="X=50, Y=24" >'+
  4520. '<area shape="circle" href="#" coords="350,185,3" title="X=50, Y=25" >'+
  4521. '<area shape="circle" href="#" coords="350,183,3" title="X=50, Y=26" >'+
  4522. '<area shape="circle" href="#" coords="350,181,3" title="X=50, Y=27" >'+
  4523. '<area shape="circle" href="#" coords="350,179,3" title="X=50, Y=28" >'+
  4524. '<area shape="circle" href="#" coords="350,177,3" title="X=50, Y=29" >'+
  4525. '<area shape="circle" href="#" coords="352,201,3" title="X=51, Y=17" >'+
  4526. '<area shape="circle" href="#" coords="352,199,3" title="X=51, Y=18" >'+
  4527. '<area shape="circle" href="#" coords="352,197,3" title="X=51, Y=19" >'+
  4528. '<area shape="circle" href="#" coords="352,195,3" title="X=51, Y=20" >'+
  4529. '<area shape="circle" href="#" coords="352,193,3" title="X=51, Y=21" >'+
  4530. '<area shape="circle" href="#" coords="352,191,3" title="X=51, Y=22" >'+
  4531. '<area shape="circle" href="#" coords="352,189,3" title="X=51, Y=23" >'+
  4532. '<area shape="circle" href="#" coords="352,187,3" title="X=51, Y=24" >'+
  4533. '<area shape="circle" href="#" coords="352,185,3" title="X=51, Y=25" >'+
  4534. '<area shape="circle" href="#" coords="352,183,3" title="X=51, Y=26" >'+
  4535. '<area shape="circle" href="#" coords="352,181,3" title="X=51, Y=27" >'+
  4536. '<area shape="circle" href="#" coords="352,179,3" title="X=51, Y=28" >'+
  4537. '<area shape="circle" href="#" coords="352,177,3" title="X=51, Y=29" >'+
  4538. '<area shape="circle" href="#" coords="352,175,3" title="X=51, Y=30" >'+
  4539. '<area shape="circle" href="#" coords="354,201,3" title="X=52, Y=17" >'+
  4540. '<area shape="circle" href="#" coords="354,199,3" title="X=52, Y=18" >'+
  4541. '<area shape="circle" href="#" coords="354,197,3" title="X=52, Y=19" >'+
  4542. '<area shape="circle" href="#" coords="354,195,3" title="X=52, Y=20" >'+
  4543. '<area shape="circle" href="#" coords="354,193,3" title="X=52, Y=21" >'+
  4544. '<area shape="circle" href="#" coords="354,191,3" title="X=52, Y=22" >'+
  4545. '<area shape="circle" href="#" coords="354,189,3" title="X=52, Y=23" >'+
  4546. '<area shape="circle" href="#" coords="354,187,3" title="X=52, Y=24" >'+
  4547. '<area shape="circle" href="#" coords="354,185,3" title="X=52, Y=25" >'+
  4548. '<area shape="circle" href="#" coords="354,183,3" title="X=52, Y=26" >'+
  4549. '<area shape="circle" href="#" coords="354,181,3" title="X=52, Y=27" >'+
  4550. '<area shape="circle" href="#" coords="354,179,3" title="X=52, Y=28" >'+
  4551. '<area shape="circle" href="#" coords="354,177,3" title="X=52, Y=29" >'+
  4552. '<area shape="circle" href="#" coords="354,175,3" title="X=52, Y=30" >'+
  4553. '<area shape="circle" href="#" coords="356,203,3" title="X=53, Y=16" >'+
  4554. '<area shape="circle" href="#" coords="356,201,3" title="X=53, Y=17" >'+
  4555. '<area shape="circle" href="#" coords="356,199,3" title="X=53, Y=18" >'+
  4556. '<area shape="circle" href="#" coords="356,197,3" title="X=53, Y=19" >'+
  4557. '<area shape="circle" href="#" coords="356,195,3" title="X=53, Y=20" >'+
  4558. '<area shape="circle" href="#" coords="356,193,3" title="X=53, Y=21" >'+
  4559. '<area shape="circle" href="#" coords="356,191,3" title="X=53, Y=22" >'+
  4560. '<area shape="circle" href="#" coords="356,189,3" title="X=53, Y=23" >'+
  4561. '<area shape="circle" href="#" coords="356,187,3" title="X=53, Y=24" >'+
  4562. '<area shape="circle" href="#" coords="356,185,3" title="X=53, Y=25" >'+
  4563. '<area shape="circle" href="#" coords="356,183,3" title="X=53, Y=26" >'+
  4564. '<area shape="circle" href="#" coords="356,181,3" title="X=53, Y=27" >'+
  4565. '<area shape="circle" href="#" coords="356,179,3" title="X=53, Y=28" >'+
  4566. '<area shape="circle" href="#" coords="356,177,3" title="X=53, Y=29" >'+
  4567. '<area shape="circle" href="#" coords="356,175,3" title="X=53, Y=30" >'+
  4568. '<area shape="circle" href="#" coords="356,173,3" title="X=53, Y=31" >'+
  4569. '<area shape="circle" href="#" coords="358,203,3" title="X=54, Y=16" >'+
  4570. '<area shape="circle" href="#" coords="358,201,3" title="X=54, Y=17" >'+
  4571. '<area shape="circle" href="#" coords="358,199,3" title="X=54, Y=18" >'+
  4572. '<area shape="circle" href="#" coords="358,197,3" title="X=54, Y=19" >'+
  4573. '<area shape="circle" href="#" coords="358,195,3" title="X=54, Y=20" >'+
  4574. '<area shape="circle" href="#" coords="358,193,3" title="X=54, Y=21" >'+
  4575. '<area shape="circle" href="#" coords="358,191,3" title="X=54, Y=22" >'+
  4576. '<area shape="circle" href="#" coords="358,189,3" title="X=54, Y=23" >'+
  4577. '<area shape="circle" href="#" coords="358,187,3" title="X=54, Y=24" >'+
  4578. '<area shape="circle" href="#" coords="358,185,3" title="X=54, Y=25" >'+
  4579. '<area shape="circle" href="#" coords="358,183,3" title="X=54, Y=26" >'+
  4580. '<area shape="circle" href="#" coords="358,181,3" title="X=54, Y=27" >'+
  4581. '<area shape="circle" href="#" coords="358,179,3" title="X=54, Y=28" >'+
  4582. '<area shape="circle" href="#" coords="358,177,3" title="X=54, Y=29" >'+
  4583. '<area shape="circle" href="#" coords="358,175,3" title="X=54, Y=30" >'+
  4584. '<area shape="circle" href="#" coords="358,173,3" title="X=54, Y=31" >'+
  4585. '<area shape="circle" href="#" coords="360,205,3" title="X=55, Y=15" >'+
  4586. '<area shape="circle" href="#" coords="360,203,3" title="X=55, Y=16" >'+
  4587. '<area shape="circle" href="#" coords="360,201,3" title="X=55, Y=17" >'+
  4588. '<area shape="circle" href="#" coords="360,199,3" title="X=55, Y=18" >'+
  4589. '<area shape="circle" href="#" coords="360,197,3" title="X=55, Y=19" >'+
  4590. '<area shape="circle" href="#" coords="360,195,3" title="X=55, Y=20" >'+
  4591. '<area shape="circle" href="#" coords="360,193,3" title="X=55, Y=21" >'+
  4592. '<area shape="circle" href="#" coords="360,191,3" title="X=55, Y=22" >'+
  4593. '<area shape="circle" href="#" coords="360,189,3" title="X=55, Y=23" >'+
  4594. '<area shape="circle" href="#" coords="360,187,3" title="X=55, Y=24" >'+
  4595. '<area shape="circle" href="#" coords="360,185,3" title="X=55, Y=25" >'+
  4596. '<area shape="circle" href="#" coords="360,183,3" title="X=55, Y=26" >'+
  4597. '<area shape="circle" href="#" coords="360,181,3" title="X=55, Y=27" >'+
  4598. '<area shape="circle" href="#" coords="360,179,3" title="X=55, Y=28" >'+
  4599. '<area shape="circle" href="#" coords="360,177,3" title="X=55, Y=29" >'+
  4600. '<area shape="circle" href="#" coords="360,175,3" title="X=55, Y=30" >'+
  4601. '<area shape="circle" href="#" coords="360,173,3" title="X=55, Y=31" >'+
  4602. '<area shape="circle" href="#" coords="360,171,3" title="X=55, Y=32" >'+
  4603. '<area shape="circle" href="#" coords="362,205,3" title="X=56, Y=15" >'+
  4604. '<area shape="circle" href="#" coords="362,203,3" title="X=56, Y=16" >'+
  4605. '<area shape="circle" href="#" coords="362,201,3" title="X=56, Y=17" >'+
  4606. '<area shape="circle" href="#" coords="362,199,3" title="X=56, Y=18" >'+
  4607. '<area shape="circle" href="#" coords="362,197,3" title="X=56, Y=19" >'+
  4608. '<area shape="circle" href="#" coords="362,195,3" title="X=56, Y=20" >'+
  4609. '<area shape="circle" href="#" coords="362,193,3" title="X=56, Y=21" >'+
  4610. '<area shape="circle" href="#" coords="362,191,3" title="X=56, Y=22" >'+
  4611. '<area shape="circle" href="#" coords="362,189,3" title="X=56, Y=23" >'+
  4612. '<area shape="circle" href="#" coords="362,187,3" title="X=56, Y=24" >'+
  4613. '<area shape="circle" href="#" coords="362,185,3" title="X=56, Y=25" >'+
  4614. '<area shape="circle" href="#" coords="362,183,3" title="X=56, Y=26" >'+
  4615. '<area shape="circle" href="#" coords="362,181,3" title="X=56, Y=27" >'+
  4616. '<area shape="circle" href="#" coords="362,179,3" title="X=56, Y=28" >'+
  4617. '<area shape="circle" href="#" coords="362,177,3" title="X=56, Y=29" >'+
  4618. '<area shape="circle" href="#" coords="362,175,3" title="X=56, Y=30" >'+
  4619. '<area shape="circle" href="#" coords="362,173,3" title="X=56, Y=31" >'+
  4620. '<area shape="circle" href="#" coords="362,171,3" title="X=56, Y=32" >'+
  4621. '<area shape="circle" href="#" coords="364,205,3" title="X=57, Y=15" >'+
  4622. '<area shape="circle" href="#" coords="364,203,3" title="X=57, Y=16" >'+
  4623. '<area shape="circle" href="#" coords="364,201,3" title="X=57, Y=17" >'+
  4624. '<area shape="circle" href="#" coords="364,199,3" title="X=57, Y=18" >'+
  4625. '<area shape="circle" href="#" coords="364,197,3" title="X=57, Y=19" >'+
  4626. '<area shape="circle" href="#" coords="364,195,3" title="X=57, Y=20" >'+
  4627. '<area shape="circle" href="#" coords="364,193,3" title="X=57, Y=21" >'+
  4628. '<area shape="circle" href="#" coords="364,191,3" title="X=57, Y=22" >'+
  4629. '<area shape="circle" href="#" coords="364,189,3" title="X=57, Y=23" >'+
  4630. '<area shape="circle" href="#" coords="364,187,3" title="X=57, Y=24" >'+
  4631. '<area shape="circle" href="#" coords="364,185,3" title="X=57, Y=25" >'+
  4632. '<area shape="circle" href="#" coords="364,183,3" title="X=57, Y=26" >'+
  4633. '<area shape="circle" href="#" coords="364,181,3" title="X=57, Y=27" >'+
  4634. '<area shape="circle" href="#" coords="364,179,3" title="X=57, Y=28" >'+
  4635. '<area shape="circle" href="#" coords="364,177,3" title="X=57, Y=29" >'+
  4636. '<area shape="circle" href="#" coords="364,175,3" title="X=57, Y=30" >'+
  4637. '<area shape="circle" href="#" coords="364,173,3" title="X=57, Y=31" >'+
  4638. '<area shape="circle" href="#" coords="364,171,3" title="X=57, Y=32" >'+
  4639. '<area shape="circle" href="#" coords="366,205,3" title="X=58, Y=15" >'+
  4640. '<area shape="circle" href="#" coords="366,203,3" title="X=58, Y=16" >'+
  4641. '<area shape="circle" href="#" coords="366,201,3" title="X=58, Y=17" >'+
  4642. '<area shape="circle" href="#" coords="366,199,3" title="X=58, Y=18" >'+
  4643. '<area shape="circle" href="#" coords="366,197,3" title="X=58, Y=19" >'+
  4644. '<area shape="circle" href="#" coords="366,195,3" title="X=58, Y=20" >'+
  4645. '<area shape="circle" href="#" coords="366,193,3" title="X=58, Y=21" >'+
  4646. '<area shape="circle" href="#" coords="366,191,3" title="X=58, Y=22" >'+
  4647. '<area shape="circle" href="#" coords="366,189,3" title="X=58, Y=23" >'+
  4648. '<area shape="circle" href="#" coords="366,187,3" title="X=58, Y=24" >'+
  4649. '<area shape="circle" href="#" coords="366,185,3" title="X=58, Y=25" >'+
  4650. '<area shape="circle" href="#" coords="366,183,3" title="X=58, Y=26" >'+
  4651. '<area shape="circle" href="#" coords="366,181,3" title="X=58, Y=27" >'+
  4652. '<area shape="circle" href="#" coords="366,179,3" title="X=58, Y=28" >'+
  4653. '<area shape="circle" href="#" coords="366,177,3" title="X=58, Y=29" >'+
  4654. '<area shape="circle" href="#" coords="366,175,3" title="X=58, Y=30" >'+
  4655. '<area shape="circle" href="#" coords="366,173,3" title="X=58, Y=31" >'+
  4656. '<area shape="circle" href="#" coords="366,171,3" title="X=58, Y=32" >'+
  4657. '<area shape="circle" href="#" coords="368,203,3" title="X=59, Y=16" >'+
  4658. '<area shape="circle" href="#" coords="368,201,3" title="X=59, Y=17" >'+
  4659. '<area shape="circle" href="#" coords="368,199,3" title="X=59, Y=18" >'+
  4660. '<area shape="circle" href="#" coords="368,197,3" title="X=59, Y=19" >'+
  4661. '<area shape="circle" href="#" coords="368,195,3" title="X=59, Y=20" >'+
  4662. '<area shape="circle" href="#" coords="368,193,3" title="X=59, Y=21" >'+
  4663. '<area shape="circle" href="#" coords="368,191,3" title="X=59, Y=22" >'+
  4664. '<area shape="circle" href="#" coords="368,189,3" title="X=59, Y=23" >'+
  4665. '<area shape="circle" href="#" coords="368,187,3" title="X=59, Y=24" >'+
  4666. '<area shape="circle" href="#" coords="368,185,3" title="X=59, Y=25" >'+
  4667. '<area shape="circle" href="#" coords="368,183,3" title="X=59, Y=26" >'+
  4668. '<area shape="circle" href="#" coords="368,181,3" title="X=59, Y=27" >'+
  4669. '<area shape="circle" href="#" coords="368,179,3" title="X=59, Y=28" >'+
  4670. '<area shape="circle" href="#" coords="368,177,3" title="X=59, Y=29" >'+
  4671. '<area shape="circle" href="#" coords="368,175,3" title="X=59, Y=30" >'+
  4672. '<area shape="circle" href="#" coords="368,173,3" title="X=59, Y=31" >'+
  4673. '<area shape="circle" href="#" coords="370,203,3" title="X=60, Y=16" >'+
  4674. '<area shape="circle" href="#" coords="370,201,3" title="X=60, Y=17" >'+
  4675. '<area shape="circle" href="#" coords="370,199,3" title="X=60, Y=18" >'+
  4676. '<area shape="circle" href="#" coords="370,197,3" title="X=60, Y=19" >'+
  4677. '<area shape="circle" href="#" coords="370,195,3" title="X=60, Y=20" >'+
  4678. '<area shape="circle" href="#" coords="370,193,3" title="X=60, Y=21" >'+
  4679. '<area shape="circle" href="#" coords="370,191,3" title="X=60, Y=22" >'+
  4680. '<area shape="circle" href="#" coords="370,189,3" title="X=60, Y=23" >'+
  4681. '<area shape="circle" href="#" coords="370,187,3" title="X=60, Y=24" >'+
  4682. '<area shape="circle" href="#" coords="370,185,3" title="X=60, Y=25" >'+
  4683. '<area shape="circle" href="#" coords="370,183,3" title="X=60, Y=26" >'+
  4684. '<area shape="circle" href="#" coords="370,181,3" title="X=60, Y=27" >'+
  4685. '<area shape="circle" href="#" coords="370,179,3" title="X=60, Y=28" >'+
  4686. '<area shape="circle" href="#" coords="370,177,3" title="X=60, Y=29" >'+
  4687. '<area shape="circle" href="#" coords="370,175,3" title="X=60, Y=30" >'+
  4688. '<area shape="circle" href="#" coords="370,173,3" title="X=60, Y=31" >'+
  4689. '<area shape="circle" href="#" coords="372,201,3" title="X=61, Y=17" >'+
  4690. '<area shape="circle" href="#" coords="372,199,3" title="X=61, Y=18" >'+
  4691. '<area shape="circle" href="#" coords="372,197,3" title="X=61, Y=19" >'+
  4692. '<area shape="circle" href="#" coords="372,195,3" title="X=61, Y=20" >'+
  4693. '<area shape="circle" href="#" coords="372,193,3" title="X=61, Y=21" >'+
  4694. '<area shape="circle" href="#" coords="372,191,3" title="X=61, Y=22" >'+
  4695. '<area shape="circle" href="#" coords="372,189,3" title="X=61, Y=23" >'+
  4696. '<area shape="circle" href="#" coords="372,187,3" title="X=61, Y=24" >'+
  4697. '<area shape="circle" href="#" coords="372,185,3" title="X=61, Y=25" >'+
  4698. '<area shape="circle" href="#" coords="372,183,3" title="X=61, Y=26" >'+
  4699. '<area shape="circle" href="#" coords="372,181,3" title="X=61, Y=27" >'+
  4700. '<area shape="circle" href="#" coords="372,179,3" title="X=61, Y=28" >'+
  4701. '<area shape="circle" href="#" coords="372,177,3" title="X=61, Y=29" >'+
  4702. '<area shape="circle" href="#" coords="372,175,3" title="X=61, Y=30" >'+
  4703. '<area shape="circle" href="#" coords="374,201,3" title="X=62, Y=17" >'+
  4704. '<area shape="circle" href="#" coords="374,199,3" title="X=62, Y=18" >'+
  4705. '<area shape="circle" href="#" coords="374,197,3" title="X=62, Y=19" >'+
  4706. '<area shape="circle" href="#" coords="374,195,3" title="X=62, Y=20" >'+
  4707. '<area shape="circle" href="#" coords="374,193,3" title="X=62, Y=21" >'+
  4708. '<area shape="circle" href="#" coords="374,191,3" title="X=62, Y=22" >'+
  4709. '<area shape="circle" href="#" coords="374,189,3" title="X=62, Y=23" >'+
  4710. '<area shape="circle" href="#" coords="374,187,3" title="X=62, Y=24" >'+
  4711. '<area shape="circle" href="#" coords="374,185,3" title="X=62, Y=25" >'+
  4712. '<area shape="circle" href="#" coords="374,183,3" title="X=62, Y=26" >'+
  4713. '<area shape="circle" href="#" coords="374,181,3" title="X=62, Y=27" >'+
  4714. '<area shape="circle" href="#" coords="374,179,3" title="X=62, Y=28" >'+
  4715. '<area shape="circle" href="#" coords="374,177,3" title="X=62, Y=29" >'+
  4716. '<area shape="circle" href="#" coords="374,175,3" title="X=62, Y=30" >'+
  4717. '<area shape="circle" href="#" coords="376,199,3" title="X=63, Y=18" >'+
  4718. '<area shape="circle" href="#" coords="376,197,3" title="X=63, Y=19" >'+
  4719. '<area shape="circle" href="#" coords="376,195,3" title="X=63, Y=20" >'+
  4720. '<area shape="circle" href="#" coords="376,193,3" title="X=63, Y=21" >'+
  4721. '<area shape="circle" href="#" coords="376,191,3" title="X=63, Y=22" >'+
  4722. '<area shape="circle" href="#" coords="376,189,3" title="X=63, Y=23" >'+
  4723. '<area shape="circle" href="#" coords="376,187,3" title="X=63, Y=24" >'+
  4724. '<area shape="circle" href="#" coords="376,185,3" title="X=63, Y=25" >'+
  4725. '<area shape="circle" href="#" coords="376,183,3" title="X=63, Y=26" >'+
  4726. '<area shape="circle" href="#" coords="376,181,3" title="X=63, Y=27" >'+
  4727. '<area shape="circle" href="#" coords="376,179,3" title="X=63, Y=28" >'+
  4728. '<area shape="circle" href="#" coords="376,177,3" title="X=63, Y=29" >'+
  4729. '<area shape="circle" href="#" coords="378,195,3" title="X=64, Y=20" >'+
  4730. '<area shape="circle" href="#" coords="378,193,3" title="X=64, Y=21" >'+
  4731. '<area shape="circle" href="#" coords="378,191,3" title="X=64, Y=22" >'+
  4732. '<area shape="circle" href="#" coords="378,189,3" title="X=64, Y=23" >'+
  4733. '<area shape="circle" href="#" coords="378,187,3" title="X=64, Y=24" >'+
  4734. '<area shape="circle" href="#" coords="378,185,3" title="X=64, Y=25" >'+
  4735. '<area shape="circle" href="#" coords="378,183,3" title="X=64, Y=26" >'+
  4736. '<area shape="circle" href="#" coords="378,181,3" title="X=64, Y=27" >'+
  4737. '<area shape="circle" href="#" coords="380,191,3" title="X=65, Y=22" >'+
  4738. '<area shape="circle" href="#" coords="380,189,3" title="X=65, Y=23" >'+
  4739. '<area shape="circle" href="#" coords="380,187,3" title="X=65, Y=24" >'+
  4740. '<area shape="circle" href="#" coords="380,185,3" title="X=65, Y=25" >'+
  4741. '</map>';
  4742.  
  4743. var nvspan = document.createElement('div');
  4744. nvspan.align = 'center';
  4745. nvspan.id = 'mz_mapdiv';
  4746. nvspan.valign = 'top';
  4747. nvspan.innerHTML = nvdiv;
  4748. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4749. var footer = document.getElementById('footer1');
  4750. footer.parentNode.insertBefore(nvspan,footer);
  4751. }
  4752.  
  4753. function testeGlissiere() {
  4754. try {
  4755. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4756. var footer = document.getElementById('footer1');
  4757. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4758. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4759. }
  4760.  
  4761. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4762. if (x0 !== undefined) {
  4763. // ouais, récursif une fois
  4764. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4765. if (PtInterm === undefined)
  4766. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4767. else
  4768. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4769. return;
  4770. }
  4771. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4772. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4773. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4774. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4775. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4776. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4777. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4778. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4779. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4780. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4781. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4782. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4783. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4784. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4785. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4786. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4787. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4788. }
  4789.  
  4790. function do_ordresgowap() {
  4791. if (newCarte) {
  4792. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4793. //testeGlissiere();
  4794. //MZ_testsUnitairesCalculIntermediaire();
  4795. } else {
  4796. setCarteGogo(); // Via script des trouillots
  4797. }
  4798. }
  4799.  
  4800. function do_listegowap() {
  4801. if (!newCarte) return;
  4802. MZ_setCarteTousGogoHTML5();
  4803. }
  4804.  
  4805. function do_lieuDescription() {
  4806. if (!newCarte) return;
  4807. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4808. MZ_setCarteTP();
  4809. }
  4810.  
  4811. function do_lieuTeleport() {
  4812. changeButtonValidate();
  4813. if (!newCarte) return;
  4814. MZ_setCarteTP();
  4815. }
  4816.  
  4817. /*********************************************************************************
  4818. * This file is part of Mountyzilla. *
  4819. * *
  4820. * Mountyzilla is free software; you can redistribute it and/or modify *
  4821. * it under the terms of the GNU General Public License as published by *
  4822. * the Free Software Foundation; either version 2 of the License, or *
  4823. * (at your option) any later version. *
  4824. * *
  4825. * Mountyzilla is distributed in the hope that it will be useful, *
  4826. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4827. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4828. * GNU General Public License for more details. *
  4829. * *
  4830. * You should have received a copy of the GNU General Public License *
  4831. * along with Mountyzilla; if not, write to the Free Software *
  4832. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4833. *********************************************************************************/
  4834.  
  4835. // x~x attaque
  4836.  
  4837. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4838.  
  4839. function do_attaque() {
  4840. }
  4841.  
  4842. /*******************************************************************************
  4843. * This file is part of Mountyzilla. *
  4844. * *
  4845. * Mountyzilla is free software; you can redistribute it and/or modify *
  4846. * it under the terms of the GNU General Public License as published by *
  4847. * the Free Software Foundation; either version 2 of the License, or *
  4848. * (at your option) any later version. *
  4849. * *
  4850. * Mountyzilla is distributed in the hope that it will be useful, *
  4851. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4852. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4853. * GNU General Public License for more details. *
  4854. * *
  4855. * You should have received a copy of the GNU General Public License *
  4856. * along with Mountyzilla; if not, write to the Free Software *
  4857. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4858. *******************************************************************************/
  4859.  
  4860. // x~x infomonstre
  4861.  
  4862. // DEBUG
  4863. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4864. // À corriger, évidemment.
  4865. var listeCDM = {};
  4866. var nomMonstre='';
  4867. var idMonstre=-1;
  4868. var tbody;
  4869. var popup;
  4870.  
  4871. function traiteMonstre() {
  4872. try {
  4873. var nodeTitre = document.evaluate(
  4874. "//div[@class='titre2' and contains(text(),'(')]",
  4875. document, null, 9, null
  4876. ).singleNodeValue;
  4877. var texte = nodeTitre.firstChild.nodeValue;
  4878. } catch(e) {
  4879. window.console.log(traceStack(e, 'traiteMonstre'));
  4880. return;
  4881. }
  4882. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4883. if(nomMonstre.indexOf(']')!=-1) {
  4884. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4885. }
  4886. idMonstre = texte.match(/\d+/)[0];
  4887. FF_XMLHttpRequest({
  4888. method: 'GET',
  4889. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4890. +MY_getValue('CDMID')
  4891. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4892. headers : {
  4893. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4894. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4895. },
  4896. trace: 'info monstre ' + nomMonstre,
  4897. onload: function(responseDetails) {
  4898. try {
  4899. var texte = responseDetails.responseText;
  4900. var lines = texte.split("\n");
  4901. if(lines.length>=1) {
  4902. var infos = lines[0].split(";");
  4903. if(infos.length<4) { return; }
  4904. var idMonstre = infos[0];
  4905. infos=infos.slice(3);
  4906. listeCDM[idMonstre]=infos;
  4907. computeMissionInfomonstre();
  4908. }
  4909. } catch(e) {
  4910. window.alert(e);
  4911. }
  4912. }
  4913. });
  4914. }
  4915.  
  4916. function initPopupInfomonstre() {
  4917. // Initialise le popup tactique (calculs att/deg)
  4918. popup = document.createElement('div');
  4919. popup.id = 'popup';
  4920. popup.className = 'mh_textbox';
  4921. popup.style =
  4922. 'position: absolute;'+
  4923. 'border: 1px solid #000000;'+
  4924. 'visibility: hidden;'+
  4925. 'display: inline;'+
  4926. 'z-index: 3;'+
  4927. 'max-width: 400px;';
  4928. document.body.appendChild(popup);
  4929. }
  4930.  
  4931. function showPopupTactique(evt) {
  4932. try {
  4933. var id = this.id;
  4934. var nom = this.nom;
  4935. var texte = getAnalyseTactique(id,nom);
  4936. if(texte=='') { return; }
  4937. popup.innerHTML = texte;
  4938. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4939. if(isPage("View/MonsterView")) {
  4940. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4941. } else {
  4942. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4943. }
  4944. popup.style.top = evt.pageY+15+'px';
  4945. popup.style.visibility = 'visible';
  4946. } catch(e) {
  4947. window.alert(e);
  4948. }
  4949. }
  4950.  
  4951. // roule 16/03/2016, existe déjà ailleurs
  4952. // function hidePopup() {
  4953. // popup.style.visibility = 'hidden';
  4954. // }
  4955.  
  4956. function toggleTableau() {
  4957. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4958. }
  4959.  
  4960. function computeMissionInfomonstre() {
  4961. // C'est quoi ce titre de fonction ? (O_o)
  4962. try {
  4963. var nodeInsert = document.evaluate(
  4964. "//div[@class = 'titre3']",
  4965. document, null, 9, null
  4966. ).singleNodeValue;
  4967. } catch(e) {
  4968. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4969. return;
  4970. }
  4971. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4972. table.align = 'center';
  4973. tbody = table.childNodes[1];
  4974. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4975. table.firstChild.firstChild.onmouseover = function() {
  4976. this.style.cursor = 'pointer';
  4977. this.className = 'mh_tdpage';
  4978. };
  4979. table.firstChild.firstChild.onmouseout = function() {
  4980. this.className = 'mh_tdtitre';
  4981. };
  4982. tbody.style.display = 'none';
  4983. table.style.width = '350px';
  4984. insertBefore(nodeInsert,table);
  4985. }
  4986.  
  4987. function do_infomonstre() {
  4988. start_script();
  4989. try {
  4990. initPopupInfomonstre();
  4991. traiteMonstre();
  4992. } catch(e) {
  4993. window.alert('Erreur infoMonstre:\n'+e);
  4994. }
  4995. displayScriptTime();
  4996. }
  4997.  
  4998. /*******************************************************************************
  4999. * This file is part of Mountyzilla. *
  5000. * *
  5001. * Mountyzilla is free software; you can redistribute it and/or modify *
  5002. * it under the terms of the GNU General Public License as published by *
  5003. * the Free Software Foundation; either version 2 of the License, or *
  5004. * (at your option) any later version. *
  5005. * *
  5006. * Mountyzilla is distributed in the hope that it will be useful, *
  5007. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5008. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5009. * GNU General Public License for more details. *
  5010. * *
  5011. * You should have received a copy of the GNU General Public License *
  5012. * along with Mountyzilla; if not, write to the Free Software *
  5013. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5014. *******************************************************************************/
  5015.  
  5016. // x~x mission
  5017.  
  5018. /* TODO
  5019. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  5020. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  5021. *
  5022. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  5023. */
  5024. function isArray(a) {
  5025. return (!!a) && (a.constructor === Array);
  5026. }
  5027.  
  5028. function saveMission(num,obEtape) {
  5029. var obMissions;
  5030. if(MY_getValue(numTroll+'.MISSIONS')) {
  5031. try {
  5032. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5033. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  5034. } catch(e) {
  5035. window.console.error(traceStack(e, 'Mission parsage'));
  5036. return;
  5037. }
  5038. }
  5039. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  5040. if (obMissions == undefined) obMissions = new Object(); // protection
  5041. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  5042. if(obEtape) {
  5043. obMissions[num] = obEtape;
  5044. } else if(obMissions[num]) {
  5045. delete obMissions[num];
  5046. }
  5047. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  5048. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5049. }
  5050.  
  5051. function addtroogle(tdLibelle, sRestrict) {
  5052. var img = document.createElement('img');
  5053. img.src = URL_MZimg + 'troogle.ico';
  5054. img.alt = 'Troogle logo';
  5055. var a = document.createElement('a');
  5056. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  5057. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  5058. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  5059. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  5060. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  5061. a.href = url;
  5062. a.title = 'Chercher sur Troogle';
  5063. a.target = 'troogle';
  5064. a.appendChild(img);
  5065. tdLibelle.appendChild(a);
  5066. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  5067. }
  5068.  
  5069. function traiteMission() {
  5070. try {
  5071. var titreMission = document.getElementsByClassName('titre2')[0];
  5072. var numMission = titreMission.textContent.match(/\d+/)[0];
  5073. var missionForm = document.getElementsByName('ActionForm')[0];
  5074. var tdLibelle = document.evaluate(
  5075. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  5076. missionForm, null, 9, null).singleNodeValue;
  5077. } catch(e) {
  5078. window.console.error(traceStack(e, 'récupération mission'));
  5079. return;
  5080. }
  5081. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  5082. try {
  5083. if(!tdLibelle) {
  5084. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  5085. debugMZ('traiteMission, la mission semble terminée');
  5086. saveMission(numMission,false);
  5087. return;
  5088. }
  5089.  
  5090. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  5091. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  5092. // debug Roule'
  5093. if (MY_DEBUG) {
  5094. for (var i =0; i < tdLibelle.childNodes.length; i++)
  5095. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  5096. }
  5097. if(libelle.indexOf('niveau égal à')!=-1) {
  5098. var nbKills = 1, niveau, mod;
  5099. // exemples :
  5100. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  5101. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  5102. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  5103. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  5104. if (tdLibelle.childNodes.length == 1) {
  5105. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  5106. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  5107. if (m) {
  5108. niveau = Number(m[1]);
  5109. mod = 'plus'
  5110. } else {
  5111. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  5112. if (m) {
  5113. niveau = Number(m[1]);
  5114. mod = Number(m[2]);
  5115. } else {
  5116. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  5117. return;
  5118. }
  5119. }
  5120. } else {
  5121. // ancienne méthode (multi childnode)
  5122. // à supprimer un jour peut-être
  5123. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  5124. // Étape de kill multiple de niveau donné
  5125. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5126. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  5127. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5128. niveau = Number(mod[0]);
  5129. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5130. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  5131. } else {
  5132. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  5133. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5134. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  5135. mod = mod ? Number(mod[0]) : 'plus';
  5136. }
  5137. } else {
  5138. // Étape de kill unique de niveau donné
  5139. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  5140. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5141. mod = mod ? Number(mod[0]) : 'plus';
  5142. }
  5143. }
  5144. // debug Roule'
  5145. if (MY_DEBUG) {
  5146. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  5147. }
  5148. saveMission(numMission,{
  5149. type: 'Niveau',
  5150. niveau: niveau,
  5151. mod: mod,
  5152. mundidey: siMundidey,
  5153. libelle: libelle
  5154. });
  5155. if (mod == 'plus')
  5156. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  5157. else
  5158. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  5159. } else if(libelle.indexOf('de la race')!=-1) {
  5160. var nbKills = 1, race;
  5161. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  5162. // Étape de kill multiple de race donnée
  5163. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5164. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5165. } else {
  5166. // Étape de kill unique de race donnée
  5167. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5168. }
  5169. race = race.replace(/\"/g,'');
  5170. saveMission(numMission,{
  5171. type: 'Race',
  5172. race: race,
  5173. mundidey: siMundidey,
  5174. libelle: libelle
  5175. });
  5176. addtroogle(tdLibelle, '@monstre ' + race);
  5177. } else if(libelle.indexOf('de la famille')!=-1) {
  5178. var nbKills = 1, famille;
  5179. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  5180. // Étape de kill multiple de famille donnée
  5181. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5182. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5183. } else {
  5184. // Étape de kill unique de famille donnée
  5185. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5186. }
  5187. famille = famille.replace(/\"/g,'');
  5188. saveMission(numMission,{
  5189. type: 'Famille',
  5190. famille: famille,
  5191. mundidey: siMundidey,
  5192. libelle: libelle
  5193. });
  5194. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  5195. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  5196. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  5197. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  5198. debugMZ('traiteMission étape capacité spéciale');
  5199. saveMission(numMission,{
  5200. type: 'Pouvoir',
  5201. pouvoir: pouvoir,
  5202. libelle: libelle
  5203. });
  5204. } else {
  5205. debugMZ('traiteMission étape pas pour troogle');
  5206. saveMission(numMission,false);
  5207. }
  5208. } catch(e) {
  5209. window.console.error(traceStack(e, 'récupération étape mission'));
  5210. return;
  5211. }
  5212. }
  5213.  
  5214. function do_mission() {
  5215. start_script(60);
  5216.  
  5217. traiteMission();
  5218.  
  5219. displayScriptTime();
  5220. }
  5221.  
  5222. /*******************************************************************************
  5223. * This file is part of Mountyzilla. *
  5224. * *
  5225. * Mountyzilla is free software; you can redistribute it and/or modify *
  5226. * it under the terms of the GNU General Public License as published by *
  5227. * the Free Software Foundation; either version 2 of the License, or *
  5228. * (at your option) any later version. *
  5229. * *
  5230. * Mountyzilla is distributed in the hope that it will be useful, *
  5231. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5232. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5233. * GNU General Public License for more details. *
  5234. * *
  5235. * You should have received a copy of the GNU General Public License *
  5236. * along with Mountyzilla; if not, write to the Free Software *
  5237. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5238. *******************************************************************************/
  5239.  
  5240. // x~x move
  5241.  
  5242. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  5243.  
  5244. var petitsTrous = {
  5245. '-52;57': true,
  5246. '55;70': true,
  5247. '64;70': true,
  5248. '12;-15': true,
  5249. '30;-52': true,
  5250. '48;-39': true
  5251. };
  5252.  
  5253. var grosTrous = {
  5254. '-35;65': true,
  5255. '-13;73': true,
  5256. '-64;9': true,
  5257. '-35;15': true,
  5258. '5;32': true,
  5259. '10;64': true,
  5260. '21;36': true,
  5261. '46;52': true,
  5262. '74;32': true,
  5263. '-71;-7': true,
  5264. '-67;-37': true,
  5265. '-60;-32': true,
  5266. '-51;-22': true,
  5267. '-36;-51': true,
  5268. '5;-49': true
  5269. };
  5270.  
  5271. var centreCarmine_X = 56.5;
  5272. var centreCarmine_Y = 23.5;
  5273. var rayonCarmine = 8.7;
  5274.  
  5275. function isTrou(x,y,n) {
  5276. if(petitsTrous[x+';'+y]) {
  5277. return n<0 && n>-60;
  5278. }
  5279. if(grosTrous[x+';'+y]
  5280. || grosTrous[x-1+';'+y]
  5281. || grosTrous[x+';'+y+1]
  5282. || grosTrous[x-1+';'+y+1]) {
  5283. return n<0 && n>-70;
  5284. }
  5285. if(Math.sqrt(
  5286. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  5287. )<=rayonCarmine) {
  5288. return n<0 && n>-100;
  5289. }
  5290. return false;
  5291. }
  5292.  
  5293. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  5294.  
  5295. function validateDestination() {
  5296. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  5297. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  5298. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  5299. var form = document.getElementsByName('ActionForm')[0];
  5300. if(form) {
  5301. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  5302. if(document.getElementsByName('ai_DeplX')[i].checked) {
  5303. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  5304. }
  5305. }
  5306. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  5307. if(document.getElementsByName('ai_DeplY')[i].checked) {
  5308. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  5309. }
  5310. }
  5311. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  5312. if(document.getElementsByName('ai_DeplN')[i].checked) {
  5313. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  5314. }
  5315. }
  5316. if(isTrou(x,y,n)) {
  5317. return window.confirm(
  5318. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5319. +'Vous allez tomber dans un trou de météorite.\n'
  5320. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  5321. );
  5322. }
  5323. }
  5324. return true;
  5325. }
  5326.  
  5327. function newsubmitDE(event) {
  5328. event.stopPropagation();
  5329. event.preventDefault();
  5330. if(validateDestination()) {
  5331. this.submit();
  5332. }
  5333. }
  5334.  
  5335. function changeValidation() {
  5336. var form = document.getElementsByName('ActionForm')[0];
  5337. if(form) {
  5338. form.addEventListener('submit', newsubmitDE, true);
  5339. }
  5340. }
  5341.  
  5342.  
  5343. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  5344.  
  5345. function validateTPDestination() {
  5346. try {
  5347. var text = document.getElementsByTagName('B')[0];
  5348. var a = text.firstChild.nodeValue.split('|');
  5349. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  5350. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  5351. var pos_n = a[2].substring(5, a[2].length) * 1;
  5352.  
  5353. var nbtrous = 0;
  5354. for(var signX=-1 ; signX<=1 ; signX+=2) {
  5355. for(var x=0 ; x<=2 ; x++) {
  5356. for(var signY=-1 ; signY<=1 ; signY+=2) {
  5357. for(var y=0 ; y<=2 ; y++) {
  5358. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  5359. for(var n = 0 ; n <= 1 ; n++) {
  5360. if(isTrou(
  5361. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  5362. )) {
  5363. nbtrous++;
  5364. }
  5365. }
  5366. }
  5367. }
  5368. }
  5369. }
  5370. }
  5371. if(nbtrous>0 && nbtrous<72) {
  5372. return window.confirm(
  5373. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5374. +'Vous avez '+Math.floor((100*nbtrous)/144)
  5375. +'% de risque de tomber dans un trou de météorite.\n'
  5376. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  5377. );
  5378. }
  5379. else if(nbtrous>=72) {
  5380. return window.confirm(
  5381. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  5382. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  5383. +'% de risque de tomber dans un trou de météorite !\n'
  5384. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  5385. );
  5386. }
  5387. return true;
  5388. }
  5389. catch(e) {
  5390. window.alert(e)
  5391. }
  5392. }
  5393.  
  5394. function newsubmitTP(event) {
  5395. event.stopPropagation();
  5396. event.preventDefault();
  5397. if(validateTPDestination()) {
  5398. this.submit();
  5399. }
  5400. }
  5401.  
  5402. function changeButtonValidate() {
  5403. var form = document.getElementsByName('Formulaire')[0];
  5404. if(form) {
  5405. if(!form.getAttribute('onsubmit')) {
  5406. form.setAttribute('onsubmit','return true;');
  5407. }
  5408. form.addEventListener('submit', newsubmitTP, true);
  5409. }
  5410. }
  5411.  
  5412.  
  5413. /*-[functions]---------------- Partie Principale -----------------------------*/
  5414.  
  5415. function do_move() {
  5416. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  5417. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  5418. changeValidation();
  5419. //}
  5420. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  5421. // changeButtonValidate();
  5422. //}
  5423. }
  5424.  
  5425. /*******************************************************************************
  5426. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  5427. * Mountyzilla is free software; provided under the GNU General Public License *
  5428. *******************************************************************************/
  5429.  
  5430. // x~x news
  5431.  
  5432. // Nombre de news à afficher & nb max de caractères par news:
  5433. const nbItems = 5;
  5434. const maxCarDescription = 300;
  5435.  
  5436. /*-[functions]------------------- Utilitaires --------------------------------*/
  5437.  
  5438. // Ne semble avoir strictement aucun effet:
  5439. String.prototype.epureDescription = function() {
  5440. return this.replace(/\\(.)/g,"$1");
  5441. }
  5442.  
  5443. function appendTitledTable(node,titre,description) {
  5444. // Crée les tables contenant les infos (avec titre)
  5445. var table = document.createElement('table');
  5446. table.border = 0;
  5447. table.className = 'mh_tdborder';
  5448. table.cellSpacing = 1;
  5449. table.cellPadding = 1;
  5450. table.style.maxWidth = '98%';
  5451. table.style.marginLeft = 'auto';
  5452. table.style.marginRight = 'auto';
  5453. var tbody = document.createElement('tbody');
  5454. table.appendChild(tbody);
  5455. var tr = appendTr(tbody,'mh_tdtitre');
  5456. var td = appendTdCenter(tr,2);
  5457. var span = document.createElement('span');
  5458. appendText(span,titre,true);
  5459. if(description) {
  5460. span.title = description;
  5461. }
  5462. td.appendChild(span);
  5463. node.appendChild(table);
  5464. return tbody;
  5465. }
  5466.  
  5467. function testCertif(paramURL, callbackOnError) {
  5468. try {
  5469. FF_XMLHttpRequest({
  5470. method: 'GET',
  5471. url: paramURL,
  5472. onload: function(responseDetails) {
  5473. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  5474. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  5475. }
  5476. });
  5477. } catch(e) {
  5478. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  5479. callbackOnError();
  5480. }
  5481. }
  5482.  
  5483. function createOrGetGrandCadre() {
  5484. var grandCadre = document.getElementById('grandCadre');
  5485. if (grandCadre) return grandCadre;
  5486. try {
  5487. var rappels = document.evaluate(
  5488. "//p[contains(a/text(),'messagerie')]",
  5489. document, null, 9, null).singleNodeValue;
  5490. }
  5491. catch(e) {
  5492. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  5493. grandCadre = document.createElement('div');
  5494. return grandCadre;
  5495. }
  5496. grandCadre = document.createElement('div');
  5497. grandCadre.id = 'grandCadre';
  5498. var sousCadre = document.createElement('div');
  5499. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  5500. sousCadre.style.textAlign = 'center';
  5501. sousCadre.style.fontSize = 'xx-large';
  5502. grandCadre.appendChild(sousCadre);
  5503.  
  5504. grandCadre.style.border = 'solid 5px red';
  5505. grandCadre.style.width = 'auto';
  5506. insertBefore(rappels,grandCadre);
  5507. return grandCadre;
  5508. }
  5509.  
  5510. function showHttpsErrorCadre1() {
  5511. window.console.log('[MZ] showHttpsErrorCadre1');
  5512. var grandCadre = createOrGetGrandCadre();
  5513. var sousCadre = document.createElement('div');
  5514. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  5515. + '<br />Cela empêchera Moutyzilla de fonctionner'
  5516. + '<br /><a style="color:blue;font-size: inherits;" href="'
  5517. + URL_CertifRaistlin1
  5518. + '" target="raistlin">clique ici</a>'
  5519. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5520. + ' « Confirmer l\'exception de sécurité »'
  5521. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5522. sousCadre.style.width = 'auto';
  5523. sousCadre.style.fontSize = 'large';
  5524. sousCadre.style.border = 'solid 1px black';
  5525. sousCadre.style.backgroundColor = 'red';
  5526. grandCadre.appendChild(sousCadre);
  5527. }
  5528.  
  5529. function showHttpsErrorCadre2() {
  5530. window.console.log('[MZ] showHttpsErrorCadre2');
  5531. var grandCadre = createOrGetGrandCadre();
  5532. var sousCadre = document.createElement('div');
  5533. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  5534. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  5535. + '<a style="color:blue;font-size: inherits;" href="'
  5536. + URL_CertifRaistlin2
  5537. + '" target="raistlin">clique ici</a>'
  5538. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5539. + ' « Confirmer l\'exception de sécurité »'
  5540. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  5541. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5542. sousCadre.style.width = 'auto';
  5543. sousCadre.style.fontSize = 'large';
  5544. sousCadre.style.border = 'solid 1px black';
  5545. sousCadre.style.backgroundColor = 'red';
  5546. grandCadre.appendChild(sousCadre);
  5547. }
  5548.  
  5549. function showHttpsErrorContenuMixte() {
  5550. window.console.log('[MZ] showHttpsErrorContenuMixte');
  5551. var grandCadre = createOrGetGrandCadre();
  5552. var sousCadre = document.createElement('div');
  5553. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5554. + '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)'
  5555. + '<ul>'
  5556. + '<li>Interface Bricol\'Troll</li>'
  5557. + '<li>Nouveautés de Mountyzilla</li>'
  5558. + '</ul>'
  5559. + '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 />'
  5560. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5561. sousCadre.style.width = 'auto';
  5562. sousCadre.style.fontSize = 'large';
  5563. sousCadre.style.border = 'solid 1px black';
  5564. grandCadre.appendChild(sousCadre);
  5565. }
  5566.  
  5567. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5568.  
  5569. function traiterJubilaires() {
  5570. // à faire
  5571. }
  5572.  
  5573. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5574. try {
  5575. FF_XMLHttpRequest({
  5576. method: 'GET',
  5577. url: URL_anniv,
  5578. headers: {
  5579. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5580. 'Accept': 'application/xml,text/xml',
  5581. },
  5582. onload: function(responseDetails) {
  5583. if ((responseDetails.status == 0) && isHTTPS) {
  5584. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5585. //showHttpsErrorContenuMixte();
  5586. return;
  5587. }
  5588. var listeTrolls = responseDetails.responseText.split('\n');
  5589. if(!listeTrolls || listeTrolls.length==0) {
  5590. return;
  5591. }
  5592. afficherJubilaires(listeTrolls);
  5593. },
  5594. });
  5595. }
  5596. catch(e) {
  5597. if (isHTTPS) {
  5598. window.console.log(traceStack(e, 'appel jubilaires'));
  5599. showHttpsErrorContenuMixte();
  5600. } else {
  5601. window.alert('Erreur Jubilaires:\n'+e);
  5602. }
  5603. }
  5604. }
  5605.  
  5606. function afficherJubilaires(listeTrolls) {
  5607. try {
  5608. var rappels = document.evaluate(
  5609. "//p[contains(a/text(),'messagerie')]",
  5610. document, null, 9, null).singleNodeValue;
  5611. }
  5612. catch(e) {
  5613. return;
  5614. }
  5615. var p = document.createElement('p');
  5616. var tbody = appendTitledTable(p,
  5617. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5618. 'Envoyez leur un message ou un cadeau !'
  5619. );
  5620. tr = appendTr(tbody,'mh_tdpage');
  5621. td = appendTdCenter(tr);
  5622. var small = document.createElement('small');
  5623. td.appendChild(small);
  5624. var first = true;
  5625. for(var i=0 ; i<listeTrolls.length ; i++) {
  5626. var infos = listeTrolls[i].split(';');
  5627. if(infos.length!=3 || infos[2]==='0') {
  5628. continue;
  5629. }
  5630. if(first) {
  5631. first = false;
  5632. }
  5633. else {
  5634. appendText(small,', ');
  5635. }
  5636. var a = document.createElement('a');
  5637. a.href = 'javascript:EPV('+infos[0]+')';
  5638. appendText(a,infos[1]);
  5639. small.appendChild(a);
  5640. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5641. }
  5642. insertBefore(rappels,p);
  5643. }
  5644.  
  5645.  
  5646. /*-[functions]--------------------- News MZ ----------------------------------*/
  5647.  
  5648. function traiterNouvelles() {
  5649. var news = new Array;
  5650. 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)']);
  5651. 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 ;).']);
  5652. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5653. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5654. 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']);
  5655. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5656. afficherNouvelles(news);
  5657. }
  5658.  
  5659. function afficherNouvelles(items) {
  5660. var footer = document.getElementById('footer1');
  5661. if(!footer) {
  5662. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5663. return;
  5664. }
  5665. var p = document.createElement('p');
  5666. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5667. var div = document.createElement('div');
  5668. div.style.position = 'absolute';
  5669. div.style.right = 0;
  5670. div.style.top = 0;
  5671. div.style.paddingRight = '3px';
  5672. div.style.whiteSpace = 'nowrap';
  5673. appendText(div, '(version ' + GM_info.script.version + ')');
  5674. tbody.rows[0].cells[0].style.position = 'relative';
  5675. tbody.rows[0].cells[0].appendChild(div);
  5676. for(var i=0 ; i<items.length ; i++) {
  5677. var tr = appendTr(tbody,'mh_tdpage');
  5678. var td = appendTdCenter(tr);
  5679. td.style.verticalAlign = 'top'; // semble sans effet
  5680. appendText(td,items[i][0],true);
  5681. td = appendTd(tr);
  5682. td.innerHTML = items[i][1];
  5683. }
  5684. insertBefore(footer,p);
  5685.  
  5686. // changelog
  5687. var p = document.createElement('p');
  5688. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5689. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5690. tbody.rows[0].cells[0].onclick = function() {
  5691. try {
  5692. tbody.rows[0].cells[0].onclick = undefined;
  5693. tbody.rows[0].cells[0].style.cursor = '';
  5694. var tr = appendTr(tbody,'mh_tdpage');
  5695. var td = appendTd(tr);
  5696. td.colSpan = 2;
  5697. var pre = document.createElement('pre');
  5698. appendText(pre,MZ_changeLog.join("\n"));
  5699. td.appendChild(pre);
  5700. } catch (e) {
  5701. window.console.log('[MZ] affichage changeLog', e);
  5702. }
  5703. };
  5704. insertBefore(footer,p);
  5705.  
  5706. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5707. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5708. if (isHTTPS) {
  5709. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5710. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5711. } else {
  5712. window.console.log('[MZ test] début switch to https');
  5713. window.sessionStorage.setItem('xxx', "test session trans https");
  5714. window.parent.xxx = "autre test";
  5715. var url = document.location.href;
  5716. window.console.log('[MZ test] url=' + url);
  5717. url = url.replace(/http:\/\//i, 'https://')
  5718. window.console.log('[MZ test] switched url=' + url);
  5719. document.location.href = url;
  5720. }
  5721. }
  5722. if (false) { // version par utilisation d'un IFrame en https
  5723. if (isHTTPS) {
  5724. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5725. //window.console.log('[MZ test] window.name=' + window.name);
  5726. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5727. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5728. var txt = window.name;
  5729. var tabtxt = txt.split(/µ/);
  5730. for (var i = 0; i < tabtxt.length; i++) {
  5731. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5732. }
  5733. } else {
  5734. var txt = '';
  5735. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5736. var k = localStorage.key(i);
  5737. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5738. txt += k + "£" + localStorage.getItem(k) + "µ";
  5739. }
  5740. var iframe = document.createElement('iframe');
  5741. var url = document.location.href;
  5742. //window.console.log('[MZ test] url=' + url);
  5743. url = url.replace(/http:\/\//i, 'https://')
  5744. //window.console.log('[MZ test] switched url=' + url);
  5745. //iframe.xxx = "truc en plume";
  5746. iframe.name = txt;
  5747. //window.xxx = "machin";
  5748. iframe.src = url;
  5749. //iframe.document.xxx = "truc en plume";
  5750. document.body.appendChild(iframe);
  5751. iframe.style.display = 'none';
  5752. }
  5753. }
  5754. }
  5755. }
  5756.  
  5757.  
  5758. /*---------------------------------- Main ------------------------------------*/
  5759.  
  5760. function do_news() {
  5761. start_script();
  5762.  
  5763. traiterJubilaires();
  5764. traiterNouvelles();
  5765.  
  5766. /* plus besoin, le certificat est "officiel"
  5767. if (isHTTPS) {
  5768. // test si les certificats raistlin ont été acceptés
  5769. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5770. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5771. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5772. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5773. }
  5774. }
  5775. */
  5776.  
  5777. displayScriptTime();
  5778. }
  5779.  
  5780. /*********************************************************************************
  5781. * This file is part of Mountyzilla. *
  5782. * *
  5783. * Mountyzilla is free software; you can redistribute it and/or modify *
  5784. * it under the terms of the GNU General Public License as published by *
  5785. * the Free Software Foundation; either version 2 of the License, or *
  5786. * (at your option) any later version. *
  5787. * *
  5788. * Mountyzilla is distributed in the hope that it will be useful, *
  5789. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5790. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5791. * GNU General Public License for more details. *
  5792. * *
  5793. * You should have received a copy of the GNU General Public License *
  5794. * along with Mountyzilla; if not, write to the Free Software *
  5795. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5796. *********************************************************************************/
  5797.  
  5798. // x~x tabcompo
  5799.  
  5800. var popup;
  5801.  
  5802. function initPopupTabcompo() {
  5803. popup = document.createElement('div');
  5804. popup.setAttribute('id', 'popup');
  5805. popup.setAttribute('class', 'mh_textbox');
  5806. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5807. + 'display: inline; z-index: 3; max-width: 400px;');
  5808. document.body.appendChild(popup);
  5809. }
  5810.  
  5811. function showPopup(evt) {
  5812. var texte = this.getAttribute("texteinfo");
  5813. popup.innerHTML = texte;
  5814. popup.style.left = evt.pageX + 15 + 'px';
  5815. popup.style.top = evt.pageY + 'px';
  5816. popup.style.visibility = "visible";
  5817. }
  5818.  
  5819. // roule 16/03/2016, existe déjà ailleurs
  5820. // function hidePopup() {
  5821. // popup.style.visibility = 'hidden';
  5822. // }
  5823.  
  5824. function createPopupImage(url, text)
  5825. {
  5826. var img = document.createElement('img');
  5827. img.setAttribute('src',url);
  5828. img.setAttribute('align','ABSMIDDLE');
  5829. img.setAttribute("texteinfo",text);
  5830. img.addEventListener("mouseover", showPopup,true);
  5831. img.addEventListener("mouseout", hidePopup,true);
  5832. return img;
  5833. }
  5834.  
  5835. function formateTexte(texte)
  5836. {
  5837. texte = texte.replace(/\n/g,"<br/>");
  5838. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5839. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5840. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5841. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5842. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5843. return texte;
  5844. }
  5845.  
  5846. function arrondi(x) {
  5847. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5848. }
  5849.  
  5850. function traiteMinerai() {
  5851. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5852. try {
  5853. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5854. +" and contains(./tr/th/text(),'Minerai')]",
  5855. document, null, 9, null).singleNodeValue;
  5856. node = node.nextSibling.nextSibling;
  5857. }
  5858. catch(e) {return;}
  5859. var trlist = document.evaluate('./tr', node, null, 7, null);
  5860. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5861. var node = trlist.snapshotItem(i);
  5862. var nature = node.childNodes[5].textContent;
  5863. var caracs = node.childNodes[7].textContent;
  5864. var taille = caracs.match(/\d+/)[0];
  5865. var coef = 1;
  5866. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5867. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5868. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5869. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5870. if (nature.indexOf('Mithril')!=-1) {
  5871. coef = 0.2*coef;
  5872. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5873. }
  5874. else {
  5875. coef = 0.75*coef+1.25;
  5876. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5877. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5878. }
  5879. }
  5880. }
  5881.  
  5882. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5883. function treateComposants() {
  5884. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5885. //On récupère les composants
  5886. var nodes = document.evaluate(
  5887. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5888. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5889. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5890. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5891. if (nodes.snapshotLength == 0) {
  5892. //window.console.log('[MZ] treateComposants DOWN');
  5893. return;
  5894. }
  5895. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5896.  
  5897. var texte = "";
  5898. for (var i = 0; i < nodes.snapshotLength; i++) {
  5899. var n1 = nodes.snapshotItem(i).childNodes[1];
  5900. var n3 = nodes.snapshotItem(i).childNodes[3];
  5901. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5902. var prix = n3.childNodes[0].nodeValue;
  5903. if (!prix)
  5904. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5905. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5906. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5907. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5908. + prix.replace(/\n/g, '') + "\n";
  5909. }
  5910.  
  5911. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5912. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5913. var id_taniere = c.snapshotItem(0).nodeValue;
  5914. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5915.  
  5916. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5917. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5918. if (form)
  5919. {
  5920. if(document.getElementsByTagName('form').length>0)
  5921. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5922. else
  5923. {
  5924. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5925. insertBefore(thisP, form);
  5926. }
  5927. }
  5928. }
  5929.  
  5930. function treateAllComposants() {
  5931. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5932. //On récupère les composants
  5933. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5934. document, null, 0, null ).numberValue;
  5935. var c = (categ == 0 ? 3 : 4);
  5936. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5937. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5938. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5939. + "td["+c+"]/text()[1] = '\240-\240' "
  5940. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5941. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5942. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5943. + "and td[1]/img/@alt = 'Identifié']",
  5944. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5945. if (nodes.snapshotLength == 0) {
  5946. // window.alert('treateAllComposants DOWN');
  5947. return;
  5948. }
  5949.  
  5950. var texte = "";
  5951. for (var i = 0; i < nodes.snapshotLength; i++) {
  5952. var n1 = nodes.snapshotItem(i).childNodes[1];
  5953. var n3 = nodes.snapshotItem(i).childNodes[3];
  5954. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5955. var prix = n3.childNodes[0].nodeValue;
  5956. if (!prix)
  5957. {
  5958. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5959. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5960. }
  5961. else
  5962. {
  5963. prix= prix.replace(/[\240 ]/g, "");
  5964. if(prix=="-")
  5965. prix=null;
  5966. }
  5967. if(prix)
  5968. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5969. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5970. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5971. + prix.replace(/\n/g, '') + "\n";
  5972. else
  5973. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5974. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5975. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5976. }
  5977.  
  5978. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5979. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5980. var id_taniere = c.snapshotItem(0).nodeValue;
  5981. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5982.  
  5983. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5984. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5985. if (form)
  5986. {
  5987. if(document.getElementsByTagName('form').length>0)
  5988. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5989. else
  5990. {
  5991. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5992. insertBefore(thisP, form);
  5993. }
  5994. }
  5995. }
  5996.  
  5997. function treateEM()
  5998. {
  5999. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  6000. if(currentURL.indexOf("as_type=Compo")==-1)
  6001. return false;
  6002. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  6003. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  6004. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6005. if (nodes.snapshotLength == 0)
  6006. return false;
  6007. for (var i = 0; i < nodes.snapshotLength; i++) {
  6008. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  6009. var link = desc[2].firstChild ;
  6010. var nomCompoTotal = desc[2].textContent ;
  6011. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6012. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6013. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  6014. var locqual = desc[3].textContent ;
  6015. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  6016. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  6017. if(isEM(nomMonstre).length>0)
  6018. {
  6019. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  6020. if(infos.length>0)
  6021. {
  6022. var shortDescr = "Variable";
  6023. var bold = 0;
  6024. if(infos != "Composant variable")
  6025. {
  6026. shortDescr = infos.substring(0,infos.indexOf(" "));
  6027. if(parseInt(shortDescr)>=0)
  6028. bold=1;
  6029. }
  6030. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  6031. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  6032. }
  6033. }
  6034. }
  6035. }
  6036.  
  6037. function treateChampi() {
  6038. if (currentURL.indexOf('as_type=Champi')==-1)
  6039. return false;
  6040. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  6041. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6042. if (nodes.snapshotLength == 0)
  6043. return false;
  6044.  
  6045. for (var i = 0; i < nodes.snapshotLength; i++) {
  6046. var node = nodes.snapshotItem(i);
  6047. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  6048. if (moisChampi[nomChampi])
  6049. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  6050. }
  6051. }
  6052.  
  6053. function treateEnchant()
  6054. {
  6055. if(currentURL.indexOf("as_type=Compo")==-1)
  6056. return false;
  6057. try
  6058. {
  6059. if(!listeMonstreEnchantement)
  6060. computeCompoEnchantement();
  6061. var nodes = document.evaluate(
  6062. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6063. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6064. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6065. if (nodes.snapshotLength == 0)
  6066. return false;
  6067. var urlImg = URL_MZimg + "enchant.png";
  6068. for (var i = 0; i < nodes.snapshotLength; i++) {
  6069. var link = nodes.snapshotItem(i);
  6070. var nomCompoTotal = link.firstChild.nodeValue;
  6071. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6072. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6073. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  6074. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  6075. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  6076. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  6077. if(isEnchant(nomMonstre).length>0)
  6078. {
  6079. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  6080. if(infos.length>0)
  6081. {
  6082. link.parentNode.appendChild(createImage(urlImg,infos));
  6083. }
  6084. }
  6085. }
  6086. }
  6087. catch(e)
  6088. {
  6089. window.alert(e);
  6090. }
  6091. }
  6092.  
  6093. function treateEquipEnchant()
  6094. {
  6095. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  6096. return false;
  6097. initPopupTabcompo();
  6098. computeEnchantementEquipement(createPopupImage,formateTexte);
  6099. }
  6100.  
  6101. function do_tancompo() {
  6102. start_script();
  6103.  
  6104. treateAllComposants();
  6105. treateComposants();
  6106. traiteMinerai();
  6107. if (MY_getValue('NOINFOEM')!='true') {
  6108. treateChampi();
  6109. treateEM();
  6110. }
  6111. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  6112. treateEnchant();
  6113. treateEquipEnchant();
  6114. }
  6115.  
  6116. displayScriptTime();
  6117. }
  6118.  
  6119. /*******************************************************************************
  6120. * This file is part of Mountyzilla. *
  6121. * *
  6122. * Mountyzilla is free software; you can redistribute it and/or modify *
  6123. * it under the terms of the GNU General Public License as published by *
  6124. * the Free Software Foundation; either version 2 of the License, or *
  6125. * (at your option) any later version. *
  6126. * *
  6127. * Mountyzilla is distributed in the hope that it will be useful, *
  6128. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6129. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6130. * GNU General Public License for more details. *
  6131. * *
  6132. * You should have received a copy of the GNU General Public License *
  6133. * along with Mountyzilla; if not, write to the Free Software *
  6134. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6135. *******************************************************************************/
  6136.  
  6137. // x~x pjview
  6138.  
  6139. /* TODO
  6140. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  6141. */
  6142.  
  6143. // Bulle d'infos
  6144. var DivInfo;
  6145. // Booléen stockant l'état de freezing de la bulle
  6146. var freezed = false;
  6147.  
  6148. // liste du matos
  6149. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  6150. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6151. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  6152. var mh_caracs = {
  6153. 'anneau de protection':
  6154. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  6155. "armure d'anneaux":
  6156. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  6157. 'armure de bois':
  6158. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  6159. 'armure de cuir':
  6160. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  6161. 'armure de peaux':
  6162. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  6163. 'armure de pierre':
  6164. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  6165. 'armure de plates':
  6166. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  6167. 'baton lesté':
  6168. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6169. 'bâtons de parade':
  6170. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6171. 'bottes':
  6172. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6173. 'bouclier à pointes':
  6174. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6175. 'boulet et chaîne':
  6176. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6177. 'cagoule':
  6178. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  6179. 'casque à cornes':
  6180. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6181. 'casque à pointes':
  6182. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  6183. 'casque en cuir':
  6184. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  6185. 'casque en métal':
  6186. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6187. 'chaîne cloutée':
  6188. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6189. 'chapeau pointu':
  6190. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  6191. 'collier de dents':
  6192. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  6193. 'collier de pierre':
  6194. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6195. 'collier à pointes':
  6196. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6197. 'cotte de mailles':
  6198. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  6199. 'couronne de cristal':
  6200. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  6201. "couronne d'obsidienne":
  6202. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  6203. "coutelas d'obsidienne":
  6204. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  6205. 'coutelas en os':
  6206. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  6207. 'crochet':
  6208. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6209. 'cuir bouilli':
  6210. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  6211. "cuirasse d'ossements":
  6212. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  6213. "cuirasse d'écailles":
  6214. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  6215. 'culotte en cuir':
  6216. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6217. 'dague':
  6218. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6219. 'epée courte':
  6220. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6221. 'epée longue':
  6222. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6223. 'espadon':
  6224. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6225. 'fouet':
  6226. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6227. 'fourrures':
  6228. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  6229. 'gantelet':
  6230. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6231. 'gorgeron en cuir':
  6232. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6233. 'gorgeron en métal':
  6234. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  6235. 'gourdin':
  6236. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6237. 'gourdin clouté':
  6238. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6239. 'grimoire':
  6240. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  6241. "gros'porte":
  6242. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  6243. 'grosse racine':
  6244. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6245. 'grosse stalagmite':
  6246. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  6247. 'hache de bataille':
  6248. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6249. 'hache de guerre en os':
  6250. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  6251. 'hache de guerre en pierre':
  6252. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  6253. "hache à deux mains d'obsidienne":
  6254. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  6255. 'hallebarde':
  6256. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  6257. "haubert d'écailles":
  6258. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  6259. 'haubert de mailles':
  6260. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  6261. 'heaume':
  6262. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  6263. 'jambières en cuir':
  6264. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6265. 'jambières en fourrure':
  6266. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  6267. 'jambières en maille':
  6268. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6269. 'jambières en métal':
  6270. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  6271. 'jambières en os':
  6272. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6273. "lame d'obsidienne":
  6274. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  6275. 'lame en os':
  6276. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6277. 'lame en pierre':
  6278. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6279. 'lorgnons':
  6280. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  6281. 'machette':
  6282. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6283. "masse d'arme":
  6284. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6285. 'pagne de mailles':
  6286. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6287. 'pagne en cuir':
  6288. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6289. 'robe de mage':
  6290. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  6291. 'rondache en bois':
  6292. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6293. 'rondache en métal':
  6294. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  6295. 'sandales':
  6296. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6297. 'souliers dorés':
  6298. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6299. "talisman d'obsidienne":
  6300. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  6301. 'talisman de pierre':
  6302. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  6303. 'targe':
  6304. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6305. 'torche':
  6306. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  6307. 'torque de pierre':
  6308. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  6309. 'tunique':
  6310. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6311. "tunique d'écailles":
  6312. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  6313. 'turban':
  6314. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  6315. }
  6316.  
  6317. // liste des templates
  6318. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  6319. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6320. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  6321. var mh_templates = {
  6322. 'de Feu':
  6323. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6324. 'de Résistance':
  6325. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  6326. "de l'Aigle":
  6327. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  6328. 'de la Salamandre':
  6329. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6330. 'des Cyclopes':
  6331. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  6332. 'des Enragés':
  6333. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  6334. 'des Tortues':
  6335. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  6336. 'des Vampires':
  6337. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6338. 'du Glacier':
  6339. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  6340. 'du Rat':
  6341. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6342. 'du Roc':
  6343. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  6344. 'du Temps':
  6345. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  6346. 'du Vent':
  6347. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6348. 'en Mithril':
  6349. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6350. 'des Anciens':
  6351. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6352. 'des Champions':
  6353. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6354. 'des Duellistes':
  6355. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6356. 'de la Terre':
  6357. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  6358. "de l'Orage":
  6359. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  6360. "de l'Ours":
  6361. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  6362. 'des Béhémoths':
  6363. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  6364. 'des Mages':
  6365. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  6366. 'du Pic':
  6367. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  6368. 'du Sable':
  6369. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  6370. 'acéré':
  6371. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6372. 'acérée':
  6373. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6374. 'équilibré':
  6375. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6376. 'équilibrée':
  6377. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6378. 'léger':
  6379. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  6380. 'légère':
  6381. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  6382. 'renforcé':
  6383. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  6384. 'renforcée':
  6385. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  6386. 'robuste':
  6387. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  6388. }
  6389.  
  6390. function clone(arr) {
  6391. // Clonage rapide
  6392. return arr.slice(0);
  6393. }
  6394.  
  6395. function addArray(arr1,arr2) {
  6396. // Somme matricielle
  6397. var res = clone(arr1);
  6398. for(i=res.length-1 ; i>=0 ; i--) {
  6399. res[i] += arr2[i];
  6400. }
  6401. return res;
  6402. }
  6403.  
  6404. function getTemplates(nomItem) {
  6405. // Déstructure le nom de l'item en array [nom, template1, ...]
  6406. var tempFound = true;
  6407. var str = nomItem.trim();
  6408. var arr = [];
  6409. while(tempFound) {
  6410. tempFound = false;
  6411. for(var temp in mh_templates) {
  6412. // on teste la fin du nom contre chaque template
  6413. if(str.slice(-temp.length)!=temp) { continue; }
  6414. tempFound = true;
  6415. str = str.slice(0,-temp.length-1);
  6416. arr.unshift(temp);
  6417. if(str.slice(-3)==' et') {
  6418. str = str.slice(0,-3);
  6419. }
  6420. }
  6421. }
  6422. arr.unshift(str);
  6423. return arr;
  6424. }
  6425.  
  6426. function addMithril(arrayCaracs,typeItem) {
  6427. // Ajoute l'effet du Mithril sur les caracs
  6428. if(typeItem=='arme') {
  6429. if(arrayCaracs[0]<0) {
  6430. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  6431. }
  6432. }
  6433. else {
  6434. if(arrayCaracs[4]<0) {
  6435. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  6436. }
  6437. }
  6438. arrayCaracs[15] /= 2;
  6439. arrayCaracs[16] /= 2;
  6440. return arrayCaracs;
  6441. }
  6442.  
  6443. function addRenfort(arrayCaracs,template) {
  6444. // Ajoute l'effet des pseudo-templates sur les caracs
  6445. // S'applique APRÈS le mithril
  6446. // WARNING - Cette formule n'a rien d'officiel, gare !
  6447. var coef = 0;
  6448. if(/^lég[e,è]re?$/.test(template)) {
  6449. coef = -1;
  6450. }
  6451. else if(/^renforcée?$/.test(template)
  6452. || template==='robuste') {
  6453. coef = 1;
  6454. }
  6455. if(coef) {
  6456. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  6457. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  6458. }
  6459. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  6460. return arrayCaracs;
  6461. }
  6462.  
  6463. function getCaracs(item) {
  6464. // Calcule les caractéristiques de l'item
  6465. var templates = getTemplates(item);
  6466. if(!mh_caracs[templates[0]]) {
  6467. // Si l'item est inconnu
  6468. return [];
  6469. }
  6470. var caracs = clone(mh_caracs[templates[0]]);
  6471. var typeItem = caracs[0];
  6472. caracs.shift();
  6473. templates.shift();
  6474. if(templates[templates.length-1]=='en Mithril') {
  6475. caracs = addMithril(caracs,typeItem);
  6476. templates.pop();
  6477. }
  6478. if(/^acérée?$/.test(templates[0])
  6479. || /^équilibrée?$/.test(templates[0])
  6480. || /^lég[e,è]re?$/.test(templates[0])
  6481. || /^renforcée?$/.test(templates[0])
  6482. || templates[0]=='robuste') {
  6483. caracs = addRenfort(caracs,templates[0]);
  6484. templates.shift();
  6485. }
  6486. for(var i=templates.length-1 ; i>=0 ; i--) {
  6487. caracs = addArray(caracs,mh_templates[templates[i]]);
  6488. }
  6489. return caracs;
  6490. }
  6491.  
  6492. function getLine(tab) {
  6493. // Préparation de la ligne à afficher lors d'un mouseover
  6494. var str = '';
  6495. if(tab[0]!=0 || tab[1]!=0) {
  6496. str += '<b>Att : </b>'+aff(tab[0]);
  6497. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  6498. str += ' | ';
  6499. }
  6500. if(tab[4]!=0) {
  6501. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  6502. }
  6503. if(tab[2]!=0 || tab[3]!=0) {
  6504. str += '<b>Deg : </b>'+aff(tab[2]);
  6505. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  6506. str += ' | ';
  6507. }
  6508. if(tab[8]!=0) {
  6509. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  6510. }
  6511. if(tab[7]!=0) {
  6512. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  6513. }
  6514. if(tab[5]!=0 || tab[6]!=0) {
  6515. str += '<b>Arm : </b>'+aff(tab[5]);
  6516. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  6517. str += ' | ';
  6518. }
  6519. if(tab[9]!=0 || tab[10]!=0) {
  6520. str += '<b>RM : </b>'+aff(tab[9])+'%';
  6521. if(tab[9]!=tab[10]) {
  6522. str += '/'+aff(tab[10])+'%';
  6523. }
  6524. str += ' | ';
  6525. }
  6526. if(tab[11]!=0 || tab[12]!=0) {
  6527. str += '<b>MM : </b>'+aff(tab[11])+'%';
  6528. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  6529. str += ' | ';
  6530. }
  6531. if(tab[13]!=0) {
  6532. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  6533. }
  6534. if(tab[14]!=0) {
  6535. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  6536. }
  6537. str += '<b>Poids : </b>'+tab[15]+' min';
  6538. if(tab[15]!=tab[16]) {
  6539. str += ' / '+tab[16]+' min';
  6540. }
  6541. return str;
  6542. }
  6543.  
  6544. function toolTipInit() {
  6545. DivInfo = document.createElement('div');
  6546. DivInfo.id = 'infosVue';
  6547. DivInfo.className = 'mh_textbox';
  6548. DivInfo.style =
  6549. 'position: absolute;'
  6550. +'border: 1px solid #000000;'
  6551. +'visibility:hidden;'
  6552. +'display:inline;'
  6553. +'z-index:99;';
  6554. document.body.appendChild(DivInfo);
  6555. document.onmousemove = getXY;
  6556. document.onclick = changeFreezeStatus;
  6557. }
  6558.  
  6559. function getXY(evt) {
  6560. if(!freezed && DivInfo.style.visibility=='visible') {
  6561. DivInfo.style.left = evt.pageX+'px';
  6562. DivInfo.style.top = evt.pageY+10+'px';
  6563. }
  6564. }
  6565.  
  6566. function changeFreezeStatus() {
  6567. if(DivInfo.style.visibility=='visible') {
  6568. freezed = !freezed;
  6569. if(!freezed) { hideInfos(); }
  6570. }
  6571. }
  6572.  
  6573. function showInfos() {
  6574. if(freezed) { return; }
  6575. var currentInfos = this.infos;
  6576. DivInfo.innerHTML = currentInfos;
  6577. DivInfo.style.visibility = 'visible';
  6578. }
  6579.  
  6580. function hideInfos() {
  6581. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6582. }
  6583.  
  6584. function treateEquipement() {
  6585. // Extrait les données du matos et réinjecte les infos déduites
  6586. if(MY_getValue('INFOCARAC')=='false') { return; }
  6587. var faireLigne = false;
  6588. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6589. var nodes = document.evaluate(
  6590. "//td/b[text()='Equipement Utilisé']/../../"
  6591. +"td[2]/img[contains(@src,bullet)]",
  6592. document, null, 7, null);
  6593. if(nodes.snapshotLength>0) {
  6594. // Si CSS de base
  6595. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6596. var node = nodes.snapshotItem(i);
  6597. var next = node.nextSibling;
  6598. var nnext = next.nextSibling;
  6599. var nom = next.nodeValue.toLowerCase();
  6600. if(nnext.childNodes.length==1) {
  6601. nom += nnext.firstChild.nodeValue;
  6602. }
  6603. nom = nom.trim();
  6604. // gestion winpostrophe
  6605. var c = String.fromCharCode(180);
  6606. while(nom.indexOf(c)!=-1) {
  6607. nom = nom.replace(c,"'");
  6608. }
  6609. var arr = getCaracs(nom);
  6610. if(arr.length>0) {
  6611. faireLigne = true;
  6612. caracs = addArray(caracs,arr);
  6613. var span = document.createElement('span');
  6614. span.appendChild(next);
  6615. span.appendChild(nnext);
  6616. span.infos = getLine(arr);
  6617. span.onmouseover = showInfos;
  6618. span.onmouseout = hideInfos;
  6619. insertBefore(node.nextSibling,span);
  6620. }
  6621. }
  6622. if(faireLigne) {
  6623. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6624. document, null, 9, null).singleNodeValue;
  6625. node.infos = getLine(caracs);
  6626. node.onmouseover = showInfos;
  6627. node.onmouseout = hideInfos;
  6628. }
  6629. }
  6630. else {
  6631. // Si CSS avancée
  6632. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6633. document, null, 7, null);
  6634. if(nodes.snapshotLength>0) {
  6635. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6636. var node = nodes.snapshotItem(i);
  6637. var nom = node.firstChild.nodeValue.toLowerCase();
  6638. if(node.childNodes.length>1) {
  6639. nom += node.childNodes[1].firstChild.nodeValue;
  6640. }
  6641. nom = nom.trim();
  6642. // gestion winpostrophe
  6643. var c = String.fromCharCode(180);
  6644. while(nom.indexOf(c)!=-1) {
  6645. nom = nom.replace(c,"'");
  6646. }
  6647. var arr = getCaracs(nom);
  6648. if(arr.length!=0) {
  6649. caracs = addArray(caracs,arr);
  6650. node.infos = getLine(arr);
  6651. node.onmouseover = showInfos;
  6652. node.onmouseout = hideInfos;
  6653. }
  6654. }
  6655. var nodes = document.evaluate("//dt[@class='equipement']",
  6656. document, null, 7, null);
  6657. var node = nodes.snapshotItem(0);
  6658. node.infos = getLine(caracs);
  6659. node.onmouseover = showInfos;
  6660. node.onmouseout = hideInfos;
  6661. }
  6662. }
  6663. }
  6664.  
  6665. function do_pjview() {
  6666. treateEquipement();
  6667. toolTipInit();
  6668. }
  6669.  
  6670. /*******************************************************************************
  6671. * This file is part of Mountyzilla. *
  6672. * *
  6673. * Mountyzilla is free software; you can redistribute it and/or modify *
  6674. * it under the terms of the GNU General Public License as published by *
  6675. * the Free Software Foundation; either version 2 of the License, or *
  6676. * (at your option) any later version. *
  6677. * *
  6678. * Mountyzilla is distributed in the hope that it will be useful, *
  6679. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6680. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6681. * GNU General Public License for more details. *
  6682. * *
  6683. * You should have received a copy of the GNU General Public License *
  6684. * along with Mountyzilla; if not, write to the Free Software *
  6685. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6686. *******************************************************************************/
  6687.  
  6688. // x~x option
  6689.  
  6690. /* TODO
  6691. * Passer le HTML injecté aux conventions HTML5
  6692. */
  6693.  
  6694.  
  6695. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6696.  
  6697. function saveITData() {
  6698. var IT = document.getElementById('itSelect').value;
  6699. if(IT=='bricol') {
  6700. var nBricol = 1;
  6701. for (var iBricol = 0; ; iBricol++) {
  6702. var extClef = nBricol == 1 ? '' : nBricol;
  6703. var eltSystem = document.getElementById('urlbricol'+iBricol);
  6704. if (eltSystem == undefined) break;
  6705. var system = eltSystem.value;
  6706. window.console.log("[MZ] saveITData system=" + system);
  6707. var login = document.getElementById('loginbricol'+iBricol).value;
  6708. var pass = document.getElementById('passbricol'+iBricol).value;
  6709. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6710. if(system && login) {
  6711. if (pass) {
  6712. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6713. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  6714. //window.console.log('v=' + v);
  6715. } else {
  6716. // vérif que rien n'a changé
  6717. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  6718. if(str) {
  6719. var arr = str.split('$');
  6720. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6721. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  6722. }
  6723. }
  6724. }
  6725. nBricol++;
  6726. }
  6727. }
  6728. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  6729. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  6730. }
  6731. else {
  6732. MY_removeValue(numTroll+'.INFOSIT');
  6733. }
  6734. }
  6735.  
  6736. function saveLinks() {
  6737. var numLinks = document.getElementById('linksBody').childNodes.length;
  6738. var data=[ [] ];
  6739. /* Récupération et tri des liens */
  6740. for(var i=1 ; i<=numLinks ; i++) {
  6741. MY_removeValue('URL'+i);
  6742. MY_removeValue('URL'+i+'.nom');
  6743. MY_removeValue('URL'+i+'.ico');
  6744. var url = document.getElementById('url'+i).value;
  6745. var nom = document.getElementById('nom'+i).value;
  6746. var ico = document.getElementById('ico'+i).value;
  6747. if(url && (nom || ico) ) {
  6748. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6749. }
  6750. }
  6751. /* Sauvegarde */
  6752. for(var i=1 ; i<data.length ; i++) {
  6753. MY_setValue('URL'+i,data[i][0]);
  6754. MY_setValue('URL'+i+'.nom',data[i][1]);
  6755. MY_setValue('URL'+i+'.ico',data[i][2]);
  6756. }
  6757. }
  6758.  
  6759. function saveAll() {
  6760. try {
  6761. var urlIco = document.getElementById('icoMenuIco').value;
  6762. if(urlIco) {
  6763. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6764. }
  6765. else {
  6766. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6767. document.getElementById('icoMenuIco').value = '';
  6768. }
  6769. saveLinks();
  6770. refreshLinks();
  6771. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6772. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6773. if(maxcdm) {
  6774. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6775. }
  6776. else {
  6777. MY_removeValue(numTroll+'.MAXCDM');
  6778. document.getElementById('maxcdm').value = '';
  6779. }
  6780.  
  6781. MY_setValue('NOINFOEM',
  6782. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6783. // Pourquoi Tilk stockait-il tout en str ?
  6784. // -> parce que les booléens c'est foireux (vérifié)
  6785. MY_setValue(numTroll+'.USECSS',
  6786. document.getElementById('usecss').checked ? 'true':'false');
  6787. MY_setValue('INFOCARAC',
  6788. document.getElementById('infocarac').checked ? 'true' : 'false');
  6789. //MY_setValue(numTroll+'.SEND_IDT',
  6790. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6791. // Fonctionnalité désactivée
  6792.  
  6793. MY_setValue(numTroll+'.AUTOCDM',
  6794. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6795. MY_setValue('VUECARAC',
  6796. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6797. MY_setValue('CONFIRMEDECALAGE',
  6798. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6799.  
  6800. saveITData();
  6801. } catch (e) {
  6802. var bouton = document.getElementById('saveAll');
  6803. window.console.log(e);
  6804. bouton.value = "il y a eu une erreur";
  6805. return;
  6806. }
  6807.  
  6808. var bouton = document.getElementById('saveAll');
  6809. bouton.value = (bouton.value=='Sauvegardé !') ?
  6810. 'Re-sauvegardé !' : 'Sauvegardé !';
  6811. }
  6812.  
  6813.  
  6814. /*-[functions]----------------- EventListeners -------------------------------*/
  6815.  
  6816. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  6817. var itBody = document.getElementById('itBody');
  6818. var nTr = itBody.rows.length;
  6819. // enlever tous les "+" des lignes précédentes
  6820. for (iTr = 0; iTr < nTr; iTr++) {
  6821. var td = itBody.rows[iTr].cells[0];
  6822. td.innerHTML = '';
  6823. td.title = '';
  6824. td.style.cursor = 'default';
  6825. }
  6826. // ajouter une ligne
  6827. var tr = appendTr(itBody,'mh_tdpage')
  6828. var td = appendTd(tr);
  6829. if (bLast) {
  6830. td.style.whiteSpace = 'nowrap';
  6831. appendText(td, '+');
  6832. td.style.cursor = 'pointer';
  6833. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  6834. td.onclick = function (e) {
  6835. addBricolIT(undefined, undefined, undefined, false, true);
  6836. }
  6837. }
  6838. var td = appendTd(tr);
  6839. td.style.whiteSpace = 'nowrap';
  6840. appendText(td,'Nom du système : ');
  6841. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  6842. td = appendTd(tr);
  6843. td.style.whiteSpace = 'nowrap';
  6844. appendText(td,'Login du compte : ');
  6845. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  6846. td = appendTd(tr);
  6847. td.style.whiteSpace = 'nowrap';
  6848. appendText(td,'Mot de passe du compte : ');
  6849. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  6850. td = appendTd(tr);
  6851. if (bFirst) {
  6852. td.style.whiteSpace = 'nowrap';
  6853. appendText(td,'Affichage des Trõlls hors vue : ');
  6854. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  6855. }
  6856. }
  6857.  
  6858. function onChangeIT() {
  6859. var IT = document.getElementById('itSelect').value;
  6860. var itBody = document.getElementById('itBody');
  6861. itBody.innerHTML = '';
  6862. var tabStr = new Array();
  6863. if(IT=='bricol') {
  6864. for (var iBricol = 1; ; iBricol++) {
  6865. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  6866. //window.console.log('onChangeIT str=' + str);
  6867. if(str) {
  6868. tabStr.push(str);
  6869. } else {
  6870. break;
  6871. }
  6872. }
  6873. if (tabStr.length == 0) {
  6874. addBricolIT('', '', 0, true, true)
  6875. } else {
  6876. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  6877. var arr = tabStr[iBricol].split('$');
  6878. var system = arr[1];
  6879. var login = arr[2];
  6880. var affhv = arr[4];
  6881. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  6882. }
  6883. }
  6884. }
  6885. }
  6886.  
  6887. function refreshLinks() {
  6888. document.getElementById('linksBody').innerHTML = '';
  6889. var anotherURL = MY_getValue('URL1');
  6890. if(!anotherURL) { addLinkField(); }
  6891. var i=1;
  6892. while(anotherURL && i<99) {
  6893. addLinkField(i,anotherURL,
  6894. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6895. i++;
  6896. anotherURL = MY_getValue('URL'+i);
  6897. }
  6898. }
  6899.  
  6900. function addLinkField(i,url,nom,ico) {
  6901. var linksBody = document.getElementById('linksBody');
  6902. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6903. var tr = appendTr(linksBody);
  6904. var td = appendTdCenter(tr);
  6905. appendText(td,'Lien '+i+' : ');
  6906. appendTextbox(td,'text','url'+i,40,150,url);
  6907. td = appendTdCenter(tr);
  6908. appendText(td,'Nom : ');
  6909. appendTextbox(td,'text','nom'+i,20,150,nom);
  6910. td = appendTdCenter(tr);
  6911. appendText(td,'Icône : ');
  6912. appendTextbox(td,'text','ico'+i,40,150,ico);
  6913. }
  6914.  
  6915. function removeLinkField() {
  6916. var linksBody = document.getElementById('linksBody');
  6917. var i = linksBody.childNodes.length;
  6918. MY_removeValue('URL'+i);
  6919. MY_removeValue('URL'+i+'.nom');
  6920. MY_removeValue('URL'+i+'.ico');
  6921. linksBody.removeChild(linksBody.lastChild);
  6922. if(linksBody.childNodes.length==0) { addLinkField(); }
  6923. }
  6924.  
  6925. function resetMainIco() {
  6926. document.getElementById('icoMenuIco').value=
  6927. URL_MZimg + 'mz_logo_small.png';
  6928. }
  6929.  
  6930.  
  6931. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6932.  
  6933. function insertTitle(next,txt) {
  6934. var div = document.createElement('div');
  6935. div.className = 'titre2';
  6936. appendText(div,txt);
  6937. insertBefore(next,div);
  6938. return div;
  6939. }
  6940.  
  6941. function insertMainTable(next) {
  6942. var table = document.createElement('table');
  6943. table.width = '98%';
  6944. table.border = 0;
  6945. table.align = 'center';
  6946. table.cellPadding = 2;
  6947. table.cellSpacing = 1;
  6948. table.className = 'mh_tdborder';
  6949. var tbody = document.createElement('tbody');
  6950. table.appendChild(tbody);
  6951. insertBefore(next,table);
  6952. return tbody;
  6953. }
  6954.  
  6955. function appendSubTable(node) {
  6956. var table = document.createElement('table');
  6957. table.width = '100%';
  6958. var tbody = document.createElement('tbody');
  6959. table.appendChild(tbody);
  6960. node.appendChild(table);
  6961. return tbody;
  6962. }
  6963.  
  6964. function insertOptionTable(insertPt) {
  6965. var mainBody = insertMainTable(insertPt);
  6966. /* Liens dans le Menu */
  6967. var tr = appendTr(mainBody,'mh_tdtitre');
  6968. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6969. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6970. appendText(td,'Icône du Menu: ');
  6971. var url = MY_getValue(numTroll+'.ICOMENU');
  6972. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6973. url = URL_MZimg + 'mz_logo_small.png';
  6974. }
  6975. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6976. appendButton(td,'Réinitialiser',resetMainIco);
  6977. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6978. var tbody = appendSubTable(td);
  6979. tbody.id = 'linksBody';
  6980. refreshLinks();
  6981. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6982. appendButton(td,'Ajouter',addLinkField);
  6983. appendButton(td,'Supprimer',removeLinkField);
  6984. /* Options de la Vue : vue externe, nb de CdM, etc */
  6985. tr = appendTr(mainBody,'mh_tdtitre');
  6986. appendTdText(tr,'Options de la Vue :',true);
  6987. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6988. tbody = appendSubTable(td);
  6989. tr = appendTr(tbody);
  6990. td = appendTdText(tr,'Vue externe : ');
  6991. var select = document.createElement('select');
  6992. select.id = 'vueext';
  6993. td.appendChild(select);
  6994. var listeVues2D = [
  6995. 'Bricol\' Vue',
  6996. 'Vue du CCM',
  6997. 'Vue Gloumfs 2D',
  6998. 'Vue Gloumfs 3D',
  6999. 'Grouky Vue!'
  7000. ];
  7001. for(var i=0 ; i<listeVues2D.length ; i++) {
  7002. appendOption(select,listeVues2D[i],listeVues2D[i]);
  7003. }
  7004. if(MY_getValue('VUEEXT')) {
  7005. select.value = MY_getValue('VUEEXT');
  7006. }
  7007. td = appendTd(tr);
  7008. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  7009. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  7010. tr = appendTr(tbody);
  7011. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  7012. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  7013. td = appendTd(tr);
  7014. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  7015. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  7016. /* Interface Tactique */
  7017. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7018. appendText(td,'Interface Tactique : ',true);
  7019. select = document.createElement('select');
  7020. select.id = 'itSelect';
  7021. appendOption(select,'none','Aucune');
  7022. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  7023. // seule interface supportée !
  7024. td.appendChild(select);
  7025. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7026. tbody = appendSubTable(td);
  7027. tbody.id = 'itBody';
  7028. select.onchange = onChangeIT;
  7029. var str = MY_getValue(numTroll+'.INFOSIT');
  7030. if(str) {
  7031. select.value = str.slice(0,str.indexOf('$'));
  7032. onChangeIT();
  7033. }
  7034. /* Options diverses */
  7035. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7036. appendText(td,'Options diverses :',true);
  7037. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7038. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  7039. appendText(td,
  7040. ' Afficher les caractéristiques des équipements des autres Trõlls');
  7041. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7042. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  7043. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  7044. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7045. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  7046. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  7047. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7048. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  7049. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  7050. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7051. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  7052. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  7053. /* Bouton SaveAll */
  7054. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  7055. input = appendButton(td,'Sauvegarder',saveAll);
  7056. input.id = 'saveAll';
  7057. }
  7058.  
  7059. function insertCreditsTable(insertPt) {
  7060. var tbody = insertMainTable(insertPt);
  7061. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  7062. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  7063. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  7064.  
  7065. var ul = document.createElement('ul');
  7066. td.appendChild(ul);
  7067. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  7068. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  7069. appendLI(ul,'Reivax (4234) pour les infos bulles');
  7070. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  7071. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  7072. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  7073. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  7074. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  7075. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  7076. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  7077. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  7078. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  7079. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  7080. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  7081. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  7082. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  7083. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  7084. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  7085. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  7086. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  7087. }
  7088.  
  7089.  
  7090. /* [functions] Obsolètes */
  7091. function deleteEnchantement()
  7092. {
  7093. try
  7094. {
  7095. var idEquipement = this.getAttribute('name');
  7096. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  7097. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  7098. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  7099. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  7100. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  7101. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7102. var string = "";
  7103. for(var i=0;i<listeEquipement.length;i++)
  7104. {
  7105. if(listeEquipement[i]!=idEquipement)
  7106. if(string=="")
  7107. string = listeEquipement[i];
  7108. else
  7109. string += ";"+listeEquipement[i];
  7110. }
  7111. if(string=="")
  7112. {
  7113. MY_removeValue(numTroll+".enchantement.liste");
  7114. var table = this.parentNode.parentNode.parentNode.parentNode;
  7115. var parent = table.parentNode;
  7116. for(var i=0;i<parent.childNodes.length;i++)
  7117. {
  7118. if(parent.childNodes[i]==table)
  7119. {
  7120. parent.removeChild(parent.childNodes[i-1]);
  7121. parent.removeChild(parent.childNodes[i-1]);
  7122. parent.removeChild(parent.childNodes[i-1]);
  7123. break;
  7124. }
  7125. }
  7126. }
  7127. else
  7128. {
  7129. MY_getValue(numTroll+".enchantement.liste",string);
  7130. this.parentNode.parentNode.parentNode
  7131. .removeChild(this.parentNode.parentNode);
  7132. }
  7133. }
  7134. catch(e)
  7135. {
  7136. window.alert(e);
  7137. }
  7138. }
  7139. /* [functions] fin Obsolètes */
  7140.  
  7141. /*-[functions]---------------- Partie principale -----------------------------*/
  7142.  
  7143. function do_option() {
  7144. start_script(712);
  7145. var insertPoint = document.getElementById('footer1');
  7146. insertBefore(insertPoint,document.createElement('p'));
  7147. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  7148. ti.onclick = function (e) {
  7149. var evt = e || window.event;
  7150. if (evt.shiftKey) {
  7151. var txt = '';
  7152. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  7153. var k = localStorage.key(i);
  7154. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  7155. txt += k + "\t" + localStorage.getItem(k) + "\n";
  7156. }
  7157. copyTextToClipboard(txt);
  7158. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  7159. } else if (evt.ctrlKey) {
  7160. var tabK= [];
  7161. var sMatch = numTroll + '.';
  7162. var lMatch = sMatch.length;
  7163. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  7164. var k = localStorage.key(i);
  7165. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  7166. }
  7167. for (var i = 0; i < tabK.length; ++i ) {
  7168. MY_removeValue(tabK[i]);
  7169. }
  7170. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  7171. }
  7172. }
  7173. ti.title = 'Version ' + GM_info.script.version;
  7174. insertOptionTable(insertPoint);
  7175. /* insertion enchantements ici
  7176. if(...)
  7177. insertEnchantementTable();
  7178. */
  7179. insertBefore(insertPoint,document.createElement('p'));
  7180. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  7181. ti.onclick = function (e) {
  7182. var evt = e || window.event;
  7183. if (!evt.shiftKey) return;
  7184. var oldDev = MY_getValue('MZ_dev');
  7185. if (oldDev) {
  7186. MY_removeValue('MZ_dev');
  7187. } else {
  7188. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  7189. MY_setValue('MZ_dev', 1);
  7190. }
  7191. document.location.href = document.location.href;
  7192. }
  7193. insertCreditsTable(insertPoint);
  7194. insertBefore(insertPoint,document.createElement('p'));
  7195.  
  7196. /* [zone] Obsolète ?? */
  7197. if(MY_getValue(numTroll+".enchantement.liste")
  7198. && MY_getValue(numTroll+".enchantement.liste")!="" )
  7199. {
  7200. insertTitle(insertPoint, 'Les Enchantements en cours');
  7201. table = document.createElement('table');
  7202. table.setAttribute('width', '98%');
  7203. table.setAttribute('border', '0');
  7204. table.setAttribute('align', 'center');
  7205. table.setAttribute('cellpadding', '2');
  7206. table.setAttribute('cellspacing', '1');
  7207. table.setAttribute('class', 'mh_tdborder');
  7208.  
  7209. tbody = document.createElement('tbody');
  7210. table.appendChild(tbody);
  7211. tr = appendTr(tbody, 'mh_tdtitre');
  7212. appendTdText(tr, 'Equipement',1);
  7213. appendTdText(tr, 'Composants',1);
  7214. appendTdText(tr, 'Enchanteur',1);
  7215. appendTdText(tr, 'Action',1);
  7216. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7217. for(var i=0;i<listeEquipement.length;i++)
  7218. {
  7219. try
  7220. {
  7221. var idEquipement = listeEquipement[i];
  7222. var nomEquipement = MY_getValue(numTroll+".enchantement."
  7223. +idEquipement+".objet");
  7224. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  7225. +idEquipement+".enchanteur").split(";");
  7226. var ul = document.createElement('UL');
  7227. for(var j=0;j<3;j++)
  7228. {
  7229. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  7230. var v = MY_getValue(k);
  7231. if (v == null) { // protection Roule 26/08/2017
  7232. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  7233. continue;
  7234. }
  7235. var infoComposant = v.split(';');
  7236. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  7237. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  7238. continue;
  7239. }
  7240. var texte = infoComposant[4].replace("Ril ","Œil ");
  7241. for(var k=5;k<infoComposant.length;k++)
  7242. {
  7243. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  7244. }
  7245. li = appendLI(ul,texte);
  7246. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  7247. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  7248. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  7249. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  7250. string+= '<input type="hidden" name="q" value="min" />';
  7251. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  7252. 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>';
  7253.  
  7254. string+= '</form>';
  7255. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  7256. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  7257. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  7258. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  7259. li.innerHTML += string;
  7260. }
  7261. tr = appendTr(tbody, 'mh_tdpage');
  7262. td = appendTdText(tr, nomEquipement);
  7263. td.setAttribute('valign', 'center');
  7264. td = document.createElement('td');
  7265. td.appendChild(ul);
  7266. tr.appendChild(td);
  7267. td.setAttribute('valign', 'center');
  7268. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  7269. td.setAttribute('valign', 'center');
  7270. td = document.createElement('td');
  7271. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  7272. input.setAttribute('name', idEquipement);
  7273. tr.appendChild(td);
  7274. td.setAttribute('valign', 'center');
  7275. }
  7276. catch(e)
  7277. {
  7278. }
  7279. }
  7280. insertBefore(insertPoint, table);
  7281. insertBefore(insertPoint, document.createElement('p'));
  7282. }
  7283. /* [zone] fin Obsolète ?? */
  7284.  
  7285.  
  7286. displayScriptTime();
  7287. }
  7288.  
  7289. /*******************************************************************************
  7290. * This file is part of Mountyzilla. *
  7291. * *
  7292. * Mountyzilla is free software; you can redistribute it and/or modify *
  7293. * it under the terms of the GNU General Public License as published by *
  7294. * the Free Software Foundation; either version 2 of the License, or *
  7295. * (at your option) any later version. *
  7296. * *
  7297. * Mountyzilla is distributed in the hope that it will be useful, *
  7298. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7299. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7300. * GNU General Public License for more details. *
  7301. * *
  7302. * You should have received a copy of the GNU General Public License *
  7303. * along with Mountyzilla; if not, write to the Free Software *
  7304. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7305. *******************************************************************************/
  7306.  
  7307. // x~x equip
  7308.  
  7309. /**
  7310. * 2014-02-08 - v2.0a (from scratch)
  7311. * 2014-02-18 - v2.0a0
  7312. * - ajout calcul Carats / UM des minerais + totaux
  7313. * 2014-03-06 - v2.0a1
  7314. * - retour Infos EM des Champis
  7315. * TODO
  7316. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  7317. */
  7318.  
  7319. function traiteChampis() {
  7320. try{
  7321. var tr = document.getElementById('mh_objet_hidden_Champignon');
  7322. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  7323. }
  7324. catch(e){return;}
  7325. if(trlist.length<=0) return;
  7326. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  7327. var node = trlist.snapshotItem(i).childNodes[7];
  7328. var str = node.textContent.trim();
  7329. var type = str.slice(0,str.lastIndexOf(' '));
  7330. var mundi = mundiChampi[type];
  7331. if(!mundi) continue;
  7332. var urlImg = URL_MZimg
  7333. +'Competences/ecritureMagique.png';
  7334. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  7335. appendText(node,' ');
  7336. node.appendChild(img);
  7337. }
  7338. }
  7339.  
  7340. function traiteCompos() {
  7341. try {
  7342. var tr = document.getElementById('mh_objet_hidden_Composant');
  7343. var tbody = document.evaluate("./td/table/tbody",
  7344. tr, null, 9, null).singleNodeValue;
  7345. }
  7346. catch(e) {return;}
  7347. insererInfosEM(tbody);
  7348. }
  7349.  
  7350. function traiteMinerai() {
  7351. try{
  7352. var tr = document.getElementById('mh_objet_hidden_Minerai');
  7353. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  7354. }
  7355. catch(e){return;}
  7356. if(trlist.length<=0) return;
  7357. var totaux = {};
  7358. var str;
  7359. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  7360. var node = trlist.snapshotItem(i);
  7361. var nature = node.childNodes[7].textContent,
  7362. caracs = node.childNodes[9].textContent;
  7363. var taille = Number(caracs.match(/\d+/)[0]);
  7364. var coef = 1;
  7365. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  7366. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  7367. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  7368. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  7369. if(nature.indexOf('Mithril')!=-1) {
  7370. coef = 0.2*coef;
  7371. str = ' | UM: ';
  7372. }
  7373. else {
  7374. coef = 0.75*coef+1.25;
  7375. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  7376. str = ' | Carats: ';
  7377. }
  7378. var carats = Math.round(taille*coef)
  7379. appendText(node.childNodes[9], str+carats );
  7380. if(!totaux[nature]) {
  7381. totaux[nature] = [taille,carats];
  7382. }
  7383. else {
  7384. totaux[nature][0] += taille;
  7385. totaux[nature][1] += carats;
  7386. }
  7387. }
  7388. str = 'Total : ';
  7389. for(var nature in totaux) {
  7390. if(str.length>8) str += ', ';
  7391. if(nature.indexOf('Mithril')!=-1) {
  7392. str += nature+totaux[nature][1]+' UM';
  7393. }
  7394. else {
  7395. str += nature+totaux[nature][0]+'U/'
  7396. +totaux[nature][1]+'c';
  7397. }
  7398. }
  7399. /*var node = document.getElementById('mh_plus_Minerai');
  7400. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  7401. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  7402. if(!titre) return;*/
  7403. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  7404. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  7405. td.colSpan = 7;
  7406. }
  7407.  
  7408. function do_equip() {
  7409. start_script();
  7410.  
  7411. traiteChampis();
  7412. traiteCompos();
  7413. traiteMinerai();
  7414.  
  7415. displayScriptTime();
  7416. }
  7417.  
  7418. /*******************************************************************************
  7419. * This file is part of Mountyzilla. *
  7420. * *
  7421. * Mountyzilla is free software; you can redistribute it and/or modify *
  7422. * it under the terms of the GNU General Public License as published by *
  7423. * the Free Software Foundation; either version 2 of the License, or *
  7424. * (at your option) any later version. *
  7425. * *
  7426. * Mountyzilla is distributed in the hope that it will be useful, *
  7427. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7428. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7429. * GNU General Public License for more details. *
  7430. * *
  7431. * You should have received a copy of the GNU General Public License *
  7432. * along with Mountyzilla; if not, write to the Free Software *
  7433. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7434. *******************************************************************************/
  7435.  
  7436. // x~x diplo
  7437.  
  7438. /*
  7439. TODO:
  7440. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  7441. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  7442. V Étape 3: Ajout de la diplo perso
  7443. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  7444. V Étape 5: Ajout des fioritures (preview de la couleur...)
  7445. Options Globales:
  7446. Actuelles:
  7447. numTroll.USECSS,
  7448. numTroll.NODIPLO
  7449. NOMYTH
  7450. Nouvelles:
  7451. TODO numTroll.USECSS
  7452. numTroll.diplo.off (remplace NODIPLO)
  7453. numTroll.diplo.guilde
  7454. numTroll.diplo.perso
  7455. Structure de diplo.guilde:
  7456. isOn: 'true' ou 'false'
  7457. isDetailOn: 'true' ou 'false'
  7458. guilde
  7459. > id
  7460. > couleur
  7461. AllAmis,AllEnnemis: couleur
  7462. Amis0,...,Ennemis5
  7463. > Troll: idTroll1;...;
  7464. > Guilde: idGuilde1;...;
  7465. > titre
  7466. > couleur
  7467. Structure de diplo.perso:
  7468. isOn: 'true' ou 'false'
  7469. mythiques: couleur
  7470. Troll,Guilde,Monstre:
  7471. > id
  7472. > couleur
  7473. > description
  7474. */
  7475.  
  7476. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7477.  
  7478. function couleurAleatoire() {
  7479. var alph = '0123456789ABCDEF'.split('');
  7480. var clr = '#';
  7481. for (var i=0; i<6; i++) {
  7482. clr+=alph[ Math.floor(16*Math.random()) ];
  7483. }
  7484. return clr;
  7485. }
  7486.  
  7487. function isCouleur(str) {
  7488. return /^#[0-9A-F]{6}$/i.test(str);
  7489. }
  7490.  
  7491. /*-[functions]---------------- Analyse de la page ----------------------------*/
  7492.  
  7493. function appendChoixCouleur(node,id) {
  7494. var span = document.createElement('span');
  7495. span.id = 'span'+id;
  7496. if(isDetailOn) {
  7497. span.style.display = 'none';
  7498. }
  7499. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  7500. if(diploGuilde[id]) {
  7501. couleur = diploGuilde[id];
  7502. }
  7503. appendText(span,' - Couleur HTML: ');
  7504. var input = appendTextbox(span,'text',id,7,7,couleur);
  7505. input.onkeyup = previewCouleur;
  7506. input.onchange = previewCouleur;
  7507. input.onkeyup();
  7508. node.appendChild(span);
  7509. }
  7510.  
  7511. function insertChoixCouleur(node,id) {
  7512. var span = document.createElement('span');
  7513. span.id = 'span'+id;
  7514. // La couleur détaillée passera à une valeur aléatoire
  7515. // si toggle vers isDetailOn
  7516. var couleur = couleurAleatoire();
  7517. if(!isDetailOn) {
  7518. span.style.display = 'none';
  7519. } else if(diploGuilde[id]) {
  7520. couleur = diploGuilde[id].couleur;
  7521. }
  7522. appendText(span,' - Couleur HTML: ');
  7523. var input = appendTextbox(span,'text',id,7,7,couleur);
  7524. input.onkeyup = previewCouleur;
  7525. input.onchange = previewCouleur;
  7526. input.onkeyup();
  7527. insertBefore(node,span);
  7528. }
  7529.  
  7530. function setChoixCouleurs() {
  7531. try {
  7532. //var form = document.getElementsByName('ActionForm')[0];
  7533. var form = document.getElementById('mhPlay');
  7534. var nodesAE = document.evaluate(
  7535. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  7536. "./table/tbody/tr/th[@class='mh_tdtitre']",
  7537. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  7538. form, null, 7, null
  7539. );
  7540. var nodes = document.evaluate(
  7541. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  7542. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  7543. form, null, 7, null
  7544. );
  7545. } catch(e) {
  7546. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  7547. return false;
  7548. };
  7549. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  7550. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  7551. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  7552. for(var i=0 ; i<5 ; i++) {
  7553. nodes.snapshotItem(i).id = 'tdAmis'+i;
  7554. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  7555. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  7556. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  7557. }
  7558. return true;
  7559. }
  7560.  
  7561. function fetchDiploGuilde() {
  7562. try {
  7563. for(var AE in {Amis:0,Ennemis:0}) {
  7564. for(var i=0 ; i<5 ; i++) {
  7565. /* Récup des A/E de rang i */
  7566. var td = document.getElementById('td'+AE+i);
  7567. var ligne = td.getElementsByTagName('table')[0].rows;
  7568. var titre = trim(td.firstChild.textContent);
  7569. // On laisse la gestion des couleurs à setChoixCouleurs:
  7570. var couleur = document.getElementById(AE+i).value;
  7571. diploGuilde[AE+i] = {
  7572. Troll:'',
  7573. Guilde:'',
  7574. titre: titre,
  7575. couleur: couleur
  7576. };
  7577. for(var j=1 ; j<ligne.length ; j++) {
  7578. var str = trim(ligne[j].cells[0].textContent);
  7579. var idx = str.lastIndexOf('(');
  7580. var num = str.slice(idx+1,-1);
  7581. var type = trim(ligne[j].cells[1].textContent);
  7582. diploGuilde[AE+i][type] += num+';';
  7583. }
  7584. }
  7585. }
  7586. } catch(e) {
  7587. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  7588. return false;
  7589. }
  7590. return true;
  7591. }
  7592.  
  7593.  
  7594. /*-[functions]--------------------- Handlers ---------------------------------*/
  7595.  
  7596. function toggleDetails() {
  7597. isDetailOn = !isDetailOn;
  7598. for(var AE in {Amis:0,Ennemis:0}) {
  7599. document.getElementById('spanAll'+AE).style.display =
  7600. (isDetailOn?'none':'');
  7601. for(var i=0 ; i<5 ; i++) {
  7602. document.getElementById('span'+AE+i).style.display =
  7603. (isDetailOn?'':'none');
  7604. }
  7605. }
  7606. }
  7607.  
  7608. function toggleMythiques() {
  7609. isMythiquesOn = !isMythiquesOn;
  7610. document.getElementById('spanMythiques').style.display =
  7611. (isMythiquesOn?'':'none');
  7612. }
  7613.  
  7614. function previewCouleur() {
  7615. var value = this.value;
  7616. if(isCouleur(value)) {
  7617. this.style.backgroundColor = value;
  7618. this.title = '';
  7619. } else {
  7620. this.style.backgroundColor = '';
  7621. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  7622. }
  7623. }
  7624.  
  7625. function appendMenuType(node,duType) {
  7626. var select = document.createElement('select');
  7627. select.className = 'SelectboxV2';
  7628. var type = ['Guilde','Troll','Monstre'];
  7629. for(var i=0 ; i<3 ; i++) {
  7630. appendOption(select,type[i],type[i]);
  7631. if(type[i]==duType) { select.selectedIndex=i; }
  7632. }
  7633. node.appendChild(select);
  7634. }
  7635.  
  7636. function ajouteChamp(type,num,couleur,descr) {
  7637. var champs = document.getElementById('diploPerso');
  7638. var nb = champs.rows.length;
  7639. var tr = champs.insertRow(-1);
  7640. var td = appendTd(tr);
  7641. appendMenuType(td,type);
  7642. td = appendTd(tr);
  7643. appendText(td,' n°');
  7644. appendTextbox(td,'text','num'+nb,6,15,num);
  7645. td = appendTd(tr);
  7646. appendText(td,' couleur HTML:');
  7647. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7648. input.onkeyup = previewCouleur;
  7649. input.onchange = previewCouleur;
  7650. input.onkeyup();
  7651. td = appendTd(tr);
  7652. appendText(td,' Description:');
  7653. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7654. td = appendTd(tr);
  7655. var span = document.createElement('span');
  7656. appendText(span,'[ok!]',true);
  7657. span.style.visibility = 'hidden';
  7658. td.appendChild(span);
  7659. td = appendTd(tr);
  7660. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7661. }
  7662.  
  7663. function retireCeChamp() {
  7664. var thisTr = this.parentNode.parentNode;
  7665. thisTr.parentNode.removeChild(thisTr);
  7666. var champs = document.getElementById('diploPerso');
  7667. if(champs.rows.length==0) { ajouteChamp(); }
  7668. }
  7669.  
  7670. function valideChamp(champ) {
  7671. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7672. isCouleur(champ.cells[2].childNodes[1].value);
  7673. if(isValide) {
  7674. champ.cells[4].firstChild.style.visibility = 'visible';
  7675. } else {
  7676. champ.cells[4].firstChild.style.visibility = 'hidden';
  7677. }
  7678. return isValide;
  7679. }
  7680.  
  7681. function sauvegarderTout() {
  7682. /* Diplo de guilde */
  7683. diploGuilde.isOn =
  7684. document.getElementById('isGuildeOn').checked?'true':'false';
  7685. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7686. var numGuilde = Number(document.getElementById('numGuilde').value);
  7687. var couleur = document.getElementById('couleurGuilde').value;
  7688. if(numGuilde) {
  7689. diploGuilde.guilde = {
  7690. id: numGuilde,
  7691. couleur: couleur
  7692. };
  7693. } else {
  7694. delete diploGuilde.guilde;
  7695. }
  7696. for(var AE in {Amis:0,Ennemis:0}) {
  7697. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7698. for(var i=0 ; i<5 ; i++) {
  7699. if(isDetailOn) {
  7700. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7701. } else {
  7702. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7703. }
  7704. }
  7705. }
  7706. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7707. /* Diplo personnelle (ex-fonction saveChamps) */
  7708. var champs = document.getElementById('diploPerso');
  7709. diploPerso = {
  7710. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7711. Guilde: {},
  7712. Troll: {},
  7713. Monstre: {}
  7714. };
  7715. if(isMythiquesOn &&
  7716. isCouleur(document.getElementById('couleurMythiques').value)) {
  7717. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7718. }
  7719. for(var i=0 ; i<champs.rows.length ; i++) {
  7720. if(valideChamp(champs.rows[i])) {
  7721. var type = champs.rows[i].cells[0].firstChild.value;
  7722. var num = champs.rows[i].cells[1].childNodes[1].value;
  7723. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7724. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7725. diploPerso[type][num] = {
  7726. couleur: couleur
  7727. };
  7728. if(descr) {
  7729. diploPerso[type][num].titre = descr;
  7730. }
  7731. }
  7732. }
  7733. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7734.  
  7735. avertissement('Données sauvegardées');
  7736. }
  7737.  
  7738.  
  7739. /*-[functions]------------- Modifications de la page -------------------------*/
  7740.  
  7741. function creeTablePrincipale() {
  7742. var insertPt = document.getElementById('insertPt');
  7743. /* Titre + bouton de Sauvegarde */
  7744. var tr = insertTr(insertPt,'mh_tdtitre');
  7745. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7746. appendButton(td,'Sauvegarder',sauvegarderTout);
  7747. /* Options fixes */
  7748. tr = insertTr(insertPt,'mh_tdpage');
  7749. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7750. appendBr(td);
  7751. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7752. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7753. appendBr(td);
  7754. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7755. appendText(td,'Utiliser des couleurs détaillées (10)');
  7756. /* Diplo personnelle */
  7757. tr = insertTr(insertPt,'mh_tdpage');
  7758. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7759. appendBr(td);
  7760. // Diplo Mythiques
  7761. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7762. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7763. var span = document.createElement('span');
  7764. span.id = 'spanMythiques';
  7765. if(!isMythiquesOn) {
  7766. span.style.display = 'none';
  7767. }
  7768. var couleur = '#FFAAAA';
  7769. if(diploPerso.mythiques) {
  7770. couleur = diploPerso.mythiques;
  7771. }
  7772. appendText(span,' - couleur HTML:');
  7773. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7774. input.onkeyup = previewCouleur;
  7775. input.onchange = previewCouleur;
  7776. input.onkeyup();
  7777. td.appendChild(span);
  7778. appendBr(td);
  7779. // Diplo éditable
  7780. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7781. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7782. appendBr(td);
  7783. var table = document.createElement('table');
  7784. table.id = 'diploPerso'
  7785. td.appendChild(table);
  7786. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7787. for(var num in diploPerso[type]) {
  7788. ajouteChamp(
  7789. type,
  7790. num,
  7791. diploPerso[type][num].couleur,
  7792. diploPerso[type][num].titre
  7793. );
  7794. }
  7795. }
  7796. if(table.rows.length==0) {
  7797. ajouteChamp();
  7798. }
  7799. appendButton(td,'Ajouter',ajouteChamp)
  7800. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7801. appendText(td,' ');
  7802. appendButton(td,
  7803. 'Exemples de couleur',
  7804. function() {
  7805. var fenetre = window.open(
  7806. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7807. 'Divers',
  7808. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7809. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7810. );
  7811. fenetre.focus();
  7812. }
  7813. );
  7814. /* Couleur de Guilde */
  7815. tr = insertTr(insertPt,'mh_tdtitre');
  7816. td = appendTdText(tr,'GUILDE',true);
  7817. appendText(td,' - n°');
  7818. appendTextbox(td,'text','numGuilde',5,10,
  7819. diploGuilde.guilde && diploGuilde.guilde.id ?
  7820. diploGuilde.guilde.id : ''
  7821. );
  7822. appendText(td,' - Couleur HTML: ');
  7823. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7824. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7825. diploGuilde.guilde.couleur : '#BBBBFF'
  7826. );
  7827. input.onkeyup = previewCouleur;
  7828. input.onchange = previewCouleur;
  7829. input.onkeyup();
  7830. }
  7831.  
  7832.  
  7833. /*-[functions]----------------------- Main -----------------------------------*/
  7834.  
  7835. function initDiplo(sType) {
  7836. var sDiplo = MY_getValue(numTroll + '.diplo.' + sType)
  7837. //console.log('sDiplo' + sType + '=' + sDiplo);
  7838. if (sDiplo && (sDiplo != 'null')) { // le stockage JSON nous donne parfois 'null'
  7839. return JSON.parse(sDiplo);
  7840. } else {
  7841. return {};
  7842. }
  7843. }
  7844. var diploGuilde = initDiplo('guilde');
  7845. var diploPerso = initDiplo('perso');
  7846. var isDetailOn = diploGuilde.isDetailOn=='true';
  7847. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7848.  
  7849. function do_diplo() {
  7850. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7851. creeTablePrincipale();
  7852. }
  7853. }
  7854.  
  7855. /*******************************************************************************
  7856. * This file is part of Mountyzilla. *
  7857. * *
  7858. * Mountyzilla is free software; you can redistribute it and/or modify *
  7859. * it under the terms of the GNU General Public License as published by *
  7860. * the Free Software Foundation; either version 2 of the License, or *
  7861. * (at your option) any later version. *
  7862. * *
  7863. * Mountyzilla is distributed in the hope that it will be useful, *
  7864. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7865. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7866. * GNU General Public License for more details. *
  7867. * *
  7868. * You should have received a copy of the GNU General Public License *
  7869. * along with Mountyzilla; if not, write to the Free Software *
  7870. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7871. *******************************************************************************/
  7872.  
  7873. // x~x cdmcomp
  7874.  
  7875. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  7876.  
  7877. function getNonNegInts(str) {
  7878. var nbrs = str.match(/\d+/g);
  7879. for(var i=0 ; i<nbrs.length ; i++) {
  7880. nbrs[i] = Number(nbrs[i]);
  7881. }
  7882. return nbrs;
  7883. }
  7884.  
  7885. function traiteCdMcomp() {
  7886. try {
  7887. var msgEffet = document.getElementById('msgEffet');
  7888. } catch(e) {
  7889. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  7890. return;
  7891. }
  7892.  
  7893. // Teste si ce message du bot est un message de CdM
  7894. if(!document.evaluate(
  7895. "./p/text()[contains(.,'fait partie')]",
  7896. msgEffet, null, 9, null
  7897. ).singleNodeValue) {
  7898. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  7899. return;
  7900. }
  7901. // Début de récupération de la CdM
  7902. /*
  7903. Roule 10/03/2017 j'ai grandement simplifié ☺ ☺ ☺
  7904. zone à supprimer
  7905. traitement Armure Physique/Magique reporté en php
  7906.  
  7907. cdm = document.evaluate(
  7908. "./p/text()[contains(.,'fait partie')]",
  7909. msgEffet, null, 9, null
  7910. ).singleNodeValue.nodeValue+'\n';
  7911. var tbody = document.evaluate(
  7912. "descendant::table/tbody",
  7913. msgEffet, null, 9, null
  7914. ).singleNodeValue;
  7915. var nomStat = document.evaluate(
  7916. "./tr/td[1]/b/text()",
  7917. tbody, null, 7, null
  7918. );
  7919. var valStat = document.evaluate(
  7920. "./tr/td[2]/descendant::text()",
  7921. tbody, null, 7, null
  7922. );
  7923. var i=0;
  7924. while(i<nomStat.snapshotLength) {
  7925. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7926. cdm += 'Armure : ';
  7927. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7928. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7929. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7930. armp = [0,armp[0]];
  7931. }
  7932. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7933. armm = [0,armm[0]];
  7934. }
  7935. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7936. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7937. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7938. } else {
  7939. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7940. }
  7941. cdm += ')\n';
  7942. i++;
  7943. } else {
  7944. cdm += nomStat.snapshotItem(i).nodeValue+
  7945. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7946. }
  7947. i++;
  7948. }
  7949. */
  7950. //cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  7951. //if (MY_DEBUG) window.console.log('cmd=' + cdm);
  7952.  
  7953. // envoi au serveur (PHP) d'un objet avec
  7954. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  7955. // tstamp: l'horodatage
  7956. var tabCdM = new Array();
  7957. var etimestamp = document.getElementById('hserveur');
  7958. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  7959. var txtBlessure;
  7960. var txtPv;
  7961. for (var iElt = 0; iElt < msgEffet.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  7962. var eHTML = msgEffet.childNodes[iElt];
  7963. switch (eHTML.nodeName) {
  7964. case '#text':
  7965. var s = eHTML.nodeValue.trim();
  7966. if (s != '') tabCdM.push(s);
  7967. break;
  7968. case 'P':
  7969. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7970. s = s.trim();
  7971. if (s != '') tabCdM.push(s);
  7972. break;
  7973. case 'TABLE':
  7974. var s = 'table';
  7975. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  7976. var eTr = eHTML.rows[iTr];
  7977. var tabTd = new Array();
  7978. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  7979. var eTd = eTr.cells[iTd];
  7980. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  7981. s = s.trim();
  7982. tabTd.push(s);
  7983. }
  7984. if (tabTd.length >= 2) {
  7985. if (tabTd[0].match(/Blessure/i)) {
  7986. txtBlessure = tabTd[1]
  7987. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  7988. txtPv = tabTd[1]
  7989. }
  7990. }
  7991. tabCdM.push(tabTd);
  7992. }
  7993. break;
  7994. default:
  7995. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  7996. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7997. if (s != '') tabCdM.push(s);
  7998. break;
  7999. }
  8000. }
  8001. var oData = {};
  8002. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  8003. oData.idTroll = numTroll;
  8004. oData.tabCdM = tabCdM;
  8005. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  8006.  
  8007. // envoi d'une CdM issue de compte-rendu de compétence
  8008. // fonction définie ici pour avoir vue sur la variable tabCdM
  8009. var sendInfoCDM = function () {
  8010. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  8011. var buttonCDM = this;
  8012. var texte = '';
  8013. FF_XMLHttpRequest({
  8014. method: 'POST',
  8015. url: URL_pageDispatcherV2,
  8016. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8017. headers : {
  8018. /* inutile, à supprimer
  8019. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8020. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8021. */
  8022. 'Content-type':'application/x-www-form-urlencoded',
  8023. },
  8024. trace: 'envoi CdM',
  8025. onload: function(responseDetails) {
  8026. texte = responseDetails.responseText;
  8027. buttonCDM.value = texte;
  8028. if (!isDEV) buttonCDM.disabled = true;
  8029. }
  8030. });
  8031. }
  8032.  
  8033. // Envoi auto ou insertion bouton envoi (suivant option)
  8034. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  8035. sendInfoCDM();
  8036. var p = document.createElement('p');
  8037. p.style.color = 'green';
  8038. appendText(p,'CdM envoyée vers la base MountyZilla !');
  8039. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  8040. } else {
  8041. insertButtonCdm('as_Action', sendInfoCDM);
  8042. }
  8043.  
  8044. // Insertion de l'estimation des PV restants
  8045. /*
  8046. var pv = valStat.snapshotItem(1).nodeValue;
  8047. if(pv.indexOf("entre")==-1) {
  8048. return;
  8049. }
  8050. var trPv = document.evaluate(
  8051. "//tr[contains(td/b/text(),'Points de Vie')]",
  8052. msgEffet, null, 9, null).singleNodeValue;
  8053. tdPv = trPv.cells[1];
  8054. txtPv = tdPv.innerText || tdPv.textContent;
  8055. if (MY_DEBUG) window.console.log('txtPv=' + txtPv);
  8056. if(0) { //pv) { // bloqué en attendant correction
  8057. */
  8058. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  8059. if (txtBlessure !== undefined && txtPv !== undefined) {
  8060. var pv = getPVsRestants(txtPv,txtBlessure);
  8061. if (MY_DEBUG) window.console.log('pv=' + pv);
  8062. if (pv) { // pv null si le monstre n'est pas blessé
  8063. var trBless = document.evaluate(
  8064. "//tr[contains(td/b/text(),'Blessure')]",
  8065. msgEffet, null, 9, null).singleNodeValue;
  8066. var tr = document.createElement('tr');
  8067. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  8068. appendTr(trBless);
  8069. appendTdText(tr, pv[0], true);
  8070. appendTdText(tr, pv[1], true);
  8071. }
  8072. }
  8073. }
  8074.  
  8075. function do_cdmcomp() {
  8076. start_script(31);
  8077. traiteCdMcomp();
  8078. displayScriptTime();
  8079. }
  8080.  
  8081. /*********************************************************************************
  8082. * This file is part of Mountyzilla. *
  8083. * *
  8084. * Mountyzilla is free software; you can redistribute it and/or modify *
  8085. * it under the terms of the GNU General Public License as published by *
  8086. * the Free Software Foundation; either version 2 of the License, or *
  8087. * (at your option) any later version. *
  8088. * *
  8089. * Mountyzilla is distributed in the hope that it will be useful, *
  8090. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8091. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8092. * GNU General Public License for more details. *
  8093. * *
  8094. * You should have received a copy of the GNU General Public License *
  8095. * along with Mountyzilla; if not, write to the Free Software *
  8096. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8097. *********************************************************************************/
  8098.  
  8099. // x~x cmdbot
  8100.  
  8101. /* v0.2 by Dab - 2013-08-20
  8102. * - patch dégueu pour gérer la décomposition P/M de l'armure
  8103. */
  8104.  
  8105. var buttonCDM;
  8106.  
  8107. /*******************************************************************************************
  8108. CDM :
  8109. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  8110.  
  8111. Il ne vous est pas possible d'améliorer cette compétence.
  8112.  
  8113. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  8114. Niveau : Inimaginable (entre 49 et 51)
  8115. Points de Vie : Surtrollesque (entre 450 et 470)
  8116. Blessure (Approximatif) : 0 %
  8117. Dés d'Attaque : Impressionnant (entre 30 et 32)
  8118. Dés d'Esquive : Impressionnant (entre 28 et 30)
  8119. Dés de Dégat : Très Fort (entre 18 et 20)
  8120. Dés de Régénération : Excellent (égal à 13)
  8121. Armure Physique : Moyen (entre 10 et 12)
  8122. Armure Magique : Faible (inférieur à 6)
  8123. Vue : Moyen (entre 9 et 11)
  8124. Maitrise Magique : Inimaginable (supérieur à 6000)
  8125. Résistance Magique : Inimaginable (supérieur à 6000)
  8126. Nombre d'attaques : 1
  8127. Vitesse de Déplacement : Normale
  8128. Voir le Caché : Oui
  8129. Attaque à distance : Non
  8130. Attaque magique : Oui
  8131. Vole : Non
  8132. Sang froid : Inexistant
  8133. DLA : Milieu
  8134. Durée Tour : Remarquable (entre 9 et 11)
  8135. Chargement : Vide
  8136. Bonus Malus : Aucun
  8137.  
  8138. Vous avez également gagné 1 PX pour la réussite.
  8139. *******************************************************************************************
  8140. BOT :
  8141. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  8142.  
  8143. Le Monstre ciblé fait partie des : Mort-Vivant
  8144.  
  8145. Niveau : Incroyable (entre 36 et 38)
  8146. *******************************************************************************************/
  8147.  
  8148. function getNNInt(str) {
  8149. var nbrs = str.match(/\d+/g);
  8150. for (var i=0 ; i<nbrs.length ; i++)
  8151. nbrs[i] = parseInt(nbrs[i]);
  8152. return nbrs;
  8153. }
  8154.  
  8155. // envoi d'une CdM issue d'un message du BOT
  8156. function sendCDM() {
  8157. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  8158. document, null, 9, null).singleNodeValue;
  8159. /* ancienne version à supprimer
  8160. cdm = td.innerHTML;
  8161. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  8162. "$3$4 ($1 - N°$2)<br>");
  8163. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  8164. 'Blessure : XX % (approximativement)');
  8165. // Supprime la décomposition P/M de l'Armure
  8166. var bgn = cdm.indexOf('Armure Physique');
  8167. if (bgn!=-1) {
  8168. var end = cdm.indexOf('Vue')-2;
  8169. var lines = cdm.substring(bgn,end).split('<br>');
  8170. var armp = getNNInt(lines[0]);
  8171. var armm = getNNInt(lines[1]);
  8172. if (lines[0].indexOf('(inf')!=-1)
  8173. armp = [0,armp[0]];
  8174. if (lines[1].indexOf('(inf')!=-1)
  8175. armm = [0,armm[0]];
  8176. var insrt = 'Armure : ';
  8177. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  8178. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  8179. else
  8180. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  8181. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  8182. }
  8183. cdm = cdm.replace(/<br>/g,'\n');
  8184. */
  8185.  
  8186. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  8187. //window.console.log(tdTxt);
  8188. var oData = {};
  8189. oData.tabCdM = tdTxt.split(/\n/);
  8190. // nettoyage entête : enlève le premier élément tant que
  8191. // - suite de *
  8192. // - "MOUNTYHALL - La Terre des Trõlls"
  8193. // - ligne vide (la première expression régulière matche les lignes vides)
  8194. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  8195. // 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
  8196. var iLigneNonVide;
  8197. for (var i = 0; i < oData.tabCdM.length; i++) {
  8198. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  8199. if (iLigneNonVide === undefined)
  8200. oData.tabCdM.splice(i);
  8201. else
  8202. oData.tabCdM.splice(iLigneNonVide+1);
  8203. break;
  8204. }
  8205. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  8206. }
  8207. //window.console.log(JSON.stringify(oData));
  8208.  
  8209. FF_XMLHttpRequest({
  8210. method: 'POST',
  8211. url: URL_pageDispatcherV2,
  8212. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8213. headers : {
  8214. /* inutile, à supprimer
  8215. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8216. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8217. */
  8218. 'Content-type':'application/x-www-form-urlencoded',
  8219. },
  8220. trace: 'envoi CdM msg du bot',
  8221. onload: function(responseDetails) {
  8222. buttonCDM.value=responseDetails.responseText;
  8223. buttonCDM.disabled = true;
  8224. }
  8225. });
  8226. }
  8227.  
  8228. function traiteCdMmsg() {
  8229. // Teste si ce message du bot est un message de CdM
  8230. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  8231. document, null, 9, null).singleNodeValue;
  8232. if (!td) return false;
  8233. cdm = td.innerHTML;
  8234. // Insertion de l'estimation des PV restants
  8235. var des = cdm.indexOf('Dés');
  8236. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  8237. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  8238. if(pv)
  8239. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  8240.  
  8241. // Insertion bouton envoi + espace
  8242. buttonCDM = insertButtonCdm('bClose',sendCDM);
  8243. }
  8244.  
  8245. /*function traitePouvoir() {
  8246. // Teste si ce message du bot est un message de CdM
  8247. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  8248. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  8249. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8250. if (!td)
  8251. return false;
  8252. var infos = td.innerHTML;
  8253. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  8254. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  8255. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  8256. var date = /alors : ([^<]+)\./.exec(infos)[1];
  8257. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  8258. var effetPouvoir="";
  8259. var full=false;
  8260. if(infos.indexOf("REDUIT")!=-1) {
  8261. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  8262. }
  8263. else {
  8264. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  8265. full=true;
  8266. }
  8267. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  8268. // On insère le bouton et un espace
  8269. //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));
  8270. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  8271. if(!MY_getValue('AUTOSENDPOUV'))
  8272. {
  8273. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  8274. button.setAttribute("onClick", "window.open('" + url
  8275. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  8276. + "this.value='Merci de votre participation'; this.disabled = true;");
  8277. }
  8278. else
  8279. {
  8280. FF_XMLHttpRequest({
  8281. method: 'GET',
  8282. url: url,
  8283. headers : {
  8284. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8285. 'Accept': 'application/atom+xml,application/xml,text/xml'
  8286. }});
  8287. }
  8288. }*/
  8289.  
  8290. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  8291. traiteCdMmsg();
  8292. }
  8293. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  8294.  
  8295. /*******************************************************************************
  8296. * This file is part of Mountyzilla. *
  8297. * *
  8298. * Mountyzilla is free software; you can redistribute it and/or modify *
  8299. * it under the terms of the GNU General Public License as published by *
  8300. * the Free Software Foundation; either version 2 of the License, or *
  8301. * (at your option) any later version. *
  8302. * *
  8303. * Mountyzilla is distributed in the hope that it will be useful, *
  8304. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8305. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8306. * GNU General Public License for more details. *
  8307. * *
  8308. * You should have received a copy of the GNU General Public License *
  8309. * along with Mountyzilla; if not, write to the Free Software *
  8310. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8311. *******************************************************************************/
  8312.  
  8313. // x~x menu
  8314. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  8315.  
  8316. var menuRac, mainIco;
  8317.  
  8318. // met à jour les carac sauvegardées (position, DLA, etc.)
  8319. function updateData() {
  8320. var inputs = document.getElementsByTagName('input');
  8321. var divs = document.getElementsByTagName('div');
  8322.  
  8323. //window.console.log('inputs=' + JSON.stringify(inputs));
  8324. if (inputs && inputs.length > 0) {
  8325. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  8326. numTroll = inputs[0].value;
  8327. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  8328. MY_setValue('NUM_TROLL', numTroll);
  8329. MY_setValue('NIV_TROLL',inputs[1].value);
  8330. if(!MY_getValue(numTroll+'.caracs.rm')) {
  8331. MY_setValue(numTroll+'.caracs.rm',0);
  8332. // assure l'init des 4 var de libs
  8333. }
  8334. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  8335. } else {
  8336. // onclick="EnterPJView(91305,750,550)"
  8337. var tabA = document.getElementsByTagName('a');
  8338. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  8339. var s = tabA[0].onclick.toString();;
  8340. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  8341. var m = s.match(/\((\d+) *,/);
  8342. //window.console.log('m=' + JSON.stringify(m));
  8343. numTroll = parseInt(m[1]);
  8344. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  8345. MY_setValue('NUM_TROLL', numTroll);
  8346. } else {
  8347. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  8348. }
  8349. }
  8350.  
  8351. var DLA = new Date(
  8352. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  8353. );
  8354. if(MY_getValue(numTroll+'.DLA.encours')) {
  8355. var DLAstockee = new Date(
  8356. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  8357. );
  8358. if(DLA>DLAstockee) {
  8359. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  8360. // Pose un pb en cas de décalage de DLA
  8361. }
  8362. }
  8363. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  8364.  
  8365. try {
  8366. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  8367. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  8368. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  8369. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  8370. } catch(e) {
  8371. 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, '‹'));
  8372. }
  8373. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  8374. }
  8375.  
  8376. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  8377. function initRaccourcis() {
  8378. var anotherURL = MY_getValue('URL1');
  8379. if(!anotherURL) { return; }
  8380.  
  8381. /* Création de l'icône faisant apparaître le menu */
  8382. mainIco = document.createElement('img');
  8383. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  8384. if(!urlIco) {
  8385. urlIco =
  8386. URL_MZimg + 'mz_logo_small.png';
  8387. }
  8388. mainIco.src = urlIco;
  8389. mainIco.alt = 'MZ';
  8390. mainIco.style = 'position:fixed; top:0px; left:0px';
  8391. mainIco.onmouseover = afficheMenu;
  8392. document.body.appendChild(mainIco);
  8393. /* Création du menu des Raccourcis */
  8394. menuRac = document.createElement('div');
  8395. menuRac.className = 'mh_textbox';
  8396. menuRac.style =
  8397. 'position:fixed; top:10px; left:10px;'+
  8398. 'max-width:190px;'+
  8399. 'border-radius: 4px; padding: 4px;'+
  8400. 'z-index: 500;'+
  8401. 'visibility: hidden;';
  8402. document.body.appendChild(menuRac);
  8403. document.addEventListener('mousemove',cacheMenu,false);
  8404. var i=1;
  8405. while(anotherURL) {
  8406. var a = document.createElement('a');
  8407. var url = MY_getValue('URL'+i);
  8408. var nom = MY_getValue('URL'+i+'.nom');
  8409. var ico = MY_getValue('URL'+i+'.ico');
  8410. a.href = url;
  8411. a.target = '_blank';
  8412. if(ico) {
  8413. var txt = nom ? nom : '';
  8414. var img = createImage(ico,txt);
  8415. a.appendChild(img);
  8416. }
  8417. else {
  8418. appendText(a,'['+nom+']');
  8419. }
  8420. menuRac.appendChild(a);
  8421. appendBr(menuRac);
  8422. i++;
  8423. anotherURL = MY_getValue('URL'+i);
  8424. }
  8425. }
  8426.  
  8427. function afficheMenu() {
  8428. menuRac.style.visibility = 'visible';
  8429. }
  8430.  
  8431. function cacheMenu(e) {
  8432. if(menuRac.style.visibility=='hidden') { return; }
  8433. // Position souris
  8434. var ptX = e.clientX;
  8435. var ptY = e.clientY;
  8436. // On recalcule en live les BoundingBox pour mainIco et menuRac
  8437. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  8438. var menuRect = menuRac.getBoundingClientRect();
  8439. var icoRect = mainIco.getBoundingClientRect();
  8440. if((ptX>icoRect.width || ptY>icoRect.height) &&
  8441. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  8442. menuRac.style.visibility = 'hidden';
  8443. }
  8444. }
  8445.  
  8446. // ajout de l'icône, branchée sur un refresh
  8447. function initUpdateCoordGauche() {
  8448. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8449. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  8450. var img = document.createElement('img');
  8451. img.src = URL_MZimg + 'recycl.png'
  8452. img.onclick = function(evt) {
  8453. document.location.href = document.location.href;
  8454. };
  8455. img.title = 'Mise à jour de la localisation';
  8456. img.style.cursor = 'pointer';
  8457. img.style.position = 'absolute';
  8458. img.style.bottom = 0;
  8459. img.style.left = 0;
  8460. div.appendChild(img);
  8461. }
  8462.  
  8463. function do_menu() {
  8464. // met à jour les carac sauvegardées (position, DLA, etc.)
  8465. updateData();
  8466. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  8467. initRaccourcis();
  8468. // Ajout bouton de mise à jour coordonnées
  8469. initUpdateCoordGauche();
  8470. }
  8471.  
  8472. /*******************************************************************************
  8473. * This file is part of Mountyzilla. *
  8474. * *
  8475. * Mountyzilla is free software; you can redistribute it and/or modify *
  8476. * it under the terms of the GNU General Public License as published by *
  8477. * the Free Software Foundation; either version 2 of the License, or *
  8478. * (at your option) any later version. *
  8479. * *
  8480. * Mountyzilla is distributed in the hope that it will be useful, *
  8481. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8482. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8483. * GNU General Public License for more details. *
  8484. * *
  8485. * You should have received a copy of the GNU General Public License *
  8486. * along with Mountyzilla; if not, write to the Free Software *
  8487. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8488. *******************************************************************************/
  8489.  
  8490. // x~x vue
  8491.  
  8492. /* TODO
  8493. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  8494. * prévoir fix ("delete infos")
  8495. */
  8496.  
  8497. /*--------------------------- Variables Globales -----------------------------*/
  8498.  
  8499. // Infos remplies par des scripts extérieurs
  8500. var listeCDM = [], listeLevels = [];
  8501.  
  8502. // Position actuelle
  8503. var currentPosition=[0,0,0];
  8504.  
  8505. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  8506. var porteeVue=[0,0,0,0];
  8507.  
  8508. // Fenêtres déplaçables
  8509. var winCurr = null;
  8510. var offsetX, offsetY;
  8511.  
  8512. // Diplomatie
  8513. var Diplo = {
  8514. Guilde: {},
  8515. Troll: {},
  8516. Monstre: {}
  8517. // .mythiques: uniquement si option activée
  8518. };
  8519. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  8520.  
  8521. // Infos tactiques
  8522. var popup;
  8523.  
  8524. // Gère l'affichage en cascade des popups de CdM
  8525. var nbCDM = 0;
  8526.  
  8527. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  8528.  
  8529. // Utilisé pour supprimer les monstres "engagés"
  8530. var listeEngages = {};
  8531. var isEngagesComputed = false;
  8532. var cursorOnLink = false; // DEBUG: wtf ?
  8533.  
  8534. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  8535. && MY_getValue(numTroll+'.enchantement.liste')!='';
  8536.  
  8537. // Checkboxes de filtrage
  8538. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  8539. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  8540. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  8541. comboBoxNiveauMin, comboBoxNiveauMax;
  8542.  
  8543. /* Acquisition & Stockage des données de DB */
  8544. const typesAFetcher = {
  8545. 'monstres':1,
  8546. 'trolls':1,
  8547. 'tresors':1,
  8548. 'champignons':1,
  8549. 'lieux':1
  8550. }
  8551. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  8552. tr_champignons = {}, tr_lieux = {};
  8553. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  8554. nbChampignons = 0, nbLieux = 0;
  8555.  
  8556. function fetchData(type) {
  8557. try {
  8558. var node = document.getElementById('mh_vue_hidden_'+type);
  8559. // this = MZ.global = sandBox de travail de MZ
  8560. // On définit donc des variables MZ-globales
  8561. this['tr_'+type] = node.getElementsByTagName('tr');
  8562. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  8563. } catch(e) {
  8564. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  8565. }
  8566. }
  8567.  
  8568.  
  8569. /*---------------------------------- DEBUG -----------------------------------*/
  8570. var mainTabs = document.getElementsByClassName('mh_tdborder');
  8571. var x_monstres = tr_monstres;
  8572. var x_trolls = tr_trolls;
  8573. var x_tresors = tr_tresors;
  8574. var x_champis = tr_champignons;
  8575. var x_lieux = tr_lieux;
  8576. /*-------------------------------- FIN DEBUG ---------------------------------*/
  8577.  
  8578.  
  8579. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8580.  
  8581. function positionToString(arr) {
  8582. return arr.join(';');
  8583. }
  8584.  
  8585. function savePosition() {
  8586. // Stocke la position (à jour) de la vue pour les autres scripts
  8587. // DEBUG: Lesquels et pourquoi?
  8588. var pos = getPosition();
  8589. MY_setValue(numTroll+'.position.X',pos[0]);
  8590. MY_setValue(numTroll+'.position.Y',pos[1]);
  8591. MY_setValue(numTroll+'.position.N',pos[2]);
  8592. }
  8593.  
  8594.  
  8595. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  8596. /* INFOS :
  8597. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  8598. * sont identifiables via leur Name
  8599. * les tables-listings sont identifiables via l'ID du tr conteneur
  8600. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  8601. */
  8602.  
  8603. /* [functions] Récup données Utilisateur */
  8604. function getPosition() {
  8605. // Pour rétrocompatibilité
  8606. return currentPosition;
  8607. }
  8608.  
  8609. function getPorteVue() {
  8610. // Pour rétrocompatibilité
  8611. return porteeVue;
  8612. }
  8613.  
  8614. function getVue() {
  8615. // Retourne [vueHpure, vueVpure]
  8616. var vues = getPorteVue();
  8617. return [ vues[0], vues[1] ];
  8618. }
  8619.  
  8620. // Roule 11/03/2016
  8621. /* [functions] Récup données monstres, trolls, etc. */
  8622. function getXxxDistance(xxx, i) {
  8623. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  8624. }
  8625. function getXxxPosition(xxx, i) {
  8626. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  8627. var l = tds.length;
  8628. return [
  8629. parseInt(tds[l-3].textContent),
  8630. parseInt(tds[l-2].textContent),
  8631. parseInt(tds[l-1].textContent)
  8632. ];
  8633. }
  8634.  
  8635.  
  8636. /* [functions] Récup données monstres */
  8637. function getMonstreDistance(i) {
  8638. return parseInt(tr_monstres[i].cells[0].textContent);
  8639. }
  8640.  
  8641. function getMonstreID(i) {
  8642. return tr_monstres[i].cells[2].firstChild.nodeValue;
  8643. }
  8644.  
  8645. function getMonstreIDByTR(tr) {
  8646. return tr.cells[2].firstChild.nodeValue;
  8647. }
  8648.  
  8649. function getMonstreLevelNode(i) {
  8650. return tr_monstres[i].cells[3];
  8651. }
  8652.  
  8653. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  8654. // function getMonstreLevel(i) {
  8655. // if(!isCDMsRetrieved) return -1;
  8656. // var donneesMonstre = listeCDM[getMonstreID(i)];
  8657. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  8658. // }
  8659.  
  8660. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  8661. if(!isCDMsRetrieved) return false;
  8662. var donneesMonstre = listeCDM[getMonstreID(i)];
  8663. if (!donneesMonstre) return false;
  8664. var nivTxt = donneesMonstre[0];
  8665. // calcul min/max du monstre
  8666. var monstreMin, monstreMax, iPos;
  8667. if (nivTxt.substring(0, 2) == '<=') {
  8668. monstreMin = 0;
  8669. monstreMax = parseInt(nivTxt.substring(2, 99));
  8670. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  8671. monstreMin = parseInt(nivTxt.substring(0, iPos));
  8672. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  8673. } else {
  8674. monstreMin = monstreMax = parseInt(nivTxt);
  8675. }
  8676. if (limitMin > 0 && monstreMax < limitMin) return true;
  8677. if (limitMax > 0 && monstreMin > limitMax) return true;
  8678. return false;
  8679. }
  8680.  
  8681. function getMonstreNomNode(i) {
  8682. try {
  8683. var td = document.evaluate(
  8684. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  8685. tr_monstres[i], null, 9, null
  8686. ).singleNodeValue;
  8687. return td;
  8688. } catch(e) {
  8689. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  8690. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  8691. }
  8692. }
  8693.  
  8694. function getMonstreNom(i) {
  8695. return getMonstreNomByTR(tr_monstres[i]);
  8696. }
  8697.  
  8698. function getMonstreNomByTR(tr) {
  8699. try {
  8700. var nom = document.evaluate(
  8701. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  8702. tr, null, 2, null
  8703. ).stringValue;
  8704. return nom;
  8705. } catch(e) {
  8706. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  8707. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  8708. }
  8709. }
  8710.  
  8711. function getMonstrePosition(i) {
  8712. var tds = tr_monstres[i].childNodes;
  8713. var l = tds.length;
  8714. return [
  8715. parseInt(tds[l-3].textContent),
  8716. parseInt(tds[l-2].textContent),
  8717. parseInt(tds[l-1].textContent)
  8718. ];
  8719. }
  8720.  
  8721. function appendMonstres(txt) {
  8722. for(var i=1; i<=nbMonstres ; i++)
  8723. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  8724. return txt;
  8725. }
  8726.  
  8727. function getMonstres() {
  8728. var vue = getVue();
  8729. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8730. }
  8731.  
  8732. function bddMonstres(start,stop) {
  8733. if(!start) { var start = 1; }
  8734. if(!stop) { var stop = nbMonstres; }
  8735. stop = Math.min(nbMonstres,stop);
  8736. var txt='';
  8737. for(var i=start ; i<=stop ; i++) {
  8738. txt += getMonstreID(i)+';'+
  8739. getMonstreNom(i)+';'+
  8740. positionToString(getMonstrePosition(i))+'\n';
  8741. }
  8742. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  8743. }
  8744.  
  8745. /* [functions] Récup données Trolls */
  8746.  
  8747. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  8748. const COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  8749.  
  8750. function getTrollDistance(i) {
  8751. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  8752. }
  8753.  
  8754. var MZ_cache_col_TrollID;
  8755. var MZ_cache_col_TrollNOM;
  8756. var MZ_cache_col_TrollGUILDE;
  8757. var MZ_cache_col_TrollNIV;
  8758.  
  8759. function MZ_find_col_titre(trs, titre) {
  8760. var l = titre.length;
  8761. for (var i=0; i < trs[0].cells.length; i++)
  8762. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  8763. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  8764. return 0;
  8765. }
  8766.  
  8767. function getTrollID(i) {
  8768. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  8769. // Roule 08/03/2017 protection
  8770. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  8771. if (isNaN(iTroll)) return;
  8772. if (iTroll == 0) return;
  8773. return iTroll;
  8774. }
  8775.  
  8776. function getTrollNomNode(i) {
  8777. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  8778. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  8779. }
  8780.  
  8781. function getTrollNivNode(i) {
  8782. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  8783. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  8784. }
  8785.  
  8786. function getTrollGuilde(i) {
  8787. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  8788. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  8789. }
  8790.  
  8791. function getTrollGuildeID(i) {
  8792. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  8793. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  8794. var href;
  8795. try {
  8796. 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"
  8797. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  8798. } catch(e) { // debug pb remonté par Marsak
  8799. window.console.error(traceStack(e, 'getTrollGuildeID')
  8800. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  8801. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  8802. return -1;
  8803. }
  8804. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  8805. }
  8806. return -1;
  8807. }
  8808.  
  8809. function getTrollPosition(i) {
  8810. var tds = tr_trolls[i].childNodes;
  8811. var l = tds.length;
  8812. return [
  8813. parseInt(tds[l-3].textContent),
  8814. parseInt(tds[l-2].textContent),
  8815. parseInt(tds[l-1].textContent)
  8816. ];
  8817. }
  8818.  
  8819. function bddTrolls() {
  8820. var txt='#DEBUT TROLLS\n'+
  8821. numTroll+';'+positionToString(getPosition())+'\n';
  8822. for(var i=1 ; i<=nbTrolls ; i++) {
  8823. txt += getTrollID(i)+';'+
  8824. positionToString(getTrollPosition(i))+'\n';
  8825. }
  8826. return txt+'#FIN TROLLS';
  8827. }
  8828.  
  8829. /* [functions] Récup données Trésors */
  8830. function getTresorDistance(i) {
  8831. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8832. }
  8833.  
  8834. function getTresorID(i) {
  8835. return trim(tr_tresors[i].cells[2].textContent);
  8836. }
  8837.  
  8838. function getTresorNom(i) {
  8839. // Utilisation de textContent pour régler le "bug de Pollux"
  8840. return trim(tr_tresors[i].cells[3].textContent);
  8841. }
  8842.  
  8843. function getTresorPosition(i) {
  8844. var tds = tr_tresors[i].childNodes;
  8845. var l = tds.length;
  8846. return [
  8847. parseInt(tds[l-3].textContent),
  8848. parseInt(tds[l-2].textContent),
  8849. parseInt(tds[l-1].textContent),
  8850. ];
  8851. }
  8852.  
  8853. function bddTresors(dmin,start,stop) {
  8854. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8855. if(!dmin) { var dmin = 0; }
  8856. if(!start) { var start = 1; }
  8857. if(!stop) { var stop = nbTresors; }
  8858. stop = Math.min(nbTresors,stop);
  8859. var txt='';
  8860. for(var i=start ; i<=stop ; i++) {
  8861. if(getTresorDistance(i)>=dmin) {
  8862. txt += getTresorID(i)+';'+
  8863. getTresorNom(i)+';'+
  8864. positionToString(getTresorPosition(i))+'\n';
  8865. }
  8866. }
  8867. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8868. }
  8869.  
  8870. /* [functions] Récup données Champignons */
  8871. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8872. function getChampignonNom(i) {
  8873. return trim(tr_champignons[i].cells[2].textContent);
  8874. }
  8875.  
  8876. function getChampignonPosition(i) {
  8877. var tds = tr_champignons[i].childNodes;
  8878. var l = tds.length;
  8879. return [
  8880. parseInt(tds[l-3].textContent),
  8881. parseInt(tds[l-2].textContent),
  8882. parseInt(tds[l-1].textContent)
  8883. ];
  8884. }
  8885.  
  8886. function bddChampignons() {
  8887. var txt='';
  8888. for(var i=1 ; i<=nbChampignons ; i++) {
  8889. txt += ';'+ // Les champis n'ont pas de Référence
  8890. getChampignonNom(i)+';'+
  8891. positionToString(getChampignonPosition(i))+'\n';
  8892. }
  8893. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8894. }
  8895.  
  8896. /* [functions] Récup données Lieux */
  8897. function getLieuDistance(i) {
  8898. return parseInt(tr_lieux[i].cells[0].textContent);
  8899. }
  8900.  
  8901. function getLieuID(i) {
  8902. return parseInt(tr_lieux[i].cells[2].textContent);
  8903. }
  8904.  
  8905. function getLieuNom(i) {
  8906. // Conversion ASCII pour éviter les bugs des Vues externes
  8907. return trim(tr_lieux[i].cells[3].textContent);
  8908. }
  8909.  
  8910. function getLieuPosition(i) {
  8911. var tds = tr_lieux[i].childNodes;
  8912. var l = tds.length;
  8913. return [
  8914. parseInt(tds[l-3].textContent),
  8915. parseInt(tds[l-2].textContent),
  8916. parseInt(tds[l-1].textContent)
  8917. ];
  8918. }
  8919.  
  8920. function appendLieux(txt) {
  8921. for(var i = 1; i < nbLieux+1; i++) {
  8922. var tds = x_lieux[i].childNodes;
  8923. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8924. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8925. }
  8926. return txt;
  8927. }
  8928.  
  8929. function getLieux() {
  8930. var vue = getVue();
  8931. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8932. }
  8933.  
  8934. function bddLieux(start,stop) {
  8935. if(!start) { var start = 1; }
  8936. if(!stop) { var stop = nbLieux; }
  8937. stop = Math.min(nbLieux,stop);
  8938. var txt='';
  8939. for(var i=start ; i<=stop ; i++) {
  8940. txt += getLieuID(i)+';'+
  8941. epure(getLieuNom(i))+';'+
  8942. positionToString(getLieuPosition(i))+'\n';
  8943. }
  8944. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8945. }
  8946.  
  8947.  
  8948. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8949.  
  8950. function saveCheckBox(chkbo, pref) {
  8951. // Enregistre et retourne l'état d'une CheckBox
  8952. var etat = chkbo.checked;
  8953. MY_setValue(pref, etat ? 'true' : 'false' );
  8954. return etat;
  8955. }
  8956.  
  8957. function recallCheckBox(chkbox, pref) {
  8958. // Restitue l'état d'une CheckBox
  8959. chkbox.checked = (MY_getValue(pref)=='true');
  8960. }
  8961.  
  8962. function saveComboBox(cbb, pref) {
  8963. // Enregistre et retourne l'état d'une ComboBox
  8964. var etat = cbb.selectedIndex;
  8965. MY_setValue(pref, etat);
  8966. return etat;
  8967. }
  8968.  
  8969. function recallComboBox(cbb, pref) {
  8970. // Restitue l'état d'une ComboBox
  8971. var nb = MY_getValue(pref);
  8972. if(nb) cbb.value = nb;
  8973. return nb;
  8974. }
  8975.  
  8976. function synchroniseFiltres() {
  8977. // Récupération de toutes les options de la vue
  8978. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8979. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8980. if(numBool) {
  8981. debutFiltrage('Monstres');
  8982. }
  8983. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  8984. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  8985. recallCheckBox(checkBoxMythiques,'NOMYTH');
  8986. recallCheckBox(checkBoxEngages,'NOENGAGE');
  8987. recallCheckBox(checkBoxLevels,'NOLEVEL');
  8988. recallCheckBox(checkBoxIntangibles,'NOINT');
  8989. recallCheckBox(checkBoxGG,'NOGG');
  8990. recallCheckBox(checkBoxCompos,'NOCOMP');
  8991. recallCheckBox(checkBoxBidouilles,'NOBID');
  8992. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  8993. recallCheckBox(checkBoxTrou,'NOTROU');
  8994. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8995. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  8996. if(MY_getValue('NOINFOEM')!='true')
  8997. recallCheckBox(checkBoxEM,'NOEM');
  8998. }
  8999.  
  9000.  
  9001. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  9002.  
  9003. function getVueScript() {
  9004. try {
  9005. var txt = bddTrolls()+
  9006. bddMonstres()+
  9007. bddChampignons()+
  9008. bddTresors()+
  9009. bddLieux()+
  9010. '#DEBUT ORIGINE\n'+
  9011. getPorteVue()[2]+';'+positionToString(getPosition())+
  9012. '\n#FIN ORIGINE\n';
  9013. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  9014. return txt;
  9015. } catch(e) {
  9016. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  9017. window.console.error(traceStack(e, 'getVueScript'))
  9018. }
  9019. }
  9020.  
  9021. /* [functions] Menu Vue 2D */
  9022. var vue2Ddata = {
  9023. 'Bricol\' Vue': {
  9024. url: URL_bricol_mountyhall + 'vue_form.php',
  9025. paramid: 'vue',
  9026. func: getVueScript,
  9027. extra_params: {
  9028. 'mode': 'vue_SP_Vue2',
  9029. 'screen_width': window.screen.width
  9030. }
  9031. },
  9032. 'Vue du CCM': {
  9033. url: URL_vue_CCM,
  9034. paramid: 'vue',
  9035. func: getVueScript,
  9036. extra_params: {
  9037. 'id': numTroll+';'+positionToString(getPosition())
  9038. }
  9039. },
  9040. 'Vue Gloumfs 2D': {
  9041. url: URL_vue_Gloumfs2D,
  9042. paramid: 'vue_mountyzilla',
  9043. func: getVueScript,
  9044. extra_params: {}
  9045. },
  9046. 'Vue Gloumfs 3D': {
  9047. url: URL_vue_Gloumfs3D,
  9048. paramid: 'vue_mountyzilla',
  9049. func: getVueScript,
  9050. extra_params: {}
  9051. },
  9052. 'Grouky Vue!': {
  9053. url: URL_vue_Grouky,
  9054. paramid: 'vue',
  9055. func: getVueScript,
  9056. extra_params: {
  9057. 'type_vue': 'V5b1'
  9058. }
  9059. },
  9060. /*'DEBUG': {
  9061. url: 'http://weblocal/testeur.php',
  9062. paramid: 'vue',
  9063. func: getVueScript,
  9064. extra_params: {}
  9065. }*/
  9066. };
  9067.  
  9068. function refresh2DViewButton() {
  9069. // = EventListener menu+bouton vue 2D
  9070. var vueext = document.getElementById('selectVue2D').value;
  9071. MY_setValue('VUEEXT',vueext);
  9072. var form = document.getElementById('viewForm');
  9073. form.innerHTML = '';
  9074. form.method = 'post';
  9075. form.action = vue2Ddata[vueext].url;
  9076. form.target = '_blank';
  9077. appendHidden(form, vue2Ddata[vueext].paramid, '');
  9078. for(var key in vue2Ddata[vueext].extra_params) {
  9079. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  9080. }
  9081. appendSubmit(form, 'Voir',
  9082. function() {
  9083. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  9084. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  9085. vue2Ddata[vueext].func();
  9086. }
  9087. );
  9088. }
  9089.  
  9090. function set2DViewSystem() {
  9091. // Initialise le système de vue 2D
  9092. // Recherche du point d'insertion
  9093. try {
  9094. var center = document.evaluate(
  9095. "//h2[@id='titre2']/following-sibling::center",
  9096. document, null, 9, null
  9097. ).singleNodeValue;
  9098. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  9099. if (!center) center = document.evaluate(
  9100. "//h2[@id='titre2']/following-sibling::div",
  9101. document, null, 9, null
  9102. ).singleNodeValue;
  9103. } catch(e) {
  9104. avertissement("Erreur d'initialisation du système de vue 2D");
  9105. window.console.error(traceStack(e, 'set2DViewSystem'));
  9106. return;
  9107. }
  9108. // Récupération de la dernière vue utilisée
  9109. var vueext = MY_getValue('VUEEXT');
  9110. if(!vueext || !vue2Ddata[vueext]) {
  9111. // sinon, la vue Bricol'Trolls est employée par défaut
  9112. vueext = 'Bricol\' Vue';
  9113. }
  9114. try {
  9115. // Création du sélecteur de vue externe
  9116. selectVue2D = document.createElement('select');
  9117. selectVue2D.id = 'selectVue2D';
  9118. selectVue2D.className = 'SelectboxV2';
  9119. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  9120. for(var view in vue2Ddata) {
  9121. appendOption(selectVue2D, view, view);
  9122. }
  9123. selectVue2D.value = vueext;
  9124. selectVue2D.onchange = refresh2DViewButton;
  9125. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  9126. var form = document.createElement('form');
  9127. form.id = 'viewForm';
  9128. // Insertion du système de vue
  9129. var table = document.createElement('table');
  9130. var tr = appendTr(table);
  9131. var td = appendTd(tr);
  9132. td.appendChild(selectVue2D);
  9133. td = appendTd(tr);
  9134. td.style.fontSize = '0px'; // gère le bug de l'extra character
  9135. td.appendChild(form);
  9136. center.insertBefore(table,center.firstChild);
  9137. insertBr(center.childNodes[1]);
  9138. // Appelle le handler pour initialiser le bouton de submit
  9139. refresh2DViewButton();
  9140. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  9141. } catch(e) {
  9142. avertissement("Erreur de traitement du système de vue 2D");
  9143. window.console.error(traceStack(e, 'set2DViewSystem'));
  9144. }
  9145. }
  9146.  
  9147. /* [functions] Tableau d'Infos */
  9148. function initialiseInfos() {
  9149. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  9150. var
  9151. infoTab = document.getElementsByName('LimitViewForm')[0].
  9152. getElementsByTagName('table')[0],
  9153. tbody = infoTab.tBodies[0],
  9154. thead = infoTab.createTHead(),
  9155. tr = appendTr(thead,'mh_tdtitre'),
  9156. td = appendTdText(tr,'INFORMATIONS',true),
  9157. span = document.createElement('span');
  9158. // Récupération de la position du joueur
  9159. try {
  9160. var strPos = document.evaluate(
  9161. ".//li/b/text()[contains(.,'X = ')]",
  9162. infoTab, null, 9, null
  9163. ).singleNodeValue.nodeValue;
  9164. // ***INIT GLOBALE*** currentPosition
  9165. currentPosition = getNumbers(strPos);
  9166. debugMZ("retrievePosition(): "+currentPosition);
  9167. } catch(e) {
  9168. // Si on ne trouve pas le "X ="
  9169. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  9170. }
  9171. // Récupération des portées (max et limitée) de la vue
  9172. try {
  9173. var
  9174. nodes = document.evaluate(
  9175. ".//li/b/text()[contains(.,'horizontalement') "+
  9176. "or contains(.,'verticalement')]",
  9177. infoTab, null, 7, null
  9178. ),
  9179. array = [];
  9180. for(var i=0 ; i<4 ; i++) {
  9181. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  9182. }
  9183. // ***INIT GLOBALE*** porteeVue
  9184. porteeVue = array;
  9185. } catch(e) {
  9186. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  9187. }
  9188.  
  9189. infoTab.id = 'infoTab'; // Pour scripts externes
  9190. tbody.id = 'corpsInfoTab';
  9191. tbody.rows[0].cells[0].colSpan = 2;
  9192. td.colSpan = 3;
  9193. td.onmouseover = function() {
  9194. this.style.cursor = 'pointer';
  9195. this.className = 'mh_tdpage';
  9196. };
  9197. td.onmouseout = function() {
  9198. this.className = 'mh_tdtitre';
  9199. };
  9200. td.onclick = function() {
  9201. toggleTableauInfos(false);
  9202. };
  9203. span.id = 'msgInfoTab';
  9204. span.style.display = 'none';
  9205. appendText(
  9206. span,
  9207. ' => Position : X = '+currentPosition[0]+
  9208. ', Y = '+currentPosition[1]+
  9209. ', N = '+currentPosition[2]+
  9210. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  9211. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  9212. true
  9213. );
  9214. td.appendChild(span);
  9215. tr = appendTr(tbody,'mh_tdpage');
  9216. td = appendTdText(tr,'EFFACER : ',true);
  9217. td.align = 'center';
  9218. td.className = 'mh_tdtitre';
  9219. td.width = 100;
  9220. td = appendTdCenter(tr,2);
  9221. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  9222. checkBoxGG = appendCheckBoxSpan(
  9223. td,'delgg',filtreTresors," Les GG'"
  9224. ).firstChild;
  9225. checkBoxCompos = appendCheckBoxSpan(
  9226. td,'delcomp',filtreTresors,' Les Compos'
  9227. ).firstChild;
  9228. checkBoxBidouilles = appendCheckBoxSpan(
  9229. td,'delbid',filtreTresors,' Les Bidouilles'
  9230. ).firstChild;
  9231. checkBoxIntangibles = appendCheckBoxSpan(
  9232. td,'delint',filtreTrolls,' Les Intangibles'
  9233. ).firstChild;
  9234. checkBoxGowapsA = appendCheckBoxSpan(
  9235. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  9236. ).firstChild;
  9237. checkBoxGowapsS = appendCheckBoxSpan(
  9238. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  9239. ).firstChild;
  9240. checkBoxEngages = appendCheckBoxSpan(
  9241. td,'delengage',filtreMonstres,' Les Engagés'
  9242. ).firstChild;
  9243. checkBoxLevels = appendCheckBoxSpan(
  9244. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  9245. ).firstChild;
  9246. checkBoxDiplo = appendCheckBoxSpan(
  9247. td,'delDiplo',refreshDiplo,' La Diplomatie'
  9248. ).firstChild;
  9249. checkBoxTrou = appendCheckBoxSpan(
  9250. td,'deltrou',filtreLieux,' Les Trous'
  9251. ).firstChild;
  9252. checkBoxMythiques = appendCheckBoxSpan(
  9253. td,'delmyth',filtreMonstres,' Les Mythiques'
  9254. ).firstChild;
  9255. if(MY_getValue('NOINFOEM')!='true') {
  9256. checkBoxEM = appendCheckBoxSpan(
  9257. td,'delem',filtreMonstres,' Les Composants EM'
  9258. ).firstChild;
  9259. }
  9260. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  9261. td,'deltres',filtreTresors,' Les Trésors non libres'
  9262. ).firstChild;
  9263. checkBoxTactique = appendCheckBoxSpan(
  9264. td,'deltactique',updateTactique,' Les Infos tactiques'
  9265. ).firstChild;
  9266. if(MY_getValue('INFOPLIE')) {
  9267. toggleTableauInfos(true);
  9268. }
  9269. }
  9270.  
  9271. function toggleTableauInfos(firstRun) {
  9272. var
  9273. msg = document.getElementById('msgInfoTab'),
  9274. corps = document.getElementById('corpsInfoTab'),
  9275. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9276. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  9277. if(!firstRun) {
  9278. infoplie = !infoplie;
  9279. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9280. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  9281. }
  9282. if(infoplie) {
  9283. msg.style.display = '';
  9284. corps.style.display = 'none';
  9285. } else {
  9286. msg.style.display = 'none';
  9287. corps.style.display = '';
  9288. }
  9289. }
  9290.  
  9291. /* [functions] Filtres */
  9292. function prepareFiltrage(ref,width) {
  9293. // = Initialise le filtre 'ref'
  9294. try {
  9295. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  9296. } catch(e) {
  9297. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  9298. return false;
  9299. }
  9300. if(width) { tdTitre.width = width; }
  9301. // Ajout du tr de Filtrage (masqué)
  9302. var tbody = tdTitre.parentNode.parentNode;
  9303. var tr = appendTr(tbody,'mh_tdpage');
  9304. tr.style.display = 'none';
  9305. tr.id = 'trFiltre'+ref;
  9306. var td = appendTd(tr);
  9307. td.colSpan = 5;
  9308. // Ajout du bouton de gestion de Filtrage
  9309. var tdBtn = insertAfterTd(tdTitre);
  9310. tdBtn.id = 'tdInsert'+ref;
  9311. var btn = appendButton(tdBtn,'Filtrer');
  9312. btn.id = 'btnFiltre'+ref;
  9313. btn.onclick = function() {
  9314. debutFiltrage(ref)
  9315. };
  9316. return td;
  9317. }
  9318.  
  9319. function debutFiltrage(ref) {
  9320. // = Handler de début de filtrage (filtre 'ref')
  9321. document.getElementById('trFiltre'+ref).style.display = '';
  9322. var btn = document.getElementById('btnFiltre'+ref);
  9323. btn.value = 'Annuler Filtre';
  9324. btn.onclick = function() {
  9325. finFiltrage(ref);
  9326. };
  9327. }
  9328.  
  9329. function finFiltrage(ref) {
  9330. // = Handler de fin de filtrage (filtre 'ref')
  9331. /* On réassigne le bouton 'Filtrer' */
  9332. document.getElementById('trFiltre'+ref).style.display = 'none';
  9333. var btn = document.getElementById('btnFiltre'+ref);
  9334. btn.value = 'Filtrer';
  9335. btn.onclick = function() {
  9336. debutFiltrage(ref);
  9337. };
  9338. /* Réinitialisation filtres */
  9339. document.getElementById('str'+ref).value = '';
  9340. switch(ref) {
  9341. case 'Monstres':
  9342. document.getElementById('nivMinMonstres').value = 0;
  9343. document.getElementById('nivMaxMonstres').value = 0;
  9344. break;
  9345. case 'Trolls':
  9346. document.getElementById('strGuildes').value = '';
  9347. }
  9348. /* Nettoyage (=lance le filtre) */
  9349. // Ici this = MZ.global = sandBox de travail de MZ
  9350. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  9351. //this['filtre'+ref]();
  9352. switch (ref) {
  9353. case 'Monstres':
  9354. filtreMonstres();
  9355. break;
  9356. case 'Trolls':
  9357. filtreTrolls();
  9358. break;
  9359. case 'Tresors':
  9360. filtreTresors();
  9361. break;
  9362. case 'Lieux':
  9363. filtreLieux();
  9364. break;
  9365. default:
  9366. window.console.log('cas incongru dans finFiltrage : ' + ref);
  9367. break;
  9368. }
  9369. }
  9370.  
  9371. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  9372. var bouton = appendButton(td,nomBouton,onClick);
  9373. appendText(td,'\u00a0');
  9374. var textbox = appendTextbox(td,'text',id,15,30);
  9375. textbox.onkeypress = function(event) {
  9376. try {
  9377. if(event.keyCode==13) {
  9378. event.preventDefault();
  9379. bouton.click();
  9380. }
  9381. }
  9382. catch(e){
  9383. window.alert(e)
  9384. }
  9385. };
  9386. }
  9387.  
  9388. function ajoutFiltreMenu(tr,id,onChange) {
  9389. var select = document.createElement('select');
  9390. select.id = id;
  9391. select.onchange = onChange;
  9392. appendOption(select,0,'Aucun');
  9393. for(var i=1 ; i<=60 ; i++) {
  9394. appendOption(select,i,i);
  9395. }
  9396. tr.appendChild(select);
  9397. return select;
  9398. }
  9399.  
  9400. function ajoutDesFiltres() {
  9401. /* Monstres */
  9402. var td = prepareFiltrage('Monstres',120);
  9403. if(td) {
  9404. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  9405. appendText(td,'\u00a0\u00a0\u00a0');
  9406. appendText(td,'Niveau Min: ');
  9407. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  9408. appendText(td,'\u00a0');
  9409. appendText(td,'Niveau Max: ');
  9410. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  9411. }
  9412. /* Trõlls */
  9413. td = prepareFiltrage('Trolls',50);
  9414. if(td) {
  9415. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  9416. appendText(td,'\u00a0\u00a0\u00a0');
  9417. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  9418. }
  9419. /* Trésors */
  9420. td = prepareFiltrage('Tresors',55);
  9421. if(td) {
  9422. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  9423. }
  9424. /* Lieux */
  9425. td = prepareFiltrage('Lieux',40);
  9426. if(td) {
  9427. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  9428. }
  9429. }
  9430.  
  9431. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  9432.  
  9433. /* [functions] Affichage de la colonne des niveaux */
  9434. function insertLevelColumn() {
  9435. // Déclenché si bascule vers affichage des niveaux des mobs
  9436. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  9437. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  9438. td.width = 25;
  9439. for(var i=1 ; i<=nbMonstres ; i++) {
  9440. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  9441. td = insertTdText(getMonstreLevelNode(i), '-');
  9442. td.onclick = function() {
  9443. basculeCDM(
  9444. getMonstreNomByTR(this.parentNode),
  9445. getMonstreIDByTR(this.parentNode)
  9446. );
  9447. };
  9448. td.onmouseover = function() {
  9449. this.style.cursor = 'pointer';
  9450. this.className = 'mh_tdtitre';
  9451. };
  9452. td.onmouseout = function() {
  9453. if(this.parentNode.diploActive=='oui') {
  9454. this.className = '';
  9455. } else {
  9456. this.className = 'mh_tdpage';
  9457. }
  9458. };
  9459. td.style = 'font-weight:bold;text-align:center;';
  9460. if(isCDMsRetrieved) {
  9461. // Rappel des niveaux si mémorisés
  9462. td.innerHTML = listeLevels[i];
  9463. }
  9464. }
  9465. }
  9466.  
  9467. function toggleLevelColumn() {
  9468. // = Handler checkBox noLevel
  9469. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  9470. insertLevelColumn();
  9471. if(!isCDMsRetrieved) { retrieveCDMs(); }
  9472. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  9473. for(var i=0 ; i<=nbMonstres ; i++) {
  9474. if(isCDMsRetrieved) {
  9475. // Mémorisation des niveaux pour rappel éventuel
  9476. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  9477. }
  9478. // Suppression du td Niveau
  9479. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  9480. }
  9481. }
  9482. }
  9483.  
  9484. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  9485. function basculeCDM(nom,id) {
  9486. // = Bascule l'affichage des popups CdM
  9487. if(listeCDM[id]) {
  9488. if(!document.getElementById('popupCDM'+id)) {
  9489. afficherCDM(nom, id);
  9490. } else {
  9491. cacherPopupCDM('popupCDM'+id);
  9492. }
  9493. }
  9494. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  9495. }
  9496.  
  9497. function cacherPopupCDM(titre) {
  9498. var popup = document.getElementById(titre);
  9499. popup.parentNode.removeChild(popup);
  9500. }
  9501.  
  9502. /* DEBUG: Section à mettre à jour */
  9503. var selectionFunction;
  9504.  
  9505. function startDrag(evt) {
  9506. winCurr = this.parentNode;
  9507. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  9508. offsetX = evt.pageX - parseInt( winCurr.style.left );
  9509. offsetY = evt.pageY - parseInt( winCurr.style.top );
  9510. selectionFunction = document.body.style.MozUserSelect;
  9511. document.body.style.MozUserSelect = 'none';
  9512. winCurr.style.MozUserSelect = 'none';
  9513. return false;
  9514. }
  9515.  
  9516. function stopDrag(evt) {
  9517. winCurr.style.MozUserSelect = selectionFunction;
  9518. document.body.style.MozUserSelect = selectionFunction;
  9519. winCurr = null;
  9520. }
  9521.  
  9522. function drag(evt) {
  9523. if(winCurr==null) { return; }
  9524. evt = evt || window.event;
  9525. winCurr.style.left = (evt.pageX - offsetX)+'px';
  9526. winCurr.style.top = (evt.pageY - offsetY)+'px';
  9527. return false;
  9528. }
  9529. /* FIN DEBUG */
  9530. if(!isPage("MH_Play/Play_equipement")) {
  9531. // Conflit overlib/Tout_MZ:
  9532. // Double définition du "onmousemove" sur la page d'équipement
  9533. document.onmousemove = drag;
  9534. }
  9535.  
  9536. function afficherCDM(nom,id) {
  9537. // Crée la table de CdM du mob n° id
  9538. var donneesMonstre = listeCDM[id];
  9539. /* Début création table */
  9540. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  9541. table.id = 'popupCDM'+id;
  9542. table.style =
  9543. 'position:fixed;'+
  9544. 'z-index:1;'+
  9545. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  9546. 'left:'+(window.innerWidth-365)+'px;'+
  9547. 'width:300px;'+
  9548. 'height:200px;';
  9549. /* Ajout du titre avec gestion Drag & Drop */
  9550. var tr = table.firstChild;
  9551. tr.style.cursor = 'move';
  9552. tr.onmousedown = startDrag;
  9553. tr.onmouseup = stopDrag;
  9554. /* Ajout du bouton "Fermer" */
  9555. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  9556. tr.onmouseover = function() {
  9557. this.style.cursor = 'pointer';
  9558. this.className = 'mh_tdpage';
  9559. };
  9560. tr.onmouseout = function() {
  9561. this.className = 'mh_tdtitre';
  9562. };
  9563. tr.idcdm = id;
  9564. tr.onclick = function() {
  9565. cacherPopupCDM('popupCDM'+this.idcdm);
  9566. this.className = 'mh_tdtitre';
  9567. };
  9568. td = appendTdText(tr,'Fermer',true);
  9569. td.colSpan = 2;
  9570. td.style = 'text-align:center;';
  9571. nbCDM++;
  9572. /* Fin création table & Affichage */
  9573. document.body.appendChild(table);
  9574. }
  9575.  
  9576. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  9577. function initPopupVue() {
  9578. popup = document.createElement('div');
  9579. popup.id = 'popup';
  9580. popup.className = 'mh_textbox';
  9581. popup.style =
  9582. 'position: absolute;'+
  9583. 'border: 1px solid #000000;'+
  9584. 'visibility: hidden;'+
  9585. 'display: inline;'+
  9586. 'z-index: 3;'+
  9587. 'max-width: 400px;';
  9588. document.body.appendChild(popup);
  9589. }
  9590.  
  9591. /* [functions] Récupération / Computation des Infos Tactiques */
  9592. // TODO à revoir
  9593. function retireMarquage(nom) {
  9594. var i = nom.indexOf(']');
  9595. switch(i) {
  9596. case -1:
  9597. case nom.length-1:
  9598. return nom;
  9599. default:
  9600. return nom.slice(0,i+1);
  9601. }
  9602. }
  9603.  
  9604. function showPopupError(sHTML) {
  9605. window.console.log('[MZ] affichage PopupError ' + sHTML);
  9606. var divpopup = document.createElement('div');
  9607. divpopup.id = 'divpopup';
  9608. divpopup.style =
  9609. 'position: fixed;'+
  9610. 'border: 3px solid #000000;'+
  9611. 'top: 300px;left: 10px;'+
  9612. 'background-color: red;'+
  9613. 'color: white;'+
  9614. 'font-size: xx-large;'+
  9615. 'z-index: 200;';
  9616. divpopup.innerHTML = sHTML;
  9617. var divcroix = document.createElement('div');
  9618. divcroix.style =
  9619. 'position: absolute;'+
  9620. 'top: 0;right: 0;'+
  9621. 'color: inherit;'+
  9622. 'font-size: inherit;'+
  9623. 'cursor: pointer;'+
  9624. 'z-index: 201;';
  9625. divcroix.innerHTML = "X";
  9626. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  9627. document.body.appendChild(divpopup);
  9628. divpopup.appendChild(divcroix);
  9629. }
  9630.  
  9631. function retrieveCDMs() {
  9632. // Roule 18/11/2017 mise en sommeil MZ V2, on a besoin de tester en mode dev avec l'ancienne version
  9633. return retrieveCDMsOld();
  9634. //if (isDEV) return retrieveCDMsNew();
  9635. //else return retrieveCDMsOld();
  9636. }
  9637.  
  9638. function retrieveCDMsNew() {
  9639. // Récupère les CdM disponibles dans la BDD
  9640. // Lancé uniquement sur toggleLevelColumn
  9641. if(checkBoxLevels.checked) return;
  9642. if (nbMonstres < 1) return;
  9643.  
  9644. var tReq = [];
  9645. for (var i=1 ; i<=nbMonstres ; i++) {
  9646. tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  9647. }
  9648.  
  9649. FF_XMLHttpRequest({
  9650. method: 'POST',
  9651. url: URL_MZgetCaracMonstre,
  9652. headers : {
  9653. 'Content-type':'application/x-www-form-urlencoded'
  9654. },
  9655. data: 'l=' + tReq.join("\n"),
  9656. trace: 'demande niveaux monstres V2',
  9657. onload: function(responseDetails) {
  9658. try {
  9659. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9660. if (responseDetails.status == 0) return;
  9661. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  9662. var texte = responseDetails.responseText;
  9663. var lines = texte.split('\n');
  9664. if(lines.length==0) return;
  9665. var begin2, end2, index;
  9666. for(var j=0 ; j<lines.length ; j++) {
  9667. var infos = lines[j].split("\t");
  9668. if(infos.length<3) { continue; }
  9669. var index = infos[0]
  9670. var idMonstre=infos[1];
  9671. var level = infos[2];
  9672. // 3 cas
  9673. // il y a des infos, infos[] a plus de 3 valeurs
  9674. // il n'y a pas d'info pour ce monstre, infos[] a 4 valeur, la 4e est "-"
  9675. // les infos n'ont pas été récupérées (après le 50e monstre), il n'y a que 3 valeurs
  9676. if (infos.length == 3) {
  9677. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9678. } else if (infos.length > 4) {
  9679. infos = infos.slice(3);
  9680. 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)
  9681. listeCDM[idMonstre] = infos;
  9682. getMonstreLevelNode(index).innerHTML = '<b>'+level+'</b>';
  9683. } else {
  9684. getMonstreLevelNode(index).innerHTML = level;
  9685. }
  9686. }
  9687. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  9688. computeMission(1, nbMonstres);
  9689. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  9690. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9691. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  9692. } catch(e) {
  9693. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9694. }
  9695. isCDMsRetrieved=true;
  9696. },
  9697. });
  9698. //str = '';
  9699. //begin = i+1;
  9700. //isCDMsRetrieved=true;
  9701. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  9702. }
  9703.  
  9704. function retrieveCDMsOld() {
  9705. // Récupère les CdM disponibles dans la BDD
  9706. // Lancé uniquement sur toggleLevelColumn
  9707. if(checkBoxLevels.checked) { return; }
  9708. // Roule, message si l'utilisateur a décoché "Menu d'actions contextuelles"
  9709. if (!tr_monstres[0].cells[2].innerHTML.match(/r[eéè]f/i)) {
  9710. avertissement('Vous avez décoché "Menu d\'actions contextuelles" dans la fenêtre de limitation de la vue, Moutyzilla ne peut pas afficher les niveaux dans ce mode<br />La fenêtre de limitation de la vue est celle qu\'on obtient en cliquant sur l\'œil dans le menu de gauche', 9999999);
  9711. return;
  9712. }
  9713.  
  9714. var str = '';
  9715. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  9716. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  9717. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  9718. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  9719. for(var i=1 ; i<=cdmMax ; i++) {
  9720. var nomMonstre = retireMarquage(getMonstreNom(i));
  9721. if(nomMonstre.indexOf(']') != -1) {
  9722. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  9723. }
  9724. // *** WARNING : PROXY RATIBUS ***
  9725. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  9726. str += 'nom[]='+escape(nomMonstre)+'$'+(
  9727. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  9728. )+'&';
  9729. }
  9730.  
  9731. // Roule 31/07/2017 suppression du saucissonnage : inutile et complique les choses ensuite
  9732. //if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  9733. FF_XMLHttpRequest({
  9734. method: 'POST',
  9735. url: URL_MZinfoMonstre,
  9736. headers : {
  9737. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9738. 'Accept': 'application/atom+xml,application/xml,text/xml',
  9739. 'Content-type':'application/x-www-form-urlencoded'
  9740. },
  9741. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  9742. trace: 'demande niveaux monstres',
  9743. onload: function(responseDetails) {
  9744. try {
  9745. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9746. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  9747. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  9748. '" target="raistlin">Mountyzilla - https<br />'+
  9749. 'Tu dois accepter le certificat de Raistlin<br />'+
  9750. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  9751. ' « Confirmer l\'exception de sécurité »</a>');
  9752. return;
  9753. }
  9754. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  9755. var texte = responseDetails.responseText;
  9756. var lines = texte.split('\n');
  9757. if(lines.length==0) { return; }
  9758. var begin2, end2, index;
  9759. for(var j=0 ; j<lines.length ; j++) {
  9760. var infos = lines[j].split(';');
  9761. if(infos.length<4) { continue; }
  9762. var idMonstre=infos[0];
  9763. var isCDM = infos[1];
  9764. index = parseInt(infos[2]);
  9765. var level = infos[3];
  9766. infos = infos.slice(3);
  9767. 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)
  9768. if(begin2==null) { begin2 = index; }
  9769. end2 = index;
  9770. listeCDM[idMonstre] = infos;
  9771. if(isCDM==1) {
  9772. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9773. } else {
  9774. getMonstreLevelNode(index).innerHTML = level;
  9775. }
  9776. }
  9777. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres avant computeMission');
  9778. computeMission(begin2,end2);
  9779. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres avant filtreMonstres');
  9780. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9781. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres fin');
  9782. } catch(e) {
  9783. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9784. }
  9785. isCDMsRetrieved=true;
  9786. },
  9787. });
  9788. //str = '';
  9789. //begin = i+1;
  9790. //isCDMsRetrieved=true;
  9791. //window.console.log('[MZd] ' + (+new Date) + ' requête ajax partie pour ' + cdmMax + ' monstres');
  9792. }
  9793.  
  9794. function computeMission(begin,end) {
  9795. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  9796. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  9797. computeVLC(begin,end);
  9798. //+++window.console.log('computeMission, après computeVLC');
  9799. if(!begin) begin=1;
  9800. if(!end) end=nbMonstres;
  9801. var str = MY_getValue(numTroll+'.MISSIONS');
  9802. if(!str) { return; }
  9803. var urlImg = URL_MZimg+'mission.png';
  9804. var obMissions = JSON.parse(str);
  9805. for(var i=end ; i>=begin ; i--) {
  9806. var mess = '';
  9807. for(var num in obMissions) {
  9808. var mobMission = false;
  9809. switch(obMissions[num].type) {
  9810. case 'Race':
  9811. var race = epure(obMissions[num].race.toLowerCase());
  9812. var nom = epure(getMonstreNom(i).toLowerCase());
  9813. if(nom.indexOf(race)!=-1) {
  9814. mobMission = true;
  9815. }
  9816. break;
  9817. case 'Niveau':
  9818. var donneesMonstre = listeCDM[getMonstreID(i)];
  9819. if(donneesMonstre) {
  9820. var nivMob = Number(donneesMonstre[0]);
  9821. var nivMimi = Number(obMissions[num].niveau),
  9822. mod = obMissions[num].mod;
  9823. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  9824. || (isNaN(mod) && nivMob>=nivMimi)) {
  9825. mobMission = true;
  9826. }
  9827. }
  9828. break;
  9829. case 'Famille':
  9830. var donneesMonstre = listeCDM[getMonstreID(i)];
  9831. if(donneesMonstre) {
  9832. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  9833. var familleMob = epure(donneesMonstre[1].toLowerCase());
  9834. if(familleMob.indexOf(familleMimi)!=-1) {
  9835. mobMission = true;
  9836. }
  9837. }
  9838. break;
  9839. case 'Pouvoir':
  9840. var donneesMonstre = listeCDM[getMonstreID(i)];
  9841. if(donneesMonstre) {
  9842. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  9843. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  9844. if(pvrMob.indexOf(pvrMimi)!=-1) {
  9845. mobMission = true;
  9846. }
  9847. }
  9848. }
  9849. if(mobMission) {
  9850. mess += mess ? '\n\n' : '';
  9851. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  9852. }
  9853. }
  9854. if(mess) {
  9855. var td = getMonstreNomNode(i);
  9856. appendText(td,' ');
  9857. td.appendChild(createImage(urlImg,mess));
  9858. }
  9859. }
  9860. }
  9861.  
  9862. function computeVLC(begin,end) {
  9863. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  9864. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  9865. computeTactique(begin,end);
  9866. //+++window.console.log('computeVLC, après computeTactique');
  9867. if(!begin) begin=1;
  9868. if(!end) end=nbMonstres;
  9869. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  9870. if(!cache)
  9871. return false;
  9872. var urlImg = URL_MZimg + "oeil.png";
  9873. for(var i = end; i >= begin;i--)
  9874. {
  9875. var id = getMonstreID(i);
  9876. var donneesMonstre = listeCDM[id];
  9877. if(donneesMonstre && donneesMonstre.length>12)
  9878. {
  9879. if(donneesMonstre[12]==1)
  9880. {
  9881. var td = getMonstreNomNode(i);
  9882. td.appendChild(document.createTextNode(" "));
  9883. td.appendChild(createImage(urlImg, "Voit le caché"));
  9884. }
  9885. }
  9886. }
  9887. }
  9888.  
  9889. /* appelé
  9890. par updateTactique
  9891. par initialiseInfos
  9892. par do_vue
  9893. par computeVLC
  9894. par computeMission
  9895. par filtreMonstres
  9896. par retrieveCDMs
  9897. */
  9898. function computeTactique(begin, end) {
  9899. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  9900. try {
  9901. if(!begin) begin = 1;
  9902. if(!end) end = nbMonstres;
  9903. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  9904. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9905. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  9906. if(noTactique || !isProfilActif()) return;
  9907. //+++window.console.log('computeTactique, après isProfilActif');
  9908.  
  9909. for(var j=end ; j>=begin ; j--) {
  9910. var id = getMonstreID(j);
  9911. var nom = getMonstreNom(j);
  9912. var donneesMonstre = listeCDM[id];
  9913. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  9914. var td = getMonstreNomNode(j);
  9915. appendText(td,' ');
  9916. td.appendChild(
  9917. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  9918. );
  9919. }
  9920. }
  9921. }
  9922. catch(e) {
  9923. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  9924. }
  9925. filtreMonstres();
  9926. }
  9927.  
  9928. function updateTactique() {
  9929. // = Handler checkBox noTactique
  9930. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9931. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  9932. if(!isCDMsRetrieved) return;
  9933. //+++window.console.log('updateTactique, isCDMsRetrieved=' + isCDMsRetrieved);
  9934.  
  9935. if(noTactique) {
  9936. for(var i=nbMonstres ; i>0 ; i--) {
  9937. var tr = getMonstreNomNode(i);
  9938. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9939. tr, null, 9, null).singleNodeValue;
  9940. if(img) {
  9941. img.parentNode.removeChild(img.previousSibling);
  9942. img.parentNode.removeChild(img);
  9943. }
  9944. }
  9945. }
  9946. else
  9947. computeTactique();
  9948. }
  9949.  
  9950. function filtreMonstres() {
  9951. // = Handler universel pour les fonctions liées aux monstres
  9952. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9953. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9954. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9955. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9956. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9957. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9958. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9959. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9960. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9961. // old/new : détermine s'il faut ou non nettoyer les tr
  9962. var oldNOEM = true, noEM = true;
  9963. if(MY_getValue('NOINFOEM')!='true') {
  9964. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9965. }
  9966. // Filtrage par nom
  9967. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9968. // Génère la liste des mobs engagés (si filtrés)
  9969. if(noEngages && !isEngagesComputed) {
  9970. for(var i=nbTrolls ; i>0 ; i--) {
  9971. var pos = getTrollPosition(i);
  9972. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  9973. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  9974. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  9975. }
  9976. isEngagesComputed = true;
  9977. }
  9978. /*** FILTRAGE ***/
  9979. /* À computer :
  9980. * - EM (nom suffit)
  9981. * - Enchant (nom suffit)
  9982. * - Mission (nécessite CdM)
  9983. * - mob VlC (nécessite CdM)
  9984. * Sans computation :
  9985. * - Gowap ? engagé ?
  9986. */
  9987. for(var i=nbMonstres ; i>0 ; i--) {
  9988. var pos = getMonstrePosition(i);
  9989. var nom = getMonstreNom(i).toLowerCase();
  9990. if(noEM!=oldNOEM) {
  9991. if(noEM) {
  9992. // Si noEM passe de false à true, on nettoie les td "Nom"
  9993. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  9994. var tr = getMonstreNomNode(i);
  9995. while(tr.childNodes.length>1) {
  9996. tr.removeChild(tr.childNodes[1]);
  9997. }
  9998. } else {
  9999. var tr = getMonstreNomNode(i);
  10000. var TypeMonstre=getEM(nom);
  10001. if(TypeMonstre!='') {
  10002. var infosCompo=compoMobEM(TypeMonstre);
  10003. if(infosCompo.length>0) {
  10004. tr.appendChild(document.createTextNode(' '));
  10005. tr.appendChild(createImage(urlImg, infosCompo));
  10006. }
  10007. }
  10008. }
  10009. }
  10010. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  10011. var texte = getInfoEnchantementFromMonstre(nom);
  10012. if(texte!='') {
  10013. var td = getMonstreNomNode(i);
  10014. td.appendChild(document.createTextNode(' '));
  10015. td.appendChild(createImage(urlEnchantImg, texte));
  10016. }
  10017. }
  10018. tr_monstres[i].style.display = (
  10019. noGowapsS &&
  10020. nom.indexOf('gowap sauvage')!=-1 &&
  10021. getMonstreDistance(i)>1
  10022. ) || (
  10023. noGowapsA &&
  10024. nom.indexOf('gowap apprivoisé')!=-1 &&
  10025. getMonstreDistance(i)>1
  10026. ) || (
  10027. noEngages &&
  10028. getMonstreDistance(i)!=0 &&
  10029. listeEngages[pos[0]] &&
  10030. listeEngages[pos[0]][pos[1]] &&
  10031. listeEngages[pos[0]][pos[1]][pos[2]]
  10032. ) || (
  10033. strMonstre!='' &&
  10034. nom.indexOf(strMonstre)==-1
  10035. ) || (
  10036. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  10037. getMonstreDistance(i)>1 &&
  10038. nom.toLowerCase().indexOf("kilamo")==-1
  10039. ) ? 'none' : '';
  10040. }
  10041. if(MY_getValue('NOINFOEM')!='true') {
  10042. if(noEM != oldNOEM) {
  10043. if(noEM && isCDMsRetrieved) computeMission();
  10044. }
  10045. oldNOEM = noEM;
  10046. }
  10047. needComputeEnchantement = false;
  10048. }
  10049.  
  10050.  
  10051. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  10052.  
  10053. function filtreTrolls() {
  10054. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  10055. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  10056. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  10057. for(var i=1 ; i<=nbTrolls ; i++) {
  10058. tr_trolls[i].style.display = (
  10059. noIntangibles &&
  10060. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  10061. ) || (
  10062. strTroll!='' &&
  10063. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  10064. ) || (
  10065. strGuilde!='' &&
  10066. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  10067. ) ? 'none' : '';
  10068. }
  10069. }
  10070.  
  10071. /* [functions] Bulle PX Trolls */
  10072. var bulle;
  10073.  
  10074. function initPXTroll() {
  10075. bulle = document.createElement('div');
  10076. bulle.id = 'bulle';
  10077. bulle.className = 'mh_textbox';
  10078. bulle.style =
  10079. 'position: absolute;'+
  10080. 'border: 1px solid #000000;'+
  10081. 'visibility: hidden;'+
  10082. 'display: inline;'+
  10083. 'z-index: 2;';
  10084. document.body.appendChild(bulle);
  10085.  
  10086. for(var i=nbTrolls ; i>0 ; i--) {
  10087. var td_niv = getTrollNivNode(i);
  10088. td_niv.onmouseover = showPXTroll;
  10089. td_niv.onmouseout = hidePXTroll;
  10090. }
  10091. }
  10092.  
  10093. function showPXTroll(evt) {
  10094. var lvl = this.firstChild.nodeValue;
  10095. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  10096. bulle.style.left = evt.pageX+15+'px';
  10097. bulle.style.top = evt.pageY+'px';
  10098. bulle.style.visibility = 'visible';
  10099. }
  10100.  
  10101. function hidePXTroll() {
  10102. bulle.style.visibility = 'hidden';
  10103. }
  10104.  
  10105. /* [functions] Envoi PX / MP */
  10106. function putBoutonPXMP() {
  10107. // Bouton d'initialisation du mode Envoi
  10108. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  10109. var td = document.getElementById('tdInsertTrolls');
  10110. if(!td) { return; }
  10111. td.width = 100;
  10112. td = insertAfterTd(td);
  10113. td.style.verticalAlign = 'top';
  10114. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  10115. bouton.id = 'btnEnvoi';
  10116. }
  10117.  
  10118. function prepareEnvoi() {
  10119. // = 1er Handler du bouton d'envoi
  10120. /* Ajout de la colonne des CheckBoxes */
  10121. var td = insertTdText(getTrollNomNode(0),'');
  10122. td.width = 5;
  10123. for(var i=nbTrolls ; i>0 ; i--) {
  10124. td = insertTd(getTrollNomNode(i));
  10125. appendCheckBox(td,'envoi'+i);
  10126. }
  10127. /* Ajout du radio de choix PX ou MP */
  10128. var btnEnvoi = document.getElementById('btnEnvoi');
  10129. if(!btnEnvoi) { return; }
  10130. var tdEnvoi = btnEnvoi.parentNode;
  10131. appendText(tdEnvoi,' ');
  10132. var span = document.createElement('span');
  10133. span.style.whiteSpace = 'nowrap';
  10134. var radioElt = document.createElement('input');
  10135. radioElt.type = 'radio';
  10136. radioElt.name = 'envoiPXMP';
  10137. radioElt.id = 'radioPX';
  10138. span.appendChild(radioElt);
  10139. appendText(span,' des PX ');
  10140. radioElt = document.createElement('input');
  10141. radioElt.type = 'radio';
  10142. radioElt.name = 'envoiPXMP';
  10143. radioElt.checked = true;
  10144. span.appendChild(radioElt);
  10145. appendText(span,' un MP');
  10146. tdEnvoi.appendChild(span);
  10147. /* Insertion du bouton Annuler */
  10148. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  10149. /* Modification de l'effet du bouton Envoi */
  10150. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  10151. }
  10152.  
  10153. function annuleEnvoi() {
  10154. // = Handler bouton Annuler
  10155. /* Nettoyage du td du bouton Envoi */
  10156. var btnEnvoi = document.getElementById('btnEnvoi');
  10157. var tdEnvoi = btnEnvoi.parentNode;
  10158. while(tdEnvoi.firstChild) {
  10159. tdEnvoi.removeChild(tdEnvoi.firstChild);
  10160. }
  10161. /* Retour à l'effet de base du bouton Envoi */
  10162. btnEnvoi.onclick = prepareEnvoi;
  10163. tdEnvoi.appendChild(btnEnvoi);
  10164. /* Suppression CheckBoxes */
  10165. for(var i=nbTrolls ; i>=0 ; i--) {
  10166. var td = getTrollNomNode(i);
  10167. td.parentNode.removeChild(td);
  10168. }
  10169. }
  10170.  
  10171. function effectueEnvoi() {
  10172. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  10173. var str='';
  10174. var errID = false;
  10175. for(var i=nbTrolls ; i>0 ; i--) {
  10176. var chb = document.getElementById('envoi'+i);
  10177. if(chb.checked) {
  10178. var idTroll = getTrollID(i);
  10179. if (idTroll == undefined) {
  10180. errID = true;
  10181. } else {
  10182. str += (str ? ',' : '') + idTroll;
  10183. }
  10184. }
  10185. }
  10186. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  10187. var PXchecked = document.getElementById('radioPX').checked;
  10188. if(PXchecked) {
  10189. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  10190. } else {
  10191. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  10192. }
  10193. }
  10194.  
  10195. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  10196.  
  10197. function filtreTresors() {
  10198. // += Handler checkboxes : gg, compos, bidouilles, non libres
  10199. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  10200. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  10201. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  10202. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  10203. if(noEngages && !isEngagesComputed) {
  10204. for(var i=nbTrolls ; i>0 ; i--) {
  10205. var pos = getTrollPosition(i);
  10206. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  10207. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  10208. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  10209. }
  10210. isEngagesComputed = true;
  10211. }
  10212. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  10213. for(var i=nbTresors ; i>0 ; i--) {
  10214. var nom = getTresorNom(i);
  10215. var pos = getTresorPosition(i);
  10216. tr_tresors[i].style.display = (
  10217. noGG &&
  10218. nom.indexOf('Gigots de Gob')!=-1
  10219. ) || (
  10220. noCompos &&
  10221. nom.indexOf('Composant')!=-1
  10222. ) || (
  10223. noEngages &&
  10224. listeEngages[pos[2]] &&
  10225. listeEngages[pos[2]][pos[1]] &&
  10226. listeEngages[pos[2]][pos[1]][pos[0]] &&
  10227. getTresorDistance(i)>0
  10228. ) || (
  10229. strTresor!='' &&
  10230. nom.toLowerCase().indexOf(strTresor)==-1
  10231. ) || (
  10232. noBidouilles &&
  10233. nom.indexOf('Bidouille')!=-1
  10234. ) ? 'none' : '';
  10235. }
  10236. }
  10237.  
  10238.  
  10239. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  10240.  
  10241. function filtreLieux() {
  10242. // += Handler checkbox trous
  10243. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  10244. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  10245. for(var i=nbLieux ; i>0 ; i--) {
  10246. tr_lieux[i].style.display = (
  10247. strLieu &&
  10248. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  10249. ) || (
  10250. noTrou &&
  10251. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  10252. getLieuDistance(i)>1
  10253. ) ? 'none' : '';
  10254. }
  10255. }
  10256.  
  10257.  
  10258. /*-[functions]-------------------- Diplomatie --------------------------------*/
  10259.  
  10260. function refreshDiplo() {
  10261. MY_setValue(numTroll+'.diplo.off',
  10262. checkBoxDiplo.checked?'true':'false'
  10263. );
  10264. if(isDiploRaw) { computeDiplo(); }
  10265. appliqueDiplo();
  10266. }
  10267.  
  10268. function computeDiplo() {
  10269. // On extrait les données de couleur et on les stocke par id
  10270. // Ordre de préséance :
  10271. // source Guilde < source Perso
  10272. // guilde cible < troll cible
  10273. /* Diplo de Guilde */
  10274. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  10275. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  10276. if(diploGuilde && diploGuilde.isOn=='true') {
  10277. // Guilde perso
  10278. if(diploGuilde.guilde) {
  10279. Diplo.Guilde[diploGuilde.guilde.id] = {
  10280. couleur: diploGuilde.guilde.couleur,
  10281. titre: 'Ma Guilde'
  10282. };
  10283. }
  10284. // Guildes/Trolls A/E
  10285. for(var AE in {Amis:0,Ennemis:0}) {
  10286. for(var i=0 ; i<5 ; i++) {
  10287. if(diploGuilde[AE+i]) {
  10288. for(var type in {Guilde:0,Troll:0}) {
  10289. var liste = diploGuilde[AE+i][type].split(';');
  10290. for(var j=liste.length-2 ; j>=0 ; j--) {
  10291. Diplo[type][liste[j]] = {
  10292. couleur: diploGuilde[AE+i].couleur,
  10293. titre: diploGuilde[AE+i].titre
  10294. };
  10295. }
  10296. }
  10297. }
  10298. }
  10299. }
  10300. }
  10301. /* Diplo Perso */
  10302. //var diploPerso = MY_getValue(numTroll+'.diplo.perso') ? JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {}; // déjà chargé
  10303. if(diploPerso && diploPerso.isOn=='true') {
  10304. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  10305. for(var id in diploPerso[type]) {
  10306. Diplo[type][id] = diploPerso[type][id];
  10307. }
  10308. }
  10309. }
  10310. if(diploPerso.mythiques) {
  10311. Diplo.mythiques = diploPerso.mythiques;
  10312. }
  10313. isDiploRaw = false;
  10314. }
  10315.  
  10316. function appliqueDiplo() {
  10317. var aAppliquer = Diplo;
  10318. if(checkBoxDiplo.checked) {
  10319. // Pour retour à l'affichage basique sur désactivation de la diplo
  10320. aAppliquer = {
  10321. Guilde: {},
  10322. Troll: {},
  10323. Monstre: {}
  10324. };
  10325. }
  10326. /* On applique "aAppliquer" */
  10327. // Diplo Trõlls
  10328. for(var i=nbTrolls ; i>0 ; i--) {
  10329. var idG = getTrollGuildeID(i);
  10330. var idT = getTrollID(i);
  10331. var tr = tr_trolls[i];
  10332. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  10333. if(aAppliquer.Troll[idT]) {
  10334. tr.className = '';
  10335. var descr = aAppliquer.Troll[idT].titre;
  10336. if(descr) {
  10337. getTrollNomNode(i).title = descr
  10338. }
  10339. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  10340. } else if(aAppliquer.Guilde[idG]) {
  10341. tr.className = '';
  10342. var descr = aAppliquer.Guilde[idG].titre;
  10343. if(descr) {
  10344. getTrollNomNode(i).title = descr
  10345. }
  10346. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  10347. } else {
  10348. tr.className = 'mh_tdpage';
  10349. getTrollNomNode(i).title = '';
  10350. }
  10351. }
  10352. // Diplo Monstres
  10353. for(var i=nbMonstres ; i>0 ; i--) {
  10354. var id = getMonstreID(i);
  10355. var nom = getMonstreNom(i).toLowerCase();
  10356. if(aAppliquer.Monstre[id]) {
  10357. tr_monstres[i].className = '';
  10358. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  10359. tr_monstres[i].diploActive = 'oui';
  10360. var descr = aAppliquer.Monstre[id].titre;
  10361. if(descr) {
  10362. getMonstreNomNode(i).title = descr;
  10363. }
  10364. } else if(aAppliquer.mythiques &&
  10365. (nom.indexOf('liche')==0 ||
  10366. nom.indexOf('hydre')==0 ||
  10367. nom.indexOf('balrog')==0 ||
  10368. nom.indexOf('beholder')==0)) {
  10369. tr_monstres[i].className = '';
  10370. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  10371. tr_monstres[i].diploActive = 'oui';
  10372. getMonstreNomNode(i).title = 'Monstre Mythique';
  10373. } else {
  10374. tr_monstres[i].className = 'mh_tdpage';
  10375. tr_monstres[i].diploActive = '';
  10376. }
  10377. }
  10378. }
  10379.  
  10380.  
  10381. /*-[functions]---------------- Actions à distance ----------------------------*/
  10382.  
  10383. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  10384. var monN = parseInt(getPosition()[2]);
  10385. for(var type in keltypes) {
  10386. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  10387. for(var i=this['nb'+type] ; i>0 ; i--) {
  10388. var tr = this['tr_'+type.toLowerCase()][i];
  10389. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  10390. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  10391. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  10392. var sonN = getXxxPosition(type, i)[2];
  10393. var d = getXxxDistance(type, i);
  10394. if(sonN==monN && d>=dmin && d<=dmax) {
  10395. var iconeAction = document.evaluate(
  10396. "./descendant::img[@alt='"+alt+"']",
  10397. tr, null, 9, null
  10398. ).singleNodeValue;
  10399. if(iconeAction) {
  10400. if(iconeAction.title) {
  10401. iconeAction.title += "\n"+message;
  10402. } else {
  10403. iconeAction.title = message;
  10404. }
  10405. iconeAction.src = urlIcon;
  10406. } else {
  10407. var tdAction = tr.getElementsByTagName('td')[1];
  10408. var icon = document.createElement('img');
  10409. icon.src = urlIcon;
  10410. icon.height = 20;
  10411. icon.alt = alt;
  10412. icon.title = message;
  10413. tdAction.appendChild(icon);
  10414. }
  10415. }
  10416. }
  10417. }
  10418. }
  10419.  
  10420. function computeCharge() {
  10421. computeActionDistante(1,
  10422. getPortee__Vue(
  10423. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  10424. MY_getValue(numTroll+".caracs.regeneration")
  10425. ),
  10426. {'Monstres':1, 'Trolls':1},
  10427. 'Attaquer',
  10428. MHicons+'E_Metal09.png',
  10429. 'Cible à portée de Charge'
  10430. );
  10431. }
  10432.  
  10433. function computeProjo() {
  10434. computeActionDistante(0,
  10435. getPortee__Vue(
  10436. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10437. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10438. ),
  10439. {'Monstres':1, 'Trolls':1},
  10440. 'Attaquer',
  10441. MHicons+'S_Fire05.png',
  10442. 'Cible à portée de Projo'
  10443. );
  10444. }
  10445.  
  10446. function computeTelek() {
  10447. computeActionDistante(0,
  10448. Math.floor((
  10449. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10450. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10451. )/2),
  10452. {'Tresors':1},
  10453. 'Telek',
  10454. MHicons+'S_Magic04.png',
  10455. 'Trésor à portée de Télékinésie'
  10456. );
  10457. }
  10458.  
  10459. function computeLdP() {
  10460. computeActionDistante(0,
  10461. 2+Math.floor((
  10462. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10463. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10464. )/5),
  10465. {'Monstres':1, 'Trolls':1},
  10466. 'self',
  10467. MHicons+'P_Red01.png',
  10468. 'Cible à portée de Lancer de Potions'
  10469. );
  10470. }
  10471.  
  10472.  
  10473. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  10474.  
  10475. function putScriptExterne(sInfo) {
  10476. for (var iBricol = 1; ; iBricol++) {
  10477. var extClef = iBricol == 1 ? '' : iBricol;
  10478. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  10479. if (!sInfo) break;
  10480. putScriptExterneOneIT(sInfo);
  10481. }
  10482. }
  10483.  
  10484. function putScriptExterneOneIT(sInfo) {
  10485. if(!sInfo || sInfo=='') return;
  10486.  
  10487. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  10488. if(nomit=='bricol') {
  10489. var data = sInfo.split('$');
  10490. try {
  10491. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  10492. // appendNewScript(URL_bricol+data[1]
  10493. // +'/mz.php?login='+data[2]
  10494. // +'&password='+data[3]
  10495. // );
  10496. FF_XMLHttpRequest({
  10497. method: 'GET',
  10498. url: URL_bricol+data[1]
  10499. +'/mz_json.php?login='+encodeURIComponent(data[2])
  10500. +'&password='+data[3],
  10501. trace: 'bricolTroll',
  10502. onload: function(responseDetails) {
  10503. try {
  10504. if (responseDetails.status == 0) {
  10505. window.console.log('status=0 à l\'appel bricol\'troll');
  10506. if (isHTTPS) {
  10507. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  10508. } else {
  10509. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  10510. }
  10511. return;
  10512. }
  10513. var ratibusData;
  10514. try {
  10515. ratibusData = JSON.parse(responseDetails.responseText);
  10516. } catch(e) {}
  10517. if (ratibusData === undefined) {
  10518. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  10519. return;
  10520. }
  10521. if (ratibusData.error) {
  10522. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  10523. } else {
  10524. putInfosTrolls(ratibusData.data.trolls, data[1]);
  10525. }
  10526. } catch(e) {
  10527. window.console.log(traceStack(e, 'retour bricol\'troll'));
  10528. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  10529. }
  10530. }
  10531. });
  10532. } catch(e) {
  10533. if (isHTTPS) {
  10534. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  10535. } else {
  10536. window.console.log(traceStack(e, 'appel bricol\'troll'));
  10537. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  10538. }
  10539. }
  10540. }
  10541. }
  10542.  
  10543. /*
  10544. * Roule 07/11/2016, on utilise mz_json qui envoie
  10545. {
  10546. "data": {
  10547. "trolls": {
  10548. "59424": {
  10549. "id": 59424,
  10550. "pv": xx,
  10551. "pv_max": xx,
  10552. "updated_at": "2016-10-31 07:28:40",
  10553. "dla": "2016-10-05 07:28:04",
  10554. "pa": 0
  10555. },
  10556. }
  10557. }
  10558. }
  10559. */
  10560.  
  10561. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  10562. function corrigeBricolTrolls(infosTrolls) {
  10563. for(var i in infosTrolls) {
  10564. var pv = infosTrolls[i][0];
  10565. var pvmax = infosTrolls[i][1];
  10566. var pvmem = MY_getValue(i+'.caracs.pv.max');
  10567. if(pvmem && pvmem>pvmax) {
  10568. infosTrolls[i][1] = pvmem;
  10569. pvmax = pvmem;
  10570. }
  10571. if(pv>pvmax) {
  10572. var newpvmax = 5*Math.ceil(pv/5);
  10573. MY_setValue(i+'.caracs.pv.max',newpvmax);
  10574. infosTrolls[i][1] = newpvmax;
  10575. }
  10576. }
  10577. }
  10578.  
  10579. // insère 2 TD avant nextTD avec les infos venant de l'IT
  10580. function addTdInfosTroll(infos, TR, itName) {
  10581. /* cadre barre PV */
  10582. var tab = document.createElement('div');
  10583. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  10584. /* barre PV */
  10585. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  10586. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  10587. .vieContainer {
  10588. background-color: #CCC;
  10589. width: 50px;
  10590. height: 6px;
  10591. border: 1px solid #000;
  10592. text-align: left;
  10593. }
  10594. */
  10595. tab.style.width = '100px';
  10596. tab.style.height = '10px';
  10597. tab.style.border = '1px solid #000';
  10598. tab.style.textAlign = 'left';
  10599. var div2 = document.createElement('div');
  10600. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  10601. var dateLimite = new Date();
  10602. dateLimite.setDate(dateLimite.getDate() - 7);
  10603. if (infos.oUpdatedAt < dateLimite) {
  10604. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  10605. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  10606. } else if (pourcentVie > 66) {
  10607. div2.style.backgroundColor = '#77EE77';
  10608. } else if (pourcentVie > 33) {
  10609. div2.style.backgroundColor = '#EEEE77';
  10610. } else {
  10611. div2.style.backgroundColor = '#FF0000';
  10612. }
  10613. div2.style.width = pourcentVie + '%';
  10614. div2.style.height = '10px';
  10615. tab.appendChild(div2);
  10616. /* ancienne méthode par img, à supprimer
  10617. var img = document.createElement('img');
  10618. img.src = '../Images/Interface/milieu.gif';
  10619. img.height = 10;
  10620. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  10621. tab.appendChild(img);
  10622. */
  10623.  
  10624. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  10625. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  10626. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  10627. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  10628.  
  10629. /* lien vers l'IT */
  10630. var lien = document.createElement('a');
  10631. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  10632. lien.href = URL_bricol+itName+'/index.php';
  10633. lien.target = '_blank';
  10634. lien.appendChild(tab);
  10635. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  10636. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  10637. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  10638. //insertTdElement(tdGuilde,lien);
  10639. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  10640. /* PAs dispos */
  10641. var span = document.createElement('span');
  10642. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  10643. appendText(span, infos.pa +' PA' );
  10644. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  10645. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  10646. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  10647. span.style.backgroundColor = 'B8EEB8';
  10648. }
  10649. //insertTdElement(tdGuilde, span);
  10650. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  10651. }
  10652.  
  10653. var MZ_tabTrTrollById;
  10654. function putInfosTrolls(infosTrolls, itName) {
  10655. try {
  10656. if (MZ_tabTrTrollById === undefined) {
  10657. MZ_tabTrTrollById = new Array;
  10658. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  10659. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  10660. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  10661. td.width = 40;
  10662. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  10663. td.width = 105;
  10664. for(i=nbTrolls ; i>0 ; i--) {
  10665. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  10666. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  10667. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  10668. }
  10669. }
  10670.  
  10671.  
  10672. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  10673. //corrigeBricolTrolls(infosTrolls);
  10674.  
  10675. // supression des infos trop vieilles (un mois)
  10676. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  10677. var dateLimite = new Date();
  10678. dateLimite.setMonth(dateLimite.getMonth() - 1);
  10679.  
  10680. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  10681. var str = MY_getValue(numTroll+'.INFOSIT');
  10682. var bAjoutTrollInvi = false;
  10683. if (str) {
  10684. var arr = str.split('$');
  10685. bAjoutTrollInvi = arr[4]>0;
  10686. }
  10687.  
  10688. var tBody = tr_trolls[0].parentNode;
  10689. if (tr_trolls[1] !== undefined)
  10690. tBody = tr_trolls[1].parentNode;
  10691.  
  10692. //window.console.log('nb Troll IT : ' + IDs.length);
  10693. var pos = getPosition();
  10694.  
  10695. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  10696. for (var idTroll in infosTrolls) {
  10697. var infos = infosTrolls[idTroll];
  10698. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  10699. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  10700. if (idTroll == numTroll) continue; // pas nous-même
  10701. var tr;
  10702. if (idTroll in MZ_tabTrTrollById) {
  10703. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  10704. tr = MZ_tabTrTrollById[idTroll];
  10705. } else {
  10706. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  10707. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  10708. // trouver où insérer ce Troll
  10709. var next = undefined;
  10710. for(var j=0 ; j<tr_trolls.length ; j++) {
  10711. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  10712. if (thisDist > distance) {
  10713. next = tr_trolls[j]
  10714. break;
  10715. }
  10716. }
  10717. if (next !== undefined) {
  10718. tr = insertTr(next,'mh_tdpage')
  10719. } else {
  10720. tr = appendTr(tBody,'mh_tdpage');
  10721. }
  10722. tr.style.color = 'orange';
  10723. var td = appendTd(tr); // distance
  10724. appendText(td, distance);
  10725. td = appendTd(tr); // actions
  10726. td = appendTd(tr); // ID
  10727. appendText(td, idTroll);
  10728. td = appendTd(tr); // Nom
  10729. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  10730. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  10731. td = appendTd(tr); // PV
  10732. td = appendTd(tr); // PA
  10733. td = appendTd(tr); // Guilde
  10734. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  10735. td = appendTd(tr); // Niveau
  10736. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  10737. td.align = 'center';
  10738. td = appendTd(tr); // Race
  10739. if (infos.race) appendText(td, infos.race);
  10740. td = appendTd(tr); // X
  10741. td.align = 'center';
  10742. if (infos.x !== undefined) appendText(td, infos.x);
  10743. td = appendTd(tr); // Y
  10744. td.align = 'center';
  10745. if (infos.y !== undefined) appendText(td, infos.y);
  10746. td = appendTd(tr); // N
  10747. td.align = 'center';
  10748. if (infos.n !== undefined) appendText(td, infos.n);
  10749. MZ_tabTrTrollById[idTroll] = tr;
  10750. }
  10751. if (!tr.done) {
  10752. addTdInfosTroll(infos, tr, itName);
  10753. tr.done = true;
  10754. }
  10755. }
  10756. } catch(e) {
  10757. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  10758. window.console.error(traceStack(e, 'putInfosTrolls'));
  10759. }
  10760. }
  10761.  
  10762.  
  10763. /* Mode Tétalanvert! ---------------------------------------------------------*/
  10764.  
  10765. function calculeDistance(maPos,posArr) {
  10766. return Math.max(
  10767. Math.abs(maPos[0]-posArr[0]),
  10768. Math.abs(maPos[1]-posArr[1]),
  10769. Math.abs(maPos[2]-posArr[2])
  10770. );
  10771. }
  10772.  
  10773. function inversionCoord() {
  10774. var maPos = getPosition();
  10775. var listeOffsets = {
  10776. 'monstres':checkBoxLevels.checked?4:3,
  10777. 'trolls':6,
  10778. };
  10779. for(var type in listeOffsets) {
  10780. var trList = this['tr_'+type];
  10781. var offset = listeOffsets[type];
  10782. for(var i=trList.length-1 ; i>0 ; i--) {
  10783. var oldX = parseInt(trList[i].cells[offset].textContent);
  10784. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  10785. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  10786. trList[i].cells[offset].innerHTML = oldY;
  10787. trList[i].cells[offset+1].innerHTML = oldX;
  10788. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  10789. }
  10790. }
  10791. }
  10792.  
  10793.  
  10794. /* Partie principale */
  10795. function do_vue() {
  10796. for(var type in typesAFetcher) {
  10797. fetchData(type);
  10798. }
  10799.  
  10800. // roule' 11/03/2016
  10801. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  10802. // je fais une recopie :(
  10803. tr_monstres = this['tr_monstres'];
  10804. tr_trolls = this['tr_trolls'];
  10805. tr_tresors = this['tr_tresors'];
  10806. tr_champignons = this['tr_champignons'];
  10807. tr_lieux = this['tr_lieux'];
  10808.  
  10809. nbMonstres = this['nbMonstres'];
  10810. nbTrolls = this['nbTrolls'];
  10811. nbTresors = this['nbTresors'];
  10812. nbChampignons = this['nbChampignons'];
  10813. nbLieux = this['nbLieux'];
  10814.  
  10815. try {
  10816. start_script(31);
  10817. initialiseInfos();
  10818. savePosition();
  10819.  
  10820. // Fonctionnalité "Têtalenvert" cachée, en test :
  10821. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  10822. inversionCoord();
  10823. }
  10824. ajoutDesFiltres();
  10825. set2DViewSystem();
  10826. //putBoutonTroogle();
  10827. putBoutonPXMP();
  10828. synchroniseFiltres();
  10829. toggleLevelColumn();
  10830.  
  10831. refreshDiplo();
  10832. //400 ms
  10833. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  10834. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  10835. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  10836. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  10837. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  10838. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  10839. var noTresorsEngages =
  10840. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  10841. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  10842. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  10843. filtreMonstres();
  10844. if(noIntangibles) {
  10845. filtreTrolls();
  10846. }
  10847. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  10848. filtreTresors();
  10849. }
  10850. if(noTrou) {
  10851. filtreLieux();
  10852. }
  10853.  
  10854. initPopupVue();
  10855. initPXTroll();
  10856.  
  10857. if(getTalent("Projectile Magique")!=0) {
  10858. computeProjo();
  10859. }
  10860. if(getTalent("Charger")!=0) {
  10861. computeCharge();
  10862. }
  10863. if(getTalent("Télékinésie")!=0) {
  10864. computeTelek();
  10865. }
  10866. if(getTalent("Lancer de Potions")!=0) {
  10867. computeLdP();
  10868. }
  10869. putScriptExterne();
  10870. displayScriptTime();
  10871. } catch(e) {
  10872. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10873. window.console.error(traceStack(e, 'vue'));
  10874. }
  10875. }
  10876.  
  10877.  
  10878.  
  10879. /*******************************************************************************
  10880. * This file is part of Mountyzilla. *
  10881. * *
  10882. * Mountyzilla is free software; you can redistribute it and/or modify *
  10883. * it under the terms of the GNU General Public License as published by *
  10884. * the Free Software Foundation; either version 2 of the License, or *
  10885. * (at your option) any later version. *
  10886. * *
  10887. * Mountyzilla is distributed in the hope that it will be useful, *
  10888. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10889. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10890. * GNU General Public License for more details. *
  10891. * *
  10892. * You should have received a copy of the GNU General Public License *
  10893. * along with Mountyzilla; if not, write to the Free Software *
  10894. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10895. *******************************************************************************/
  10896.  
  10897. // x~x profil2
  10898.  
  10899. /*---------------------------- Variables globales ----------------------------*/
  10900.  
  10901. var
  10902. // Anatrolliseur
  10903. urlAnatrolliseur,
  10904. // Infobulles talents
  10905. hauteur = 50, bulleStyle = null,
  10906. // Caracteristiques
  10907. // Infos troll
  10908. race, niv, idtroll, datecrea,
  10909. idguilde, nomguilde,
  10910. // Etats du troll
  10911. fatigue, bmfatigue,
  10912.  
  10913. // Experience, Pi, ...
  10914. pxdistribuables, pxperso,
  10915. piutilisable, pitotal,
  10916. nbmeurtres, nbmorts,
  10917. // utilisee pour les moyennes MM/jour, kill/jour, etc
  10918. NBjours,
  10919. // calcul des DLA suivantes
  10920. DLA, DLAsuiv, HeureServeur,
  10921. // details duree du tour (calcul pvdispo) :
  10922. dtb, pdm, bmt, adb, dpt,
  10923. //posale
  10924. posX, posY, posN,
  10925. // caracs physiques
  10926. vue, vuebp, vuebm, vuetotale,
  10927. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  10928. reg, regbp, regbm, regmoy,
  10929. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  10930. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  10931. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  10932. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  10933. rm, rmbp, rmbm, rmtotale,
  10934. mm, mmbp, mmbm, mmtotale,
  10935.  
  10936. // Variables speciales Kastars
  10937. pvActuelKastar, minParPV, overDLA,
  10938. // id pour edition manuelle de lastDLA :
  10939. inJour, inMois, inAn, inHr, inMin, inSec,
  10940. // id pour auto-refresh lastDLA :
  10941. lastDLAZone, maxAMZone, cumulZone,
  10942. lastDLA, DLAaccel;
  10943.  
  10944.  
  10945. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  10946.  
  10947. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10948. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10949. function getUniqueValueBySelector(selector, defaultValue){
  10950. var valNode = document.querySelector(selector);
  10951. if(valNode!=null){
  10952. if(valNode.hasChildNodes()) {
  10953. return valNode.childNodes[0].nodeValue;
  10954. }else{
  10955. return defaultValue;
  10956. }
  10957. } else{
  10958. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10959. return defaultValue;
  10960. }
  10961. }
  10962. function getUniqueStringValueBySelector(selector){
  10963. return getUniqueValueBySelector(selector,"");
  10964. }
  10965. function getUniqueIntValueBySelector(selector){
  10966. var ret = getUniqueValueBySelector(selector,0);
  10967. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10968. ret = 0;
  10969. }
  10970. return parseInt(ret);
  10971. }
  10972. function getUniqueFloatValueBySelector(selector){
  10973. var ret = getUniqueValueBySelector(selector,0.0);
  10974. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10975. ret = 0.0;
  10976. }
  10977. return parseFloat(ret);
  10978. }
  10979.  
  10980.  
  10981. function resiste(Ddeg,bm) {
  10982. // version naive mais compréhensible ^^
  10983. // DEBUG: à revoir
  10984. if(!bm) {
  10985. return 2*Math.floor(Ddeg/2);
  10986. }
  10987. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  10988. }
  10989.  
  10990. function retourAZero(fatig) {
  10991. var fat = fatig, raz = 0;
  10992. while(fat>0) {
  10993. raz++;
  10994. fat = Math.floor(fat/1.25);
  10995. }
  10996. return raz;
  10997. }
  10998.  
  10999. function decumulPumPrem(bonus) {
  11000. switch(bonus) {
  11001. case 20: return 33;
  11002. case 33: return 41;
  11003. case 41: return 46;
  11004. case 46: return 49;
  11005. case 49: return 51;
  11006. default: return 20;
  11007. }
  11008. }
  11009.  
  11010. function coefDecumul(i) {
  11011. switch(i) {
  11012. case 2: return 0.67;
  11013. case 3: return 0.4;
  11014. case 4: return 0.25;
  11015. case 5: return 0.15;
  11016. default: return 0.1;
  11017. }
  11018. }
  11019.  
  11020. function dureeHM(dmin) {
  11021. var ret = "";
  11022. dmin = Math.floor(dmin);
  11023. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  11024. var mins = dmin%60;
  11025. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  11026. return (ret) ? ret : "-";
  11027. }
  11028.  
  11029. // extraction d'une durée
  11030. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  11031. // c'est protégé (rend 0 si l'élément est absent)
  11032. // Roule' 24/12/2016
  11033. function extractionDuree(selecteur) {
  11034. var s = getUniqueStringValueBySelector(selecteur);
  11035. if (!s) return 0;
  11036. var tabN = getNumbers(s);
  11037. if (tabN.length < 2) return 0;
  11038. return tabN[0] * 60 + tabN[1];
  11039. }
  11040.  
  11041. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  11042.  
  11043. function extractionDonnees() {
  11044. // Variables temporaires
  11045. var Nbrs = {};
  11046.  
  11047. // *********************
  11048. // Cadre "Description"
  11049. // *********************
  11050. race = getUniqueStringValueBySelector('#descr #race');
  11051. debugMZ("Race : " + race);
  11052. idtroll = getUniqueStringValueBySelector('#descr #id');
  11053. debugMZ("Id troll : " + idtroll);
  11054. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  11055. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  11056. datecrea = new Date(StringToDate(strDateCrea));
  11057. debugMZ("Date creation : " + datecrea);
  11058. // Guilde
  11059. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  11060. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  11061. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  11062.  
  11063. // *******************
  11064. // Cadre "Experience"
  11065. // *******************
  11066. // Niveau de troll
  11067. niv = getUniqueIntValueBySelector('#exp #niv');
  11068. nivTroll = niv;
  11069. debugMZ("Niveau : " + niv);
  11070. // PX
  11071. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  11072. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  11073. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  11074. // PI
  11075. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  11076. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  11077. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  11078. // Meutres/Morts
  11079. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  11080. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  11081. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  11082.  
  11083. // *********************
  11084. // Cadre "Tour de Jeu"
  11085. // *********************
  11086. // DLA
  11087. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  11088. DLA = new Date(StringToDate(Nbrs["dla"]));
  11089. debugMZ("DLA: " + DLA);
  11090. // DLA suivante
  11091. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  11092. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  11093. debugMZ("DLAsuiv: " + DLAsuiv);
  11094. // Duree normale de mon Tour
  11095. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  11096. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  11097. dtb = extractionDuree("#dla #tour");
  11098. debugMZ("Duree normale de mon Tour : " + dtb);
  11099. // Bonus/Malus sur la duree
  11100. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  11101. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  11102. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  11103. debugMZ("Bonus/Malus sur la duree : " + bmt);
  11104. // Augmentation due aux blessures
  11105. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  11106. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  11107. adb = extractionDuree("#dla #blessure");
  11108. debugMZ("Augmentation due aux blessures : " + adb);
  11109. // Poids de l'equipement
  11110. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  11111. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  11112. pdm = extractionDuree("#dla #poids");
  11113. debugMZ("Poids de l'equipement : " + pdm);
  11114. // Duree de mon prochain Tour
  11115. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  11116. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  11117. dpt = extractionDuree("#dla #duree>b");
  11118. debugMZ('Duree de mon prochain Tour : ' + dpt);
  11119.  
  11120. // ****************
  11121. // Cadre "Etats"
  11122. // ****************
  11123. // Position du troll :
  11124. posX = getUniqueIntValueBySelector('#pos #x');
  11125. posY = getUniqueIntValueBySelector('#pos #y');
  11126. posN = getUniqueIntValueBySelector('#pos #n');
  11127. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  11128. // PV actuel
  11129. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  11130. pvActuelKastar = pvcourant;
  11131. debugMZ("PV actuel : " + pvcourant)
  11132. // Fatigue
  11133. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  11134. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  11135. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  11136.  
  11137. // **************************
  11138. // Cadre "Caracteristiques"
  11139. // **************************
  11140. // Attaque
  11141. att = getUniqueIntValueBySelector('#carac #att');
  11142. attbp = getUniqueIntValueBySelector('#carac #att_p');
  11143. attbm = getUniqueIntValueBySelector('#carac #att_m');
  11144. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  11145. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  11146. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  11147. attmoy = 3.5*att + attbp + attbm;
  11148. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  11149. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  11150. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  11151. // Esquive
  11152. esq = getUniqueIntValueBySelector('#carac #esq');
  11153. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  11154. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  11155. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  11156. esqmoy = 3.5*esq + esqbp+esqbm;
  11157. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  11158. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  11159. // Degat
  11160. deg = getUniqueIntValueBySelector('#carac #deg');
  11161. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  11162. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  11163. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  11164. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  11165. degmoy = 2*deg + degbp+degbm;
  11166. degmoycrit = 3*deg + degbp+degbm;
  11167. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  11168. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  11169. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  11170. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  11171. // PV
  11172. pvbase = getUniqueIntValueBySelector('#carac #pv');
  11173. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  11174. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  11175. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  11176. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  11177. // Regeneration
  11178. reg = getUniqueIntValueBySelector('#carac #reg');
  11179. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  11180. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  11181. regmoy = 2 * reg + regbp + regbm; // D3
  11182. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  11183. // Armure
  11184. arm = getUniqueIntValueBySelector('#carac #arm');
  11185. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  11186. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  11187. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  11188. armmoy = 2*arm + armbp+armbm;
  11189. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  11190. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  11191. // TODO : D d'armure non active
  11192. // Vue
  11193. vue = getUniqueIntValueBySelector('#carac #vue');
  11194. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  11195. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  11196. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  11197. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  11198. // RM
  11199. rm = getUniqueIntValueBySelector('#carac #rm');
  11200. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  11201. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  11202. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  11203. rmTroll = rmtotale;
  11204. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  11205. // MM
  11206. mm = getUniqueIntValueBySelector('#carac #mm');
  11207. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  11208. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  11209. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  11210. mmTroll = mmtotale;
  11211. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  11212.  
  11213. // Heure Serveur
  11214. try {
  11215. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  11216. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  11217. HeureServeur = new Date(StringToDate(heureServeurSTR));
  11218. } catch (e) {
  11219. window.console.warn(
  11220. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  11221. );
  11222. HeureServeur = new Date();
  11223. }
  11224. debugMZ("HeureServeur: " + HeureServeur);
  11225.  
  11226. // ***INIT GLOBALE*** NBjours
  11227. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  11228.  
  11229. // Calcul debut lien anatroliseur avec les caracteristiques connues
  11230. var amelio_dtb = function(dtb) {
  11231. if(dtb>555) {
  11232. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  11233. }
  11234. return 10+Math.ceil((555-dtb)/2.5);
  11235. },
  11236. amelio_pv = Math.floor(pvbase/10)-3,
  11237. amelio_vue = vue-3,
  11238. amelio_att = att-3,
  11239. amelio_esq = esq-3,
  11240. amelio_deg = deg-3,
  11241. amelio_reg = reg-1,
  11242. amelio_arm = arm-1;
  11243. if(race==="Darkling"){amelio_reg--; }
  11244. if(race==="Durakuir"){amelio_pv-- ; }
  11245. if(race==="Kastar") {amelio_deg--; }
  11246. if(race==="Skrim") {amelio_att--; }
  11247. if(race==="Tomawak") {amelio_vue--; }
  11248.  
  11249. urlAnatrolliseur = URL_AnatrolDispas
  11250. +"outils_anatrolliseur.php?anatrolliseur=v8"
  11251. +"|r="+race.toLowerCase()
  11252. +"|dla="+amelio_dtb(dtb)
  11253. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  11254. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  11255. +"|att="+amelio_att+","+attbp+","+attbm
  11256. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  11257. +"|deg="+amelio_deg+","+degbp+","+degbm
  11258. +"|reg="+amelio_reg+","+regbp+","+regbm
  11259. +"|arm="+amelio_arm+","+armbp+","+armbm
  11260. +"|mm="+mmtotale
  11261. +"|rm="+rmtotale+"|";
  11262. }
  11263.  
  11264. function saveProfil() {
  11265. MY_setValue(idtroll+'.caracs.attaque',att);
  11266. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  11267. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  11268. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  11269. if(atttourD||atttourP||atttourM) {
  11270. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  11271. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  11272. }
  11273. MY_setValue(idtroll+'.caracs.esquive',esq);
  11274. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  11275. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  11276. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  11277. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  11278. MY_setValue(idtroll+'.caracs.degats',deg);
  11279. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  11280. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  11281. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  11282. if(degtourP||degtourM){
  11283. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  11284. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  11285. }
  11286. MY_setValue(idtroll+'.caracs.regeneration',reg);
  11287. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  11288. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  11289. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  11290. MY_setValue(idtroll+'.caracs.vue',vue);
  11291. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  11292. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  11293. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  11294. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  11295. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  11296. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  11297. MY_setValue(idtroll+'.caracs.rm',rm);
  11298. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  11299. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  11300. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  11301. MY_setValue(idtroll+'.caracs.mm',mm);
  11302. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  11303. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  11304. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  11305. MY_setValue(idtroll+'.caracs.armure',arm);
  11306. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  11307. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  11308. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  11309. MY_setValue(idtroll+'.position.X',posX);
  11310. MY_setValue(idtroll+'.position.Y',posY);
  11311. MY_setValue(idtroll+'.position.N',posN);
  11312. MY_setValue(idtroll+'.race',race);
  11313. MY_setValue(idtroll+'.niveau',niv);
  11314. MY_setValue(idtroll+'.idguilde',idguilde);
  11315. MY_setValue(idtroll+'.nomguilde',nomguilde);
  11316. }
  11317.  
  11318.  
  11319. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  11320.  
  11321. function setInfosCaracteristiques() {
  11322. // Modification de l'entete
  11323. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  11324. thTotal.innerHTML+='|<i>Moyenne</i>';
  11325. thTotal.title="Moyenne (Moyenne ce tour)";
  11326.  
  11327. // Ajout des informations calculees
  11328. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  11329. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  11330. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  11331.  
  11332. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  11333. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  11334. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  11335.  
  11336. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  11337. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  11338. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  11339.  
  11340. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  11341. var tdRegTotal = trRegeneration.children[5];
  11342. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  11343. // Temps recupere par reg (propale R')
  11344. var regmoyTemp = Math.max(0, regmoy);
  11345. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  11346. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  11347. if (sec != 0) {
  11348. regTitle += " " + sec + " sec";
  11349. }
  11350. trRegeneration.title = regTitle;
  11351.  
  11352. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  11353. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  11354. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  11355.  
  11356. var trRM=document.querySelector("table#caracs #rm").parentElement;
  11357. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  11358. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  11359.  
  11360.  
  11361. var trMM=document.querySelector("table#caracs #mm").parentElement;
  11362. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  11363. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  11364.  
  11365. var tdRefl=document.querySelector("#refl");
  11366. // TODO : prendre en compte bonus/malus D esq du tour ?
  11367. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + esqbp + esqbm;
  11368. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  11369. }
  11370.  
  11371. function setLienAnatrolliseur(){
  11372. var pTableAmelio = document.querySelector("#carac>div>p");
  11373. pTableAmelio.innerHTML+=" - ";
  11374. var aElt = document.createElement("a");
  11375. aElt.setAttribute("href",urlAnatrolliseur);
  11376. aElt.setAttribute("target","_blank");
  11377. aElt.className="AllLinks";
  11378. aElt.innerHTML="Anatrolliser";
  11379. pTableAmelio.appendChild(aElt);
  11380. }
  11381. function setInfoDescription() {
  11382. var txtDateCrea = (NBjours!=1) ?
  11383. " ("+NBjours+" jours dans le hall)" :
  11384. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  11385. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  11386. }
  11387.  
  11388. function setInfosEtatLieux() {
  11389. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  11390. '?search=position&orderBy=distance&posx='+
  11391. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  11392. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  11393. appendBr(tdPosition);
  11394. var aElt = document.createElement("a");
  11395. aElt.setAttribute("href",urlBricol);
  11396. aElt.setAttribute("target","_blank");
  11397. aElt.className="AllLinks";
  11398. aElt.innerHTML="Lieux à proximité";
  11399. tdPosition.appendChild(aElt);
  11400. }
  11401.  
  11402. function setInfosEtatPV() { // pour AM et Sacro
  11403. var
  11404. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  11405. sec = Math.floor(15000/pvtotal)%60,
  11406. lifebar = document.querySelector("#pos .barre-vie");
  11407. if(sec!=0) { txt += " "+sec+" sec"; }
  11408. if(lifebar) { lifebar.title = txt; }
  11409. if(pvcourant<=0) { return; }
  11410. // Difference PV p/r a equilibre de temps (propale R')
  11411. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  11412. // ***INIT GLOBALE*** pvdispo
  11413. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11414. var span = document.createElement("span");
  11415. span.title = txt;
  11416. span.style.fontStyle = "italic";
  11417. if(bmt+pdm>=0) {
  11418. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  11419. } else if(pvdispo>0) {
  11420. txt = "Vous pouvez encore perdre "+
  11421. Math.min(pvdispo,pvcourant)+
  11422. " PV sans malus de temps.";
  11423. } else if(pvdispo<0) {
  11424. txt = "Il vous manque "
  11425. +(-pvdispo)
  11426. +" PV pour ne plus avoir de malus de temps.";
  11427. } else {
  11428. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  11429. }
  11430. appendText(span,txt);
  11431. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  11432. }
  11433.  
  11434. // Complete le cadre "Experience"
  11435. function setInfosExp() {
  11436. var tdNiv = document.querySelector("#exp #niv");
  11437.  
  11438. // Calcul niveau monstre/troll min pour gain PX
  11439. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  11440. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  11441.  
  11442. // Calcul PX restant
  11443. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  11444. if (pxRestant >= 0) {
  11445. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  11446. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  11447. }
  11448.  
  11449. // Calul pi/jour
  11450. var
  11451. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  11452. tdPi = document.querySelector("#exp #pi").parentElement;
  11453. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  11454. tdPi.title = tdPiTotal.title;
  11455.  
  11456. // Rapports meurtres,morts
  11457. var tdKill = document.querySelector("#exp #kill");
  11458. tdKill.setAttribute("colspan", 1);
  11459. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  11460.  
  11461. var tdMort = document.querySelector("#exp #mort");
  11462. tdMort.setAttribute("colspan", 1);
  11463. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  11464.  
  11465. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  11466. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  11467. }
  11468.  
  11469.  
  11470. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  11471.  
  11472. function minParPVsac(fat,bm) {
  11473. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  11474. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  11475. var out = [];
  11476. out[0] = (fat>4) ?
  11477. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  11478. 30;
  11479. if(bm && bm>0) {
  11480. var totalfat=fat+bm;
  11481. out[1] = (totalfat>4) ?
  11482. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  11483. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  11484. }
  11485. return out;
  11486. }
  11487.  
  11488. function toInt(str) {
  11489. str = parseInt(str);
  11490. return (str) ? str : 0;
  11491. }
  11492.  
  11493. function saveLastDLA() {
  11494. // pour les calculs d'AM max
  11495. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  11496. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  11497. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  11498. lastDLA = new Date( StringToDate(str) );
  11499. MY_setValue(numTroll+'.DLA.ancienne',str);
  11500. lastDLAZone.innerHTML = '';
  11501. var b = document.createElement('b');
  11502. b.addEventListener('click',inputMode,false);
  11503. appendText(b,str);
  11504. lastDLAZone.appendChild(b);
  11505. refreshAccel();
  11506. }
  11507.  
  11508. function inputMode() {
  11509. // Edition manuelle lastDLA
  11510. var date;
  11511. if(lastDLA)
  11512. date = new Date( lastDLA );
  11513. else
  11514. date = new Date( DLAaccel );
  11515. lastDLAZone.innerHTML = '';
  11516. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  11517. appendText(lastDLAZone,'/');
  11518. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  11519. appendText(lastDLAZone,'/');
  11520. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  11521. appendText(lastDLAZone,' - ');
  11522. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  11523. appendText(lastDLAZone,':');
  11524. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  11525. appendText(lastDLAZone,':');
  11526. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  11527. appendText(lastDLAZone,' - ');
  11528. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  11529. }
  11530.  
  11531. function setAccel() {
  11532. var
  11533. BMfrais=false,
  11534. fat=fatigue, listeBmFat=[],
  11535. tr, th, insertPt;
  11536.  
  11537. // Creation ligne speciale pour AM dans le cadre "Etat"
  11538. tr = document.createElement('tr');
  11539. th = document.createElement('th');
  11540. appendText(th,'Fatigue et AM',true);
  11541. tr.appendChild(th);
  11542. insertPt = document.createElement('td');
  11543. tr.appendChild(insertPt);
  11544. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  11545.  
  11546. // Est-on en over-DLA ?
  11547. // ***INIT GLOBALE*** overDLA
  11548. overDLA = (HeureServeur>DLA.getTime()+3e5);
  11549. if(overDLA) {
  11550. fat=Math.floor(fatigue/1.25);
  11551. }
  11552.  
  11553. // Gestion des BM de fatigue
  11554. if(bmfatigue>0) {
  11555. // On tente de recuperer les BM de fatigue de la page des BM
  11556. if(MY_getValue(numTroll+'.bm.fatigue')) {
  11557. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  11558. BMmemoire.pop();
  11559. var tour = 0;
  11560. for(var i=0 ; i<BMmemoire.length ; i++) {
  11561. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  11562. while(tour<=parseInt(nbrs[0])) {
  11563. listeBmFat[tour]=parseInt(nbrs[1]);
  11564. tour++;
  11565. }
  11566. }
  11567. }
  11568. if(listeBmFat[0]==bmfatigue) {
  11569. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  11570. BMfrais = true;
  11571. MY_removeValue(numTroll+".bm.fatigue");
  11572. }
  11573. } else {
  11574. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  11575. BMfrais = true;
  11576. }
  11577. if(!BMfrais && bmfatigue>0) {
  11578. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  11579. if(bmfatigue==15) {
  11580. listeBmFat = [15,15,15];
  11581. } else {
  11582. listeBmFat = [30,30,15];
  11583. }
  11584. }
  11585. if(overDLA) {
  11586. // Si on est en over-DLA, on decale les bm d'un tour
  11587. listeBmFat.shift();
  11588. }
  11589. // Tableau des fatigues et accel futures
  11590. var
  11591. minppv = minParPVsac(fat,listeBmFat[0]),
  11592. table, tbody,
  11593. ligneTour, ligneFat, ligneMin,
  11594. col;
  11595. // ***INIT GLOBALE*** minParPV
  11596. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  11597. if(fat>0 || listeBmFat[0]>0) {
  11598. table = document.createElement('table');
  11599. table.className = 'mh_tdborder';
  11600. table.border = 0;
  11601. table.cellSpacing = 1;
  11602. table.cellPadding = 1;
  11603. table.style.textAlign = "center";
  11604. tbody = document.createElement('tbody');
  11605. table.appendChild(tbody);
  11606. insertPt.appendChild(table);
  11607. ligneTour = appendTr(tbody,'mh_tdtitre');
  11608. ligneTour.style.fontWeight = "bold";
  11609. var td = appendTdText(ligneTour,'Tour :',true);
  11610. td.align = 'left';
  11611. ligneFat = appendTr(tbody,'mh_tdpage');
  11612. td = appendTdText(ligneFat,'Fatigue :',true);
  11613. td.className = 'mh_tdtitre';
  11614. td.align = 'left';
  11615. ligneMin = appendTr(tbody,'mh_tdpage');
  11616. td = appendTdText(ligneMin,'1 PV =',true);
  11617. td.className = 'mh_tdtitre';
  11618. td.align = 'left';
  11619. col=0;
  11620. while(col<9 && (fat>0 || listeBmFat[col])) {
  11621. if(col==0) {
  11622. if(overDLA) {
  11623. var i = document.createElement('i');
  11624. appendText(i,'A activer');
  11625. ligneTour.appendChild(i);
  11626. } else {
  11627. appendTdText(ligneTour,'En cours');
  11628. }
  11629. } else {
  11630. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  11631. }
  11632. if(listeBmFat[col]) {
  11633. if(BMfrais || (!overDLA && col==0)) {
  11634. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  11635. appendTdText(ligneMin,minppv[1]+'\'');
  11636. } else {
  11637. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  11638. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  11639. }
  11640. } else {
  11641. appendTdText(ligneFat,fat);
  11642. appendTdText(ligneMin,minppv[0]+'\'');
  11643. }
  11644. col++;
  11645. fat = Math.floor(fat / 1.25);
  11646. minppv = minParPVsac(fat,listeBmFat[col]);
  11647. }
  11648. if(fat>1 || (fat==1 && !overDLA)) {
  11649. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  11650. appendTdText(ligneFat,'-');
  11651. appendTdText(ligneMin,'-');
  11652. }
  11653. col = (overDLA) ?
  11654. Math.max(retourAZero(fatigue)-1,col) :
  11655. Math.max(retourAZero(fatigue),col);
  11656. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  11657. appendTdText(ligneFat,'0');
  11658. appendTdText(ligneMin,'30\'');
  11659. if(!BMfrais && bmfatigue) {
  11660. // si les BM n'ont pas ete rafraichis, on signale:
  11661. appendText(
  11662. insertPt,
  11663. '/!\\ Visitez la page des Bonus/Malus '+
  11664. 'pour mettre à jour votre fatigue. /!\\',
  11665. true
  11666. );
  11667. appendBr(insertPt);
  11668. }
  11669. appendBr(insertPt);
  11670. }
  11671. if(pvcourant<=0) {
  11672. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  11673. return;
  11674. }
  11675. if(fatigue>30) {
  11676. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  11677. return;
  11678. }
  11679. // Setup lastDLAZone
  11680. if(overDLA) {
  11681. // bypass des infos de "menu_FF.js" en cas d'overDLA
  11682. DLAaccel = new Date( DLAsuiv );
  11683. lastDLA = new Date( DLA );
  11684. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  11685. // ***INIT GLOBALE*** pvActuelKastar
  11686. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  11687. appendText(
  11688. insertPt,
  11689. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  11690. true
  11691. );
  11692. appendBr(insertPt);
  11693. } else {
  11694. DLAaccel = new Date( DLA );
  11695. pvActuelKastar = pvcourant;
  11696. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  11697. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  11698. } else {
  11699. lastDLA = false;
  11700. }
  11701. }
  11702. appendText(insertPt,'Dernière DLA enregistrée : ');
  11703. lastDLAZone = document.createElement('span');
  11704. lastDLAZone.style.cursor = 'pointer';
  11705. var b = document.createElement('b');
  11706. b.onclick = inputMode;
  11707. lastDLAZone.appendChild(b);
  11708. insertPt.appendChild(lastDLAZone);
  11709. if(lastDLA) {
  11710. appendText(b,DateToString(lastDLA));
  11711. } else {
  11712. appendText(b,'aucune');
  11713. }
  11714. appendBr(insertPt);
  11715. // Setup maxAMZone et cumulZone
  11716. appendText(insertPt,'Accélération maximale possible : ');
  11717. maxAMZone = document.createElement('b');
  11718. insertPt.appendChild(maxAMZone);
  11719. appendBr(insertPt);
  11720. cumulZone = document.createElement('span');
  11721. insertPt.appendChild(cumulZone);
  11722. refreshAccel();
  11723. }
  11724.  
  11725. function refreshAccel() {
  11726. var pvs, pvsmax;
  11727. // Acceleration pour cumul instantane
  11728. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  11729. if(lastDLA) {
  11730. pvsmax = Math.min(
  11731. pvActuelKastar-1,
  11732. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  11733. );
  11734. maxAMZone.innerHTML = pvsmax+" PV";
  11735. } else {
  11736. pvsmax = pvActuelKastar-1;
  11737. maxAMZone.innerHTML = "inconnue";
  11738. }
  11739. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  11740. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  11741. cumulZone.innerHTML = '';
  11742. if(pvs<=pvsmax) {
  11743. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  11744. appendText(cumulZone,pvs+' PV', true);
  11745. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  11746. if(pvs!=1) {
  11747. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  11748. -(pvs-1)*60*minParPV;
  11749. appendText(
  11750. cumulZone,
  11751. ' ('+(pvs-1)+' PV dans '+
  11752. Math.floor(gainSec/60)+'min'+
  11753. addZero(gainSec%60)+'s)'
  11754. );
  11755. }
  11756. } else {
  11757. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  11758. appendText(
  11759. cumulZone,
  11760. 'Après votre accélération maximale, il vous faudra encore attendre '+
  11761. dureeHM(avantDLA/6e4)+
  11762. ' avant de réactiver.'
  11763. );
  11764. }
  11765. }
  11766.  
  11767.  
  11768. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  11769.  
  11770. function traitementTalents() {
  11771. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  11772. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  11773. removeAllTalents();
  11774. var totalComp = injecteInfosBulles(trCompetence,'competences');
  11775. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  11776. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  11777. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  11778. }
  11779.  
  11780. function injecteInfosBulles(liste,fonction) {
  11781. var totalpc = 0;
  11782. // on parse la liste des talents du type 'fonction'
  11783. for(var i=0 ; i<liste.length ; i++) {
  11784. var
  11785. trTalent=liste[i],
  11786. node=trTalent.cells[1].querySelector('a'),
  11787. nomTalent=epure(trim(node.textContent)),
  11788. indiceTDniveaux=7,
  11789. indiceTDSousCompetence=2,
  11790. sousCompetences=undefined;
  11791. if(fonction=="competences"){
  11792. // un TD en plus pour des information complementaire liees a la comp
  11793. indiceTDniveaux++;
  11794. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  11795. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  11796. for (var j=0; j < sousCompetences.length; j++) {
  11797. sousCompetences[j] = sousCompetences[j].epure().trim();
  11798. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  11799. }
  11800. }
  11801. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  11802. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  11803. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  11804. totalpc += niveauxMaitrisesTalentArray[1];
  11805.  
  11806. // stockage des niveaux inferieurs du talent si presents
  11807. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  11808. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  11809. totalpc+=niveauxMaitrisesTalentArray[j+1];
  11810. }
  11811. }
  11812. return totalpc;
  11813. }
  11814.  
  11815. function setInfos(node,nom,fonction,niveau) {
  11816. node.nom = nom;
  11817. node.fonction = fonction;
  11818. node.niveau = niveau;
  11819. node.onmouseover = setBulle;
  11820. node.onmouseout = cacherBulle;
  11821. }
  11822.  
  11823. var arrayModifAnatroll = {
  11824. 'Glue':'Glu',
  11825. 'PuM':'PuiM',
  11826. 'HE':'Hurlement',
  11827. //'Insultes':'Insu',
  11828. 'Pistage':'Pist',
  11829. 'PuC':'Planter'
  11830. }
  11831.  
  11832. function setTalent(nom,pc,niveau,sousCompetences) {
  11833. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  11834. // (et pas les % dont osf) ne serait pas plus rentable
  11835. var nomEnBase = arrayTalents[epure(nom)];
  11836. if(!nomEnBase) { return; }
  11837. if(!niveau) { niveau = 1; }
  11838. switch(nomEnBase) {
  11839. case 'Insultes':
  11840. urlAnatrolliseur += 'Insu'+niveau+'|';
  11841. case 'IdT':
  11842. nomEnBase += niveau;
  11843. break;
  11844. case 'Golemo':
  11845. case 'Piege':
  11846. for (var i=0 ; i < sousCompetences.length ; i++) {
  11847. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  11848. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  11849. }
  11850. break;
  11851. case 'AP':
  11852. case 'Baroufle':
  11853. case 'CdB':
  11854. case 'CdM':
  11855. case 'Parer':
  11856. case 'Retraite':
  11857. case 'RB':
  11858. case 'SInterposer':
  11859. nomEnBase += niveau;
  11860. default:
  11861. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  11862. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  11863. }
  11864. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  11865. }
  11866.  
  11867. function creerBulleVide() {
  11868. var table = document.createElement('table');
  11869. table.id = 'bulle';
  11870. table.className = 'mh_tdborder';
  11871. table.width = 300;
  11872. table.border = 0;
  11873. table.cellPadding = 5;
  11874. table.cellSpacing = 1;
  11875. table.style =
  11876. 'position:absolute;'
  11877. +'visibility:hidden;'
  11878. +'z-index:800;'
  11879. +'height:auto;';
  11880. var tr = appendTr(table,'mh_tdtitre');
  11881. appendTdText(tr,'Titre');
  11882. tr = appendTr(table,'mh_tdpage');
  11883. appendTdText(tr,'Contenu');
  11884. var aList = document.getElementsByTagName('a');
  11885. aList[aList.length-1].parentNode.appendChild(table);
  11886. }
  11887.  
  11888. function cacherBulle() {
  11889. if(bulleStyle)
  11890. bulleStyle.visibility = 'hidden';
  11891. }
  11892.  
  11893. function setBulle(evt) {
  11894. var nom = this.nom;
  11895. var fonction = this.fonction;
  11896. var niveau = parseInt(this.niveau);
  11897. var str='';
  11898. if(fonction=='competences'){
  11899. str=competences(nom,niveau);
  11900. } else if(fonction=='sortileges') {
  11901. str=sortileges(nom,true);
  11902. }
  11903. if(str=='') return;
  11904. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  11905. var xfenetre, yfenetre, xpage, ypage, element = null;
  11906. var offset = 15;
  11907. var bulleWidth = 300;
  11908. if(!hauteur) hauteur = 50;
  11909. element = document.getElementById('bulle');
  11910. xfenetre = evt.clientX;
  11911. yfenetre = evt.clientY;
  11912. xpage = xfenetre;
  11913. ypage = yfenetre;
  11914. if(evt.pageX) xpage = evt.pageX;
  11915. if(evt.pageY) ypage = evt.pageY;
  11916. if(element) {
  11917. bulleStyle = element.style;
  11918. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  11919. element.childNodes[1].firstChild.innerHTML = str;
  11920. }
  11921. if(bulleStyle) {
  11922. if(xfenetre>bulleWidth+offset)
  11923. xpage -= bulleWidth+offset;
  11924. else
  11925. xpage += offset;
  11926. if(yfenetre>hauteur+offset)
  11927. ypage -= hauteur + offset;
  11928. bulleStyle.width = bulleWidth;
  11929. bulleStyle.left = xpage + 'px';
  11930. bulleStyle.top = ypage + 'px';
  11931. bulleStyle.visibility = 'visible';
  11932. }
  11933. }
  11934.  
  11935.  
  11936. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  11937.  
  11938. function competences(comp,niveau) {
  11939. var texte = '';
  11940. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  11941. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  11942. if(minParPV>1) texte += 's';
  11943. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  11944. }
  11945. else if(comp.indexOf('Attaque Precise')!=-1) {
  11946. var pc, lastmax=0, espatt=0;
  11947. var notMaxedOut = false;
  11948. for(var i=niveau ; i>0 ; i--) {
  11949. pc = getTalent(comp,i);
  11950. if(lastmax!=0 && pc<=lastmax) continue;
  11951. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  11952. attbp+attbm;
  11953. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11954. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  11955. ' => <b>'+jetatt+'</b><br/>';
  11956. espatt += (pc-lastmax)*jetatt;
  11957. lastmax = pc;
  11958. if(i<niveau) notMaxedOut = true;
  11959. }
  11960. if(notMaxedOut) {
  11961. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  11962. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  11963. }
  11964. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  11965. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11966. }
  11967. else if(comp.indexOf('Balayage')!=-1)
  11968. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  11969. +' => <b>'+attmoy+'</b><br/>'
  11970. +'Effet : <b>Met à terre l\'adversaire</b>';
  11971. else if(comp.indexOf('Bidouille')!=-1)
  11972. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  11973. +'de votre inventaire avec le texte de votre choix.';
  11974. else if(comp.indexOf('Baroufle')!=-1){
  11975. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  11976. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  11977. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  11978. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  11979. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  11980. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  11981. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  11982. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  11983. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  11984. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  11985. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  11986. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  11987. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  11988. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  11989. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  11990. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  11991. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  11992. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  11993. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  11994. '</tbody></table>';
  11995. }
  11996. else if(comp.indexOf('Botte Secrete')!=-1){
  11997. texte = 'Attaque : <b>'
  11998. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11999. +' => <b>'
  12000. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  12001. +'</b><br/>Dégâts : <b>'
  12002. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  12003. +' => <b>'
  12004. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  12005. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  12006. +'</b>';
  12007. }
  12008. else if(comp.indexOf('Camouflage')!=-1) {
  12009. var camou = getTalent('Camouflage');
  12010. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  12011. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  12012. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  12013. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  12014. }
  12015. else if(comp.indexOf('Charger')!=-1) {
  12016. if(pvcourant<=0)
  12017. return '<i>On ne peut charger personne quand on est mort !</i>';
  12018. var portee = Math.min(
  12019. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  12020. vuetotale);
  12021. if(portee<1)
  12022. return '<b>Impossible de charger</b>';
  12023. else {
  12024. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  12025. +' => <b>'+attmoy+'</b><br/>'
  12026. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  12027. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  12028. +'<br/>Portée : <b>'+portee+'</b> case';
  12029. if(portee>1) texte += 's';
  12030. }
  12031. }
  12032. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  12033. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  12034. if(vuetotale>1) texte += 's';
  12035. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  12036. if(vuetotale>2) texte += 's';
  12037. }
  12038. else if(comp.indexOf('Piege')!=-1) {
  12039. if(comp.indexOf('Glue')!=-1)
  12040. texte = 'Et si vous colliez vos adversaires au sol ?';
  12041. if(comp.indexOf('Feu')!=-1) {
  12042. if(texte){
  12043. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  12044. }
  12045. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  12046. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  12047. }
  12048. }
  12049. else if(comp.indexOf('Contre-Attaquer')!=-1){
  12050. texte = 'Attaque : <b>'
  12051. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  12052. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  12053. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  12054. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  12055. }
  12056. else if(comp.indexOf('Coup de Butoir')!=-1) {
  12057. var pc, lastmax=0, espdeg=0;
  12058. var notMaxedOut = false;
  12059. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  12060. +' => <b>'+attmoy+'</b>';
  12061. for(var i=niveau ; i>0 ; i--) {
  12062. pc = getTalent(comp,i);
  12063. if(lastmax!=0 && pc<=lastmax) continue;
  12064. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  12065. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  12066. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  12067. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  12068. espdeg += (pc-lastmax)*jetdeg;
  12069. lastmax = pc;
  12070. if(i<niveau) notMaxedOut = true;
  12071. }
  12072. if(notMaxedOut) {
  12073. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  12074. Math.floor(10*espdeg/lastmax)/10+'/'+
  12075. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  12076. }
  12077. }
  12078. else if(comp.indexOf('Course')!=-1)
  12079. texte = 'Déplacement gratuit : <b>'
  12080. +Math.floor(getTalent('Course')/2)
  12081. +' %</b> de chance';
  12082. else if(comp.indexOf('Deplacement Eclair')!=-1)
  12083. texte = 'Permet d\'économiser <b>1</b> PA '
  12084. +'par rapport au déplacement classique';
  12085. else if(comp.indexOf('Dressage')!=-1)
  12086. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  12087. +'ou un gnu sauvage.';
  12088. else if(comp.indexOf('Ecriture Magique')!=-1)
  12089. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  12090. +'la formule nécessite de réunir les composants de cette formule, '
  12091. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  12092. +'un champignon adéquat pour confectionner l\'encre.';
  12093. else if(comp.indexOf('Frenesie')!=-1) {
  12094. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  12095. +' => <b>'+attmoy+'</b><br/>'
  12096. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  12097. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  12098. }
  12099. else if(comp.indexOf('Golem')!=-1)
  12100. texte = 'Animez votre golem en assemblant divers matériaux '
  12101. +'autour d\'un cerveau minéral.'
  12102. else if(comp.indexOf('Grattage')!=-1) {
  12103. texte = 'Permet de confectionner un Parchemin Vierge '
  12104. +'à partir de composants et de Gigots de Gob\'.';
  12105. }
  12106. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  12107. texte = 'Fait fuir un monstre si tout se passe bien.'
  12108. +'<br/>Lui donne de gros bonus sinon...';
  12109. else if(comp.indexOf('Identification des Champignons')!=-1) {
  12110. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  12111. if(vuetotale>2) texte += 's';
  12112. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  12113. if(vuetotale>4) texte += 's';
  12114. }
  12115. else if(comp.indexOf('Insultes')!=-1)
  12116. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  12117. else if(comp.indexOf('interposer')!=-1)
  12118. texte = 'Jet de réflexe : <b>'
  12119. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  12120. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  12121. else if(comp.indexOf('Lancer de Potions') != -1)
  12122. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  12123. else if(comp.indexOf('Marquage')!=-1)
  12124. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  12125. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  12126. +'se trouver dans la même caverne que le monstre pour le marquer.';
  12127. else if(comp.indexOf('Melange Magique')!=-1)
  12128. texte = 'Cette Compétence permet de combiner deux Potions pour '
  12129. +'en réaliser une nouvelle dont l\'effet est la somme '
  12130. +'des effets des potions initiales.';
  12131. else if(comp.indexOf('Miner')!=-1) // obsolète
  12132. texte = 'Portée horizontale (officieuse) : <b>'
  12133. +2*vuetotale+'</b> cases<br/>'
  12134. +'Portée verticale (officieuse) : <b>'
  12135. +2*Math.ceil(vuetotale/2)+'</b> cases';
  12136. else if(comp.indexOf('Travail de la pierre')!=-1)
  12137. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  12138. +2*vuetotale+'</b> cases</li>'
  12139. +'<li>Portée verticale (officieuse) : <b>'
  12140. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  12141. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  12142. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  12143. else if(comp.indexOf('Necromancie')!=-1)
  12144. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  12145. +'de faire "revivre" ce monstre.';
  12146. else if(comp.indexOf('Painthure de Guerre')!=-1)
  12147. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  12148. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  12149. +'pour s\'inspirer, et laissez parler votre créativité.'
  12150. else if(comp.indexOf('Parer')!=-1)
  12151. texte = 'Jet de parade : <b>'
  12152. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  12153. +' => <b>'
  12154. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  12155. +'</b><hr><i>Equivalent esquive : <b>'
  12156. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  12157. +' => <b>'
  12158. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  12159. +'</b></i>';
  12160. else if(comp.indexOf('Pistage')!=-1)
  12161. texte = 'Portée horizontale : <b>'
  12162. +2*vuetotale+'</b> cases<br/>'
  12163. +'Portée verticale : <b>'
  12164. +2*Math.ceil(vuetotale/2)+'</b> cases';
  12165. else if(comp.indexOf('Planter un Champignon')!=-1)
  12166. texte = 'Planter un Champignon est une compétence qui vous permet de '
  12167. +'créer des colonies d\'une variété donnée de champignon à partir de '
  12168. +'quelques exemplaires préalablement enterrés.';
  12169. else if(comp.indexOf('Regeneration Accrue')!=-1)
  12170. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  12171. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  12172. else if(comp.indexOf('Reparation')!=-1)
  12173. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  12174. +'et réparez vous-même votre matériel !';
  12175. else if(comp.indexOf('Retraite')!=-1)
  12176. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  12177. +'préférable de préparer un repli stratégique pour déconcerter '
  12178. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  12179. +'Quelle intelligence démoniaque.';
  12180. else if(comp.indexOf('Rotobaffe')!=-1) {
  12181. var Datt = att, vattbm = attbp+attbm;
  12182. var Ddeg = deg, vdegbm = degbp+degbm;
  12183. for(var i=1 ; i<niveau+2 ; i++) {
  12184. texte += '<b>Attaque n°'+i+' :</b><br/>'
  12185. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  12186. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  12187. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  12188. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  12189. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  12190. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  12191. if(i<niveau+1) texte += '<hr>';
  12192. }
  12193. }
  12194. else if(comp.indexOf('Shamaner')!=-1)
  12195. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  12196. +'des monstres en utilisant des champignons (de 1 à 3).';
  12197. else if(comp.indexOf('Tailler')!=-1){ // obsolète
  12198. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  12199. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  12200. }
  12201. return texte;
  12202. }
  12203.  
  12204. function decumul_buff(nom,str,buff) {
  12205. // Decumul des sorts de buff
  12206. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  12207. var dec = buff, total = buff, i=1;
  12208. while(i<6) {
  12209. i++;
  12210. dec = Math.floor(coefDecumul(i)*buff);
  12211. if(dec<=1 || i==6) break;
  12212. total += dec;
  12213. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  12214. +str+' +'+dec+' (+'+total+')</i>';
  12215. }
  12216. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  12217. return ret;
  12218. }
  12219.  
  12220.  
  12221. function sortileges(sort,mainCall,pcA,pcD) {
  12222. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  12223. var texte = '';
  12224. if (mainCall) {
  12225. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  12226. pcA = (atttourP+atttourM);
  12227. pcD = (degtourP+degtourM);
  12228. }
  12229. if (sort.indexOf('Analyse Anatomique') != -1) {
  12230. texte = 'Portée horizontale : <b>'
  12231. + Math.floor(vuetotale / 2) + '</b> case';
  12232. if (vuetotale > 3){ texte += 's'; }
  12233. texte += '<br/>Portée verticale : <b>'
  12234. + Math.floor((vuetotale+1)/4)+'</b> case';
  12235. if (vuetotale > 7){ texte += 's'; }
  12236. }
  12237. else if (sort.indexOf('Armure Etheree') != -1){
  12238. texte = decumul_buff('AE', 'Armure magique', reg);
  12239. }
  12240. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  12241. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  12242. }
  12243. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  12244. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  12245. }
  12246. else if (sort.indexOf('Augmentation des Degats') != -1){
  12247. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  12248. }
  12249. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  12250. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  12251. }
  12252. else if(sort.indexOf('Bulle Magique')!=-1){
  12253. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  12254. }
  12255. else if(sort.indexOf('Explosion')!=-1){
  12256. texte = 'Dégâts : <b>'
  12257. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  12258. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  12259. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  12260. }
  12261. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  12262. if(pvcourant<=0)
  12263. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  12264. texte = 'Portée horizontale : <b>'
  12265. +Math.min(1,vuetotale)+'</b> case<br/>'
  12266. +'Dégâts physiques : <b>-'
  12267. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  12268. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  12269. +'Dégâts magiques : <b>-'
  12270. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  12271. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  12272. }
  12273. else if(sort.indexOf('Flash Aveuglant')!=-1){
  12274. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  12275. }
  12276. else if(sort.indexOf('Glue')!=-1) {
  12277. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  12278. if(vuetotale>2) texte += 's';
  12279. }
  12280. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  12281. /* Frappe */
  12282. var modD = 0;
  12283. texte = 'Attaque : <b>'+att+'</b> D6 ';
  12284. if(pcA!=0){
  12285. modD = parseInt(att*pcA/100);
  12286. texte += '<i>'+aff(modD)+'D6</i> ';
  12287. }
  12288. texte += aff(attbm)
  12289. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  12290. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  12291. if(pcD!=0) {
  12292. modD = parseInt(Math.floor(deg/2)*pcD/100);
  12293. texte += '<i>'+aff(modD)+'D3</i> ';
  12294. }else
  12295. modD = 0;
  12296. texte += aff(degbm)+' => <b>'
  12297. +(2*(Math.floor(deg/2)+modD)+degbm)
  12298. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  12299. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  12300. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  12301. +')</b>';
  12302. if(!mainCall) return texte;
  12303. /* Venins */
  12304. function addVenin(type,effet,duree) {
  12305. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  12306. +' pendant <b>'+duree+'</b> tour';
  12307. if(duree>1) ret += 's';
  12308. var dred = Math.max(Math.floor(duree/2),1);
  12309. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  12310. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  12311. }
  12312. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  12313. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  12314. effet = Math.floor(1.5*effet);
  12315. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  12316. }
  12317. else if(sort.indexOf('Hypnotisme')!=-1)
  12318. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  12319. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  12320. else if(sort.indexOf('Identification des tresors')!=-1)
  12321. texte = 'Permet de connaitre les caractéristiques et effets précis '
  12322. +'d\'un trésor.';
  12323. else if(sort.indexOf('Invisibilite')!=-1)
  12324. texte = 'Un troll invisible est indétectable même quand on se trouve '
  12325. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  12326. +'fait disparaître l\'invisibilité.';
  12327. else if(sort.indexOf('Levitation')!=-1)
  12328. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  12329. +'Comme les pièges ou les trous par exemple...';
  12330. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  12331. var eps = 1,
  12332. pc = 20;
  12333. var str = 'PréM';
  12334. var newSort;
  12335. var sortAtt = [
  12336. 'Projectile Magique',
  12337. 'Rafale Psychique',
  12338. 'Siphon des Ames',
  12339. 'Vampirisme',
  12340. 'Griffe du Sorcier'
  12341. ];
  12342. if(sort.indexOf('Puissance')!=-1) {
  12343. eps = -1; str='PuM';
  12344. }
  12345. for(var i=1 ; i<4 ; i++) {
  12346. if(texte) { texte += '<hr>'; }
  12347. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  12348. newSort = false;
  12349. for(var j=0 ; j<sortAtt.length ; j++) {
  12350. if(getTalent(sortAtt[j])) {
  12351. if(newSort) { texte += '<br/><br/>'; }
  12352. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  12353. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  12354. newSort = true;
  12355. }
  12356. }
  12357. pc = decumulPumPrem(pc);
  12358. }
  12359. }
  12360. else if(sort.indexOf('Projectile Magique')!=-1) {
  12361. var modD = 0;
  12362. var portee = getPortee__Profil(vuetotale);
  12363. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  12364. if(pcA!=0) {
  12365. modD = parseInt(vue*pcA/100);
  12366. texte += '<i>'+aff(modD)+'D6</i> ';
  12367. }
  12368. texte += aff(attbm)
  12369. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  12370. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  12371. if(pcD!=0) {
  12372. modD = parseInt(Math.floor(vue/2)+pcD);
  12373. texte += '<i>'+aff(modD)+'D3</i> ';
  12374. }else
  12375. modD = 0;
  12376. texte += aff(degbm)
  12377. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  12378. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  12379. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  12380. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+') (+ 1D3 par bonus de portée)</b>';
  12381. if(!mainCall) return texte;
  12382. texte += '<br/>Portée : <b>'+portee+'</b> case';
  12383. if(portee>1) texte += 's';
  12384. }
  12385. else if(sort.indexOf('Projection')!=-1) {
  12386. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  12387. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  12388. +'Si le jet de résistance de la victime est réussi:<br/>'
  12389. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  12390. }
  12391. else if(sort.indexOf('Rafale Psychique')!=-1) {
  12392. var modD = 0;
  12393. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  12394. if(pcD!=0) {
  12395. modD = parseInt(deg*pcD/100);
  12396. texte += '<i>'+aff(modD)+'D3</i> ';
  12397. }
  12398. texte += aff(degbm)
  12399. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  12400. if(!mainCall) return texte;
  12401. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  12402. }
  12403. else if(sort.indexOf('Sacrifice')!=-1) {
  12404. if(pvcourant<=0)
  12405. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  12406.  
  12407. function perteSacro(sac) {
  12408. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  12409. }
  12410.  
  12411. var sac = Math.floor((pvcourant-1)/2);
  12412. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  12413. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  12414. /* Sacros max et optimal sans malus (propale R') */
  12415. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  12416. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  12417. if(sac>0)
  12418. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  12419. else
  12420. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  12421. /*if(sac>3) {
  12422. sac = 5*Math.floor((sac+1)/5)-1;
  12423. texte += '<br/>Soin optimal sans malus de temps : <b>'
  12424. +sac+'</b> PV'+perteSacro(sac);
  12425. }*/
  12426. }
  12427. else if(sort.indexOf('Siphon')!=-1) {
  12428. var modD = 0;
  12429. texte = 'Attaque : <b>'+att+'</b> D6 ';
  12430. if(pcA!=0) {
  12431. modD = parseInt(att*pcA/100);
  12432. texte += '<i>'+aff(modD)+'D6</i> ';
  12433. }
  12434. texte += aff(attbm)
  12435. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  12436. +'Dégâts : <b>'+reg+'</b> D3 ';
  12437. if(pcD!=0) {
  12438. modD = parseInt(reg*pcD/100);
  12439. texte += '<i>'+aff(modD)+'D3</i> ';
  12440. }else
  12441. modD = 0;
  12442. texte += aff(degbm)
  12443. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  12444. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  12445. if(!mainCall) return texte;
  12446. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  12447. }
  12448. else if(sort.indexOf('Telekinesie')!=-1) {
  12449. texte = 'Portée horizontale :';
  12450. var vt = Math.floor(vuetotale/2)+2;
  12451. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  12452. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  12453. for(var i=0 ; i<5 ; i++) {
  12454. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  12455. if(vt>1) texte += 's';
  12456. vt=Math.max(0,vt-1);
  12457. }
  12458. }
  12459. else if(sort.indexOf('Teleportation')!=-1) {
  12460. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  12461. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  12462. var pmh = (20+vue+portee);
  12463. var pmv = 3+Math.floor(portee/3);
  12464. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  12465. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  12466. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  12467. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  12468. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  12469. }
  12470. else if(sort.indexOf('Vampirisme')!=-1) {
  12471. var modD = 0;
  12472. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  12473. if(pcA!=0) {
  12474. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  12475. texte += '<i>'+aff(modD)+'D6</i> ';
  12476. }
  12477. texte += aff(attbm)
  12478. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  12479. +'Dégâts : <b>'+deg+'</b> D3 ';
  12480. if(pcD!=0) {
  12481. modD = parseInt(deg*pcD/100);
  12482. texte += '<i>'+aff(modD)+'D3</i> ';
  12483. }else
  12484. modD = 0;
  12485. texte += aff(degbm)
  12486. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  12487. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  12488. }
  12489. else if(sort.indexOf('Vision Accrue')!=-1)
  12490. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  12491. else if(sort.indexOf('Vision lointaine')!=-1)
  12492. texte = 'En ciblant une zone située n\'importe où dans le '
  12493. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  12494. else if(sort.indexOf('Voir le Cache')!=-1)
  12495. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  12496. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  12497. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  12498. +getPortee__Profil(vuetotale)+'</b> cases';
  12499. else if(sort.indexOf('Vue Troublee')!=-1)
  12500. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  12501. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  12502. return texte;
  12503. }
  12504.  
  12505.  
  12506. /*---------------------------------- Main ------------------------------------*/
  12507.  
  12508. function do_profil2()
  12509. {
  12510. try {
  12511. start_script(31);
  12512.  
  12513. extractionDonnees();
  12514. setInfosCaracteristiques();
  12515. setInfoDescription();
  12516. setInfosEtatLieux();
  12517. setInfosEtatPV();
  12518. setInfosExp();
  12519.  
  12520. creerBulleVide();
  12521. traitementTalents();
  12522. setLienAnatrolliseur();
  12523.  
  12524. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  12525. if(race=='Kastar'){ setAccel(); }
  12526. saveProfil();
  12527. displayScriptTime();
  12528. } catch(e) {
  12529. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  12530. window.console.error(traceStack(e, 'profil2'));
  12531. }
  12532. }
  12533.  
  12534. /*******************************************************************************
  12535. * This file is part of Mountyzilla. *
  12536. * *
  12537. * Mountyzilla is free software; you can redistribute it and/or modify *
  12538. * it under the terms of the GNU General Public License as published by *
  12539. * the Free Software Foundation; either version 2 of the License, or *
  12540. * (at your option) any later version. *
  12541. * *
  12542. * Mountyzilla is distributed in the hope that it will be useful, *
  12543. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12544. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12545. * GNU General Public License for more details. *
  12546. * *
  12547. * You should have received a copy of the GNU General Public License *
  12548. * along with Mountyzilla; if not, write to the Free Software *
  12549. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  12550. *******************************************************************************/
  12551.  
  12552. // x~x script_principal
  12553.  
  12554. function isPage(url) {
  12555. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  12556. }
  12557.  
  12558. // x~x md5.js
  12559. /*
  12560. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  12561. * Digest Algorithm, as defined in RFC 1321.
  12562. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  12563. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  12564. * Distributed under the BSD License
  12565. * See http://pajhome.org.uk/crypt/md5 for more info.
  12566. */
  12567.  
  12568. /*
  12569. * Configurable variables. You may need to tweak these to be compatible with
  12570. * the server-side, but the defaults work in most cases.
  12571. */
  12572. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  12573. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  12574. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  12575.  
  12576. /*
  12577. * These are the functions you'll usually want to call
  12578. * They take string arguments and return either hex or base-64 encoded strings
  12579. */
  12580. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  12581. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  12582. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  12583. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  12584. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  12585. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  12586.  
  12587. /*
  12588. * Perform a simple self-test to see if the VM is working
  12589. */
  12590. function md5_vm_test()
  12591. {
  12592. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  12593. }
  12594.  
  12595. /*
  12596. * Calculate the MD5 of an array of little-endian words, and a bit length
  12597. */
  12598. function core_md5(x, len)
  12599. {
  12600. /* append padding */
  12601. x[len >> 5] |= 0x80 << ((len) % 32);
  12602. x[(((len + 64) >>> 9) << 4) + 14] = len;
  12603.  
  12604. var a = 1732584193;
  12605. var b = -271733879;
  12606. var c = -1732584194;
  12607. var d = 271733878;
  12608.  
  12609. for(var i = 0; i < x.length; i += 16)
  12610. {
  12611. var olda = a;
  12612. var oldb = b;
  12613. var oldc = c;
  12614. var oldd = d;
  12615.  
  12616. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  12617. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  12618. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  12619. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  12620. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  12621. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  12622. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  12623. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  12624. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  12625. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  12626. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  12627. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  12628. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  12629. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  12630. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  12631. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  12632.  
  12633. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  12634. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  12635. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  12636. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  12637. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  12638. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  12639. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  12640. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  12641. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  12642. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  12643. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  12644. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  12645. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  12646. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  12647. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  12648. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  12649.  
  12650. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  12651. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  12652. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  12653. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  12654. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  12655. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  12656. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  12657. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  12658. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  12659. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  12660. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  12661. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  12662. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  12663. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  12664. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  12665. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  12666.  
  12667. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  12668. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  12669. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  12670. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  12671. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  12672. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  12673. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  12674. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  12675. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  12676. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  12677. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  12678. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  12679. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  12680. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  12681. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  12682. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  12683.  
  12684. a = safe_add(a, olda);
  12685. b = safe_add(b, oldb);
  12686. c = safe_add(c, oldc);
  12687. d = safe_add(d, oldd);
  12688. }
  12689. return Array(a, b, c, d);
  12690.  
  12691. }
  12692.  
  12693. /*
  12694. * These functions implement the four basic operations the algorithm uses.
  12695. */
  12696. function md5_cmn(q, a, b, x, s, t)
  12697. {
  12698. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  12699. }
  12700. function md5_ff(a, b, c, d, x, s, t)
  12701. {
  12702. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  12703. }
  12704. function md5_gg(a, b, c, d, x, s, t)
  12705. {
  12706. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  12707. }
  12708. function md5_hh(a, b, c, d, x, s, t)
  12709. {
  12710. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  12711. }
  12712. function md5_ii(a, b, c, d, x, s, t)
  12713. {
  12714. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  12715. }
  12716.  
  12717. /*
  12718. * Calculate the HMAC-MD5, of a key and some data
  12719. */
  12720. function core_hmac_md5(key, data)
  12721. {
  12722. var bkey = str2binl(key);
  12723. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  12724.  
  12725. var ipad = Array(16), opad = Array(16);
  12726. for(var i = 0; i < 16; i++)
  12727. {
  12728. ipad[i] = bkey[i] ^ 0x36363636;
  12729. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  12730. }
  12731.  
  12732. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  12733. return core_md5(opad.concat(hash), 512 + 128);
  12734. }
  12735.  
  12736. /*
  12737. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  12738. * to work around bugs in some JS interpreters.
  12739. */
  12740. function safe_add(x, y)
  12741. {
  12742. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  12743. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  12744. return (msw << 16) | (lsw & 0xFFFF);
  12745. }
  12746.  
  12747. /*
  12748. * Bitwise rotate a 32-bit number to the left.
  12749. */
  12750. function bit_rol(num, cnt)
  12751. {
  12752. return (num << cnt) | (num >>> (32 - cnt));
  12753. }
  12754.  
  12755. /*
  12756. * Convert a string to an array of little-endian words
  12757. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  12758. */
  12759. function str2binl(str)
  12760. {
  12761. var bin = Array();
  12762. var mask = (1 << chrsz) - 1;
  12763. for(var i = 0; i < str.length * chrsz; i += chrsz)
  12764. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  12765. return bin;
  12766. }
  12767.  
  12768. /*
  12769. * Convert an array of little-endian words to a string
  12770. */
  12771. function binl2str(bin)
  12772. {
  12773. var str = "";
  12774. var mask = (1 << chrsz) - 1;
  12775. for(var i = 0; i < bin.length * 32; i += chrsz)
  12776. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  12777. return str;
  12778. }
  12779.  
  12780. /*
  12781. * Convert an array of little-endian words to a hex string.
  12782. */
  12783. function binl2hex(binarray)
  12784. {
  12785. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  12786. var str = "";
  12787. for(var i = 0; i < binarray.length * 4; i++)
  12788. {
  12789. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  12790. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  12791. }
  12792. return str;
  12793. }
  12794.  
  12795. /*
  12796. * Convert an array of little-endian words to a base-64 string
  12797. */
  12798. function binl2b64(binarray)
  12799. {
  12800. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  12801. var str = "";
  12802. for(var i = 0; i < binarray.length * 4; i += 3)
  12803. {
  12804. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  12805. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  12806. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  12807. for(var j = 0; j < 4; j++)
  12808. {
  12809. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  12810. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  12811. }
  12812. }
  12813. return str;
  12814. }
  12815.  
  12816. ///////////////////////////////////////////
  12817. // debug cartes capitan Roule 07/12/2016
  12818. ///////////////////////////////////
  12819. // essais : objet
  12820. // .mode : description
  12821. // .essais : tableau d'objets essai
  12822. // .mode : description
  12823. // .essais : tableau de cartes
  12824. // .noCarte : id de la carte
  12825. // .essais : tableau d'essais, [x, y, n, nb]
  12826. function AfficheEssais(essais, sMode) {
  12827. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  12828. if (!eBigDiv) {
  12829. var insertPoint = document.getElementById('footer1');
  12830. eBigDiv = document.createElement('table');
  12831. eBigDiv.id = 'ListeEssaiCapitan';
  12832. insertBefore(insertPoint, document.createElement('p'));
  12833. insertTitle(insertPoint,'Capitan : Liste des essais');
  12834. insertBefore(insertPoint, eBigDiv);
  12835. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  12836. }
  12837. if (!essais) {
  12838. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  12839. return;
  12840. }
  12841. var carte;
  12842. for (carte in essais) {
  12843. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  12844. }
  12845. if (carte === undefined) {
  12846. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  12847. }
  12848. }
  12849.  
  12850. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  12851. var tr = appendTr(eTable);
  12852. var td = appendTd(tr);
  12853. appendText(td, sMode, bBold);
  12854. td = appendTd(tr);
  12855. appendText(td, sCarte, bBold);
  12856. td = appendTd(tr);
  12857. appendText(td, sText, bBold);
  12858. }
  12859.  
  12860. function getEssaiV1_0() {
  12861. try {
  12862. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  12863. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  12864. var tabK, nK;
  12865. prefs.getChildList('', nK, tabK);
  12866. window.console.log('getEssaiV1_0, nb key : ' + nK);
  12867. //window.console.log('getEssaiV1_0, ' + nK);
  12868. return;
  12869. //return r;
  12870. } catch (e) {
  12871. window.console.log(traceStack(e, 'getEssaiV1_0'));
  12872. }
  12873. }
  12874.  
  12875. function getEssaiV1_1() {
  12876. var locSto = window.localStorage;
  12877. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  12878. var r = [];
  12879. for (var i = 0; i < locSto.length; i++) {
  12880. var k = locSto.key(i);
  12881. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  12882. var t = k.split(/\./);
  12883. if (t[0] !== 'capitan') continue;
  12884. if (t[2] !== 'essai') continue;
  12885. var carte = 'carte n°' + t[1];
  12886. if (r[carte]) r[carte]++;
  12887. else r[carte] = 1;
  12888. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  12889. }
  12890. return r;
  12891. }
  12892.  
  12893. function showEssaiCartes() {
  12894. window.console.log('début showEssai Tout_MZ');
  12895. var essais = getEssaiV1_0();
  12896. AfficheEssais(essais, 'V1.0');
  12897. essais = getEssaiV1_1();
  12898. AfficheEssais(essais, 'V1.1');
  12899. window.console.log('fin showEssai Tout_MZ');
  12900. }
  12901.  
  12902. function testBoolLocalStorage() {
  12903. var b = true;
  12904. var key = 'MZ_essai_bool';
  12905. GM_setValue(key, b);
  12906. window.localStorage[key] = b;
  12907. var v = GM_getValue(key);
  12908. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  12909. var v = window.localStorage.getItem(key);
  12910. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  12911.  
  12912. var b = false;
  12913. GM_setValue(key, b);
  12914. window.localStorage[key] = b;
  12915. var v = GM_getValue(key);
  12916. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  12917. var v = window.localStorage.getItem(key);
  12918. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  12919.  
  12920. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  12921. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  12922. var y = GM_getValue('654654897894654654');
  12923. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  12924. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  12925. }
  12926.  
  12927. /*--------------------------------- Création liste trolligion ---------------------------------*/
  12928. function export_trolligion() {
  12929. try {
  12930. var tabDl = document.getElementsByTagName('dl');
  12931. if ((!tabDl) || !tabDl[0]) {
  12932. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  12933. return;
  12934. }
  12935. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  12936. // nom : string
  12937. // rayonnement : entier
  12938. // grades : table d'objets (une occurence par grade)
  12939. // nom : string
  12940. // trolls : table d'objets (un par Trõll)
  12941. // id
  12942. // nom
  12943. // idguilde
  12944. // guilde
  12945. // race
  12946. // niveau
  12947. // ferveur
  12948. var currentDieu;
  12949. var currentGrade;
  12950. for (var iChild1 in tabDl[0].children) {
  12951. var eChild1 = tabDl[0].children[iChild1];
  12952. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  12953. case 'dd': // Trõll
  12954. var oTroll = {};
  12955. export_trolligion_analyse(oTroll, eChild1);
  12956. currentGrade.trolls.push(oTroll);
  12957. break;
  12958. case 'dt':
  12959. var tabH3 = eChild1.getElementsByTagName('h3');
  12960. if (tabH3 && tabH3[0]) { // changement de dieu
  12961. currentDieu = {
  12962. nom: tabH3[0].innerText || tabH3[0].textContent
  12963. , grades: []};
  12964. var txt = eChild1.innerText || eChild1.textContent;
  12965. var m = txt.match(/yon*ement *:* *(\d+)/);
  12966. if (m) currentDieu.rayonnement = parseInt(m[1]);
  12967. currentGrade = undefined;
  12968. tabDieux.push(currentDieu);
  12969. break;
  12970. }
  12971. var tabH4 = eChild1.getElementsByTagName('h4');
  12972. if (tabH4 && tabH4[0]) { // changement de grade
  12973. var grade;
  12974. var txt = tabH4[0].innerText || tabH4[0].textContent;
  12975. tabI = tabH4[0].getElementsByTagName('i');
  12976. if (tabI && tabI[0]) {
  12977. grade = tabI[0].innerText || tabI[0].textContent;
  12978. grade = grade.replace(/"/g, '');
  12979. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  12980. if (m) grade += ' (' + m[1] + ')';
  12981. } else {
  12982. grade = txt.replace(/"/g, '');
  12983. }
  12984. currentGrade = {nom: grade, trolls: []};
  12985. currentDieu.grades.push(currentGrade);
  12986. break;
  12987. }
  12988. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  12989. break;
  12990. default:
  12991. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  12992. }
  12993. }
  12994.  
  12995. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  12996. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  12997. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  12998. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  12999. for (var iDieu in tabDieux) {
  13000. var oDieu = tabDieux[iDieu];
  13001. for (var iGrade in oDieu.grades) {
  13002. var oGrade = oDieu.grades[iGrade];
  13003. for (var iTroll in oGrade.trolls) {
  13004. var oTroll = oGrade.trolls[iTroll];
  13005. var t = [oDieu.nom, oDieu.rayonnement
  13006. , oGrade.nom
  13007. , oTroll.id, oTroll.nom
  13008. , oTroll.idguilde, oTroll.guilde
  13009. , oTroll.race, oTroll.niveau
  13010. , oTroll.ferveur];
  13011. for (var iParam in t) {
  13012. if (t[iParam] === undefined) t[iParam] = ''; // protection
  13013. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  13014. }
  13015. txt += t.join("\t") + "\n";
  13016. }
  13017. }
  13018. var t = [oDieu.nom, oDieu.rayonnement];
  13019. for (var iParam in t) {
  13020. if (t[iParam] === undefined) t[iParam] = ''; // protection
  13021. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  13022. }
  13023. txt2 += t.join("\t") + "\n";
  13024. }
  13025. txt += "\n" + txt2;
  13026. } catch (e) {
  13027. window.alert("Échec à l'extraction\n" + e);
  13028. }
  13029. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  13030. try {
  13031. if (copyTextToClipboard(txt)) {
  13032. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  13033. + "Collez dans Calc\n"
  13034. + "ou, au pire, dans EXCEL®");
  13035. } else {
  13036. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  13037. }
  13038. } catch(e) {
  13039. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  13040. }
  13041. }
  13042.  
  13043. function export_trolligion_analyse(oTroll, eChild1) {
  13044. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  13045. var eChild2 = eChild1.childNodes[iChild2];
  13046. if (eChild2.nodeType === undefined) continue; // properties
  13047. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  13048. switch (eChild2.nodeType) {
  13049. case 1: //ELEMENT_NODE:
  13050. switch (eChild2.nodeName.toLowerCase()) {
  13051. case 'a':
  13052. var m;
  13053. if (!eChild2.href) {
  13054. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  13055. break;
  13056. }
  13057. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  13058. if (m) {
  13059. oTroll.id = parseInt(m[1]);
  13060. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  13061. break;
  13062. }
  13063. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  13064. if (m) {
  13065. var idGuilde = parseInt(m[1]);
  13066. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  13067. oTroll.idguilde = parseInt(m[1]);
  13068. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  13069. }
  13070. break;
  13071. }
  13072. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  13073. break;
  13074. case 'br': // ignore
  13075. case 'style': // ignore
  13076. case 'img': // ignore
  13077. break;
  13078. case 'div': // barre de vie
  13079. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  13080. eChild3 = eChild2.children[0];
  13081. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  13082. var eChild4 = eChild3.children[0];
  13083. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  13084. break;
  13085. }
  13086. }
  13087. //window.console.log(eChild2.innerHTML);
  13088. export_trolligion_analyse(oTroll, eChild2);
  13089. break;
  13090. default:
  13091. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  13092. break;
  13093. }
  13094. break;
  13095. case 3: //TEXT_NODE:
  13096. var txt = eChild2.nodeValue.trim();
  13097. if (txt === '') break;
  13098. var m = txt.match(/(.*) *\((\d+)\)/);
  13099. if (m) {
  13100. oTroll.race = m[1].trim();
  13101. oTroll.niveau = parseInt(m[2]);
  13102. } else {
  13103. oTroll.race = txt;
  13104. }
  13105. break;
  13106. default: // ne devrait pas arriver
  13107. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  13108. break;
  13109. }
  13110. }
  13111. }
  13112.  
  13113. function do_trolligion() {
  13114. var divpopup = document.createElement('div');
  13115. divpopup.id = 'MZ_divCopier';
  13116. divpopup.style.position = 'fixed';
  13117. divpopup.style.top = '2px';
  13118. divpopup.style.left = '2px;';
  13119. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  13120. divpopup.style.cursor = 'pointer';
  13121. divpopup.style.zIndex = 200;
  13122. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  13123. divpopup.onclick = export_trolligion;
  13124. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  13125. divpopup.appendChild(img);
  13126. document.body.appendChild(divpopup);
  13127. }
  13128.  
  13129. /*--------------------------------- Dispatch ---------------------------------*/
  13130.  
  13131. //chargerScriptDev("libs");
  13132. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  13133. //if (isDEV) testBoolLocalStorage();
  13134.  
  13135. // Détection de la page à traiter
  13136. if(isPage("Messagerie/ViewMessageBot")) {
  13137. do_cdmbot();
  13138. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  13139. do_cdmcomp();
  13140. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  13141. do_cdmcomp();
  13142. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  13143. do_cdmcomp();
  13144. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  13145. do_diplo();
  13146. } else if(isPage("MH_Play/Play_equipement")) {
  13147. do_equip();
  13148. } else if(isPage("MH_Play/Play_menu")) {
  13149. do_menu();
  13150. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  13151. do_option();
  13152. //showEssaiCartes();
  13153. } else if(isPage("View/PJView")) {
  13154. do_pjview();
  13155. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  13156. do_profil();
  13157. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  13158. do_tancompo();
  13159. } else if(isPage("MH_Play/Play_vue")) {
  13160. do_vue();
  13161. } else if(isPage("MH_Play/Play_news")) {
  13162. do_news();
  13163. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  13164. do_move();
  13165. } else if(isPage("MH_Missions/Mission_Etape")) {
  13166. do_mission();
  13167. } else if(isPage("View/MonsterView")) {
  13168. do_infomonstre();
  13169. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  13170. do_attaque();
  13171. } else if(isPage("MH_Play/Play_e_follo.php")) {
  13172. do_listegowap();
  13173. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  13174. do_lieuDescription();
  13175. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  13176. do_lieuTeleport();
  13177. } else if(isPage("MH_Follower/FO_Ordres")) {
  13178. do_ordresgowap();
  13179. } else if(isPage("MH_Follower/FO_Equipement")) {
  13180. do_equipgowap();
  13181. } else if(isPage("MH_Play/Play_mouche")) {
  13182. do_mouches();
  13183. } else if(isPage("MH_Play/Play_BM")) {
  13184. do_malus();
  13185. } else if(isPage("MH_Play/Play_evenement")) {
  13186. do_myevent();
  13187. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  13188. do_enchant();
  13189. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  13190. do_pre_enchant();
  13191. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  13192. do_actions();
  13193. } 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')) {
  13194. do_mission_liste();
  13195. } else if(isPage('MH_Play/Play_action')) {
  13196. do_actions();
  13197. } else if(isPage('MH_Play/Play_profil2')) {
  13198. do_profil2();
  13199. } else if(isPage('View/TrolligionView.php')) {
  13200. do_trolligion();
  13201. }
  13202. } catch(e) {
  13203. try {
  13204. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  13205. } catch(e2) {
  13206. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  13207. }
  13208. }