Tout_MZ

Client MountyZilla

当前为 2019-04-15 提交的版本,查看 最新版本

  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.19.1
  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.1 15/04/2019",
  39. " Dabihul, Nouvelles versions de AdA/AdD",
  40. "V1.2.18.15 29/03/2019",
  41. " Correction simple quote dans toutes les missions",
  42. "V1.2.18.14 09/03/2019",
  43. " Correction affichage vues 2D externes suite à une modif MH",
  44. "V1.2.18.13 27/02/2019",
  45. " Correction simple quote dans les familles de monstre des missions",
  46. "V1.2.18.12 23/12/2018",
  47. " Message si \"Menu d'actions contextuelles\" est décoché",
  48. "V1.2.18.11 21/11/2018",
  49. " Correction it bricol'troll, login avec accent",
  50. "V1.2.18.10 08/08/2018",
  51. " Correction boulette sDiplo",
  52. "V1.2.18.09 04/08/2018",
  53. " Protection contre diplomatie mal initialisée",
  54. "V1.2.18.08 11/07/2018",
  55. " Correction pour fonctionnement hors GM",
  56. "V1.2.18.07 18/05/2018",
  57. " prise en compte bonus magique d'esquive dans le profil, correction gestion de la souris dans la page d'équipement [Dabihul, welcome back]",
  58. "V1.2.18.06 28/01/2018",
  59. " Protection malus Crasc sans durée",
  60. "V1.2.18.05 18/11/2017",
  61. " Désactivation MZ V2 en mode dev pour les tests d'adaptation violentmonkey",
  62. "V1.2.18.04 04/09/2017",
  63. " retour version 1.2.18.02 avec GM 3.17",
  64. "V1.2.18.03 01/09/2017",
  65. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  66. "V1.2.18.02 26/08/2017",
  67. " correction boulette sur le compos d'enchantement",
  68. "V1.2.18.01 25/08/2017",
  69. " Suppression des messages sur les certificats en https",
  70. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  71. "V1.2.17.19 23/08/2017",
  72. " Possibilité de plusieurs IT Bricol'Troll",
  73. "V1.2.17.18 22/08/2017",
  74. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  75. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  76. "V1.2.17.17 16/07/2017",
  77. " modification du mécanisme de filtrage pour contourner un pb",
  78. "V1.2.17.16 16/07/2017",
  79. " Ajout de messages de debug sur les retours AJAX",
  80. "V1.2.17.15 15/07/2017",
  81. " modification du mécanisme de filtrage pour contourner un pb",
  82. "V1.2.17.14 14/07/2017",
  83. " correction dans la gestion des étapes de mission",
  84. "V1.2.17.13 12/07/2017",
  85. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  86. "V1.2.17.12 16/06/2017",
  87. " Correction mauvais compte de PX quand on change de Trõll",
  88. "V1.2.17.11 01/05/2017",
  89. " Travail sur le fonctionnement hors Greasemonkey",
  90. "V1.2.17.10 30/04/2017",
  91. " Protection dans la récupération d'erreur",
  92. "V1.2.17.9 30/04/2017",
  93. " Correction récupération d'erreur IT Bricol'Troll",
  94. "V1.2.17.8 29/04/2017",
  95. " Correction Bonus/Malus cas +0\+10 (AE)",
  96. " Correction portée IdC",
  97. " Prise en compte du bonus de portée PM dans le calcul tactique",
  98. "V1.2.17.7 26/04/2017",
  99. " Version compatible hors GreaseMonkey",
  100. "V1.2.17.6 23/04/2017",
  101. " Correction gestion des missions en cas de réinstallation",
  102. "V1.2.17.5 20/04/2017",
  103. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  104. "V1.2.17.4 08/04/2017",
  105. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  106. " Adaptation de la diplomatie à une modification de la page MH",
  107. "V1.2.17.3 04/04/2017",
  108. " Messages console en cas de cadre d'erreur",
  109. " Trolls de l'IT mais pas dans le vue en orange",
  110. "V1.2.17.2 20/03/2017",
  111. " Correction des PV restants",
  112. "V1.2.17.1 20/03/2017",
  113. " Blocage des PV restants en attendant résolution de bug",
  114. "V1.2.17 19/03/2017",
  115. " Refonte de l'envoi des CdM",
  116. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  117. "V1.2.16.4 08/03/2017",
  118. " correction ID de troll en envoi de PX/MP",
  119. "V1.2.16.3 27/02/2017",
  120. " correction bonus/malus FP",
  121. "V1.2.16.2 24/02/2017",
  122. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  123. "V1.2.16.1 21/02/2017",
  124. " corrige bug sur Fx 38.8 ESR",
  125. "V1.2.16 21/02/2017",
  126. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  127. " possibilité de masquer les Gowaps Sauvages dans la vue",
  128. " calcul des caractéristiques du siphon des âmes",
  129. "V1.2.15.2 02/02/2017",
  130. " adaptation décumul VlC (page des bonus/malus)",
  131. "V1.2.15.1 29/01/2017",
  132. " carte sur la page de description du lieu TP",
  133. "V1.2.15 25/01/2017",
  134. " mise en place des nouvelles cartes (suivants, TP)",
  135. "V1.2.14.3 25/01/2017",
  136. " résumé dans l'export des données Trõlligion",
  137. "V1.2.14.2 20/01/2017",
  138. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  139. "V1.2.14.1 20/01/2017",
  140. " réécriture filtrage des monstres par niveau dans la vue",
  141. " Changelog dans la page des news MZ",
  142. "V1.2.14 20/01/2017",
  143. " Ajout de l'export des données Trõlligion",
  144. "V1.2.13.7 10/01/2017",
  145. " Exclusion Bricoll'troll dans l'entête GM",
  146. "V1.2.13.6 08/01/2017",
  147. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  148. "V1.2.13.5 07/01/2017",
  149. " Correction bug qui se manisfestait sous LINUX",
  150. "V1.2.13.4 07/01/2017",
  151. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  152. "V1.2.13.3 07/01/2017",
  153. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  154. "V1.2.13.2 07/01/2017",
  155. " Correction missions, recherche troogle (familles et types de monstres)",
  156. "V1.2.13.1 06/01/2017",
  157. " Suppression oldSchoolProfile qui n'existe plus",
  158. " Ajout du 'refresh' du cadre de gauche",
  159. "V1.2.13 01/01/2017",
  160. " homogénéisation des messages d'erreur",
  161. " Ajout du lien Troogle sur les étapes de mission monstre",
  162. "V1.2.12.2 30/12/2016",
  163. " retour en mode normal (http si jeu en http)",
  164. "V1.2.12.1 27/12/2016",
  165. " Correction mode IP",
  166. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  167. "V1.2.12 24/12/2016",
  168. " Nettoyage des URL",
  169. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  170. " Interface bricoll'Troll en https",
  171. " Remise en marche des cartes des trajets des gowaps",
  172. "V1.2.11.5 à 7 20 & 21/12/2016",
  173. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  174. "V1.2.11.4 19/12/2016",
  175. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  176. "V1.2.11.3 19/12/2016",
  177. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  178. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  179. "V1.2.11.2 18/12/2016",
  180. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  181. "V1.2.11.1 17/12/2016",
  182. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  183. "V1.2.11 13/12/2016",
  184. " Passage sur BdD Raistlin \\o/",
  185. "V1.2.10.4 12/12/2016",
  186. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  187. "V1.2.10.3 09/12/2016",
  188. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  189. "V1.2.10.2 09/12/2016",
  190. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  191. "V1.2.10.1 08/12/2016",
  192. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  193. "V1.2.10 07/12/2016",
  194. " correction décumul des bonus/malus",
  195. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  196. "V1.2.9 16/11/2016",
  197. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  198. "V1.2.8 10/11/2016",
  199. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  200. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  201. "V1.2.7 07/11/2016",
  202. " remise en route de l'interface avec l'IT bricol'Troll",
  203. "V1.2.6 19/10/2016",
  204. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  205. " stockage idguilde et nomguilde",
  206. "V1.2.5 17/10/2016",
  207. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  208. " remise en route de la gestion des options avec intégration md5 dans ce script",
  209. "V1.2.4 14/10/2016",
  210. " utilisation du relai raistlin pour l'envoi des CdM",
  211. "V1.2.3 :",
  212. " suppression ancien profil",
  213. " nettoyage doublon sur getPortee",
  214. " adaptation portee TP basée sur les PI",
  215. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  216. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  217. "V1.2.1 :",
  218. " include des URLs MH alternatives",
  219. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  220. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  221. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  222. "V1.1 : regroupement en un gros paquet sale",
  223. ];
  224.  
  225. /**********************************************************
  226. À faire / propositions d'évolutions
  227.  
  228. Bireli-Gravos 08/12/2018
  229. FAIT faire un warning si l'utilisateur a désactivé la case "Menu d'actions contextuelles" dans la fenêtre "limiter la vue"
  230. breizhou13 20/12/2016
  231. envoyer les données à l'IT (Bricol'Trolls) aussi
  232. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  233. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  234. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  235. Akkila le boeuf le 26-03-2017 à 15:56
  236. - bouton pour rafraîchir les infos des trolls de son groupe
  237. Roule'
  238. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  239. Réactiver les jubilaires
  240. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  241. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  242. - voir l'intérêt de refaire fonctionner
  243. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  244. Prévision des DLA de monstre
  245. Niveau des monstres à la méthode Roule'
  246. Raistlin
  247. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  248. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  249. 80117 - Héra
  250. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  251. 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)
  252. FAIT Possibilité de plusieurs systèmes Bricol'troll
  253. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  254. ?
  255. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  256. Alanae/Gnu
  257. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  258. Kali
  259. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  260. **********************************************************/
  261.  
  262. /**********************************************************
  263. **** Début de zone à déplacer dans une bibli commune ******
  264. **********************************************************/
  265.  
  266. // URL de base serveur MZ
  267. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  268. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  269. //var URL_MZ = 'http://192.99.225.92/mz';
  270.  
  271. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  272. // à supprimer
  273. const newCarte = true;
  274. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  275.  
  276. // URLs externes redirection (pas de souci CORS)
  277. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  278. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  279. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  280. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  281. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  282. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  283. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  284. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  285. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  286.  
  287. // URLs de test HTTPS
  288. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  289. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  290.  
  291. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  292. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  293. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  294.  
  295. // x~x Libs
  296.  
  297. /* ancien TODO
  298. * - revoir la gestion des CdM --> nott armure magique
  299. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  300. * - vérfier la gestion des enchants
  301. */
  302.  
  303. // Roule 04/09/2016 switch extern URLs to https if available
  304. var isHTTPS = false;
  305. if (window.location.protocol.indexOf('https') === 0) {
  306. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  307. URL_bricol = URL_bricol_https;
  308. isHTTPS = true;
  309. }
  310.  
  311. // Roule 23/12/2016 mode dev
  312. var isDEV = false;
  313. if (window.localStorage.getItem('MZ_dev')
  314. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  315. || window.location.href.indexOf('mzdev.mh') >= 0) {
  316. URL_MZ = URL_MZ.replace(/$/, 'dev');
  317. isDEV = true;
  318. }
  319.  
  320. // Images (pas de souci CORS)
  321. var URL_MZimg = URL_MZ + '/img/';
  322. // URLs externes ajax (CORS OK)
  323. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  324. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  325. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  326.  
  327. // liens externes déduits
  328. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  329. var MHicons = '/mountyhall/Images/Icones/';
  330. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  331. var MY_DEBUG = false;
  332.  
  333. var horsGM = false;
  334. try { // à partir du 11/07/2018, (GM_getValue === undefined) provoque une exception
  335. horsGM = (GM_getValue === undefined);
  336. } catch (e2) {
  337. horsGM = true;
  338. //window.console.log('test GM_getValue, exception=' + e2);
  339. }
  340. if (horsGM) { // éviter le blocage si pas sous GM
  341. window.console.log('Fonctionnement hors Greasemonkey');
  342. // Roule 18/11/2017 il ne faut pas de "var" dans les ligne précédente. Ça fonctionnait sous Greasemonkey mais plus sous Violentmonkey
  343. GM_getValue = function(key) {};
  344. GM_setValue = function(key, val) {};
  345. GM_deleteValue = function(key) {};
  346. GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  347. }
  348.  
  349. /* Utilisation de la gestion de l'enregistrement des données de
  350. GreaseMonkey, avec partage entre scripts via le localStorage, par
  351. Vapulabehemot (82169) 07/02/2017 */
  352. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  353. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  354. function MY_getValue(key) {
  355. var v = window.localStorage.getItem(key);
  356. vGM = GM_getValue(key);
  357. if ((vGM == null)
  358. || (v != null && v != vGM)){
  359. GM_setValue(key, v);
  360. } else if (v == null && vGM != null) {
  361. v = vGM;
  362. window.localStorage[key] = vGM;
  363. }
  364. return v;
  365. }
  366. function MY_removeValue(key) {
  367. GM_deleteValue(key);
  368. window.localStorage.removeItem(key);
  369. }
  370. function MY_setValue(key, val) {
  371. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  372. val = 1;
  373. else if (val === false)
  374. val = 0;
  375. try {
  376. GM_setValue(key, val);
  377. } catch(e) {
  378. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  379. }
  380. try {
  381. window.localStorage[key] = val;
  382. } catch(e) {
  383. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  384. }
  385. }
  386.  
  387. /*---------------- mise à jour de variables globales utiles ------------------*/
  388. // utilisé pour accès bdd (un peu partout) :
  389. var numTroll = MY_getValue('NUM_TROLL');
  390. // utilisé dans vue pour PX :
  391. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  392. var nivTroll; // = MY_getValue('NIV_TROLL');
  393. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  394. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  395. // utilisés dans actions et vue (calculs SR) :
  396. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  397. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  398. var currentURL = window.location.href;
  399.  
  400. /*-[functions]------------ Fonctions durée de script -------------------------*/
  401. var date_debut = null;
  402.  
  403. function start_script(nbJours_exp) {
  404. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  405. if(date_debut) return;
  406. date_debut = new Date();
  407. // Créé la variable expdate si demandé
  408. if(nbJours_exp) {
  409. expdate = new Date();
  410. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  411. }
  412. }
  413.  
  414. function displayScriptTime() {
  415. var footerNode = document.getElementById('footer2');
  416. if(!footerNode) return;
  417. try{
  418. var node = document.evaluate(
  419. ".//text()[contains(.,'Page générée en')]/../br",
  420. footerNode,null,9,null).singleNodeValue;
  421. }
  422. catch(e){return;}
  423. insertText(node,
  424. ' - [Script MZ exécuté en '
  425. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  426. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  427. }
  428.  
  429. function traceStack(e, sModule) {
  430. var version = '';
  431. if (GM_info && GM_info.script && GM_info.script.version)
  432. version = ' ' + GM_info.script.version;
  433. sRet = '[MZ' + version + ']'
  434. if (sModule) sRet += ' {' + sModule + '}';
  435. try {
  436. if (e.message) sRet += ' ' + e.message;
  437. } catch (e2) {
  438. sRet += ' <exception acces message>';//+ e2.message;
  439. }
  440. try {
  441. if (e.stack) {
  442. var sStack = e.stack;
  443. // enlever les infos confidentielles
  444. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  445. }
  446. } catch (e2) {
  447. sRet += ' <exception acces stack>'; // + e2.message;
  448. }
  449. return sRet;
  450. }
  451.  
  452. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  453.  
  454. function debugMZ(str){
  455. if(MY_DEBUG){
  456. window.console.debug('[MZ_DEBUG] '+str);
  457. if(typeof str === "object"){
  458. window.console.debug(str);
  459. }
  460. }
  461. }
  462.  
  463. function FF_XMLHttpRequest(MY_XHR_Ob) {
  464. var request = new XMLHttpRequest();
  465. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  466. for(var head in MY_XHR_Ob.headers) {
  467. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  468. }
  469. request.onreadystatechange = function() {
  470. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  471. if(request.readyState!=4) { return; }
  472. if(request.error) {
  473. if(MY_XHR_Ob.onerror) {
  474. MY_XHR_Ob.onerror(request);
  475. }
  476. return;
  477. }
  478. if ((request.status == 0)) {
  479. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  480. if (isDEV) {
  481. var grandCadre = createOrGetGrandCadre();
  482. var sousCadre = document.createElement('div');
  483. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  484. sousCadre.style.width = 'auto';
  485. sousCadre.style.fontSize = 'large';
  486. sousCadre.style.border = 'solid 1px black';
  487. grandCadre.appendChild(sousCadre);
  488. }
  489. //showHttpsErrorContenuMixte();
  490. return;
  491. }
  492. if(MY_XHR_Ob.onload) {
  493. var version;
  494. if (MY_XHR_Ob.trace) {
  495. version = '';
  496. if (GM_info && GM_info.script && GM_info.script.version)
  497. version = ' ' + GM_info.script.version;
  498. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  499. }
  500. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  501. MY_XHR_Ob.onload(request);
  502. if (MY_XHR_Ob.trace)
  503. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  504. }
  505. };
  506. request.send(MY_XHR_Ob.data);
  507. }
  508.  
  509. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  510. function MZ_formatDateMS(d) {
  511. if (d === undefined) d = new Date();
  512. var day = d.getDate();
  513. var month = d.getMonth()+1;
  514. var year = d.getFullYear();
  515. var hours = d.getHours();
  516. var minutes = d.getMinutes();
  517. var seconds = d.getSeconds();
  518. var ms = d.getMilliseconds();
  519. if (day < 10) {day = "0"+day;}
  520. if (month < 10) {month = "0"+month;}
  521. if (hours < 10) {hours = "0"+hours;}
  522. if (hours < 10) {hours = "0"+hours;}
  523. if (minutes < 10) {minutes = "0"+minutes;}
  524. if (seconds < 10) {seconds = "0"+seconds;}
  525. ms = ('000' + ms).substr(-3, 3);
  526. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  527. }
  528.  
  529. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  530.  
  531. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  532. function copyTextToClipboard(text) {
  533. var textArea = document.createElement("textarea");
  534.  
  535. //
  536. // *** This styling is an extra step which is likely not required. ***
  537. //
  538. // Why is it here? To ensure:
  539. // 1. the element is able to have focus and selection.
  540. // 2. if element was to flash render it has minimal visual impact.
  541. // 3. less flakyness with selection and copying which **might** occur if
  542. // the textarea element is not visible.
  543. //
  544. // The likelihood is the element won't even render, not even a flash,
  545. // so some of these are just precautions. However in IE the element
  546. // is visible whilst the popup box asking the user for permission for
  547. // the web page to copy to the clipboard.
  548. //
  549.  
  550. // Place in top-left corner of screen regardless of scroll position.
  551. textArea.style.position = 'fixed';
  552. textArea.style.top = 0;
  553. textArea.style.left = 0;
  554.  
  555. // Ensure it has a small width and height. Setting to 1px / 1em
  556. // doesn't work as this gives a negative w/h on some browsers.
  557. textArea.style.width = '2em';
  558. textArea.style.height = '2em';
  559.  
  560. // We don't need padding, reducing the size if it does flash render.
  561. textArea.style.padding = 0;
  562.  
  563. // Clean up any borders.
  564. textArea.style.border = 'none';
  565. textArea.style.outline = 'none';
  566. textArea.style.boxShadow = 'none';
  567.  
  568. // Avoid flash of white box if rendered for any reason.
  569. textArea.style.background = 'transparent';
  570.  
  571. textArea.value = text;
  572.  
  573. document.body.appendChild(textArea);
  574.  
  575. textArea.select();
  576.  
  577. var successful = document.execCommand('copy');
  578.  
  579. document.body.removeChild(textArea);
  580. return successful;
  581. }
  582.  
  583. function avertissement(txt,duree) {
  584. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  585. if(!duree) duree = 15000;
  586. var div = document.createElement('div');
  587. // On numérote les avertissements pour destruction sélective
  588. var num = document.getElementsByName('avertissement').length;
  589. div.num = num;
  590. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  591. div.setAttribute('name','avertissement');
  592. div.className = 'mh_textbox';
  593. div.style.position = 'fixed';
  594. div.style.top = (10+15*num)+'px';
  595. div.style.left = (10+5*num)+'px';
  596. div.style.border = '5px solid red';
  597. div.style.zIndex = 2+num;
  598. div.style.cursor = 'pointer';
  599. div.style.fontSize = 'large';
  600. div.innerHTML = txt;
  601. div.onclick=function(){ tueAvertissement(this.num) };
  602.  
  603. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  604. var divcroix = document.createElement('div');
  605. divcroix.style.position = 'absolute';
  606. divcroix.style.top = 0;
  607. divcroix.style.right = 0;
  608. divcroix.style.color = 'black';
  609. divcroix.style.fontSize = 'inherit';
  610. divcroix.style.cursor = 'pointer'
  611. divcroix.style.zIndex = 2+num;
  612. divcroix.innerHTML = "X";
  613. div.appendChild(divcroix);
  614.  
  615. document.body.appendChild(div);
  616. // Destruction automatique de l'avertissement après "un certain temps"
  617. window.setTimeout(function(){ tueAvertissement(num) },duree);
  618. }
  619.  
  620. function tueAvertissement(num) {
  621. var divs = document.getElementsByName('avertissement');
  622. if(divs.length==0) { return; }
  623. for(var i=0 ; i<divs.length ; i++) {
  624. if(divs[i].num==num) {
  625. divs[i].parentNode.removeChild(divs[i]);
  626. return;
  627. }
  628. }
  629. }
  630.  
  631.  
  632. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  633.  
  634. function insertBefore(next,el) {
  635. next.parentNode.insertBefore(el,next);
  636. }
  637.  
  638. function appendTr(tbody,clas) {
  639. var tr = document.createElement('tr');
  640. if(clas) tr.className = clas;
  641. tbody.appendChild(tr);
  642. return tr;
  643. }
  644.  
  645. function insertTr(next,clas) {
  646. var tr = document.createElement('tr');
  647. if(clas) tr.className = clas;
  648. insertBefore(next,tr);
  649. return tr;
  650. }
  651.  
  652. function appendTd(tr) {
  653. var td = document.createElement('td');
  654. if(tr) tr.appendChild(td);
  655. return td;
  656. }
  657.  
  658. function insertTd(next) {
  659. var td = document.createElement('td');
  660. insertBefore(next,td);
  661. return td;
  662. }
  663.  
  664. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  665. function insertAfterTd(eTd) {
  666. var newTd = document.createElement('td');
  667. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  668. return newTd;
  669. }
  670.  
  671. function appendTdCenter(tr,colspan) {
  672. var td = appendTd(tr);
  673. td.align = 'center'; // WARNING - Obsolete
  674. if(colspan) td.colSpan = colspan;
  675. return td;
  676. }
  677.  
  678. function insertTdElement(next,el) {
  679. var td = insertTd(next);
  680. if(el) td.appendChild(el);
  681. return td;
  682. }
  683.  
  684. function appendA(paren,href,cssClass,text) {
  685. var a = document.createElement('a');
  686. if (href) a.href = href;
  687. if (cssClass) a.className = cssClass;
  688. if (text) a.appendChild(document.createTextNode(text));
  689. paren.appendChild(a);
  690. }
  691.  
  692. function appendText(paren,text,bold) {
  693. if(bold) {
  694. var b = document.createElement('b');
  695. b.appendChild(document.createTextNode(text));
  696. paren.appendChild(b);
  697. }
  698. else
  699. paren.appendChild(document.createTextNode(text));
  700. }
  701.  
  702. function insertText(next,text,bold) {
  703. if(bold) {
  704. var b = document.createElement('b');
  705. appendText(b,text);
  706. insertBefore(next,b);
  707. }
  708. else
  709. insertBefore(next,document.createTextNode(text));
  710. }
  711.  
  712. function appendTdText(tr,text,bold) {
  713. var td = appendTd(tr);
  714. appendText(td,text,bold);
  715. return td;
  716. }
  717.  
  718. function insertTdText(next,text,bold) {
  719. var td = insertTd(next);
  720. appendText(td,text,bold);
  721. return td;
  722. }
  723.  
  724. function appendBr(paren) {
  725. paren.appendChild(document.createElement('br'));
  726. }
  727.  
  728. function insertBr(next) {
  729. insertBefore(next,document.createElement('br'));
  730. }
  731.  
  732. function appendLI(ul,text) {
  733. // uniquement utilisé dans les options (crédits)
  734. var li = document.createElement('li');
  735. appendText(li,text);
  736. ul.appendChild(li);
  737. return li;
  738. }
  739.  
  740. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  741. var input = document.createElement('input');
  742. input.className = 'TextboxV2';
  743. input.type = type;
  744. input.name = nam;
  745. if (sId === undefined) input.id = nam;
  746. else input.id = sId;
  747. input.size = size;
  748. input.maxLength = maxlength;
  749. if(value) input.value = value;
  750. paren.appendChild(input);
  751. return input;
  752. }
  753.  
  754. function appendCheckBox(paren,nam,checked,onClick) {
  755. var input = document.createElement('input');
  756. input.type = 'checkbox';
  757. input.name = nam;
  758. input.id = nam;
  759. if(checked) input.checked = true;
  760. if(onClick) input.onclick = onClick;
  761. paren.appendChild(input);
  762. return input;
  763. }
  764.  
  765. function appendNobr(paren,id,delgg,text) {
  766. var nobr = document.createElement('nobr');
  767. appendCheckBox(nobr,id,null,delgg);
  768. appendText(nobr,text);
  769. paren.appendChild(nobr);
  770. appendText(paren,' ');
  771. return nobr;
  772. }
  773.  
  774. function appendCheckBoxSpan(paren,id,onClick,text) {
  775. var span = document.createElement('span');
  776. span.style.whiteSpace = 'nowrap';
  777. appendCheckBox(span,id,false,onClick);
  778. var label = document.createElement('label');
  779. appendText(label,text);
  780. label.htmlFor = id;
  781. label.style.marginLeft = '-5px';
  782. span.appendChild(label);
  783. span.style.marginRight = '3px';
  784. paren.appendChild(span);
  785. appendText(paren, ' ');
  786. return span;
  787. }
  788.  
  789. function appendOption(select,value,text) {
  790. var option = document.createElement('option');
  791. option.value = value;
  792. appendText(option,text);
  793. select.appendChild(option);
  794. return option;
  795. }
  796.  
  797. function appendHidden(form,nam,value) {
  798. var input = document.createElement('input');
  799. input.type = 'hidden';
  800. input.name = nam;
  801. input.id = nam;
  802. input.value = value;
  803. form.appendChild(input);
  804. }
  805.  
  806. function appendButton(paren,value,onClick) {
  807. var input = document.createElement('input');
  808. input.type = 'button';
  809. input.className = 'mh_form_submit';
  810. input.value = value;
  811. input.onmouseover = function(){this.style.cursor='pointer';};
  812. if(onClick) input.onclick = onClick;
  813. paren.appendChild(input);
  814. return input;
  815. }
  816.  
  817. function insertButton(next,value,onClick) {
  818. var input = document.createElement('input');
  819. input.type = 'button';
  820. input.className = 'mh_form_submit';
  821. input.value = value;
  822. input.onmouseover = function(){this.style.cursor='pointer';};
  823. input.onclick = onClick;
  824. insertBefore(next,input);
  825. return input;
  826. }
  827.  
  828. function appendSubmit(paren,value,onClick) {
  829. var input = document.createElement('input');
  830. input.type = 'submit';
  831. input.className = 'mh_form_submit';
  832. input.value = value;
  833. input.onmouseover = function(){this.style.cursor='pointer';};
  834. if(onClick) input.onclick = onClick;
  835. paren.appendChild(input);
  836. return input;
  837. }
  838.  
  839. function createImage(url,title,style) {
  840. var img = document.createElement('img');
  841. img.src = url;
  842. img.title = title;
  843. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  844. if (style) img.style = style;
  845. return img;
  846. }
  847.  
  848. function createAltImage(url,alt,title) {
  849. var img = document.createElement('img');
  850. img.src = url;
  851. img.alt = alt;
  852. if (title) img.title = title;
  853. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  854. return img;
  855. }
  856.  
  857. function createImageSpan(url,alt,title,text,bold) {
  858. var span = document.createElement('span');
  859. span.title = title;
  860. var img = document.createElement('img');
  861. img.src = url;
  862. img.alt = alt;
  863. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  864. span.appendChild(img);
  865. appendText(span,text,bold);
  866. return span;
  867. }
  868.  
  869. function createCase(titre,table,width) {
  870. if(!width) width=120;
  871. var tr = appendTr(table,'mh_tdpage');
  872. var td = appendTdText(tr,titre,true);
  873. td.className = 'mh_tdtitre';
  874. td.width = width;
  875. td = appendTdText(tr,'');
  876. td.className = 'mh_tdpage';
  877. return td;
  878. }
  879.  
  880. function getMyID(e) {
  881. var parent = e.parentNode;
  882. for(var i=0 ; i<parent.childNodes.length ; i++) {
  883. if(e==parent.childNodes[i])
  884. return i;
  885. }
  886. return -1;
  887. }
  888.  
  889. function insertAfter(elt,newElt) {
  890. var id = getMyID(elt);
  891. if(id==-1) return;
  892. if(id<elt.parentNode.childNodes.length-1)
  893. insertBefore(elt.nextSibling,newElt);
  894. else
  895. elt.parentNode.appendChild(newElt);
  896. }
  897.  
  898.  
  899. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  900.  
  901. function aff(nb) {
  902. return (nb>=0) ? '+'+nb : nb;
  903. }
  904.  
  905. function getNumber(str) {
  906. var nbr = str.match(/\d+/);
  907. return nbr ? Number(nbr[0]) : Number.NaN;
  908. }
  909.  
  910. function getNumbers(str) {
  911. var nbrs = str.match(/-?\d+/g);
  912. if (!nbrs) return [];
  913. for(var i=0 ; i<nbrs.length ; i++)
  914. nbrs[i] = Number(nbrs[i]);
  915. return nbrs;
  916. }
  917.  
  918. function trim(str) {
  919. return str.replace(/(^\s*)|(\s*$)/g,'');
  920. }
  921.  
  922. String.prototype.trim = function() {
  923. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  924. }
  925.  
  926. function epure(texte) {
  927. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  928. .replace(/[ç]/g,'c')
  929. .replace(/[éêèë]/g,'e')
  930. .replace(/[ïî]/g,'i')
  931. .replace(/[ôöõ]/g,'o')
  932. .replace(/[ùûü]/g,'u');
  933. }
  934.  
  935. String.prototype.epure = function () {
  936. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  937. .replace(/[ç]/g,'c')
  938. .replace(/[éêèë]/g,'e')
  939. .replace(/[ïî]/g,'i')
  940. .replace(/[ôöõ]/g,'o')
  941. .replace(/[ùûü]/g,'u');
  942. }
  943.  
  944. function bbcode(texte) {
  945. return texte.replace(/&/g,'&amp;')
  946. .replace(/"/g,'&quot;')
  947. .replace(/</g,'&lt;')
  948. .replace(/>/g,'&gt;')
  949. .replace(/'/g,'&#146;')
  950. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  951. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  952. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  953. }
  954.  
  955.  
  956. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  957.  
  958. function addZero(i) {
  959. return (i<10) ? '0'+i : i;
  960. }
  961.  
  962. function DateToString(date) {
  963. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  964. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  965. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  966. }
  967.  
  968. function StringToDate(str) {
  969. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  970. }
  971.  
  972. // fonctionne aussi avec datetime
  973. function SQLDateToFrench(str) {
  974. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  975. }
  976.  
  977. // ... et ajoute un "à" du plus bel effet
  978. function SQLDateToFrenchTime(str) {
  979. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  980. }
  981.  
  982. // SQLDate vers objet date Javascript
  983. function SQLDateToObject(str) {
  984. var t = str.split(/[- :]/);
  985. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  986. }
  987.  
  988. var mz_ie = (window.attachEvent)? true:false;
  989. if ("function" !== typeof addEvent) {
  990. if (mz_ie) {
  991. function addEvent(obj, typ, fn, sens) {
  992. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  993. obj["e"+typ+fn]( window.event );
  994. }
  995. obj.attachEvent("on"+typ, obj[typ+fn] );
  996. }
  997. }
  998. else {
  999. function addEvent(obj, typ, fn, sens) {
  1000. obj.addEventListener(typ, fn, sens);
  1001. }
  1002. }
  1003. }
  1004.  
  1005. /**********************
  1006. * glissière en mode objet
  1007. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  1008. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  1009. *
  1010. * Usage:
  1011. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  1012. * ref : utilisé pour diversifier les IDs HTML
  1013. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  1014. * target : peut être de 3 types
  1015. * - élément HTML : l'élément HTML à zoomer
  1016. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  1017. * - function : callback quand le curseur bouge
  1018. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  1019. * dans le mode dynamique, la callback est appelée sur mouseMove
  1020. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  1021. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  1022. * autres méthodes
  1023. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  1024. **********************/
  1025.  
  1026. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  1027. try {
  1028. var mouseDown = false;
  1029. var div_gliss = document.createElement("div"); // la DIV mère
  1030. div_gliss.id = "MZ_gliss_"+ref;
  1031. var div_label = document.createElement("span"); // le label
  1032. div_label.innerHTML = labelHTML;
  1033. div_gliss.appendChild(div_label);
  1034. div_gliss.className = "choix_zoom";
  1035. var dessin = document.createElement("canvas"); // le dessin lui-même
  1036. dessin.id = "MZ_gliss_dessin_"+ref;
  1037. dessin.style.cursor = "pointer";
  1038. dessin.width = 104;
  1039. dessin.height = 12;
  1040. dessin.style.marginLeft = '2px';
  1041. dessin.style.marginRight = '2px';
  1042. div_gliss.appendChild(dessin);
  1043. var pourcent = document.createElement("span"); // le pourcentage
  1044. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1045. var pourcent_text = document.createTextNode('');
  1046. var previousVal;
  1047. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1048.  
  1049. // alignement vertical
  1050. dessin.style.verticalAlign = 'middle';
  1051. div_label.style.verticalAlign = 'middle';
  1052. pourcent.style.verticalAlign = 'middle';
  1053.  
  1054. pourcent.appendChild(pourcent_text);
  1055. div_gliss.appendChild(pourcent);
  1056.  
  1057. var bulle_pourcent = document.createElement("div"); // la bulle
  1058. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1059. bulle_pourcent.style.display = 'block';
  1060. bulle_pourcent.style.visibility = 'hidden';
  1061. bulle_pourcent.style.position = 'absolute';
  1062. bulle_pourcent.style.zIndex = 3500;
  1063. bulle_pourcent.style.border = '1px solid #a1927f';
  1064. var bulle_pourcent_text = document.createTextNode('');
  1065. bulle_pourcent.appendChild(bulle_pourcent_text);
  1066. document.body.appendChild(bulle_pourcent);
  1067.  
  1068. this.getElt = function() {return div_gliss;};
  1069.  
  1070. ////////////////////////////////////
  1071. // dessine et redessine le curseur
  1072. ////////////////////////////////////
  1073. var dessine_glissiere = function(val) {
  1074. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1075. var ctx = dessin.getContext('2d');
  1076. ctx.clearRect(0, 0,104, 12);
  1077. ctx.fillStyle = "rgb(0,0,0)";
  1078. ctx.fillRect(0,0,2,12);
  1079. ctx.fillRect(102,0,2,12);
  1080. ctx.fillRect(0,5,104,2);
  1081.  
  1082. ctx.fillStyle = "rgb(80,80,80)";
  1083. ctx.fillRect(pos_0_100,0,5,12);
  1084. ctx.fillStyle = "rgb(200,200,200)";
  1085. ctx.fillRect(pos_0_100+1,1,3,10);
  1086. pourcent_text.nodeValue = val+'%';
  1087. previousVal = parseInt(val);
  1088. };
  1089.  
  1090. ////////////////////////////////////
  1091. // action sur mousedown et mousemove
  1092. // stocker la nouvelle valeur
  1093. // redessiner
  1094. // afficher la nouvelle valeur
  1095. // action selon ce qui a été demandé
  1096. ////////////////////////////////////
  1097. var doCallback_glissiere = function (evt) {
  1098. try {
  1099. if (evt.type === 'mousedown') mouseDown = true;
  1100. if (evt.offsetX) {
  1101. var xsouris = evt.offsetX;
  1102. var xpos = evt.clientX;
  1103. var ypos = evt.clientY + document.body.scrollTop;
  1104. }
  1105. else {
  1106. var xsouris = evt.layerX;
  1107. var xpos = evt.pageX;
  1108. var ypos = evt.pageY;
  1109. }
  1110. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1111. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1112. // afficher la nouvelle valeur dans la bulle
  1113. bulle_pourcent_text.nodeValue = val + '%';
  1114. bulle_pourcent.style.top = (ypos+3)+'px';
  1115. bulle_pourcent.style.left = (xpos+16)+'px';
  1116. if (evt.buttons === undefined) {
  1117. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1118. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1119. } else {
  1120. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1121. }
  1122. // stocker la nouvelle valeur
  1123. MY_setValue("MZ_glissiere_" + ref, val);
  1124. // redessiner la glissière avec le curseur où il faut
  1125. dessine_glissiere(val);
  1126. // action selon ce qui a été demandé
  1127. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1128. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1129. if (typeof paramTarget === 'object') {
  1130. var elt = paramTarget;
  1131. } else if (typeof paramTarget === 'string') {
  1132. var elt = document.getElementById(paramTarget);
  1133. } else if (typeof paramTarget === 'function') {
  1134. paramTarget(val);
  1135. return;
  1136. }
  1137. if (elt.setZoom != undefined) elt.setZoom(val);
  1138. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1139. };
  1140.  
  1141. ////////////////////////////////////
  1142. // event mousedown et mousemove : redessiner et callback
  1143. ////////////////////////////////////
  1144. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1145. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1146. ////////////////////////////////////
  1147. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1148. ////////////////////////////////////
  1149. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1150. ////////////////////////////////////
  1151. // event mouseout & mouseover : afficher/cacher la bulle
  1152. ////////////////////////////////////
  1153. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1154. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1155.  
  1156. ////////////////////////////////////
  1157. // dessiner la première fois
  1158. ////////////////////////////////////
  1159. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1160. if (val_init === undefined) val_init = valDef;
  1161. dessine_glissiere(val_init);
  1162. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1163. }
  1164.  
  1165. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1166. // reçoit 2 objets avec des propriétés x et y
  1167. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1168. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1169. var deltaX = locArrivee.x - locDepart.x;
  1170. if (deltaX == 0) return; // pas de point intermédiaire
  1171. var deltaY = locArrivee.y - locDepart.y;
  1172. if (deltaY == 0) return; // pas de point intermédiaire
  1173. var absDeltaX = Math.abs(deltaX);
  1174. var absDeltaY = Math.abs(deltaY);
  1175. if (absDeltaX > absDeltaY) {
  1176. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1177. } else if (absDeltaY > absDeltaX) {
  1178. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1179. } else {
  1180. return; // égalité, pas de point intermédiaire
  1181. }
  1182. }
  1183.  
  1184. /**********************
  1185. * carte en mode objet
  1186. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1187. *
  1188. * Usage:
  1189. * carte = new carte_MZ(ref, tabDepl);
  1190. * ref : utilisé pour diversifier les IDs HTML
  1191. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1192. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1193. * autres méthodes
  1194. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1195. **********************/
  1196.  
  1197. function carte_MZ(ref, tabDepl) {
  1198. try {
  1199. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1200. div1_carte.id = "MZ_carte_"+ref;
  1201. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1202. div1_carte.style.backgroundImage = 'none';
  1203. div1_carte.style.backgroundColor = 'transparent';
  1204. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1205. div2_carte.className = "carte_MZ";
  1206. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1207. var dessin = document.createElement("canvas"); // le dessin lui-même
  1208. dessin.id = "MZ_carte_dessin_"+ref;
  1209. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1210. div1_carte.appendChild(div2_carte);
  1211. div2_carte.appendChild(dessin);
  1212.  
  1213. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1214. , [-66.5, -37.5, 2, 1.5, -69]
  1215. , [-63.5, 8.5, 2, 1.5, -69]
  1216. , [-59.5, -32.5, 2, 1.5, -69]
  1217. , [-52, 57, 0.25, 0.8, -59]
  1218. , [-50.5, -22.5, 2, 1.5, -69]
  1219. , [-35.5, -51.5, 2, 1.5, -69]
  1220. , [-34.5, 14.5, 2, 1.5, -69]
  1221. , [-34.5, 64.5, 2, 1.5, -69]
  1222. , [-11.5, 72.5, 2, 1.5, -69]
  1223. , [5.5, -49.5, 2, 1.5, -69]
  1224. , [5.5, 31.5, 2, 1.5, -69]
  1225. , [10.5, 63.5, 2, 1.5, -69]
  1226. , [12, -15, 0.25, 0.8, -59]
  1227. , [21.5, 35.5, 2, 1.5, -69]
  1228. , [30, -52, 0.25, 0.8, -59]
  1229. , [46.5, 51.5, 2, 1.5, -69]
  1230. , [48, -39, 0.25, 0.8, -59]
  1231. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1232. , [56.5, 23.5, 75, 8.7, -99]
  1233. , [64, 70, 0.25, 0.8, -59]
  1234. , [74.5, 31.5, 2, 1.5, -69]];
  1235.  
  1236. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1237. var couleur_cible = 'rgba(0,0,0,0.5)';
  1238. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1239. var couleur_trou = 'rgb(200,0,0)';
  1240.  
  1241. var coord_x = function(val) {
  1242. return decalh+coeff*(val+100);
  1243. };
  1244. var coord_y = function(val) {
  1245. return decalv+coeff*(100-val);
  1246. };
  1247.  
  1248. var ctx = dessin.getContext('2d');
  1249. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1250. if (coeff) coeff /= 50;
  1251. else coeff = 2;
  1252. var decalv=30, decalh=30;
  1253.  
  1254. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1255. //var res = false
  1256. var x0 = pos0.x;
  1257. var y0 = pos0.x;
  1258. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1259. var px = Math.sign(pos1.x - pos0.x);
  1260. var py = Math.sign(pos1.y - pos0.y);
  1261. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1262. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1263.  
  1264. for(var k in position_trous_MZ) {
  1265. a = parseFloat(px*px+py*py);
  1266. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1267. 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]);
  1268. delta = b*b-a*c
  1269. if(delta >= 0) {
  1270. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1271. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1272. if(t0 <= tmax && t1 >= 0) {
  1273. // 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
  1274. //res = true;
  1275. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1276. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1277. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1278. // Roule : pas utile pour nous
  1279. //res = true;
  1280. //chute.push([x0+l*px, y0+l*py]);
  1281. return true;
  1282. }
  1283. }
  1284. }
  1285. }
  1286. //return res;
  1287. return false;
  1288. };
  1289.  
  1290. var dessine_carte = function () {
  1291. dessin.width = 200*coeff+2*decalh;
  1292. dessin.height = 200*coeff+2*decalv;
  1293.  
  1294. //repere
  1295. ctx.beginPath();
  1296. ctx.moveTo(coord_x(0), coord_y(100));
  1297. ctx.lineTo(coord_x(0), coord_y(-100));
  1298. ctx.moveTo(coord_x(-100), coord_y(0));
  1299. ctx.lineTo(coord_x(100), coord_y(0));
  1300. ctx.stroke();
  1301. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1302.  
  1303. //trous
  1304. ctx.fillStyle = couleur_trou;
  1305. for(var i in position_trous_MZ) {
  1306. ctx.beginPath();
  1307. 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);
  1308. ctx.fill();
  1309. }
  1310. // trajets
  1311. ctx.lineCap = "round";
  1312. ctx.lineJoin = "round";
  1313. for (var iSuivant in tabDepl) {
  1314. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1315. var tabDeplOneSuivant = tabDepl[iSuivant];
  1316. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1317. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1318. // La "cible" au départ
  1319. var typeDepart = tabDeplOneSuivant[0].typ;
  1320. switch (typeDepart) {
  1321. case 'tp':
  1322. ctx.beginPath();
  1323. ctx.lineWidth = 2;
  1324. ctx.strokeStyle = couleur_cible;
  1325. ctx.fillStyle = couleur_cible;
  1326. ctx.moveTo(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.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1330. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1331. ctx.moveTo(x0 + coeff * 3, y0);
  1332. ctx.lineTo(x0 - coeff * 3, y0);
  1333. ctx.moveTo(x0, y0 + coeff * 3);
  1334. ctx.lineTo(x0, y0 - coeff * 3);
  1335. ctx.stroke();
  1336. break;
  1337. default:
  1338. ctx.beginPath();
  1339. ctx.lineWidth = 1;
  1340. ctx.strokeStyle = couleur_cible;
  1341. ctx.fillStyle = couleur_cible;
  1342. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1343. ctx.moveTo(x0 + coeff * 4, y0);
  1344. ctx.lineTo(x0 - coeff * 4, y0);
  1345. ctx.moveTo(x0, y0 + coeff * 4);
  1346. ctx.lineTo(x0, y0 - coeff * 4);
  1347. ctx.stroke();
  1348. break;
  1349. }
  1350. // les segments
  1351. var nb_pts = tabDeplOneSuivant.length;
  1352. var pointPrecedent = tabDeplOneSuivant[0];
  1353. for (var i=1; i<nb_pts; i++) {
  1354. ctx.beginPath();
  1355. ctx.lineWidth = coeff;
  1356. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1357. ctx.strokeStyle = couleur_depl_normal;
  1358. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1359. if (pointIntermediaire === undefined) {
  1360. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1361. ctx.strokeStyle = couleur_depl_collision_trou;
  1362. else
  1363. ctx.strokeStyle = couleur_depl_normal;
  1364. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1365. } else {
  1366. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1367. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1368. ctx.strokeStyle = couleur_depl_collision_trou;
  1369. else
  1370. ctx.strokeStyle = couleur_depl_normal;
  1371. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1372. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1373. }
  1374. pointPrecedent = tabDeplOneSuivant[i];
  1375. ctx.stroke();
  1376. }
  1377. // Les points à chaque étape
  1378. ctx.fillStyle = couleur_depl_normal;
  1379. for (var i=1; i<nb_pts; i++) {
  1380. ctx.beginPath();
  1381. var x = coord_x(tabDeplOneSuivant[i].x);
  1382. var y = coord_y(tabDeplOneSuivant[i].y);
  1383. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1384. ctx.fill();
  1385. }
  1386. }
  1387. }
  1388.  
  1389. this.setZoom = function (val) {
  1390. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1391. coeff = val / 50;
  1392. dessine_carte();
  1393. }
  1394.  
  1395. // glissiere
  1396. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1397. var eGliss = gliss.getElt();
  1398. eGliss.style.position = 'absolute';
  1399. eGliss.style.top = (coeff * 2) + 'px';
  1400. eGliss.style.left = decalh + 'px';
  1401. dessin.style.position = 'relative';
  1402. div2_carte.style.position = 'relative';
  1403. eGliss.style.zIndex = 9000;
  1404. div2_carte.appendChild(eGliss);
  1405.  
  1406. // affichage au survol de la souris
  1407. var bulle = document.createElement('div');
  1408. bulle.style.visibility = 'hidden';
  1409. bulle.style.position = 'absolute';
  1410. bulle.style.zIndex = 3100;
  1411. bulle.style.border = 'solid 1px #a1927f';
  1412. bulle.className = 'mh_tdpage';
  1413. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1414. var bulleHaut = document.createElement('div');
  1415. bulleHaut.style.display = 'block';
  1416. bulleHaut.style.paddingRight = '3px';
  1417. bulleHaut.className = 'mh_tdtitre';
  1418. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1419. bulle.appendChild(bulleHaut);
  1420. var bulleBas = document.createElement('div');
  1421. bulleBas.style.display = 'block';
  1422. bulleBas.style.whiteSpace = "nowrap";
  1423. bulleBas.style.paddingRight = '3px';
  1424.  
  1425. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1426. bulle.appendChild(bulleBas);
  1427. div2_carte.appendChild(bulle);
  1428. var affichePosition = function(evt) {
  1429. if (evt.offsetX) {
  1430. var xsouris = evt.offsetX;
  1431. var ysouris = evt.offsetY;
  1432. var xpos = evt.clientX;
  1433. var ypos = evt.clientY + document.body.scrollTop;
  1434. }
  1435. else {
  1436. var xsouris = evt.layerX;
  1437. var ysouris = evt.layerY;
  1438. var xpos = evt.pageX;
  1439. var ypos = evt.pageY;
  1440. }
  1441. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1442. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1443. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1444. var tabHTMLbas = [];
  1445. // message pour les trous
  1446. for (var i in position_trous_MZ) {
  1447. var ceTrou = position_trous_MZ[i];
  1448. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1449. if(dist <= 0) {
  1450. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1451. break;
  1452. }
  1453. }
  1454. // messages pour les suivants
  1455. for (var i in tabDepl) {
  1456. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1457. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1458. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1459. }
  1460. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1461. bulle.style.top = (ysouris+8) + 'px';
  1462. bulle.style.left = (xsouris+16) + 'px';
  1463. };
  1464. addEvent(dessin, "mousemove", affichePosition, true);
  1465. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1466. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1467.  
  1468. // dessin initial
  1469. dessine_carte();
  1470.  
  1471. this.getElt = function() {return div1_carte;};
  1472.  
  1473. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1474. }
  1475.  
  1476.  
  1477. /**********************************************************
  1478. **** Fin de zone à déplacer dans une bibli commune ********
  1479. **********************************************************/
  1480.  
  1481. /* DEBUG: NETTOYAGE TAGS */
  1482. if(MY_getValue(numTroll+'.TAGSURL')) {
  1483. MY_removeValue(numTroll+'.TAGSURL');
  1484. }
  1485.  
  1486. // Alerte si mode dev
  1487. if (isDEV) {
  1488. var divpopup = document.createElement('div');
  1489. divpopup.id = 'divDEV';
  1490. divpopup.style =
  1491. 'position: fixed;'+
  1492. 'border: 15px solid red;'+
  1493. 'top: 10px;right: 10px;'+
  1494. 'background-color: white;'+
  1495. 'color: black;'+
  1496. 'font-size: large;'+
  1497. 'padding: 5px'+
  1498. 'z-index: 200;';
  1499. appendText(divpopup, '[MZ] Mode DEV');
  1500. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1501. document.body.appendChild(divpopup);
  1502. }
  1503.  
  1504. /*---------- regroupement des getPortee() ------------------------------------*/
  1505. // issu des script profil et profil2
  1506. function getPortee__Profil(param) {
  1507. param = Math.max(0,Number(param));
  1508. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1509. // ça devrait être floor, +10.25, -2.5
  1510. }
  1511.  
  1512. // issu du script vue
  1513. function getPortee__Vue(param) {
  1514. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1515. }
  1516.  
  1517.  
  1518. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1519.  
  1520. function getPXKill(niv) {
  1521. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1522. return Math.max(0,10+3*niv-2*nivTroll);
  1523. }
  1524.  
  1525. function getPXDeath(niv) {
  1526. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1527. return Math.max(0,10+3*nivTroll-2*niv);
  1528. }
  1529.  
  1530. function analysePX(niv) {
  1531. niv = niv+'';
  1532. var i = niv.indexOf('+');
  1533. if(i!=-1) // si niv = 'XX+' ??
  1534. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1535. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1536. if(i!=-1) {
  1537. var max = getPXKill(niv.slice(i+2));
  1538. if(max==0)
  1539. return ' --> <b>0</b> PX';
  1540. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1541. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1542. }
  1543. i = niv.indexOf('='); // ???
  1544. if(i!=-1) {
  1545. var max = getPXKill(niv.slice(i+1));
  1546. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1547. }
  1548. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1549. }
  1550.  
  1551. function analysePXTroll(niv) {
  1552. var str = analysePX(niv);
  1553. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1554. return str;
  1555. }
  1556.  
  1557.  
  1558. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1559. // Refonte totale du code de Zorya
  1560.  
  1561. // Elements à implémenter en dur dans MZ2.0
  1562. var numQualite = {
  1563. 'Très Mauvaise':1,
  1564. 'Mauvaise':2,
  1565. 'Moyenne':3,
  1566. 'Bonne':4,
  1567. 'Très Bonne':5
  1568. };
  1569.  
  1570. var qualiteNum = [
  1571. '_dummy_',
  1572. 'Très Mauvaise',
  1573. 'Mauvaise',
  1574. 'Moyenne',
  1575. 'Bonne',
  1576. 'Très Bonne'
  1577. ];
  1578.  
  1579. var nival = {
  1580. 'Abishaii Bleu':19,
  1581. 'Abishaii Noir':10,
  1582. 'Abishaii Rouge':23,
  1583. 'Abishaii Vert':15,
  1584. 'Ame-en-peine':8,
  1585. 'Amibe Geante':9,
  1586. 'Anaconda des Catacombes':8,
  1587. 'Ankheg':10,
  1588. 'Anoploure Purpurin':36,
  1589. 'Araignee Geante':2,
  1590. 'Ashashin':35,
  1591. 'Balrog':50,
  1592. 'Banshee':16,
  1593. 'Barghest':36,
  1594. 'Basilisk':11,
  1595. 'Behemoth':34,
  1596. 'Behir':14,
  1597. 'Beholder':50,
  1598. 'Boggart':3,
  1599. 'Bondin':9,
  1600. "Bouj'Dla Placide":37,
  1601. "Bouj'Dla":19,
  1602. 'Bulette':19,
  1603. 'Caillouteux':1,
  1604. 'Capitan':35,
  1605. 'Carnosaure':25,
  1606. 'Champi-Glouton':3,
  1607. 'Chauve-Souris Geante':4,
  1608. 'Cheval a Dents de Sabre':23,
  1609. 'Chevalier du Chaos':20,
  1610. 'Chimere':13,
  1611. 'Chonchon':24,
  1612. 'Coccicruelle':22,
  1613. 'Cockatrice':5,
  1614. 'Crasc Medius':17,
  1615. 'Crasc Maexus':25,
  1616. 'Crasc':10,
  1617. 'Croquemitaine':6,
  1618. 'Cube Gelatineux':32,
  1619. 'Daemonite':27,
  1620. 'Diablotin':5,
  1621. 'Dindon du Chaos':1,
  1622. 'Djinn':29,
  1623. 'Ectoplasme':18,
  1624. 'Effrit':27,
  1625. "Elementaire d'Air":23,
  1626. "Elementaire d'Eau":17,
  1627. 'Elementaire de Feu':21,
  1628. 'Elementaire de Terre':21,
  1629. 'Elementaire du Chaos':26,
  1630. 'Erinyes':7,
  1631. 'Esprit-Follet':16,
  1632. 'Essaim Craterien':30,
  1633. 'Essaim Sanguinaire':25,
  1634. 'Ettin':8,
  1635. 'Familier':1,
  1636. 'Fantome':24,
  1637. 'Feu Follet':20,
  1638. 'Flagelleur Mental':33,
  1639. 'Foudroyeur':38,
  1640. 'Fumeux':22,
  1641. 'Fungus Geant':9,
  1642. 'Fungus Violet':4,
  1643. 'Furgolin':10,
  1644. 'Gargouille':3,
  1645. 'Geant de Pierre':13,
  1646. 'Geant des Gouffres':22,
  1647. "Geck'oo Majestueux":40,
  1648. "Geck'oo":15,
  1649. 'Glouton':20,
  1650. 'Gnoll':5,
  1651. 'Gnu Domestique':1,
  1652. 'Gnu Sauvage':1,
  1653. 'Goblin':4,
  1654. 'Goblours':4,
  1655. "Golem d'Argile":15,
  1656. 'Golem de cuir':1,
  1657. 'Golem de Chair':8,
  1658. 'Golem de Fer':31,
  1659. 'Golem de mithril':1,
  1660. 'Golem de metal':1,
  1661. 'Golem de papier':1,
  1662. 'Golem de Pierre':23,
  1663. 'Gorgone':11,
  1664. 'Goule':4,
  1665. 'Gowap Apprivoise':1,
  1666. 'Gowap Sauvage':1,
  1667. 'Gremlins':3,
  1668. 'Gritche':39,
  1669. 'Grouilleux':4,
  1670. 'Grylle':31,
  1671. 'Harpie':4,
  1672. 'Hellrot':18,
  1673. 'Homme-Lezard':4,
  1674. 'Hurleur':8,
  1675. 'Hydre':50,
  1676. 'Incube':13,
  1677. 'Kobold':2,
  1678. 'Labeilleux':26,
  1679. 'Lezard Geant':5,
  1680. 'Liche':50,
  1681. 'Limace Geante':10,
  1682. 'Loup-Garou':8,
  1683. 'Lutin':4,
  1684. 'Mante Fulcreuse':30,
  1685. 'Manticore':9,
  1686. 'Marilith':33,
  1687. 'Meduse':6,
  1688. 'Megacephale':38,
  1689. 'Mille-Pattes Geant':14,
  1690. 'Mimique':6,
  1691. 'Minotaure':7,
  1692. 'Molosse Satanique':8,
  1693. 'Momie':4,
  1694. 'Monstre Rouilleur':3,
  1695. "Mouch'oo Domestique":14,
  1696. "Mouch'oo Majestueux Sauvage":33,
  1697. "Mouch'oo Sauvage":14,
  1698. 'Na-Haniym-Heee':0,
  1699. 'Necrochore':37,
  1700. 'Necromant':39,
  1701. 'Necrophage':8,
  1702. 'Naga':10,
  1703. 'Nuee de Vermine':13,
  1704. "Nuage d'Insectes":7,
  1705. 'Ogre':7,
  1706. 'Ombre de Roches':13,
  1707. 'Ombre':2,
  1708. 'Orque':3,
  1709. 'Ours-Garou':18,
  1710. 'Palefroi Infernal':29,
  1711. 'Phoenix':32,
  1712. 'Pititabeille':0,
  1713. 'Plante Carnivore':4,
  1714. 'Pseudo-Dragon':5,
  1715. 'Rat Geant':2,
  1716. 'Rat-Garou':3,
  1717. 'Rocketeux':5,
  1718. 'Sagouin':3,
  1719. 'Scarabee Geant':4,
  1720. 'Scorpion Geant':10,
  1721. 'Shai':28,
  1722. 'Sirene':8,
  1723. 'Slaad':5,
  1724. 'Sorciere':17,
  1725. 'Spectre':14,
  1726. 'Sphinx':30,
  1727. 'Squelette':1,
  1728. 'Strige':2,
  1729. 'Succube':13,
  1730. 'Tertre Errant':20,
  1731. 'Thri-kreen':10,
  1732. 'Tigre-Garou':12,
  1733. 'Titan':26,
  1734. 'Trancheur':35,
  1735. 'Tubercule Tueur':14,
  1736. 'Tutoki':4,
  1737. 'Vampire':29,
  1738. 'Ver Carnivore Geant':12,
  1739. 'Ver Carnivore':11,
  1740. 'Veskan Du Chaos':14,
  1741. 'Vouivre':33,
  1742. 'Worg':5,
  1743. 'Xorn':14,
  1744. 'Yeti':8,
  1745. 'Yuan-ti':15,
  1746. 'Zombie':2
  1747. }
  1748.  
  1749. var tabEM = {
  1750. //Monstre: [Compo exact, Sort, Position, Localisation]
  1751. // AA
  1752. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1753. // AE
  1754. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1755. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1756. // AdA
  1757. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1758. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1759. // AdE
  1760. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1761. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1762. // AdD
  1763. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1764. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1765. // BAM
  1766. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1767. // BuM
  1768. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1769. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1770. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1771. // Explo
  1772. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1773. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1774. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1775. // FP
  1776. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1777. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1778. // FA
  1779. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1780. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1781. // Glue
  1782. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1783. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1784. // GdS
  1785. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1786. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1787. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1788. // Invi
  1789. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1790. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1791. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1792. // Lévitation
  1793. // ???
  1794. // PréM :
  1795. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1796. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1797. // Proj
  1798. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1799. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1800. // PuM :
  1801. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1802. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1803. // Sacro
  1804. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1805. // Télék
  1806. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1807. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1808. // TP
  1809. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1810. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1811. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1812. // VA
  1813. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1814. // VL
  1815. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1816. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1817. // VlC
  1818. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1819. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1820. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1821. // VT
  1822. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1823. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1824. // Variables
  1825. 'Rat':["d'un"],
  1826. 'Rat Géant':["d'un"],
  1827. 'Dindon':["d'un"],
  1828. 'Goblin':["d'un"],
  1829. 'Limace':["d'une"],
  1830. 'Limace Géante':["d'une"],
  1831. 'Ver':["d'un"],
  1832. 'Ver Carnivore':["d'un"],
  1833. 'Ver Carnivore Géant':["d'un"],
  1834. 'Fungus':["d'un"],
  1835. 'Vouivre':["d'une"],
  1836. 'Gnu':["d'un"],
  1837. 'Scarabée':["d'un"]
  1838. };
  1839.  
  1840. var mundiChampi = {
  1841. 'Préscientus Reguis':'du Phoenix',
  1842. 'Amanite Trolloïde':'de la Mouche',
  1843. 'Girolle Sanglante':'du Dindon',
  1844. 'Horreur Des Prés':'du Gobelin',
  1845. 'Bolet Péteur':'du Démon',
  1846. 'Pied Jaune':'de la Limace',
  1847. 'Agaric Sous-Terrain':'du Rat',
  1848. 'Suinte Cadavre':"de l'Hydre",
  1849. 'Cèpe Lumineux':'du Ver',
  1850. 'Fungus Rampant':'du Fungus',
  1851. 'Nez Noir':'de la Vouivre',
  1852. 'Pleurote Pleureuse':'du Gnu',
  1853. 'Phytomassus Xilénique':'du Scarabée'
  1854. };
  1855.  
  1856. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1857. appendText(node,' ');
  1858. var urlImg = URL_MZimg
  1859. +'Competences/melangeMagique.png';
  1860. var text = ' [-'+(niv+effetQ)+' %]';
  1861. var str = '';
  1862. switch(mob[0]) {
  1863. case 'A':
  1864. case 'E':
  1865. case 'I':
  1866. case 'O':
  1867. case 'U':
  1868. str = "Compo d'";
  1869. break;
  1870. default:
  1871. str = 'Compo de ';
  1872. }
  1873. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1874. var span = createImageSpan(urlImg,'MM:',title,text);
  1875. node.appendChild(span);
  1876. }
  1877. function addInfoEM(node,mob,compo,qualite,localisation) {
  1878. if(!tabEM[mob]) return;
  1879. var title = 'Composant variable', texte = 'Variable';
  1880. var bold = false;
  1881. if(tabEM[mob].length>1) {
  1882. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1883. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1884. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1885. if(pc<-20) return;
  1886. if(pc>=0) bold = true;
  1887. texte = aff(pc)+'%';
  1888. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1889. }
  1890. var urlImg = URL_MZimg
  1891. +'Competences/ecritureMagique.png';
  1892. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1893. node.appendChild(span);
  1894. }
  1895.  
  1896. function insererInfosEM(tbody) {
  1897. // lancé par equip, equipgowap
  1898. var trCompos = document.evaluate(
  1899. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1900. tbody,null,7,null);
  1901. var strCompos = '';
  1902. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1903. var node = trCompos.snapshotItem(i).childNodes[7];
  1904. var str = node.firstChild.textContent;
  1905. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1906. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1907. // Si non-EM on stoppe le traitement
  1908. if(!tabEM[mob]) continue;
  1909. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1910. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1911. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1912. addInfoEM(node,mob,compo,qualite,localisation);
  1913. }
  1914. }
  1915.  
  1916. function getQualite(qualite) {
  1917. var nb = numQualite[qualite];
  1918. return nb ? nb-1 : -1;
  1919. }
  1920.  
  1921. function getEM(nom) {
  1922. if(nom.indexOf('[')!=-1)
  1923. nom = trim(nom.substring(0,nom.indexOf('[')));
  1924. if(tabEM[nom]) return nom;
  1925. return '';
  1926. }
  1927.  
  1928. // DEBUG ex-fonction composantEM
  1929. function compoMobEM(mob) {
  1930. if(!tabEM[mob]) return '';
  1931. if(tabEM[mob].length==1)
  1932. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1933. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1934. +") pour l'écriture de "+tabEM[mob][1];
  1935. }
  1936.  
  1937. // DEBUG ex-fonction compoEM
  1938. function titreCompoEM(mob,compo,localisation,qualite) {
  1939. if(!tabEM[mob]) return '';
  1940. if(tabEM[mob].length==1) return 'Composant variable';
  1941. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1942. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1943. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1944. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1945. return '';
  1946. }
  1947.  
  1948. // DEBUG - rétrocompatibilité
  1949. function compoEM(mob) {
  1950. // appelé dans libs, vue
  1951. return compoMobEM(mob);
  1952. }
  1953. function composantEM(mob,compo,localisation,qualite) {
  1954. // appelé dans libs, tancompo
  1955. return titreCompoEM(mob,compo,localisation,qualite);
  1956. }
  1957. //
  1958.  
  1959.  
  1960. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1961.  
  1962. arrayTalents = {
  1963. /* Compétences */
  1964. 'Acceleration du Metabolisme':'AM',
  1965. 'Attaque Precise':'AP',
  1966. 'Balayage':'Balayage',
  1967. //'Balluchonnage':'Ballu',
  1968. 'Baroufle':'Baroufle',
  1969. 'Bidouille':'Bidouille',
  1970. 'Botte Secrete':'BS',
  1971. 'Camouflage':'Camou',
  1972. 'Charger':'Charger',
  1973. 'Connaissance des Monstres':'CdM',
  1974. 'Construire un Piege':'Piege',
  1975. 'Piege a Feu':'PiegeFeu',
  1976. 'Piege a Glue':'PiegeGlue',
  1977. 'Contre-Attaquer':'CA',
  1978. 'Coup de Butoir':'CdB',
  1979. 'Course':'Course',
  1980. 'Deplacement Eclair':'DE',
  1981. 'Dressage':'Dressage',
  1982. 'Ecriture Magique':'EM',
  1983. 'Frenesie':'Frenesie',
  1984. 'Golemologie':'Golemo',
  1985. 'Golem de cuir':'GolemCuir',
  1986. 'Golem de metal':'GolemMetal',
  1987. 'Golem de mithril':'GolemMithril',
  1988. 'Golem de papier':'GolemPapier',
  1989. 'Grattage':'Grattage',
  1990. 'Hurlement Effrayant':'HE',
  1991. 'Identification des Champignons':'IdC',
  1992. 'Insultes':'Insultes',
  1993. 'Lancer de Potions':'LdP',
  1994. 'Marquage':'Marquage',
  1995. 'Melange Magique':'Melange',
  1996. 'Miner':'Miner',
  1997. 'Travail de la pierre':'Pierre',
  1998. 'Necromancie':'Necro',
  1999. 'Painthure de Guerre':'PG',
  2000. 'Parer':'Parer',
  2001. 'Pistage':'Pistage',
  2002. 'Planter un Champignon':'PuC',
  2003. 'Regeneration Accrue':'RA',
  2004. 'Reparation':'Reparation',
  2005. 'Retraite':'Retraite',
  2006. 'RotoBaffe':'RB',
  2007. 'Shamaner':'Shamaner',
  2008. "S'interposer":'SInterposer',
  2009. 'Tailler':'Tailler',
  2010. //'Vol':'Vol',
  2011. /* Sortilèges */
  2012. 'Analyse Anatomique':'AA',
  2013. 'Armure Etheree':'AE',
  2014. 'Augmentation de l´Attaque':'AdA', // obsolète?
  2015. "Augmentation de l'Attaque":'AdA',
  2016. 'Augmentation de l´Esquive':'AdE',
  2017. 'Augmentation des Degats':'AdD',
  2018. 'Bulle Anti-Magie':'BAM',
  2019. 'Bulle Magique':'BuM',
  2020. 'Explosion':'Explo',
  2021. 'Faiblesse Passagere':'FP',
  2022. 'Flash Aveuglant':'FA',
  2023. 'Glue':'Glue',
  2024. 'Griffe du Sorcier':'GdS',
  2025. 'Hypnotisme':'Hypno',
  2026. 'Identification des tresors':'IdT',
  2027. 'Invisibilite':'Invi',
  2028. 'Levitation':'Levitation',
  2029. 'Precision Magique':'PreM',
  2030. 'Projectile Magique':'Projo',
  2031. 'Projection':'Proj',
  2032. 'Puissance Magique':'PuM',
  2033. 'Rafale Psychique':'Rafale',
  2034. 'Sacrifice':'Sacro',
  2035. 'Siphon des ames':'Siphon',
  2036. 'Telekinesie':'Telek',
  2037. 'Teleportation':'TP',
  2038. 'Vampirisme':'Vampi',
  2039. 'Vision Accrue':'VA',
  2040. 'Vision lointaine':'VL',
  2041. 'Voir le Cache':'VlC',
  2042. 'Vue Troublee':'VT'
  2043. //'':''
  2044. }
  2045.  
  2046. // DEBUG - Pour rétrocompatibilité
  2047. function getSortComp(nom,niveau) {
  2048. return getTalent(nom,niveau);
  2049. }
  2050. //
  2051.  
  2052. function getTalent(nom,niveau) {
  2053. if(nom===true) return true;
  2054. var nomEnBase = arrayTalents[epure(nom)];
  2055. if(!nomEnBase) nomEnBase=nom;
  2056. if(!niveau) var niveau = '';
  2057. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2058. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  2059. return 0;
  2060. }
  2061.  
  2062. function removeAllTalents() {
  2063. for(var talent in arrayTalents) {
  2064. var nomEnBase = arrayTalents[talent];
  2065. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2066. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2067. continue;
  2068. }
  2069. var niveau = 1;
  2070. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2071. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2072. niveau++;
  2073. }
  2074. }
  2075. }
  2076.  
  2077. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2078. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2079. var att = MY_getValue(numTroll+'.caracs.attaque');
  2080. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2081. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2082. var mm = MY_getValue(numTroll+'.caracs.mm');
  2083. var deg = MY_getValue(numTroll+'.caracs.degats');
  2084. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2085. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2086. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2087. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2088. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2089. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2090. return false;
  2091. return true;
  2092. } catch(e) {
  2093. return false;
  2094. }
  2095. }
  2096.  
  2097.  
  2098. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2099.  
  2100. function getPVsRestants(pv,bless,vue) {
  2101. bless = Number(bless.match(/\d+/)[0]);
  2102. if(bless==0) return null;
  2103. var pvminmax = pv.match(/\d+/g);
  2104. if(bless==95) {
  2105. var pvb = 1;
  2106. var pvh = Math.floor( pvminmax[1]/20 );
  2107. }
  2108. else if(bless==5) {
  2109. var pvb = Math.floor( pvminmax[0]*19/20 );
  2110. var pvh = pvminmax[1];
  2111. }
  2112. else {
  2113. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2114. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2115. }
  2116. return vue ? ' ('+pvb+'-'+pvh+')' :
  2117. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2118. }
  2119.  
  2120. function insertButtonCdm(nextName,onClick,texte) {
  2121. if(texte==null) texte = 'Participer au bestiaire';
  2122. var nextNode = document.getElementsByName(nextName)[0];
  2123.  
  2124. var espace = document.createTextNode('\t');
  2125. insertBefore(nextNode,espace);
  2126.  
  2127. var button = document.createElement('input');
  2128. button.type = 'button';
  2129. button.className = 'mh_form_submit';
  2130. button.value = texte;
  2131. button.onmouseover = function(){this.style.cursor='pointer';};
  2132. if(onClick) button.onclick = onClick;
  2133. insertBefore(espace,button);
  2134. return button;
  2135. }
  2136.  
  2137. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  2138. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  2139. 'Capacité spéciale','Résistance Magique','Autres'];
  2140.  
  2141. /* appelé par
  2142. createCDMTable (dans le popup DcM)
  2143. computeTactique (à coté du nom des monstres dans la vue et dans la page de détail des monstres)
  2144. */
  2145. function createImageTactique(url,id,nom) {
  2146. var img = document.createElement('img');
  2147. img.src = url;
  2148. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  2149. img.id = id;
  2150. img.nom = nom;
  2151. img.onmouseover = showPopupTactique;
  2152. img.onmouseout = hidePopup;
  2153. return img;
  2154. }
  2155.  
  2156. function createCDMTable(id,nom,donneesMonstre) {
  2157. try {
  2158. var urlImg = URL_MZimg;
  2159. var table = document.createElement('table');
  2160. var profilActif = isProfilActif();
  2161. table.className = 'mh_tdborder';
  2162. table.border = 0;
  2163. table.cellSpacing = 1;
  2164. table.cellPadding = 4;
  2165. var thead = document.createElement('thead');
  2166. var tr = appendTr(thead,'mh_tdtitre');
  2167. var td = appendTdText(tr,
  2168. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  2169. true
  2170. );
  2171. td.colSpan = 2;
  2172. table.appendChild(thead);
  2173. var tbody = document.createElement('tbody');
  2174. table.appendChild(tbody);
  2175. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  2176. createCase(listeTitres[i],tbody,80);
  2177. }
  2178. var TypeMonstre = getEM(nom);
  2179. var infosCompo='';
  2180. if(TypeMonstre!='') {
  2181. infosCompo = compoEM(TypeMonstre);
  2182. }
  2183. var nodes = tbody.childNodes;
  2184. nodes[0].childNodes[1].innerHTML =
  2185. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  2186. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  2187. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  2188. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  2189. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  2190. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  2191. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  2192. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  2193. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  2194. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  2195. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  2196. td = createCase(listeTitres[10],tbody);
  2197. td.innerHTML = bbcode(donneesMonstre[10]);
  2198. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2199. td.appendChild(document.createTextNode(" "));
  2200. if(donneesMonstre[16] == "De zone")
  2201. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2202. else if(donneesMonstre[16] == "Automatique")
  2203. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2204. else if(donneesMonstre[16] == "Au toucher")
  2205. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2206. }
  2207. }
  2208. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2209. {
  2210. td = createCase(listeTitres[11],tbody);
  2211. td.innerHTML = bbcode(donneesMonstre[9]);
  2212. // seuil de résistance du monstre
  2213. var lb = td.getElementsByTagName('b');
  2214. if(lb.length == 1) {
  2215. var mrm = lb[0].firstChild.nodeValue * 1;
  2216. var v = (mrm / mmTroll);
  2217. lb[0].firstChild.nodeValue += " ("
  2218. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2219. }
  2220. }
  2221. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2222. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2223. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2224. {
  2225. td = createCase(listeTitres[12],tbody);
  2226. if(donneesMonstre[12]==1)
  2227. {
  2228. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2229. }
  2230. if(donneesMonstre[13]==1)
  2231. {
  2232. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2233. }
  2234. else if(donneesMonstre[13]==0)
  2235. {
  2236. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2237. }
  2238. if(donneesMonstre[14]==1)
  2239. {
  2240. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2241. }
  2242. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2243. {
  2244. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2245. }
  2246. else if(donneesMonstre[14]>6)
  2247. {
  2248. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2249. }
  2250. if(donneesMonstre[15]=="Lente")
  2251. {
  2252. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2253. }
  2254. else if(donneesMonstre[15]=="Normale")
  2255. {
  2256. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2257. }
  2258. else if(donneesMonstre[15]=="Rapide")
  2259. {
  2260. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2261. }
  2262. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2263. {
  2264. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2265. }
  2266. if(infosCompo.length>0)
  2267. {
  2268. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2269. }
  2270. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2271. {
  2272. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2273. }
  2274. }
  2275. // pourcentage de blessure
  2276. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2277. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2278. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2279. if(pvs)
  2280. lb[0].firstChild.nodeValue += pvs;
  2281. }
  2282. return table;
  2283. }
  2284. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2285. }
  2286.  
  2287.  
  2288. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2289.  
  2290. var listeMonstreEnchantement = null,
  2291. listeEquipementEnchantement = null,
  2292. listeInfoEnchantement = null;
  2293.  
  2294. function computeCompoEnchantement()
  2295. {
  2296. listeMonstreEnchantement = new Array();
  2297. listeInfoEnchantement = new Array();
  2298. listeEquipementEnchantement = new Array();
  2299. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2300. for(var i=0;i<liste.length;i++)
  2301. {
  2302. var idEquipement = liste[i]*1;
  2303. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2304. continue;
  2305. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2306. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2307. var texteGlobal='';
  2308. for(var j=0;j<3;j++)
  2309. {
  2310. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2311. var v = MY_getValue(k);
  2312. var infoComposant = MY_getValue().split(';');
  2313. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2314. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2315. continue;
  2316. }
  2317. listeMonstreEnchantement[infoComposant[2]] = 1;
  2318. var array = new Array();
  2319. array[0]=infoComposant[0].replace("Ril","Œil");
  2320. array[1]=infoComposant[1];
  2321. array[2]=infoComposant[2];
  2322. array[3]=getQualite(infoComposant[3]);
  2323. var texte = infoComposant[4].replace("Ril","Œil");
  2324. for(var k=5;k<infoComposant.length;k++)
  2325. {
  2326. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2327. }
  2328. texteGlobal+=texte+'\n';
  2329. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2330. array[4]=texte;
  2331. listeInfoEnchantement.push(array);
  2332. }
  2333. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2334. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2335. }
  2336. }
  2337.  
  2338. function isEnchant(nom) {
  2339. var monstreEnchant = '';
  2340. for(j in listeInfoEnchantement) {
  2341. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2342. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2343. monstreEnchant=monstre;
  2344. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2345. }
  2346. }
  2347. return trim(monstreEnchant);
  2348. }
  2349.  
  2350. function getInfoEnchantementFromMonstre(nom)
  2351. {
  2352. try
  2353. {
  2354. if(!listeMonstreEnchantement)
  2355. {
  2356. computeCompoEnchantement();
  2357. }
  2358. var infosEnchant = '';
  2359. for(j in listeInfoEnchantement) {
  2360. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2361. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2362. if(infosEnchant=='')
  2363. infosEnchant=listeInfoEnchantement[j][4];
  2364. else
  2365. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2366. }
  2367. }
  2368. return trim(infosEnchant);
  2369. }
  2370. catch(e)
  2371. {
  2372. window.alert(e);
  2373. }
  2374. }
  2375.  
  2376. function composantEnchant(Monstre,composant,localisation,qualite) {
  2377. var compo='';
  2378. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2379. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2380. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2381. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2382. listeInfoEnchantement[i][3]<=qualite
  2383. ) {
  2384. return listeInfoEnchantement[i][4];
  2385. }
  2386. }
  2387. return compo;
  2388. }
  2389.  
  2390. function insertEnchantInfos(tbody) {
  2391. try
  2392. {
  2393. if(!listeMonstreEnchantement)
  2394. computeCompoEnchantement();
  2395. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2396. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2397. if(nodes.snapshotLength == 0)
  2398. return false;
  2399. var urlImg = URL_MZimg + 'enchant.png';
  2400. for(var i = 0; i < nodes.snapshotLength; i++) {
  2401. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2402. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2403. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2404. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2405. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2406. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2407. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2408. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2409. if(isEnchant(nomMonstre).length>0)
  2410. {
  2411. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2412. if(infos.length>0)
  2413. {
  2414. if(link.parentNode == link.nextSibling.parentNode)
  2415. {
  2416. var tmp = link.nextSibling;
  2417. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2418. }
  2419. else
  2420. {
  2421. link.parentNode.appendChild(createImage(urlImg,infos));
  2422. }
  2423. }
  2424. }
  2425. }
  2426. }
  2427. catch(e)
  2428. {
  2429. window.alert(e);
  2430. }
  2431. }
  2432.  
  2433. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2434. {
  2435. try
  2436. {
  2437. if(!listeMonstreEnchantement)
  2438. computeCompoEnchantement();
  2439. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2440. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2441. if(nodes.snapshotLength == 0)
  2442. return false;
  2443. var urlImg = URL_MZimg + 'enchant.png';
  2444. for(var i = 0; i < nodes.snapshotLength; i++)
  2445. {
  2446. var link = nodes.snapshotItem(i);
  2447. var idEquipement = link.getAttribute('href');
  2448. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2449. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2450. var nomEquipement = trim(link.firstChild.nodeValue);
  2451. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2452. if(!enchanteur || enchanteur == '')
  2453. continue;
  2454. var infos = listeEquipementEnchantement[idEquipement];
  2455. infos=formateTexte(infos);
  2456. if(infos.length>0)
  2457. {
  2458. if(link.parentNode == link.nextSibling.parentNode)
  2459. {
  2460. var tmp = link.nextSibling;
  2461. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2462. }
  2463. else
  2464. {
  2465. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2466. }
  2467. }
  2468. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2469. }
  2470. }
  2471. catch(e)
  2472. {
  2473. window.alert(e);
  2474. }
  2475. }
  2476.  
  2477. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2478.  
  2479.  
  2480. // Les % de toucher
  2481. var c = new Array();
  2482.  
  2483. // coefficients binomiaux
  2484. function cnp(n,k)
  2485. {
  2486. if(c[n] != null && c[n][k] != null)
  2487. return c[n][k];
  2488. if(c[n] == null)
  2489. c[n] = new Array();
  2490. if(k==0)
  2491. {
  2492. c[n][k] = 1;
  2493. return 1;
  2494. }
  2495. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2496. c[n][k] = result;
  2497. // Roule debug
  2498. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2499. return result;
  2500. }
  2501.  
  2502. // by Dab, à comparer
  2503. function binom(n,p) {
  2504. if(p<0 || p>n) return 0;
  2505. if(c[n])
  2506. if(c[n][p]) return c[n][p];
  2507. else {
  2508. c[n]=[1];
  2509. c[n][n]=1;
  2510. if(p==0 || p==n) return 1;
  2511. }
  2512. if(2*p>n)
  2513. c[n][p]=binom(n,n-p);
  2514. else
  2515. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2516. return c[n][p];
  2517. }
  2518.  
  2519. var coeff = new Array();
  2520.  
  2521. function coef(n,p)
  2522. {
  2523. if(n==0 && p==0)
  2524. return 1;
  2525. if(p>n*3.5)
  2526. p = 7*n-p
  2527. // roule désactive cache
  2528. if(coeff[n] != null && coeff[n][p] !=null)
  2529. return coeff[n][p];
  2530. if(coeff[n] == null)
  2531. coeff[n] = new Array();
  2532. var kmax = Math.floor((p-n)/6);
  2533. var x=0;
  2534. for(var k=0;k<=kmax;k++)
  2535. {
  2536. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2537. }
  2538. coeff[n][p] = x;
  2539. // Roule debug
  2540. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2541. return x;
  2542. }
  2543.  
  2544. function chanceEsquiveParfaite(a,d,ba,bd)
  2545. {
  2546. var win = 0;
  2547. var los = 0;
  2548. if(ba==null)
  2549. ba=0;
  2550. if(bd==null)
  2551. bd=0;
  2552. /* if(6*a+ba<2*(d+bd))
  2553. return 100;
  2554. if(a+ba>2*(6*d+bd))
  2555. return 0;*/
  2556. for(var ds=d;ds<=6*d;ds++)
  2557. {
  2558. var cd = coef(d,ds);
  2559. for(var as=a;as<=6*a;as++)
  2560. {
  2561. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2562. win += cd * coef(a,as);
  2563. else
  2564. los += cd * coef(a,as);
  2565. }
  2566. }
  2567. // roule debug
  2568. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2569. return Math.round(100*win/(win+los));
  2570. }
  2571.  
  2572. function chanceTouche(a,d,ba,bd)
  2573. {
  2574. var win = 0;
  2575. var los = 0;
  2576. if(ba==null)
  2577. ba=0;
  2578. if(bd==null)
  2579. bd=0;
  2580. if(a+ba>6*d+bd)
  2581. return 100;
  2582. if(6*a+ba<d+bd)
  2583. return 0;
  2584. for(var ds=d;ds<=6*d;ds++)
  2585. {
  2586. var cd = coef(d,ds);
  2587. for(var as=a;as<=6*a;as++)
  2588. {
  2589. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2590. win += cd * coef(a,as);
  2591. else
  2592. los += cd * coef(a,as);
  2593. }
  2594. }
  2595. return Math.round(100*win/(win+los));
  2596. }
  2597.  
  2598. function chanceCritique(a,d,ba,bd)
  2599. {
  2600. var win = 0;
  2601. var los = 0;
  2602. if(ba==null)
  2603. ba=0;
  2604. if(bd==null)
  2605. bd=0;
  2606. if(a+ba>2*(6*d+bd))
  2607. return 100;
  2608. if(6*a+ba<2*(d+bd))
  2609. return 0;
  2610. for(var ds=d;ds<=6*d;ds++)
  2611. {
  2612. var cd = coef(d,ds);
  2613. for(var as=a;as<=6*a;as++)
  2614. {
  2615. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2616. win += cd * coef(a,as);
  2617. else
  2618. los += cd * coef(a,as);
  2619. }
  2620. }
  2621. return Math.round(100*win/(win+los));
  2622. }
  2623.  
  2624. /***********************************************
  2625. Analyse tactique
  2626. ***********************************************/
  2627.  
  2628. function getTexteAnalyse(modificateur,chiffre)
  2629. {
  2630. if(chiffre==0)
  2631. return chiffre;
  2632. return modificateur+chiffre;
  2633. }
  2634.  
  2635. // rend le HTML pour le tableau de la "calculette"
  2636. function getAnalyseTactique(id,nom)
  2637. {
  2638. var donneesMonstre = listeCDM[id];
  2639. var needAutres=false;
  2640. var i;
  2641. if(donneesMonstre == null)
  2642. return;
  2643. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2644. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2645. if(array==null)
  2646. return "";
  2647. 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>";
  2648. for(i=0;i<array.length;i++)
  2649. {
  2650. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2651. {
  2652. needAutres=true;
  2653. break;
  2654. }
  2655. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2656. 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>";
  2657. else if(i==0) // attaque du monstre sur le Trõll => italique
  2658. 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>";
  2659. else // autre, pas de décoration
  2660. 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>";
  2661. }
  2662. if(needAutres)
  2663. {
  2664. if(i==array.length-1)
  2665. 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>";
  2666. else if(i==1)
  2667. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2668. else
  2669. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2670. }
  2671. return str+"</table>";
  2672. }
  2673.  
  2674. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2675. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2676. function analyseTactique(donneesMonstre,nom) {
  2677. try
  2678. {
  2679. var listeAttaques = [];
  2680. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2681. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2682. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2683. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2684. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2685. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2686. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2687. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2688. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2689. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2690. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2691. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2692. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2693. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2694. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2695. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2696. var modificateurEsquive = '';
  2697. var modificateurArmure = '';
  2698. var modificateurMagie = '';
  2699. var modificateurEsquiveM = '';
  2700. var modificateurArmureM = '';
  2701. var pasDeSR=false;
  2702. var esqM,attM,armM,degM;
  2703. 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)
  2704. return null;
  2705. var td = document.createElement('td')
  2706. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2707. var esqM = 0;
  2708. try
  2709. {
  2710. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2711. }
  2712. catch(e)
  2713. {
  2714. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  2715. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2716. modificateurEsquive = '<';
  2717. modificateurArmure = '<';
  2718. modificateurMagie = '<';
  2719. }
  2720. td.innerHTML = bbcode(donneesMonstre[3]);
  2721. var attM = 0;
  2722. try
  2723. {
  2724. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2725. }
  2726. catch(e)
  2727. {
  2728. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  2729. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2730. modificateurEsquiveM = '>';
  2731. modificateurArmureM = '>';
  2732. }
  2733. td.innerHTML = bbcode(donneesMonstre[5]);
  2734. var degM = 0;
  2735. try
  2736. {
  2737. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2738. }
  2739. catch(e)
  2740. {
  2741. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  2742. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2743. modificateurArmureM = '>';
  2744. }
  2745. td.innerHTML = bbcode(donneesMonstre[7]);
  2746. var armM = 0;
  2747. try
  2748. {
  2749. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2750. }
  2751. catch(e)
  2752. {
  2753. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  2754. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2755. modificateurArmure = '<';
  2756. }
  2757. var coeffSeuil = 0.95;
  2758. try
  2759. {
  2760. td.innerHTML = bbcode(donneesMonstre[9]);
  2761. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  2762. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2763. var v = (rm / mm);
  2764. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2765. coeffSeuil = (200-seuil)/200;
  2766. }
  2767. catch(e)
  2768. {
  2769. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  2770. modificateurMagie = '<';
  2771. pasDeSR = true;
  2772. }
  2773. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2774. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2775. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2776. // roule debug
  2777. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2778. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2779. 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);
  2780. //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);
  2781. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2782. if(getSortComp("Vampirisme")>0)
  2783. {
  2784. var pour = getSortComp("Vampirisme");
  2785. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2786. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2787. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2788. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2789. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2790. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2791. }
  2792. if(getSortComp("Siphon des âmes")>0)
  2793. {
  2794. var pour = getSortComp("Siphon des âmes");
  2795. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2796. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2797. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2798. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2799. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2800. }
  2801. if(getSortComp("Botte Secrète")>0)
  2802. {
  2803. var pour = getSortComp("Botte Secrète");
  2804. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2805. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2806. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2807. 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;
  2808. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2809. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2810. }
  2811. if(getSortComp("Rafale Psychique")>0)
  2812. {
  2813. var pour = getSortComp("Rafale Psychique");
  2814. chanceDEsquiveParfaite = 0;
  2815. chanceDeTouche = Math.round(100*pour/100);
  2816. chanceDeCritique = Math.round(0*pour/100);
  2817. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2818. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2819. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2820. }
  2821. if(getSortComp("Explosion")>0)
  2822. {
  2823. var pour = getSortComp("Explosion");
  2824. chanceDEsquiveParfaite = 0;
  2825. chanceDeTouche = Math.round(100*pour/100);
  2826. chanceDeCritique = Math.round(0*pour/100);
  2827. 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;
  2828. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2829. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2830. }
  2831. if(getSortComp("Projectile Magique")>0)
  2832. {
  2833. var pour = getSortComp("Projectile Magique");
  2834. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2835. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2836. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2837. // distance troll - monstre
  2838. 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;
  2839. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2840. if (donneesMonstre['iTR'] !== undefined) {
  2841. var dist = getMonstreDistance(donneesMonstre['iTR']+1);
  2842. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  2843. var portee = getPortee__Profil(vue+vue_bm);
  2844. if (dist <= portee) {
  2845. degats += 2 * (portee-dist);
  2846. } else {
  2847. degats += ' (plus bonus de portée)';
  2848. }
  2849. debugMZ('analyseTactique, iTR= ' + donneesMonstre['iTR'] + ', dist=' + dist + ', porteePM=' + portee);
  2850. } else {
  2851. degats += ' (plus bonus de portée)';
  2852. }
  2853. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2854. }
  2855. if(getSortComp("Frénésie")>0)
  2856. {
  2857. var pour = getSortComp("Frénésie");
  2858. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2859. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2860. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2861. 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;
  2862. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2863. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2864. }
  2865. if(getSortComp("Charger")>0)
  2866. {
  2867. var pour = getSortComp("Charger");
  2868. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2869. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2870. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2871. 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;
  2872. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2873. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2874. }
  2875. if(getSortComp("Griffe du Sorcier")>0)
  2876. {
  2877. var pour = getSortComp("Griffe du Sorcier");
  2878. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2879. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2880. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2881. 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;
  2882. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2883. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2884. }
  2885. if(getSortComp("Attaque Précise",1)>0)
  2886. {
  2887. var niveau = 5;
  2888. var oldPour = 0;
  2889. var chanceDEsquiveParfaite = 0;
  2890. var chanceDeTouche = 0;
  2891. var chanceDeCritique = 0;
  2892. degats = 0;
  2893. while(niveau>0)
  2894. {
  2895. var pour = getSortComp("Attaque Précise",niveau);
  2896. if(pour>oldPour)
  2897. {
  2898. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2899. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2900. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2901. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2902. chanceDeTouche += chanceDeToucheNiveau;
  2903. chanceDeCritique += chanceDeCritiqueNiveau;
  2904. 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);
  2905. oldPour = pour;
  2906. }
  2907. niveau--;
  2908. }
  2909. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2910. 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));
  2911. }
  2912. if(getSortComp("Coup de Butoir",1)>0)
  2913. {
  2914. var niveau = 5;
  2915. var oldPour =0;
  2916. var chanceDEsquiveParfaite = 0;
  2917. var chanceDeTouche=0;
  2918. var chanceDeCritique=0;
  2919. degats=0;
  2920. while(niveau>0)
  2921. {
  2922. var pour = getSortComp("Coup de Butoir",niveau);
  2923. if(pour>oldPour)
  2924. {
  2925. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2926. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2927. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2928. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2929. chanceDeTouche += chanceDeToucheNiveau;
  2930. chanceDeCritique += chanceDeCritiqueNiveau;
  2931. 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);
  2932. oldPour = pour;
  2933. }
  2934. niveau--;
  2935. }
  2936. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2937. 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));
  2938. }
  2939. 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;});
  2940. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2941. {
  2942. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2943. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2944. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2945. }
  2946. else
  2947. {
  2948. chanceDEsquiveParfaite = 0;
  2949. chanceDeTouche = 100;
  2950. chanceDeCritique = 0;
  2951. }
  2952. 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;
  2953.  
  2954. 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));
  2955. return listeAttaques;
  2956. }
  2957. catch(e) { window.alert(e);}
  2958. }
  2959.  
  2960. // x~~x marque pour s'y retrouver sous l'éditeur
  2961.  
  2962. /*
  2963. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2964. * published under GNU License v2.
  2965. *
  2966. * Patch :
  2967. * gestion des missions terminées
  2968. */
  2969. // x~x mission_liste
  2970.  
  2971. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2972. try {
  2973. var titresMimis = document.evaluate(
  2974. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2975. document, null, 7, null
  2976. );
  2977. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2978. } catch(e) {
  2979. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2980. return;
  2981. }
  2982. var enCours = {};
  2983. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2984. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2985. enCours[num] = true;
  2986. }
  2987. for(var numMimi in obMissions) {
  2988. if(!enCours[numMimi]) {
  2989. delete obMissions[numMimi];
  2990. }
  2991. }
  2992. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2993. }
  2994.  
  2995. function do_mission_liste() {
  2996. checkLesMimis();
  2997. }
  2998.  
  2999. /*******************************************************************************
  3000. * This file is part of Mountyzilla. *
  3001. * *
  3002. * Mountyzilla is free software; you can redistribute it and/or modify *
  3003. * it under the terms of the GNU General Public License as published by *
  3004. * the Free Software Foundation; either version 2 of the License, or *
  3005. * (at your option) any later version. *
  3006. * *
  3007. * Mountyzilla is distributed in the hope that it will be useful, *
  3008. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3009. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3010. * GNU General Public License for more details. *
  3011. * *
  3012. * You should have received a copy of the GNU General Public License *
  3013. * along with Mountyzilla; if not, write to the Free Software *
  3014. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3015. *******************************************************************************/
  3016.  
  3017. // x~x actions
  3018.  
  3019. /* TODO
  3020. * getLvl pour Explo, Rotobaffe et cie
  3021. */
  3022.  
  3023.  
  3024.  
  3025. /* Page de combat */
  3026.  
  3027. function getLevel() {
  3028. var divList = document.getElementsByTagName('div');
  3029. if(divList.length <= 2)
  3030. return;
  3031. // On essaie de voir si cette action était une attaque
  3032. var pList = document.getElementsByTagName('p');
  3033. var nomM = '';
  3034. // Modification pour Frénésie by TetDure
  3035. var numAtt = 0;
  3036. for (var i = 0; i < pList.length; i++) {
  3037. if(pList[i].firstChild) {
  3038. nomM = pList[i].firstChild.nodeValue;
  3039. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3040. numAtt++;
  3041. }
  3042. }
  3043. if(nomM == '')
  3044. return;
  3045. // Si c'est une attaque normale, un seul PX
  3046. var comPX = 1;
  3047. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3048. comPX++;
  3049.  
  3050. // Extraction des infos du monstre attaqué
  3051. var idM;
  3052. var male;
  3053. if(nomM.slice(20, 21) == 'e') {
  3054. male = false;
  3055. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3056. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3057. }
  3058. else {
  3059. male = true;
  3060. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3061. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3062. }
  3063. if(idM == '')
  3064. return;
  3065. var bList = document.getElementsByTagName('b');
  3066. var niveau = '';
  3067. for (var i = 0; i < bList.length; i++) {
  3068. var b = bList[i];
  3069. if(b.childNodes[0].nodeValue != "TUÉ")
  3070. continue;
  3071. var nbPX = "";
  3072. for (i++; i < bList.length; i++) {
  3073. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3074. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3075. return;
  3076. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3077. nbPX = bList[i].childNodes[0].nodeValue;
  3078. break;
  3079. }
  3080. }
  3081. if(nbPX == '')
  3082. return;
  3083. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3084. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3085. if(!nbPX)
  3086. nbPX = 0;
  3087. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3088. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3089. if(comPX > nbPX) {
  3090. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3091. niveau = "";
  3092. } else if(Math.floor(niveau) == niveau) {
  3093. chaine += niveau + ".";
  3094. } else {
  3095. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3096. niveau = "";
  3097. }
  3098. insertBr(b.nextSibling.nextSibling.nextSibling);
  3099. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3100. }
  3101.  
  3102. if(niveau != '') {
  3103. var button = insertButtonCdm('as_Action');
  3104. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3105. + escape(nomM) + "&niveau=" + escape(niveau)
  3106. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3107. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3108. }
  3109. }
  3110.  
  3111.  
  3112. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3113.  
  3114. function insertInfoMagie(node, intitule, magie) {
  3115. if(node.nextSibling) {
  3116. node = node.nextSibling;
  3117. insertBr(node);
  3118. insertText(node, intitule);
  3119. insertText(node, magie, true);
  3120. } else {
  3121. node = node.parentNode;
  3122. appendBr(node);
  3123. appendText(node, intitule);
  3124. appendText(node, magie, true);
  3125. }
  3126. }
  3127.  
  3128. function getMM(sr) {
  3129. if(rmTroll<=0) {
  3130. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3131. }
  3132. sr = Number(sr.match(/\d+/)[0]);
  3133. if(sr==10) {
  3134. return '\u2265 '+5*rmTroll;
  3135. }
  3136. if(sr<=50) {
  3137. return Math.round(50*rmTroll/sr);
  3138. }
  3139. if(sr<90) {
  3140. return Math.round((100-sr)*rmTroll/50);
  3141. }
  3142. return '\u2264 '+Math.round(rmTroll/5);
  3143. }
  3144.  
  3145. function traiteMM() {
  3146. var node = document.evaluate(
  3147. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3148. document, null, 9, null).singleNodeValue;
  3149. if(node) {
  3150. var mm = getMM(node.nodeValue);
  3151. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3152. } else {
  3153. var node = document.evaluate(
  3154. "//p/text()[contains(., 'Seuil de Résistance')]",
  3155. document, null, 9, null).singleNodeValue;
  3156. if(!node) {
  3157. return;
  3158. }
  3159. var mm = getMM(node.nodeValue);
  3160. node = node.nextSibling.nextSibling;
  3161. }
  3162. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3163. }
  3164.  
  3165. function getRM(sr) {
  3166. if(mmTroll<=0) {
  3167. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3168. }
  3169. sr = Number(sr.match(/\d+/)[0]);
  3170. if(sr==10) {
  3171. return '\u2264 '+Math.round(mmTroll/5);
  3172. }
  3173. if(sr<=50) {
  3174. return Math.round(sr*mmTroll/50);
  3175. }
  3176. if(sr<90) {
  3177. return Math.round(50*mmTroll/(100-sr));
  3178. }
  3179. return '\u2265 '+5*mmTroll;
  3180. }
  3181.  
  3182. function traiteRM() {
  3183. var nodes = document.evaluate(
  3184. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3185. document, null, 7, null);
  3186. if(nodes.snapshotLength==0) {
  3187. return;
  3188. }
  3189. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3190. var node = nodes.snapshotItem(i);
  3191. var rm = getRM(node.nodeValue);
  3192. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3193. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3194. }
  3195. }
  3196.  
  3197.  
  3198. /* Fonction stats IdT par Raistlin */
  3199. /*function getIdt() {
  3200. if(MY_getValue("SEND_IDT") == "non")
  3201. return false;
  3202. var regExpBeginning = /^\s+/;
  3203. var regExpEnd = /\s+$/;
  3204.  
  3205. var nomIdt = document.evaluate(
  3206. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3207. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3208. if(!nomIdt)
  3209. return false;
  3210.  
  3211. var caracIdt;
  3212. if(nomIdt.indexOf("Malédiction !") != -1) {
  3213. caracIdt = "";
  3214. nomIdt = "Mission maudite";
  3215. } else {
  3216. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3217. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3218. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3219. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3220. }
  3221. FF_XMLHttpRequest({
  3222. method: 'GET',
  3223. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3224. headers : {
  3225. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3226. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3227. }
  3228. });
  3229. return true;
  3230. }*/
  3231.  
  3232.  
  3233. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3234.  
  3235. function confirmeDecalage() {
  3236. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3237. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3238. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3239. var newDLA = new Date( oldDLA );
  3240. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3241. return window.confirm(
  3242. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3243. +'\nConfirmez-vous ce décalage ?'
  3244. );
  3245. }
  3246.  
  3247. function newsubmitDLA(evt) {
  3248. evt.stopPropagation();
  3249. evt.preventDefault();
  3250. if(confirmeDecalage()) {
  3251. this.submit();
  3252. }
  3253. }
  3254.  
  3255. function changeActionDecalage() {
  3256. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3257. return;
  3258. }
  3259. try {
  3260. // On récupère le contenu du script JS MH de calcul du décalage
  3261. var scriptTxt = document.evaluate(
  3262. ".//script[ not(@src) ]",
  3263. document, null, 9, null
  3264. ).singleNodeValue.textContent;
  3265. // On en extrait la DLA courante
  3266. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3267. scriptTxt = scriptTxt.split('\n')[0];
  3268. var nbs = scriptTxt.match(/\d+/g);
  3269. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3270. } catch(e) {
  3271. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3272. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3273. return;
  3274. }
  3275. var form = document.getElementsByName('ActionForm')[0];
  3276. if(form) {
  3277. form.addEventListener('submit', newsubmitDLA, true);
  3278. } else {
  3279. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3280. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3281. }
  3282. }
  3283.  
  3284. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3285.  
  3286. function prochainMundi() {
  3287. try {
  3288. var node;
  3289. node = document.evaluate(
  3290. "//div[@class='dateAction']/b",
  3291. document, null, 9, null
  3292. ).singleNodeValue;
  3293. if (document.evaluate) {
  3294. } else { // repli en JQuery
  3295. //node = $(
  3296. }
  3297. } catch(e) {
  3298. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3299. return;
  3300. }
  3301. if(!node) { return; }
  3302.  
  3303. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3304. var jour = longueurMois+1-getNumber(node.textContent);
  3305. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3306. var txt = '[Prochain Mundidey ';
  3307. if(jour>1) {
  3308. txt += 'dans '+jour+' jours]';
  3309. } else {
  3310. txt += 'demain]';
  3311. }
  3312. insertText(node.parentNode.nextSibling,txt,true);
  3313. }
  3314.  
  3315.  
  3316. /* Fonction principale */
  3317.  
  3318. function dispatch() {
  3319. if(isPage('MH_Play/Play_action')) {
  3320. prochainMundi();
  3321. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3322. var oldDLA;
  3323. changeActionDecalage();
  3324. } else if(isPage('MH_Play/Actions')) {
  3325. if(document.evaluate(
  3326. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3327. document, null, 2, null
  3328. ).stringValue) {
  3329. traiteMM();
  3330. } else if(document.evaluate(
  3331. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3332. document, null, 2, null
  3333. ).stringValue) {
  3334. //getIdt();
  3335. traiteRM();
  3336. } /*else {
  3337. // Est censé se lancer sur quoi *précisément* ?
  3338. traiteRM();
  3339. getLevel();
  3340. }*/
  3341. } else {
  3342. /* Traitement des messages du bot */
  3343. var messageTitle = document.evaluate(
  3344. "//form/table/tbody/tr[1]/td[1]/"
  3345. +"descendant::text()[contains(.,'[MountyHall]')]",
  3346. document, null, 2, null
  3347. ).stringValue;
  3348. if(messageTitle.indexOf('Attaquant') != -1 &&
  3349. messageTitle.indexOf('sur') != -1) {
  3350. getLevel();
  3351. traiteRM();
  3352. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3353. messageTitle.indexOf('Défenseur') != -1) {
  3354. traiteMM();
  3355. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3356. // à replacer avec Attaque après révision getLvl :
  3357. messageTitle.indexOf('Explosion') != -1 ||
  3358. messageTitle.indexOf('Insulte') != -1) {
  3359. traiteRM();
  3360. }
  3361. }
  3362. }
  3363.  
  3364. function do_actions() {
  3365. start_script(31);
  3366. dispatch();
  3367. displayScriptTime();
  3368. }
  3369.  
  3370. /*********************************************************************************
  3371. * This file is part of Mountyzilla. *
  3372. * *
  3373. * Mountyzilla is free software; you can redistribute it and/or modify *
  3374. * it under the terms of the GNU General Public License as published by *
  3375. * the Free Software Foundation; either version 2 of the License, or *
  3376. * (at your option) any later version. *
  3377. * *
  3378. * Mountyzilla is distributed in the hope that it will be useful, *
  3379. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3380. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3381. * GNU General Public License for more details. *
  3382. * *
  3383. * You should have received a copy of the GNU General Public License *
  3384. * along with Mountyzilla; if not, write to the Free Software *
  3385. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3386. *********************************************************************************/
  3387.  
  3388. // x~x pre-enchant
  3389.  
  3390. /* 2013-08-19 : correction auto syntaxe alert */
  3391.  
  3392. var combobox=null;
  3393.  
  3394. function changeObject()
  3395. {
  3396. if(!combobox)
  3397. return ;
  3398. var id = combobox.options[combobox.selectedIndex].value;
  3399. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3400. if(!id || id=="")
  3401. {
  3402. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3403. return;
  3404. }
  3405. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3406. }
  3407.  
  3408. function treatePreEnchantement() {
  3409. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3410. if(!input || input.getAttribute("type")=="hidden")
  3411. {
  3412. return false;
  3413. }
  3414. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3415. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3416. if(!combobox)
  3417. {
  3418. return true;
  3419. }
  3420. combobox.addEventListener('change', changeObject, true);
  3421. return true;
  3422. }
  3423.  
  3424. function treateEnchantement() {
  3425. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3426. if(!input || input.getAttribute("type")!="hidden")
  3427. {
  3428. return false;
  3429. }
  3430. var idEquipement = input.getAttribute("value");
  3431. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3432. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3433. if(enchanteur && enchanteur != null)
  3434. return true;
  3435. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3436. if(!input || input.getAttribute("type")!="hidden")
  3437. {
  3438. return false;
  3439. }
  3440. var idEnchanteur = input.getAttribute("value");
  3441. var nodes = document.evaluate(
  3442. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3443. if (nodes.snapshotLength != 3)
  3444. return;
  3445. for(var i=0;i<3;i++)
  3446. {
  3447. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3448. texte = texte.replace(" d'une "," d'un ");
  3449. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3450. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3451. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3452. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3453. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3454. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3455. }
  3456. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3457. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3458. var liste = MY_getValue(numTroll+".enchantement.liste");
  3459. if(!liste || liste=="")
  3460. {
  3461. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3462. }
  3463. else
  3464. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3465. }
  3466.  
  3467. function do_pre_enchant() {
  3468. start_script(60);
  3469. if(!treatePreEnchantement())
  3470. treateEnchantement();
  3471. displayScriptTime();
  3472. }
  3473.  
  3474. /*********************************************************************************
  3475. * This file is part of Mountyzilla. *
  3476. * *
  3477. * Mountyzilla is free software; you can redistribute it and/or modify *
  3478. * it under the terms of the GNU General Public License as published by *
  3479. * the Free Software Foundation; either version 2 of the License, or *
  3480. * (at your option) any later version. *
  3481. * *
  3482. * Mountyzilla is distributed in the hope that it will be useful, *
  3483. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3484. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3485. * GNU General Public License for more details. *
  3486. * *
  3487. * You should have received a copy of the GNU General Public License *
  3488. * along with Mountyzilla; if not, write to the Free Software *
  3489. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3490. *********************************************************************************/
  3491.  
  3492. // x~x enchant
  3493.  
  3494. /* 2013-08-19 : correction auto syntaxe alert */
  3495.  
  3496. function treateEnchantement() {
  3497. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3498. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3499. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3500. return;
  3501. var tab = infoEquipement.split(";");
  3502. if(tab.length<2)
  3503. return;
  3504. var idEquipement = tab[0];
  3505. var nomEquipement = tab[1];
  3506. for(var i=2;i<tab.length;i++)
  3507. nomEquipement += ";"+tab[i];
  3508. var nodes = document.evaluate(
  3509. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3510. if (nodes.snapshotLength != 3)
  3511. return;
  3512. for(var i=0;i<3;i++)
  3513. {
  3514. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3515. texte = texte.replace(" d'une "," d'un ");
  3516. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3517. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3518. monstre = monstre.replace(/ Géante?/,"");
  3519. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3520. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3521. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3522. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3523. }
  3524. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3525. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3526. var liste = MY_getValue(numTroll+".enchantement.liste");
  3527. if(!liste || liste=="")
  3528. {
  3529. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3530. }
  3531. else
  3532. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3533. }
  3534.  
  3535. function do_enchant() {
  3536. start_script(60);
  3537.  
  3538. treateEnchantement();
  3539. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3540. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3541. displayScriptTime();
  3542. }
  3543.  
  3544. /*********************************************************************************
  3545. * This file is part of Mountyzilla. *
  3546. * *
  3547. * Mountyzilla is free software; you can redistribute it and/or modify *
  3548. * it under the terms of the GNU General Public License as published by *
  3549. * the Free Software Foundation; either version 2 of the License, or *
  3550. * (at your option) any later version. *
  3551. * *
  3552. * Mountyzilla is distributed in the hope that it will be useful, *
  3553. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3554. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3555. * GNU General Public License for more details. *
  3556. * *
  3557. * You should have received a copy of the GNU General Public License *
  3558. * along with Mountyzilla; if not, write to the Free Software *
  3559. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3560. *********************************************************************************/
  3561.  
  3562. // x~x myevent
  3563.  
  3564. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3565. function do_myevent() {
  3566. }
  3567.  
  3568. /*********************************************************************************
  3569. * This file is part of Mountyzilla. *
  3570. * *
  3571. * Mountyzilla is free software; you can redistribute it and/or modify *
  3572. * it under the terms of the GNU General Public License as published by *
  3573. * the Free Software Foundation; either version 2 of the License, or *
  3574. * (at your option) any later version. *
  3575. * *
  3576. * Mountyzilla is distributed in the hope that it will be useful, *
  3577. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3578. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3579. * GNU General Public License for more details. *
  3580. * *
  3581. * You should have received a copy of the GNU General Public License *
  3582. * along with Mountyzilla; if not, write to the Free Software *
  3583. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3584. *********************************************************************************/
  3585.  
  3586. // x~x malus
  3587.  
  3588. /* v1.4 - 2014-01-06
  3589. * - Gestion des sorts double composante
  3590. * v1.4.1 - 2014-01-22
  3591. * - Correction décumul
  3592. * TODO
  3593. * - Identifier la position de "PV" dans l'ordre MH
  3594. */
  3595.  
  3596. var listeBM;
  3597.  
  3598.  
  3599. /* [functions] Utilitaires */
  3600.  
  3601. function decumul(bmt,nbr) {
  3602. var bmr;
  3603. if(!nbr || nbr<2) bmr = bmt;
  3604. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3605. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3606. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3607. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3608. else bmr = parseInt(0.1*bmt);
  3609. if(bmt<0) return Math.min(-1,bmr);
  3610. return Math.max(1,bmr);
  3611. }
  3612.  
  3613. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3614. // Roule 23/11/2016 ajout PV
  3615. switch( a ) {
  3616. case 'ATT':
  3617. return -1;
  3618. case 'ESQ':
  3619. if(b=='ATT') return 1;
  3620. return -1;
  3621. case 'DEG':
  3622. switch( b ) {
  3623. case 'ATT':
  3624. case 'ESQ':
  3625. return 1;
  3626. default:
  3627. return -1;
  3628. }
  3629. case 'REG':
  3630. switch( b ) {
  3631. case 'ATT':
  3632. case 'ESQ':
  3633. case 'DEG':
  3634. return 1;
  3635. default:
  3636. return -1;
  3637. }
  3638. case 'Vue':
  3639. switch( b ) {
  3640. case 'ATT':
  3641. case 'ESQ':
  3642. case 'DEG':
  3643. case 'REG':
  3644. return 1;
  3645. default:
  3646. return -1;
  3647. }
  3648. case 'TOUR':
  3649. switch( b ) {
  3650. case 'ATT':
  3651. case 'ESQ':
  3652. case 'DEG':
  3653. case 'REG':
  3654. case 'Vue':
  3655. return 1;
  3656. default:
  3657. return -1;
  3658. }
  3659. case 'PV':
  3660. switch( b ) {
  3661. case 'ATT':
  3662. case 'ESQ':
  3663. case 'DEG':
  3664. case 'REG':
  3665. case 'Vue':
  3666. case 'TOUR':
  3667. return 1;
  3668. default:
  3669. return -1;
  3670. }
  3671. case 'Armure':
  3672. switch( b ) {
  3673. case 'ATT':
  3674. case 'ESQ':
  3675. case 'DEG':
  3676. case 'REG':
  3677. case 'Vue':
  3678. case 'TOUR':
  3679. case 'PV':
  3680. return 1;
  3681. default:
  3682. return -1;
  3683. }
  3684. case 'RM':
  3685. switch( b ) {
  3686. case 'ATT':
  3687. case 'ESQ':
  3688. case 'DEG':
  3689. case 'REG':
  3690. case 'Vue':
  3691. case 'TOUR':
  3692. case 'PV':
  3693. case 'Armure':
  3694. return 1;
  3695. default:
  3696. return -1;
  3697. }
  3698. case 'MM':
  3699. switch( b ) {
  3700. case 'ATT':
  3701. case 'ESQ':
  3702. case 'DEG':
  3703. case 'REG':
  3704. case 'Vue':
  3705. case 'TOUR':
  3706. case 'PV':
  3707. case 'Armure':
  3708. case 'RM':
  3709. return 1;
  3710. default:
  3711. return -1;
  3712. }
  3713. case 'Concentration':
  3714. switch( b ) {
  3715. case 'ATT':
  3716. case 'ESQ':
  3717. case 'DEG':
  3718. case 'REG':
  3719. case 'Vue':
  3720. case 'TOUR':
  3721. case 'PV':
  3722. case 'Armure':
  3723. case 'RM':
  3724. case 'MM':
  3725. return 1;
  3726. default:
  3727. return -1;
  3728. }
  3729. case 'Fatigue':
  3730. switch( b ) {
  3731. case 'ATT':
  3732. case 'ESQ':
  3733. case 'DEG':
  3734. case 'REG':
  3735. case 'Vue':
  3736. case 'TOUR':
  3737. case 'PV':
  3738. case 'Armure':
  3739. case 'RM':
  3740. case 'MM':
  3741. case 'Concentration':
  3742. return 1;
  3743. default:
  3744. return -1;
  3745. }
  3746. case "Dés d'attaque":
  3747. switch( b ) {
  3748. case 'ATT':
  3749. case 'ESQ':
  3750. case 'DEG':
  3751. case 'REG':
  3752. case 'Vue':
  3753. case 'TOUR':
  3754. case 'PV':
  3755. case 'Armure':
  3756. case 'RM':
  3757. case 'MM':
  3758. case 'Concentration':
  3759. case 'Fatigue':
  3760. return 1;
  3761. default:
  3762. return -1;
  3763. }
  3764. case 'Dés de dégâts':
  3765. switch( b ) {
  3766. case 'ATT':
  3767. case 'ESQ':
  3768. case 'DEG':
  3769. case 'REG':
  3770. case 'Vue':
  3771. case 'TOUR':
  3772. case 'PV':
  3773. case 'Armure':
  3774. case 'RM':
  3775. case 'MM':
  3776. case 'Concentration':
  3777. case 'Fatigue':
  3778. case "Dés d'attaque":
  3779. return 1;
  3780. default:
  3781. return -1;
  3782. }
  3783. default :
  3784. switch( b ) {
  3785. case 'ATT':
  3786. case 'ESQ':
  3787. case 'DEG':
  3788. case 'REG':
  3789. case 'Vue':
  3790. case 'TOUR':
  3791. case 'PV':
  3792. case 'Armure':
  3793. case 'RM':
  3794. case 'MM':
  3795. case 'Concentration':
  3796. case 'Fatigue':
  3797. case "Dés d'attaque":
  3798. case 'Dés de dégâts':
  3799. return 1;
  3800. default:
  3801. return -1;
  3802. }
  3803. }
  3804. }
  3805.  
  3806.  
  3807. /* [functions] Fonctions hide / display */
  3808.  
  3809. function toggleDetailsBM() {
  3810. if(MY_getValue('BMDETAIL')!='false') {
  3811. MY_setValue('BMDETAIL','false');
  3812. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3813. for(var i=0 ; i<trlist.length ; i++)
  3814. trlist[i].style.display = 'none';
  3815. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3816. for(var i=0 ; i<trlist.length ; i++)
  3817. trlist[i].style = '';
  3818. }
  3819. else {
  3820. MY_setValue('BMDETAIL','true');
  3821. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3822. for(var i=0 ; i<trlist.length ; i++)
  3823. trlist[i].style.display = 'none';
  3824. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3825. for(var i=0 ; i<trlist.length ; i++)
  3826. trlist[i].style = '';
  3827. }
  3828. }
  3829.  
  3830. function toggleBMList() {
  3831. if(MY_getValue('BMHIDELIST')=='true') {
  3832. MY_setValue('BMHIDELIST','false');
  3833. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3834. listeBM.snapshotItem(i).style = '';
  3835. document.getElementsByTagName('thead')[0].style = '';
  3836. document.getElementById('trhelp').style = '';
  3837. }
  3838. else {
  3839. MY_setValue('BMHIDELIST','true');
  3840. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3841. listeBM.snapshotItem(i).style.display = 'none';
  3842. document.getElementsByTagName('thead')[0].style.display = 'none';
  3843. document.getElementById('trhelp').style.display = 'none';
  3844. }
  3845. }
  3846.  
  3847. function setDisplayBM() {
  3848. if(!listeBM) return;
  3849. var titre = document.getElementById('titre2');
  3850. if(titre) {
  3851. titre.style.cursor = 'pointer';
  3852. titre.onclick = toggleBMList;
  3853. }
  3854. var tfoot = document.getElementsByTagName('tfoot')[0];
  3855. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3856. tfoot, null, 9, null).singleNodeValue;
  3857. tr.id = 'trhelp';
  3858. if(MY_getValue('BMHIDELIST')=='true') {
  3859. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3860. listeBM.snapshotItem(i).style.display = 'none';
  3861. document.getElementsByTagName('thead')[0].style.display = 'none';
  3862. tr.style.display = 'none';
  3863. }
  3864. }
  3865.  
  3866.  
  3867. /* [functions] Fonction principale */
  3868.  
  3869. function traiteMalus() {
  3870. var mainTab = document.getElementsByTagName('table')[0];
  3871. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3872. if(listeBM.snapshotLength==0) return;
  3873. /* Suppression des BM de fatigue stockés */
  3874. if(MY_getValue(numTroll+'.bm.fatigue'))
  3875. MY_removeValue(numTroll+'.bm.fatigue');
  3876. /* Extraction des données */
  3877. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3878. var nb = 0;
  3879. while(nb<listeBM.snapshotLength) {
  3880. tr = listeBM.snapshotItem(nb); nb++;
  3881. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3882. var phymag = tr.childNodes[9].textContent;
  3883. var duree = tr.childNodes[11].textContent.match(/\d+/);
  3884. if (duree == null) { // Roule 28/01/2018 protection malus Crasc sans durée
  3885. duree = 1;
  3886. } else {
  3887. duree = Number(duree[0]);
  3888. }
  3889. var type = tr.childNodes[3].textContent, nom;
  3890. // si c'est un type à décumul
  3891. /*
  3892. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3893. switch(type) {
  3894. case 'Potion':
  3895. case 'Parchemin':
  3896. case 'Sortilège':
  3897. case 'Capacité Spéciale':
  3898. nom = tr.childNodes[1].textContent+phymag;
  3899. break;
  3900. default:
  3901. nom = 'pasdedecumul';
  3902. }
  3903. */
  3904. nom = tr.childNodes[1].textContent+phymag;
  3905. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3906. nom = 'pasdedecumul';
  3907. uniListe[nb] = {
  3908. 'duree':duree,
  3909. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3910. 'caracs':{}
  3911. }
  3912. for(var i=0 ; i<effetsT.length ; i++) {
  3913. if(effetsT[i].indexOf(':')==-1) continue;
  3914. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3915. // nom = 'pasdedecumul' si pas de décumul
  3916. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3917. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3918. uniListe[nb]['type'] = phymag;
  3919. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3920. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  3921. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  3922. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  3923. uniListe[nb]['caracs'][carac] = bm;
  3924. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  3925. listeDurees[duree] = true;
  3926. }
  3927. } // fin boucle sur les lignes de bonus/malus
  3928. /* Gestion des décumuls et cumuls des durées */
  3929. var toursGeres = [];
  3930. for(var d in listeDurees) toursGeres.push(d);
  3931. toursGeres.sort( function (a,b){return b-a;} );
  3932. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  3933. // pour sauvegarder les bm de fatigue
  3934. var strfat = '';
  3935. // Pour affichage & adpatation à footable.js (statique)
  3936. var thead = document.getElementsByTagName('thead')[0];
  3937. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3938. thead, null, 7, null).snapshotLength;
  3939. var tfoot = document.getElementsByTagName('tfoot')[0];
  3940. for(var i=0 ; i<toursGeres.length ; i++) {
  3941. var tour = toursGeres[i];
  3942. var effetsCeTour = {}; decumulsCeTour = {};
  3943. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3944. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3945. continue;
  3946. var nom = uniListe[nb]['nom'];
  3947. if(nom!='pasdedecumul') {
  3948. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3949. decumulsCeTour[nom]++;
  3950. }
  3951. for(var carac in uniListe[nb]['caracs']) {
  3952. var bm = uniListe[nb]['caracs'][carac];
  3953. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3954. var type = uniListe[nb]['type'];
  3955. if(!effetsCeTour[carac])
  3956. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3957. var thisBm;
  3958. if(nom=='pasdedecumul')
  3959. thisBm = bm;
  3960. else
  3961. thisBm = decumul(bm,decumulsCeTour[nom]);
  3962. effetsCeTour[carac][type] += thisBm;
  3963. 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]);
  3964. } else {
  3965. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3966. var thisBm;
  3967. if(nom=='pasdedecumul' || carac=='Fatigue')
  3968. thisBm = bm;
  3969. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3970. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3971. else
  3972. thisBm = decumul(bm,decumulsCeTour[nom]);
  3973. effetsCeTour[carac] += thisBm;
  3974. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3975. }
  3976. } // fin boucle sur les caractéristiques
  3977. } // fin boucle sur les bonus/malus
  3978. /* Création du bilan du tour */
  3979. var texteD = '', texteS = '';
  3980. var caracGerees = [];
  3981. for(var k in effetsCeTour) caracGerees.push(k);
  3982. caracGerees.sort( triecaracs );
  3983. for(var j=0 ; j<caracGerees.length ; j++) {
  3984. var carac = caracGerees[j], str = '';
  3985. switch( carac ) {
  3986. case 'ATT':
  3987. case 'DEG':
  3988. case 'Armure':
  3989. var phy = effetsCeTour[carac]['Physique'];
  3990. var mag = effetsCeTour[carac]['Magie'];
  3991. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3992. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3993. break;
  3994. case 'TOUR':
  3995. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3996. break;
  3997. case 'Fatigue':
  3998. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3999. case 'PV':
  4000. case 'ESQ':
  4001. case 'REG':
  4002. case 'Vue':
  4003. case 'Voir le Caché':
  4004. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  4005. break;
  4006. default:
  4007. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  4008. }
  4009. if(str) {
  4010. texteD += str;
  4011. texteS += str;
  4012. }
  4013. } // fin boucle sur les caractéristiques
  4014. /* Affichage */
  4015. // Si rien à afficher on passe
  4016. if(!texteD) continue;
  4017. // Si BMM+BMP=0
  4018. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  4019. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  4020. if(MY_getValue('BMDETAIL')=='false')
  4021. tr.style.display = 'none';
  4022. var td = appendTdText(tr,texteD.substring(3));
  4023. td.colSpan = 5-nbHidden;
  4024. var txttour = toursGeres[i]+' Tour';
  4025. if(toursGeres[i]>1) txttour += 's';
  4026. appendTdText(tr,txttour);
  4027. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  4028. if(MY_getValue('BMDETAIL')!='false')
  4029. tr.style.display = 'none';
  4030. td = appendTdText(tr,texteS);
  4031. td.colSpan = 5-nbHidden;
  4032. appendTdText(tr,txttour);
  4033. } // fin boucle sur les tours générés
  4034. /* mise en place toggleDetails */
  4035. tfoot.style.cursor = 'pointer';
  4036. tfoot.onclick = toggleDetailsBM;
  4037. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4038. if(strfat)
  4039. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4040. }
  4041.  
  4042. function do_malus() {
  4043. try {
  4044. start_script();
  4045. traiteMalus();
  4046. setDisplayBM();
  4047. displayScriptTime();
  4048. }
  4049. catch(e) {window.alert(e)};
  4050. }
  4051.  
  4052. /*******************************************************************************
  4053. * This file is part of Mountyzilla. *
  4054. * *
  4055. * Mountyzilla is free software; you can redistribute it and/or modify *
  4056. * it under the terms of the GNU General Public License as published by *
  4057. * the Free Software Foundation; either version 2 of the License, or *
  4058. * (at your option) any later version. *
  4059. * *
  4060. * Mountyzilla is distributed in the hope that it will be useful, *
  4061. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4062. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4063. * GNU General Public License for more details. *
  4064. * *
  4065. * You should have received a copy of the GNU General Public License *
  4066. * along with Mountyzilla; if not, write to the Free Software *
  4067. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4068. *******************************************************************************/
  4069.  
  4070. // x~x mouches
  4071.  
  4072. var mainTab, tr_mouches;
  4073.  
  4074. function initialiseMouches() {
  4075. // Lanceur global
  4076. try {
  4077. mainTab = document.getElementById('mouches');
  4078. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4079. } catch(e) {
  4080. avertissement('Erreur MZ:<br />Consulter la console.');
  4081. window.console.error(traceStack(e, 'mouches'));
  4082. return;
  4083. }
  4084. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4085. setDisplayMouches();
  4086. traiteMouches();
  4087. }
  4088.  
  4089. function setDisplayMouches() {
  4090. // Initialise l'affichage / l'effacement du détail des mouches
  4091. var titre = document.getElementById('titre2');
  4092. if(titre) {
  4093. titre.style.cursor = 'pointer';
  4094. titre.onclick = toggleMouches;
  4095. }
  4096. var tfoot = document.getElementsByTagName('tfoot')[0];
  4097. if(tfoot) {
  4098. tfoot.style.cursor = 'pointer';
  4099. tfoot.onclick = toggleMouches;
  4100. }
  4101. if(MY_getValue('HIDEMOUCHES')=='true') {
  4102. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4103. tr_mouches.snapshotItem(i).style.display = 'none';
  4104. }
  4105. document.getElementsByTagName('thead')[0].style.display = 'none';
  4106. }
  4107. }
  4108.  
  4109. function toggleMouches() {
  4110. // Handler pour afficher / masquer les détasil
  4111. if(MY_getValue('HIDEMOUCHES')=='true') {
  4112. MY_setValue('HIDEMOUCHES','false');
  4113. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4114. tr_mouches.snapshotItem(i).style.display = '';
  4115. }
  4116. document.getElementsByTagName('thead')[0].style.display = '';
  4117. } else {
  4118. MY_setValue('HIDEMOUCHES','true');
  4119. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4120. tr_mouches.snapshotItem(i).style.display = 'none';
  4121. }
  4122. document.getElementsByTagName('thead')[0].style.display = 'none';
  4123. }
  4124. }
  4125.  
  4126. function traiteMouches() {
  4127. // Traitement complet: présence et effets des mouches
  4128. var listeTypes = {}, effetsActifs = {};
  4129. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4130. var tr = tr_mouches.snapshotItem(i);
  4131. // La mouche est-elle présente?
  4132. var etat = document.evaluate(
  4133. './img',
  4134. tr.cells[6], null, 9, null
  4135. ).singleNodeValue.alt;
  4136. if(etat!='La Mouche est là') { continue; }
  4137. // Extraction du type de mouche
  4138. var type = trim(tr.cells[3].textContent);
  4139. if(!listeTypes[type]) {
  4140. listeTypes[type] = 1;
  4141. } else {
  4142. listeTypes[type]++;
  4143. }
  4144. // La mouche a-t-elle un effet?
  4145. var effet = trim(tr.cells[2].textContent);
  4146. if(etat!='La Mouche est là' || !effet) { continue; }
  4147. // Si oui, extraction des effets (multiples pour pogées)
  4148. var caracs = effet.split(' | ');
  4149. for(var j=0 ; j<caracs.length ; j++) {
  4150. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4151. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4152. if(effetsActifs[carac]===void(0)) {
  4153. effetsActifs[carac] = valeur;
  4154. } else {
  4155. effetsActifs[carac] += valeur;
  4156. }
  4157. }
  4158. }
  4159. // Extraction Effet total et affichage des différences à la normale
  4160. var tfoot = document.getElementsByTagName('tfoot')[0];
  4161. if(!tfoot) { return; }
  4162. var nodeTotal = document.evaluate(
  4163. ".//b[contains(./text(),'Effet total')]",
  4164. tfoot, null, 9, null
  4165. ).singleNodeValue.nextSibling;
  4166. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4167. var texte = ' ';
  4168. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4169. if(texte.length>1) { texte += ' | '; }
  4170. var carac = trim(
  4171. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4172. );
  4173. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4174. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4175. texte += effetsTheoriques[i];
  4176. } else {
  4177. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4178. if(carac=='TOUR') { texte += ' min'; }
  4179. texte += '</b>';
  4180. }
  4181. }
  4182. var span = document.createElement('span');
  4183. span.innerHTML = texte;
  4184. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4185. // Affichage des différences du nombre de mouches de chaque type
  4186. var mouchesParType = document.evaluate(
  4187. "./tr/td/ul/li/text()",
  4188. tfoot, null, 7, null
  4189. );
  4190. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4191. var node = mouchesParType.snapshotItem(i);
  4192. var mots = node.nodeValue.split(' ');
  4193. var type = mots.pop();
  4194. if(!listeTypes[type]) {
  4195. node.nodeValue += ' (0 présente)';
  4196. } else if(mots[0]!=listeTypes[type]) {
  4197. if(listeTypes[type]==1) {
  4198. node.nodeValue += ' (1 présente)';
  4199. } else {
  4200. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4201. }
  4202. }
  4203. }
  4204. }
  4205.  
  4206. function do_mouches() {
  4207. start_script();
  4208. initialiseMouches();
  4209. displayScriptTime();
  4210. }
  4211.  
  4212. /*********************************************************************************
  4213. * This file is part of Mountyzilla. *
  4214. * *
  4215. * Mountyzilla is free software; you can redistribute it and/or modify *
  4216. * it under the terms of the GNU General Public License as published by *
  4217. * the Free Software Foundation; either version 2 of the License, or *
  4218. * (at your option) any later version. *
  4219. * *
  4220. * Mountyzilla is distributed in the hope that it will be useful, *
  4221. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4222. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4223. * GNU General Public License for more details. *
  4224. * *
  4225. * You should have received a copy of the GNU General Public License *
  4226. * along with Mountyzilla; if not, write to the Free Software *
  4227. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4228. *********************************************************************************/
  4229.  
  4230. // x~x equipgowap
  4231.  
  4232. var popup;
  4233.  
  4234. function initPopupEquipgowap() {
  4235. popup = document.createElement('div');
  4236. popup.setAttribute('id', 'popup');
  4237. popup.setAttribute('class', 'mh_textbox');
  4238. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4239. 'display: inline; z-index: 3; max-width: 400px;');
  4240. document.body.appendChild(popup);
  4241. }
  4242.  
  4243. function showPopupEquipgowap(evt) {
  4244. var texte = this.getAttribute("texteinfo");
  4245. popup.innerHTML = texte;
  4246. popup.style.left = evt.pageX + 15 + 'px';
  4247. popup.style.top = evt.pageY + 'px';
  4248. popup.style.visibility = "visible";
  4249. }
  4250.  
  4251. function hidePopup() {
  4252. popup.style.visibility = "hidden";
  4253. }
  4254.  
  4255. function createPopupImage(url, text)
  4256. {
  4257. var img = document.createElement('img');
  4258. img.setAttribute('src',url);
  4259. img.setAttribute('align','ABSMIDDLE');
  4260. img.setAttribute("texteinfo",text);
  4261. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4262. img.addEventListener("mouseout", hidePopup,true);
  4263. return img;
  4264. }
  4265.  
  4266. function formateTexte(texte)
  4267. {
  4268. texte = texte.replace(/\n/g,"<br/>");
  4269. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4270. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4271. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4272. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4273. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4274. return texte;
  4275. }
  4276.  
  4277.  
  4278. function treateGowaps() {
  4279. //On récupère les gowaps possédants des composants
  4280. var tbodys = document.evaluate(
  4281. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4282. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4283. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4284. var tbody = tbodys.snapshotItem(j);
  4285. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4286. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4287. if(MY_getValue("NOINFOEM") != "true")
  4288. insertEMInfos(tbody);
  4289. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4290. insertEnchantInfos(tbody);
  4291. }
  4292. }
  4293.  
  4294. function treateChampi() {
  4295. if(MY_getValue("NOINFOEM") == "true")
  4296. return false;
  4297. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4298. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4299. if (nodes.snapshotLength == 0)
  4300. return false;
  4301.  
  4302. for (var i = 0; i < nodes.snapshotLength; i++) {
  4303. var node = nodes.snapshotItem(i);
  4304. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4305. if(texte.indexOf("*")!=-1)
  4306. texte = texte.substring(0,texte.lastIndexOf(" "));
  4307. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4308. if(moisChampi[nomChampi])
  4309. {
  4310. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4311. }
  4312. }
  4313. }
  4314.  
  4315. function do_equipgowap() {
  4316. start_script();
  4317.  
  4318. treateGowaps();
  4319. treateChampi();
  4320. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4321. {
  4322. initPopupEquipgowap();
  4323. computeEnchantementEquipement(createPopupImage,formateTexte);
  4324. }
  4325.  
  4326. displayScriptTime();
  4327. }
  4328.  
  4329. /*********************************************************************************
  4330. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4331. *********************************************************************************/
  4332.  
  4333. // x~x ordresgowap
  4334.  
  4335. // version Roule' janvier 2017
  4336. function MZ_setCarteUnGogoHTML5() {
  4337. // fabriquer la liste des positions successives
  4338. var listeDepl = []; // ce sera un tableau d'objets
  4339. // position courrante
  4340. var eTitle = document.getElementById('titre2');
  4341. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4342. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4343. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4344. , y: parseInt(tabPos[1])
  4345. , n: parseInt(tabPos[2])
  4346. , nom: tabNomID[2]
  4347. , id: tabNomID[1]});
  4348. // déplacements
  4349. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4350. for(var i=0 ; i<lignes.length ; i++) {
  4351. if(lignes[i].className == 'mh_tdpage_fo') {
  4352. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4353. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4354. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4355. }
  4356. }
  4357. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4358. }
  4359.  
  4360. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4361. function MZ_showCarteBottom(listeSuiv) {
  4362. // générer la carte
  4363. var carte = new carte_MZ('cartegogo', listeSuiv);
  4364. // positionner la carte
  4365. var eCarte = carte.getElt();
  4366. eCarte.style.textAlign = 'left';
  4367. eCarte.style.marginTop = '2px';
  4368. var footer = document.getElementById('footer1');
  4369. // Lieu_Teleport.php n'a pas de footer1 :(
  4370. if (!footer) footer = document.getElementById('footer2');
  4371. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4372. else document.body.appendChild(eCarte);
  4373. }
  4374.  
  4375. function MZ_setCarteTousGogoHTML5() {
  4376. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4377. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4378. var suivants = [];
  4379. for (var i=0;i<ligne.length;i++) {
  4380. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4381. var cas = ligne[i].getElementsByTagName("td")[0];
  4382. //if (cas.className == "mh_tdtitre") {
  4383. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4384. var oGogo = {};
  4385. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4386. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4387. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4388. oGogo.x = parseInt(point[1]);
  4389. oGogo.y = parseInt(point[2]);
  4390. oGogo.n = parseInt(point[3]);
  4391. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4392. }
  4393. }
  4394. if (suivants.length == 0) return;
  4395. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4396. }
  4397.  
  4398. function MZ_setCarteTP() {
  4399. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4400. 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);
  4401. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4402. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4403. }
  4404.  
  4405. /* v0.2 by Dab - 2013-08-31
  4406. * - correction acquisition posale initiale
  4407. * - correction tare et affichage mire
  4408. */
  4409.  
  4410. function setCarteGogo() {
  4411. try {
  4412. //var pars = document.getElementsByTagName('p');
  4413. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4414. var eTitle = document.getElementById('titre2');
  4415. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4416. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4417. var serv_img_cible = URL_MZimg + "rep.png";
  4418.  
  4419. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4420. //var lignes = pars[0].getElementsByTagName('tr');
  4421. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4422. var nbpt = 0;
  4423. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4424. for(var i=0 ; i<lignes.length ; i++) {
  4425. if(lignes[i].className == 'mh_tdpage_fo') {
  4426. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4427. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4428. if(point) {
  4429. nbpt++;
  4430. trajet += point[1]+','+point[2]+','+point[3]+',';
  4431. }
  4432. }
  4433. }
  4434. }
  4435. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4436. 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'/>";
  4437. var base = [-229,-5];
  4438. if (nbpt>0) {
  4439. base = [-684,-5];
  4440. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4441. }
  4442. 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;'/>";
  4443.  
  4444. nvdiv += '<map name="coord_trou">'+
  4445. '<area shape="circle" href="#" coords="260,333,3" title="X=5, Y=-49" >'+
  4446. '<area shape="circle" href="#" coords="262,335,3" title="X=6, Y=-50" >'+
  4447. '<area shape="circle" href="#" coords="260,335,3" title="X=5, Y=-50" >'+
  4448. '<area shape="circle" href="#" coords="262,333,3" title="X=6, Y=-49" >'+
  4449. '<area shape="circle" href="#" coords="294,163,3" title="X=22, Y=36" >'+
  4450. '<area shape="circle" href="#" coords="292,163,3" title="X=21, Y=36" >'+
  4451. '<area shape="circle" href="#" coords="294,165,3" title="X=22, Y=35" >'+
  4452. '<area shape="circle" href="#" coords="292,165,3" title="X=21, Y=35" >'+
  4453. '<area shape="circle" href="#" coords="124,217,3" title="X=-63, Y=9" >'+
  4454. '<area shape="circle" href="#" coords="122,217,3" title="X=-64, Y=9" >'+
  4455. '<area shape="circle" href="#" coords="124,219,3" title="X=-63, Y=8" >'+
  4456. '<area shape="circle" href="#" coords="122,219,3" title="X=-64, Y=8" >'+
  4457. '<area shape="circle" href="#" coords="378,95,3" title="X=64, Y=70" >'+
  4458. '<area shape="circle" href="#" coords="146,121,3" title="X=-52, Y=57" >'+
  4459. '<area shape="circle" href="#" coords="346,313,3" title="X=48, Y=-39" >'+
  4460. '<area shape="circle" href="#" coords="310,339,3" title="X=30, Y=-52" >'+
  4461. '<area shape="circle" href="#" coords="274,265,3" title="X=12, Y=-15" >'+
  4462. '<area shape="circle" href="#" coords="360,95,3" title="X=55, Y=70" >'+
  4463. '<area shape="circle" href="#" coords="224,91,3" title="X=-13, Y=72" >'+
  4464. '<area shape="circle" href="#" coords="226,91,3" title="X=-12, Y=72" >'+
  4465. '<area shape="circle" href="#" coords="224,89,3" title="X=-13, Y=73" >'+
  4466. '<area shape="circle" href="#" coords="226,89,3" title="X=-12, Y=73" >'+
  4467. '<area shape="circle" href="#" coords="148,281,3" title="X=-51, Y=-23" >'+
  4468. '<area shape="circle" href="#" coords="150,281,3" title="X=-50, Y=-23" >'+
  4469. '<area shape="circle" href="#" coords="148,279,3" title="X=-51, Y=-22" >'+
  4470. '<area shape="circle" href="#" coords="150,279,3" title="X=-50, Y=-22" >'+
  4471. '<area shape="circle" href="#" coords="130,301,3" title="X=-60, Y=-33" >'+
  4472. '<area shape="circle" href="#" coords="132,301,3" title="X=-59, Y=-33" >'+
  4473. '<area shape="circle" href="#" coords="130,299,3" title="X=-60, Y=-32" >'+
  4474. '<area shape="circle" href="#" coords="132,299,3" title="X=-59, Y=-32" >'+
  4475. '<area shape="circle" href="#" coords="116,311,3" title="X=-67, Y=-38" >'+
  4476. '<area shape="circle" href="#" coords="118,311,3" title="X=-66, Y=-38" >'+
  4477. '<area shape="circle" href="#" coords="116,309,3" title="X=-67, Y=-37" >'+
  4478. '<area shape="circle" href="#" coords="118,309,3" title="X=-66, Y=-37" >'+
  4479. '<area shape="circle" href="#" coords="260,173,3" title="X=5, Y=31" >'+
  4480. '<area shape="circle" href="#" coords="262,173,3" title="X=6, Y=31" >'+
  4481. '<area shape="circle" href="#" coords="260,171,3" title="X=5, Y=32" >'+
  4482. '<area shape="circle" href="#" coords="262,171,3" title="X=6, Y=32" >'+
  4483. '<area shape="circle" href="#" coords="178,339,3" title="X=-36, Y=-52" >'+
  4484. '<area shape="circle" href="#" coords="180,339,3" title="X=-35, Y=-52" >'+
  4485. '<area shape="circle" href="#" coords="178,337,3" title="X=-36, Y=-51" >'+
  4486. '<area shape="circle" href="#" coords="180,337,3" title="X=-35, Y=-51" >'+
  4487. '<area shape="circle" href="#" coords="182,107,3" title="X=-34, Y=64" >'+
  4488. '<area shape="circle" href="#" coords="182,105,3" title="X=-34, Y=65" >'+
  4489. '<area shape="circle" href="#" coords="270,109,3" title="X=10, Y=63" >'+
  4490. '<area shape="circle" href="#" coords="272,109,3" title="X=11, Y=63" >'+
  4491. '<area shape="circle" href="#" coords="270,107,3" title="X=10, Y=64" >'+
  4492. '<area shape="circle" href="#" coords="272,107,3" title="X=11, Y=64" >'+
  4493. '<area shape="circle" href="#" coords="180,207,3" title="X=-35, Y=14" >'+
  4494. '<area shape="circle" href="#" coords="182,207,3" title="X=-34, Y=14" >'+
  4495. '<area shape="circle" href="#" coords="180,205,3" title="X=-35, Y=15" >'+
  4496. '<area shape="circle" href="#" coords="182,205,3" title="X=-34, Y=15" >'+
  4497. '<area shape="circle" href="#" coords="398,173,3" title="X=74, Y=31" >'+
  4498. '<area shape="circle" href="#" coords="400,173,3" title="X=75, Y=31" >'+
  4499. '<area shape="circle" href="#" coords="398,171,3" title="X=74, Y=32" >'+
  4500. '<area shape="circle" href="#" coords="400,171,3" title="X=75, Y=32" >'+
  4501. '<area shape="circle" href="#" coords="342,133,3" title="X=46, Y=51" >'+
  4502. '<area shape="circle" href="#" coords="344,133,3" title="X=47, Y=51" >'+
  4503. '<area shape="circle" href="#" coords="342,131,3" title="X=46, Y=52" >'+
  4504. '<area shape="circle" href="#" coords="344,131,3" title="X=47, Y=52" >'+
  4505. '<area shape="circle" href="#" coords="180,107,3" title="X=-35, Y=64" >'+
  4506. '<area shape="circle" href="#" coords="180,105,3" title="X=-35, Y=65" >'+
  4507. '<area shape="circle" href="#" coords="108,251,3" title="X=-71, Y=-8" >'+
  4508. '<area shape="circle" href="#" coords="110,251,3" title="X=-70, Y=-8" >'+
  4509. '<area shape="circle" href="#" coords="108,249,3" title="X=-71, Y=-7" >'+
  4510. '<area shape="circle" href="#" coords="110,249,3" title="X=-70, Y=-7" >'+
  4511. '<area shape="circle" href="#" coords="346,191,3" title="X=48, Y=22" >'+
  4512. '<area shape="circle" href="#" coords="346,189,3" title="X=48, Y=23" >'+
  4513. '<area shape="circle" href="#" coords="346,187,3" title="X=48, Y=24" >'+
  4514. '<area shape="circle" href="#" coords="346,185,3" title="X=48, Y=25" >'+
  4515. '<area shape="circle" href="#" coords="348,195,3" title="X=49, Y=20" >'+
  4516. '<area shape="circle" href="#" coords="348,193,3" title="X=49, Y=21" >'+
  4517. '<area shape="circle" href="#" coords="348,191,3" title="X=49, Y=22" >'+
  4518. '<area shape="circle" href="#" coords="348,189,3" title="X=49, Y=23" >'+
  4519. '<area shape="circle" href="#" coords="348,187,3" title="X=49, Y=24" >'+
  4520. '<area shape="circle" href="#" coords="348,185,3" title="X=49, Y=25" >'+
  4521. '<area shape="circle" href="#" coords="348,183,3" title="X=49, Y=26" >'+
  4522. '<area shape="circle" href="#" coords="348,181,3" title="X=49, Y=27" >'+
  4523. '<area shape="circle" href="#" coords="350,199,3" title="X=50, Y=18" >'+
  4524. '<area shape="circle" href="#" coords="350,197,3" title="X=50, Y=19" >'+
  4525. '<area shape="circle" href="#" coords="350,195,3" title="X=50, Y=20" >'+
  4526. '<area shape="circle" href="#" coords="350,193,3" title="X=50, Y=21" >'+
  4527. '<area shape="circle" href="#" coords="350,191,3" title="X=50, Y=22" >'+
  4528. '<area shape="circle" href="#" coords="350,189,3" title="X=50, Y=23" >'+
  4529. '<area shape="circle" href="#" coords="350,187,3" title="X=50, Y=24" >'+
  4530. '<area shape="circle" href="#" coords="350,185,3" title="X=50, Y=25" >'+
  4531. '<area shape="circle" href="#" coords="350,183,3" title="X=50, Y=26" >'+
  4532. '<area shape="circle" href="#" coords="350,181,3" title="X=50, Y=27" >'+
  4533. '<area shape="circle" href="#" coords="350,179,3" title="X=50, Y=28" >'+
  4534. '<area shape="circle" href="#" coords="350,177,3" title="X=50, Y=29" >'+
  4535. '<area shape="circle" href="#" coords="352,201,3" title="X=51, Y=17" >'+
  4536. '<area shape="circle" href="#" coords="352,199,3" title="X=51, Y=18" >'+
  4537. '<area shape="circle" href="#" coords="352,197,3" title="X=51, Y=19" >'+
  4538. '<area shape="circle" href="#" coords="352,195,3" title="X=51, Y=20" >'+
  4539. '<area shape="circle" href="#" coords="352,193,3" title="X=51, Y=21" >'+
  4540. '<area shape="circle" href="#" coords="352,191,3" title="X=51, Y=22" >'+
  4541. '<area shape="circle" href="#" coords="352,189,3" title="X=51, Y=23" >'+
  4542. '<area shape="circle" href="#" coords="352,187,3" title="X=51, Y=24" >'+
  4543. '<area shape="circle" href="#" coords="352,185,3" title="X=51, Y=25" >'+
  4544. '<area shape="circle" href="#" coords="352,183,3" title="X=51, Y=26" >'+
  4545. '<area shape="circle" href="#" coords="352,181,3" title="X=51, Y=27" >'+
  4546. '<area shape="circle" href="#" coords="352,179,3" title="X=51, Y=28" >'+
  4547. '<area shape="circle" href="#" coords="352,177,3" title="X=51, Y=29" >'+
  4548. '<area shape="circle" href="#" coords="352,175,3" title="X=51, Y=30" >'+
  4549. '<area shape="circle" href="#" coords="354,201,3" title="X=52, Y=17" >'+
  4550. '<area shape="circle" href="#" coords="354,199,3" title="X=52, Y=18" >'+
  4551. '<area shape="circle" href="#" coords="354,197,3" title="X=52, Y=19" >'+
  4552. '<area shape="circle" href="#" coords="354,195,3" title="X=52, Y=20" >'+
  4553. '<area shape="circle" href="#" coords="354,193,3" title="X=52, Y=21" >'+
  4554. '<area shape="circle" href="#" coords="354,191,3" title="X=52, Y=22" >'+
  4555. '<area shape="circle" href="#" coords="354,189,3" title="X=52, Y=23" >'+
  4556. '<area shape="circle" href="#" coords="354,187,3" title="X=52, Y=24" >'+
  4557. '<area shape="circle" href="#" coords="354,185,3" title="X=52, Y=25" >'+
  4558. '<area shape="circle" href="#" coords="354,183,3" title="X=52, Y=26" >'+
  4559. '<area shape="circle" href="#" coords="354,181,3" title="X=52, Y=27" >'+
  4560. '<area shape="circle" href="#" coords="354,179,3" title="X=52, Y=28" >'+
  4561. '<area shape="circle" href="#" coords="354,177,3" title="X=52, Y=29" >'+
  4562. '<area shape="circle" href="#" coords="354,175,3" title="X=52, Y=30" >'+
  4563. '<area shape="circle" href="#" coords="356,203,3" title="X=53, Y=16" >'+
  4564. '<area shape="circle" href="#" coords="356,201,3" title="X=53, Y=17" >'+
  4565. '<area shape="circle" href="#" coords="356,199,3" title="X=53, Y=18" >'+
  4566. '<area shape="circle" href="#" coords="356,197,3" title="X=53, Y=19" >'+
  4567. '<area shape="circle" href="#" coords="356,195,3" title="X=53, Y=20" >'+
  4568. '<area shape="circle" href="#" coords="356,193,3" title="X=53, Y=21" >'+
  4569. '<area shape="circle" href="#" coords="356,191,3" title="X=53, Y=22" >'+
  4570. '<area shape="circle" href="#" coords="356,189,3" title="X=53, Y=23" >'+
  4571. '<area shape="circle" href="#" coords="356,187,3" title="X=53, Y=24" >'+
  4572. '<area shape="circle" href="#" coords="356,185,3" title="X=53, Y=25" >'+
  4573. '<area shape="circle" href="#" coords="356,183,3" title="X=53, Y=26" >'+
  4574. '<area shape="circle" href="#" coords="356,181,3" title="X=53, Y=27" >'+
  4575. '<area shape="circle" href="#" coords="356,179,3" title="X=53, Y=28" >'+
  4576. '<area shape="circle" href="#" coords="356,177,3" title="X=53, Y=29" >'+
  4577. '<area shape="circle" href="#" coords="356,175,3" title="X=53, Y=30" >'+
  4578. '<area shape="circle" href="#" coords="356,173,3" title="X=53, Y=31" >'+
  4579. '<area shape="circle" href="#" coords="358,203,3" title="X=54, Y=16" >'+
  4580. '<area shape="circle" href="#" coords="358,201,3" title="X=54, Y=17" >'+
  4581. '<area shape="circle" href="#" coords="358,199,3" title="X=54, Y=18" >'+
  4582. '<area shape="circle" href="#" coords="358,197,3" title="X=54, Y=19" >'+
  4583. '<area shape="circle" href="#" coords="358,195,3" title="X=54, Y=20" >'+
  4584. '<area shape="circle" href="#" coords="358,193,3" title="X=54, Y=21" >'+
  4585. '<area shape="circle" href="#" coords="358,191,3" title="X=54, Y=22" >'+
  4586. '<area shape="circle" href="#" coords="358,189,3" title="X=54, Y=23" >'+
  4587. '<area shape="circle" href="#" coords="358,187,3" title="X=54, Y=24" >'+
  4588. '<area shape="circle" href="#" coords="358,185,3" title="X=54, Y=25" >'+
  4589. '<area shape="circle" href="#" coords="358,183,3" title="X=54, Y=26" >'+
  4590. '<area shape="circle" href="#" coords="358,181,3" title="X=54, Y=27" >'+
  4591. '<area shape="circle" href="#" coords="358,179,3" title="X=54, Y=28" >'+
  4592. '<area shape="circle" href="#" coords="358,177,3" title="X=54, Y=29" >'+
  4593. '<area shape="circle" href="#" coords="358,175,3" title="X=54, Y=30" >'+
  4594. '<area shape="circle" href="#" coords="358,173,3" title="X=54, Y=31" >'+
  4595. '<area shape="circle" href="#" coords="360,205,3" title="X=55, Y=15" >'+
  4596. '<area shape="circle" href="#" coords="360,203,3" title="X=55, Y=16" >'+
  4597. '<area shape="circle" href="#" coords="360,201,3" title="X=55, Y=17" >'+
  4598. '<area shape="circle" href="#" coords="360,199,3" title="X=55, Y=18" >'+
  4599. '<area shape="circle" href="#" coords="360,197,3" title="X=55, Y=19" >'+
  4600. '<area shape="circle" href="#" coords="360,195,3" title="X=55, Y=20" >'+
  4601. '<area shape="circle" href="#" coords="360,193,3" title="X=55, Y=21" >'+
  4602. '<area shape="circle" href="#" coords="360,191,3" title="X=55, Y=22" >'+
  4603. '<area shape="circle" href="#" coords="360,189,3" title="X=55, Y=23" >'+
  4604. '<area shape="circle" href="#" coords="360,187,3" title="X=55, Y=24" >'+
  4605. '<area shape="circle" href="#" coords="360,185,3" title="X=55, Y=25" >'+
  4606. '<area shape="circle" href="#" coords="360,183,3" title="X=55, Y=26" >'+
  4607. '<area shape="circle" href="#" coords="360,181,3" title="X=55, Y=27" >'+
  4608. '<area shape="circle" href="#" coords="360,179,3" title="X=55, Y=28" >'+
  4609. '<area shape="circle" href="#" coords="360,177,3" title="X=55, Y=29" >'+
  4610. '<area shape="circle" href="#" coords="360,175,3" title="X=55, Y=30" >'+
  4611. '<area shape="circle" href="#" coords="360,173,3" title="X=55, Y=31" >'+
  4612. '<area shape="circle" href="#" coords="360,171,3" title="X=55, Y=32" >'+
  4613. '<area shape="circle" href="#" coords="362,205,3" title="X=56, Y=15" >'+
  4614. '<area shape="circle" href="#" coords="362,203,3" title="X=56, Y=16" >'+
  4615. '<area shape="circle" href="#" coords="362,201,3" title="X=56, Y=17" >'+
  4616. '<area shape="circle" href="#" coords="362,199,3" title="X=56, Y=18" >'+
  4617. '<area shape="circle" href="#" coords="362,197,3" title="X=56, Y=19" >'+
  4618. '<area shape="circle" href="#" coords="362,195,3" title="X=56, Y=20" >'+
  4619. '<area shape="circle" href="#" coords="362,193,3" title="X=56, Y=21" >'+
  4620. '<area shape="circle" href="#" coords="362,191,3" title="X=56, Y=22" >'+
  4621. '<area shape="circle" href="#" coords="362,189,3" title="X=56, Y=23" >'+
  4622. '<area shape="circle" href="#" coords="362,187,3" title="X=56, Y=24" >'+
  4623. '<area shape="circle" href="#" coords="362,185,3" title="X=56, Y=25" >'+
  4624. '<area shape="circle" href="#" coords="362,183,3" title="X=56, Y=26" >'+
  4625. '<area shape="circle" href="#" coords="362,181,3" title="X=56, Y=27" >'+
  4626. '<area shape="circle" href="#" coords="362,179,3" title="X=56, Y=28" >'+
  4627. '<area shape="circle" href="#" coords="362,177,3" title="X=56, Y=29" >'+
  4628. '<area shape="circle" href="#" coords="362,175,3" title="X=56, Y=30" >'+
  4629. '<area shape="circle" href="#" coords="362,173,3" title="X=56, Y=31" >'+
  4630. '<area shape="circle" href="#" coords="362,171,3" title="X=56, Y=32" >'+
  4631. '<area shape="circle" href="#" coords="364,205,3" title="X=57, Y=15" >'+
  4632. '<area shape="circle" href="#" coords="364,203,3" title="X=57, Y=16" >'+
  4633. '<area shape="circle" href="#" coords="364,201,3" title="X=57, Y=17" >'+
  4634. '<area shape="circle" href="#" coords="364,199,3" title="X=57, Y=18" >'+
  4635. '<area shape="circle" href="#" coords="364,197,3" title="X=57, Y=19" >'+
  4636. '<area shape="circle" href="#" coords="364,195,3" title="X=57, Y=20" >'+
  4637. '<area shape="circle" href="#" coords="364,193,3" title="X=57, Y=21" >'+
  4638. '<area shape="circle" href="#" coords="364,191,3" title="X=57, Y=22" >'+
  4639. '<area shape="circle" href="#" coords="364,189,3" title="X=57, Y=23" >'+
  4640. '<area shape="circle" href="#" coords="364,187,3" title="X=57, Y=24" >'+
  4641. '<area shape="circle" href="#" coords="364,185,3" title="X=57, Y=25" >'+
  4642. '<area shape="circle" href="#" coords="364,183,3" title="X=57, Y=26" >'+
  4643. '<area shape="circle" href="#" coords="364,181,3" title="X=57, Y=27" >'+
  4644. '<area shape="circle" href="#" coords="364,179,3" title="X=57, Y=28" >'+
  4645. '<area shape="circle" href="#" coords="364,177,3" title="X=57, Y=29" >'+
  4646. '<area shape="circle" href="#" coords="364,175,3" title="X=57, Y=30" >'+
  4647. '<area shape="circle" href="#" coords="364,173,3" title="X=57, Y=31" >'+
  4648. '<area shape="circle" href="#" coords="364,171,3" title="X=57, Y=32" >'+
  4649. '<area shape="circle" href="#" coords="366,205,3" title="X=58, Y=15" >'+
  4650. '<area shape="circle" href="#" coords="366,203,3" title="X=58, Y=16" >'+
  4651. '<area shape="circle" href="#" coords="366,201,3" title="X=58, Y=17" >'+
  4652. '<area shape="circle" href="#" coords="366,199,3" title="X=58, Y=18" >'+
  4653. '<area shape="circle" href="#" coords="366,197,3" title="X=58, Y=19" >'+
  4654. '<area shape="circle" href="#" coords="366,195,3" title="X=58, Y=20" >'+
  4655. '<area shape="circle" href="#" coords="366,193,3" title="X=58, Y=21" >'+
  4656. '<area shape="circle" href="#" coords="366,191,3" title="X=58, Y=22" >'+
  4657. '<area shape="circle" href="#" coords="366,189,3" title="X=58, Y=23" >'+
  4658. '<area shape="circle" href="#" coords="366,187,3" title="X=58, Y=24" >'+
  4659. '<area shape="circle" href="#" coords="366,185,3" title="X=58, Y=25" >'+
  4660. '<area shape="circle" href="#" coords="366,183,3" title="X=58, Y=26" >'+
  4661. '<area shape="circle" href="#" coords="366,181,3" title="X=58, Y=27" >'+
  4662. '<area shape="circle" href="#" coords="366,179,3" title="X=58, Y=28" >'+
  4663. '<area shape="circle" href="#" coords="366,177,3" title="X=58, Y=29" >'+
  4664. '<area shape="circle" href="#" coords="366,175,3" title="X=58, Y=30" >'+
  4665. '<area shape="circle" href="#" coords="366,173,3" title="X=58, Y=31" >'+
  4666. '<area shape="circle" href="#" coords="366,171,3" title="X=58, Y=32" >'+
  4667. '<area shape="circle" href="#" coords="368,203,3" title="X=59, Y=16" >'+
  4668. '<area shape="circle" href="#" coords="368,201,3" title="X=59, Y=17" >'+
  4669. '<area shape="circle" href="#" coords="368,199,3" title="X=59, Y=18" >'+
  4670. '<area shape="circle" href="#" coords="368,197,3" title="X=59, Y=19" >'+
  4671. '<area shape="circle" href="#" coords="368,195,3" title="X=59, Y=20" >'+
  4672. '<area shape="circle" href="#" coords="368,193,3" title="X=59, Y=21" >'+
  4673. '<area shape="circle" href="#" coords="368,191,3" title="X=59, Y=22" >'+
  4674. '<area shape="circle" href="#" coords="368,189,3" title="X=59, Y=23" >'+
  4675. '<area shape="circle" href="#" coords="368,187,3" title="X=59, Y=24" >'+
  4676. '<area shape="circle" href="#" coords="368,185,3" title="X=59, Y=25" >'+
  4677. '<area shape="circle" href="#" coords="368,183,3" title="X=59, Y=26" >'+
  4678. '<area shape="circle" href="#" coords="368,181,3" title="X=59, Y=27" >'+
  4679. '<area shape="circle" href="#" coords="368,179,3" title="X=59, Y=28" >'+
  4680. '<area shape="circle" href="#" coords="368,177,3" title="X=59, Y=29" >'+
  4681. '<area shape="circle" href="#" coords="368,175,3" title="X=59, Y=30" >'+
  4682. '<area shape="circle" href="#" coords="368,173,3" title="X=59, Y=31" >'+
  4683. '<area shape="circle" href="#" coords="370,203,3" title="X=60, Y=16" >'+
  4684. '<area shape="circle" href="#" coords="370,201,3" title="X=60, Y=17" >'+
  4685. '<area shape="circle" href="#" coords="370,199,3" title="X=60, Y=18" >'+
  4686. '<area shape="circle" href="#" coords="370,197,3" title="X=60, Y=19" >'+
  4687. '<area shape="circle" href="#" coords="370,195,3" title="X=60, Y=20" >'+
  4688. '<area shape="circle" href="#" coords="370,193,3" title="X=60, Y=21" >'+
  4689. '<area shape="circle" href="#" coords="370,191,3" title="X=60, Y=22" >'+
  4690. '<area shape="circle" href="#" coords="370,189,3" title="X=60, Y=23" >'+
  4691. '<area shape="circle" href="#" coords="370,187,3" title="X=60, Y=24" >'+
  4692. '<area shape="circle" href="#" coords="370,185,3" title="X=60, Y=25" >'+
  4693. '<area shape="circle" href="#" coords="370,183,3" title="X=60, Y=26" >'+
  4694. '<area shape="circle" href="#" coords="370,181,3" title="X=60, Y=27" >'+
  4695. '<area shape="circle" href="#" coords="370,179,3" title="X=60, Y=28" >'+
  4696. '<area shape="circle" href="#" coords="370,177,3" title="X=60, Y=29" >'+
  4697. '<area shape="circle" href="#" coords="370,175,3" title="X=60, Y=30" >'+
  4698. '<area shape="circle" href="#" coords="370,173,3" title="X=60, Y=31" >'+
  4699. '<area shape="circle" href="#" coords="372,201,3" title="X=61, Y=17" >'+
  4700. '<area shape="circle" href="#" coords="372,199,3" title="X=61, Y=18" >'+
  4701. '<area shape="circle" href="#" coords="372,197,3" title="X=61, Y=19" >'+
  4702. '<area shape="circle" href="#" coords="372,195,3" title="X=61, Y=20" >'+
  4703. '<area shape="circle" href="#" coords="372,193,3" title="X=61, Y=21" >'+
  4704. '<area shape="circle" href="#" coords="372,191,3" title="X=61, Y=22" >'+
  4705. '<area shape="circle" href="#" coords="372,189,3" title="X=61, Y=23" >'+
  4706. '<area shape="circle" href="#" coords="372,187,3" title="X=61, Y=24" >'+
  4707. '<area shape="circle" href="#" coords="372,185,3" title="X=61, Y=25" >'+
  4708. '<area shape="circle" href="#" coords="372,183,3" title="X=61, Y=26" >'+
  4709. '<area shape="circle" href="#" coords="372,181,3" title="X=61, Y=27" >'+
  4710. '<area shape="circle" href="#" coords="372,179,3" title="X=61, Y=28" >'+
  4711. '<area shape="circle" href="#" coords="372,177,3" title="X=61, Y=29" >'+
  4712. '<area shape="circle" href="#" coords="372,175,3" title="X=61, Y=30" >'+
  4713. '<area shape="circle" href="#" coords="374,201,3" title="X=62, Y=17" >'+
  4714. '<area shape="circle" href="#" coords="374,199,3" title="X=62, Y=18" >'+
  4715. '<area shape="circle" href="#" coords="374,197,3" title="X=62, Y=19" >'+
  4716. '<area shape="circle" href="#" coords="374,195,3" title="X=62, Y=20" >'+
  4717. '<area shape="circle" href="#" coords="374,193,3" title="X=62, Y=21" >'+
  4718. '<area shape="circle" href="#" coords="374,191,3" title="X=62, Y=22" >'+
  4719. '<area shape="circle" href="#" coords="374,189,3" title="X=62, Y=23" >'+
  4720. '<area shape="circle" href="#" coords="374,187,3" title="X=62, Y=24" >'+
  4721. '<area shape="circle" href="#" coords="374,185,3" title="X=62, Y=25" >'+
  4722. '<area shape="circle" href="#" coords="374,183,3" title="X=62, Y=26" >'+
  4723. '<area shape="circle" href="#" coords="374,181,3" title="X=62, Y=27" >'+
  4724. '<area shape="circle" href="#" coords="374,179,3" title="X=62, Y=28" >'+
  4725. '<area shape="circle" href="#" coords="374,177,3" title="X=62, Y=29" >'+
  4726. '<area shape="circle" href="#" coords="374,175,3" title="X=62, Y=30" >'+
  4727. '<area shape="circle" href="#" coords="376,199,3" title="X=63, Y=18" >'+
  4728. '<area shape="circle" href="#" coords="376,197,3" title="X=63, Y=19" >'+
  4729. '<area shape="circle" href="#" coords="376,195,3" title="X=63, Y=20" >'+
  4730. '<area shape="circle" href="#" coords="376,193,3" title="X=63, Y=21" >'+
  4731. '<area shape="circle" href="#" coords="376,191,3" title="X=63, Y=22" >'+
  4732. '<area shape="circle" href="#" coords="376,189,3" title="X=63, Y=23" >'+
  4733. '<area shape="circle" href="#" coords="376,187,3" title="X=63, Y=24" >'+
  4734. '<area shape="circle" href="#" coords="376,185,3" title="X=63, Y=25" >'+
  4735. '<area shape="circle" href="#" coords="376,183,3" title="X=63, Y=26" >'+
  4736. '<area shape="circle" href="#" coords="376,181,3" title="X=63, Y=27" >'+
  4737. '<area shape="circle" href="#" coords="376,179,3" title="X=63, Y=28" >'+
  4738. '<area shape="circle" href="#" coords="376,177,3" title="X=63, Y=29" >'+
  4739. '<area shape="circle" href="#" coords="378,195,3" title="X=64, Y=20" >'+
  4740. '<area shape="circle" href="#" coords="378,193,3" title="X=64, Y=21" >'+
  4741. '<area shape="circle" href="#" coords="378,191,3" title="X=64, Y=22" >'+
  4742. '<area shape="circle" href="#" coords="378,189,3" title="X=64, Y=23" >'+
  4743. '<area shape="circle" href="#" coords="378,187,3" title="X=64, Y=24" >'+
  4744. '<area shape="circle" href="#" coords="378,185,3" title="X=64, Y=25" >'+
  4745. '<area shape="circle" href="#" coords="378,183,3" title="X=64, Y=26" >'+
  4746. '<area shape="circle" href="#" coords="378,181,3" title="X=64, Y=27" >'+
  4747. '<area shape="circle" href="#" coords="380,191,3" title="X=65, Y=22" >'+
  4748. '<area shape="circle" href="#" coords="380,189,3" title="X=65, Y=23" >'+
  4749. '<area shape="circle" href="#" coords="380,187,3" title="X=65, Y=24" >'+
  4750. '<area shape="circle" href="#" coords="380,185,3" title="X=65, Y=25" >'+
  4751. '</map>';
  4752.  
  4753. var nvspan = document.createElement('div');
  4754. nvspan.align = 'center';
  4755. nvspan.id = 'mz_mapdiv';
  4756. nvspan.valign = 'top';
  4757. nvspan.innerHTML = nvdiv;
  4758. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4759. var footer = document.getElementById('footer1');
  4760. footer.parentNode.insertBefore(nvspan,footer);
  4761. }
  4762.  
  4763. function testeGlissiere() {
  4764. try {
  4765. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4766. var footer = document.getElementById('footer1');
  4767. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4768. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4769. }
  4770.  
  4771. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4772. if (x0 !== undefined) {
  4773. // ouais, récursif une fois
  4774. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4775. if (PtInterm === undefined)
  4776. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4777. else
  4778. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4779. return;
  4780. }
  4781. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4782. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4783. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4784. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4785. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4786. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4787. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4788. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4789. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4790. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4791. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4792. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4793. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4794. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4795. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4796. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4797. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4798. }
  4799.  
  4800. function do_ordresgowap() {
  4801. if (newCarte) {
  4802. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4803. //testeGlissiere();
  4804. //MZ_testsUnitairesCalculIntermediaire();
  4805. } else {
  4806. setCarteGogo(); // Via script des trouillots
  4807. }
  4808. }
  4809.  
  4810. function do_listegowap() {
  4811. if (!newCarte) return;
  4812. MZ_setCarteTousGogoHTML5();
  4813. }
  4814.  
  4815. function do_lieuDescription() {
  4816. if (!newCarte) return;
  4817. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4818. MZ_setCarteTP();
  4819. }
  4820.  
  4821. function do_lieuTeleport() {
  4822. changeButtonValidate();
  4823. if (!newCarte) return;
  4824. MZ_setCarteTP();
  4825. }
  4826.  
  4827. /*********************************************************************************
  4828. * This file is part of Mountyzilla. *
  4829. * *
  4830. * Mountyzilla is free software; you can redistribute it and/or modify *
  4831. * it under the terms of the GNU General Public License as published by *
  4832. * the Free Software Foundation; either version 2 of the License, or *
  4833. * (at your option) any later version. *
  4834. * *
  4835. * Mountyzilla is distributed in the hope that it will be useful, *
  4836. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4837. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4838. * GNU General Public License for more details. *
  4839. * *
  4840. * You should have received a copy of the GNU General Public License *
  4841. * along with Mountyzilla; if not, write to the Free Software *
  4842. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4843. *********************************************************************************/
  4844.  
  4845. // x~x attaque
  4846.  
  4847. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4848.  
  4849. function do_attaque() {
  4850. }
  4851.  
  4852. /*******************************************************************************
  4853. * This file is part of Mountyzilla. *
  4854. * *
  4855. * Mountyzilla is free software; you can redistribute it and/or modify *
  4856. * it under the terms of the GNU General Public License as published by *
  4857. * the Free Software Foundation; either version 2 of the License, or *
  4858. * (at your option) any later version. *
  4859. * *
  4860. * Mountyzilla is distributed in the hope that it will be useful, *
  4861. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4862. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4863. * GNU General Public License for more details. *
  4864. * *
  4865. * You should have received a copy of the GNU General Public License *
  4866. * along with Mountyzilla; if not, write to the Free Software *
  4867. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4868. *******************************************************************************/
  4869.  
  4870. // x~x infomonstre
  4871.  
  4872. // DEBUG
  4873. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4874. // À corriger, évidemment.
  4875. var listeCDM = {};
  4876. var nomMonstre='';
  4877. var idMonstre=-1;
  4878. var tbody;
  4879. var popup;
  4880.  
  4881. function traiteMonstre() {
  4882. try {
  4883. var nodeTitre = document.evaluate(
  4884. "//div[@class='titre2' and contains(text(),'(')]",
  4885. document, null, 9, null
  4886. ).singleNodeValue;
  4887. var texte = nodeTitre.firstChild.nodeValue;
  4888. } catch(e) {
  4889. window.console.log(traceStack(e, 'traiteMonstre'));
  4890. return;
  4891. }
  4892. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4893. if(nomMonstre.indexOf(']')!=-1) {
  4894. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4895. }
  4896. idMonstre = texte.match(/\d+/)[0];
  4897. FF_XMLHttpRequest({
  4898. method: 'GET',
  4899. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4900. +MY_getValue('CDMID')
  4901. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4902. headers : {
  4903. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4904. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4905. },
  4906. trace: 'info monstre ' + nomMonstre,
  4907. onload: function(responseDetails) {
  4908. try {
  4909. var texte = responseDetails.responseText;
  4910. var lines = texte.split("\n");
  4911. if(lines.length>=1) {
  4912. var infos = lines[0].split(";");
  4913. if(infos.length<4) { return; }
  4914. var idMonstre = infos[0];
  4915. infos=infos.slice(3);
  4916. listeCDM[idMonstre]=infos;
  4917. computeMissionInfomonstre();
  4918. }
  4919. } catch(e) {
  4920. window.alert(e);
  4921. }
  4922. }
  4923. });
  4924. }
  4925.  
  4926. function initPopupInfomonstre() {
  4927. // Initialise le popup tactique (calculs att/deg)
  4928. popup = document.createElement('div');
  4929. popup.id = 'popup';
  4930. popup.className = 'mh_textbox';
  4931. popup.style =
  4932. 'position: absolute;'+
  4933. 'border: 1px solid #000000;'+
  4934. 'visibility: hidden;'+
  4935. 'display: inline;'+
  4936. 'z-index: 3;'+
  4937. 'max-width: 400px;';
  4938. document.body.appendChild(popup);
  4939. }
  4940.  
  4941. function showPopupTactique(evt) {
  4942. try {
  4943. var id = this.id;
  4944. var nom = this.nom;
  4945. var texte = getAnalyseTactique(id,nom);
  4946. if(texte=='') { return; }
  4947. popup.innerHTML = texte;
  4948. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4949. if(isPage("View/MonsterView")) {
  4950. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4951. } else {
  4952. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4953. }
  4954. popup.style.top = evt.pageY+15+'px';
  4955. popup.style.visibility = 'visible';
  4956. } catch(e) {
  4957. window.alert(e);
  4958. }
  4959. }
  4960.  
  4961. // roule 16/03/2016, existe déjà ailleurs
  4962. // function hidePopup() {
  4963. // popup.style.visibility = 'hidden';
  4964. // }
  4965.  
  4966. function toggleTableau() {
  4967. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4968. }
  4969.  
  4970. function computeMissionInfomonstre() {
  4971. // C'est quoi ce titre de fonction ? (O_o)
  4972. try {
  4973. var nodeInsert = document.evaluate(
  4974. "//div[@class = 'titre3']",
  4975. document, null, 9, null
  4976. ).singleNodeValue;
  4977. } catch(e) {
  4978. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4979. return;
  4980. }
  4981. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4982. table.align = 'center';
  4983. tbody = table.childNodes[1];
  4984. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4985. table.firstChild.firstChild.onmouseover = function() {
  4986. this.style.cursor = 'pointer';
  4987. this.className = 'mh_tdpage';
  4988. };
  4989. table.firstChild.firstChild.onmouseout = function() {
  4990. this.className = 'mh_tdtitre';
  4991. };
  4992. tbody.style.display = 'none';
  4993. table.style.width = '350px';
  4994. insertBefore(nodeInsert,table);
  4995. }
  4996.  
  4997. function do_infomonstre() {
  4998. start_script();
  4999. try {
  5000. initPopupInfomonstre();
  5001. traiteMonstre();
  5002. } catch(e) {
  5003. window.alert('Erreur infoMonstre:\n'+e);
  5004. }
  5005. displayScriptTime();
  5006. }
  5007.  
  5008. /*******************************************************************************
  5009. * This file is part of Mountyzilla. *
  5010. * *
  5011. * Mountyzilla is free software; you can redistribute it and/or modify *
  5012. * it under the terms of the GNU General Public License as published by *
  5013. * the Free Software Foundation; either version 2 of the License, or *
  5014. * (at your option) any later version. *
  5015. * *
  5016. * Mountyzilla is distributed in the hope that it will be useful, *
  5017. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5018. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5019. * GNU General Public License for more details. *
  5020. * *
  5021. * You should have received a copy of the GNU General Public License *
  5022. * along with Mountyzilla; if not, write to the Free Software *
  5023. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5024. *******************************************************************************/
  5025.  
  5026. // x~x mission
  5027.  
  5028. /* TODO
  5029. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  5030. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  5031. *
  5032. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  5033. */
  5034. function isArray(a) {
  5035. return (!!a) && (a.constructor === Array);
  5036. }
  5037.  
  5038. function saveMission(num,obEtape) {
  5039. var obMissions;
  5040. if(MY_getValue(numTroll+'.MISSIONS')) {
  5041. try {
  5042. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5043. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  5044. } catch(e) {
  5045. window.console.error(traceStack(e, 'Mission parsage'));
  5046. return;
  5047. }
  5048. }
  5049. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  5050. if (obMissions == undefined) obMissions = new Object(); // protection
  5051. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  5052. if(obEtape) {
  5053. obMissions[num] = obEtape;
  5054. } else if(obMissions[num]) {
  5055. delete obMissions[num];
  5056. }
  5057. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  5058. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5059. }
  5060.  
  5061. function addtroogle(tdLibelle, sRestrict) {
  5062. var img = document.createElement('img');
  5063. img.src = URL_MZimg + 'troogle.ico';
  5064. img.alt = 'Troogle logo';
  5065. var a = document.createElement('a');
  5066. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  5067. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  5068. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  5069. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  5070. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  5071. a.href = url;
  5072. a.title = 'Chercher sur Troogle';
  5073. a.target = 'troogle';
  5074. a.appendChild(img);
  5075. tdLibelle.appendChild(a);
  5076. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  5077. }
  5078.  
  5079. function traiteMission() {
  5080. try {
  5081. var titreMission = document.getElementsByClassName('titre2')[0];
  5082. var numMission = titreMission.textContent.match(/\d+/)[0];
  5083. var missionForm = document.getElementsByName('ActionForm')[0];
  5084. var tdLibelle = document.evaluate(
  5085. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  5086. missionForm, null, 9, null).singleNodeValue;
  5087. } catch(e) {
  5088. window.console.error(traceStack(e, 'récupération mission'));
  5089. return;
  5090. }
  5091. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  5092. try {
  5093. if(!tdLibelle) {
  5094. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  5095. debugMZ('traiteMission, la mission semble terminée');
  5096. saveMission(numMission,false);
  5097. return;
  5098. }
  5099.  
  5100. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  5101. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  5102. // debug Roule'
  5103. if (MY_DEBUG) {
  5104. for (var i =0; i < tdLibelle.childNodes.length; i++)
  5105. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  5106. }
  5107. if(libelle.indexOf('niveau égal à')!=-1) {
  5108. var nbKills = 1, niveau, mod;
  5109. // exemples :
  5110. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  5111. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  5112. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  5113. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  5114. if (tdLibelle.childNodes.length == 1) {
  5115. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  5116. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  5117. if (m) {
  5118. niveau = Number(m[1]);
  5119. mod = 'plus'
  5120. } else {
  5121. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  5122. if (m) {
  5123. niveau = Number(m[1]);
  5124. mod = Number(m[2]);
  5125. } else {
  5126. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  5127. return;
  5128. }
  5129. }
  5130. } else {
  5131. // ancienne méthode (multi childnode)
  5132. // à supprimer un jour peut-être
  5133. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  5134. // Étape de kill multiple de niveau donné
  5135. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5136. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  5137. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5138. niveau = Number(mod[0]);
  5139. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5140. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  5141. } else {
  5142. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  5143. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5144. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  5145. mod = mod ? Number(mod[0]) : 'plus';
  5146. }
  5147. } else {
  5148. // Étape de kill unique de niveau donné
  5149. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  5150. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5151. mod = mod ? Number(mod[0]) : 'plus';
  5152. }
  5153. }
  5154. // debug Roule'
  5155. if (MY_DEBUG) {
  5156. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  5157. }
  5158. saveMission(numMission,{
  5159. type: 'Niveau',
  5160. niveau: niveau,
  5161. mod: mod,
  5162. mundidey: siMundidey,
  5163. libelle: libelle
  5164. });
  5165. if (mod == 'plus')
  5166. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  5167. else
  5168. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  5169. } else if(libelle.indexOf('de la race')!=-1) {
  5170. var nbKills = 1, race;
  5171. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  5172. // Étape de kill multiple de race donnée
  5173. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5174. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5175. } else {
  5176. // Étape de kill unique de race donnée
  5177. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5178. }
  5179. race = race.replace(/\"/g,'');
  5180. race = removeEnclosingSimpleCote(race); // Roule 29/03/2019 Maintenant, on a des '
  5181. saveMission(numMission,{
  5182. type: 'Race',
  5183. race: race,
  5184. mundidey: siMundidey,
  5185. libelle: libelle
  5186. });
  5187. addtroogle(tdLibelle, '@monstre ' + race);
  5188. } else if(libelle.indexOf('de la famille')!=-1) {
  5189. var nbKills = 1, famille;
  5190. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  5191. // Étape de kill multiple de famille donnée
  5192. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5193. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5194. } else {
  5195. // Étape de kill unique de famille donnée
  5196. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5197. }
  5198. famille = famille.replace(/\"/g,'');
  5199. famille = removeEnclosingSimpleCote(famille); // Roule 29/03/2019 Maintenant, on a des '
  5200. saveMission(numMission,{
  5201. type: 'Famille',
  5202. famille: famille,
  5203. mundidey: siMundidey,
  5204. libelle: libelle
  5205. });
  5206. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  5207. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  5208. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  5209. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  5210. debugMZ('traiteMission étape capacité spéciale');
  5211. pouvoir = removeEnclosingSimpleCote(pouvoir); // Roule 29/03/2019 Maintenant, on a des '
  5212. saveMission(numMission,{
  5213. type: 'Pouvoir',
  5214. pouvoir: pouvoir,
  5215. libelle: libelle
  5216. });
  5217. } else {
  5218. debugMZ('traiteMission étape pas pour troogle');
  5219. saveMission(numMission,false);
  5220. }
  5221. } catch(e) {
  5222. window.console.error(traceStack(e, 'récupération étape mission'));
  5223. return;
  5224. }
  5225. }
  5226.  
  5227. function removeEnclosingSimpleCote(x) { // Roule 29/03/2019
  5228. return x.replace(/'$/, '').replace(/^'/, '');
  5229. }
  5230.  
  5231. function do_mission() {
  5232. start_script(60);
  5233.  
  5234. traiteMission();
  5235.  
  5236. displayScriptTime();
  5237. }
  5238.  
  5239. /*******************************************************************************
  5240. * This file is part of Mountyzilla. *
  5241. * *
  5242. * Mountyzilla is free software; you can redistribute it and/or modify *
  5243. * it under the terms of the GNU General Public License as published by *
  5244. * the Free Software Foundation; either version 2 of the License, or *
  5245. * (at your option) any later version. *
  5246. * *
  5247. * Mountyzilla is distributed in the hope that it will be useful, *
  5248. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5249. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5250. * GNU General Public License for more details. *
  5251. * *
  5252. * You should have received a copy of the GNU General Public License *
  5253. * along with Mountyzilla; if not, write to the Free Software *
  5254. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5255. *******************************************************************************/
  5256.  
  5257. // x~x move
  5258.  
  5259. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  5260.  
  5261. var petitsTrous = {
  5262. '-52;57': true,
  5263. '55;70': true,
  5264. '64;70': true,
  5265. '12;-15': true,
  5266. '30;-52': true,
  5267. '48;-39': true
  5268. };
  5269.  
  5270. var grosTrous = {
  5271. '-35;65': true,
  5272. '-13;73': true,
  5273. '-64;9': true,
  5274. '-35;15': true,
  5275. '5;32': true,
  5276. '10;64': true,
  5277. '21;36': true,
  5278. '46;52': true,
  5279. '74;32': true,
  5280. '-71;-7': true,
  5281. '-67;-37': true,
  5282. '-60;-32': true,
  5283. '-51;-22': true,
  5284. '-36;-51': true,
  5285. '5;-49': true
  5286. };
  5287.  
  5288. var centreCarmine_X = 56.5;
  5289. var centreCarmine_Y = 23.5;
  5290. var rayonCarmine = 8.7;
  5291.  
  5292. function isTrou(x,y,n) {
  5293. if(petitsTrous[x+';'+y]) {
  5294. return n<0 && n>-60;
  5295. }
  5296. if(grosTrous[x+';'+y]
  5297. || grosTrous[x-1+';'+y]
  5298. || grosTrous[x+';'+y+1]
  5299. || grosTrous[x-1+';'+y+1]) {
  5300. return n<0 && n>-70;
  5301. }
  5302. if(Math.sqrt(
  5303. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  5304. )<=rayonCarmine) {
  5305. return n<0 && n>-100;
  5306. }
  5307. return false;
  5308. }
  5309.  
  5310. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  5311.  
  5312. function validateDestination() {
  5313. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  5314. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  5315. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  5316. var form = document.getElementsByName('ActionForm')[0];
  5317. if(form) {
  5318. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  5319. if(document.getElementsByName('ai_DeplX')[i].checked) {
  5320. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  5321. }
  5322. }
  5323. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  5324. if(document.getElementsByName('ai_DeplY')[i].checked) {
  5325. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  5326. }
  5327. }
  5328. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  5329. if(document.getElementsByName('ai_DeplN')[i].checked) {
  5330. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  5331. }
  5332. }
  5333. if(isTrou(x,y,n)) {
  5334. return window.confirm(
  5335. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5336. +'Vous allez tomber dans un trou de météorite.\n'
  5337. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  5338. );
  5339. }
  5340. }
  5341. return true;
  5342. }
  5343.  
  5344. function newsubmitDE(event) {
  5345. event.stopPropagation();
  5346. event.preventDefault();
  5347. if(validateDestination()) {
  5348. this.submit();
  5349. }
  5350. }
  5351.  
  5352. function changeValidation() {
  5353. var form = document.getElementsByName('ActionForm')[0];
  5354. if(form) {
  5355. form.addEventListener('submit', newsubmitDE, true);
  5356. }
  5357. }
  5358.  
  5359.  
  5360. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  5361.  
  5362. function validateTPDestination() {
  5363. try {
  5364. var text = document.getElementsByTagName('B')[0];
  5365. var a = text.firstChild.nodeValue.split('|');
  5366. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  5367. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  5368. var pos_n = a[2].substring(5, a[2].length) * 1;
  5369.  
  5370. var nbtrous = 0;
  5371. for(var signX=-1 ; signX<=1 ; signX+=2) {
  5372. for(var x=0 ; x<=2 ; x++) {
  5373. for(var signY=-1 ; signY<=1 ; signY+=2) {
  5374. for(var y=0 ; y<=2 ; y++) {
  5375. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  5376. for(var n = 0 ; n <= 1 ; n++) {
  5377. if(isTrou(
  5378. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  5379. )) {
  5380. nbtrous++;
  5381. }
  5382. }
  5383. }
  5384. }
  5385. }
  5386. }
  5387. }
  5388. if(nbtrous>0 && nbtrous<72) {
  5389. return window.confirm(
  5390. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5391. +'Vous avez '+Math.floor((100*nbtrous)/144)
  5392. +'% de risque de tomber dans un trou de météorite.\n'
  5393. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  5394. );
  5395. }
  5396. else if(nbtrous>=72) {
  5397. return window.confirm(
  5398. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  5399. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  5400. +'% de risque de tomber dans un trou de météorite !\n'
  5401. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  5402. );
  5403. }
  5404. return true;
  5405. }
  5406. catch(e) {
  5407. window.alert(e)
  5408. }
  5409. }
  5410.  
  5411. function newsubmitTP(event) {
  5412. event.stopPropagation();
  5413. event.preventDefault();
  5414. if(validateTPDestination()) {
  5415. this.submit();
  5416. }
  5417. }
  5418.  
  5419. function changeButtonValidate() {
  5420. var form = document.getElementsByName('Formulaire')[0];
  5421. if(form) {
  5422. if(!form.getAttribute('onsubmit')) {
  5423. form.setAttribute('onsubmit','return true;');
  5424. }
  5425. form.addEventListener('submit', newsubmitTP, true);
  5426. }
  5427. }
  5428.  
  5429.  
  5430. /*-[functions]---------------- Partie Principale -----------------------------*/
  5431.  
  5432. function do_move() {
  5433. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  5434. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  5435. changeValidation();
  5436. //}
  5437. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  5438. // changeButtonValidate();
  5439. //}
  5440. }
  5441.  
  5442. /*******************************************************************************
  5443. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  5444. * Mountyzilla is free software; provided under the GNU General Public License *
  5445. *******************************************************************************/
  5446.  
  5447. // x~x news
  5448.  
  5449. // Nombre de news à afficher & nb max de caractères par news:
  5450. const nbItems = 5;
  5451. const maxCarDescription = 300;
  5452.  
  5453. /*-[functions]------------------- Utilitaires --------------------------------*/
  5454.  
  5455. // Ne semble avoir strictement aucun effet:
  5456. String.prototype.epureDescription = function() {
  5457. return this.replace(/\\(.)/g,"$1");
  5458. }
  5459.  
  5460. function appendTitledTable(node,titre,description) {
  5461. // Crée les tables contenant les infos (avec titre)
  5462. var table = document.createElement('table');
  5463. table.border = 0;
  5464. table.className = 'mh_tdborder';
  5465. table.cellSpacing = 1;
  5466. table.cellPadding = 1;
  5467. table.style.maxWidth = '98%';
  5468. table.style.marginLeft = 'auto';
  5469. table.style.marginRight = 'auto';
  5470. var tbody = document.createElement('tbody');
  5471. table.appendChild(tbody);
  5472. var tr = appendTr(tbody,'mh_tdtitre');
  5473. var td = appendTdCenter(tr,2);
  5474. var span = document.createElement('span');
  5475. appendText(span,titre,true);
  5476. if(description) {
  5477. span.title = description;
  5478. }
  5479. td.appendChild(span);
  5480. node.appendChild(table);
  5481. return tbody;
  5482. }
  5483.  
  5484. function testCertif(paramURL, callbackOnError) {
  5485. try {
  5486. FF_XMLHttpRequest({
  5487. method: 'GET',
  5488. url: paramURL,
  5489. onload: function(responseDetails) {
  5490. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  5491. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  5492. }
  5493. });
  5494. } catch(e) {
  5495. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  5496. callbackOnError();
  5497. }
  5498. }
  5499.  
  5500. function createOrGetGrandCadre() {
  5501. var grandCadre = document.getElementById('grandCadre');
  5502. if (grandCadre) return grandCadre;
  5503. try {
  5504. var rappels = document.evaluate(
  5505. "//p[contains(a/text(),'messagerie')]",
  5506. document, null, 9, null).singleNodeValue;
  5507. }
  5508. catch(e) {
  5509. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  5510. grandCadre = document.createElement('div');
  5511. return grandCadre;
  5512. }
  5513. grandCadre = document.createElement('div');
  5514. grandCadre.id = 'grandCadre';
  5515. var sousCadre = document.createElement('div');
  5516. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  5517. sousCadre.style.textAlign = 'center';
  5518. sousCadre.style.fontSize = 'xx-large';
  5519. grandCadre.appendChild(sousCadre);
  5520.  
  5521. grandCadre.style.border = 'solid 5px red';
  5522. grandCadre.style.width = 'auto';
  5523. insertBefore(rappels,grandCadre);
  5524. return grandCadre;
  5525. }
  5526.  
  5527. function showHttpsErrorCadre1() {
  5528. window.console.log('[MZ] showHttpsErrorCadre1');
  5529. var grandCadre = createOrGetGrandCadre();
  5530. var sousCadre = document.createElement('div');
  5531. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  5532. + '<br />Cela empêchera Moutyzilla de fonctionner'
  5533. + '<br /><a style="color:blue;font-size: inherits;" href="'
  5534. + URL_CertifRaistlin1
  5535. + '" target="raistlin">clique ici</a>'
  5536. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5537. + ' « Confirmer l\'exception de sécurité »'
  5538. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5539. sousCadre.style.width = 'auto';
  5540. sousCadre.style.fontSize = 'large';
  5541. sousCadre.style.border = 'solid 1px black';
  5542. sousCadre.style.backgroundColor = 'red';
  5543. grandCadre.appendChild(sousCadre);
  5544. }
  5545.  
  5546. function showHttpsErrorCadre2() {
  5547. window.console.log('[MZ] showHttpsErrorCadre2');
  5548. var grandCadre = createOrGetGrandCadre();
  5549. var sousCadre = document.createElement('div');
  5550. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  5551. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  5552. + '<a style="color:blue;font-size: inherits;" href="'
  5553. + URL_CertifRaistlin2
  5554. + '" target="raistlin">clique ici</a>'
  5555. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5556. + ' « Confirmer l\'exception de sécurité »'
  5557. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  5558. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5559. sousCadre.style.width = 'auto';
  5560. sousCadre.style.fontSize = 'large';
  5561. sousCadre.style.border = 'solid 1px black';
  5562. sousCadre.style.backgroundColor = 'red';
  5563. grandCadre.appendChild(sousCadre);
  5564. }
  5565.  
  5566. function showHttpsErrorContenuMixte() {
  5567. window.console.log('[MZ] showHttpsErrorContenuMixte');
  5568. var grandCadre = createOrGetGrandCadre();
  5569. var sousCadre = document.createElement('div');
  5570. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5571. + '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)'
  5572. + '<ul>'
  5573. + '<li>Interface Bricol\'Troll</li>'
  5574. + '<li>Nouveautés de Mountyzilla</li>'
  5575. + '</ul>'
  5576. + '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 />'
  5577. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5578. sousCadre.style.width = 'auto';
  5579. sousCadre.style.fontSize = 'large';
  5580. sousCadre.style.border = 'solid 1px black';
  5581. grandCadre.appendChild(sousCadre);
  5582. }
  5583.  
  5584. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5585.  
  5586. function traiterJubilaires() {
  5587. // à faire
  5588. }
  5589.  
  5590. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5591. try {
  5592. FF_XMLHttpRequest({
  5593. method: 'GET',
  5594. url: URL_anniv,
  5595. headers: {
  5596. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5597. 'Accept': 'application/xml,text/xml',
  5598. },
  5599. onload: function(responseDetails) {
  5600. if ((responseDetails.status == 0) && isHTTPS) {
  5601. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5602. //showHttpsErrorContenuMixte();
  5603. return;
  5604. }
  5605. var listeTrolls = responseDetails.responseText.split('\n');
  5606. if(!listeTrolls || listeTrolls.length==0) {
  5607. return;
  5608. }
  5609. afficherJubilaires(listeTrolls);
  5610. },
  5611. });
  5612. }
  5613. catch(e) {
  5614. if (isHTTPS) {
  5615. window.console.log(traceStack(e, 'appel jubilaires'));
  5616. showHttpsErrorContenuMixte();
  5617. } else {
  5618. window.alert('Erreur Jubilaires:\n'+e);
  5619. }
  5620. }
  5621. }
  5622.  
  5623. function afficherJubilaires(listeTrolls) {
  5624. try {
  5625. var rappels = document.evaluate(
  5626. "//p[contains(a/text(),'messagerie')]",
  5627. document, null, 9, null).singleNodeValue;
  5628. }
  5629. catch(e) {
  5630. return;
  5631. }
  5632. var p = document.createElement('p');
  5633. var tbody = appendTitledTable(p,
  5634. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5635. 'Envoyez leur un message ou un cadeau !'
  5636. );
  5637. tr = appendTr(tbody,'mh_tdpage');
  5638. td = appendTdCenter(tr);
  5639. var small = document.createElement('small');
  5640. td.appendChild(small);
  5641. var first = true;
  5642. for(var i=0 ; i<listeTrolls.length ; i++) {
  5643. var infos = listeTrolls[i].split(';');
  5644. if(infos.length!=3 || infos[2]==='0') {
  5645. continue;
  5646. }
  5647. if(first) {
  5648. first = false;
  5649. }
  5650. else {
  5651. appendText(small,', ');
  5652. }
  5653. var a = document.createElement('a');
  5654. a.href = 'javascript:EPV('+infos[0]+')';
  5655. appendText(a,infos[1]);
  5656. small.appendChild(a);
  5657. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5658. }
  5659. insertBefore(rappels,p);
  5660. }
  5661.  
  5662.  
  5663. /*-[functions]--------------------- News MZ ----------------------------------*/
  5664.  
  5665. function traiterNouvelles() {
  5666. var news = new Array;
  5667. 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)']);
  5668. 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 ;).']);
  5669. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5670. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5671. 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']);
  5672. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5673. afficherNouvelles(news);
  5674. }
  5675.  
  5676. function afficherNouvelles(items) {
  5677. var footer = document.getElementById('footer1');
  5678. if(!footer) {
  5679. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5680. return;
  5681. }
  5682. var p = document.createElement('p');
  5683. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5684. var div = document.createElement('div');
  5685. div.style.position = 'absolute';
  5686. div.style.right = 0;
  5687. div.style.top = 0;
  5688. div.style.paddingRight = '3px';
  5689. div.style.whiteSpace = 'nowrap';
  5690. appendText(div, '(version ' + GM_info.script.version + ')');
  5691. tbody.rows[0].cells[0].style.position = 'relative';
  5692. tbody.rows[0].cells[0].appendChild(div);
  5693. for(var i=0 ; i<items.length ; i++) {
  5694. var tr = appendTr(tbody,'mh_tdpage');
  5695. var td = appendTdCenter(tr);
  5696. td.style.verticalAlign = 'top'; // semble sans effet
  5697. appendText(td,items[i][0],true);
  5698. td = appendTd(tr);
  5699. td.innerHTML = items[i][1];
  5700. }
  5701. insertBefore(footer,p);
  5702.  
  5703. // changelog
  5704. var p = document.createElement('p');
  5705. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5706. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5707. tbody.rows[0].cells[0].onclick = function() {
  5708. try {
  5709. tbody.rows[0].cells[0].onclick = undefined;
  5710. tbody.rows[0].cells[0].style.cursor = '';
  5711. var tr = appendTr(tbody,'mh_tdpage');
  5712. var td = appendTd(tr);
  5713. td.colSpan = 2;
  5714. var pre = document.createElement('pre');
  5715. appendText(pre,MZ_changeLog.join("\n"));
  5716. td.appendChild(pre);
  5717. } catch (e) {
  5718. window.console.log('[MZ] affichage changeLog', e);
  5719. }
  5720. };
  5721. insertBefore(footer,p);
  5722.  
  5723. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5724. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5725. if (isHTTPS) {
  5726. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5727. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5728. } else {
  5729. window.console.log('[MZ test] début switch to https');
  5730. window.sessionStorage.setItem('xxx', "test session trans https");
  5731. window.parent.xxx = "autre test";
  5732. var url = document.location.href;
  5733. window.console.log('[MZ test] url=' + url);
  5734. url = url.replace(/http:\/\//i, 'https://')
  5735. window.console.log('[MZ test] switched url=' + url);
  5736. document.location.href = url;
  5737. }
  5738. }
  5739. if (false) { // version par utilisation d'un IFrame en https
  5740. if (isHTTPS) {
  5741. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5742. //window.console.log('[MZ test] window.name=' + window.name);
  5743. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5744. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5745. var txt = window.name;
  5746. var tabtxt = txt.split(/µ/);
  5747. for (var i = 0; i < tabtxt.length; i++) {
  5748. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5749. }
  5750. } else {
  5751. var txt = '';
  5752. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5753. var k = localStorage.key(i);
  5754. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5755. txt += k + "£" + localStorage.getItem(k) + "µ";
  5756. }
  5757. var iframe = document.createElement('iframe');
  5758. var url = document.location.href;
  5759. //window.console.log('[MZ test] url=' + url);
  5760. url = url.replace(/http:\/\//i, 'https://')
  5761. //window.console.log('[MZ test] switched url=' + url);
  5762. //iframe.xxx = "truc en plume";
  5763. iframe.name = txt;
  5764. //window.xxx = "machin";
  5765. iframe.src = url;
  5766. //iframe.document.xxx = "truc en plume";
  5767. document.body.appendChild(iframe);
  5768. iframe.style.display = 'none';
  5769. }
  5770. }
  5771. }
  5772. }
  5773.  
  5774.  
  5775. /*---------------------------------- Main ------------------------------------*/
  5776.  
  5777. function do_news() {
  5778. start_script();
  5779.  
  5780. traiterJubilaires();
  5781. traiterNouvelles();
  5782.  
  5783. /* plus besoin, le certificat est "officiel"
  5784. if (isHTTPS) {
  5785. // test si les certificats raistlin ont été acceptés
  5786. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5787. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5788. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5789. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5790. }
  5791. }
  5792. */
  5793.  
  5794. displayScriptTime();
  5795. }
  5796.  
  5797. /*********************************************************************************
  5798. * This file is part of Mountyzilla. *
  5799. * *
  5800. * Mountyzilla is free software; you can redistribute it and/or modify *
  5801. * it under the terms of the GNU General Public License as published by *
  5802. * the Free Software Foundation; either version 2 of the License, or *
  5803. * (at your option) any later version. *
  5804. * *
  5805. * Mountyzilla is distributed in the hope that it will be useful, *
  5806. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5807. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5808. * GNU General Public License for more details. *
  5809. * *
  5810. * You should have received a copy of the GNU General Public License *
  5811. * along with Mountyzilla; if not, write to the Free Software *
  5812. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5813. *********************************************************************************/
  5814.  
  5815. // x~x tabcompo
  5816.  
  5817. var popup;
  5818.  
  5819. function initPopupTabcompo() {
  5820. popup = document.createElement('div');
  5821. popup.setAttribute('id', 'popup');
  5822. popup.setAttribute('class', 'mh_textbox');
  5823. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5824. + 'display: inline; z-index: 3; max-width: 400px;');
  5825. document.body.appendChild(popup);
  5826. }
  5827.  
  5828. function showPopup(evt) {
  5829. var texte = this.getAttribute("texteinfo");
  5830. popup.innerHTML = texte;
  5831. popup.style.left = evt.pageX + 15 + 'px';
  5832. popup.style.top = evt.pageY + 'px';
  5833. popup.style.visibility = "visible";
  5834. }
  5835.  
  5836. // roule 16/03/2016, existe déjà ailleurs
  5837. // function hidePopup() {
  5838. // popup.style.visibility = 'hidden';
  5839. // }
  5840.  
  5841. function createPopupImage(url, text)
  5842. {
  5843. var img = document.createElement('img');
  5844. img.setAttribute('src',url);
  5845. img.setAttribute('align','ABSMIDDLE');
  5846. img.setAttribute("texteinfo",text);
  5847. img.addEventListener("mouseover", showPopup,true);
  5848. img.addEventListener("mouseout", hidePopup,true);
  5849. return img;
  5850. }
  5851.  
  5852. function formateTexte(texte)
  5853. {
  5854. texte = texte.replace(/\n/g,"<br/>");
  5855. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5856. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5857. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5858. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5859. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5860. return texte;
  5861. }
  5862.  
  5863. function arrondi(x) {
  5864. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5865. }
  5866.  
  5867. function traiteMinerai() {
  5868. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5869. try {
  5870. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5871. +" and contains(./tr/th/text(),'Minerai')]",
  5872. document, null, 9, null).singleNodeValue;
  5873. node = node.nextSibling.nextSibling;
  5874. }
  5875. catch(e) {return;}
  5876. var trlist = document.evaluate('./tr', node, null, 7, null);
  5877. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5878. var node = trlist.snapshotItem(i);
  5879. var nature = node.childNodes[5].textContent;
  5880. var caracs = node.childNodes[7].textContent;
  5881. var taille = caracs.match(/\d+/)[0];
  5882. var coef = 1;
  5883. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5884. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5885. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5886. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5887. if (nature.indexOf('Mithril')!=-1) {
  5888. coef = 0.2*coef;
  5889. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5890. }
  5891. else {
  5892. coef = 0.75*coef+1.25;
  5893. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5894. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5895. }
  5896. }
  5897. }
  5898.  
  5899. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5900. function treateComposants() {
  5901. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5902. //On récupère les composants
  5903. var nodes = document.evaluate(
  5904. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5905. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5906. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5907. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5908. if (nodes.snapshotLength == 0) {
  5909. //window.console.log('[MZ] treateComposants DOWN');
  5910. return;
  5911. }
  5912. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5913.  
  5914. var texte = "";
  5915. for (var i = 0; i < nodes.snapshotLength; i++) {
  5916. var n1 = nodes.snapshotItem(i).childNodes[1];
  5917. var n3 = nodes.snapshotItem(i).childNodes[3];
  5918. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5919. var prix = n3.childNodes[0].nodeValue;
  5920. if (!prix)
  5921. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5922. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5923. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5924. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5925. + prix.replace(/\n/g, '') + "\n";
  5926. }
  5927.  
  5928. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5929. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5930. var id_taniere = c.snapshotItem(0).nodeValue;
  5931. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5932.  
  5933. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5934. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5935. if (form)
  5936. {
  5937. if(document.getElementsByTagName('form').length>0)
  5938. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5939. else
  5940. {
  5941. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5942. insertBefore(thisP, form);
  5943. }
  5944. }
  5945. }
  5946.  
  5947. function treateAllComposants() {
  5948. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5949. //On récupère les composants
  5950. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5951. document, null, 0, null ).numberValue;
  5952. var c = (categ == 0 ? 3 : 4);
  5953. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5954. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5955. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5956. + "td["+c+"]/text()[1] = '\240-\240' "
  5957. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5958. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5959. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5960. + "and td[1]/img/@alt = 'Identifié']",
  5961. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5962. if (nodes.snapshotLength == 0) {
  5963. // window.alert('treateAllComposants DOWN');
  5964. return;
  5965. }
  5966.  
  5967. var texte = "";
  5968. for (var i = 0; i < nodes.snapshotLength; i++) {
  5969. var n1 = nodes.snapshotItem(i).childNodes[1];
  5970. var n3 = nodes.snapshotItem(i).childNodes[3];
  5971. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5972. var prix = n3.childNodes[0].nodeValue;
  5973. if (!prix)
  5974. {
  5975. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5976. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5977. }
  5978. else
  5979. {
  5980. prix= prix.replace(/[\240 ]/g, "");
  5981. if(prix=="-")
  5982. prix=null;
  5983. }
  5984. if(prix)
  5985. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5986. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5987. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5988. + prix.replace(/\n/g, '') + "\n";
  5989. else
  5990. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5991. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5992. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5993. }
  5994.  
  5995. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5996. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5997. var id_taniere = c.snapshotItem(0).nodeValue;
  5998. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5999.  
  6000. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6001. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  6002. if (form)
  6003. {
  6004. if(document.getElementsByTagName('form').length>0)
  6005. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6006. else
  6007. {
  6008. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6009. insertBefore(thisP, form);
  6010. }
  6011. }
  6012. }
  6013.  
  6014. function treateEM()
  6015. {
  6016. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  6017. if(currentURL.indexOf("as_type=Compo")==-1)
  6018. return false;
  6019. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  6020. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  6021. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6022. if (nodes.snapshotLength == 0)
  6023. return false;
  6024. for (var i = 0; i < nodes.snapshotLength; i++) {
  6025. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  6026. var link = desc[2].firstChild ;
  6027. var nomCompoTotal = desc[2].textContent ;
  6028. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6029. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6030. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  6031. var locqual = desc[3].textContent ;
  6032. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  6033. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  6034. if(isEM(nomMonstre).length>0)
  6035. {
  6036. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  6037. if(infos.length>0)
  6038. {
  6039. var shortDescr = "Variable";
  6040. var bold = 0;
  6041. if(infos != "Composant variable")
  6042. {
  6043. shortDescr = infos.substring(0,infos.indexOf(" "));
  6044. if(parseInt(shortDescr)>=0)
  6045. bold=1;
  6046. }
  6047. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  6048. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  6049. }
  6050. }
  6051. }
  6052. }
  6053.  
  6054. function treateChampi() {
  6055. if (currentURL.indexOf('as_type=Champi')==-1)
  6056. return false;
  6057. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  6058. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6059. if (nodes.snapshotLength == 0)
  6060. return false;
  6061.  
  6062. for (var i = 0; i < nodes.snapshotLength; i++) {
  6063. var node = nodes.snapshotItem(i);
  6064. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  6065. if (moisChampi[nomChampi])
  6066. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  6067. }
  6068. }
  6069.  
  6070. function treateEnchant()
  6071. {
  6072. if(currentURL.indexOf("as_type=Compo")==-1)
  6073. return false;
  6074. try
  6075. {
  6076. if(!listeMonstreEnchantement)
  6077. computeCompoEnchantement();
  6078. var nodes = document.evaluate(
  6079. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6080. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6081. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6082. if (nodes.snapshotLength == 0)
  6083. return false;
  6084. var urlImg = URL_MZimg + "enchant.png";
  6085. for (var i = 0; i < nodes.snapshotLength; i++) {
  6086. var link = nodes.snapshotItem(i);
  6087. var nomCompoTotal = link.firstChild.nodeValue;
  6088. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6089. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6090. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  6091. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  6092. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  6093. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  6094. if(isEnchant(nomMonstre).length>0)
  6095. {
  6096. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  6097. if(infos.length>0)
  6098. {
  6099. link.parentNode.appendChild(createImage(urlImg,infos));
  6100. }
  6101. }
  6102. }
  6103. }
  6104. catch(e)
  6105. {
  6106. window.alert(e);
  6107. }
  6108. }
  6109.  
  6110. function treateEquipEnchant()
  6111. {
  6112. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  6113. return false;
  6114. initPopupTabcompo();
  6115. computeEnchantementEquipement(createPopupImage,formateTexte);
  6116. }
  6117.  
  6118. function do_tancompo() {
  6119. start_script();
  6120.  
  6121. treateAllComposants();
  6122. treateComposants();
  6123. traiteMinerai();
  6124. if (MY_getValue('NOINFOEM')!='true') {
  6125. treateChampi();
  6126. treateEM();
  6127. }
  6128. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  6129. treateEnchant();
  6130. treateEquipEnchant();
  6131. }
  6132.  
  6133. displayScriptTime();
  6134. }
  6135.  
  6136. /*******************************************************************************
  6137. * This file is part of Mountyzilla. *
  6138. * *
  6139. * Mountyzilla is free software; you can redistribute it and/or modify *
  6140. * it under the terms of the GNU General Public License as published by *
  6141. * the Free Software Foundation; either version 2 of the License, or *
  6142. * (at your option) any later version. *
  6143. * *
  6144. * Mountyzilla is distributed in the hope that it will be useful, *
  6145. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6146. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6147. * GNU General Public License for more details. *
  6148. * *
  6149. * You should have received a copy of the GNU General Public License *
  6150. * along with Mountyzilla; if not, write to the Free Software *
  6151. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6152. *******************************************************************************/
  6153.  
  6154. // x~x pjview
  6155.  
  6156. /* TODO
  6157. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  6158. */
  6159.  
  6160. // Bulle d'infos
  6161. var DivInfo;
  6162. // Booléen stockant l'état de freezing de la bulle
  6163. var freezed = false;
  6164.  
  6165. // liste du matos
  6166. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  6167. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6168. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  6169. var mh_caracs = {
  6170. 'anneau de protection':
  6171. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  6172. "armure d'anneaux":
  6173. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  6174. 'armure de bois':
  6175. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  6176. 'armure de cuir':
  6177. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  6178. 'armure de peaux':
  6179. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  6180. 'armure de pierre':
  6181. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  6182. 'armure de plates':
  6183. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  6184. 'baton lesté':
  6185. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6186. 'bâtons de parade':
  6187. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6188. 'bottes':
  6189. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6190. 'bouclier à pointes':
  6191. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6192. 'boulet et chaîne':
  6193. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6194. 'cagoule':
  6195. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  6196. 'casque à cornes':
  6197. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6198. 'casque à pointes':
  6199. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  6200. 'casque en cuir':
  6201. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  6202. 'casque en métal':
  6203. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6204. 'chaîne cloutée':
  6205. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6206. 'chapeau pointu':
  6207. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  6208. 'collier de dents':
  6209. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  6210. 'collier de pierre':
  6211. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6212. 'collier à pointes':
  6213. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6214. 'cotte de mailles':
  6215. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  6216. 'couronne de cristal':
  6217. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  6218. "couronne d'obsidienne":
  6219. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  6220. "coutelas d'obsidienne":
  6221. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  6222. 'coutelas en os':
  6223. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  6224. 'crochet':
  6225. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6226. 'cuir bouilli':
  6227. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  6228. "cuirasse d'ossements":
  6229. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  6230. "cuirasse d'écailles":
  6231. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  6232. 'culotte en cuir':
  6233. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6234. 'dague':
  6235. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6236. 'epée courte':
  6237. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6238. 'epée longue':
  6239. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6240. 'espadon':
  6241. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6242. 'fouet':
  6243. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6244. 'fourrures':
  6245. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  6246. 'gantelet':
  6247. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6248. 'gorgeron en cuir':
  6249. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6250. 'gorgeron en métal':
  6251. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  6252. 'gourdin':
  6253. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6254. 'gourdin clouté':
  6255. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6256. 'grimoire':
  6257. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  6258. "gros'porte":
  6259. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  6260. 'grosse racine':
  6261. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6262. 'grosse stalagmite':
  6263. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  6264. 'hache de bataille':
  6265. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6266. 'hache de guerre en os':
  6267. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  6268. 'hache de guerre en pierre':
  6269. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  6270. "hache à deux mains d'obsidienne":
  6271. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  6272. 'hallebarde':
  6273. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  6274. "haubert d'écailles":
  6275. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  6276. 'haubert de mailles':
  6277. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  6278. 'heaume':
  6279. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  6280. 'jambières en cuir':
  6281. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6282. 'jambières en fourrure':
  6283. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  6284. 'jambières en maille':
  6285. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6286. 'jambières en métal':
  6287. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  6288. 'jambières en os':
  6289. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6290. "lame d'obsidienne":
  6291. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  6292. 'lame en os':
  6293. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6294. 'lame en pierre':
  6295. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6296. 'lorgnons':
  6297. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  6298. 'machette':
  6299. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6300. "masse d'arme":
  6301. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6302. 'pagne de mailles':
  6303. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6304. 'pagne en cuir':
  6305. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6306. 'robe de mage':
  6307. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  6308. 'rondache en bois':
  6309. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6310. 'rondache en métal':
  6311. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  6312. 'sandales':
  6313. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6314. 'souliers dorés':
  6315. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6316. "talisman d'obsidienne":
  6317. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  6318. 'talisman de pierre':
  6319. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  6320. 'targe':
  6321. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6322. 'torche':
  6323. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  6324. 'torque de pierre':
  6325. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  6326. 'tunique':
  6327. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6328. "tunique d'écailles":
  6329. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  6330. 'turban':
  6331. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  6332. }
  6333.  
  6334. // liste des templates
  6335. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  6336. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6337. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  6338. var mh_templates = {
  6339. 'de Feu':
  6340. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6341. 'de Résistance':
  6342. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  6343. "de l'Aigle":
  6344. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  6345. 'de la Salamandre':
  6346. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6347. 'des Cyclopes':
  6348. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  6349. 'des Enragés':
  6350. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  6351. 'des Tortues':
  6352. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  6353. 'des Vampires':
  6354. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6355. 'du Glacier':
  6356. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  6357. 'du Rat':
  6358. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6359. 'du Roc':
  6360. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  6361. 'du Temps':
  6362. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  6363. 'du Vent':
  6364. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6365. 'en Mithril':
  6366. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6367. 'des Anciens':
  6368. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6369. 'des Champions':
  6370. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6371. 'des Duellistes':
  6372. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6373. 'de la Terre':
  6374. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  6375. "de l'Orage":
  6376. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  6377. "de l'Ours":
  6378. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  6379. 'des Béhémoths':
  6380. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  6381. 'des Mages':
  6382. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  6383. 'du Pic':
  6384. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  6385. 'du Sable':
  6386. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  6387. 'acéré':
  6388. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6389. 'acérée':
  6390. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6391. 'équilibré':
  6392. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6393. 'équilibrée':
  6394. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6395. 'léger':
  6396. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  6397. 'légère':
  6398. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  6399. 'renforcé':
  6400. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  6401. 'renforcée':
  6402. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  6403. 'robuste':
  6404. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  6405. }
  6406.  
  6407. function clone(arr) {
  6408. // Clonage rapide
  6409. return arr.slice(0);
  6410. }
  6411.  
  6412. function addArray(arr1,arr2) {
  6413. // Somme matricielle
  6414. var res = clone(arr1);
  6415. for(i=res.length-1 ; i>=0 ; i--) {
  6416. res[i] += arr2[i];
  6417. }
  6418. return res;
  6419. }
  6420.  
  6421. function getTemplates(nomItem) {
  6422. // Déstructure le nom de l'item en array [nom, template1, ...]
  6423. var tempFound = true;
  6424. var str = nomItem.trim();
  6425. var arr = [];
  6426. while(tempFound) {
  6427. tempFound = false;
  6428. for(var temp in mh_templates) {
  6429. // on teste la fin du nom contre chaque template
  6430. if(str.slice(-temp.length)!=temp) { continue; }
  6431. tempFound = true;
  6432. str = str.slice(0,-temp.length-1);
  6433. arr.unshift(temp);
  6434. if(str.slice(-3)==' et') {
  6435. str = str.slice(0,-3);
  6436. }
  6437. }
  6438. }
  6439. arr.unshift(str);
  6440. return arr;
  6441. }
  6442.  
  6443. function addMithril(arrayCaracs,typeItem) {
  6444. // Ajoute l'effet du Mithril sur les caracs
  6445. if(typeItem=='arme') {
  6446. if(arrayCaracs[0]<0) {
  6447. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  6448. }
  6449. }
  6450. else {
  6451. if(arrayCaracs[4]<0) {
  6452. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  6453. }
  6454. }
  6455. arrayCaracs[15] /= 2;
  6456. arrayCaracs[16] /= 2;
  6457. return arrayCaracs;
  6458. }
  6459.  
  6460. function addRenfort(arrayCaracs,template) {
  6461. // Ajoute l'effet des pseudo-templates sur les caracs
  6462. // S'applique APRÈS le mithril
  6463. // WARNING - Cette formule n'a rien d'officiel, gare !
  6464. var coef = 0;
  6465. if(/^lég[e,è]re?$/.test(template)) {
  6466. coef = -1;
  6467. }
  6468. else if(/^renforcée?$/.test(template)
  6469. || template==='robuste') {
  6470. coef = 1;
  6471. }
  6472. if(coef) {
  6473. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  6474. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  6475. }
  6476. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  6477. return arrayCaracs;
  6478. }
  6479.  
  6480. function getCaracs(item) {
  6481. // Calcule les caractéristiques de l'item
  6482. var templates = getTemplates(item);
  6483. if(!mh_caracs[templates[0]]) {
  6484. // Si l'item est inconnu
  6485. return [];
  6486. }
  6487. var caracs = clone(mh_caracs[templates[0]]);
  6488. var typeItem = caracs[0];
  6489. caracs.shift();
  6490. templates.shift();
  6491. if(templates[templates.length-1]=='en Mithril') {
  6492. caracs = addMithril(caracs,typeItem);
  6493. templates.pop();
  6494. }
  6495. if(/^acérée?$/.test(templates[0])
  6496. || /^équilibrée?$/.test(templates[0])
  6497. || /^lég[e,è]re?$/.test(templates[0])
  6498. || /^renforcée?$/.test(templates[0])
  6499. || templates[0]=='robuste') {
  6500. caracs = addRenfort(caracs,templates[0]);
  6501. templates.shift();
  6502. }
  6503. for(var i=templates.length-1 ; i>=0 ; i--) {
  6504. caracs = addArray(caracs,mh_templates[templates[i]]);
  6505. }
  6506. return caracs;
  6507. }
  6508.  
  6509. function getLine(tab) {
  6510. // Préparation de la ligne à afficher lors d'un mouseover
  6511. var str = '';
  6512. if(tab[0]!=0 || tab[1]!=0) {
  6513. str += '<b>Att : </b>'+aff(tab[0]);
  6514. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  6515. str += ' | ';
  6516. }
  6517. if(tab[4]!=0) {
  6518. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  6519. }
  6520. if(tab[2]!=0 || tab[3]!=0) {
  6521. str += '<b>Deg : </b>'+aff(tab[2]);
  6522. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  6523. str += ' | ';
  6524. }
  6525. if(tab[8]!=0) {
  6526. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  6527. }
  6528. if(tab[7]!=0) {
  6529. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  6530. }
  6531. if(tab[5]!=0 || tab[6]!=0) {
  6532. str += '<b>Arm : </b>'+aff(tab[5]);
  6533. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  6534. str += ' | ';
  6535. }
  6536. if(tab[9]!=0 || tab[10]!=0) {
  6537. str += '<b>RM : </b>'+aff(tab[9])+'%';
  6538. if(tab[9]!=tab[10]) {
  6539. str += '/'+aff(tab[10])+'%';
  6540. }
  6541. str += ' | ';
  6542. }
  6543. if(tab[11]!=0 || tab[12]!=0) {
  6544. str += '<b>MM : </b>'+aff(tab[11])+'%';
  6545. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  6546. str += ' | ';
  6547. }
  6548. if(tab[13]!=0) {
  6549. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  6550. }
  6551. if(tab[14]!=0) {
  6552. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  6553. }
  6554. str += '<b>Poids : </b>'+tab[15]+' min';
  6555. if(tab[15]!=tab[16]) {
  6556. str += ' / '+tab[16]+' min';
  6557. }
  6558. return str;
  6559. }
  6560.  
  6561. function toolTipInit() {
  6562. DivInfo = document.createElement('div');
  6563. DivInfo.id = 'infosVue';
  6564. DivInfo.className = 'mh_textbox';
  6565. DivInfo.style =
  6566. 'position: absolute;'
  6567. +'border: 1px solid #000000;'
  6568. +'visibility:hidden;'
  6569. +'display:inline;'
  6570. +'z-index:99;';
  6571. document.body.appendChild(DivInfo);
  6572. document.onmousemove = getXY;
  6573. document.onclick = changeFreezeStatus;
  6574. }
  6575.  
  6576. function getXY(evt) {
  6577. if(!freezed && DivInfo.style.visibility=='visible') {
  6578. DivInfo.style.left = evt.pageX+'px';
  6579. DivInfo.style.top = evt.pageY+10+'px';
  6580. }
  6581. }
  6582.  
  6583. function changeFreezeStatus() {
  6584. if(DivInfo.style.visibility=='visible') {
  6585. freezed = !freezed;
  6586. if(!freezed) { hideInfos(); }
  6587. }
  6588. }
  6589.  
  6590. function showInfos() {
  6591. if(freezed) { return; }
  6592. var currentInfos = this.infos;
  6593. DivInfo.innerHTML = currentInfos;
  6594. DivInfo.style.visibility = 'visible';
  6595. }
  6596.  
  6597. function hideInfos() {
  6598. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6599. }
  6600.  
  6601. function treateEquipement() {
  6602. // Extrait les données du matos et réinjecte les infos déduites
  6603. if(MY_getValue('INFOCARAC')=='false') { return; }
  6604. var faireLigne = false;
  6605. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6606. var nodes = document.evaluate(
  6607. "//td/b[text()='Equipement Utilisé']/../../"
  6608. +"td[2]/img[contains(@src,bullet)]",
  6609. document, null, 7, null);
  6610. if(nodes.snapshotLength>0) {
  6611. // Si CSS de base
  6612. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6613. var node = nodes.snapshotItem(i);
  6614. var next = node.nextSibling;
  6615. var nnext = next.nextSibling;
  6616. var nom = next.nodeValue.toLowerCase();
  6617. if(nnext.childNodes.length==1) {
  6618. nom += nnext.firstChild.nodeValue;
  6619. }
  6620. nom = nom.trim();
  6621. // gestion winpostrophe
  6622. var c = String.fromCharCode(180);
  6623. while(nom.indexOf(c)!=-1) {
  6624. nom = nom.replace(c,"'");
  6625. }
  6626. var arr = getCaracs(nom);
  6627. if(arr.length>0) {
  6628. faireLigne = true;
  6629. caracs = addArray(caracs,arr);
  6630. var span = document.createElement('span');
  6631. span.appendChild(next);
  6632. span.appendChild(nnext);
  6633. span.infos = getLine(arr);
  6634. span.onmouseover = showInfos;
  6635. span.onmouseout = hideInfos;
  6636. insertBefore(node.nextSibling,span);
  6637. }
  6638. }
  6639. if(faireLigne) {
  6640. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6641. document, null, 9, null).singleNodeValue;
  6642. node.infos = getLine(caracs);
  6643. node.onmouseover = showInfos;
  6644. node.onmouseout = hideInfos;
  6645. }
  6646. }
  6647. else {
  6648. // Si CSS avancée
  6649. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6650. document, null, 7, null);
  6651. if(nodes.snapshotLength>0) {
  6652. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6653. var node = nodes.snapshotItem(i);
  6654. var nom = node.firstChild.nodeValue.toLowerCase();
  6655. if(node.childNodes.length>1) {
  6656. nom += node.childNodes[1].firstChild.nodeValue;
  6657. }
  6658. nom = nom.trim();
  6659. // gestion winpostrophe
  6660. var c = String.fromCharCode(180);
  6661. while(nom.indexOf(c)!=-1) {
  6662. nom = nom.replace(c,"'");
  6663. }
  6664. var arr = getCaracs(nom);
  6665. if(arr.length!=0) {
  6666. caracs = addArray(caracs,arr);
  6667. node.infos = getLine(arr);
  6668. node.onmouseover = showInfos;
  6669. node.onmouseout = hideInfos;
  6670. }
  6671. }
  6672. var nodes = document.evaluate("//dt[@class='equipement']",
  6673. document, null, 7, null);
  6674. var node = nodes.snapshotItem(0);
  6675. node.infos = getLine(caracs);
  6676. node.onmouseover = showInfos;
  6677. node.onmouseout = hideInfos;
  6678. }
  6679. }
  6680. }
  6681.  
  6682. function do_pjview() {
  6683. treateEquipement();
  6684. toolTipInit();
  6685. }
  6686.  
  6687. /*******************************************************************************
  6688. * This file is part of Mountyzilla. *
  6689. * *
  6690. * Mountyzilla is free software; you can redistribute it and/or modify *
  6691. * it under the terms of the GNU General Public License as published by *
  6692. * the Free Software Foundation; either version 2 of the License, or *
  6693. * (at your option) any later version. *
  6694. * *
  6695. * Mountyzilla is distributed in the hope that it will be useful, *
  6696. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6697. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6698. * GNU General Public License for more details. *
  6699. * *
  6700. * You should have received a copy of the GNU General Public License *
  6701. * along with Mountyzilla; if not, write to the Free Software *
  6702. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6703. *******************************************************************************/
  6704.  
  6705. // x~x option
  6706.  
  6707. /* TODO
  6708. * Passer le HTML injecté aux conventions HTML5
  6709. */
  6710.  
  6711.  
  6712. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6713.  
  6714. function saveITData() {
  6715. var IT = document.getElementById('itSelect').value;
  6716. if(IT=='bricol') {
  6717. var nBricol = 1;
  6718. for (var iBricol = 0; ; iBricol++) {
  6719. var extClef = nBricol == 1 ? '' : nBricol;
  6720. var eltSystem = document.getElementById('urlbricol'+iBricol);
  6721. if (eltSystem == undefined) break;
  6722. var system = eltSystem.value;
  6723. window.console.log("[MZ] saveITData system=" + system);
  6724. var login = document.getElementById('loginbricol'+iBricol).value;
  6725. var pass = document.getElementById('passbricol'+iBricol).value;
  6726. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6727. if(system && login) {
  6728. if (pass) {
  6729. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6730. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  6731. //window.console.log('v=' + v);
  6732. } else {
  6733. // vérif que rien n'a changé
  6734. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  6735. if(str) {
  6736. var arr = str.split('$');
  6737. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6738. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  6739. }
  6740. }
  6741. }
  6742. nBricol++;
  6743. }
  6744. }
  6745. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  6746. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  6747. }
  6748. else {
  6749. MY_removeValue(numTroll+'.INFOSIT');
  6750. }
  6751. }
  6752.  
  6753. function saveLinks() {
  6754. var numLinks = document.getElementById('linksBody').childNodes.length;
  6755. var data=[ [] ];
  6756. /* Récupération et tri des liens */
  6757. for(var i=1 ; i<=numLinks ; i++) {
  6758. MY_removeValue('URL'+i);
  6759. MY_removeValue('URL'+i+'.nom');
  6760. MY_removeValue('URL'+i+'.ico');
  6761. var url = document.getElementById('url'+i).value;
  6762. var nom = document.getElementById('nom'+i).value;
  6763. var ico = document.getElementById('ico'+i).value;
  6764. if(url && (nom || ico) ) {
  6765. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6766. }
  6767. }
  6768. /* Sauvegarde */
  6769. for(var i=1 ; i<data.length ; i++) {
  6770. MY_setValue('URL'+i,data[i][0]);
  6771. MY_setValue('URL'+i+'.nom',data[i][1]);
  6772. MY_setValue('URL'+i+'.ico',data[i][2]);
  6773. }
  6774. }
  6775.  
  6776. function saveAll() {
  6777. try {
  6778. var urlIco = document.getElementById('icoMenuIco').value;
  6779. if(urlIco) {
  6780. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6781. }
  6782. else {
  6783. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6784. document.getElementById('icoMenuIco').value = '';
  6785. }
  6786. saveLinks();
  6787. refreshLinks();
  6788. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6789. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6790. if(maxcdm) {
  6791. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6792. }
  6793. else {
  6794. MY_removeValue(numTroll+'.MAXCDM');
  6795. document.getElementById('maxcdm').value = '';
  6796. }
  6797.  
  6798. MY_setValue('NOINFOEM',
  6799. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6800. // Pourquoi Tilk stockait-il tout en str ?
  6801. // -> parce que les booléens c'est foireux (vérifié)
  6802. MY_setValue(numTroll+'.USECSS',
  6803. document.getElementById('usecss').checked ? 'true':'false');
  6804. MY_setValue('INFOCARAC',
  6805. document.getElementById('infocarac').checked ? 'true' : 'false');
  6806. //MY_setValue(numTroll+'.SEND_IDT',
  6807. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6808. // Fonctionnalité désactivée
  6809.  
  6810. MY_setValue(numTroll+'.AUTOCDM',
  6811. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6812. MY_setValue('VUECARAC',
  6813. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6814. MY_setValue('CONFIRMEDECALAGE',
  6815. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6816.  
  6817. saveITData();
  6818. } catch (e) {
  6819. var bouton = document.getElementById('saveAll');
  6820. window.console.log(e);
  6821. bouton.value = "il y a eu une erreur";
  6822. return;
  6823. }
  6824.  
  6825. var bouton = document.getElementById('saveAll');
  6826. bouton.value = (bouton.value=='Sauvegardé !') ?
  6827. 'Re-sauvegardé !' : 'Sauvegardé !';
  6828. }
  6829.  
  6830.  
  6831. /*-[functions]----------------- EventListeners -------------------------------*/
  6832.  
  6833. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  6834. var itBody = document.getElementById('itBody');
  6835. var nTr = itBody.rows.length;
  6836. // enlever tous les "+" des lignes précédentes
  6837. for (iTr = 0; iTr < nTr; iTr++) {
  6838. var td = itBody.rows[iTr].cells[0];
  6839. td.innerHTML = '';
  6840. td.title = '';
  6841. td.style.cursor = 'default';
  6842. }
  6843. // ajouter une ligne
  6844. var tr = appendTr(itBody,'mh_tdpage')
  6845. var td = appendTd(tr);
  6846. if (bLast) {
  6847. td.style.whiteSpace = 'nowrap';
  6848. appendText(td, '+');
  6849. td.style.cursor = 'pointer';
  6850. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  6851. td.onclick = function (e) {
  6852. addBricolIT(undefined, undefined, undefined, false, true);
  6853. }
  6854. }
  6855. var td = appendTd(tr);
  6856. td.style.whiteSpace = 'nowrap';
  6857. appendText(td,'Nom du système : ');
  6858. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  6859. td = appendTd(tr);
  6860. td.style.whiteSpace = 'nowrap';
  6861. appendText(td,'Login du compte : ');
  6862. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  6863. td = appendTd(tr);
  6864. td.style.whiteSpace = 'nowrap';
  6865. appendText(td,'Mot de passe du compte : ');
  6866. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  6867. td = appendTd(tr);
  6868. if (bFirst) {
  6869. td.style.whiteSpace = 'nowrap';
  6870. appendText(td,'Affichage des Trõlls hors vue : ');
  6871. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  6872. }
  6873. }
  6874.  
  6875. function onChangeIT() {
  6876. var IT = document.getElementById('itSelect').value;
  6877. var itBody = document.getElementById('itBody');
  6878. itBody.innerHTML = '';
  6879. var tabStr = new Array();
  6880. if(IT=='bricol') {
  6881. for (var iBricol = 1; ; iBricol++) {
  6882. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  6883. //window.console.log('onChangeIT str=' + str);
  6884. if(str) {
  6885. tabStr.push(str);
  6886. } else {
  6887. break;
  6888. }
  6889. }
  6890. if (tabStr.length == 0) {
  6891. addBricolIT('', '', 0, true, true)
  6892. } else {
  6893. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  6894. var arr = tabStr[iBricol].split('$');
  6895. var system = arr[1];
  6896. var login = arr[2];
  6897. var affhv = arr[4];
  6898. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  6899. }
  6900. }
  6901. }
  6902. }
  6903.  
  6904. function refreshLinks() {
  6905. document.getElementById('linksBody').innerHTML = '';
  6906. var anotherURL = MY_getValue('URL1');
  6907. if(!anotherURL) { addLinkField(); }
  6908. var i=1;
  6909. while(anotherURL && i<99) {
  6910. addLinkField(i,anotherURL,
  6911. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6912. i++;
  6913. anotherURL = MY_getValue('URL'+i);
  6914. }
  6915. }
  6916.  
  6917. function addLinkField(i,url,nom,ico) {
  6918. var linksBody = document.getElementById('linksBody');
  6919. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6920. var tr = appendTr(linksBody);
  6921. var td = appendTdCenter(tr);
  6922. appendText(td,'Lien '+i+' : ');
  6923. appendTextbox(td,'text','url'+i,40,150,url);
  6924. td = appendTdCenter(tr);
  6925. appendText(td,'Nom : ');
  6926. appendTextbox(td,'text','nom'+i,20,150,nom);
  6927. td = appendTdCenter(tr);
  6928. appendText(td,'Icône : ');
  6929. appendTextbox(td,'text','ico'+i,40,150,ico);
  6930. }
  6931.  
  6932. function removeLinkField() {
  6933. var linksBody = document.getElementById('linksBody');
  6934. var i = linksBody.childNodes.length;
  6935. MY_removeValue('URL'+i);
  6936. MY_removeValue('URL'+i+'.nom');
  6937. MY_removeValue('URL'+i+'.ico');
  6938. linksBody.removeChild(linksBody.lastChild);
  6939. if(linksBody.childNodes.length==0) { addLinkField(); }
  6940. }
  6941.  
  6942. function resetMainIco() {
  6943. document.getElementById('icoMenuIco').value=
  6944. URL_MZimg + 'mz_logo_small.png';
  6945. }
  6946.  
  6947.  
  6948. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6949.  
  6950. function insertTitle(next,txt) {
  6951. var div = document.createElement('div');
  6952. div.className = 'titre2';
  6953. appendText(div,txt);
  6954. insertBefore(next,div);
  6955. return div;
  6956. }
  6957.  
  6958. function insertMainTable(next) {
  6959. var table = document.createElement('table');
  6960. table.width = '98%';
  6961. table.border = 0;
  6962. table.align = 'center';
  6963. table.cellPadding = 2;
  6964. table.cellSpacing = 1;
  6965. table.className = 'mh_tdborder';
  6966. var tbody = document.createElement('tbody');
  6967. table.appendChild(tbody);
  6968. insertBefore(next,table);
  6969. return tbody;
  6970. }
  6971.  
  6972. function appendSubTable(node) {
  6973. var table = document.createElement('table');
  6974. table.width = '100%';
  6975. var tbody = document.createElement('tbody');
  6976. table.appendChild(tbody);
  6977. node.appendChild(table);
  6978. return tbody;
  6979. }
  6980.  
  6981. function insertOptionTable(insertPt) {
  6982. var mainBody = insertMainTable(insertPt);
  6983. /* Liens dans le Menu */
  6984. var tr = appendTr(mainBody,'mh_tdtitre');
  6985. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6986. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6987. appendText(td,'Icône du Menu: ');
  6988. var url = MY_getValue(numTroll+'.ICOMENU');
  6989. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6990. url = URL_MZimg + 'mz_logo_small.png';
  6991. }
  6992. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6993. appendButton(td,'Réinitialiser',resetMainIco);
  6994. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6995. var tbody = appendSubTable(td);
  6996. tbody.id = 'linksBody';
  6997. refreshLinks();
  6998. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6999. appendButton(td,'Ajouter',addLinkField);
  7000. appendButton(td,'Supprimer',removeLinkField);
  7001. /* Options de la Vue : vue externe, nb de CdM, etc */
  7002. tr = appendTr(mainBody,'mh_tdtitre');
  7003. appendTdText(tr,'Options de la Vue :',true);
  7004. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7005. tbody = appendSubTable(td);
  7006. tr = appendTr(tbody);
  7007. td = appendTdText(tr,'Vue externe : ');
  7008. var select = document.createElement('select');
  7009. select.id = 'vueext';
  7010. td.appendChild(select);
  7011. var listeVues2D = [
  7012. 'Bricol\' Vue',
  7013. 'Vue du CCM',
  7014. 'Vue Gloumfs 2D',
  7015. 'Vue Gloumfs 3D',
  7016. 'Grouky Vue!'
  7017. ];
  7018. for(var i=0 ; i<listeVues2D.length ; i++) {
  7019. appendOption(select,listeVues2D[i],listeVues2D[i]);
  7020. }
  7021. if(MY_getValue('VUEEXT')) {
  7022. select.value = MY_getValue('VUEEXT');
  7023. }
  7024. td = appendTd(tr);
  7025. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  7026. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  7027. tr = appendTr(tbody);
  7028. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  7029. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  7030. td = appendTd(tr);
  7031. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  7032. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  7033. /* Interface Tactique */
  7034. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7035. appendText(td,'Interface Tactique : ',true);
  7036. select = document.createElement('select');
  7037. select.id = 'itSelect';
  7038. appendOption(select,'none','Aucune');
  7039. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  7040. // seule interface supportée !
  7041. td.appendChild(select);
  7042. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7043. tbody = appendSubTable(td);
  7044. tbody.id = 'itBody';
  7045. select.onchange = onChangeIT;
  7046. var str = MY_getValue(numTroll+'.INFOSIT');
  7047. if(str) {
  7048. select.value = str.slice(0,str.indexOf('$'));
  7049. onChangeIT();
  7050. }
  7051. /* Options diverses */
  7052. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7053. appendText(td,'Options diverses :',true);
  7054. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7055. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  7056. appendText(td,
  7057. ' Afficher les caractéristiques des équipements des autres Trõlls');
  7058. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7059. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  7060. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  7061. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7062. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  7063. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  7064. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7065. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  7066. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  7067. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7068. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  7069. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  7070. /* Bouton SaveAll */
  7071. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  7072. input = appendButton(td,'Sauvegarder',saveAll);
  7073. input.id = 'saveAll';
  7074. }
  7075.  
  7076. function insertCreditsTable(insertPt) {
  7077. var tbody = insertMainTable(insertPt);
  7078. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  7079. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  7080. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  7081.  
  7082. var ul = document.createElement('ul');
  7083. td.appendChild(ul);
  7084. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  7085. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  7086. appendLI(ul,'Reivax (4234) pour les infos bulles');
  7087. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  7088. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  7089. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  7090. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  7091. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  7092. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  7093. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  7094. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  7095. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  7096. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  7097. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  7098. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  7099. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  7100. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  7101. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  7102. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  7103. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  7104. }
  7105.  
  7106.  
  7107. /* [functions] Obsolètes */
  7108. function deleteEnchantement()
  7109. {
  7110. try
  7111. {
  7112. var idEquipement = this.getAttribute('name');
  7113. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  7114. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  7115. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  7116. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  7117. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  7118. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7119. var string = "";
  7120. for(var i=0;i<listeEquipement.length;i++)
  7121. {
  7122. if(listeEquipement[i]!=idEquipement)
  7123. if(string=="")
  7124. string = listeEquipement[i];
  7125. else
  7126. string += ";"+listeEquipement[i];
  7127. }
  7128. if(string=="")
  7129. {
  7130. MY_removeValue(numTroll+".enchantement.liste");
  7131. var table = this.parentNode.parentNode.parentNode.parentNode;
  7132. var parent = table.parentNode;
  7133. for(var i=0;i<parent.childNodes.length;i++)
  7134. {
  7135. if(parent.childNodes[i]==table)
  7136. {
  7137. parent.removeChild(parent.childNodes[i-1]);
  7138. parent.removeChild(parent.childNodes[i-1]);
  7139. parent.removeChild(parent.childNodes[i-1]);
  7140. break;
  7141. }
  7142. }
  7143. }
  7144. else
  7145. {
  7146. MY_getValue(numTroll+".enchantement.liste",string);
  7147. this.parentNode.parentNode.parentNode
  7148. .removeChild(this.parentNode.parentNode);
  7149. }
  7150. }
  7151. catch(e)
  7152. {
  7153. window.alert(e);
  7154. }
  7155. }
  7156. /* [functions] fin Obsolètes */
  7157.  
  7158. /*-[functions]---------------- Partie principale -----------------------------*/
  7159.  
  7160. function do_option() {
  7161. start_script(712);
  7162. var insertPoint = document.getElementById('footer1');
  7163. insertBefore(insertPoint,document.createElement('p'));
  7164. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  7165. ti.onclick = function (e) {
  7166. var evt = e || window.event;
  7167. if (evt.shiftKey) {
  7168. var txt = '';
  7169. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  7170. var k = localStorage.key(i);
  7171. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  7172. txt += k + "\t" + localStorage.getItem(k) + "\n";
  7173. }
  7174. copyTextToClipboard(txt);
  7175. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  7176. } else if (evt.ctrlKey) {
  7177. var tabK= [];
  7178. var sMatch = numTroll + '.';
  7179. var lMatch = sMatch.length;
  7180. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  7181. var k = localStorage.key(i);
  7182. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  7183. }
  7184. for (var i = 0; i < tabK.length; ++i ) {
  7185. MY_removeValue(tabK[i]);
  7186. }
  7187. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  7188. }
  7189. }
  7190. ti.title = 'Version ' + GM_info.script.version;
  7191. insertOptionTable(insertPoint);
  7192. /* insertion enchantements ici
  7193. if(...)
  7194. insertEnchantementTable();
  7195. */
  7196. insertBefore(insertPoint,document.createElement('p'));
  7197. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  7198. ti.onclick = function (e) {
  7199. var evt = e || window.event;
  7200. if (!evt.shiftKey) return;
  7201. var oldDev = MY_getValue('MZ_dev');
  7202. if (oldDev) {
  7203. MY_removeValue('MZ_dev');
  7204. } else {
  7205. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  7206. MY_setValue('MZ_dev', 1);
  7207. }
  7208. document.location.href = document.location.href;
  7209. }
  7210. insertCreditsTable(insertPoint);
  7211. insertBefore(insertPoint,document.createElement('p'));
  7212.  
  7213. /* [zone] Obsolète ?? */
  7214. if(MY_getValue(numTroll+".enchantement.liste")
  7215. && MY_getValue(numTroll+".enchantement.liste")!="" )
  7216. {
  7217. insertTitle(insertPoint, 'Les Enchantements en cours');
  7218. table = document.createElement('table');
  7219. table.setAttribute('width', '98%');
  7220. table.setAttribute('border', '0');
  7221. table.setAttribute('align', 'center');
  7222. table.setAttribute('cellpadding', '2');
  7223. table.setAttribute('cellspacing', '1');
  7224. table.setAttribute('class', 'mh_tdborder');
  7225.  
  7226. tbody = document.createElement('tbody');
  7227. table.appendChild(tbody);
  7228. tr = appendTr(tbody, 'mh_tdtitre');
  7229. appendTdText(tr, 'Equipement',1);
  7230. appendTdText(tr, 'Composants',1);
  7231. appendTdText(tr, 'Enchanteur',1);
  7232. appendTdText(tr, 'Action',1);
  7233. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7234. for(var i=0;i<listeEquipement.length;i++)
  7235. {
  7236. try
  7237. {
  7238. var idEquipement = listeEquipement[i];
  7239. var nomEquipement = MY_getValue(numTroll+".enchantement."
  7240. +idEquipement+".objet");
  7241. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  7242. +idEquipement+".enchanteur").split(";");
  7243. var ul = document.createElement('UL');
  7244. for(var j=0;j<3;j++)
  7245. {
  7246. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  7247. var v = MY_getValue(k);
  7248. if (v == null) { // protection Roule 26/08/2017
  7249. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  7250. continue;
  7251. }
  7252. var infoComposant = v.split(';');
  7253. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  7254. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  7255. continue;
  7256. }
  7257. var texte = infoComposant[4].replace("Ril ","Œil ");
  7258. for(var k=5;k<infoComposant.length;k++)
  7259. {
  7260. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  7261. }
  7262. li = appendLI(ul,texte);
  7263. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  7264. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  7265. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  7266. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  7267. string+= '<input type="hidden" name="q" value="min" />';
  7268. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  7269. 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>';
  7270.  
  7271. string+= '</form>';
  7272. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  7273. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  7274. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  7275. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  7276. li.innerHTML += string;
  7277. }
  7278. tr = appendTr(tbody, 'mh_tdpage');
  7279. td = appendTdText(tr, nomEquipement);
  7280. td.setAttribute('valign', 'center');
  7281. td = document.createElement('td');
  7282. td.appendChild(ul);
  7283. tr.appendChild(td);
  7284. td.setAttribute('valign', 'center');
  7285. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  7286. td.setAttribute('valign', 'center');
  7287. td = document.createElement('td');
  7288. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  7289. input.setAttribute('name', idEquipement);
  7290. tr.appendChild(td);
  7291. td.setAttribute('valign', 'center');
  7292. }
  7293. catch(e)
  7294. {
  7295. }
  7296. }
  7297. insertBefore(insertPoint, table);
  7298. insertBefore(insertPoint, document.createElement('p'));
  7299. }
  7300. /* [zone] fin Obsolète ?? */
  7301.  
  7302.  
  7303. displayScriptTime();
  7304. }
  7305.  
  7306. /*******************************************************************************
  7307. * This file is part of Mountyzilla. *
  7308. * *
  7309. * Mountyzilla is free software; you can redistribute it and/or modify *
  7310. * it under the terms of the GNU General Public License as published by *
  7311. * the Free Software Foundation; either version 2 of the License, or *
  7312. * (at your option) any later version. *
  7313. * *
  7314. * Mountyzilla is distributed in the hope that it will be useful, *
  7315. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7316. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7317. * GNU General Public License for more details. *
  7318. * *
  7319. * You should have received a copy of the GNU General Public License *
  7320. * along with Mountyzilla; if not, write to the Free Software *
  7321. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7322. *******************************************************************************/
  7323.  
  7324. // x~x equip
  7325.  
  7326. /**
  7327. * 2014-02-08 - v2.0a (from scratch)
  7328. * 2014-02-18 - v2.0a0
  7329. * - ajout calcul Carats / UM des minerais + totaux
  7330. * 2014-03-06 - v2.0a1
  7331. * - retour Infos EM des Champis
  7332. * TODO
  7333. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  7334. */
  7335.  
  7336. function traiteChampis() {
  7337. try{
  7338. var tr = document.getElementById('mh_objet_hidden_Champignon');
  7339. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  7340. }
  7341. catch(e){return;}
  7342. if(trlist.length<=0) return;
  7343. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  7344. var node = trlist.snapshotItem(i).childNodes[7];
  7345. var str = node.textContent.trim();
  7346. var type = str.slice(0,str.lastIndexOf(' '));
  7347. var mundi = mundiChampi[type];
  7348. if(!mundi) continue;
  7349. var urlImg = URL_MZimg
  7350. +'Competences/ecritureMagique.png';
  7351. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  7352. appendText(node,' ');
  7353. node.appendChild(img);
  7354. }
  7355. }
  7356.  
  7357. function traiteCompos() {
  7358. try {
  7359. var tr = document.getElementById('mh_objet_hidden_Composant');
  7360. var tbody = document.evaluate("./td/table/tbody",
  7361. tr, null, 9, null).singleNodeValue;
  7362. }
  7363. catch(e) {return;}
  7364. insererInfosEM(tbody);
  7365. }
  7366.  
  7367. function traiteMinerai() {
  7368. try{
  7369. var tr = document.getElementById('mh_objet_hidden_Minerai');
  7370. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  7371. }
  7372. catch(e){return;}
  7373. if(trlist.length<=0) return;
  7374. var totaux = {};
  7375. var str;
  7376. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  7377. var node = trlist.snapshotItem(i);
  7378. var nature = node.childNodes[7].textContent,
  7379. caracs = node.childNodes[9].textContent;
  7380. var taille = Number(caracs.match(/\d+/)[0]);
  7381. var coef = 1;
  7382. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  7383. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  7384. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  7385. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  7386. if(nature.indexOf('Mithril')!=-1) {
  7387. coef = 0.2*coef;
  7388. str = ' | UM: ';
  7389. }
  7390. else {
  7391. coef = 0.75*coef+1.25;
  7392. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  7393. str = ' | Carats: ';
  7394. }
  7395. var carats = Math.round(taille*coef)
  7396. appendText(node.childNodes[9], str+carats );
  7397. if(!totaux[nature]) {
  7398. totaux[nature] = [taille,carats];
  7399. }
  7400. else {
  7401. totaux[nature][0] += taille;
  7402. totaux[nature][1] += carats;
  7403. }
  7404. }
  7405. str = 'Total : ';
  7406. for(var nature in totaux) {
  7407. if(str.length>8) str += ', ';
  7408. if(nature.indexOf('Mithril')!=-1) {
  7409. str += nature+totaux[nature][1]+' UM';
  7410. }
  7411. else {
  7412. str += nature+totaux[nature][0]+'U/'
  7413. +totaux[nature][1]+'c';
  7414. }
  7415. }
  7416. /*var node = document.getElementById('mh_plus_Minerai');
  7417. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  7418. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  7419. if(!titre) return;*/
  7420. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  7421. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  7422. td.colSpan = 7;
  7423. }
  7424.  
  7425. function do_equip() {
  7426. start_script();
  7427.  
  7428. traiteChampis();
  7429. traiteCompos();
  7430. traiteMinerai();
  7431.  
  7432. displayScriptTime();
  7433. }
  7434.  
  7435. /*******************************************************************************
  7436. * This file is part of Mountyzilla. *
  7437. * *
  7438. * Mountyzilla is free software; you can redistribute it and/or modify *
  7439. * it under the terms of the GNU General Public License as published by *
  7440. * the Free Software Foundation; either version 2 of the License, or *
  7441. * (at your option) any later version. *
  7442. * *
  7443. * Mountyzilla is distributed in the hope that it will be useful, *
  7444. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7445. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7446. * GNU General Public License for more details. *
  7447. * *
  7448. * You should have received a copy of the GNU General Public License *
  7449. * along with Mountyzilla; if not, write to the Free Software *
  7450. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7451. *******************************************************************************/
  7452.  
  7453. // x~x diplo
  7454.  
  7455. /*
  7456. TODO:
  7457. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  7458. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  7459. V Étape 3: Ajout de la diplo perso
  7460. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  7461. V Étape 5: Ajout des fioritures (preview de la couleur...)
  7462. Options Globales:
  7463. Actuelles:
  7464. numTroll.USECSS,
  7465. numTroll.NODIPLO
  7466. NOMYTH
  7467. Nouvelles:
  7468. TODO numTroll.USECSS
  7469. numTroll.diplo.off (remplace NODIPLO)
  7470. numTroll.diplo.guilde
  7471. numTroll.diplo.perso
  7472. Structure de diplo.guilde:
  7473. isOn: 'true' ou 'false'
  7474. isDetailOn: 'true' ou 'false'
  7475. guilde
  7476. > id
  7477. > couleur
  7478. AllAmis,AllEnnemis: couleur
  7479. Amis0,...,Ennemis5
  7480. > Troll: idTroll1;...;
  7481. > Guilde: idGuilde1;...;
  7482. > titre
  7483. > couleur
  7484. Structure de diplo.perso:
  7485. isOn: 'true' ou 'false'
  7486. mythiques: couleur
  7487. Troll,Guilde,Monstre:
  7488. > id
  7489. > couleur
  7490. > description
  7491. */
  7492.  
  7493. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7494.  
  7495. function couleurAleatoire() {
  7496. var alph = '0123456789ABCDEF'.split('');
  7497. var clr = '#';
  7498. for (var i=0; i<6; i++) {
  7499. clr+=alph[ Math.floor(16*Math.random()) ];
  7500. }
  7501. return clr;
  7502. }
  7503.  
  7504. function isCouleur(str) {
  7505. return /^#[0-9A-F]{6}$/i.test(str);
  7506. }
  7507.  
  7508. /*-[functions]---------------- Analyse de la page ----------------------------*/
  7509.  
  7510. function appendChoixCouleur(node,id) {
  7511. var span = document.createElement('span');
  7512. span.id = 'span'+id;
  7513. if(isDetailOn) {
  7514. span.style.display = 'none';
  7515. }
  7516. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  7517. if(diploGuilde[id]) {
  7518. couleur = diploGuilde[id];
  7519. }
  7520. appendText(span,' - Couleur HTML: ');
  7521. var input = appendTextbox(span,'text',id,7,7,couleur);
  7522. input.onkeyup = previewCouleur;
  7523. input.onchange = previewCouleur;
  7524. input.onkeyup();
  7525. node.appendChild(span);
  7526. }
  7527.  
  7528. function insertChoixCouleur(node,id) {
  7529. var span = document.createElement('span');
  7530. span.id = 'span'+id;
  7531. // La couleur détaillée passera à une valeur aléatoire
  7532. // si toggle vers isDetailOn
  7533. var couleur = couleurAleatoire();
  7534. if(!isDetailOn) {
  7535. span.style.display = 'none';
  7536. } else if(diploGuilde[id]) {
  7537. couleur = diploGuilde[id].couleur;
  7538. }
  7539. appendText(span,' - Couleur HTML: ');
  7540. var input = appendTextbox(span,'text',id,7,7,couleur);
  7541. input.onkeyup = previewCouleur;
  7542. input.onchange = previewCouleur;
  7543. input.onkeyup();
  7544. insertBefore(node,span);
  7545. }
  7546.  
  7547. function setChoixCouleurs() {
  7548. try {
  7549. //var form = document.getElementsByName('ActionForm')[0];
  7550. var form = document.getElementById('mhPlay');
  7551. var nodesAE = document.evaluate(
  7552. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  7553. "./table/tbody/tr/th[@class='mh_tdtitre']",
  7554. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  7555. form, null, 7, null
  7556. );
  7557. var nodes = document.evaluate(
  7558. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  7559. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  7560. form, null, 7, null
  7561. );
  7562. } catch(e) {
  7563. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  7564. return false;
  7565. };
  7566. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  7567. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  7568. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  7569. for(var i=0 ; i<5 ; i++) {
  7570. nodes.snapshotItem(i).id = 'tdAmis'+i;
  7571. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  7572. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  7573. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  7574. }
  7575. return true;
  7576. }
  7577.  
  7578. function fetchDiploGuilde() {
  7579. try {
  7580. for(var AE in {Amis:0,Ennemis:0}) {
  7581. for(var i=0 ; i<5 ; i++) {
  7582. /* Récup des A/E de rang i */
  7583. var td = document.getElementById('td'+AE+i);
  7584. var ligne = td.getElementsByTagName('table')[0].rows;
  7585. var titre = trim(td.firstChild.textContent);
  7586. // On laisse la gestion des couleurs à setChoixCouleurs:
  7587. var couleur = document.getElementById(AE+i).value;
  7588. diploGuilde[AE+i] = {
  7589. Troll:'',
  7590. Guilde:'',
  7591. titre: titre,
  7592. couleur: couleur
  7593. };
  7594. for(var j=1 ; j<ligne.length ; j++) {
  7595. var str = trim(ligne[j].cells[0].textContent);
  7596. var idx = str.lastIndexOf('(');
  7597. var num = str.slice(idx+1,-1);
  7598. var type = trim(ligne[j].cells[1].textContent);
  7599. diploGuilde[AE+i][type] += num+';';
  7600. }
  7601. }
  7602. }
  7603. } catch(e) {
  7604. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  7605. return false;
  7606. }
  7607. return true;
  7608. }
  7609.  
  7610.  
  7611. /*-[functions]--------------------- Handlers ---------------------------------*/
  7612.  
  7613. function toggleDetails() {
  7614. isDetailOn = !isDetailOn;
  7615. for(var AE in {Amis:0,Ennemis:0}) {
  7616. document.getElementById('spanAll'+AE).style.display =
  7617. (isDetailOn?'none':'');
  7618. for(var i=0 ; i<5 ; i++) {
  7619. document.getElementById('span'+AE+i).style.display =
  7620. (isDetailOn?'':'none');
  7621. }
  7622. }
  7623. }
  7624.  
  7625. function toggleMythiques() {
  7626. isMythiquesOn = !isMythiquesOn;
  7627. document.getElementById('spanMythiques').style.display =
  7628. (isMythiquesOn?'':'none');
  7629. }
  7630.  
  7631. function previewCouleur() {
  7632. var value = this.value;
  7633. if(isCouleur(value)) {
  7634. this.style.backgroundColor = value;
  7635. this.title = '';
  7636. } else {
  7637. this.style.backgroundColor = '';
  7638. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  7639. }
  7640. }
  7641.  
  7642. function appendMenuType(node,duType) {
  7643. var select = document.createElement('select');
  7644. select.className = 'SelectboxV2';
  7645. var type = ['Guilde','Troll','Monstre'];
  7646. for(var i=0 ; i<3 ; i++) {
  7647. appendOption(select,type[i],type[i]);
  7648. if(type[i]==duType) { select.selectedIndex=i; }
  7649. }
  7650. node.appendChild(select);
  7651. }
  7652.  
  7653. function ajouteChamp(type,num,couleur,descr) {
  7654. var champs = document.getElementById('diploPerso');
  7655. var nb = champs.rows.length;
  7656. var tr = champs.insertRow(-1);
  7657. var td = appendTd(tr);
  7658. appendMenuType(td,type);
  7659. td = appendTd(tr);
  7660. appendText(td,' n°');
  7661. appendTextbox(td,'text','num'+nb,6,15,num);
  7662. td = appendTd(tr);
  7663. appendText(td,' couleur HTML:');
  7664. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7665. input.onkeyup = previewCouleur;
  7666. input.onchange = previewCouleur;
  7667. input.onkeyup();
  7668. td = appendTd(tr);
  7669. appendText(td,' Description:');
  7670. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7671. td = appendTd(tr);
  7672. var span = document.createElement('span');
  7673. appendText(span,'[ok!]',true);
  7674. span.style.visibility = 'hidden';
  7675. td.appendChild(span);
  7676. td = appendTd(tr);
  7677. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7678. }
  7679.  
  7680. function retireCeChamp() {
  7681. var thisTr = this.parentNode.parentNode;
  7682. thisTr.parentNode.removeChild(thisTr);
  7683. var champs = document.getElementById('diploPerso');
  7684. if(champs.rows.length==0) { ajouteChamp(); }
  7685. }
  7686.  
  7687. function valideChamp(champ) {
  7688. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7689. isCouleur(champ.cells[2].childNodes[1].value);
  7690. if(isValide) {
  7691. champ.cells[4].firstChild.style.visibility = 'visible';
  7692. } else {
  7693. champ.cells[4].firstChild.style.visibility = 'hidden';
  7694. }
  7695. return isValide;
  7696. }
  7697.  
  7698. function sauvegarderTout() {
  7699. /* Diplo de guilde */
  7700. diploGuilde.isOn =
  7701. document.getElementById('isGuildeOn').checked?'true':'false';
  7702. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7703. var numGuilde = Number(document.getElementById('numGuilde').value);
  7704. var couleur = document.getElementById('couleurGuilde').value;
  7705. if(numGuilde) {
  7706. diploGuilde.guilde = {
  7707. id: numGuilde,
  7708. couleur: couleur
  7709. };
  7710. } else {
  7711. delete diploGuilde.guilde;
  7712. }
  7713. for(var AE in {Amis:0,Ennemis:0}) {
  7714. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7715. for(var i=0 ; i<5 ; i++) {
  7716. if(isDetailOn) {
  7717. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7718. } else {
  7719. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7720. }
  7721. }
  7722. }
  7723. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7724. /* Diplo personnelle (ex-fonction saveChamps) */
  7725. var champs = document.getElementById('diploPerso');
  7726. diploPerso = {
  7727. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7728. Guilde: {},
  7729. Troll: {},
  7730. Monstre: {}
  7731. };
  7732. if(isMythiquesOn &&
  7733. isCouleur(document.getElementById('couleurMythiques').value)) {
  7734. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7735. }
  7736. for(var i=0 ; i<champs.rows.length ; i++) {
  7737. if(valideChamp(champs.rows[i])) {
  7738. var type = champs.rows[i].cells[0].firstChild.value;
  7739. var num = champs.rows[i].cells[1].childNodes[1].value;
  7740. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7741. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7742. diploPerso[type][num] = {
  7743. couleur: couleur
  7744. };
  7745. if(descr) {
  7746. diploPerso[type][num].titre = descr;
  7747. }
  7748. }
  7749. }
  7750. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7751.  
  7752. avertissement('Données sauvegardées');
  7753. }
  7754.  
  7755.  
  7756. /*-[functions]------------- Modifications de la page -------------------------*/
  7757.  
  7758. function creeTablePrincipale() {
  7759. var insertPt = document.getElementById('insertPt');
  7760. /* Titre + bouton de Sauvegarde */
  7761. var tr = insertTr(insertPt,'mh_tdtitre');
  7762. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7763. appendButton(td,'Sauvegarder',sauvegarderTout);
  7764. /* Options fixes */
  7765. tr = insertTr(insertPt,'mh_tdpage');
  7766. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7767. appendBr(td);
  7768. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7769. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7770. appendBr(td);
  7771. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7772. appendText(td,'Utiliser des couleurs détaillées (10)');
  7773. /* Diplo personnelle */
  7774. tr = insertTr(insertPt,'mh_tdpage');
  7775. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7776. appendBr(td);
  7777. // Diplo Mythiques
  7778. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7779. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7780. var span = document.createElement('span');
  7781. span.id = 'spanMythiques';
  7782. if(!isMythiquesOn) {
  7783. span.style.display = 'none';
  7784. }
  7785. var couleur = '#FFAAAA';
  7786. if(diploPerso.mythiques) {
  7787. couleur = diploPerso.mythiques;
  7788. }
  7789. appendText(span,' - couleur HTML:');
  7790. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7791. input.onkeyup = previewCouleur;
  7792. input.onchange = previewCouleur;
  7793. input.onkeyup();
  7794. td.appendChild(span);
  7795. appendBr(td);
  7796. // Diplo éditable
  7797. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7798. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7799. appendBr(td);
  7800. var table = document.createElement('table');
  7801. table.id = 'diploPerso'
  7802. td.appendChild(table);
  7803. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7804. for(var num in diploPerso[type]) {
  7805. ajouteChamp(
  7806. type,
  7807. num,
  7808. diploPerso[type][num].couleur,
  7809. diploPerso[type][num].titre
  7810. );
  7811. }
  7812. }
  7813. if(table.rows.length==0) {
  7814. ajouteChamp();
  7815. }
  7816. appendButton(td,'Ajouter',ajouteChamp)
  7817. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7818. appendText(td,' ');
  7819. appendButton(td,
  7820. 'Exemples de couleur',
  7821. function() {
  7822. var fenetre = window.open(
  7823. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7824. 'Divers',
  7825. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7826. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7827. );
  7828. fenetre.focus();
  7829. }
  7830. );
  7831. /* Couleur de Guilde */
  7832. tr = insertTr(insertPt,'mh_tdtitre');
  7833. td = appendTdText(tr,'GUILDE',true);
  7834. appendText(td,' - n°');
  7835. appendTextbox(td,'text','numGuilde',5,10,
  7836. diploGuilde.guilde && diploGuilde.guilde.id ?
  7837. diploGuilde.guilde.id : ''
  7838. );
  7839. appendText(td,' - Couleur HTML: ');
  7840. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7841. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7842. diploGuilde.guilde.couleur : '#BBBBFF'
  7843. );
  7844. input.onkeyup = previewCouleur;
  7845. input.onchange = previewCouleur;
  7846. input.onkeyup();
  7847. }
  7848.  
  7849.  
  7850. /*-[functions]----------------------- Main -----------------------------------*/
  7851.  
  7852. function initDiplo(sType) {
  7853. var sDiplo = MY_getValue(numTroll + '.diplo.' + sType)
  7854. //console.log('sDiplo' + sType + '=' + sDiplo);
  7855. if (sDiplo && (sDiplo != 'null')) { // le stockage JSON nous donne parfois 'null'
  7856. return JSON.parse(sDiplo);
  7857. } else {
  7858. return {};
  7859. }
  7860. }
  7861. var diploGuilde = initDiplo('guilde');
  7862. var diploPerso = initDiplo('perso');
  7863. var isDetailOn = diploGuilde.isDetailOn=='true';
  7864. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7865.  
  7866. function do_diplo() {
  7867. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7868. creeTablePrincipale();
  7869. }
  7870. }
  7871.  
  7872. /*******************************************************************************
  7873. * This file is part of Mountyzilla. *
  7874. * *
  7875. * Mountyzilla is free software; you can redistribute it and/or modify *
  7876. * it under the terms of the GNU General Public License as published by *
  7877. * the Free Software Foundation; either version 2 of the License, or *
  7878. * (at your option) any later version. *
  7879. * *
  7880. * Mountyzilla is distributed in the hope that it will be useful, *
  7881. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7882. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7883. * GNU General Public License for more details. *
  7884. * *
  7885. * You should have received a copy of the GNU General Public License *
  7886. * along with Mountyzilla; if not, write to the Free Software *
  7887. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7888. *******************************************************************************/
  7889.  
  7890. // x~x cdmcomp
  7891.  
  7892. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  7893.  
  7894. function getNonNegInts(str) {
  7895. var nbrs = str.match(/\d+/g);
  7896. for(var i=0 ; i<nbrs.length ; i++) {
  7897. nbrs[i] = Number(nbrs[i]);
  7898. }
  7899. return nbrs;
  7900. }
  7901.  
  7902. function traiteCdMcomp() {
  7903. try {
  7904. var msgEffet = document.getElementById('msgEffet');
  7905. } catch(e) {
  7906. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  7907. return;
  7908. }
  7909.  
  7910. // Teste si ce message du bot est un message de CdM
  7911. if(!document.evaluate(
  7912. "./p/text()[contains(.,'fait partie')]",
  7913. msgEffet, null, 9, null
  7914. ).singleNodeValue) {
  7915. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  7916. return;
  7917. }
  7918. // Début de récupération de la CdM
  7919. /*
  7920. Roule 10/03/2017 j'ai grandement simplifié ☺ ☺ ☺
  7921. zone à supprimer
  7922. traitement Armure Physique/Magique reporté en php
  7923.  
  7924. cdm = document.evaluate(
  7925. "./p/text()[contains(.,'fait partie')]",
  7926. msgEffet, null, 9, null
  7927. ).singleNodeValue.nodeValue+'\n';
  7928. var tbody = document.evaluate(
  7929. "descendant::table/tbody",
  7930. msgEffet, null, 9, null
  7931. ).singleNodeValue;
  7932. var nomStat = document.evaluate(
  7933. "./tr/td[1]/b/text()",
  7934. tbody, null, 7, null
  7935. );
  7936. var valStat = document.evaluate(
  7937. "./tr/td[2]/descendant::text()",
  7938. tbody, null, 7, null
  7939. );
  7940. var i=0;
  7941. while(i<nomStat.snapshotLength) {
  7942. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7943. cdm += 'Armure : ';
  7944. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7945. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7946. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7947. armp = [0,armp[0]];
  7948. }
  7949. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7950. armm = [0,armm[0]];
  7951. }
  7952. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7953. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7954. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7955. } else {
  7956. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7957. }
  7958. cdm += ')\n';
  7959. i++;
  7960. } else {
  7961. cdm += nomStat.snapshotItem(i).nodeValue+
  7962. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7963. }
  7964. i++;
  7965. }
  7966. */
  7967. //cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  7968. //if (MY_DEBUG) window.console.log('cmd=' + cdm);
  7969.  
  7970. // envoi au serveur (PHP) d'un objet avec
  7971. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  7972. // tstamp: l'horodatage
  7973. var tabCdM = new Array();
  7974. var etimestamp = document.getElementById('hserveur');
  7975. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  7976. var txtBlessure;
  7977. var txtPv;
  7978. for (var iElt = 0; iElt < msgEffet.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  7979. var eHTML = msgEffet.childNodes[iElt];
  7980. switch (eHTML.nodeName) {
  7981. case '#text':
  7982. var s = eHTML.nodeValue.trim();
  7983. if (s != '') tabCdM.push(s);
  7984. break;
  7985. case 'P':
  7986. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7987. s = s.trim();
  7988. if (s != '') tabCdM.push(s);
  7989. break;
  7990. case 'TABLE':
  7991. var s = 'table';
  7992. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  7993. var eTr = eHTML.rows[iTr];
  7994. var tabTd = new Array();
  7995. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  7996. var eTd = eTr.cells[iTd];
  7997. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  7998. s = s.trim();
  7999. tabTd.push(s);
  8000. }
  8001. if (tabTd.length >= 2) {
  8002. if (tabTd[0].match(/Blessure/i)) {
  8003. txtBlessure = tabTd[1]
  8004. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  8005. txtPv = tabTd[1]
  8006. }
  8007. }
  8008. tabCdM.push(tabTd);
  8009. }
  8010. break;
  8011. default:
  8012. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  8013. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8014. if (s != '') tabCdM.push(s);
  8015. break;
  8016. }
  8017. }
  8018. var oData = {};
  8019. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  8020. oData.idTroll = numTroll;
  8021. oData.tabCdM = tabCdM;
  8022. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  8023.  
  8024. // envoi d'une CdM issue de compte-rendu de compétence
  8025. // fonction définie ici pour avoir vue sur la variable tabCdM
  8026. var sendInfoCDM = function () {
  8027. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  8028. var buttonCDM = this;
  8029. var texte = '';
  8030. FF_XMLHttpRequest({
  8031. method: 'POST',
  8032. url: URL_pageDispatcherV2,
  8033. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8034. headers : {
  8035. /* inutile, à supprimer
  8036. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8037. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8038. */
  8039. 'Content-type':'application/x-www-form-urlencoded',
  8040. },
  8041. trace: 'envoi CdM',
  8042. onload: function(responseDetails) {
  8043. texte = responseDetails.responseText;
  8044. buttonCDM.value = texte;
  8045. if (!isDEV) buttonCDM.disabled = true;
  8046. }
  8047. });
  8048. }
  8049.  
  8050. // Envoi auto ou insertion bouton envoi (suivant option)
  8051. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  8052. sendInfoCDM();
  8053. var p = document.createElement('p');
  8054. p.style.color = 'green';
  8055. appendText(p,'CdM envoyée vers la base MountyZilla !');
  8056. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  8057. } else {
  8058. insertButtonCdm('as_Action', sendInfoCDM);
  8059. }
  8060.  
  8061. // Insertion de l'estimation des PV restants
  8062. /*
  8063. var pv = valStat.snapshotItem(1).nodeValue;
  8064. if(pv.indexOf("entre")==-1) {
  8065. return;
  8066. }
  8067. var trPv = document.evaluate(
  8068. "//tr[contains(td/b/text(),'Points de Vie')]",
  8069. msgEffet, null, 9, null).singleNodeValue;
  8070. tdPv = trPv.cells[1];
  8071. txtPv = tdPv.innerText || tdPv.textContent;
  8072. if (MY_DEBUG) window.console.log('txtPv=' + txtPv);
  8073. if(0) { //pv) { // bloqué en attendant correction
  8074. */
  8075. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  8076. if (txtBlessure !== undefined && txtPv !== undefined) {
  8077. var pv = getPVsRestants(txtPv,txtBlessure);
  8078. if (MY_DEBUG) window.console.log('pv=' + pv);
  8079. if (pv) { // pv null si le monstre n'est pas blessé
  8080. var trBless = document.evaluate(
  8081. "//tr[contains(td/b/text(),'Blessure')]",
  8082. msgEffet, null, 9, null).singleNodeValue;
  8083. var tr = document.createElement('tr');
  8084. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  8085. appendTr(trBless);
  8086. appendTdText(tr, pv[0], true);
  8087. appendTdText(tr, pv[1], true);
  8088. }
  8089. }
  8090. }
  8091.  
  8092. function do_cdmcomp() {
  8093. start_script(31);
  8094. traiteCdMcomp();
  8095. displayScriptTime();
  8096. }
  8097.  
  8098. /*********************************************************************************
  8099. * This file is part of Mountyzilla. *
  8100. * *
  8101. * Mountyzilla is free software; you can redistribute it and/or modify *
  8102. * it under the terms of the GNU General Public License as published by *
  8103. * the Free Software Foundation; either version 2 of the License, or *
  8104. * (at your option) any later version. *
  8105. * *
  8106. * Mountyzilla is distributed in the hope that it will be useful, *
  8107. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8108. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8109. * GNU General Public License for more details. *
  8110. * *
  8111. * You should have received a copy of the GNU General Public License *
  8112. * along with Mountyzilla; if not, write to the Free Software *
  8113. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8114. *********************************************************************************/
  8115.  
  8116. // x~x cmdbot
  8117.  
  8118. /* v0.2 by Dab - 2013-08-20
  8119. * - patch dégueu pour gérer la décomposition P/M de l'armure
  8120. */
  8121.  
  8122. var buttonCDM;
  8123.  
  8124. /*******************************************************************************************
  8125. CDM :
  8126. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  8127.  
  8128. Il ne vous est pas possible d'améliorer cette compétence.
  8129.  
  8130. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  8131. Niveau : Inimaginable (entre 49 et 51)
  8132. Points de Vie : Surtrollesque (entre 450 et 470)
  8133. Blessure (Approximatif) : 0 %
  8134. Dés d'Attaque : Impressionnant (entre 30 et 32)
  8135. Dés d'Esquive : Impressionnant (entre 28 et 30)
  8136. Dés de Dégat : Très Fort (entre 18 et 20)
  8137. Dés de Régénération : Excellent (égal à 13)
  8138. Armure Physique : Moyen (entre 10 et 12)
  8139. Armure Magique : Faible (inférieur à 6)
  8140. Vue : Moyen (entre 9 et 11)
  8141. Maitrise Magique : Inimaginable (supérieur à 6000)
  8142. Résistance Magique : Inimaginable (supérieur à 6000)
  8143. Nombre d'attaques : 1
  8144. Vitesse de Déplacement : Normale
  8145. Voir le Caché : Oui
  8146. Attaque à distance : Non
  8147. Attaque magique : Oui
  8148. Vole : Non
  8149. Sang froid : Inexistant
  8150. DLA : Milieu
  8151. Durée Tour : Remarquable (entre 9 et 11)
  8152. Chargement : Vide
  8153. Bonus Malus : Aucun
  8154.  
  8155. Vous avez également gagné 1 PX pour la réussite.
  8156. *******************************************************************************************
  8157. BOT :
  8158. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  8159.  
  8160. Le Monstre ciblé fait partie des : Mort-Vivant
  8161.  
  8162. Niveau : Incroyable (entre 36 et 38)
  8163. *******************************************************************************************/
  8164.  
  8165. function getNNInt(str) {
  8166. var nbrs = str.match(/\d+/g);
  8167. for (var i=0 ; i<nbrs.length ; i++)
  8168. nbrs[i] = parseInt(nbrs[i]);
  8169. return nbrs;
  8170. }
  8171.  
  8172. // envoi d'une CdM issue d'un message du BOT
  8173. function sendCDM() {
  8174. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  8175. document, null, 9, null).singleNodeValue;
  8176. /* ancienne version à supprimer
  8177. cdm = td.innerHTML;
  8178. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  8179. "$3$4 ($1 - N°$2)<br>");
  8180. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  8181. 'Blessure : XX % (approximativement)');
  8182. // Supprime la décomposition P/M de l'Armure
  8183. var bgn = cdm.indexOf('Armure Physique');
  8184. if (bgn!=-1) {
  8185. var end = cdm.indexOf('Vue')-2;
  8186. var lines = cdm.substring(bgn,end).split('<br>');
  8187. var armp = getNNInt(lines[0]);
  8188. var armm = getNNInt(lines[1]);
  8189. if (lines[0].indexOf('(inf')!=-1)
  8190. armp = [0,armp[0]];
  8191. if (lines[1].indexOf('(inf')!=-1)
  8192. armm = [0,armm[0]];
  8193. var insrt = 'Armure : ';
  8194. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  8195. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  8196. else
  8197. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  8198. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  8199. }
  8200. cdm = cdm.replace(/<br>/g,'\n');
  8201. */
  8202.  
  8203. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  8204. //window.console.log(tdTxt);
  8205. var oData = {};
  8206. oData.tabCdM = tdTxt.split(/\n/);
  8207. // nettoyage entête : enlève le premier élément tant que
  8208. // - suite de *
  8209. // - "MOUNTYHALL - La Terre des Trõlls"
  8210. // - ligne vide (la première expression régulière matche les lignes vides)
  8211. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  8212. // 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
  8213. var iLigneNonVide;
  8214. for (var i = 0; i < oData.tabCdM.length; i++) {
  8215. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  8216. if (iLigneNonVide === undefined)
  8217. oData.tabCdM.splice(i);
  8218. else
  8219. oData.tabCdM.splice(iLigneNonVide+1);
  8220. break;
  8221. }
  8222. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  8223. }
  8224. //window.console.log(JSON.stringify(oData));
  8225.  
  8226. FF_XMLHttpRequest({
  8227. method: 'POST',
  8228. url: URL_pageDispatcherV2,
  8229. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8230. headers : {
  8231. /* inutile, à supprimer
  8232. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8233. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8234. */
  8235. 'Content-type':'application/x-www-form-urlencoded',
  8236. },
  8237. trace: 'envoi CdM msg du bot',
  8238. onload: function(responseDetails) {
  8239. buttonCDM.value=responseDetails.responseText;
  8240. buttonCDM.disabled = true;
  8241. }
  8242. });
  8243. }
  8244.  
  8245. function traiteCdMmsg() {
  8246. // Teste si ce message du bot est un message de CdM
  8247. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  8248. document, null, 9, null).singleNodeValue;
  8249. if (!td) return false;
  8250. cdm = td.innerHTML;
  8251. // Insertion de l'estimation des PV restants
  8252. var des = cdm.indexOf('Dés');
  8253. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  8254. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  8255. if(pv)
  8256. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  8257.  
  8258. // Insertion bouton envoi + espace
  8259. buttonCDM = insertButtonCdm('bClose',sendCDM);
  8260. }
  8261.  
  8262. /*function traitePouvoir() {
  8263. // Teste si ce message du bot est un message de CdM
  8264. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  8265. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  8266. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8267. if (!td)
  8268. return false;
  8269. var infos = td.innerHTML;
  8270. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  8271. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  8272. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  8273. var date = /alors : ([^<]+)\./.exec(infos)[1];
  8274. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  8275. var effetPouvoir="";
  8276. var full=false;
  8277. if(infos.indexOf("REDUIT")!=-1) {
  8278. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  8279. }
  8280. else {
  8281. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  8282. full=true;
  8283. }
  8284. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  8285. // On insère le bouton et un espace
  8286. //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));
  8287. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  8288. if(!MY_getValue('AUTOSENDPOUV'))
  8289. {
  8290. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  8291. button.setAttribute("onClick", "window.open('" + url
  8292. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  8293. + "this.value='Merci de votre participation'; this.disabled = true;");
  8294. }
  8295. else
  8296. {
  8297. FF_XMLHttpRequest({
  8298. method: 'GET',
  8299. url: url,
  8300. headers : {
  8301. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8302. 'Accept': 'application/atom+xml,application/xml,text/xml'
  8303. }});
  8304. }
  8305. }*/
  8306.  
  8307. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  8308. traiteCdMmsg();
  8309. }
  8310. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  8311.  
  8312. /*******************************************************************************
  8313. * This file is part of Mountyzilla. *
  8314. * *
  8315. * Mountyzilla is free software; you can redistribute it and/or modify *
  8316. * it under the terms of the GNU General Public License as published by *
  8317. * the Free Software Foundation; either version 2 of the License, or *
  8318. * (at your option) any later version. *
  8319. * *
  8320. * Mountyzilla is distributed in the hope that it will be useful, *
  8321. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8322. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8323. * GNU General Public License for more details. *
  8324. * *
  8325. * You should have received a copy of the GNU General Public License *
  8326. * along with Mountyzilla; if not, write to the Free Software *
  8327. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8328. *******************************************************************************/
  8329.  
  8330. // x~x menu
  8331. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  8332.  
  8333. var menuRac, mainIco;
  8334.  
  8335. // met à jour les carac sauvegardées (position, DLA, etc.)
  8336. function updateData() {
  8337. var inputs = document.getElementsByTagName('input');
  8338. var divs = document.getElementsByTagName('div');
  8339.  
  8340. //window.console.log('inputs=' + JSON.stringify(inputs));
  8341. if (inputs && inputs.length > 0) {
  8342. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  8343. numTroll = inputs[0].value;
  8344. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  8345. MY_setValue('NUM_TROLL', numTroll);
  8346. MY_setValue('NIV_TROLL',inputs[1].value);
  8347. if(!MY_getValue(numTroll+'.caracs.rm')) {
  8348. MY_setValue(numTroll+'.caracs.rm',0);
  8349. // assure l'init des 4 var de libs
  8350. }
  8351. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  8352. } else {
  8353. // onclick="EnterPJView(91305,750,550)"
  8354. var tabA = document.getElementsByTagName('a');
  8355. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  8356. var s = tabA[0].onclick.toString();;
  8357. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  8358. var m = s.match(/\((\d+) *,/);
  8359. //window.console.log('m=' + JSON.stringify(m));
  8360. numTroll = parseInt(m[1]);
  8361. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  8362. MY_setValue('NUM_TROLL', numTroll);
  8363. } else {
  8364. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  8365. }
  8366. }
  8367.  
  8368. var DLA = new Date(
  8369. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  8370. );
  8371. if(MY_getValue(numTroll+'.DLA.encours')) {
  8372. var DLAstockee = new Date(
  8373. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  8374. );
  8375. if(DLA>DLAstockee) {
  8376. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  8377. // Pose un pb en cas de décalage de DLA
  8378. }
  8379. }
  8380. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  8381.  
  8382. try {
  8383. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  8384. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  8385. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  8386. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  8387. } catch(e) {
  8388. 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, '‹'));
  8389. }
  8390. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  8391. }
  8392.  
  8393. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  8394. function initRaccourcis() {
  8395. var anotherURL = MY_getValue('URL1');
  8396. if(!anotherURL) { return; }
  8397.  
  8398. /* Création de l'icône faisant apparaître le menu */
  8399. mainIco = document.createElement('img');
  8400. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  8401. if(!urlIco) {
  8402. urlIco =
  8403. URL_MZimg + 'mz_logo_small.png';
  8404. }
  8405. mainIco.src = urlIco;
  8406. mainIco.alt = 'MZ';
  8407. mainIco.style = 'position:fixed; top:0px; left:0px';
  8408. mainIco.onmouseover = afficheMenu;
  8409. document.body.appendChild(mainIco);
  8410. /* Création du menu des Raccourcis */
  8411. menuRac = document.createElement('div');
  8412. menuRac.className = 'mh_textbox';
  8413. menuRac.style =
  8414. 'position:fixed; top:10px; left:10px;'+
  8415. 'max-width:190px;'+
  8416. 'border-radius: 4px; padding: 4px;'+
  8417. 'z-index: 500;'+
  8418. 'visibility: hidden;';
  8419. document.body.appendChild(menuRac);
  8420. document.addEventListener('mousemove',cacheMenu,false);
  8421. var i=1;
  8422. while(anotherURL) {
  8423. var a = document.createElement('a');
  8424. var url = MY_getValue('URL'+i);
  8425. var nom = MY_getValue('URL'+i+'.nom');
  8426. var ico = MY_getValue('URL'+i+'.ico');
  8427. a.href = url;
  8428. a.target = '_blank';
  8429. if(ico) {
  8430. var txt = nom ? nom : '';
  8431. var img = createImage(ico,txt);
  8432. a.appendChild(img);
  8433. }
  8434. else {
  8435. appendText(a,'['+nom+']');
  8436. }
  8437. menuRac.appendChild(a);
  8438. appendBr(menuRac);
  8439. i++;
  8440. anotherURL = MY_getValue('URL'+i);
  8441. }
  8442. }
  8443.  
  8444. function afficheMenu() {
  8445. menuRac.style.visibility = 'visible';
  8446. }
  8447.  
  8448. function cacheMenu(e) {
  8449. if(menuRac.style.visibility=='hidden') { return; }
  8450. // Position souris
  8451. var ptX = e.clientX;
  8452. var ptY = e.clientY;
  8453. // On recalcule en live les BoundingBox pour mainIco et menuRac
  8454. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  8455. var menuRect = menuRac.getBoundingClientRect();
  8456. var icoRect = mainIco.getBoundingClientRect();
  8457. if((ptX>icoRect.width || ptY>icoRect.height) &&
  8458. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  8459. menuRac.style.visibility = 'hidden';
  8460. }
  8461. }
  8462.  
  8463. // ajout de l'icône, branchée sur un refresh
  8464. function initUpdateCoordGauche() {
  8465. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8466. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  8467. var img = document.createElement('img');
  8468. img.src = URL_MZimg + 'recycl.png'
  8469. img.onclick = function(evt) {
  8470. document.location.href = document.location.href;
  8471. };
  8472. img.title = 'Mise à jour de la localisation';
  8473. img.style.cursor = 'pointer';
  8474. img.style.position = 'absolute';
  8475. img.style.bottom = 0;
  8476. img.style.left = 0;
  8477. div.appendChild(img);
  8478. }
  8479.  
  8480. function do_menu() {
  8481. // met à jour les carac sauvegardées (position, DLA, etc.)
  8482. updateData();
  8483. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  8484. initRaccourcis();
  8485. // Ajout bouton de mise à jour coordonnées
  8486. initUpdateCoordGauche();
  8487. }
  8488.  
  8489. /*******************************************************************************
  8490. * This file is part of Mountyzilla. *
  8491. * *
  8492. * Mountyzilla is free software; you can redistribute it and/or modify *
  8493. * it under the terms of the GNU General Public License as published by *
  8494. * the Free Software Foundation; either version 2 of the License, or *
  8495. * (at your option) any later version. *
  8496. * *
  8497. * Mountyzilla is distributed in the hope that it will be useful, *
  8498. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8499. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8500. * GNU General Public License for more details. *
  8501. * *
  8502. * You should have received a copy of the GNU General Public License *
  8503. * along with Mountyzilla; if not, write to the Free Software *
  8504. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8505. *******************************************************************************/
  8506.  
  8507. // x~x vue
  8508.  
  8509. /* TODO
  8510. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  8511. * prévoir fix ("delete infos")
  8512. */
  8513.  
  8514. /*--------------------------- Variables Globales -----------------------------*/
  8515.  
  8516. // Infos remplies par des scripts extérieurs
  8517. var listeCDM = [], listeLevels = [];
  8518.  
  8519. // Position actuelle
  8520. var currentPosition=[0,0,0];
  8521.  
  8522. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  8523. var porteeVue=[0,0,0,0];
  8524.  
  8525. // Fenêtres déplaçables
  8526. var winCurr = null;
  8527. var offsetX, offsetY;
  8528.  
  8529. // Diplomatie
  8530. var Diplo = {
  8531. Guilde: {},
  8532. Troll: {},
  8533. Monstre: {}
  8534. // .mythiques: uniquement si option activée
  8535. };
  8536. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  8537.  
  8538. // Infos tactiques
  8539. var popup;
  8540.  
  8541. // Gère l'affichage en cascade des popups de CdM
  8542. var nbCDM = 0;
  8543.  
  8544. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  8545.  
  8546. // Utilisé pour supprimer les monstres "engagés"
  8547. var listeEngages = {};
  8548. var isEngagesComputed = false;
  8549. var cursorOnLink = false; // DEBUG: wtf ?
  8550.  
  8551. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  8552. && MY_getValue(numTroll+'.enchantement.liste')!='';
  8553.  
  8554. // Checkboxes de filtrage
  8555. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  8556. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  8557. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  8558. comboBoxNiveauMin, comboBoxNiveauMax;
  8559.  
  8560. /* Acquisition & Stockage des données de DB */
  8561. const typesAFetcher = {
  8562. 'monstres':1,
  8563. 'trolls':1,
  8564. 'tresors':1,
  8565. 'champignons':1,
  8566. 'lieux':1
  8567. }
  8568. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  8569. tr_champignons = {}, tr_lieux = {};
  8570. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  8571. nbChampignons = 0, nbLieux = 0;
  8572.  
  8573. function fetchData(type) {
  8574. try {
  8575. var node = document.getElementById('mh_vue_hidden_'+type);
  8576. // this = MZ.global = sandBox de travail de MZ
  8577. // On définit donc des variables MZ-globales
  8578. this['tr_'+type] = node.getElementsByTagName('tr');
  8579. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  8580. } catch(e) {
  8581. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  8582. }
  8583. }
  8584.  
  8585.  
  8586. /*---------------------------------- DEBUG -----------------------------------*/
  8587. var mainTabs = document.getElementsByClassName('mh_tdborder');
  8588. var x_monstres = tr_monstres;
  8589. var x_trolls = tr_trolls;
  8590. var x_tresors = tr_tresors;
  8591. var x_champis = tr_champignons;
  8592. var x_lieux = tr_lieux;
  8593. /*-------------------------------- FIN DEBUG ---------------------------------*/
  8594.  
  8595.  
  8596. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8597.  
  8598. function positionToString(arr) {
  8599. return arr.join(';');
  8600. }
  8601.  
  8602. function savePosition() {
  8603. // Stocke la position (à jour) de la vue pour les autres scripts
  8604. // DEBUG: Lesquels et pourquoi?
  8605. var pos = getPosition();
  8606. MY_setValue(numTroll+'.position.X',pos[0]);
  8607. MY_setValue(numTroll+'.position.Y',pos[1]);
  8608. MY_setValue(numTroll+'.position.N',pos[2]);
  8609. }
  8610.  
  8611.  
  8612. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  8613. /* INFOS :
  8614. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  8615. * sont identifiables via leur Name
  8616. * les tables-listings sont identifiables via l'ID du tr conteneur
  8617. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  8618. */
  8619.  
  8620. /* [functions] Récup données Utilisateur */
  8621. function getPosition() {
  8622. // Pour rétrocompatibilité
  8623. return currentPosition;
  8624. }
  8625.  
  8626. function getPorteVue() {
  8627. // Pour rétrocompatibilité
  8628. return porteeVue;
  8629. }
  8630.  
  8631. function getVue() {
  8632. // Retourne [vueHpure, vueVpure]
  8633. var vues = getPorteVue();
  8634. return [ vues[0], vues[1] ];
  8635. }
  8636.  
  8637. // Roule 11/03/2016
  8638. /* [functions] Récup données monstres, trolls, etc. */
  8639. function getXxxDistance(xxx, i) {
  8640. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  8641. }
  8642. function getXxxPosition(xxx, i) {
  8643. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  8644. var l = tds.length;
  8645. return [
  8646. parseInt(tds[l-3].textContent),
  8647. parseInt(tds[l-2].textContent),
  8648. parseInt(tds[l-1].textContent)
  8649. ];
  8650. }
  8651.  
  8652.  
  8653. /* [functions] Récup données monstres */
  8654. function getMonstreDistance(i) {
  8655. return parseInt(tr_monstres[i].cells[0].textContent);
  8656. }
  8657.  
  8658. function getMonstreID(i) {
  8659. return tr_monstres[i].cells[2].firstChild.nodeValue;
  8660. }
  8661.  
  8662. function getMonstreIDByTR(tr) {
  8663. return tr.cells[2].firstChild.nodeValue;
  8664. }
  8665.  
  8666. function getMonstreLevelNode(i) {
  8667. return tr_monstres[i].cells[3];
  8668. }
  8669.  
  8670. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  8671. // function getMonstreLevel(i) {
  8672. // if(!isCDMsRetrieved) return -1;
  8673. // var donneesMonstre = listeCDM[getMonstreID(i)];
  8674. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  8675. // }
  8676.  
  8677. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  8678. if(!isCDMsRetrieved) return false;
  8679. var donneesMonstre = listeCDM[getMonstreID(i)];
  8680. if (!donneesMonstre) return false;
  8681. var nivTxt = donneesMonstre[0];
  8682. // calcul min/max du monstre
  8683. var monstreMin, monstreMax, iPos;
  8684. if (nivTxt.substring(0, 2) == '<=') {
  8685. monstreMin = 0;
  8686. monstreMax = parseInt(nivTxt.substring(2, 99));
  8687. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  8688. monstreMin = parseInt(nivTxt.substring(0, iPos));
  8689. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  8690. } else {
  8691. monstreMin = monstreMax = parseInt(nivTxt);
  8692. }
  8693. if (limitMin > 0 && monstreMax < limitMin) return true;
  8694. if (limitMax > 0 && monstreMin > limitMax) return true;
  8695. return false;
  8696. }
  8697.  
  8698. function getMonstreNomNode(i) {
  8699. try {
  8700. var td = document.evaluate(
  8701. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  8702. tr_monstres[i], null, 9, null
  8703. ).singleNodeValue;
  8704. return td;
  8705. } catch(e) {
  8706. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  8707. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  8708. }
  8709. }
  8710.  
  8711. function getMonstreNom(i) {
  8712. return getMonstreNomByTR(tr_monstres[i]);
  8713. }
  8714.  
  8715. function getMonstreNomByTR(tr) {
  8716. try {
  8717. var nom = document.evaluate(
  8718. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  8719. tr, null, 2, null
  8720. ).stringValue;
  8721. return nom;
  8722. } catch(e) {
  8723. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  8724. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  8725. }
  8726. }
  8727.  
  8728. function getMonstrePosition(i) {
  8729. var tds = tr_monstres[i].childNodes;
  8730. var l = tds.length;
  8731. return [
  8732. parseInt(tds[l-3].textContent),
  8733. parseInt(tds[l-2].textContent),
  8734. parseInt(tds[l-1].textContent)
  8735. ];
  8736. }
  8737.  
  8738. function appendMonstres(txt) {
  8739. for(var i=1; i<=nbMonstres ; i++)
  8740. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  8741. return txt;
  8742. }
  8743.  
  8744. function getMonstres() {
  8745. var vue = getVue();
  8746. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8747. }
  8748.  
  8749. function bddMonstres(start,stop) {
  8750. if(!start) { var start = 1; }
  8751. if(!stop) { var stop = nbMonstres; }
  8752. stop = Math.min(nbMonstres,stop);
  8753. var txt='';
  8754. for(var i=start ; i<=stop ; i++) {
  8755. txt += getMonstreID(i)+';'+
  8756. getMonstreNom(i)+';'+
  8757. positionToString(getMonstrePosition(i))+'\n';
  8758. }
  8759. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  8760. }
  8761.  
  8762. /* [functions] Récup données Trolls */
  8763.  
  8764. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  8765. const COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  8766.  
  8767. function getTrollDistance(i) {
  8768. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  8769. }
  8770.  
  8771. var MZ_cache_col_TrollID;
  8772. var MZ_cache_col_TrollNOM;
  8773. var MZ_cache_col_TrollGUILDE;
  8774. var MZ_cache_col_TrollNIV;
  8775.  
  8776. function MZ_find_col_titre(trs, titre) {
  8777. var l = titre.length;
  8778. for (var i=0; i < trs[0].cells.length; i++)
  8779. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  8780. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  8781. return 0;
  8782. }
  8783.  
  8784. function getTrollID(i) {
  8785. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  8786. // Roule 08/03/2017 protection
  8787. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  8788. if (isNaN(iTroll)) return;
  8789. if (iTroll == 0) return;
  8790. return iTroll;
  8791. }
  8792.  
  8793. function getTrollNomNode(i) {
  8794. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  8795. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  8796. }
  8797.  
  8798. function getTrollNivNode(i) {
  8799. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  8800. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  8801. }
  8802.  
  8803. function getTrollGuilde(i) {
  8804. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  8805. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  8806. }
  8807.  
  8808. function getTrollGuildeID(i) {
  8809. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  8810. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  8811. var href;
  8812. try {
  8813. 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"
  8814. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  8815. } catch(e) { // debug pb remonté par Marsak
  8816. window.console.error(traceStack(e, 'getTrollGuildeID')
  8817. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  8818. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  8819. return -1;
  8820. }
  8821. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  8822. }
  8823. return -1;
  8824. }
  8825.  
  8826. function getTrollPosition(i) {
  8827. var tds = tr_trolls[i].childNodes;
  8828. var l = tds.length;
  8829. return [
  8830. parseInt(tds[l-3].textContent),
  8831. parseInt(tds[l-2].textContent),
  8832. parseInt(tds[l-1].textContent)
  8833. ];
  8834. }
  8835.  
  8836. function bddTrolls() {
  8837. var txt='#DEBUT TROLLS\n'+
  8838. numTroll+';'+positionToString(getPosition())+'\n';
  8839. for(var i=1 ; i<=nbTrolls ; i++) {
  8840. txt += getTrollID(i)+';'+
  8841. positionToString(getTrollPosition(i))+'\n';
  8842. }
  8843. return txt+'#FIN TROLLS';
  8844. }
  8845.  
  8846. /* [functions] Récup données Trésors */
  8847. function getTresorDistance(i) {
  8848. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8849. }
  8850.  
  8851. function getTresorID(i) {
  8852. return trim(tr_tresors[i].cells[2].textContent);
  8853. }
  8854.  
  8855. function getTresorNom(i) {
  8856. // Utilisation de textContent pour régler le "bug de Pollux"
  8857. return trim(tr_tresors[i].cells[3].textContent);
  8858. }
  8859.  
  8860. function getTresorPosition(i) {
  8861. var tds = tr_tresors[i].childNodes;
  8862. var l = tds.length;
  8863. return [
  8864. parseInt(tds[l-3].textContent),
  8865. parseInt(tds[l-2].textContent),
  8866. parseInt(tds[l-1].textContent),
  8867. ];
  8868. }
  8869.  
  8870. function bddTresors(dmin,start,stop) {
  8871. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8872. if(!dmin) { var dmin = 0; }
  8873. if(!start) { var start = 1; }
  8874. if(!stop) { var stop = nbTresors; }
  8875. stop = Math.min(nbTresors,stop);
  8876. var txt='';
  8877. for(var i=start ; i<=stop ; i++) {
  8878. if(getTresorDistance(i)>=dmin) {
  8879. txt += getTresorID(i)+';'+
  8880. getTresorNom(i)+';'+
  8881. positionToString(getTresorPosition(i))+'\n';
  8882. }
  8883. }
  8884. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8885. }
  8886.  
  8887. /* [functions] Récup données Champignons */
  8888. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8889. function getChampignonNom(i) {
  8890. return trim(tr_champignons[i].cells[2].textContent);
  8891. }
  8892.  
  8893. function getChampignonPosition(i) {
  8894. var tds = tr_champignons[i].childNodes;
  8895. var l = tds.length;
  8896. return [
  8897. parseInt(tds[l-3].textContent),
  8898. parseInt(tds[l-2].textContent),
  8899. parseInt(tds[l-1].textContent)
  8900. ];
  8901. }
  8902.  
  8903. function bddChampignons() {
  8904. var txt='';
  8905. for(var i=1 ; i<=nbChampignons ; i++) {
  8906. txt += ';'+ // Les champis n'ont pas de Référence
  8907. getChampignonNom(i)+';'+
  8908. positionToString(getChampignonPosition(i))+'\n';
  8909. }
  8910. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8911. }
  8912.  
  8913. /* [functions] Récup données Lieux */
  8914. function getLieuDistance(i) {
  8915. return parseInt(tr_lieux[i].cells[0].textContent);
  8916. }
  8917.  
  8918. function getLieuID(i) {
  8919. return parseInt(tr_lieux[i].cells[2].textContent);
  8920. }
  8921.  
  8922. function getLieuNom(i) {
  8923. // Conversion ASCII pour éviter les bugs des Vues externes
  8924. return trim(tr_lieux[i].cells[3].textContent);
  8925. }
  8926.  
  8927. function getLieuPosition(i) {
  8928. var tds = tr_lieux[i].childNodes;
  8929. var l = tds.length;
  8930. return [
  8931. parseInt(tds[l-3].textContent),
  8932. parseInt(tds[l-2].textContent),
  8933. parseInt(tds[l-1].textContent)
  8934. ];
  8935. }
  8936.  
  8937. function appendLieux(txt) {
  8938. for(var i = 1; i < nbLieux+1; i++) {
  8939. var tds = x_lieux[i].childNodes;
  8940. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8941. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8942. }
  8943. return txt;
  8944. }
  8945.  
  8946. function getLieux() {
  8947. var vue = getVue();
  8948. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8949. }
  8950.  
  8951. function bddLieux(start,stop) {
  8952. if(!start) { var start = 1; }
  8953. if(!stop) { var stop = nbLieux; }
  8954. stop = Math.min(nbLieux,stop);
  8955. var txt='';
  8956. for(var i=start ; i<=stop ; i++) {
  8957. txt += getLieuID(i)+';'+
  8958. epure(getLieuNom(i))+';'+
  8959. positionToString(getLieuPosition(i))+'\n';
  8960. }
  8961. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8962. }
  8963.  
  8964.  
  8965. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8966.  
  8967. function saveCheckBox(chkbo, pref) {
  8968. // Enregistre et retourne l'état d'une CheckBox
  8969. var etat = chkbo.checked;
  8970. MY_setValue(pref, etat ? 'true' : 'false' );
  8971. return etat;
  8972. }
  8973.  
  8974. function recallCheckBox(chkbox, pref) {
  8975. // Restitue l'état d'une CheckBox
  8976. chkbox.checked = (MY_getValue(pref)=='true');
  8977. }
  8978.  
  8979. function saveComboBox(cbb, pref) {
  8980. // Enregistre et retourne l'état d'une ComboBox
  8981. var etat = cbb.selectedIndex;
  8982. MY_setValue(pref, etat);
  8983. return etat;
  8984. }
  8985.  
  8986. function recallComboBox(cbb, pref) {
  8987. // Restitue l'état d'une ComboBox
  8988. var nb = MY_getValue(pref);
  8989. if(nb) cbb.value = nb;
  8990. return nb;
  8991. }
  8992.  
  8993. function synchroniseFiltres() {
  8994. // Récupération de toutes les options de la vue
  8995. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8996. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8997. if(numBool) {
  8998. debutFiltrage('Monstres');
  8999. }
  9000. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9001. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9002. recallCheckBox(checkBoxMythiques,'NOMYTH');
  9003. recallCheckBox(checkBoxEngages,'NOENGAGE');
  9004. recallCheckBox(checkBoxLevels,'NOLEVEL');
  9005. recallCheckBox(checkBoxIntangibles,'NOINT');
  9006. recallCheckBox(checkBoxGG,'NOGG');
  9007. recallCheckBox(checkBoxCompos,'NOCOMP');
  9008. recallCheckBox(checkBoxBidouilles,'NOBID');
  9009. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  9010. recallCheckBox(checkBoxTrou,'NOTROU');
  9011. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9012. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  9013. if(MY_getValue('NOINFOEM')!='true')
  9014. recallCheckBox(checkBoxEM,'NOEM');
  9015. }
  9016.  
  9017.  
  9018. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  9019.  
  9020. function getVueScript() {
  9021. try {
  9022. var txt = bddTrolls()+
  9023. bddMonstres()+
  9024. bddChampignons()+
  9025. bddTresors()+
  9026. bddLieux()+
  9027. '#DEBUT ORIGINE\n'+
  9028. getPorteVue()[2]+';'+positionToString(getPosition())+
  9029. '\n#FIN ORIGINE\n';
  9030. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  9031. return txt;
  9032. } catch(e) {
  9033. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  9034. window.console.error(traceStack(e, 'getVueScript'))
  9035. }
  9036. }
  9037.  
  9038. /* [functions] Menu Vue 2D */
  9039. var vue2Ddata = {
  9040. 'Bricol\' Vue': {
  9041. url: URL_bricol_mountyhall + 'vue_form.php',
  9042. paramid: 'vue',
  9043. func: getVueScript,
  9044. extra_params: {
  9045. 'mode': 'vue_SP_Vue2',
  9046. 'screen_width': window.screen.width
  9047. }
  9048. },
  9049. 'Vue du CCM': {
  9050. url: URL_vue_CCM,
  9051. paramid: 'vue',
  9052. func: getVueScript,
  9053. extra_params: {
  9054. 'id': numTroll+';'+positionToString(getPosition())
  9055. }
  9056. },
  9057. 'Vue Gloumfs 2D': {
  9058. url: URL_vue_Gloumfs2D,
  9059. paramid: 'vue_mountyzilla',
  9060. func: getVueScript,
  9061. extra_params: {}
  9062. },
  9063. 'Vue Gloumfs 3D': {
  9064. url: URL_vue_Gloumfs3D,
  9065. paramid: 'vue_mountyzilla',
  9066. func: getVueScript,
  9067. extra_params: {}
  9068. },
  9069. 'Grouky Vue!': {
  9070. url: URL_vue_Grouky,
  9071. paramid: 'vue',
  9072. func: getVueScript,
  9073. extra_params: {
  9074. 'type_vue': 'V5b1'
  9075. }
  9076. },
  9077. /*'DEBUG': {
  9078. url: 'http://weblocal/testeur.php',
  9079. paramid: 'vue',
  9080. func: getVueScript,
  9081. extra_params: {}
  9082. }*/
  9083. };
  9084.  
  9085. function refresh2DViewButton() {
  9086. // = EventListener menu+bouton vue 2D
  9087. var vueext = document.getElementById('selectVue2D').value;
  9088. MY_setValue('VUEEXT',vueext);
  9089. var form = document.getElementById('viewForm');
  9090. form.innerHTML = '';
  9091. form.method = 'post';
  9092. form.action = vue2Ddata[vueext].url;
  9093. form.target = '_blank';
  9094. appendHidden(form, vue2Ddata[vueext].paramid, '');
  9095. for(var key in vue2Ddata[vueext].extra_params) {
  9096. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  9097. }
  9098. appendSubmit(form, 'Voir',
  9099. function() {
  9100. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  9101. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  9102. vue2Ddata[vueext].func();
  9103. }
  9104. );
  9105. }
  9106.  
  9107. function set2DViewSystem() {
  9108. // Initialise le système de vue 2D
  9109. // Recherche du point d'insertion
  9110. var center;
  9111. try {
  9112. // Roule 09/03/2019, encore un changement MH, je fais suivre comme je peux
  9113. center = document.getElementById('titre2');
  9114. // version initiale "pré-Roule"
  9115. if (!center) center = document.evaluate(
  9116. "//h2[@id='titre2']/following-sibling::center",
  9117. document, null, 9, null
  9118. ).singleNodeValue;
  9119. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  9120. if (!center) center = document.evaluate(
  9121. "//h2[@id='titre2']/following-sibling::div",
  9122. document, null, 9, null
  9123. ).singleNodeValue;
  9124. } catch(e) {
  9125. avertissement("Erreur d'initialisation du système de vue 2D");
  9126. window.console.error(traceStack(e, 'set2DViewSystem'));
  9127. return;
  9128. }
  9129. // Récupération de la dernière vue utilisée
  9130. var vueext = MY_getValue('VUEEXT');
  9131. if(!vueext || !vue2Ddata[vueext]) {
  9132. // sinon, la vue Bricol'Trolls est employée par défaut
  9133. vueext = 'Bricol\' Vue';
  9134. }
  9135. try {
  9136. // Création du sélecteur de vue externe
  9137. selectVue2D = document.createElement('select');
  9138. selectVue2D.id = 'selectVue2D';
  9139. selectVue2D.className = 'SelectboxV2';
  9140. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  9141. for(var view in vue2Ddata) {
  9142. appendOption(selectVue2D, view, view);
  9143. }
  9144. selectVue2D.value = vueext;
  9145. selectVue2D.onchange = refresh2DViewButton;
  9146. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  9147. var form = document.createElement('form');
  9148. form.id = 'viewForm';
  9149. // Insertion du système de vue
  9150. var table = document.createElement('table');
  9151. var tr = appendTr(table);
  9152. var td = appendTd(tr);
  9153. td.appendChild(selectVue2D);
  9154. td = appendTd(tr);
  9155. td.style.fontSize = '0px'; // gère le bug de l'extra character
  9156. td.appendChild(form);
  9157. if (center.id == 'titre2') { // 09/03/2019 nouvelle méthode
  9158. var eDiv = document.createElement('div');
  9159. eDiv.appendChild(table);
  9160. eDiv.style.witdth = '100%';
  9161. eDiv.style.textAlign = 'center';
  9162. table.style.width = '180px';
  9163. table.style.margin = '0 auto';
  9164. center.parentNode.insertBefore(eDiv,center.nextSibling);
  9165. } else { // ancienne méthode
  9166. center.insertBefore(table,center.firstChild);
  9167. insertBr(center.childNodes[1]);
  9168. }
  9169. // Appelle le handler pour initialiser le bouton de submit
  9170. refresh2DViewButton();
  9171. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  9172. } catch(e) {
  9173. avertissement("Erreur de traitement du système de vue 2D");
  9174. window.console.error(traceStack(e, 'set2DViewSystem'));
  9175. }
  9176. }
  9177.  
  9178. /* [functions] Tableau d'Infos */
  9179. function initialiseInfos() {
  9180. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  9181. var
  9182. infoTab = document.getElementsByName('LimitViewForm')[0].
  9183. getElementsByTagName('table')[0],
  9184. tbody = infoTab.tBodies[0],
  9185. thead = infoTab.createTHead(),
  9186. tr = appendTr(thead,'mh_tdtitre'),
  9187. td = appendTdText(tr,'INFORMATIONS',true),
  9188. span = document.createElement('span');
  9189. // Récupération de la position du joueur
  9190. try {
  9191. var strPos = document.evaluate(
  9192. ".//li/b/text()[contains(.,'X = ')]",
  9193. infoTab, null, 9, null
  9194. ).singleNodeValue.nodeValue;
  9195. // ***INIT GLOBALE*** currentPosition
  9196. currentPosition = getNumbers(strPos);
  9197. debugMZ("retrievePosition(): "+currentPosition);
  9198. } catch(e) {
  9199. // Si on ne trouve pas le "X ="
  9200. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  9201. }
  9202. // Récupération des portées (max et limitée) de la vue
  9203. try {
  9204. var
  9205. nodes = document.evaluate(
  9206. ".//li/b/text()[contains(.,'horizontalement') "+
  9207. "or contains(.,'verticalement')]",
  9208. infoTab, null, 7, null
  9209. ),
  9210. array = [];
  9211. for(var i=0 ; i<4 ; i++) {
  9212. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  9213. }
  9214. // ***INIT GLOBALE*** porteeVue
  9215. porteeVue = array;
  9216. } catch(e) {
  9217. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  9218. }
  9219.  
  9220. infoTab.id = 'infoTab'; // Pour scripts externes
  9221. tbody.id = 'corpsInfoTab';
  9222. tbody.rows[0].cells[0].colSpan = 2;
  9223. td.colSpan = 3;
  9224. td.onmouseover = function() {
  9225. this.style.cursor = 'pointer';
  9226. this.className = 'mh_tdpage';
  9227. };
  9228. td.onmouseout = function() {
  9229. this.className = 'mh_tdtitre';
  9230. };
  9231. td.onclick = function() {
  9232. toggleTableauInfos(false);
  9233. };
  9234. span.id = 'msgInfoTab';
  9235. span.style.display = 'none';
  9236. appendText(
  9237. span,
  9238. ' => Position : X = '+currentPosition[0]+
  9239. ', Y = '+currentPosition[1]+
  9240. ', N = '+currentPosition[2]+
  9241. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  9242. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  9243. true
  9244. );
  9245. td.appendChild(span);
  9246. tr = appendTr(tbody,'mh_tdpage');
  9247. td = appendTdText(tr,'EFFACER : ',true);
  9248. td.align = 'center';
  9249. td.className = 'mh_tdtitre';
  9250. td.width = 100;
  9251. td = appendTdCenter(tr,2);
  9252. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  9253. checkBoxGG = appendCheckBoxSpan(
  9254. td,'delgg',filtreTresors," Les GG'"
  9255. ).firstChild;
  9256. checkBoxCompos = appendCheckBoxSpan(
  9257. td,'delcomp',filtreTresors,' Les Compos'
  9258. ).firstChild;
  9259. checkBoxBidouilles = appendCheckBoxSpan(
  9260. td,'delbid',filtreTresors,' Les Bidouilles'
  9261. ).firstChild;
  9262. checkBoxIntangibles = appendCheckBoxSpan(
  9263. td,'delint',filtreTrolls,' Les Intangibles'
  9264. ).firstChild;
  9265. checkBoxGowapsA = appendCheckBoxSpan(
  9266. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  9267. ).firstChild;
  9268. checkBoxGowapsS = appendCheckBoxSpan(
  9269. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  9270. ).firstChild;
  9271. checkBoxEngages = appendCheckBoxSpan(
  9272. td,'delengage',filtreMonstres,' Les Engagés'
  9273. ).firstChild;
  9274. checkBoxLevels = appendCheckBoxSpan(
  9275. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  9276. ).firstChild;
  9277. checkBoxDiplo = appendCheckBoxSpan(
  9278. td,'delDiplo',refreshDiplo,' La Diplomatie'
  9279. ).firstChild;
  9280. checkBoxTrou = appendCheckBoxSpan(
  9281. td,'deltrou',filtreLieux,' Les Trous'
  9282. ).firstChild;
  9283. checkBoxMythiques = appendCheckBoxSpan(
  9284. td,'delmyth',filtreMonstres,' Les Mythiques'
  9285. ).firstChild;
  9286. if(MY_getValue('NOINFOEM')!='true') {
  9287. checkBoxEM = appendCheckBoxSpan(
  9288. td,'delem',filtreMonstres,' Les Composants EM'
  9289. ).firstChild;
  9290. }
  9291. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  9292. td,'deltres',filtreTresors,' Les Trésors non libres'
  9293. ).firstChild;
  9294. checkBoxTactique = appendCheckBoxSpan(
  9295. td,'deltactique',updateTactique,' Les Infos tactiques'
  9296. ).firstChild;
  9297. if(MY_getValue('INFOPLIE')) {
  9298. toggleTableauInfos(true);
  9299. }
  9300. }
  9301.  
  9302. function toggleTableauInfos(firstRun) {
  9303. var
  9304. msg = document.getElementById('msgInfoTab'),
  9305. corps = document.getElementById('corpsInfoTab'),
  9306. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9307. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  9308. if(!firstRun) {
  9309. infoplie = !infoplie;
  9310. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9311. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  9312. }
  9313. if(infoplie) {
  9314. msg.style.display = '';
  9315. corps.style.display = 'none';
  9316. } else {
  9317. msg.style.display = 'none';
  9318. corps.style.display = '';
  9319. }
  9320. }
  9321.  
  9322. /* [functions] Filtres */
  9323. function prepareFiltrage(ref,width) {
  9324. // = Initialise le filtre 'ref'
  9325. try {
  9326. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  9327. } catch(e) {
  9328. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  9329. return false;
  9330. }
  9331. if(width) { tdTitre.width = width; }
  9332. // Ajout du tr de Filtrage (masqué)
  9333. var tbody = tdTitre.parentNode.parentNode;
  9334. var tr = appendTr(tbody,'mh_tdpage');
  9335. tr.style.display = 'none';
  9336. tr.id = 'trFiltre'+ref;
  9337. var td = appendTd(tr);
  9338. td.colSpan = 5;
  9339. // Ajout du bouton de gestion de Filtrage
  9340. var tdBtn = insertAfterTd(tdTitre);
  9341. tdBtn.id = 'tdInsert'+ref;
  9342. var btn = appendButton(tdBtn,'Filtrer');
  9343. btn.id = 'btnFiltre'+ref;
  9344. btn.onclick = function() {
  9345. debutFiltrage(ref)
  9346. };
  9347. return td;
  9348. }
  9349.  
  9350. function debutFiltrage(ref) {
  9351. // = Handler de début de filtrage (filtre 'ref')
  9352. document.getElementById('trFiltre'+ref).style.display = '';
  9353. var btn = document.getElementById('btnFiltre'+ref);
  9354. btn.value = 'Annuler Filtre';
  9355. btn.onclick = function() {
  9356. finFiltrage(ref);
  9357. };
  9358. }
  9359.  
  9360. function finFiltrage(ref) {
  9361. // = Handler de fin de filtrage (filtre 'ref')
  9362. /* On réassigne le bouton 'Filtrer' */
  9363. document.getElementById('trFiltre'+ref).style.display = 'none';
  9364. var btn = document.getElementById('btnFiltre'+ref);
  9365. btn.value = 'Filtrer';
  9366. btn.onclick = function() {
  9367. debutFiltrage(ref);
  9368. };
  9369. /* Réinitialisation filtres */
  9370. document.getElementById('str'+ref).value = '';
  9371. switch(ref) {
  9372. case 'Monstres':
  9373. document.getElementById('nivMinMonstres').value = 0;
  9374. document.getElementById('nivMaxMonstres').value = 0;
  9375. break;
  9376. case 'Trolls':
  9377. document.getElementById('strGuildes').value = '';
  9378. }
  9379. /* Nettoyage (=lance le filtre) */
  9380. // Ici this = MZ.global = sandBox de travail de MZ
  9381. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  9382. //this['filtre'+ref]();
  9383. switch (ref) {
  9384. case 'Monstres':
  9385. filtreMonstres();
  9386. break;
  9387. case 'Trolls':
  9388. filtreTrolls();
  9389. break;
  9390. case 'Tresors':
  9391. filtreTresors();
  9392. break;
  9393. case 'Lieux':
  9394. filtreLieux();
  9395. break;
  9396. default:
  9397. window.console.log('cas incongru dans finFiltrage : ' + ref);
  9398. break;
  9399. }
  9400. }
  9401.  
  9402. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  9403. var bouton = appendButton(td,nomBouton,onClick);
  9404. appendText(td,'\u00a0');
  9405. var textbox = appendTextbox(td,'text',id,15,30);
  9406. textbox.onkeypress = function(event) {
  9407. try {
  9408. if(event.keyCode==13) {
  9409. event.preventDefault();
  9410. bouton.click();
  9411. }
  9412. }
  9413. catch(e){
  9414. window.alert(e)
  9415. }
  9416. };
  9417. }
  9418.  
  9419. function ajoutFiltreMenu(tr,id,onChange) {
  9420. var select = document.createElement('select');
  9421. select.id = id;
  9422. select.onchange = onChange;
  9423. appendOption(select,0,'Aucun');
  9424. for(var i=1 ; i<=60 ; i++) {
  9425. appendOption(select,i,i);
  9426. }
  9427. tr.appendChild(select);
  9428. return select;
  9429. }
  9430.  
  9431. function ajoutDesFiltres() {
  9432. /* Monstres */
  9433. var td = prepareFiltrage('Monstres',120);
  9434. if(td) {
  9435. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  9436. appendText(td,'\u00a0\u00a0\u00a0');
  9437. appendText(td,'Niveau Min: ');
  9438. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  9439. appendText(td,'\u00a0');
  9440. appendText(td,'Niveau Max: ');
  9441. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  9442. }
  9443. /* Trõlls */
  9444. td = prepareFiltrage('Trolls',50);
  9445. if(td) {
  9446. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  9447. appendText(td,'\u00a0\u00a0\u00a0');
  9448. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  9449. }
  9450. /* Trésors */
  9451. td = prepareFiltrage('Tresors',55);
  9452. if(td) {
  9453. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  9454. }
  9455. /* Lieux */
  9456. td = prepareFiltrage('Lieux',40);
  9457. if(td) {
  9458. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  9459. }
  9460. }
  9461.  
  9462. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  9463.  
  9464. /* [functions] Affichage de la colonne des niveaux */
  9465. function insertLevelColumn() {
  9466. // Déclenché si bascule vers affichage des niveaux des mobs
  9467. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  9468. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  9469. td.width = 25;
  9470. for(var i=1 ; i<=nbMonstres ; i++) {
  9471. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  9472. td = insertTdText(getMonstreLevelNode(i), '-');
  9473. td.onclick = function() {
  9474. basculeCDM(
  9475. getMonstreNomByTR(this.parentNode),
  9476. getMonstreIDByTR(this.parentNode)
  9477. );
  9478. };
  9479. td.onmouseover = function() {
  9480. this.style.cursor = 'pointer';
  9481. this.className = 'mh_tdtitre';
  9482. };
  9483. td.onmouseout = function() {
  9484. if(this.parentNode.diploActive=='oui') {
  9485. this.className = '';
  9486. } else {
  9487. this.className = 'mh_tdpage';
  9488. }
  9489. };
  9490. td.style = 'font-weight:bold;text-align:center;';
  9491. if(isCDMsRetrieved) {
  9492. // Rappel des niveaux si mémorisés
  9493. td.innerHTML = listeLevels[i];
  9494. }
  9495. }
  9496. }
  9497.  
  9498. function toggleLevelColumn() {
  9499. // = Handler checkBox noLevel
  9500. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  9501. insertLevelColumn();
  9502. if(!isCDMsRetrieved) { retrieveCDMs(); }
  9503. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  9504. for(var i=0 ; i<=nbMonstres ; i++) {
  9505. if(isCDMsRetrieved) {
  9506. // Mémorisation des niveaux pour rappel éventuel
  9507. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  9508. }
  9509. // Suppression du td Niveau
  9510. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  9511. }
  9512. }
  9513. }
  9514.  
  9515. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  9516. function basculeCDM(nom,id) {
  9517. // = Bascule l'affichage des popups CdM
  9518. if(listeCDM[id]) {
  9519. if(!document.getElementById('popupCDM'+id)) {
  9520. afficherCDM(nom, id);
  9521. } else {
  9522. cacherPopupCDM('popupCDM'+id);
  9523. }
  9524. }
  9525. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  9526. }
  9527.  
  9528. function cacherPopupCDM(titre) {
  9529. var popup = document.getElementById(titre);
  9530. popup.parentNode.removeChild(popup);
  9531. }
  9532.  
  9533. /* DEBUG: Section à mettre à jour */
  9534. var selectionFunction;
  9535.  
  9536. function startDrag(evt) {
  9537. winCurr = this.parentNode;
  9538. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  9539. offsetX = evt.pageX - parseInt( winCurr.style.left );
  9540. offsetY = evt.pageY - parseInt( winCurr.style.top );
  9541. selectionFunction = document.body.style.MozUserSelect;
  9542. document.body.style.MozUserSelect = 'none';
  9543. winCurr.style.MozUserSelect = 'none';
  9544. return false;
  9545. }
  9546.  
  9547. function stopDrag(evt) {
  9548. winCurr.style.MozUserSelect = selectionFunction;
  9549. document.body.style.MozUserSelect = selectionFunction;
  9550. winCurr = null;
  9551. }
  9552.  
  9553. function drag(evt) {
  9554. if(winCurr==null) { return; }
  9555. evt = evt || window.event;
  9556. winCurr.style.left = (evt.pageX - offsetX)+'px';
  9557. winCurr.style.top = (evt.pageY - offsetY)+'px';
  9558. return false;
  9559. }
  9560. /* FIN DEBUG */
  9561. if(!isPage("MH_Play/Play_equipement")) {
  9562. // Conflit overlib/Tout_MZ:
  9563. // Double définition du "onmousemove" sur la page d'équipement
  9564. document.onmousemove = drag;
  9565. }
  9566.  
  9567. function afficherCDM(nom,id) {
  9568. // Crée la table de CdM du mob n° id
  9569. var donneesMonstre = listeCDM[id];
  9570. /* Début création table */
  9571. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  9572. table.id = 'popupCDM'+id;
  9573. table.style =
  9574. 'position:fixed;'+
  9575. 'z-index:1;'+
  9576. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  9577. 'left:'+(window.innerWidth-365)+'px;'+
  9578. 'width:300px;'+
  9579. 'height:200px;';
  9580. /* Ajout du titre avec gestion Drag & Drop */
  9581. var tr = table.firstChild;
  9582. tr.style.cursor = 'move';
  9583. tr.onmousedown = startDrag;
  9584. tr.onmouseup = stopDrag;
  9585. /* Ajout du bouton "Fermer" */
  9586. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  9587. tr.onmouseover = function() {
  9588. this.style.cursor = 'pointer';
  9589. this.className = 'mh_tdpage';
  9590. };
  9591. tr.onmouseout = function() {
  9592. this.className = 'mh_tdtitre';
  9593. };
  9594. tr.idcdm = id;
  9595. tr.onclick = function() {
  9596. cacherPopupCDM('popupCDM'+this.idcdm);
  9597. this.className = 'mh_tdtitre';
  9598. };
  9599. td = appendTdText(tr,'Fermer',true);
  9600. td.colSpan = 2;
  9601. td.style = 'text-align:center;';
  9602. nbCDM++;
  9603. /* Fin création table & Affichage */
  9604. document.body.appendChild(table);
  9605. }
  9606.  
  9607. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  9608. function initPopupVue() {
  9609. popup = document.createElement('div');
  9610. popup.id = 'popup';
  9611. popup.className = 'mh_textbox';
  9612. popup.style =
  9613. 'position: absolute;'+
  9614. 'border: 1px solid #000000;'+
  9615. 'visibility: hidden;'+
  9616. 'display: inline;'+
  9617. 'z-index: 3;'+
  9618. 'max-width: 400px;';
  9619. document.body.appendChild(popup);
  9620. }
  9621.  
  9622. /* [functions] Récupération / Computation des Infos Tactiques */
  9623. // TODO à revoir
  9624. function retireMarquage(nom) {
  9625. var i = nom.indexOf(']');
  9626. switch(i) {
  9627. case -1:
  9628. case nom.length-1:
  9629. return nom;
  9630. default:
  9631. return nom.slice(0,i+1);
  9632. }
  9633. }
  9634.  
  9635. function showPopupError(sHTML) {
  9636. window.console.log('[MZ] affichage PopupError ' + sHTML);
  9637. var divpopup = document.createElement('div');
  9638. divpopup.id = 'divpopup';
  9639. divpopup.style =
  9640. 'position: fixed;'+
  9641. 'border: 3px solid #000000;'+
  9642. 'top: 300px;left: 10px;'+
  9643. 'background-color: red;'+
  9644. 'color: white;'+
  9645. 'font-size: xx-large;'+
  9646. 'z-index: 200;';
  9647. divpopup.innerHTML = sHTML;
  9648. var divcroix = document.createElement('div');
  9649. divcroix.style =
  9650. 'position: absolute;'+
  9651. 'top: 0;right: 0;'+
  9652. 'color: inherit;'+
  9653. 'font-size: inherit;'+
  9654. 'cursor: pointer;'+
  9655. 'z-index: 201;';
  9656. divcroix.innerHTML = "X";
  9657. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  9658. document.body.appendChild(divpopup);
  9659. divpopup.appendChild(divcroix);
  9660. }
  9661.  
  9662. function retrieveCDMs() {
  9663. // Roule 18/11/2017 mise en sommeil MZ V2, on a besoin de tester en mode dev avec l'ancienne version
  9664. return retrieveCDMsOld();
  9665. //if (isDEV) return retrieveCDMsNew();
  9666. //else return retrieveCDMsOld();
  9667. }
  9668.  
  9669. function retrieveCDMsNew() {
  9670. // Récupère les CdM disponibles dans la BDD
  9671. // Lancé uniquement sur toggleLevelColumn
  9672. if(checkBoxLevels.checked) return;
  9673. if (nbMonstres < 1) return;
  9674.  
  9675. var tReq = [];
  9676. for (var i=1 ; i<=nbMonstres ; i++) {
  9677. tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  9678. }
  9679.  
  9680. FF_XMLHttpRequest({
  9681. method: 'POST',
  9682. url: URL_MZgetCaracMonstre,
  9683. headers : {
  9684. 'Content-type':'application/x-www-form-urlencoded'
  9685. },
  9686. data: 'l=' + tReq.join("\n"),
  9687. trace: 'demande niveaux monstres V2',
  9688. onload: function(responseDetails) {
  9689. try {
  9690. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9691. if (responseDetails.status == 0) return;
  9692. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  9693. var texte = responseDetails.responseText;
  9694. var lines = texte.split('\n');
  9695. if(lines.length==0) return;
  9696. var begin2, end2, index;
  9697. for(var j=0 ; j<lines.length ; j++) {
  9698. var infos = lines[j].split("\t");
  9699. if(infos.length<3) { continue; }
  9700. var index = infos[0]
  9701. var idMonstre=infos[1];
  9702. var level = infos[2];
  9703. // 3 cas
  9704. // il y a des infos, infos[] a plus de 3 valeurs
  9705. // il n'y a pas d'info pour ce monstre, infos[] a 4 valeur, la 4e est "-"
  9706. // les infos n'ont pas été récupérées (après le 50e monstre), il n'y a que 3 valeurs
  9707. if (infos.length == 3) {
  9708. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9709. } else if (infos.length > 4) {
  9710. infos = infos.slice(3);
  9711. 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)
  9712. listeCDM[idMonstre] = infos;
  9713. getMonstreLevelNode(index).innerHTML = '<b>'+level+'</b>';
  9714. } else {
  9715. getMonstreLevelNode(index).innerHTML = level;
  9716. }
  9717. }
  9718. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  9719. computeMission(1, nbMonstres);
  9720. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  9721. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9722. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  9723. } catch(e) {
  9724. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9725. }
  9726. isCDMsRetrieved=true;
  9727. },
  9728. });
  9729. //str = '';
  9730. //begin = i+1;
  9731. //isCDMsRetrieved=true;
  9732. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  9733. }
  9734.  
  9735. function retrieveCDMsOld() {
  9736. // Récupère les CdM disponibles dans la BDD
  9737. // Lancé uniquement sur toggleLevelColumn
  9738. if(checkBoxLevels.checked) { return; }
  9739. // Roule, message si l'utilisateur a décoché "Menu d'actions contextuelles"
  9740. if (!tr_monstres[0].cells[2].innerHTML.match(/r[eéè]f/i)) {
  9741. 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);
  9742. return;
  9743. }
  9744.  
  9745. var str = '';
  9746. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  9747. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  9748. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  9749. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  9750. for(var i=1 ; i<=cdmMax ; i++) {
  9751. var nomMonstre = retireMarquage(getMonstreNom(i));
  9752. if(nomMonstre.indexOf(']') != -1) {
  9753. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  9754. }
  9755. // *** WARNING : PROXY RATIBUS ***
  9756. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  9757. str += 'nom[]='+escape(nomMonstre)+'$'+(
  9758. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  9759. )+'&';
  9760. }
  9761.  
  9762. // Roule 31/07/2017 suppression du saucissonnage : inutile et complique les choses ensuite
  9763. //if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  9764. FF_XMLHttpRequest({
  9765. method: 'POST',
  9766. url: URL_MZinfoMonstre,
  9767. headers : {
  9768. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9769. 'Accept': 'application/atom+xml,application/xml,text/xml',
  9770. 'Content-type':'application/x-www-form-urlencoded'
  9771. },
  9772. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  9773. trace: 'demande niveaux monstres',
  9774. onload: function(responseDetails) {
  9775. try {
  9776. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9777. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  9778. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  9779. '" target="raistlin">Mountyzilla - https<br />'+
  9780. 'Tu dois accepter le certificat de Raistlin<br />'+
  9781. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  9782. ' « Confirmer l\'exception de sécurité »</a>');
  9783. return;
  9784. }
  9785. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  9786. var texte = responseDetails.responseText;
  9787. var lines = texte.split('\n');
  9788. if(lines.length==0) { return; }
  9789. var begin2, end2, index;
  9790. for(var j=0 ; j<lines.length ; j++) {
  9791. var infos = lines[j].split(';');
  9792. if(infos.length<4) { continue; }
  9793. var idMonstre=infos[0];
  9794. var isCDM = infos[1];
  9795. index = parseInt(infos[2]);
  9796. var level = infos[3];
  9797. infos = infos.slice(3);
  9798. 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)
  9799. if(begin2==null) { begin2 = index; }
  9800. end2 = index;
  9801. listeCDM[idMonstre] = infos;
  9802. if(isCDM==1) {
  9803. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9804. } else {
  9805. getMonstreLevelNode(index).innerHTML = level;
  9806. }
  9807. }
  9808. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres avant computeMission');
  9809. computeMission(begin2,end2);
  9810. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres avant filtreMonstres');
  9811. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9812. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres fin');
  9813. } catch(e) {
  9814. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9815. }
  9816. isCDMsRetrieved=true;
  9817. },
  9818. });
  9819. //str = '';
  9820. //begin = i+1;
  9821. //isCDMsRetrieved=true;
  9822. //window.console.log('[MZd] ' + (+new Date) + ' requête ajax partie pour ' + cdmMax + ' monstres');
  9823. }
  9824.  
  9825. function computeMission(begin,end) {
  9826. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  9827. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  9828. computeVLC(begin,end);
  9829. //+++window.console.log('computeMission, après computeVLC');
  9830. if(!begin) begin=1;
  9831. if(!end) end=nbMonstres;
  9832. var str = MY_getValue(numTroll+'.MISSIONS');
  9833. if(!str) { return; }
  9834. var urlImg = URL_MZimg+'mission.png';
  9835. var obMissions = JSON.parse(str);
  9836. for(var i=end ; i>=begin ; i--) {
  9837. var mess = '';
  9838. for(var num in obMissions) {
  9839. var mobMission = false;
  9840. switch(obMissions[num].type) {
  9841. case 'Race':
  9842. var race = epure(obMissions[num].race.toLowerCase());
  9843. var nom = epure(getMonstreNom(i).toLowerCase());
  9844. if(nom.indexOf(race)!=-1) {
  9845. mobMission = true;
  9846. }
  9847. break;
  9848. case 'Niveau':
  9849. var donneesMonstre = listeCDM[getMonstreID(i)];
  9850. if(donneesMonstre) {
  9851. var nivMob = Number(donneesMonstre[0]);
  9852. var nivMimi = Number(obMissions[num].niveau),
  9853. mod = obMissions[num].mod;
  9854. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  9855. || (isNaN(mod) && nivMob>=nivMimi)) {
  9856. mobMission = true;
  9857. }
  9858. }
  9859. break;
  9860. case 'Famille':
  9861. var donneesMonstre = listeCDM[getMonstreID(i)];
  9862. if(donneesMonstre) {
  9863. var familleMimi = epure(obMissions[num].famille.toLowerCase()).replace(/[']/g,''); // Roule 27/02/2019 simple quote dans les familles
  9864. var familleMob = epure(donneesMonstre[1].toLowerCase());
  9865. if(familleMob.indexOf(familleMimi)!=-1) {
  9866. mobMission = true;
  9867. }
  9868. }
  9869. break;
  9870. case 'Pouvoir':
  9871. var donneesMonstre = listeCDM[getMonstreID(i)];
  9872. if(donneesMonstre) {
  9873. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  9874. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  9875. if(pvrMob.indexOf(pvrMimi)!=-1) {
  9876. mobMission = true;
  9877. }
  9878. }
  9879. }
  9880. if(mobMission) {
  9881. mess += mess ? '\n\n' : '';
  9882. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  9883. }
  9884. }
  9885. if(mess) {
  9886. var td = getMonstreNomNode(i);
  9887. appendText(td,' ');
  9888. td.appendChild(createImage(urlImg,mess));
  9889. }
  9890. }
  9891. }
  9892.  
  9893. function computeVLC(begin,end) {
  9894. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  9895. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  9896. computeTactique(begin,end);
  9897. //+++window.console.log('computeVLC, après computeTactique');
  9898. if(!begin) begin=1;
  9899. if(!end) end=nbMonstres;
  9900. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  9901. if(!cache)
  9902. return false;
  9903. var urlImg = URL_MZimg + "oeil.png";
  9904. for(var i = end; i >= begin;i--)
  9905. {
  9906. var id = getMonstreID(i);
  9907. var donneesMonstre = listeCDM[id];
  9908. if(donneesMonstre && donneesMonstre.length>12)
  9909. {
  9910. if(donneesMonstre[12]==1)
  9911. {
  9912. var td = getMonstreNomNode(i);
  9913. td.appendChild(document.createTextNode(" "));
  9914. td.appendChild(createImage(urlImg, "Voit le caché"));
  9915. }
  9916. }
  9917. }
  9918. }
  9919.  
  9920. /* appelé
  9921. par updateTactique
  9922. par initialiseInfos
  9923. par do_vue
  9924. par computeVLC
  9925. par computeMission
  9926. par filtreMonstres
  9927. par retrieveCDMs
  9928. */
  9929. function computeTactique(begin, end) {
  9930. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  9931. try {
  9932. if(!begin) begin = 1;
  9933. if(!end) end = nbMonstres;
  9934. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  9935. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9936. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  9937. if(noTactique || !isProfilActif()) return;
  9938. //+++window.console.log('computeTactique, après isProfilActif');
  9939.  
  9940. for(var j=end ; j>=begin ; j--) {
  9941. var id = getMonstreID(j);
  9942. var nom = getMonstreNom(j);
  9943. var donneesMonstre = listeCDM[id];
  9944. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  9945. var td = getMonstreNomNode(j);
  9946. appendText(td,' ');
  9947. td.appendChild(
  9948. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  9949. );
  9950. }
  9951. }
  9952. }
  9953. catch(e) {
  9954. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  9955. }
  9956. filtreMonstres();
  9957. }
  9958.  
  9959. function updateTactique() {
  9960. // = Handler checkBox noTactique
  9961. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9962. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  9963. if(!isCDMsRetrieved) return;
  9964. //+++window.console.log('updateTactique, isCDMsRetrieved=' + isCDMsRetrieved);
  9965.  
  9966. if(noTactique) {
  9967. for(var i=nbMonstres ; i>0 ; i--) {
  9968. var tr = getMonstreNomNode(i);
  9969. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9970. tr, null, 9, null).singleNodeValue;
  9971. if(img) {
  9972. img.parentNode.removeChild(img.previousSibling);
  9973. img.parentNode.removeChild(img);
  9974. }
  9975. }
  9976. }
  9977. else
  9978. computeTactique();
  9979. }
  9980.  
  9981. function filtreMonstres() {
  9982. // = Handler universel pour les fonctions liées aux monstres
  9983. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9984. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9985. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9986. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9987. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9988. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9989. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9990. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9991. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9992. // old/new : détermine s'il faut ou non nettoyer les tr
  9993. var oldNOEM = true, noEM = true;
  9994. if(MY_getValue('NOINFOEM')!='true') {
  9995. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9996. }
  9997. // Filtrage par nom
  9998. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9999. // Génère la liste des mobs engagés (si filtrés)
  10000. if(noEngages && !isEngagesComputed) {
  10001. for(var i=nbTrolls ; i>0 ; i--) {
  10002. var pos = getTrollPosition(i);
  10003. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  10004. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  10005. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  10006. }
  10007. isEngagesComputed = true;
  10008. }
  10009. /*** FILTRAGE ***/
  10010. /* À computer :
  10011. * - EM (nom suffit)
  10012. * - Enchant (nom suffit)
  10013. * - Mission (nécessite CdM)
  10014. * - mob VlC (nécessite CdM)
  10015. * Sans computation :
  10016. * - Gowap ? engagé ?
  10017. */
  10018. for(var i=nbMonstres ; i>0 ; i--) {
  10019. var pos = getMonstrePosition(i);
  10020. var nom = getMonstreNom(i).toLowerCase();
  10021. if(noEM!=oldNOEM) {
  10022. if(noEM) {
  10023. // Si noEM passe de false à true, on nettoie les td "Nom"
  10024. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  10025. var tr = getMonstreNomNode(i);
  10026. while(tr.childNodes.length>1) {
  10027. tr.removeChild(tr.childNodes[1]);
  10028. }
  10029. } else {
  10030. var tr = getMonstreNomNode(i);
  10031. var TypeMonstre=getEM(nom);
  10032. if(TypeMonstre!='') {
  10033. var infosCompo=compoMobEM(TypeMonstre);
  10034. if(infosCompo.length>0) {
  10035. tr.appendChild(document.createTextNode(' '));
  10036. tr.appendChild(createImage(urlImg, infosCompo));
  10037. }
  10038. }
  10039. }
  10040. }
  10041. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  10042. var texte = getInfoEnchantementFromMonstre(nom);
  10043. if(texte!='') {
  10044. var td = getMonstreNomNode(i);
  10045. td.appendChild(document.createTextNode(' '));
  10046. td.appendChild(createImage(urlEnchantImg, texte));
  10047. }
  10048. }
  10049. tr_monstres[i].style.display = (
  10050. noGowapsS &&
  10051. nom.indexOf('gowap sauvage')!=-1 &&
  10052. getMonstreDistance(i)>1
  10053. ) || (
  10054. noGowapsA &&
  10055. nom.indexOf('gowap apprivoisé')!=-1 &&
  10056. getMonstreDistance(i)>1
  10057. ) || (
  10058. noEngages &&
  10059. getMonstreDistance(i)!=0 &&
  10060. listeEngages[pos[0]] &&
  10061. listeEngages[pos[0]][pos[1]] &&
  10062. listeEngages[pos[0]][pos[1]][pos[2]]
  10063. ) || (
  10064. strMonstre!='' &&
  10065. nom.indexOf(strMonstre)==-1
  10066. ) || (
  10067. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  10068. getMonstreDistance(i)>1 &&
  10069. nom.toLowerCase().indexOf("kilamo")==-1
  10070. ) ? 'none' : '';
  10071. }
  10072. if(MY_getValue('NOINFOEM')!='true') {
  10073. if(noEM != oldNOEM) {
  10074. if(noEM && isCDMsRetrieved) computeMission();
  10075. }
  10076. oldNOEM = noEM;
  10077. }
  10078. needComputeEnchantement = false;
  10079. }
  10080.  
  10081.  
  10082. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  10083.  
  10084. function filtreTrolls() {
  10085. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  10086. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  10087. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  10088. for(var i=1 ; i<=nbTrolls ; i++) {
  10089. tr_trolls[i].style.display = (
  10090. noIntangibles &&
  10091. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  10092. ) || (
  10093. strTroll!='' &&
  10094. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  10095. ) || (
  10096. strGuilde!='' &&
  10097. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  10098. ) ? 'none' : '';
  10099. }
  10100. }
  10101.  
  10102. /* [functions] Bulle PX Trolls */
  10103. var bulle;
  10104.  
  10105. function initPXTroll() {
  10106. bulle = document.createElement('div');
  10107. bulle.id = 'bulle';
  10108. bulle.className = 'mh_textbox';
  10109. bulle.style =
  10110. 'position: absolute;'+
  10111. 'border: 1px solid #000000;'+
  10112. 'visibility: hidden;'+
  10113. 'display: inline;'+
  10114. 'z-index: 2;';
  10115. document.body.appendChild(bulle);
  10116.  
  10117. for(var i=nbTrolls ; i>0 ; i--) {
  10118. var td_niv = getTrollNivNode(i);
  10119. td_niv.onmouseover = showPXTroll;
  10120. td_niv.onmouseout = hidePXTroll;
  10121. }
  10122. }
  10123.  
  10124. function showPXTroll(evt) {
  10125. var lvl = this.firstChild.nodeValue;
  10126. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  10127. bulle.style.left = evt.pageX+15+'px';
  10128. bulle.style.top = evt.pageY+'px';
  10129. bulle.style.visibility = 'visible';
  10130. }
  10131.  
  10132. function hidePXTroll() {
  10133. bulle.style.visibility = 'hidden';
  10134. }
  10135.  
  10136. /* [functions] Envoi PX / MP */
  10137. function putBoutonPXMP() {
  10138. // Bouton d'initialisation du mode Envoi
  10139. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  10140. var td = document.getElementById('tdInsertTrolls');
  10141. if(!td) { return; }
  10142. td.width = 100;
  10143. td = insertAfterTd(td);
  10144. td.style.verticalAlign = 'top';
  10145. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  10146. bouton.id = 'btnEnvoi';
  10147. }
  10148.  
  10149. function prepareEnvoi() {
  10150. // = 1er Handler du bouton d'envoi
  10151. /* Ajout de la colonne des CheckBoxes */
  10152. var td = insertTdText(getTrollNomNode(0),'');
  10153. td.width = 5;
  10154. for(var i=nbTrolls ; i>0 ; i--) {
  10155. td = insertTd(getTrollNomNode(i));
  10156. appendCheckBox(td,'envoi'+i);
  10157. }
  10158. /* Ajout du radio de choix PX ou MP */
  10159. var btnEnvoi = document.getElementById('btnEnvoi');
  10160. if(!btnEnvoi) { return; }
  10161. var tdEnvoi = btnEnvoi.parentNode;
  10162. appendText(tdEnvoi,' ');
  10163. var span = document.createElement('span');
  10164. span.style.whiteSpace = 'nowrap';
  10165. var radioElt = document.createElement('input');
  10166. radioElt.type = 'radio';
  10167. radioElt.name = 'envoiPXMP';
  10168. radioElt.id = 'radioPX';
  10169. span.appendChild(radioElt);
  10170. appendText(span,' des PX ');
  10171. radioElt = document.createElement('input');
  10172. radioElt.type = 'radio';
  10173. radioElt.name = 'envoiPXMP';
  10174. radioElt.checked = true;
  10175. span.appendChild(radioElt);
  10176. appendText(span,' un MP');
  10177. tdEnvoi.appendChild(span);
  10178. /* Insertion du bouton Annuler */
  10179. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  10180. /* Modification de l'effet du bouton Envoi */
  10181. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  10182. }
  10183.  
  10184. function annuleEnvoi() {
  10185. // = Handler bouton Annuler
  10186. /* Nettoyage du td du bouton Envoi */
  10187. var btnEnvoi = document.getElementById('btnEnvoi');
  10188. var tdEnvoi = btnEnvoi.parentNode;
  10189. while(tdEnvoi.firstChild) {
  10190. tdEnvoi.removeChild(tdEnvoi.firstChild);
  10191. }
  10192. /* Retour à l'effet de base du bouton Envoi */
  10193. btnEnvoi.onclick = prepareEnvoi;
  10194. tdEnvoi.appendChild(btnEnvoi);
  10195. /* Suppression CheckBoxes */
  10196. for(var i=nbTrolls ; i>=0 ; i--) {
  10197. var td = getTrollNomNode(i);
  10198. td.parentNode.removeChild(td);
  10199. }
  10200. }
  10201.  
  10202. function effectueEnvoi() {
  10203. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  10204. var str='';
  10205. var errID = false;
  10206. for(var i=nbTrolls ; i>0 ; i--) {
  10207. var chb = document.getElementById('envoi'+i);
  10208. if(chb.checked) {
  10209. var idTroll = getTrollID(i);
  10210. if (idTroll == undefined) {
  10211. errID = true;
  10212. } else {
  10213. str += (str ? ',' : '') + idTroll;
  10214. }
  10215. }
  10216. }
  10217. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  10218. var PXchecked = document.getElementById('radioPX').checked;
  10219. if(PXchecked) {
  10220. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  10221. } else {
  10222. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  10223. }
  10224. }
  10225.  
  10226. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  10227.  
  10228. function filtreTresors() {
  10229. // += Handler checkboxes : gg, compos, bidouilles, non libres
  10230. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  10231. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  10232. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  10233. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  10234. if(noEngages && !isEngagesComputed) {
  10235. for(var i=nbTrolls ; i>0 ; i--) {
  10236. var pos = getTrollPosition(i);
  10237. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  10238. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  10239. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  10240. }
  10241. isEngagesComputed = true;
  10242. }
  10243. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  10244. for(var i=nbTresors ; i>0 ; i--) {
  10245. var nom = getTresorNom(i);
  10246. var pos = getTresorPosition(i);
  10247. tr_tresors[i].style.display = (
  10248. noGG &&
  10249. nom.indexOf('Gigots de Gob')!=-1
  10250. ) || (
  10251. noCompos &&
  10252. nom.indexOf('Composant')!=-1
  10253. ) || (
  10254. noEngages &&
  10255. listeEngages[pos[2]] &&
  10256. listeEngages[pos[2]][pos[1]] &&
  10257. listeEngages[pos[2]][pos[1]][pos[0]] &&
  10258. getTresorDistance(i)>0
  10259. ) || (
  10260. strTresor!='' &&
  10261. nom.toLowerCase().indexOf(strTresor)==-1
  10262. ) || (
  10263. noBidouilles &&
  10264. nom.indexOf('Bidouille')!=-1
  10265. ) ? 'none' : '';
  10266. }
  10267. }
  10268.  
  10269.  
  10270. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  10271.  
  10272. function filtreLieux() {
  10273. // += Handler checkbox trous
  10274. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  10275. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  10276. for(var i=nbLieux ; i>0 ; i--) {
  10277. tr_lieux[i].style.display = (
  10278. strLieu &&
  10279. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  10280. ) || (
  10281. noTrou &&
  10282. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  10283. getLieuDistance(i)>1
  10284. ) ? 'none' : '';
  10285. }
  10286. }
  10287.  
  10288.  
  10289. /*-[functions]-------------------- Diplomatie --------------------------------*/
  10290.  
  10291. function refreshDiplo() {
  10292. MY_setValue(numTroll+'.diplo.off',
  10293. checkBoxDiplo.checked?'true':'false'
  10294. );
  10295. if(isDiploRaw) { computeDiplo(); }
  10296. appliqueDiplo();
  10297. }
  10298.  
  10299. function computeDiplo() {
  10300. // On extrait les données de couleur et on les stocke par id
  10301. // Ordre de préséance :
  10302. // source Guilde < source Perso
  10303. // guilde cible < troll cible
  10304. /* Diplo de Guilde */
  10305. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  10306. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  10307. if(diploGuilde && diploGuilde.isOn=='true') {
  10308. // Guilde perso
  10309. if(diploGuilde.guilde) {
  10310. Diplo.Guilde[diploGuilde.guilde.id] = {
  10311. couleur: diploGuilde.guilde.couleur,
  10312. titre: 'Ma Guilde'
  10313. };
  10314. }
  10315. // Guildes/Trolls A/E
  10316. for(var AE in {Amis:0,Ennemis:0}) {
  10317. for(var i=0 ; i<5 ; i++) {
  10318. if(diploGuilde[AE+i]) {
  10319. for(var type in {Guilde:0,Troll:0}) {
  10320. var liste = diploGuilde[AE+i][type].split(';');
  10321. for(var j=liste.length-2 ; j>=0 ; j--) {
  10322. Diplo[type][liste[j]] = {
  10323. couleur: diploGuilde[AE+i].couleur,
  10324. titre: diploGuilde[AE+i].titre
  10325. };
  10326. }
  10327. }
  10328. }
  10329. }
  10330. }
  10331. }
  10332. /* Diplo Perso */
  10333. //var diploPerso = MY_getValue(numTroll+'.diplo.perso') ? JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {}; // déjà chargé
  10334. if(diploPerso && diploPerso.isOn=='true') {
  10335. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  10336. for(var id in diploPerso[type]) {
  10337. Diplo[type][id] = diploPerso[type][id];
  10338. }
  10339. }
  10340. }
  10341. if(diploPerso.mythiques) {
  10342. Diplo.mythiques = diploPerso.mythiques;
  10343. }
  10344. isDiploRaw = false;
  10345. }
  10346.  
  10347. function appliqueDiplo() {
  10348. var aAppliquer = Diplo;
  10349. if(checkBoxDiplo.checked) {
  10350. // Pour retour à l'affichage basique sur désactivation de la diplo
  10351. aAppliquer = {
  10352. Guilde: {},
  10353. Troll: {},
  10354. Monstre: {}
  10355. };
  10356. }
  10357. /* On applique "aAppliquer" */
  10358. // Diplo Trõlls
  10359. for(var i=nbTrolls ; i>0 ; i--) {
  10360. var idG = getTrollGuildeID(i);
  10361. var idT = getTrollID(i);
  10362. var tr = tr_trolls[i];
  10363. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  10364. if(aAppliquer.Troll[idT]) {
  10365. tr.className = '';
  10366. var descr = aAppliquer.Troll[idT].titre;
  10367. if(descr) {
  10368. getTrollNomNode(i).title = descr
  10369. }
  10370. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  10371. } else if(aAppliquer.Guilde[idG]) {
  10372. tr.className = '';
  10373. var descr = aAppliquer.Guilde[idG].titre;
  10374. if(descr) {
  10375. getTrollNomNode(i).title = descr
  10376. }
  10377. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  10378. } else {
  10379. tr.className = 'mh_tdpage';
  10380. getTrollNomNode(i).title = '';
  10381. }
  10382. }
  10383. // Diplo Monstres
  10384. for(var i=nbMonstres ; i>0 ; i--) {
  10385. var id = getMonstreID(i);
  10386. var nom = getMonstreNom(i).toLowerCase();
  10387. if(aAppliquer.Monstre[id]) {
  10388. tr_monstres[i].className = '';
  10389. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  10390. tr_monstres[i].diploActive = 'oui';
  10391. var descr = aAppliquer.Monstre[id].titre;
  10392. if(descr) {
  10393. getMonstreNomNode(i).title = descr;
  10394. }
  10395. } else if(aAppliquer.mythiques &&
  10396. (nom.indexOf('liche')==0 ||
  10397. nom.indexOf('hydre')==0 ||
  10398. nom.indexOf('balrog')==0 ||
  10399. nom.indexOf('beholder')==0)) {
  10400. tr_monstres[i].className = '';
  10401. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  10402. tr_monstres[i].diploActive = 'oui';
  10403. getMonstreNomNode(i).title = 'Monstre Mythique';
  10404. } else {
  10405. tr_monstres[i].className = 'mh_tdpage';
  10406. tr_monstres[i].diploActive = '';
  10407. }
  10408. }
  10409. }
  10410.  
  10411.  
  10412. /*-[functions]---------------- Actions à distance ----------------------------*/
  10413.  
  10414. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  10415. var monN = parseInt(getPosition()[2]);
  10416. for(var type in keltypes) {
  10417. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  10418. for(var i=this['nb'+type] ; i>0 ; i--) {
  10419. var tr = this['tr_'+type.toLowerCase()][i];
  10420. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  10421. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  10422. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  10423. var sonN = getXxxPosition(type, i)[2];
  10424. var d = getXxxDistance(type, i);
  10425. if(sonN==monN && d>=dmin && d<=dmax) {
  10426. var iconeAction = document.evaluate(
  10427. "./descendant::img[@alt='"+alt+"']",
  10428. tr, null, 9, null
  10429. ).singleNodeValue;
  10430. if(iconeAction) {
  10431. if(iconeAction.title) {
  10432. iconeAction.title += "\n"+message;
  10433. } else {
  10434. iconeAction.title = message;
  10435. }
  10436. iconeAction.src = urlIcon;
  10437. } else {
  10438. var tdAction = tr.getElementsByTagName('td')[1];
  10439. var icon = document.createElement('img');
  10440. icon.src = urlIcon;
  10441. icon.height = 20;
  10442. icon.alt = alt;
  10443. icon.title = message;
  10444. tdAction.appendChild(icon);
  10445. }
  10446. }
  10447. }
  10448. }
  10449. }
  10450.  
  10451. function computeCharge() {
  10452. computeActionDistante(1,
  10453. getPortee__Vue(
  10454. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  10455. MY_getValue(numTroll+".caracs.regeneration")
  10456. ),
  10457. {'Monstres':1, 'Trolls':1},
  10458. 'Attaquer',
  10459. MHicons+'E_Metal09.png',
  10460. 'Cible à portée de Charge'
  10461. );
  10462. }
  10463.  
  10464. function computeProjo() {
  10465. computeActionDistante(0,
  10466. getPortee__Vue(
  10467. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10468. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10469. ),
  10470. {'Monstres':1, 'Trolls':1},
  10471. 'Attaquer',
  10472. MHicons+'S_Fire05.png',
  10473. 'Cible à portée de Projo'
  10474. );
  10475. }
  10476.  
  10477. function computeTelek() {
  10478. computeActionDistante(0,
  10479. Math.floor((
  10480. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10481. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10482. )/2),
  10483. {'Tresors':1},
  10484. 'Telek',
  10485. MHicons+'S_Magic04.png',
  10486. 'Trésor à portée de Télékinésie'
  10487. );
  10488. }
  10489.  
  10490. function computeLdP() {
  10491. computeActionDistante(0,
  10492. 2+Math.floor((
  10493. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  10494. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  10495. )/5),
  10496. {'Monstres':1, 'Trolls':1},
  10497. 'self',
  10498. MHicons+'P_Red01.png',
  10499. 'Cible à portée de Lancer de Potions'
  10500. );
  10501. }
  10502.  
  10503.  
  10504. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  10505.  
  10506. function putScriptExterne(sInfo) {
  10507. for (var iBricol = 1; ; iBricol++) {
  10508. var extClef = iBricol == 1 ? '' : iBricol;
  10509. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  10510. if (!sInfo) break;
  10511. putScriptExterneOneIT(sInfo);
  10512. }
  10513. }
  10514.  
  10515. function putScriptExterneOneIT(sInfo) {
  10516. if(!sInfo || sInfo=='') return;
  10517.  
  10518. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  10519. if(nomit=='bricol') {
  10520. var data = sInfo.split('$');
  10521. try {
  10522. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  10523. // appendNewScript(URL_bricol+data[1]
  10524. // +'/mz.php?login='+data[2]
  10525. // +'&password='+data[3]
  10526. // );
  10527. FF_XMLHttpRequest({
  10528. method: 'GET',
  10529. url: URL_bricol+data[1]
  10530. +'/mz_json.php?login='+encodeURIComponent(data[2])
  10531. +'&password='+data[3],
  10532. trace: 'bricolTroll',
  10533. onload: function(responseDetails) {
  10534. try {
  10535. if (responseDetails.status == 0) {
  10536. window.console.log('status=0 à l\'appel bricol\'troll');
  10537. if (isHTTPS) {
  10538. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  10539. } else {
  10540. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  10541. }
  10542. return;
  10543. }
  10544. var ratibusData;
  10545. try {
  10546. ratibusData = JSON.parse(responseDetails.responseText);
  10547. } catch(e) {}
  10548. if (ratibusData === undefined) {
  10549. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  10550. return;
  10551. }
  10552. if (ratibusData.error) {
  10553. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  10554. } else {
  10555. putInfosTrolls(ratibusData.data.trolls, data[1]);
  10556. }
  10557. } catch(e) {
  10558. window.console.log(traceStack(e, 'retour bricol\'troll'));
  10559. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  10560. }
  10561. }
  10562. });
  10563. } catch(e) {
  10564. if (isHTTPS) {
  10565. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  10566. } else {
  10567. window.console.log(traceStack(e, 'appel bricol\'troll'));
  10568. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  10569. }
  10570. }
  10571. }
  10572. }
  10573.  
  10574. /*
  10575. * Roule 07/11/2016, on utilise mz_json qui envoie
  10576. {
  10577. "data": {
  10578. "trolls": {
  10579. "59424": {
  10580. "id": 59424,
  10581. "pv": xx,
  10582. "pv_max": xx,
  10583. "updated_at": "2016-10-31 07:28:40",
  10584. "dla": "2016-10-05 07:28:04",
  10585. "pa": 0
  10586. },
  10587. }
  10588. }
  10589. }
  10590. */
  10591.  
  10592. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  10593. function corrigeBricolTrolls(infosTrolls) {
  10594. for(var i in infosTrolls) {
  10595. var pv = infosTrolls[i][0];
  10596. var pvmax = infosTrolls[i][1];
  10597. var pvmem = MY_getValue(i+'.caracs.pv.max');
  10598. if(pvmem && pvmem>pvmax) {
  10599. infosTrolls[i][1] = pvmem;
  10600. pvmax = pvmem;
  10601. }
  10602. if(pv>pvmax) {
  10603. var newpvmax = 5*Math.ceil(pv/5);
  10604. MY_setValue(i+'.caracs.pv.max',newpvmax);
  10605. infosTrolls[i][1] = newpvmax;
  10606. }
  10607. }
  10608. }
  10609.  
  10610. // insère 2 TD avant nextTD avec les infos venant de l'IT
  10611. function addTdInfosTroll(infos, TR, itName) {
  10612. /* cadre barre PV */
  10613. var tab = document.createElement('div');
  10614. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  10615. /* barre PV */
  10616. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  10617. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  10618. .vieContainer {
  10619. background-color: #CCC;
  10620. width: 50px;
  10621. height: 6px;
  10622. border: 1px solid #000;
  10623. text-align: left;
  10624. }
  10625. */
  10626. tab.style.width = '100px';
  10627. tab.style.height = '10px';
  10628. tab.style.border = '1px solid #000';
  10629. tab.style.textAlign = 'left';
  10630. var div2 = document.createElement('div');
  10631. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  10632. var dateLimite = new Date();
  10633. dateLimite.setDate(dateLimite.getDate() - 7);
  10634. if (infos.oUpdatedAt < dateLimite) {
  10635. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  10636. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  10637. } else if (pourcentVie > 66) {
  10638. div2.style.backgroundColor = '#77EE77';
  10639. } else if (pourcentVie > 33) {
  10640. div2.style.backgroundColor = '#EEEE77';
  10641. } else {
  10642. div2.style.backgroundColor = '#FF0000';
  10643. }
  10644. div2.style.width = pourcentVie + '%';
  10645. div2.style.height = '10px';
  10646. tab.appendChild(div2);
  10647. /* ancienne méthode par img, à supprimer
  10648. var img = document.createElement('img');
  10649. img.src = '../Images/Interface/milieu.gif';
  10650. img.height = 10;
  10651. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  10652. tab.appendChild(img);
  10653. */
  10654.  
  10655. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  10656. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  10657. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  10658. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  10659.  
  10660. /* lien vers l'IT */
  10661. var lien = document.createElement('a');
  10662. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  10663. lien.href = URL_bricol+itName+'/index.php';
  10664. lien.target = '_blank';
  10665. lien.appendChild(tab);
  10666. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  10667. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  10668. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  10669. //insertTdElement(tdGuilde,lien);
  10670. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  10671. /* PAs dispos */
  10672. var span = document.createElement('span');
  10673. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  10674. appendText(span, infos.pa +' PA' );
  10675. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  10676. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  10677. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  10678. span.style.backgroundColor = 'B8EEB8';
  10679. }
  10680. //insertTdElement(tdGuilde, span);
  10681. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  10682. }
  10683.  
  10684. var MZ_tabTrTrollById;
  10685. function putInfosTrolls(infosTrolls, itName) {
  10686. try {
  10687. if (MZ_tabTrTrollById === undefined) {
  10688. MZ_tabTrTrollById = new Array;
  10689. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  10690. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  10691. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  10692. td.width = 40;
  10693. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  10694. td.width = 105;
  10695. for(i=nbTrolls ; i>0 ; i--) {
  10696. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  10697. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  10698. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  10699. }
  10700. }
  10701.  
  10702.  
  10703. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  10704. //corrigeBricolTrolls(infosTrolls);
  10705.  
  10706. // supression des infos trop vieilles (un mois)
  10707. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  10708. var dateLimite = new Date();
  10709. dateLimite.setMonth(dateLimite.getMonth() - 1);
  10710.  
  10711. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  10712. var str = MY_getValue(numTroll+'.INFOSIT');
  10713. var bAjoutTrollInvi = false;
  10714. if (str) {
  10715. var arr = str.split('$');
  10716. bAjoutTrollInvi = arr[4]>0;
  10717. }
  10718.  
  10719. var tBody = tr_trolls[0].parentNode;
  10720. if (tr_trolls[1] !== undefined)
  10721. tBody = tr_trolls[1].parentNode;
  10722.  
  10723. //window.console.log('nb Troll IT : ' + IDs.length);
  10724. var pos = getPosition();
  10725.  
  10726. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  10727. for (var idTroll in infosTrolls) {
  10728. var infos = infosTrolls[idTroll];
  10729. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  10730. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  10731. if (idTroll == numTroll) continue; // pas nous-même
  10732. var tr;
  10733. if (idTroll in MZ_tabTrTrollById) {
  10734. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  10735. tr = MZ_tabTrTrollById[idTroll];
  10736. } else {
  10737. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  10738. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  10739. // trouver où insérer ce Troll
  10740. var next = undefined;
  10741. for(var j=0 ; j<tr_trolls.length ; j++) {
  10742. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  10743. if (thisDist > distance) {
  10744. next = tr_trolls[j]
  10745. break;
  10746. }
  10747. }
  10748. if (next !== undefined) {
  10749. tr = insertTr(next,'mh_tdpage')
  10750. } else {
  10751. tr = appendTr(tBody,'mh_tdpage');
  10752. }
  10753. tr.style.color = 'orange';
  10754. var td = appendTd(tr); // distance
  10755. appendText(td, distance);
  10756. td = appendTd(tr); // actions
  10757. td = appendTd(tr); // ID
  10758. appendText(td, idTroll);
  10759. td = appendTd(tr); // Nom
  10760. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  10761. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  10762. td = appendTd(tr); // PV
  10763. td = appendTd(tr); // PA
  10764. td = appendTd(tr); // Guilde
  10765. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  10766. td = appendTd(tr); // Niveau
  10767. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  10768. td.align = 'center';
  10769. td = appendTd(tr); // Race
  10770. if (infos.race) appendText(td, infos.race);
  10771. td = appendTd(tr); // X
  10772. td.align = 'center';
  10773. if (infos.x !== undefined) appendText(td, infos.x);
  10774. td = appendTd(tr); // Y
  10775. td.align = 'center';
  10776. if (infos.y !== undefined) appendText(td, infos.y);
  10777. td = appendTd(tr); // N
  10778. td.align = 'center';
  10779. if (infos.n !== undefined) appendText(td, infos.n);
  10780. MZ_tabTrTrollById[idTroll] = tr;
  10781. }
  10782. if (!tr.done) {
  10783. addTdInfosTroll(infos, tr, itName);
  10784. tr.done = true;
  10785. }
  10786. }
  10787. } catch(e) {
  10788. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  10789. window.console.error(traceStack(e, 'putInfosTrolls'));
  10790. }
  10791. }
  10792.  
  10793.  
  10794. /* Mode Tétalanvert! ---------------------------------------------------------*/
  10795.  
  10796. function calculeDistance(maPos,posArr) {
  10797. return Math.max(
  10798. Math.abs(maPos[0]-posArr[0]),
  10799. Math.abs(maPos[1]-posArr[1]),
  10800. Math.abs(maPos[2]-posArr[2])
  10801. );
  10802. }
  10803.  
  10804. function inversionCoord() {
  10805. var maPos = getPosition();
  10806. var listeOffsets = {
  10807. 'monstres':checkBoxLevels.checked?4:3,
  10808. 'trolls':6,
  10809. };
  10810. for(var type in listeOffsets) {
  10811. var trList = this['tr_'+type];
  10812. var offset = listeOffsets[type];
  10813. for(var i=trList.length-1 ; i>0 ; i--) {
  10814. var oldX = parseInt(trList[i].cells[offset].textContent);
  10815. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  10816. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  10817. trList[i].cells[offset].innerHTML = oldY;
  10818. trList[i].cells[offset+1].innerHTML = oldX;
  10819. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  10820. }
  10821. }
  10822. }
  10823.  
  10824.  
  10825. /* Partie principale */
  10826. function do_vue() {
  10827. for(var type in typesAFetcher) {
  10828. fetchData(type);
  10829. }
  10830.  
  10831. // roule' 11/03/2016
  10832. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  10833. // je fais une recopie :(
  10834. tr_monstres = this['tr_monstres'];
  10835. tr_trolls = this['tr_trolls'];
  10836. tr_tresors = this['tr_tresors'];
  10837. tr_champignons = this['tr_champignons'];
  10838. tr_lieux = this['tr_lieux'];
  10839.  
  10840. nbMonstres = this['nbMonstres'];
  10841. nbTrolls = this['nbTrolls'];
  10842. nbTresors = this['nbTresors'];
  10843. nbChampignons = this['nbChampignons'];
  10844. nbLieux = this['nbLieux'];
  10845.  
  10846. try {
  10847. start_script(31);
  10848. initialiseInfos();
  10849. savePosition();
  10850.  
  10851. // Fonctionnalité "Têtalenvert" cachée, en test :
  10852. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  10853. inversionCoord();
  10854. }
  10855. ajoutDesFiltres();
  10856. set2DViewSystem();
  10857. //putBoutonTroogle();
  10858. putBoutonPXMP();
  10859. synchroniseFiltres();
  10860. toggleLevelColumn();
  10861.  
  10862. refreshDiplo();
  10863. //400 ms
  10864. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  10865. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  10866. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  10867. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  10868. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  10869. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  10870. var noTresorsEngages =
  10871. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  10872. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  10873. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  10874. filtreMonstres();
  10875. if(noIntangibles) {
  10876. filtreTrolls();
  10877. }
  10878. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  10879. filtreTresors();
  10880. }
  10881. if(noTrou) {
  10882. filtreLieux();
  10883. }
  10884.  
  10885. initPopupVue();
  10886. initPXTroll();
  10887.  
  10888. if(getTalent("Projectile Magique")!=0) {
  10889. computeProjo();
  10890. }
  10891. if(getTalent("Charger")!=0) {
  10892. computeCharge();
  10893. }
  10894. if(getTalent("Télékinésie")!=0) {
  10895. computeTelek();
  10896. }
  10897. if(getTalent("Lancer de Potions")!=0) {
  10898. computeLdP();
  10899. }
  10900. putScriptExterne();
  10901. displayScriptTime();
  10902. } catch(e) {
  10903. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10904. window.console.error(traceStack(e, 'vue'));
  10905. }
  10906. }
  10907.  
  10908.  
  10909.  
  10910. /*******************************************************************************
  10911. * This file is part of Mountyzilla. *
  10912. * *
  10913. * Mountyzilla is free software; you can redistribute it and/or modify *
  10914. * it under the terms of the GNU General Public License as published by *
  10915. * the Free Software Foundation; either version 2 of the License, or *
  10916. * (at your option) any later version. *
  10917. * *
  10918. * Mountyzilla is distributed in the hope that it will be useful, *
  10919. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10920. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10921. * GNU General Public License for more details. *
  10922. * *
  10923. * You should have received a copy of the GNU General Public License *
  10924. * along with Mountyzilla; if not, write to the Free Software *
  10925. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10926. *******************************************************************************/
  10927.  
  10928. // x~x profil2
  10929.  
  10930. /*---------------------------- Variables globales ----------------------------*/
  10931.  
  10932. var
  10933. // Anatrolliseur
  10934. urlAnatrolliseur,
  10935. // Infobulles talents
  10936. hauteur = 50, bulleStyle = null,
  10937. // Caracteristiques
  10938. // Infos troll
  10939. race, niv, idtroll, datecrea,
  10940. idguilde, nomguilde,
  10941. // Etats du troll
  10942. fatigue, bmfatigue,
  10943.  
  10944. // Experience, Pi, ...
  10945. pxdistribuables, pxperso,
  10946. piutilisable, pitotal,
  10947. nbmeurtres, nbmorts,
  10948. // utilisee pour les moyennes MM/jour, kill/jour, etc
  10949. NBjours,
  10950. // calcul des DLA suivantes
  10951. DLA, DLAsuiv, HeureServeur,
  10952. // details duree du tour (calcul pvdispo) :
  10953. dtb, pdm, bmt, adb, dpt,
  10954. //posale
  10955. posX, posY, posN,
  10956. // caracs physiques
  10957. vue, vuebp, vuebm, vuetotale,
  10958. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  10959. reg, regbp, regbm, regmoy,
  10960. att, attbp, attbm, attmoy, atttourD, atttour, attmoytour,
  10961. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  10962. deg, degbp, degbm, degmoy, degmoycrit, degtour, degmoytour, degmoycrittour,
  10963. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  10964. rm, rmbp, rmbm, rmtotale,
  10965. mm, mmbp, mmbm, mmtotale,
  10966.  
  10967. // Variables speciales Kastars
  10968. pvActuelKastar, minParPV, overDLA,
  10969. // id pour edition manuelle de lastDLA :
  10970. inJour, inMois, inAn, inHr, inMin, inSec,
  10971. // id pour auto-refresh lastDLA :
  10972. lastDLAZone, maxAMZone, cumulZone,
  10973. lastDLA, DLAaccel;
  10974.  
  10975.  
  10976. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  10977.  
  10978. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10979. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10980. function getUniqueValueBySelector(selector, defaultValue){
  10981. var valNode = document.querySelector(selector);
  10982. if(valNode!=null){
  10983. if(valNode.hasChildNodes()) {
  10984. return valNode.childNodes[0].nodeValue;
  10985. }else{
  10986. return defaultValue;
  10987. }
  10988. } else{
  10989. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10990. return defaultValue;
  10991. }
  10992. }
  10993. function getUniqueStringValueBySelector(selector){
  10994. return getUniqueValueBySelector(selector,"");
  10995. }
  10996. function getUniqueIntValueBySelector(selector){
  10997. var ret = getUniqueValueBySelector(selector,0);
  10998. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10999. ret = 0;
  11000. }
  11001. return parseInt(ret);
  11002. }
  11003. function getUniqueFloatValueBySelector(selector){
  11004. var ret = getUniqueValueBySelector(selector,0.0);
  11005. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  11006. ret = 0.0;
  11007. }
  11008. return parseFloat(ret);
  11009. }
  11010.  
  11011.  
  11012. function resiste(Ddeg,bm) {
  11013. // version naive mais compréhensible ^^
  11014. // DEBUG: à revoir
  11015. if(!bm) {
  11016. return 2*Math.floor(Ddeg/2);
  11017. }
  11018. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  11019. }
  11020.  
  11021. function retourAZero(fatig) {
  11022. var fat = fatig, raz = 0;
  11023. while(fat>0) {
  11024. raz++;
  11025. fat = Math.floor(fat/1.25);
  11026. }
  11027. return raz;
  11028. }
  11029.  
  11030. function coefDecumul(i) {
  11031. switch(i) {
  11032. case 2: return 0.67;
  11033. case 3: return 0.4;
  11034. case 4: return 0.25;
  11035. case 5: return 0.15;
  11036. default: return 0.1;
  11037. }
  11038. }
  11039.  
  11040. function dureeHM(dmin) {
  11041. var ret = "";
  11042. dmin = Math.floor(dmin);
  11043. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  11044. var mins = dmin%60;
  11045. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  11046. return (ret) ? ret : "-";
  11047. }
  11048.  
  11049. // extraction d'une durée
  11050. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  11051. // c'est protégé (rend 0 si l'élément est absent)
  11052. // Roule' 24/12/2016
  11053. function extractionDuree(selecteur) {
  11054. var s = getUniqueStringValueBySelector(selecteur);
  11055. if (!s) return 0;
  11056. var tabN = getNumbers(s);
  11057. if (tabN.length < 2) return 0;
  11058. return tabN[0] * 60 + tabN[1];
  11059. }
  11060.  
  11061. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  11062.  
  11063. function extractionDonnees() {
  11064. // Variables temporaires
  11065. var Nbrs = {};
  11066.  
  11067. // *********************
  11068. // Cadre "Description"
  11069. // *********************
  11070. race = getUniqueStringValueBySelector('#descr #race');
  11071. debugMZ("Race : " + race);
  11072. idtroll = getUniqueStringValueBySelector('#descr #id');
  11073. debugMZ("Id troll : " + idtroll);
  11074. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  11075. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  11076. datecrea = new Date(StringToDate(strDateCrea));
  11077. debugMZ("Date creation : " + datecrea);
  11078. // Guilde
  11079. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  11080. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  11081. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  11082.  
  11083. // *******************
  11084. // Cadre "Experience"
  11085. // *******************
  11086. // Niveau de troll
  11087. niv = getUniqueIntValueBySelector('#exp #niv');
  11088. nivTroll = niv;
  11089. debugMZ("Niveau : " + niv);
  11090. // PX
  11091. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  11092. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  11093. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  11094. // PI
  11095. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  11096. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  11097. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  11098. // Meutres/Morts
  11099. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  11100. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  11101. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  11102.  
  11103. // *********************
  11104. // Cadre "Tour de Jeu"
  11105. // *********************
  11106. // DLA
  11107. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  11108. DLA = new Date(StringToDate(Nbrs["dla"]));
  11109. debugMZ("DLA: " + DLA);
  11110. // DLA suivante
  11111. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  11112. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  11113. debugMZ("DLAsuiv: " + DLAsuiv);
  11114. // Duree normale de mon Tour
  11115. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  11116. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  11117. dtb = extractionDuree("#dla #tour");
  11118. debugMZ("Duree normale de mon Tour : " + dtb);
  11119. // Bonus/Malus sur la duree
  11120. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  11121. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  11122. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  11123. debugMZ("Bonus/Malus sur la duree : " + bmt);
  11124. // Augmentation due aux blessures
  11125. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  11126. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  11127. adb = extractionDuree("#dla #blessure");
  11128. debugMZ("Augmentation due aux blessures : " + adb);
  11129. // Poids de l'equipement
  11130. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  11131. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  11132. pdm = extractionDuree("#dla #poids");
  11133. debugMZ("Poids de l'equipement : " + pdm);
  11134. // Duree de mon prochain Tour
  11135. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  11136. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  11137. dpt = extractionDuree("#dla #duree>b");
  11138. debugMZ('Duree de mon prochain Tour : ' + dpt);
  11139.  
  11140. // ****************
  11141. // Cadre "Etats"
  11142. // ****************
  11143. // Position du troll :
  11144. posX = getUniqueIntValueBySelector('#pos #x');
  11145. posY = getUniqueIntValueBySelector('#pos #y');
  11146. posN = getUniqueIntValueBySelector('#pos #n');
  11147. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  11148. // PV actuel
  11149. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  11150. pvActuelKastar = pvcourant;
  11151. debugMZ("PV actuel : " + pvcourant)
  11152. // Fatigue
  11153. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  11154. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  11155. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  11156.  
  11157. // **************************
  11158. // Cadre "Caracteristiques"
  11159. // **************************
  11160. // Attaque
  11161. att = getUniqueIntValueBySelector('#carac #att');
  11162. attbp = getUniqueIntValueBySelector('#carac #att_p');
  11163. attbm = getUniqueIntValueBySelector('#carac #att_m');
  11164. atttour = getUniqueIntValueBySelector('#carac #att_tour'); // % bonus AdA
  11165. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d'); // malus Parade
  11166. attmoy = 3.5*att + attbp + attbm;
  11167. var DAttBonus = Math.floor(((att+atttourD)*atttour/100)); // À vérifier
  11168. attmoytour = 3.5*(att+DAttBonus) + attbp + attbm;
  11169. debugMZ(
  11170. "ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+
  11171. "; BM Dé att/tour:("+atttourD+"D;"+atttour+"%) "+(atttourD+DAttBonus)+
  11172. "D ;AttMoyTour:"+attmoytour
  11173. );
  11174. // Esquive
  11175. esq = getUniqueIntValueBySelector('#carac #esq');
  11176. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  11177. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  11178. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  11179. esqmoy = 3.5*esq + esqbp+esqbm;
  11180. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  11181. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  11182. // Degat
  11183. deg = getUniqueIntValueBySelector('#carac #deg');
  11184. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  11185. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  11186. degtour = getUniqueIntValueBySelector('#carac #deg_tour'); // % bonus AdD
  11187. degmoy = 2*deg + degbp + degbm;
  11188. degmoycrit = 2*(deg+Math.floor(deg/2)) + degbp + degbm;
  11189. var DDegBonus = Math.floor(deg*degtour/100);
  11190. degmoytour = 2*(deg + DDegBonus) + degbp + degbm;
  11191. degmoycrittour = degmoytour + 2*Math.floor(deg/2);
  11192. debugMZ(
  11193. "DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+
  11194. " ;deg/tour:("+degtour+"%) "+DDegBonus+
  11195. "D; DegMoyTour:"+degmoytour+"/"+degmoycrittour
  11196. );
  11197. // PV
  11198. pvbase = getUniqueIntValueBySelector('#carac #pv');
  11199. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  11200. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  11201. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  11202. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  11203. // Regeneration
  11204. reg = getUniqueIntValueBySelector('#carac #reg');
  11205. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  11206. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  11207. regmoy = 2 * reg + regbp + regbm; // D3
  11208. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  11209. // Armure
  11210. arm = getUniqueIntValueBySelector('#carac #arm');
  11211. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  11212. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  11213. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  11214. armmoy = 2*arm + armbp+armbm;
  11215. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  11216. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  11217. // TODO : D d'armure non active
  11218. // Vue
  11219. vue = getUniqueIntValueBySelector('#carac #vue');
  11220. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  11221. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  11222. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  11223. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  11224. // RM
  11225. rm = getUniqueIntValueBySelector('#carac #rm');
  11226. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  11227. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  11228. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  11229. rmTroll = rmtotale;
  11230. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  11231. // MM
  11232. mm = getUniqueIntValueBySelector('#carac #mm');
  11233. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  11234. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  11235. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  11236. mmTroll = mmtotale;
  11237. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  11238.  
  11239. // Heure Serveur
  11240. try {
  11241. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  11242. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  11243. HeureServeur = new Date(StringToDate(heureServeurSTR));
  11244. } catch (e) {
  11245. window.console.warn(
  11246. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  11247. );
  11248. HeureServeur = new Date();
  11249. }
  11250. debugMZ("HeureServeur: " + HeureServeur);
  11251.  
  11252. // ***INIT GLOBALE*** NBjours
  11253. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  11254.  
  11255. // Calcul debut lien anatroliseur avec les caracteristiques connues
  11256. var amelio_dtb = function(dtb) {
  11257. if(dtb>555) {
  11258. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  11259. }
  11260. return 10+Math.ceil((555-dtb)/2.5);
  11261. },
  11262. amelio_pv = Math.floor(pvbase/10)-3,
  11263. amelio_vue = vue-3,
  11264. amelio_att = att-3,
  11265. amelio_esq = esq-3,
  11266. amelio_deg = deg-3,
  11267. amelio_reg = reg-1,
  11268. amelio_arm = arm-1;
  11269. if(race==="Darkling"){amelio_reg--; }
  11270. if(race==="Durakuir"){amelio_pv-- ; }
  11271. if(race==="Kastar") {amelio_deg--; }
  11272. if(race==="Skrim") {amelio_att--; }
  11273. if(race==="Tomawak") {amelio_vue--; }
  11274.  
  11275. urlAnatrolliseur = URL_AnatrolDispas
  11276. +"outils_anatrolliseur.php?anatrolliseur=v8"
  11277. +"|r="+race.toLowerCase()
  11278. +"|dla="+amelio_dtb(dtb)
  11279. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  11280. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  11281. +"|att="+amelio_att+","+attbp+","+attbm
  11282. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  11283. +"|deg="+amelio_deg+","+degbp+","+degbm
  11284. +"|reg="+amelio_reg+","+regbp+","+regbm
  11285. +"|arm="+amelio_arm+","+armbp+","+armbm
  11286. +"|mm="+mmtotale
  11287. +"|rm="+rmtotale+"|";
  11288. }
  11289.  
  11290. function saveProfil() {
  11291. MY_setValue(idtroll+'.caracs.attaque',att);
  11292. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  11293. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  11294. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  11295. if(atttourD||atttour) {
  11296. var DAttBonus = atttourD + Math.floor((att+atttourD)*atttour/100);
  11297. MY_setValue(idtroll+'.bonus.DAttM',DAttBonus);
  11298. } else {
  11299. MY_removeValue(idtroll+'.bonus.DAttM');
  11300. }
  11301. MY_setValue(idtroll+'.caracs.esquive',esq);
  11302. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  11303. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  11304. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  11305. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  11306. MY_setValue(idtroll+'.caracs.degats',deg);
  11307. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  11308. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  11309. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  11310. if(degtour) {
  11311. var DDegBonus = Math.floor(deg*degtour/100);
  11312. MY_setValue(idtroll+'.bonus.DDeg',DDegBonus);
  11313. } else {
  11314. MY_removeValue(idtroll+'.bonus.DDeg');
  11315. }
  11316. MY_setValue(idtroll+'.caracs.regeneration',reg);
  11317. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  11318. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  11319. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  11320. MY_setValue(idtroll+'.caracs.vue',vue);
  11321. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  11322. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  11323. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  11324. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  11325. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  11326. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  11327. MY_setValue(idtroll+'.caracs.rm',rm);
  11328. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  11329. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  11330. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  11331. MY_setValue(idtroll+'.caracs.mm',mm);
  11332. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  11333. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  11334. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  11335. MY_setValue(idtroll+'.caracs.armure',arm);
  11336. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  11337. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  11338. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  11339. MY_setValue(idtroll+'.position.X',posX);
  11340. MY_setValue(idtroll+'.position.Y',posY);
  11341. MY_setValue(idtroll+'.position.N',posN);
  11342. MY_setValue(idtroll+'.race',race);
  11343. MY_setValue(idtroll+'.niveau',niv);
  11344. MY_setValue(idtroll+'.idguilde',idguilde);
  11345. MY_setValue(idtroll+'.nomguilde',nomguilde);
  11346. }
  11347.  
  11348.  
  11349. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  11350.  
  11351. function setInfosCaracteristiques() {
  11352. // Modification de l'entete
  11353. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  11354. thTotal.innerHTML+='|<i>Moyenne</i>';
  11355. thTotal.title="Moyenne (Moyenne ce tour)";
  11356.  
  11357. // Ajout des informations calculees
  11358. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  11359. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  11360. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  11361.  
  11362. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  11363. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  11364. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  11365.  
  11366. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  11367. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  11368. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  11369.  
  11370. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  11371. var tdRegTotal = trRegeneration.children[5];
  11372. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  11373. // Temps recupere par reg (propale R')
  11374. var regmoyTemp = Math.max(0, regmoy);
  11375. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  11376. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  11377. if (sec != 0) {
  11378. regTitle += " " + sec + " sec";
  11379. }
  11380. trRegeneration.title = regTitle;
  11381.  
  11382. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  11383. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  11384. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  11385.  
  11386. var trRM=document.querySelector("table#caracs #rm").parentElement;
  11387. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  11388. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  11389.  
  11390.  
  11391. var trMM=document.querySelector("table#caracs #mm").parentElement;
  11392. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  11393. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  11394.  
  11395. var tdRefl=document.querySelector("#refl");
  11396. // TODO : prendre en compte bonus/malus D esq du tour ?
  11397. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + esqbp + esqbm;
  11398. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  11399. }
  11400.  
  11401. function setLienAnatrolliseur(){
  11402. var pTableAmelio = document.querySelector("#carac>div>p");
  11403. pTableAmelio.innerHTML+=" - ";
  11404. var aElt = document.createElement("a");
  11405. aElt.setAttribute("href",urlAnatrolliseur);
  11406. aElt.setAttribute("target","_blank");
  11407. aElt.className="AllLinks";
  11408. aElt.innerHTML="Anatrolliser";
  11409. pTableAmelio.appendChild(aElt);
  11410. }
  11411. function setInfoDescription() {
  11412. var txtDateCrea = (NBjours!=1) ?
  11413. " ("+NBjours+" jours dans le hall)" :
  11414. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  11415. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  11416. }
  11417.  
  11418. function setInfosEtatLieux() {
  11419. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  11420. '?search=position&orderBy=distance&posx='+
  11421. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  11422. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  11423. appendBr(tdPosition);
  11424. var aElt = document.createElement("a");
  11425. aElt.setAttribute("href",urlBricol);
  11426. aElt.setAttribute("target","_blank");
  11427. aElt.className="AllLinks";
  11428. aElt.innerHTML="Lieux à proximité";
  11429. tdPosition.appendChild(aElt);
  11430. }
  11431.  
  11432. function setInfosEtatPV() { // pour AM et Sacro
  11433. var
  11434. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  11435. sec = Math.floor(15000/pvtotal)%60,
  11436. lifebar = document.querySelector("#pos .barre-vie");
  11437. if(sec!=0) { txt += " "+sec+" sec"; }
  11438. if(lifebar) { lifebar.title = txt; }
  11439. if(pvcourant<=0) { return; }
  11440. // Difference PV p/r a equilibre de temps (propale R')
  11441. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  11442. // ***INIT GLOBALE*** pvdispo
  11443. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11444. var span = document.createElement("span");
  11445. span.title = txt;
  11446. span.style.fontStyle = "italic";
  11447. if(bmt+pdm>=0) {
  11448. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  11449. } else if(pvdispo>0) {
  11450. txt = "Vous pouvez encore perdre "+
  11451. Math.min(pvdispo,pvcourant)+
  11452. " PV sans malus de temps.";
  11453. } else if(pvdispo<0) {
  11454. txt = "Il vous manque "
  11455. +(-pvdispo)
  11456. +" PV pour ne plus avoir de malus de temps.";
  11457. } else {
  11458. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  11459. }
  11460. appendText(span,txt);
  11461. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  11462. }
  11463.  
  11464. // Complete le cadre "Experience"
  11465. function setInfosExp() {
  11466. var tdNiv = document.querySelector("#exp #niv");
  11467.  
  11468. // Calcul niveau monstre/troll min pour gain PX
  11469. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  11470. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  11471.  
  11472. // Calcul PX restant
  11473. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  11474. if (pxRestant >= 0) {
  11475. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  11476. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  11477. }
  11478.  
  11479. // Calul pi/jour
  11480. var
  11481. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  11482. tdPi = document.querySelector("#exp #pi").parentElement;
  11483. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  11484. tdPi.title = tdPiTotal.title;
  11485.  
  11486. // Rapports meurtres,morts
  11487. var tdKill = document.querySelector("#exp #kill");
  11488. tdKill.setAttribute("colspan", 1);
  11489. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  11490.  
  11491. var tdMort = document.querySelector("#exp #mort");
  11492. tdMort.setAttribute("colspan", 1);
  11493. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  11494.  
  11495. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  11496. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  11497. }
  11498.  
  11499.  
  11500. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  11501.  
  11502. function minParPVsac(fat,bm) {
  11503. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  11504. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  11505. var out = [];
  11506. out[0] = (fat>4) ?
  11507. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  11508. 30;
  11509. if(bm && bm>0) {
  11510. var totalfat=fat+bm;
  11511. out[1] = (totalfat>4) ?
  11512. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  11513. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  11514. }
  11515. return out;
  11516. }
  11517.  
  11518. function toInt(str) {
  11519. str = parseInt(str);
  11520. return (str) ? str : 0;
  11521. }
  11522.  
  11523. function saveLastDLA() {
  11524. // pour les calculs d'AM max
  11525. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  11526. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  11527. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  11528. lastDLA = new Date( StringToDate(str) );
  11529. MY_setValue(numTroll+'.DLA.ancienne',str);
  11530. lastDLAZone.innerHTML = '';
  11531. var b = document.createElement('b');
  11532. b.addEventListener('click',inputMode,false);
  11533. appendText(b,str);
  11534. lastDLAZone.appendChild(b);
  11535. refreshAccel();
  11536. }
  11537.  
  11538. function inputMode() {
  11539. // Edition manuelle lastDLA
  11540. var date;
  11541. if(lastDLA)
  11542. date = new Date( lastDLA );
  11543. else
  11544. date = new Date( DLAaccel );
  11545. lastDLAZone.innerHTML = '';
  11546. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  11547. appendText(lastDLAZone,'/');
  11548. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  11549. appendText(lastDLAZone,'/');
  11550. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  11551. appendText(lastDLAZone,' - ');
  11552. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  11553. appendText(lastDLAZone,':');
  11554. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  11555. appendText(lastDLAZone,':');
  11556. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  11557. appendText(lastDLAZone,' - ');
  11558. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  11559. }
  11560.  
  11561. function setAccel() {
  11562. var
  11563. BMfrais=false,
  11564. fat=fatigue, listeBmFat=[],
  11565. tr, th, insertPt;
  11566.  
  11567. // Creation ligne speciale pour AM dans le cadre "Etat"
  11568. tr = document.createElement('tr');
  11569. th = document.createElement('th');
  11570. appendText(th,'Fatigue et AM',true);
  11571. tr.appendChild(th);
  11572. insertPt = document.createElement('td');
  11573. tr.appendChild(insertPt);
  11574. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  11575.  
  11576. // Est-on en over-DLA ?
  11577. // ***INIT GLOBALE*** overDLA
  11578. overDLA = (HeureServeur>DLA.getTime()+3e5);
  11579. if(overDLA) {
  11580. fat=Math.floor(fatigue/1.25);
  11581. }
  11582.  
  11583. // Gestion des BM de fatigue
  11584. if(bmfatigue>0) {
  11585. // On tente de recuperer les BM de fatigue de la page des BM
  11586. if(MY_getValue(numTroll+'.bm.fatigue')) {
  11587. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  11588. BMmemoire.pop();
  11589. var tour = 0;
  11590. for(var i=0 ; i<BMmemoire.length ; i++) {
  11591. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  11592. while(tour<=parseInt(nbrs[0])) {
  11593. listeBmFat[tour]=parseInt(nbrs[1]);
  11594. tour++;
  11595. }
  11596. }
  11597. }
  11598. if(listeBmFat[0]==bmfatigue) {
  11599. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  11600. BMfrais = true;
  11601. MY_removeValue(numTroll+".bm.fatigue");
  11602. }
  11603. } else {
  11604. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  11605. BMfrais = true;
  11606. }
  11607. if(!BMfrais && bmfatigue>0) {
  11608. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  11609. if(bmfatigue==15) {
  11610. listeBmFat = [15,15,15];
  11611. } else {
  11612. listeBmFat = [30,30,15];
  11613. }
  11614. }
  11615. if(overDLA) {
  11616. // Si on est en over-DLA, on decale les bm d'un tour
  11617. listeBmFat.shift();
  11618. }
  11619. // Tableau des fatigues et accel futures
  11620. var
  11621. minppv = minParPVsac(fat,listeBmFat[0]),
  11622. table, tbody,
  11623. ligneTour, ligneFat, ligneMin,
  11624. col;
  11625. // ***INIT GLOBALE*** minParPV
  11626. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  11627. if(fat>0 || listeBmFat[0]>0) {
  11628. table = document.createElement('table');
  11629. table.className = 'mh_tdborder';
  11630. table.border = 0;
  11631. table.cellSpacing = 1;
  11632. table.cellPadding = 1;
  11633. table.style.textAlign = "center";
  11634. tbody = document.createElement('tbody');
  11635. table.appendChild(tbody);
  11636. insertPt.appendChild(table);
  11637. ligneTour = appendTr(tbody,'mh_tdtitre');
  11638. ligneTour.style.fontWeight = "bold";
  11639. var td = appendTdText(ligneTour,'Tour :',true);
  11640. td.align = 'left';
  11641. ligneFat = appendTr(tbody,'mh_tdpage');
  11642. td = appendTdText(ligneFat,'Fatigue :',true);
  11643. td.className = 'mh_tdtitre';
  11644. td.align = 'left';
  11645. ligneMin = appendTr(tbody,'mh_tdpage');
  11646. td = appendTdText(ligneMin,'1 PV =',true);
  11647. td.className = 'mh_tdtitre';
  11648. td.align = 'left';
  11649. col=0;
  11650. while(col<9 && (fat>0 || listeBmFat[col])) {
  11651. if(col==0) {
  11652. if(overDLA) {
  11653. var i = document.createElement('i');
  11654. appendText(i,'A activer');
  11655. ligneTour.appendChild(i);
  11656. } else {
  11657. appendTdText(ligneTour,'En cours');
  11658. }
  11659. } else {
  11660. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  11661. }
  11662. if(listeBmFat[col]) {
  11663. if(BMfrais || (!overDLA && col==0)) {
  11664. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  11665. appendTdText(ligneMin,minppv[1]+'\'');
  11666. } else {
  11667. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  11668. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  11669. }
  11670. } else {
  11671. appendTdText(ligneFat,fat);
  11672. appendTdText(ligneMin,minppv[0]+'\'');
  11673. }
  11674. col++;
  11675. fat = Math.floor(fat / 1.25);
  11676. minppv = minParPVsac(fat,listeBmFat[col]);
  11677. }
  11678. if(fat>1 || (fat==1 && !overDLA)) {
  11679. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  11680. appendTdText(ligneFat,'-');
  11681. appendTdText(ligneMin,'-');
  11682. }
  11683. col = (overDLA) ?
  11684. Math.max(retourAZero(fatigue)-1,col) :
  11685. Math.max(retourAZero(fatigue),col);
  11686. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  11687. appendTdText(ligneFat,'0');
  11688. appendTdText(ligneMin,'30\'');
  11689. if(!BMfrais && bmfatigue) {
  11690. // si les BM n'ont pas ete rafraichis, on signale:
  11691. appendText(
  11692. insertPt,
  11693. '/!\\ Visitez la page des Bonus/Malus '+
  11694. 'pour mettre à jour votre fatigue. /!\\',
  11695. true
  11696. );
  11697. appendBr(insertPt);
  11698. }
  11699. appendBr(insertPt);
  11700. }
  11701. if(pvcourant<=0) {
  11702. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  11703. return;
  11704. }
  11705. if(fatigue>30) {
  11706. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  11707. return;
  11708. }
  11709. // Setup lastDLAZone
  11710. if(overDLA) {
  11711. // bypass des infos de "menu_FF.js" en cas d'overDLA
  11712. DLAaccel = new Date( DLAsuiv );
  11713. lastDLA = new Date( DLA );
  11714. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  11715. // ***INIT GLOBALE*** pvActuelKastar
  11716. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  11717. appendText(
  11718. insertPt,
  11719. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  11720. true
  11721. );
  11722. appendBr(insertPt);
  11723. } else {
  11724. DLAaccel = new Date( DLA );
  11725. pvActuelKastar = pvcourant;
  11726. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  11727. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  11728. } else {
  11729. lastDLA = false;
  11730. }
  11731. }
  11732. appendText(insertPt,'Dernière DLA enregistrée : ');
  11733. lastDLAZone = document.createElement('span');
  11734. lastDLAZone.style.cursor = 'pointer';
  11735. var b = document.createElement('b');
  11736. b.onclick = inputMode;
  11737. lastDLAZone.appendChild(b);
  11738. insertPt.appendChild(lastDLAZone);
  11739. if(lastDLA) {
  11740. appendText(b,DateToString(lastDLA));
  11741. } else {
  11742. appendText(b,'aucune');
  11743. }
  11744. appendBr(insertPt);
  11745. // Setup maxAMZone et cumulZone
  11746. appendText(insertPt,'Accélération maximale possible : ');
  11747. maxAMZone = document.createElement('b');
  11748. insertPt.appendChild(maxAMZone);
  11749. appendBr(insertPt);
  11750. cumulZone = document.createElement('span');
  11751. insertPt.appendChild(cumulZone);
  11752. refreshAccel();
  11753. }
  11754.  
  11755. function refreshAccel() {
  11756. var pvs, pvsmax;
  11757. // Acceleration pour cumul instantane
  11758. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  11759. if(lastDLA) {
  11760. pvsmax = Math.min(
  11761. pvActuelKastar-1,
  11762. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  11763. );
  11764. maxAMZone.innerHTML = pvsmax+" PV";
  11765. } else {
  11766. pvsmax = pvActuelKastar-1;
  11767. maxAMZone.innerHTML = "inconnue";
  11768. }
  11769. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  11770. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  11771. cumulZone.innerHTML = '';
  11772. if(pvs<=pvsmax) {
  11773. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  11774. appendText(cumulZone,pvs+' PV', true);
  11775. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  11776. if(pvs!=1) {
  11777. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  11778. -(pvs-1)*60*minParPV;
  11779. appendText(
  11780. cumulZone,
  11781. ' ('+(pvs-1)+' PV dans '+
  11782. Math.floor(gainSec/60)+'min'+
  11783. addZero(gainSec%60)+'s)'
  11784. );
  11785. }
  11786. } else {
  11787. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  11788. appendText(
  11789. cumulZone,
  11790. 'Après votre accélération maximale, il vous faudra encore attendre '+
  11791. dureeHM(avantDLA/6e4)+
  11792. ' avant de réactiver.'
  11793. );
  11794. }
  11795. }
  11796.  
  11797.  
  11798. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  11799.  
  11800. function traitementTalents() {
  11801. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  11802. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  11803. removeAllTalents();
  11804. var totalComp = injecteInfosBulles(trCompetence,'competences');
  11805. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  11806. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  11807. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  11808. }
  11809.  
  11810. function injecteInfosBulles(liste,fonction) {
  11811. var totalpc = 0;
  11812. // on parse la liste des talents du type 'fonction'
  11813. for(var i=0 ; i<liste.length ; i++) {
  11814. var
  11815. trTalent=liste[i],
  11816. node=trTalent.cells[1].querySelector('a'),
  11817. nomTalent=epure(trim(node.textContent)),
  11818. indiceTDniveaux=7,
  11819. indiceTDSousCompetence=2,
  11820. sousCompetences=undefined;
  11821. if(fonction=="competences"){
  11822. // un TD en plus pour des information complementaire liees a la comp
  11823. indiceTDniveaux++;
  11824. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  11825. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  11826. for (var j=0; j < sousCompetences.length; j++) {
  11827. sousCompetences[j] = sousCompetences[j].epure().trim();
  11828. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  11829. }
  11830. }
  11831. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  11832. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  11833. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  11834. totalpc += niveauxMaitrisesTalentArray[1];
  11835.  
  11836. // stockage des niveaux inferieurs du talent si presents
  11837. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  11838. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  11839. totalpc+=niveauxMaitrisesTalentArray[j+1];
  11840. }
  11841. }
  11842. return totalpc;
  11843. }
  11844.  
  11845. function setInfos(node,nom,fonction,niveau) {
  11846. node.nom = nom;
  11847. node.fonction = fonction;
  11848. node.niveau = niveau;
  11849. node.onmouseover = setBulle;
  11850. node.onmouseout = cacherBulle;
  11851. }
  11852.  
  11853. var arrayModifAnatroll = {
  11854. 'Glue':'Glu',
  11855. 'PuM':'PuiM',
  11856. 'HE':'Hurlement',
  11857. //'Insultes':'Insu',
  11858. 'Pistage':'Pist',
  11859. 'PuC':'Planter'
  11860. }
  11861.  
  11862. function setTalent(nom,pc,niveau,sousCompetences) {
  11863. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  11864. // (et pas les % dont osf) ne serait pas plus rentable
  11865. var nomEnBase = arrayTalents[epure(nom)];
  11866. if(!nomEnBase) {
  11867. debugMZ("setTalent: le talent "+nom+" n'est pas dans la base MZ");
  11868. return;
  11869. }
  11870. if(!niveau) { niveau = 1; }
  11871. switch(nomEnBase) {
  11872. case 'Insultes':
  11873. urlAnatrolliseur += 'Insu'+niveau+'|';
  11874. case 'IdT':
  11875. nomEnBase += niveau;
  11876. break;
  11877. case 'Golemo':
  11878. case 'Piege':
  11879. for (var i=0 ; i < sousCompetences.length ; i++) {
  11880. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  11881. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  11882. }
  11883. break;
  11884. case 'AP':
  11885. case 'Baroufle':
  11886. case 'CdB':
  11887. case 'CdM':
  11888. case 'Parer':
  11889. case 'Retraite':
  11890. case 'RB':
  11891. case 'SInterposer':
  11892. nomEnBase += niveau;
  11893. default:
  11894. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  11895. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  11896. }
  11897. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  11898. }
  11899.  
  11900. function creerBulleVide() {
  11901. var table = document.createElement('table');
  11902. table.id = 'bulle';
  11903. table.className = 'mh_tdborder';
  11904. table.width = 300;
  11905. table.border = 0;
  11906. table.cellPadding = 5;
  11907. table.cellSpacing = 1;
  11908. table.style =
  11909. 'position:absolute;'
  11910. +'visibility:hidden;'
  11911. +'z-index:800;'
  11912. +'height:auto;';
  11913. var tr = appendTr(table,'mh_tdtitre');
  11914. appendTdText(tr,'Titre');
  11915. tr = appendTr(table,'mh_tdpage');
  11916. appendTdText(tr,'Contenu');
  11917. var aList = document.getElementsByTagName('a');
  11918. aList[aList.length-1].parentNode.appendChild(table);
  11919. }
  11920.  
  11921. function cacherBulle() {
  11922. if(bulleStyle)
  11923. bulleStyle.visibility = 'hidden';
  11924. }
  11925.  
  11926. function setBulle(evt) {
  11927. var nom = this.nom;
  11928. var fonction = this.fonction;
  11929. var niveau = parseInt(this.niveau);
  11930. var str='';
  11931. if(fonction=='competences'){
  11932. str=competences(nom,niveau);
  11933. } else if(fonction=='sortileges') {
  11934. str=sortileges(nom);
  11935. }
  11936. if(str=='') return;
  11937. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  11938. var xfenetre, yfenetre, xpage, ypage, element = null;
  11939. var offset = 15;
  11940. var bulleWidth = 300;
  11941. if(!hauteur) hauteur = 50;
  11942. element = document.getElementById('bulle');
  11943. xfenetre = evt.clientX;
  11944. yfenetre = evt.clientY;
  11945. xpage = xfenetre;
  11946. ypage = yfenetre;
  11947. if(evt.pageX) xpage = evt.pageX;
  11948. if(evt.pageY) ypage = evt.pageY;
  11949. if(element) {
  11950. bulleStyle = element.style;
  11951. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  11952. element.childNodes[1].firstChild.innerHTML = str;
  11953. }
  11954. if(bulleStyle) {
  11955. if(xfenetre>bulleWidth+offset)
  11956. xpage -= bulleWidth+offset;
  11957. else
  11958. xpage += offset;
  11959. if(yfenetre>hauteur+offset)
  11960. ypage -= hauteur + offset;
  11961. bulleStyle.width = bulleWidth;
  11962. bulleStyle.left = xpage + 'px';
  11963. bulleStyle.top = ypage + 'px';
  11964. bulleStyle.visibility = 'visible';
  11965. }
  11966. }
  11967.  
  11968.  
  11969. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  11970.  
  11971. function competences(comp,niveau) {
  11972. var
  11973. modA = atttour?Math.floor((att+atttourD)*atttour/100):0,
  11974. modD = degtour?Math.floor(deg*degtour/100):0,
  11975. texte = "";
  11976. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  11977. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  11978. if(minParPV>1) texte += 's';
  11979. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  11980. } else if(comp.indexOf("Attaque Precise")!=-1) {
  11981. var
  11982. i, pc,
  11983. lastmax=0,
  11984. jetatt, espatt=0,
  11985. notMaxedOut = false;
  11986. for(i=niveau ; i>0 ; i--) {
  11987. pc = getTalent(comp,i);
  11988. if(lastmax!=0 && pc<=lastmax) {
  11989. // Si %AP(i)<%AP(i+1), on passe AP(i)
  11990. continue;
  11991. }
  11992. jetatt = Math.round(3.5*(
  11993. Math.min(Math.floor(1.5*att), att+3*i) + modA
  11994. )) + attbp+attbm;
  11995. espatt += (pc-lastmax)*jetatt;
  11996. texte += "Attaque niv. "+i +
  11997. " ("+(pc-lastmax)+"%) : <b>" +
  11998. Math.min(Math.floor(att*1.5), att+3*i)+"</b> D6 ";
  11999. if(modA) {
  12000. texte += "<i>"+aff(modA)+"D6</i> ";
  12001. }
  12002. texte += aff(attbp+attbm)+" => <b>"+jetatt+"</b><br>";
  12003. lastmax = pc;
  12004. if(i<niveau) {
  12005. // Si l'un des % de niveau inf est > % nivmax,
  12006. // on affiche l'espérance à la fin
  12007. notMaxedOut = true;
  12008. }
  12009. }
  12010. if(notMaxedOut) {
  12011. texte += "<i>Attaque moyenne (si réussite) : <b>" +
  12012. Math.floor(10*espatt/lastmax)/10+"</b></i><br>";
  12013. }
  12014. texte += "Dégâts : <b>"+deg+"</b> D3 ";
  12015. if(modD) {
  12016. texte += "<i>"+aff(modD)+"D3</i> ";
  12017. }
  12018. texte += aff(degbp+degbm) +
  12019. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  12020. } else if(comp.indexOf("Balayage")!=-1) {
  12021. texte = "Déstabilisation : <b>"+att+"</b> D6 ";
  12022. if(modA) {
  12023. texte += "<i>"+aff(modA)+"D6</i> ";
  12024. }
  12025. texte += aff(attbp+attbm) +
  12026. " => <b>"+attmoytour+"</b><br>" +
  12027. "Effet : <b>Met à terre l'adversaire</b>";
  12028. } else if(comp.indexOf('Bidouille')!=-1)
  12029. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  12030. +'de votre inventaire avec le texte de votre choix.';
  12031. else if(comp.indexOf('Baroufle')!=-1){
  12032. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  12033. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  12034. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  12035. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  12036. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  12037. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  12038. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  12039. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  12040. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  12041. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  12042. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  12043. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  12044. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  12045. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  12046. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  12047. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  12048. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  12049. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  12050. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  12051. '</tbody></table>';
  12052. } else if(comp.indexOf("Botte Secrete")!=-1) {
  12053. modA = atttour?Math.floor(Math.floor(2*att/3)*atttour/100):0;
  12054. modD = degtour?Math.floor(Math.floor(att/2)*degtour/100):0;
  12055. texte = "Attaque : <b>"+Math.floor(2*att/3)+"</b> D6 ";
  12056. if(modA) {
  12057. texte += "<i>"+aff(modA)+"D6</i> ";
  12058. }
  12059. texte += aff(Math.floor((attbp+attbm)/2)) +
  12060. " => <b>"+Math.round(
  12061. 3.5*(Math.floor(2*att/3)+modA)+Math.floor((attbp+attbm)/2)
  12062. )+"</b><br/>Dégâts : <b>"+Math.floor(att/2)+"</b> D3 ";
  12063. if(modD) {
  12064. texte += "<i>"+aff(modD)+"D3</i> ";
  12065. }
  12066. texte += aff(Math.floor((degbp+degbm)/2))+" => <b>" +
  12067. (2*(Math.floor(att/2)+modD)+Math.floor((degbp+degbm)/2)) +
  12068. "/"+(
  12069. 2*(Math.floor(1.5*Math.floor(att/2))+modD) +
  12070. Math.floor((degbp+degbm)/2)
  12071. )+"</b>";
  12072. } else if(comp.indexOf('Camouflage')!=-1) {
  12073. var camou = getTalent('Camouflage');
  12074. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  12075. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  12076. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  12077. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  12078. } else if(comp.indexOf("Charger")!=-1) {
  12079. if(pvcourant<=0) {
  12080. // N'est plus censé se produire : activation obligatoire si mort
  12081. return "<i>On ne peut charger personne quand on est mort !</i>";
  12082. }
  12083. var portee = Math.min(
  12084. Math.max(
  12085. getPortee__Profil(reg+Math.floor(pvcourant/10)) -
  12086. Math.floor((fatigue+bmfatigue)/5),
  12087. 1
  12088. ),
  12089. vuetotale
  12090. );
  12091. if(portee<1) {
  12092. return "<b>Impossible de charger</b>";
  12093. }
  12094. texte = "Attaque : <b>"+att+"</b> D6 ";
  12095. if(modA) {
  12096. texte += "<i>"+aff(modA)+"D6</i> ";
  12097. }
  12098. texte += aff(attbp+attbm) +
  12099. " => <b>"+attmoytour+"</b><br>" +
  12100. "Dégâts : <b>"+deg+"</b> D3 ";
  12101. if(modD) {
  12102. texte += "<i>"+aff(modD)+"D3</i> ";
  12103. }
  12104. texte += aff(degbp+degbm) +
  12105. " => <b>"+degmoytour+"/"+degmoycrittour+"</b><br>" +
  12106. "Portée : <b>"+portee+"</b> case";
  12107. if(portee>1) { texte += "s"; }
  12108. } else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  12109. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  12110. if(vuetotale>1) texte += 's';
  12111. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  12112. if(vuetotale>2) texte += 's';
  12113. }
  12114. else if(comp.indexOf('Piege')!=-1) {
  12115. if(comp.indexOf('Glue')!=-1)
  12116. texte = 'Et si vous colliez vos adversaires au sol ?';
  12117. if(comp.indexOf('Feu')!=-1) {
  12118. if(texte){
  12119. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  12120. }
  12121. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  12122. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  12123. }
  12124. } else if(comp.indexOf("Contre-Attaquer")!=-1) {
  12125. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  12126. texte = "Attaque : <b>"+Math.floor(att/2)+"</b> D6 ";
  12127. if(modA) {
  12128. texte += "<i>"+aff(modA)+"D6</i> ";
  12129. }
  12130. texte += aff(Math.floor((attbp+attbm)/2)) +
  12131. " => <b>"+Math.round(
  12132. 3.5*(Math.floor(att/2)+modA)+Math.floor((attbp+attbm)/2)
  12133. )+"</b><br>" +
  12134. "Dégâts : <b>"+deg+"</b> D3 ";
  12135. if(modD) {
  12136. texte += "<i>"+aff(modD)+"D3</i> ";
  12137. }
  12138. texte += aff(degbp+degbm) +
  12139. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  12140. } else if(comp.indexOf("Coup de Butoir")!=-1) {
  12141. var
  12142. i, pc,
  12143. lastmax=0,
  12144. jetdeg, espdeg=0,
  12145. notMaxedOut = false;
  12146. texte = "Attaque : <b>"+att+"</b> D6 ";
  12147. if(modA) {
  12148. texte += "<i>"+aff(modA)+"D6</i> ";
  12149. }
  12150. texte += aff(attbp+attbm) +
  12151. " => <b>"+attmoytour+"</b>";
  12152. for(i=niveau ; i>0 ; i--) {
  12153. pc = getTalent(comp,i);
  12154. if(lastmax!=0 && pc<=lastmax) {
  12155. // Si %CdB(i)<%CdB(i+1), on passe CdB(i)
  12156. continue;
  12157. }
  12158. jetdeg = 2*(
  12159. Math.min(Math.floor(1.5*deg), deg+3*i) + modD
  12160. ) + degbp+degbm;
  12161. espdeg += (pc-lastmax)*jetdeg;
  12162. texte += "<br>Dégâts niv. "+i+" ("+(pc-lastmax)+"%) : <b>" +
  12163. Math.min(Math.floor(deg*1.5),deg+3*i)+"</b> D3 ";
  12164. if(modD) {
  12165. texte += "<i>"+aff(modD)+"D3</i> ";
  12166. }
  12167. texte += aff(degbp+degbm) +
  12168. " => <b>"+jetdeg +
  12169. "/"+(jetdeg+2*Math.floor(deg/2))+"</b>";
  12170. lastmax = pc;
  12171. if(i<niveau) {
  12172. // Si l'un des % de niveau inf est > % nivmax,
  12173. // on affiche l'espérance à la fin
  12174. notMaxedOut = true;
  12175. }
  12176. }
  12177. if(notMaxedOut) {
  12178. texte += "<br><i>Dégâts moyens (si réussite) : <b>" +
  12179. Math.floor(10*espdeg/lastmax)/10+"/" +
  12180. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2)) +
  12181. "</b></i>";
  12182. }
  12183. } else if(comp.indexOf('Course')!=-1)
  12184. texte = 'Déplacement gratuit : <b>'
  12185. +Math.floor(getTalent('Course')/2)
  12186. +' %</b> de chance';
  12187. else if(comp.indexOf('Deplacement Eclair')!=-1)
  12188. texte = 'Permet d\'économiser <b>1</b> PA '
  12189. +'par rapport au déplacement classique';
  12190. else if(comp.indexOf('Dressage')!=-1)
  12191. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  12192. +'ou un gnu sauvage.';
  12193. else if(comp.indexOf('Ecriture Magique')!=-1)
  12194. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  12195. +'la formule nécessite de réunir les composants de cette formule, '
  12196. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  12197. +'un champignon adéquat pour confectionner l\'encre.';
  12198. else if(comp.indexOf('Frenesie')!=-1) {
  12199. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  12200. +' => <b>'+attmoy+'</b><br/>'
  12201. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  12202. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  12203. }
  12204. else if(comp.indexOf('Golem')!=-1)
  12205. texte = 'Animez votre golem en assemblant divers matériaux '
  12206. +'autour d\'un cerveau minéral.'
  12207. else if(comp.indexOf('Grattage')!=-1) {
  12208. texte = 'Permet de confectionner un Parchemin Vierge '
  12209. +'à partir de composants et de Gigots de Gob\'.';
  12210. }
  12211. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  12212. texte = 'Fait fuir un monstre si tout se passe bien.'
  12213. +'<br/>Lui donne de gros bonus sinon...';
  12214. else if(comp.indexOf('Identification des Champignons')!=-1) {
  12215. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  12216. if(vuetotale>2) texte += 's';
  12217. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  12218. if(vuetotale>4) texte += 's';
  12219. }
  12220. else if(comp.indexOf('Insultes')!=-1)
  12221. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  12222. else if(comp.indexOf('interposer')!=-1)
  12223. texte = 'Jet de réflexe : <b>'
  12224. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  12225. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  12226. else if(comp.indexOf('Lancer de Potions') != -1)
  12227. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  12228. else if(comp.indexOf('Marquage')!=-1)
  12229. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  12230. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  12231. +'se trouver dans la même caverne que le monstre pour le marquer.';
  12232. else if(comp.indexOf('Melange Magique')!=-1)
  12233. texte = 'Cette Compétence permet de combiner deux Potions pour '
  12234. +'en réaliser une nouvelle dont l\'effet est la somme '
  12235. +'des effets des potions initiales.';
  12236. else if(comp.indexOf('Travail de la pierre')!=-1)
  12237. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  12238. +2*vuetotale+'</b> cases</li>'
  12239. +'<li>Portée verticale (officieuse) : <b>'
  12240. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  12241. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  12242. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  12243. else if(comp.indexOf('Necromancie')!=-1)
  12244. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  12245. +'de faire "revivre" ce monstre.';
  12246. else if(comp.indexOf('Painthure de Guerre')!=-1)
  12247. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  12248. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  12249. +'pour s\'inspirer, et laissez parler votre créativité.'
  12250. else if(comp.indexOf("Parer")!=-1) {
  12251. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  12252. texte = "Jet de parade : <b>"+Math.floor(att/2)+"</b> D6 ";
  12253. if(modA) {
  12254. texte += "<i>"+aff(modA)+"D6</i> ";
  12255. }
  12256. texte += aff(Math.floor((attbp+attbm)/2)) +
  12257. " => <b>"+Math.round(
  12258. 3.5*(Math.floor(att/2)+modA) +
  12259. Math.floor((attbp+attbm)/2)
  12260. )+"</b><hr>Equivalent esquive : <b>" +
  12261. (Math.floor(att/2)+esq)+"</b> D6 ";
  12262. if(modA) {
  12263. texte += "<i>"+aff(modA)+"D6</i> ";
  12264. }
  12265. texte += aff(Math.floor((attbp+attbm)/2)+esqbp+esqbm) +
  12266. " => <b>"+(Math.round(
  12267. 3.5*(Math.floor(att/2)+modA+esq) +
  12268. Math.floor((attbp+attbm)/2)
  12269. )+esqbp+esqbm)+"</b></i>";
  12270. } else if(comp.indexOf('Pistage')!=-1)
  12271. texte = 'Portée horizontale : <b>'
  12272. +2*vuetotale+'</b> cases<br/>'
  12273. +'Portée verticale : <b>'
  12274. +2*Math.ceil(vuetotale/2)+'</b> cases';
  12275. else if(comp.indexOf('Planter un Champignon')!=-1)
  12276. texte = 'Planter un Champignon est une compétence qui vous permet de '
  12277. +'créer des colonies d\'une variété donnée de champignon à partir de '
  12278. +'quelques exemplaires préalablement enterrés.';
  12279. else if(comp.indexOf('Regeneration Accrue')!=-1)
  12280. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  12281. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  12282. else if(comp.indexOf('Reparation')!=-1)
  12283. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  12284. +'et réparez vous-même votre matériel !';
  12285. else if(comp.indexOf('Retraite')!=-1)
  12286. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  12287. +'préférable de préparer un repli stratégique pour déconcerter '
  12288. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  12289. +'Quelle intelligence démoniaque.';
  12290. else if(comp.indexOf("RotoBaffe")!=-1) {
  12291. var
  12292. Datt = att, vattbm = attbp+attbm,
  12293. Ddeg = deg, vdegbm = degbp+degbm;
  12294. for(var i=1 ; i<niveau+2 ; i++) {
  12295. texte += "<b>Attaque n°"+i+" :</b><br>" +
  12296. "Attaque : <b>"+Datt+"</b> D6 ";
  12297. if(modA) {
  12298. texte += "<i>"+aff(modA)+"D6</i> ";
  12299. }
  12300. texte += aff(vattbm) +
  12301. " => <b>"+(Math.round(3.5*(Datt+modA))+vattbm)+"</b><br>" +
  12302. "Dégâts : <b>"+Ddeg+"</b> D3 ";
  12303. if(modD) {
  12304. texte += "<i>"+aff(modD)+"D3</i> ";
  12305. }
  12306. texte += aff(vdegbm) +
  12307. " => <b>"+(2*(Ddeg+modD)+vdegbm) +
  12308. "/"+(2*(Math.floor(1.5*Ddeg)+modD)+vdegbm)+"</b>";
  12309. Datt = Math.floor(0.75*Datt);
  12310. modA = atttour?Math.floor((Datt+atttourD)*atttour/100):0;
  12311. vattbm = Math.floor(0.75*vattbm);
  12312. Ddeg = Math.floor(0.75*Ddeg);
  12313. modD = degtour?Math.floor(Ddeg*degtour/100):0;
  12314. vdegbm = Math.floor(0.75*vdegbm);
  12315. if(i<niveau+1) { texte += "<hr>"; }
  12316. }
  12317. } else if(comp.indexOf('Shamaner')!=-1)
  12318. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  12319. +'des monstres en utilisant des champignons (de 1 à 3).';
  12320. return texte;
  12321. }
  12322.  
  12323. function sortileges(sort) {
  12324. var
  12325. // Fonctions utiles uniquement à "sortileges"
  12326. decumul_buff = function(nom,str,buff) {
  12327. // Décumul des sorts de buff (old school)
  12328. var
  12329. txt = "1<sup>ere</sup>"+nom+" : <b>"+str+" +"+buff+"</b>",
  12330. dec = buff,
  12331. total = buff,
  12332. i=1;
  12333. while(i<6) {
  12334. i++;
  12335. dec = Math.floor(coefDecumul(i)*buff);
  12336. if(dec<=1 || i==6) break;
  12337. total += dec;
  12338. txt += "<br/><i>"+i+"<sup>e</sup> "+nom+" : "+
  12339. str+" +"+dec+" (+"+total+")</i>";
  12340. }
  12341. txt += "<br/><i>"+i+"<sup>e</sup> et + : "+str+" +"+dec+"</i>";
  12342. return txt;
  12343. },
  12344. nbrAdX = function(pc) {
  12345. // Détermine le nombre d'AdX actifs à partir du % de D
  12346. switch(Number(pc)) {
  12347. case 0 : return 0;
  12348. case 20: return 1;
  12349. case 33: return 2;
  12350. case 41: return 3;
  12351. case 46: return 4;
  12352. default: return Math.floor((Number(pc)-39)/2);
  12353. }
  12354. },
  12355. decumulPc = function(n) {
  12356. // Détermine le % de D décumulé du n-ième AdX
  12357. switch(Number(n)) {
  12358. case 0: return 0;
  12359. case 1: return 20;
  12360. case 2: return 13;
  12361. case 3: return 8;
  12362. case 4: return 5;
  12363. case 5: return 3;
  12364. default: return 2;
  12365. }
  12366. },
  12367. decumulFixe = function(bm, n) {
  12368. // Détermine le bonus fixe décumulé du n-ième AdX
  12369. switch(Number(n)) {
  12370. case 0: return 0;
  12371. case 1: return Math.max(1,bm);
  12372. case 2: return Math.max(1,Math.round(bm*6.7)/10);
  12373. case 3: return Math.max(1,Math.round(bm*4)/10);
  12374. default: return 1; // Sous les 1 de moyenne même en D6
  12375. }
  12376. },
  12377. texte = "";
  12378. if (sort.indexOf('Analyse Anatomique') != -1) {
  12379. texte = 'Portée horizontale : <b>'
  12380. + Math.floor(vuetotale / 2) + '</b> case';
  12381. if (vuetotale > 3){ texte += 's'; }
  12382. texte += '<br/>Portée verticale : <b>'
  12383. + Math.floor((vuetotale+1)/4)+'</b> case';
  12384. if (vuetotale > 7){ texte += 's'; }
  12385. } else if (sort.indexOf('Armure Etheree') != -1) {
  12386. texte = decumul_buff('AE', 'Armure magique', reg);
  12387. } else if (sort.indexOf("Augmentation")!=-1 && sort.indexOf("Attaque")!=-1) {
  12388. var
  12389. categoriesAdA = {
  12390. "attx1": {
  12391. // Affichage: code MZ (cf arrayTalents)
  12392. "AN": true,
  12393. "AP": "AP1",
  12394. "Balayage": "Balayage",
  12395. "Charge": "Charger",
  12396. "CdB": "CdB1",
  12397. "Frénésie": "Frenesie",
  12398. "RB": "RB1",
  12399. "GdS": "GdS",
  12400. "Siphon": "Siphon"
  12401. },
  12402. "attx2/3": {
  12403. "Botte Secrète": "BS"
  12404. },
  12405. "attx1/2": {
  12406. "CA": "CA",
  12407. "Parer": "Parer1"
  12408. },
  12409. "degx2/3": {
  12410. "Vampirisme": "Vampi"
  12411. },
  12412. "vuex1": {
  12413. "Projectile Magique": "Projo"
  12414. }
  12415. },
  12416. baseAdA = {
  12417. "attx1" : att,
  12418. "attx2/3": Math.floor(2*att/3),
  12419. "attx1/2": Math.floor(att/2),
  12420. "degx2/3": Math.floor(2*deg/3),
  12421. "vuex1" : vue
  12422. },
  12423. pc = atttour,
  12424. pcInit = pc,
  12425. nbrAdA = nbrAdX(pc),
  12426. categorie, talent, newTalent,
  12427. i, DSup, fixe=0;
  12428. i=nbrAdA;
  12429. while(i++<nbrAdA+3) {
  12430. pc += decumulPc(i);
  12431. fixe += decumulFixe(3.5,i);
  12432. if(texte) { texte += "<hr>"; }
  12433. texte += "<b>"+i+"<sup>e</sup> AdA : " +
  12434. aff(pc)+"% de Dés d'attaque :</b><br>";
  12435. for(categorie in categoriesAdA) {
  12436. // On génére la liste: "talent1, talent2"
  12437. DSup = Math.floor(baseAdA[categorie]*pc/100) -
  12438. Math.floor(baseAdA[categorie]*pcInit/100);
  12439. newTalent = false;
  12440. for(var talent in categoriesAdA[categorie]) {
  12441. if(getTalent(categoriesAdA[categorie][talent])) {
  12442. if(newTalent) { texte += ", "; }
  12443. texte += talent;
  12444. newTalent = true;
  12445. }
  12446. }
  12447. if(newTalent) {
  12448. // Si le trõll a au moins un talent dans la catégorie :
  12449. texte += ": <b>+"+DSup+"D6 +"+Math.floor(fixe)+"</b> <i>(+" +
  12450. Math.floor(3.5*DSup+fixe) +")</i><br>";
  12451. }
  12452. }
  12453. }
  12454. } else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1) {
  12455. texte = decumul_buff('AdE', 'Esquive', Math.floor((esq-1)/2));
  12456. } else if (sort.indexOf("Augmentation des Degats")!=-1) {
  12457. var
  12458. categoriesAdD = {
  12459. "attx1/2": {
  12460. "Botte Secrète": "BS"
  12461. },
  12462. "degx1": {
  12463. "AN": true,
  12464. "AP": "AP1",
  12465. "Charge": "Charger",
  12466. "CA": "CA",
  12467. "CdB": "CdB1",
  12468. "Frénésie": "Frenesie",
  12469. "RB": "RB1",
  12470. "Rafale": "Rafale",
  12471. "Vampi": "Vampi"
  12472. },
  12473. "degx1/2": {
  12474. "Griffe du Sorcier": "GdS"
  12475. },
  12476. "vuex1/2": {
  12477. "Projectile Magique": "Projo"
  12478. },
  12479. "regx1": {
  12480. "Siphon des Âmes": "Siphon"
  12481. }
  12482. },
  12483. baseAdD = {
  12484. "attx1/2": Math.floor(att/2),
  12485. "degx1" : deg,
  12486. "degx1/2": Math.floor(deg/2),
  12487. "vuex1/2": Math.floor(vue/2),
  12488. "regx1" : reg
  12489. },
  12490. pc = degtour,
  12491. pcInit = pc,
  12492. nbrAdD = nbrAdX(pc),
  12493. categorie, talent, newTalent,
  12494. i, DSup, fixe=0;
  12495. i=nbrAdD;
  12496. while(i++<nbrAdD+3) {
  12497. pc += decumulPc(i);
  12498. fixe += decumulFixe(2,i);
  12499. if(texte) { texte += "<hr>"; }
  12500. texte += "<b>"+i+"<sup>e</sup> AdD : " +
  12501. aff(pc)+"% de Dés de dégâts :</b><br>";
  12502. for(categorie in categoriesAdD) {
  12503. // On génére la liste: "talent1, talent2"
  12504. DSup = Math.floor(baseAdD[categorie]*pc/100) -
  12505. Math.floor(baseAdD[categorie]*pcInit/100);
  12506. newTalent = false;
  12507. for(var talent in categoriesAdD[categorie]) {
  12508. if(getTalent(categoriesAdD[categorie][talent])) {
  12509. if(newTalent) { texte += ", "; }
  12510. texte += talent;
  12511. newTalent = true;
  12512. }
  12513. }
  12514. if(newTalent) {
  12515. // Si le trõll a au moins un talent dans la catégorie :
  12516. texte += ": <b>+"+DSup+"D3 +"+Math.floor(fixe) +
  12517. "</b> <i>(+"+Math.floor(3.5*DSup+fixe) +
  12518. ")</i><br>";
  12519. }
  12520. }
  12521. }
  12522. } else if(sort.indexOf('Bulle Anti-Magie')!=-1) {
  12523. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  12524. }
  12525. else if(sort.indexOf('Bulle Magique')!=-1){
  12526. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  12527. }
  12528. else if(sort.indexOf('Explosion')!=-1){
  12529. texte = 'Dégâts : <b>'
  12530. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  12531. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  12532. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  12533. }
  12534. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  12535. if(pvcourant<=0)
  12536. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  12537. texte = 'Portée horizontale : <b>'
  12538. +Math.min(1,vuetotale)+'</b> case<br/>'
  12539. +'Dégâts physiques : <b>-'
  12540. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  12541. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  12542. +'Dégâts magiques : <b>-'
  12543. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  12544. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  12545. }
  12546. else if(sort.indexOf('Flash Aveuglant')!=-1){
  12547. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  12548. }
  12549. else if(sort.indexOf('Glue')!=-1) {
  12550. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  12551. if(vuetotale>2) texte += 's';
  12552. } else if(sort.indexOf("Griffe du Sorcier")!=-1) {
  12553. var
  12554. modD =0,
  12555. addVenin = function(type, effet, duree) {
  12556. var
  12557. ret = "<b>Venin "+type+" : </b><br/><b>" +
  12558. effet+"</b> D3" +
  12559. " pendant <b>"+duree+"</b> tour",
  12560. dureeReduite = Math.max(Math.floor(duree/2),1);
  12561. if(duree>1) {
  12562. ret += "s";
  12563. }
  12564. return ret +
  12565. " => <b>"+2*effet+" x "+duree+" = "+2*effet*duree +
  12566. "</b> ("+2*effet+" x "+dureeReduite+" = " +
  12567. 2*effet*dureeReduite+")";
  12568. },
  12569. effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  12570. // Frappe
  12571. texte = "Attaque : <b>"+att+"</b> D6 ";
  12572. if(atttour!=0) {
  12573. modD = Math.floor(att*atttour/100);
  12574. texte += "<i>"+aff(modD)+"D6</i> ";
  12575. }
  12576. texte += aff(attbm)
  12577. +" => <b>"+(Math.round(3.5*(att+modD))+attbm)+"</b><br/>"
  12578. +"Dégâts : <b>"+Math.floor(deg/2)+"</b> D3 ";
  12579. if(degtour!=0) {
  12580. modD = Math.floor(Math.floor(deg/2)*degtour/100);
  12581. texte += "<i>"+aff(modD)+"D3</i> ";
  12582. } else {
  12583. modD = 0;
  12584. }
  12585. texte += aff(degbm) +
  12586. " => <b>"+(2*(Math.floor(deg/2)+modD)+degbm) +
  12587. "/"+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm) +
  12588. " ("+resiste(Math.floor(deg/2)+modD,degbm) +
  12589. "/"+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm) +
  12590. ")</b>";
  12591. // Venins
  12592. texte += "<hr>"+addVenin("insidieux",effet,2+Math.floor(vue/5));
  12593. effet = Math.floor(1.5*effet);
  12594. texte += "<hr>"+addVenin("virulent",effet,1+Math.floor(vue/10));
  12595. } else if(sort.indexOf('Hypnotisme')!=-1)
  12596. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  12597. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  12598. else if(sort.indexOf('Identification des tresors')!=-1)
  12599. texte = 'Permet de connaitre les caractéristiques et effets précis '
  12600. +'d\'un trésor.';
  12601. else if(sort.indexOf('Invisibilite')!=-1)
  12602. texte = 'Un troll invisible est indétectable même quand on se trouve '
  12603. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  12604. +'fait disparaître l\'invisibilité.';
  12605. else if(sort.indexOf('Levitation')!=-1)
  12606. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  12607. +'Comme les pièges ou les trous par exemple...';
  12608. else if(sort.indexOf("Projectile Magique")!=-1) {
  12609. var
  12610. modD = 0,
  12611. portee = getPortee__Profil(vuetotale);
  12612. // Att
  12613. texte = "Attaque : <b>"+vue+"</b> D6 ";
  12614. if(atttour!=0) {
  12615. modD = Math.floor(vue*atttour/100);
  12616. texte += "<i>"+aff(modD)+"D6</i> ";
  12617. }
  12618. texte += aff(attbm) +
  12619. " => <b>"+(Math.round(3.5*(vue+modD))+attbm)+"</b><br>" +
  12620. "Dégâts : <b>"+Math.floor(vue/2)+"</b> D3 ";
  12621. // Deg
  12622. if(degtour!=0) {
  12623. modD = Math.floor(Math.floor(vue/2)*degtour/100);
  12624. texte += "<i>"+aff(modD)+"D3</i> ";
  12625. } else {
  12626. modD = 0;
  12627. }
  12628. texte += aff(degbm) +
  12629. " => <b>"+(2*(Math.floor(vue/2)+modD)+degbm) +
  12630. "/"+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm) +
  12631. " ("+resiste(Math.floor(vue/2)+modD,degbm) +
  12632. "/"+resiste(1.5*Math.floor(vue/2)+modD,degbm) +
  12633. ") (+ 1D3 par bonus de portée)</b>";
  12634. // Portée
  12635. texte += "<br/>Portée : <b>"+portee+"</b> case";
  12636. if(portee>1) texte += "s";
  12637. } else if(sort.indexOf('Projection')!=-1) {
  12638. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  12639. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  12640. +'Si le jet de résistance de la victime est réussi:<br/>'
  12641. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  12642. } else if(sort.indexOf("Rafale Psychique")!=-1) {
  12643. var modD = 0;
  12644. texte = "Dégâts : <b>"+deg+"</b> D3 ";
  12645. if(degtour!=0) {
  12646. modD = Math.floor(deg*degtour/100);
  12647. texte += "<i>"+aff(modD)+"D3</i> ";
  12648. }
  12649. texte += aff(degbm) +
  12650. " => <b>"+(2*(deg+modD)+degbm) +
  12651. " ("+resiste(deg+modD,degbm)+")</b><br>" +
  12652. "Malus : régénération <b>-"+(deg+modD)+"</b>";
  12653. } else if(sort.indexOf("Sacrifice")!=-1) {
  12654. if(pvcourant<=0) {
  12655. // N'est plus censé se produire : activation obligatoire si mort
  12656. return "<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>";
  12657. }
  12658. var
  12659. perteSacro = function(sac) {
  12660. return " (-"+(sac+2*(1+Math.floor(sac/5)))+" PV)";
  12661. },
  12662. sac = Math.floor((pvcourant-1)/2),
  12663. pvdispoSansMalusTemps =
  12664. pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  12665. texte = "Portée horizontale : <b>" +
  12666. Math.min(1,vuetotale)+"</b> case<br>" +
  12667. "Soin maximal : <b>"+sac+"</b> PV"+perteSacro(sac);
  12668. // Sacros max et optimal sans malus (propale R')
  12669. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  12670. if(sac>0) {
  12671. texte += "<hr>Soin maximum limitant les risques de malus " +
  12672. "de temps : <b>" +sac+"</b> PV"+perteSacro(sac);
  12673. } else {
  12674. texte += "<hr>Vous ne pouvez pas compenser de blessures " +
  12675. "dues à un sacrifice";
  12676. }
  12677. } else if(sort.indexOf("Siphon")!=-1) {
  12678. var modD = 0;
  12679. texte = "Attaque : <b>"+att+"</b> D6 ";
  12680. if(atttour!=0) {
  12681. modD = Math.floor(att*atttour/100);
  12682. texte += "<i>"+aff(modD)+"D6</i> ";
  12683. }
  12684. texte += aff(attbm) +
  12685. " => <b>"+Math.round(3.5*(att+modD)+attbm)+"</b><br>" +
  12686. "Dégâts : <b>"+reg+"</b> D3 ";
  12687. if(degtour!=0) {
  12688. modD = Math.floor(reg*degtour/100);
  12689. texte += "<i>"+aff(modD)+"D3</i> ";
  12690. } else {
  12691. modD = 0;
  12692. }
  12693. texte += aff(degbm) +
  12694. " => <b>"+(2*(reg+modD)+degbm) +
  12695. "/" + (2*(Math.floor(1.5*reg)+modD)+degbm) +
  12696. " ("+resiste(reg+modD,degbm) +
  12697. "/"+resiste(1.5*reg+modD,degbm)+")</b>";
  12698. texte += "<br>Nécrose : attaque magique <b>-"+(reg+modD)+"</b>";
  12699. } else if(sort.indexOf('Telekinesie')!=-1) {
  12700. texte = 'Portée horizontale :';
  12701. var vt = Math.floor(vuetotale/2)+2;
  12702. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  12703. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  12704. for(var i=0 ; i<5 ; i++) {
  12705. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  12706. if(vt>1) texte += 's';
  12707. vt=Math.max(0,vt-1);
  12708. }
  12709. }
  12710. else if(sort.indexOf('Teleportation')!=-1) {
  12711. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  12712. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  12713. var pmh = (20+vue+portee);
  12714. var pmv = 3+Math.floor(portee/3);
  12715. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  12716. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  12717. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  12718. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  12719. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  12720. } else if(sort.indexOf('Vampirisme')!=-1) {
  12721. var modD = 0;
  12722. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  12723. if(atttour!=0) {
  12724. modD = Math.floor(Math.floor(2*deg/3)*atttour/100);
  12725. texte += '<i>'+aff(modD)+'D6</i> ';
  12726. }
  12727. texte += aff(attbm) +
  12728. ' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm) +
  12729. '</b><br/>Dégâts : <b>'+deg+'</b> D3 ';
  12730. if(degtour!=0) {
  12731. modD = Math.floor(deg*degtour/100);
  12732. texte += '<i>'+aff(modD)+'D3</i> ';
  12733. } else {
  12734. modD = 0;
  12735. }
  12736. texte += aff(degbm) +
  12737. ' => <b>'+(2*(deg+modD)+degbm) +
  12738. '/'+(2*(Math.floor(1.5*deg)+modD)+degbm) +
  12739. ' ('+resiste(deg+modD,degbm) +
  12740. '/'+resiste(1.5*deg+modD,degbm)+')</b>';
  12741. } else if(sort.indexOf('Vision Accrue')!=-1)
  12742. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  12743. else if(sort.indexOf('Vision lointaine')!=-1)
  12744. texte = 'En ciblant une zone située n\'importe où dans le '
  12745. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  12746. else if(sort.indexOf('Voir le Cache')!=-1)
  12747. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  12748. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  12749. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  12750. +getPortee__Profil(vuetotale)+'</b> cases';
  12751. else if(sort.indexOf('Vue Troublee')!=-1)
  12752. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  12753. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  12754. return texte;
  12755. }
  12756.  
  12757.  
  12758. /*---------------------------------- Main ------------------------------------*/
  12759.  
  12760. function do_profil2()
  12761. {
  12762. try {
  12763. start_script(31);
  12764.  
  12765. extractionDonnees();
  12766. setInfosCaracteristiques();
  12767. setInfoDescription();
  12768. setInfosEtatLieux();
  12769. setInfosEtatPV();
  12770. setInfosExp();
  12771.  
  12772. creerBulleVide();
  12773. traitementTalents();
  12774. setLienAnatrolliseur();
  12775.  
  12776. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  12777. if(race=='Kastar'){ setAccel(); }
  12778. saveProfil();
  12779. displayScriptTime();
  12780. } catch(e) {
  12781. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  12782. window.console.error(traceStack(e, 'profil2'));
  12783. }
  12784. }
  12785.  
  12786. /*******************************************************************************
  12787. * This file is part of Mountyzilla. *
  12788. * *
  12789. * Mountyzilla is free software; you can redistribute it and/or modify *
  12790. * it under the terms of the GNU General Public License as published by *
  12791. * the Free Software Foundation; either version 2 of the License, or *
  12792. * (at your option) any later version. *
  12793. * *
  12794. * Mountyzilla is distributed in the hope that it will be useful, *
  12795. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12796. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12797. * GNU General Public License for more details. *
  12798. * *
  12799. * You should have received a copy of the GNU General Public License *
  12800. * along with Mountyzilla; if not, write to the Free Software *
  12801. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  12802. *******************************************************************************/
  12803.  
  12804. // x~x script_principal
  12805.  
  12806. function isPage(url) {
  12807. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  12808. }
  12809.  
  12810. // x~x md5.js
  12811. /*
  12812. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  12813. * Digest Algorithm, as defined in RFC 1321.
  12814. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  12815. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  12816. * Distributed under the BSD License
  12817. * See http://pajhome.org.uk/crypt/md5 for more info.
  12818. */
  12819.  
  12820. /*
  12821. * Configurable variables. You may need to tweak these to be compatible with
  12822. * the server-side, but the defaults work in most cases.
  12823. */
  12824. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  12825. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  12826. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  12827.  
  12828. /*
  12829. * These are the functions you'll usually want to call
  12830. * They take string arguments and return either hex or base-64 encoded strings
  12831. */
  12832. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  12833. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  12834. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  12835. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  12836. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  12837. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  12838.  
  12839. /*
  12840. * Perform a simple self-test to see if the VM is working
  12841. */
  12842. function md5_vm_test()
  12843. {
  12844. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  12845. }
  12846.  
  12847. /*
  12848. * Calculate the MD5 of an array of little-endian words, and a bit length
  12849. */
  12850. function core_md5(x, len)
  12851. {
  12852. /* append padding */
  12853. x[len >> 5] |= 0x80 << ((len) % 32);
  12854. x[(((len + 64) >>> 9) << 4) + 14] = len;
  12855.  
  12856. var a = 1732584193;
  12857. var b = -271733879;
  12858. var c = -1732584194;
  12859. var d = 271733878;
  12860.  
  12861. for(var i = 0; i < x.length; i += 16)
  12862. {
  12863. var olda = a;
  12864. var oldb = b;
  12865. var oldc = c;
  12866. var oldd = d;
  12867.  
  12868. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  12869. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  12870. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  12871. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  12872. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  12873. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  12874. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  12875. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  12876. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  12877. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  12878. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  12879. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  12880. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  12881. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  12882. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  12883. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  12884.  
  12885. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  12886. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  12887. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  12888. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  12889. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  12890. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  12891. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  12892. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  12893. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  12894. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  12895. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  12896. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  12897. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  12898. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  12899. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  12900. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  12901.  
  12902. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  12903. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  12904. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  12905. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  12906. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  12907. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  12908. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  12909. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  12910. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  12911. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  12912. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  12913. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  12914. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  12915. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  12916. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  12917. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  12918.  
  12919. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  12920. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  12921. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  12922. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  12923. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  12924. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  12925. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  12926. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  12927. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  12928. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  12929. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  12930. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  12931. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  12932. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  12933. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  12934. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  12935.  
  12936. a = safe_add(a, olda);
  12937. b = safe_add(b, oldb);
  12938. c = safe_add(c, oldc);
  12939. d = safe_add(d, oldd);
  12940. }
  12941. return Array(a, b, c, d);
  12942.  
  12943. }
  12944.  
  12945. /*
  12946. * These functions implement the four basic operations the algorithm uses.
  12947. */
  12948. function md5_cmn(q, a, b, x, s, t)
  12949. {
  12950. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  12951. }
  12952. function md5_ff(a, b, c, d, x, s, t)
  12953. {
  12954. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  12955. }
  12956. function md5_gg(a, b, c, d, x, s, t)
  12957. {
  12958. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  12959. }
  12960. function md5_hh(a, b, c, d, x, s, t)
  12961. {
  12962. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  12963. }
  12964. function md5_ii(a, b, c, d, x, s, t)
  12965. {
  12966. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  12967. }
  12968.  
  12969. /*
  12970. * Calculate the HMAC-MD5, of a key and some data
  12971. */
  12972. function core_hmac_md5(key, data)
  12973. {
  12974. var bkey = str2binl(key);
  12975. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  12976.  
  12977. var ipad = Array(16), opad = Array(16);
  12978. for(var i = 0; i < 16; i++)
  12979. {
  12980. ipad[i] = bkey[i] ^ 0x36363636;
  12981. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  12982. }
  12983.  
  12984. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  12985. return core_md5(opad.concat(hash), 512 + 128);
  12986. }
  12987.  
  12988. /*
  12989. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  12990. * to work around bugs in some JS interpreters.
  12991. */
  12992. function safe_add(x, y)
  12993. {
  12994. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  12995. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  12996. return (msw << 16) | (lsw & 0xFFFF);
  12997. }
  12998.  
  12999. /*
  13000. * Bitwise rotate a 32-bit number to the left.
  13001. */
  13002. function bit_rol(num, cnt)
  13003. {
  13004. return (num << cnt) | (num >>> (32 - cnt));
  13005. }
  13006.  
  13007. /*
  13008. * Convert a string to an array of little-endian words
  13009. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  13010. */
  13011. function str2binl(str)
  13012. {
  13013. var bin = Array();
  13014. var mask = (1 << chrsz) - 1;
  13015. for(var i = 0; i < str.length * chrsz; i += chrsz)
  13016. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  13017. return bin;
  13018. }
  13019.  
  13020. /*
  13021. * Convert an array of little-endian words to a string
  13022. */
  13023. function binl2str(bin)
  13024. {
  13025. var str = "";
  13026. var mask = (1 << chrsz) - 1;
  13027. for(var i = 0; i < bin.length * 32; i += chrsz)
  13028. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  13029. return str;
  13030. }
  13031.  
  13032. /*
  13033. * Convert an array of little-endian words to a hex string.
  13034. */
  13035. function binl2hex(binarray)
  13036. {
  13037. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  13038. var str = "";
  13039. for(var i = 0; i < binarray.length * 4; i++)
  13040. {
  13041. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  13042. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  13043. }
  13044. return str;
  13045. }
  13046.  
  13047. /*
  13048. * Convert an array of little-endian words to a base-64 string
  13049. */
  13050. function binl2b64(binarray)
  13051. {
  13052. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  13053. var str = "";
  13054. for(var i = 0; i < binarray.length * 4; i += 3)
  13055. {
  13056. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  13057. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  13058. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  13059. for(var j = 0; j < 4; j++)
  13060. {
  13061. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  13062. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  13063. }
  13064. }
  13065. return str;
  13066. }
  13067.  
  13068. ///////////////////////////////////////////
  13069. // debug cartes capitan Roule 07/12/2016
  13070. ///////////////////////////////////
  13071. // essais : objet
  13072. // .mode : description
  13073. // .essais : tableau d'objets essai
  13074. // .mode : description
  13075. // .essais : tableau de cartes
  13076. // .noCarte : id de la carte
  13077. // .essais : tableau d'essais, [x, y, n, nb]
  13078. function AfficheEssais(essais, sMode) {
  13079. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  13080. if (!eBigDiv) {
  13081. var insertPoint = document.getElementById('footer1');
  13082. eBigDiv = document.createElement('table');
  13083. eBigDiv.id = 'ListeEssaiCapitan';
  13084. insertBefore(insertPoint, document.createElement('p'));
  13085. insertTitle(insertPoint,'Capitan : Liste des essais');
  13086. insertBefore(insertPoint, eBigDiv);
  13087. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  13088. }
  13089. if (!essais) {
  13090. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  13091. return;
  13092. }
  13093. var carte;
  13094. for (carte in essais) {
  13095. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  13096. }
  13097. if (carte === undefined) {
  13098. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  13099. }
  13100. }
  13101.  
  13102. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  13103. var tr = appendTr(eTable);
  13104. var td = appendTd(tr);
  13105. appendText(td, sMode, bBold);
  13106. td = appendTd(tr);
  13107. appendText(td, sCarte, bBold);
  13108. td = appendTd(tr);
  13109. appendText(td, sText, bBold);
  13110. }
  13111.  
  13112. function getEssaiV1_0() {
  13113. try {
  13114. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  13115. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  13116. var tabK, nK;
  13117. prefs.getChildList('', nK, tabK);
  13118. window.console.log('getEssaiV1_0, nb key : ' + nK);
  13119. //window.console.log('getEssaiV1_0, ' + nK);
  13120. return;
  13121. //return r;
  13122. } catch (e) {
  13123. window.console.log(traceStack(e, 'getEssaiV1_0'));
  13124. }
  13125. }
  13126.  
  13127. function getEssaiV1_1() {
  13128. var locSto = window.localStorage;
  13129. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  13130. var r = [];
  13131. for (var i = 0; i < locSto.length; i++) {
  13132. var k = locSto.key(i);
  13133. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  13134. var t = k.split(/\./);
  13135. if (t[0] !== 'capitan') continue;
  13136. if (t[2] !== 'essai') continue;
  13137. var carte = 'carte n°' + t[1];
  13138. if (r[carte]) r[carte]++;
  13139. else r[carte] = 1;
  13140. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  13141. }
  13142. return r;
  13143. }
  13144.  
  13145. function showEssaiCartes() {
  13146. window.console.log('début showEssai Tout_MZ');
  13147. var essais = getEssaiV1_0();
  13148. AfficheEssais(essais, 'V1.0');
  13149. essais = getEssaiV1_1();
  13150. AfficheEssais(essais, 'V1.1');
  13151. window.console.log('fin showEssai Tout_MZ');
  13152. }
  13153.  
  13154. function testBoolLocalStorage() {
  13155. var b = true;
  13156. var key = 'MZ_essai_bool';
  13157. GM_setValue(key, b);
  13158. window.localStorage[key] = b;
  13159. var v = GM_getValue(key);
  13160. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  13161. var v = window.localStorage.getItem(key);
  13162. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  13163.  
  13164. var b = false;
  13165. GM_setValue(key, b);
  13166. window.localStorage[key] = b;
  13167. var v = GM_getValue(key);
  13168. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  13169. var v = window.localStorage.getItem(key);
  13170. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  13171.  
  13172. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  13173. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  13174. var y = GM_getValue('654654897894654654');
  13175. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  13176. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  13177. }
  13178.  
  13179. /*--------------------------------- Création liste trolligion ---------------------------------*/
  13180. function export_trolligion() {
  13181. try {
  13182. var tabDl = document.getElementsByTagName('dl');
  13183. if ((!tabDl) || !tabDl[0]) {
  13184. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  13185. return;
  13186. }
  13187. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  13188. // nom : string
  13189. // rayonnement : entier
  13190. // grades : table d'objets (une occurence par grade)
  13191. // nom : string
  13192. // trolls : table d'objets (un par Trõll)
  13193. // id
  13194. // nom
  13195. // idguilde
  13196. // guilde
  13197. // race
  13198. // niveau
  13199. // ferveur
  13200. var currentDieu;
  13201. var currentGrade;
  13202. for (var iChild1 in tabDl[0].children) {
  13203. var eChild1 = tabDl[0].children[iChild1];
  13204. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  13205. case 'dd': // Trõll
  13206. var oTroll = {};
  13207. export_trolligion_analyse(oTroll, eChild1);
  13208. currentGrade.trolls.push(oTroll);
  13209. break;
  13210. case 'dt':
  13211. var tabH3 = eChild1.getElementsByTagName('h3');
  13212. if (tabH3 && tabH3[0]) { // changement de dieu
  13213. currentDieu = {
  13214. nom: tabH3[0].innerText || tabH3[0].textContent
  13215. , grades: []};
  13216. var txt = eChild1.innerText || eChild1.textContent;
  13217. var m = txt.match(/yon*ement *:* *(\d+)/);
  13218. if (m) currentDieu.rayonnement = parseInt(m[1]);
  13219. currentGrade = undefined;
  13220. tabDieux.push(currentDieu);
  13221. break;
  13222. }
  13223. var tabH4 = eChild1.getElementsByTagName('h4');
  13224. if (tabH4 && tabH4[0]) { // changement de grade
  13225. var grade;
  13226. var txt = tabH4[0].innerText || tabH4[0].textContent;
  13227. tabI = tabH4[0].getElementsByTagName('i');
  13228. if (tabI && tabI[0]) {
  13229. grade = tabI[0].innerText || tabI[0].textContent;
  13230. grade = grade.replace(/"/g, '');
  13231. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  13232. if (m) grade += ' (' + m[1] + ')';
  13233. } else {
  13234. grade = txt.replace(/"/g, '');
  13235. }
  13236. currentGrade = {nom: grade, trolls: []};
  13237. currentDieu.grades.push(currentGrade);
  13238. break;
  13239. }
  13240. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  13241. break;
  13242. default:
  13243. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  13244. }
  13245. }
  13246.  
  13247. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  13248. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  13249. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  13250. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  13251. for (var iDieu in tabDieux) {
  13252. var oDieu = tabDieux[iDieu];
  13253. for (var iGrade in oDieu.grades) {
  13254. var oGrade = oDieu.grades[iGrade];
  13255. for (var iTroll in oGrade.trolls) {
  13256. var oTroll = oGrade.trolls[iTroll];
  13257. var t = [oDieu.nom, oDieu.rayonnement
  13258. , oGrade.nom
  13259. , oTroll.id, oTroll.nom
  13260. , oTroll.idguilde, oTroll.guilde
  13261. , oTroll.race, oTroll.niveau
  13262. , oTroll.ferveur];
  13263. for (var iParam in t) {
  13264. if (t[iParam] === undefined) t[iParam] = ''; // protection
  13265. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  13266. }
  13267. txt += t.join("\t") + "\n";
  13268. }
  13269. }
  13270. var t = [oDieu.nom, oDieu.rayonnement];
  13271. for (var iParam in t) {
  13272. if (t[iParam] === undefined) t[iParam] = ''; // protection
  13273. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  13274. }
  13275. txt2 += t.join("\t") + "\n";
  13276. }
  13277. txt += "\n" + txt2;
  13278. } catch (e) {
  13279. window.alert("Échec à l'extraction\n" + e);
  13280. }
  13281. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  13282. try {
  13283. if (copyTextToClipboard(txt)) {
  13284. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  13285. + "Collez dans Calc\n"
  13286. + "ou, au pire, dans EXCEL®");
  13287. } else {
  13288. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  13289. }
  13290. } catch(e) {
  13291. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  13292. }
  13293. }
  13294.  
  13295. function export_trolligion_analyse(oTroll, eChild1) {
  13296. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  13297. var eChild2 = eChild1.childNodes[iChild2];
  13298. if (eChild2.nodeType === undefined) continue; // properties
  13299. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  13300. switch (eChild2.nodeType) {
  13301. case 1: //ELEMENT_NODE:
  13302. switch (eChild2.nodeName.toLowerCase()) {
  13303. case 'a':
  13304. var m;
  13305. if (!eChild2.href) {
  13306. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  13307. break;
  13308. }
  13309. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  13310. if (m) {
  13311. oTroll.id = parseInt(m[1]);
  13312. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  13313. break;
  13314. }
  13315. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  13316. if (m) {
  13317. var idGuilde = parseInt(m[1]);
  13318. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  13319. oTroll.idguilde = parseInt(m[1]);
  13320. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  13321. }
  13322. break;
  13323. }
  13324. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  13325. break;
  13326. case 'br': // ignore
  13327. case 'style': // ignore
  13328. case 'img': // ignore
  13329. break;
  13330. case 'div': // barre de vie
  13331. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  13332. eChild3 = eChild2.children[0];
  13333. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  13334. var eChild4 = eChild3.children[0];
  13335. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  13336. break;
  13337. }
  13338. }
  13339. //window.console.log(eChild2.innerHTML);
  13340. export_trolligion_analyse(oTroll, eChild2);
  13341. break;
  13342. default:
  13343. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  13344. break;
  13345. }
  13346. break;
  13347. case 3: //TEXT_NODE:
  13348. var txt = eChild2.nodeValue.trim();
  13349. if (txt === '') break;
  13350. var m = txt.match(/(.*) *\((\d+)\)/);
  13351. if (m) {
  13352. oTroll.race = m[1].trim();
  13353. oTroll.niveau = parseInt(m[2]);
  13354. } else {
  13355. oTroll.race = txt;
  13356. }
  13357. break;
  13358. default: // ne devrait pas arriver
  13359. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  13360. break;
  13361. }
  13362. }
  13363. }
  13364.  
  13365. function do_trolligion() {
  13366. var divpopup = document.createElement('div');
  13367. divpopup.id = 'MZ_divCopier';
  13368. divpopup.style.position = 'fixed';
  13369. divpopup.style.top = '2px';
  13370. divpopup.style.left = '2px;';
  13371. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  13372. divpopup.style.cursor = 'pointer';
  13373. divpopup.style.zIndex = 200;
  13374. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  13375. divpopup.onclick = export_trolligion;
  13376. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  13377. divpopup.appendChild(img);
  13378. document.body.appendChild(divpopup);
  13379. }
  13380.  
  13381. /*--------------------------------- Dispatch ---------------------------------*/
  13382.  
  13383. //chargerScriptDev("libs");
  13384. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  13385. //if (isDEV) testBoolLocalStorage();
  13386.  
  13387. // Détection de la page à traiter
  13388. if(isPage("Messagerie/ViewMessageBot")) {
  13389. do_cdmbot();
  13390. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  13391. do_cdmcomp();
  13392. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  13393. do_cdmcomp();
  13394. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  13395. do_cdmcomp();
  13396. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  13397. do_diplo();
  13398. } else if(isPage("MH_Play/Play_equipement")) {
  13399. do_equip();
  13400. } else if(isPage("MH_Play/Play_menu")) {
  13401. do_menu();
  13402. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  13403. do_option();
  13404. //showEssaiCartes();
  13405. } else if(isPage("View/PJView")) {
  13406. do_pjview();
  13407. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  13408. do_profil();
  13409. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  13410. do_tancompo();
  13411. } else if(isPage("MH_Play/Play_vue")) {
  13412. do_vue();
  13413. } else if(isPage("MH_Play/Play_news")) {
  13414. do_news();
  13415. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  13416. do_move();
  13417. } else if(isPage("MH_Missions/Mission_Etape")) {
  13418. do_mission();
  13419. } else if(isPage("View/MonsterView")) {
  13420. do_infomonstre();
  13421. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  13422. do_attaque();
  13423. } else if(isPage("MH_Play/Play_e_follo.php")) {
  13424. do_listegowap();
  13425. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  13426. do_lieuDescription();
  13427. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  13428. do_lieuTeleport();
  13429. } else if(isPage("MH_Follower/FO_Ordres")) {
  13430. do_ordresgowap();
  13431. } else if(isPage("MH_Follower/FO_Equipement")) {
  13432. do_equipgowap();
  13433. } else if(isPage("MH_Play/Play_mouche")) {
  13434. do_mouches();
  13435. } else if(isPage("MH_Play/Play_BM")) {
  13436. do_malus();
  13437. } else if(isPage("MH_Play/Play_evenement")) {
  13438. do_myevent();
  13439. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  13440. do_enchant();
  13441. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  13442. do_pre_enchant();
  13443. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  13444. do_actions();
  13445. } 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')) {
  13446. do_mission_liste();
  13447. } else if(isPage('MH_Play/Play_action')) {
  13448. do_actions();
  13449. } else if(isPage('MH_Play/Play_profil2')) {
  13450. do_profil2();
  13451. } else if(isPage('View/TrolligionView.php')) {
  13452. do_trolligion();
  13453. }
  13454. } catch(e) {
  13455. try {
  13456. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  13457. } catch(e2) {
  13458. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  13459. }
  13460. }