Tout_MZ

Client MountyZilla

当前为 2019-03-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Tout_MZ
  3. // @namespace MH
  4. // @description Client MountyZilla
  5. // @include */mountyhall/*
  6. // @exclude *trolls.ratibus.net*
  7. // @exclude *it.mh.raistlin.fr*
  8. // @exclude *mh2.mh.raistlin.fr*
  9. // @exclude *mzdev.mh.raistlin.fr*
  10. // @version 1.2.18.15
  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.15 29/03/2019",
  39. " Correction simple quote dans toutes les missions",
  40. "V1.2.18.14 09/03/2019",
  41. " Correction affichage vues 2D externes suite à une modif MH",
  42. "V1.2.18.13 27/02/2019",
  43. " Correction simple quote dans les familles de monstre des missions",
  44. "V1.2.18.12 23/12/2018",
  45. " Message si \"Menu d'actions contextuelles\" est décoché",
  46. "V1.2.18.11 21/11/2018",
  47. " Correction it bricol'troll, login avec accent",
  48. "V1.2.18.10 08/08/2018",
  49. " Correction boulette sDiplo",
  50. "V1.2.18.09 04/08/2018",
  51. " Protection contre diplomatie mal initialisée",
  52. "V1.2.18.08 11/07/2018",
  53. " Correction pour fonctionnement hors GM",
  54. "V1.2.18.07 18/05/2018",
  55. " prise en compte bonus magique d'esquive dans le profil, correction gestion de la souris dans la page d'équipement [Dabihul, welcome back]",
  56. "V1.2.18.06 28/01/2018",
  57. " Protection malus Crasc sans durée",
  58. "V1.2.18.05 18/11/2017",
  59. " Désactivation MZ V2 en mode dev pour les tests d'adaptation violentmonkey",
  60. "V1.2.18.04 04/09/2017",
  61. " retour version 1.2.18.02 avec GM 3.17",
  62. "V1.2.18.03 01/09/2017",
  63. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  64. "V1.2.18.02 26/08/2017",
  65. " correction boulette sur le compos d'enchantement",
  66. "V1.2.18.01 25/08/2017",
  67. " Suppression des messages sur les certificats en https",
  68. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  69. "V1.2.17.19 23/08/2017",
  70. " Possibilité de plusieurs IT Bricol'Troll",
  71. "V1.2.17.18 22/08/2017",
  72. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  73. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  74. "V1.2.17.17 16/07/2017",
  75. " modification du mécanisme de filtrage pour contourner un pb",
  76. "V1.2.17.16 16/07/2017",
  77. " Ajout de messages de debug sur les retours AJAX",
  78. "V1.2.17.15 15/07/2017",
  79. " modification du mécanisme de filtrage pour contourner un pb",
  80. "V1.2.17.14 14/07/2017",
  81. " correction dans la gestion des étapes de mission",
  82. "V1.2.17.13 12/07/2017",
  83. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  84. "V1.2.17.12 16/06/2017",
  85. " Correction mauvais compte de PX quand on change de Trõll",
  86. "V1.2.17.11 01/05/2017",
  87. " Travail sur le fonctionnement hors Greasemonkey",
  88. "V1.2.17.10 30/04/2017",
  89. " Protection dans la récupération d'erreur",
  90. "V1.2.17.9 30/04/2017",
  91. " Correction récupération d'erreur IT Bricol'Troll",
  92. "V1.2.17.8 29/04/2017",
  93. " Correction Bonus/Malus cas +0\+10 (AE)",
  94. " Correction portée IdC",
  95. " Prise en compte du bonus de portée PM dans le calcul tactique",
  96. "V1.2.17.7 26/04/2017",
  97. " Version compatible hors GreaseMonkey",
  98. "V1.2.17.6 23/04/2017",
  99. " Correction gestion des missions en cas de réinstallation",
  100. "V1.2.17.5 20/04/2017",
  101. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  102. "V1.2.17.4 08/04/2017",
  103. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  104. " Adaptation de la diplomatie à une modification de la page MH",
  105. "V1.2.17.3 04/04/2017",
  106. " Messages console en cas de cadre d'erreur",
  107. " Trolls de l'IT mais pas dans le vue en orange",
  108. "V1.2.17.2 20/03/2017",
  109. " Correction des PV restants",
  110. "V1.2.17.1 20/03/2017",
  111. " Blocage des PV restants en attendant résolution de bug",
  112. "V1.2.17 19/03/2017",
  113. " Refonte de l'envoi des CdM",
  114. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  115. "V1.2.16.4 08/03/2017",
  116. " correction ID de troll en envoi de PX/MP",
  117. "V1.2.16.3 27/02/2017",
  118. " correction bonus/malus FP",
  119. "V1.2.16.2 24/02/2017",
  120. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  121. "V1.2.16.1 21/02/2017",
  122. " corrige bug sur Fx 38.8 ESR",
  123. "V1.2.16 21/02/2017",
  124. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  125. " possibilité de masquer les Gowaps Sauvages dans la vue",
  126. " calcul des caractéristiques du siphon des âmes",
  127. "V1.2.15.2 02/02/2017",
  128. " adaptation décumul VlC (page des bonus/malus)",
  129. "V1.2.15.1 29/01/2017",
  130. " carte sur la page de description du lieu TP",
  131. "V1.2.15 25/01/2017",
  132. " mise en place des nouvelles cartes (suivants, TP)",
  133. "V1.2.14.3 25/01/2017",
  134. " résumé dans l'export des données Trõlligion",
  135. "V1.2.14.2 20/01/2017",
  136. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  137. "V1.2.14.1 20/01/2017",
  138. " réécriture filtrage des monstres par niveau dans la vue",
  139. " Changelog dans la page des news MZ",
  140. "V1.2.14 20/01/2017",
  141. " Ajout de l'export des données Trõlligion",
  142. "V1.2.13.7 10/01/2017",
  143. " Exclusion Bricoll'troll dans l'entête GM",
  144. "V1.2.13.6 08/01/2017",
  145. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  146. "V1.2.13.5 07/01/2017",
  147. " Correction bug qui se manisfestait sous LINUX",
  148. "V1.2.13.4 07/01/2017",
  149. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  150. "V1.2.13.3 07/01/2017",
  151. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  152. "V1.2.13.2 07/01/2017",
  153. " Correction missions, recherche troogle (familles et types de monstres)",
  154. "V1.2.13.1 06/01/2017",
  155. " Suppression oldSchoolProfile qui n'existe plus",
  156. " Ajout du 'refresh' du cadre de gauche",
  157. "V1.2.13 01/01/2017",
  158. " homogénéisation des messages d'erreur",
  159. " Ajout du lien Troogle sur les étapes de mission monstre",
  160. "V1.2.12.2 30/12/2016",
  161. " retour en mode normal (http si jeu en http)",
  162. "V1.2.12.1 27/12/2016",
  163. " Correction mode IP",
  164. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  165. "V1.2.12 24/12/2016",
  166. " Nettoyage des URL",
  167. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  168. " Interface bricoll'Troll en https",
  169. " Remise en marche des cartes des trajets des gowaps",
  170. "V1.2.11.5 à 7 20 & 21/12/2016",
  171. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  172. "V1.2.11.4 19/12/2016",
  173. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  174. "V1.2.11.3 19/12/2016",
  175. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  176. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  177. "V1.2.11.2 18/12/2016",
  178. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  179. "V1.2.11.1 17/12/2016",
  180. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  181. "V1.2.11 13/12/2016",
  182. " Passage sur BdD Raistlin \\o/",
  183. "V1.2.10.4 12/12/2016",
  184. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  185. "V1.2.10.3 09/12/2016",
  186. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  187. "V1.2.10.2 09/12/2016",
  188. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  189. "V1.2.10.1 08/12/2016",
  190. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  191. "V1.2.10 07/12/2016",
  192. " correction décumul des bonus/malus",
  193. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  194. "V1.2.9 16/11/2016",
  195. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  196. "V1.2.8 10/11/2016",
  197. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  198. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  199. "V1.2.7 07/11/2016",
  200. " remise en route de l'interface avec l'IT bricol'Troll",
  201. "V1.2.6 19/10/2016",
  202. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  203. " stockage idguilde et nomguilde",
  204. "V1.2.5 17/10/2016",
  205. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  206. " remise en route de la gestion des options avec intégration md5 dans ce script",
  207. "V1.2.4 14/10/2016",
  208. " utilisation du relai raistlin pour l'envoi des CdM",
  209. "V1.2.3 :",
  210. " suppression ancien profil",
  211. " nettoyage doublon sur getPortee",
  212. " adaptation portee TP basée sur les PI",
  213. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  214. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  215. "V1.2.1 :",
  216. " include des URLs MH alternatives",
  217. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  218. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  219. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  220. "V1.1 : regroupement en un gros paquet sale",
  221. ];
  222.  
  223. /**********************************************************
  224. À faire / propositions d'évolutions
  225.  
  226. Bireli-Gravos 08/12/2018
  227. FAIT faire un warning si l'utilisateur a désactivé la case "Menu d'actions contextuelles" dans la fenêtre "limiter la vue"
  228. breizhou13 20/12/2016
  229. envoyer les données à l'IT (Bricol'Trolls) aussi
  230. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  231. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  232. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  233. Akkila le boeuf le 26-03-2017 à 15:56
  234. - bouton pour rafraîchir les infos des trolls de son groupe
  235. Roule'
  236. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  237. Réactiver les jubilaires
  238. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  239. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  240. - voir l'intérêt de refaire fonctionner
  241. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  242. Prévision des DLA de monstre
  243. Niveau des monstres à la méthode Roule'
  244. Raistlin
  245. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  246. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  247. 80117 - Héra
  248. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  249. 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)
  250. FAIT Possibilité de plusieurs systèmes Bricol'troll
  251. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  252. ?
  253. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  254. Alanae/Gnu
  255. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  256. Kali
  257. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  258. **********************************************************/
  259.  
  260. /**********************************************************
  261. **** Début de zone à déplacer dans une bibli commune ******
  262. **********************************************************/
  263.  
  264. // URL de base serveur MZ
  265. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  266. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  267. //var URL_MZ = 'http://192.99.225.92/mz';
  268.  
  269. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  270. // à supprimer
  271. const newCarte = true;
  272. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  273.  
  274. // URLs externes redirection (pas de souci CORS)
  275. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  276. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  277. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  278. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  279. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  280. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  281. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  282. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  283. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  284.  
  285. // URLs de test HTTPS
  286. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  287. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  288.  
  289. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  290. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  291. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  292.  
  293. // x~x Libs
  294.  
  295. /* ancien TODO
  296. * - revoir la gestion des CdM --> nott armure magique
  297. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  298. * - vérfier la gestion des enchants
  299. */
  300.  
  301. // Roule 04/09/2016 switch extern URLs to https if available
  302. var isHTTPS = false;
  303. if (window.location.protocol.indexOf('https') === 0) {
  304. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  305. URL_bricol = URL_bricol_https;
  306. isHTTPS = true;
  307. }
  308.  
  309. // Roule 23/12/2016 mode dev
  310. var isDEV = false;
  311. if (window.localStorage.getItem('MZ_dev')
  312. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  313. || window.location.href.indexOf('mzdev.mh') >= 0) {
  314. URL_MZ = URL_MZ.replace(/$/, 'dev');
  315. isDEV = true;
  316. }
  317.  
  318. // Images (pas de souci CORS)
  319. var URL_MZimg = URL_MZ + '/img/';
  320. // URLs externes ajax (CORS OK)
  321. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  322. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  323. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  324.  
  325. // liens externes déduits
  326. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  327. var MHicons = '/mountyhall/Images/Icones/';
  328. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  329. var MY_DEBUG = false;
  330.  
  331. var horsGM = false;
  332. try { // à partir du 11/07/2018, (GM_getValue === undefined) provoque une exception
  333. horsGM = (GM_getValue === undefined);
  334. } catch (e2) {
  335. horsGM = true;
  336. //window.console.log('test GM_getValue, exception=' + e2);
  337. }
  338. if (horsGM) { // éviter le blocage si pas sous GM
  339. window.console.log('Fonctionnement hors Greasemonkey');
  340. // Roule 18/11/2017 il ne faut pas de "var" dans les ligne précédente. Ça fonctionnait sous Greasemonkey mais plus sous Violentmonkey
  341. GM_getValue = function(key) {};
  342. GM_setValue = function(key, val) {};
  343. GM_deleteValue = function(key) {};
  344. GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  345. }
  346.  
  347. /* Utilisation de la gestion de l'enregistrement des données de
  348. GreaseMonkey, avec partage entre scripts via le localStorage, par
  349. Vapulabehemot (82169) 07/02/2017 */
  350. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  351. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  352. function MY_getValue(key) {
  353. var v = window.localStorage.getItem(key);
  354. vGM = GM_getValue(key);
  355. if ((vGM == null)
  356. || (v != null && v != vGM)){
  357. GM_setValue(key, v);
  358. } else if (v == null && vGM != null) {
  359. v = vGM;
  360. window.localStorage[key] = vGM;
  361. }
  362. return v;
  363. }
  364. function MY_removeValue(key) {
  365. GM_deleteValue(key);
  366. window.localStorage.removeItem(key);
  367. }
  368. function MY_setValue(key, val) {
  369. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  370. val = 1;
  371. else if (val === false)
  372. val = 0;
  373. try {
  374. GM_setValue(key, val);
  375. } catch(e) {
  376. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  377. }
  378. try {
  379. window.localStorage[key] = val;
  380. } catch(e) {
  381. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  382. }
  383. }
  384.  
  385. /*---------------- mise à jour de variables globales utiles ------------------*/
  386. // utilisé pour accès bdd (un peu partout) :
  387. var numTroll = MY_getValue('NUM_TROLL');
  388. // utilisé dans vue pour PX :
  389. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  390. var nivTroll; // = MY_getValue('NIV_TROLL');
  391. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  392. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  393. // utilisés dans actions et vue (calculs SR) :
  394. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  395. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  396. var currentURL = window.location.href;
  397.  
  398. /*-[functions]------------ Fonctions durée de script -------------------------*/
  399. var date_debut = null;
  400.  
  401. function start_script(nbJours_exp) {
  402. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  403. if(date_debut) return;
  404. date_debut = new Date();
  405. // Créé la variable expdate si demandé
  406. if(nbJours_exp) {
  407. expdate = new Date();
  408. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  409. }
  410. }
  411.  
  412. function displayScriptTime() {
  413. var footerNode = document.getElementById('footer2');
  414. if(!footerNode) return;
  415. try{
  416. var node = document.evaluate(
  417. ".//text()[contains(.,'Page générée en')]/../br",
  418. footerNode,null,9,null).singleNodeValue;
  419. }
  420. catch(e){return;}
  421. insertText(node,
  422. ' - [Script MZ exécuté en '
  423. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  424. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  425. }
  426.  
  427. function traceStack(e, sModule) {
  428. var version = '';
  429. if (GM_info && GM_info.script && GM_info.script.version)
  430. version = ' ' + GM_info.script.version;
  431. sRet = '[MZ' + version + ']'
  432. if (sModule) sRet += ' {' + sModule + '}';
  433. try {
  434. if (e.message) sRet += ' ' + e.message;
  435. } catch (e2) {
  436. sRet += ' <exception acces message>';//+ e2.message;
  437. }
  438. try {
  439. if (e.stack) {
  440. var sStack = e.stack;
  441. // enlever les infos confidentielles
  442. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  443. }
  444. } catch (e2) {
  445. sRet += ' <exception acces stack>'; // + e2.message;
  446. }
  447. return sRet;
  448. }
  449.  
  450. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  451.  
  452. function debugMZ(str){
  453. if(MY_DEBUG){
  454. window.console.debug('[MZ_DEBUG] '+str);
  455. if(typeof str === "object"){
  456. window.console.debug(str);
  457. }
  458. }
  459. }
  460.  
  461. function FF_XMLHttpRequest(MY_XHR_Ob) {
  462. var request = new XMLHttpRequest();
  463. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  464. for(var head in MY_XHR_Ob.headers) {
  465. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  466. }
  467. request.onreadystatechange = function() {
  468. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  469. if(request.readyState!=4) { return; }
  470. if(request.error) {
  471. if(MY_XHR_Ob.onerror) {
  472. MY_XHR_Ob.onerror(request);
  473. }
  474. return;
  475. }
  476. if ((request.status == 0)) {
  477. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  478. if (isDEV) {
  479. var grandCadre = createOrGetGrandCadre();
  480. var sousCadre = document.createElement('div');
  481. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  482. sousCadre.style.width = 'auto';
  483. sousCadre.style.fontSize = 'large';
  484. sousCadre.style.border = 'solid 1px black';
  485. grandCadre.appendChild(sousCadre);
  486. }
  487. //showHttpsErrorContenuMixte();
  488. return;
  489. }
  490. if(MY_XHR_Ob.onload) {
  491. var version;
  492. if (MY_XHR_Ob.trace) {
  493. version = '';
  494. if (GM_info && GM_info.script && GM_info.script.version)
  495. version = ' ' + GM_info.script.version;
  496. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  497. }
  498. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  499. MY_XHR_Ob.onload(request);
  500. if (MY_XHR_Ob.trace)
  501. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  502. }
  503. };
  504. request.send(MY_XHR_Ob.data);
  505. }
  506.  
  507. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  508. function MZ_formatDateMS(d) {
  509. if (d === undefined) d = new Date();
  510. var day = d.getDate();
  511. var month = d.getMonth()+1;
  512. var year = d.getFullYear();
  513. var hours = d.getHours();
  514. var minutes = d.getMinutes();
  515. var seconds = d.getSeconds();
  516. var ms = d.getMilliseconds();
  517. if (day < 10) {day = "0"+day;}
  518. if (month < 10) {month = "0"+month;}
  519. if (hours < 10) {hours = "0"+hours;}
  520. if (hours < 10) {hours = "0"+hours;}
  521. if (minutes < 10) {minutes = "0"+minutes;}
  522. if (seconds < 10) {seconds = "0"+seconds;}
  523. ms = ('000' + ms).substr(-3, 3);
  524. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  525. }
  526.  
  527. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  528.  
  529. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  530. function copyTextToClipboard(text) {
  531. var textArea = document.createElement("textarea");
  532.  
  533. //
  534. // *** This styling is an extra step which is likely not required. ***
  535. //
  536. // Why is it here? To ensure:
  537. // 1. the element is able to have focus and selection.
  538. // 2. if element was to flash render it has minimal visual impact.
  539. // 3. less flakyness with selection and copying which **might** occur if
  540. // the textarea element is not visible.
  541. //
  542. // The likelihood is the element won't even render, not even a flash,
  543. // so some of these are just precautions. However in IE the element
  544. // is visible whilst the popup box asking the user for permission for
  545. // the web page to copy to the clipboard.
  546. //
  547.  
  548. // Place in top-left corner of screen regardless of scroll position.
  549. textArea.style.position = 'fixed';
  550. textArea.style.top = 0;
  551. textArea.style.left = 0;
  552.  
  553. // Ensure it has a small width and height. Setting to 1px / 1em
  554. // doesn't work as this gives a negative w/h on some browsers.
  555. textArea.style.width = '2em';
  556. textArea.style.height = '2em';
  557.  
  558. // We don't need padding, reducing the size if it does flash render.
  559. textArea.style.padding = 0;
  560.  
  561. // Clean up any borders.
  562. textArea.style.border = 'none';
  563. textArea.style.outline = 'none';
  564. textArea.style.boxShadow = 'none';
  565.  
  566. // Avoid flash of white box if rendered for any reason.
  567. textArea.style.background = 'transparent';
  568.  
  569. textArea.value = text;
  570.  
  571. document.body.appendChild(textArea);
  572.  
  573. textArea.select();
  574.  
  575. var successful = document.execCommand('copy');
  576.  
  577. document.body.removeChild(textArea);
  578. return successful;
  579. }
  580.  
  581. function avertissement(txt,duree) {
  582. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  583. if(!duree) duree = 15000;
  584. var div = document.createElement('div');
  585. // On numérote les avertissements pour destruction sélective
  586. var num = document.getElementsByName('avertissement').length;
  587. div.num = num;
  588. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  589. div.setAttribute('name','avertissement');
  590. div.className = 'mh_textbox';
  591. div.style.position = 'fixed';
  592. div.style.top = (10+15*num)+'px';
  593. div.style.left = (10+5*num)+'px';
  594. div.style.border = '5px solid red';
  595. div.style.zIndex = 2+num;
  596. div.style.cursor = 'pointer';
  597. div.style.fontSize = 'large';
  598. div.innerHTML = txt;
  599. div.onclick=function(){ tueAvertissement(this.num) };
  600.  
  601. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  602. var divcroix = document.createElement('div');
  603. divcroix.style.position = 'absolute';
  604. divcroix.style.top = 0;
  605. divcroix.style.right = 0;
  606. divcroix.style.color = 'black';
  607. divcroix.style.fontSize = 'inherit';
  608. divcroix.style.cursor = 'pointer'
  609. divcroix.style.zIndex = 2+num;
  610. divcroix.innerHTML = "X";
  611. div.appendChild(divcroix);
  612.  
  613. document.body.appendChild(div);
  614. // Destruction automatique de l'avertissement après "un certain temps"
  615. window.setTimeout(function(){ tueAvertissement(num) },duree);
  616. }
  617.  
  618. function tueAvertissement(num) {
  619. var divs = document.getElementsByName('avertissement');
  620. if(divs.length==0) { return; }
  621. for(var i=0 ; i<divs.length ; i++) {
  622. if(divs[i].num==num) {
  623. divs[i].parentNode.removeChild(divs[i]);
  624. return;
  625. }
  626. }
  627. }
  628.  
  629.  
  630. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  631.  
  632. function insertBefore(next,el) {
  633. next.parentNode.insertBefore(el,next);
  634. }
  635.  
  636. function appendTr(tbody,clas) {
  637. var tr = document.createElement('tr');
  638. if(clas) tr.className = clas;
  639. tbody.appendChild(tr);
  640. return tr;
  641. }
  642.  
  643. function insertTr(next,clas) {
  644. var tr = document.createElement('tr');
  645. if(clas) tr.className = clas;
  646. insertBefore(next,tr);
  647. return tr;
  648. }
  649.  
  650. function appendTd(tr) {
  651. var td = document.createElement('td');
  652. if(tr) tr.appendChild(td);
  653. return td;
  654. }
  655.  
  656. function insertTd(next) {
  657. var td = document.createElement('td');
  658. insertBefore(next,td);
  659. return td;
  660. }
  661.  
  662. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  663. function insertAfterTd(eTd) {
  664. var newTd = document.createElement('td');
  665. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  666. return newTd;
  667. }
  668.  
  669. function appendTdCenter(tr,colspan) {
  670. var td = appendTd(tr);
  671. td.align = 'center'; // WARNING - Obsolete
  672. if(colspan) td.colSpan = colspan;
  673. return td;
  674. }
  675.  
  676. function insertTdElement(next,el) {
  677. var td = insertTd(next);
  678. if(el) td.appendChild(el);
  679. return td;
  680. }
  681.  
  682. function appendA(paren,href,cssClass,text) {
  683. var a = document.createElement('a');
  684. if (href) a.href = href;
  685. if (cssClass) a.className = cssClass;
  686. if (text) a.appendChild(document.createTextNode(text));
  687. paren.appendChild(a);
  688. }
  689.  
  690. function appendText(paren,text,bold) {
  691. if(bold) {
  692. var b = document.createElement('b');
  693. b.appendChild(document.createTextNode(text));
  694. paren.appendChild(b);
  695. }
  696. else
  697. paren.appendChild(document.createTextNode(text));
  698. }
  699.  
  700. function insertText(next,text,bold) {
  701. if(bold) {
  702. var b = document.createElement('b');
  703. appendText(b,text);
  704. insertBefore(next,b);
  705. }
  706. else
  707. insertBefore(next,document.createTextNode(text));
  708. }
  709.  
  710. function appendTdText(tr,text,bold) {
  711. var td = appendTd(tr);
  712. appendText(td,text,bold);
  713. return td;
  714. }
  715.  
  716. function insertTdText(next,text,bold) {
  717. var td = insertTd(next);
  718. appendText(td,text,bold);
  719. return td;
  720. }
  721.  
  722. function appendBr(paren) {
  723. paren.appendChild(document.createElement('br'));
  724. }
  725.  
  726. function insertBr(next) {
  727. insertBefore(next,document.createElement('br'));
  728. }
  729.  
  730. function appendLI(ul,text) {
  731. // uniquement utilisé dans les options (crédits)
  732. var li = document.createElement('li');
  733. appendText(li,text);
  734. ul.appendChild(li);
  735. return li;
  736. }
  737.  
  738. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  739. var input = document.createElement('input');
  740. input.className = 'TextboxV2';
  741. input.type = type;
  742. input.name = nam;
  743. if (sId === undefined) input.id = nam;
  744. else input.id = sId;
  745. input.size = size;
  746. input.maxLength = maxlength;
  747. if(value) input.value = value;
  748. paren.appendChild(input);
  749. return input;
  750. }
  751.  
  752. function appendCheckBox(paren,nam,checked,onClick) {
  753. var input = document.createElement('input');
  754. input.type = 'checkbox';
  755. input.name = nam;
  756. input.id = nam;
  757. if(checked) input.checked = true;
  758. if(onClick) input.onclick = onClick;
  759. paren.appendChild(input);
  760. return input;
  761. }
  762.  
  763. function appendNobr(paren,id,delgg,text) {
  764. var nobr = document.createElement('nobr');
  765. appendCheckBox(nobr,id,null,delgg);
  766. appendText(nobr,text);
  767. paren.appendChild(nobr);
  768. appendText(paren,' ');
  769. return nobr;
  770. }
  771.  
  772. function appendCheckBoxSpan(paren,id,onClick,text) {
  773. var span = document.createElement('span');
  774. span.style.whiteSpace = 'nowrap';
  775. appendCheckBox(span,id,false,onClick);
  776. var label = document.createElement('label');
  777. appendText(label,text);
  778. label.htmlFor = id;
  779. label.style.marginLeft = '-5px';
  780. span.appendChild(label);
  781. span.style.marginRight = '3px';
  782. paren.appendChild(span);
  783. appendText(paren, ' ');
  784. return span;
  785. }
  786.  
  787. function appendOption(select,value,text) {
  788. var option = document.createElement('option');
  789. option.value = value;
  790. appendText(option,text);
  791. select.appendChild(option);
  792. return option;
  793. }
  794.  
  795. function appendHidden(form,nam,value) {
  796. var input = document.createElement('input');
  797. input.type = 'hidden';
  798. input.name = nam;
  799. input.id = nam;
  800. input.value = value;
  801. form.appendChild(input);
  802. }
  803.  
  804. function appendButton(paren,value,onClick) {
  805. var input = document.createElement('input');
  806. input.type = 'button';
  807. input.className = 'mh_form_submit';
  808. input.value = value;
  809. input.onmouseover = function(){this.style.cursor='pointer';};
  810. if(onClick) input.onclick = onClick;
  811. paren.appendChild(input);
  812. return input;
  813. }
  814.  
  815. function insertButton(next,value,onClick) {
  816. var input = document.createElement('input');
  817. input.type = 'button';
  818. input.className = 'mh_form_submit';
  819. input.value = value;
  820. input.onmouseover = function(){this.style.cursor='pointer';};
  821. input.onclick = onClick;
  822. insertBefore(next,input);
  823. return input;
  824. }
  825.  
  826. function appendSubmit(paren,value,onClick) {
  827. var input = document.createElement('input');
  828. input.type = 'submit';
  829. input.className = 'mh_form_submit';
  830. input.value = value;
  831. input.onmouseover = function(){this.style.cursor='pointer';};
  832. if(onClick) input.onclick = onClick;
  833. paren.appendChild(input);
  834. return input;
  835. }
  836.  
  837. function createImage(url,title,style) {
  838. var img = document.createElement('img');
  839. img.src = url;
  840. img.title = title;
  841. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  842. if (style) img.style = style;
  843. return img;
  844. }
  845.  
  846. function createAltImage(url,alt,title) {
  847. var img = document.createElement('img');
  848. img.src = url;
  849. img.alt = alt;
  850. if (title) img.title = title;
  851. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  852. return img;
  853. }
  854.  
  855. function createImageSpan(url,alt,title,text,bold) {
  856. var span = document.createElement('span');
  857. span.title = title;
  858. var img = document.createElement('img');
  859. img.src = url;
  860. img.alt = alt;
  861. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  862. span.appendChild(img);
  863. appendText(span,text,bold);
  864. return span;
  865. }
  866.  
  867. function createCase(titre,table,width) {
  868. if(!width) width=120;
  869. var tr = appendTr(table,'mh_tdpage');
  870. var td = appendTdText(tr,titre,true);
  871. td.className = 'mh_tdtitre';
  872. td.width = width;
  873. td = appendTdText(tr,'');
  874. td.className = 'mh_tdpage';
  875. return td;
  876. }
  877.  
  878. function getMyID(e) {
  879. var parent = e.parentNode;
  880. for(var i=0 ; i<parent.childNodes.length ; i++) {
  881. if(e==parent.childNodes[i])
  882. return i;
  883. }
  884. return -1;
  885. }
  886.  
  887. function insertAfter(elt,newElt) {
  888. var id = getMyID(elt);
  889. if(id==-1) return;
  890. if(id<elt.parentNode.childNodes.length-1)
  891. insertBefore(elt.nextSibling,newElt);
  892. else
  893. elt.parentNode.appendChild(newElt);
  894. }
  895.  
  896.  
  897. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  898.  
  899. function aff(nb) {
  900. return (nb>=0) ? '+'+nb : nb;
  901. }
  902.  
  903. function getNumber(str) {
  904. var nbr = str.match(/\d+/);
  905. return nbr ? Number(nbr[0]) : Number.NaN;
  906. }
  907.  
  908. function getNumbers(str) {
  909. var nbrs = str.match(/-?\d+/g);
  910. if (!nbrs) return [];
  911. for(var i=0 ; i<nbrs.length ; i++)
  912. nbrs[i] = Number(nbrs[i]);
  913. return nbrs;
  914. }
  915.  
  916. function trim(str) {
  917. return str.replace(/(^\s*)|(\s*$)/g,'');
  918. }
  919.  
  920. String.prototype.trim = function() {
  921. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  922. }
  923.  
  924. function epure(texte) {
  925. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  926. .replace(/[ç]/g,'c')
  927. .replace(/[éêèë]/g,'e')
  928. .replace(/[ïî]/g,'i')
  929. .replace(/[ôöõ]/g,'o')
  930. .replace(/[ùûü]/g,'u');
  931. }
  932.  
  933. String.prototype.epure = function () {
  934. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  935. .replace(/[ç]/g,'c')
  936. .replace(/[éêèë]/g,'e')
  937. .replace(/[ïî]/g,'i')
  938. .replace(/[ôöõ]/g,'o')
  939. .replace(/[ùûü]/g,'u');
  940. }
  941.  
  942. function bbcode(texte) {
  943. return texte.replace(/&/g,'&amp;')
  944. .replace(/"/g,'&quot;')
  945. .replace(/</g,'&lt;')
  946. .replace(/>/g,'&gt;')
  947. .replace(/'/g,'&#146;')
  948. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  949. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  950. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  951. }
  952.  
  953.  
  954. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  955.  
  956. function addZero(i) {
  957. return (i<10) ? '0'+i : i;
  958. }
  959.  
  960. function DateToString(date) {
  961. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  962. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  963. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  964. }
  965.  
  966. function StringToDate(str) {
  967. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  968. }
  969.  
  970. // fonctionne aussi avec datetime
  971. function SQLDateToFrench(str) {
  972. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  973. }
  974.  
  975. // ... et ajoute un "à" du plus bel effet
  976. function SQLDateToFrenchTime(str) {
  977. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  978. }
  979.  
  980. // SQLDate vers objet date Javascript
  981. function SQLDateToObject(str) {
  982. var t = str.split(/[- :]/);
  983. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  984. }
  985.  
  986. var mz_ie = (window.attachEvent)? true:false;
  987. if ("function" !== typeof addEvent) {
  988. if (mz_ie) {
  989. function addEvent(obj, typ, fn, sens) {
  990. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  991. obj["e"+typ+fn]( window.event );
  992. }
  993. obj.attachEvent("on"+typ, obj[typ+fn] );
  994. }
  995. }
  996. else {
  997. function addEvent(obj, typ, fn, sens) {
  998. obj.addEventListener(typ, fn, sens);
  999. }
  1000. }
  1001. }
  1002.  
  1003. /**********************
  1004. * glissière en mode objet
  1005. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  1006. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  1007. *
  1008. * Usage:
  1009. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  1010. * ref : utilisé pour diversifier les IDs HTML
  1011. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  1012. * target : peut être de 3 types
  1013. * - élément HTML : l'élément HTML à zoomer
  1014. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  1015. * - function : callback quand le curseur bouge
  1016. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  1017. * dans le mode dynamique, la callback est appelée sur mouseMove
  1018. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  1019. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  1020. * autres méthodes
  1021. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  1022. **********************/
  1023.  
  1024. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  1025. try {
  1026. var mouseDown = false;
  1027. var div_gliss = document.createElement("div"); // la DIV mère
  1028. div_gliss.id = "MZ_gliss_"+ref;
  1029. var div_label = document.createElement("span"); // le label
  1030. div_label.innerHTML = labelHTML;
  1031. div_gliss.appendChild(div_label);
  1032. div_gliss.className = "choix_zoom";
  1033. var dessin = document.createElement("canvas"); // le dessin lui-même
  1034. dessin.id = "MZ_gliss_dessin_"+ref;
  1035. dessin.style.cursor = "pointer";
  1036. dessin.width = 104;
  1037. dessin.height = 12;
  1038. dessin.style.marginLeft = '2px';
  1039. dessin.style.marginRight = '2px';
  1040. div_gliss.appendChild(dessin);
  1041. var pourcent = document.createElement("span"); // le pourcentage
  1042. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1043. var pourcent_text = document.createTextNode('');
  1044. var previousVal;
  1045. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1046.  
  1047. // alignement vertical
  1048. dessin.style.verticalAlign = 'middle';
  1049. div_label.style.verticalAlign = 'middle';
  1050. pourcent.style.verticalAlign = 'middle';
  1051.  
  1052. pourcent.appendChild(pourcent_text);
  1053. div_gliss.appendChild(pourcent);
  1054.  
  1055. var bulle_pourcent = document.createElement("div"); // la bulle
  1056. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1057. bulle_pourcent.style.display = 'block';
  1058. bulle_pourcent.style.visibility = 'hidden';
  1059. bulle_pourcent.style.position = 'absolute';
  1060. bulle_pourcent.style.zIndex = 3500;
  1061. bulle_pourcent.style.border = '1px solid #a1927f';
  1062. var bulle_pourcent_text = document.createTextNode('');
  1063. bulle_pourcent.appendChild(bulle_pourcent_text);
  1064. document.body.appendChild(bulle_pourcent);
  1065.  
  1066. this.getElt = function() {return div_gliss;};
  1067.  
  1068. ////////////////////////////////////
  1069. // dessine et redessine le curseur
  1070. ////////////////////////////////////
  1071. var dessine_glissiere = function(val) {
  1072. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1073. var ctx = dessin.getContext('2d');
  1074. ctx.clearRect(0, 0,104, 12);
  1075. ctx.fillStyle = "rgb(0,0,0)";
  1076. ctx.fillRect(0,0,2,12);
  1077. ctx.fillRect(102,0,2,12);
  1078. ctx.fillRect(0,5,104,2);
  1079.  
  1080. ctx.fillStyle = "rgb(80,80,80)";
  1081. ctx.fillRect(pos_0_100,0,5,12);
  1082. ctx.fillStyle = "rgb(200,200,200)";
  1083. ctx.fillRect(pos_0_100+1,1,3,10);
  1084. pourcent_text.nodeValue = val+'%';
  1085. previousVal = parseInt(val);
  1086. };
  1087.  
  1088. ////////////////////////////////////
  1089. // action sur mousedown et mousemove
  1090. // stocker la nouvelle valeur
  1091. // redessiner
  1092. // afficher la nouvelle valeur
  1093. // action selon ce qui a été demandé
  1094. ////////////////////////////////////
  1095. var doCallback_glissiere = function (evt) {
  1096. try {
  1097. if (evt.type === 'mousedown') mouseDown = true;
  1098. if (evt.offsetX) {
  1099. var xsouris = evt.offsetX;
  1100. var xpos = evt.clientX;
  1101. var ypos = evt.clientY + document.body.scrollTop;
  1102. }
  1103. else {
  1104. var xsouris = evt.layerX;
  1105. var xpos = evt.pageX;
  1106. var ypos = evt.pageY;
  1107. }
  1108. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1109. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1110. // afficher la nouvelle valeur dans la bulle
  1111. bulle_pourcent_text.nodeValue = val + '%';
  1112. bulle_pourcent.style.top = (ypos+3)+'px';
  1113. bulle_pourcent.style.left = (xpos+16)+'px';
  1114. if (evt.buttons === undefined) {
  1115. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1116. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1117. } else {
  1118. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1119. }
  1120. // stocker la nouvelle valeur
  1121. MY_setValue("MZ_glissiere_" + ref, val);
  1122. // redessiner la glissière avec le curseur où il faut
  1123. dessine_glissiere(val);
  1124. // action selon ce qui a été demandé
  1125. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1126. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1127. if (typeof paramTarget === 'object') {
  1128. var elt = paramTarget;
  1129. } else if (typeof paramTarget === 'string') {
  1130. var elt = document.getElementById(paramTarget);
  1131. } else if (typeof paramTarget === 'function') {
  1132. paramTarget(val);
  1133. return;
  1134. }
  1135. if (elt.setZoom != undefined) elt.setZoom(val);
  1136. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1137. };
  1138.  
  1139. ////////////////////////////////////
  1140. // event mousedown et mousemove : redessiner et callback
  1141. ////////////////////////////////////
  1142. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1143. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1144. ////////////////////////////////////
  1145. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1146. ////////////////////////////////////
  1147. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1148. ////////////////////////////////////
  1149. // event mouseout & mouseover : afficher/cacher la bulle
  1150. ////////////////////////////////////
  1151. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1152. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1153.  
  1154. ////////////////////////////////////
  1155. // dessiner la première fois
  1156. ////////////////////////////////////
  1157. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1158. if (val_init === undefined) val_init = valDef;
  1159. dessine_glissiere(val_init);
  1160. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1161. }
  1162.  
  1163. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1164. // reçoit 2 objets avec des propriétés x et y
  1165. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1166. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1167. var deltaX = locArrivee.x - locDepart.x;
  1168. if (deltaX == 0) return; // pas de point intermédiaire
  1169. var deltaY = locArrivee.y - locDepart.y;
  1170. if (deltaY == 0) return; // pas de point intermédiaire
  1171. var absDeltaX = Math.abs(deltaX);
  1172. var absDeltaY = Math.abs(deltaY);
  1173. if (absDeltaX > absDeltaY) {
  1174. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1175. } else if (absDeltaY > absDeltaX) {
  1176. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1177. } else {
  1178. return; // égalité, pas de point intermédiaire
  1179. }
  1180. }
  1181.  
  1182. /**********************
  1183. * carte en mode objet
  1184. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1185. *
  1186. * Usage:
  1187. * carte = new carte_MZ(ref, tabDepl);
  1188. * ref : utilisé pour diversifier les IDs HTML
  1189. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1190. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1191. * autres méthodes
  1192. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1193. **********************/
  1194.  
  1195. function carte_MZ(ref, tabDepl) {
  1196. try {
  1197. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1198. div1_carte.id = "MZ_carte_"+ref;
  1199. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1200. div1_carte.style.backgroundImage = 'none';
  1201. div1_carte.style.backgroundColor = 'transparent';
  1202. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1203. div2_carte.className = "carte_MZ";
  1204. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1205. var dessin = document.createElement("canvas"); // le dessin lui-même
  1206. dessin.id = "MZ_carte_dessin_"+ref;
  1207. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1208. div1_carte.appendChild(div2_carte);
  1209. div2_carte.appendChild(dessin);
  1210.  
  1211. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1212. , [-66.5, -37.5, 2, 1.5, -69]
  1213. , [-63.5, 8.5, 2, 1.5, -69]
  1214. , [-59.5, -32.5, 2, 1.5, -69]
  1215. , [-52, 57, 0.25, 0.8, -59]
  1216. , [-50.5, -22.5, 2, 1.5, -69]
  1217. , [-35.5, -51.5, 2, 1.5, -69]
  1218. , [-34.5, 14.5, 2, 1.5, -69]
  1219. , [-34.5, 64.5, 2, 1.5, -69]
  1220. , [-11.5, 72.5, 2, 1.5, -69]
  1221. , [5.5, -49.5, 2, 1.5, -69]
  1222. , [5.5, 31.5, 2, 1.5, -69]
  1223. , [10.5, 63.5, 2, 1.5, -69]
  1224. , [12, -15, 0.25, 0.8, -59]
  1225. , [21.5, 35.5, 2, 1.5, -69]
  1226. , [30, -52, 0.25, 0.8, -59]
  1227. , [46.5, 51.5, 2, 1.5, -69]
  1228. , [48, -39, 0.25, 0.8, -59]
  1229. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1230. , [56.5, 23.5, 75, 8.7, -99]
  1231. , [64, 70, 0.25, 0.8, -59]
  1232. , [74.5, 31.5, 2, 1.5, -69]];
  1233.  
  1234. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1235. var couleur_cible = 'rgba(0,0,0,0.5)';
  1236. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1237. var couleur_trou = 'rgb(200,0,0)';
  1238.  
  1239. var coord_x = function(val) {
  1240. return decalh+coeff*(val+100);
  1241. };
  1242. var coord_y = function(val) {
  1243. return decalv+coeff*(100-val);
  1244. };
  1245.  
  1246. var ctx = dessin.getContext('2d');
  1247. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1248. if (coeff) coeff /= 50;
  1249. else coeff = 2;
  1250. var decalv=30, decalh=30;
  1251.  
  1252. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1253. //var res = false
  1254. var x0 = pos0.x;
  1255. var y0 = pos0.x;
  1256. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1257. var px = Math.sign(pos1.x - pos0.x);
  1258. var py = Math.sign(pos1.y - pos0.y);
  1259. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1260. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1261.  
  1262. for(var k in position_trous_MZ) {
  1263. a = parseFloat(px*px+py*py);
  1264. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1265. 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]);
  1266. delta = b*b-a*c
  1267. if(delta >= 0) {
  1268. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1269. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1270. if(t0 <= tmax && t1 >= 0) {
  1271. // 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
  1272. //res = true;
  1273. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1274. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1275. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1276. // Roule : pas utile pour nous
  1277. //res = true;
  1278. //chute.push([x0+l*px, y0+l*py]);
  1279. return true;
  1280. }
  1281. }
  1282. }
  1283. }
  1284. //return res;
  1285. return false;
  1286. };
  1287.  
  1288. var dessine_carte = function () {
  1289. dessin.width = 200*coeff+2*decalh;
  1290. dessin.height = 200*coeff+2*decalv;
  1291.  
  1292. //repere
  1293. ctx.beginPath();
  1294. ctx.moveTo(coord_x(0), coord_y(100));
  1295. ctx.lineTo(coord_x(0), coord_y(-100));
  1296. ctx.moveTo(coord_x(-100), coord_y(0));
  1297. ctx.lineTo(coord_x(100), coord_y(0));
  1298. ctx.stroke();
  1299. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1300.  
  1301. //trous
  1302. ctx.fillStyle = couleur_trou;
  1303. for(var i in position_trous_MZ) {
  1304. ctx.beginPath();
  1305. 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);
  1306. ctx.fill();
  1307. }
  1308. // trajets
  1309. ctx.lineCap = "round";
  1310. ctx.lineJoin = "round";
  1311. for (var iSuivant in tabDepl) {
  1312. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1313. var tabDeplOneSuivant = tabDepl[iSuivant];
  1314. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1315. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1316. // La "cible" au départ
  1317. var typeDepart = tabDeplOneSuivant[0].typ;
  1318. switch (typeDepart) {
  1319. case 'tp':
  1320. ctx.beginPath();
  1321. ctx.lineWidth = 2;
  1322. ctx.strokeStyle = couleur_cible;
  1323. ctx.fillStyle = couleur_cible;
  1324. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1325. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1326. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1327. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1328. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1329. ctx.moveTo(x0 + coeff * 3, y0);
  1330. ctx.lineTo(x0 - coeff * 3, y0);
  1331. ctx.moveTo(x0, y0 + coeff * 3);
  1332. ctx.lineTo(x0, y0 - coeff * 3);
  1333. ctx.stroke();
  1334. break;
  1335. default:
  1336. ctx.beginPath();
  1337. ctx.lineWidth = 1;
  1338. ctx.strokeStyle = couleur_cible;
  1339. ctx.fillStyle = couleur_cible;
  1340. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1341. ctx.moveTo(x0 + coeff * 4, y0);
  1342. ctx.lineTo(x0 - coeff * 4, y0);
  1343. ctx.moveTo(x0, y0 + coeff * 4);
  1344. ctx.lineTo(x0, y0 - coeff * 4);
  1345. ctx.stroke();
  1346. break;
  1347. }
  1348. // les segments
  1349. var nb_pts = tabDeplOneSuivant.length;
  1350. var pointPrecedent = tabDeplOneSuivant[0];
  1351. for (var i=1; i<nb_pts; i++) {
  1352. ctx.beginPath();
  1353. ctx.lineWidth = coeff;
  1354. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1355. ctx.strokeStyle = couleur_depl_normal;
  1356. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1357. if (pointIntermediaire === undefined) {
  1358. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1359. ctx.strokeStyle = couleur_depl_collision_trou;
  1360. else
  1361. ctx.strokeStyle = couleur_depl_normal;
  1362. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1363. } else {
  1364. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1365. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1366. ctx.strokeStyle = couleur_depl_collision_trou;
  1367. else
  1368. ctx.strokeStyle = couleur_depl_normal;
  1369. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1370. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1371. }
  1372. pointPrecedent = tabDeplOneSuivant[i];
  1373. ctx.stroke();
  1374. }
  1375. // Les points à chaque étape
  1376. ctx.fillStyle = couleur_depl_normal;
  1377. for (var i=1; i<nb_pts; i++) {
  1378. ctx.beginPath();
  1379. var x = coord_x(tabDeplOneSuivant[i].x);
  1380. var y = coord_y(tabDeplOneSuivant[i].y);
  1381. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1382. ctx.fill();
  1383. }
  1384. }
  1385. }
  1386.  
  1387. this.setZoom = function (val) {
  1388. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1389. coeff = val / 50;
  1390. dessine_carte();
  1391. }
  1392.  
  1393. // glissiere
  1394. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1395. var eGliss = gliss.getElt();
  1396. eGliss.style.position = 'absolute';
  1397. eGliss.style.top = (coeff * 2) + 'px';
  1398. eGliss.style.left = decalh + 'px';
  1399. dessin.style.position = 'relative';
  1400. div2_carte.style.position = 'relative';
  1401. eGliss.style.zIndex = 9000;
  1402. div2_carte.appendChild(eGliss);
  1403.  
  1404. // affichage au survol de la souris
  1405. var bulle = document.createElement('div');
  1406. bulle.style.visibility = 'hidden';
  1407. bulle.style.position = 'absolute';
  1408. bulle.style.zIndex = 3100;
  1409. bulle.style.border = 'solid 1px #a1927f';
  1410. bulle.className = 'mh_tdpage';
  1411. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1412. var bulleHaut = document.createElement('div');
  1413. bulleHaut.style.display = 'block';
  1414. bulleHaut.style.paddingRight = '3px';
  1415. bulleHaut.className = 'mh_tdtitre';
  1416. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1417. bulle.appendChild(bulleHaut);
  1418. var bulleBas = document.createElement('div');
  1419. bulleBas.style.display = 'block';
  1420. bulleBas.style.whiteSpace = "nowrap";
  1421. bulleBas.style.paddingRight = '3px';
  1422.  
  1423. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1424. bulle.appendChild(bulleBas);
  1425. div2_carte.appendChild(bulle);
  1426. var affichePosition = function(evt) {
  1427. if (evt.offsetX) {
  1428. var xsouris = evt.offsetX;
  1429. var ysouris = evt.offsetY;
  1430. var xpos = evt.clientX;
  1431. var ypos = evt.clientY + document.body.scrollTop;
  1432. }
  1433. else {
  1434. var xsouris = evt.layerX;
  1435. var ysouris = evt.layerY;
  1436. var xpos = evt.pageX;
  1437. var ypos = evt.pageY;
  1438. }
  1439. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1440. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1441. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1442. var tabHTMLbas = [];
  1443. // message pour les trous
  1444. for (var i in position_trous_MZ) {
  1445. var ceTrou = position_trous_MZ[i];
  1446. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1447. if(dist <= 0) {
  1448. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1449. break;
  1450. }
  1451. }
  1452. // messages pour les suivants
  1453. for (var i in tabDepl) {
  1454. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1455. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1456. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1457. }
  1458. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1459. bulle.style.top = (ysouris+8) + 'px';
  1460. bulle.style.left = (xsouris+16) + 'px';
  1461. };
  1462. addEvent(dessin, "mousemove", affichePosition, true);
  1463. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1464. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1465.  
  1466. // dessin initial
  1467. dessine_carte();
  1468.  
  1469. this.getElt = function() {return div1_carte;};
  1470.  
  1471. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1472. }
  1473.  
  1474.  
  1475. /**********************************************************
  1476. **** Fin de zone à déplacer dans une bibli commune ********
  1477. **********************************************************/
  1478.  
  1479. /* DEBUG: NETTOYAGE TAGS */
  1480. if(MY_getValue(numTroll+'.TAGSURL')) {
  1481. MY_removeValue(numTroll+'.TAGSURL');
  1482. }
  1483.  
  1484. // Alerte si mode dev
  1485. if (isDEV) {
  1486. var divpopup = document.createElement('div');
  1487. divpopup.id = 'divDEV';
  1488. divpopup.style =
  1489. 'position: fixed;'+
  1490. 'border: 15px solid red;'+
  1491. 'top: 10px;right: 10px;'+
  1492. 'background-color: white;'+
  1493. 'color: black;'+
  1494. 'font-size: large;'+
  1495. 'padding: 5px'+
  1496. 'z-index: 200;';
  1497. appendText(divpopup, '[MZ] Mode DEV');
  1498. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1499. document.body.appendChild(divpopup);
  1500. }
  1501.  
  1502. /*---------- regroupement des getPortee() ------------------------------------*/
  1503. // issu des script profil et profil2
  1504. function getPortee__Profil(param) {
  1505. param = Math.max(0,Number(param));
  1506. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1507. // ça devrait être floor, +10.25, -2.5
  1508. }
  1509.  
  1510. // issu du script vue
  1511. function getPortee__Vue(param) {
  1512. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1513. }
  1514.  
  1515.  
  1516. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1517.  
  1518. function getPXKill(niv) {
  1519. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1520. return Math.max(0,10+3*niv-2*nivTroll);
  1521. }
  1522.  
  1523. function getPXDeath(niv) {
  1524. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1525. return Math.max(0,10+3*nivTroll-2*niv);
  1526. }
  1527.  
  1528. function analysePX(niv) {
  1529. niv = niv+'';
  1530. var i = niv.indexOf('+');
  1531. if(i!=-1) // si niv = 'XX+' ??
  1532. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1533. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1534. if(i!=-1) {
  1535. var max = getPXKill(niv.slice(i+2));
  1536. if(max==0)
  1537. return ' --> <b>0</b> PX';
  1538. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1539. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1540. }
  1541. i = niv.indexOf('='); // ???
  1542. if(i!=-1) {
  1543. var max = getPXKill(niv.slice(i+1));
  1544. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1545. }
  1546. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1547. }
  1548.  
  1549. function analysePXTroll(niv) {
  1550. var str = analysePX(niv);
  1551. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1552. return str;
  1553. }
  1554.  
  1555.  
  1556. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1557. // Refonte totale du code de Zorya
  1558.  
  1559. // Elements à implémenter en dur dans MZ2.0
  1560. var numQualite = {
  1561. 'Très Mauvaise':1,
  1562. 'Mauvaise':2,
  1563. 'Moyenne':3,
  1564. 'Bonne':4,
  1565. 'Très Bonne':5
  1566. };
  1567.  
  1568. var qualiteNum = [
  1569. '_dummy_',
  1570. 'Très Mauvaise',
  1571. 'Mauvaise',
  1572. 'Moyenne',
  1573. 'Bonne',
  1574. 'Très Bonne'
  1575. ];
  1576.  
  1577. var nival = {
  1578. 'Abishaii Bleu':19,
  1579. 'Abishaii Noir':10,
  1580. 'Abishaii Rouge':23,
  1581. 'Abishaii Vert':15,
  1582. 'Ame-en-peine':8,
  1583. 'Amibe Geante':9,
  1584. 'Anaconda des Catacombes':8,
  1585. 'Ankheg':10,
  1586. 'Anoploure Purpurin':36,
  1587. 'Araignee Geante':2,
  1588. 'Ashashin':35,
  1589. 'Balrog':50,
  1590. 'Banshee':16,
  1591. 'Barghest':36,
  1592. 'Basilisk':11,
  1593. 'Behemoth':34,
  1594. 'Behir':14,
  1595. 'Beholder':50,
  1596. 'Boggart':3,
  1597. 'Bondin':9,
  1598. "Bouj'Dla Placide":37,
  1599. "Bouj'Dla":19,
  1600. 'Bulette':19,
  1601. 'Caillouteux':1,
  1602. 'Capitan':35,
  1603. 'Carnosaure':25,
  1604. 'Champi-Glouton':3,
  1605. 'Chauve-Souris Geante':4,
  1606. 'Cheval a Dents de Sabre':23,
  1607. 'Chevalier du Chaos':20,
  1608. 'Chimere':13,
  1609. 'Chonchon':24,
  1610. 'Coccicruelle':22,
  1611. 'Cockatrice':5,
  1612. 'Crasc Medius':17,
  1613. 'Crasc Maexus':25,
  1614. 'Crasc':10,
  1615. 'Croquemitaine':6,
  1616. 'Cube Gelatineux':32,
  1617. 'Daemonite':27,
  1618. 'Diablotin':5,
  1619. 'Dindon du Chaos':1,
  1620. 'Djinn':29,
  1621. 'Ectoplasme':18,
  1622. 'Effrit':27,
  1623. "Elementaire d'Air":23,
  1624. "Elementaire d'Eau":17,
  1625. 'Elementaire de Feu':21,
  1626. 'Elementaire de Terre':21,
  1627. 'Elementaire du Chaos':26,
  1628. 'Erinyes':7,
  1629. 'Esprit-Follet':16,
  1630. 'Essaim Craterien':30,
  1631. 'Essaim Sanguinaire':25,
  1632. 'Ettin':8,
  1633. 'Familier':1,
  1634. 'Fantome':24,
  1635. 'Feu Follet':20,
  1636. 'Flagelleur Mental':33,
  1637. 'Foudroyeur':38,
  1638. 'Fumeux':22,
  1639. 'Fungus Geant':9,
  1640. 'Fungus Violet':4,
  1641. 'Furgolin':10,
  1642. 'Gargouille':3,
  1643. 'Geant de Pierre':13,
  1644. 'Geant des Gouffres':22,
  1645. "Geck'oo Majestueux":40,
  1646. "Geck'oo":15,
  1647. 'Glouton':20,
  1648. 'Gnoll':5,
  1649. 'Gnu Domestique':1,
  1650. 'Gnu Sauvage':1,
  1651. 'Goblin':4,
  1652. 'Goblours':4,
  1653. "Golem d'Argile":15,
  1654. 'Golem de cuir':1,
  1655. 'Golem de Chair':8,
  1656. 'Golem de Fer':31,
  1657. 'Golem de mithril':1,
  1658. 'Golem de metal':1,
  1659. 'Golem de papier':1,
  1660. 'Golem de Pierre':23,
  1661. 'Gorgone':11,
  1662. 'Goule':4,
  1663. 'Gowap Apprivoise':1,
  1664. 'Gowap Sauvage':1,
  1665. 'Gremlins':3,
  1666. 'Gritche':39,
  1667. 'Grouilleux':4,
  1668. 'Grylle':31,
  1669. 'Harpie':4,
  1670. 'Hellrot':18,
  1671. 'Homme-Lezard':4,
  1672. 'Hurleur':8,
  1673. 'Hydre':50,
  1674. 'Incube':13,
  1675. 'Kobold':2,
  1676. 'Labeilleux':26,
  1677. 'Lezard Geant':5,
  1678. 'Liche':50,
  1679. 'Limace Geante':10,
  1680. 'Loup-Garou':8,
  1681. 'Lutin':4,
  1682. 'Mante Fulcreuse':30,
  1683. 'Manticore':9,
  1684. 'Marilith':33,
  1685. 'Meduse':6,
  1686. 'Megacephale':38,
  1687. 'Mille-Pattes Geant':14,
  1688. 'Mimique':6,
  1689. 'Minotaure':7,
  1690. 'Molosse Satanique':8,
  1691. 'Momie':4,
  1692. 'Monstre Rouilleur':3,
  1693. "Mouch'oo Domestique":14,
  1694. "Mouch'oo Majestueux Sauvage":33,
  1695. "Mouch'oo Sauvage":14,
  1696. 'Na-Haniym-Heee':0,
  1697. 'Necrochore':37,
  1698. 'Necromant':39,
  1699. 'Necrophage':8,
  1700. 'Naga':10,
  1701. 'Nuee de Vermine':13,
  1702. "Nuage d'Insectes":7,
  1703. 'Ogre':7,
  1704. 'Ombre de Roches':13,
  1705. 'Ombre':2,
  1706. 'Orque':3,
  1707. 'Ours-Garou':18,
  1708. 'Palefroi Infernal':29,
  1709. 'Phoenix':32,
  1710. 'Pititabeille':0,
  1711. 'Plante Carnivore':4,
  1712. 'Pseudo-Dragon':5,
  1713. 'Rat Geant':2,
  1714. 'Rat-Garou':3,
  1715. 'Rocketeux':5,
  1716. 'Sagouin':3,
  1717. 'Scarabee Geant':4,
  1718. 'Scorpion Geant':10,
  1719. 'Shai':28,
  1720. 'Sirene':8,
  1721. 'Slaad':5,
  1722. 'Sorciere':17,
  1723. 'Spectre':14,
  1724. 'Sphinx':30,
  1725. 'Squelette':1,
  1726. 'Strige':2,
  1727. 'Succube':13,
  1728. 'Tertre Errant':20,
  1729. 'Thri-kreen':10,
  1730. 'Tigre-Garou':12,
  1731. 'Titan':26,
  1732. 'Trancheur':35,
  1733. 'Tubercule Tueur':14,
  1734. 'Tutoki':4,
  1735. 'Vampire':29,
  1736. 'Ver Carnivore Geant':12,
  1737. 'Ver Carnivore':11,
  1738. 'Veskan Du Chaos':14,
  1739. 'Vouivre':33,
  1740. 'Worg':5,
  1741. 'Xorn':14,
  1742. 'Yeti':8,
  1743. 'Yuan-ti':15,
  1744. 'Zombie':2
  1745. }
  1746.  
  1747. var tabEM = {
  1748. //Monstre: [Compo exact, Sort, Position, Localisation]
  1749. // AA
  1750. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1751. // AE
  1752. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1753. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1754. // AdA
  1755. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1756. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1757. // AdE
  1758. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1759. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1760. // AdD
  1761. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1762. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1763. // BAM
  1764. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1765. // BuM
  1766. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1767. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1768. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1769. // Explo
  1770. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1771. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1772. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1773. // FP
  1774. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1775. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1776. // FA
  1777. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1778. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1779. // Glue
  1780. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1781. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1782. // GdS
  1783. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1784. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1785. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1786. // Invi
  1787. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1788. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1789. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1790. // Lévitation
  1791. // ???
  1792. // PréM :
  1793. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1794. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1795. // Proj
  1796. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1797. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1798. // PuM :
  1799. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1800. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1801. // Sacro
  1802. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1803. // Télék
  1804. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1805. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1806. // TP
  1807. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1808. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1809. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1810. // VA
  1811. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1812. // VL
  1813. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1814. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1815. // VlC
  1816. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1817. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1818. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1819. // VT
  1820. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1821. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1822. // Variables
  1823. 'Rat':["d'un"],
  1824. 'Rat Géant':["d'un"],
  1825. 'Dindon':["d'un"],
  1826. 'Goblin':["d'un"],
  1827. 'Limace':["d'une"],
  1828. 'Limace Géante':["d'une"],
  1829. 'Ver':["d'un"],
  1830. 'Ver Carnivore':["d'un"],
  1831. 'Ver Carnivore Géant':["d'un"],
  1832. 'Fungus':["d'un"],
  1833. 'Vouivre':["d'une"],
  1834. 'Gnu':["d'un"],
  1835. 'Scarabée':["d'un"]
  1836. };
  1837.  
  1838. var mundiChampi = {
  1839. 'Préscientus Reguis':'du Phoenix',
  1840. 'Amanite Trolloïde':'de la Mouche',
  1841. 'Girolle Sanglante':'du Dindon',
  1842. 'Horreur Des Prés':'du Gobelin',
  1843. 'Bolet Péteur':'du Démon',
  1844. 'Pied Jaune':'de la Limace',
  1845. 'Agaric Sous-Terrain':'du Rat',
  1846. 'Suinte Cadavre':"de l'Hydre",
  1847. 'Cèpe Lumineux':'du Ver',
  1848. 'Fungus Rampant':'du Fungus',
  1849. 'Nez Noir':'de la Vouivre',
  1850. 'Pleurote Pleureuse':'du Gnu',
  1851. 'Phytomassus Xilénique':'du Scarabée'
  1852. };
  1853.  
  1854. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1855. appendText(node,' ');
  1856. var urlImg = URL_MZimg
  1857. +'Competences/melangeMagique.png';
  1858. var text = ' [-'+(niv+effetQ)+' %]';
  1859. var str = '';
  1860. switch(mob[0]) {
  1861. case 'A':
  1862. case 'E':
  1863. case 'I':
  1864. case 'O':
  1865. case 'U':
  1866. str = "Compo d'";
  1867. break;
  1868. default:
  1869. str = 'Compo de ';
  1870. }
  1871. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1872. var span = createImageSpan(urlImg,'MM:',title,text);
  1873. node.appendChild(span);
  1874. }
  1875. function addInfoEM(node,mob,compo,qualite,localisation) {
  1876. if(!tabEM[mob]) return;
  1877. var title = 'Composant variable', texte = 'Variable';
  1878. var bold = false;
  1879. if(tabEM[mob].length>1) {
  1880. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1881. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1882. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1883. if(pc<-20) return;
  1884. if(pc>=0) bold = true;
  1885. texte = aff(pc)+'%';
  1886. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1887. }
  1888. var urlImg = URL_MZimg
  1889. +'Competences/ecritureMagique.png';
  1890. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1891. node.appendChild(span);
  1892. }
  1893.  
  1894. function insererInfosEM(tbody) {
  1895. // lancé par equip, equipgowap
  1896. var trCompos = document.evaluate(
  1897. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1898. tbody,null,7,null);
  1899. var strCompos = '';
  1900. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1901. var node = trCompos.snapshotItem(i).childNodes[7];
  1902. var str = node.firstChild.textContent;
  1903. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1904. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1905. // Si non-EM on stoppe le traitement
  1906. if(!tabEM[mob]) continue;
  1907. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1908. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1909. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1910. addInfoEM(node,mob,compo,qualite,localisation);
  1911. }
  1912. }
  1913.  
  1914. function getQualite(qualite) {
  1915. var nb = numQualite[qualite];
  1916. return nb ? nb-1 : -1;
  1917. }
  1918.  
  1919. function getEM(nom) {
  1920. if(nom.indexOf('[')!=-1)
  1921. nom = trim(nom.substring(0,nom.indexOf('[')));
  1922. if(tabEM[nom]) return nom;
  1923. return '';
  1924. }
  1925.  
  1926. // DEBUG ex-fonction composantEM
  1927. function compoMobEM(mob) {
  1928. if(!tabEM[mob]) return '';
  1929. if(tabEM[mob].length==1)
  1930. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1931. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1932. +") pour l'écriture de "+tabEM[mob][1];
  1933. }
  1934.  
  1935. // DEBUG ex-fonction compoEM
  1936. function titreCompoEM(mob,compo,localisation,qualite) {
  1937. if(!tabEM[mob]) return '';
  1938. if(tabEM[mob].length==1) return 'Composant variable';
  1939. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1940. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1941. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1942. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1943. return '';
  1944. }
  1945.  
  1946. // DEBUG - rétrocompatibilité
  1947. function compoEM(mob) {
  1948. // appelé dans libs, vue
  1949. return compoMobEM(mob);
  1950. }
  1951. function composantEM(mob,compo,localisation,qualite) {
  1952. // appelé dans libs, tancompo
  1953. return titreCompoEM(mob,compo,localisation,qualite);
  1954. }
  1955. //
  1956.  
  1957.  
  1958. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1959.  
  1960. arrayTalents = {
  1961. /* Compétences */
  1962. 'Acceleration du Metabolisme':'AM',
  1963. 'Attaque Precise':'AP',
  1964. 'Balayage':'Balayage',
  1965. //'Balluchonnage':'Ballu',
  1966. 'Baroufle':'Baroufle',
  1967. 'Bidouille':'Bidouille',
  1968. 'Botte Secrete':'BS',
  1969. 'Camouflage':'Camou',
  1970. 'Charger':'Charger',
  1971. 'Connaissance des Monstres':'CdM',
  1972. 'Construire un Piege':'Piege',
  1973. 'Piege a Feu':'PiegeFeu',
  1974. 'Piege a Glue':'PiegeGlue',
  1975. 'Contre-Attaquer':'CA',
  1976. 'Coup de Butoir':'CdB',
  1977. 'Course':'Course',
  1978. 'Deplacement Eclair':'DE',
  1979. 'Dressage':'Dressage',
  1980. 'Ecriture Magique':'EM',
  1981. 'Frenesie':'Frenesie',
  1982. 'Golemologie':'Golemo',
  1983. 'Golem de cuir':'GolemCuir',
  1984. 'Golem de metal':'GolemMetal',
  1985. 'Golem de mithril':'GolemMithril',
  1986. 'Golem de papier':'GolemPapier',
  1987. 'Grattage':'Grattage',
  1988. 'Hurlement Effrayant':'HE',
  1989. 'Identification des Champignons':'IdC',
  1990. 'Insultes':'Insultes',
  1991. 'Lancer de Potions':'LdP',
  1992. 'Marquage':'Marquage',
  1993. 'Melange Magique':'Melange',
  1994. 'Miner':'Miner',
  1995. 'Travail de la pierre':'Pierre',
  1996. 'Necromancie':'Necro',
  1997. 'Painthure de Guerre':'PG',
  1998. 'Parer':'Parer',
  1999. 'Pistage':'Pistage',
  2000. 'Planter un Champignon':'PuC',
  2001. 'Regeneration Accrue':'RA',
  2002. 'Reparation':'Reparation',
  2003. 'Retraite':'Retraite',
  2004. 'Rotobaffe':'RB',
  2005. 'Shamaner':'Shamaner',
  2006. "S'interposer":'SInterposer',
  2007. 'Tailler':'Tailler',
  2008. //'Vol':'Vol',
  2009. /* Sortilèges */
  2010. 'Analyse Anatomique':'AA',
  2011. 'Armure Etheree':'AE',
  2012. 'Augmentation de l´Attaque':'AdA',
  2013. 'Augmentation de l´Esquive':'AdE',
  2014. 'Augmentation des Degats':'AdD',
  2015. 'Bulle Anti-Magie':'BAM',
  2016. 'Bulle Magique':'BuM',
  2017. 'Explosion':'Explo',
  2018. 'Faiblesse Passagere':'FP',
  2019. 'Flash Aveuglant':'FA',
  2020. 'Glue':'Glue',
  2021. 'Griffe du Sorcier':'GdS',
  2022. 'Hypnotisme':'Hypno',
  2023. 'Identification des tresors':'IdT',
  2024. 'Invisibilite':'Invi',
  2025. 'Levitation':'Levitation',
  2026. 'Precision Magique':'PreM',
  2027. 'Projectile Magique':'Projo',
  2028. 'Projection':'Proj',
  2029. 'Puissance Magique':'PuM',
  2030. 'Rafale Psychique':'Rafale',
  2031. 'Sacrifice':'Sacro',
  2032. 'Siphon des ames':'Siphon',
  2033. 'Telekinesie':'Telek',
  2034. 'Teleportation':'TP',
  2035. 'Vampirisme':'Vampi',
  2036. 'Vision Accrue':'VA',
  2037. 'Vision lointaine':'VL',
  2038. 'Voir le Cache':'VlC',
  2039. 'Vue Troublee':'VT'
  2040. //'':''
  2041. }
  2042.  
  2043. // DEBUG - Pour rétrocompatibilité
  2044. function getSortComp(nom,niveau) {
  2045. return getTalent(nom,niveau);
  2046. }
  2047. //
  2048.  
  2049. function getTalent(nom,niveau) {
  2050. var nomEnBase = arrayTalents[epure(nom)];
  2051. if(!nomEnBase) return 0;
  2052. if(!niveau) var niveau = '';
  2053. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2054. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  2055. return 0;
  2056. }
  2057.  
  2058. function removeAllTalents() {
  2059. for(var talent in arrayTalents) {
  2060. var nomEnBase = arrayTalents[talent];
  2061. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2062. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2063. continue;
  2064. }
  2065. var niveau = 1;
  2066. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2067. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2068. niveau++;
  2069. }
  2070. }
  2071. }
  2072.  
  2073. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2074. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2075. var att = MY_getValue(numTroll+'.caracs.attaque');
  2076. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2077. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2078. var mm = MY_getValue(numTroll+'.caracs.mm');
  2079. var deg = MY_getValue(numTroll+'.caracs.degats');
  2080. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2081. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2082. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2083. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2084. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2085. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2086. return false;
  2087. return true;
  2088. } catch(e) {
  2089. return false;
  2090. }
  2091. }
  2092.  
  2093.  
  2094. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2095.  
  2096. function getPVsRestants(pv,bless,vue) {
  2097. bless = Number(bless.match(/\d+/)[0]);
  2098. if(bless==0) return null;
  2099. var pvminmax = pv.match(/\d+/g);
  2100. if(bless==95) {
  2101. var pvb = 1;
  2102. var pvh = Math.floor( pvminmax[1]/20 );
  2103. }
  2104. else if(bless==5) {
  2105. var pvb = Math.floor( pvminmax[0]*19/20 );
  2106. var pvh = pvminmax[1];
  2107. }
  2108. else {
  2109. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2110. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2111. }
  2112. return vue ? ' ('+pvb+'-'+pvh+')' :
  2113. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2114. }
  2115.  
  2116. function insertButtonCdm(nextName,onClick,texte) {
  2117. if(texte==null) texte = 'Participer au bestiaire';
  2118. var nextNode = document.getElementsByName(nextName)[0];
  2119.  
  2120. var espace = document.createTextNode('\t');
  2121. insertBefore(nextNode,espace);
  2122.  
  2123. var button = document.createElement('input');
  2124. button.type = 'button';
  2125. button.className = 'mh_form_submit';
  2126. button.value = texte;
  2127. button.onmouseover = function(){this.style.cursor='pointer';};
  2128. if(onClick) button.onclick = onClick;
  2129. insertBefore(espace,button);
  2130. return button;
  2131. }
  2132.  
  2133. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  2134. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  2135. 'Capacité spéciale','Résistance Magique','Autres'];
  2136.  
  2137. /* appelé par
  2138. createCDMTable (dans le popup DcM)
  2139. computeTactique (à coté du nom des monstres dans la vue et dans la page de détail des monstres)
  2140. */
  2141. function createImageTactique(url,id,nom) {
  2142. var img = document.createElement('img');
  2143. img.src = url;
  2144. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  2145. img.id = id;
  2146. img.nom = nom;
  2147. img.onmouseover = showPopupTactique;
  2148. img.onmouseout = hidePopup;
  2149. return img;
  2150. }
  2151.  
  2152. function createCDMTable(id,nom,donneesMonstre) {
  2153. try {
  2154. var urlImg = URL_MZimg;
  2155. var table = document.createElement('table');
  2156. var profilActif = isProfilActif();
  2157. table.className = 'mh_tdborder';
  2158. table.border = 0;
  2159. table.cellSpacing = 1;
  2160. table.cellPadding = 4;
  2161. var thead = document.createElement('thead');
  2162. var tr = appendTr(thead,'mh_tdtitre');
  2163. var td = appendTdText(tr,
  2164. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  2165. true
  2166. );
  2167. td.colSpan = 2;
  2168. table.appendChild(thead);
  2169. var tbody = document.createElement('tbody');
  2170. table.appendChild(tbody);
  2171. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  2172. createCase(listeTitres[i],tbody,80);
  2173. }
  2174. var TypeMonstre = getEM(nom);
  2175. var infosCompo='';
  2176. if(TypeMonstre!='') {
  2177. infosCompo = compoEM(TypeMonstre);
  2178. }
  2179. var nodes = tbody.childNodes;
  2180. nodes[0].childNodes[1].innerHTML =
  2181. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  2182. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  2183. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  2184. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  2185. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  2186. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  2187. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  2188. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  2189. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  2190. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  2191. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  2192. td = createCase(listeTitres[10],tbody);
  2193. td.innerHTML = bbcode(donneesMonstre[10]);
  2194. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2195. td.appendChild(document.createTextNode(" "));
  2196. if(donneesMonstre[16] == "De zone")
  2197. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2198. else if(donneesMonstre[16] == "Automatique")
  2199. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2200. else if(donneesMonstre[16] == "Au toucher")
  2201. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2202. }
  2203. }
  2204. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2205. {
  2206. td = createCase(listeTitres[11],tbody);
  2207. td.innerHTML = bbcode(donneesMonstre[9]);
  2208. // seuil de résistance du monstre
  2209. var lb = td.getElementsByTagName('b');
  2210. if(lb.length == 1) {
  2211. var mrm = lb[0].firstChild.nodeValue * 1;
  2212. var v = (mrm / mmTroll);
  2213. lb[0].firstChild.nodeValue += " ("
  2214. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2215. }
  2216. }
  2217. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2218. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2219. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2220. {
  2221. td = createCase(listeTitres[12],tbody);
  2222. if(donneesMonstre[12]==1)
  2223. {
  2224. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2225. }
  2226. if(donneesMonstre[13]==1)
  2227. {
  2228. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2229. }
  2230. else if(donneesMonstre[13]==0)
  2231. {
  2232. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2233. }
  2234. if(donneesMonstre[14]==1)
  2235. {
  2236. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2237. }
  2238. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2239. {
  2240. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2241. }
  2242. else if(donneesMonstre[14]>6)
  2243. {
  2244. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2245. }
  2246. if(donneesMonstre[15]=="Lente")
  2247. {
  2248. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2249. }
  2250. else if(donneesMonstre[15]=="Normale")
  2251. {
  2252. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2253. }
  2254. else if(donneesMonstre[15]=="Rapide")
  2255. {
  2256. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2257. }
  2258. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2259. {
  2260. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2261. }
  2262. if(infosCompo.length>0)
  2263. {
  2264. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2265. }
  2266. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2267. {
  2268. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2269. }
  2270. }
  2271. // pourcentage de blessure
  2272. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2273. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2274. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2275. if(pvs)
  2276. lb[0].firstChild.nodeValue += pvs;
  2277. }
  2278. return table;
  2279. }
  2280. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2281. }
  2282.  
  2283.  
  2284. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2285.  
  2286. var listeMonstreEnchantement = null,
  2287. listeEquipementEnchantement = null,
  2288. listeInfoEnchantement = null;
  2289.  
  2290. function computeCompoEnchantement()
  2291. {
  2292. listeMonstreEnchantement = new Array();
  2293. listeInfoEnchantement = new Array();
  2294. listeEquipementEnchantement = new Array();
  2295. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2296. for(var i=0;i<liste.length;i++)
  2297. {
  2298. var idEquipement = liste[i]*1;
  2299. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2300. continue;
  2301. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2302. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2303. var texteGlobal='';
  2304. for(var j=0;j<3;j++)
  2305. {
  2306. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2307. var v = MY_getValue(k);
  2308. var infoComposant = MY_getValue().split(';');
  2309. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2310. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2311. continue;
  2312. }
  2313. listeMonstreEnchantement[infoComposant[2]] = 1;
  2314. var array = new Array();
  2315. array[0]=infoComposant[0].replace("Ril","Œil");
  2316. array[1]=infoComposant[1];
  2317. array[2]=infoComposant[2];
  2318. array[3]=getQualite(infoComposant[3]);
  2319. var texte = infoComposant[4].replace("Ril","Œil");
  2320. for(var k=5;k<infoComposant.length;k++)
  2321. {
  2322. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2323. }
  2324. texteGlobal+=texte+'\n';
  2325. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2326. array[4]=texte;
  2327. listeInfoEnchantement.push(array);
  2328. }
  2329. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2330. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2331. }
  2332. }
  2333.  
  2334. function isEnchant(nom) {
  2335. var monstreEnchant = '';
  2336. for(j in listeInfoEnchantement) {
  2337. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2338. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2339. monstreEnchant=monstre;
  2340. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2341. }
  2342. }
  2343. return trim(monstreEnchant);
  2344. }
  2345.  
  2346. function getInfoEnchantementFromMonstre(nom)
  2347. {
  2348. try
  2349. {
  2350. if(!listeMonstreEnchantement)
  2351. {
  2352. computeCompoEnchantement();
  2353. }
  2354. var infosEnchant = '';
  2355. for(j in listeInfoEnchantement) {
  2356. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2357. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2358. if(infosEnchant=='')
  2359. infosEnchant=listeInfoEnchantement[j][4];
  2360. else
  2361. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2362. }
  2363. }
  2364. return trim(infosEnchant);
  2365. }
  2366. catch(e)
  2367. {
  2368. window.alert(e);
  2369. }
  2370. }
  2371.  
  2372. function composantEnchant(Monstre,composant,localisation,qualite) {
  2373. var compo='';
  2374. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2375. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2376. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2377. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2378. listeInfoEnchantement[i][3]<=qualite
  2379. ) {
  2380. return listeInfoEnchantement[i][4];
  2381. }
  2382. }
  2383. return compo;
  2384. }
  2385.  
  2386. function insertEnchantInfos(tbody) {
  2387. try
  2388. {
  2389. if(!listeMonstreEnchantement)
  2390. computeCompoEnchantement();
  2391. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2392. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2393. if(nodes.snapshotLength == 0)
  2394. return false;
  2395. var urlImg = URL_MZimg + 'enchant.png';
  2396. for(var i = 0; i < nodes.snapshotLength; i++) {
  2397. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2398. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2399. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2400. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2401. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2402. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2403. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2404. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2405. if(isEnchant(nomMonstre).length>0)
  2406. {
  2407. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2408. if(infos.length>0)
  2409. {
  2410. if(link.parentNode == link.nextSibling.parentNode)
  2411. {
  2412. var tmp = link.nextSibling;
  2413. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2414. }
  2415. else
  2416. {
  2417. link.parentNode.appendChild(createImage(urlImg,infos));
  2418. }
  2419. }
  2420. }
  2421. }
  2422. }
  2423. catch(e)
  2424. {
  2425. window.alert(e);
  2426. }
  2427. }
  2428.  
  2429. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2430. {
  2431. try
  2432. {
  2433. if(!listeMonstreEnchantement)
  2434. computeCompoEnchantement();
  2435. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2436. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2437. if(nodes.snapshotLength == 0)
  2438. return false;
  2439. var urlImg = URL_MZimg + 'enchant.png';
  2440. for(var i = 0; i < nodes.snapshotLength; i++)
  2441. {
  2442. var link = nodes.snapshotItem(i);
  2443. var idEquipement = link.getAttribute('href');
  2444. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2445. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2446. var nomEquipement = trim(link.firstChild.nodeValue);
  2447. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2448. if(!enchanteur || enchanteur == '')
  2449. continue;
  2450. var infos = listeEquipementEnchantement[idEquipement];
  2451. infos=formateTexte(infos);
  2452. if(infos.length>0)
  2453. {
  2454. if(link.parentNode == link.nextSibling.parentNode)
  2455. {
  2456. var tmp = link.nextSibling;
  2457. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2458. }
  2459. else
  2460. {
  2461. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2462. }
  2463. }
  2464. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2465. }
  2466. }
  2467. catch(e)
  2468. {
  2469. window.alert(e);
  2470. }
  2471. }
  2472.  
  2473. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2474.  
  2475.  
  2476. // Les % de toucher
  2477. var c = new Array();
  2478.  
  2479. // coefficients binomiaux
  2480. function cnp(n,k)
  2481. {
  2482. if(c[n] != null && c[n][k] != null)
  2483. return c[n][k];
  2484. if(c[n] == null)
  2485. c[n] = new Array();
  2486. if(k==0)
  2487. {
  2488. c[n][k] = 1;
  2489. return 1;
  2490. }
  2491. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2492. c[n][k] = result;
  2493. // Roule debug
  2494. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2495. return result;
  2496. }
  2497.  
  2498. // by Dab, à comparer
  2499. function binom(n,p) {
  2500. if(p<0 || p>n) return 0;
  2501. if(c[n])
  2502. if(c[n][p]) return c[n][p];
  2503. else {
  2504. c[n]=[1];
  2505. c[n][n]=1;
  2506. if(p==0 || p==n) return 1;
  2507. }
  2508. if(2*p>n)
  2509. c[n][p]=binom(n,n-p);
  2510. else
  2511. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2512. return c[n][p];
  2513. }
  2514.  
  2515. var coeff = new Array();
  2516.  
  2517. function coef(n,p)
  2518. {
  2519. if(n==0 && p==0)
  2520. return 1;
  2521. if(p>n*3.5)
  2522. p = 7*n-p
  2523. // roule désactive cache
  2524. if(coeff[n] != null && coeff[n][p] !=null)
  2525. return coeff[n][p];
  2526. if(coeff[n] == null)
  2527. coeff[n] = new Array();
  2528. var kmax = Math.floor((p-n)/6);
  2529. var x=0;
  2530. for(var k=0;k<=kmax;k++)
  2531. {
  2532. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2533. }
  2534. coeff[n][p] = x;
  2535. // Roule debug
  2536. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2537. return x;
  2538. }
  2539.  
  2540. function chanceEsquiveParfaite(a,d,ba,bd)
  2541. {
  2542. var win = 0;
  2543. var los = 0;
  2544. if(ba==null)
  2545. ba=0;
  2546. if(bd==null)
  2547. bd=0;
  2548. /* if(6*a+ba<2*(d+bd))
  2549. return 100;
  2550. if(a+ba>2*(6*d+bd))
  2551. return 0;*/
  2552. for(var ds=d;ds<=6*d;ds++)
  2553. {
  2554. var cd = coef(d,ds);
  2555. for(var as=a;as<=6*a;as++)
  2556. {
  2557. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2558. win += cd * coef(a,as);
  2559. else
  2560. los += cd * coef(a,as);
  2561. }
  2562. }
  2563. // roule debug
  2564. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2565. return Math.round(100*win/(win+los));
  2566. }
  2567.  
  2568. function chanceTouche(a,d,ba,bd)
  2569. {
  2570. var win = 0;
  2571. var los = 0;
  2572. if(ba==null)
  2573. ba=0;
  2574. if(bd==null)
  2575. bd=0;
  2576. if(a+ba>6*d+bd)
  2577. return 100;
  2578. if(6*a+ba<d+bd)
  2579. return 0;
  2580. for(var ds=d;ds<=6*d;ds++)
  2581. {
  2582. var cd = coef(d,ds);
  2583. for(var as=a;as<=6*a;as++)
  2584. {
  2585. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2586. win += cd * coef(a,as);
  2587. else
  2588. los += cd * coef(a,as);
  2589. }
  2590. }
  2591. return Math.round(100*win/(win+los));
  2592. }
  2593.  
  2594. function chanceCritique(a,d,ba,bd)
  2595. {
  2596. var win = 0;
  2597. var los = 0;
  2598. if(ba==null)
  2599. ba=0;
  2600. if(bd==null)
  2601. bd=0;
  2602. if(a+ba>2*(6*d+bd))
  2603. return 100;
  2604. if(6*a+ba<2*(d+bd))
  2605. return 0;
  2606. for(var ds=d;ds<=6*d;ds++)
  2607. {
  2608. var cd = coef(d,ds);
  2609. for(var as=a;as<=6*a;as++)
  2610. {
  2611. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2612. win += cd * coef(a,as);
  2613. else
  2614. los += cd * coef(a,as);
  2615. }
  2616. }
  2617. return Math.round(100*win/(win+los));
  2618. }
  2619.  
  2620. /***********************************************
  2621. Analyse tactique
  2622. ***********************************************/
  2623.  
  2624. function getTexteAnalyse(modificateur,chiffre)
  2625. {
  2626. if(chiffre==0)
  2627. return chiffre;
  2628. return modificateur+chiffre;
  2629. }
  2630.  
  2631. // rend le HTML pour le tableau de la "calculette"
  2632. function getAnalyseTactique(id,nom)
  2633. {
  2634. var donneesMonstre = listeCDM[id];
  2635. var needAutres=false;
  2636. var i;
  2637. if(donneesMonstre == null)
  2638. return;
  2639. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2640. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2641. if(array==null)
  2642. return "";
  2643. 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>";
  2644. for(i=0;i<array.length;i++)
  2645. {
  2646. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2647. {
  2648. needAutres=true;
  2649. break;
  2650. }
  2651. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2652. 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>";
  2653. else if(i==0) // attaque du monstre sur le Trõll => italique
  2654. 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>";
  2655. else // autre, pas de décoration
  2656. 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>";
  2657. }
  2658. if(needAutres)
  2659. {
  2660. if(i==array.length-1)
  2661. 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>";
  2662. else if(i==1)
  2663. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2664. else
  2665. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2666. }
  2667. return str+"</table>";
  2668. }
  2669.  
  2670. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2671. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2672. function analyseTactique(donneesMonstre,nom) {
  2673. try
  2674. {
  2675. var listeAttaques = [];
  2676. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2677. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2678. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2679. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2680. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2681. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2682. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2683. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2684. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2685. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2686. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2687. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2688. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2689. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2690. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2691. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2692. var modificateurEsquive = '';
  2693. var modificateurArmure = '';
  2694. var modificateurMagie = '';
  2695. var modificateurEsquiveM = '';
  2696. var modificateurArmureM = '';
  2697. var pasDeSR=false;
  2698. var esqM,attM,armM,degM;
  2699. 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)
  2700. return null;
  2701. var td = document.createElement('td')
  2702. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2703. var esqM = 0;
  2704. try
  2705. {
  2706. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2707. }
  2708. catch(e)
  2709. {
  2710. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  2711. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2712. modificateurEsquive = '<';
  2713. modificateurArmure = '<';
  2714. modificateurMagie = '<';
  2715. }
  2716. td.innerHTML = bbcode(donneesMonstre[3]);
  2717. var attM = 0;
  2718. try
  2719. {
  2720. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2721. }
  2722. catch(e)
  2723. {
  2724. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  2725. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2726. modificateurEsquiveM = '>';
  2727. modificateurArmureM = '>';
  2728. }
  2729. td.innerHTML = bbcode(donneesMonstre[5]);
  2730. var degM = 0;
  2731. try
  2732. {
  2733. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2734. }
  2735. catch(e)
  2736. {
  2737. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  2738. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2739. modificateurArmureM = '>';
  2740. }
  2741. td.innerHTML = bbcode(donneesMonstre[7]);
  2742. var armM = 0;
  2743. try
  2744. {
  2745. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2746. }
  2747. catch(e)
  2748. {
  2749. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  2750. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2751. modificateurArmure = '<';
  2752. }
  2753. var coeffSeuil = 0.95;
  2754. try
  2755. {
  2756. td.innerHTML = bbcode(donneesMonstre[9]);
  2757. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  2758. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2759. var v = (rm / mm);
  2760. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2761. coeffSeuil = (200-seuil)/200;
  2762. }
  2763. catch(e)
  2764. {
  2765. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  2766. modificateurMagie = '<';
  2767. pasDeSR = true;
  2768. }
  2769. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2770. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2771. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2772. // roule debug
  2773. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2774. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2775. 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);
  2776. //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);
  2777. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2778. if(getSortComp("Vampirisme")>0)
  2779. {
  2780. var pour = getSortComp("Vampirisme");
  2781. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2782. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2783. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2784. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2785. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2786. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2787. }
  2788. if(getSortComp("Siphon des âmes")>0)
  2789. {
  2790. var pour = getSortComp("Siphon des âmes");
  2791. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2792. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2793. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2794. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2795. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2796. }
  2797. if(getSortComp("Botte Secrète")>0)
  2798. {
  2799. var pour = getSortComp("Botte Secrète");
  2800. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2801. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2802. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2803. 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;
  2804. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2805. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2806. }
  2807. if(getSortComp("Rafale Psychique")>0)
  2808. {
  2809. var pour = getSortComp("Rafale Psychique");
  2810. chanceDEsquiveParfaite = 0;
  2811. chanceDeTouche = Math.round(100*pour/100);
  2812. chanceDeCritique = Math.round(0*pour/100);
  2813. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2814. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2815. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2816. }
  2817. if(getSortComp("Explosion")>0)
  2818. {
  2819. var pour = getSortComp("Explosion");
  2820. chanceDEsquiveParfaite = 0;
  2821. chanceDeTouche = Math.round(100*pour/100);
  2822. chanceDeCritique = Math.round(0*pour/100);
  2823. 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;
  2824. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2825. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2826. }
  2827. if(getSortComp("Projectile Magique")>0)
  2828. {
  2829. var pour = getSortComp("Projectile Magique");
  2830. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2831. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2832. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2833. // distance troll - monstre
  2834. 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;
  2835. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2836. if (donneesMonstre['iTR'] !== undefined) {
  2837. var dist = getMonstreDistance(donneesMonstre['iTR']+1);
  2838. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  2839. var portee = getPortee__Profil(vue+vue_bm);
  2840. if (dist <= portee) {
  2841. degats += 2 * (portee-dist);
  2842. } else {
  2843. degats += ' (plus bonus de portée)';
  2844. }
  2845. debugMZ('analyseTactique, iTR= ' + donneesMonstre['iTR'] + ', dist=' + dist + ', porteePM=' + portee);
  2846. } else {
  2847. degats += ' (plus bonus de portée)';
  2848. }
  2849. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2850. }
  2851. if(getSortComp("Frénésie")>0)
  2852. {
  2853. var pour = getSortComp("Frénésie");
  2854. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2855. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2856. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2857. 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;
  2858. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2859. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2860. }
  2861. if(getSortComp("Charger")>0)
  2862. {
  2863. var pour = getSortComp("Charger");
  2864. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2865. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2866. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2867. 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;
  2868. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2869. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2870. }
  2871. if(getSortComp("Griffe du Sorcier")>0)
  2872. {
  2873. var pour = getSortComp("Griffe du Sorcier");
  2874. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2875. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2876. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2877. 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;
  2878. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2879. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2880. }
  2881. if(getSortComp("Attaque Précise",1)>0)
  2882. {
  2883. var niveau = 5;
  2884. var oldPour = 0;
  2885. var chanceDEsquiveParfaite = 0;
  2886. var chanceDeTouche = 0;
  2887. var chanceDeCritique = 0;
  2888. degats = 0;
  2889. while(niveau>0)
  2890. {
  2891. var pour = getSortComp("Attaque Précise",niveau);
  2892. if(pour>oldPour)
  2893. {
  2894. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2895. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2896. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2897. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2898. chanceDeTouche += chanceDeToucheNiveau;
  2899. chanceDeCritique += chanceDeCritiqueNiveau;
  2900. 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);
  2901. oldPour = pour;
  2902. }
  2903. niveau--;
  2904. }
  2905. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2906. listeAttaques.push(new Array("Attaque Précise",chanceDEsquiveParfaite,Math.round(chanceDeTouche*100)/100,Math.round(chanceDeCritique*100)/100,Math.round(degats*100)/100,modificateurEsquive,modificateurArmure));
  2907. }
  2908. if(getSortComp("Coup de Butoir",1)>0)
  2909. {
  2910. var niveau = 5;
  2911. var oldPour =0;
  2912. var chanceDEsquiveParfaite = 0;
  2913. var chanceDeTouche=0;
  2914. var chanceDeCritique=0;
  2915. degats=0;
  2916. while(niveau>0)
  2917. {
  2918. var pour = getSortComp("Coup de Butoir",niveau);
  2919. if(pour>oldPour)
  2920. {
  2921. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2922. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2923. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2924. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2925. chanceDeTouche += chanceDeToucheNiveau;
  2926. chanceDeCritique += chanceDeCritiqueNiveau;
  2927. 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);
  2928. oldPour = pour;
  2929. }
  2930. niveau--;
  2931. }
  2932. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2933. 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));
  2934. }
  2935. 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;});
  2936. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2937. {
  2938. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2939. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2940. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2941. }
  2942. else
  2943. {
  2944. chanceDEsquiveParfaite = 0;
  2945. chanceDeTouche = 100;
  2946. chanceDeCritique = 0;
  2947. }
  2948. 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;
  2949.  
  2950. 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));
  2951. return listeAttaques;
  2952. }
  2953. catch(e) { window.alert(e);}
  2954. }
  2955.  
  2956. // x~~x marque pour s'y retrouver sous l'éditeur
  2957.  
  2958. /*
  2959. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2960. * published under GNU License v2.
  2961. *
  2962. * Patch :
  2963. * gestion des missions terminées
  2964. */
  2965. // x~x mission_liste
  2966.  
  2967. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2968. try {
  2969. var titresMimis = document.evaluate(
  2970. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2971. document, null, 7, null
  2972. );
  2973. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2974. } catch(e) {
  2975. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2976. return;
  2977. }
  2978. var enCours = {};
  2979. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2980. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2981. enCours[num] = true;
  2982. }
  2983. for(var numMimi in obMissions) {
  2984. if(!enCours[numMimi]) {
  2985. delete obMissions[numMimi];
  2986. }
  2987. }
  2988. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2989. }
  2990.  
  2991. function do_mission_liste() {
  2992. checkLesMimis();
  2993. }
  2994.  
  2995. /*******************************************************************************
  2996. * This file is part of Mountyzilla. *
  2997. * *
  2998. * Mountyzilla is free software; you can redistribute it and/or modify *
  2999. * it under the terms of the GNU General Public License as published by *
  3000. * the Free Software Foundation; either version 2 of the License, or *
  3001. * (at your option) any later version. *
  3002. * *
  3003. * Mountyzilla is distributed in the hope that it will be useful, *
  3004. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3005. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3006. * GNU General Public License for more details. *
  3007. * *
  3008. * You should have received a copy of the GNU General Public License *
  3009. * along with Mountyzilla; if not, write to the Free Software *
  3010. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3011. *******************************************************************************/
  3012.  
  3013. // x~x actions
  3014.  
  3015. /* TODO
  3016. * getLvl pour Explo, Rotobaffe et cie
  3017. */
  3018.  
  3019.  
  3020.  
  3021. /* Page de combat */
  3022.  
  3023. function getLevel() {
  3024. var divList = document.getElementsByTagName('div');
  3025. if(divList.length <= 2)
  3026. return;
  3027. // On essaie de voir si cette action était une attaque
  3028. var pList = document.getElementsByTagName('p');
  3029. var nomM = '';
  3030. // Modification pour Frénésie by TetDure
  3031. var numAtt = 0;
  3032. for (var i = 0; i < pList.length; i++) {
  3033. if(pList[i].firstChild) {
  3034. nomM = pList[i].firstChild.nodeValue;
  3035. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3036. numAtt++;
  3037. }
  3038. }
  3039. if(nomM == '')
  3040. return;
  3041. // Si c'est une attaque normale, un seul PX
  3042. var comPX = 1;
  3043. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3044. comPX++;
  3045.  
  3046. // Extraction des infos du monstre attaqué
  3047. var idM;
  3048. var male;
  3049. if(nomM.slice(20, 21) == 'e') {
  3050. male = false;
  3051. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3052. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3053. }
  3054. else {
  3055. male = true;
  3056. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3057. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3058. }
  3059. if(idM == '')
  3060. return;
  3061. var bList = document.getElementsByTagName('b');
  3062. var niveau = '';
  3063. for (var i = 0; i < bList.length; i++) {
  3064. var b = bList[i];
  3065. if(b.childNodes[0].nodeValue != "TUÉ")
  3066. continue;
  3067. var nbPX = "";
  3068. for (i++; i < bList.length; i++) {
  3069. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3070. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3071. return;
  3072. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3073. nbPX = bList[i].childNodes[0].nodeValue;
  3074. break;
  3075. }
  3076. }
  3077. if(nbPX == '')
  3078. return;
  3079. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3080. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3081. if(!nbPX)
  3082. nbPX = 0;
  3083. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3084. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3085. if(comPX > nbPX) {
  3086. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3087. niveau = "";
  3088. } else if(Math.floor(niveau) == niveau) {
  3089. chaine += niveau + ".";
  3090. } else {
  3091. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3092. niveau = "";
  3093. }
  3094. insertBr(b.nextSibling.nextSibling.nextSibling);
  3095. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3096. }
  3097.  
  3098. if(niveau != '') {
  3099. var button = insertButtonCdm('as_Action');
  3100. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3101. + escape(nomM) + "&niveau=" + escape(niveau)
  3102. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3103. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3104. }
  3105. }
  3106.  
  3107.  
  3108. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3109.  
  3110. function insertInfoMagie(node, intitule, magie) {
  3111. if(node.nextSibling) {
  3112. node = node.nextSibling;
  3113. insertBr(node);
  3114. insertText(node, intitule);
  3115. insertText(node, magie, true);
  3116. } else {
  3117. node = node.parentNode;
  3118. appendBr(node);
  3119. appendText(node, intitule);
  3120. appendText(node, magie, true);
  3121. }
  3122. }
  3123.  
  3124. function getMM(sr) {
  3125. if(rmTroll<=0) {
  3126. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3127. }
  3128. sr = Number(sr.match(/\d+/)[0]);
  3129. if(sr==10) {
  3130. return '\u2265 '+5*rmTroll;
  3131. }
  3132. if(sr<=50) {
  3133. return Math.round(50*rmTroll/sr);
  3134. }
  3135. if(sr<90) {
  3136. return Math.round((100-sr)*rmTroll/50);
  3137. }
  3138. return '\u2264 '+Math.round(rmTroll/5);
  3139. }
  3140.  
  3141. function traiteMM() {
  3142. var node = document.evaluate(
  3143. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3144. document, null, 9, null).singleNodeValue;
  3145. if(node) {
  3146. var mm = getMM(node.nodeValue);
  3147. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3148. } else {
  3149. var node = document.evaluate(
  3150. "//p/text()[contains(., 'Seuil de Résistance')]",
  3151. document, null, 9, null).singleNodeValue;
  3152. if(!node) {
  3153. return;
  3154. }
  3155. var mm = getMM(node.nodeValue);
  3156. node = node.nextSibling.nextSibling;
  3157. }
  3158. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3159. }
  3160.  
  3161. function getRM(sr) {
  3162. if(mmTroll<=0) {
  3163. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3164. }
  3165. sr = Number(sr.match(/\d+/)[0]);
  3166. if(sr==10) {
  3167. return '\u2264 '+Math.round(mmTroll/5);
  3168. }
  3169. if(sr<=50) {
  3170. return Math.round(sr*mmTroll/50);
  3171. }
  3172. if(sr<90) {
  3173. return Math.round(50*mmTroll/(100-sr));
  3174. }
  3175. return '\u2265 '+5*mmTroll;
  3176. }
  3177.  
  3178. function traiteRM() {
  3179. var nodes = document.evaluate(
  3180. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3181. document, null, 7, null);
  3182. if(nodes.snapshotLength==0) {
  3183. return;
  3184. }
  3185. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3186. var node = nodes.snapshotItem(i);
  3187. var rm = getRM(node.nodeValue);
  3188. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3189. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3190. }
  3191. }
  3192.  
  3193.  
  3194. /* Fonction stats IdT par Raistlin */
  3195. /*function getIdt() {
  3196. if(MY_getValue("SEND_IDT") == "non")
  3197. return false;
  3198. var regExpBeginning = /^\s+/;
  3199. var regExpEnd = /\s+$/;
  3200.  
  3201. var nomIdt = document.evaluate(
  3202. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3203. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3204. if(!nomIdt)
  3205. return false;
  3206.  
  3207. var caracIdt;
  3208. if(nomIdt.indexOf("Malédiction !") != -1) {
  3209. caracIdt = "";
  3210. nomIdt = "Mission maudite";
  3211. } else {
  3212. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3213. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3214. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3215. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3216. }
  3217. FF_XMLHttpRequest({
  3218. method: 'GET',
  3219. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3220. headers : {
  3221. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3222. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3223. }
  3224. });
  3225. return true;
  3226. }*/
  3227.  
  3228.  
  3229. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3230.  
  3231. function confirmeDecalage() {
  3232. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3233. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3234. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3235. var newDLA = new Date( oldDLA );
  3236. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3237. return window.confirm(
  3238. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3239. +'\nConfirmez-vous ce décalage ?'
  3240. );
  3241. }
  3242.  
  3243. function newsubmitDLA(evt) {
  3244. evt.stopPropagation();
  3245. evt.preventDefault();
  3246. if(confirmeDecalage()) {
  3247. this.submit();
  3248. }
  3249. }
  3250.  
  3251. function changeActionDecalage() {
  3252. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3253. return;
  3254. }
  3255. try {
  3256. // On récupère le contenu du script JS MH de calcul du décalage
  3257. var scriptTxt = document.evaluate(
  3258. ".//script[ not(@src) ]",
  3259. document, null, 9, null
  3260. ).singleNodeValue.textContent;
  3261. // On en extrait la DLA courante
  3262. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3263. scriptTxt = scriptTxt.split('\n')[0];
  3264. var nbs = scriptTxt.match(/\d+/g);
  3265. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3266. } catch(e) {
  3267. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3268. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3269. return;
  3270. }
  3271. var form = document.getElementsByName('ActionForm')[0];
  3272. if(form) {
  3273. form.addEventListener('submit', newsubmitDLA, true);
  3274. } else {
  3275. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3276. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3277. }
  3278. }
  3279.  
  3280. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3281.  
  3282. function prochainMundi() {
  3283. try {
  3284. var node;
  3285. node = document.evaluate(
  3286. "//div[@class='dateAction']/b",
  3287. document, null, 9, null
  3288. ).singleNodeValue;
  3289. if (document.evaluate) {
  3290. } else { // repli en JQuery
  3291. //node = $(
  3292. }
  3293. } catch(e) {
  3294. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3295. return;
  3296. }
  3297. if(!node) { return; }
  3298.  
  3299. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3300. var jour = longueurMois+1-getNumber(node.textContent);
  3301. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3302. var txt = '[Prochain Mundidey ';
  3303. if(jour>1) {
  3304. txt += 'dans '+jour+' jours]';
  3305. } else {
  3306. txt += 'demain]';
  3307. }
  3308. insertText(node.parentNode.nextSibling,txt,true);
  3309. }
  3310.  
  3311.  
  3312. /* Fonction principale */
  3313.  
  3314. function dispatch() {
  3315. if(isPage('MH_Play/Play_action')) {
  3316. prochainMundi();
  3317. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3318. var oldDLA;
  3319. changeActionDecalage();
  3320. } else if(isPage('MH_Play/Actions')) {
  3321. if(document.evaluate(
  3322. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3323. document, null, 2, null
  3324. ).stringValue) {
  3325. traiteMM();
  3326. } else if(document.evaluate(
  3327. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3328. document, null, 2, null
  3329. ).stringValue) {
  3330. //getIdt();
  3331. traiteRM();
  3332. } /*else {
  3333. // Est censé se lancer sur quoi *précisément* ?
  3334. traiteRM();
  3335. getLevel();
  3336. }*/
  3337. } else {
  3338. /* Traitement des messages du bot */
  3339. var messageTitle = document.evaluate(
  3340. "//form/table/tbody/tr[1]/td[1]/"
  3341. +"descendant::text()[contains(.,'[MountyHall]')]",
  3342. document, null, 2, null
  3343. ).stringValue;
  3344. if(messageTitle.indexOf('Attaquant') != -1 &&
  3345. messageTitle.indexOf('sur') != -1) {
  3346. getLevel();
  3347. traiteRM();
  3348. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3349. messageTitle.indexOf('Défenseur') != -1) {
  3350. traiteMM();
  3351. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3352. // à replacer avec Attaque après révision getLvl :
  3353. messageTitle.indexOf('Explosion') != -1 ||
  3354. messageTitle.indexOf('Insulte') != -1) {
  3355. traiteRM();
  3356. }
  3357. }
  3358. }
  3359.  
  3360. function do_actions() {
  3361. start_script(31);
  3362. dispatch();
  3363. displayScriptTime();
  3364. }
  3365.  
  3366. /*********************************************************************************
  3367. * This file is part of Mountyzilla. *
  3368. * *
  3369. * Mountyzilla is free software; you can redistribute it and/or modify *
  3370. * it under the terms of the GNU General Public License as published by *
  3371. * the Free Software Foundation; either version 2 of the License, or *
  3372. * (at your option) any later version. *
  3373. * *
  3374. * Mountyzilla is distributed in the hope that it will be useful, *
  3375. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3376. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3377. * GNU General Public License for more details. *
  3378. * *
  3379. * You should have received a copy of the GNU General Public License *
  3380. * along with Mountyzilla; if not, write to the Free Software *
  3381. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3382. *********************************************************************************/
  3383.  
  3384. // x~x pre-enchant
  3385.  
  3386. /* 2013-08-19 : correction auto syntaxe alert */
  3387.  
  3388. var combobox=null;
  3389.  
  3390. function changeObject()
  3391. {
  3392. if(!combobox)
  3393. return ;
  3394. var id = combobox.options[combobox.selectedIndex].value;
  3395. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3396. if(!id || id=="")
  3397. {
  3398. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3399. return;
  3400. }
  3401. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3402. }
  3403.  
  3404. function treatePreEnchantement() {
  3405. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3406. if(!input || input.getAttribute("type")=="hidden")
  3407. {
  3408. return false;
  3409. }
  3410. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3411. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3412. if(!combobox)
  3413. {
  3414. return true;
  3415. }
  3416. combobox.addEventListener('change', changeObject, true);
  3417. return true;
  3418. }
  3419.  
  3420. function treateEnchantement() {
  3421. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3422. if(!input || input.getAttribute("type")!="hidden")
  3423. {
  3424. return false;
  3425. }
  3426. var idEquipement = input.getAttribute("value");
  3427. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3428. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3429. if(enchanteur && enchanteur != null)
  3430. return true;
  3431. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3432. if(!input || input.getAttribute("type")!="hidden")
  3433. {
  3434. return false;
  3435. }
  3436. var idEnchanteur = input.getAttribute("value");
  3437. var nodes = document.evaluate(
  3438. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3439. if (nodes.snapshotLength != 3)
  3440. return;
  3441. for(var i=0;i<3;i++)
  3442. {
  3443. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3444. texte = texte.replace(" d'une "," d'un ");
  3445. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3446. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3447. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3448. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3449. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3450. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3451. }
  3452. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3453. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3454. var liste = MY_getValue(numTroll+".enchantement.liste");
  3455. if(!liste || liste=="")
  3456. {
  3457. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3458. }
  3459. else
  3460. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3461. }
  3462.  
  3463. function do_pre_enchant() {
  3464. start_script(60);
  3465. if(!treatePreEnchantement())
  3466. treateEnchantement();
  3467. displayScriptTime();
  3468. }
  3469.  
  3470. /*********************************************************************************
  3471. * This file is part of Mountyzilla. *
  3472. * *
  3473. * Mountyzilla is free software; you can redistribute it and/or modify *
  3474. * it under the terms of the GNU General Public License as published by *
  3475. * the Free Software Foundation; either version 2 of the License, or *
  3476. * (at your option) any later version. *
  3477. * *
  3478. * Mountyzilla is distributed in the hope that it will be useful, *
  3479. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3480. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3481. * GNU General Public License for more details. *
  3482. * *
  3483. * You should have received a copy of the GNU General Public License *
  3484. * along with Mountyzilla; if not, write to the Free Software *
  3485. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3486. *********************************************************************************/
  3487.  
  3488. // x~x enchant
  3489.  
  3490. /* 2013-08-19 : correction auto syntaxe alert */
  3491.  
  3492. function treateEnchantement() {
  3493. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3494. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3495. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3496. return;
  3497. var tab = infoEquipement.split(";");
  3498. if(tab.length<2)
  3499. return;
  3500. var idEquipement = tab[0];
  3501. var nomEquipement = tab[1];
  3502. for(var i=2;i<tab.length;i++)
  3503. nomEquipement += ";"+tab[i];
  3504. var nodes = document.evaluate(
  3505. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3506. if (nodes.snapshotLength != 3)
  3507. return;
  3508. for(var i=0;i<3;i++)
  3509. {
  3510. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3511. texte = texte.replace(" d'une "," d'un ");
  3512. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3513. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3514. monstre = monstre.replace(/ Géante?/,"");
  3515. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3516. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3517. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3518. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3519. }
  3520. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3521. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3522. var liste = MY_getValue(numTroll+".enchantement.liste");
  3523. if(!liste || liste=="")
  3524. {
  3525. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3526. }
  3527. else
  3528. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3529. }
  3530.  
  3531. function do_enchant() {
  3532. start_script(60);
  3533.  
  3534. treateEnchantement();
  3535. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3536. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3537. displayScriptTime();
  3538. }
  3539.  
  3540. /*********************************************************************************
  3541. * This file is part of Mountyzilla. *
  3542. * *
  3543. * Mountyzilla is free software; you can redistribute it and/or modify *
  3544. * it under the terms of the GNU General Public License as published by *
  3545. * the Free Software Foundation; either version 2 of the License, or *
  3546. * (at your option) any later version. *
  3547. * *
  3548. * Mountyzilla is distributed in the hope that it will be useful, *
  3549. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3550. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3551. * GNU General Public License for more details. *
  3552. * *
  3553. * You should have received a copy of the GNU General Public License *
  3554. * along with Mountyzilla; if not, write to the Free Software *
  3555. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3556. *********************************************************************************/
  3557.  
  3558. // x~x myevent
  3559.  
  3560. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3561. function do_myevent() {
  3562. }
  3563.  
  3564. /*********************************************************************************
  3565. * This file is part of Mountyzilla. *
  3566. * *
  3567. * Mountyzilla is free software; you can redistribute it and/or modify *
  3568. * it under the terms of the GNU General Public License as published by *
  3569. * the Free Software Foundation; either version 2 of the License, or *
  3570. * (at your option) any later version. *
  3571. * *
  3572. * Mountyzilla is distributed in the hope that it will be useful, *
  3573. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3574. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3575. * GNU General Public License for more details. *
  3576. * *
  3577. * You should have received a copy of the GNU General Public License *
  3578. * along with Mountyzilla; if not, write to the Free Software *
  3579. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3580. *********************************************************************************/
  3581.  
  3582. // x~x malus
  3583.  
  3584. /* v1.4 - 2014-01-06
  3585. * - Gestion des sorts double composante
  3586. * v1.4.1 - 2014-01-22
  3587. * - Correction décumul
  3588. * TODO
  3589. * - Identifier la position de "PV" dans l'ordre MH
  3590. */
  3591.  
  3592. var listeBM;
  3593.  
  3594.  
  3595. /* [functions] Utilitaires */
  3596.  
  3597. function decumul(bmt,nbr) {
  3598. var bmr;
  3599. if(!nbr || nbr<2) bmr = bmt;
  3600. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3601. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3602. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3603. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3604. else bmr = parseInt(0.1*bmt);
  3605. if(bmt<0) return Math.min(-1,bmr);
  3606. return Math.max(1,bmr);
  3607. }
  3608.  
  3609. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3610. // Roule 23/11/2016 ajout PV
  3611. switch( a ) {
  3612. case 'ATT':
  3613. return -1;
  3614. case 'ESQ':
  3615. if(b=='ATT') return 1;
  3616. return -1;
  3617. case 'DEG':
  3618. switch( b ) {
  3619. case 'ATT':
  3620. case 'ESQ':
  3621. return 1;
  3622. default:
  3623. return -1;
  3624. }
  3625. case 'REG':
  3626. switch( b ) {
  3627. case 'ATT':
  3628. case 'ESQ':
  3629. case 'DEG':
  3630. return 1;
  3631. default:
  3632. return -1;
  3633. }
  3634. case 'Vue':
  3635. switch( b ) {
  3636. case 'ATT':
  3637. case 'ESQ':
  3638. case 'DEG':
  3639. case 'REG':
  3640. return 1;
  3641. default:
  3642. return -1;
  3643. }
  3644. case 'TOUR':
  3645. switch( b ) {
  3646. case 'ATT':
  3647. case 'ESQ':
  3648. case 'DEG':
  3649. case 'REG':
  3650. case 'Vue':
  3651. return 1;
  3652. default:
  3653. return -1;
  3654. }
  3655. case 'PV':
  3656. switch( b ) {
  3657. case 'ATT':
  3658. case 'ESQ':
  3659. case 'DEG':
  3660. case 'REG':
  3661. case 'Vue':
  3662. case 'TOUR':
  3663. return 1;
  3664. default:
  3665. return -1;
  3666. }
  3667. case 'Armure':
  3668. switch( b ) {
  3669. case 'ATT':
  3670. case 'ESQ':
  3671. case 'DEG':
  3672. case 'REG':
  3673. case 'Vue':
  3674. case 'TOUR':
  3675. case 'PV':
  3676. return 1;
  3677. default:
  3678. return -1;
  3679. }
  3680. case 'RM':
  3681. switch( b ) {
  3682. case 'ATT':
  3683. case 'ESQ':
  3684. case 'DEG':
  3685. case 'REG':
  3686. case 'Vue':
  3687. case 'TOUR':
  3688. case 'PV':
  3689. case 'Armure':
  3690. return 1;
  3691. default:
  3692. return -1;
  3693. }
  3694. case 'MM':
  3695. switch( b ) {
  3696. case 'ATT':
  3697. case 'ESQ':
  3698. case 'DEG':
  3699. case 'REG':
  3700. case 'Vue':
  3701. case 'TOUR':
  3702. case 'PV':
  3703. case 'Armure':
  3704. case 'RM':
  3705. return 1;
  3706. default:
  3707. return -1;
  3708. }
  3709. case 'Concentration':
  3710. switch( b ) {
  3711. case 'ATT':
  3712. case 'ESQ':
  3713. case 'DEG':
  3714. case 'REG':
  3715. case 'Vue':
  3716. case 'TOUR':
  3717. case 'PV':
  3718. case 'Armure':
  3719. case 'RM':
  3720. case 'MM':
  3721. return 1;
  3722. default:
  3723. return -1;
  3724. }
  3725. case 'Fatigue':
  3726. switch( b ) {
  3727. case 'ATT':
  3728. case 'ESQ':
  3729. case 'DEG':
  3730. case 'REG':
  3731. case 'Vue':
  3732. case 'TOUR':
  3733. case 'PV':
  3734. case 'Armure':
  3735. case 'RM':
  3736. case 'MM':
  3737. case 'Concentration':
  3738. return 1;
  3739. default:
  3740. return -1;
  3741. }
  3742. case "Dés d'attaque":
  3743. switch( b ) {
  3744. case 'ATT':
  3745. case 'ESQ':
  3746. case 'DEG':
  3747. case 'REG':
  3748. case 'Vue':
  3749. case 'TOUR':
  3750. case 'PV':
  3751. case 'Armure':
  3752. case 'RM':
  3753. case 'MM':
  3754. case 'Concentration':
  3755. case 'Fatigue':
  3756. return 1;
  3757. default:
  3758. return -1;
  3759. }
  3760. case 'Dés de dégâts':
  3761. switch( b ) {
  3762. case 'ATT':
  3763. case 'ESQ':
  3764. case 'DEG':
  3765. case 'REG':
  3766. case 'Vue':
  3767. case 'TOUR':
  3768. case 'PV':
  3769. case 'Armure':
  3770. case 'RM':
  3771. case 'MM':
  3772. case 'Concentration':
  3773. case 'Fatigue':
  3774. case "Dés d'attaque":
  3775. return 1;
  3776. default:
  3777. return -1;
  3778. }
  3779. default :
  3780. switch( b ) {
  3781. case 'ATT':
  3782. case 'ESQ':
  3783. case 'DEG':
  3784. case 'REG':
  3785. case 'Vue':
  3786. case 'TOUR':
  3787. case 'PV':
  3788. case 'Armure':
  3789. case 'RM':
  3790. case 'MM':
  3791. case 'Concentration':
  3792. case 'Fatigue':
  3793. case "Dés d'attaque":
  3794. case 'Dés de dégâts':
  3795. return 1;
  3796. default:
  3797. return -1;
  3798. }
  3799. }
  3800. }
  3801.  
  3802.  
  3803. /* [functions] Fonctions hide / display */
  3804.  
  3805. function toggleDetailsBM() {
  3806. if(MY_getValue('BMDETAIL')!='false') {
  3807. MY_setValue('BMDETAIL','false');
  3808. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3809. for(var i=0 ; i<trlist.length ; i++)
  3810. trlist[i].style.display = 'none';
  3811. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3812. for(var i=0 ; i<trlist.length ; i++)
  3813. trlist[i].style = '';
  3814. }
  3815. else {
  3816. MY_setValue('BMDETAIL','true');
  3817. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3818. for(var i=0 ; i<trlist.length ; i++)
  3819. trlist[i].style.display = 'none';
  3820. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3821. for(var i=0 ; i<trlist.length ; i++)
  3822. trlist[i].style = '';
  3823. }
  3824. }
  3825.  
  3826. function toggleBMList() {
  3827. if(MY_getValue('BMHIDELIST')=='true') {
  3828. MY_setValue('BMHIDELIST','false');
  3829. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3830. listeBM.snapshotItem(i).style = '';
  3831. document.getElementsByTagName('thead')[0].style = '';
  3832. document.getElementById('trhelp').style = '';
  3833. }
  3834. else {
  3835. MY_setValue('BMHIDELIST','true');
  3836. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3837. listeBM.snapshotItem(i).style.display = 'none';
  3838. document.getElementsByTagName('thead')[0].style.display = 'none';
  3839. document.getElementById('trhelp').style.display = 'none';
  3840. }
  3841. }
  3842.  
  3843. function setDisplayBM() {
  3844. if(!listeBM) return;
  3845. var titre = document.getElementById('titre2');
  3846. if(titre) {
  3847. titre.style.cursor = 'pointer';
  3848. titre.onclick = toggleBMList;
  3849. }
  3850. var tfoot = document.getElementsByTagName('tfoot')[0];
  3851. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3852. tfoot, null, 9, null).singleNodeValue;
  3853. tr.id = 'trhelp';
  3854. if(MY_getValue('BMHIDELIST')=='true') {
  3855. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3856. listeBM.snapshotItem(i).style.display = 'none';
  3857. document.getElementsByTagName('thead')[0].style.display = 'none';
  3858. tr.style.display = 'none';
  3859. }
  3860. }
  3861.  
  3862.  
  3863. /* [functions] Fonction principale */
  3864.  
  3865. function traiteMalus() {
  3866. var mainTab = document.getElementsByTagName('table')[0];
  3867. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3868. if(listeBM.snapshotLength==0) return;
  3869. /* Suppression des BM de fatigue stockés */
  3870. if(MY_getValue(numTroll+'.bm.fatigue'))
  3871. MY_removeValue(numTroll+'.bm.fatigue');
  3872. /* Extraction des données */
  3873. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3874. var nb = 0;
  3875. while(nb<listeBM.snapshotLength) {
  3876. tr = listeBM.snapshotItem(nb); nb++;
  3877. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3878. var phymag = tr.childNodes[9].textContent;
  3879. var duree = tr.childNodes[11].textContent.match(/\d+/);
  3880. if (duree == null) { // Roule 28/01/2018 protection malus Crasc sans durée
  3881. duree = 1;
  3882. } else {
  3883. duree = Number(duree[0]);
  3884. }
  3885. var type = tr.childNodes[3].textContent, nom;
  3886. // si c'est un type à décumul
  3887. /*
  3888. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3889. switch(type) {
  3890. case 'Potion':
  3891. case 'Parchemin':
  3892. case 'Sortilège':
  3893. case 'Capacité Spéciale':
  3894. nom = tr.childNodes[1].textContent+phymag;
  3895. break;
  3896. default:
  3897. nom = 'pasdedecumul';
  3898. }
  3899. */
  3900. nom = tr.childNodes[1].textContent+phymag;
  3901. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3902. nom = 'pasdedecumul';
  3903. uniListe[nb] = {
  3904. 'duree':duree,
  3905. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3906. 'caracs':{}
  3907. }
  3908. for(var i=0 ; i<effetsT.length ; i++) {
  3909. if(effetsT[i].indexOf(':')==-1) continue;
  3910. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3911. // nom = 'pasdedecumul' si pas de décumul
  3912. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3913. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3914. uniListe[nb]['type'] = phymag;
  3915. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3916. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  3917. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  3918. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  3919. uniListe[nb]['caracs'][carac] = bm;
  3920. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  3921. listeDurees[duree] = true;
  3922. }
  3923. } // fin boucle sur les lignes de bonus/malus
  3924. /* Gestion des décumuls et cumuls des durées */
  3925. var toursGeres = [];
  3926. for(var d in listeDurees) toursGeres.push(d);
  3927. toursGeres.sort( function (a,b){return b-a;} );
  3928. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  3929. // pour sauvegarder les bm de fatigue
  3930. var strfat = '';
  3931. // Pour affichage & adpatation à footable.js (statique)
  3932. var thead = document.getElementsByTagName('thead')[0];
  3933. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3934. thead, null, 7, null).snapshotLength;
  3935. var tfoot = document.getElementsByTagName('tfoot')[0];
  3936. for(var i=0 ; i<toursGeres.length ; i++) {
  3937. var tour = toursGeres[i];
  3938. var effetsCeTour = {}; decumulsCeTour = {};
  3939. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3940. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3941. continue;
  3942. var nom = uniListe[nb]['nom'];
  3943. if(nom!='pasdedecumul') {
  3944. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3945. decumulsCeTour[nom]++;
  3946. }
  3947. for(var carac in uniListe[nb]['caracs']) {
  3948. var bm = uniListe[nb]['caracs'][carac];
  3949. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3950. var type = uniListe[nb]['type'];
  3951. if(!effetsCeTour[carac])
  3952. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3953. var thisBm;
  3954. if(nom=='pasdedecumul')
  3955. thisBm = bm;
  3956. else
  3957. thisBm = decumul(bm,decumulsCeTour[nom]);
  3958. effetsCeTour[carac][type] += thisBm;
  3959. 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]);
  3960. } else {
  3961. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3962. var thisBm;
  3963. if(nom=='pasdedecumul' || carac=='Fatigue')
  3964. thisBm = bm;
  3965. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3966. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3967. else
  3968. thisBm = decumul(bm,decumulsCeTour[nom]);
  3969. effetsCeTour[carac] += thisBm;
  3970. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3971. }
  3972. } // fin boucle sur les caractéristiques
  3973. } // fin boucle sur les bonus/malus
  3974. /* Création du bilan du tour */
  3975. var texteD = '', texteS = '';
  3976. var caracGerees = [];
  3977. for(var k in effetsCeTour) caracGerees.push(k);
  3978. caracGerees.sort( triecaracs );
  3979. for(var j=0 ; j<caracGerees.length ; j++) {
  3980. var carac = caracGerees[j], str = '';
  3981. switch( carac ) {
  3982. case 'ATT':
  3983. case 'DEG':
  3984. case 'Armure':
  3985. var phy = effetsCeTour[carac]['Physique'];
  3986. var mag = effetsCeTour[carac]['Magie'];
  3987. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3988. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3989. break;
  3990. case 'TOUR':
  3991. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3992. break;
  3993. case 'Fatigue':
  3994. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3995. case 'PV':
  3996. case 'ESQ':
  3997. case 'REG':
  3998. case 'Vue':
  3999. case 'Voir le Caché':
  4000. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  4001. break;
  4002. default:
  4003. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  4004. }
  4005. if(str) {
  4006. texteD += str;
  4007. texteS += str;
  4008. }
  4009. } // fin boucle sur les caractéristiques
  4010. /* Affichage */
  4011. // Si rien à afficher on passe
  4012. if(!texteD) continue;
  4013. // Si BMM+BMP=0
  4014. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  4015. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  4016. if(MY_getValue('BMDETAIL')=='false')
  4017. tr.style.display = 'none';
  4018. var td = appendTdText(tr,texteD.substring(3));
  4019. td.colSpan = 5-nbHidden;
  4020. var txttour = toursGeres[i]+' Tour';
  4021. if(toursGeres[i]>1) txttour += 's';
  4022. appendTdText(tr,txttour);
  4023. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  4024. if(MY_getValue('BMDETAIL')!='false')
  4025. tr.style.display = 'none';
  4026. td = appendTdText(tr,texteS);
  4027. td.colSpan = 5-nbHidden;
  4028. appendTdText(tr,txttour);
  4029. } // fin boucle sur les tours générés
  4030. /* mise en place toggleDetails */
  4031. tfoot.style.cursor = 'pointer';
  4032. tfoot.onclick = toggleDetailsBM;
  4033. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4034. if(strfat)
  4035. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4036. }
  4037.  
  4038. function do_malus() {
  4039. try {
  4040. start_script();
  4041. traiteMalus();
  4042. setDisplayBM();
  4043. displayScriptTime();
  4044. }
  4045. catch(e) {window.alert(e)};
  4046. }
  4047.  
  4048. /*******************************************************************************
  4049. * This file is part of Mountyzilla. *
  4050. * *
  4051. * Mountyzilla is free software; you can redistribute it and/or modify *
  4052. * it under the terms of the GNU General Public License as published by *
  4053. * the Free Software Foundation; either version 2 of the License, or *
  4054. * (at your option) any later version. *
  4055. * *
  4056. * Mountyzilla is distributed in the hope that it will be useful, *
  4057. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4058. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4059. * GNU General Public License for more details. *
  4060. * *
  4061. * You should have received a copy of the GNU General Public License *
  4062. * along with Mountyzilla; if not, write to the Free Software *
  4063. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4064. *******************************************************************************/
  4065.  
  4066. // x~x mouches
  4067.  
  4068. var mainTab, tr_mouches;
  4069.  
  4070. function initialiseMouches() {
  4071. // Lanceur global
  4072. try {
  4073. mainTab = document.getElementById('mouches');
  4074. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4075. } catch(e) {
  4076. avertissement('Erreur MZ:<br />Consulter la console.');
  4077. window.console.error(traceStack(e, 'mouches'));
  4078. return;
  4079. }
  4080. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4081. setDisplayMouches();
  4082. traiteMouches();
  4083. }
  4084.  
  4085. function setDisplayMouches() {
  4086. // Initialise l'affichage / l'effacement du détail des mouches
  4087. var titre = document.getElementById('titre2');
  4088. if(titre) {
  4089. titre.style.cursor = 'pointer';
  4090. titre.onclick = toggleMouches;
  4091. }
  4092. var tfoot = document.getElementsByTagName('tfoot')[0];
  4093. if(tfoot) {
  4094. tfoot.style.cursor = 'pointer';
  4095. tfoot.onclick = toggleMouches;
  4096. }
  4097. if(MY_getValue('HIDEMOUCHES')=='true') {
  4098. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4099. tr_mouches.snapshotItem(i).style.display = 'none';
  4100. }
  4101. document.getElementsByTagName('thead')[0].style.display = 'none';
  4102. }
  4103. }
  4104.  
  4105. function toggleMouches() {
  4106. // Handler pour afficher / masquer les détasil
  4107. if(MY_getValue('HIDEMOUCHES')=='true') {
  4108. MY_setValue('HIDEMOUCHES','false');
  4109. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4110. tr_mouches.snapshotItem(i).style.display = '';
  4111. }
  4112. document.getElementsByTagName('thead')[0].style.display = '';
  4113. } else {
  4114. MY_setValue('HIDEMOUCHES','true');
  4115. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4116. tr_mouches.snapshotItem(i).style.display = 'none';
  4117. }
  4118. document.getElementsByTagName('thead')[0].style.display = 'none';
  4119. }
  4120. }
  4121.  
  4122. function traiteMouches() {
  4123. // Traitement complet: présence et effets des mouches
  4124. var listeTypes = {}, effetsActifs = {};
  4125. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4126. var tr = tr_mouches.snapshotItem(i);
  4127. // La mouche est-elle présente?
  4128. var etat = document.evaluate(
  4129. './img',
  4130. tr.cells[6], null, 9, null
  4131. ).singleNodeValue.alt;
  4132. if(etat!='La Mouche est là') { continue; }
  4133. // Extraction du type de mouche
  4134. var type = trim(tr.cells[3].textContent);
  4135. if(!listeTypes[type]) {
  4136. listeTypes[type] = 1;
  4137. } else {
  4138. listeTypes[type]++;
  4139. }
  4140. // La mouche a-t-elle un effet?
  4141. var effet = trim(tr.cells[2].textContent);
  4142. if(etat!='La Mouche est là' || !effet) { continue; }
  4143. // Si oui, extraction des effets (multiples pour pogées)
  4144. var caracs = effet.split(' | ');
  4145. for(var j=0 ; j<caracs.length ; j++) {
  4146. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4147. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4148. if(effetsActifs[carac]===void(0)) {
  4149. effetsActifs[carac] = valeur;
  4150. } else {
  4151. effetsActifs[carac] += valeur;
  4152. }
  4153. }
  4154. }
  4155. // Extraction Effet total et affichage des différences à la normale
  4156. var tfoot = document.getElementsByTagName('tfoot')[0];
  4157. if(!tfoot) { return; }
  4158. var nodeTotal = document.evaluate(
  4159. ".//b[contains(./text(),'Effet total')]",
  4160. tfoot, null, 9, null
  4161. ).singleNodeValue.nextSibling;
  4162. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4163. var texte = ' ';
  4164. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4165. if(texte.length>1) { texte += ' | '; }
  4166. var carac = trim(
  4167. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4168. );
  4169. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4170. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4171. texte += effetsTheoriques[i];
  4172. } else {
  4173. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4174. if(carac=='TOUR') { texte += ' min'; }
  4175. texte += '</b>';
  4176. }
  4177. }
  4178. var span = document.createElement('span');
  4179. span.innerHTML = texte;
  4180. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4181. // Affichage des différences du nombre de mouches de chaque type
  4182. var mouchesParType = document.evaluate(
  4183. "./tr/td/ul/li/text()",
  4184. tfoot, null, 7, null
  4185. );
  4186. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4187. var node = mouchesParType.snapshotItem(i);
  4188. var mots = node.nodeValue.split(' ');
  4189. var type = mots.pop();
  4190. if(!listeTypes[type]) {
  4191. node.nodeValue += ' (0 présente)';
  4192. } else if(mots[0]!=listeTypes[type]) {
  4193. if(listeTypes[type]==1) {
  4194. node.nodeValue += ' (1 présente)';
  4195. } else {
  4196. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4197. }
  4198. }
  4199. }
  4200. }
  4201.  
  4202. function do_mouches() {
  4203. start_script();
  4204. initialiseMouches();
  4205. displayScriptTime();
  4206. }
  4207.  
  4208. /*********************************************************************************
  4209. * This file is part of Mountyzilla. *
  4210. * *
  4211. * Mountyzilla is free software; you can redistribute it and/or modify *
  4212. * it under the terms of the GNU General Public License as published by *
  4213. * the Free Software Foundation; either version 2 of the License, or *
  4214. * (at your option) any later version. *
  4215. * *
  4216. * Mountyzilla is distributed in the hope that it will be useful, *
  4217. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4218. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4219. * GNU General Public License for more details. *
  4220. * *
  4221. * You should have received a copy of the GNU General Public License *
  4222. * along with Mountyzilla; if not, write to the Free Software *
  4223. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4224. *********************************************************************************/
  4225.  
  4226. // x~x equipgowap
  4227.  
  4228. var popup;
  4229.  
  4230. function initPopupEquipgowap() {
  4231. popup = document.createElement('div');
  4232. popup.setAttribute('id', 'popup');
  4233. popup.setAttribute('class', 'mh_textbox');
  4234. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4235. 'display: inline; z-index: 3; max-width: 400px;');
  4236. document.body.appendChild(popup);
  4237. }
  4238.  
  4239. function showPopupEquipgowap(evt) {
  4240. var texte = this.getAttribute("texteinfo");
  4241. popup.innerHTML = texte;
  4242. popup.style.left = evt.pageX + 15 + 'px';
  4243. popup.style.top = evt.pageY + 'px';
  4244. popup.style.visibility = "visible";
  4245. }
  4246.  
  4247. function hidePopup() {
  4248. popup.style.visibility = "hidden";
  4249. }
  4250.  
  4251. function createPopupImage(url, text)
  4252. {
  4253. var img = document.createElement('img');
  4254. img.setAttribute('src',url);
  4255. img.setAttribute('align','ABSMIDDLE');
  4256. img.setAttribute("texteinfo",text);
  4257. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4258. img.addEventListener("mouseout", hidePopup,true);
  4259. return img;
  4260. }
  4261.  
  4262. function formateTexte(texte)
  4263. {
  4264. texte = texte.replace(/\n/g,"<br/>");
  4265. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4266. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4267. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4268. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4269. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4270. return texte;
  4271. }
  4272.  
  4273.  
  4274. function treateGowaps() {
  4275. //On récupère les gowaps possédants des composants
  4276. var tbodys = document.evaluate(
  4277. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4278. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4279. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4280. var tbody = tbodys.snapshotItem(j);
  4281. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4282. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4283. if(MY_getValue("NOINFOEM") != "true")
  4284. insertEMInfos(tbody);
  4285. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4286. insertEnchantInfos(tbody);
  4287. }
  4288. }
  4289.  
  4290. function treateChampi() {
  4291. if(MY_getValue("NOINFOEM") == "true")
  4292. return false;
  4293. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4294. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4295. if (nodes.snapshotLength == 0)
  4296. return false;
  4297.  
  4298. for (var i = 0; i < nodes.snapshotLength; i++) {
  4299. var node = nodes.snapshotItem(i);
  4300. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4301. if(texte.indexOf("*")!=-1)
  4302. texte = texte.substring(0,texte.lastIndexOf(" "));
  4303. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4304. if(moisChampi[nomChampi])
  4305. {
  4306. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4307. }
  4308. }
  4309. }
  4310.  
  4311. function do_equipgowap() {
  4312. start_script();
  4313.  
  4314. treateGowaps();
  4315. treateChampi();
  4316. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4317. {
  4318. initPopupEquipgowap();
  4319. computeEnchantementEquipement(createPopupImage,formateTexte);
  4320. }
  4321.  
  4322. displayScriptTime();
  4323. }
  4324.  
  4325. /*********************************************************************************
  4326. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4327. *********************************************************************************/
  4328.  
  4329. // x~x ordresgowap
  4330.  
  4331. // version Roule' janvier 2017
  4332. function MZ_setCarteUnGogoHTML5() {
  4333. // fabriquer la liste des positions successives
  4334. var listeDepl = []; // ce sera un tableau d'objets
  4335. // position courrante
  4336. var eTitle = document.getElementById('titre2');
  4337. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4338. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4339. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4340. , y: parseInt(tabPos[1])
  4341. , n: parseInt(tabPos[2])
  4342. , nom: tabNomID[2]
  4343. , id: tabNomID[1]});
  4344. // déplacements
  4345. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4346. for(var i=0 ; i<lignes.length ; i++) {
  4347. if(lignes[i].className == 'mh_tdpage_fo') {
  4348. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4349. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4350. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4351. }
  4352. }
  4353. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4354. }
  4355.  
  4356. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4357. function MZ_showCarteBottom(listeSuiv) {
  4358. // générer la carte
  4359. var carte = new carte_MZ('cartegogo', listeSuiv);
  4360. // positionner la carte
  4361. var eCarte = carte.getElt();
  4362. eCarte.style.textAlign = 'left';
  4363. eCarte.style.marginTop = '2px';
  4364. var footer = document.getElementById('footer1');
  4365. // Lieu_Teleport.php n'a pas de footer1 :(
  4366. if (!footer) footer = document.getElementById('footer2');
  4367. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4368. else document.body.appendChild(eCarte);
  4369. }
  4370.  
  4371. function MZ_setCarteTousGogoHTML5() {
  4372. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4373. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4374. var suivants = [];
  4375. for (var i=0;i<ligne.length;i++) {
  4376. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4377. var cas = ligne[i].getElementsByTagName("td")[0];
  4378. //if (cas.className == "mh_tdtitre") {
  4379. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4380. var oGogo = {};
  4381. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4382. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4383. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4384. oGogo.x = parseInt(point[1]);
  4385. oGogo.y = parseInt(point[2]);
  4386. oGogo.n = parseInt(point[3]);
  4387. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4388. }
  4389. }
  4390. if (suivants.length == 0) return;
  4391. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4392. }
  4393.  
  4394. function MZ_setCarteTP() {
  4395. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4396. 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);
  4397. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4398. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4399. }
  4400.  
  4401. /* v0.2 by Dab - 2013-08-31
  4402. * - correction acquisition posale initiale
  4403. * - correction tare et affichage mire
  4404. */
  4405.  
  4406. function setCarteGogo() {
  4407. try {
  4408. //var pars = document.getElementsByTagName('p');
  4409. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4410. var eTitle = document.getElementById('titre2');
  4411. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4412. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4413. var serv_img_cible = URL_MZimg + "rep.png";
  4414.  
  4415. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4416. //var lignes = pars[0].getElementsByTagName('tr');
  4417. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4418. var nbpt = 0;
  4419. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4420. for(var i=0 ; i<lignes.length ; i++) {
  4421. if(lignes[i].className == 'mh_tdpage_fo') {
  4422. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4423. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4424. if(point) {
  4425. nbpt++;
  4426. trajet += point[1]+','+point[2]+','+point[3]+',';
  4427. }
  4428. }
  4429. }
  4430. }
  4431. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4432. 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'/>";
  4433. var base = [-229,-5];
  4434. if (nbpt>0) {
  4435. base = [-684,-5];
  4436. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4437. }
  4438. 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;'/>";
  4439.  
  4440. nvdiv += '<map name="coord_trou">'+
  4441. '<area shape="circle" href="#" coords="260,333,3" title="X=5, Y=-49" >'+
  4442. '<area shape="circle" href="#" coords="262,335,3" title="X=6, Y=-50" >'+
  4443. '<area shape="circle" href="#" coords="260,335,3" title="X=5, Y=-50" >'+
  4444. '<area shape="circle" href="#" coords="262,333,3" title="X=6, Y=-49" >'+
  4445. '<area shape="circle" href="#" coords="294,163,3" title="X=22, Y=36" >'+
  4446. '<area shape="circle" href="#" coords="292,163,3" title="X=21, Y=36" >'+
  4447. '<area shape="circle" href="#" coords="294,165,3" title="X=22, Y=35" >'+
  4448. '<area shape="circle" href="#" coords="292,165,3" title="X=21, Y=35" >'+
  4449. '<area shape="circle" href="#" coords="124,217,3" title="X=-63, Y=9" >'+
  4450. '<area shape="circle" href="#" coords="122,217,3" title="X=-64, Y=9" >'+
  4451. '<area shape="circle" href="#" coords="124,219,3" title="X=-63, Y=8" >'+
  4452. '<area shape="circle" href="#" coords="122,219,3" title="X=-64, Y=8" >'+
  4453. '<area shape="circle" href="#" coords="378,95,3" title="X=64, Y=70" >'+
  4454. '<area shape="circle" href="#" coords="146,121,3" title="X=-52, Y=57" >'+
  4455. '<area shape="circle" href="#" coords="346,313,3" title="X=48, Y=-39" >'+
  4456. '<area shape="circle" href="#" coords="310,339,3" title="X=30, Y=-52" >'+
  4457. '<area shape="circle" href="#" coords="274,265,3" title="X=12, Y=-15" >'+
  4458. '<area shape="circle" href="#" coords="360,95,3" title="X=55, Y=70" >'+
  4459. '<area shape="circle" href="#" coords="224,91,3" title="X=-13, Y=72" >'+
  4460. '<area shape="circle" href="#" coords="226,91,3" title="X=-12, Y=72" >'+
  4461. '<area shape="circle" href="#" coords="224,89,3" title="X=-13, Y=73" >'+
  4462. '<area shape="circle" href="#" coords="226,89,3" title="X=-12, Y=73" >'+
  4463. '<area shape="circle" href="#" coords="148,281,3" title="X=-51, Y=-23" >'+
  4464. '<area shape="circle" href="#" coords="150,281,3" title="X=-50, Y=-23" >'+
  4465. '<area shape="circle" href="#" coords="148,279,3" title="X=-51, Y=-22" >'+
  4466. '<area shape="circle" href="#" coords="150,279,3" title="X=-50, Y=-22" >'+
  4467. '<area shape="circle" href="#" coords="130,301,3" title="X=-60, Y=-33" >'+
  4468. '<area shape="circle" href="#" coords="132,301,3" title="X=-59, Y=-33" >'+
  4469. '<area shape="circle" href="#" coords="130,299,3" title="X=-60, Y=-32" >'+
  4470. '<area shape="circle" href="#" coords="132,299,3" title="X=-59, Y=-32" >'+
  4471. '<area shape="circle" href="#" coords="116,311,3" title="X=-67, Y=-38" >'+
  4472. '<area shape="circle" href="#" coords="118,311,3" title="X=-66, Y=-38" >'+
  4473. '<area shape="circle" href="#" coords="116,309,3" title="X=-67, Y=-37" >'+
  4474. '<area shape="circle" href="#" coords="118,309,3" title="X=-66, Y=-37" >'+
  4475. '<area shape="circle" href="#" coords="260,173,3" title="X=5, Y=31" >'+
  4476. '<area shape="circle" href="#" coords="262,173,3" title="X=6, Y=31" >'+
  4477. '<area shape="circle" href="#" coords="260,171,3" title="X=5, Y=32" >'+
  4478. '<area shape="circle" href="#" coords="262,171,3" title="X=6, Y=32" >'+
  4479. '<area shape="circle" href="#" coords="178,339,3" title="X=-36, Y=-52" >'+
  4480. '<area shape="circle" href="#" coords="180,339,3" title="X=-35, Y=-52" >'+
  4481. '<area shape="circle" href="#" coords="178,337,3" title="X=-36, Y=-51" >'+
  4482. '<area shape="circle" href="#" coords="180,337,3" title="X=-35, Y=-51" >'+
  4483. '<area shape="circle" href="#" coords="182,107,3" title="X=-34, Y=64" >'+
  4484. '<area shape="circle" href="#" coords="182,105,3" title="X=-34, Y=65" >'+
  4485. '<area shape="circle" href="#" coords="270,109,3" title="X=10, Y=63" >'+
  4486. '<area shape="circle" href="#" coords="272,109,3" title="X=11, Y=63" >'+
  4487. '<area shape="circle" href="#" coords="270,107,3" title="X=10, Y=64" >'+
  4488. '<area shape="circle" href="#" coords="272,107,3" title="X=11, Y=64" >'+
  4489. '<area shape="circle" href="#" coords="180,207,3" title="X=-35, Y=14" >'+
  4490. '<area shape="circle" href="#" coords="182,207,3" title="X=-34, Y=14" >'+
  4491. '<area shape="circle" href="#" coords="180,205,3" title="X=-35, Y=15" >'+
  4492. '<area shape="circle" href="#" coords="182,205,3" title="X=-34, Y=15" >'+
  4493. '<area shape="circle" href="#" coords="398,173,3" title="X=74, Y=31" >'+
  4494. '<area shape="circle" href="#" coords="400,173,3" title="X=75, Y=31" >'+
  4495. '<area shape="circle" href="#" coords="398,171,3" title="X=74, Y=32" >'+
  4496. '<area shape="circle" href="#" coords="400,171,3" title="X=75, Y=32" >'+
  4497. '<area shape="circle" href="#" coords="342,133,3" title="X=46, Y=51" >'+
  4498. '<area shape="circle" href="#" coords="344,133,3" title="X=47, Y=51" >'+
  4499. '<area shape="circle" href="#" coords="342,131,3" title="X=46, Y=52" >'+
  4500. '<area shape="circle" href="#" coords="344,131,3" title="X=47, Y=52" >'+
  4501. '<area shape="circle" href="#" coords="180,107,3" title="X=-35, Y=64" >'+
  4502. '<area shape="circle" href="#" coords="180,105,3" title="X=-35, Y=65" >'+
  4503. '<area shape="circle" href="#" coords="108,251,3" title="X=-71, Y=-8" >'+
  4504. '<area shape="circle" href="#" coords="110,251,3" title="X=-70, Y=-8" >'+
  4505. '<area shape="circle" href="#" coords="108,249,3" title="X=-71, Y=-7" >'+
  4506. '<area shape="circle" href="#" coords="110,249,3" title="X=-70, Y=-7" >'+
  4507. '<area shape="circle" href="#" coords="346,191,3" title="X=48, Y=22" >'+
  4508. '<area shape="circle" href="#" coords="346,189,3" title="X=48, Y=23" >'+
  4509. '<area shape="circle" href="#" coords="346,187,3" title="X=48, Y=24" >'+
  4510. '<area shape="circle" href="#" coords="346,185,3" title="X=48, Y=25" >'+
  4511. '<area shape="circle" href="#" coords="348,195,3" title="X=49, Y=20" >'+
  4512. '<area shape="circle" href="#" coords="348,193,3" title="X=49, Y=21" >'+
  4513. '<area shape="circle" href="#" coords="348,191,3" title="X=49, Y=22" >'+
  4514. '<area shape="circle" href="#" coords="348,189,3" title="X=49, Y=23" >'+
  4515. '<area shape="circle" href="#" coords="348,187,3" title="X=49, Y=24" >'+
  4516. '<area shape="circle" href="#" coords="348,185,3" title="X=49, Y=25" >'+
  4517. '<area shape="circle" href="#" coords="348,183,3" title="X=49, Y=26" >'+
  4518. '<area shape="circle" href="#" coords="348,181,3" title="X=49, Y=27" >'+
  4519. '<area shape="circle" href="#" coords="350,199,3" title="X=50, Y=18" >'+
  4520. '<area shape="circle" href="#" coords="350,197,3" title="X=50, Y=19" >'+
  4521. '<area shape="circle" href="#" coords="350,195,3" title="X=50, Y=20" >'+
  4522. '<area shape="circle" href="#" coords="350,193,3" title="X=50, Y=21" >'+
  4523. '<area shape="circle" href="#" coords="350,191,3" title="X=50, Y=22" >'+
  4524. '<area shape="circle" href="#" coords="350,189,3" title="X=50, Y=23" >'+
  4525. '<area shape="circle" href="#" coords="350,187,3" title="X=50, Y=24" >'+
  4526. '<area shape="circle" href="#" coords="350,185,3" title="X=50, Y=25" >'+
  4527. '<area shape="circle" href="#" coords="350,183,3" title="X=50, Y=26" >'+
  4528. '<area shape="circle" href="#" coords="350,181,3" title="X=50, Y=27" >'+
  4529. '<area shape="circle" href="#" coords="350,179,3" title="X=50, Y=28" >'+
  4530. '<area shape="circle" href="#" coords="350,177,3" title="X=50, Y=29" >'+
  4531. '<area shape="circle" href="#" coords="352,201,3" title="X=51, Y=17" >'+
  4532. '<area shape="circle" href="#" coords="352,199,3" title="X=51, Y=18" >'+
  4533. '<area shape="circle" href="#" coords="352,197,3" title="X=51, Y=19" >'+
  4534. '<area shape="circle" href="#" coords="352,195,3" title="X=51, Y=20" >'+
  4535. '<area shape="circle" href="#" coords="352,193,3" title="X=51, Y=21" >'+
  4536. '<area shape="circle" href="#" coords="352,191,3" title="X=51, Y=22" >'+
  4537. '<area shape="circle" href="#" coords="352,189,3" title="X=51, Y=23" >'+
  4538. '<area shape="circle" href="#" coords="352,187,3" title="X=51, Y=24" >'+
  4539. '<area shape="circle" href="#" coords="352,185,3" title="X=51, Y=25" >'+
  4540. '<area shape="circle" href="#" coords="352,183,3" title="X=51, Y=26" >'+
  4541. '<area shape="circle" href="#" coords="352,181,3" title="X=51, Y=27" >'+
  4542. '<area shape="circle" href="#" coords="352,179,3" title="X=51, Y=28" >'+
  4543. '<area shape="circle" href="#" coords="352,177,3" title="X=51, Y=29" >'+
  4544. '<area shape="circle" href="#" coords="352,175,3" title="X=51, Y=30" >'+
  4545. '<area shape="circle" href="#" coords="354,201,3" title="X=52, Y=17" >'+
  4546. '<area shape="circle" href="#" coords="354,199,3" title="X=52, Y=18" >'+
  4547. '<area shape="circle" href="#" coords="354,197,3" title="X=52, Y=19" >'+
  4548. '<area shape="circle" href="#" coords="354,195,3" title="X=52, Y=20" >'+
  4549. '<area shape="circle" href="#" coords="354,193,3" title="X=52, Y=21" >'+
  4550. '<area shape="circle" href="#" coords="354,191,3" title="X=52, Y=22" >'+
  4551. '<area shape="circle" href="#" coords="354,189,3" title="X=52, Y=23" >'+
  4552. '<area shape="circle" href="#" coords="354,187,3" title="X=52, Y=24" >'+
  4553. '<area shape="circle" href="#" coords="354,185,3" title="X=52, Y=25" >'+
  4554. '<area shape="circle" href="#" coords="354,183,3" title="X=52, Y=26" >'+
  4555. '<area shape="circle" href="#" coords="354,181,3" title="X=52, Y=27" >'+
  4556. '<area shape="circle" href="#" coords="354,179,3" title="X=52, Y=28" >'+
  4557. '<area shape="circle" href="#" coords="354,177,3" title="X=52, Y=29" >'+
  4558. '<area shape="circle" href="#" coords="354,175,3" title="X=52, Y=30" >'+
  4559. '<area shape="circle" href="#" coords="356,203,3" title="X=53, Y=16" >'+
  4560. '<area shape="circle" href="#" coords="356,201,3" title="X=53, Y=17" >'+
  4561. '<area shape="circle" href="#" coords="356,199,3" title="X=53, Y=18" >'+
  4562. '<area shape="circle" href="#" coords="356,197,3" title="X=53, Y=19" >'+
  4563. '<area shape="circle" href="#" coords="356,195,3" title="X=53, Y=20" >'+
  4564. '<area shape="circle" href="#" coords="356,193,3" title="X=53, Y=21" >'+
  4565. '<area shape="circle" href="#" coords="356,191,3" title="X=53, Y=22" >'+
  4566. '<area shape="circle" href="#" coords="356,189,3" title="X=53, Y=23" >'+
  4567. '<area shape="circle" href="#" coords="356,187,3" title="X=53, Y=24" >'+
  4568. '<area shape="circle" href="#" coords="356,185,3" title="X=53, Y=25" >'+
  4569. '<area shape="circle" href="#" coords="356,183,3" title="X=53, Y=26" >'+
  4570. '<area shape="circle" href="#" coords="356,181,3" title="X=53, Y=27" >'+
  4571. '<area shape="circle" href="#" coords="356,179,3" title="X=53, Y=28" >'+
  4572. '<area shape="circle" href="#" coords="356,177,3" title="X=53, Y=29" >'+
  4573. '<area shape="circle" href="#" coords="356,175,3" title="X=53, Y=30" >'+
  4574. '<area shape="circle" href="#" coords="356,173,3" title="X=53, Y=31" >'+
  4575. '<area shape="circle" href="#" coords="358,203,3" title="X=54, Y=16" >'+
  4576. '<area shape="circle" href="#" coords="358,201,3" title="X=54, Y=17" >'+
  4577. '<area shape="circle" href="#" coords="358,199,3" title="X=54, Y=18" >'+
  4578. '<area shape="circle" href="#" coords="358,197,3" title="X=54, Y=19" >'+
  4579. '<area shape="circle" href="#" coords="358,195,3" title="X=54, Y=20" >'+
  4580. '<area shape="circle" href="#" coords="358,193,3" title="X=54, Y=21" >'+
  4581. '<area shape="circle" href="#" coords="358,191,3" title="X=54, Y=22" >'+
  4582. '<area shape="circle" href="#" coords="358,189,3" title="X=54, Y=23" >'+
  4583. '<area shape="circle" href="#" coords="358,187,3" title="X=54, Y=24" >'+
  4584. '<area shape="circle" href="#" coords="358,185,3" title="X=54, Y=25" >'+
  4585. '<area shape="circle" href="#" coords="358,183,3" title="X=54, Y=26" >'+
  4586. '<area shape="circle" href="#" coords="358,181,3" title="X=54, Y=27" >'+
  4587. '<area shape="circle" href="#" coords="358,179,3" title="X=54, Y=28" >'+
  4588. '<area shape="circle" href="#" coords="358,177,3" title="X=54, Y=29" >'+
  4589. '<area shape="circle" href="#" coords="358,175,3" title="X=54, Y=30" >'+
  4590. '<area shape="circle" href="#" coords="358,173,3" title="X=54, Y=31" >'+
  4591. '<area shape="circle" href="#" coords="360,205,3" title="X=55, Y=15" >'+
  4592. '<area shape="circle" href="#" coords="360,203,3" title="X=55, Y=16" >'+
  4593. '<area shape="circle" href="#" coords="360,201,3" title="X=55, Y=17" >'+
  4594. '<area shape="circle" href="#" coords="360,199,3" title="X=55, Y=18" >'+
  4595. '<area shape="circle" href="#" coords="360,197,3" title="X=55, Y=19" >'+
  4596. '<area shape="circle" href="#" coords="360,195,3" title="X=55, Y=20" >'+
  4597. '<area shape="circle" href="#" coords="360,193,3" title="X=55, Y=21" >'+
  4598. '<area shape="circle" href="#" coords="360,191,3" title="X=55, Y=22" >'+
  4599. '<area shape="circle" href="#" coords="360,189,3" title="X=55, Y=23" >'+
  4600. '<area shape="circle" href="#" coords="360,187,3" title="X=55, Y=24" >'+
  4601. '<area shape="circle" href="#" coords="360,185,3" title="X=55, Y=25" >'+
  4602. '<area shape="circle" href="#" coords="360,183,3" title="X=55, Y=26" >'+
  4603. '<area shape="circle" href="#" coords="360,181,3" title="X=55, Y=27" >'+
  4604. '<area shape="circle" href="#" coords="360,179,3" title="X=55, Y=28" >'+
  4605. '<area shape="circle" href="#" coords="360,177,3" title="X=55, Y=29" >'+
  4606. '<area shape="circle" href="#" coords="360,175,3" title="X=55, Y=30" >'+
  4607. '<area shape="circle" href="#" coords="360,173,3" title="X=55, Y=31" >'+
  4608. '<area shape="circle" href="#" coords="360,171,3" title="X=55, Y=32" >'+
  4609. '<area shape="circle" href="#" coords="362,205,3" title="X=56, Y=15" >'+
  4610. '<area shape="circle" href="#" coords="362,203,3" title="X=56, Y=16" >'+
  4611. '<area shape="circle" href="#" coords="362,201,3" title="X=56, Y=17" >'+
  4612. '<area shape="circle" href="#" coords="362,199,3" title="X=56, Y=18" >'+
  4613. '<area shape="circle" href="#" coords="362,197,3" title="X=56, Y=19" >'+
  4614. '<area shape="circle" href="#" coords="362,195,3" title="X=56, Y=20" >'+
  4615. '<area shape="circle" href="#" coords="362,193,3" title="X=56, Y=21" >'+
  4616. '<area shape="circle" href="#" coords="362,191,3" title="X=56, Y=22" >'+
  4617. '<area shape="circle" href="#" coords="362,189,3" title="X=56, Y=23" >'+
  4618. '<area shape="circle" href="#" coords="362,187,3" title="X=56, Y=24" >'+
  4619. '<area shape="circle" href="#" coords="362,185,3" title="X=56, Y=25" >'+
  4620. '<area shape="circle" href="#" coords="362,183,3" title="X=56, Y=26" >'+
  4621. '<area shape="circle" href="#" coords="362,181,3" title="X=56, Y=27" >'+
  4622. '<area shape="circle" href="#" coords="362,179,3" title="X=56, Y=28" >'+
  4623. '<area shape="circle" href="#" coords="362,177,3" title="X=56, Y=29" >'+
  4624. '<area shape="circle" href="#" coords="362,175,3" title="X=56, Y=30" >'+
  4625. '<area shape="circle" href="#" coords="362,173,3" title="X=56, Y=31" >'+
  4626. '<area shape="circle" href="#" coords="362,171,3" title="X=56, Y=32" >'+
  4627. '<area shape="circle" href="#" coords="364,205,3" title="X=57, Y=15" >'+
  4628. '<area shape="circle" href="#" coords="364,203,3" title="X=57, Y=16" >'+
  4629. '<area shape="circle" href="#" coords="364,201,3" title="X=57, Y=17" >'+
  4630. '<area shape="circle" href="#" coords="364,199,3" title="X=57, Y=18" >'+
  4631. '<area shape="circle" href="#" coords="364,197,3" title="X=57, Y=19" >'+
  4632. '<area shape="circle" href="#" coords="364,195,3" title="X=57, Y=20" >'+
  4633. '<area shape="circle" href="#" coords="364,193,3" title="X=57, Y=21" >'+
  4634. '<area shape="circle" href="#" coords="364,191,3" title="X=57, Y=22" >'+
  4635. '<area shape="circle" href="#" coords="364,189,3" title="X=57, Y=23" >'+
  4636. '<area shape="circle" href="#" coords="364,187,3" title="X=57, Y=24" >'+
  4637. '<area shape="circle" href="#" coords="364,185,3" title="X=57, Y=25" >'+
  4638. '<area shape="circle" href="#" coords="364,183,3" title="X=57, Y=26" >'+
  4639. '<area shape="circle" href="#" coords="364,181,3" title="X=57, Y=27" >'+
  4640. '<area shape="circle" href="#" coords="364,179,3" title="X=57, Y=28" >'+
  4641. '<area shape="circle" href="#" coords="364,177,3" title="X=57, Y=29" >'+
  4642. '<area shape="circle" href="#" coords="364,175,3" title="X=57, Y=30" >'+
  4643. '<area shape="circle" href="#" coords="364,173,3" title="X=57, Y=31" >'+
  4644. '<area shape="circle" href="#" coords="364,171,3" title="X=57, Y=32" >'+
  4645. '<area shape="circle" href="#" coords="366,205,3" title="X=58, Y=15" >'+
  4646. '<area shape="circle" href="#" coords="366,203,3" title="X=58, Y=16" >'+
  4647. '<area shape="circle" href="#" coords="366,201,3" title="X=58, Y=17" >'+
  4648. '<area shape="circle" href="#" coords="366,199,3" title="X=58, Y=18" >'+
  4649. '<area shape="circle" href="#" coords="366,197,3" title="X=58, Y=19" >'+
  4650. '<area shape="circle" href="#" coords="366,195,3" title="X=58, Y=20" >'+
  4651. '<area shape="circle" href="#" coords="366,193,3" title="X=58, Y=21" >'+
  4652. '<area shape="circle" href="#" coords="366,191,3" title="X=58, Y=22" >'+
  4653. '<area shape="circle" href="#" coords="366,189,3" title="X=58, Y=23" >'+
  4654. '<area shape="circle" href="#" coords="366,187,3" title="X=58, Y=24" >'+
  4655. '<area shape="circle" href="#" coords="366,185,3" title="X=58, Y=25" >'+
  4656. '<area shape="circle" href="#" coords="366,183,3" title="X=58, Y=26" >'+
  4657. '<area shape="circle" href="#" coords="366,181,3" title="X=58, Y=27" >'+
  4658. '<area shape="circle" href="#" coords="366,179,3" title="X=58, Y=28" >'+
  4659. '<area shape="circle" href="#" coords="366,177,3" title="X=58, Y=29" >'+
  4660. '<area shape="circle" href="#" coords="366,175,3" title="X=58, Y=30" >'+
  4661. '<area shape="circle" href="#" coords="366,173,3" title="X=58, Y=31" >'+
  4662. '<area shape="circle" href="#" coords="366,171,3" title="X=58, Y=32" >'+
  4663. '<area shape="circle" href="#" coords="368,203,3" title="X=59, Y=16" >'+
  4664. '<area shape="circle" href="#" coords="368,201,3" title="X=59, Y=17" >'+
  4665. '<area shape="circle" href="#" coords="368,199,3" title="X=59, Y=18" >'+
  4666. '<area shape="circle" href="#" coords="368,197,3" title="X=59, Y=19" >'+
  4667. '<area shape="circle" href="#" coords="368,195,3" title="X=59, Y=20" >'+
  4668. '<area shape="circle" href="#" coords="368,193,3" title="X=59, Y=21" >'+
  4669. '<area shape="circle" href="#" coords="368,191,3" title="X=59, Y=22" >'+
  4670. '<area shape="circle" href="#" coords="368,189,3" title="X=59, Y=23" >'+
  4671. '<area shape="circle" href="#" coords="368,187,3" title="X=59, Y=24" >'+
  4672. '<area shape="circle" href="#" coords="368,185,3" title="X=59, Y=25" >'+
  4673. '<area shape="circle" href="#" coords="368,183,3" title="X=59, Y=26" >'+
  4674. '<area shape="circle" href="#" coords="368,181,3" title="X=59, Y=27" >'+
  4675. '<area shape="circle" href="#" coords="368,179,3" title="X=59, Y=28" >'+
  4676. '<area shape="circle" href="#" coords="368,177,3" title="X=59, Y=29" >'+
  4677. '<area shape="circle" href="#" coords="368,175,3" title="X=59, Y=30" >'+
  4678. '<area shape="circle" href="#" coords="368,173,3" title="X=59, Y=31" >'+
  4679. '<area shape="circle" href="#" coords="370,203,3" title="X=60, Y=16" >'+
  4680. '<area shape="circle" href="#" coords="370,201,3" title="X=60, Y=17" >'+
  4681. '<area shape="circle" href="#" coords="370,199,3" title="X=60, Y=18" >'+
  4682. '<area shape="circle" href="#" coords="370,197,3" title="X=60, Y=19" >'+
  4683. '<area shape="circle" href="#" coords="370,195,3" title="X=60, Y=20" >'+
  4684. '<area shape="circle" href="#" coords="370,193,3" title="X=60, Y=21" >'+
  4685. '<area shape="circle" href="#" coords="370,191,3" title="X=60, Y=22" >'+
  4686. '<area shape="circle" href="#" coords="370,189,3" title="X=60, Y=23" >'+
  4687. '<area shape="circle" href="#" coords="370,187,3" title="X=60, Y=24" >'+
  4688. '<area shape="circle" href="#" coords="370,185,3" title="X=60, Y=25" >'+
  4689. '<area shape="circle" href="#" coords="370,183,3" title="X=60, Y=26" >'+
  4690. '<area shape="circle" href="#" coords="370,181,3" title="X=60, Y=27" >'+
  4691. '<area shape="circle" href="#" coords="370,179,3" title="X=60, Y=28" >'+
  4692. '<area shape="circle" href="#" coords="370,177,3" title="X=60, Y=29" >'+
  4693. '<area shape="circle" href="#" coords="370,175,3" title="X=60, Y=30" >'+
  4694. '<area shape="circle" href="#" coords="370,173,3" title="X=60, Y=31" >'+
  4695. '<area shape="circle" href="#" coords="372,201,3" title="X=61, Y=17" >'+
  4696. '<area shape="circle" href="#" coords="372,199,3" title="X=61, Y=18" >'+
  4697. '<area shape="circle" href="#" coords="372,197,3" title="X=61, Y=19" >'+
  4698. '<area shape="circle" href="#" coords="372,195,3" title="X=61, Y=20" >'+
  4699. '<area shape="circle" href="#" coords="372,193,3" title="X=61, Y=21" >'+
  4700. '<area shape="circle" href="#" coords="372,191,3" title="X=61, Y=22" >'+
  4701. '<area shape="circle" href="#" coords="372,189,3" title="X=61, Y=23" >'+
  4702. '<area shape="circle" href="#" coords="372,187,3" title="X=61, Y=24" >'+
  4703. '<area shape="circle" href="#" coords="372,185,3" title="X=61, Y=25" >'+
  4704. '<area shape="circle" href="#" coords="372,183,3" title="X=61, Y=26" >'+
  4705. '<area shape="circle" href="#" coords="372,181,3" title="X=61, Y=27" >'+
  4706. '<area shape="circle" href="#" coords="372,179,3" title="X=61, Y=28" >'+
  4707. '<area shape="circle" href="#" coords="372,177,3" title="X=61, Y=29" >'+
  4708. '<area shape="circle" href="#" coords="372,175,3" title="X=61, Y=30" >'+
  4709. '<area shape="circle" href="#" coords="374,201,3" title="X=62, Y=17" >'+
  4710. '<area shape="circle" href="#" coords="374,199,3" title="X=62, Y=18" >'+
  4711. '<area shape="circle" href="#" coords="374,197,3" title="X=62, Y=19" >'+
  4712. '<area shape="circle" href="#" coords="374,195,3" title="X=62, Y=20" >'+
  4713. '<area shape="circle" href="#" coords="374,193,3" title="X=62, Y=21" >'+
  4714. '<area shape="circle" href="#" coords="374,191,3" title="X=62, Y=22" >'+
  4715. '<area shape="circle" href="#" coords="374,189,3" title="X=62, Y=23" >'+
  4716. '<area shape="circle" href="#" coords="374,187,3" title="X=62, Y=24" >'+
  4717. '<area shape="circle" href="#" coords="374,185,3" title="X=62, Y=25" >'+
  4718. '<area shape="circle" href="#" coords="374,183,3" title="X=62, Y=26" >'+
  4719. '<area shape="circle" href="#" coords="374,181,3" title="X=62, Y=27" >'+
  4720. '<area shape="circle" href="#" coords="374,179,3" title="X=62, Y=28" >'+
  4721. '<area shape="circle" href="#" coords="374,177,3" title="X=62, Y=29" >'+
  4722. '<area shape="circle" href="#" coords="374,175,3" title="X=62, Y=30" >'+
  4723. '<area shape="circle" href="#" coords="376,199,3" title="X=63, Y=18" >'+
  4724. '<area shape="circle" href="#" coords="376,197,3" title="X=63, Y=19" >'+
  4725. '<area shape="circle" href="#" coords="376,195,3" title="X=63, Y=20" >'+
  4726. '<area shape="circle" href="#" coords="376,193,3" title="X=63, Y=21" >'+
  4727. '<area shape="circle" href="#" coords="376,191,3" title="X=63, Y=22" >'+
  4728. '<area shape="circle" href="#" coords="376,189,3" title="X=63, Y=23" >'+
  4729. '<area shape="circle" href="#" coords="376,187,3" title="X=63, Y=24" >'+
  4730. '<area shape="circle" href="#" coords="376,185,3" title="X=63, Y=25" >'+
  4731. '<area shape="circle" href="#" coords="376,183,3" title="X=63, Y=26" >'+
  4732. '<area shape="circle" href="#" coords="376,181,3" title="X=63, Y=27" >'+
  4733. '<area shape="circle" href="#" coords="376,179,3" title="X=63, Y=28" >'+
  4734. '<area shape="circle" href="#" coords="376,177,3" title="X=63, Y=29" >'+
  4735. '<area shape="circle" href="#" coords="378,195,3" title="X=64, Y=20" >'+
  4736. '<area shape="circle" href="#" coords="378,193,3" title="X=64, Y=21" >'+
  4737. '<area shape="circle" href="#" coords="378,191,3" title="X=64, Y=22" >'+
  4738. '<area shape="circle" href="#" coords="378,189,3" title="X=64, Y=23" >'+
  4739. '<area shape="circle" href="#" coords="378,187,3" title="X=64, Y=24" >'+
  4740. '<area shape="circle" href="#" coords="378,185,3" title="X=64, Y=25" >'+
  4741. '<area shape="circle" href="#" coords="378,183,3" title="X=64, Y=26" >'+
  4742. '<area shape="circle" href="#" coords="378,181,3" title="X=64, Y=27" >'+
  4743. '<area shape="circle" href="#" coords="380,191,3" title="X=65, Y=22" >'+
  4744. '<area shape="circle" href="#" coords="380,189,3" title="X=65, Y=23" >'+
  4745. '<area shape="circle" href="#" coords="380,187,3" title="X=65, Y=24" >'+
  4746. '<area shape="circle" href="#" coords="380,185,3" title="X=65, Y=25" >'+
  4747. '</map>';
  4748.  
  4749. var nvspan = document.createElement('div');
  4750. nvspan.align = 'center';
  4751. nvspan.id = 'mz_mapdiv';
  4752. nvspan.valign = 'top';
  4753. nvspan.innerHTML = nvdiv;
  4754. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4755. var footer = document.getElementById('footer1');
  4756. footer.parentNode.insertBefore(nvspan,footer);
  4757. }
  4758.  
  4759. function testeGlissiere() {
  4760. try {
  4761. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4762. var footer = document.getElementById('footer1');
  4763. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4764. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4765. }
  4766.  
  4767. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4768. if (x0 !== undefined) {
  4769. // ouais, récursif une fois
  4770. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4771. if (PtInterm === undefined)
  4772. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4773. else
  4774. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4775. return;
  4776. }
  4777. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4778. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4779. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4780. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4781. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4782. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4783. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4784. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4785. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4786. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4787. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4788. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4789. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4790. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4791. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4792. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4793. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4794. }
  4795.  
  4796. function do_ordresgowap() {
  4797. if (newCarte) {
  4798. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4799. //testeGlissiere();
  4800. //MZ_testsUnitairesCalculIntermediaire();
  4801. } else {
  4802. setCarteGogo(); // Via script des trouillots
  4803. }
  4804. }
  4805.  
  4806. function do_listegowap() {
  4807. if (!newCarte) return;
  4808. MZ_setCarteTousGogoHTML5();
  4809. }
  4810.  
  4811. function do_lieuDescription() {
  4812. if (!newCarte) return;
  4813. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4814. MZ_setCarteTP();
  4815. }
  4816.  
  4817. function do_lieuTeleport() {
  4818. changeButtonValidate();
  4819. if (!newCarte) return;
  4820. MZ_setCarteTP();
  4821. }
  4822.  
  4823. /*********************************************************************************
  4824. * This file is part of Mountyzilla. *
  4825. * *
  4826. * Mountyzilla is free software; you can redistribute it and/or modify *
  4827. * it under the terms of the GNU General Public License as published by *
  4828. * the Free Software Foundation; either version 2 of the License, or *
  4829. * (at your option) any later version. *
  4830. * *
  4831. * Mountyzilla is distributed in the hope that it will be useful, *
  4832. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4833. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4834. * GNU General Public License for more details. *
  4835. * *
  4836. * You should have received a copy of the GNU General Public License *
  4837. * along with Mountyzilla; if not, write to the Free Software *
  4838. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4839. *********************************************************************************/
  4840.  
  4841. // x~x attaque
  4842.  
  4843. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4844.  
  4845. function do_attaque() {
  4846. }
  4847.  
  4848. /*******************************************************************************
  4849. * This file is part of Mountyzilla. *
  4850. * *
  4851. * Mountyzilla is free software; you can redistribute it and/or modify *
  4852. * it under the terms of the GNU General Public License as published by *
  4853. * the Free Software Foundation; either version 2 of the License, or *
  4854. * (at your option) any later version. *
  4855. * *
  4856. * Mountyzilla is distributed in the hope that it will be useful, *
  4857. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4858. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4859. * GNU General Public License for more details. *
  4860. * *
  4861. * You should have received a copy of the GNU General Public License *
  4862. * along with Mountyzilla; if not, write to the Free Software *
  4863. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4864. *******************************************************************************/
  4865.  
  4866. // x~x infomonstre
  4867.  
  4868. // DEBUG
  4869. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4870. // À corriger, évidemment.
  4871. var listeCDM = {};
  4872. var nomMonstre='';
  4873. var idMonstre=-1;
  4874. var tbody;
  4875. var popup;
  4876.  
  4877. function traiteMonstre() {
  4878. try {
  4879. var nodeTitre = document.evaluate(
  4880. "//div[@class='titre2' and contains(text(),'(')]",
  4881. document, null, 9, null
  4882. ).singleNodeValue;
  4883. var texte = nodeTitre.firstChild.nodeValue;
  4884. } catch(e) {
  4885. window.console.log(traceStack(e, 'traiteMonstre'));
  4886. return;
  4887. }
  4888. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4889. if(nomMonstre.indexOf(']')!=-1) {
  4890. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4891. }
  4892. idMonstre = texte.match(/\d+/)[0];
  4893. FF_XMLHttpRequest({
  4894. method: 'GET',
  4895. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4896. +MY_getValue('CDMID')
  4897. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4898. headers : {
  4899. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4900. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4901. },
  4902. trace: 'info monstre ' + nomMonstre,
  4903. onload: function(responseDetails) {
  4904. try {
  4905. var texte = responseDetails.responseText;
  4906. var lines = texte.split("\n");
  4907. if(lines.length>=1) {
  4908. var infos = lines[0].split(";");
  4909. if(infos.length<4) { return; }
  4910. var idMonstre = infos[0];
  4911. infos=infos.slice(3);
  4912. listeCDM[idMonstre]=infos;
  4913. computeMissionInfomonstre();
  4914. }
  4915. } catch(e) {
  4916. window.alert(e);
  4917. }
  4918. }
  4919. });
  4920. }
  4921.  
  4922. function initPopupInfomonstre() {
  4923. // Initialise le popup tactique (calculs att/deg)
  4924. popup = document.createElement('div');
  4925. popup.id = 'popup';
  4926. popup.className = 'mh_textbox';
  4927. popup.style =
  4928. 'position: absolute;'+
  4929. 'border: 1px solid #000000;'+
  4930. 'visibility: hidden;'+
  4931. 'display: inline;'+
  4932. 'z-index: 3;'+
  4933. 'max-width: 400px;';
  4934. document.body.appendChild(popup);
  4935. }
  4936.  
  4937. function showPopupTactique(evt) {
  4938. try {
  4939. var id = this.id;
  4940. var nom = this.nom;
  4941. var texte = getAnalyseTactique(id,nom);
  4942. if(texte=='') { return; }
  4943. popup.innerHTML = texte;
  4944. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4945. if(isPage("View/MonsterView")) {
  4946. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4947. } else {
  4948. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4949. }
  4950. popup.style.top = evt.pageY+15+'px';
  4951. popup.style.visibility = 'visible';
  4952. } catch(e) {
  4953. window.alert(e);
  4954. }
  4955. }
  4956.  
  4957. // roule 16/03/2016, existe déjà ailleurs
  4958. // function hidePopup() {
  4959. // popup.style.visibility = 'hidden';
  4960. // }
  4961.  
  4962. function toggleTableau() {
  4963. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4964. }
  4965.  
  4966. function computeMissionInfomonstre() {
  4967. // C'est quoi ce titre de fonction ? (O_o)
  4968. try {
  4969. var nodeInsert = document.evaluate(
  4970. "//div[@class = 'titre3']",
  4971. document, null, 9, null
  4972. ).singleNodeValue;
  4973. } catch(e) {
  4974. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4975. return;
  4976. }
  4977. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4978. table.align = 'center';
  4979. tbody = table.childNodes[1];
  4980. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4981. table.firstChild.firstChild.onmouseover = function() {
  4982. this.style.cursor = 'pointer';
  4983. this.className = 'mh_tdpage';
  4984. };
  4985. table.firstChild.firstChild.onmouseout = function() {
  4986. this.className = 'mh_tdtitre';
  4987. };
  4988. tbody.style.display = 'none';
  4989. table.style.width = '350px';
  4990. insertBefore(nodeInsert,table);
  4991. }
  4992.  
  4993. function do_infomonstre() {
  4994. start_script();
  4995. try {
  4996. initPopupInfomonstre();
  4997. traiteMonstre();
  4998. } catch(e) {
  4999. window.alert('Erreur infoMonstre:\n'+e);
  5000. }
  5001. displayScriptTime();
  5002. }
  5003.  
  5004. /*******************************************************************************
  5005. * This file is part of Mountyzilla. *
  5006. * *
  5007. * Mountyzilla is free software; you can redistribute it and/or modify *
  5008. * it under the terms of the GNU General Public License as published by *
  5009. * the Free Software Foundation; either version 2 of the License, or *
  5010. * (at your option) any later version. *
  5011. * *
  5012. * Mountyzilla is distributed in the hope that it will be useful, *
  5013. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5014. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5015. * GNU General Public License for more details. *
  5016. * *
  5017. * You should have received a copy of the GNU General Public License *
  5018. * along with Mountyzilla; if not, write to the Free Software *
  5019. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5020. *******************************************************************************/
  5021.  
  5022. // x~x mission
  5023.  
  5024. /* TODO
  5025. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  5026. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  5027. *
  5028. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  5029. */
  5030. function isArray(a) {
  5031. return (!!a) && (a.constructor === Array);
  5032. }
  5033.  
  5034. function saveMission(num,obEtape) {
  5035. var obMissions;
  5036. if(MY_getValue(numTroll+'.MISSIONS')) {
  5037. try {
  5038. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5039. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  5040. } catch(e) {
  5041. window.console.error(traceStack(e, 'Mission parsage'));
  5042. return;
  5043. }
  5044. }
  5045. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  5046. if (obMissions == undefined) obMissions = new Object(); // protection
  5047. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  5048. if(obEtape) {
  5049. obMissions[num] = obEtape;
  5050. } else if(obMissions[num]) {
  5051. delete obMissions[num];
  5052. }
  5053. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  5054. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5055. }
  5056.  
  5057. function addtroogle(tdLibelle, sRestrict) {
  5058. var img = document.createElement('img');
  5059. img.src = URL_MZimg + 'troogle.ico';
  5060. img.alt = 'Troogle logo';
  5061. var a = document.createElement('a');
  5062. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  5063. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  5064. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  5065. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  5066. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  5067. a.href = url;
  5068. a.title = 'Chercher sur Troogle';
  5069. a.target = 'troogle';
  5070. a.appendChild(img);
  5071. tdLibelle.appendChild(a);
  5072. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  5073. }
  5074.  
  5075. function traiteMission() {
  5076. try {
  5077. var titreMission = document.getElementsByClassName('titre2')[0];
  5078. var numMission = titreMission.textContent.match(/\d+/)[0];
  5079. var missionForm = document.getElementsByName('ActionForm')[0];
  5080. var tdLibelle = document.evaluate(
  5081. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  5082. missionForm, null, 9, null).singleNodeValue;
  5083. } catch(e) {
  5084. window.console.error(traceStack(e, 'récupération mission'));
  5085. return;
  5086. }
  5087. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  5088. try {
  5089. if(!tdLibelle) {
  5090. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  5091. debugMZ('traiteMission, la mission semble terminée');
  5092. saveMission(numMission,false);
  5093. return;
  5094. }
  5095.  
  5096. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  5097. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  5098. // debug Roule'
  5099. if (MY_DEBUG) {
  5100. for (var i =0; i < tdLibelle.childNodes.length; i++)
  5101. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  5102. }
  5103. if(libelle.indexOf('niveau égal à')!=-1) {
  5104. var nbKills = 1, niveau, mod;
  5105. // exemples :
  5106. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  5107. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  5108. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  5109. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  5110. if (tdLibelle.childNodes.length == 1) {
  5111. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  5112. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  5113. if (m) {
  5114. niveau = Number(m[1]);
  5115. mod = 'plus'
  5116. } else {
  5117. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  5118. if (m) {
  5119. niveau = Number(m[1]);
  5120. mod = Number(m[2]);
  5121. } else {
  5122. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  5123. return;
  5124. }
  5125. }
  5126. } else {
  5127. // ancienne méthode (multi childnode)
  5128. // à supprimer un jour peut-être
  5129. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  5130. // Étape de kill multiple de niveau donné
  5131. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5132. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  5133. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5134. niveau = Number(mod[0]);
  5135. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5136. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  5137. } else {
  5138. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  5139. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5140. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  5141. mod = mod ? Number(mod[0]) : 'plus';
  5142. }
  5143. } else {
  5144. // Étape de kill unique de niveau donné
  5145. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  5146. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5147. mod = mod ? Number(mod[0]) : 'plus';
  5148. }
  5149. }
  5150. // debug Roule'
  5151. if (MY_DEBUG) {
  5152. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  5153. }
  5154. saveMission(numMission,{
  5155. type: 'Niveau',
  5156. niveau: niveau,
  5157. mod: mod,
  5158. mundidey: siMundidey,
  5159. libelle: libelle
  5160. });
  5161. if (mod == 'plus')
  5162. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  5163. else
  5164. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  5165. } else if(libelle.indexOf('de la race')!=-1) {
  5166. var nbKills = 1, race;
  5167. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  5168. // Étape de kill multiple de race donnée
  5169. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5170. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5171. } else {
  5172. // Étape de kill unique de race donnée
  5173. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5174. }
  5175. race = race.replace(/\"/g,'');
  5176. race = removeEnclosingSimpleCote(race); // Roule 29/03/2019 Maintenant, on a des '
  5177. saveMission(numMission,{
  5178. type: 'Race',
  5179. race: race,
  5180. mundidey: siMundidey,
  5181. libelle: libelle
  5182. });
  5183. addtroogle(tdLibelle, '@monstre ' + race);
  5184. } else if(libelle.indexOf('de la famille')!=-1) {
  5185. var nbKills = 1, famille;
  5186. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  5187. // Étape de kill multiple de famille donnée
  5188. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5189. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5190. } else {
  5191. // Étape de kill unique de famille donnée
  5192. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5193. }
  5194. famille = famille.replace(/\"/g,'');
  5195. famille = removeEnclosingSimpleCote(famille); // Roule 29/03/2019 Maintenant, on a des '
  5196. saveMission(numMission,{
  5197. type: 'Famille',
  5198. famille: famille,
  5199. mundidey: siMundidey,
  5200. libelle: libelle
  5201. });
  5202. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  5203. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  5204. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  5205. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  5206. debugMZ('traiteMission étape capacité spéciale');
  5207. pouvoir = removeEnclosingSimpleCote(pouvoir); // Roule 29/03/2019 Maintenant, on a des '
  5208. saveMission(numMission,{
  5209. type: 'Pouvoir',
  5210. pouvoir: pouvoir,
  5211. libelle: libelle
  5212. });
  5213. } else {
  5214. debugMZ('traiteMission étape pas pour troogle');
  5215. saveMission(numMission,false);
  5216. }
  5217. } catch(e) {
  5218. window.console.error(traceStack(e, 'récupération étape mission'));
  5219. return;
  5220. }
  5221. }
  5222.  
  5223. function removeEnclosingSimpleCote(x) { // Roule 29/03/2019
  5224. return x.replace(/'$/, '').replace(/^'/, '');
  5225. }
  5226.  
  5227. function do_mission() {
  5228. start_script(60);
  5229.  
  5230. traiteMission();
  5231.  
  5232. displayScriptTime();
  5233. }
  5234.  
  5235. /*******************************************************************************
  5236. * This file is part of Mountyzilla. *
  5237. * *
  5238. * Mountyzilla is free software; you can redistribute it and/or modify *
  5239. * it under the terms of the GNU General Public License as published by *
  5240. * the Free Software Foundation; either version 2 of the License, or *
  5241. * (at your option) any later version. *
  5242. * *
  5243. * Mountyzilla is distributed in the hope that it will be useful, *
  5244. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5245. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5246. * GNU General Public License for more details. *
  5247. * *
  5248. * You should have received a copy of the GNU General Public License *
  5249. * along with Mountyzilla; if not, write to the Free Software *
  5250. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5251. *******************************************************************************/
  5252.  
  5253. // x~x move
  5254.  
  5255. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  5256.  
  5257. var petitsTrous = {
  5258. '-52;57': true,
  5259. '55;70': true,
  5260. '64;70': true,
  5261. '12;-15': true,
  5262. '30;-52': true,
  5263. '48;-39': true
  5264. };
  5265.  
  5266. var grosTrous = {
  5267. '-35;65': true,
  5268. '-13;73': true,
  5269. '-64;9': true,
  5270. '-35;15': true,
  5271. '5;32': true,
  5272. '10;64': true,
  5273. '21;36': true,
  5274. '46;52': true,
  5275. '74;32': true,
  5276. '-71;-7': true,
  5277. '-67;-37': true,
  5278. '-60;-32': true,
  5279. '-51;-22': true,
  5280. '-36;-51': true,
  5281. '5;-49': true
  5282. };
  5283.  
  5284. var centreCarmine_X = 56.5;
  5285. var centreCarmine_Y = 23.5;
  5286. var rayonCarmine = 8.7;
  5287.  
  5288. function isTrou(x,y,n) {
  5289. if(petitsTrous[x+';'+y]) {
  5290. return n<0 && n>-60;
  5291. }
  5292. if(grosTrous[x+';'+y]
  5293. || grosTrous[x-1+';'+y]
  5294. || grosTrous[x+';'+y+1]
  5295. || grosTrous[x-1+';'+y+1]) {
  5296. return n<0 && n>-70;
  5297. }
  5298. if(Math.sqrt(
  5299. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  5300. )<=rayonCarmine) {
  5301. return n<0 && n>-100;
  5302. }
  5303. return false;
  5304. }
  5305.  
  5306. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  5307.  
  5308. function validateDestination() {
  5309. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  5310. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  5311. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  5312. var form = document.getElementsByName('ActionForm')[0];
  5313. if(form) {
  5314. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  5315. if(document.getElementsByName('ai_DeplX')[i].checked) {
  5316. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  5317. }
  5318. }
  5319. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  5320. if(document.getElementsByName('ai_DeplY')[i].checked) {
  5321. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  5322. }
  5323. }
  5324. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  5325. if(document.getElementsByName('ai_DeplN')[i].checked) {
  5326. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  5327. }
  5328. }
  5329. if(isTrou(x,y,n)) {
  5330. return window.confirm(
  5331. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5332. +'Vous allez tomber dans un trou de météorite.\n'
  5333. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  5334. );
  5335. }
  5336. }
  5337. return true;
  5338. }
  5339.  
  5340. function newsubmitDE(event) {
  5341. event.stopPropagation();
  5342. event.preventDefault();
  5343. if(validateDestination()) {
  5344. this.submit();
  5345. }
  5346. }
  5347.  
  5348. function changeValidation() {
  5349. var form = document.getElementsByName('ActionForm')[0];
  5350. if(form) {
  5351. form.addEventListener('submit', newsubmitDE, true);
  5352. }
  5353. }
  5354.  
  5355.  
  5356. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  5357.  
  5358. function validateTPDestination() {
  5359. try {
  5360. var text = document.getElementsByTagName('B')[0];
  5361. var a = text.firstChild.nodeValue.split('|');
  5362. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  5363. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  5364. var pos_n = a[2].substring(5, a[2].length) * 1;
  5365.  
  5366. var nbtrous = 0;
  5367. for(var signX=-1 ; signX<=1 ; signX+=2) {
  5368. for(var x=0 ; x<=2 ; x++) {
  5369. for(var signY=-1 ; signY<=1 ; signY+=2) {
  5370. for(var y=0 ; y<=2 ; y++) {
  5371. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  5372. for(var n = 0 ; n <= 1 ; n++) {
  5373. if(isTrou(
  5374. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  5375. )) {
  5376. nbtrous++;
  5377. }
  5378. }
  5379. }
  5380. }
  5381. }
  5382. }
  5383. }
  5384. if(nbtrous>0 && nbtrous<72) {
  5385. return window.confirm(
  5386. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5387. +'Vous avez '+Math.floor((100*nbtrous)/144)
  5388. +'% de risque de tomber dans un trou de météorite.\n'
  5389. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  5390. );
  5391. }
  5392. else if(nbtrous>=72) {
  5393. return window.confirm(
  5394. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  5395. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  5396. +'% de risque de tomber dans un trou de météorite !\n'
  5397. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  5398. );
  5399. }
  5400. return true;
  5401. }
  5402. catch(e) {
  5403. window.alert(e)
  5404. }
  5405. }
  5406.  
  5407. function newsubmitTP(event) {
  5408. event.stopPropagation();
  5409. event.preventDefault();
  5410. if(validateTPDestination()) {
  5411. this.submit();
  5412. }
  5413. }
  5414.  
  5415. function changeButtonValidate() {
  5416. var form = document.getElementsByName('Formulaire')[0];
  5417. if(form) {
  5418. if(!form.getAttribute('onsubmit')) {
  5419. form.setAttribute('onsubmit','return true;');
  5420. }
  5421. form.addEventListener('submit', newsubmitTP, true);
  5422. }
  5423. }
  5424.  
  5425.  
  5426. /*-[functions]---------------- Partie Principale -----------------------------*/
  5427.  
  5428. function do_move() {
  5429. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  5430. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  5431. changeValidation();
  5432. //}
  5433. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  5434. // changeButtonValidate();
  5435. //}
  5436. }
  5437.  
  5438. /*******************************************************************************
  5439. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  5440. * Mountyzilla is free software; provided under the GNU General Public License *
  5441. *******************************************************************************/
  5442.  
  5443. // x~x news
  5444.  
  5445. // Nombre de news à afficher & nb max de caractères par news:
  5446. const nbItems = 5;
  5447. const maxCarDescription = 300;
  5448.  
  5449. /*-[functions]------------------- Utilitaires --------------------------------*/
  5450.  
  5451. // Ne semble avoir strictement aucun effet:
  5452. String.prototype.epureDescription = function() {
  5453. return this.replace(/\\(.)/g,"$1");
  5454. }
  5455.  
  5456. function appendTitledTable(node,titre,description) {
  5457. // Crée les tables contenant les infos (avec titre)
  5458. var table = document.createElement('table');
  5459. table.border = 0;
  5460. table.className = 'mh_tdborder';
  5461. table.cellSpacing = 1;
  5462. table.cellPadding = 1;
  5463. table.style.maxWidth = '98%';
  5464. table.style.marginLeft = 'auto';
  5465. table.style.marginRight = 'auto';
  5466. var tbody = document.createElement('tbody');
  5467. table.appendChild(tbody);
  5468. var tr = appendTr(tbody,'mh_tdtitre');
  5469. var td = appendTdCenter(tr,2);
  5470. var span = document.createElement('span');
  5471. appendText(span,titre,true);
  5472. if(description) {
  5473. span.title = description;
  5474. }
  5475. td.appendChild(span);
  5476. node.appendChild(table);
  5477. return tbody;
  5478. }
  5479.  
  5480. function testCertif(paramURL, callbackOnError) {
  5481. try {
  5482. FF_XMLHttpRequest({
  5483. method: 'GET',
  5484. url: paramURL,
  5485. onload: function(responseDetails) {
  5486. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  5487. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  5488. }
  5489. });
  5490. } catch(e) {
  5491. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  5492. callbackOnError();
  5493. }
  5494. }
  5495.  
  5496. function createOrGetGrandCadre() {
  5497. var grandCadre = document.getElementById('grandCadre');
  5498. if (grandCadre) return grandCadre;
  5499. try {
  5500. var rappels = document.evaluate(
  5501. "//p[contains(a/text(),'messagerie')]",
  5502. document, null, 9, null).singleNodeValue;
  5503. }
  5504. catch(e) {
  5505. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  5506. grandCadre = document.createElement('div');
  5507. return grandCadre;
  5508. }
  5509. grandCadre = document.createElement('div');
  5510. grandCadre.id = 'grandCadre';
  5511. var sousCadre = document.createElement('div');
  5512. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  5513. sousCadre.style.textAlign = 'center';
  5514. sousCadre.style.fontSize = 'xx-large';
  5515. grandCadre.appendChild(sousCadre);
  5516.  
  5517. grandCadre.style.border = 'solid 5px red';
  5518. grandCadre.style.width = 'auto';
  5519. insertBefore(rappels,grandCadre);
  5520. return grandCadre;
  5521. }
  5522.  
  5523. function showHttpsErrorCadre1() {
  5524. window.console.log('[MZ] showHttpsErrorCadre1');
  5525. var grandCadre = createOrGetGrandCadre();
  5526. var sousCadre = document.createElement('div');
  5527. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  5528. + '<br />Cela empêchera Moutyzilla de fonctionner'
  5529. + '<br /><a style="color:blue;font-size: inherits;" href="'
  5530. + URL_CertifRaistlin1
  5531. + '" target="raistlin">clique ici</a>'
  5532. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5533. + ' « Confirmer l\'exception de sécurité »'
  5534. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5535. sousCadre.style.width = 'auto';
  5536. sousCadre.style.fontSize = 'large';
  5537. sousCadre.style.border = 'solid 1px black';
  5538. sousCadre.style.backgroundColor = 'red';
  5539. grandCadre.appendChild(sousCadre);
  5540. }
  5541.  
  5542. function showHttpsErrorCadre2() {
  5543. window.console.log('[MZ] showHttpsErrorCadre2');
  5544. var grandCadre = createOrGetGrandCadre();
  5545. var sousCadre = document.createElement('div');
  5546. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  5547. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  5548. + '<a style="color:blue;font-size: inherits;" href="'
  5549. + URL_CertifRaistlin2
  5550. + '" target="raistlin">clique ici</a>'
  5551. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5552. + ' « Confirmer l\'exception de sécurité »'
  5553. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  5554. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5555. sousCadre.style.width = 'auto';
  5556. sousCadre.style.fontSize = 'large';
  5557. sousCadre.style.border = 'solid 1px black';
  5558. sousCadre.style.backgroundColor = 'red';
  5559. grandCadre.appendChild(sousCadre);
  5560. }
  5561.  
  5562. function showHttpsErrorContenuMixte() {
  5563. window.console.log('[MZ] showHttpsErrorContenuMixte');
  5564. var grandCadre = createOrGetGrandCadre();
  5565. var sousCadre = document.createElement('div');
  5566. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5567. + '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)'
  5568. + '<ul>'
  5569. + '<li>Interface Bricol\'Troll</li>'
  5570. + '<li>Nouveautés de Mountyzilla</li>'
  5571. + '</ul>'
  5572. + '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 />'
  5573. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5574. sousCadre.style.width = 'auto';
  5575. sousCadre.style.fontSize = 'large';
  5576. sousCadre.style.border = 'solid 1px black';
  5577. grandCadre.appendChild(sousCadre);
  5578. }
  5579.  
  5580. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5581.  
  5582. function traiterJubilaires() {
  5583. // à faire
  5584. }
  5585.  
  5586. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5587. try {
  5588. FF_XMLHttpRequest({
  5589. method: 'GET',
  5590. url: URL_anniv,
  5591. headers: {
  5592. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5593. 'Accept': 'application/xml,text/xml',
  5594. },
  5595. onload: function(responseDetails) {
  5596. if ((responseDetails.status == 0) && isHTTPS) {
  5597. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5598. //showHttpsErrorContenuMixte();
  5599. return;
  5600. }
  5601. var listeTrolls = responseDetails.responseText.split('\n');
  5602. if(!listeTrolls || listeTrolls.length==0) {
  5603. return;
  5604. }
  5605. afficherJubilaires(listeTrolls);
  5606. },
  5607. });
  5608. }
  5609. catch(e) {
  5610. if (isHTTPS) {
  5611. window.console.log(traceStack(e, 'appel jubilaires'));
  5612. showHttpsErrorContenuMixte();
  5613. } else {
  5614. window.alert('Erreur Jubilaires:\n'+e);
  5615. }
  5616. }
  5617. }
  5618.  
  5619. function afficherJubilaires(listeTrolls) {
  5620. try {
  5621. var rappels = document.evaluate(
  5622. "//p[contains(a/text(),'messagerie')]",
  5623. document, null, 9, null).singleNodeValue;
  5624. }
  5625. catch(e) {
  5626. return;
  5627. }
  5628. var p = document.createElement('p');
  5629. var tbody = appendTitledTable(p,
  5630. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5631. 'Envoyez leur un message ou un cadeau !'
  5632. );
  5633. tr = appendTr(tbody,'mh_tdpage');
  5634. td = appendTdCenter(tr);
  5635. var small = document.createElement('small');
  5636. td.appendChild(small);
  5637. var first = true;
  5638. for(var i=0 ; i<listeTrolls.length ; i++) {
  5639. var infos = listeTrolls[i].split(';');
  5640. if(infos.length!=3 || infos[2]==='0') {
  5641. continue;
  5642. }
  5643. if(first) {
  5644. first = false;
  5645. }
  5646. else {
  5647. appendText(small,', ');
  5648. }
  5649. var a = document.createElement('a');
  5650. a.href = 'javascript:EPV('+infos[0]+')';
  5651. appendText(a,infos[1]);
  5652. small.appendChild(a);
  5653. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5654. }
  5655. insertBefore(rappels,p);
  5656. }
  5657.  
  5658.  
  5659. /*-[functions]--------------------- News MZ ----------------------------------*/
  5660.  
  5661. function traiterNouvelles() {
  5662. var news = new Array;
  5663. 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)']);
  5664. 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 ;).']);
  5665. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5666. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5667. 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']);
  5668. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5669. afficherNouvelles(news);
  5670. }
  5671.  
  5672. function afficherNouvelles(items) {
  5673. var footer = document.getElementById('footer1');
  5674. if(!footer) {
  5675. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5676. return;
  5677. }
  5678. var p = document.createElement('p');
  5679. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5680. var div = document.createElement('div');
  5681. div.style.position = 'absolute';
  5682. div.style.right = 0;
  5683. div.style.top = 0;
  5684. div.style.paddingRight = '3px';
  5685. div.style.whiteSpace = 'nowrap';
  5686. appendText(div, '(version ' + GM_info.script.version + ')');
  5687. tbody.rows[0].cells[0].style.position = 'relative';
  5688. tbody.rows[0].cells[0].appendChild(div);
  5689. for(var i=0 ; i<items.length ; i++) {
  5690. var tr = appendTr(tbody,'mh_tdpage');
  5691. var td = appendTdCenter(tr);
  5692. td.style.verticalAlign = 'top'; // semble sans effet
  5693. appendText(td,items[i][0],true);
  5694. td = appendTd(tr);
  5695. td.innerHTML = items[i][1];
  5696. }
  5697. insertBefore(footer,p);
  5698.  
  5699. // changelog
  5700. var p = document.createElement('p');
  5701. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5702. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5703. tbody.rows[0].cells[0].onclick = function() {
  5704. try {
  5705. tbody.rows[0].cells[0].onclick = undefined;
  5706. tbody.rows[0].cells[0].style.cursor = '';
  5707. var tr = appendTr(tbody,'mh_tdpage');
  5708. var td = appendTd(tr);
  5709. td.colSpan = 2;
  5710. var pre = document.createElement('pre');
  5711. appendText(pre,MZ_changeLog.join("\n"));
  5712. td.appendChild(pre);
  5713. } catch (e) {
  5714. window.console.log('[MZ] affichage changeLog', e);
  5715. }
  5716. };
  5717. insertBefore(footer,p);
  5718.  
  5719. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5720. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5721. if (isHTTPS) {
  5722. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5723. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5724. } else {
  5725. window.console.log('[MZ test] début switch to https');
  5726. window.sessionStorage.setItem('xxx', "test session trans https");
  5727. window.parent.xxx = "autre test";
  5728. var url = document.location.href;
  5729. window.console.log('[MZ test] url=' + url);
  5730. url = url.replace(/http:\/\//i, 'https://')
  5731. window.console.log('[MZ test] switched url=' + url);
  5732. document.location.href = url;
  5733. }
  5734. }
  5735. if (false) { // version par utilisation d'un IFrame en https
  5736. if (isHTTPS) {
  5737. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5738. //window.console.log('[MZ test] window.name=' + window.name);
  5739. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5740. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5741. var txt = window.name;
  5742. var tabtxt = txt.split(/µ/);
  5743. for (var i = 0; i < tabtxt.length; i++) {
  5744. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5745. }
  5746. } else {
  5747. var txt = '';
  5748. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5749. var k = localStorage.key(i);
  5750. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5751. txt += k + "£" + localStorage.getItem(k) + "µ";
  5752. }
  5753. var iframe = document.createElement('iframe');
  5754. var url = document.location.href;
  5755. //window.console.log('[MZ test] url=' + url);
  5756. url = url.replace(/http:\/\//i, 'https://')
  5757. //window.console.log('[MZ test] switched url=' + url);
  5758. //iframe.xxx = "truc en plume";
  5759. iframe.name = txt;
  5760. //window.xxx = "machin";
  5761. iframe.src = url;
  5762. //iframe.document.xxx = "truc en plume";
  5763. document.body.appendChild(iframe);
  5764. iframe.style.display = 'none';
  5765. }
  5766. }
  5767. }
  5768. }
  5769.  
  5770.  
  5771. /*---------------------------------- Main ------------------------------------*/
  5772.  
  5773. function do_news() {
  5774. start_script();
  5775.  
  5776. traiterJubilaires();
  5777. traiterNouvelles();
  5778.  
  5779. /* plus besoin, le certificat est "officiel"
  5780. if (isHTTPS) {
  5781. // test si les certificats raistlin ont été acceptés
  5782. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5783. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5784. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5785. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5786. }
  5787. }
  5788. */
  5789.  
  5790. displayScriptTime();
  5791. }
  5792.  
  5793. /*********************************************************************************
  5794. * This file is part of Mountyzilla. *
  5795. * *
  5796. * Mountyzilla is free software; you can redistribute it and/or modify *
  5797. * it under the terms of the GNU General Public License as published by *
  5798. * the Free Software Foundation; either version 2 of the License, or *
  5799. * (at your option) any later version. *
  5800. * *
  5801. * Mountyzilla is distributed in the hope that it will be useful, *
  5802. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5803. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5804. * GNU General Public License for more details. *
  5805. * *
  5806. * You should have received a copy of the GNU General Public License *
  5807. * along with Mountyzilla; if not, write to the Free Software *
  5808. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5809. *********************************************************************************/
  5810.  
  5811. // x~x tabcompo
  5812.  
  5813. var popup;
  5814.  
  5815. function initPopupTabcompo() {
  5816. popup = document.createElement('div');
  5817. popup.setAttribute('id', 'popup');
  5818. popup.setAttribute('class', 'mh_textbox');
  5819. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5820. + 'display: inline; z-index: 3; max-width: 400px;');
  5821. document.body.appendChild(popup);
  5822. }
  5823.  
  5824. function showPopup(evt) {
  5825. var texte = this.getAttribute("texteinfo");
  5826. popup.innerHTML = texte;
  5827. popup.style.left = evt.pageX + 15 + 'px';
  5828. popup.style.top = evt.pageY + 'px';
  5829. popup.style.visibility = "visible";
  5830. }
  5831.  
  5832. // roule 16/03/2016, existe déjà ailleurs
  5833. // function hidePopup() {
  5834. // popup.style.visibility = 'hidden';
  5835. // }
  5836.  
  5837. function createPopupImage(url, text)
  5838. {
  5839. var img = document.createElement('img');
  5840. img.setAttribute('src',url);
  5841. img.setAttribute('align','ABSMIDDLE');
  5842. img.setAttribute("texteinfo",text);
  5843. img.addEventListener("mouseover", showPopup,true);
  5844. img.addEventListener("mouseout", hidePopup,true);
  5845. return img;
  5846. }
  5847.  
  5848. function formateTexte(texte)
  5849. {
  5850. texte = texte.replace(/\n/g,"<br/>");
  5851. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5852. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5853. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5854. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5855. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5856. return texte;
  5857. }
  5858.  
  5859. function arrondi(x) {
  5860. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5861. }
  5862.  
  5863. function traiteMinerai() {
  5864. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5865. try {
  5866. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5867. +" and contains(./tr/th/text(),'Minerai')]",
  5868. document, null, 9, null).singleNodeValue;
  5869. node = node.nextSibling.nextSibling;
  5870. }
  5871. catch(e) {return;}
  5872. var trlist = document.evaluate('./tr', node, null, 7, null);
  5873. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5874. var node = trlist.snapshotItem(i);
  5875. var nature = node.childNodes[5].textContent;
  5876. var caracs = node.childNodes[7].textContent;
  5877. var taille = caracs.match(/\d+/)[0];
  5878. var coef = 1;
  5879. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5880. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5881. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5882. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5883. if (nature.indexOf('Mithril')!=-1) {
  5884. coef = 0.2*coef;
  5885. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5886. }
  5887. else {
  5888. coef = 0.75*coef+1.25;
  5889. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5890. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5891. }
  5892. }
  5893. }
  5894.  
  5895. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5896. function treateComposants() {
  5897. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5898. //On récupère les composants
  5899. var nodes = document.evaluate(
  5900. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5901. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5902. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5903. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5904. if (nodes.snapshotLength == 0) {
  5905. //window.console.log('[MZ] treateComposants DOWN');
  5906. return;
  5907. }
  5908. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5909.  
  5910. var texte = "";
  5911. for (var i = 0; i < nodes.snapshotLength; i++) {
  5912. var n1 = nodes.snapshotItem(i).childNodes[1];
  5913. var n3 = nodes.snapshotItem(i).childNodes[3];
  5914. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5915. var prix = n3.childNodes[0].nodeValue;
  5916. if (!prix)
  5917. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5918. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5919. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5920. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5921. + prix.replace(/\n/g, '') + "\n";
  5922. }
  5923.  
  5924. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5925. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5926. var id_taniere = c.snapshotItem(0).nodeValue;
  5927. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5928.  
  5929. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5930. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5931. if (form)
  5932. {
  5933. if(document.getElementsByTagName('form').length>0)
  5934. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5935. else
  5936. {
  5937. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5938. insertBefore(thisP, form);
  5939. }
  5940. }
  5941. }
  5942.  
  5943. function treateAllComposants() {
  5944. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5945. //On récupère les composants
  5946. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5947. document, null, 0, null ).numberValue;
  5948. var c = (categ == 0 ? 3 : 4);
  5949. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5950. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5951. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5952. + "td["+c+"]/text()[1] = '\240-\240' "
  5953. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5954. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5955. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5956. + "and td[1]/img/@alt = 'Identifié']",
  5957. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5958. if (nodes.snapshotLength == 0) {
  5959. // window.alert('treateAllComposants DOWN');
  5960. return;
  5961. }
  5962.  
  5963. var texte = "";
  5964. for (var i = 0; i < nodes.snapshotLength; i++) {
  5965. var n1 = nodes.snapshotItem(i).childNodes[1];
  5966. var n3 = nodes.snapshotItem(i).childNodes[3];
  5967. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5968. var prix = n3.childNodes[0].nodeValue;
  5969. if (!prix)
  5970. {
  5971. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5972. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5973. }
  5974. else
  5975. {
  5976. prix= prix.replace(/[\240 ]/g, "");
  5977. if(prix=="-")
  5978. prix=null;
  5979. }
  5980. if(prix)
  5981. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5982. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5983. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5984. + prix.replace(/\n/g, '') + "\n";
  5985. else
  5986. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5987. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5988. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5989. }
  5990.  
  5991. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5992. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5993. var id_taniere = c.snapshotItem(0).nodeValue;
  5994. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5995.  
  5996. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5997. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5998. if (form)
  5999. {
  6000. if(document.getElementsByTagName('form').length>0)
  6001. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6002. else
  6003. {
  6004. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6005. insertBefore(thisP, form);
  6006. }
  6007. }
  6008. }
  6009.  
  6010. function treateEM()
  6011. {
  6012. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  6013. if(currentURL.indexOf("as_type=Compo")==-1)
  6014. return false;
  6015. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  6016. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  6017. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6018. if (nodes.snapshotLength == 0)
  6019. return false;
  6020. for (var i = 0; i < nodes.snapshotLength; i++) {
  6021. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  6022. var link = desc[2].firstChild ;
  6023. var nomCompoTotal = desc[2].textContent ;
  6024. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6025. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6026. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  6027. var locqual = desc[3].textContent ;
  6028. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  6029. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  6030. if(isEM(nomMonstre).length>0)
  6031. {
  6032. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  6033. if(infos.length>0)
  6034. {
  6035. var shortDescr = "Variable";
  6036. var bold = 0;
  6037. if(infos != "Composant variable")
  6038. {
  6039. shortDescr = infos.substring(0,infos.indexOf(" "));
  6040. if(parseInt(shortDescr)>=0)
  6041. bold=1;
  6042. }
  6043. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  6044. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  6045. }
  6046. }
  6047. }
  6048. }
  6049.  
  6050. function treateChampi() {
  6051. if (currentURL.indexOf('as_type=Champi')==-1)
  6052. return false;
  6053. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  6054. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6055. if (nodes.snapshotLength == 0)
  6056. return false;
  6057.  
  6058. for (var i = 0; i < nodes.snapshotLength; i++) {
  6059. var node = nodes.snapshotItem(i);
  6060. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  6061. if (moisChampi[nomChampi])
  6062. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  6063. }
  6064. }
  6065.  
  6066. function treateEnchant()
  6067. {
  6068. if(currentURL.indexOf("as_type=Compo")==-1)
  6069. return false;
  6070. try
  6071. {
  6072. if(!listeMonstreEnchantement)
  6073. computeCompoEnchantement();
  6074. var nodes = document.evaluate(
  6075. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6076. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6077. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6078. if (nodes.snapshotLength == 0)
  6079. return false;
  6080. var urlImg = URL_MZimg + "enchant.png";
  6081. for (var i = 0; i < nodes.snapshotLength; i++) {
  6082. var link = nodes.snapshotItem(i);
  6083. var nomCompoTotal = link.firstChild.nodeValue;
  6084. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6085. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6086. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  6087. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  6088. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  6089. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  6090. if(isEnchant(nomMonstre).length>0)
  6091. {
  6092. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  6093. if(infos.length>0)
  6094. {
  6095. link.parentNode.appendChild(createImage(urlImg,infos));
  6096. }
  6097. }
  6098. }
  6099. }
  6100. catch(e)
  6101. {
  6102. window.alert(e);
  6103. }
  6104. }
  6105.  
  6106. function treateEquipEnchant()
  6107. {
  6108. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  6109. return false;
  6110. initPopupTabcompo();
  6111. computeEnchantementEquipement(createPopupImage,formateTexte);
  6112. }
  6113.  
  6114. function do_tancompo() {
  6115. start_script();
  6116.  
  6117. treateAllComposants();
  6118. treateComposants();
  6119. traiteMinerai();
  6120. if (MY_getValue('NOINFOEM')!='true') {
  6121. treateChampi();
  6122. treateEM();
  6123. }
  6124. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  6125. treateEnchant();
  6126. treateEquipEnchant();
  6127. }
  6128.  
  6129. displayScriptTime();
  6130. }
  6131.  
  6132. /*******************************************************************************
  6133. * This file is part of Mountyzilla. *
  6134. * *
  6135. * Mountyzilla is free software; you can redistribute it and/or modify *
  6136. * it under the terms of the GNU General Public License as published by *
  6137. * the Free Software Foundation; either version 2 of the License, or *
  6138. * (at your option) any later version. *
  6139. * *
  6140. * Mountyzilla is distributed in the hope that it will be useful, *
  6141. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6142. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6143. * GNU General Public License for more details. *
  6144. * *
  6145. * You should have received a copy of the GNU General Public License *
  6146. * along with Mountyzilla; if not, write to the Free Software *
  6147. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6148. *******************************************************************************/
  6149.  
  6150. // x~x pjview
  6151.  
  6152. /* TODO
  6153. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  6154. */
  6155.  
  6156. // Bulle d'infos
  6157. var DivInfo;
  6158. // Booléen stockant l'état de freezing de la bulle
  6159. var freezed = false;
  6160.  
  6161. // liste du matos
  6162. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  6163. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6164. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  6165. var mh_caracs = {
  6166. 'anneau de protection':
  6167. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  6168. "armure d'anneaux":
  6169. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  6170. 'armure de bois':
  6171. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  6172. 'armure de cuir':
  6173. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  6174. 'armure de peaux':
  6175. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  6176. 'armure de pierre':
  6177. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  6178. 'armure de plates':
  6179. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  6180. 'baton lesté':
  6181. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6182. 'bâtons de parade':
  6183. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6184. 'bottes':
  6185. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6186. 'bouclier à pointes':
  6187. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6188. 'boulet et chaîne':
  6189. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6190. 'cagoule':
  6191. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  6192. 'casque à cornes':
  6193. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6194. 'casque à pointes':
  6195. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  6196. 'casque en cuir':
  6197. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  6198. 'casque en métal':
  6199. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6200. 'chaîne cloutée':
  6201. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6202. 'chapeau pointu':
  6203. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  6204. 'collier de dents':
  6205. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  6206. 'collier de pierre':
  6207. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6208. 'collier à pointes':
  6209. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6210. 'cotte de mailles':
  6211. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  6212. 'couronne de cristal':
  6213. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  6214. "couronne d'obsidienne":
  6215. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  6216. "coutelas d'obsidienne":
  6217. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  6218. 'coutelas en os':
  6219. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  6220. 'crochet':
  6221. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6222. 'cuir bouilli':
  6223. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  6224. "cuirasse d'ossements":
  6225. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  6226. "cuirasse d'écailles":
  6227. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  6228. 'culotte en cuir':
  6229. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6230. 'dague':
  6231. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6232. 'epée courte':
  6233. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6234. 'epée longue':
  6235. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6236. 'espadon':
  6237. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6238. 'fouet':
  6239. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6240. 'fourrures':
  6241. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  6242. 'gantelet':
  6243. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6244. 'gorgeron en cuir':
  6245. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6246. 'gorgeron en métal':
  6247. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  6248. 'gourdin':
  6249. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6250. 'gourdin clouté':
  6251. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6252. 'grimoire':
  6253. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  6254. "gros'porte":
  6255. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  6256. 'grosse racine':
  6257. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6258. 'grosse stalagmite':
  6259. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  6260. 'hache de bataille':
  6261. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6262. 'hache de guerre en os':
  6263. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  6264. 'hache de guerre en pierre':
  6265. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  6266. "hache à deux mains d'obsidienne":
  6267. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  6268. 'hallebarde':
  6269. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  6270. "haubert d'écailles":
  6271. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  6272. 'haubert de mailles':
  6273. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  6274. 'heaume':
  6275. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  6276. 'jambières en cuir':
  6277. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6278. 'jambières en fourrure':
  6279. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  6280. 'jambières en maille':
  6281. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6282. 'jambières en métal':
  6283. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  6284. 'jambières en os':
  6285. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6286. "lame d'obsidienne":
  6287. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  6288. 'lame en os':
  6289. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6290. 'lame en pierre':
  6291. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6292. 'lorgnons':
  6293. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  6294. 'machette':
  6295. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6296. "masse d'arme":
  6297. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6298. 'pagne de mailles':
  6299. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6300. 'pagne en cuir':
  6301. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6302. 'robe de mage':
  6303. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  6304. 'rondache en bois':
  6305. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6306. 'rondache en métal':
  6307. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  6308. 'sandales':
  6309. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6310. 'souliers dorés':
  6311. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6312. "talisman d'obsidienne":
  6313. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  6314. 'talisman de pierre':
  6315. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  6316. 'targe':
  6317. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6318. 'torche':
  6319. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  6320. 'torque de pierre':
  6321. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  6322. 'tunique':
  6323. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6324. "tunique d'écailles":
  6325. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  6326. 'turban':
  6327. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  6328. }
  6329.  
  6330. // liste des templates
  6331. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  6332. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6333. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  6334. var mh_templates = {
  6335. 'de Feu':
  6336. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6337. 'de Résistance':
  6338. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  6339. "de l'Aigle":
  6340. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  6341. 'de la Salamandre':
  6342. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6343. 'des Cyclopes':
  6344. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  6345. 'des Enragés':
  6346. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  6347. 'des Tortues':
  6348. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  6349. 'des Vampires':
  6350. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6351. 'du Glacier':
  6352. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  6353. 'du Rat':
  6354. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6355. 'du Roc':
  6356. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  6357. 'du Temps':
  6358. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  6359. 'du Vent':
  6360. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6361. 'en Mithril':
  6362. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6363. 'des Anciens':
  6364. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6365. 'des Champions':
  6366. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6367. 'des Duellistes':
  6368. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6369. 'de la Terre':
  6370. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  6371. "de l'Orage":
  6372. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  6373. "de l'Ours":
  6374. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  6375. 'des Béhémoths':
  6376. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  6377. 'des Mages':
  6378. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  6379. 'du Pic':
  6380. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  6381. 'du Sable':
  6382. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  6383. 'acéré':
  6384. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6385. 'acérée':
  6386. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6387. 'équilibré':
  6388. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6389. 'équilibrée':
  6390. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6391. 'léger':
  6392. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  6393. 'légère':
  6394. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  6395. 'renforcé':
  6396. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  6397. 'renforcée':
  6398. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  6399. 'robuste':
  6400. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  6401. }
  6402.  
  6403. function clone(arr) {
  6404. // Clonage rapide
  6405. return arr.slice(0);
  6406. }
  6407.  
  6408. function addArray(arr1,arr2) {
  6409. // Somme matricielle
  6410. var res = clone(arr1);
  6411. for(i=res.length-1 ; i>=0 ; i--) {
  6412. res[i] += arr2[i];
  6413. }
  6414. return res;
  6415. }
  6416.  
  6417. function getTemplates(nomItem) {
  6418. // Déstructure le nom de l'item en array [nom, template1, ...]
  6419. var tempFound = true;
  6420. var str = nomItem.trim();
  6421. var arr = [];
  6422. while(tempFound) {
  6423. tempFound = false;
  6424. for(var temp in mh_templates) {
  6425. // on teste la fin du nom contre chaque template
  6426. if(str.slice(-temp.length)!=temp) { continue; }
  6427. tempFound = true;
  6428. str = str.slice(0,-temp.length-1);
  6429. arr.unshift(temp);
  6430. if(str.slice(-3)==' et') {
  6431. str = str.slice(0,-3);
  6432. }
  6433. }
  6434. }
  6435. arr.unshift(str);
  6436. return arr;
  6437. }
  6438.  
  6439. function addMithril(arrayCaracs,typeItem) {
  6440. // Ajoute l'effet du Mithril sur les caracs
  6441. if(typeItem=='arme') {
  6442. if(arrayCaracs[0]<0) {
  6443. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  6444. }
  6445. }
  6446. else {
  6447. if(arrayCaracs[4]<0) {
  6448. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  6449. }
  6450. }
  6451. arrayCaracs[15] /= 2;
  6452. arrayCaracs[16] /= 2;
  6453. return arrayCaracs;
  6454. }
  6455.  
  6456. function addRenfort(arrayCaracs,template) {
  6457. // Ajoute l'effet des pseudo-templates sur les caracs
  6458. // S'applique APRÈS le mithril
  6459. // WARNING - Cette formule n'a rien d'officiel, gare !
  6460. var coef = 0;
  6461. if(/^lég[e,è]re?$/.test(template)) {
  6462. coef = -1;
  6463. }
  6464. else if(/^renforcée?$/.test(template)
  6465. || template==='robuste') {
  6466. coef = 1;
  6467. }
  6468. if(coef) {
  6469. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  6470. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  6471. }
  6472. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  6473. return arrayCaracs;
  6474. }
  6475.  
  6476. function getCaracs(item) {
  6477. // Calcule les caractéristiques de l'item
  6478. var templates = getTemplates(item);
  6479. if(!mh_caracs[templates[0]]) {
  6480. // Si l'item est inconnu
  6481. return [];
  6482. }
  6483. var caracs = clone(mh_caracs[templates[0]]);
  6484. var typeItem = caracs[0];
  6485. caracs.shift();
  6486. templates.shift();
  6487. if(templates[templates.length-1]=='en Mithril') {
  6488. caracs = addMithril(caracs,typeItem);
  6489. templates.pop();
  6490. }
  6491. if(/^acérée?$/.test(templates[0])
  6492. || /^équilibrée?$/.test(templates[0])
  6493. || /^lég[e,è]re?$/.test(templates[0])
  6494. || /^renforcée?$/.test(templates[0])
  6495. || templates[0]=='robuste') {
  6496. caracs = addRenfort(caracs,templates[0]);
  6497. templates.shift();
  6498. }
  6499. for(var i=templates.length-1 ; i>=0 ; i--) {
  6500. caracs = addArray(caracs,mh_templates[templates[i]]);
  6501. }
  6502. return caracs;
  6503. }
  6504.  
  6505. function getLine(tab) {
  6506. // Préparation de la ligne à afficher lors d'un mouseover
  6507. var str = '';
  6508. if(tab[0]!=0 || tab[1]!=0) {
  6509. str += '<b>Att : </b>'+aff(tab[0]);
  6510. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  6511. str += ' | ';
  6512. }
  6513. if(tab[4]!=0) {
  6514. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  6515. }
  6516. if(tab[2]!=0 || tab[3]!=0) {
  6517. str += '<b>Deg : </b>'+aff(tab[2]);
  6518. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  6519. str += ' | ';
  6520. }
  6521. if(tab[8]!=0) {
  6522. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  6523. }
  6524. if(tab[7]!=0) {
  6525. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  6526. }
  6527. if(tab[5]!=0 || tab[6]!=0) {
  6528. str += '<b>Arm : </b>'+aff(tab[5]);
  6529. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  6530. str += ' | ';
  6531. }
  6532. if(tab[9]!=0 || tab[10]!=0) {
  6533. str += '<b>RM : </b>'+aff(tab[9])+'%';
  6534. if(tab[9]!=tab[10]) {
  6535. str += '/'+aff(tab[10])+'%';
  6536. }
  6537. str += ' | ';
  6538. }
  6539. if(tab[11]!=0 || tab[12]!=0) {
  6540. str += '<b>MM : </b>'+aff(tab[11])+'%';
  6541. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  6542. str += ' | ';
  6543. }
  6544. if(tab[13]!=0) {
  6545. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  6546. }
  6547. if(tab[14]!=0) {
  6548. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  6549. }
  6550. str += '<b>Poids : </b>'+tab[15]+' min';
  6551. if(tab[15]!=tab[16]) {
  6552. str += ' / '+tab[16]+' min';
  6553. }
  6554. return str;
  6555. }
  6556.  
  6557. function toolTipInit() {
  6558. DivInfo = document.createElement('div');
  6559. DivInfo.id = 'infosVue';
  6560. DivInfo.className = 'mh_textbox';
  6561. DivInfo.style =
  6562. 'position: absolute;'
  6563. +'border: 1px solid #000000;'
  6564. +'visibility:hidden;'
  6565. +'display:inline;'
  6566. +'z-index:99;';
  6567. document.body.appendChild(DivInfo);
  6568. document.onmousemove = getXY;
  6569. document.onclick = changeFreezeStatus;
  6570. }
  6571.  
  6572. function getXY(evt) {
  6573. if(!freezed && DivInfo.style.visibility=='visible') {
  6574. DivInfo.style.left = evt.pageX+'px';
  6575. DivInfo.style.top = evt.pageY+10+'px';
  6576. }
  6577. }
  6578.  
  6579. function changeFreezeStatus() {
  6580. if(DivInfo.style.visibility=='visible') {
  6581. freezed = !freezed;
  6582. if(!freezed) { hideInfos(); }
  6583. }
  6584. }
  6585.  
  6586. function showInfos() {
  6587. if(freezed) { return; }
  6588. var currentInfos = this.infos;
  6589. DivInfo.innerHTML = currentInfos;
  6590. DivInfo.style.visibility = 'visible';
  6591. }
  6592.  
  6593. function hideInfos() {
  6594. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6595. }
  6596.  
  6597. function treateEquipement() {
  6598. // Extrait les données du matos et réinjecte les infos déduites
  6599. if(MY_getValue('INFOCARAC')=='false') { return; }
  6600. var faireLigne = false;
  6601. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6602. var nodes = document.evaluate(
  6603. "//td/b[text()='Equipement Utilisé']/../../"
  6604. +"td[2]/img[contains(@src,bullet)]",
  6605. document, null, 7, null);
  6606. if(nodes.snapshotLength>0) {
  6607. // Si CSS de base
  6608. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6609. var node = nodes.snapshotItem(i);
  6610. var next = node.nextSibling;
  6611. var nnext = next.nextSibling;
  6612. var nom = next.nodeValue.toLowerCase();
  6613. if(nnext.childNodes.length==1) {
  6614. nom += nnext.firstChild.nodeValue;
  6615. }
  6616. nom = nom.trim();
  6617. // gestion winpostrophe
  6618. var c = String.fromCharCode(180);
  6619. while(nom.indexOf(c)!=-1) {
  6620. nom = nom.replace(c,"'");
  6621. }
  6622. var arr = getCaracs(nom);
  6623. if(arr.length>0) {
  6624. faireLigne = true;
  6625. caracs = addArray(caracs,arr);
  6626. var span = document.createElement('span');
  6627. span.appendChild(next);
  6628. span.appendChild(nnext);
  6629. span.infos = getLine(arr);
  6630. span.onmouseover = showInfos;
  6631. span.onmouseout = hideInfos;
  6632. insertBefore(node.nextSibling,span);
  6633. }
  6634. }
  6635. if(faireLigne) {
  6636. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6637. document, null, 9, null).singleNodeValue;
  6638. node.infos = getLine(caracs);
  6639. node.onmouseover = showInfos;
  6640. node.onmouseout = hideInfos;
  6641. }
  6642. }
  6643. else {
  6644. // Si CSS avancée
  6645. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6646. document, null, 7, null);
  6647. if(nodes.snapshotLength>0) {
  6648. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6649. var node = nodes.snapshotItem(i);
  6650. var nom = node.firstChild.nodeValue.toLowerCase();
  6651. if(node.childNodes.length>1) {
  6652. nom += node.childNodes[1].firstChild.nodeValue;
  6653. }
  6654. nom = nom.trim();
  6655. // gestion winpostrophe
  6656. var c = String.fromCharCode(180);
  6657. while(nom.indexOf(c)!=-1) {
  6658. nom = nom.replace(c,"'");
  6659. }
  6660. var arr = getCaracs(nom);
  6661. if(arr.length!=0) {
  6662. caracs = addArray(caracs,arr);
  6663. node.infos = getLine(arr);
  6664. node.onmouseover = showInfos;
  6665. node.onmouseout = hideInfos;
  6666. }
  6667. }
  6668. var nodes = document.evaluate("//dt[@class='equipement']",
  6669. document, null, 7, null);
  6670. var node = nodes.snapshotItem(0);
  6671. node.infos = getLine(caracs);
  6672. node.onmouseover = showInfos;
  6673. node.onmouseout = hideInfos;
  6674. }
  6675. }
  6676. }
  6677.  
  6678. function do_pjview() {
  6679. treateEquipement();
  6680. toolTipInit();
  6681. }
  6682.  
  6683. /*******************************************************************************
  6684. * This file is part of Mountyzilla. *
  6685. * *
  6686. * Mountyzilla is free software; you can redistribute it and/or modify *
  6687. * it under the terms of the GNU General Public License as published by *
  6688. * the Free Software Foundation; either version 2 of the License, or *
  6689. * (at your option) any later version. *
  6690. * *
  6691. * Mountyzilla is distributed in the hope that it will be useful, *
  6692. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6693. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6694. * GNU General Public License for more details. *
  6695. * *
  6696. * You should have received a copy of the GNU General Public License *
  6697. * along with Mountyzilla; if not, write to the Free Software *
  6698. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6699. *******************************************************************************/
  6700.  
  6701. // x~x option
  6702.  
  6703. /* TODO
  6704. * Passer le HTML injecté aux conventions HTML5
  6705. */
  6706.  
  6707.  
  6708. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6709.  
  6710. function saveITData() {
  6711. var IT = document.getElementById('itSelect').value;
  6712. if(IT=='bricol') {
  6713. var nBricol = 1;
  6714. for (var iBricol = 0; ; iBricol++) {
  6715. var extClef = nBricol == 1 ? '' : nBricol;
  6716. var eltSystem = document.getElementById('urlbricol'+iBricol);
  6717. if (eltSystem == undefined) break;
  6718. var system = eltSystem.value;
  6719. window.console.log("[MZ] saveITData system=" + system);
  6720. var login = document.getElementById('loginbricol'+iBricol).value;
  6721. var pass = document.getElementById('passbricol'+iBricol).value;
  6722. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6723. if(system && login) {
  6724. if (pass) {
  6725. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6726. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  6727. //window.console.log('v=' + v);
  6728. } else {
  6729. // vérif que rien n'a changé
  6730. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  6731. if(str) {
  6732. var arr = str.split('$');
  6733. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6734. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  6735. }
  6736. }
  6737. }
  6738. nBricol++;
  6739. }
  6740. }
  6741. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  6742. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  6743. }
  6744. else {
  6745. MY_removeValue(numTroll+'.INFOSIT');
  6746. }
  6747. }
  6748.  
  6749. function saveLinks() {
  6750. var numLinks = document.getElementById('linksBody').childNodes.length;
  6751. var data=[ [] ];
  6752. /* Récupération et tri des liens */
  6753. for(var i=1 ; i<=numLinks ; i++) {
  6754. MY_removeValue('URL'+i);
  6755. MY_removeValue('URL'+i+'.nom');
  6756. MY_removeValue('URL'+i+'.ico');
  6757. var url = document.getElementById('url'+i).value;
  6758. var nom = document.getElementById('nom'+i).value;
  6759. var ico = document.getElementById('ico'+i).value;
  6760. if(url && (nom || ico) ) {
  6761. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6762. }
  6763. }
  6764. /* Sauvegarde */
  6765. for(var i=1 ; i<data.length ; i++) {
  6766. MY_setValue('URL'+i,data[i][0]);
  6767. MY_setValue('URL'+i+'.nom',data[i][1]);
  6768. MY_setValue('URL'+i+'.ico',data[i][2]);
  6769. }
  6770. }
  6771.  
  6772. function saveAll() {
  6773. try {
  6774. var urlIco = document.getElementById('icoMenuIco').value;
  6775. if(urlIco) {
  6776. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6777. }
  6778. else {
  6779. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6780. document.getElementById('icoMenuIco').value = '';
  6781. }
  6782. saveLinks();
  6783. refreshLinks();
  6784. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6785. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6786. if(maxcdm) {
  6787. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6788. }
  6789. else {
  6790. MY_removeValue(numTroll+'.MAXCDM');
  6791. document.getElementById('maxcdm').value = '';
  6792. }
  6793.  
  6794. MY_setValue('NOINFOEM',
  6795. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6796. // Pourquoi Tilk stockait-il tout en str ?
  6797. // -> parce que les booléens c'est foireux (vérifié)
  6798. MY_setValue(numTroll+'.USECSS',
  6799. document.getElementById('usecss').checked ? 'true':'false');
  6800. MY_setValue('INFOCARAC',
  6801. document.getElementById('infocarac').checked ? 'true' : 'false');
  6802. //MY_setValue(numTroll+'.SEND_IDT',
  6803. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6804. // Fonctionnalité désactivée
  6805.  
  6806. MY_setValue(numTroll+'.AUTOCDM',
  6807. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6808. MY_setValue('VUECARAC',
  6809. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6810. MY_setValue('CONFIRMEDECALAGE',
  6811. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6812.  
  6813. saveITData();
  6814. } catch (e) {
  6815. var bouton = document.getElementById('saveAll');
  6816. window.console.log(e);
  6817. bouton.value = "il y a eu une erreur";
  6818. return;
  6819. }
  6820.  
  6821. var bouton = document.getElementById('saveAll');
  6822. bouton.value = (bouton.value=='Sauvegardé !') ?
  6823. 'Re-sauvegardé !' : 'Sauvegardé !';
  6824. }
  6825.  
  6826.  
  6827. /*-[functions]----------------- EventListeners -------------------------------*/
  6828.  
  6829. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  6830. var itBody = document.getElementById('itBody');
  6831. var nTr = itBody.rows.length;
  6832. // enlever tous les "+" des lignes précédentes
  6833. for (iTr = 0; iTr < nTr; iTr++) {
  6834. var td = itBody.rows[iTr].cells[0];
  6835. td.innerHTML = '';
  6836. td.title = '';
  6837. td.style.cursor = 'default';
  6838. }
  6839. // ajouter une ligne
  6840. var tr = appendTr(itBody,'mh_tdpage')
  6841. var td = appendTd(tr);
  6842. if (bLast) {
  6843. td.style.whiteSpace = 'nowrap';
  6844. appendText(td, '+');
  6845. td.style.cursor = 'pointer';
  6846. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  6847. td.onclick = function (e) {
  6848. addBricolIT(undefined, undefined, undefined, false, true);
  6849. }
  6850. }
  6851. var td = appendTd(tr);
  6852. td.style.whiteSpace = 'nowrap';
  6853. appendText(td,'Nom du système : ');
  6854. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  6855. td = appendTd(tr);
  6856. td.style.whiteSpace = 'nowrap';
  6857. appendText(td,'Login du compte : ');
  6858. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  6859. td = appendTd(tr);
  6860. td.style.whiteSpace = 'nowrap';
  6861. appendText(td,'Mot de passe du compte : ');
  6862. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  6863. td = appendTd(tr);
  6864. if (bFirst) {
  6865. td.style.whiteSpace = 'nowrap';
  6866. appendText(td,'Affichage des Trõlls hors vue : ');
  6867. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  6868. }
  6869. }
  6870.  
  6871. function onChangeIT() {
  6872. var IT = document.getElementById('itSelect').value;
  6873. var itBody = document.getElementById('itBody');
  6874. itBody.innerHTML = '';
  6875. var tabStr = new Array();
  6876. if(IT=='bricol') {
  6877. for (var iBricol = 1; ; iBricol++) {
  6878. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  6879. //window.console.log('onChangeIT str=' + str);
  6880. if(str) {
  6881. tabStr.push(str);
  6882. } else {
  6883. break;
  6884. }
  6885. }
  6886. if (tabStr.length == 0) {
  6887. addBricolIT('', '', 0, true, true)
  6888. } else {
  6889. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  6890. var arr = tabStr[iBricol].split('$');
  6891. var system = arr[1];
  6892. var login = arr[2];
  6893. var affhv = arr[4];
  6894. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  6895. }
  6896. }
  6897. }
  6898. }
  6899.  
  6900. function refreshLinks() {
  6901. document.getElementById('linksBody').innerHTML = '';
  6902. var anotherURL = MY_getValue('URL1');
  6903. if(!anotherURL) { addLinkField(); }
  6904. var i=1;
  6905. while(anotherURL && i<99) {
  6906. addLinkField(i,anotherURL,
  6907. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6908. i++;
  6909. anotherURL = MY_getValue('URL'+i);
  6910. }
  6911. }
  6912.  
  6913. function addLinkField(i,url,nom,ico) {
  6914. var linksBody = document.getElementById('linksBody');
  6915. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6916. var tr = appendTr(linksBody);
  6917. var td = appendTdCenter(tr);
  6918. appendText(td,'Lien '+i+' : ');
  6919. appendTextbox(td,'text','url'+i,40,150,url);
  6920. td = appendTdCenter(tr);
  6921. appendText(td,'Nom : ');
  6922. appendTextbox(td,'text','nom'+i,20,150,nom);
  6923. td = appendTdCenter(tr);
  6924. appendText(td,'Icône : ');
  6925. appendTextbox(td,'text','ico'+i,40,150,ico);
  6926. }
  6927.  
  6928. function removeLinkField() {
  6929. var linksBody = document.getElementById('linksBody');
  6930. var i = linksBody.childNodes.length;
  6931. MY_removeValue('URL'+i);
  6932. MY_removeValue('URL'+i+'.nom');
  6933. MY_removeValue('URL'+i+'.ico');
  6934. linksBody.removeChild(linksBody.lastChild);
  6935. if(linksBody.childNodes.length==0) { addLinkField(); }
  6936. }
  6937.  
  6938. function resetMainIco() {
  6939. document.getElementById('icoMenuIco').value=
  6940. URL_MZimg + 'mz_logo_small.png';
  6941. }
  6942.  
  6943.  
  6944. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6945.  
  6946. function insertTitle(next,txt) {
  6947. var div = document.createElement('div');
  6948. div.className = 'titre2';
  6949. appendText(div,txt);
  6950. insertBefore(next,div);
  6951. return div;
  6952. }
  6953.  
  6954. function insertMainTable(next) {
  6955. var table = document.createElement('table');
  6956. table.width = '98%';
  6957. table.border = 0;
  6958. table.align = 'center';
  6959. table.cellPadding = 2;
  6960. table.cellSpacing = 1;
  6961. table.className = 'mh_tdborder';
  6962. var tbody = document.createElement('tbody');
  6963. table.appendChild(tbody);
  6964. insertBefore(next,table);
  6965. return tbody;
  6966. }
  6967.  
  6968. function appendSubTable(node) {
  6969. var table = document.createElement('table');
  6970. table.width = '100%';
  6971. var tbody = document.createElement('tbody');
  6972. table.appendChild(tbody);
  6973. node.appendChild(table);
  6974. return tbody;
  6975. }
  6976.  
  6977. function insertOptionTable(insertPt) {
  6978. var mainBody = insertMainTable(insertPt);
  6979. /* Liens dans le Menu */
  6980. var tr = appendTr(mainBody,'mh_tdtitre');
  6981. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6982. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6983. appendText(td,'Icône du Menu: ');
  6984. var url = MY_getValue(numTroll+'.ICOMENU');
  6985. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6986. url = URL_MZimg + 'mz_logo_small.png';
  6987. }
  6988. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6989. appendButton(td,'Réinitialiser',resetMainIco);
  6990. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6991. var tbody = appendSubTable(td);
  6992. tbody.id = 'linksBody';
  6993. refreshLinks();
  6994. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6995. appendButton(td,'Ajouter',addLinkField);
  6996. appendButton(td,'Supprimer',removeLinkField);
  6997. /* Options de la Vue : vue externe, nb de CdM, etc */
  6998. tr = appendTr(mainBody,'mh_tdtitre');
  6999. appendTdText(tr,'Options de la Vue :',true);
  7000. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7001. tbody = appendSubTable(td);
  7002. tr = appendTr(tbody);
  7003. td = appendTdText(tr,'Vue externe : ');
  7004. var select = document.createElement('select');
  7005. select.id = 'vueext';
  7006. td.appendChild(select);
  7007. var listeVues2D = [
  7008. 'Bricol\' Vue',
  7009. 'Vue du CCM',
  7010. 'Vue Gloumfs 2D',
  7011. 'Vue Gloumfs 3D',
  7012. 'Grouky Vue!'
  7013. ];
  7014. for(var i=0 ; i<listeVues2D.length ; i++) {
  7015. appendOption(select,listeVues2D[i],listeVues2D[i]);
  7016. }
  7017. if(MY_getValue('VUEEXT')) {
  7018. select.value = MY_getValue('VUEEXT');
  7019. }
  7020. td = appendTd(tr);
  7021. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  7022. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  7023. tr = appendTr(tbody);
  7024. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  7025. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  7026. td = appendTd(tr);
  7027. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  7028. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  7029. /* Interface Tactique */
  7030. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7031. appendText(td,'Interface Tactique : ',true);
  7032. select = document.createElement('select');
  7033. select.id = 'itSelect';
  7034. appendOption(select,'none','Aucune');
  7035. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  7036. // seule interface supportée !
  7037. td.appendChild(select);
  7038. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7039. tbody = appendSubTable(td);
  7040. tbody.id = 'itBody';
  7041. select.onchange = onChangeIT;
  7042. var str = MY_getValue(numTroll+'.INFOSIT');
  7043. if(str) {
  7044. select.value = str.slice(0,str.indexOf('$'));
  7045. onChangeIT();
  7046. }
  7047. /* Options diverses */
  7048. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7049. appendText(td,'Options diverses :',true);
  7050. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7051. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  7052. appendText(td,
  7053. ' Afficher les caractéristiques des équipements des autres Trõlls');
  7054. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7055. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  7056. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  7057. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7058. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  7059. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  7060. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7061. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  7062. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  7063. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7064. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  7065. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  7066. /* Bouton SaveAll */
  7067. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  7068. input = appendButton(td,'Sauvegarder',saveAll);
  7069. input.id = 'saveAll';
  7070. }
  7071.  
  7072. function insertCreditsTable(insertPt) {
  7073. var tbody = insertMainTable(insertPt);
  7074. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  7075. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  7076. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  7077.  
  7078. var ul = document.createElement('ul');
  7079. td.appendChild(ul);
  7080. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  7081. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  7082. appendLI(ul,'Reivax (4234) pour les infos bulles');
  7083. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  7084. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  7085. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  7086. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  7087. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  7088. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  7089. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  7090. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  7091. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  7092. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  7093. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  7094. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  7095. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  7096. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  7097. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  7098. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  7099. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  7100. }
  7101.  
  7102.  
  7103. /* [functions] Obsolètes */
  7104. function deleteEnchantement()
  7105. {
  7106. try
  7107. {
  7108. var idEquipement = this.getAttribute('name');
  7109. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  7110. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  7111. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  7112. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  7113. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  7114. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7115. var string = "";
  7116. for(var i=0;i<listeEquipement.length;i++)
  7117. {
  7118. if(listeEquipement[i]!=idEquipement)
  7119. if(string=="")
  7120. string = listeEquipement[i];
  7121. else
  7122. string += ";"+listeEquipement[i];
  7123. }
  7124. if(string=="")
  7125. {
  7126. MY_removeValue(numTroll+".enchantement.liste");
  7127. var table = this.parentNode.parentNode.parentNode.parentNode;
  7128. var parent = table.parentNode;
  7129. for(var i=0;i<parent.childNodes.length;i++)
  7130. {
  7131. if(parent.childNodes[i]==table)
  7132. {
  7133. parent.removeChild(parent.childNodes[i-1]);
  7134. parent.removeChild(parent.childNodes[i-1]);
  7135. parent.removeChild(parent.childNodes[i-1]);
  7136. break;
  7137. }
  7138. }
  7139. }
  7140. else
  7141. {
  7142. MY_getValue(numTroll+".enchantement.liste",string);
  7143. this.parentNode.parentNode.parentNode
  7144. .removeChild(this.parentNode.parentNode);
  7145. }
  7146. }
  7147. catch(e)
  7148. {
  7149. window.alert(e);
  7150. }
  7151. }
  7152. /* [functions] fin Obsolètes */
  7153.  
  7154. /*-[functions]---------------- Partie principale -----------------------------*/
  7155.  
  7156. function do_option() {
  7157. start_script(712);
  7158. var insertPoint = document.getElementById('footer1');
  7159. insertBefore(insertPoint,document.createElement('p'));
  7160. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  7161. ti.onclick = function (e) {
  7162. var evt = e || window.event;
  7163. if (evt.shiftKey) {
  7164. var txt = '';
  7165. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  7166. var k = localStorage.key(i);
  7167. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  7168. txt += k + "\t" + localStorage.getItem(k) + "\n";
  7169. }
  7170. copyTextToClipboard(txt);
  7171. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  7172. } else if (evt.ctrlKey) {
  7173. var tabK= [];
  7174. var sMatch = numTroll + '.';
  7175. var lMatch = sMatch.length;
  7176. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  7177. var k = localStorage.key(i);
  7178. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  7179. }
  7180. for (var i = 0; i < tabK.length; ++i ) {
  7181. MY_removeValue(tabK[i]);
  7182. }
  7183. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  7184. }
  7185. }
  7186. ti.title = 'Version ' + GM_info.script.version;
  7187. insertOptionTable(insertPoint);
  7188. /* insertion enchantements ici
  7189. if(...)
  7190. insertEnchantementTable();
  7191. */
  7192. insertBefore(insertPoint,document.createElement('p'));
  7193. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  7194. ti.onclick = function (e) {
  7195. var evt = e || window.event;
  7196. if (!evt.shiftKey) return;
  7197. var oldDev = MY_getValue('MZ_dev');
  7198. if (oldDev) {
  7199. MY_removeValue('MZ_dev');
  7200. } else {
  7201. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  7202. MY_setValue('MZ_dev', 1);
  7203. }
  7204. document.location.href = document.location.href;
  7205. }
  7206. insertCreditsTable(insertPoint);
  7207. insertBefore(insertPoint,document.createElement('p'));
  7208.  
  7209. /* [zone] Obsolète ?? */
  7210. if(MY_getValue(numTroll+".enchantement.liste")
  7211. && MY_getValue(numTroll+".enchantement.liste")!="" )
  7212. {
  7213. insertTitle(insertPoint, 'Les Enchantements en cours');
  7214. table = document.createElement('table');
  7215. table.setAttribute('width', '98%');
  7216. table.setAttribute('border', '0');
  7217. table.setAttribute('align', 'center');
  7218. table.setAttribute('cellpadding', '2');
  7219. table.setAttribute('cellspacing', '1');
  7220. table.setAttribute('class', 'mh_tdborder');
  7221.  
  7222. tbody = document.createElement('tbody');
  7223. table.appendChild(tbody);
  7224. tr = appendTr(tbody, 'mh_tdtitre');
  7225. appendTdText(tr, 'Equipement',1);
  7226. appendTdText(tr, 'Composants',1);
  7227. appendTdText(tr, 'Enchanteur',1);
  7228. appendTdText(tr, 'Action',1);
  7229. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7230. for(var i=0;i<listeEquipement.length;i++)
  7231. {
  7232. try
  7233. {
  7234. var idEquipement = listeEquipement[i];
  7235. var nomEquipement = MY_getValue(numTroll+".enchantement."
  7236. +idEquipement+".objet");
  7237. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  7238. +idEquipement+".enchanteur").split(";");
  7239. var ul = document.createElement('UL');
  7240. for(var j=0;j<3;j++)
  7241. {
  7242. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  7243. var v = MY_getValue(k);
  7244. if (v == null) { // protection Roule 26/08/2017
  7245. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  7246. continue;
  7247. }
  7248. var infoComposant = v.split(';');
  7249. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  7250. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  7251. continue;
  7252. }
  7253. var texte = infoComposant[4].replace("Ril ","Œil ");
  7254. for(var k=5;k<infoComposant.length;k++)
  7255. {
  7256. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  7257. }
  7258. li = appendLI(ul,texte);
  7259. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  7260. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  7261. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  7262. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  7263. string+= '<input type="hidden" name="q" value="min" />';
  7264. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  7265. 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>';
  7266.  
  7267. string+= '</form>';
  7268. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  7269. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  7270. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  7271. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  7272. li.innerHTML += string;
  7273. }
  7274. tr = appendTr(tbody, 'mh_tdpage');
  7275. td = appendTdText(tr, nomEquipement);
  7276. td.setAttribute('valign', 'center');
  7277. td = document.createElement('td');
  7278. td.appendChild(ul);
  7279. tr.appendChild(td);
  7280. td.setAttribute('valign', 'center');
  7281. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  7282. td.setAttribute('valign', 'center');
  7283. td = document.createElement('td');
  7284. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  7285. input.setAttribute('name', idEquipement);
  7286. tr.appendChild(td);
  7287. td.setAttribute('valign', 'center');
  7288. }
  7289. catch(e)
  7290. {
  7291. }
  7292. }
  7293. insertBefore(insertPoint, table);
  7294. insertBefore(insertPoint, document.createElement('p'));
  7295. }
  7296. /* [zone] fin Obsolète ?? */
  7297.  
  7298.  
  7299. displayScriptTime();
  7300. }
  7301.  
  7302. /*******************************************************************************
  7303. * This file is part of Mountyzilla. *
  7304. * *
  7305. * Mountyzilla is free software; you can redistribute it and/or modify *
  7306. * it under the terms of the GNU General Public License as published by *
  7307. * the Free Software Foundation; either version 2 of the License, or *
  7308. * (at your option) any later version. *
  7309. * *
  7310. * Mountyzilla is distributed in the hope that it will be useful, *
  7311. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7312. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7313. * GNU General Public License for more details. *
  7314. * *
  7315. * You should have received a copy of the GNU General Public License *
  7316. * along with Mountyzilla; if not, write to the Free Software *
  7317. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7318. *******************************************************************************/
  7319.  
  7320. // x~x equip
  7321.  
  7322. /**
  7323. * 2014-02-08 - v2.0a (from scratch)
  7324. * 2014-02-18 - v2.0a0
  7325. * - ajout calcul Carats / UM des minerais + totaux
  7326. * 2014-03-06 - v2.0a1
  7327. * - retour Infos EM des Champis
  7328. * TODO
  7329. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  7330. */
  7331.  
  7332. function traiteChampis() {
  7333. try{
  7334. var tr = document.getElementById('mh_objet_hidden_Champignon');
  7335. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  7336. }
  7337. catch(e){return;}
  7338. if(trlist.length<=0) return;
  7339. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  7340. var node = trlist.snapshotItem(i).childNodes[7];
  7341. var str = node.textContent.trim();
  7342. var type = str.slice(0,str.lastIndexOf(' '));
  7343. var mundi = mundiChampi[type];
  7344. if(!mundi) continue;
  7345. var urlImg = URL_MZimg
  7346. +'Competences/ecritureMagique.png';
  7347. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  7348. appendText(node,' ');
  7349. node.appendChild(img);
  7350. }
  7351. }
  7352.  
  7353. function traiteCompos() {
  7354. try {
  7355. var tr = document.getElementById('mh_objet_hidden_Composant');
  7356. var tbody = document.evaluate("./td/table/tbody",
  7357. tr, null, 9, null).singleNodeValue;
  7358. }
  7359. catch(e) {return;}
  7360. insererInfosEM(tbody);
  7361. }
  7362.  
  7363. function traiteMinerai() {
  7364. try{
  7365. var tr = document.getElementById('mh_objet_hidden_Minerai');
  7366. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  7367. }
  7368. catch(e){return;}
  7369. if(trlist.length<=0) return;
  7370. var totaux = {};
  7371. var str;
  7372. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  7373. var node = trlist.snapshotItem(i);
  7374. var nature = node.childNodes[7].textContent,
  7375. caracs = node.childNodes[9].textContent;
  7376. var taille = Number(caracs.match(/\d+/)[0]);
  7377. var coef = 1;
  7378. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  7379. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  7380. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  7381. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  7382. if(nature.indexOf('Mithril')!=-1) {
  7383. coef = 0.2*coef;
  7384. str = ' | UM: ';
  7385. }
  7386. else {
  7387. coef = 0.75*coef+1.25;
  7388. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  7389. str = ' | Carats: ';
  7390. }
  7391. var carats = Math.round(taille*coef)
  7392. appendText(node.childNodes[9], str+carats );
  7393. if(!totaux[nature]) {
  7394. totaux[nature] = [taille,carats];
  7395. }
  7396. else {
  7397. totaux[nature][0] += taille;
  7398. totaux[nature][1] += carats;
  7399. }
  7400. }
  7401. str = 'Total : ';
  7402. for(var nature in totaux) {
  7403. if(str.length>8) str += ', ';
  7404. if(nature.indexOf('Mithril')!=-1) {
  7405. str += nature+totaux[nature][1]+' UM';
  7406. }
  7407. else {
  7408. str += nature+totaux[nature][0]+'U/'
  7409. +totaux[nature][1]+'c';
  7410. }
  7411. }
  7412. /*var node = document.getElementById('mh_plus_Minerai');
  7413. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  7414. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  7415. if(!titre) return;*/
  7416. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  7417. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  7418. td.colSpan = 7;
  7419. }
  7420.  
  7421. function do_equip() {
  7422. start_script();
  7423.  
  7424. traiteChampis();
  7425. traiteCompos();
  7426. traiteMinerai();
  7427.  
  7428. displayScriptTime();
  7429. }
  7430.  
  7431. /*******************************************************************************
  7432. * This file is part of Mountyzilla. *
  7433. * *
  7434. * Mountyzilla is free software; you can redistribute it and/or modify *
  7435. * it under the terms of the GNU General Public License as published by *
  7436. * the Free Software Foundation; either version 2 of the License, or *
  7437. * (at your option) any later version. *
  7438. * *
  7439. * Mountyzilla is distributed in the hope that it will be useful, *
  7440. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7441. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7442. * GNU General Public License for more details. *
  7443. * *
  7444. * You should have received a copy of the GNU General Public License *
  7445. * along with Mountyzilla; if not, write to the Free Software *
  7446. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7447. *******************************************************************************/
  7448.  
  7449. // x~x diplo
  7450.  
  7451. /*
  7452. TODO:
  7453. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  7454. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  7455. V Étape 3: Ajout de la diplo perso
  7456. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  7457. V Étape 5: Ajout des fioritures (preview de la couleur...)
  7458. Options Globales:
  7459. Actuelles:
  7460. numTroll.USECSS,
  7461. numTroll.NODIPLO
  7462. NOMYTH
  7463. Nouvelles:
  7464. TODO numTroll.USECSS
  7465. numTroll.diplo.off (remplace NODIPLO)
  7466. numTroll.diplo.guilde
  7467. numTroll.diplo.perso
  7468. Structure de diplo.guilde:
  7469. isOn: 'true' ou 'false'
  7470. isDetailOn: 'true' ou 'false'
  7471. guilde
  7472. > id
  7473. > couleur
  7474. AllAmis,AllEnnemis: couleur
  7475. Amis0,...,Ennemis5
  7476. > Troll: idTroll1;...;
  7477. > Guilde: idGuilde1;...;
  7478. > titre
  7479. > couleur
  7480. Structure de diplo.perso:
  7481. isOn: 'true' ou 'false'
  7482. mythiques: couleur
  7483. Troll,Guilde,Monstre:
  7484. > id
  7485. > couleur
  7486. > description
  7487. */
  7488.  
  7489. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7490.  
  7491. function couleurAleatoire() {
  7492. var alph = '0123456789ABCDEF'.split('');
  7493. var clr = '#';
  7494. for (var i=0; i<6; i++) {
  7495. clr+=alph[ Math.floor(16*Math.random()) ];
  7496. }
  7497. return clr;
  7498. }
  7499.  
  7500. function isCouleur(str) {
  7501. return /^#[0-9A-F]{6}$/i.test(str);
  7502. }
  7503.  
  7504. /*-[functions]---------------- Analyse de la page ----------------------------*/
  7505.  
  7506. function appendChoixCouleur(node,id) {
  7507. var span = document.createElement('span');
  7508. span.id = 'span'+id;
  7509. if(isDetailOn) {
  7510. span.style.display = 'none';
  7511. }
  7512. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  7513. if(diploGuilde[id]) {
  7514. couleur = diploGuilde[id];
  7515. }
  7516. appendText(span,' - Couleur HTML: ');
  7517. var input = appendTextbox(span,'text',id,7,7,couleur);
  7518. input.onkeyup = previewCouleur;
  7519. input.onchange = previewCouleur;
  7520. input.onkeyup();
  7521. node.appendChild(span);
  7522. }
  7523.  
  7524. function insertChoixCouleur(node,id) {
  7525. var span = document.createElement('span');
  7526. span.id = 'span'+id;
  7527. // La couleur détaillée passera à une valeur aléatoire
  7528. // si toggle vers isDetailOn
  7529. var couleur = couleurAleatoire();
  7530. if(!isDetailOn) {
  7531. span.style.display = 'none';
  7532. } else if(diploGuilde[id]) {
  7533. couleur = diploGuilde[id].couleur;
  7534. }
  7535. appendText(span,' - Couleur HTML: ');
  7536. var input = appendTextbox(span,'text',id,7,7,couleur);
  7537. input.onkeyup = previewCouleur;
  7538. input.onchange = previewCouleur;
  7539. input.onkeyup();
  7540. insertBefore(node,span);
  7541. }
  7542.  
  7543. function setChoixCouleurs() {
  7544. try {
  7545. //var form = document.getElementsByName('ActionForm')[0];
  7546. var form = document.getElementById('mhPlay');
  7547. var nodesAE = document.evaluate(
  7548. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  7549. "./table/tbody/tr/th[@class='mh_tdtitre']",
  7550. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  7551. form, null, 7, null
  7552. );
  7553. var nodes = document.evaluate(
  7554. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  7555. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  7556. form, null, 7, null
  7557. );
  7558. } catch(e) {
  7559. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  7560. return false;
  7561. };
  7562. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  7563. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  7564. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  7565. for(var i=0 ; i<5 ; i++) {
  7566. nodes.snapshotItem(i).id = 'tdAmis'+i;
  7567. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  7568. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  7569. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  7570. }
  7571. return true;
  7572. }
  7573.  
  7574. function fetchDiploGuilde() {
  7575. try {
  7576. for(var AE in {Amis:0,Ennemis:0}) {
  7577. for(var i=0 ; i<5 ; i++) {
  7578. /* Récup des A/E de rang i */
  7579. var td = document.getElementById('td'+AE+i);
  7580. var ligne = td.getElementsByTagName('table')[0].rows;
  7581. var titre = trim(td.firstChild.textContent);
  7582. // On laisse la gestion des couleurs à setChoixCouleurs:
  7583. var couleur = document.getElementById(AE+i).value;
  7584. diploGuilde[AE+i] = {
  7585. Troll:'',
  7586. Guilde:'',
  7587. titre: titre,
  7588. couleur: couleur
  7589. };
  7590. for(var j=1 ; j<ligne.length ; j++) {
  7591. var str = trim(ligne[j].cells[0].textContent);
  7592. var idx = str.lastIndexOf('(');
  7593. var num = str.slice(idx+1,-1);
  7594. var type = trim(ligne[j].cells[1].textContent);
  7595. diploGuilde[AE+i][type] += num+';';
  7596. }
  7597. }
  7598. }
  7599. } catch(e) {
  7600. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  7601. return false;
  7602. }
  7603. return true;
  7604. }
  7605.  
  7606.  
  7607. /*-[functions]--------------------- Handlers ---------------------------------*/
  7608.  
  7609. function toggleDetails() {
  7610. isDetailOn = !isDetailOn;
  7611. for(var AE in {Amis:0,Ennemis:0}) {
  7612. document.getElementById('spanAll'+AE).style.display =
  7613. (isDetailOn?'none':'');
  7614. for(var i=0 ; i<5 ; i++) {
  7615. document.getElementById('span'+AE+i).style.display =
  7616. (isDetailOn?'':'none');
  7617. }
  7618. }
  7619. }
  7620.  
  7621. function toggleMythiques() {
  7622. isMythiquesOn = !isMythiquesOn;
  7623. document.getElementById('spanMythiques').style.display =
  7624. (isMythiquesOn?'':'none');
  7625. }
  7626.  
  7627. function previewCouleur() {
  7628. var value = this.value;
  7629. if(isCouleur(value)) {
  7630. this.style.backgroundColor = value;
  7631. this.title = '';
  7632. } else {
  7633. this.style.backgroundColor = '';
  7634. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  7635. }
  7636. }
  7637.  
  7638. function appendMenuType(node,duType) {
  7639. var select = document.createElement('select');
  7640. select.className = 'SelectboxV2';
  7641. var type = ['Guilde','Troll','Monstre'];
  7642. for(var i=0 ; i<3 ; i++) {
  7643. appendOption(select,type[i],type[i]);
  7644. if(type[i]==duType) { select.selectedIndex=i; }
  7645. }
  7646. node.appendChild(select);
  7647. }
  7648.  
  7649. function ajouteChamp(type,num,couleur,descr) {
  7650. var champs = document.getElementById('diploPerso');
  7651. var nb = champs.rows.length;
  7652. var tr = champs.insertRow(-1);
  7653. var td = appendTd(tr);
  7654. appendMenuType(td,type);
  7655. td = appendTd(tr);
  7656. appendText(td,' n°');
  7657. appendTextbox(td,'text','num'+nb,6,15,num);
  7658. td = appendTd(tr);
  7659. appendText(td,' couleur HTML:');
  7660. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7661. input.onkeyup = previewCouleur;
  7662. input.onchange = previewCouleur;
  7663. input.onkeyup();
  7664. td = appendTd(tr);
  7665. appendText(td,' Description:');
  7666. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7667. td = appendTd(tr);
  7668. var span = document.createElement('span');
  7669. appendText(span,'[ok!]',true);
  7670. span.style.visibility = 'hidden';
  7671. td.appendChild(span);
  7672. td = appendTd(tr);
  7673. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7674. }
  7675.  
  7676. function retireCeChamp() {
  7677. var thisTr = this.parentNode.parentNode;
  7678. thisTr.parentNode.removeChild(thisTr);
  7679. var champs = document.getElementById('diploPerso');
  7680. if(champs.rows.length==0) { ajouteChamp(); }
  7681. }
  7682.  
  7683. function valideChamp(champ) {
  7684. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7685. isCouleur(champ.cells[2].childNodes[1].value);
  7686. if(isValide) {
  7687. champ.cells[4].firstChild.style.visibility = 'visible';
  7688. } else {
  7689. champ.cells[4].firstChild.style.visibility = 'hidden';
  7690. }
  7691. return isValide;
  7692. }
  7693.  
  7694. function sauvegarderTout() {
  7695. /* Diplo de guilde */
  7696. diploGuilde.isOn =
  7697. document.getElementById('isGuildeOn').checked?'true':'false';
  7698. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7699. var numGuilde = Number(document.getElementById('numGuilde').value);
  7700. var couleur = document.getElementById('couleurGuilde').value;
  7701. if(numGuilde) {
  7702. diploGuilde.guilde = {
  7703. id: numGuilde,
  7704. couleur: couleur
  7705. };
  7706. } else {
  7707. delete diploGuilde.guilde;
  7708. }
  7709. for(var AE in {Amis:0,Ennemis:0}) {
  7710. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7711. for(var i=0 ; i<5 ; i++) {
  7712. if(isDetailOn) {
  7713. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7714. } else {
  7715. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7716. }
  7717. }
  7718. }
  7719. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7720. /* Diplo personnelle (ex-fonction saveChamps) */
  7721. var champs = document.getElementById('diploPerso');
  7722. diploPerso = {
  7723. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7724. Guilde: {},
  7725. Troll: {},
  7726. Monstre: {}
  7727. };
  7728. if(isMythiquesOn &&
  7729. isCouleur(document.getElementById('couleurMythiques').value)) {
  7730. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7731. }
  7732. for(var i=0 ; i<champs.rows.length ; i++) {
  7733. if(valideChamp(champs.rows[i])) {
  7734. var type = champs.rows[i].cells[0].firstChild.value;
  7735. var num = champs.rows[i].cells[1].childNodes[1].value;
  7736. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7737. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7738. diploPerso[type][num] = {
  7739. couleur: couleur
  7740. };
  7741. if(descr) {
  7742. diploPerso[type][num].titre = descr;
  7743. }
  7744. }
  7745. }
  7746. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7747.  
  7748. avertissement('Données sauvegardées');
  7749. }
  7750.  
  7751.  
  7752. /*-[functions]------------- Modifications de la page -------------------------*/
  7753.  
  7754. function creeTablePrincipale() {
  7755. var insertPt = document.getElementById('insertPt');
  7756. /* Titre + bouton de Sauvegarde */
  7757. var tr = insertTr(insertPt,'mh_tdtitre');
  7758. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7759. appendButton(td,'Sauvegarder',sauvegarderTout);
  7760. /* Options fixes */
  7761. tr = insertTr(insertPt,'mh_tdpage');
  7762. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7763. appendBr(td);
  7764. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7765. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7766. appendBr(td);
  7767. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7768. appendText(td,'Utiliser des couleurs détaillées (10)');
  7769. /* Diplo personnelle */
  7770. tr = insertTr(insertPt,'mh_tdpage');
  7771. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7772. appendBr(td);
  7773. // Diplo Mythiques
  7774. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7775. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7776. var span = document.createElement('span');
  7777. span.id = 'spanMythiques';
  7778. if(!isMythiquesOn) {
  7779. span.style.display = 'none';
  7780. }
  7781. var couleur = '#FFAAAA';
  7782. if(diploPerso.mythiques) {
  7783. couleur = diploPerso.mythiques;
  7784. }
  7785. appendText(span,' - couleur HTML:');
  7786. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7787. input.onkeyup = previewCouleur;
  7788. input.onchange = previewCouleur;
  7789. input.onkeyup();
  7790. td.appendChild(span);
  7791. appendBr(td);
  7792. // Diplo éditable
  7793. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7794. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7795. appendBr(td);
  7796. var table = document.createElement('table');
  7797. table.id = 'diploPerso'
  7798. td.appendChild(table);
  7799. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7800. for(var num in diploPerso[type]) {
  7801. ajouteChamp(
  7802. type,
  7803. num,
  7804. diploPerso[type][num].couleur,
  7805. diploPerso[type][num].titre
  7806. );
  7807. }
  7808. }
  7809. if(table.rows.length==0) {
  7810. ajouteChamp();
  7811. }
  7812. appendButton(td,'Ajouter',ajouteChamp)
  7813. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7814. appendText(td,' ');
  7815. appendButton(td,
  7816. 'Exemples de couleur',
  7817. function() {
  7818. var fenetre = window.open(
  7819. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7820. 'Divers',
  7821. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7822. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7823. );
  7824. fenetre.focus();
  7825. }
  7826. );
  7827. /* Couleur de Guilde */
  7828. tr = insertTr(insertPt,'mh_tdtitre');
  7829. td = appendTdText(tr,'GUILDE',true);
  7830. appendText(td,' - n°');
  7831. appendTextbox(td,'text','numGuilde',5,10,
  7832. diploGuilde.guilde && diploGuilde.guilde.id ?
  7833. diploGuilde.guilde.id : ''
  7834. );
  7835. appendText(td,' - Couleur HTML: ');
  7836. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7837. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7838. diploGuilde.guilde.couleur : '#BBBBFF'
  7839. );
  7840. input.onkeyup = previewCouleur;
  7841. input.onchange = previewCouleur;
  7842. input.onkeyup();
  7843. }
  7844.  
  7845.  
  7846. /*-[functions]----------------------- Main -----------------------------------*/
  7847.  
  7848. function initDiplo(sType) {
  7849. var sDiplo = MY_getValue(numTroll + '.diplo.' + sType)
  7850. //console.log('sDiplo' + sType + '=' + sDiplo);
  7851. if (sDiplo && (sDiplo != 'null')) { // le stockage JSON nous donne parfois 'null'
  7852. return JSON.parse(sDiplo);
  7853. } else {
  7854. return {};
  7855. }
  7856. }
  7857. var diploGuilde = initDiplo('guilde');
  7858. var diploPerso = initDiplo('perso');
  7859. var isDetailOn = diploGuilde.isDetailOn=='true';
  7860. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7861.  
  7862. function do_diplo() {
  7863. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7864. creeTablePrincipale();
  7865. }
  7866. }
  7867.  
  7868. /*******************************************************************************
  7869. * This file is part of Mountyzilla. *
  7870. * *
  7871. * Mountyzilla is free software; you can redistribute it and/or modify *
  7872. * it under the terms of the GNU General Public License as published by *
  7873. * the Free Software Foundation; either version 2 of the License, or *
  7874. * (at your option) any later version. *
  7875. * *
  7876. * Mountyzilla is distributed in the hope that it will be useful, *
  7877. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7878. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7879. * GNU General Public License for more details. *
  7880. * *
  7881. * You should have received a copy of the GNU General Public License *
  7882. * along with Mountyzilla; if not, write to the Free Software *
  7883. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7884. *******************************************************************************/
  7885.  
  7886. // x~x cdmcomp
  7887.  
  7888. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  7889.  
  7890. function getNonNegInts(str) {
  7891. var nbrs = str.match(/\d+/g);
  7892. for(var i=0 ; i<nbrs.length ; i++) {
  7893. nbrs[i] = Number(nbrs[i]);
  7894. }
  7895. return nbrs;
  7896. }
  7897.  
  7898. function traiteCdMcomp() {
  7899. try {
  7900. var msgEffet = document.getElementById('msgEffet');
  7901. } catch(e) {
  7902. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  7903. return;
  7904. }
  7905.  
  7906. // Teste si ce message du bot est un message de CdM
  7907. if(!document.evaluate(
  7908. "./p/text()[contains(.,'fait partie')]",
  7909. msgEffet, null, 9, null
  7910. ).singleNodeValue) {
  7911. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  7912. return;
  7913. }
  7914. // Début de récupération de la CdM
  7915. /*
  7916. Roule 10/03/2017 j'ai grandement simplifié ☺ ☺ ☺
  7917. zone à supprimer
  7918. traitement Armure Physique/Magique reporté en php
  7919.  
  7920. cdm = document.evaluate(
  7921. "./p/text()[contains(.,'fait partie')]",
  7922. msgEffet, null, 9, null
  7923. ).singleNodeValue.nodeValue+'\n';
  7924. var tbody = document.evaluate(
  7925. "descendant::table/tbody",
  7926. msgEffet, null, 9, null
  7927. ).singleNodeValue;
  7928. var nomStat = document.evaluate(
  7929. "./tr/td[1]/b/text()",
  7930. tbody, null, 7, null
  7931. );
  7932. var valStat = document.evaluate(
  7933. "./tr/td[2]/descendant::text()",
  7934. tbody, null, 7, null
  7935. );
  7936. var i=0;
  7937. while(i<nomStat.snapshotLength) {
  7938. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7939. cdm += 'Armure : ';
  7940. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7941. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7942. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7943. armp = [0,armp[0]];
  7944. }
  7945. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7946. armm = [0,armm[0]];
  7947. }
  7948. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7949. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7950. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7951. } else {
  7952. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7953. }
  7954. cdm += ')\n';
  7955. i++;
  7956. } else {
  7957. cdm += nomStat.snapshotItem(i).nodeValue+
  7958. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7959. }
  7960. i++;
  7961. }
  7962. */
  7963. //cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  7964. //if (MY_DEBUG) window.console.log('cmd=' + cdm);
  7965.  
  7966. // envoi au serveur (PHP) d'un objet avec
  7967. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  7968. // tstamp: l'horodatage
  7969. var tabCdM = new Array();
  7970. var etimestamp = document.getElementById('hserveur');
  7971. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  7972. var txtBlessure;
  7973. var txtPv;
  7974. for (var iElt = 0; iElt < msgEffet.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  7975. var eHTML = msgEffet.childNodes[iElt];
  7976. switch (eHTML.nodeName) {
  7977. case '#text':
  7978. var s = eHTML.nodeValue.trim();
  7979. if (s != '') tabCdM.push(s);
  7980. break;
  7981. case 'P':
  7982. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7983. s = s.trim();
  7984. if (s != '') tabCdM.push(s);
  7985. break;
  7986. case 'TABLE':
  7987. var s = 'table';
  7988. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  7989. var eTr = eHTML.rows[iTr];
  7990. var tabTd = new Array();
  7991. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  7992. var eTd = eTr.cells[iTd];
  7993. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  7994. s = s.trim();
  7995. tabTd.push(s);
  7996. }
  7997. if (tabTd.length >= 2) {
  7998. if (tabTd[0].match(/Blessure/i)) {
  7999. txtBlessure = tabTd[1]
  8000. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  8001. txtPv = tabTd[1]
  8002. }
  8003. }
  8004. tabCdM.push(tabTd);
  8005. }
  8006. break;
  8007. default:
  8008. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  8009. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8010. if (s != '') tabCdM.push(s);
  8011. break;
  8012. }
  8013. }
  8014. var oData = {};
  8015. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  8016. oData.idTroll = numTroll;
  8017. oData.tabCdM = tabCdM;
  8018. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  8019.  
  8020. // envoi d'une CdM issue de compte-rendu de compétence
  8021. // fonction définie ici pour avoir vue sur la variable tabCdM
  8022. var sendInfoCDM = function () {
  8023. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  8024. var buttonCDM = this;
  8025. var texte = '';
  8026. FF_XMLHttpRequest({
  8027. method: 'POST',
  8028. url: URL_pageDispatcherV2,
  8029. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8030. headers : {
  8031. /* inutile, à supprimer
  8032. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8033. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8034. */
  8035. 'Content-type':'application/x-www-form-urlencoded',
  8036. },
  8037. trace: 'envoi CdM',
  8038. onload: function(responseDetails) {
  8039. texte = responseDetails.responseText;
  8040. buttonCDM.value = texte;
  8041. if (!isDEV) buttonCDM.disabled = true;
  8042. }
  8043. });
  8044. }
  8045.  
  8046. // Envoi auto ou insertion bouton envoi (suivant option)
  8047. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  8048. sendInfoCDM();
  8049. var p = document.createElement('p');
  8050. p.style.color = 'green';
  8051. appendText(p,'CdM envoyée vers la base MountyZilla !');
  8052. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  8053. } else {
  8054. insertButtonCdm('as_Action', sendInfoCDM);
  8055. }
  8056.  
  8057. // Insertion de l'estimation des PV restants
  8058. /*
  8059. var pv = valStat.snapshotItem(1).nodeValue;
  8060. if(pv.indexOf("entre")==-1) {
  8061. return;
  8062. }
  8063. var trPv = document.evaluate(
  8064. "//tr[contains(td/b/text(),'Points de Vie')]",
  8065. msgEffet, null, 9, null).singleNodeValue;
  8066. tdPv = trPv.cells[1];
  8067. txtPv = tdPv.innerText || tdPv.textContent;
  8068. if (MY_DEBUG) window.console.log('txtPv=' + txtPv);
  8069. if(0) { //pv) { // bloqué en attendant correction
  8070. */
  8071. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  8072. if (txtBlessure !== undefined && txtPv !== undefined) {
  8073. var pv = getPVsRestants(txtPv,txtBlessure);
  8074. if (MY_DEBUG) window.console.log('pv=' + pv);
  8075. if (pv) { // pv null si le monstre n'est pas blessé
  8076. var trBless = document.evaluate(
  8077. "//tr[contains(td/b/text(),'Blessure')]",
  8078. msgEffet, null, 9, null).singleNodeValue;
  8079. var tr = document.createElement('tr');
  8080. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  8081. appendTr(trBless);
  8082. appendTdText(tr, pv[0], true);
  8083. appendTdText(tr, pv[1], true);
  8084. }
  8085. }
  8086. }
  8087.  
  8088. function do_cdmcomp() {
  8089. start_script(31);
  8090. traiteCdMcomp();
  8091. displayScriptTime();
  8092. }
  8093.  
  8094. /*********************************************************************************
  8095. * This file is part of Mountyzilla. *
  8096. * *
  8097. * Mountyzilla is free software; you can redistribute it and/or modify *
  8098. * it under the terms of the GNU General Public License as published by *
  8099. * the Free Software Foundation; either version 2 of the License, or *
  8100. * (at your option) any later version. *
  8101. * *
  8102. * Mountyzilla is distributed in the hope that it will be useful, *
  8103. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8104. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8105. * GNU General Public License for more details. *
  8106. * *
  8107. * You should have received a copy of the GNU General Public License *
  8108. * along with Mountyzilla; if not, write to the Free Software *
  8109. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8110. *********************************************************************************/
  8111.  
  8112. // x~x cmdbot
  8113.  
  8114. /* v0.2 by Dab - 2013-08-20
  8115. * - patch dégueu pour gérer la décomposition P/M de l'armure
  8116. */
  8117.  
  8118. var buttonCDM;
  8119.  
  8120. /*******************************************************************************************
  8121. CDM :
  8122. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  8123.  
  8124. Il ne vous est pas possible d'améliorer cette compétence.
  8125.  
  8126. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  8127. Niveau : Inimaginable (entre 49 et 51)
  8128. Points de Vie : Surtrollesque (entre 450 et 470)
  8129. Blessure (Approximatif) : 0 %
  8130. Dés d'Attaque : Impressionnant (entre 30 et 32)
  8131. Dés d'Esquive : Impressionnant (entre 28 et 30)
  8132. Dés de Dégat : Très Fort (entre 18 et 20)
  8133. Dés de Régénération : Excellent (égal à 13)
  8134. Armure Physique : Moyen (entre 10 et 12)
  8135. Armure Magique : Faible (inférieur à 6)
  8136. Vue : Moyen (entre 9 et 11)
  8137. Maitrise Magique : Inimaginable (supérieur à 6000)
  8138. Résistance Magique : Inimaginable (supérieur à 6000)
  8139. Nombre d'attaques : 1
  8140. Vitesse de Déplacement : Normale
  8141. Voir le Caché : Oui
  8142. Attaque à distance : Non
  8143. Attaque magique : Oui
  8144. Vole : Non
  8145. Sang froid : Inexistant
  8146. DLA : Milieu
  8147. Durée Tour : Remarquable (entre 9 et 11)
  8148. Chargement : Vide
  8149. Bonus Malus : Aucun
  8150.  
  8151. Vous avez également gagné 1 PX pour la réussite.
  8152. *******************************************************************************************
  8153. BOT :
  8154. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  8155.  
  8156. Le Monstre ciblé fait partie des : Mort-Vivant
  8157.  
  8158. Niveau : Incroyable (entre 36 et 38)
  8159. *******************************************************************************************/
  8160.  
  8161. function getNNInt(str) {
  8162. var nbrs = str.match(/\d+/g);
  8163. for (var i=0 ; i<nbrs.length ; i++)
  8164. nbrs[i] = parseInt(nbrs[i]);
  8165. return nbrs;
  8166. }
  8167.  
  8168. // envoi d'une CdM issue d'un message du BOT
  8169. function sendCDM() {
  8170. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  8171. document, null, 9, null).singleNodeValue;
  8172. /* ancienne version à supprimer
  8173. cdm = td.innerHTML;
  8174. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  8175. "$3$4 ($1 - N°$2)<br>");
  8176. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  8177. 'Blessure : XX % (approximativement)');
  8178. // Supprime la décomposition P/M de l'Armure
  8179. var bgn = cdm.indexOf('Armure Physique');
  8180. if (bgn!=-1) {
  8181. var end = cdm.indexOf('Vue')-2;
  8182. var lines = cdm.substring(bgn,end).split('<br>');
  8183. var armp = getNNInt(lines[0]);
  8184. var armm = getNNInt(lines[1]);
  8185. if (lines[0].indexOf('(inf')!=-1)
  8186. armp = [0,armp[0]];
  8187. if (lines[1].indexOf('(inf')!=-1)
  8188. armm = [0,armm[0]];
  8189. var insrt = 'Armure : ';
  8190. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  8191. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  8192. else
  8193. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  8194. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  8195. }
  8196. cdm = cdm.replace(/<br>/g,'\n');
  8197. */
  8198.  
  8199. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  8200. //window.console.log(tdTxt);
  8201. var oData = {};
  8202. oData.tabCdM = tdTxt.split(/\n/);
  8203. // nettoyage entête : enlève le premier élément tant que
  8204. // - suite de *
  8205. // - "MOUNTYHALL - La Terre des Trõlls"
  8206. // - ligne vide (la première expression régulière matche les lignes vides)
  8207. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  8208. // 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
  8209. var iLigneNonVide;
  8210. for (var i = 0; i < oData.tabCdM.length; i++) {
  8211. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  8212. if (iLigneNonVide === undefined)
  8213. oData.tabCdM.splice(i);
  8214. else
  8215. oData.tabCdM.splice(iLigneNonVide+1);
  8216. break;
  8217. }
  8218. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  8219. }
  8220. //window.console.log(JSON.stringify(oData));
  8221.  
  8222. FF_XMLHttpRequest({
  8223. method: 'POST',
  8224. url: URL_pageDispatcherV2,
  8225. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8226. headers : {
  8227. /* inutile, à supprimer
  8228. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8229. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8230. */
  8231. 'Content-type':'application/x-www-form-urlencoded',
  8232. },
  8233. trace: 'envoi CdM msg du bot',
  8234. onload: function(responseDetails) {
  8235. buttonCDM.value=responseDetails.responseText;
  8236. buttonCDM.disabled = true;
  8237. }
  8238. });
  8239. }
  8240.  
  8241. function traiteCdMmsg() {
  8242. // Teste si ce message du bot est un message de CdM
  8243. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  8244. document, null, 9, null).singleNodeValue;
  8245. if (!td) return false;
  8246. cdm = td.innerHTML;
  8247. // Insertion de l'estimation des PV restants
  8248. var des = cdm.indexOf('Dés');
  8249. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  8250. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  8251. if(pv)
  8252. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  8253.  
  8254. // Insertion bouton envoi + espace
  8255. buttonCDM = insertButtonCdm('bClose',sendCDM);
  8256. }
  8257.  
  8258. /*function traitePouvoir() {
  8259. // Teste si ce message du bot est un message de CdM
  8260. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  8261. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  8262. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8263. if (!td)
  8264. return false;
  8265. var infos = td.innerHTML;
  8266. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  8267. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  8268. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  8269. var date = /alors : ([^<]+)\./.exec(infos)[1];
  8270. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  8271. var effetPouvoir="";
  8272. var full=false;
  8273. if(infos.indexOf("REDUIT")!=-1) {
  8274. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  8275. }
  8276. else {
  8277. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  8278. full=true;
  8279. }
  8280. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  8281. // On insère le bouton et un espace
  8282. //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));
  8283. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  8284. if(!MY_getValue('AUTOSENDPOUV'))
  8285. {
  8286. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  8287. button.setAttribute("onClick", "window.open('" + url
  8288. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  8289. + "this.value='Merci de votre participation'; this.disabled = true;");
  8290. }
  8291. else
  8292. {
  8293. FF_XMLHttpRequest({
  8294. method: 'GET',
  8295. url: url,
  8296. headers : {
  8297. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8298. 'Accept': 'application/atom+xml,application/xml,text/xml'
  8299. }});
  8300. }
  8301. }*/
  8302.  
  8303. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  8304. traiteCdMmsg();
  8305. }
  8306. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  8307.  
  8308. /*******************************************************************************
  8309. * This file is part of Mountyzilla. *
  8310. * *
  8311. * Mountyzilla is free software; you can redistribute it and/or modify *
  8312. * it under the terms of the GNU General Public License as published by *
  8313. * the Free Software Foundation; either version 2 of the License, or *
  8314. * (at your option) any later version. *
  8315. * *
  8316. * Mountyzilla is distributed in the hope that it will be useful, *
  8317. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8318. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8319. * GNU General Public License for more details. *
  8320. * *
  8321. * You should have received a copy of the GNU General Public License *
  8322. * along with Mountyzilla; if not, write to the Free Software *
  8323. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8324. *******************************************************************************/
  8325.  
  8326. // x~x menu
  8327. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  8328.  
  8329. var menuRac, mainIco;
  8330.  
  8331. // met à jour les carac sauvegardées (position, DLA, etc.)
  8332. function updateData() {
  8333. var inputs = document.getElementsByTagName('input');
  8334. var divs = document.getElementsByTagName('div');
  8335.  
  8336. //window.console.log('inputs=' + JSON.stringify(inputs));
  8337. if (inputs && inputs.length > 0) {
  8338. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  8339. numTroll = inputs[0].value;
  8340. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  8341. MY_setValue('NUM_TROLL', numTroll);
  8342. MY_setValue('NIV_TROLL',inputs[1].value);
  8343. if(!MY_getValue(numTroll+'.caracs.rm')) {
  8344. MY_setValue(numTroll+'.caracs.rm',0);
  8345. // assure l'init des 4 var de libs
  8346. }
  8347. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  8348. } else {
  8349. // onclick="EnterPJView(91305,750,550)"
  8350. var tabA = document.getElementsByTagName('a');
  8351. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  8352. var s = tabA[0].onclick.toString();;
  8353. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  8354. var m = s.match(/\((\d+) *,/);
  8355. //window.console.log('m=' + JSON.stringify(m));
  8356. numTroll = parseInt(m[1]);
  8357. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  8358. MY_setValue('NUM_TROLL', numTroll);
  8359. } else {
  8360. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  8361. }
  8362. }
  8363.  
  8364. var DLA = new Date(
  8365. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  8366. );
  8367. if(MY_getValue(numTroll+'.DLA.encours')) {
  8368. var DLAstockee = new Date(
  8369. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  8370. );
  8371. if(DLA>DLAstockee) {
  8372. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  8373. // Pose un pb en cas de décalage de DLA
  8374. }
  8375. }
  8376. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  8377.  
  8378. try {
  8379. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  8380. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  8381. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  8382. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  8383. } catch(e) {
  8384. 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, '‹'));
  8385. }
  8386. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  8387. }
  8388.  
  8389. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  8390. function initRaccourcis() {
  8391. var anotherURL = MY_getValue('URL1');
  8392. if(!anotherURL) { return; }
  8393.  
  8394. /* Création de l'icône faisant apparaître le menu */
  8395. mainIco = document.createElement('img');
  8396. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  8397. if(!urlIco) {
  8398. urlIco =
  8399. URL_MZimg + 'mz_logo_small.png';
  8400. }
  8401. mainIco.src = urlIco;
  8402. mainIco.alt = 'MZ';
  8403. mainIco.style = 'position:fixed; top:0px; left:0px';
  8404. mainIco.onmouseover = afficheMenu;
  8405. document.body.appendChild(mainIco);
  8406. /* Création du menu des Raccourcis */
  8407. menuRac = document.createElement('div');
  8408. menuRac.className = 'mh_textbox';
  8409. menuRac.style =
  8410. 'position:fixed; top:10px; left:10px;'+
  8411. 'max-width:190px;'+
  8412. 'border-radius: 4px; padding: 4px;'+
  8413. 'z-index: 500;'+
  8414. 'visibility: hidden;';
  8415. document.body.appendChild(menuRac);
  8416. document.addEventListener('mousemove',cacheMenu,false);
  8417. var i=1;
  8418. while(anotherURL) {
  8419. var a = document.createElement('a');
  8420. var url = MY_getValue('URL'+i);
  8421. var nom = MY_getValue('URL'+i+'.nom');
  8422. var ico = MY_getValue('URL'+i+'.ico');
  8423. a.href = url;
  8424. a.target = '_blank';
  8425. if(ico) {
  8426. var txt = nom ? nom : '';
  8427. var img = createImage(ico,txt);
  8428. a.appendChild(img);
  8429. }
  8430. else {
  8431. appendText(a,'['+nom+']');
  8432. }
  8433. menuRac.appendChild(a);
  8434. appendBr(menuRac);
  8435. i++;
  8436. anotherURL = MY_getValue('URL'+i);
  8437. }
  8438. }
  8439.  
  8440. function afficheMenu() {
  8441. menuRac.style.visibility = 'visible';
  8442. }
  8443.  
  8444. function cacheMenu(e) {
  8445. if(menuRac.style.visibility=='hidden') { return; }
  8446. // Position souris
  8447. var ptX = e.clientX;
  8448. var ptY = e.clientY;
  8449. // On recalcule en live les BoundingBox pour mainIco et menuRac
  8450. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  8451. var menuRect = menuRac.getBoundingClientRect();
  8452. var icoRect = mainIco.getBoundingClientRect();
  8453. if((ptX>icoRect.width || ptY>icoRect.height) &&
  8454. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  8455. menuRac.style.visibility = 'hidden';
  8456. }
  8457. }
  8458.  
  8459. // ajout de l'icône, branchée sur un refresh
  8460. function initUpdateCoordGauche() {
  8461. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8462. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  8463. var img = document.createElement('img');
  8464. img.src = URL_MZimg + 'recycl.png'
  8465. img.onclick = function(evt) {
  8466. document.location.href = document.location.href;
  8467. };
  8468. img.title = 'Mise à jour de la localisation';
  8469. img.style.cursor = 'pointer';
  8470. img.style.position = 'absolute';
  8471. img.style.bottom = 0;
  8472. img.style.left = 0;
  8473. div.appendChild(img);
  8474. }
  8475.  
  8476. function do_menu() {
  8477. // met à jour les carac sauvegardées (position, DLA, etc.)
  8478. updateData();
  8479. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  8480. initRaccourcis();
  8481. // Ajout bouton de mise à jour coordonnées
  8482. initUpdateCoordGauche();
  8483. }
  8484.  
  8485. /*******************************************************************************
  8486. * This file is part of Mountyzilla. *
  8487. * *
  8488. * Mountyzilla is free software; you can redistribute it and/or modify *
  8489. * it under the terms of the GNU General Public License as published by *
  8490. * the Free Software Foundation; either version 2 of the License, or *
  8491. * (at your option) any later version. *
  8492. * *
  8493. * Mountyzilla is distributed in the hope that it will be useful, *
  8494. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8495. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8496. * GNU General Public License for more details. *
  8497. * *
  8498. * You should have received a copy of the GNU General Public License *
  8499. * along with Mountyzilla; if not, write to the Free Software *
  8500. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8501. *******************************************************************************/
  8502.  
  8503. // x~x vue
  8504.  
  8505. /* TODO
  8506. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  8507. * prévoir fix ("delete infos")
  8508. */
  8509.  
  8510. /*--------------------------- Variables Globales -----------------------------*/
  8511.  
  8512. // Infos remplies par des scripts extérieurs
  8513. var listeCDM = [], listeLevels = [];
  8514.  
  8515. // Position actuelle
  8516. var currentPosition=[0,0,0];
  8517.  
  8518. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  8519. var porteeVue=[0,0,0,0];
  8520.  
  8521. // Fenêtres déplaçables
  8522. var winCurr = null;
  8523. var offsetX, offsetY;
  8524.  
  8525. // Diplomatie
  8526. var Diplo = {
  8527. Guilde: {},
  8528. Troll: {},
  8529. Monstre: {}
  8530. // .mythiques: uniquement si option activée
  8531. };
  8532. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  8533.  
  8534. // Infos tactiques
  8535. var popup;
  8536.  
  8537. // Gère l'affichage en cascade des popups de CdM
  8538. var nbCDM = 0;
  8539.  
  8540. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  8541.  
  8542. // Utilisé pour supprimer les monstres "engagés"
  8543. var listeEngages = {};
  8544. var isEngagesComputed = false;
  8545. var cursorOnLink = false; // DEBUG: wtf ?
  8546.  
  8547. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  8548. && MY_getValue(numTroll+'.enchantement.liste')!='';
  8549.  
  8550. // Checkboxes de filtrage
  8551. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  8552. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  8553. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  8554. comboBoxNiveauMin, comboBoxNiveauMax;
  8555.  
  8556. /* Acquisition & Stockage des données de DB */
  8557. const typesAFetcher = {
  8558. 'monstres':1,
  8559. 'trolls':1,
  8560. 'tresors':1,
  8561. 'champignons':1,
  8562. 'lieux':1
  8563. }
  8564. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  8565. tr_champignons = {}, tr_lieux = {};
  8566. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  8567. nbChampignons = 0, nbLieux = 0;
  8568.  
  8569. function fetchData(type) {
  8570. try {
  8571. var node = document.getElementById('mh_vue_hidden_'+type);
  8572. // this = MZ.global = sandBox de travail de MZ
  8573. // On définit donc des variables MZ-globales
  8574. this['tr_'+type] = node.getElementsByTagName('tr');
  8575. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  8576. } catch(e) {
  8577. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  8578. }
  8579. }
  8580.  
  8581.  
  8582. /*---------------------------------- DEBUG -----------------------------------*/
  8583. var mainTabs = document.getElementsByClassName('mh_tdborder');
  8584. var x_monstres = tr_monstres;
  8585. var x_trolls = tr_trolls;
  8586. var x_tresors = tr_tresors;
  8587. var x_champis = tr_champignons;
  8588. var x_lieux = tr_lieux;
  8589. /*-------------------------------- FIN DEBUG ---------------------------------*/
  8590.  
  8591.  
  8592. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8593.  
  8594. function positionToString(arr) {
  8595. return arr.join(';');
  8596. }
  8597.  
  8598. function savePosition() {
  8599. // Stocke la position (à jour) de la vue pour les autres scripts
  8600. // DEBUG: Lesquels et pourquoi?
  8601. var pos = getPosition();
  8602. MY_setValue(numTroll+'.position.X',pos[0]);
  8603. MY_setValue(numTroll+'.position.Y',pos[1]);
  8604. MY_setValue(numTroll+'.position.N',pos[2]);
  8605. }
  8606.  
  8607.  
  8608. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  8609. /* INFOS :
  8610. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  8611. * sont identifiables via leur Name
  8612. * les tables-listings sont identifiables via l'ID du tr conteneur
  8613. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  8614. */
  8615.  
  8616. /* [functions] Récup données Utilisateur */
  8617. function getPosition() {
  8618. // Pour rétrocompatibilité
  8619. return currentPosition;
  8620. }
  8621.  
  8622. function getPorteVue() {
  8623. // Pour rétrocompatibilité
  8624. return porteeVue;
  8625. }
  8626.  
  8627. function getVue() {
  8628. // Retourne [vueHpure, vueVpure]
  8629. var vues = getPorteVue();
  8630. return [ vues[0], vues[1] ];
  8631. }
  8632.  
  8633. // Roule 11/03/2016
  8634. /* [functions] Récup données monstres, trolls, etc. */
  8635. function getXxxDistance(xxx, i) {
  8636. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  8637. }
  8638. function getXxxPosition(xxx, i) {
  8639. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  8640. var l = tds.length;
  8641. return [
  8642. parseInt(tds[l-3].textContent),
  8643. parseInt(tds[l-2].textContent),
  8644. parseInt(tds[l-1].textContent)
  8645. ];
  8646. }
  8647.  
  8648.  
  8649. /* [functions] Récup données monstres */
  8650. function getMonstreDistance(i) {
  8651. return parseInt(tr_monstres[i].cells[0].textContent);
  8652. }
  8653.  
  8654. function getMonstreID(i) {
  8655. return tr_monstres[i].cells[2].firstChild.nodeValue;
  8656. }
  8657.  
  8658. function getMonstreIDByTR(tr) {
  8659. return tr.cells[2].firstChild.nodeValue;
  8660. }
  8661.  
  8662. function getMonstreLevelNode(i) {
  8663. return tr_monstres[i].cells[3];
  8664. }
  8665.  
  8666. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  8667. // function getMonstreLevel(i) {
  8668. // if(!isCDMsRetrieved) return -1;
  8669. // var donneesMonstre = listeCDM[getMonstreID(i)];
  8670. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  8671. // }
  8672.  
  8673. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  8674. if(!isCDMsRetrieved) return false;
  8675. var donneesMonstre = listeCDM[getMonstreID(i)];
  8676. if (!donneesMonstre) return false;
  8677. var nivTxt = donneesMonstre[0];
  8678. // calcul min/max du monstre
  8679. var monstreMin, monstreMax, iPos;
  8680. if (nivTxt.substring(0, 2) == '<=') {
  8681. monstreMin = 0;
  8682. monstreMax = parseInt(nivTxt.substring(2, 99));
  8683. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  8684. monstreMin = parseInt(nivTxt.substring(0, iPos));
  8685. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  8686. } else {
  8687. monstreMin = monstreMax = parseInt(nivTxt);
  8688. }
  8689. if (limitMin > 0 && monstreMax < limitMin) return true;
  8690. if (limitMax > 0 && monstreMin > limitMax) return true;
  8691. return false;
  8692. }
  8693.  
  8694. function getMonstreNomNode(i) {
  8695. try {
  8696. var td = document.evaluate(
  8697. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  8698. tr_monstres[i], null, 9, null
  8699. ).singleNodeValue;
  8700. return td;
  8701. } catch(e) {
  8702. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  8703. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  8704. }
  8705. }
  8706.  
  8707. function getMonstreNom(i) {
  8708. return getMonstreNomByTR(tr_monstres[i]);
  8709. }
  8710.  
  8711. function getMonstreNomByTR(tr) {
  8712. try {
  8713. var nom = document.evaluate(
  8714. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  8715. tr, null, 2, null
  8716. ).stringValue;
  8717. return nom;
  8718. } catch(e) {
  8719. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  8720. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  8721. }
  8722. }
  8723.  
  8724. function getMonstrePosition(i) {
  8725. var tds = tr_monstres[i].childNodes;
  8726. var l = tds.length;
  8727. return [
  8728. parseInt(tds[l-3].textContent),
  8729. parseInt(tds[l-2].textContent),
  8730. parseInt(tds[l-1].textContent)
  8731. ];
  8732. }
  8733.  
  8734. function appendMonstres(txt) {
  8735. for(var i=1; i<=nbMonstres ; i++)
  8736. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  8737. return txt;
  8738. }
  8739.  
  8740. function getMonstres() {
  8741. var vue = getVue();
  8742. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8743. }
  8744.  
  8745. function bddMonstres(start,stop) {
  8746. if(!start) { var start = 1; }
  8747. if(!stop) { var stop = nbMonstres; }
  8748. stop = Math.min(nbMonstres,stop);
  8749. var txt='';
  8750. for(var i=start ; i<=stop ; i++) {
  8751. txt += getMonstreID(i)+';'+
  8752. getMonstreNom(i)+';'+
  8753. positionToString(getMonstrePosition(i))+'\n';
  8754. }
  8755. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  8756. }
  8757.  
  8758. /* [functions] Récup données Trolls */
  8759.  
  8760. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  8761. const COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  8762.  
  8763. function getTrollDistance(i) {
  8764. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  8765. }
  8766.  
  8767. var MZ_cache_col_TrollID;
  8768. var MZ_cache_col_TrollNOM;
  8769. var MZ_cache_col_TrollGUILDE;
  8770. var MZ_cache_col_TrollNIV;
  8771.  
  8772. function MZ_find_col_titre(trs, titre) {
  8773. var l = titre.length;
  8774. for (var i=0; i < trs[0].cells.length; i++)
  8775. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  8776. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  8777. return 0;
  8778. }
  8779.  
  8780. function getTrollID(i) {
  8781. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  8782. // Roule 08/03/2017 protection
  8783. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  8784. if (isNaN(iTroll)) return;
  8785. if (iTroll == 0) return;
  8786. return iTroll;
  8787. }
  8788.  
  8789. function getTrollNomNode(i) {
  8790. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  8791. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  8792. }
  8793.  
  8794. function getTrollNivNode(i) {
  8795. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  8796. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  8797. }
  8798.  
  8799. function getTrollGuilde(i) {
  8800. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  8801. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  8802. }
  8803.  
  8804. function getTrollGuildeID(i) {
  8805. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  8806. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  8807. var href;
  8808. try {
  8809. 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"
  8810. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  8811. } catch(e) { // debug pb remonté par Marsak
  8812. window.console.error(traceStack(e, 'getTrollGuildeID')
  8813. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  8814. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  8815. return -1;
  8816. }
  8817. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  8818. }
  8819. return -1;
  8820. }
  8821.  
  8822. function getTrollPosition(i) {
  8823. var tds = tr_trolls[i].childNodes;
  8824. var l = tds.length;
  8825. return [
  8826. parseInt(tds[l-3].textContent),
  8827. parseInt(tds[l-2].textContent),
  8828. parseInt(tds[l-1].textContent)
  8829. ];
  8830. }
  8831.  
  8832. function bddTrolls() {
  8833. var txt='#DEBUT TROLLS\n'+
  8834. numTroll+';'+positionToString(getPosition())+'\n';
  8835. for(var i=1 ; i<=nbTrolls ; i++) {
  8836. txt += getTrollID(i)+';'+
  8837. positionToString(getTrollPosition(i))+'\n';
  8838. }
  8839. return txt+'#FIN TROLLS';
  8840. }
  8841.  
  8842. /* [functions] Récup données Trésors */
  8843. function getTresorDistance(i) {
  8844. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8845. }
  8846.  
  8847. function getTresorID(i) {
  8848. return trim(tr_tresors[i].cells[2].textContent);
  8849. }
  8850.  
  8851. function getTresorNom(i) {
  8852. // Utilisation de textContent pour régler le "bug de Pollux"
  8853. return trim(tr_tresors[i].cells[3].textContent);
  8854. }
  8855.  
  8856. function getTresorPosition(i) {
  8857. var tds = tr_tresors[i].childNodes;
  8858. var l = tds.length;
  8859. return [
  8860. parseInt(tds[l-3].textContent),
  8861. parseInt(tds[l-2].textContent),
  8862. parseInt(tds[l-1].textContent),
  8863. ];
  8864. }
  8865.  
  8866. function bddTresors(dmin,start,stop) {
  8867. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8868. if(!dmin) { var dmin = 0; }
  8869. if(!start) { var start = 1; }
  8870. if(!stop) { var stop = nbTresors; }
  8871. stop = Math.min(nbTresors,stop);
  8872. var txt='';
  8873. for(var i=start ; i<=stop ; i++) {
  8874. if(getTresorDistance(i)>=dmin) {
  8875. txt += getTresorID(i)+';'+
  8876. getTresorNom(i)+';'+
  8877. positionToString(getTresorPosition(i))+'\n';
  8878. }
  8879. }
  8880. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8881. }
  8882.  
  8883. /* [functions] Récup données Champignons */
  8884. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8885. function getChampignonNom(i) {
  8886. return trim(tr_champignons[i].cells[2].textContent);
  8887. }
  8888.  
  8889. function getChampignonPosition(i) {
  8890. var tds = tr_champignons[i].childNodes;
  8891. var l = tds.length;
  8892. return [
  8893. parseInt(tds[l-3].textContent),
  8894. parseInt(tds[l-2].textContent),
  8895. parseInt(tds[l-1].textContent)
  8896. ];
  8897. }
  8898.  
  8899. function bddChampignons() {
  8900. var txt='';
  8901. for(var i=1 ; i<=nbChampignons ; i++) {
  8902. txt += ';'+ // Les champis n'ont pas de Référence
  8903. getChampignonNom(i)+';'+
  8904. positionToString(getChampignonPosition(i))+'\n';
  8905. }
  8906. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8907. }
  8908.  
  8909. /* [functions] Récup données Lieux */
  8910. function getLieuDistance(i) {
  8911. return parseInt(tr_lieux[i].cells[0].textContent);
  8912. }
  8913.  
  8914. function getLieuID(i) {
  8915. return parseInt(tr_lieux[i].cells[2].textContent);
  8916. }
  8917.  
  8918. function getLieuNom(i) {
  8919. // Conversion ASCII pour éviter les bugs des Vues externes
  8920. return trim(tr_lieux[i].cells[3].textContent);
  8921. }
  8922.  
  8923. function getLieuPosition(i) {
  8924. var tds = tr_lieux[i].childNodes;
  8925. var l = tds.length;
  8926. return [
  8927. parseInt(tds[l-3].textContent),
  8928. parseInt(tds[l-2].textContent),
  8929. parseInt(tds[l-1].textContent)
  8930. ];
  8931. }
  8932.  
  8933. function appendLieux(txt) {
  8934. for(var i = 1; i < nbLieux+1; i++) {
  8935. var tds = x_lieux[i].childNodes;
  8936. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8937. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8938. }
  8939. return txt;
  8940. }
  8941.  
  8942. function getLieux() {
  8943. var vue = getVue();
  8944. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8945. }
  8946.  
  8947. function bddLieux(start,stop) {
  8948. if(!start) { var start = 1; }
  8949. if(!stop) { var stop = nbLieux; }
  8950. stop = Math.min(nbLieux,stop);
  8951. var txt='';
  8952. for(var i=start ; i<=stop ; i++) {
  8953. txt += getLieuID(i)+';'+
  8954. epure(getLieuNom(i))+';'+
  8955. positionToString(getLieuPosition(i))+'\n';
  8956. }
  8957. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8958. }
  8959.  
  8960.  
  8961. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8962.  
  8963. function saveCheckBox(chkbo, pref) {
  8964. // Enregistre et retourne l'état d'une CheckBox
  8965. var etat = chkbo.checked;
  8966. MY_setValue(pref, etat ? 'true' : 'false' );
  8967. return etat;
  8968. }
  8969.  
  8970. function recallCheckBox(chkbox, pref) {
  8971. // Restitue l'état d'une CheckBox
  8972. chkbox.checked = (MY_getValue(pref)=='true');
  8973. }
  8974.  
  8975. function saveComboBox(cbb, pref) {
  8976. // Enregistre et retourne l'état d'une ComboBox
  8977. var etat = cbb.selectedIndex;
  8978. MY_setValue(pref, etat);
  8979. return etat;
  8980. }
  8981.  
  8982. function recallComboBox(cbb, pref) {
  8983. // Restitue l'état d'une ComboBox
  8984. var nb = MY_getValue(pref);
  8985. if(nb) cbb.value = nb;
  8986. return nb;
  8987. }
  8988.  
  8989. function synchroniseFiltres() {
  8990. // Récupération de toutes les options de la vue
  8991. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8992. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8993. if(numBool) {
  8994. debutFiltrage('Monstres');
  8995. }
  8996. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  8997. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  8998. recallCheckBox(checkBoxMythiques,'NOMYTH');
  8999. recallCheckBox(checkBoxEngages,'NOENGAGE');
  9000. recallCheckBox(checkBoxLevels,'NOLEVEL');
  9001. recallCheckBox(checkBoxIntangibles,'NOINT');
  9002. recallCheckBox(checkBoxGG,'NOGG');
  9003. recallCheckBox(checkBoxCompos,'NOCOMP');
  9004. recallCheckBox(checkBoxBidouilles,'NOBID');
  9005. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  9006. recallCheckBox(checkBoxTrou,'NOTROU');
  9007. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9008. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  9009. if(MY_getValue('NOINFOEM')!='true')
  9010. recallCheckBox(checkBoxEM,'NOEM');
  9011. }
  9012.  
  9013.  
  9014. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  9015.  
  9016. function getVueScript() {
  9017. try {
  9018. var txt = bddTrolls()+
  9019. bddMonstres()+
  9020. bddChampignons()+
  9021. bddTresors()+
  9022. bddLieux()+
  9023. '#DEBUT ORIGINE\n'+
  9024. getPorteVue()[2]+';'+positionToString(getPosition())+
  9025. '\n#FIN ORIGINE\n';
  9026. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  9027. return txt;
  9028. } catch(e) {
  9029. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  9030. window.console.error(traceStack(e, 'getVueScript'))
  9031. }
  9032. }
  9033.  
  9034. /* [functions] Menu Vue 2D */
  9035. var vue2Ddata = {
  9036. 'Bricol\' Vue': {
  9037. url: URL_bricol_mountyhall + 'vue_form.php',
  9038. paramid: 'vue',
  9039. func: getVueScript,
  9040. extra_params: {
  9041. 'mode': 'vue_SP_Vue2',
  9042. 'screen_width': window.screen.width
  9043. }
  9044. },
  9045. 'Vue du CCM': {
  9046. url: URL_vue_CCM,
  9047. paramid: 'vue',
  9048. func: getVueScript,
  9049. extra_params: {
  9050. 'id': numTroll+';'+positionToString(getPosition())
  9051. }
  9052. },
  9053. 'Vue Gloumfs 2D': {
  9054. url: URL_vue_Gloumfs2D,
  9055. paramid: 'vue_mountyzilla',
  9056. func: getVueScript,
  9057. extra_params: {}
  9058. },
  9059. 'Vue Gloumfs 3D': {
  9060. url: URL_vue_Gloumfs3D,
  9061. paramid: 'vue_mountyzilla',
  9062. func: getVueScript,
  9063. extra_params: {}
  9064. },
  9065. 'Grouky Vue!': {
  9066. url: URL_vue_Grouky,
  9067. paramid: 'vue',
  9068. func: getVueScript,
  9069. extra_params: {
  9070. 'type_vue': 'V5b1'
  9071. }
  9072. },
  9073. /*'DEBUG': {
  9074. url: 'http://weblocal/testeur.php',
  9075. paramid: 'vue',
  9076. func: getVueScript,
  9077. extra_params: {}
  9078. }*/
  9079. };
  9080.  
  9081. function refresh2DViewButton() {
  9082. // = EventListener menu+bouton vue 2D
  9083. var vueext = document.getElementById('selectVue2D').value;
  9084. MY_setValue('VUEEXT',vueext);
  9085. var form = document.getElementById('viewForm');
  9086. form.innerHTML = '';
  9087. form.method = 'post';
  9088. form.action = vue2Ddata[vueext].url;
  9089. form.target = '_blank';
  9090. appendHidden(form, vue2Ddata[vueext].paramid, '');
  9091. for(var key in vue2Ddata[vueext].extra_params) {
  9092. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  9093. }
  9094. appendSubmit(form, 'Voir',
  9095. function() {
  9096. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  9097. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  9098. vue2Ddata[vueext].func();
  9099. }
  9100. );
  9101. }
  9102.  
  9103. function set2DViewSystem() {
  9104. // Initialise le système de vue 2D
  9105. // Recherche du point d'insertion
  9106. var center;
  9107. try {
  9108. // Roule 09/03/2019, encore un changement MH, je fais suivre comme je peux
  9109. center = document.getElementById('titre2');
  9110. // version initiale "pré-Roule"
  9111. if (!center) center = document.evaluate(
  9112. "//h2[@id='titre2']/following-sibling::center",
  9113. document, null, 9, null
  9114. ).singleNodeValue;
  9115. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  9116. if (!center) center = document.evaluate(
  9117. "//h2[@id='titre2']/following-sibling::div",
  9118. document, null, 9, null
  9119. ).singleNodeValue;
  9120. } catch(e) {
  9121. avertissement("Erreur d'initialisation du système de vue 2D");
  9122. window.console.error(traceStack(e, 'set2DViewSystem'));
  9123. return;
  9124. }
  9125. // Récupération de la dernière vue utilisée
  9126. var vueext = MY_getValue('VUEEXT');
  9127. if(!vueext || !vue2Ddata[vueext]) {
  9128. // sinon, la vue Bricol'Trolls est employée par défaut
  9129. vueext = 'Bricol\' Vue';
  9130. }
  9131. try {
  9132. // Création du sélecteur de vue externe
  9133. selectVue2D = document.createElement('select');
  9134. selectVue2D.id = 'selectVue2D';
  9135. selectVue2D.className = 'SelectboxV2';
  9136. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  9137. for(var view in vue2Ddata) {
  9138. appendOption(selectVue2D, view, view);
  9139. }
  9140. selectVue2D.value = vueext;
  9141. selectVue2D.onchange = refresh2DViewButton;
  9142. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  9143. var form = document.createElement('form');
  9144. form.id = 'viewForm';
  9145. // Insertion du système de vue
  9146. var table = document.createElement('table');
  9147. var tr = appendTr(table);
  9148. var td = appendTd(tr);
  9149. td.appendChild(selectVue2D);
  9150. td = appendTd(tr);
  9151. td.style.fontSize = '0px'; // gère le bug de l'extra character
  9152. td.appendChild(form);
  9153. if (center.id == 'titre2') { // 09/03/2019 nouvelle méthode
  9154. var eDiv = document.createElement('div');
  9155. eDiv.appendChild(table);
  9156. eDiv.style.witdth = '100%';
  9157. eDiv.style.textAlign = 'center';
  9158. table.style.width = '180px';
  9159. table.style.margin = '0 auto';
  9160. center.parentNode.insertBefore(eDiv,center.nextSibling);
  9161. } else { // ancienne méthode
  9162. center.insertBefore(table,center.firstChild);
  9163. insertBr(center.childNodes[1]);
  9164. }
  9165. // Appelle le handler pour initialiser le bouton de submit
  9166. refresh2DViewButton();
  9167. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  9168. } catch(e) {
  9169. avertissement("Erreur de traitement du système de vue 2D");
  9170. window.console.error(traceStack(e, 'set2DViewSystem'));
  9171. }
  9172. }
  9173.  
  9174. /* [functions] Tableau d'Infos */
  9175. function initialiseInfos() {
  9176. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  9177. var
  9178. infoTab = document.getElementsByName('LimitViewForm')[0].
  9179. getElementsByTagName('table')[0],
  9180. tbody = infoTab.tBodies[0],
  9181. thead = infoTab.createTHead(),
  9182. tr = appendTr(thead,'mh_tdtitre'),
  9183. td = appendTdText(tr,'INFORMATIONS',true),
  9184. span = document.createElement('span');
  9185. // Récupération de la position du joueur
  9186. try {
  9187. var strPos = document.evaluate(
  9188. ".//li/b/text()[contains(.,'X = ')]",
  9189. infoTab, null, 9, null
  9190. ).singleNodeValue.nodeValue;
  9191. // ***INIT GLOBALE*** currentPosition
  9192. currentPosition = getNumbers(strPos);
  9193. debugMZ("retrievePosition(): "+currentPosition);
  9194. } catch(e) {
  9195. // Si on ne trouve pas le "X ="
  9196. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  9197. }
  9198. // Récupération des portées (max et limitée) de la vue
  9199. try {
  9200. var
  9201. nodes = document.evaluate(
  9202. ".//li/b/text()[contains(.,'horizontalement') "+
  9203. "or contains(.,'verticalement')]",
  9204. infoTab, null, 7, null
  9205. ),
  9206. array = [];
  9207. for(var i=0 ; i<4 ; i++) {
  9208. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  9209. }
  9210. // ***INIT GLOBALE*** porteeVue
  9211. porteeVue = array;
  9212. } catch(e) {
  9213. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  9214. }
  9215.  
  9216. infoTab.id = 'infoTab'; // Pour scripts externes
  9217. tbody.id = 'corpsInfoTab';
  9218. tbody.rows[0].cells[0].colSpan = 2;
  9219. td.colSpan = 3;
  9220. td.onmouseover = function() {
  9221. this.style.cursor = 'pointer';
  9222. this.className = 'mh_tdpage';
  9223. };
  9224. td.onmouseout = function() {
  9225. this.className = 'mh_tdtitre';
  9226. };
  9227. td.onclick = function() {
  9228. toggleTableauInfos(false);
  9229. };
  9230. span.id = 'msgInfoTab';
  9231. span.style.display = 'none';
  9232. appendText(
  9233. span,
  9234. ' => Position : X = '+currentPosition[0]+
  9235. ', Y = '+currentPosition[1]+
  9236. ', N = '+currentPosition[2]+
  9237. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  9238. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  9239. true
  9240. );
  9241. td.appendChild(span);
  9242. tr = appendTr(tbody,'mh_tdpage');
  9243. td = appendTdText(tr,'EFFACER : ',true);
  9244. td.align = 'center';
  9245. td.className = 'mh_tdtitre';
  9246. td.width = 100;
  9247. td = appendTdCenter(tr,2);
  9248. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  9249. checkBoxGG = appendCheckBoxSpan(
  9250. td,'delgg',filtreTresors," Les GG'"
  9251. ).firstChild;
  9252. checkBoxCompos = appendCheckBoxSpan(
  9253. td,'delcomp',filtreTresors,' Les Compos'
  9254. ).firstChild;
  9255. checkBoxBidouilles = appendCheckBoxSpan(
  9256. td,'delbid',filtreTresors,' Les Bidouilles'
  9257. ).firstChild;
  9258. checkBoxIntangibles = appendCheckBoxSpan(
  9259. td,'delint',filtreTrolls,' Les Intangibles'
  9260. ).firstChild;
  9261. checkBoxGowapsA = appendCheckBoxSpan(
  9262. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  9263. ).firstChild;
  9264. checkBoxGowapsS = appendCheckBoxSpan(
  9265. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  9266. ).firstChild;
  9267. checkBoxEngages = appendCheckBoxSpan(
  9268. td,'delengage',filtreMonstres,' Les Engagés'
  9269. ).firstChild;
  9270. checkBoxLevels = appendCheckBoxSpan(
  9271. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  9272. ).firstChild;
  9273. checkBoxDiplo = appendCheckBoxSpan(
  9274. td,'delDiplo',refreshDiplo,' La Diplomatie'
  9275. ).firstChild;
  9276. checkBoxTrou = appendCheckBoxSpan(
  9277. td,'deltrou',filtreLieux,' Les Trous'
  9278. ).firstChild;
  9279. checkBoxMythiques = appendCheckBoxSpan(
  9280. td,'delmyth',filtreMonstres,' Les Mythiques'
  9281. ).firstChild;
  9282. if(MY_getValue('NOINFOEM')!='true') {
  9283. checkBoxEM = appendCheckBoxSpan(
  9284. td,'delem',filtreMonstres,' Les Composants EM'
  9285. ).firstChild;
  9286. }
  9287. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  9288. td,'deltres',filtreTresors,' Les Trésors non libres'
  9289. ).firstChild;
  9290. checkBoxTactique = appendCheckBoxSpan(
  9291. td,'deltactique',updateTactique,' Les Infos tactiques'
  9292. ).firstChild;
  9293. if(MY_getValue('INFOPLIE')) {
  9294. toggleTableauInfos(true);
  9295. }
  9296. }
  9297.  
  9298. function toggleTableauInfos(firstRun) {
  9299. var
  9300. msg = document.getElementById('msgInfoTab'),
  9301. corps = document.getElementById('corpsInfoTab'),
  9302. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9303. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  9304. if(!firstRun) {
  9305. infoplie = !infoplie;
  9306. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9307. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  9308. }
  9309. if(infoplie) {
  9310. msg.style.display = '';
  9311. corps.style.display = 'none';
  9312. } else {
  9313. msg.style.display = 'none';
  9314. corps.style.display = '';
  9315. }
  9316. }
  9317.  
  9318. /* [functions] Filtres */
  9319. function prepareFiltrage(ref,width) {
  9320. // = Initialise le filtre 'ref'
  9321. try {
  9322. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  9323. } catch(e) {
  9324. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  9325. return false;
  9326. }
  9327. if(width) { tdTitre.width = width; }
  9328. // Ajout du tr de Filtrage (masqué)
  9329. var tbody = tdTitre.parentNode.parentNode;
  9330. var tr = appendTr(tbody,'mh_tdpage');
  9331. tr.style.display = 'none';
  9332. tr.id = 'trFiltre'+ref;
  9333. var td = appendTd(tr);
  9334. td.colSpan = 5;
  9335. // Ajout du bouton de gestion de Filtrage
  9336. var tdBtn = insertAfterTd(tdTitre);
  9337. tdBtn.id = 'tdInsert'+ref;
  9338. var btn = appendButton(tdBtn,'Filtrer');
  9339. btn.id = 'btnFiltre'+ref;
  9340. btn.onclick = function() {
  9341. debutFiltrage(ref)
  9342. };
  9343. return td;
  9344. }
  9345.  
  9346. function debutFiltrage(ref) {
  9347. // = Handler de début de filtrage (filtre 'ref')
  9348. document.getElementById('trFiltre'+ref).style.display = '';
  9349. var btn = document.getElementById('btnFiltre'+ref);
  9350. btn.value = 'Annuler Filtre';
  9351. btn.onclick = function() {
  9352. finFiltrage(ref);
  9353. };
  9354. }
  9355.  
  9356. function finFiltrage(ref) {
  9357. // = Handler de fin de filtrage (filtre 'ref')
  9358. /* On réassigne le bouton 'Filtrer' */
  9359. document.getElementById('trFiltre'+ref).style.display = 'none';
  9360. var btn = document.getElementById('btnFiltre'+ref);
  9361. btn.value = 'Filtrer';
  9362. btn.onclick = function() {
  9363. debutFiltrage(ref);
  9364. };
  9365. /* Réinitialisation filtres */
  9366. document.getElementById('str'+ref).value = '';
  9367. switch(ref) {
  9368. case 'Monstres':
  9369. document.getElementById('nivMinMonstres').value = 0;
  9370. document.getElementById('nivMaxMonstres').value = 0;
  9371. break;
  9372. case 'Trolls':
  9373. document.getElementById('strGuildes').value = '';
  9374. }
  9375. /* Nettoyage (=lance le filtre) */
  9376. // Ici this = MZ.global = sandBox de travail de MZ
  9377. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  9378. //this['filtre'+ref]();
  9379. switch (ref) {
  9380. case 'Monstres':
  9381. filtreMonstres();
  9382. break;
  9383. case 'Trolls':
  9384. filtreTrolls();
  9385. break;
  9386. case 'Tresors':
  9387. filtreTresors();
  9388. break;
  9389. case 'Lieux':
  9390. filtreLieux();
  9391. break;
  9392. default:
  9393. window.console.log('cas incongru dans finFiltrage : ' + ref);
  9394. break;
  9395. }
  9396. }
  9397.  
  9398. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  9399. var bouton = appendButton(td,nomBouton,onClick);
  9400. appendText(td,'\u00a0');
  9401. var textbox = appendTextbox(td,'text',id,15,30);
  9402. textbox.onkeypress = function(event) {
  9403. try {
  9404. if(event.keyCode==13) {
  9405. event.preventDefault();
  9406. bouton.click();
  9407. }
  9408. }
  9409. catch(e){
  9410. window.alert(e)
  9411. }
  9412. };
  9413. }
  9414.  
  9415. function ajoutFiltreMenu(tr,id,onChange) {
  9416. var select = document.createElement('select');
  9417. select.id = id;
  9418. select.onchange = onChange;
  9419. appendOption(select,0,'Aucun');
  9420. for(var i=1 ; i<=60 ; i++) {
  9421. appendOption(select,i,i);
  9422. }
  9423. tr.appendChild(select);
  9424. return select;
  9425. }
  9426.  
  9427. function ajoutDesFiltres() {
  9428. /* Monstres */
  9429. var td = prepareFiltrage('Monstres',120);
  9430. if(td) {
  9431. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  9432. appendText(td,'\u00a0\u00a0\u00a0');
  9433. appendText(td,'Niveau Min: ');
  9434. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  9435. appendText(td,'\u00a0');
  9436. appendText(td,'Niveau Max: ');
  9437. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  9438. }
  9439. /* Trõlls */
  9440. td = prepareFiltrage('Trolls',50);
  9441. if(td) {
  9442. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  9443. appendText(td,'\u00a0\u00a0\u00a0');
  9444. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  9445. }
  9446. /* Trésors */
  9447. td = prepareFiltrage('Tresors',55);
  9448. if(td) {
  9449. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  9450. }
  9451. /* Lieux */
  9452. td = prepareFiltrage('Lieux',40);
  9453. if(td) {
  9454. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  9455. }
  9456. }
  9457.  
  9458. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  9459.  
  9460. /* [functions] Affichage de la colonne des niveaux */
  9461. function insertLevelColumn() {
  9462. // Déclenché si bascule vers affichage des niveaux des mobs
  9463. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  9464. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  9465. td.width = 25;
  9466. for(var i=1 ; i<=nbMonstres ; i++) {
  9467. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  9468. td = insertTdText(getMonstreLevelNode(i), '-');
  9469. td.onclick = function() {
  9470. basculeCDM(
  9471. getMonstreNomByTR(this.parentNode),
  9472. getMonstreIDByTR(this.parentNode)
  9473. );
  9474. };
  9475. td.onmouseover = function() {
  9476. this.style.cursor = 'pointer';
  9477. this.className = 'mh_tdtitre';
  9478. };
  9479. td.onmouseout = function() {
  9480. if(this.parentNode.diploActive=='oui') {
  9481. this.className = '';
  9482. } else {
  9483. this.className = 'mh_tdpage';
  9484. }
  9485. };
  9486. td.style = 'font-weight:bold;text-align:center;';
  9487. if(isCDMsRetrieved) {
  9488. // Rappel des niveaux si mémorisés
  9489. td.innerHTML = listeLevels[i];
  9490. }
  9491. }
  9492. }
  9493.  
  9494. function toggleLevelColumn() {
  9495. // = Handler checkBox noLevel
  9496. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  9497. insertLevelColumn();
  9498. if(!isCDMsRetrieved) { retrieveCDMs(); }
  9499. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  9500. for(var i=0 ; i<=nbMonstres ; i++) {
  9501. if(isCDMsRetrieved) {
  9502. // Mémorisation des niveaux pour rappel éventuel
  9503. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  9504. }
  9505. // Suppression du td Niveau
  9506. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  9507. }
  9508. }
  9509. }
  9510.  
  9511. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  9512. function basculeCDM(nom,id) {
  9513. // = Bascule l'affichage des popups CdM
  9514. if(listeCDM[id]) {
  9515. if(!document.getElementById('popupCDM'+id)) {
  9516. afficherCDM(nom, id);
  9517. } else {
  9518. cacherPopupCDM('popupCDM'+id);
  9519. }
  9520. }
  9521. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  9522. }
  9523.  
  9524. function cacherPopupCDM(titre) {
  9525. var popup = document.getElementById(titre);
  9526. popup.parentNode.removeChild(popup);
  9527. }
  9528.  
  9529. /* DEBUG: Section à mettre à jour */
  9530. var selectionFunction;
  9531.  
  9532. function startDrag(evt) {
  9533. winCurr = this.parentNode;
  9534. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  9535. offsetX = evt.pageX - parseInt( winCurr.style.left );
  9536. offsetY = evt.pageY - parseInt( winCurr.style.top );
  9537. selectionFunction = document.body.style.MozUserSelect;
  9538. document.body.style.MozUserSelect = 'none';
  9539. winCurr.style.MozUserSelect = 'none';
  9540. return false;
  9541. }
  9542.  
  9543. function stopDrag(evt) {
  9544. winCurr.style.MozUserSelect = selectionFunction;
  9545. document.body.style.MozUserSelect = selectionFunction;
  9546. winCurr = null;
  9547. }
  9548.  
  9549. function drag(evt) {
  9550. if(winCurr==null) { return; }
  9551. evt = evt || window.event;
  9552. winCurr.style.left = (evt.pageX - offsetX)+'px';
  9553. winCurr.style.top = (evt.pageY - offsetY)+'px';
  9554. return false;
  9555. }
  9556. /* FIN DEBUG */
  9557. if(!isPage("MH_Play/Play_equipement")) {
  9558. // Conflit overlib/Tout_MZ:
  9559. // Double définition du "onmousemove" sur la page d'équipement
  9560. document.onmousemove = drag;
  9561. }
  9562.  
  9563. function afficherCDM(nom,id) {
  9564. // Crée la table de CdM du mob n° id
  9565. var donneesMonstre = listeCDM[id];
  9566. /* Début création table */
  9567. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  9568. table.id = 'popupCDM'+id;
  9569. table.style =
  9570. 'position:fixed;'+
  9571. 'z-index:1;'+
  9572. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  9573. 'left:'+(window.innerWidth-365)+'px;'+
  9574. 'width:300px;'+
  9575. 'height:200px;';
  9576. /* Ajout du titre avec gestion Drag & Drop */
  9577. var tr = table.firstChild;
  9578. tr.style.cursor = 'move';
  9579. tr.onmousedown = startDrag;
  9580. tr.onmouseup = stopDrag;
  9581. /* Ajout du bouton "Fermer" */
  9582. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  9583. tr.onmouseover = function() {
  9584. this.style.cursor = 'pointer';
  9585. this.className = 'mh_tdpage';
  9586. };
  9587. tr.onmouseout = function() {
  9588. this.className = 'mh_tdtitre';
  9589. };
  9590. tr.idcdm = id;
  9591. tr.onclick = function() {
  9592. cacherPopupCDM('popupCDM'+this.idcdm);
  9593. this.className = 'mh_tdtitre';
  9594. };
  9595. td = appendTdText(tr,'Fermer',true);
  9596. td.colSpan = 2;
  9597. td.style = 'text-align:center;';
  9598. nbCDM++;
  9599. /* Fin création table & Affichage */
  9600. document.body.appendChild(table);
  9601. }
  9602.  
  9603. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  9604. function initPopupVue() {
  9605. popup = document.createElement('div');
  9606. popup.id = 'popup';
  9607. popup.className = 'mh_textbox';
  9608. popup.style =
  9609. 'position: absolute;'+
  9610. 'border: 1px solid #000000;'+
  9611. 'visibility: hidden;'+
  9612. 'display: inline;'+
  9613. 'z-index: 3;'+
  9614. 'max-width: 400px;';
  9615. document.body.appendChild(popup);
  9616. }
  9617.  
  9618. /* [functions] Récupération / Computation des Infos Tactiques */
  9619. // TODO à revoir
  9620. function retireMarquage(nom) {
  9621. var i = nom.indexOf(']');
  9622. switch(i) {
  9623. case -1:
  9624. case nom.length-1:
  9625. return nom;
  9626. default:
  9627. return nom.slice(0,i+1);
  9628. }
  9629. }
  9630.  
  9631. function showPopupError(sHTML) {
  9632. window.console.log('[MZ] affichage PopupError ' + sHTML);
  9633. var divpopup = document.createElement('div');
  9634. divpopup.id = 'divpopup';
  9635. divpopup.style =
  9636. 'position: fixed;'+
  9637. 'border: 3px solid #000000;'+
  9638. 'top: 300px;left: 10px;'+
  9639. 'background-color: red;'+
  9640. 'color: white;'+
  9641. 'font-size: xx-large;'+
  9642. 'z-index: 200;';
  9643. divpopup.innerHTML = sHTML;
  9644. var divcroix = document.createElement('div');
  9645. divcroix.style =
  9646. 'position: absolute;'+
  9647. 'top: 0;right: 0;'+
  9648. 'color: inherit;'+
  9649. 'font-size: inherit;'+
  9650. 'cursor: pointer;'+
  9651. 'z-index: 201;';
  9652. divcroix.innerHTML = "X";
  9653. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  9654. document.body.appendChild(divpopup);
  9655. divpopup.appendChild(divcroix);
  9656. }
  9657.  
  9658. function retrieveCDMs() {
  9659. // Roule 18/11/2017 mise en sommeil MZ V2, on a besoin de tester en mode dev avec l'ancienne version
  9660. return retrieveCDMsOld();
  9661. //if (isDEV) return retrieveCDMsNew();
  9662. //else return retrieveCDMsOld();
  9663. }
  9664.  
  9665. function retrieveCDMsNew() {
  9666. // Récupère les CdM disponibles dans la BDD
  9667. // Lancé uniquement sur toggleLevelColumn
  9668. if(checkBoxLevels.checked) return;
  9669. if (nbMonstres < 1) return;
  9670.  
  9671. var tReq = [];
  9672. for (var i=1 ; i<=nbMonstres ; i++) {
  9673. tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  9674. }
  9675.  
  9676. FF_XMLHttpRequest({
  9677. method: 'POST',
  9678. url: URL_MZgetCaracMonstre,
  9679. headers : {
  9680. 'Content-type':'application/x-www-form-urlencoded'
  9681. },
  9682. data: 'l=' + tReq.join("\n"),
  9683. trace: 'demande niveaux monstres V2',
  9684. onload: function(responseDetails) {
  9685. try {
  9686. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9687. if (responseDetails.status == 0) return;
  9688. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  9689. var texte = responseDetails.responseText;
  9690. var lines = texte.split('\n');
  9691. if(lines.length==0) return;
  9692. var begin2, end2, index;
  9693. for(var j=0 ; j<lines.length ; j++) {
  9694. var infos = lines[j].split("\t");
  9695. if(infos.length<3) { continue; }
  9696. var index = infos[0]
  9697. var idMonstre=infos[1];
  9698. var level = infos[2];
  9699. // 3 cas
  9700. // il y a des infos, infos[] a plus de 3 valeurs
  9701. // il n'y a pas d'info pour ce monstre, infos[] a 4 valeur, la 4e est "-"
  9702. // les infos n'ont pas été récupérées (après le 50e monstre), il n'y a que 3 valeurs
  9703. if (infos.length == 3) {
  9704. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9705. } else if (infos.length > 4) {
  9706. infos = infos.slice(3);
  9707. 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)
  9708. listeCDM[idMonstre] = infos;
  9709. getMonstreLevelNode(index).innerHTML = '<b>'+level+'</b>';
  9710. } else {
  9711. getMonstreLevelNode(index).innerHTML = level;
  9712. }
  9713. }
  9714. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  9715. computeMission(1, nbMonstres);
  9716. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  9717. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9718. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  9719. } catch(e) {
  9720. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9721. }
  9722. isCDMsRetrieved=true;
  9723. },
  9724. });
  9725. //str = '';
  9726. //begin = i+1;
  9727. //isCDMsRetrieved=true;
  9728. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  9729. }
  9730.  
  9731. function retrieveCDMsOld() {
  9732. // Récupère les CdM disponibles dans la BDD
  9733. // Lancé uniquement sur toggleLevelColumn
  9734. if(checkBoxLevels.checked) { return; }
  9735. // Roule, message si l'utilisateur a décoché "Menu d'actions contextuelles"
  9736. if (!tr_monstres[0].cells[2].innerHTML.match(/r[eéè]f/i)) {
  9737. 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);
  9738. return;
  9739. }
  9740.  
  9741. var str = '';
  9742. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  9743. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  9744. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  9745. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  9746. for(var i=1 ; i<=cdmMax ; i++) {
  9747. var nomMonstre = retireMarquage(getMonstreNom(i));
  9748. if(nomMonstre.indexOf(']') != -1) {
  9749. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  9750. }
  9751. // *** WARNING : PROXY RATIBUS ***
  9752. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  9753. str += 'nom[]='+escape(nomMonstre)+'$'+(
  9754. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  9755. )+'&';
  9756. }
  9757.  
  9758. // Roule 31/07/2017 suppression du saucissonnage : inutile et complique les choses ensuite
  9759. //if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  9760. FF_XMLHttpRequest({
  9761. method: 'POST',
  9762. url: URL_MZinfoMonstre,
  9763. headers : {
  9764. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9765. 'Accept': 'application/atom+xml,application/xml,text/xml',
  9766. 'Content-type':'application/x-www-form-urlencoded'
  9767. },
  9768. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  9769. trace: 'demande niveaux monstres',
  9770. onload: function(responseDetails) {
  9771. try {
  9772. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9773. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  9774. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  9775. '" target="raistlin">Mountyzilla - https<br />'+
  9776. 'Tu dois accepter le certificat de Raistlin<br />'+
  9777. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  9778. ' « Confirmer l\'exception de sécurité »</a>');
  9779. return;
  9780. }
  9781. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  9782. var texte = responseDetails.responseText;
  9783. var lines = texte.split('\n');
  9784. if(lines.length==0) { return; }
  9785. var begin2, end2, index;
  9786. for(var j=0 ; j<lines.length ; j++) {
  9787. var infos = lines[j].split(';');
  9788. if(infos.length<4) { continue; }
  9789. var idMonstre=infos[0];
  9790. var isCDM = infos[1];
  9791. index = parseInt(infos[2]);
  9792. var level = infos[3];
  9793. infos = infos.slice(3);
  9794. 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)
  9795. if(begin2==null) { begin2 = index; }
  9796. end2 = index;
  9797. listeCDM[idMonstre] = infos;
  9798. if(isCDM==1) {
  9799. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9800. } else {
  9801. getMonstreLevelNode(index).innerHTML = level;
  9802. }
  9803. }
  9804. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres avant computeMission');
  9805. computeMission(begin2,end2);
  9806. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres avant filtreMonstres');
  9807. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9808. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres fin');
  9809. } catch(e) {
  9810. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9811. }
  9812. isCDMsRetrieved=true;
  9813. },
  9814. });
  9815. //str = '';
  9816. //begin = i+1;
  9817. //isCDMsRetrieved=true;
  9818. //window.console.log('[MZd] ' + (+new Date) + ' requête ajax partie pour ' + cdmMax + ' monstres');
  9819. }
  9820.  
  9821. function computeMission(begin,end) {
  9822. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  9823. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  9824. computeVLC(begin,end);
  9825. //+++window.console.log('computeMission, après computeVLC');
  9826. if(!begin) begin=1;
  9827. if(!end) end=nbMonstres;
  9828. var str = MY_getValue(numTroll+'.MISSIONS');
  9829. if(!str) { return; }
  9830. var urlImg = URL_MZimg+'mission.png';
  9831. var obMissions = JSON.parse(str);
  9832. for(var i=end ; i>=begin ; i--) {
  9833. var mess = '';
  9834. for(var num in obMissions) {
  9835. var mobMission = false;
  9836. switch(obMissions[num].type) {
  9837. case 'Race':
  9838. var race = epure(obMissions[num].race.toLowerCase());
  9839. var nom = epure(getMonstreNom(i).toLowerCase());
  9840. if(nom.indexOf(race)!=-1) {
  9841. mobMission = true;
  9842. }
  9843. break;
  9844. case 'Niveau':
  9845. var donneesMonstre = listeCDM[getMonstreID(i)];
  9846. if(donneesMonstre) {
  9847. var nivMob = Number(donneesMonstre[0]);
  9848. var nivMimi = Number(obMissions[num].niveau),
  9849. mod = obMissions[num].mod;
  9850. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  9851. || (isNaN(mod) && nivMob>=nivMimi)) {
  9852. mobMission = true;
  9853. }
  9854. }
  9855. break;
  9856. case 'Famille':
  9857. var donneesMonstre = listeCDM[getMonstreID(i)];
  9858. if(donneesMonstre) {
  9859. var familleMimi = epure(obMissions[num].famille.toLowerCase()).replace(/[']/g,''); // Roule 27/02/2019 simple quote dans les familles
  9860. var familleMob = epure(donneesMonstre[1].toLowerCase());
  9861. if(familleMob.indexOf(familleMimi)!=-1) {
  9862. mobMission = true;
  9863. }
  9864. }
  9865. break;
  9866. case 'Pouvoir':
  9867. var donneesMonstre = listeCDM[getMonstreID(i)];
  9868. if(donneesMonstre) {
  9869. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  9870. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  9871. if(pvrMob.indexOf(pvrMimi)!=-1) {
  9872. mobMission = true;
  9873. }
  9874. }
  9875. }
  9876. if(mobMission) {
  9877. mess += mess ? '\n\n' : '';
  9878. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  9879. }
  9880. }
  9881. if(mess) {
  9882. var td = getMonstreNomNode(i);
  9883. appendText(td,' ');
  9884. td.appendChild(createImage(urlImg,mess));
  9885. }
  9886. }
  9887. }
  9888.  
  9889. function computeVLC(begin,end) {
  9890. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  9891. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  9892. computeTactique(begin,end);
  9893. //+++window.console.log('computeVLC, après computeTactique');
  9894. if(!begin) begin=1;
  9895. if(!end) end=nbMonstres;
  9896. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  9897. if(!cache)
  9898. return false;
  9899. var urlImg = URL_MZimg + "oeil.png";
  9900. for(var i = end; i >= begin;i--)
  9901. {
  9902. var id = getMonstreID(i);
  9903. var donneesMonstre = listeCDM[id];
  9904. if(donneesMonstre && donneesMonstre.length>12)
  9905. {
  9906. if(donneesMonstre[12]==1)
  9907. {
  9908. var td = getMonstreNomNode(i);
  9909. td.appendChild(document.createTextNode(" "));
  9910. td.appendChild(createImage(urlImg, "Voit le caché"));
  9911. }
  9912. }
  9913. }
  9914. }
  9915.  
  9916. /* appelé
  9917. par updateTactique
  9918. par initialiseInfos
  9919. par do_vue
  9920. par computeVLC
  9921. par computeMission
  9922. par filtreMonstres
  9923. par retrieveCDMs
  9924. */
  9925. function computeTactique(begin, end) {
  9926. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  9927. try {
  9928. if(!begin) begin = 1;
  9929. if(!end) end = nbMonstres;
  9930. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  9931. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9932. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  9933. if(noTactique || !isProfilActif()) return;
  9934. //+++window.console.log('computeTactique, après isProfilActif');
  9935.  
  9936. for(var j=end ; j>=begin ; j--) {
  9937. var id = getMonstreID(j);
  9938. var nom = getMonstreNom(j);
  9939. var donneesMonstre = listeCDM[id];
  9940. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  9941. var td = getMonstreNomNode(j);
  9942. appendText(td,' ');
  9943. td.appendChild(
  9944. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  9945. );
  9946. }
  9947. }
  9948. }
  9949. catch(e) {
  9950. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  9951. }
  9952. filtreMonstres();
  9953. }
  9954.  
  9955. function updateTactique() {
  9956. // = Handler checkBox noTactique
  9957. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9958. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  9959. if(!isCDMsRetrieved) return;
  9960. //+++window.console.log('updateTactique, isCDMsRetrieved=' + isCDMsRetrieved);
  9961.  
  9962. if(noTactique) {
  9963. for(var i=nbMonstres ; i>0 ; i--) {
  9964. var tr = getMonstreNomNode(i);
  9965. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9966. tr, null, 9, null).singleNodeValue;
  9967. if(img) {
  9968. img.parentNode.removeChild(img.previousSibling);
  9969. img.parentNode.removeChild(img);
  9970. }
  9971. }
  9972. }
  9973. else
  9974. computeTactique();
  9975. }
  9976.  
  9977. function filtreMonstres() {
  9978. // = Handler universel pour les fonctions liées aux monstres
  9979. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9980. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9981. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9982. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9983. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9984. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9985. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9986. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9987. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9988. // old/new : détermine s'il faut ou non nettoyer les tr
  9989. var oldNOEM = true, noEM = true;
  9990. if(MY_getValue('NOINFOEM')!='true') {
  9991. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9992. }
  9993. // Filtrage par nom
  9994. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9995. // Génère la liste des mobs engagés (si filtrés)
  9996. if(noEngages && !isEngagesComputed) {
  9997. for(var i=nbTrolls ; i>0 ; i--) {
  9998. var pos = getTrollPosition(i);
  9999. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  10000. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  10001. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  10002. }
  10003. isEngagesComputed = true;
  10004. }
  10005. /*** FILTRAGE ***/
  10006. /* À computer :
  10007. * - EM (nom suffit)
  10008. * - Enchant (nom suffit)
  10009. * - Mission (nécessite CdM)
  10010. * - mob VlC (nécessite CdM)
  10011. * Sans computation :
  10012. * - Gowap ? engagé ?
  10013. */
  10014. for(var i=nbMonstres ; i>0 ; i--) {
  10015. var pos = getMonstrePosition(i);
  10016. var nom = getMonstreNom(i).toLowerCase();
  10017. if(noEM!=oldNOEM) {
  10018. if(noEM) {
  10019. // Si noEM passe de false à true, on nettoie les td "Nom"
  10020. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  10021. var tr = getMonstreNomNode(i);
  10022. while(tr.childNodes.length>1) {
  10023. tr.removeChild(tr.childNodes[1]);
  10024. }
  10025. } else {
  10026. var tr = getMonstreNomNode(i);
  10027. var TypeMonstre=getEM(nom);
  10028. if(TypeMonstre!='') {
  10029. var infosCompo=compoMobEM(TypeMonstre);
  10030. if(infosCompo.length>0) {
  10031. tr.appendChild(document.createTextNode(' '));
  10032. tr.appendChild(createImage(urlImg, infosCompo));
  10033. }
  10034. }
  10035. }
  10036. }
  10037. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  10038. var texte = getInfoEnchantementFromMonstre(nom);
  10039. if(texte!='') {
  10040. var td = getMonstreNomNode(i);
  10041. td.appendChild(document.createTextNode(' '));
  10042. td.appendChild(createImage(urlEnchantImg, texte));
  10043. }
  10044. }
  10045. tr_monstres[i].style.display = (
  10046. noGowapsS &&
  10047. nom.indexOf('gowap sauvage')!=-1 &&
  10048. getMonstreDistance(i)>1
  10049. ) || (
  10050. noGowapsA &&
  10051. nom.indexOf('gowap apprivoisé')!=-1 &&
  10052. getMonstreDistance(i)>1
  10053. ) || (
  10054. noEngages &&
  10055. getMonstreDistance(i)!=0 &&
  10056. listeEngages[pos[0]] &&
  10057. listeEngages[pos[0]][pos[1]] &&
  10058. listeEngages[pos[0]][pos[1]][pos[2]]
  10059. ) || (
  10060. strMonstre!='' &&
  10061. nom.indexOf(strMonstre)==-1
  10062. ) || (
  10063. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  10064. getMonstreDistance(i)>1 &&
  10065. nom.toLowerCase().indexOf("kilamo")==-1
  10066. ) ? 'none' : '';
  10067. }
  10068. if(MY_getValue('NOINFOEM')!='true') {
  10069. if(noEM != oldNOEM) {
  10070. if(noEM && isCDMsRetrieved) computeMission();
  10071. }
  10072. oldNOEM = noEM;
  10073. }
  10074. needComputeEnchantement = false;
  10075. }
  10076.  
  10077.  
  10078. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  10079.  
  10080. function filtreTrolls() {
  10081. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  10082. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  10083. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  10084. for(var i=1 ; i<=nbTrolls ; i++) {
  10085. tr_trolls[i].style.display = (
  10086. noIntangibles &&
  10087. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  10088. ) || (
  10089. strTroll!='' &&
  10090. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  10091. ) || (
  10092. strGuilde!='' &&
  10093. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  10094. ) ? 'none' : '';
  10095. }
  10096. }
  10097.  
  10098. /* [functions] Bulle PX Trolls */
  10099. var bulle;
  10100.  
  10101. function initPXTroll() {
  10102. bulle = document.createElement('div');
  10103. bulle.id = 'bulle';
  10104. bulle.className = 'mh_textbox';
  10105. bulle.style =
  10106. 'position: absolute;'+
  10107. 'border: 1px solid #000000;'+
  10108. 'visibility: hidden;'+
  10109. 'display: inline;'+
  10110. 'z-index: 2;';
  10111. document.body.appendChild(bulle);
  10112.  
  10113. for(var i=nbTrolls ; i>0 ; i--) {
  10114. var td_niv = getTrollNivNode(i);
  10115. td_niv.onmouseover = showPXTroll;
  10116. td_niv.onmouseout = hidePXTroll;
  10117. }
  10118. }
  10119.  
  10120. function showPXTroll(evt) {
  10121. var lvl = this.firstChild.nodeValue;
  10122. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  10123. bulle.style.left = evt.pageX+15+'px';
  10124. bulle.style.top = evt.pageY+'px';
  10125. bulle.style.visibility = 'visible';
  10126. }
  10127.  
  10128. function hidePXTroll() {
  10129. bulle.style.visibility = 'hidden';
  10130. }
  10131.  
  10132. /* [functions] Envoi PX / MP */
  10133. function putBoutonPXMP() {
  10134. // Bouton d'initialisation du mode Envoi
  10135. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  10136. var td = document.getElementById('tdInsertTrolls');
  10137. if(!td) { return; }
  10138. td.width = 100;
  10139. td = insertAfterTd(td);
  10140. td.style.verticalAlign = 'top';
  10141. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  10142. bouton.id = 'btnEnvoi';
  10143. }
  10144.  
  10145. function prepareEnvoi() {
  10146. // = 1er Handler du bouton d'envoi
  10147. /* Ajout de la colonne des CheckBoxes */
  10148. var td = insertTdText(getTrollNomNode(0),'');
  10149. td.width = 5;
  10150. for(var i=nbTrolls ; i>0 ; i--) {
  10151. td = insertTd(getTrollNomNode(i));
  10152. appendCheckBox(td,'envoi'+i);
  10153. }
  10154. /* Ajout du radio de choix PX ou MP */
  10155. var btnEnvoi = document.getElementById('btnEnvoi');
  10156. if(!btnEnvoi) { return; }
  10157. var tdEnvoi = btnEnvoi.parentNode;
  10158. appendText(tdEnvoi,' ');
  10159. var span = document.createElement('span');
  10160. span.style.whiteSpace = 'nowrap';
  10161. var radioElt = document.createElement('input');
  10162. radioElt.type = 'radio';
  10163. radioElt.name = 'envoiPXMP';
  10164. radioElt.id = 'radioPX';
  10165. span.appendChild(radioElt);
  10166. appendText(span,' des PX ');
  10167. radioElt = document.createElement('input');
  10168. radioElt.type = 'radio';
  10169. radioElt.name = 'envoiPXMP';
  10170. radioElt.checked = true;
  10171. span.appendChild(radioElt);
  10172. appendText(span,' un MP');
  10173. tdEnvoi.appendChild(span);
  10174. /* Insertion du bouton Annuler */
  10175. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  10176. /* Modification de l'effet du bouton Envoi */
  10177. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  10178. }
  10179.  
  10180. function annuleEnvoi() {
  10181. // = Handler bouton Annuler
  10182. /* Nettoyage du td du bouton Envoi */
  10183. var btnEnvoi = document.getElementById('btnEnvoi');
  10184. var tdEnvoi = btnEnvoi.parentNode;
  10185. while(tdEnvoi.firstChild) {
  10186. tdEnvoi.removeChild(tdEnvoi.firstChild);
  10187. }
  10188. /* Retour à l'effet de base du bouton Envoi */
  10189. btnEnvoi.onclick = prepareEnvoi;
  10190. tdEnvoi.appendChild(btnEnvoi);
  10191. /* Suppression CheckBoxes */
  10192. for(var i=nbTrolls ; i>=0 ; i--) {
  10193. var td = getTrollNomNode(i);
  10194. td.parentNode.removeChild(td);
  10195. }
  10196. }
  10197.  
  10198. function effectueEnvoi() {
  10199. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  10200. var str='';
  10201. var errID = false;
  10202. for(var i=nbTrolls ; i>0 ; i--) {
  10203. var chb = document.getElementById('envoi'+i);
  10204. if(chb.checked) {
  10205. var idTroll = getTrollID(i);
  10206. if (idTroll == undefined) {
  10207. errID = true;
  10208. } else {
  10209. str += (str ? ',' : '') + idTroll;
  10210. }
  10211. }
  10212. }
  10213. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  10214. var PXchecked = document.getElementById('radioPX').checked;
  10215. if(PXchecked) {
  10216. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  10217. } else {
  10218. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  10219. }
  10220. }
  10221.  
  10222. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  10223.  
  10224. function filtreTresors() {
  10225. // += Handler checkboxes : gg, compos, bidouilles, non libres
  10226. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  10227. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  10228. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  10229. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  10230. if(noEngages && !isEngagesComputed) {
  10231. for(var i=nbTrolls ; i>0 ; i--) {
  10232. var pos = getTrollPosition(i);
  10233. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  10234. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  10235. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  10236. }
  10237. isEngagesComputed = true;
  10238. }
  10239. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  10240. for(var i=nbTresors ; i>0 ; i--) {
  10241. var nom = getTresorNom(i);
  10242. var pos = getTresorPosition(i);
  10243. tr_tresors[i].style.display = (
  10244. noGG &&
  10245. nom.indexOf('Gigots de Gob')!=-1
  10246. ) || (
  10247. noCompos &&
  10248. nom.indexOf('Composant')!=-1
  10249. ) || (
  10250. noEngages &&
  10251. listeEngages[pos[2]] &&
  10252. listeEngages[pos[2]][pos[1]] &&
  10253. listeEngages[pos[2]][pos[1]][pos[0]] &&
  10254. getTresorDistance(i)>0
  10255. ) || (
  10256. strTresor!='' &&
  10257. nom.toLowerCase().indexOf(strTresor)==-1
  10258. ) || (
  10259. noBidouilles &&
  10260. nom.indexOf('Bidouille')!=-1
  10261. ) ? 'none' : '';
  10262. }
  10263. }
  10264.  
  10265.  
  10266. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  10267.  
  10268. function filtreLieux() {
  10269. // += Handler checkbox trous
  10270. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  10271. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  10272. for(var i=nbLieux ; i>0 ; i--) {
  10273. tr_lieux[i].style.display = (
  10274. strLieu &&
  10275. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  10276. ) || (
  10277. noTrou &&
  10278. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  10279. getLieuDistance(i)>1
  10280. ) ? 'none' : '';
  10281. }
  10282. }
  10283.  
  10284.  
  10285. /*-[functions]-------------------- Diplomatie --------------------------------*/
  10286.  
  10287. function refreshDiplo() {
  10288. MY_setValue(numTroll+'.diplo.off',
  10289. checkBoxDiplo.checked?'true':'false'
  10290. );
  10291. if(isDiploRaw) { computeDiplo(); }
  10292. appliqueDiplo();
  10293. }
  10294.  
  10295. function computeDiplo() {
  10296. // On extrait les données de couleur et on les stocke par id
  10297. // Ordre de préséance :
  10298. // source Guilde < source Perso
  10299. // guilde cible < troll cible
  10300. /* Diplo de Guilde */
  10301. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  10302. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  10303. if(diploGuilde && diploGuilde.isOn=='true') {
  10304. // Guilde perso
  10305. if(diploGuilde.guilde) {
  10306. Diplo.Guilde[diploGuilde.guilde.id] = {
  10307. couleur: diploGuilde.guilde.couleur,
  10308. titre: 'Ma Guilde'
  10309. };
  10310. }
  10311. // Guildes/Trolls A/E
  10312. for(var AE in {Amis:0,Ennemis:0}) {
  10313. for(var i=0 ; i<5 ; i++) {
  10314. if(diploGuilde[AE+i]) {
  10315. for(var type in {Guilde:0,Troll:0}) {
  10316. var liste = diploGuilde[AE+i][type].split(';');
  10317. for(var j=liste.length-2 ; j>=0 ; j--) {
  10318. Diplo[type][liste[j]] = {
  10319. couleur: diploGuilde[AE+i].couleur,
  10320. titre: diploGuilde[AE+i].titre
  10321. };
  10322. }
  10323. }
  10324. }
  10325. }
  10326. }
  10327. }
  10328. /* Diplo Perso */
  10329. //var diploPerso = MY_getValue(numTroll+'.diplo.perso') ? JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {}; // déjà chargé
  10330. if(diploPerso && diploPerso.isOn=='true') {
  10331. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  10332. for(var id in diploPerso[type]) {
  10333. Diplo[type][id] = diploPerso[type][id];
  10334. }
  10335. }
  10336. }
  10337. if(diploPerso.mythiques) {
  10338. Diplo.mythiques = diploPerso.mythiques;
  10339. }
  10340. isDiploRaw = false;
  10341. }
  10342.  
  10343. function appliqueDiplo() {
  10344. var aAppliquer = Diplo;
  10345. if(checkBoxDiplo.checked) {
  10346. // Pour retour à l'affichage basique sur désactivation de la diplo
  10347. aAppliquer = {
  10348. Guilde: {},
  10349. Troll: {},
  10350. Monstre: {}
  10351. };
  10352. }
  10353. /* On applique "aAppliquer" */
  10354. // Diplo Trõlls
  10355. for(var i=nbTrolls ; i>0 ; i--) {
  10356. var idG = getTrollGuildeID(i);
  10357. var idT = getTrollID(i);
  10358. var tr = tr_trolls[i];
  10359. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  10360. if(aAppliquer.Troll[idT]) {
  10361. tr.className = '';
  10362. var descr = aAppliquer.Troll[idT].titre;
  10363. if(descr) {
  10364. getTrollNomNode(i).title = descr
  10365. }
  10366. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  10367. } else if(aAppliquer.Guilde[idG]) {
  10368. tr.className = '';
  10369. var descr = aAppliquer.Guilde[idG].titre;
  10370. if(descr) {
  10371. getTrollNomNode(i).title = descr
  10372. }
  10373. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  10374. } else {
  10375. tr.className = 'mh_tdpage';
  10376. getTrollNomNode(i).title = '';
  10377. }
  10378. }
  10379. // Diplo Monstres
  10380. for(var i=nbMonstres ; i>0 ; i--) {
  10381. var id = getMonstreID(i);
  10382. var nom = getMonstreNom(i).toLowerCase();
  10383. if(aAppliquer.Monstre[id]) {
  10384. tr_monstres[i].className = '';
  10385. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  10386. tr_monstres[i].diploActive = 'oui';
  10387. var descr = aAppliquer.Monstre[id].titre;
  10388. if(descr) {
  10389. getMonstreNomNode(i).title = descr;
  10390. }
  10391. } else if(aAppliquer.mythiques &&
  10392. (nom.indexOf('liche')==0 ||
  10393. nom.indexOf('hydre')==0 ||
  10394. nom.indexOf('balrog')==0 ||
  10395. nom.indexOf('beholder')==0)) {
  10396. tr_monstres[i].className = '';
  10397. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  10398. tr_monstres[i].diploActive = 'oui';
  10399. getMonstreNomNode(i).title = 'Monstre Mythique';
  10400. } else {
  10401. tr_monstres[i].className = 'mh_tdpage';
  10402. tr_monstres[i].diploActive = '';
  10403. }
  10404. }
  10405. }
  10406.  
  10407.  
  10408. /*-[functions]---------------- Actions à distance ----------------------------*/
  10409.  
  10410. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  10411. var monN = parseInt(getPosition()[2]);
  10412. for(var type in keltypes) {
  10413. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  10414. for(var i=this['nb'+type] ; i>0 ; i--) {
  10415. var tr = this['tr_'+type.toLowerCase()][i];
  10416. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  10417. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  10418. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  10419. var sonN = getXxxPosition(type, i)[2];
  10420. var d = getXxxDistance(type, i);
  10421. if(sonN==monN && d>=dmin && d<=dmax) {
  10422. var iconeAction = document.evaluate(
  10423. "./descendant::img[@alt='"+alt+"']",
  10424. tr, null, 9, null
  10425. ).singleNodeValue;
  10426. if(iconeAction) {
  10427. if(iconeAction.title) {
  10428. iconeAction.title += "\n"+message;
  10429. } else {
  10430. iconeAction.title = message;
  10431. }
  10432. iconeAction.src = urlIcon;
  10433. } else {
  10434. var tdAction = tr.getElementsByTagName('td')[1];
  10435. var icon = document.createElement('img');
  10436. icon.src = urlIcon;
  10437. icon.height = 20;
  10438. icon.alt = alt;
  10439. icon.title = message;
  10440. tdAction.appendChild(icon);
  10441. }
  10442. }
  10443. }
  10444. }
  10445. }
  10446.  
  10447. function computeCharge() {
  10448. computeActionDistante(1,
  10449. getPortee__Vue(
  10450. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  10451. MY_getValue(numTroll+".caracs.regeneration")
  10452. ),
  10453. {'Monstres':1, 'Trolls':1},
  10454. 'Attaquer',
  10455. MHicons+'E_Metal09.png',
  10456. 'Cible à portée de Charge'
  10457. );
  10458. }
  10459.  
  10460. function computeProjo() {
  10461. computeActionDistante(0,
  10462. getPortee__Vue(
  10463. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10464. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10465. ),
  10466. {'Monstres':1, 'Trolls':1},
  10467. 'Attaquer',
  10468. MHicons+'S_Fire05.png',
  10469. 'Cible à portée de Projo'
  10470. );
  10471. }
  10472.  
  10473. function computeTelek() {
  10474. computeActionDistante(0,
  10475. Math.floor((
  10476. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10477. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10478. )/2),
  10479. {'Tresors':1},
  10480. 'Telek',
  10481. MHicons+'S_Magic04.png',
  10482. 'Trésor à portée de Télékinésie'
  10483. );
  10484. }
  10485.  
  10486. function computeLdP() {
  10487. computeActionDistante(0,
  10488. 2+Math.floor((
  10489. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10490. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10491. )/5),
  10492. {'Monstres':1, 'Trolls':1},
  10493. 'self',
  10494. MHicons+'P_Red01.png',
  10495. 'Cible à portée de Lancer de Potions'
  10496. );
  10497. }
  10498.  
  10499.  
  10500. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  10501.  
  10502. function putScriptExterne(sInfo) {
  10503. for (var iBricol = 1; ; iBricol++) {
  10504. var extClef = iBricol == 1 ? '' : iBricol;
  10505. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  10506. if (!sInfo) break;
  10507. putScriptExterneOneIT(sInfo);
  10508. }
  10509. }
  10510.  
  10511. function putScriptExterneOneIT(sInfo) {
  10512. if(!sInfo || sInfo=='') return;
  10513.  
  10514. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  10515. if(nomit=='bricol') {
  10516. var data = sInfo.split('$');
  10517. try {
  10518. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  10519. // appendNewScript(URL_bricol+data[1]
  10520. // +'/mz.php?login='+data[2]
  10521. // +'&password='+data[3]
  10522. // );
  10523. FF_XMLHttpRequest({
  10524. method: 'GET',
  10525. url: URL_bricol+data[1]
  10526. +'/mz_json.php?login='+encodeURIComponent(data[2])
  10527. +'&password='+data[3],
  10528. trace: 'bricolTroll',
  10529. onload: function(responseDetails) {
  10530. try {
  10531. if (responseDetails.status == 0) {
  10532. window.console.log('status=0 à l\'appel bricol\'troll');
  10533. if (isHTTPS) {
  10534. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  10535. } else {
  10536. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  10537. }
  10538. return;
  10539. }
  10540. var ratibusData;
  10541. try {
  10542. ratibusData = JSON.parse(responseDetails.responseText);
  10543. } catch(e) {}
  10544. if (ratibusData === undefined) {
  10545. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  10546. return;
  10547. }
  10548. if (ratibusData.error) {
  10549. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  10550. } else {
  10551. putInfosTrolls(ratibusData.data.trolls, data[1]);
  10552. }
  10553. } catch(e) {
  10554. window.console.log(traceStack(e, 'retour bricol\'troll'));
  10555. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  10556. }
  10557. }
  10558. });
  10559. } catch(e) {
  10560. if (isHTTPS) {
  10561. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  10562. } else {
  10563. window.console.log(traceStack(e, 'appel bricol\'troll'));
  10564. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  10565. }
  10566. }
  10567. }
  10568. }
  10569.  
  10570. /*
  10571. * Roule 07/11/2016, on utilise mz_json qui envoie
  10572. {
  10573. "data": {
  10574. "trolls": {
  10575. "59424": {
  10576. "id": 59424,
  10577. "pv": xx,
  10578. "pv_max": xx,
  10579. "updated_at": "2016-10-31 07:28:40",
  10580. "dla": "2016-10-05 07:28:04",
  10581. "pa": 0
  10582. },
  10583. }
  10584. }
  10585. }
  10586. */
  10587.  
  10588. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  10589. function corrigeBricolTrolls(infosTrolls) {
  10590. for(var i in infosTrolls) {
  10591. var pv = infosTrolls[i][0];
  10592. var pvmax = infosTrolls[i][1];
  10593. var pvmem = MY_getValue(i+'.caracs.pv.max');
  10594. if(pvmem && pvmem>pvmax) {
  10595. infosTrolls[i][1] = pvmem;
  10596. pvmax = pvmem;
  10597. }
  10598. if(pv>pvmax) {
  10599. var newpvmax = 5*Math.ceil(pv/5);
  10600. MY_setValue(i+'.caracs.pv.max',newpvmax);
  10601. infosTrolls[i][1] = newpvmax;
  10602. }
  10603. }
  10604. }
  10605.  
  10606. // insère 2 TD avant nextTD avec les infos venant de l'IT
  10607. function addTdInfosTroll(infos, TR, itName) {
  10608. /* cadre barre PV */
  10609. var tab = document.createElement('div');
  10610. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  10611. /* barre PV */
  10612. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  10613. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  10614. .vieContainer {
  10615. background-color: #CCC;
  10616. width: 50px;
  10617. height: 6px;
  10618. border: 1px solid #000;
  10619. text-align: left;
  10620. }
  10621. */
  10622. tab.style.width = '100px';
  10623. tab.style.height = '10px';
  10624. tab.style.border = '1px solid #000';
  10625. tab.style.textAlign = 'left';
  10626. var div2 = document.createElement('div');
  10627. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  10628. var dateLimite = new Date();
  10629. dateLimite.setDate(dateLimite.getDate() - 7);
  10630. if (infos.oUpdatedAt < dateLimite) {
  10631. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  10632. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  10633. } else if (pourcentVie > 66) {
  10634. div2.style.backgroundColor = '#77EE77';
  10635. } else if (pourcentVie > 33) {
  10636. div2.style.backgroundColor = '#EEEE77';
  10637. } else {
  10638. div2.style.backgroundColor = '#FF0000';
  10639. }
  10640. div2.style.width = pourcentVie + '%';
  10641. div2.style.height = '10px';
  10642. tab.appendChild(div2);
  10643. /* ancienne méthode par img, à supprimer
  10644. var img = document.createElement('img');
  10645. img.src = '../Images/Interface/milieu.gif';
  10646. img.height = 10;
  10647. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  10648. tab.appendChild(img);
  10649. */
  10650.  
  10651. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  10652. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  10653. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  10654. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  10655.  
  10656. /* lien vers l'IT */
  10657. var lien = document.createElement('a');
  10658. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  10659. lien.href = URL_bricol+itName+'/index.php';
  10660. lien.target = '_blank';
  10661. lien.appendChild(tab);
  10662. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  10663. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  10664. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  10665. //insertTdElement(tdGuilde,lien);
  10666. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  10667. /* PAs dispos */
  10668. var span = document.createElement('span');
  10669. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  10670. appendText(span, infos.pa +' PA' );
  10671. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  10672. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  10673. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  10674. span.style.backgroundColor = 'B8EEB8';
  10675. }
  10676. //insertTdElement(tdGuilde, span);
  10677. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  10678. }
  10679.  
  10680. var MZ_tabTrTrollById;
  10681. function putInfosTrolls(infosTrolls, itName) {
  10682. try {
  10683. if (MZ_tabTrTrollById === undefined) {
  10684. MZ_tabTrTrollById = new Array;
  10685. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  10686. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  10687. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  10688. td.width = 40;
  10689. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  10690. td.width = 105;
  10691. for(i=nbTrolls ; i>0 ; i--) {
  10692. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  10693. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  10694. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  10695. }
  10696. }
  10697.  
  10698.  
  10699. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  10700. //corrigeBricolTrolls(infosTrolls);
  10701.  
  10702. // supression des infos trop vieilles (un mois)
  10703. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  10704. var dateLimite = new Date();
  10705. dateLimite.setMonth(dateLimite.getMonth() - 1);
  10706.  
  10707. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  10708. var str = MY_getValue(numTroll+'.INFOSIT');
  10709. var bAjoutTrollInvi = false;
  10710. if (str) {
  10711. var arr = str.split('$');
  10712. bAjoutTrollInvi = arr[4]>0;
  10713. }
  10714.  
  10715. var tBody = tr_trolls[0].parentNode;
  10716. if (tr_trolls[1] !== undefined)
  10717. tBody = tr_trolls[1].parentNode;
  10718.  
  10719. //window.console.log('nb Troll IT : ' + IDs.length);
  10720. var pos = getPosition();
  10721.  
  10722. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  10723. for (var idTroll in infosTrolls) {
  10724. var infos = infosTrolls[idTroll];
  10725. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  10726. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  10727. if (idTroll == numTroll) continue; // pas nous-même
  10728. var tr;
  10729. if (idTroll in MZ_tabTrTrollById) {
  10730. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  10731. tr = MZ_tabTrTrollById[idTroll];
  10732. } else {
  10733. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  10734. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  10735. // trouver où insérer ce Troll
  10736. var next = undefined;
  10737. for(var j=0 ; j<tr_trolls.length ; j++) {
  10738. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  10739. if (thisDist > distance) {
  10740. next = tr_trolls[j]
  10741. break;
  10742. }
  10743. }
  10744. if (next !== undefined) {
  10745. tr = insertTr(next,'mh_tdpage')
  10746. } else {
  10747. tr = appendTr(tBody,'mh_tdpage');
  10748. }
  10749. tr.style.color = 'orange';
  10750. var td = appendTd(tr); // distance
  10751. appendText(td, distance);
  10752. td = appendTd(tr); // actions
  10753. td = appendTd(tr); // ID
  10754. appendText(td, idTroll);
  10755. td = appendTd(tr); // Nom
  10756. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  10757. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  10758. td = appendTd(tr); // PV
  10759. td = appendTd(tr); // PA
  10760. td = appendTd(tr); // Guilde
  10761. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  10762. td = appendTd(tr); // Niveau
  10763. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  10764. td.align = 'center';
  10765. td = appendTd(tr); // Race
  10766. if (infos.race) appendText(td, infos.race);
  10767. td = appendTd(tr); // X
  10768. td.align = 'center';
  10769. if (infos.x !== undefined) appendText(td, infos.x);
  10770. td = appendTd(tr); // Y
  10771. td.align = 'center';
  10772. if (infos.y !== undefined) appendText(td, infos.y);
  10773. td = appendTd(tr); // N
  10774. td.align = 'center';
  10775. if (infos.n !== undefined) appendText(td, infos.n);
  10776. MZ_tabTrTrollById[idTroll] = tr;
  10777. }
  10778. if (!tr.done) {
  10779. addTdInfosTroll(infos, tr, itName);
  10780. tr.done = true;
  10781. }
  10782. }
  10783. } catch(e) {
  10784. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  10785. window.console.error(traceStack(e, 'putInfosTrolls'));
  10786. }
  10787. }
  10788.  
  10789.  
  10790. /* Mode Tétalanvert! ---------------------------------------------------------*/
  10791.  
  10792. function calculeDistance(maPos,posArr) {
  10793. return Math.max(
  10794. Math.abs(maPos[0]-posArr[0]),
  10795. Math.abs(maPos[1]-posArr[1]),
  10796. Math.abs(maPos[2]-posArr[2])
  10797. );
  10798. }
  10799.  
  10800. function inversionCoord() {
  10801. var maPos = getPosition();
  10802. var listeOffsets = {
  10803. 'monstres':checkBoxLevels.checked?4:3,
  10804. 'trolls':6,
  10805. };
  10806. for(var type in listeOffsets) {
  10807. var trList = this['tr_'+type];
  10808. var offset = listeOffsets[type];
  10809. for(var i=trList.length-1 ; i>0 ; i--) {
  10810. var oldX = parseInt(trList[i].cells[offset].textContent);
  10811. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  10812. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  10813. trList[i].cells[offset].innerHTML = oldY;
  10814. trList[i].cells[offset+1].innerHTML = oldX;
  10815. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  10816. }
  10817. }
  10818. }
  10819.  
  10820.  
  10821. /* Partie principale */
  10822. function do_vue() {
  10823. for(var type in typesAFetcher) {
  10824. fetchData(type);
  10825. }
  10826.  
  10827. // roule' 11/03/2016
  10828. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  10829. // je fais une recopie :(
  10830. tr_monstres = this['tr_monstres'];
  10831. tr_trolls = this['tr_trolls'];
  10832. tr_tresors = this['tr_tresors'];
  10833. tr_champignons = this['tr_champignons'];
  10834. tr_lieux = this['tr_lieux'];
  10835.  
  10836. nbMonstres = this['nbMonstres'];
  10837. nbTrolls = this['nbTrolls'];
  10838. nbTresors = this['nbTresors'];
  10839. nbChampignons = this['nbChampignons'];
  10840. nbLieux = this['nbLieux'];
  10841.  
  10842. try {
  10843. start_script(31);
  10844. initialiseInfos();
  10845. savePosition();
  10846.  
  10847. // Fonctionnalité "Têtalenvert" cachée, en test :
  10848. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  10849. inversionCoord();
  10850. }
  10851. ajoutDesFiltres();
  10852. set2DViewSystem();
  10853. //putBoutonTroogle();
  10854. putBoutonPXMP();
  10855. synchroniseFiltres();
  10856. toggleLevelColumn();
  10857.  
  10858. refreshDiplo();
  10859. //400 ms
  10860. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  10861. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  10862. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  10863. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  10864. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  10865. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  10866. var noTresorsEngages =
  10867. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  10868. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  10869. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  10870. filtreMonstres();
  10871. if(noIntangibles) {
  10872. filtreTrolls();
  10873. }
  10874. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  10875. filtreTresors();
  10876. }
  10877. if(noTrou) {
  10878. filtreLieux();
  10879. }
  10880.  
  10881. initPopupVue();
  10882. initPXTroll();
  10883.  
  10884. if(getTalent("Projectile Magique")!=0) {
  10885. computeProjo();
  10886. }
  10887. if(getTalent("Charger")!=0) {
  10888. computeCharge();
  10889. }
  10890. if(getTalent("Télékinésie")!=0) {
  10891. computeTelek();
  10892. }
  10893. if(getTalent("Lancer de Potions")!=0) {
  10894. computeLdP();
  10895. }
  10896. putScriptExterne();
  10897. displayScriptTime();
  10898. } catch(e) {
  10899. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10900. window.console.error(traceStack(e, 'vue'));
  10901. }
  10902. }
  10903.  
  10904.  
  10905.  
  10906. /*******************************************************************************
  10907. * This file is part of Mountyzilla. *
  10908. * *
  10909. * Mountyzilla is free software; you can redistribute it and/or modify *
  10910. * it under the terms of the GNU General Public License as published by *
  10911. * the Free Software Foundation; either version 2 of the License, or *
  10912. * (at your option) any later version. *
  10913. * *
  10914. * Mountyzilla is distributed in the hope that it will be useful, *
  10915. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10916. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10917. * GNU General Public License for more details. *
  10918. * *
  10919. * You should have received a copy of the GNU General Public License *
  10920. * along with Mountyzilla; if not, write to the Free Software *
  10921. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10922. *******************************************************************************/
  10923.  
  10924. // x~x profil2
  10925.  
  10926. /*---------------------------- Variables globales ----------------------------*/
  10927.  
  10928. var
  10929. // Anatrolliseur
  10930. urlAnatrolliseur,
  10931. // Infobulles talents
  10932. hauteur = 50, bulleStyle = null,
  10933. // Caracteristiques
  10934. // Infos troll
  10935. race, niv, idtroll, datecrea,
  10936. idguilde, nomguilde,
  10937. // Etats du troll
  10938. fatigue, bmfatigue,
  10939.  
  10940. // Experience, Pi, ...
  10941. pxdistribuables, pxperso,
  10942. piutilisable, pitotal,
  10943. nbmeurtres, nbmorts,
  10944. // utilisee pour les moyennes MM/jour, kill/jour, etc
  10945. NBjours,
  10946. // calcul des DLA suivantes
  10947. DLA, DLAsuiv, HeureServeur,
  10948. // details duree du tour (calcul pvdispo) :
  10949. dtb, pdm, bmt, adb, dpt,
  10950. //posale
  10951. posX, posY, posN,
  10952. // caracs physiques
  10953. vue, vuebp, vuebm, vuetotale,
  10954. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  10955. reg, regbp, regbm, regmoy,
  10956. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  10957. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  10958. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  10959. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  10960. rm, rmbp, rmbm, rmtotale,
  10961. mm, mmbp, mmbm, mmtotale,
  10962.  
  10963. // Variables speciales Kastars
  10964. pvActuelKastar, minParPV, overDLA,
  10965. // id pour edition manuelle de lastDLA :
  10966. inJour, inMois, inAn, inHr, inMin, inSec,
  10967. // id pour auto-refresh lastDLA :
  10968. lastDLAZone, maxAMZone, cumulZone,
  10969. lastDLA, DLAaccel;
  10970.  
  10971.  
  10972. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  10973.  
  10974. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10975. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10976. function getUniqueValueBySelector(selector, defaultValue){
  10977. var valNode = document.querySelector(selector);
  10978. if(valNode!=null){
  10979. if(valNode.hasChildNodes()) {
  10980. return valNode.childNodes[0].nodeValue;
  10981. }else{
  10982. return defaultValue;
  10983. }
  10984. } else{
  10985. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10986. return defaultValue;
  10987. }
  10988. }
  10989. function getUniqueStringValueBySelector(selector){
  10990. return getUniqueValueBySelector(selector,"");
  10991. }
  10992. function getUniqueIntValueBySelector(selector){
  10993. var ret = getUniqueValueBySelector(selector,0);
  10994. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10995. ret = 0;
  10996. }
  10997. return parseInt(ret);
  10998. }
  10999. function getUniqueFloatValueBySelector(selector){
  11000. var ret = getUniqueValueBySelector(selector,0.0);
  11001. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  11002. ret = 0.0;
  11003. }
  11004. return parseFloat(ret);
  11005. }
  11006.  
  11007.  
  11008. function resiste(Ddeg,bm) {
  11009. // version naive mais compréhensible ^^
  11010. // DEBUG: à revoir
  11011. if(!bm) {
  11012. return 2*Math.floor(Ddeg/2);
  11013. }
  11014. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  11015. }
  11016.  
  11017. function retourAZero(fatig) {
  11018. var fat = fatig, raz = 0;
  11019. while(fat>0) {
  11020. raz++;
  11021. fat = Math.floor(fat/1.25);
  11022. }
  11023. return raz;
  11024. }
  11025.  
  11026. function decumulPumPrem(bonus) {
  11027. switch(bonus) {
  11028. case 20: return 33;
  11029. case 33: return 41;
  11030. case 41: return 46;
  11031. case 46: return 49;
  11032. case 49: return 51;
  11033. default: return 20;
  11034. }
  11035. }
  11036.  
  11037. function coefDecumul(i) {
  11038. switch(i) {
  11039. case 2: return 0.67;
  11040. case 3: return 0.4;
  11041. case 4: return 0.25;
  11042. case 5: return 0.15;
  11043. default: return 0.1;
  11044. }
  11045. }
  11046.  
  11047. function dureeHM(dmin) {
  11048. var ret = "";
  11049. dmin = Math.floor(dmin);
  11050. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  11051. var mins = dmin%60;
  11052. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  11053. return (ret) ? ret : "-";
  11054. }
  11055.  
  11056. // extraction d'une durée
  11057. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  11058. // c'est protégé (rend 0 si l'élément est absent)
  11059. // Roule' 24/12/2016
  11060. function extractionDuree(selecteur) {
  11061. var s = getUniqueStringValueBySelector(selecteur);
  11062. if (!s) return 0;
  11063. var tabN = getNumbers(s);
  11064. if (tabN.length < 2) return 0;
  11065. return tabN[0] * 60 + tabN[1];
  11066. }
  11067.  
  11068. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  11069.  
  11070. function extractionDonnees() {
  11071. // Variables temporaires
  11072. var Nbrs = {};
  11073.  
  11074. // *********************
  11075. // Cadre "Description"
  11076. // *********************
  11077. race = getUniqueStringValueBySelector('#descr #race');
  11078. debugMZ("Race : " + race);
  11079. idtroll = getUniqueStringValueBySelector('#descr #id');
  11080. debugMZ("Id troll : " + idtroll);
  11081. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  11082. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  11083. datecrea = new Date(StringToDate(strDateCrea));
  11084. debugMZ("Date creation : " + datecrea);
  11085. // Guilde
  11086. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  11087. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  11088. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  11089.  
  11090. // *******************
  11091. // Cadre "Experience"
  11092. // *******************
  11093. // Niveau de troll
  11094. niv = getUniqueIntValueBySelector('#exp #niv');
  11095. nivTroll = niv;
  11096. debugMZ("Niveau : " + niv);
  11097. // PX
  11098. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  11099. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  11100. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  11101. // PI
  11102. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  11103. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  11104. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  11105. // Meutres/Morts
  11106. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  11107. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  11108. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  11109.  
  11110. // *********************
  11111. // Cadre "Tour de Jeu"
  11112. // *********************
  11113. // DLA
  11114. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  11115. DLA = new Date(StringToDate(Nbrs["dla"]));
  11116. debugMZ("DLA: " + DLA);
  11117. // DLA suivante
  11118. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  11119. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  11120. debugMZ("DLAsuiv: " + DLAsuiv);
  11121. // Duree normale de mon Tour
  11122. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  11123. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  11124. dtb = extractionDuree("#dla #tour");
  11125. debugMZ("Duree normale de mon Tour : " + dtb);
  11126. // Bonus/Malus sur la duree
  11127. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  11128. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  11129. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  11130. debugMZ("Bonus/Malus sur la duree : " + bmt);
  11131. // Augmentation due aux blessures
  11132. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  11133. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  11134. adb = extractionDuree("#dla #blessure");
  11135. debugMZ("Augmentation due aux blessures : " + adb);
  11136. // Poids de l'equipement
  11137. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  11138. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  11139. pdm = extractionDuree("#dla #poids");
  11140. debugMZ("Poids de l'equipement : " + pdm);
  11141. // Duree de mon prochain Tour
  11142. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  11143. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  11144. dpt = extractionDuree("#dla #duree>b");
  11145. debugMZ('Duree de mon prochain Tour : ' + dpt);
  11146.  
  11147. // ****************
  11148. // Cadre "Etats"
  11149. // ****************
  11150. // Position du troll :
  11151. posX = getUniqueIntValueBySelector('#pos #x');
  11152. posY = getUniqueIntValueBySelector('#pos #y');
  11153. posN = getUniqueIntValueBySelector('#pos #n');
  11154. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  11155. // PV actuel
  11156. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  11157. pvActuelKastar = pvcourant;
  11158. debugMZ("PV actuel : " + pvcourant)
  11159. // Fatigue
  11160. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  11161. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  11162. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  11163.  
  11164. // **************************
  11165. // Cadre "Caracteristiques"
  11166. // **************************
  11167. // Attaque
  11168. att = getUniqueIntValueBySelector('#carac #att');
  11169. attbp = getUniqueIntValueBySelector('#carac #att_p');
  11170. attbm = getUniqueIntValueBySelector('#carac #att_m');
  11171. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  11172. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  11173. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  11174. attmoy = 3.5*att + attbp + attbm;
  11175. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  11176. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  11177. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  11178. // Esquive
  11179. esq = getUniqueIntValueBySelector('#carac #esq');
  11180. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  11181. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  11182. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  11183. esqmoy = 3.5*esq + esqbp+esqbm;
  11184. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  11185. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  11186. // Degat
  11187. deg = getUniqueIntValueBySelector('#carac #deg');
  11188. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  11189. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  11190. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  11191. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  11192. degmoy = 2*deg + degbp+degbm;
  11193. degmoycrit = 3*deg + degbp+degbm;
  11194. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  11195. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  11196. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  11197. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  11198. // PV
  11199. pvbase = getUniqueIntValueBySelector('#carac #pv');
  11200. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  11201. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  11202. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  11203. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  11204. // Regeneration
  11205. reg = getUniqueIntValueBySelector('#carac #reg');
  11206. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  11207. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  11208. regmoy = 2 * reg + regbp + regbm; // D3
  11209. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  11210. // Armure
  11211. arm = getUniqueIntValueBySelector('#carac #arm');
  11212. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  11213. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  11214. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  11215. armmoy = 2*arm + armbp+armbm;
  11216. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  11217. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  11218. // TODO : D d'armure non active
  11219. // Vue
  11220. vue = getUniqueIntValueBySelector('#carac #vue');
  11221. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  11222. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  11223. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  11224. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  11225. // RM
  11226. rm = getUniqueIntValueBySelector('#carac #rm');
  11227. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  11228. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  11229. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  11230. rmTroll = rmtotale;
  11231. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  11232. // MM
  11233. mm = getUniqueIntValueBySelector('#carac #mm');
  11234. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  11235. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  11236. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  11237. mmTroll = mmtotale;
  11238. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  11239.  
  11240. // Heure Serveur
  11241. try {
  11242. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  11243. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  11244. HeureServeur = new Date(StringToDate(heureServeurSTR));
  11245. } catch (e) {
  11246. window.console.warn(
  11247. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  11248. );
  11249. HeureServeur = new Date();
  11250. }
  11251. debugMZ("HeureServeur: " + HeureServeur);
  11252.  
  11253. // ***INIT GLOBALE*** NBjours
  11254. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  11255.  
  11256. // Calcul debut lien anatroliseur avec les caracteristiques connues
  11257. var amelio_dtb = function(dtb) {
  11258. if(dtb>555) {
  11259. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  11260. }
  11261. return 10+Math.ceil((555-dtb)/2.5);
  11262. },
  11263. amelio_pv = Math.floor(pvbase/10)-3,
  11264. amelio_vue = vue-3,
  11265. amelio_att = att-3,
  11266. amelio_esq = esq-3,
  11267. amelio_deg = deg-3,
  11268. amelio_reg = reg-1,
  11269. amelio_arm = arm-1;
  11270. if(race==="Darkling"){amelio_reg--; }
  11271. if(race==="Durakuir"){amelio_pv-- ; }
  11272. if(race==="Kastar") {amelio_deg--; }
  11273. if(race==="Skrim") {amelio_att--; }
  11274. if(race==="Tomawak") {amelio_vue--; }
  11275.  
  11276. urlAnatrolliseur = URL_AnatrolDispas
  11277. +"outils_anatrolliseur.php?anatrolliseur=v8"
  11278. +"|r="+race.toLowerCase()
  11279. +"|dla="+amelio_dtb(dtb)
  11280. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  11281. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  11282. +"|att="+amelio_att+","+attbp+","+attbm
  11283. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  11284. +"|deg="+amelio_deg+","+degbp+","+degbm
  11285. +"|reg="+amelio_reg+","+regbp+","+regbm
  11286. +"|arm="+amelio_arm+","+armbp+","+armbm
  11287. +"|mm="+mmtotale
  11288. +"|rm="+rmtotale+"|";
  11289. }
  11290.  
  11291. function saveProfil() {
  11292. MY_setValue(idtroll+'.caracs.attaque',att);
  11293. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  11294. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  11295. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  11296. if(atttourD||atttourP||atttourM) {
  11297. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  11298. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  11299. }
  11300. MY_setValue(idtroll+'.caracs.esquive',esq);
  11301. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  11302. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  11303. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  11304. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  11305. MY_setValue(idtroll+'.caracs.degats',deg);
  11306. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  11307. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  11308. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  11309. if(degtourP||degtourM){
  11310. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  11311. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  11312. }
  11313. MY_setValue(idtroll+'.caracs.regeneration',reg);
  11314. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  11315. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  11316. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  11317. MY_setValue(idtroll+'.caracs.vue',vue);
  11318. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  11319. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  11320. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  11321. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  11322. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  11323. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  11324. MY_setValue(idtroll+'.caracs.rm',rm);
  11325. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  11326. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  11327. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  11328. MY_setValue(idtroll+'.caracs.mm',mm);
  11329. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  11330. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  11331. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  11332. MY_setValue(idtroll+'.caracs.armure',arm);
  11333. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  11334. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  11335. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  11336. MY_setValue(idtroll+'.position.X',posX);
  11337. MY_setValue(idtroll+'.position.Y',posY);
  11338. MY_setValue(idtroll+'.position.N',posN);
  11339. MY_setValue(idtroll+'.race',race);
  11340. MY_setValue(idtroll+'.niveau',niv);
  11341. MY_setValue(idtroll+'.idguilde',idguilde);
  11342. MY_setValue(idtroll+'.nomguilde',nomguilde);
  11343. }
  11344.  
  11345.  
  11346. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  11347.  
  11348. function setInfosCaracteristiques() {
  11349. // Modification de l'entete
  11350. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  11351. thTotal.innerHTML+='|<i>Moyenne</i>';
  11352. thTotal.title="Moyenne (Moyenne ce tour)";
  11353.  
  11354. // Ajout des informations calculees
  11355. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  11356. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  11357. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  11358.  
  11359. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  11360. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  11361. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  11362.  
  11363. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  11364. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  11365. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  11366.  
  11367. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  11368. var tdRegTotal = trRegeneration.children[5];
  11369. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  11370. // Temps recupere par reg (propale R')
  11371. var regmoyTemp = Math.max(0, regmoy);
  11372. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  11373. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  11374. if (sec != 0) {
  11375. regTitle += " " + sec + " sec";
  11376. }
  11377. trRegeneration.title = regTitle;
  11378.  
  11379. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  11380. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  11381. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  11382.  
  11383. var trRM=document.querySelector("table#caracs #rm").parentElement;
  11384. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  11385. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  11386.  
  11387.  
  11388. var trMM=document.querySelector("table#caracs #mm").parentElement;
  11389. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  11390. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  11391.  
  11392. var tdRefl=document.querySelector("#refl");
  11393. // TODO : prendre en compte bonus/malus D esq du tour ?
  11394. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + esqbp + esqbm;
  11395. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  11396. }
  11397.  
  11398. function setLienAnatrolliseur(){
  11399. var pTableAmelio = document.querySelector("#carac>div>p");
  11400. pTableAmelio.innerHTML+=" - ";
  11401. var aElt = document.createElement("a");
  11402. aElt.setAttribute("href",urlAnatrolliseur);
  11403. aElt.setAttribute("target","_blank");
  11404. aElt.className="AllLinks";
  11405. aElt.innerHTML="Anatrolliser";
  11406. pTableAmelio.appendChild(aElt);
  11407. }
  11408. function setInfoDescription() {
  11409. var txtDateCrea = (NBjours!=1) ?
  11410. " ("+NBjours+" jours dans le hall)" :
  11411. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  11412. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  11413. }
  11414.  
  11415. function setInfosEtatLieux() {
  11416. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  11417. '?search=position&orderBy=distance&posx='+
  11418. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  11419. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  11420. appendBr(tdPosition);
  11421. var aElt = document.createElement("a");
  11422. aElt.setAttribute("href",urlBricol);
  11423. aElt.setAttribute("target","_blank");
  11424. aElt.className="AllLinks";
  11425. aElt.innerHTML="Lieux à proximité";
  11426. tdPosition.appendChild(aElt);
  11427. }
  11428.  
  11429. function setInfosEtatPV() { // pour AM et Sacro
  11430. var
  11431. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  11432. sec = Math.floor(15000/pvtotal)%60,
  11433. lifebar = document.querySelector("#pos .barre-vie");
  11434. if(sec!=0) { txt += " "+sec+" sec"; }
  11435. if(lifebar) { lifebar.title = txt; }
  11436. if(pvcourant<=0) { return; }
  11437. // Difference PV p/r a equilibre de temps (propale R')
  11438. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  11439. // ***INIT GLOBALE*** pvdispo
  11440. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11441. var span = document.createElement("span");
  11442. span.title = txt;
  11443. span.style.fontStyle = "italic";
  11444. if(bmt+pdm>=0) {
  11445. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  11446. } else if(pvdispo>0) {
  11447. txt = "Vous pouvez encore perdre "+
  11448. Math.min(pvdispo,pvcourant)+
  11449. " PV sans malus de temps.";
  11450. } else if(pvdispo<0) {
  11451. txt = "Il vous manque "
  11452. +(-pvdispo)
  11453. +" PV pour ne plus avoir de malus de temps.";
  11454. } else {
  11455. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  11456. }
  11457. appendText(span,txt);
  11458. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  11459. }
  11460.  
  11461. // Complete le cadre "Experience"
  11462. function setInfosExp() {
  11463. var tdNiv = document.querySelector("#exp #niv");
  11464.  
  11465. // Calcul niveau monstre/troll min pour gain PX
  11466. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  11467. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  11468.  
  11469. // Calcul PX restant
  11470. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  11471. if (pxRestant >= 0) {
  11472. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  11473. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  11474. }
  11475.  
  11476. // Calul pi/jour
  11477. var
  11478. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  11479. tdPi = document.querySelector("#exp #pi").parentElement;
  11480. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  11481. tdPi.title = tdPiTotal.title;
  11482.  
  11483. // Rapports meurtres,morts
  11484. var tdKill = document.querySelector("#exp #kill");
  11485. tdKill.setAttribute("colspan", 1);
  11486. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  11487.  
  11488. var tdMort = document.querySelector("#exp #mort");
  11489. tdMort.setAttribute("colspan", 1);
  11490. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  11491.  
  11492. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  11493. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  11494. }
  11495.  
  11496.  
  11497. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  11498.  
  11499. function minParPVsac(fat,bm) {
  11500. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  11501. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  11502. var out = [];
  11503. out[0] = (fat>4) ?
  11504. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  11505. 30;
  11506. if(bm && bm>0) {
  11507. var totalfat=fat+bm;
  11508. out[1] = (totalfat>4) ?
  11509. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  11510. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  11511. }
  11512. return out;
  11513. }
  11514.  
  11515. function toInt(str) {
  11516. str = parseInt(str);
  11517. return (str) ? str : 0;
  11518. }
  11519.  
  11520. function saveLastDLA() {
  11521. // pour les calculs d'AM max
  11522. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  11523. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  11524. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  11525. lastDLA = new Date( StringToDate(str) );
  11526. MY_setValue(numTroll+'.DLA.ancienne',str);
  11527. lastDLAZone.innerHTML = '';
  11528. var b = document.createElement('b');
  11529. b.addEventListener('click',inputMode,false);
  11530. appendText(b,str);
  11531. lastDLAZone.appendChild(b);
  11532. refreshAccel();
  11533. }
  11534.  
  11535. function inputMode() {
  11536. // Edition manuelle lastDLA
  11537. var date;
  11538. if(lastDLA)
  11539. date = new Date( lastDLA );
  11540. else
  11541. date = new Date( DLAaccel );
  11542. lastDLAZone.innerHTML = '';
  11543. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  11544. appendText(lastDLAZone,'/');
  11545. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  11546. appendText(lastDLAZone,'/');
  11547. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  11548. appendText(lastDLAZone,' - ');
  11549. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  11550. appendText(lastDLAZone,':');
  11551. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  11552. appendText(lastDLAZone,':');
  11553. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  11554. appendText(lastDLAZone,' - ');
  11555. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  11556. }
  11557.  
  11558. function setAccel() {
  11559. var
  11560. BMfrais=false,
  11561. fat=fatigue, listeBmFat=[],
  11562. tr, th, insertPt;
  11563.  
  11564. // Creation ligne speciale pour AM dans le cadre "Etat"
  11565. tr = document.createElement('tr');
  11566. th = document.createElement('th');
  11567. appendText(th,'Fatigue et AM',true);
  11568. tr.appendChild(th);
  11569. insertPt = document.createElement('td');
  11570. tr.appendChild(insertPt);
  11571. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  11572.  
  11573. // Est-on en over-DLA ?
  11574. // ***INIT GLOBALE*** overDLA
  11575. overDLA = (HeureServeur>DLA.getTime()+3e5);
  11576. if(overDLA) {
  11577. fat=Math.floor(fatigue/1.25);
  11578. }
  11579.  
  11580. // Gestion des BM de fatigue
  11581. if(bmfatigue>0) {
  11582. // On tente de recuperer les BM de fatigue de la page des BM
  11583. if(MY_getValue(numTroll+'.bm.fatigue')) {
  11584. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  11585. BMmemoire.pop();
  11586. var tour = 0;
  11587. for(var i=0 ; i<BMmemoire.length ; i++) {
  11588. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  11589. while(tour<=parseInt(nbrs[0])) {
  11590. listeBmFat[tour]=parseInt(nbrs[1]);
  11591. tour++;
  11592. }
  11593. }
  11594. }
  11595. if(listeBmFat[0]==bmfatigue) {
  11596. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  11597. BMfrais = true;
  11598. MY_removeValue(numTroll+".bm.fatigue");
  11599. }
  11600. } else {
  11601. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  11602. BMfrais = true;
  11603. }
  11604. if(!BMfrais && bmfatigue>0) {
  11605. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  11606. if(bmfatigue==15) {
  11607. listeBmFat = [15,15,15];
  11608. } else {
  11609. listeBmFat = [30,30,15];
  11610. }
  11611. }
  11612. if(overDLA) {
  11613. // Si on est en over-DLA, on decale les bm d'un tour
  11614. listeBmFat.shift();
  11615. }
  11616. // Tableau des fatigues et accel futures
  11617. var
  11618. minppv = minParPVsac(fat,listeBmFat[0]),
  11619. table, tbody,
  11620. ligneTour, ligneFat, ligneMin,
  11621. col;
  11622. // ***INIT GLOBALE*** minParPV
  11623. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  11624. if(fat>0 || listeBmFat[0]>0) {
  11625. table = document.createElement('table');
  11626. table.className = 'mh_tdborder';
  11627. table.border = 0;
  11628. table.cellSpacing = 1;
  11629. table.cellPadding = 1;
  11630. table.style.textAlign = "center";
  11631. tbody = document.createElement('tbody');
  11632. table.appendChild(tbody);
  11633. insertPt.appendChild(table);
  11634. ligneTour = appendTr(tbody,'mh_tdtitre');
  11635. ligneTour.style.fontWeight = "bold";
  11636. var td = appendTdText(ligneTour,'Tour :',true);
  11637. td.align = 'left';
  11638. ligneFat = appendTr(tbody,'mh_tdpage');
  11639. td = appendTdText(ligneFat,'Fatigue :',true);
  11640. td.className = 'mh_tdtitre';
  11641. td.align = 'left';
  11642. ligneMin = appendTr(tbody,'mh_tdpage');
  11643. td = appendTdText(ligneMin,'1 PV =',true);
  11644. td.className = 'mh_tdtitre';
  11645. td.align = 'left';
  11646. col=0;
  11647. while(col<9 && (fat>0 || listeBmFat[col])) {
  11648. if(col==0) {
  11649. if(overDLA) {
  11650. var i = document.createElement('i');
  11651. appendText(i,'A activer');
  11652. ligneTour.appendChild(i);
  11653. } else {
  11654. appendTdText(ligneTour,'En cours');
  11655. }
  11656. } else {
  11657. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  11658. }
  11659. if(listeBmFat[col]) {
  11660. if(BMfrais || (!overDLA && col==0)) {
  11661. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  11662. appendTdText(ligneMin,minppv[1]+'\'');
  11663. } else {
  11664. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  11665. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  11666. }
  11667. } else {
  11668. appendTdText(ligneFat,fat);
  11669. appendTdText(ligneMin,minppv[0]+'\'');
  11670. }
  11671. col++;
  11672. fat = Math.floor(fat / 1.25);
  11673. minppv = minParPVsac(fat,listeBmFat[col]);
  11674. }
  11675. if(fat>1 || (fat==1 && !overDLA)) {
  11676. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  11677. appendTdText(ligneFat,'-');
  11678. appendTdText(ligneMin,'-');
  11679. }
  11680. col = (overDLA) ?
  11681. Math.max(retourAZero(fatigue)-1,col) :
  11682. Math.max(retourAZero(fatigue),col);
  11683. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  11684. appendTdText(ligneFat,'0');
  11685. appendTdText(ligneMin,'30\'');
  11686. if(!BMfrais && bmfatigue) {
  11687. // si les BM n'ont pas ete rafraichis, on signale:
  11688. appendText(
  11689. insertPt,
  11690. '/!\\ Visitez la page des Bonus/Malus '+
  11691. 'pour mettre à jour votre fatigue. /!\\',
  11692. true
  11693. );
  11694. appendBr(insertPt);
  11695. }
  11696. appendBr(insertPt);
  11697. }
  11698. if(pvcourant<=0) {
  11699. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  11700. return;
  11701. }
  11702. if(fatigue>30) {
  11703. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  11704. return;
  11705. }
  11706. // Setup lastDLAZone
  11707. if(overDLA) {
  11708. // bypass des infos de "menu_FF.js" en cas d'overDLA
  11709. DLAaccel = new Date( DLAsuiv );
  11710. lastDLA = new Date( DLA );
  11711. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  11712. // ***INIT GLOBALE*** pvActuelKastar
  11713. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  11714. appendText(
  11715. insertPt,
  11716. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  11717. true
  11718. );
  11719. appendBr(insertPt);
  11720. } else {
  11721. DLAaccel = new Date( DLA );
  11722. pvActuelKastar = pvcourant;
  11723. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  11724. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  11725. } else {
  11726. lastDLA = false;
  11727. }
  11728. }
  11729. appendText(insertPt,'Dernière DLA enregistrée : ');
  11730. lastDLAZone = document.createElement('span');
  11731. lastDLAZone.style.cursor = 'pointer';
  11732. var b = document.createElement('b');
  11733. b.onclick = inputMode;
  11734. lastDLAZone.appendChild(b);
  11735. insertPt.appendChild(lastDLAZone);
  11736. if(lastDLA) {
  11737. appendText(b,DateToString(lastDLA));
  11738. } else {
  11739. appendText(b,'aucune');
  11740. }
  11741. appendBr(insertPt);
  11742. // Setup maxAMZone et cumulZone
  11743. appendText(insertPt,'Accélération maximale possible : ');
  11744. maxAMZone = document.createElement('b');
  11745. insertPt.appendChild(maxAMZone);
  11746. appendBr(insertPt);
  11747. cumulZone = document.createElement('span');
  11748. insertPt.appendChild(cumulZone);
  11749. refreshAccel();
  11750. }
  11751.  
  11752. function refreshAccel() {
  11753. var pvs, pvsmax;
  11754. // Acceleration pour cumul instantane
  11755. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  11756. if(lastDLA) {
  11757. pvsmax = Math.min(
  11758. pvActuelKastar-1,
  11759. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  11760. );
  11761. maxAMZone.innerHTML = pvsmax+" PV";
  11762. } else {
  11763. pvsmax = pvActuelKastar-1;
  11764. maxAMZone.innerHTML = "inconnue";
  11765. }
  11766. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  11767. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  11768. cumulZone.innerHTML = '';
  11769. if(pvs<=pvsmax) {
  11770. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  11771. appendText(cumulZone,pvs+' PV', true);
  11772. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  11773. if(pvs!=1) {
  11774. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  11775. -(pvs-1)*60*minParPV;
  11776. appendText(
  11777. cumulZone,
  11778. ' ('+(pvs-1)+' PV dans '+
  11779. Math.floor(gainSec/60)+'min'+
  11780. addZero(gainSec%60)+'s)'
  11781. );
  11782. }
  11783. } else {
  11784. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  11785. appendText(
  11786. cumulZone,
  11787. 'Après votre accélération maximale, il vous faudra encore attendre '+
  11788. dureeHM(avantDLA/6e4)+
  11789. ' avant de réactiver.'
  11790. );
  11791. }
  11792. }
  11793.  
  11794.  
  11795. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  11796.  
  11797. function traitementTalents() {
  11798. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  11799. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  11800. removeAllTalents();
  11801. var totalComp = injecteInfosBulles(trCompetence,'competences');
  11802. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  11803. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  11804. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  11805. }
  11806.  
  11807. function injecteInfosBulles(liste,fonction) {
  11808. var totalpc = 0;
  11809. // on parse la liste des talents du type 'fonction'
  11810. for(var i=0 ; i<liste.length ; i++) {
  11811. var
  11812. trTalent=liste[i],
  11813. node=trTalent.cells[1].querySelector('a'),
  11814. nomTalent=epure(trim(node.textContent)),
  11815. indiceTDniveaux=7,
  11816. indiceTDSousCompetence=2,
  11817. sousCompetences=undefined;
  11818. if(fonction=="competences"){
  11819. // un TD en plus pour des information complementaire liees a la comp
  11820. indiceTDniveaux++;
  11821. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  11822. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  11823. for (var j=0; j < sousCompetences.length; j++) {
  11824. sousCompetences[j] = sousCompetences[j].epure().trim();
  11825. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  11826. }
  11827. }
  11828. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  11829. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  11830. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  11831. totalpc += niveauxMaitrisesTalentArray[1];
  11832.  
  11833. // stockage des niveaux inferieurs du talent si presents
  11834. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  11835. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  11836. totalpc+=niveauxMaitrisesTalentArray[j+1];
  11837. }
  11838. }
  11839. return totalpc;
  11840. }
  11841.  
  11842. function setInfos(node,nom,fonction,niveau) {
  11843. node.nom = nom;
  11844. node.fonction = fonction;
  11845. node.niveau = niveau;
  11846. node.onmouseover = setBulle;
  11847. node.onmouseout = cacherBulle;
  11848. }
  11849.  
  11850. var arrayModifAnatroll = {
  11851. 'Glue':'Glu',
  11852. 'PuM':'PuiM',
  11853. 'HE':'Hurlement',
  11854. //'Insultes':'Insu',
  11855. 'Pistage':'Pist',
  11856. 'PuC':'Planter'
  11857. }
  11858.  
  11859. function setTalent(nom,pc,niveau,sousCompetences) {
  11860. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  11861. // (et pas les % dont osf) ne serait pas plus rentable
  11862. var nomEnBase = arrayTalents[epure(nom)];
  11863. if(!nomEnBase) { return; }
  11864. if(!niveau) { niveau = 1; }
  11865. switch(nomEnBase) {
  11866. case 'Insultes':
  11867. urlAnatrolliseur += 'Insu'+niveau+'|';
  11868. case 'IdT':
  11869. nomEnBase += niveau;
  11870. break;
  11871. case 'Golemo':
  11872. case 'Piege':
  11873. for (var i=0 ; i < sousCompetences.length ; i++) {
  11874. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  11875. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  11876. }
  11877. break;
  11878. case 'AP':
  11879. case 'Baroufle':
  11880. case 'CdB':
  11881. case 'CdM':
  11882. case 'Parer':
  11883. case 'Retraite':
  11884. case 'RB':
  11885. case 'SInterposer':
  11886. nomEnBase += niveau;
  11887. default:
  11888. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  11889. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  11890. }
  11891. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  11892. }
  11893.  
  11894. function creerBulleVide() {
  11895. var table = document.createElement('table');
  11896. table.id = 'bulle';
  11897. table.className = 'mh_tdborder';
  11898. table.width = 300;
  11899. table.border = 0;
  11900. table.cellPadding = 5;
  11901. table.cellSpacing = 1;
  11902. table.style =
  11903. 'position:absolute;'
  11904. +'visibility:hidden;'
  11905. +'z-index:800;'
  11906. +'height:auto;';
  11907. var tr = appendTr(table,'mh_tdtitre');
  11908. appendTdText(tr,'Titre');
  11909. tr = appendTr(table,'mh_tdpage');
  11910. appendTdText(tr,'Contenu');
  11911. var aList = document.getElementsByTagName('a');
  11912. aList[aList.length-1].parentNode.appendChild(table);
  11913. }
  11914.  
  11915. function cacherBulle() {
  11916. if(bulleStyle)
  11917. bulleStyle.visibility = 'hidden';
  11918. }
  11919.  
  11920. function setBulle(evt) {
  11921. var nom = this.nom;
  11922. var fonction = this.fonction;
  11923. var niveau = parseInt(this.niveau);
  11924. var str='';
  11925. if(fonction=='competences'){
  11926. str=competences(nom,niveau);
  11927. } else if(fonction=='sortileges') {
  11928. str=sortileges(nom,true);
  11929. }
  11930. if(str=='') return;
  11931. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  11932. var xfenetre, yfenetre, xpage, ypage, element = null;
  11933. var offset = 15;
  11934. var bulleWidth = 300;
  11935. if(!hauteur) hauteur = 50;
  11936. element = document.getElementById('bulle');
  11937. xfenetre = evt.clientX;
  11938. yfenetre = evt.clientY;
  11939. xpage = xfenetre;
  11940. ypage = yfenetre;
  11941. if(evt.pageX) xpage = evt.pageX;
  11942. if(evt.pageY) ypage = evt.pageY;
  11943. if(element) {
  11944. bulleStyle = element.style;
  11945. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  11946. element.childNodes[1].firstChild.innerHTML = str;
  11947. }
  11948. if(bulleStyle) {
  11949. if(xfenetre>bulleWidth+offset)
  11950. xpage -= bulleWidth+offset;
  11951. else
  11952. xpage += offset;
  11953. if(yfenetre>hauteur+offset)
  11954. ypage -= hauteur + offset;
  11955. bulleStyle.width = bulleWidth;
  11956. bulleStyle.left = xpage + 'px';
  11957. bulleStyle.top = ypage + 'px';
  11958. bulleStyle.visibility = 'visible';
  11959. }
  11960. }
  11961.  
  11962.  
  11963. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  11964.  
  11965. function competences(comp,niveau) {
  11966. var texte = '';
  11967. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  11968. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  11969. if(minParPV>1) texte += 's';
  11970. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  11971. }
  11972. else if(comp.indexOf('Attaque Precise')!=-1) {
  11973. var pc, lastmax=0, espatt=0;
  11974. var notMaxedOut = false;
  11975. for(var i=niveau ; i>0 ; i--) {
  11976. pc = getTalent(comp,i);
  11977. if(lastmax!=0 && pc<=lastmax) continue;
  11978. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  11979. attbp+attbm;
  11980. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11981. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  11982. ' => <b>'+jetatt+'</b><br/>';
  11983. espatt += (pc-lastmax)*jetatt;
  11984. lastmax = pc;
  11985. if(i<niveau) notMaxedOut = true;
  11986. }
  11987. if(notMaxedOut) {
  11988. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  11989. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  11990. }
  11991. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  11992. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11993. }
  11994. else if(comp.indexOf('Balayage')!=-1)
  11995. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  11996. +' => <b>'+attmoy+'</b><br/>'
  11997. +'Effet : <b>Met à terre l\'adversaire</b>';
  11998. else if(comp.indexOf('Bidouille')!=-1)
  11999. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  12000. +'de votre inventaire avec le texte de votre choix.';
  12001. else if(comp.indexOf('Baroufle')!=-1){
  12002. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  12003. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  12004. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  12005. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  12006. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  12007. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  12008. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  12009. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  12010. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  12011. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  12012. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  12013. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  12014. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  12015. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  12016. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  12017. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  12018. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  12019. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  12020. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  12021. '</tbody></table>';
  12022. }
  12023. else if(comp.indexOf('Botte Secrete')!=-1){
  12024. texte = 'Attaque : <b>'
  12025. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  12026. +' => <b>'
  12027. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  12028. +'</b><br/>Dégâts : <b>'
  12029. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  12030. +' => <b>'
  12031. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  12032. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  12033. +'</b>';
  12034. }
  12035. else if(comp.indexOf('Camouflage')!=-1) {
  12036. var camou = getTalent('Camouflage');
  12037. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  12038. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  12039. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  12040. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  12041. }
  12042. else if(comp.indexOf('Charger')!=-1) {
  12043. if(pvcourant<=0)
  12044. return '<i>On ne peut charger personne quand on est mort !</i>';
  12045. var portee = Math.min(
  12046. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  12047. vuetotale);
  12048. if(portee<1)
  12049. return '<b>Impossible de charger</b>';
  12050. else {
  12051. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  12052. +' => <b>'+attmoy+'</b><br/>'
  12053. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  12054. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  12055. +'<br/>Portée : <b>'+portee+'</b> case';
  12056. if(portee>1) texte += 's';
  12057. }
  12058. }
  12059. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  12060. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  12061. if(vuetotale>1) texte += 's';
  12062. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  12063. if(vuetotale>2) texte += 's';
  12064. }
  12065. else if(comp.indexOf('Piege')!=-1) {
  12066. if(comp.indexOf('Glue')!=-1)
  12067. texte = 'Et si vous colliez vos adversaires au sol ?';
  12068. if(comp.indexOf('Feu')!=-1) {
  12069. if(texte){
  12070. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  12071. }
  12072. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  12073. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  12074. }
  12075. }
  12076. else if(comp.indexOf('Contre-Attaquer')!=-1){
  12077. texte = 'Attaque : <b>'
  12078. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  12079. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  12080. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  12081. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  12082. }
  12083. else if(comp.indexOf('Coup de Butoir')!=-1) {
  12084. var pc, lastmax=0, espdeg=0;
  12085. var notMaxedOut = false;
  12086. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  12087. +' => <b>'+attmoy+'</b>';
  12088. for(var i=niveau ; i>0 ; i--) {
  12089. pc = getTalent(comp,i);
  12090. if(lastmax!=0 && pc<=lastmax) continue;
  12091. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  12092. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  12093. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  12094. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  12095. espdeg += (pc-lastmax)*jetdeg;
  12096. lastmax = pc;
  12097. if(i<niveau) notMaxedOut = true;
  12098. }
  12099. if(notMaxedOut) {
  12100. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  12101. Math.floor(10*espdeg/lastmax)/10+'/'+
  12102. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  12103. }
  12104. }
  12105. else if(comp.indexOf('Course')!=-1)
  12106. texte = 'Déplacement gratuit : <b>'
  12107. +Math.floor(getTalent('Course')/2)
  12108. +' %</b> de chance';
  12109. else if(comp.indexOf('Deplacement Eclair')!=-1)
  12110. texte = 'Permet d\'économiser <b>1</b> PA '
  12111. +'par rapport au déplacement classique';
  12112. else if(comp.indexOf('Dressage')!=-1)
  12113. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  12114. +'ou un gnu sauvage.';
  12115. else if(comp.indexOf('Ecriture Magique')!=-1)
  12116. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  12117. +'la formule nécessite de réunir les composants de cette formule, '
  12118. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  12119. +'un champignon adéquat pour confectionner l\'encre.';
  12120. else if(comp.indexOf('Frenesie')!=-1) {
  12121. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  12122. +' => <b>'+attmoy+'</b><br/>'
  12123. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  12124. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  12125. }
  12126. else if(comp.indexOf('Golem')!=-1)
  12127. texte = 'Animez votre golem en assemblant divers matériaux '
  12128. +'autour d\'un cerveau minéral.'
  12129. else if(comp.indexOf('Grattage')!=-1) {
  12130. texte = 'Permet de confectionner un Parchemin Vierge '
  12131. +'à partir de composants et de Gigots de Gob\'.';
  12132. }
  12133. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  12134. texte = 'Fait fuir un monstre si tout se passe bien.'
  12135. +'<br/>Lui donne de gros bonus sinon...';
  12136. else if(comp.indexOf('Identification des Champignons')!=-1) {
  12137. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  12138. if(vuetotale>2) texte += 's';
  12139. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  12140. if(vuetotale>4) texte += 's';
  12141. }
  12142. else if(comp.indexOf('Insultes')!=-1)
  12143. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  12144. else if(comp.indexOf('interposer')!=-1)
  12145. texte = 'Jet de réflexe : <b>'
  12146. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  12147. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  12148. else if(comp.indexOf('Lancer de Potions') != -1)
  12149. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  12150. else if(comp.indexOf('Marquage')!=-1)
  12151. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  12152. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  12153. +'se trouver dans la même caverne que le monstre pour le marquer.';
  12154. else if(comp.indexOf('Melange Magique')!=-1)
  12155. texte = 'Cette Compétence permet de combiner deux Potions pour '
  12156. +'en réaliser une nouvelle dont l\'effet est la somme '
  12157. +'des effets des potions initiales.';
  12158. else if(comp.indexOf('Miner')!=-1) // obsolète
  12159. texte = 'Portée horizontale (officieuse) : <b>'
  12160. +2*vuetotale+'</b> cases<br/>'
  12161. +'Portée verticale (officieuse) : <b>'
  12162. +2*Math.ceil(vuetotale/2)+'</b> cases';
  12163. else if(comp.indexOf('Travail de la pierre')!=-1)
  12164. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  12165. +2*vuetotale+'</b> cases</li>'
  12166. +'<li>Portée verticale (officieuse) : <b>'
  12167. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  12168. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  12169. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  12170. else if(comp.indexOf('Necromancie')!=-1)
  12171. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  12172. +'de faire "revivre" ce monstre.';
  12173. else if(comp.indexOf('Painthure de Guerre')!=-1)
  12174. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  12175. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  12176. +'pour s\'inspirer, et laissez parler votre créativité.'
  12177. else if(comp.indexOf('Parer')!=-1)
  12178. texte = 'Jet de parade : <b>'
  12179. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  12180. +' => <b>'
  12181. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  12182. +'</b><hr><i>Equivalent esquive : <b>'
  12183. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  12184. +' => <b>'
  12185. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  12186. +'</b></i>';
  12187. else if(comp.indexOf('Pistage')!=-1)
  12188. texte = 'Portée horizontale : <b>'
  12189. +2*vuetotale+'</b> cases<br/>'
  12190. +'Portée verticale : <b>'
  12191. +2*Math.ceil(vuetotale/2)+'</b> cases';
  12192. else if(comp.indexOf('Planter un Champignon')!=-1)
  12193. texte = 'Planter un Champignon est une compétence qui vous permet de '
  12194. +'créer des colonies d\'une variété donnée de champignon à partir de '
  12195. +'quelques exemplaires préalablement enterrés.';
  12196. else if(comp.indexOf('Regeneration Accrue')!=-1)
  12197. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  12198. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  12199. else if(comp.indexOf('Reparation')!=-1)
  12200. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  12201. +'et réparez vous-même votre matériel !';
  12202. else if(comp.indexOf('Retraite')!=-1)
  12203. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  12204. +'préférable de préparer un repli stratégique pour déconcerter '
  12205. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  12206. +'Quelle intelligence démoniaque.';
  12207. else if(comp.indexOf('Rotobaffe')!=-1) {
  12208. var Datt = att, vattbm = attbp+attbm;
  12209. var Ddeg = deg, vdegbm = degbp+degbm;
  12210. for(var i=1 ; i<niveau+2 ; i++) {
  12211. texte += '<b>Attaque n°'+i+' :</b><br/>'
  12212. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  12213. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  12214. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  12215. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  12216. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  12217. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  12218. if(i<niveau+1) texte += '<hr>';
  12219. }
  12220. }
  12221. else if(comp.indexOf('Shamaner')!=-1)
  12222. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  12223. +'des monstres en utilisant des champignons (de 1 à 3).';
  12224. else if(comp.indexOf('Tailler')!=-1){ // obsolète
  12225. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  12226. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  12227. }
  12228. return texte;
  12229. }
  12230.  
  12231. function decumul_buff(nom,str,buff) {
  12232. // Decumul des sorts de buff
  12233. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  12234. var dec = buff, total = buff, i=1;
  12235. while(i<6) {
  12236. i++;
  12237. dec = Math.floor(coefDecumul(i)*buff);
  12238. if(dec<=1 || i==6) break;
  12239. total += dec;
  12240. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  12241. +str+' +'+dec+' (+'+total+')</i>';
  12242. }
  12243. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  12244. return ret;
  12245. }
  12246.  
  12247.  
  12248. function sortileges(sort,mainCall,pcA,pcD) {
  12249. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  12250. var texte = '';
  12251. if (mainCall) {
  12252. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  12253. pcA = (atttourP+atttourM);
  12254. pcD = (degtourP+degtourM);
  12255. }
  12256. if (sort.indexOf('Analyse Anatomique') != -1) {
  12257. texte = 'Portée horizontale : <b>'
  12258. + Math.floor(vuetotale / 2) + '</b> case';
  12259. if (vuetotale > 3){ texte += 's'; }
  12260. texte += '<br/>Portée verticale : <b>'
  12261. + Math.floor((vuetotale+1)/4)+'</b> case';
  12262. if (vuetotale > 7){ texte += 's'; }
  12263. }
  12264. else if (sort.indexOf('Armure Etheree') != -1){
  12265. texte = decumul_buff('AE', 'Armure magique', reg);
  12266. }
  12267. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  12268. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  12269. }
  12270. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  12271. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  12272. }
  12273. else if (sort.indexOf('Augmentation des Degats') != -1){
  12274. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  12275. }
  12276. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  12277. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  12278. }
  12279. else if(sort.indexOf('Bulle Magique')!=-1){
  12280. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  12281. }
  12282. else if(sort.indexOf('Explosion')!=-1){
  12283. texte = 'Dégâts : <b>'
  12284. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  12285. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  12286. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  12287. }
  12288. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  12289. if(pvcourant<=0)
  12290. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  12291. texte = 'Portée horizontale : <b>'
  12292. +Math.min(1,vuetotale)+'</b> case<br/>'
  12293. +'Dégâts physiques : <b>-'
  12294. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  12295. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  12296. +'Dégâts magiques : <b>-'
  12297. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  12298. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  12299. }
  12300. else if(sort.indexOf('Flash Aveuglant')!=-1){
  12301. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  12302. }
  12303. else if(sort.indexOf('Glue')!=-1) {
  12304. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  12305. if(vuetotale>2) texte += 's';
  12306. }
  12307. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  12308. /* Frappe */
  12309. var modD = 0;
  12310. texte = 'Attaque : <b>'+att+'</b> D6 ';
  12311. if(pcA!=0){
  12312. modD = parseInt(att*pcA/100);
  12313. texte += '<i>'+aff(modD)+'D6</i> ';
  12314. }
  12315. texte += aff(attbm)
  12316. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  12317. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  12318. if(pcD!=0) {
  12319. modD = parseInt(Math.floor(deg/2)*pcD/100);
  12320. texte += '<i>'+aff(modD)+'D3</i> ';
  12321. }else
  12322. modD = 0;
  12323. texte += aff(degbm)+' => <b>'
  12324. +(2*(Math.floor(deg/2)+modD)+degbm)
  12325. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  12326. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  12327. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  12328. +')</b>';
  12329. if(!mainCall) return texte;
  12330. /* Venins */
  12331. function addVenin(type,effet,duree) {
  12332. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  12333. +' pendant <b>'+duree+'</b> tour';
  12334. if(duree>1) ret += 's';
  12335. var dred = Math.max(Math.floor(duree/2),1);
  12336. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  12337. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  12338. }
  12339. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  12340. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  12341. effet = Math.floor(1.5*effet);
  12342. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  12343. }
  12344. else if(sort.indexOf('Hypnotisme')!=-1)
  12345. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  12346. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  12347. else if(sort.indexOf('Identification des tresors')!=-1)
  12348. texte = 'Permet de connaitre les caractéristiques et effets précis '
  12349. +'d\'un trésor.';
  12350. else if(sort.indexOf('Invisibilite')!=-1)
  12351. texte = 'Un troll invisible est indétectable même quand on se trouve '
  12352. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  12353. +'fait disparaître l\'invisibilité.';
  12354. else if(sort.indexOf('Levitation')!=-1)
  12355. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  12356. +'Comme les pièges ou les trous par exemple...';
  12357. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  12358. var eps = 1,
  12359. pc = 20;
  12360. var str = 'PréM';
  12361. var newSort;
  12362. var sortAtt = [
  12363. 'Projectile Magique',
  12364. 'Rafale Psychique',
  12365. 'Siphon des Ames',
  12366. 'Vampirisme',
  12367. 'Griffe du Sorcier'
  12368. ];
  12369. if(sort.indexOf('Puissance')!=-1) {
  12370. eps = -1; str='PuM';
  12371. }
  12372. for(var i=1 ; i<4 ; i++) {
  12373. if(texte) { texte += '<hr>'; }
  12374. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  12375. newSort = false;
  12376. for(var j=0 ; j<sortAtt.length ; j++) {
  12377. if(getTalent(sortAtt[j])) {
  12378. if(newSort) { texte += '<br/><br/>'; }
  12379. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  12380. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  12381. newSort = true;
  12382. }
  12383. }
  12384. pc = decumulPumPrem(pc);
  12385. }
  12386. }
  12387. else if(sort.indexOf('Projectile Magique')!=-1) {
  12388. var modD = 0;
  12389. var portee = getPortee__Profil(vuetotale);
  12390. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  12391. if(pcA!=0) {
  12392. modD = parseInt(vue*pcA/100);
  12393. texte += '<i>'+aff(modD)+'D6</i> ';
  12394. }
  12395. texte += aff(attbm)
  12396. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  12397. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  12398. if(pcD!=0) {
  12399. modD = parseInt(Math.floor(vue/2)+pcD);
  12400. texte += '<i>'+aff(modD)+'D3</i> ';
  12401. }else
  12402. modD = 0;
  12403. texte += aff(degbm)
  12404. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  12405. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  12406. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  12407. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+') (+ 1D3 par bonus de portée)</b>';
  12408. if(!mainCall) return texte;
  12409. texte += '<br/>Portée : <b>'+portee+'</b> case';
  12410. if(portee>1) texte += 's';
  12411. }
  12412. else if(sort.indexOf('Projection')!=-1) {
  12413. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  12414. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  12415. +'Si le jet de résistance de la victime est réussi:<br/>'
  12416. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  12417. }
  12418. else if(sort.indexOf('Rafale Psychique')!=-1) {
  12419. var modD = 0;
  12420. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  12421. if(pcD!=0) {
  12422. modD = parseInt(deg*pcD/100);
  12423. texte += '<i>'+aff(modD)+'D3</i> ';
  12424. }
  12425. texte += aff(degbm)
  12426. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  12427. if(!mainCall) return texte;
  12428. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  12429. }
  12430. else if(sort.indexOf('Sacrifice')!=-1) {
  12431. if(pvcourant<=0)
  12432. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  12433.  
  12434. function perteSacro(sac) {
  12435. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  12436. }
  12437.  
  12438. var sac = Math.floor((pvcourant-1)/2);
  12439. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  12440. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  12441. /* Sacros max et optimal sans malus (propale R') */
  12442. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  12443. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  12444. if(sac>0)
  12445. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  12446. else
  12447. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  12448. /*if(sac>3) {
  12449. sac = 5*Math.floor((sac+1)/5)-1;
  12450. texte += '<br/>Soin optimal sans malus de temps : <b>'
  12451. +sac+'</b> PV'+perteSacro(sac);
  12452. }*/
  12453. }
  12454. else if(sort.indexOf('Siphon')!=-1) {
  12455. var modD = 0;
  12456. texte = 'Attaque : <b>'+att+'</b> D6 ';
  12457. if(pcA!=0) {
  12458. modD = parseInt(att*pcA/100);
  12459. texte += '<i>'+aff(modD)+'D6</i> ';
  12460. }
  12461. texte += aff(attbm)
  12462. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  12463. +'Dégâts : <b>'+reg+'</b> D3 ';
  12464. if(pcD!=0) {
  12465. modD = parseInt(reg*pcD/100);
  12466. texte += '<i>'+aff(modD)+'D3</i> ';
  12467. }else
  12468. modD = 0;
  12469. texte += aff(degbm)
  12470. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  12471. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  12472. if(!mainCall) return texte;
  12473. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  12474. }
  12475. else if(sort.indexOf('Telekinesie')!=-1) {
  12476. texte = 'Portée horizontale :';
  12477. var vt = Math.floor(vuetotale/2)+2;
  12478. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  12479. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  12480. for(var i=0 ; i<5 ; i++) {
  12481. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  12482. if(vt>1) texte += 's';
  12483. vt=Math.max(0,vt-1);
  12484. }
  12485. }
  12486. else if(sort.indexOf('Teleportation')!=-1) {
  12487. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  12488. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  12489. var pmh = (20+vue+portee);
  12490. var pmv = 3+Math.floor(portee/3);
  12491. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  12492. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  12493. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  12494. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  12495. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  12496. }
  12497. else if(sort.indexOf('Vampirisme')!=-1) {
  12498. var modD = 0;
  12499. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  12500. if(pcA!=0) {
  12501. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  12502. texte += '<i>'+aff(modD)+'D6</i> ';
  12503. }
  12504. texte += aff(attbm)
  12505. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  12506. +'Dégâts : <b>'+deg+'</b> D3 ';
  12507. if(pcD!=0) {
  12508. modD = parseInt(deg*pcD/100);
  12509. texte += '<i>'+aff(modD)+'D3</i> ';
  12510. }else
  12511. modD = 0;
  12512. texte += aff(degbm)
  12513. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  12514. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  12515. }
  12516. else if(sort.indexOf('Vision Accrue')!=-1)
  12517. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  12518. else if(sort.indexOf('Vision lointaine')!=-1)
  12519. texte = 'En ciblant une zone située n\'importe où dans le '
  12520. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  12521. else if(sort.indexOf('Voir le Cache')!=-1)
  12522. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  12523. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  12524. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  12525. +getPortee__Profil(vuetotale)+'</b> cases';
  12526. else if(sort.indexOf('Vue Troublee')!=-1)
  12527. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  12528. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  12529. return texte;
  12530. }
  12531.  
  12532.  
  12533. /*---------------------------------- Main ------------------------------------*/
  12534.  
  12535. function do_profil2()
  12536. {
  12537. try {
  12538. start_script(31);
  12539.  
  12540. extractionDonnees();
  12541. setInfosCaracteristiques();
  12542. setInfoDescription();
  12543. setInfosEtatLieux();
  12544. setInfosEtatPV();
  12545. setInfosExp();
  12546.  
  12547. creerBulleVide();
  12548. traitementTalents();
  12549. setLienAnatrolliseur();
  12550.  
  12551. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  12552. if(race=='Kastar'){ setAccel(); }
  12553. saveProfil();
  12554. displayScriptTime();
  12555. } catch(e) {
  12556. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  12557. window.console.error(traceStack(e, 'profil2'));
  12558. }
  12559. }
  12560.  
  12561. /*******************************************************************************
  12562. * This file is part of Mountyzilla. *
  12563. * *
  12564. * Mountyzilla is free software; you can redistribute it and/or modify *
  12565. * it under the terms of the GNU General Public License as published by *
  12566. * the Free Software Foundation; either version 2 of the License, or *
  12567. * (at your option) any later version. *
  12568. * *
  12569. * Mountyzilla is distributed in the hope that it will be useful, *
  12570. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12571. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12572. * GNU General Public License for more details. *
  12573. * *
  12574. * You should have received a copy of the GNU General Public License *
  12575. * along with Mountyzilla; if not, write to the Free Software *
  12576. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  12577. *******************************************************************************/
  12578.  
  12579. // x~x script_principal
  12580.  
  12581. function isPage(url) {
  12582. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  12583. }
  12584.  
  12585. // x~x md5.js
  12586. /*
  12587. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  12588. * Digest Algorithm, as defined in RFC 1321.
  12589. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  12590. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  12591. * Distributed under the BSD License
  12592. * See http://pajhome.org.uk/crypt/md5 for more info.
  12593. */
  12594.  
  12595. /*
  12596. * Configurable variables. You may need to tweak these to be compatible with
  12597. * the server-side, but the defaults work in most cases.
  12598. */
  12599. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  12600. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  12601. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  12602.  
  12603. /*
  12604. * These are the functions you'll usually want to call
  12605. * They take string arguments and return either hex or base-64 encoded strings
  12606. */
  12607. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  12608. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  12609. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  12610. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  12611. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  12612. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  12613.  
  12614. /*
  12615. * Perform a simple self-test to see if the VM is working
  12616. */
  12617. function md5_vm_test()
  12618. {
  12619. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  12620. }
  12621.  
  12622. /*
  12623. * Calculate the MD5 of an array of little-endian words, and a bit length
  12624. */
  12625. function core_md5(x, len)
  12626. {
  12627. /* append padding */
  12628. x[len >> 5] |= 0x80 << ((len) % 32);
  12629. x[(((len + 64) >>> 9) << 4) + 14] = len;
  12630.  
  12631. var a = 1732584193;
  12632. var b = -271733879;
  12633. var c = -1732584194;
  12634. var d = 271733878;
  12635.  
  12636. for(var i = 0; i < x.length; i += 16)
  12637. {
  12638. var olda = a;
  12639. var oldb = b;
  12640. var oldc = c;
  12641. var oldd = d;
  12642.  
  12643. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  12644. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  12645. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  12646. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  12647. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  12648. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  12649. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  12650. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  12651. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  12652. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  12653. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  12654. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  12655. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  12656. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  12657. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  12658. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  12659.  
  12660. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  12661. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  12662. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  12663. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  12664. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  12665. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  12666. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  12667. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  12668. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  12669. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  12670. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  12671. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  12672. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  12673. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  12674. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  12675. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  12676.  
  12677. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  12678. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  12679. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  12680. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  12681. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  12682. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  12683. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  12684. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  12685. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  12686. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  12687. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  12688. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  12689. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  12690. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  12691. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  12692. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  12693.  
  12694. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  12695. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  12696. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  12697. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  12698. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  12699. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  12700. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  12701. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  12702. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  12703. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  12704. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  12705. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  12706. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  12707. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  12708. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  12709. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  12710.  
  12711. a = safe_add(a, olda);
  12712. b = safe_add(b, oldb);
  12713. c = safe_add(c, oldc);
  12714. d = safe_add(d, oldd);
  12715. }
  12716. return Array(a, b, c, d);
  12717.  
  12718. }
  12719.  
  12720. /*
  12721. * These functions implement the four basic operations the algorithm uses.
  12722. */
  12723. function md5_cmn(q, a, b, x, s, t)
  12724. {
  12725. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  12726. }
  12727. function md5_ff(a, b, c, d, x, s, t)
  12728. {
  12729. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  12730. }
  12731. function md5_gg(a, b, c, d, x, s, t)
  12732. {
  12733. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  12734. }
  12735. function md5_hh(a, b, c, d, x, s, t)
  12736. {
  12737. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  12738. }
  12739. function md5_ii(a, b, c, d, x, s, t)
  12740. {
  12741. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  12742. }
  12743.  
  12744. /*
  12745. * Calculate the HMAC-MD5, of a key and some data
  12746. */
  12747. function core_hmac_md5(key, data)
  12748. {
  12749. var bkey = str2binl(key);
  12750. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  12751.  
  12752. var ipad = Array(16), opad = Array(16);
  12753. for(var i = 0; i < 16; i++)
  12754. {
  12755. ipad[i] = bkey[i] ^ 0x36363636;
  12756. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  12757. }
  12758.  
  12759. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  12760. return core_md5(opad.concat(hash), 512 + 128);
  12761. }
  12762.  
  12763. /*
  12764. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  12765. * to work around bugs in some JS interpreters.
  12766. */
  12767. function safe_add(x, y)
  12768. {
  12769. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  12770. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  12771. return (msw << 16) | (lsw & 0xFFFF);
  12772. }
  12773.  
  12774. /*
  12775. * Bitwise rotate a 32-bit number to the left.
  12776. */
  12777. function bit_rol(num, cnt)
  12778. {
  12779. return (num << cnt) | (num >>> (32 - cnt));
  12780. }
  12781.  
  12782. /*
  12783. * Convert a string to an array of little-endian words
  12784. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  12785. */
  12786. function str2binl(str)
  12787. {
  12788. var bin = Array();
  12789. var mask = (1 << chrsz) - 1;
  12790. for(var i = 0; i < str.length * chrsz; i += chrsz)
  12791. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  12792. return bin;
  12793. }
  12794.  
  12795. /*
  12796. * Convert an array of little-endian words to a string
  12797. */
  12798. function binl2str(bin)
  12799. {
  12800. var str = "";
  12801. var mask = (1 << chrsz) - 1;
  12802. for(var i = 0; i < bin.length * 32; i += chrsz)
  12803. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  12804. return str;
  12805. }
  12806.  
  12807. /*
  12808. * Convert an array of little-endian words to a hex string.
  12809. */
  12810. function binl2hex(binarray)
  12811. {
  12812. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  12813. var str = "";
  12814. for(var i = 0; i < binarray.length * 4; i++)
  12815. {
  12816. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  12817. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  12818. }
  12819. return str;
  12820. }
  12821.  
  12822. /*
  12823. * Convert an array of little-endian words to a base-64 string
  12824. */
  12825. function binl2b64(binarray)
  12826. {
  12827. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  12828. var str = "";
  12829. for(var i = 0; i < binarray.length * 4; i += 3)
  12830. {
  12831. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  12832. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  12833. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  12834. for(var j = 0; j < 4; j++)
  12835. {
  12836. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  12837. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  12838. }
  12839. }
  12840. return str;
  12841. }
  12842.  
  12843. ///////////////////////////////////////////
  12844. // debug cartes capitan Roule 07/12/2016
  12845. ///////////////////////////////////
  12846. // essais : objet
  12847. // .mode : description
  12848. // .essais : tableau d'objets essai
  12849. // .mode : description
  12850. // .essais : tableau de cartes
  12851. // .noCarte : id de la carte
  12852. // .essais : tableau d'essais, [x, y, n, nb]
  12853. function AfficheEssais(essais, sMode) {
  12854. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  12855. if (!eBigDiv) {
  12856. var insertPoint = document.getElementById('footer1');
  12857. eBigDiv = document.createElement('table');
  12858. eBigDiv.id = 'ListeEssaiCapitan';
  12859. insertBefore(insertPoint, document.createElement('p'));
  12860. insertTitle(insertPoint,'Capitan : Liste des essais');
  12861. insertBefore(insertPoint, eBigDiv);
  12862. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  12863. }
  12864. if (!essais) {
  12865. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  12866. return;
  12867. }
  12868. var carte;
  12869. for (carte in essais) {
  12870. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  12871. }
  12872. if (carte === undefined) {
  12873. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  12874. }
  12875. }
  12876.  
  12877. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  12878. var tr = appendTr(eTable);
  12879. var td = appendTd(tr);
  12880. appendText(td, sMode, bBold);
  12881. td = appendTd(tr);
  12882. appendText(td, sCarte, bBold);
  12883. td = appendTd(tr);
  12884. appendText(td, sText, bBold);
  12885. }
  12886.  
  12887. function getEssaiV1_0() {
  12888. try {
  12889. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  12890. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  12891. var tabK, nK;
  12892. prefs.getChildList('', nK, tabK);
  12893. window.console.log('getEssaiV1_0, nb key : ' + nK);
  12894. //window.console.log('getEssaiV1_0, ' + nK);
  12895. return;
  12896. //return r;
  12897. } catch (e) {
  12898. window.console.log(traceStack(e, 'getEssaiV1_0'));
  12899. }
  12900. }
  12901.  
  12902. function getEssaiV1_1() {
  12903. var locSto = window.localStorage;
  12904. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  12905. var r = [];
  12906. for (var i = 0; i < locSto.length; i++) {
  12907. var k = locSto.key(i);
  12908. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  12909. var t = k.split(/\./);
  12910. if (t[0] !== 'capitan') continue;
  12911. if (t[2] !== 'essai') continue;
  12912. var carte = 'carte n°' + t[1];
  12913. if (r[carte]) r[carte]++;
  12914. else r[carte] = 1;
  12915. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  12916. }
  12917. return r;
  12918. }
  12919.  
  12920. function showEssaiCartes() {
  12921. window.console.log('début showEssai Tout_MZ');
  12922. var essais = getEssaiV1_0();
  12923. AfficheEssais(essais, 'V1.0');
  12924. essais = getEssaiV1_1();
  12925. AfficheEssais(essais, 'V1.1');
  12926. window.console.log('fin showEssai Tout_MZ');
  12927. }
  12928.  
  12929. function testBoolLocalStorage() {
  12930. var b = true;
  12931. var key = 'MZ_essai_bool';
  12932. GM_setValue(key, b);
  12933. window.localStorage[key] = b;
  12934. var v = GM_getValue(key);
  12935. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  12936. var v = window.localStorage.getItem(key);
  12937. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  12938.  
  12939. var b = false;
  12940. GM_setValue(key, b);
  12941. window.localStorage[key] = b;
  12942. var v = GM_getValue(key);
  12943. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  12944. var v = window.localStorage.getItem(key);
  12945. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  12946.  
  12947. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  12948. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  12949. var y = GM_getValue('654654897894654654');
  12950. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  12951. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  12952. }
  12953.  
  12954. /*--------------------------------- Création liste trolligion ---------------------------------*/
  12955. function export_trolligion() {
  12956. try {
  12957. var tabDl = document.getElementsByTagName('dl');
  12958. if ((!tabDl) || !tabDl[0]) {
  12959. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  12960. return;
  12961. }
  12962. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  12963. // nom : string
  12964. // rayonnement : entier
  12965. // grades : table d'objets (une occurence par grade)
  12966. // nom : string
  12967. // trolls : table d'objets (un par Trõll)
  12968. // id
  12969. // nom
  12970. // idguilde
  12971. // guilde
  12972. // race
  12973. // niveau
  12974. // ferveur
  12975. var currentDieu;
  12976. var currentGrade;
  12977. for (var iChild1 in tabDl[0].children) {
  12978. var eChild1 = tabDl[0].children[iChild1];
  12979. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  12980. case 'dd': // Trõll
  12981. var oTroll = {};
  12982. export_trolligion_analyse(oTroll, eChild1);
  12983. currentGrade.trolls.push(oTroll);
  12984. break;
  12985. case 'dt':
  12986. var tabH3 = eChild1.getElementsByTagName('h3');
  12987. if (tabH3 && tabH3[0]) { // changement de dieu
  12988. currentDieu = {
  12989. nom: tabH3[0].innerText || tabH3[0].textContent
  12990. , grades: []};
  12991. var txt = eChild1.innerText || eChild1.textContent;
  12992. var m = txt.match(/yon*ement *:* *(\d+)/);
  12993. if (m) currentDieu.rayonnement = parseInt(m[1]);
  12994. currentGrade = undefined;
  12995. tabDieux.push(currentDieu);
  12996. break;
  12997. }
  12998. var tabH4 = eChild1.getElementsByTagName('h4');
  12999. if (tabH4 && tabH4[0]) { // changement de grade
  13000. var grade;
  13001. var txt = tabH4[0].innerText || tabH4[0].textContent;
  13002. tabI = tabH4[0].getElementsByTagName('i');
  13003. if (tabI && tabI[0]) {
  13004. grade = tabI[0].innerText || tabI[0].textContent;
  13005. grade = grade.replace(/"/g, '');
  13006. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  13007. if (m) grade += ' (' + m[1] + ')';
  13008. } else {
  13009. grade = txt.replace(/"/g, '');
  13010. }
  13011. currentGrade = {nom: grade, trolls: []};
  13012. currentDieu.grades.push(currentGrade);
  13013. break;
  13014. }
  13015. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  13016. break;
  13017. default:
  13018. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  13019. }
  13020. }
  13021.  
  13022. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  13023. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  13024. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  13025. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  13026. for (var iDieu in tabDieux) {
  13027. var oDieu = tabDieux[iDieu];
  13028. for (var iGrade in oDieu.grades) {
  13029. var oGrade = oDieu.grades[iGrade];
  13030. for (var iTroll in oGrade.trolls) {
  13031. var oTroll = oGrade.trolls[iTroll];
  13032. var t = [oDieu.nom, oDieu.rayonnement
  13033. , oGrade.nom
  13034. , oTroll.id, oTroll.nom
  13035. , oTroll.idguilde, oTroll.guilde
  13036. , oTroll.race, oTroll.niveau
  13037. , oTroll.ferveur];
  13038. for (var iParam in t) {
  13039. if (t[iParam] === undefined) t[iParam] = ''; // protection
  13040. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  13041. }
  13042. txt += t.join("\t") + "\n";
  13043. }
  13044. }
  13045. var t = [oDieu.nom, oDieu.rayonnement];
  13046. for (var iParam in t) {
  13047. if (t[iParam] === undefined) t[iParam] = ''; // protection
  13048. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  13049. }
  13050. txt2 += t.join("\t") + "\n";
  13051. }
  13052. txt += "\n" + txt2;
  13053. } catch (e) {
  13054. window.alert("Échec à l'extraction\n" + e);
  13055. }
  13056. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  13057. try {
  13058. if (copyTextToClipboard(txt)) {
  13059. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  13060. + "Collez dans Calc\n"
  13061. + "ou, au pire, dans EXCEL®");
  13062. } else {
  13063. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  13064. }
  13065. } catch(e) {
  13066. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  13067. }
  13068. }
  13069.  
  13070. function export_trolligion_analyse(oTroll, eChild1) {
  13071. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  13072. var eChild2 = eChild1.childNodes[iChild2];
  13073. if (eChild2.nodeType === undefined) continue; // properties
  13074. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  13075. switch (eChild2.nodeType) {
  13076. case 1: //ELEMENT_NODE:
  13077. switch (eChild2.nodeName.toLowerCase()) {
  13078. case 'a':
  13079. var m;
  13080. if (!eChild2.href) {
  13081. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  13082. break;
  13083. }
  13084. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  13085. if (m) {
  13086. oTroll.id = parseInt(m[1]);
  13087. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  13088. break;
  13089. }
  13090. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  13091. if (m) {
  13092. var idGuilde = parseInt(m[1]);
  13093. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  13094. oTroll.idguilde = parseInt(m[1]);
  13095. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  13096. }
  13097. break;
  13098. }
  13099. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  13100. break;
  13101. case 'br': // ignore
  13102. case 'style': // ignore
  13103. case 'img': // ignore
  13104. break;
  13105. case 'div': // barre de vie
  13106. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  13107. eChild3 = eChild2.children[0];
  13108. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  13109. var eChild4 = eChild3.children[0];
  13110. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  13111. break;
  13112. }
  13113. }
  13114. //window.console.log(eChild2.innerHTML);
  13115. export_trolligion_analyse(oTroll, eChild2);
  13116. break;
  13117. default:
  13118. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  13119. break;
  13120. }
  13121. break;
  13122. case 3: //TEXT_NODE:
  13123. var txt = eChild2.nodeValue.trim();
  13124. if (txt === '') break;
  13125. var m = txt.match(/(.*) *\((\d+)\)/);
  13126. if (m) {
  13127. oTroll.race = m[1].trim();
  13128. oTroll.niveau = parseInt(m[2]);
  13129. } else {
  13130. oTroll.race = txt;
  13131. }
  13132. break;
  13133. default: // ne devrait pas arriver
  13134. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  13135. break;
  13136. }
  13137. }
  13138. }
  13139.  
  13140. function do_trolligion() {
  13141. var divpopup = document.createElement('div');
  13142. divpopup.id = 'MZ_divCopier';
  13143. divpopup.style.position = 'fixed';
  13144. divpopup.style.top = '2px';
  13145. divpopup.style.left = '2px;';
  13146. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  13147. divpopup.style.cursor = 'pointer';
  13148. divpopup.style.zIndex = 200;
  13149. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  13150. divpopup.onclick = export_trolligion;
  13151. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  13152. divpopup.appendChild(img);
  13153. document.body.appendChild(divpopup);
  13154. }
  13155.  
  13156. /*--------------------------------- Dispatch ---------------------------------*/
  13157.  
  13158. //chargerScriptDev("libs");
  13159. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  13160. //if (isDEV) testBoolLocalStorage();
  13161.  
  13162. // Détection de la page à traiter
  13163. if(isPage("Messagerie/ViewMessageBot")) {
  13164. do_cdmbot();
  13165. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  13166. do_cdmcomp();
  13167. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  13168. do_cdmcomp();
  13169. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  13170. do_cdmcomp();
  13171. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  13172. do_diplo();
  13173. } else if(isPage("MH_Play/Play_equipement")) {
  13174. do_equip();
  13175. } else if(isPage("MH_Play/Play_menu")) {
  13176. do_menu();
  13177. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  13178. do_option();
  13179. //showEssaiCartes();
  13180. } else if(isPage("View/PJView")) {
  13181. do_pjview();
  13182. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  13183. do_profil();
  13184. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  13185. do_tancompo();
  13186. } else if(isPage("MH_Play/Play_vue")) {
  13187. do_vue();
  13188. } else if(isPage("MH_Play/Play_news")) {
  13189. do_news();
  13190. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  13191. do_move();
  13192. } else if(isPage("MH_Missions/Mission_Etape")) {
  13193. do_mission();
  13194. } else if(isPage("View/MonsterView")) {
  13195. do_infomonstre();
  13196. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  13197. do_attaque();
  13198. } else if(isPage("MH_Play/Play_e_follo.php")) {
  13199. do_listegowap();
  13200. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  13201. do_lieuDescription();
  13202. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  13203. do_lieuTeleport();
  13204. } else if(isPage("MH_Follower/FO_Ordres")) {
  13205. do_ordresgowap();
  13206. } else if(isPage("MH_Follower/FO_Equipement")) {
  13207. do_equipgowap();
  13208. } else if(isPage("MH_Play/Play_mouche")) {
  13209. do_mouches();
  13210. } else if(isPage("MH_Play/Play_BM")) {
  13211. do_malus();
  13212. } else if(isPage("MH_Play/Play_evenement")) {
  13213. do_myevent();
  13214. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  13215. do_enchant();
  13216. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  13217. do_pre_enchant();
  13218. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  13219. do_actions();
  13220. } 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')) {
  13221. do_mission_liste();
  13222. } else if(isPage('MH_Play/Play_action')) {
  13223. do_actions();
  13224. } else if(isPage('MH_Play/Play_profil2')) {
  13225. do_profil2();
  13226. } else if(isPage('View/TrolligionView.php')) {
  13227. do_trolligion();
  13228. }
  13229. } catch(e) {
  13230. try {
  13231. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  13232. } catch(e2) {
  13233. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  13234. }
  13235. }