Tout_MZ

Client MountyZilla

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

  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.3.0.15
  11. // @grant GM_getValue
  12. // @grant GM_deleteValue
  13. // @grant GM_setValue
  14. // ==/UserScript==
  15.  
  16. // vérif UTF-8 ş
  17.  
  18. /*******************************************************************************
  19. * This file is part of Mountyzilla. *
  20. * *
  21. * Mountyzilla is free software; you can redistribute it and/or modify *
  22. * it under the terms of the GNU General Public License as published by *
  23. * the Free Software Foundation; either version 2 of the License, or *
  24. * (at your option) any later version. *
  25. * *
  26. * Mountyzilla is distributed in the hope that it will be useful, *
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  29. * GNU General Public License for more details. *
  30. * *
  31. * You should have received a copy of the GNU General Public License *
  32. * along with Mountyzilla; if not, write to the Free Software *
  33. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  34. *******************************************************************************/
  35.  
  36. try {
  37. const MZ_changeLog = [
  38. "V1.3.0.15 10/01/2020",
  39. " Amélioration du support SCIZ (Fix sur les événements de zone)",
  40. "V1.3.0.14 06/01/2020",
  41. " Correction filtre par famille piur les monstres variables et sans cdm",
  42. "V1.3.0.13 06/01/2020",
  43. " Ajout du filtre sur la famille des monstres",
  44. "V1.3.0.12 28/12/2019",
  45. " Fixed bug fix pour SCIZ (JWT)",
  46. "V1.3.0.11 28/12/2019",
  47. " Bug fix pour SCIZ (JWT)",
  48. "V1.3.0.10 22/12/2019",
  49. " Corrections mineures pour SCIZ",
  50. "V1.3.0.9 19/12/2019",
  51. " Amélioration du support SCIZ (Fixes + AdvancedCSS + SwitchEvent)",
  52. "V1.3.0.8 16/12/2019",
  53. " Amélioration du support SCIZ (Fixes + Play_evenement + PJView_Events)",
  54. "V1.3.0.7 12/12/2019",
  55. " correction cibles des missions 'famille', 'pouvoir' et cas particulier de 'race'",
  56. "V1.3.0.6 11/12/2019",
  57. " suppression infobulle sur l'intervalle de confiance s'il n'y en a pas, correction affiche de l'heure dernière CdM, plus de debug en profil de monstre",
  58. "V1.3.0.5 11/12/2019",
  59. " Première interconnexion avec SCIZ (Options + MonsterView)",
  60. "V1.3.0.4 29/11/2019",
  61. " Ajout des déciles",
  62. "V1.3.0.3 29/11/2019",
  63. " Affichage d'une icône pour les Phœnix dont la génération est connue",
  64. "V1.3.0.2 24/11/2019",
  65. " Réduction taille info CdM",
  66. "V1.3.0.1 22/11/2019",
  67. " Ajustements sur les infos tactiques",
  68. "V1.3.0 15/11/2019",
  69. " Refonte calculs tactiques de la vue - beta",
  70. "V1.2.20.6 09/11/2019",
  71. " Correction de la formule d'AdD dans le profil",
  72. "V1.2.20.5 16/10/2019",
  73. " Mutualisation analyse ordres suivants MZ_analyse_page_ordre_suivant",
  74. "V1.2.20.4 03/10/2019",
  75. " Adaptation modif MH de la page des suivants",
  76. "V1.2.20.3 02/09/2019",
  77. " Compétence golem vers l'anatroliseur",
  78. "V1.2.20.2 25/05/2019",
  79. " Gestion des Parasitus pour les missions",
  80. "V1.2.20.1 25/05/2019",
  81. " Correction de la cible en cas de mission demandant un kill de Crasc + message d'alerte en cas de fumeux",
  82. "V1.2.20.0 25/05/2019",
  83. " Adaptation aux modifications des CdM par MH",
  84. "V1.2.19.2 16/04/2019",
  85. " Correction majuscules dans les talents",
  86. "V1.2.19.1 14/04/2019",
  87. " Prise en compte des nouvelles AdX dans profil2",
  88. "V1.2.18.15 29/03/2019",
  89. " Correction simple quote dans toutes les missions",
  90. "V1.2.18.14 09/03/2019",
  91. " Correction affichage vues 2D externes suite à une modif MH",
  92. "V1.2.18.13 27/02/2019",
  93. " Correction simple quote dans les familles de monstre des missions",
  94. "V1.2.18.12 23/12/2018",
  95. " Message si \"Menu d'actions contextuelles\" est décoché",
  96. "V1.2.18.11 21/11/2018",
  97. " Correction it bricol'troll, login avec accent",
  98. "V1.2.18.10 08/08/2018",
  99. " Correction boulette sDiplo",
  100. "V1.2.18.09 04/08/2018",
  101. " Protection contre diplomatie mal initialisée",
  102. "V1.2.18.08 11/07/2018",
  103. " Correction pour fonctionnement hors GM",
  104. "V1.2.18.07 18/05/2018",
  105. " prise en compte bonus magique d'esquive dans le profil, correction gestion de la souris dans la page d'équipement [Dabihul, welcome back]",
  106. "V1.2.18.06 28/01/2018",
  107. " Protection malus Crasc sans durée",
  108. "V1.2.18.05 18/11/2017",
  109. " Désactivation MZ V2 en mode dev pour les tests d'adaptation violentmonkey",
  110. "V1.2.18.04 04/09/2017",
  111. " retour version 1.2.18.02 avec GM 3.17",
  112. "V1.2.18.03 01/09/2017",
  113. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  114. "V1.2.18.02 26/08/2017",
  115. " correction boulette sur le compos d'enchantement",
  116. "V1.2.18.01 25/08/2017",
  117. " Suppression des messages sur les certificats en https",
  118. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  119. "V1.2.17.19 23/08/2017",
  120. " Possibilité de plusieurs IT Bricol'Troll",
  121. "V1.2.17.18 22/08/2017",
  122. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  123. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  124. "V1.2.17.17 16/07/2017",
  125. " modification du mécanisme de filtrage pour contourner un pb",
  126. "V1.2.17.16 16/07/2017",
  127. " Ajout de messages de debug sur les retours AJAX",
  128. "V1.2.17.15 15/07/2017",
  129. " modification du mécanisme de filtrage pour contourner un pb",
  130. "V1.2.17.14 14/07/2017",
  131. " correction dans la gestion des étapes de mission",
  132. "V1.2.17.13 12/07/2017",
  133. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  134. "V1.2.17.12 16/06/2017",
  135. " Correction mauvais compte de PX quand on change de Trõll",
  136. "V1.2.17.11 01/05/2017",
  137. " Travail sur le fonctionnement hors Greasemonkey",
  138. "V1.2.17.10 30/04/2017",
  139. " Protection dans la récupération d'erreur",
  140. "V1.2.17.9 30/04/2017",
  141. " Correction récupération d'erreur IT Bricol'Troll",
  142. "V1.2.17.8 29/04/2017",
  143. " Correction Bonus/Malus cas +0\+10 (AE)",
  144. " Correction portée IdC",
  145. " Prise en compte du bonus de portée PM dans le calcul tactique",
  146. "V1.2.17.7 26/04/2017",
  147. " Version compatible hors GreaseMonkey",
  148. "V1.2.17.6 23/04/2017",
  149. " Correction gestion des missions en cas de réinstallation",
  150. "V1.2.17.5 20/04/2017",
  151. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  152. "V1.2.17.4 08/04/2017",
  153. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  154. " Adaptation de la diplomatie à une modification de la page MH",
  155. "V1.2.17.3 04/04/2017",
  156. " Messages console en cas de cadre d'erreur",
  157. " Trolls de l'IT mais pas dans le vue en orange",
  158. "V1.2.17.2 20/03/2017",
  159. " Correction des PV restants",
  160. "V1.2.17.1 20/03/2017",
  161. " Blocage des PV restants en attendant résolution de bug",
  162. "V1.2.17 19/03/2017",
  163. " Refonte de l'envoi des CdM",
  164. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  165. "V1.2.16.4 08/03/2017",
  166. " correction ID de troll en envoi de PX/MP",
  167. "V1.2.16.3 27/02/2017",
  168. " correction bonus/malus FP",
  169. "V1.2.16.2 24/02/2017",
  170. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  171. "V1.2.16.1 21/02/2017",
  172. " corrige bug sur Fx 38.8 ESR",
  173. "V1.2.16 21/02/2017",
  174. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  175. " possibilité de masquer les Gowaps Sauvages dans la vue",
  176. " calcul des caractéristiques du siphon des âmes",
  177. "V1.2.15.2 02/02/2017",
  178. " adaptation décumul VlC (page des bonus/malus)",
  179. "V1.2.15.1 29/01/2017",
  180. " carte sur la page de description du lieu TP",
  181. "V1.2.15 25/01/2017",
  182. " mise en place des nouvelles cartes (suivants, TP)",
  183. "V1.2.14.3 25/01/2017",
  184. " résumé dans l'export des données Trõlligion",
  185. "V1.2.14.2 20/01/2017",
  186. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  187. "V1.2.14.1 20/01/2017",
  188. " réécriture filtrage des monstres par niveau dans la vue",
  189. " Changelog dans la page des news MZ",
  190. "V1.2.14 20/01/2017",
  191. " Ajout de l'export des données Trõlligion",
  192. "V1.2.13.7 10/01/2017",
  193. " Exclusion Bricoll'troll dans l'entête GM",
  194. "V1.2.13.6 08/01/2017",
  195. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  196. "V1.2.13.5 07/01/2017",
  197. " Correction bug qui se manisfestait sous LINUX",
  198. "V1.2.13.4 07/01/2017",
  199. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  200. "V1.2.13.3 07/01/2017",
  201. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  202. "V1.2.13.2 07/01/2017",
  203. " Correction missions, recherche troogle (familles et types de monstres)",
  204. "V1.2.13.1 06/01/2017",
  205. " Suppression oldSchoolProfile qui n'existe plus",
  206. " Ajout du 'refresh' du cadre de gauche",
  207. "V1.2.13 01/01/2017",
  208. " homogénéisation des messages d'erreur",
  209. " Ajout du lien Troogle sur les étapes de mission monstre",
  210. "V1.2.12.2 30/12/2016",
  211. " retour en mode normal (http si jeu en http)",
  212. "V1.2.12.1 27/12/2016",
  213. " Correction mode IP",
  214. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  215. "V1.2.12 24/12/2016",
  216. " Nettoyage des URL",
  217. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  218. " Interface bricoll'Troll en https",
  219. " Remise en marche des cartes des trajets des gowaps",
  220. "V1.2.11.5 à 7 20 & 21/12/2016",
  221. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  222. "V1.2.11.4 19/12/2016",
  223. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  224. "V1.2.11.3 19/12/2016",
  225. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  226. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  227. "V1.2.11.2 18/12/2016",
  228. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  229. "V1.2.11.1 17/12/2016",
  230. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  231. "V1.2.11 13/12/2016",
  232. " Passage sur BdD Raistlin \\o/",
  233. "V1.2.10.4 12/12/2016",
  234. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  235. "V1.2.10.3 09/12/2016",
  236. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  237. "V1.2.10.2 09/12/2016",
  238. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  239. "V1.2.10.1 08/12/2016",
  240. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  241. "V1.2.10 07/12/2016",
  242. " correction décumul des bonus/malus",
  243. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  244. "V1.2.9 16/11/2016",
  245. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  246. "V1.2.8 10/11/2016",
  247. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  248. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  249. "V1.2.7 07/11/2016",
  250. " remise en route de l'interface avec l'IT bricol'Troll",
  251. "V1.2.6 19/10/2016",
  252. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  253. " stockage idguilde et nomguilde",
  254. "V1.2.5 17/10/2016",
  255. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  256. " remise en route de la gestion des options avec intégration md5 dans ce script",
  257. "V1.2.4 14/10/2016",
  258. " utilisation du relai raistlin pour l'envoi des CdM",
  259. "V1.2.3 :",
  260. " suppression ancien profil",
  261. " nettoyage doublon sur getPortee",
  262. " adaptation portee TP basée sur les PI",
  263. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  264. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  265. "V1.2.1 :",
  266. " include des URLs MH alternatives",
  267. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  268. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  269. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  270. "V1.1 : regroupement en un gros paquet sale",
  271. ];
  272.  
  273. /**********************************************************
  274. À faire / propositions d'évolutions
  275.  
  276. Bireli-Gravos 08/12/2018
  277. FAIT faire un warning si l'utilisateur a désactivé la case "Menu d'actions contextuelles" dans la fenêtre "limiter la vue"
  278. breizhou13 20/12/2016
  279. envoyer les données à l'IT (Bricol'Trolls) aussi
  280. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  281. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  282. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  283. Akkila le boeuf le 26-03-2017 à 15:56
  284. - bouton pour rafraîchir les infos des trolls de son groupe
  285. Roule'
  286. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  287. Réactiver les jubilaires
  288. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  289. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  290. - voir l'intérêt de refaire fonctionner
  291. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  292. FAIT : ambiguité sur le nom de monstres de mission : Shai, Ombre, Geck'oo et Boujd'la
  293. Sans doute à corriger, la compétence Baroufle pour le lien vers l'anatroliseur
  294. Prévision des DLA de monstre
  295. FAIT Niveau des monstres à la méthode Roule'
  296. Raistlin
  297. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  298. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  299. 80117 - Héra
  300. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  301. 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)
  302. FAIT Possibilité de plusieurs systèmes Bricol'troll
  303. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  304. ?
  305. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  306. Alanae/Gnu
  307. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  308. Kali
  309. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  310. **********************************************************/
  311.  
  312. /**********************************************************
  313. **** Début de zone à déplacer dans une bibli commune ******
  314. **********************************************************/
  315.  
  316. // URL de base serveur MZ
  317. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  318. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  319. //var URL_MZ = 'http://192.99.225.92/mz';
  320.  
  321. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  322. // à supprimer
  323. const newCarte = true;
  324. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  325.  
  326. // URLs externes redirection (pas de souci CORS)
  327. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  328. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  329. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  330. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  331. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  332. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  333. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  334. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  335. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  336.  
  337. // URLs de test HTTPS
  338. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  339. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  340.  
  341. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  342. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  343. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  344.  
  345. // x~x Libs
  346.  
  347. /* ancien TODO
  348. * - revoir la gestion des CdM --> nott armure magique
  349. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  350. * - vérfier la gestion des enchants
  351. */
  352.  
  353. // Roule 04/09/2016 switch extern URLs to https if available
  354. var isHTTPS = false;
  355. if (window.location.protocol.indexOf('https') === 0) {
  356. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  357. URL_bricol = URL_bricol_https;
  358. isHTTPS = true;
  359. }
  360.  
  361. // Roule 23/12/2016 mode dev
  362. var isDEV = false;
  363. if (window.localStorage.getItem('MZ_dev')
  364. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  365. || window.location.href.indexOf('mzdev.mh') >= 0) {
  366. URL_MZ = URL_MZ.replace(/$/, 'dev');
  367. isDEV = true;
  368. }
  369.  
  370. // Images (pas de souci CORS)
  371. var URL_MZimg = URL_MZ + '/img/';
  372. // URLs externes ajax (CORS OK)
  373. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  374. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  375. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  376.  
  377. // liens externes déduits
  378. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  379.  
  380. var MHicons = '/mountyhall/Images/Icones/';
  381. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  382. var MY_DEBUG = false;
  383.  
  384. var horsGM = false;
  385. try { // à partir du 11/07/2018, (GM_getValue === undefined) provoque une exception
  386. horsGM = (GM_getValue === undefined);
  387. } catch (e2) {
  388. horsGM = true;
  389. //window.console.log('test GM_getValue, exception=' + e2);
  390. }
  391. if (horsGM) { // éviter le blocage si pas sous GM
  392. window.console.log('Fonctionnement hors Greasemonkey');
  393. // Roule 18/11/2017 il ne faut pas de "var" dans les ligne précédente. Ça fonctionnait sous Greasemonkey mais plus sous Violentmonkey
  394. GM_getValue = function(key) {};
  395. GM_setValue = function(key, val) {};
  396. GM_deleteValue = function(key) {};
  397. GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  398. }
  399.  
  400. /* Utilisation de la gestion de l'enregistrement des données de
  401. GreaseMonkey, avec partage entre scripts via le localStorage, par
  402. Vapulabehemot (82169) 07/02/2017 */
  403. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  404. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  405. function MY_getValue(key) {
  406. var v = window.localStorage.getItem(key);
  407. vGM = GM_getValue(key);
  408. if ((vGM == null)
  409. || (v != null && v != vGM)){
  410. GM_setValue(key, v);
  411. } else if (v == null && vGM != null) {
  412. v = vGM;
  413. window.localStorage[key] = vGM;
  414. }
  415. return v;
  416. }
  417. function MY_removeValue(key) {
  418. GM_deleteValue(key);
  419. window.localStorage.removeItem(key);
  420. }
  421. function MY_setValue(key, val) {
  422. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  423. val = 1;
  424. else if (val === false)
  425. val = 0;
  426. try {
  427. GM_setValue(key, val);
  428. } catch(e) {
  429. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  430. }
  431. try {
  432. window.localStorage[key] = val;
  433. } catch(e) {
  434. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  435. }
  436. }
  437.  
  438. /*---------------- mise à jour de variables globales utiles ------------------*/
  439. // utilisé pour accès bdd (un peu partout) :
  440. var numTroll = MY_getValue('NUM_TROLL');
  441. // utilisé dans vue pour PX :
  442. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  443. var nivTroll; // = MY_getValue('NIV_TROLL');
  444. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  445. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  446. // utilisés dans actions et vue (calculs SR) :
  447. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  448. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  449. var currentURL = window.location.href;
  450.  
  451. /*-[functions]------------ Fonctions durée de script -------------------------*/
  452. var date_debut = null;
  453.  
  454. function start_script(nbJours_exp) {
  455. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  456. if(date_debut) return;
  457. date_debut = new Date();
  458. // Créé la variable expdate si demandé
  459. if(nbJours_exp) {
  460. expdate = new Date();
  461. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  462. }
  463. }
  464.  
  465. function displayScriptTime(duree, texte) {
  466. var footerNode = document.getElementById('footer2');
  467. if(!footerNode) return;
  468. try{
  469. var node = document.evaluate(
  470. ".//text()[contains(.,'Page générée en')]/../br",
  471. footerNode,null,9,null).singleNodeValue;
  472. }
  473. catch(e){return;}
  474. if (duree) {
  475. insertText(node,
  476. ' - [' + texte + ' en ' + (duree/1000) +' sec.]');
  477. return;
  478. }
  479. insertText(node,
  480. ' - [Script MZ exécuté en '
  481. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  482. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  483. }
  484.  
  485. function traceStack(e, sModule) {
  486. var version = '';
  487. if (GM_info && GM_info.script && GM_info.script.version)
  488. version = ' ' + GM_info.script.version;
  489. sRet = '[MZ' + version + ']'
  490. if (sModule) sRet += ' {' + sModule + '}';
  491. try {
  492. if (e.message) sRet += ' ' + e.message;
  493. } catch (e2) {
  494. sRet += ' <exception acces message>';//+ e2.message;
  495. }
  496. try {
  497. if (e.stack) {
  498. var sStack = e.stack;
  499. // enlever les infos confidentielles
  500. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  501. }
  502. } catch (e2) {
  503. sRet += ' <exception acces stack>'; // + e2.message;
  504. }
  505. return sRet;
  506. }
  507.  
  508. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  509.  
  510. function debugMZ(str){
  511. if(MY_DEBUG){
  512. window.console.debug('[MZ_DEBUG] '+str);
  513. if(typeof str === "object"){
  514. window.console.debug(str);
  515. }
  516. }
  517. }
  518.  
  519. if("function" != typeof isPage) {
  520. function isPage(url) {
  521. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  522. }
  523. }
  524.  
  525. function FF_XMLHttpRequest(MY_XHR_Ob) {
  526. var request = new XMLHttpRequest();
  527. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  528. for(var head in MY_XHR_Ob.headers) {
  529. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  530. }
  531. request.onreadystatechange = function() {
  532. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  533. if(request.readyState!=4) { return; }
  534. if(request.error) {
  535. if(MY_XHR_Ob.onerror) {
  536. MY_XHR_Ob.onerror(request);
  537. }
  538. return;
  539. }
  540. if ((request.status == 0)) {
  541. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  542. if (isDEV) {
  543. var grandCadre = createOrGetGrandCadre();
  544. var sousCadre = document.createElement('div');
  545. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  546. sousCadre.style.width = 'auto';
  547. sousCadre.style.fontSize = 'large';
  548. sousCadre.style.border = 'solid 1px black';
  549. grandCadre.appendChild(sousCadre);
  550. }
  551. //showHttpsErrorContenuMixte();
  552. return;
  553. }
  554. if(MY_XHR_Ob.onload) {
  555. var version;
  556. if (MY_XHR_Ob.trace) {
  557. version = '';
  558. if (GM_info && GM_info.script && GM_info.script.version)
  559. version = ' ' + GM_info.script.version;
  560. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  561. }
  562. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  563. MY_XHR_Ob.onload(request);
  564. if (MY_XHR_Ob.trace)
  565. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  566. }
  567. };
  568. request.send(MY_XHR_Ob.data);
  569. }
  570.  
  571. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  572. function MZ_formatDateMS(d, sansMicroSecondes) {
  573. if (d === undefined) d = new Date();
  574. var day = d.getDate();
  575. var month = d.getMonth()+1;
  576. var year = d.getFullYear();
  577. var hours = d.getHours();
  578. var minutes = d.getMinutes();
  579. var seconds = d.getSeconds();
  580. if (day < 10) {day = "0"+day;}
  581. if (month < 10) {month = "0"+month;}
  582. if (hours < 10) {hours = "0"+hours;}
  583. if (minutes < 10) {minutes = "0"+minutes;}
  584. if (seconds < 10) {seconds = "0"+seconds;}
  585. if (sansMicroSecondes) {
  586. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds;
  587. } else {
  588. var ms = d.getMilliseconds();
  589. ms = ('000' + ms).substr(-3, 3);
  590. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  591. }
  592. }
  593.  
  594. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  595.  
  596. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  597. function copyTextToClipboard(text) {
  598. var textArea = document.createElement("textarea");
  599.  
  600. //
  601. // *** This styling is an extra step which is likely not required. ***
  602. //
  603. // Why is it here? To ensure:
  604. // 1. the element is able to have focus and selection.
  605. // 2. if element was to flash render it has minimal visual impact.
  606. // 3. less flakyness with selection and copying which **might** occur if
  607. // the textarea element is not visible.
  608. //
  609. // The likelihood is the element won't even render, not even a flash,
  610. // so some of these are just precautions. However in IE the element
  611. // is visible whilst the popup box asking the user for permission for
  612. // the web page to copy to the clipboard.
  613. //
  614.  
  615. // Place in top-left corner of screen regardless of scroll position.
  616. textArea.style.position = 'fixed';
  617. textArea.style.top = 0;
  618. textArea.style.left = 0;
  619.  
  620. // Ensure it has a small width and height. Setting to 1px / 1em
  621. // doesn't work as this gives a negative w/h on some browsers.
  622. textArea.style.width = '2em';
  623. textArea.style.height = '2em';
  624.  
  625. // We don't need padding, reducing the size if it does flash render.
  626. textArea.style.padding = 0;
  627.  
  628. // Clean up any borders.
  629. textArea.style.border = 'none';
  630. textArea.style.outline = 'none';
  631. textArea.style.boxShadow = 'none';
  632.  
  633. // Avoid flash of white box if rendered for any reason.
  634. textArea.style.background = 'transparent';
  635.  
  636. textArea.value = text;
  637.  
  638. document.body.appendChild(textArea);
  639.  
  640. textArea.select();
  641.  
  642. var successful = document.execCommand('copy');
  643.  
  644. document.body.removeChild(textArea);
  645. return successful;
  646. }
  647.  
  648. function avertissement(txt,duree) {
  649. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  650. if(!duree) duree = 15000;
  651. var div = document.createElement('div');
  652. // On numérote les avertissements pour destruction sélective
  653. var num = document.getElementsByName('avertissement').length;
  654. div.num = num;
  655. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  656. div.setAttribute('name','avertissement');
  657. div.className = 'mh_textbox';
  658. div.style.position = 'fixed';
  659. div.style.top = (10+15*num)+'px';
  660. div.style.left = (10+5*num)+'px';
  661. div.style.border = '5px solid red';
  662. div.style.zIndex = 2+num;
  663. div.style.cursor = 'pointer';
  664. div.style.fontSize = 'large';
  665. div.innerHTML = txt;
  666. div.onclick=function(){ tueAvertissement(this.num) };
  667.  
  668. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  669. var divcroix = document.createElement('div');
  670. divcroix.style.position = 'absolute';
  671. divcroix.style.top = 0;
  672. divcroix.style.right = 0;
  673. divcroix.style.color = 'black';
  674. divcroix.style.fontSize = 'inherit';
  675. divcroix.style.cursor = 'pointer'
  676. divcroix.style.zIndex = 2+num;
  677. divcroix.innerHTML = "X";
  678. div.appendChild(divcroix);
  679.  
  680. document.body.appendChild(div);
  681. // Destruction automatique de l'avertissement après "un certain temps"
  682. window.setTimeout(function(){ tueAvertissement(num) },duree);
  683. }
  684.  
  685. function tueAvertissement(num) {
  686. var divs = document.getElementsByName('avertissement');
  687. if(divs.length==0) { return; }
  688. for(var i=0 ; i<divs.length ; i++) {
  689. if(divs[i].num==num) {
  690. divs[i].parentNode.removeChild(divs[i]);
  691. return;
  692. }
  693. }
  694. }
  695.  
  696.  
  697. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  698.  
  699. function insertBefore(next,el) {
  700. next.parentNode.insertBefore(el,next);
  701. }
  702.  
  703. function appendTr(tbody,clas) {
  704. var tr = document.createElement('tr');
  705. if(clas) tr.className = clas;
  706. tbody.appendChild(tr);
  707. return tr;
  708. }
  709.  
  710. function insertTr(next,clas) {
  711. var tr = document.createElement('tr');
  712. if(clas) tr.className = clas;
  713. insertBefore(next,tr);
  714. return tr;
  715. }
  716.  
  717. function appendTd(tr) {
  718. var td = document.createElement('td');
  719. if(tr) tr.appendChild(td);
  720. return td;
  721. }
  722.  
  723. function insertTd(next) {
  724. var td = document.createElement('td');
  725. insertBefore(next,td);
  726. return td;
  727. }
  728.  
  729. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  730. function insertAfterTd(eTd) {
  731. var newTd = document.createElement('td');
  732. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  733. return newTd;
  734. }
  735.  
  736. function appendTdCenter(tr,colspan) {
  737. var td = appendTd(tr);
  738. td.align = 'center'; // WARNING - Obsolete
  739. if(colspan) td.colSpan = colspan;
  740. return td;
  741. }
  742.  
  743. function insertTdElement(next,el) {
  744. var td = insertTd(next);
  745. if(el) td.appendChild(el);
  746. return td;
  747. }
  748.  
  749. function appendA(paren,href,cssClass,text) {
  750. var a = document.createElement('a');
  751. if (href) a.href = href;
  752. if (cssClass) a.className = cssClass;
  753. if (text) a.appendChild(document.createTextNode(text));
  754. paren.appendChild(a);
  755. }
  756.  
  757. function appendText(paren,text,bold) {
  758. if(bold) {
  759. var b = document.createElement('b');
  760. b.appendChild(document.createTextNode(text));
  761. paren.appendChild(b);
  762. }
  763. else
  764. paren.appendChild(document.createTextNode(text));
  765. }
  766.  
  767. function insertText(next,text,bold) {
  768. if(bold) {
  769. var b = document.createElement('b');
  770. appendText(b,text);
  771. insertBefore(next,b);
  772. }
  773. else
  774. insertBefore(next,document.createTextNode(text));
  775. }
  776.  
  777. function appendThText(tr,text,bold) {
  778. var th = document.createElement('th');
  779. if(tr) tr.appendChild(th);
  780. th.appendChild(document.createTextNode(text));
  781. if (bold) th.style.fontWeight = 'bold';
  782. return th;
  783. }
  784.  
  785. function appendTdText(tr,text,bold) {
  786. var td = appendTd(tr);
  787. td.appendChild(document.createTextNode(text));
  788. if (bold) td.style.fontWeight = 'bold';
  789. return td;
  790. }
  791.  
  792. function insertTdText(next,text,bold) {
  793. var td = insertTd(next);
  794. appendText(td,text,bold);
  795. return td;
  796. }
  797.  
  798. function appendBr(paren) {
  799. paren.appendChild(document.createElement('br'));
  800. }
  801.  
  802. function insertBr(next) {
  803. insertBefore(next,document.createElement('br'));
  804. }
  805.  
  806. function appendLI(ul,text) {
  807. // uniquement utilisé dans les options (crédits)
  808. var li = document.createElement('li');
  809. appendText(li,text);
  810. ul.appendChild(li);
  811. return li;
  812. }
  813.  
  814. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  815. var input = document.createElement('input');
  816. input.className = 'TextboxV2';
  817. input.type = type;
  818. input.name = nam;
  819. if (sId === undefined) input.id = nam;
  820. else input.id = sId;
  821. input.size = size;
  822. input.maxLength = maxlength;
  823. if(value) input.value = value;
  824. paren.appendChild(input);
  825. return input;
  826. }
  827.  
  828. function appendCheckBox(paren,nam,checked,onClick) {
  829. var input = document.createElement('input');
  830. input.type = 'checkbox';
  831. input.name = nam;
  832. input.id = nam;
  833. if(checked) input.checked = true;
  834. if(onClick) input.onclick = onClick;
  835. paren.appendChild(input);
  836. return input;
  837. }
  838.  
  839. function appendNobr(paren,id,delgg,text) {
  840. var nobr = document.createElement('nobr');
  841. appendCheckBox(nobr,id,null,delgg);
  842. appendText(nobr,text);
  843. paren.appendChild(nobr);
  844. appendText(paren,' ');
  845. return nobr;
  846. }
  847.  
  848. function appendCheckBoxSpan(paren,id,onClick,text) {
  849. var span = document.createElement('span');
  850. span.style.whiteSpace = 'nowrap';
  851. appendCheckBox(span,id,false,onClick);
  852. var label = document.createElement('label');
  853. appendText(label,text);
  854. label.htmlFor = id;
  855. label.style.marginLeft = '-5px';
  856. span.appendChild(label);
  857. span.style.marginRight = '3px';
  858. paren.appendChild(span);
  859. appendText(paren, ' ');
  860. return span;
  861. }
  862.  
  863. function appendOption(select,value,text) {
  864. var option = document.createElement('option');
  865. option.value = value;
  866. appendText(option,text);
  867. select.appendChild(option);
  868. return option;
  869. }
  870.  
  871. function appendHidden(form,nam,value) {
  872. var input = document.createElement('input');
  873. input.type = 'hidden';
  874. input.name = nam;
  875. input.id = nam;
  876. input.value = value;
  877. form.appendChild(input);
  878. }
  879.  
  880. function appendButton(paren,value,onClick) {
  881. var input = document.createElement('input');
  882. input.type = 'button';
  883. input.className = 'mh_form_submit';
  884. input.value = value;
  885. input.onmouseover = function(){this.style.cursor='pointer';};
  886. if(onClick) input.onclick = onClick;
  887. paren.appendChild(input);
  888. return input;
  889. }
  890.  
  891. function insertButton(next,value,onClick) {
  892. var input = document.createElement('input');
  893. input.type = 'button';
  894. input.className = 'mh_form_submit';
  895. input.value = value;
  896. input.onmouseover = function(){this.style.cursor='pointer';};
  897. input.onclick = onClick;
  898. insertBefore(next,input);
  899. return input;
  900. }
  901.  
  902. function appendSubmit(paren,value,onClick) {
  903. var input = document.createElement('input');
  904. input.type = 'submit';
  905. input.className = 'mh_form_submit';
  906. input.value = value;
  907. input.onmouseover = function(){this.style.cursor='pointer';};
  908. if(onClick) input.onclick = onClick;
  909. paren.appendChild(input);
  910. return input;
  911. }
  912.  
  913. function createImage(url,title,style) {
  914. var img = document.createElement('img');
  915. img.src = url;
  916. img.title = title;
  917. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  918. if (style) img.style = style;
  919. return img;
  920. }
  921.  
  922. function createAltImage(url,alt,title) {
  923. var img = document.createElement('img');
  924. img.src = url;
  925. img.alt = alt;
  926. if (title) img.title = title;
  927. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  928. return img;
  929. }
  930.  
  931. function createImageSpan(url,alt,title,text,bold) {
  932. var span = document.createElement('span');
  933. span.title = title;
  934. var img = document.createElement('img');
  935. img.src = url;
  936. img.alt = alt;
  937. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  938. span.appendChild(img);
  939. appendText(span,text,bold);
  940. return span;
  941. }
  942.  
  943. function createCase(titre,table,width) {
  944. if(!width) width=120;
  945. var tr = appendTr(table,'mh_tdpage');
  946.  
  947. var td = appendTdText(tr,titre,true);
  948. td.className = 'mh_tdtitre';
  949. td.width = width;
  950.  
  951. td = appendTdText(tr,'');
  952. td.className = 'mh_tdpage';
  953. return td;
  954. }
  955.  
  956. function getMyID(e) {
  957. var parent = e.parentNode;
  958. for(var i=0 ; i<parent.childNodes.length ; i++) {
  959. if(e==parent.childNodes[i])
  960. return i;
  961. }
  962. return -1;
  963. }
  964.  
  965. function insertAfter(elt,newElt) {
  966. var id = getMyID(elt);
  967. if(id==-1) return;
  968. if(id<elt.parentNode.childNodes.length-1)
  969. insertBefore(elt.nextSibling,newElt);
  970. else
  971. elt.parentNode.appendChild(newElt);
  972. }
  973.  
  974.  
  975. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  976.  
  977. function aff(nb) {
  978. return (nb>=0) ? '+'+nb : nb;
  979. }
  980.  
  981. function getNumber(str) {
  982. var nbr = str.match(/\d+/);
  983. return nbr ? Number(nbr[0]) : Number.NaN;
  984. }
  985.  
  986. function getNumbers(str) {
  987. var nbrs = str.match(/-?\d+/g);
  988. if (!nbrs) return [];
  989. for(var i=0 ; i<nbrs.length ; i++)
  990. nbrs[i] = Number(nbrs[i]);
  991. return nbrs;
  992. }
  993.  
  994. function trim(str) {
  995. return str.replace(/(^\s*)|(\s*$)/g,'');
  996. }
  997.  
  998. String.prototype.trim = function() {
  999. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  1000. }
  1001.  
  1002. function epure(texte) {
  1003. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1004. .replace(/[ç]/g,'c')
  1005. .replace(/[éêèë]/g,'e')
  1006. .replace(/[ïî]/g,'i')
  1007. .replace(/[ôöõ]/g,'o')
  1008. .replace(/[ùûü]/g,'u');
  1009. }
  1010.  
  1011. String.prototype.epure = function () {
  1012. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1013. .replace(/[ç]/g,'c')
  1014. .replace(/[éêèë]/g,'e')
  1015. .replace(/[ïî]/g,'i')
  1016. .replace(/[ôöõ]/g,'o')
  1017. .replace(/[ùûü]/g,'u');
  1018. }
  1019.  
  1020. function bbcode(texte) {
  1021. return texte.replace(/&/g,'&amp;')
  1022. .replace(/"/g,'&quot;')
  1023. .replace(/</g,'&lt;')
  1024. .replace(/>/g,'&gt;')
  1025. .replace(/'/g,'&#146;')
  1026. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  1027. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  1028. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  1029. }
  1030.  
  1031.  
  1032. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  1033.  
  1034. function addZero(i) {
  1035. return (i<10) ? '0'+i : i;
  1036. }
  1037.  
  1038. function DateToString(date) {
  1039. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  1040. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  1041. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  1042. }
  1043.  
  1044. function StringToDate(str) {
  1045. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  1046. }
  1047.  
  1048. // fonctionne aussi avec datetime
  1049. function SQLDateToFrench(str) {
  1050. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  1051. }
  1052.  
  1053. // ... et ajoute un "à" du plus bel effet
  1054. function SQLDateToFrenchTime(str) {
  1055. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  1056. }
  1057.  
  1058. // SQLDate vers objet date Javascript
  1059. function SQLDateToObject(str) {
  1060. var t = str.split(/[- :]/);
  1061. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  1062. }
  1063.  
  1064. var mz_ie = (window.attachEvent)? true:false;
  1065. if ("function" !== typeof addEvent) {
  1066. if (mz_ie) {
  1067. function addEvent(obj, typ, fn, sens) {
  1068. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  1069. obj["e"+typ+fn]( window.event );
  1070. }
  1071. obj.attachEvent("on"+typ, obj[typ+fn] );
  1072. }
  1073. }
  1074. else {
  1075. function addEvent(obj, typ, fn, sens) {
  1076. obj.addEventListener(typ, fn, sens);
  1077. }
  1078. }
  1079. }
  1080.  
  1081. /**********************
  1082. * glissière en mode objet
  1083. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  1084. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  1085. *
  1086. * Usage:
  1087. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  1088. * ref : utilisé pour diversifier les IDs HTML
  1089. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  1090. * target : peut être de 3 types
  1091. * - élément HTML : l'élément HTML à zoomer
  1092. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  1093. * - function : callback quand le curseur bouge
  1094. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  1095. * dans le mode dynamique, la callback est appelée sur mouseMove
  1096. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  1097. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  1098. * autres méthodes
  1099. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  1100. **********************/
  1101.  
  1102. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  1103. try {
  1104. var mouseDown = false;
  1105. var div_gliss = document.createElement("div"); // la DIV mère
  1106. div_gliss.id = "MZ_gliss_"+ref;
  1107. var div_label = document.createElement("span"); // le label
  1108. div_label.innerHTML = labelHTML;
  1109. div_gliss.appendChild(div_label);
  1110. div_gliss.className = "choix_zoom";
  1111. var dessin = document.createElement("canvas"); // le dessin lui-même
  1112. dessin.id = "MZ_gliss_dessin_"+ref;
  1113. dessin.style.cursor = "pointer";
  1114. dessin.width = 104;
  1115. dessin.height = 12;
  1116. dessin.style.marginLeft = '2px';
  1117. dessin.style.marginRight = '2px';
  1118. div_gliss.appendChild(dessin);
  1119. var pourcent = document.createElement("span"); // le pourcentage
  1120. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1121. var pourcent_text = document.createTextNode('');
  1122. var previousVal;
  1123. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1124.  
  1125. // alignement vertical
  1126. dessin.style.verticalAlign = 'middle';
  1127. div_label.style.verticalAlign = 'middle';
  1128. pourcent.style.verticalAlign = 'middle';
  1129.  
  1130. pourcent.appendChild(pourcent_text);
  1131. div_gliss.appendChild(pourcent);
  1132.  
  1133. var bulle_pourcent = document.createElement("div"); // la bulle
  1134. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1135. bulle_pourcent.style.display = 'block';
  1136. bulle_pourcent.style.visibility = 'hidden';
  1137. bulle_pourcent.style.position = 'absolute';
  1138. bulle_pourcent.style.zIndex = 3500;
  1139. bulle_pourcent.style.border = '1px solid #a1927f';
  1140. var bulle_pourcent_text = document.createTextNode('');
  1141. bulle_pourcent.appendChild(bulle_pourcent_text);
  1142. document.body.appendChild(bulle_pourcent);
  1143.  
  1144. this.getElt = function() {return div_gliss;};
  1145.  
  1146. ////////////////////////////////////
  1147. // dessine et redessine le curseur
  1148. ////////////////////////////////////
  1149. var dessine_glissiere = function(val) {
  1150. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1151. var ctx = dessin.getContext('2d');
  1152. ctx.clearRect(0, 0,104, 12);
  1153. ctx.fillStyle = "rgb(0,0,0)";
  1154. ctx.fillRect(0,0,2,12);
  1155. ctx.fillRect(102,0,2,12);
  1156. ctx.fillRect(0,5,104,2);
  1157.  
  1158. ctx.fillStyle = "rgb(80,80,80)";
  1159. ctx.fillRect(pos_0_100,0,5,12);
  1160. ctx.fillStyle = "rgb(200,200,200)";
  1161. ctx.fillRect(pos_0_100+1,1,3,10);
  1162. pourcent_text.nodeValue = val+'%';
  1163. previousVal = parseInt(val);
  1164. };
  1165.  
  1166. ////////////////////////////////////
  1167. // action sur mousedown et mousemove
  1168. // stocker la nouvelle valeur
  1169. // redessiner
  1170. // afficher la nouvelle valeur
  1171. // action selon ce qui a été demandé
  1172. ////////////////////////////////////
  1173. var doCallback_glissiere = function (evt) {
  1174. try {
  1175. if (evt.type === 'mousedown') mouseDown = true;
  1176. if (evt.offsetX) {
  1177. var xsouris = evt.offsetX;
  1178. var xpos = evt.clientX;
  1179. var ypos = evt.clientY + document.body.scrollTop;
  1180. }
  1181. else {
  1182. var xsouris = evt.layerX;
  1183. var xpos = evt.pageX;
  1184. var ypos = evt.pageY;
  1185. }
  1186. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1187. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1188. // afficher la nouvelle valeur dans la bulle
  1189. bulle_pourcent_text.nodeValue = val + '%';
  1190. bulle_pourcent.style.top = (ypos+3)+'px';
  1191. bulle_pourcent.style.left = (xpos+16)+'px';
  1192. if (evt.buttons === undefined) {
  1193. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1194. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1195. } else {
  1196. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1197. }
  1198. // stocker la nouvelle valeur
  1199. MY_setValue("MZ_glissiere_" + ref, val);
  1200. // redessiner la glissière avec le curseur où il faut
  1201. dessine_glissiere(val);
  1202. // action selon ce qui a été demandé
  1203. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1204. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1205. if (typeof paramTarget === 'object') {
  1206. var elt = paramTarget;
  1207. } else if (typeof paramTarget === 'string') {
  1208. var elt = document.getElementById(paramTarget);
  1209. } else if (typeof paramTarget === 'function') {
  1210. paramTarget(val);
  1211. return;
  1212. }
  1213. if (elt.setZoom != undefined) elt.setZoom(val);
  1214. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1215. };
  1216.  
  1217. ////////////////////////////////////
  1218. // event mousedown et mousemove : redessiner et callback
  1219. ////////////////////////////////////
  1220. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1221. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1222. ////////////////////////////////////
  1223. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1224. ////////////////////////////////////
  1225. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1226. ////////////////////////////////////
  1227. // event mouseout & mouseover : afficher/cacher la bulle
  1228. ////////////////////////////////////
  1229. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1230. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1231.  
  1232. ////////////////////////////////////
  1233. // dessiner la première fois
  1234. ////////////////////////////////////
  1235. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1236. if (val_init === undefined) val_init = valDef;
  1237. dessine_glissiere(val_init);
  1238. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1239. }
  1240.  
  1241. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1242. // reçoit 2 objets avec des propriétés x et y
  1243. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1244. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1245. var deltaX = locArrivee.x - locDepart.x;
  1246. if (deltaX == 0) return; // pas de point intermédiaire
  1247. var deltaY = locArrivee.y - locDepart.y;
  1248. if (deltaY == 0) return; // pas de point intermédiaire
  1249. var absDeltaX = Math.abs(deltaX);
  1250. var absDeltaY = Math.abs(deltaY);
  1251. if (absDeltaX > absDeltaY) {
  1252. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1253. } else if (absDeltaY > absDeltaX) {
  1254. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1255. } else {
  1256. return; // égalité, pas de point intermédiaire
  1257. }
  1258. }
  1259.  
  1260. /**********************
  1261. * carte en mode objet
  1262. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1263. *
  1264. * Usage:
  1265. * carte = new carte_MZ(ref, tabDepl);
  1266. * ref : utilisé pour diversifier les IDs HTML
  1267. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1268. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1269. * autres méthodes
  1270. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1271. **********************/
  1272.  
  1273. function carte_MZ(ref, tabDepl) {
  1274. try {
  1275. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1276. div1_carte.id = "MZ_carte_"+ref;
  1277. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1278. div1_carte.style.backgroundImage = 'none';
  1279. div1_carte.style.backgroundColor = 'transparent';
  1280. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1281. div2_carte.className = "carte_MZ";
  1282. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1283. var dessin = document.createElement("canvas"); // le dessin lui-même
  1284. dessin.id = "MZ_carte_dessin_"+ref;
  1285. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1286. div1_carte.appendChild(div2_carte);
  1287. div2_carte.appendChild(dessin);
  1288.  
  1289. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1290. , [-66.5, -37.5, 2, 1.5, -69]
  1291. , [-63.5, 8.5, 2, 1.5, -69]
  1292. , [-59.5, -32.5, 2, 1.5, -69]
  1293. , [-52, 57, 0.25, 0.8, -59]
  1294. , [-50.5, -22.5, 2, 1.5, -69]
  1295. , [-35.5, -51.5, 2, 1.5, -69]
  1296. , [-34.5, 14.5, 2, 1.5, -69]
  1297. , [-34.5, 64.5, 2, 1.5, -69]
  1298. , [-11.5, 72.5, 2, 1.5, -69]
  1299. , [5.5, -49.5, 2, 1.5, -69]
  1300. , [5.5, 31.5, 2, 1.5, -69]
  1301. , [10.5, 63.5, 2, 1.5, -69]
  1302. , [12, -15, 0.25, 0.8, -59]
  1303. , [21.5, 35.5, 2, 1.5, -69]
  1304. , [30, -52, 0.25, 0.8, -59]
  1305. , [46.5, 51.5, 2, 1.5, -69]
  1306. , [48, -39, 0.25, 0.8, -59]
  1307. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1308. , [56.5, 23.5, 75, 8.7, -99]
  1309. , [64, 70, 0.25, 0.8, -59]
  1310. , [74.5, 31.5, 2, 1.5, -69]];
  1311.  
  1312. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1313. var couleur_cible = 'rgba(0,0,0,0.5)';
  1314. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1315. var couleur_trou = 'rgb(200,0,0)';
  1316.  
  1317. var coord_x = function(val) {
  1318. return decalh+coeff*(val+100);
  1319. };
  1320. var coord_y = function(val) {
  1321. return decalv+coeff*(100-val);
  1322. };
  1323.  
  1324. var ctx = dessin.getContext('2d');
  1325. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1326. if (coeff) coeff /= 50;
  1327. else coeff = 2;
  1328. var decalv=30, decalh=30;
  1329.  
  1330. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1331. //var res = false
  1332. var x0 = pos0.x;
  1333. var y0 = pos0.x;
  1334. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1335. var px = Math.sign(pos1.x - pos0.x);
  1336. var py = Math.sign(pos1.y - pos0.y);
  1337. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1338. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1339.  
  1340. for(var k in position_trous_MZ) {
  1341. a = parseFloat(px*px+py*py);
  1342. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1343. 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]);
  1344. delta = b*b-a*c
  1345. if(delta >= 0) {
  1346. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1347. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1348. if(t0 <= tmax && t1 >= 0) {
  1349. // 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
  1350. //res = true;
  1351. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1352. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1353. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1354. // Roule : pas utile pour nous
  1355. //res = true;
  1356. //chute.push([x0+l*px, y0+l*py]);
  1357. return true;
  1358. }
  1359. }
  1360. }
  1361. }
  1362. //return res;
  1363. return false;
  1364. };
  1365.  
  1366. var dessine_carte = function () {
  1367. dessin.width = 200*coeff+2*decalh;
  1368. dessin.height = 200*coeff+2*decalv;
  1369.  
  1370. //repere
  1371. ctx.beginPath();
  1372. ctx.moveTo(coord_x(0), coord_y(100));
  1373. ctx.lineTo(coord_x(0), coord_y(-100));
  1374. ctx.moveTo(coord_x(-100), coord_y(0));
  1375. ctx.lineTo(coord_x(100), coord_y(0));
  1376. ctx.stroke();
  1377. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1378.  
  1379. //trous
  1380. ctx.fillStyle = couleur_trou;
  1381. for(var i in position_trous_MZ) {
  1382. ctx.beginPath();
  1383. 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);
  1384. ctx.fill();
  1385. }
  1386. // trajets
  1387. ctx.lineCap = "round";
  1388. ctx.lineJoin = "round";
  1389. for (var iSuivant in tabDepl) {
  1390. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1391. var tabDeplOneSuivant = tabDepl[iSuivant];
  1392. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1393. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1394. // La "cible" au départ
  1395. var typeDepart = tabDeplOneSuivant[0].typ;
  1396. switch (typeDepart) {
  1397. case 'tp':
  1398. ctx.beginPath();
  1399. ctx.lineWidth = 2;
  1400. ctx.strokeStyle = couleur_cible;
  1401. ctx.fillStyle = couleur_cible;
  1402. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1403. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1404. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1405. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1406. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1407. ctx.moveTo(x0 + coeff * 3, y0);
  1408. ctx.lineTo(x0 - coeff * 3, y0);
  1409. ctx.moveTo(x0, y0 + coeff * 3);
  1410. ctx.lineTo(x0, y0 - coeff * 3);
  1411. ctx.stroke();
  1412. break;
  1413. default:
  1414. ctx.beginPath();
  1415. ctx.lineWidth = 1;
  1416. ctx.strokeStyle = couleur_cible;
  1417. ctx.fillStyle = couleur_cible;
  1418. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1419. ctx.moveTo(x0 + coeff * 4, y0);
  1420. ctx.lineTo(x0 - coeff * 4, y0);
  1421. ctx.moveTo(x0, y0 + coeff * 4);
  1422. ctx.lineTo(x0, y0 - coeff * 4);
  1423. ctx.stroke();
  1424. break;
  1425. }
  1426. // les segments
  1427. var nb_pts = tabDeplOneSuivant.length;
  1428. var pointPrecedent = tabDeplOneSuivant[0];
  1429. for (var i=1; i<nb_pts; i++) {
  1430. ctx.beginPath();
  1431. ctx.lineWidth = coeff;
  1432. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1433. ctx.strokeStyle = couleur_depl_normal;
  1434. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1435. if (pointIntermediaire === undefined) {
  1436. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1437. ctx.strokeStyle = couleur_depl_collision_trou;
  1438. else
  1439. ctx.strokeStyle = couleur_depl_normal;
  1440. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1441. } else {
  1442. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1443. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1444. ctx.strokeStyle = couleur_depl_collision_trou;
  1445. else
  1446. ctx.strokeStyle = couleur_depl_normal;
  1447. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1448. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1449. }
  1450. pointPrecedent = tabDeplOneSuivant[i];
  1451. ctx.stroke();
  1452. }
  1453. // Les points à chaque étape
  1454. ctx.fillStyle = couleur_depl_normal;
  1455. for (var i=1; i<nb_pts; i++) {
  1456. ctx.beginPath();
  1457. var x = coord_x(tabDeplOneSuivant[i].x);
  1458. var y = coord_y(tabDeplOneSuivant[i].y);
  1459. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1460. ctx.fill();
  1461. }
  1462. }
  1463. }
  1464.  
  1465. this.setZoom = function (val) {
  1466. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1467. coeff = val / 50;
  1468. dessine_carte();
  1469. }
  1470.  
  1471. // glissiere
  1472. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1473. var eGliss = gliss.getElt();
  1474. eGliss.style.position = 'absolute';
  1475. eGliss.style.top = (coeff * 2) + 'px';
  1476. eGliss.style.left = decalh + 'px';
  1477. dessin.style.position = 'relative';
  1478. div2_carte.style.position = 'relative';
  1479. eGliss.style.zIndex = 9000;
  1480. div2_carte.appendChild(eGliss);
  1481.  
  1482. // affichage au survol de la souris
  1483. var bulle = document.createElement('div');
  1484. bulle.style.visibility = 'hidden';
  1485. bulle.style.position = 'absolute';
  1486. bulle.style.zIndex = 3100;
  1487. bulle.style.border = 'solid 1px #a1927f';
  1488. bulle.className = 'mh_tdpage';
  1489. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1490. var bulleHaut = document.createElement('div');
  1491. bulleHaut.style.display = 'block';
  1492. bulleHaut.style.paddingRight = '3px';
  1493. bulleHaut.className = 'mh_tdtitre';
  1494. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1495. bulle.appendChild(bulleHaut);
  1496. var bulleBas = document.createElement('div');
  1497. bulleBas.style.display = 'block';
  1498. bulleBas.style.whiteSpace = "nowrap";
  1499. bulleBas.style.paddingRight = '3px';
  1500.  
  1501. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1502. bulle.appendChild(bulleBas);
  1503. div2_carte.appendChild(bulle);
  1504. var affichePosition = function(evt) {
  1505. if (evt.offsetX) {
  1506. var xsouris = evt.offsetX;
  1507. var ysouris = evt.offsetY;
  1508. var xpos = evt.clientX;
  1509. var ypos = evt.clientY + document.body.scrollTop;
  1510. }
  1511. else {
  1512. var xsouris = evt.layerX;
  1513. var ysouris = evt.layerY;
  1514. var xpos = evt.pageX;
  1515. var ypos = evt.pageY;
  1516. }
  1517. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1518. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1519. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1520. var tabHTMLbas = [];
  1521. // message pour les trous
  1522. for (var i in position_trous_MZ) {
  1523. var ceTrou = position_trous_MZ[i];
  1524. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1525. if(dist <= 0) {
  1526. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1527. break;
  1528. }
  1529. }
  1530. // messages pour les suivants
  1531. for (var i in tabDepl) {
  1532. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1533. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1534. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1535. }
  1536. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1537. bulle.style.top = (ysouris+8) + 'px';
  1538. bulle.style.left = (xsouris+16) + 'px';
  1539. };
  1540. addEvent(dessin, "mousemove", affichePosition, true);
  1541. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1542. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1543.  
  1544. // dessin initial
  1545. dessine_carte();
  1546.  
  1547. this.getElt = function() {return div1_carte;};
  1548.  
  1549. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1550. }
  1551.  
  1552.  
  1553. /**********************************************************
  1554. **** Fin de zone à déplacer dans une bibli commune ********
  1555. **********************************************************/
  1556.  
  1557. /* DEBUG: NETTOYAGE TAGS */
  1558. if(MY_getValue(numTroll+'.TAGSURL')) {
  1559. MY_removeValue(numTroll+'.TAGSURL');
  1560. }
  1561.  
  1562. // Alerte si mode dev
  1563. if (isDEV) {
  1564. var divpopup = document.createElement('div');
  1565. divpopup.id = 'divDEV';
  1566. divpopup.style =
  1567. 'position: fixed;'+
  1568. 'border: 15px solid red;'+
  1569. 'top: 10px;right: 10px;'+
  1570. 'background-color: white;'+
  1571. 'color: black;'+
  1572. 'font-size: large;'+
  1573. 'padding: 5px'+
  1574. 'z-index: 200;';
  1575. appendText(divpopup, '[MZ] Mode DEV');
  1576. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1577. document.body.appendChild(divpopup);
  1578. }
  1579.  
  1580. /*---------- regroupement des getPortee() ------------------------------------*/
  1581. // issu des script profil et profil2
  1582. function getPortee__Profil(param) {
  1583. param = Math.max(0,Number(param));
  1584. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1585. // ça devrait être floor, +10.25, -2.5
  1586. }
  1587.  
  1588. // issu du script vue
  1589. function getPortee__Vue(param) {
  1590. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1591. }
  1592.  
  1593.  
  1594. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1595.  
  1596. function getPXKill(niv) {
  1597. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1598. return Math.max(0,10+3*niv-2*nivTroll);
  1599. }
  1600.  
  1601. function getPXDeath(niv) {
  1602. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1603. return Math.max(0,10+3*nivTroll-2*niv);
  1604. }
  1605.  
  1606. function analysePX(niv) {
  1607. niv = niv+'';
  1608. var i = niv.indexOf('+');
  1609. if(i!=-1) // si niv = 'XX+' ??
  1610. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1611. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1612. if(i!=-1) {
  1613. var max = getPXKill(niv.slice(i+2));
  1614. if(max==0)
  1615. return ' --> <b>0</b> PX';
  1616. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1617. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1618. }
  1619. i = niv.indexOf('='); // ???
  1620. if(i!=-1) {
  1621. var max = getPXKill(niv.slice(i+1));
  1622. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1623. }
  1624. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1625. }
  1626.  
  1627. function analysePXTroll(niv) {
  1628. var str = analysePX(niv);
  1629. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1630. return str;
  1631. }
  1632.  
  1633.  
  1634. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1635. // Refonte totale du code de Zorya
  1636.  
  1637. // Elements à implémenter en dur dans MZ2.0
  1638. var numQualite = {
  1639. 'Très Mauvaise':1,
  1640. 'Mauvaise':2,
  1641. 'Moyenne':3,
  1642. 'Bonne':4,
  1643. 'Très Bonne':5
  1644. };
  1645.  
  1646. var qualiteNum = [
  1647. '_dummy_',
  1648. 'Très Mauvaise',
  1649. 'Mauvaise',
  1650. 'Moyenne',
  1651. 'Bonne',
  1652. 'Très Bonne'
  1653. ];
  1654.  
  1655. var nival = {
  1656. 'Abishaii Bleu':19,
  1657. 'Abishaii Noir':10,
  1658. 'Abishaii Rouge':23,
  1659. 'Abishaii Vert':15,
  1660. 'Ame-en-peine':8,
  1661. 'Amibe Geante':9,
  1662. 'Anaconda des Catacombes':8,
  1663. 'Ankheg':10,
  1664. 'Anoploure Purpurin':36,
  1665. 'Araignee Geante':2,
  1666. 'Ashashin':35,
  1667. 'Balrog':50,
  1668. 'Banshee':16,
  1669. 'Barghest':36,
  1670. 'Basilisk':11,
  1671. 'Behemoth':34,
  1672. 'Behir':14,
  1673. 'Beholder':50,
  1674. 'Boggart':3,
  1675. 'Bondin':9,
  1676. "Bouj'Dla Placide":37,
  1677. "Bouj'Dla":19,
  1678. 'Bulette':19,
  1679. 'Caillouteux':1,
  1680. 'Capitan':35,
  1681. 'Carnosaure':25,
  1682. 'Champi-Glouton':3,
  1683. 'Chauve-Souris Geante':4,
  1684. 'Cheval a Dents de Sabre':23,
  1685. 'Chevalier du Chaos':20,
  1686. 'Chimere':13,
  1687. 'Chonchon':24,
  1688. 'Coccicruelle':22,
  1689. 'Cockatrice':5,
  1690. 'Crasc Medius':17,
  1691. 'Crasc Maexus':25,
  1692. 'Crasc':10,
  1693. 'Croquemitaine':6,
  1694. 'Cube Gelatineux':32,
  1695. 'Daemonite':27,
  1696. 'Diablotin':5,
  1697. 'Dindon du Chaos':1,
  1698. 'Djinn':29,
  1699. 'Ectoplasme':18,
  1700. 'Effrit':27,
  1701. "Elementaire d'Air":23,
  1702. "Elementaire d'Eau":17,
  1703. 'Elementaire de Feu':21,
  1704. 'Elementaire de Terre':21,
  1705. 'Elementaire du Chaos':26,
  1706. 'Erinyes':7,
  1707. 'Esprit-Follet':16,
  1708. 'Essaim Craterien':30,
  1709. 'Essaim Sanguinaire':25,
  1710. 'Ettin':8,
  1711. 'Familier':1,
  1712. 'Fantome':24,
  1713. 'Feu Follet':20,
  1714. 'Flagelleur Mental':33,
  1715. 'Foudroyeur':38,
  1716. 'Fumeux':22,
  1717. 'Fungus Geant':9,
  1718. 'Fungus Violet':4,
  1719. 'Furgolin':10,
  1720. 'Gargouille':3,
  1721. 'Geant de Pierre':13,
  1722. 'Geant des Gouffres':22,
  1723. "Geck'oo Majestueux":40,
  1724. "Geck'oo":15,
  1725. 'Glouton':20,
  1726. 'Gnoll':5,
  1727. 'Gnu Domestique':1,
  1728. 'Gnu Sauvage':1,
  1729. 'Goblin':4,
  1730. 'Goblours':4,
  1731. "Golem d'Argile":15,
  1732. 'Golem de cuir':1,
  1733. 'Golem de Chair':8,
  1734. 'Golem de Fer':31,
  1735. 'Golem de mithril':1,
  1736. 'Golem de metal':1,
  1737. 'Golem de papier':1,
  1738. 'Golem de Pierre':23,
  1739. 'Gorgone':11,
  1740. 'Goule':4,
  1741. 'Gowap Apprivoise':1,
  1742. 'Gowap Sauvage':1,
  1743. 'Gremlins':3,
  1744. 'Gritche':39,
  1745. 'Grouilleux':4,
  1746. 'Grylle':31,
  1747. 'Harpie':4,
  1748. 'Hellrot':18,
  1749. 'Homme-Lezard':4,
  1750. 'Hurleur':8,
  1751. 'Hydre':50,
  1752. 'Incube':13,
  1753. 'Kobold':2,
  1754. 'Labeilleux':26,
  1755. 'Lezard Geant':5,
  1756. 'Liche':50,
  1757. 'Limace Geante':10,
  1758. 'Loup-Garou':8,
  1759. 'Lutin':4,
  1760. 'Mante Fulcreuse':30,
  1761. 'Manticore':9,
  1762. 'Marilith':33,
  1763. 'Meduse':6,
  1764. 'Megacephale':38,
  1765. 'Mille-Pattes Geant':14,
  1766. 'Mimique':6,
  1767. 'Minotaure':7,
  1768. 'Molosse Satanique':8,
  1769. 'Momie':4,
  1770. 'Monstre Rouilleur':3,
  1771. "Mouch'oo Domestique":14,
  1772. "Mouch'oo Majestueux Sauvage":33,
  1773. "Mouch'oo Sauvage":14,
  1774. 'Na-Haniym-Heee':0,
  1775. 'Necrochore':37,
  1776. 'Necromant':39,
  1777. 'Necrophage':8,
  1778. 'Naga':10,
  1779. 'Nuee de Vermine':13,
  1780. "Nuage d'Insectes":7,
  1781. 'Ogre':7,
  1782. 'Ombre de Roches':13,
  1783. 'Ombre':2,
  1784. 'Orque':3,
  1785. 'Ours-Garou':18,
  1786. 'Palefroi Infernal':29,
  1787. 'Phoenix':32,
  1788. 'Pititabeille':0,
  1789. 'Plante Carnivore':4,
  1790. 'Pseudo-Dragon':5,
  1791. 'Rat Geant':2,
  1792. 'Rat-Garou':3,
  1793. 'Rocketeux':5,
  1794. 'Sagouin':3,
  1795. 'Scarabee Geant':4,
  1796. 'Scorpion Geant':10,
  1797. 'Shai':28,
  1798. 'Sirene':8,
  1799. 'Slaad':5,
  1800. 'Sorciere':17,
  1801. 'Spectre':14,
  1802. 'Sphinx':30,
  1803. 'Squelette':1,
  1804. 'Strige':2,
  1805. 'Succube':13,
  1806. 'Tertre Errant':20,
  1807. 'Thri-kreen':10,
  1808. 'Tigre-Garou':12,
  1809. 'Titan':26,
  1810. 'Trancheur':35,
  1811. 'Tubercule Tueur':14,
  1812. 'Tutoki':4,
  1813. 'Vampire':29,
  1814. 'Ver Carnivore Geant':12,
  1815. 'Ver Carnivore':11,
  1816. 'Veskan Du Chaos':14,
  1817. 'Vouivre':33,
  1818. 'Worg':5,
  1819. 'Xorn':14,
  1820. 'Yeti':8,
  1821. 'Yuan-ti':15,
  1822. 'Zombie':2
  1823. }
  1824.  
  1825. var tabEM = {
  1826. //Monstre: [Compo exact, Sort, Position, Localisation]
  1827. // AA
  1828. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1829. // AE
  1830. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1831. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1832. // AdA
  1833. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1834. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1835. // AdE
  1836. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1837. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1838. // AdD
  1839. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1840. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1841. // BAM
  1842. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1843. // BuM
  1844. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1845. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1846. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1847. // Explo
  1848. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1849. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1850. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1851. // FP
  1852. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1853. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1854. // FA
  1855. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1856. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1857. // Glue
  1858. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1859. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1860. // GdS
  1861. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1862. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1863. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1864. // Invi
  1865. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1866. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1867. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1868. // Lévitation
  1869. // ???
  1870. // PréM :
  1871. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1872. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1873. // Proj
  1874. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1875. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1876. // PuM :
  1877. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1878. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1879. // Sacro
  1880. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1881. // Télék
  1882. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1883. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1884. // TP
  1885. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1886. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1887. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1888. // VA
  1889. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1890. // VL
  1891. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1892. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1893. // VlC
  1894. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1895. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1896. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1897. // VT
  1898. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1899. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1900. // Variables
  1901. 'Rat':["d'un"],
  1902. 'Rat Géant':["d'un"],
  1903. 'Dindon':["d'un"],
  1904. 'Goblin':["d'un"],
  1905. 'Limace':["d'une"],
  1906. 'Limace Géante':["d'une"],
  1907. 'Ver':["d'un"],
  1908. 'Ver Carnivore':["d'un"],
  1909. 'Ver Carnivore Géant':["d'un"],
  1910. 'Fungus':["d'un"],
  1911. 'Vouivre':["d'une"],
  1912. 'Gnu':["d'un"],
  1913. 'Scarabée':["d'un"]
  1914. };
  1915.  
  1916. var mundiChampi = {
  1917. 'Préscientus Reguis':'du Phoenix',
  1918. 'Amanite Trolloïde':'de la Mouche',
  1919. 'Girolle Sanglante':'du Dindon',
  1920. 'Horreur Des Prés':'du Gobelin',
  1921. 'Bolet Péteur':'du Démon',
  1922. 'Pied Jaune':'de la Limace',
  1923. 'Agaric Sous-Terrain':'du Rat',
  1924. 'Suinte Cadavre':"de l'Hydre",
  1925. 'Cèpe Lumineux':'du Ver',
  1926. 'Fungus Rampant':'du Fungus',
  1927. 'Nez Noir':'de la Vouivre',
  1928. 'Pleurote Pleureuse':'du Gnu',
  1929. 'Phytomassus Xilénique':'du Scarabée'
  1930. };
  1931.  
  1932. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1933. appendText(node,' ');
  1934. var urlImg = URL_MZimg
  1935. +'Competences/melangeMagique.png';
  1936. var text = ' [-'+(niv+effetQ)+' %]';
  1937. var str = '';
  1938. switch(mob[0]) {
  1939. case 'A':
  1940. case 'E':
  1941. case 'I':
  1942. case 'O':
  1943. case 'U':
  1944. str = "Compo d'";
  1945. break;
  1946. default:
  1947. str = 'Compo de ';
  1948. }
  1949. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1950. var span = createImageSpan(urlImg,'MM:',title,text);
  1951. node.appendChild(span);
  1952. }
  1953.  
  1954. function addInfoEM(node,mob,compo,qualite,localisation) {
  1955. if(!tabEM[mob]) return;
  1956. var title = 'Composant variable', texte = 'Variable';
  1957. var bold = false;
  1958. if(tabEM[mob].length>1) {
  1959. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1960. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1961. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1962. if(pc<-20) return;
  1963. if(pc>=0) bold = true;
  1964. texte = aff(pc)+'%';
  1965. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1966. }
  1967. var urlImg = URL_MZimg
  1968. +'Competences/ecritureMagique.png';
  1969. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1970. node.appendChild(span);
  1971. }
  1972.  
  1973. function insererInfosEM(tbody) {
  1974. // lancé par equip, equipgowap
  1975. var trCompos = document.evaluate(
  1976. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1977. tbody,null,7,null);
  1978. var strCompos = '';
  1979. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1980. var node = trCompos.snapshotItem(i).childNodes[7];
  1981. var str = node.firstChild.textContent;
  1982. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1983. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1984. // Si non-EM on stoppe le traitement
  1985. if(!tabEM[mob]) continue;
  1986. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1987. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1988. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1989. addInfoEM(node,mob,compo,qualite,localisation);
  1990. }
  1991. }
  1992.  
  1993. function getQualite(qualite) {
  1994. var nb = numQualite[qualite];
  1995. return nb ? nb-1 : -1;
  1996. }
  1997.  
  1998. function getEM(nom) {
  1999. if(nom.indexOf('[')!=-1)
  2000. nom = trim(nom.substring(0,nom.indexOf('[')));
  2001. if(tabEM[nom]) return nom;
  2002. return '';
  2003. }
  2004.  
  2005. // DEBUG ex-fonction composantEM
  2006. function compoMobEM(mob) {
  2007. if(!tabEM[mob]) return '';
  2008. if(tabEM[mob].length==1)
  2009. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  2010. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  2011. +") pour l'écriture de "+tabEM[mob][1];
  2012. }
  2013.  
  2014. // DEBUG ex-fonction compoEM
  2015. function titreCompoEM(mob,compo,localisation,qualite) {
  2016. if(!tabEM[mob]) return '';
  2017. if(tabEM[mob].length==1) return 'Composant variable';
  2018.  
  2019. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  2020. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  2021. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  2022.  
  2023. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  2024. return '';
  2025. }
  2026.  
  2027. // DEBUG - rétrocompatibilité
  2028. function compoEM(mob) {
  2029. // appelé dans libs, vue
  2030. return compoMobEM(mob);
  2031. }
  2032. function composantEM(mob,compo,localisation,qualite) {
  2033. // appelé dans libs, tancompo
  2034. return titreCompoEM(mob,compo,localisation,qualite);
  2035. }
  2036. //
  2037.  
  2038.  
  2039. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  2040.  
  2041. arrayTalents = {
  2042. /* Compétences */
  2043. 'Acceleration du Metabolisme':'AM',
  2044. 'Attaque Precise':'AP',
  2045. 'Balayage':'Balayage',
  2046. //'Balluchonnage':'Ballu',
  2047. 'Baroufle':'Baroufle',
  2048. 'Bidouille':'Bidouille',
  2049. 'Botte Secrete':'BS',
  2050. 'Camouflage':'Camou',
  2051. 'Charger':'Charger',
  2052. 'Connaissance des Monstres':'CdM',
  2053. 'Construire un Piege':'Piege',
  2054. 'Piege a Feu':'PiegeFeu',
  2055. 'Piege a Glue':'PiegeGlue',
  2056. 'Contre-Attaquer':'CA',
  2057. 'Coup de Butoir':'CdB',
  2058. 'Course':'Course',
  2059. 'Deplacement Eclair':'DE',
  2060. 'Dressage':'Dressage',
  2061. 'Ecriture Magique':'EM',
  2062. 'Frenesie':'Frenesie',
  2063. 'Golemologie':'Golemo',
  2064. 'Golem de cuir':'GolemCuir',
  2065. 'Golem de metal':'GolemMetal',
  2066. 'Golem de mithril':'GolemMithril',
  2067. 'Golem de papier':'GolemPapier',
  2068. 'Grattage':'Grattage',
  2069. 'Hurlement Effrayant':'HE',
  2070. 'Identification des Champignons':'IdC',
  2071. 'Insultes':'Insultes',
  2072. 'Lancer de Potions':'LdP',
  2073. 'Marquage':'Marquage',
  2074. 'Melange Magique':'Melange',
  2075. 'Miner':'Miner',
  2076. 'Travail de la Pierre':'Pierre',
  2077. 'Necromancie':'Necro',
  2078. 'Painthure de Guerre':'PG',
  2079. 'Parer':'Parer',
  2080. 'Pistage':'Pistage',
  2081. 'Planter un Champignon':'PuC',
  2082. 'Regeneration Accrue':'RA',
  2083. 'Reparation':'Reparation',
  2084. 'Retraite':'Retraite',
  2085. 'RotoBaffe':'RB',
  2086. 'Shamaner':'Shamaner',
  2087. "S'interposer":'SInterposer',
  2088. 'Tailler':'Tailler',
  2089. //'Vol':'Vol',
  2090. /* Sortilèges */
  2091. 'Analyse Anatomique':'AA',
  2092. 'Armure Etheree':'AE',
  2093. 'Augmentation de l´Attaque':'AdA', // obsolète?
  2094. "Augmentation de l'Attaque":'AdA',
  2095. 'Augmentation de l´Esquive':'AdE',
  2096. 'Augmentation des Degats':'AdD',
  2097. 'Bulle Anti-Magie':'BAM',
  2098. 'Bulle Magique':'BuM',
  2099. 'Explosion':'Explo',
  2100. 'Faiblesse Passagere':'FP',
  2101. 'Flash Aveuglant':'FA',
  2102. 'Glue':'Glue',
  2103. 'Griffe du Sorcier':'GdS',
  2104. 'Hypnotisme':'Hypno',
  2105. 'Identification des Tresors':'IdT',
  2106. 'Invisibilite':'Invi',
  2107. 'Levitation':'Levitation',
  2108. 'Precision Magique':'PreM',
  2109. 'Projectile Magique':'Projo',
  2110. 'Projection':'Proj',
  2111. 'Puissance Magique':'PuM',
  2112. 'Rafale Psychique':'Rafale',
  2113. 'Sacrifice':'Sacro',
  2114. 'Siphon des ames':'Siphon',
  2115. 'Telekinesie':'Telek',
  2116. 'Teleportation':'TP',
  2117. 'Vampirisme':'Vampi',
  2118. 'Vision Accrue':'VA',
  2119. 'Vision lointaine':'VL',
  2120. 'Voir le Cache':'VlC',
  2121. 'Vue Troublee':'VT'
  2122. //'':''
  2123. }
  2124.  
  2125. // DEBUG - Pour rétrocompatibilité
  2126. function getSortComp(nom,niveau) {
  2127. return getTalent(nom,niveau);
  2128. }
  2129. //
  2130.  
  2131. function getTalent(nom,niveau) {
  2132. if(nom===true) return true;
  2133. var nomEnBase = arrayTalents[epure(nom)];
  2134. if(!nomEnBase) nomEnBase=nom;
  2135. if(!niveau) var niveau = '';
  2136. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2137. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  2138. return 0;
  2139. }
  2140.  
  2141. function removeAllTalents() {
  2142. for(var talent in arrayTalents) {
  2143. var nomEnBase = arrayTalents[talent];
  2144. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2145. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2146. continue;
  2147. }
  2148. var niveau = 1;
  2149. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2150. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2151. niveau++;
  2152. }
  2153. }
  2154. }
  2155.  
  2156. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2157. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2158. var att = MY_getValue(numTroll+'.caracs.attaque');
  2159. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2160. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2161. var mm = MY_getValue(numTroll+'.caracs.mm');
  2162. var deg = MY_getValue(numTroll+'.caracs.degats');
  2163. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2164. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2165. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2166. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2167. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2168. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2169. return false;
  2170. return true;
  2171. } catch(e) {
  2172. return false;
  2173. }
  2174. }
  2175.  
  2176.  
  2177. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2178.  
  2179. function getPVsRestants(pv,bless,vue) {
  2180. bless = Number(bless.match(/\d+/)[0]);
  2181. if(bless==0) return null;
  2182. var pvminmax = pv.match(/\d+/g);
  2183. var oMinMaxPV = {min: pvminmax[0], max: pvminmax[1]};
  2184. var oMinMaxPVRestant = MZ_getPVsRestants(oMinMaxPV, bless);
  2185. return vue ? ' ('+oMinMaxPVRestant.min+'-'+oMinMaxPVRestant.max+')' :
  2186. ['Points de Vie restants : ','Entre '+oMinMaxPVRestant.min+' et '+oMinMaxPVRestant.max];
  2187. /* à supprimer
  2188. if(bless==95) {
  2189. var pvb = 1;
  2190. var pvh = Math.floor( pvminmax[1]/20 );
  2191. }
  2192. else if(bless==5) {
  2193. var pvb = Math.floor( pvminmax[0]*19/20 );
  2194. var pvh = pvminmax[1];
  2195. }
  2196. else {
  2197. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2198. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2199. }
  2200. return vue ? ' ('+pvb+'-'+pvh+')' :
  2201. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2202. }
  2203. */
  2204. }
  2205.  
  2206. function MZ_getPVsRestants(oMinMaxPV, bless) { // rend un objet minmax
  2207. if(bless==95) {
  2208. return {min: 1, max:Math.floor( oMinMaxPV.max/20 )};
  2209. } else if(bless==5) {
  2210. return {min: Math.floor( oMinMaxPV.min*19/20 ), max: oMinMaxPV.max};
  2211. } else {
  2212. return {min: Math.ceil( oMinMaxPV.min*(95-bless) / 100 ), max: Math.floor( oMinMaxPV.max*(105-bless) / 100 )};
  2213. }
  2214. }
  2215.  
  2216. function insertButtonCdm(nextName,onClick,texte) {
  2217. if(texte==null) texte = 'Participer au bestiaire';
  2218. var nextNode = document.getElementsByName(nextName)[0];
  2219.  
  2220. var espace = document.createTextNode('\t');
  2221. insertBefore(nextNode,espace);
  2222.  
  2223. var button = document.createElement('input');
  2224. button.type = 'button';
  2225. button.className = 'mh_form_submit';
  2226. button.value = texte;
  2227. button.onmouseover = function(){this.style.cursor='pointer';};
  2228. if(onClick) button.onclick = onClick;
  2229. insertBefore(espace,button);
  2230. return button;
  2231. }
  2232.  
  2233. /* appelé par
  2234. createCDMTable (dans le popup DcM)
  2235. computeTactique (à coté du nom des monstres dans la vue et dans la page de détail des monstres)
  2236. */
  2237. function createImageTactique(url,id,nom) {
  2238. var img = document.createElement('img');
  2239. img.src = url;
  2240. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  2241. img.id = id;
  2242. img.nom = nom;
  2243. img.onmouseover = showPopupTactique;
  2244. img.onmouseout = hidePopup;
  2245. return img;
  2246. }
  2247.  
  2248. function createCDMTable(id,nom,donneesMonstre, closeFunct) { // rend un Élément Table
  2249. try {
  2250. var table = document.createElement('table');
  2251. var profilActif = isProfilActif();
  2252. table.className = 'mh_tdborder';
  2253. table.border = 0;
  2254. table.cellSpacing = 1;
  2255. table.cellPadding = 4;
  2256.  
  2257. var thead = document.createElement('thead');
  2258. var tr = appendTr(thead,'mh_tdtitre');
  2259. var td = appendTdText(tr, 'CDM de ' + nom + ' (N° '+ id + ')', false);
  2260. td.style.fontWeight = 'bold';
  2261. if (closeFunct) {
  2262. td.colSpan = 2;
  2263. td.style.borderRight = 'none';
  2264. td = appendTdText(tr, 'X', false);
  2265. td.style.cursor = 'pointer';
  2266. td.style.textAlign = 'right';
  2267. td.style.fontWeight = 'bold';
  2268. td.style.width = '1%';
  2269. td.style.borderLeft = 'none';
  2270. td.onclick = closeFunct;
  2271. } else {
  2272. td.colSpan = 3;
  2273. }
  2274. table.appendChild(thead);
  2275. var tbody = document.createElement('tbody');
  2276. table.appendChild(tbody);
  2277.  
  2278. // calcul des PX gagnés
  2279. var ominmaxPX = {};
  2280. if (donneesMonstre.niv) {
  2281. if (donneesMonstre.niv.min) ominmaxPX.min = getPXKill(donneesMonstre.niv.min);
  2282. if (donneesMonstre.niv.max) ominmaxPX.max = getPXKill(donneesMonstre.niv.max);
  2283. }
  2284.  
  2285. MZ_tab_carac_add_tr_minmax2(tbody, 'Niveau', donneesMonstre.niv, 'PX', ominmaxPX);
  2286. MZ_tab_carac_add_tr_texte(tbody, 'Famille', donneesMonstre.fam, '');
  2287. //MZ_tab_carac_add_tr_texte(tbody, 'Génération', donneesMonstre.gen == 23 ? '2 ou 3' : donneesMonstre.gen, ''); // remplacé par une icône
  2288. MZ_tab_carac_add_tr_texte(tbody, 'Blessure', MZ_tab_carac_mkBlessureTexte(donneesMonstre), '');
  2289. MZ_tab_carac_add_tr_minmax(tbody, 'Points de Vie', donneesMonstre.pv, 'PV');
  2290. MZ_tab_carac_add_tr_minmax(tbody, 'Attaque', donneesMonstre.att, 'D6');
  2291. MZ_tab_carac_add_tr_minmax(tbody, 'Esquive', donneesMonstre.esq, 'D6');
  2292. MZ_tab_carac_add_tr_minmax(tbody, 'Dégâts', donneesMonstre.deg, 'D3');
  2293. MZ_tab_carac_add_tr_minmax(tbody, 'Régénération', donneesMonstre.reg, 'D3');
  2294. MZ_tab_carac_add_tr_minmax(tbody, 'Armure physique', donneesMonstre.armP, '');
  2295. MZ_tab_carac_add_tr_minmax(tbody, 'Armure magique', donneesMonstre.armM, '');
  2296. MZ_tab_carac_add_tr_minmax(tbody, 'Armure totale', donneesMonstre.arm, '');
  2297. MZ_tab_carac_add_tr_minmax(tbody, 'Vue', donneesMonstre.vue, 'Case(s)');
  2298. MZ_tab_carac_add_tr_minmax(tbody, 'MM', donneesMonstre.MM, '');
  2299. MZ_tab_carac_add_tr_minmax(tbody, 'RM', donneesMonstre.RM, '');
  2300. MZ_tab_carac_add_tr_minmax(tbody, 'Durée du tour', donneesMonstre.duree, ' heures');
  2301. MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre);
  2302. MZ_tab_carac_add_tr_autres(tbody, donneesMonstre, id, nom);
  2303. /* à supprimer, remplacé par un "title" sur le 3e td de "autres"
  2304. var msgInfo = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2305. if (msgInfo) MZ_tab_carac_add_tr_sansTitre(tbody, msgInfo, 0, true);
  2306. */
  2307. return table;
  2308. }
  2309. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2310. }
  2311.  
  2312. function MZ_tab_carac_mkBlessureTexte(donneesMonstre) {
  2313. if (donneesMonstre.bless === undefined) return;
  2314. var texte = donneesMonstre.bless + '%';
  2315. if (donneesMonstre.bless > 0 && donneesMonstre.pv && donneesMonstre.pv.min && donneesMonstre.pv.max) {
  2316. ominmax = MZ_getPVsRestants(donneesMonstre.pv, donneesMonstre.bless);
  2317. texte += ' (' + ominmax.min + '-' + ominmax.max + ')';
  2318. }
  2319. if (donneesMonstre.timegmt) {
  2320. texte += ' le ' + MZ_formatDateMS(new Date(donneesMonstre.timegmt * 1000), true);
  2321. }
  2322. return texte;
  2323. }
  2324.  
  2325. function MZ_tab_carac_add_tr_sansTitre(table, msg, bItalic) {
  2326. if (!msg) return;
  2327. var tr = appendTr(table,'mh_tdpage');
  2328. td = appendTdText(tr,msg);
  2329. td.colSpan = 3;
  2330. if (bItalic) td.style.fontStyle = 'italic';
  2331. td.className = 'mh_tdpage';
  2332. return td;
  2333. }
  2334.  
  2335. function MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre) {
  2336. if (!donneesMonstre.pouv) return;
  2337. var td = MZ_tab_carac_add_tr_texte(tbody, 'Pouvoir', donneesMonstre.pouv + ' ', '', 0);
  2338. var tabImg = [];
  2339. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.portpouv, {
  2340. 'de zone': ["zone.gif","Pouvoir de zone"],
  2341. 'automatique': ["automatique.gif","Pouvoir automatique"],
  2342. 'au toucher': ["toucher.gif","Pouvoir au toucher"]});
  2343. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2344. var thisImg = tabImg[iImg];
  2345. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2346. }
  2347. }
  2348.  
  2349. function MZ_tab_carac_add_tr_autres(table, donneesMonstre, id, nom) {
  2350. var tabImg = [];
  2351. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attd, {
  2352. '1': ["distance.gif","Attaque à distance"],
  2353. '~': ["cac.gif","Corps à corps"]}); // si absent
  2354. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.nb_att, {
  2355. '1': ["1.gif","1 attaque par tour"],
  2356. '2': ["2.gif","2 attaques par tour"],
  2357. '3': ["3.gif","3 attaques par tour"],
  2358. '4': ["4.gif","4 attaques par tour"],
  2359. '5': ["5.gif","5 attaques par tour"],
  2360. '6': ["6.gif","6 attaques par tour"],
  2361. '999': ["plus.gif","Beaucoup d'attaques par tour"]});
  2362. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attm, {
  2363. '1': ["magic-wand.png","Attaque magique"]});
  2364. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vit, {
  2365. 'lente': ["lent.gif","Lent à se déplacer"],
  2366. 'normale': ["normal.gif","Vitesse normale de déplacement"],
  2367. 'rapide': ["rapide.gif","Déplacement rapide"]});
  2368. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.charg, {
  2369. 'vide': [null,null],
  2370. '~': ["charge2.gif", "Possède de l'équipement (" + donneesMonstre.charg + ")"]});
  2371. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vlc, {
  2372. '1': ["oeil.gif","Voit le caché"]});
  2373. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.gen, {
  2374. '1': ["Phoenix1.png","Phœnix de première génération"],
  2375. '2': ["Phoenix2.png","Phœnix de deuxième génération"],
  2376. '3': ["Phoenix3.png","Phœnix de troisième génération"],
  2377. '23': ["Phoenix23.png","Phœnix de deuxième ou troisième génération"],
  2378. });
  2379.  
  2380. var tr = appendTr(table,'mh_tdpage');
  2381. var td = appendTdText(tr,'Autres',true);
  2382. td.className = 'mh_tdtitre';
  2383. td.width = MZ_EtatCdMs.tdWitdh;
  2384.  
  2385. td = appendTd(tr);
  2386. td.className = 'mh_tdpage';
  2387. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2388. var thisImg = tabImg[iImg];
  2389. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2390. }
  2391. if (donneesMonstre.esq != undefined) td.appendChild(createImageTactique(URL_MZimg+"calc.png", id, nom), null);
  2392.  
  2393. var txt = String.fromCharCode(160); // blanc insécable
  2394. if (donneesMonstre.nCdM) txt = donneesMonstre.nCdM;
  2395. var td2 = appendTdText(tr, txt);
  2396. td2.title = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2397. td2.style.width = '1%';
  2398. var myColor = MZ_CdMColorFromMode(donneesMonstre);
  2399. if (myColor) {
  2400. td2.style.backgroundColor = myColor;
  2401. td2.style.color = 'white';
  2402. }
  2403.  
  2404. return td;
  2405. }
  2406.  
  2407. function MZ_tab_carac_add_tr_one_img(tabImg, val, listCas) {
  2408. if (val == undefined) return;
  2409. //console.log('MZ_tab_carac_add_tr_one_img: val=' + val);
  2410. var lVal = (val + '').toLowerCase(); // astuce : transformer le nombre en string (beurk !)
  2411. if (listCas[lVal]) {
  2412. var t = listCas[lVal];
  2413. if (t[0] == null) return;
  2414. tabImg.push(t);
  2415. } else if (listCas['~']) {
  2416. tabImg.push(listCas['~']);
  2417. }
  2418. }
  2419.  
  2420. function MZ_tab_carac_add_tr_texte(table, titre, msg, unit) {
  2421. if (!msg) return;
  2422. var tr = appendTr(table,'mh_tdpage');
  2423.  
  2424. var td = appendTdText(tr,titre,true);
  2425. td.className = 'mh_tdtitre';
  2426. td.width = MZ_EtatCdMs.tdWitdh;
  2427.  
  2428. var texte = msg;
  2429. if (unit) texte += ' ' + unit;
  2430. td = appendTdText(tr,texte);
  2431. td.colSpan = 2;
  2432. td.className = 'mh_tdpage';
  2433. return td;
  2434. }
  2435.  
  2436. function MZ_tab_carac_add_tr_minmax(table, titre, ominmax, unit) {
  2437. if (!ominmax) return;
  2438. if (!(ominmax.min || ominmax.max)) return;
  2439.  
  2440. var tr = appendTr(table,'mh_tdpage');
  2441.  
  2442. var td = appendTdText(tr,titre,true);
  2443. td.className = 'mh_tdtitre';
  2444. td.width = MZ_EtatCdMs.tdWitdh;
  2445.  
  2446. if ((!ominmax.min) || ominmax.min == 0) {
  2447. var texte = '\u2A7D' + ominmax.max + '\u00A0' + unit; // <= (mais plus beau)
  2448. } else if (!ominmax.max) {
  2449. var texte = '\u2A7E' + ominmax.min + '\u00A0' + unit; // >=
  2450. } else {
  2451. var texte = '';
  2452. if (ominmax.min != ominmax.max) {
  2453. var texte = ominmax.min + '-' + ominmax.max + '\u00A0-->\u00A0';
  2454. if (ominmax.min > ominmax.min) {
  2455. td.style.color = 'red';
  2456. unit += ' *** erreur ***';
  2457. }
  2458. }
  2459. texte += ((ominmax.min + ominmax.max)/2) + '\u00A0' + unit;
  2460. }
  2461. td = appendTdText(tr,texte);
  2462. if (ominmax.min2 || ominmax.max2) { // affichage de l'intervalle de confiance à 80%
  2463. if (!ominmax.min2) {
  2464. var txt2 = '\u2A7D' + ominmax.max2; // <= (mais plus beau)
  2465. } else if (!ominmax.max2) {
  2466. var txt2 = '\u2A7E' + ominmax.min2; // >=
  2467. } else {
  2468. var txt2 = ominmax.min2 + '-' + ominmax.max2;
  2469. }
  2470. var span = document.createElement('span');
  2471. span.appendChild(document.createTextNode(txt2));
  2472. span.style.float = 'right';
  2473. span.style.textAlign = 'right';
  2474. span.style.background = 'yellow';
  2475. td.insertBefore(span, td.firstChild);
  2476. table.title = "En jaune : intervalle de confiance à 80%";
  2477. }
  2478. td.colSpan = 2;
  2479. td.className = 'mh_tdpage';
  2480. return td;
  2481. }
  2482.  
  2483. function MZ_tab_carac_add_tr_minmax2(table, titre, ominmax, unit, ominmaxUnit) {
  2484. if (!ominmax) return;
  2485. if (!(ominmax.min || ominmax.max)) return;
  2486.  
  2487. var tr = appendTr(table,'mh_tdpage');
  2488.  
  2489. var td = appendTdText(tr,titre,true);
  2490. td.className = 'mh_tdtitre';
  2491. td.width = MZ_EtatCdMs.tdWitdh;
  2492.  
  2493. if ((!ominmax.min) || ominmax.min == 0) {
  2494. var texte = '\u2A7D' + ominmax.max;
  2495. } else if (!ominmax.max) {
  2496. var texte = '\u2A7E' + ominmax.min;
  2497. } else {
  2498. var texte = '';
  2499. if (ominmax.min != ominmax.max) {
  2500. var texte = ominmax.min + '-' + ominmax.max;
  2501. if (ominmax.min > ominmax.max) {
  2502. td.style.color = 'red';
  2503. texte += ' *** erreur ***';
  2504. }
  2505. } else {
  2506. var texte = ominmax.min;
  2507. }
  2508. }
  2509.  
  2510. if (ominmaxUnit.min === undefined) {
  2511. if (ominmaxUnit.max === undefined) {
  2512. // ignore (ne devrait pas arriver)
  2513. } else {
  2514. texte += ' --> ' + unit + '\u2A7D' + ominmaxUnit.max;
  2515. }
  2516. } else {
  2517. if (ominmaxUnit.max === undefined) {
  2518. texte += ' --> ' + unit + '\u2A7E' + ominmaxUnit.min;
  2519. } else if (ominmaxUnit.min != ominmaxUnit.max) {
  2520. texte += ' --> ' + ominmaxUnit.min + '\u2A7D' + unit + '\u2A7D' + ominmaxUnit.max;
  2521. if (ominmaxUnit.min > ominmaxUnit.max) {
  2522. td.style.color = 'red';
  2523. texte += ' *** erreur ***';
  2524. }
  2525. } else if (isNaN(ominmaxUnit.min)) {
  2526. texte += ' --> ' + ominmaxUnit.min;
  2527. } else {
  2528. texte += ' --> ' + ominmaxUnit.max + '\u00A0' + unit;
  2529. }
  2530. }
  2531.  
  2532. td = appendTdText(tr,texte);
  2533. td.colSpan = 2;
  2534. td.className = 'mh_tdpage';
  2535. return td;
  2536. }
  2537.  
  2538.  
  2539. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2540.  
  2541. var listeMonstreEnchantement = null,
  2542. listeEquipementEnchantement = null,
  2543. listeInfoEnchantement = null;
  2544.  
  2545. function computeCompoEnchantement()
  2546. {
  2547. listeMonstreEnchantement = new Array();
  2548. listeInfoEnchantement = new Array();
  2549. listeEquipementEnchantement = new Array();
  2550. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2551. for(var i=0;i<liste.length;i++)
  2552. {
  2553. var idEquipement = liste[i]*1;
  2554. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2555. continue;
  2556. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2557. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2558. var texteGlobal='';
  2559. for(var j=0;j<3;j++)
  2560. {
  2561. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2562. var v = MY_getValue(k);
  2563. var infoComposant = MY_getValue().split(';');
  2564. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2565. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2566. continue;
  2567. }
  2568. listeMonstreEnchantement[infoComposant[2]] = 1;
  2569. var array = new Array();
  2570. array[0]=infoComposant[0].replace("Ril","Œil");
  2571. array[1]=infoComposant[1];
  2572. array[2]=infoComposant[2];
  2573. array[3]=getQualite(infoComposant[3]);
  2574. var texte = infoComposant[4].replace("Ril","Œil");
  2575. for(var k=5;k<infoComposant.length;k++)
  2576. {
  2577. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2578. }
  2579. texteGlobal+=texte+'\n';
  2580. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2581. array[4]=texte;
  2582. listeInfoEnchantement.push(array);
  2583. }
  2584. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2585. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2586. }
  2587.  
  2588. }
  2589.  
  2590. function isEnchant(nom) {
  2591. var monstreEnchant = '';
  2592. for(j in listeInfoEnchantement) {
  2593. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2594. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2595. monstreEnchant=monstre;
  2596. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2597. }
  2598. }
  2599. return trim(monstreEnchant);
  2600. }
  2601.  
  2602. function getInfoEnchantementFromMonstre(nom)
  2603. {
  2604. try
  2605. {
  2606. if(!listeMonstreEnchantement)
  2607. {
  2608. computeCompoEnchantement();
  2609. }
  2610. var infosEnchant = '';
  2611. for(j in listeInfoEnchantement) {
  2612. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2613. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2614. if(infosEnchant=='')
  2615. infosEnchant=listeInfoEnchantement[j][4];
  2616. else
  2617. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2618. }
  2619. }
  2620. return trim(infosEnchant);
  2621. }
  2622. catch(e)
  2623. {
  2624. window.alert(e);
  2625. }
  2626. }
  2627.  
  2628. function composantEnchant(Monstre,composant,localisation,qualite) {
  2629. var compo='';
  2630. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2631. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2632. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2633. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2634. listeInfoEnchantement[i][3]<=qualite
  2635. ) {
  2636. return listeInfoEnchantement[i][4];
  2637. }
  2638. }
  2639. return compo;
  2640. }
  2641.  
  2642. function insertEnchantInfos(tbody) {
  2643. try
  2644. {
  2645. if(!listeMonstreEnchantement)
  2646. computeCompoEnchantement();
  2647. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2648. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2649. if(nodes.snapshotLength == 0)
  2650. return false;
  2651. var urlImg = URL_MZimg + 'enchant.png';
  2652. for(var i = 0; i < nodes.snapshotLength; i++) {
  2653. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2654. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2655. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2656. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2657. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2658. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2659. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2660. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2661. if(isEnchant(nomMonstre).length>0)
  2662. {
  2663. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2664. if(infos.length>0)
  2665. {
  2666. if(link.parentNode == link.nextSibling.parentNode)
  2667. {
  2668. var tmp = link.nextSibling;
  2669. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2670. }
  2671. else
  2672. {
  2673. link.parentNode.appendChild(createImage(urlImg,infos));
  2674. }
  2675. }
  2676. }
  2677. }
  2678. }
  2679. catch(e)
  2680. {
  2681. window.alert(e);
  2682. }
  2683. }
  2684.  
  2685. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2686. {
  2687. try
  2688. {
  2689. if(!listeMonstreEnchantement)
  2690. computeCompoEnchantement();
  2691. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2692. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2693. if(nodes.snapshotLength == 0)
  2694. return false;
  2695. var urlImg = URL_MZimg + 'enchant.png';
  2696. for(var i = 0; i < nodes.snapshotLength; i++)
  2697. {
  2698. var link = nodes.snapshotItem(i);
  2699. var idEquipement = link.getAttribute('href');
  2700. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2701. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2702. var nomEquipement = trim(link.firstChild.nodeValue);
  2703. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2704. if(!enchanteur || enchanteur == '')
  2705. continue;
  2706. var infos = listeEquipementEnchantement[idEquipement];
  2707. infos=formateTexte(infos);
  2708. if(infos.length>0)
  2709. {
  2710. if(link.parentNode == link.nextSibling.parentNode)
  2711. {
  2712. var tmp = link.nextSibling;
  2713. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2714. }
  2715. else
  2716. {
  2717. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2718. }
  2719. }
  2720. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2721. }
  2722. }
  2723. catch(e)
  2724. {
  2725. window.alert(e);
  2726. }
  2727. }
  2728.  
  2729. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2730.  
  2731.  
  2732. // Les % de toucher
  2733. var c = new Array();
  2734.  
  2735. // coefficients binomiaux
  2736. function cnp(n,k)
  2737. {
  2738. if(c[n] != null && c[n][k] != null)
  2739. return c[n][k];
  2740. if(c[n] == null)
  2741. c[n] = new Array();
  2742. if(k==0)
  2743. {
  2744. c[n][k] = 1;
  2745. return 1;
  2746. }
  2747. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2748. c[n][k] = result;
  2749. // Roule debug
  2750. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2751. return result;
  2752. }
  2753.  
  2754. // by Dab, à comparer
  2755. function binom(n,p) {
  2756. if(p<0 || p>n) return 0;
  2757.  
  2758. if(c[n])
  2759. if(c[n][p]) return c[n][p];
  2760. else {
  2761. c[n]=[1];
  2762. c[n][n]=1;
  2763. if(p==0 || p==n) return 1;
  2764. }
  2765.  
  2766. if(2*p>n)
  2767. c[n][p]=binom(n,n-p);
  2768. else
  2769. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2770.  
  2771. return c[n][p];
  2772. }
  2773.  
  2774. var coeff = new Array();
  2775.  
  2776. function coef(n,p)
  2777. {
  2778. if(n==0 && p==0)
  2779. return 1;
  2780. if(p>n*3.5)
  2781. p = 7*n-p
  2782. // roule désactive cache
  2783. if(coeff[n] != null && coeff[n][p] !=null)
  2784. return coeff[n][p];
  2785. if(coeff[n] == null)
  2786. coeff[n] = new Array();
  2787. var kmax = Math.floor((p-n)/6);
  2788. var x=0;
  2789. for(var k=0;k<=kmax;k++)
  2790. {
  2791. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2792. }
  2793. coeff[n][p] = x;
  2794. // Roule debug
  2795. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2796. return x;
  2797. }
  2798.  
  2799. function chanceEsquiveParfaite(a,d,ba,bd)
  2800. {
  2801. var win = 0;
  2802. var los = 0;
  2803. if(ba==null)
  2804. ba=0;
  2805. if(bd==null)
  2806. bd=0;
  2807. /* if(6*a+ba<2*(d+bd))
  2808. return 100;
  2809. if(a+ba>2*(6*d+bd))
  2810. return 0;*/
  2811. for(var ds=d;ds<=6*d;ds++)
  2812. {
  2813. var cd = coef(d,ds);
  2814. for(var as=a;as<=6*a;as++)
  2815. {
  2816. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2817. win += cd * coef(a,as);
  2818. else
  2819. los += cd * coef(a,as);
  2820. }
  2821. }
  2822. // roule debug
  2823. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2824. return Math.round(100*win/(win+los));
  2825. }
  2826.  
  2827. function chanceTouche(a,d,ba,bd)
  2828. {
  2829. var win = 0;
  2830. var los = 0;
  2831. if(ba==null)
  2832. ba=0;
  2833. if(bd==null)
  2834. bd=0;
  2835. if(a+ba>6*d+bd)
  2836. return 100;
  2837. if(6*a+ba<d+bd)
  2838. return 0;
  2839. for(var ds=d;ds<=6*d;ds++)
  2840. {
  2841. var cd = coef(d,ds);
  2842. for(var as=a;as<=6*a;as++)
  2843. {
  2844. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2845. win += cd * coef(a,as);
  2846. else
  2847. los += cd * coef(a,as);
  2848. }
  2849. }
  2850. return Math.round(100*win/(win+los));
  2851. }
  2852.  
  2853. function chanceCritique(a,d,ba,bd)
  2854. {
  2855. var win = 0;
  2856. var los = 0;
  2857. if(ba==null)
  2858. ba=0;
  2859. if(bd==null)
  2860. bd=0;
  2861. if(a+ba>2*(6*d+bd))
  2862. return 100;
  2863. if(6*a+ba<2*(d+bd))
  2864. return 0;
  2865. for(var ds=d;ds<=6*d;ds++)
  2866. {
  2867. var cd = coef(d,ds);
  2868. for(var as=a;as<=6*a;as++)
  2869. {
  2870. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2871. win += cd * coef(a,as);
  2872. else
  2873. los += cd * coef(a,as);
  2874. }
  2875. }
  2876. return Math.round(100*win/(win+los));
  2877. }
  2878.  
  2879. /***********************************************
  2880. Analyse tactique
  2881. ***********************************************/
  2882.  
  2883. function getTexteAnalyse(modificateur,chiffre)
  2884. {
  2885. if(chiffre==0)
  2886. return chiffre;
  2887. return modificateur+ chiffre;
  2888. }
  2889.  
  2890. // rend le HTML pour le tableau de la "calculette"
  2891. function getAnalyseTactique(id,nom) {
  2892. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  2893. var needAutres=false;
  2894. var i;
  2895. if(donneesMonstre == null)
  2896. return;
  2897. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2898. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2899. if(array==null)
  2900. return "";
  2901. 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>";
  2902. for(i=0;i<array.length;i++)
  2903. {
  2904. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2905. {
  2906. needAutres=true;
  2907. break;
  2908. }
  2909. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2910. 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>";
  2911. else if(i==0) // attaque du monstre sur le Trõll => italique
  2912. 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>";
  2913. else // autre, pas de décoration
  2914. 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>";
  2915. }
  2916. if(needAutres)
  2917. {
  2918. if(i==array.length-1)
  2919. 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>";
  2920. else if(i==1)
  2921. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2922. else
  2923. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2924. }
  2925. var txtCdM = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2926. if (txtCdM) str += '<tr class="mh_tdpage"><td colspan="5" style="font-style: italic;">' + txtCdM + '</td></tr>';
  2927. return str+"</table>";
  2928. }
  2929.  
  2930. function MZ_carac_build_nb_cmd_msg(donneesMonstre) {
  2931. if (!donneesMonstre) return;
  2932. if (!donneesMonstre.Mode) return;
  2933. switch (donneesMonstre.Mode) {
  2934. case 'cdm':
  2935. return 'fondé sur ' + (+donneesMonstre.nCdM) + ' CdM' + (donneesMonstre.nCdM > 1 ? 's' : '') + ' de ce monstre à cet âge';
  2936. case 'stat':
  2937. return 'fondé sur les statistiques de ' + (+donneesMonstre.nCdM) + ' CdM' + (donneesMonstre.nCdM > 1 ? 's' : '') + ' de ce type de monstre (même type, même âge, même template)';
  2938. case 'statV1':
  2939. return 'fondé sur les statistiques anciennes (MZ V1)';
  2940. case 'nom':
  2941. return 'fondé sur le nom du monstre, pas de CdM';
  2942. }
  2943. return 'Mode ' + donneesMonstre.Mode;
  2944. }
  2945.  
  2946. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2947. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2948. function analyseTactique(donneesMonstre,nom) {
  2949. try
  2950. {
  2951. var listeAttaques = [];
  2952. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2953. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2954. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2955. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2956. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2957. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2958. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2959. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2960. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2961. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2962. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2963. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2964. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2965. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2966. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2967. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2968. var modificateurEsquive = '';
  2969. var modificateurArmure = '';
  2970. var modificateurMagie = '';
  2971. var modificateurEsquiveM = '';
  2972. var modificateurArmureM = '';
  2973. var pasDeSR=false;
  2974. var esqM=0,attM=0,armM_mag=0,armM_tot=0,degM=0;
  2975. 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)
  2976. return null;
  2977.  
  2978. if (MY_DEBUG) window.console.log('analyseTactique nom=' + nom + ' ' + JSON.stringify(donneesMonstre));
  2979. if (donneesMonstre.index == undefined) {
  2980. // à supprimer
  2981. var td = document.createElement('td')
  2982. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2983. var esqM = 0;
  2984. try
  2985. {
  2986. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2987. }
  2988. catch(e)
  2989. {
  2990. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  2991. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2992. modificateurEsquive = '<';
  2993. modificateurArmure = '<';
  2994. modificateurMagie = '<';
  2995. }
  2996.  
  2997. td.innerHTML = bbcode(donneesMonstre[3]);
  2998. var attM = 0;
  2999. try
  3000. {
  3001. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3002. }
  3003. catch(e)
  3004. {
  3005. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  3006. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3007. modificateurEsquiveM = '>';
  3008. modificateurArmureM = '>';
  3009. }
  3010.  
  3011. td.innerHTML = bbcode(donneesMonstre[5]);
  3012. var degM = 0;
  3013. try
  3014. {
  3015. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3016. }
  3017. catch(e)
  3018. {
  3019. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  3020. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3021. modificateurArmureM = '>';
  3022. }
  3023.  
  3024. td.innerHTML = bbcode(donneesMonstre[7]);
  3025. try
  3026. {
  3027. armM_tot=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3028. armM_mag=armM_tot; // compatibilité avec ancien calcul
  3029. }
  3030. catch(e)
  3031. {
  3032. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  3033. armM_tot=Math.ceil(parseInt(td.firstChild.nodeValue));
  3034. armM_mag=armM_tot;
  3035. modificateurArmure = '<';
  3036. }
  3037.  
  3038. var coeffSeuil = 0.95;
  3039. try
  3040. {
  3041. td.innerHTML = bbcode(donneesMonstre[9]);
  3042. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  3043. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3044. var v = (rm / mm);
  3045. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3046. coeffSeuil = (200-seuil)/200;
  3047. }
  3048. catch(e)
  3049. {
  3050. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  3051. modificateurMagie = '<';
  3052. pasDeSR = true;
  3053. }
  3054. } else {
  3055. //calcul de modificateurEsquive, modificateurArmure, modificateurMagie, modificateurEsquiveM, modificateurArmureM, pasDeSR, esqM, attM, armM_mag, armM_tot, degM;
  3056. if (donneesMonstre.esq) {
  3057. if (donneesMonstre.esq.min && donneesMonstre.esq.max) {
  3058. esqM = Math.ceil((donneesMonstre.esq.min + donneesMonstre.esq.max) / 2);
  3059. } else if (donneesMonstre.esq.max) {
  3060. esqM = donneesMonstre.esq.max;
  3061. modificateurEsquive = '<';
  3062. modificateurArmure = '<';
  3063. modificateurMagie = '<';
  3064. }
  3065. }
  3066.  
  3067. if (donneesMonstre.att) {
  3068. if (donneesMonstre.att.min && donneesMonstre.att.max) {
  3069. attM = Math.ceil((donneesMonstre.att.min + donneesMonstre.att.max) / 2);
  3070. } else if (donneesMonstre.att.max) {
  3071. attM = donneesMonstre.att.max;
  3072. modificateurEsquiveM = '>';
  3073. modificateurArmureM = '>';
  3074. }
  3075. }
  3076.  
  3077. if (donneesMonstre.armM) {
  3078. if (donneesMonstre.armM.min && donneesMonstre.armM.max) {
  3079. armM_mag = Math.ceil((donneesMonstre.armM.min + donneesMonstre.armM.max) / 2);
  3080. } else if (donneesMonstre.armM.max) {
  3081. armM_mag = donneesMonstre.armM.max;
  3082. modificateurArmure = '<';
  3083. }
  3084. if (donneesMonstre.armP) {
  3085. if (donneesMonstre.armP.min && donneesMonstre.armP.max) {
  3086. armM_phy = Math.ceil((donneesMonstre.armP.min + donneesMonstre.armP.max) / 2);
  3087. } else if (donneesMonstre.armP.max) {
  3088. armM_phy = donneesMonstre.armP.max;
  3089. modificateurArmure = '<';
  3090. }
  3091. armM_tot = armM_mag + armM_phy;
  3092. } else { // ça ne devrait pas arriver
  3093. armM_tot = armM_mag;
  3094. }
  3095. } else if (donneesMonstre.arm) {
  3096. if (donneesMonstre.arm.min && donneesMonstre.arm.max) {
  3097. armM_tot = Math.ceil((donneesMonstre.arm.min + donneesMonstre.arm.max) / 2);
  3098. armM_mag=armM_tot; // worst case
  3099. } else if (donneesMonstre.arm.max) {
  3100. armM_tot = donneesMonstre.arm.max;
  3101. armM_mag=armM_tot;
  3102. modificateurArmure = '<';
  3103. }
  3104. }
  3105.  
  3106. if (donneesMonstre.deg) {
  3107. if (donneesMonstre.deg.min && donneesMonstre.deg.max) {
  3108. degM = Math.ceil((donneesMonstre.deg.min + donneesMonstre.deg.max) / 2);
  3109. } else if (donneesMonstre.deg.max) {
  3110. degM = donneesMonstre.deg.max;
  3111. modificateurArmureM = '>';
  3112. }
  3113. }
  3114.  
  3115. var coeffSeuil = 0.95;
  3116. if (donneesMonstre.RM) {
  3117. if (donneesMonstre.RM.min && donneesMonstre.RM.max) {
  3118. var rmM = Math.ceil((donneesMonstre.RM.min + donneesMonstre.RM.max) / 2);
  3119. var v = (rmM / mm);
  3120. var seuil = (rmM < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3121. coeffSeuil = (200-seuil)/200;
  3122. } else if (donneesMonstre.deg.max) {
  3123. }
  3124. modificateurMagie = '<';
  3125. pasDeSR = true;
  3126. }
  3127. }
  3128. if (MY_DEBUG) window.console.log('modificateurEsquive=' + modificateurEsquive + ', modificateurArmure=' + modificateurArmure + ', modificateurMagie=' + modificateurMagie + ', modificateurEsquiveM=' + modificateurEsquiveM + ', modificateurArmureM=' + modificateurArmureM + ', pasDeSR=' + pasDeSR + ', esqM=' + esqM + ', attM=' + attM + ', armM_tot=' + armM_tot + ', armM_mag=' + armM_mag + ', degM=' + degM + ', coeffSeuil=' + coeffSeuil);
  3129.  
  3130. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  3131. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  3132. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  3133. // roule debug
  3134. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  3135. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  3136. var degats = (((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmp+degbmm-armM_tot,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmp+degbmm-armM_tot,1))/100);
  3137. //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);
  3138. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3139. if(getSortComp("Vampirisme")>0)
  3140. {
  3141. var pour = getSortComp("Vampirisme");
  3142. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3143. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3144. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3145. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm-armM_mag,1)))/100;
  3146. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3147. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3148. }
  3149. if(getSortComp("Siphon des âmes")>0)
  3150. {
  3151. var pour = getSortComp("Siphon des âmes");
  3152. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3153. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3154. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3155. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm-armM_mag,1))/100);
  3156. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3157. }
  3158. if(getSortComp("Botte Secrète")>0)
  3159. {
  3160. var pour = getSortComp("Botte Secrète");
  3161. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3162. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3163. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3164. degats = Math.round(((chanceDeTouche-chanceDeCritique)*Math.max(Math.floor(deg/2)*2+Math.floor((degbmp+degbmm)/2)-Math.floor(armM_tot/2),1)+chanceDeCritique*Math.max(Math.floor(deg*1.5/2)*2+Math.floor((degbmp+degbmm)/2)-Math.floor(armM_tot/2),1)))/100;
  3165. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3166. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3167. }
  3168. if(getSortComp("Rafale Psychique")>0)
  3169. {
  3170. var pour = getSortComp("Rafale Psychique");
  3171. chanceDEsquiveParfaite = 0;
  3172. chanceDeTouche = Math.round(100*pour/100);
  3173. chanceDeCritique = Math.round(0*pour/100);
  3174. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm-armM_mag,1)))/100;
  3175. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3176. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3177. }
  3178. if(getSortComp("Explosion")>0)
  3179. {
  3180. var pour = getSortComp("Explosion");
  3181. chanceDEsquiveParfaite = 0;
  3182. chanceDeTouche = Math.round(100*pour/100);
  3183. chanceDeCritique = Math.round(0*pour/100);
  3184. 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;
  3185. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3186. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3187. }
  3188. if(getSortComp("Projectile Magique")>0)
  3189. {
  3190. var pour = getSortComp("Projectile Magique");
  3191. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  3192. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  3193. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  3194. // distance troll - monstre
  3195. 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-armM_mag,1)))/100;
  3196. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3197. if (donneesMonstre.index !== undefined && MZ_EtatCdMs.tr_monstres !== undefined && MZ_EtatCdMs.tr_monstres[donneesMonstre.index] !== undefined) {
  3198. var dist = getMonstreDistance(donneesMonstre.index);
  3199. //if (isDEV) window.console.log('Dist pour PM=' + dist);
  3200. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  3201. var portee = getPortee__Profil(vue+vue_bm);
  3202. if (dist <= portee) {
  3203. degats = Math.round((degats + 2 * (portee-dist)) * 100) / 100;
  3204. } else {
  3205. degats += ' (plus bonus de portée)';
  3206. }
  3207. debugMZ('analyseTactique, iTR= ' + donneesMonstre.index + ', dist=' + dist + ', porteePM=' + portee);
  3208. } else {
  3209. degats += ' (plus bonus de portée)';
  3210. }
  3211. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3212. }
  3213. if(getSortComp("Frénésie")>0)
  3214. {
  3215. var pour = getSortComp("Frénésie");
  3216. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3217. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3218. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3219. degats = Math.round(((chanceDeTouche-chanceDeCritique)*2*Math.max((deg*2+degbmp+degbmm-armM_tot),1)+chanceDeCritique*2*Math.max(Math.floor(deg*1.5)*2+degbmm+degbmp-armM_tot,1)))/100;
  3220. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3221. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3222. }
  3223. if(getSortComp("Charger")>0)
  3224. {
  3225. var pour = getSortComp("Charger");
  3226. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3227. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3228. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3229. var degats = Math.round(((chanceDeTouche-chanceDeCritique)*Math.max((deg*2+degbmp+degbmm-armM_tot),1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm+degbmp-armM_tot,1)))/100;
  3230. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3231. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3232. }
  3233. if(getSortComp("Griffe du Sorcier")>0)
  3234. {
  3235. var pour = getSortComp("Griffe du Sorcier");
  3236. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3237. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3238. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3239. 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;
  3240. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3241. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3242. }
  3243. if(getSortComp("Attaque Précise",1)>0)
  3244. {
  3245. var niveau = 5;
  3246. var oldPour = 0;
  3247. var chanceDEsquiveParfaite = 0;
  3248. var chanceDeTouche = 0;
  3249. var chanceDeCritique = 0;
  3250. degats = 0;
  3251. while(niveau>0)
  3252. {
  3253. var pour = getSortComp("Attaque Précise",niveau);
  3254. if(pour>oldPour)
  3255. {
  3256. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3257. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3258. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3259. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3260. chanceDeTouche += chanceDeToucheNiveau;
  3261. chanceDeCritique += chanceDeCritiqueNiveau;
  3262. degats += (((chanceDeToucheNiveau-chanceDeCritiqueNiveau)*Math.max((deg*2+degbmp+degbmm-armM_tot),1)+chanceDeCritiqueNiveau*Math.max(Math.floor(deg*1.5)*2+degbmm+degbmp-armM_tot,1))/100);
  3263. oldPour = pour;
  3264. }
  3265. niveau--;
  3266. }
  3267. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3268. 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));
  3269. }
  3270. if(getSortComp("Coup de Butoir",1)>0)
  3271. {
  3272. var niveau = 5;
  3273. var oldPour =0;
  3274. var chanceDEsquiveParfaite = 0;
  3275. var chanceDeTouche=0;
  3276. var chanceDeCritique=0;
  3277. degats=0;
  3278. while(niveau>0)
  3279. {
  3280. var pour = getSortComp("Coup de Butoir",niveau);
  3281. if(pour>oldPour)
  3282. {
  3283. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3284. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3285. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3286. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3287. chanceDeTouche += chanceDeToucheNiveau;
  3288. chanceDeCritique += chanceDeCritiqueNiveau;
  3289. degats += (((chanceDeToucheNiveau-chanceDeCritiqueNiveau)*Math.max((Math.min(Math.floor(deg*1.5),deg+3*niveau)*2+degbmp+degbmm-armM_tot),1)+chanceDeCritiqueNiveau*Math.max(Math.floor(Math.min(Math.floor(deg*1.5),deg+3*niveau)*1.5)*2+degbmm+degbmp-armM_tot,1))/100);
  3290. oldPour = pour;
  3291. }
  3292. niveau--;
  3293. }
  3294. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3295. 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));
  3296. }
  3297. 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;});
  3298. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  3299. {
  3300. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  3301. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  3302. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  3303. }
  3304. else
  3305. {
  3306. chanceDEsquiveParfaite = 0;
  3307. chanceDeTouche = 100;
  3308. chanceDeCritique = 0;
  3309. }
  3310. 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;
  3311.  
  3312. 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));
  3313. return listeAttaques;
  3314. }
  3315. catch(e) {
  3316. window.console.error(traceStack(e, 'analyseTactique'));
  3317. window.alert(e);
  3318. }
  3319. }
  3320.  
  3321. // x~~x marque pour s'y retrouver sous l'éditeur
  3322.  
  3323. /*
  3324. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  3325. * published under GNU License v2.
  3326. *
  3327. * Patch :
  3328. * gestion des missions terminées
  3329. */
  3330.  
  3331. // x~x mission_liste
  3332.  
  3333. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  3334. try {
  3335. var titresMimis = document.evaluate(
  3336. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  3337. document, null, 7, null
  3338. );
  3339. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3340. } catch(e) {
  3341. window.console.error(traceStack(e, 'mission_liste initialisation'));
  3342. return;
  3343. }
  3344.  
  3345. var enCours = {};
  3346. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  3347. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  3348. enCours[num] = true;
  3349. }
  3350.  
  3351. for(var numMimi in obMissions) {
  3352. if(!enCours[numMimi]) {
  3353. delete obMissions[numMimi];
  3354. }
  3355. }
  3356. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3357. }
  3358.  
  3359. function do_mission_liste() {
  3360. checkLesMimis();
  3361. }
  3362.  
  3363. /*******************************************************************************
  3364. * This file is part of Mountyzilla. *
  3365. * *
  3366. * Mountyzilla is free software; you can redistribute it and/or modify *
  3367. * it under the terms of the GNU General Public License as published by *
  3368. * the Free Software Foundation; either version 2 of the License, or *
  3369. * (at your option) any later version. *
  3370. * *
  3371. * Mountyzilla is distributed in the hope that it will be useful, *
  3372. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3373. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3374. * GNU General Public License for more details. *
  3375. * *
  3376. * You should have received a copy of the GNU General Public License *
  3377. * along with Mountyzilla; if not, write to the Free Software *
  3378. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3379. *******************************************************************************/
  3380.  
  3381. // x~x actions
  3382.  
  3383. /* TODO
  3384. * getLvl pour Explo, Rotobaffe et cie
  3385. */
  3386.  
  3387.  
  3388.  
  3389. /* Page de combat */
  3390.  
  3391. function getLevel() {
  3392. var divList = document.getElementsByTagName('div');
  3393. if(divList.length <= 2)
  3394. return;
  3395.  
  3396. // On essaie de voir si cette action était une attaque
  3397. var pList = document.getElementsByTagName('p');
  3398. var nomM = '';
  3399. // Modification pour Frénésie by TetDure
  3400. var numAtt = 0;
  3401. for (var i = 0; i < pList.length; i++) {
  3402. if(pList[i].firstChild) {
  3403. nomM = pList[i].firstChild.nodeValue;
  3404. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3405. numAtt++;
  3406. }
  3407. }
  3408.  
  3409. if(nomM == '')
  3410. return;
  3411.  
  3412. // Si c'est une attaque normale, un seul PX
  3413. var comPX = 1;
  3414. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3415. comPX++;
  3416.  
  3417. // Extraction des infos du monstre attaqué
  3418. var idM;
  3419. var male;
  3420. if(nomM.slice(20, 21) == 'e') {
  3421. male = false;
  3422. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3423. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3424. }
  3425. else {
  3426. male = true;
  3427. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3428. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3429. }
  3430.  
  3431. if(idM == '')
  3432. return;
  3433.  
  3434. var bList = document.getElementsByTagName('b');
  3435. var niveau = '';
  3436. for (var i = 0; i < bList.length; i++) {
  3437. var b = bList[i];
  3438. if(b.childNodes[0].nodeValue != "TUÉ")
  3439. continue;
  3440. var nbPX = "";
  3441. for (i++; i < bList.length; i++) {
  3442. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3443. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3444. return;
  3445. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3446. nbPX = bList[i].childNodes[0].nodeValue;
  3447. break;
  3448. }
  3449. }
  3450. if(nbPX == '')
  3451. return;
  3452. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3453. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3454. if(!nbPX)
  3455. nbPX = 0;
  3456. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3457. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3458. if(comPX > nbPX) {
  3459. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3460. niveau = "";
  3461. } else if(Math.floor(niveau) == niveau) {
  3462. chaine += niveau + ".";
  3463. } else {
  3464. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3465. niveau = "";
  3466. }
  3467. insertBr(b.nextSibling.nextSibling.nextSibling);
  3468. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3469. }
  3470.  
  3471. if(niveau != '') {
  3472. var button = insertButtonCdm('as_Action');
  3473. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3474. + escape(nomM) + "&niveau=" + escape(niveau)
  3475. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3476. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3477. }
  3478. }
  3479.  
  3480.  
  3481. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3482.  
  3483. function insertInfoMagie(node, intitule, magie) {
  3484. if(node.nextSibling) {
  3485. node = node.nextSibling;
  3486. insertBr(node);
  3487. insertText(node, intitule);
  3488. insertText(node, magie, true);
  3489. } else {
  3490. node = node.parentNode;
  3491. appendBr(node);
  3492. appendText(node, intitule);
  3493. appendText(node, magie, true);
  3494. }
  3495. }
  3496.  
  3497. function getMM(sr) {
  3498. if(rmTroll<=0) {
  3499. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3500. }
  3501. sr = Number(sr.match(/\d+/)[0]);
  3502. if(sr==10) {
  3503. return '\u2265 '+5*rmTroll;
  3504. }
  3505. if(sr<=50) {
  3506. return Math.round(50*rmTroll/sr);
  3507. }
  3508. if(sr<90) {
  3509. return Math.round((100-sr)*rmTroll/50);
  3510. }
  3511. return '\u2264 '+Math.round(rmTroll/5);
  3512. }
  3513.  
  3514. function traiteMM() {
  3515. var node = document.evaluate(
  3516. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3517. document, null, 9, null).singleNodeValue;
  3518.  
  3519. if(node) {
  3520. var mm = getMM(node.nodeValue);
  3521. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3522. } else {
  3523. var node = document.evaluate(
  3524. "//p/text()[contains(., 'Seuil de Résistance')]",
  3525. document, null, 9, null).singleNodeValue;
  3526. if(!node) {
  3527. return;
  3528. }
  3529. var mm = getMM(node.nodeValue);
  3530. node = node.nextSibling.nextSibling;
  3531. }
  3532. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3533. }
  3534.  
  3535. function getRM(sr) {
  3536. if(mmTroll<=0) {
  3537. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3538. }
  3539. sr = Number(sr.match(/\d+/)[0]);
  3540. if(sr==10) {
  3541. return '\u2264 '+Math.round(mmTroll/5);
  3542. }
  3543. if(sr<=50) {
  3544. return Math.round(sr*mmTroll/50);
  3545. }
  3546. if(sr<90) {
  3547. return Math.round(50*mmTroll/(100-sr));
  3548. }
  3549. return '\u2265 '+5*mmTroll;
  3550. }
  3551.  
  3552. function traiteRM() {
  3553. var nodes = document.evaluate(
  3554. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3555. document, null, 7, null);
  3556. if(nodes.snapshotLength==0) {
  3557. return;
  3558. }
  3559.  
  3560. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3561. var node = nodes.snapshotItem(i);
  3562. var rm = getRM(node.nodeValue);
  3563. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3564. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3565. }
  3566. }
  3567.  
  3568.  
  3569. /* Fonction stats IdT par Raistlin */
  3570.  
  3571. /*function getIdt() {
  3572. if(MY_getValue("SEND_IDT") == "non")
  3573. return false;
  3574.  
  3575. var regExpBeginning = /^\s+/;
  3576. var regExpEnd = /\s+$/;
  3577.  
  3578. var nomIdt = document.evaluate(
  3579. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3580. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3581. if(!nomIdt)
  3582. return false;
  3583.  
  3584. var caracIdt;
  3585. if(nomIdt.indexOf("Malédiction !") != -1) {
  3586. caracIdt = "";
  3587. nomIdt = "Mission maudite";
  3588. } else {
  3589. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3590. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3591. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3592. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3593. }
  3594. FF_XMLHttpRequest({
  3595. method: 'GET',
  3596. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3597. headers : {
  3598. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3599. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3600. }
  3601. });
  3602. return true;
  3603. }*/
  3604.  
  3605.  
  3606. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3607.  
  3608. function confirmeDecalage() {
  3609. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3610. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3611. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3612.  
  3613. var newDLA = new Date( oldDLA );
  3614. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3615. return window.confirm(
  3616. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3617. +'\nConfirmez-vous ce décalage ?'
  3618. );
  3619. }
  3620.  
  3621. function newsubmitDLA(evt) {
  3622. evt.stopPropagation();
  3623. evt.preventDefault();
  3624. if(confirmeDecalage()) {
  3625. this.submit();
  3626. }
  3627. }
  3628.  
  3629. function changeActionDecalage() {
  3630. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3631. return;
  3632. }
  3633. try {
  3634. // On récupère le contenu du script JS MH de calcul du décalage
  3635. var scriptTxt = document.evaluate(
  3636. ".//script[ not(@src) ]",
  3637. document, null, 9, null
  3638. ).singleNodeValue.textContent;
  3639. // On en extrait la DLA courante
  3640. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3641. scriptTxt = scriptTxt.split('\n')[0];
  3642. var nbs = scriptTxt.match(/\d+/g);
  3643. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3644. } catch(e) {
  3645. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3646. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3647. return;
  3648. }
  3649. var form = document.getElementsByName('ActionForm')[0];
  3650. if(form) {
  3651. form.addEventListener('submit', newsubmitDLA, true);
  3652. } else {
  3653. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3654. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3655. }
  3656. }
  3657.  
  3658. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3659.  
  3660. function prochainMundi() {
  3661. try {
  3662. var node;
  3663. node = document.evaluate(
  3664. "//div[@class='dateAction']/b",
  3665. document, null, 9, null
  3666. ).singleNodeValue;
  3667. if (document.evaluate) {
  3668. } else { // repli en JQuery
  3669. //node = $(
  3670. }
  3671. } catch(e) {
  3672. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3673. return;
  3674. }
  3675. if(!node) { return; }
  3676.  
  3677. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3678. var jour = longueurMois+1-getNumber(node.textContent);
  3679. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3680. var txt = '[Prochain Mundidey ';
  3681. if(jour>1) {
  3682. txt += 'dans '+jour+' jours]';
  3683. } else {
  3684. txt += 'demain]';
  3685. }
  3686. insertText(node.parentNode.nextSibling,txt,true);
  3687. }
  3688.  
  3689.  
  3690. /* Fonction principale */
  3691.  
  3692. function dispatch() {
  3693. if(isPage('MH_Play/Play_action')) {
  3694. prochainMundi();
  3695. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3696. var oldDLA;
  3697. changeActionDecalage();
  3698. } else if(isPage('MH_Play/Actions')) {
  3699. if(document.evaluate(
  3700. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3701. document, null, 2, null
  3702. ).stringValue) {
  3703. traiteMM();
  3704. } else if(document.evaluate(
  3705. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3706. document, null, 2, null
  3707. ).stringValue) {
  3708. //getIdt();
  3709. traiteRM();
  3710. } /*else {
  3711. // Est censé se lancer sur quoi *précisément* ?
  3712. traiteRM();
  3713. getLevel();
  3714. }*/
  3715. } else {
  3716. /* Traitement des messages du bot */
  3717. var messageTitle = document.evaluate(
  3718. "//form/table/tbody/tr[1]/td[1]/"
  3719. +"descendant::text()[contains(.,'[MountyHall]')]",
  3720. document, null, 2, null
  3721. ).stringValue;
  3722. if(messageTitle.indexOf('Attaquant') != -1 &&
  3723. messageTitle.indexOf('sur') != -1) {
  3724. getLevel();
  3725. traiteRM();
  3726. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3727. messageTitle.indexOf('Défenseur') != -1) {
  3728. traiteMM();
  3729. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3730. // à replacer avec Attaque après révision getLvl :
  3731. messageTitle.indexOf('Explosion') != -1 ||
  3732. messageTitle.indexOf('Insulte') != -1) {
  3733. traiteRM();
  3734. }
  3735. }
  3736. }
  3737.  
  3738. function do_actions() {
  3739. start_script(31);
  3740. dispatch();
  3741. displayScriptTime();
  3742. }
  3743.  
  3744. /*********************************************************************************
  3745. * This file is part of Mountyzilla. *
  3746. * *
  3747. * Mountyzilla is free software; you can redistribute it and/or modify *
  3748. * it under the terms of the GNU General Public License as published by *
  3749. * the Free Software Foundation; either version 2 of the License, or *
  3750. * (at your option) any later version. *
  3751. * *
  3752. * Mountyzilla is distributed in the hope that it will be useful, *
  3753. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3754. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3755. * GNU General Public License for more details. *
  3756. * *
  3757. * You should have received a copy of the GNU General Public License *
  3758. * along with Mountyzilla; if not, write to the Free Software *
  3759. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3760. *********************************************************************************/
  3761.  
  3762. // x~x pre-enchant
  3763.  
  3764. /* 2013-08-19 : correction auto syntaxe alert */
  3765.  
  3766. var combobox=null;
  3767.  
  3768. function changeObject()
  3769. {
  3770. if(!combobox)
  3771. return ;
  3772. var id = combobox.options[combobox.selectedIndex].value;
  3773. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3774. if(!id || id=="")
  3775. {
  3776. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3777. return;
  3778. }
  3779. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3780. }
  3781.  
  3782. function treatePreEnchantement() {
  3783. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3784. if(!input || input.getAttribute("type")=="hidden")
  3785. {
  3786. return false;
  3787. }
  3788. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3789. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3790. if(!combobox)
  3791. {
  3792. return true;
  3793. }
  3794. combobox.addEventListener('change', changeObject, true);
  3795. return true;
  3796. }
  3797.  
  3798. function treateEnchantement() {
  3799. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3800. if(!input || input.getAttribute("type")!="hidden")
  3801. {
  3802. return false;
  3803. }
  3804. var idEquipement = input.getAttribute("value");
  3805. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3806. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3807. if(enchanteur && enchanteur != null)
  3808. return true;
  3809. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3810. if(!input || input.getAttribute("type")!="hidden")
  3811. {
  3812. return false;
  3813. }
  3814. var idEnchanteur = input.getAttribute("value");
  3815.  
  3816. var nodes = document.evaluate(
  3817. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3818. if (nodes.snapshotLength != 3)
  3819. return;
  3820. for(var i=0;i<3;i++)
  3821. {
  3822. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3823. texte = texte.replace(" d'une "," d'un ");
  3824. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3825. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3826. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3827. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3828. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3829. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3830. }
  3831. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3832. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3833. var liste = MY_getValue(numTroll+".enchantement.liste");
  3834. if(!liste || liste=="")
  3835. {
  3836. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3837. }
  3838. else
  3839. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3840. }
  3841.  
  3842. function do_pre_enchant() {
  3843. start_script(60);
  3844. if(!treatePreEnchantement())
  3845. treateEnchantement();
  3846. displayScriptTime();
  3847. }
  3848.  
  3849. /*********************************************************************************
  3850. * This file is part of Mountyzilla. *
  3851. * *
  3852. * Mountyzilla is free software; you can redistribute it and/or modify *
  3853. * it under the terms of the GNU General Public License as published by *
  3854. * the Free Software Foundation; either version 2 of the License, or *
  3855. * (at your option) any later version. *
  3856. * *
  3857. * Mountyzilla is distributed in the hope that it will be useful, *
  3858. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3859. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3860. * GNU General Public License for more details. *
  3861. * *
  3862. * You should have received a copy of the GNU General Public License *
  3863. * along with Mountyzilla; if not, write to the Free Software *
  3864. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3865. *********************************************************************************/
  3866.  
  3867. // x~x enchant
  3868.  
  3869. /* 2013-08-19 : correction auto syntaxe alert */
  3870.  
  3871. function treateEnchantement() {
  3872. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3873. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3874. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3875. return;
  3876. var tab = infoEquipement.split(";");
  3877. if(tab.length<2)
  3878. return;
  3879. var idEquipement = tab[0];
  3880. var nomEquipement = tab[1];
  3881. for(var i=2;i<tab.length;i++)
  3882. nomEquipement += ";"+tab[i];
  3883.  
  3884. var nodes = document.evaluate(
  3885. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3886. if (nodes.snapshotLength != 3)
  3887. return;
  3888. for(var i=0;i<3;i++)
  3889. {
  3890. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3891. texte = texte.replace(" d'une "," d'un ");
  3892. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3893. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3894. monstre = monstre.replace(/ Géante?/,"");
  3895. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3896. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3897. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3898. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3899. }
  3900. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3901. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3902. var liste = MY_getValue(numTroll+".enchantement.liste");
  3903. if(!liste || liste=="")
  3904. {
  3905. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3906. }
  3907. else
  3908. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3909. }
  3910.  
  3911. function do_enchant() {
  3912. start_script(60);
  3913.  
  3914. treateEnchantement();
  3915. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3916. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3917. displayScriptTime();
  3918. }
  3919.  
  3920. /*********************************************************************************
  3921. * This file is part of Mountyzilla. *
  3922. * *
  3923. * Mountyzilla is free software; you can redistribute it and/or modify *
  3924. * it under the terms of the GNU General Public License as published by *
  3925. * the Free Software Foundation; either version 2 of the License, or *
  3926. * (at your option) any later version. *
  3927. * *
  3928. * Mountyzilla is distributed in the hope that it will be useful, *
  3929. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3930. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3931. * GNU General Public License for more details. *
  3932. * *
  3933. * You should have received a copy of the GNU General Public License *
  3934. * along with Mountyzilla; if not, write to the Free Software *
  3935. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3936. *********************************************************************************/
  3937.  
  3938. // x~x myevent
  3939.  
  3940. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3941. function do_myevent() {
  3942. }
  3943.  
  3944. /*********************************************************************************
  3945. * This file is part of Mountyzilla. *
  3946. * *
  3947. * Mountyzilla is free software; you can redistribute it and/or modify *
  3948. * it under the terms of the GNU General Public License as published by *
  3949. * the Free Software Foundation; either version 2 of the License, or *
  3950. * (at your option) any later version. *
  3951. * *
  3952. * Mountyzilla is distributed in the hope that it will be useful, *
  3953. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3954. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3955. * GNU General Public License for more details. *
  3956. * *
  3957. * You should have received a copy of the GNU General Public License *
  3958. * along with Mountyzilla; if not, write to the Free Software *
  3959. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3960. *********************************************************************************/
  3961.  
  3962. // x~x malus
  3963.  
  3964. /* v1.4 - 2014-01-06
  3965. * - Gestion des sorts double composante
  3966. * v1.4.1 - 2014-01-22
  3967. * - Correction décumul
  3968. * TODO
  3969. * - Identifier la position de "PV" dans l'ordre MH
  3970. */
  3971.  
  3972. var listeBM;
  3973.  
  3974.  
  3975. /* [functions] Utilitaires */
  3976.  
  3977. function decumul(bmt,nbr) {
  3978. var bmr;
  3979. if(!nbr || nbr<2) bmr = bmt;
  3980. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3981. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3982. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3983. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3984. else bmr = parseInt(0.1*bmt);
  3985. if(bmt<0) return Math.min(-1,bmr);
  3986. return Math.max(1,bmr);
  3987. }
  3988.  
  3989. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3990. // Roule 23/11/2016 ajout PV
  3991. switch( a ) {
  3992. case 'ATT':
  3993. return -1;
  3994. case 'ESQ':
  3995. if(b=='ATT') return 1;
  3996. return -1;
  3997. case 'DEG':
  3998. switch( b ) {
  3999. case 'ATT':
  4000. case 'ESQ':
  4001. return 1;
  4002. default:
  4003. return -1;
  4004. }
  4005. case 'REG':
  4006. switch( b ) {
  4007. case 'ATT':
  4008. case 'ESQ':
  4009. case 'DEG':
  4010. return 1;
  4011. default:
  4012. return -1;
  4013. }
  4014. case 'Vue':
  4015. switch( b ) {
  4016. case 'ATT':
  4017. case 'ESQ':
  4018. case 'DEG':
  4019. case 'REG':
  4020. return 1;
  4021. default:
  4022. return -1;
  4023. }
  4024. case 'TOUR':
  4025. switch( b ) {
  4026. case 'ATT':
  4027. case 'ESQ':
  4028. case 'DEG':
  4029. case 'REG':
  4030. case 'Vue':
  4031. return 1;
  4032. default:
  4033. return -1;
  4034. }
  4035. case 'PV':
  4036. switch( b ) {
  4037. case 'ATT':
  4038. case 'ESQ':
  4039. case 'DEG':
  4040. case 'REG':
  4041. case 'Vue':
  4042. case 'TOUR':
  4043. return 1;
  4044. default:
  4045. return -1;
  4046. }
  4047. case 'Armure':
  4048. switch( b ) {
  4049. case 'ATT':
  4050. case 'ESQ':
  4051. case 'DEG':
  4052. case 'REG':
  4053. case 'Vue':
  4054. case 'TOUR':
  4055. case 'PV':
  4056. return 1;
  4057. default:
  4058. return -1;
  4059. }
  4060. case 'RM':
  4061. switch( b ) {
  4062. case 'ATT':
  4063. case 'ESQ':
  4064. case 'DEG':
  4065. case 'REG':
  4066. case 'Vue':
  4067. case 'TOUR':
  4068. case 'PV':
  4069. case 'Armure':
  4070. return 1;
  4071. default:
  4072. return -1;
  4073. }
  4074. case 'MM':
  4075. switch( b ) {
  4076. case 'ATT':
  4077. case 'ESQ':
  4078. case 'DEG':
  4079. case 'REG':
  4080. case 'Vue':
  4081. case 'TOUR':
  4082. case 'PV':
  4083. case 'Armure':
  4084. case 'RM':
  4085. return 1;
  4086. default:
  4087. return -1;
  4088. }
  4089. case 'Concentration':
  4090. switch( b ) {
  4091. case 'ATT':
  4092. case 'ESQ':
  4093. case 'DEG':
  4094. case 'REG':
  4095. case 'Vue':
  4096. case 'TOUR':
  4097. case 'PV':
  4098. case 'Armure':
  4099. case 'RM':
  4100. case 'MM':
  4101. return 1;
  4102. default:
  4103. return -1;
  4104. }
  4105. case 'Fatigue':
  4106. switch( b ) {
  4107. case 'ATT':
  4108. case 'ESQ':
  4109. case 'DEG':
  4110. case 'REG':
  4111. case 'Vue':
  4112. case 'TOUR':
  4113. case 'PV':
  4114. case 'Armure':
  4115. case 'RM':
  4116. case 'MM':
  4117. case 'Concentration':
  4118. return 1;
  4119. default:
  4120. return -1;
  4121. }
  4122. case "Dés d'attaque":
  4123. switch( b ) {
  4124. case 'ATT':
  4125. case 'ESQ':
  4126. case 'DEG':
  4127. case 'REG':
  4128. case 'Vue':
  4129. case 'TOUR':
  4130. case 'PV':
  4131. case 'Armure':
  4132. case 'RM':
  4133. case 'MM':
  4134. case 'Concentration':
  4135. case 'Fatigue':
  4136. return 1;
  4137. default:
  4138. return -1;
  4139. }
  4140. case 'Dés de dégâts':
  4141. switch( b ) {
  4142. case 'ATT':
  4143. case 'ESQ':
  4144. case 'DEG':
  4145. case 'REG':
  4146. case 'Vue':
  4147. case 'TOUR':
  4148. case 'PV':
  4149. case 'Armure':
  4150. case 'RM':
  4151. case 'MM':
  4152. case 'Concentration':
  4153. case 'Fatigue':
  4154. case "Dés d'attaque":
  4155. return 1;
  4156. default:
  4157. return -1;
  4158. }
  4159. default :
  4160. switch( b ) {
  4161. case 'ATT':
  4162. case 'ESQ':
  4163. case 'DEG':
  4164. case 'REG':
  4165. case 'Vue':
  4166. case 'TOUR':
  4167. case 'PV':
  4168. case 'Armure':
  4169. case 'RM':
  4170. case 'MM':
  4171. case 'Concentration':
  4172. case 'Fatigue':
  4173. case "Dés d'attaque":
  4174. case 'Dés de dégâts':
  4175. return 1;
  4176. default:
  4177. return -1;
  4178. }
  4179. }
  4180. }
  4181.  
  4182.  
  4183. /* [functions] Fonctions hide / display */
  4184.  
  4185. function toggleDetailsBM() {
  4186. if(MY_getValue('BMDETAIL')!='false') {
  4187. MY_setValue('BMDETAIL','false');
  4188. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4189. for(var i=0 ; i<trlist.length ; i++)
  4190. trlist[i].style.display = 'none';
  4191. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4192. for(var i=0 ; i<trlist.length ; i++)
  4193. trlist[i].style = '';
  4194. }
  4195. else {
  4196. MY_setValue('BMDETAIL','true');
  4197. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4198. for(var i=0 ; i<trlist.length ; i++)
  4199. trlist[i].style.display = 'none';
  4200. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4201. for(var i=0 ; i<trlist.length ; i++)
  4202. trlist[i].style = '';
  4203. }
  4204. }
  4205.  
  4206. function toggleBMList() {
  4207. if(MY_getValue('BMHIDELIST')=='true') {
  4208. MY_setValue('BMHIDELIST','false');
  4209. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4210. listeBM.snapshotItem(i).style = '';
  4211. document.getElementsByTagName('thead')[0].style = '';
  4212. document.getElementById('trhelp').style = '';
  4213. }
  4214. else {
  4215. MY_setValue('BMHIDELIST','true');
  4216. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4217. listeBM.snapshotItem(i).style.display = 'none';
  4218. document.getElementsByTagName('thead')[0].style.display = 'none';
  4219. document.getElementById('trhelp').style.display = 'none';
  4220. }
  4221. }
  4222.  
  4223. function setDisplayBM() {
  4224. if(!listeBM) return;
  4225.  
  4226. var titre = document.getElementById('titre2');
  4227. if(titre) {
  4228. titre.style.cursor = 'pointer';
  4229. titre.onclick = toggleBMList;
  4230. }
  4231.  
  4232. var tfoot = document.getElementsByTagName('tfoot')[0];
  4233. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  4234. tfoot, null, 9, null).singleNodeValue;
  4235. tr.id = 'trhelp';
  4236.  
  4237. if(MY_getValue('BMHIDELIST')=='true') {
  4238. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4239. listeBM.snapshotItem(i).style.display = 'none';
  4240. document.getElementsByTagName('thead')[0].style.display = 'none';
  4241. tr.style.display = 'none';
  4242. }
  4243. }
  4244.  
  4245.  
  4246. /* [functions] Fonction principale */
  4247.  
  4248. function traiteMalus() {
  4249. var mainTab = document.getElementsByTagName('table')[0];
  4250. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4251. if(listeBM.snapshotLength==0) return;
  4252.  
  4253. /* Suppression des BM de fatigue stockés */
  4254. if(MY_getValue(numTroll+'.bm.fatigue'))
  4255. MY_removeValue(numTroll+'.bm.fatigue');
  4256.  
  4257. /* Extraction des données */
  4258. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  4259. var nb = 0;
  4260. while(nb<listeBM.snapshotLength) {
  4261. tr = listeBM.snapshotItem(nb); nb++;
  4262. var effetsT = tr.childNodes[5].textContent.split(' | ');
  4263. var phymag = tr.childNodes[9].textContent;
  4264. var duree = tr.childNodes[11].textContent.match(/\d+/);
  4265. if (duree == null) { // Roule 28/01/2018 protection malus Crasc sans durée
  4266. duree = 1;
  4267. } else {
  4268. duree = Number(duree[0]);
  4269. }
  4270. var type = tr.childNodes[3].textContent, nom;
  4271. // si c'est un type à décumul
  4272. /*
  4273. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  4274. switch(type) {
  4275. case 'Potion':
  4276. case 'Parchemin':
  4277. case 'Sortilège':
  4278. case 'Capacité Spéciale':
  4279. nom = tr.childNodes[1].textContent+phymag;
  4280. break;
  4281. default:
  4282. nom = 'pasdedecumul';
  4283. }
  4284. */
  4285. nom = tr.childNodes[1].textContent+phymag;
  4286. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  4287. nom = 'pasdedecumul';
  4288.  
  4289. uniListe[nb] = {
  4290. 'duree':duree,
  4291. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  4292. 'caracs':{}
  4293. }
  4294. for(var i=0 ; i<effetsT.length ; i++) {
  4295. if(effetsT[i].indexOf(':')==-1) continue;
  4296. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  4297. // nom = 'pasdedecumul' si pas de décumul
  4298. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  4299. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  4300. uniListe[nb]['type'] = phymag;
  4301. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  4302. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  4303. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  4304. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  4305. uniListe[nb]['caracs'][carac] = bm;
  4306. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  4307. listeDurees[duree] = true;
  4308. }
  4309. } // fin boucle sur les lignes de bonus/malus
  4310.  
  4311. /* Gestion des décumuls et cumuls des durées */
  4312. var toursGeres = [];
  4313. for(var d in listeDurees) toursGeres.push(d);
  4314. toursGeres.sort( function (a,b){return b-a;} );
  4315. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  4316. // pour sauvegarder les bm de fatigue
  4317. var strfat = '';
  4318. // Pour affichage & adpatation à footable.js (statique)
  4319. var thead = document.getElementsByTagName('thead')[0];
  4320. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  4321. thead, null, 7, null).snapshotLength;
  4322. var tfoot = document.getElementsByTagName('tfoot')[0];
  4323.  
  4324. for(var i=0 ; i<toursGeres.length ; i++) {
  4325. var tour = toursGeres[i];
  4326. var effetsCeTour = {}; decumulsCeTour = {};
  4327. for(var nb=1 ; nb<uniListe.length ; nb++) {
  4328. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  4329. continue;
  4330. var nom = uniListe[nb]['nom'];
  4331. if(nom!='pasdedecumul') {
  4332. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  4333. decumulsCeTour[nom]++;
  4334. }
  4335. for(var carac in uniListe[nb]['caracs']) {
  4336. var bm = uniListe[nb]['caracs'][carac];
  4337. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  4338. var type = uniListe[nb]['type'];
  4339. if(!effetsCeTour[carac])
  4340. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  4341. var thisBm;
  4342. if(nom=='pasdedecumul')
  4343. thisBm = bm;
  4344. else
  4345. thisBm = decumul(bm,decumulsCeTour[nom]);
  4346. effetsCeTour[carac][type] += thisBm;
  4347. 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]);
  4348. } else {
  4349. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  4350. var thisBm;
  4351. if(nom=='pasdedecumul' || carac=='Fatigue')
  4352. thisBm = bm;
  4353. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  4354. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  4355. else
  4356. thisBm = decumul(bm,decumulsCeTour[nom]);
  4357. effetsCeTour[carac] += thisBm;
  4358. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  4359. }
  4360. } // fin boucle sur les caractéristiques
  4361. } // fin boucle sur les bonus/malus
  4362.  
  4363. /* Création du bilan du tour */
  4364. var texteD = '', texteS = '';
  4365. var caracGerees = [];
  4366. for(var k in effetsCeTour) caracGerees.push(k);
  4367. caracGerees.sort( triecaracs );
  4368.  
  4369. for(var j=0 ; j<caracGerees.length ; j++) {
  4370. var carac = caracGerees[j], str = '';
  4371.  
  4372. switch( carac ) {
  4373. case 'ATT':
  4374. case 'DEG':
  4375. case 'Armure':
  4376. var phy = effetsCeTour[carac]['Physique'];
  4377. var mag = effetsCeTour[carac]['Magie'];
  4378. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  4379. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  4380. break;
  4381. case 'TOUR':
  4382. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  4383. break;
  4384. case 'Fatigue':
  4385. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  4386. case 'PV':
  4387. case 'ESQ':
  4388. case 'REG':
  4389. case 'Vue':
  4390. case 'Voir le Caché':
  4391. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  4392. break;
  4393. default:
  4394. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  4395. }
  4396. if(str) {
  4397. texteD += str;
  4398. texteS += str;
  4399. }
  4400. } // fin boucle sur les caractéristiques
  4401.  
  4402. /* Affichage */
  4403. // Si rien à afficher on passe
  4404. if(!texteD) continue;
  4405. // Si BMM+BMP=0
  4406. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  4407. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  4408. if(MY_getValue('BMDETAIL')=='false')
  4409. tr.style.display = 'none';
  4410. var td = appendTdText(tr,texteD.substring(3));
  4411. td.colSpan = 5-nbHidden;
  4412. var txttour = toursGeres[i]+' Tour';
  4413. if(toursGeres[i]>1) txttour += 's';
  4414. appendTdText(tr,txttour);
  4415.  
  4416. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  4417. if(MY_getValue('BMDETAIL')!='false')
  4418. tr.style.display = 'none';
  4419. td = appendTdText(tr,texteS);
  4420. td.colSpan = 5-nbHidden;
  4421. appendTdText(tr,txttour);
  4422. } // fin boucle sur les tours générés
  4423.  
  4424. /* mise en place toggleDetails */
  4425. tfoot.style.cursor = 'pointer';
  4426. tfoot.onclick = toggleDetailsBM;
  4427.  
  4428. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4429. if(strfat)
  4430. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4431. }
  4432.  
  4433. function do_malus() {
  4434. try {
  4435. start_script();
  4436. traiteMalus();
  4437. setDisplayBM();
  4438. displayScriptTime();
  4439. }
  4440. catch(e) {window.alert(e)};
  4441. }
  4442.  
  4443. /*******************************************************************************
  4444. * This file is part of Mountyzilla. *
  4445. * *
  4446. * Mountyzilla is free software; you can redistribute it and/or modify *
  4447. * it under the terms of the GNU General Public License as published by *
  4448. * the Free Software Foundation; either version 2 of the License, or *
  4449. * (at your option) any later version. *
  4450. * *
  4451. * Mountyzilla is distributed in the hope that it will be useful, *
  4452. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4453. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4454. * GNU General Public License for more details. *
  4455. * *
  4456. * You should have received a copy of the GNU General Public License *
  4457. * along with Mountyzilla; if not, write to the Free Software *
  4458. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4459. *******************************************************************************/
  4460.  
  4461. // x~x mouches
  4462.  
  4463. var mainTab, tr_mouches;
  4464.  
  4465. function initialiseMouches() {
  4466. // Lanceur global
  4467. try {
  4468. mainTab = document.getElementById('mouches');
  4469. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4470. } catch(e) {
  4471. avertissement('Erreur MZ:<br />Consulter la console.');
  4472. window.console.error(traceStack(e, 'mouches'));
  4473. return;
  4474. }
  4475. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4476.  
  4477. setDisplayMouches();
  4478. traiteMouches();
  4479. }
  4480.  
  4481. function setDisplayMouches() {
  4482. // Initialise l'affichage / l'effacement du détail des mouches
  4483. var titre = document.getElementById('titre2');
  4484. if(titre) {
  4485. titre.style.cursor = 'pointer';
  4486. titre.onclick = toggleMouches;
  4487. }
  4488.  
  4489. var tfoot = document.getElementsByTagName('tfoot')[0];
  4490. if(tfoot) {
  4491. tfoot.style.cursor = 'pointer';
  4492. tfoot.onclick = toggleMouches;
  4493. }
  4494.  
  4495. if(MY_getValue('HIDEMOUCHES')=='true') {
  4496. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4497. tr_mouches.snapshotItem(i).style.display = 'none';
  4498. }
  4499. document.getElementsByTagName('thead')[0].style.display = 'none';
  4500. }
  4501. }
  4502.  
  4503. function toggleMouches() {
  4504. // Handler pour afficher / masquer les détasil
  4505. if(MY_getValue('HIDEMOUCHES')=='true') {
  4506. MY_setValue('HIDEMOUCHES','false');
  4507. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4508. tr_mouches.snapshotItem(i).style.display = '';
  4509. }
  4510. document.getElementsByTagName('thead')[0].style.display = '';
  4511. } else {
  4512. MY_setValue('HIDEMOUCHES','true');
  4513. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4514. tr_mouches.snapshotItem(i).style.display = 'none';
  4515. }
  4516. document.getElementsByTagName('thead')[0].style.display = 'none';
  4517. }
  4518. }
  4519.  
  4520. function traiteMouches() {
  4521. // Traitement complet: présence et effets des mouches
  4522. var listeTypes = {}, effetsActifs = {};
  4523.  
  4524. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4525. var tr = tr_mouches.snapshotItem(i);
  4526.  
  4527. // La mouche est-elle présente?
  4528. var etat = document.evaluate(
  4529. './img',
  4530. tr.cells[6], null, 9, null
  4531. ).singleNodeValue.alt;
  4532. if(etat!='La Mouche est là') { continue; }
  4533. // Extraction du type de mouche
  4534. var type = trim(tr.cells[3].textContent);
  4535. if(!listeTypes[type]) {
  4536. listeTypes[type] = 1;
  4537. } else {
  4538. listeTypes[type]++;
  4539. }
  4540.  
  4541. // La mouche a-t-elle un effet?
  4542. var effet = trim(tr.cells[2].textContent);
  4543. if(etat!='La Mouche est là' || !effet) { continue; }
  4544. // Si oui, extraction des effets (multiples pour pogées)
  4545. var caracs = effet.split(' | ');
  4546. for(var j=0 ; j<caracs.length ; j++) {
  4547. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4548. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4549. if(effetsActifs[carac]===void(0)) {
  4550. effetsActifs[carac] = valeur;
  4551. } else {
  4552. effetsActifs[carac] += valeur;
  4553. }
  4554. }
  4555. }
  4556.  
  4557. // Extraction Effet total et affichage des différences à la normale
  4558. var tfoot = document.getElementsByTagName('tfoot')[0];
  4559. if(!tfoot) { return; }
  4560. var nodeTotal = document.evaluate(
  4561. ".//b[contains(./text(),'Effet total')]",
  4562. tfoot, null, 9, null
  4563. ).singleNodeValue.nextSibling;
  4564. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4565. var texte = ' ';
  4566. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4567. if(texte.length>1) { texte += ' | '; }
  4568. var carac = trim(
  4569. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4570. );
  4571. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4572. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4573. texte += effetsTheoriques[i];
  4574. } else {
  4575. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4576. if(carac=='TOUR') { texte += ' min'; }
  4577. texte += '</b>';
  4578. }
  4579. }
  4580. var span = document.createElement('span');
  4581. span.innerHTML = texte;
  4582. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4583.  
  4584. // Affichage des différences du nombre de mouches de chaque type
  4585. var mouchesParType = document.evaluate(
  4586. "./tr/td/ul/li/text()",
  4587. tfoot, null, 7, null
  4588. );
  4589. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4590. var node = mouchesParType.snapshotItem(i);
  4591. var mots = node.nodeValue.split(' ');
  4592. var type = mots.pop();
  4593. if(!listeTypes[type]) {
  4594. node.nodeValue += ' (0 présente)';
  4595. } else if(mots[0]!=listeTypes[type]) {
  4596. if(listeTypes[type]==1) {
  4597. node.nodeValue += ' (1 présente)';
  4598. } else {
  4599. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4600. }
  4601. }
  4602. }
  4603. }
  4604.  
  4605. function do_mouches() {
  4606. start_script();
  4607. initialiseMouches();
  4608. displayScriptTime();
  4609. }
  4610.  
  4611. /*********************************************************************************
  4612. * This file is part of Mountyzilla. *
  4613. * *
  4614. * Mountyzilla is free software; you can redistribute it and/or modify *
  4615. * it under the terms of the GNU General Public License as published by *
  4616. * the Free Software Foundation; either version 2 of the License, or *
  4617. * (at your option) any later version. *
  4618. * *
  4619. * Mountyzilla is distributed in the hope that it will be useful, *
  4620. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4621. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4622. * GNU General Public License for more details. *
  4623. * *
  4624. * You should have received a copy of the GNU General Public License *
  4625. * along with Mountyzilla; if not, write to the Free Software *
  4626. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4627. *********************************************************************************/
  4628.  
  4629. // x~x equipgowap
  4630.  
  4631. var popup;
  4632.  
  4633. function initPopupEquipgowap() {
  4634. popup = document.createElement('div');
  4635. popup.setAttribute('id', 'popup');
  4636. popup.setAttribute('class', 'mh_textbox');
  4637. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4638. 'display: inline; z-index: 3; max-width: 400px;');
  4639. document.body.appendChild(popup);
  4640. }
  4641.  
  4642. function showPopupEquipgowap(evt) {
  4643. var texte = this.getAttribute("texteinfo");
  4644. popup.innerHTML = texte;
  4645. popup.style.left = evt.pageX + 15 + 'px';
  4646. popup.style.top = evt.pageY + 'px';
  4647. popup.style.visibility = "visible";
  4648. }
  4649.  
  4650. function hidePopup() {
  4651. popup.style.visibility = "hidden";
  4652. }
  4653.  
  4654. function createPopupImage(url, text)
  4655. {
  4656. var img = document.createElement('img');
  4657. img.setAttribute('src',url);
  4658. img.setAttribute('align','ABSMIDDLE');
  4659. img.setAttribute("texteinfo",text);
  4660. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4661. img.addEventListener("mouseout", hidePopup,true);
  4662. return img;
  4663. }
  4664.  
  4665. function formateTexte(texte)
  4666. {
  4667. texte = texte.replace(/\n/g,"<br/>");
  4668. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4669. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4670. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4671. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4672. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4673. return texte;
  4674. }
  4675.  
  4676.  
  4677. function treateGowaps() {
  4678. //On récupère les gowaps possédants des composants
  4679. var tbodys = document.evaluate(
  4680. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4681. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4682. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4683. var tbody = tbodys.snapshotItem(j);
  4684. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4685. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4686. if(MY_getValue("NOINFOEM") != "true")
  4687. insertEMInfos(tbody);
  4688. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4689. insertEnchantInfos(tbody);
  4690. }
  4691. }
  4692.  
  4693. function treateChampi() {
  4694. if(MY_getValue("NOINFOEM") == "true")
  4695. return false;
  4696. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4697. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4698. if (nodes.snapshotLength == 0)
  4699. return false;
  4700.  
  4701. for (var i = 0; i < nodes.snapshotLength; i++) {
  4702. var node = nodes.snapshotItem(i);
  4703. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4704. if(texte.indexOf("*")!=-1)
  4705. texte = texte.substring(0,texte.lastIndexOf(" "));
  4706. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4707. if(moisChampi[nomChampi])
  4708. {
  4709. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4710. }
  4711.  
  4712. }
  4713. }
  4714.  
  4715. function do_equipgowap() {
  4716. start_script();
  4717.  
  4718. treateGowaps();
  4719. treateChampi();
  4720. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4721. {
  4722. initPopupEquipgowap();
  4723. computeEnchantementEquipement(createPopupImage,formateTexte);
  4724. }
  4725.  
  4726. displayScriptTime();
  4727. }
  4728.  
  4729. /*********************************************************************************
  4730. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4731. *********************************************************************************/
  4732.  
  4733. // x~x ordresgowap
  4734.  
  4735. var MZ_analyse_page_ordre_suivant;
  4736. if (MZ_analyse_page_ordre_suivant === undefined && isPage("MH_Follower/FO_Ordres")) {
  4737. // Roule 07/10/2019
  4738. // Fonction réutilisée dans MZ, dans Trajet_canvas et dans une extension perso ☺
  4739. // rend un object, par exemple
  4740. var MZ_analyse_page_ordre_suivant = {
  4741. 'result': {ordres: []},
  4742. 'init': function() {
  4743. // façon blindée de tester la variable MY_DEBUG
  4744. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('start MZ_analyse_page_ordre_suivant.init');
  4745. try {
  4746. var eTitle = document.getElementById('titre2');
  4747. // au 07/10/2019, on peut se baser sur les <tr> de l'élément HTML parent 'titre2'
  4748. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('eTitle.nextSibling=' + eTitle.parentNode);
  4749. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4750. for(var i=0 ; i<lignes.length ; i++) {
  4751. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + ' className=' + lignes[i].className);
  4752. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + lignes[i].innerHTML);
  4753. if(lignes[i].className == 'mh_tdtitre_fo') {
  4754. var tds = lignes[i].getElementsByTagName('div');
  4755. for (var j=0; j < tds.length; j++) {
  4756. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant div ' + j + ' ' + tds[j].innerText);
  4757. var tabmatch = tds[j].innerText.match(/(\d+) *\.* *(.*\[.*\].*)$/);
  4758. if (tabmatch) {
  4759. // ID, Nom
  4760. this.result.id = tabmatch[1].trim();
  4761. this.result.nom = tabmatch[2].trim();
  4762. }
  4763. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-?\d+).*Y = (-?\d+).*N = (-?\d+)/i);
  4764. if (tabmatch) {
  4765. // PA, x, y, n
  4766. this.result.PA = parseInt(tabmatch[1]);
  4767. this.result.x = parseInt(tabmatch[2]);
  4768. this.result.y = parseInt(tabmatch[3]);
  4769. this.result.n = parseInt(tabmatch[4]);
  4770. // Trajet_canvas a besoin d'un pointeur vers cette div
  4771. this.result.eltPos = tds[j];
  4772. }
  4773. }
  4774. }
  4775. if(lignes[i].className == 'mh_tdpage_fo') {
  4776. var etd = lignes[i].getElementsByTagName('td')[0];
  4777. if (etd !== undefined) { // undefined dans le cas des Golems
  4778. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant etd ' + etd.firstChild.nodeValue);
  4779. var tabmatch = etd.firstChild.nodeValue.match(/^(.*)X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4780. if (tabmatch) {
  4781. this.result.ordres.push({ordre: tabmatch[1].trim(), x: parseInt(tabmatch[2]), y: parseInt(tabmatch[3]), n: parseInt(tabmatch[4])});
  4782. } else {
  4783. this.result.ordres.push({ordre: etd.firstChild.nodeValue.trim()});
  4784. }
  4785. }
  4786. }
  4787. }
  4788. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('fin MZ_analyse_page_ordre_suivant ' + JSON.stringify(this.result));
  4789. } catch(e) {
  4790. window.console.log('Exception dans MZ_analyse_page_ordre_suivant.init ' + e);
  4791. }
  4792. }
  4793. }
  4794. MZ_analyse_page_ordre_suivant.init();
  4795. }
  4796.  
  4797. // version Roule' janvier 2017
  4798. function MZ_setCarteUnGogoHTML5() {
  4799. // fabriquer la liste des positions successives
  4800. var listeDepl = []; // ce sera un tableau d'objets
  4801. listeDepl = MZ_analyse_page_ordre_suivant.result.ordres.slice(0); // clone array
  4802. listeDepl.unshift(MZ_analyse_page_ordre_suivant.result); // le result de MZ_analyse_page_ordre_suivant a déjà juste les bonne propriétés
  4803.  
  4804. /* à supprimer, remplacé par MZ_analyse_page_ordre_suivant
  4805. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  4806. , y: parseInt(tabPos[3])
  4807. , n: parseInt(tabPos[4])
  4808. , nom: tabNomID[2]
  4809. , id: tabNomID[1]});
  4810.  
  4811. // position courante
  4812. var eTitle = document.getElementById('titre2');
  4813. // déplacements
  4814. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4815. for(var i=0 ; i<lignes.length ; i++) {
  4816. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + ' className=' + lignes[i].className);
  4817. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + lignes[i].innerHTML);
  4818. if(lignes[i].className == 'mh_tdtitre_fo') {
  4819. var tds = lignes[i].getElementsByTagName('div');
  4820. for (var j=0; j < tds.length; j++) {
  4821. tabmatch = tds[j].innerText.match(/(\d+) *(.*\[.*\].*)$/);
  4822. if (tabmatch) var tabNomID = tabmatch;
  4823. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-.\d+).*Y = (-.\d+).*N = (-.\d+)/i);
  4824. if (tabmatch) var tabPos = tabmatch;
  4825. }
  4826. if (tabPos != undefined && tabNomID != undefined) { // null dans le cas des Golems
  4827. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  4828. , y: parseInt(tabPos[3])
  4829. , n: parseInt(tabPos[4])
  4830. , nom: tabNomID[2]
  4831. , id: tabNomID[1]});
  4832. } else {
  4833. return;
  4834. }
  4835. }
  4836. if(lignes[i].className == 'mh_tdpage_fo') {
  4837. var etd = lignes[i].getElementsByTagName('td')[0];
  4838. if (etd === undefined) return; // cas des Golems
  4839. var point = etd.firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4840. if (point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4841. }
  4842. }
  4843. */
  4844. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4845. }
  4846.  
  4847. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4848. function MZ_showCarteBottom(listeSuiv) {
  4849. // générer la carte
  4850. var carte = new carte_MZ('cartegogo', listeSuiv);
  4851. // positionner la carte
  4852. var eCarte = carte.getElt();
  4853. eCarte.style.textAlign = 'left';
  4854. eCarte.style.marginTop = '2px';
  4855. var footer = document.getElementById('footer1');
  4856. // Lieu_Teleport.php n'a pas de footer1 :(
  4857. if (!footer) footer = document.getElementById('footer2');
  4858. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4859. else document.body.appendChild(eCarte);
  4860. }
  4861.  
  4862. function MZ_setCarteTousGogoHTML5() {
  4863. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4864. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4865. var suivants = [];
  4866. for (var i=0;i<ligne.length;i++) {
  4867. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4868. var cas = ligne[i].getElementsByTagName("td")[0];
  4869. //if (cas.className == "mh_tdtitre") {
  4870. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4871. var oGogo = {};
  4872. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4873. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4874. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4875. oGogo.x = parseInt(point[1]);
  4876. oGogo.y = parseInt(point[2]);
  4877. oGogo.n = parseInt(point[3]);
  4878. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4879. }
  4880. }
  4881. if (suivants.length == 0) return;
  4882. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4883. }
  4884.  
  4885. function MZ_setCarteTP() {
  4886. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4887. 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);
  4888. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4889. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4890. }
  4891.  
  4892. /* v0.2 by Dab - 2013-08-31
  4893. * - correction acquisition posale initiale
  4894. * - correction tare et affichage mire
  4895. */
  4896.  
  4897. function setCarteGogo() {
  4898. try {
  4899. //var pars = document.getElementsByTagName('p');
  4900. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4901. var eTitle = document.getElementById('titre2');
  4902. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4903. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4904. var serv_img_cible = URL_MZimg + "rep.png";
  4905.  
  4906. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4907. //var lignes = pars[0].getElementsByTagName('tr');
  4908. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4909. var nbpt = 0;
  4910. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4911. for(var i=0 ; i<lignes.length ; i++) {
  4912. if(lignes[i].className == 'mh_tdpage_fo') {
  4913. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4914. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4915. if(point) {
  4916. nbpt++;
  4917. trajet += point[1]+','+point[2]+','+point[3]+',';
  4918. }
  4919. }
  4920. }
  4921. }
  4922. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4923. 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'/>";
  4924. var base = [-229,-5];
  4925. if (nbpt>0) {
  4926. base = [-684,-5];
  4927. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4928. }
  4929. 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;'/>";
  4930.  
  4931. nvdiv += '<map name="coord_trou">'+
  4932. '<area shape="circle" href="#" coords="260,333,3" title="X=5, Y=-49" >'+
  4933. '<area shape="circle" href="#" coords="262,335,3" title="X=6, Y=-50" >'+
  4934. '<area shape="circle" href="#" coords="260,335,3" title="X=5, Y=-50" >'+
  4935. '<area shape="circle" href="#" coords="262,333,3" title="X=6, Y=-49" >'+
  4936. '<area shape="circle" href="#" coords="294,163,3" title="X=22, Y=36" >'+
  4937. '<area shape="circle" href="#" coords="292,163,3" title="X=21, Y=36" >'+
  4938. '<area shape="circle" href="#" coords="294,165,3" title="X=22, Y=35" >'+
  4939. '<area shape="circle" href="#" coords="292,165,3" title="X=21, Y=35" >'+
  4940. '<area shape="circle" href="#" coords="124,217,3" title="X=-63, Y=9" >'+
  4941. '<area shape="circle" href="#" coords="122,217,3" title="X=-64, Y=9" >'+
  4942. '<area shape="circle" href="#" coords="124,219,3" title="X=-63, Y=8" >'+
  4943. '<area shape="circle" href="#" coords="122,219,3" title="X=-64, Y=8" >'+
  4944. '<area shape="circle" href="#" coords="378,95,3" title="X=64, Y=70" >'+
  4945. '<area shape="circle" href="#" coords="146,121,3" title="X=-52, Y=57" >'+
  4946. '<area shape="circle" href="#" coords="346,313,3" title="X=48, Y=-39" >'+
  4947. '<area shape="circle" href="#" coords="310,339,3" title="X=30, Y=-52" >'+
  4948. '<area shape="circle" href="#" coords="274,265,3" title="X=12, Y=-15" >'+
  4949. '<area shape="circle" href="#" coords="360,95,3" title="X=55, Y=70" >'+
  4950. '<area shape="circle" href="#" coords="224,91,3" title="X=-13, Y=72" >'+
  4951. '<area shape="circle" href="#" coords="226,91,3" title="X=-12, Y=72" >'+
  4952. '<area shape="circle" href="#" coords="224,89,3" title="X=-13, Y=73" >'+
  4953. '<area shape="circle" href="#" coords="226,89,3" title="X=-12, Y=73" >'+
  4954. '<area shape="circle" href="#" coords="148,281,3" title="X=-51, Y=-23" >'+
  4955. '<area shape="circle" href="#" coords="150,281,3" title="X=-50, Y=-23" >'+
  4956. '<area shape="circle" href="#" coords="148,279,3" title="X=-51, Y=-22" >'+
  4957. '<area shape="circle" href="#" coords="150,279,3" title="X=-50, Y=-22" >'+
  4958. '<area shape="circle" href="#" coords="130,301,3" title="X=-60, Y=-33" >'+
  4959. '<area shape="circle" href="#" coords="132,301,3" title="X=-59, Y=-33" >'+
  4960. '<area shape="circle" href="#" coords="130,299,3" title="X=-60, Y=-32" >'+
  4961. '<area shape="circle" href="#" coords="132,299,3" title="X=-59, Y=-32" >'+
  4962. '<area shape="circle" href="#" coords="116,311,3" title="X=-67, Y=-38" >'+
  4963. '<area shape="circle" href="#" coords="118,311,3" title="X=-66, Y=-38" >'+
  4964. '<area shape="circle" href="#" coords="116,309,3" title="X=-67, Y=-37" >'+
  4965. '<area shape="circle" href="#" coords="118,309,3" title="X=-66, Y=-37" >'+
  4966. '<area shape="circle" href="#" coords="260,173,3" title="X=5, Y=31" >'+
  4967. '<area shape="circle" href="#" coords="262,173,3" title="X=6, Y=31" >'+
  4968. '<area shape="circle" href="#" coords="260,171,3" title="X=5, Y=32" >'+
  4969. '<area shape="circle" href="#" coords="262,171,3" title="X=6, Y=32" >'+
  4970. '<area shape="circle" href="#" coords="178,339,3" title="X=-36, Y=-52" >'+
  4971. '<area shape="circle" href="#" coords="180,339,3" title="X=-35, Y=-52" >'+
  4972. '<area shape="circle" href="#" coords="178,337,3" title="X=-36, Y=-51" >'+
  4973. '<area shape="circle" href="#" coords="180,337,3" title="X=-35, Y=-51" >'+
  4974. '<area shape="circle" href="#" coords="182,107,3" title="X=-34, Y=64" >'+
  4975. '<area shape="circle" href="#" coords="182,105,3" title="X=-34, Y=65" >'+
  4976. '<area shape="circle" href="#" coords="270,109,3" title="X=10, Y=63" >'+
  4977. '<area shape="circle" href="#" coords="272,109,3" title="X=11, Y=63" >'+
  4978. '<area shape="circle" href="#" coords="270,107,3" title="X=10, Y=64" >'+
  4979. '<area shape="circle" href="#" coords="272,107,3" title="X=11, Y=64" >'+
  4980. '<area shape="circle" href="#" coords="180,207,3" title="X=-35, Y=14" >'+
  4981. '<area shape="circle" href="#" coords="182,207,3" title="X=-34, Y=14" >'+
  4982. '<area shape="circle" href="#" coords="180,205,3" title="X=-35, Y=15" >'+
  4983. '<area shape="circle" href="#" coords="182,205,3" title="X=-34, Y=15" >'+
  4984. '<area shape="circle" href="#" coords="398,173,3" title="X=74, Y=31" >'+
  4985. '<area shape="circle" href="#" coords="400,173,3" title="X=75, Y=31" >'+
  4986. '<area shape="circle" href="#" coords="398,171,3" title="X=74, Y=32" >'+
  4987. '<area shape="circle" href="#" coords="400,171,3" title="X=75, Y=32" >'+
  4988. '<area shape="circle" href="#" coords="342,133,3" title="X=46, Y=51" >'+
  4989. '<area shape="circle" href="#" coords="344,133,3" title="X=47, Y=51" >'+
  4990. '<area shape="circle" href="#" coords="342,131,3" title="X=46, Y=52" >'+
  4991. '<area shape="circle" href="#" coords="344,131,3" title="X=47, Y=52" >'+
  4992. '<area shape="circle" href="#" coords="180,107,3" title="X=-35, Y=64" >'+
  4993. '<area shape="circle" href="#" coords="180,105,3" title="X=-35, Y=65" >'+
  4994. '<area shape="circle" href="#" coords="108,251,3" title="X=-71, Y=-8" >'+
  4995. '<area shape="circle" href="#" coords="110,251,3" title="X=-70, Y=-8" >'+
  4996. '<area shape="circle" href="#" coords="108,249,3" title="X=-71, Y=-7" >'+
  4997. '<area shape="circle" href="#" coords="110,249,3" title="X=-70, Y=-7" >'+
  4998. '<area shape="circle" href="#" coords="346,191,3" title="X=48, Y=22" >'+
  4999. '<area shape="circle" href="#" coords="346,189,3" title="X=48, Y=23" >'+
  5000. '<area shape="circle" href="#" coords="346,187,3" title="X=48, Y=24" >'+
  5001. '<area shape="circle" href="#" coords="346,185,3" title="X=48, Y=25" >'+
  5002. '<area shape="circle" href="#" coords="348,195,3" title="X=49, Y=20" >'+
  5003. '<area shape="circle" href="#" coords="348,193,3" title="X=49, Y=21" >'+
  5004. '<area shape="circle" href="#" coords="348,191,3" title="X=49, Y=22" >'+
  5005. '<area shape="circle" href="#" coords="348,189,3" title="X=49, Y=23" >'+
  5006. '<area shape="circle" href="#" coords="348,187,3" title="X=49, Y=24" >'+
  5007. '<area shape="circle" href="#" coords="348,185,3" title="X=49, Y=25" >'+
  5008. '<area shape="circle" href="#" coords="348,183,3" title="X=49, Y=26" >'+
  5009. '<area shape="circle" href="#" coords="348,181,3" title="X=49, Y=27" >'+
  5010. '<area shape="circle" href="#" coords="350,199,3" title="X=50, Y=18" >'+
  5011. '<area shape="circle" href="#" coords="350,197,3" title="X=50, Y=19" >'+
  5012. '<area shape="circle" href="#" coords="350,195,3" title="X=50, Y=20" >'+
  5013. '<area shape="circle" href="#" coords="350,193,3" title="X=50, Y=21" >'+
  5014. '<area shape="circle" href="#" coords="350,191,3" title="X=50, Y=22" >'+
  5015. '<area shape="circle" href="#" coords="350,189,3" title="X=50, Y=23" >'+
  5016. '<area shape="circle" href="#" coords="350,187,3" title="X=50, Y=24" >'+
  5017. '<area shape="circle" href="#" coords="350,185,3" title="X=50, Y=25" >'+
  5018. '<area shape="circle" href="#" coords="350,183,3" title="X=50, Y=26" >'+
  5019. '<area shape="circle" href="#" coords="350,181,3" title="X=50, Y=27" >'+
  5020. '<area shape="circle" href="#" coords="350,179,3" title="X=50, Y=28" >'+
  5021. '<area shape="circle" href="#" coords="350,177,3" title="X=50, Y=29" >'+
  5022. '<area shape="circle" href="#" coords="352,201,3" title="X=51, Y=17" >'+
  5023. '<area shape="circle" href="#" coords="352,199,3" title="X=51, Y=18" >'+
  5024. '<area shape="circle" href="#" coords="352,197,3" title="X=51, Y=19" >'+
  5025. '<area shape="circle" href="#" coords="352,195,3" title="X=51, Y=20" >'+
  5026. '<area shape="circle" href="#" coords="352,193,3" title="X=51, Y=21" >'+
  5027. '<area shape="circle" href="#" coords="352,191,3" title="X=51, Y=22" >'+
  5028. '<area shape="circle" href="#" coords="352,189,3" title="X=51, Y=23" >'+
  5029. '<area shape="circle" href="#" coords="352,187,3" title="X=51, Y=24" >'+
  5030. '<area shape="circle" href="#" coords="352,185,3" title="X=51, Y=25" >'+
  5031. '<area shape="circle" href="#" coords="352,183,3" title="X=51, Y=26" >'+
  5032. '<area shape="circle" href="#" coords="352,181,3" title="X=51, Y=27" >'+
  5033. '<area shape="circle" href="#" coords="352,179,3" title="X=51, Y=28" >'+
  5034. '<area shape="circle" href="#" coords="352,177,3" title="X=51, Y=29" >'+
  5035. '<area shape="circle" href="#" coords="352,175,3" title="X=51, Y=30" >'+
  5036. '<area shape="circle" href="#" coords="354,201,3" title="X=52, Y=17" >'+
  5037. '<area shape="circle" href="#" coords="354,199,3" title="X=52, Y=18" >'+
  5038. '<area shape="circle" href="#" coords="354,197,3" title="X=52, Y=19" >'+
  5039. '<area shape="circle" href="#" coords="354,195,3" title="X=52, Y=20" >'+
  5040. '<area shape="circle" href="#" coords="354,193,3" title="X=52, Y=21" >'+
  5041. '<area shape="circle" href="#" coords="354,191,3" title="X=52, Y=22" >'+
  5042. '<area shape="circle" href="#" coords="354,189,3" title="X=52, Y=23" >'+
  5043. '<area shape="circle" href="#" coords="354,187,3" title="X=52, Y=24" >'+
  5044. '<area shape="circle" href="#" coords="354,185,3" title="X=52, Y=25" >'+
  5045. '<area shape="circle" href="#" coords="354,183,3" title="X=52, Y=26" >'+
  5046. '<area shape="circle" href="#" coords="354,181,3" title="X=52, Y=27" >'+
  5047. '<area shape="circle" href="#" coords="354,179,3" title="X=52, Y=28" >'+
  5048. '<area shape="circle" href="#" coords="354,177,3" title="X=52, Y=29" >'+
  5049. '<area shape="circle" href="#" coords="354,175,3" title="X=52, Y=30" >'+
  5050. '<area shape="circle" href="#" coords="356,203,3" title="X=53, Y=16" >'+
  5051. '<area shape="circle" href="#" coords="356,201,3" title="X=53, Y=17" >'+
  5052. '<area shape="circle" href="#" coords="356,199,3" title="X=53, Y=18" >'+
  5053. '<area shape="circle" href="#" coords="356,197,3" title="X=53, Y=19" >'+
  5054. '<area shape="circle" href="#" coords="356,195,3" title="X=53, Y=20" >'+
  5055. '<area shape="circle" href="#" coords="356,193,3" title="X=53, Y=21" >'+
  5056. '<area shape="circle" href="#" coords="356,191,3" title="X=53, Y=22" >'+
  5057. '<area shape="circle" href="#" coords="356,189,3" title="X=53, Y=23" >'+
  5058. '<area shape="circle" href="#" coords="356,187,3" title="X=53, Y=24" >'+
  5059. '<area shape="circle" href="#" coords="356,185,3" title="X=53, Y=25" >'+
  5060. '<area shape="circle" href="#" coords="356,183,3" title="X=53, Y=26" >'+
  5061. '<area shape="circle" href="#" coords="356,181,3" title="X=53, Y=27" >'+
  5062. '<area shape="circle" href="#" coords="356,179,3" title="X=53, Y=28" >'+
  5063. '<area shape="circle" href="#" coords="356,177,3" title="X=53, Y=29" >'+
  5064. '<area shape="circle" href="#" coords="356,175,3" title="X=53, Y=30" >'+
  5065. '<area shape="circle" href="#" coords="356,173,3" title="X=53, Y=31" >'+
  5066. '<area shape="circle" href="#" coords="358,203,3" title="X=54, Y=16" >'+
  5067. '<area shape="circle" href="#" coords="358,201,3" title="X=54, Y=17" >'+
  5068. '<area shape="circle" href="#" coords="358,199,3" title="X=54, Y=18" >'+
  5069. '<area shape="circle" href="#" coords="358,197,3" title="X=54, Y=19" >'+
  5070. '<area shape="circle" href="#" coords="358,195,3" title="X=54, Y=20" >'+
  5071. '<area shape="circle" href="#" coords="358,193,3" title="X=54, Y=21" >'+
  5072. '<area shape="circle" href="#" coords="358,191,3" title="X=54, Y=22" >'+
  5073. '<area shape="circle" href="#" coords="358,189,3" title="X=54, Y=23" >'+
  5074. '<area shape="circle" href="#" coords="358,187,3" title="X=54, Y=24" >'+
  5075. '<area shape="circle" href="#" coords="358,185,3" title="X=54, Y=25" >'+
  5076. '<area shape="circle" href="#" coords="358,183,3" title="X=54, Y=26" >'+
  5077. '<area shape="circle" href="#" coords="358,181,3" title="X=54, Y=27" >'+
  5078. '<area shape="circle" href="#" coords="358,179,3" title="X=54, Y=28" >'+
  5079. '<area shape="circle" href="#" coords="358,177,3" title="X=54, Y=29" >'+
  5080. '<area shape="circle" href="#" coords="358,175,3" title="X=54, Y=30" >'+
  5081. '<area shape="circle" href="#" coords="358,173,3" title="X=54, Y=31" >'+
  5082. '<area shape="circle" href="#" coords="360,205,3" title="X=55, Y=15" >'+
  5083. '<area shape="circle" href="#" coords="360,203,3" title="X=55, Y=16" >'+
  5084. '<area shape="circle" href="#" coords="360,201,3" title="X=55, Y=17" >'+
  5085. '<area shape="circle" href="#" coords="360,199,3" title="X=55, Y=18" >'+
  5086. '<area shape="circle" href="#" coords="360,197,3" title="X=55, Y=19" >'+
  5087. '<area shape="circle" href="#" coords="360,195,3" title="X=55, Y=20" >'+
  5088. '<area shape="circle" href="#" coords="360,193,3" title="X=55, Y=21" >'+
  5089. '<area shape="circle" href="#" coords="360,191,3" title="X=55, Y=22" >'+
  5090. '<area shape="circle" href="#" coords="360,189,3" title="X=55, Y=23" >'+
  5091. '<area shape="circle" href="#" coords="360,187,3" title="X=55, Y=24" >'+
  5092. '<area shape="circle" href="#" coords="360,185,3" title="X=55, Y=25" >'+
  5093. '<area shape="circle" href="#" coords="360,183,3" title="X=55, Y=26" >'+
  5094. '<area shape="circle" href="#" coords="360,181,3" title="X=55, Y=27" >'+
  5095. '<area shape="circle" href="#" coords="360,179,3" title="X=55, Y=28" >'+
  5096. '<area shape="circle" href="#" coords="360,177,3" title="X=55, Y=29" >'+
  5097. '<area shape="circle" href="#" coords="360,175,3" title="X=55, Y=30" >'+
  5098. '<area shape="circle" href="#" coords="360,173,3" title="X=55, Y=31" >'+
  5099. '<area shape="circle" href="#" coords="360,171,3" title="X=55, Y=32" >'+
  5100. '<area shape="circle" href="#" coords="362,205,3" title="X=56, Y=15" >'+
  5101. '<area shape="circle" href="#" coords="362,203,3" title="X=56, Y=16" >'+
  5102. '<area shape="circle" href="#" coords="362,201,3" title="X=56, Y=17" >'+
  5103. '<area shape="circle" href="#" coords="362,199,3" title="X=56, Y=18" >'+
  5104. '<area shape="circle" href="#" coords="362,197,3" title="X=56, Y=19" >'+
  5105. '<area shape="circle" href="#" coords="362,195,3" title="X=56, Y=20" >'+
  5106. '<area shape="circle" href="#" coords="362,193,3" title="X=56, Y=21" >'+
  5107. '<area shape="circle" href="#" coords="362,191,3" title="X=56, Y=22" >'+
  5108. '<area shape="circle" href="#" coords="362,189,3" title="X=56, Y=23" >'+
  5109. '<area shape="circle" href="#" coords="362,187,3" title="X=56, Y=24" >'+
  5110. '<area shape="circle" href="#" coords="362,185,3" title="X=56, Y=25" >'+
  5111. '<area shape="circle" href="#" coords="362,183,3" title="X=56, Y=26" >'+
  5112. '<area shape="circle" href="#" coords="362,181,3" title="X=56, Y=27" >'+
  5113. '<area shape="circle" href="#" coords="362,179,3" title="X=56, Y=28" >'+
  5114. '<area shape="circle" href="#" coords="362,177,3" title="X=56, Y=29" >'+
  5115. '<area shape="circle" href="#" coords="362,175,3" title="X=56, Y=30" >'+
  5116. '<area shape="circle" href="#" coords="362,173,3" title="X=56, Y=31" >'+
  5117. '<area shape="circle" href="#" coords="362,171,3" title="X=56, Y=32" >'+
  5118. '<area shape="circle" href="#" coords="364,205,3" title="X=57, Y=15" >'+
  5119. '<area shape="circle" href="#" coords="364,203,3" title="X=57, Y=16" >'+
  5120. '<area shape="circle" href="#" coords="364,201,3" title="X=57, Y=17" >'+
  5121. '<area shape="circle" href="#" coords="364,199,3" title="X=57, Y=18" >'+
  5122. '<area shape="circle" href="#" coords="364,197,3" title="X=57, Y=19" >'+
  5123. '<area shape="circle" href="#" coords="364,195,3" title="X=57, Y=20" >'+
  5124. '<area shape="circle" href="#" coords="364,193,3" title="X=57, Y=21" >'+
  5125. '<area shape="circle" href="#" coords="364,191,3" title="X=57, Y=22" >'+
  5126. '<area shape="circle" href="#" coords="364,189,3" title="X=57, Y=23" >'+
  5127. '<area shape="circle" href="#" coords="364,187,3" title="X=57, Y=24" >'+
  5128. '<area shape="circle" href="#" coords="364,185,3" title="X=57, Y=25" >'+
  5129. '<area shape="circle" href="#" coords="364,183,3" title="X=57, Y=26" >'+
  5130. '<area shape="circle" href="#" coords="364,181,3" title="X=57, Y=27" >'+
  5131. '<area shape="circle" href="#" coords="364,179,3" title="X=57, Y=28" >'+
  5132. '<area shape="circle" href="#" coords="364,177,3" title="X=57, Y=29" >'+
  5133. '<area shape="circle" href="#" coords="364,175,3" title="X=57, Y=30" >'+
  5134. '<area shape="circle" href="#" coords="364,173,3" title="X=57, Y=31" >'+
  5135. '<area shape="circle" href="#" coords="364,171,3" title="X=57, Y=32" >'+
  5136. '<area shape="circle" href="#" coords="366,205,3" title="X=58, Y=15" >'+
  5137. '<area shape="circle" href="#" coords="366,203,3" title="X=58, Y=16" >'+
  5138. '<area shape="circle" href="#" coords="366,201,3" title="X=58, Y=17" >'+
  5139. '<area shape="circle" href="#" coords="366,199,3" title="X=58, Y=18" >'+
  5140. '<area shape="circle" href="#" coords="366,197,3" title="X=58, Y=19" >'+
  5141. '<area shape="circle" href="#" coords="366,195,3" title="X=58, Y=20" >'+
  5142. '<area shape="circle" href="#" coords="366,193,3" title="X=58, Y=21" >'+
  5143. '<area shape="circle" href="#" coords="366,191,3" title="X=58, Y=22" >'+
  5144. '<area shape="circle" href="#" coords="366,189,3" title="X=58, Y=23" >'+
  5145. '<area shape="circle" href="#" coords="366,187,3" title="X=58, Y=24" >'+
  5146. '<area shape="circle" href="#" coords="366,185,3" title="X=58, Y=25" >'+
  5147. '<area shape="circle" href="#" coords="366,183,3" title="X=58, Y=26" >'+
  5148. '<area shape="circle" href="#" coords="366,181,3" title="X=58, Y=27" >'+
  5149. '<area shape="circle" href="#" coords="366,179,3" title="X=58, Y=28" >'+
  5150. '<area shape="circle" href="#" coords="366,177,3" title="X=58, Y=29" >'+
  5151. '<area shape="circle" href="#" coords="366,175,3" title="X=58, Y=30" >'+
  5152. '<area shape="circle" href="#" coords="366,173,3" title="X=58, Y=31" >'+
  5153. '<area shape="circle" href="#" coords="366,171,3" title="X=58, Y=32" >'+
  5154. '<area shape="circle" href="#" coords="368,203,3" title="X=59, Y=16" >'+
  5155. '<area shape="circle" href="#" coords="368,201,3" title="X=59, Y=17" >'+
  5156. '<area shape="circle" href="#" coords="368,199,3" title="X=59, Y=18" >'+
  5157. '<area shape="circle" href="#" coords="368,197,3" title="X=59, Y=19" >'+
  5158. '<area shape="circle" href="#" coords="368,195,3" title="X=59, Y=20" >'+
  5159. '<area shape="circle" href="#" coords="368,193,3" title="X=59, Y=21" >'+
  5160. '<area shape="circle" href="#" coords="368,191,3" title="X=59, Y=22" >'+
  5161. '<area shape="circle" href="#" coords="368,189,3" title="X=59, Y=23" >'+
  5162. '<area shape="circle" href="#" coords="368,187,3" title="X=59, Y=24" >'+
  5163. '<area shape="circle" href="#" coords="368,185,3" title="X=59, Y=25" >'+
  5164. '<area shape="circle" href="#" coords="368,183,3" title="X=59, Y=26" >'+
  5165. '<area shape="circle" href="#" coords="368,181,3" title="X=59, Y=27" >'+
  5166. '<area shape="circle" href="#" coords="368,179,3" title="X=59, Y=28" >'+
  5167. '<area shape="circle" href="#" coords="368,177,3" title="X=59, Y=29" >'+
  5168. '<area shape="circle" href="#" coords="368,175,3" title="X=59, Y=30" >'+
  5169. '<area shape="circle" href="#" coords="368,173,3" title="X=59, Y=31" >'+
  5170. '<area shape="circle" href="#" coords="370,203,3" title="X=60, Y=16" >'+
  5171. '<area shape="circle" href="#" coords="370,201,3" title="X=60, Y=17" >'+
  5172. '<area shape="circle" href="#" coords="370,199,3" title="X=60, Y=18" >'+
  5173. '<area shape="circle" href="#" coords="370,197,3" title="X=60, Y=19" >'+
  5174. '<area shape="circle" href="#" coords="370,195,3" title="X=60, Y=20" >'+
  5175. '<area shape="circle" href="#" coords="370,193,3" title="X=60, Y=21" >'+
  5176. '<area shape="circle" href="#" coords="370,191,3" title="X=60, Y=22" >'+
  5177. '<area shape="circle" href="#" coords="370,189,3" title="X=60, Y=23" >'+
  5178. '<area shape="circle" href="#" coords="370,187,3" title="X=60, Y=24" >'+
  5179. '<area shape="circle" href="#" coords="370,185,3" title="X=60, Y=25" >'+
  5180. '<area shape="circle" href="#" coords="370,183,3" title="X=60, Y=26" >'+
  5181. '<area shape="circle" href="#" coords="370,181,3" title="X=60, Y=27" >'+
  5182. '<area shape="circle" href="#" coords="370,179,3" title="X=60, Y=28" >'+
  5183. '<area shape="circle" href="#" coords="370,177,3" title="X=60, Y=29" >'+
  5184. '<area shape="circle" href="#" coords="370,175,3" title="X=60, Y=30" >'+
  5185. '<area shape="circle" href="#" coords="370,173,3" title="X=60, Y=31" >'+
  5186. '<area shape="circle" href="#" coords="372,201,3" title="X=61, Y=17" >'+
  5187. '<area shape="circle" href="#" coords="372,199,3" title="X=61, Y=18" >'+
  5188. '<area shape="circle" href="#" coords="372,197,3" title="X=61, Y=19" >'+
  5189. '<area shape="circle" href="#" coords="372,195,3" title="X=61, Y=20" >'+
  5190. '<area shape="circle" href="#" coords="372,193,3" title="X=61, Y=21" >'+
  5191. '<area shape="circle" href="#" coords="372,191,3" title="X=61, Y=22" >'+
  5192. '<area shape="circle" href="#" coords="372,189,3" title="X=61, Y=23" >'+
  5193. '<area shape="circle" href="#" coords="372,187,3" title="X=61, Y=24" >'+
  5194. '<area shape="circle" href="#" coords="372,185,3" title="X=61, Y=25" >'+
  5195. '<area shape="circle" href="#" coords="372,183,3" title="X=61, Y=26" >'+
  5196. '<area shape="circle" href="#" coords="372,181,3" title="X=61, Y=27" >'+
  5197. '<area shape="circle" href="#" coords="372,179,3" title="X=61, Y=28" >'+
  5198. '<area shape="circle" href="#" coords="372,177,3" title="X=61, Y=29" >'+
  5199. '<area shape="circle" href="#" coords="372,175,3" title="X=61, Y=30" >'+
  5200. '<area shape="circle" href="#" coords="374,201,3" title="X=62, Y=17" >'+
  5201. '<area shape="circle" href="#" coords="374,199,3" title="X=62, Y=18" >'+
  5202. '<area shape="circle" href="#" coords="374,197,3" title="X=62, Y=19" >'+
  5203. '<area shape="circle" href="#" coords="374,195,3" title="X=62, Y=20" >'+
  5204. '<area shape="circle" href="#" coords="374,193,3" title="X=62, Y=21" >'+
  5205. '<area shape="circle" href="#" coords="374,191,3" title="X=62, Y=22" >'+
  5206. '<area shape="circle" href="#" coords="374,189,3" title="X=62, Y=23" >'+
  5207. '<area shape="circle" href="#" coords="374,187,3" title="X=62, Y=24" >'+
  5208. '<area shape="circle" href="#" coords="374,185,3" title="X=62, Y=25" >'+
  5209. '<area shape="circle" href="#" coords="374,183,3" title="X=62, Y=26" >'+
  5210. '<area shape="circle" href="#" coords="374,181,3" title="X=62, Y=27" >'+
  5211. '<area shape="circle" href="#" coords="374,179,3" title="X=62, Y=28" >'+
  5212. '<area shape="circle" href="#" coords="374,177,3" title="X=62, Y=29" >'+
  5213. '<area shape="circle" href="#" coords="374,175,3" title="X=62, Y=30" >'+
  5214. '<area shape="circle" href="#" coords="376,199,3" title="X=63, Y=18" >'+
  5215. '<area shape="circle" href="#" coords="376,197,3" title="X=63, Y=19" >'+
  5216. '<area shape="circle" href="#" coords="376,195,3" title="X=63, Y=20" >'+
  5217. '<area shape="circle" href="#" coords="376,193,3" title="X=63, Y=21" >'+
  5218. '<area shape="circle" href="#" coords="376,191,3" title="X=63, Y=22" >'+
  5219. '<area shape="circle" href="#" coords="376,189,3" title="X=63, Y=23" >'+
  5220. '<area shape="circle" href="#" coords="376,187,3" title="X=63, Y=24" >'+
  5221. '<area shape="circle" href="#" coords="376,185,3" title="X=63, Y=25" >'+
  5222. '<area shape="circle" href="#" coords="376,183,3" title="X=63, Y=26" >'+
  5223. '<area shape="circle" href="#" coords="376,181,3" title="X=63, Y=27" >'+
  5224. '<area shape="circle" href="#" coords="376,179,3" title="X=63, Y=28" >'+
  5225. '<area shape="circle" href="#" coords="376,177,3" title="X=63, Y=29" >'+
  5226. '<area shape="circle" href="#" coords="378,195,3" title="X=64, Y=20" >'+
  5227. '<area shape="circle" href="#" coords="378,193,3" title="X=64, Y=21" >'+
  5228. '<area shape="circle" href="#" coords="378,191,3" title="X=64, Y=22" >'+
  5229. '<area shape="circle" href="#" coords="378,189,3" title="X=64, Y=23" >'+
  5230. '<area shape="circle" href="#" coords="378,187,3" title="X=64, Y=24" >'+
  5231. '<area shape="circle" href="#" coords="378,185,3" title="X=64, Y=25" >'+
  5232. '<area shape="circle" href="#" coords="378,183,3" title="X=64, Y=26" >'+
  5233. '<area shape="circle" href="#" coords="378,181,3" title="X=64, Y=27" >'+
  5234. '<area shape="circle" href="#" coords="380,191,3" title="X=65, Y=22" >'+
  5235. '<area shape="circle" href="#" coords="380,189,3" title="X=65, Y=23" >'+
  5236. '<area shape="circle" href="#" coords="380,187,3" title="X=65, Y=24" >'+
  5237. '<area shape="circle" href="#" coords="380,185,3" title="X=65, Y=25" >'+
  5238. '</map>';
  5239.  
  5240. var nvspan = document.createElement('div');
  5241. nvspan.align = 'center';
  5242. nvspan.id = 'mz_mapdiv';
  5243. nvspan.valign = 'top';
  5244. nvspan.innerHTML = nvdiv;
  5245. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  5246. var footer = document.getElementById('footer1');
  5247. footer.parentNode.insertBefore(nvspan,footer);
  5248. }
  5249.  
  5250. function testeGlissiere() {
  5251. try {
  5252. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  5253. var footer = document.getElementById('footer1');
  5254. footer.parentNode.insertBefore(gliss.getElt(), footer);
  5255. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  5256. }
  5257.  
  5258. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  5259. if (x0 !== undefined) {
  5260. // ouais, récursif une fois
  5261. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  5262. if (PtInterm === undefined)
  5263. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  5264. else
  5265. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  5266. return;
  5267. }
  5268. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  5269. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  5270. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  5271. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  5272. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  5273. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  5274. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  5275. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  5276. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  5277. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  5278. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  5279. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  5280. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  5281. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  5282. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  5283. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  5284. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  5285. }
  5286.  
  5287. function do_ordresgowap() {
  5288. if (newCarte) {
  5289. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  5290. //testeGlissiere();
  5291. //MZ_testsUnitairesCalculIntermediaire();
  5292. } else {
  5293. setCarteGogo(); // Via script des trouillots
  5294. }
  5295. }
  5296.  
  5297. function do_listegowap() {
  5298. if (!newCarte) return;
  5299. MZ_setCarteTousGogoHTML5();
  5300. }
  5301.  
  5302. function do_lieuDescription() {
  5303. if (!newCarte) return;
  5304. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  5305. MZ_setCarteTP();
  5306. }
  5307.  
  5308. function do_lieuTeleport() {
  5309. changeButtonValidate();
  5310. if (!newCarte) return;
  5311. MZ_setCarteTP();
  5312. }
  5313.  
  5314. /*********************************************************************************
  5315. * This file is part of Mountyzilla. *
  5316. * *
  5317. * Mountyzilla is free software; you can redistribute it and/or modify *
  5318. * it under the terms of the GNU General Public License as published by *
  5319. * the Free Software Foundation; either version 2 of the License, or *
  5320. * (at your option) any later version. *
  5321. * *
  5322. * Mountyzilla is distributed in the hope that it will be useful, *
  5323. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5324. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5325. * GNU General Public License for more details. *
  5326. * *
  5327. * You should have received a copy of the GNU General Public License *
  5328. * along with Mountyzilla; if not, write to the Free Software *
  5329. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5330. *********************************************************************************/
  5331.  
  5332. // x~x attaque
  5333.  
  5334. // Script désactivé en attendant la màj vers le nouveau système de missions.
  5335.  
  5336. function do_attaque() {
  5337. }
  5338.  
  5339. /*******************************************************************************
  5340. * This file is part of Mountyzilla. *
  5341. * *
  5342. * Mountyzilla is free software; you can redistribute it and/or modify *
  5343. * it under the terms of the GNU General Public License as published by *
  5344. * the Free Software Foundation; either version 2 of the License, or *
  5345. * (at your option) any later version. *
  5346. * *
  5347. * Mountyzilla is distributed in the hope that it will be useful, *
  5348. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5349. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5350. * GNU General Public License for more details. *
  5351. * *
  5352. * You should have received a copy of the GNU General Public License *
  5353. * along with Mountyzilla; if not, write to the Free Software *
  5354. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5355. *******************************************************************************/
  5356.  
  5357. // x~x infomonstre
  5358.  
  5359. // DEBUG
  5360. var nomMonstre='';
  5361. var idMonstre=-1;
  5362. //var tbody;
  5363. var popup;
  5364.  
  5365. function traiteMonstre() {
  5366. try {
  5367. var nodeTitre = document.evaluate(
  5368. "//div[@class='titre2' and contains(text(),'(')]",
  5369. document, null, 9, null
  5370. ).singleNodeValue;
  5371. var texte = nodeTitre.firstChild.nodeValue;
  5372. } catch(e) {
  5373. window.console.log(traceStack(e, 'traiteMonstre'));
  5374. return;
  5375. }
  5376.  
  5377. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  5378. if(nomMonstre.indexOf(']')!=-1) {
  5379. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  5380. }
  5381. idMonstre = texte.match(/\d+/)[0];
  5382. var tReq = [{'index':1, 'id':+idMonstre, 'nom':nomMonstre}]; // "+" pour forcer du numérique
  5383. FF_XMLHttpRequest({
  5384. method: 'POST',
  5385. url: URL_MZgetCaracMonstre,
  5386. headers : {
  5387. 'Content-type':'application/x-www-form-urlencoded'
  5388. },
  5389. data: 'l=' + JSON.stringify(tReq),
  5390. trace: 'demande niveaux monstres V2, MonsterView',
  5391. onload: function(responseDetails) {
  5392. try {
  5393. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  5394. if (responseDetails.status == 0) return;
  5395. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  5396. var texte = responseDetails.responseText;
  5397. var infosRet = JSON.parse(texte);
  5398. if(infosRet.length==0) return;
  5399. var info = infosRet[0];
  5400. MZ_EtatCdMs.listeCDM[idMonstre]=info;
  5401. try {
  5402. var nodeInsert = document.evaluate(
  5403. "//div[@class = 'titre3']",
  5404. document, null, 9, null
  5405. ).singleNodeValue;
  5406. } catch(e) {
  5407. window.console.log(traceStack(e, 'recherche node pour info CdM'));
  5408. return;
  5409. }
  5410. var table = createCDMTable(idMonstre,nomMonstre,info);
  5411. table.align = 'center';
  5412. var tbody = table.childNodes[1];
  5413. var thead = table.childNodes[0];
  5414. var tdEntete = thead.firstChild.firstChild;
  5415. tdEntete.onclick = toggleTableau;
  5416. tdEntete.style.cursor = 'pointer';
  5417. thead.firstChild.style = 'mh_tdpage';
  5418. tbody.style.display = 'none';
  5419. table.style.width = '350px';
  5420. insertBefore(nodeInsert,table);
  5421. } catch(e) {
  5422. window.console.log(e);
  5423. }
  5424. },
  5425. });
  5426. }
  5427.  
  5428. function initPopupInfomonstre() {
  5429. // Initialise le popup tactique (calculs att/deg)
  5430. popup = document.createElement('div');
  5431. popup.id = 'popup';
  5432. popup.className = 'mh_textbox';
  5433. popup.style =
  5434. 'position: absolute;'+
  5435. 'border: 1px solid #000000;'+
  5436. 'visibility: hidden;'+
  5437. 'display: inline;'+
  5438. 'z-index: 3;'+
  5439. 'max-width: 400px;';
  5440. document.body.appendChild(popup);
  5441. }
  5442.  
  5443. function showPopupTactique(evt) {
  5444. try {
  5445. var id = this.id;
  5446. var nom = this.nom;
  5447. var texte = getAnalyseTactique(id,nom);
  5448. if(texte==undefined || texte=='') { return; }
  5449. popup.innerHTML = texte;
  5450. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  5451. if(isPage("View/MonsterView")) {
  5452. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  5453. } else {
  5454. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  5455. }
  5456. popup.style.top = evt.pageY+15+'px';
  5457. popup.style.visibility = 'visible';
  5458. } catch(e) {
  5459. //window.alert(e);
  5460. window.console.log(e);
  5461. }
  5462. }
  5463.  
  5464. function toggleTableau() { // click sur un td de thead
  5465. var tbody = this.parentNode.parentNode.parentNode.childNodes[1];
  5466. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  5467. }
  5468.  
  5469. function do_infomonstre() {
  5470. start_script();
  5471. try {
  5472. initPopupInfomonstre();
  5473. traiteMonstre();
  5474. } catch(e) {
  5475. window.console.error(traceStack(e, 'do_infomonstre'));
  5476. window.alert('Erreur infoMonstre:\n'+e);
  5477. }
  5478. displayScriptTime();
  5479. }
  5480.  
  5481. /***
  5482. *** SCIZ
  5483. ***/
  5484. var scizGlobal = {
  5485. events: []
  5486. };
  5487.  
  5488. function scizPrettyPrintEvent(e) {
  5489. e.message = e.message.replace(/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}\s[0-9]{2}h[0-9]{2}:[0-9]{2}(\sMORT\s\-)?/g, ''); // Delete date and death flag
  5490. e.message = e.message.replace(/\n\s*\n*/g, '<br/>');
  5491. const beings = [[e.att_id, e.att_nom], [e.def_id, e.def_nom], [e.mob_id, e.mob_nom], [e.owner_id, e.owner_nom], [e.troll_id, e.troll_nom]];
  5492. beings.forEach(b => {
  5493. if (b[0] && b[1]) {
  5494. b[1] = b[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  5495. if (b[0].toString().length > 6) {
  5496. // Mob
  5497. b[1] = b[1].replace(/^une?\s/g, '');
  5498. e.message = e.message.replace(new RegExp('(' + b[1] + ')','g'), '<b><a href="/mountyhall/View/MonsterView.php?ai_IDPJ=' + b[0] + '" rel="modal:open" class="mh_monstres">\$1</a></b>');
  5499. } else {
  5500. // Troll
  5501. e.message = e.message.replace(new RegExp('(' + b[1] + ')','g'), '<b><a href="javascript:EPV(\'' + b[0] + '\')" class="mh_trolls_1">\$1</a></b>');
  5502. }
  5503. }
  5504. });
  5505. return e;
  5506. }
  5507.  
  5508. function do_scizOverwriteEvents() {
  5509. scizGlobal.events = [];
  5510. var eventTableNode = null;
  5511.  
  5512. // Ensure we have a JWT setup for the current user
  5513. jwt = MY_getValue(numTroll + '.SCIZJWT');
  5514. if (!jwt) { return; }
  5515.  
  5516. // Retrieve being ID
  5517. const url = new URL(window.location.href);
  5518. var id = url.searchParams.get('ai_IDPJ');
  5519. id = (!id) ? numTroll : id;
  5520.  
  5521. // Check for advanced profil
  5522. const advanced = document.querySelector("[href*='MH_Style_ProfilAvance.css']") !== null;
  5523. const xPathQuery = (advanced) ? "//*/table[@id='events']/tbody/tr" : "//*/tr[@class='mh_tdpage']";
  5524.  
  5525. // Retrieve local events
  5526. var xPathEvents = document.evaluate(xPathQuery, document, null, 0, null);
  5527. while (xPathEvent = xPathEvents.iterateNext()) {
  5528. scizGlobal.events.push({
  5529. 'time': Date.parse(StringToDate(xPathEvent.children[0].innerHTML)),
  5530. 'type': xPathEvent.children[1].innerHTML,
  5531. 'desc': xPathEvent.children[2].innerHTML,
  5532. 'sciz_desc': null,
  5533. 'node': xPathEvent,
  5534. });
  5535. if (eventTableNode === null) {
  5536. eventTableNode = xPathEvent.parentNode.parentNode;
  5537. }
  5538. }
  5539. const interval = 5000; // Maximum interval (seconds) for matching some events
  5540. const startTime = Math.min.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) - interval;
  5541. const endTime = Math.max.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) + interval;
  5542.  
  5543. // Check if events have been found in the page
  5544. if (scizGlobal.events.length < 1) {
  5545. window.console.log('ERREUR - MZ/SCIZ - Aucun événement trouvé sur la page...');
  5546. return;
  5547. }
  5548.  
  5549. // Call SCIZ
  5550. var sciz_url = 'https://www.sciz.fr/api/hook/events/' + id + '/' + startTime + '/' + endTime;
  5551. const eventType = url.searchParams.get('as_EventType'); // Retrieve event type filter
  5552. sciz_url += (eventType !== null && eventType !== '') ? '/' + eventType.split(' ')[0] : '' // Only the first word used for filtering ("MORT par monstre" => "MORT");
  5553. FF_XMLHttpRequest({
  5554. method: 'GET',
  5555. url: sciz_url,
  5556. headers : { 'Authorization': jwt },
  5557. // trace: 'Appel à SCIZ pour l'entité ' + id,
  5558. onload: function(responseDetails) {
  5559. try {
  5560. if (responseDetails.status == 0) {
  5561. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5562. window.console.log(responseDetails);
  5563. return;
  5564. }
  5565. var events = JSON.parse(responseDetails.responseText);
  5566. if (events.events.length < 1) {
  5567. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5568. return;
  5569. }
  5570. // Look for events to overwrite (based on timestamps)
  5571. events.events.forEach(e => {
  5572. if (e.message.includes(id)) { // Exclude any event we were not looking for...
  5573. const t = Date.parse(StringToDate(e.time));
  5574. // Look for the best event matching and not already replaced
  5575. var i = -1;
  5576. var lastDelta = Infinity;
  5577. for (j = 0; j < scizGlobal.events.length; j++) {
  5578. if (scizGlobal.events[j].sciz_desc === null) {
  5579. var delta = Math.abs(t - scizGlobal.events[j].time);
  5580. if (delta <= interval && delta < lastDelta) {
  5581. lastDelta = delta;
  5582. i = j;
  5583. }
  5584. }
  5585. }
  5586. if (i > -1) {
  5587. // PrettyPrint
  5588. e = scizPrettyPrintEvent(e);
  5589. // Store the SCIZ event
  5590. scizGlobal.events[i].sciz_desc = e.message;
  5591. // Actual display overwrite
  5592. scizGlobal.events[i].node.children[2].innerHTML = scizGlobal.events[i].sciz_desc;
  5593. }
  5594. }
  5595. });
  5596. // Add the switch button
  5597. if (eventTableNode !== null) {
  5598. var img = document.createElement('img');
  5599. img.src = 'https://www.sciz.fr/static/104126/sciz-logo-quarter.png';
  5600. img.alt = 'SCIZ logo';
  5601. img.style = 'height: 50px; cursor: pointer;';
  5602. img.onclick = do_scizSwitchEvents;
  5603. var div = document.createElement('div');
  5604. div.style = 'text-align: center;';
  5605. div.appendChild(img);
  5606. eventTableNode.parentNode.insertBefore(div, eventTableNode.nextSibling);
  5607. }
  5608. } catch(e) {
  5609. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5610. window.console.log(e);
  5611. }
  5612. }
  5613. });
  5614. }
  5615.  
  5616. function do_scizSwitchEvents() {
  5617. scizGlobal.events.forEach((e) => {
  5618. const currentDesc = e.node.children[2].innerHTML;
  5619. e.node.children[2].innerHTML = (currentDesc === e.desc) ? ((e.sciz_desc !== null) ? e.sciz_desc : e.desc) : e.desc;
  5620. });
  5621. }
  5622.  
  5623. /*******************************************************************************
  5624. * This file is part of Mountyzilla. *
  5625. * *
  5626. * Mountyzilla is free software; you can redistribute it and/or modify *
  5627. * it under the terms of the GNU General Public License as published by *
  5628. * the Free Software Foundation; either version 2 of the License, or *
  5629. * (at your option) any later version. *
  5630. * *
  5631. * Mountyzilla is distributed in the hope that it will be useful, *
  5632. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5633. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5634. * GNU General Public License for more details. *
  5635. * *
  5636. * You should have received a copy of the GNU General Public License *
  5637. * along with Mountyzilla; if not, write to the Free Software *
  5638. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5639. *******************************************************************************/
  5640.  
  5641. // x~x mission
  5642.  
  5643. /* TODO
  5644. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  5645. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  5646. *
  5647. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  5648. */
  5649. function isArray(a) {
  5650. return (!!a) && (a.constructor === Array);
  5651. }
  5652.  
  5653. function saveMission(num,obEtape) {
  5654. var obMissions;
  5655. if(MY_getValue(numTroll+'.MISSIONS')) {
  5656. try {
  5657. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5658. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  5659. } catch(e) {
  5660. window.console.error(traceStack(e, 'Mission parsage'));
  5661. return;
  5662. }
  5663. }
  5664. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  5665. if (obMissions == undefined) obMissions = new Object(); // protection
  5666. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  5667. if(obEtape) {
  5668. obMissions[num] = obEtape;
  5669. } else if(obMissions[num]) {
  5670. delete obMissions[num];
  5671. }
  5672. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  5673. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5674. }
  5675.  
  5676. function addtroogle(tdLibelle, sRestrict) {
  5677. var img = document.createElement('img');
  5678. img.src = URL_MZimg + 'troogle.ico';
  5679. img.alt = 'Troogle logo';
  5680. var a = document.createElement('a');
  5681. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  5682. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  5683. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  5684. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  5685. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  5686. a.href = url;
  5687. a.title = 'Chercher sur Troogle';
  5688. a.target = 'troogle';
  5689. a.appendChild(img);
  5690. tdLibelle.appendChild(a);
  5691. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  5692. }
  5693.  
  5694. function traiteMission() {
  5695. try {
  5696. var titreMission = document.getElementsByClassName('titre2')[0];
  5697. var numMission = titreMission.textContent.match(/\d+/)[0];
  5698. var missionForm = document.getElementsByName('ActionForm')[0];
  5699. var tdLibelle = document.evaluate(
  5700. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  5701. missionForm, null, 9, null).singleNodeValue;
  5702. } catch(e) {
  5703. window.console.error(traceStack(e, 'récupération mission'));
  5704. return;
  5705. }
  5706. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  5707. try {
  5708. if(!tdLibelle) {
  5709. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  5710. debugMZ('traiteMission, la mission semble terminée');
  5711. saveMission(numMission,false);
  5712. return;
  5713. }
  5714.  
  5715. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  5716. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  5717. // debug Roule'
  5718. if (MY_DEBUG) {
  5719. for (var i =0; i < tdLibelle.childNodes.length; i++)
  5720. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  5721. }
  5722. if(libelle.indexOf('niveau égal à')!=-1) {
  5723. var nbKills = 1, niveau, mod;
  5724. // exemples :
  5725. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  5726. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  5727. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  5728. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  5729. if (tdLibelle.childNodes.length == 1) {
  5730. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  5731. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  5732. if (m) {
  5733. niveau = Number(m[1]);
  5734. mod = 'plus'
  5735. } else {
  5736. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  5737. if (m) {
  5738. niveau = Number(m[1]);
  5739. mod = Number(m[2]);
  5740. } else {
  5741. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  5742. return;
  5743. }
  5744. }
  5745. } else {
  5746. // ancienne méthode (multi childnode)
  5747. // à supprimer un jour peut-être
  5748. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  5749. // Étape de kill multiple de niveau donné
  5750. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5751. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  5752. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5753. niveau = Number(mod[0]);
  5754. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5755. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  5756. } else {
  5757. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  5758. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5759. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  5760. mod = mod ? Number(mod[0]) : 'plus';
  5761. }
  5762. } else {
  5763. // Étape de kill unique de niveau donné
  5764. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  5765. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5766. mod = mod ? Number(mod[0]) : 'plus';
  5767. }
  5768. }
  5769. // if (isDEV) {
  5770. // niveau = 35; // pour les tests Roule
  5771. // alert('niveau forcé à 35 pour test');
  5772. // }
  5773. // debug Roule'
  5774. if (MY_DEBUG) {
  5775. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  5776. }
  5777. saveMission(numMission,{
  5778. type: 'Niveau',
  5779. niveau: niveau,
  5780. mod: mod,
  5781. mundidey: siMundidey,
  5782. libelle: libelle
  5783. });
  5784. if (mod == 'plus')
  5785. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  5786. else
  5787. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  5788. } else if(libelle.indexOf('de la race')!=-1) {
  5789. var nbKills = 1, race;
  5790. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  5791. // Étape de kill multiple de race donnée
  5792. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5793. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5794. } else {
  5795. // Étape de kill unique de race donnée
  5796. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5797. }
  5798. race = race.replace(/\"/g,'');
  5799. race = removeEnclosingSimpleCote(race); // Roule 29/03/2019 Maintenant, on a des '
  5800. saveMission(numMission,{
  5801. type: 'Race',
  5802. race: race,
  5803. mundidey: siMundidey,
  5804. libelle: libelle
  5805. });
  5806. addtroogle(tdLibelle, '@monstre ' + race);
  5807. } else if(libelle.indexOf('de la famille')!=-1) {
  5808. var nbKills = 1, famille;
  5809. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  5810. // Étape de kill multiple de famille donnée
  5811. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5812. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5813. } else {
  5814. // Étape de kill unique de famille donnée
  5815. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5816. }
  5817. famille = famille.replace(/\"/g,'');
  5818. famille = removeEnclosingSimpleCote(famille); // Roule 29/03/2019 Maintenant, on a des '
  5819. saveMission(numMission,{
  5820. type: 'Famille',
  5821. famille: famille,
  5822. mundidey: siMundidey,
  5823. libelle: libelle
  5824. });
  5825. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  5826. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  5827. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  5828. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  5829. debugMZ('traiteMission étape capacité spéciale');
  5830. pouvoir = removeEnclosingSimpleCote(pouvoir); // Roule 29/03/2019 Maintenant, on a des '
  5831. saveMission(numMission,{
  5832. type: 'Pouvoir',
  5833. pouvoir: pouvoir,
  5834. libelle: libelle
  5835. });
  5836. } else {
  5837. debugMZ('traiteMission étape pas pour troogle');
  5838. saveMission(numMission,false);
  5839. }
  5840. } catch(e) {
  5841. window.console.error(traceStack(e, 'récupération étape mission'));
  5842. return;
  5843. }
  5844. }
  5845.  
  5846. function removeEnclosingSimpleCote(x) { // Roule 29/03/2019
  5847. return x.replace(/'$/, '').replace(/^'/, '');
  5848. }
  5849.  
  5850. function do_mission() {
  5851. start_script(60);
  5852.  
  5853. traiteMission();
  5854.  
  5855. displayScriptTime();
  5856. }
  5857.  
  5858. /*******************************************************************************
  5859. * This file is part of Mountyzilla. *
  5860. * *
  5861. * Mountyzilla is free software; you can redistribute it and/or modify *
  5862. * it under the terms of the GNU General Public License as published by *
  5863. * the Free Software Foundation; either version 2 of the License, or *
  5864. * (at your option) any later version. *
  5865. * *
  5866. * Mountyzilla is distributed in the hope that it will be useful, *
  5867. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5868. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5869. * GNU General Public License for more details. *
  5870. * *
  5871. * You should have received a copy of the GNU General Public License *
  5872. * along with Mountyzilla; if not, write to the Free Software *
  5873. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5874. *******************************************************************************/
  5875.  
  5876. // x~x move
  5877.  
  5878. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  5879.  
  5880. var petitsTrous = {
  5881. '-52;57': true,
  5882. '55;70': true,
  5883. '64;70': true,
  5884. '12;-15': true,
  5885. '30;-52': true,
  5886. '48;-39': true
  5887. };
  5888.  
  5889. var grosTrous = {
  5890. '-35;65': true,
  5891. '-13;73': true,
  5892. '-64;9': true,
  5893. '-35;15': true,
  5894. '5;32': true,
  5895. '10;64': true,
  5896. '21;36': true,
  5897. '46;52': true,
  5898. '74;32': true,
  5899. '-71;-7': true,
  5900. '-67;-37': true,
  5901. '-60;-32': true,
  5902. '-51;-22': true,
  5903. '-36;-51': true,
  5904. '5;-49': true
  5905. };
  5906.  
  5907. var centreCarmine_X = 56.5;
  5908. var centreCarmine_Y = 23.5;
  5909. var rayonCarmine = 8.7;
  5910.  
  5911. function isTrou(x,y,n) {
  5912. if(petitsTrous[x+';'+y]) {
  5913. return n<0 && n>-60;
  5914. }
  5915. if(grosTrous[x+';'+y]
  5916. || grosTrous[x-1+';'+y]
  5917. || grosTrous[x+';'+y+1]
  5918. || grosTrous[x-1+';'+y+1]) {
  5919. return n<0 && n>-70;
  5920. }
  5921. if(Math.sqrt(
  5922. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  5923. )<=rayonCarmine) {
  5924. return n<0 && n>-100;
  5925. }
  5926. return false;
  5927. }
  5928.  
  5929. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  5930.  
  5931. function validateDestination() {
  5932. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  5933. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  5934. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  5935. var form = document.getElementsByName('ActionForm')[0];
  5936. if(form) {
  5937. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  5938. if(document.getElementsByName('ai_DeplX')[i].checked) {
  5939. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  5940. }
  5941. }
  5942. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  5943. if(document.getElementsByName('ai_DeplY')[i].checked) {
  5944. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  5945. }
  5946. }
  5947. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  5948. if(document.getElementsByName('ai_DeplN')[i].checked) {
  5949. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  5950. }
  5951. }
  5952. if(isTrou(x,y,n)) {
  5953. return window.confirm(
  5954. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5955. +'Vous allez tomber dans un trou de météorite.\n'
  5956. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  5957. );
  5958. }
  5959. }
  5960. return true;
  5961. }
  5962.  
  5963. function newsubmitDE(event) {
  5964. event.stopPropagation();
  5965. event.preventDefault();
  5966. if(validateDestination()) {
  5967. this.submit();
  5968. }
  5969. }
  5970.  
  5971. function changeValidation() {
  5972. var form = document.getElementsByName('ActionForm')[0];
  5973. if(form) {
  5974. form.addEventListener('submit', newsubmitDE, true);
  5975. }
  5976. }
  5977.  
  5978.  
  5979. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  5980.  
  5981. function validateTPDestination() {
  5982. try {
  5983. var text = document.getElementsByTagName('B')[0];
  5984. var a = text.firstChild.nodeValue.split('|');
  5985. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  5986. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  5987. var pos_n = a[2].substring(5, a[2].length) * 1;
  5988.  
  5989. var nbtrous = 0;
  5990. for(var signX=-1 ; signX<=1 ; signX+=2) {
  5991. for(var x=0 ; x<=2 ; x++) {
  5992. for(var signY=-1 ; signY<=1 ; signY+=2) {
  5993. for(var y=0 ; y<=2 ; y++) {
  5994. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  5995. for(var n = 0 ; n <= 1 ; n++) {
  5996. if(isTrou(
  5997. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  5998. )) {
  5999. nbtrous++;
  6000. }
  6001. }
  6002. }
  6003. }
  6004. }
  6005. }
  6006. }
  6007. if(nbtrous>0 && nbtrous<72) {
  6008. return window.confirm(
  6009. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  6010. +'Vous avez '+Math.floor((100*nbtrous)/144)
  6011. +'% de risque de tomber dans un trou de météorite.\n'
  6012. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  6013. );
  6014. }
  6015. else if(nbtrous>=72) {
  6016. return window.confirm(
  6017. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  6018. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  6019. +'% de risque de tomber dans un trou de météorite !\n'
  6020. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  6021. );
  6022. }
  6023. return true;
  6024. }
  6025. catch(e) {
  6026. window.alert(e)
  6027. }
  6028. }
  6029.  
  6030. function newsubmitTP(event) {
  6031. event.stopPropagation();
  6032. event.preventDefault();
  6033. if(validateTPDestination()) {
  6034. this.submit();
  6035. }
  6036. }
  6037.  
  6038. function changeButtonValidate() {
  6039. var form = document.getElementsByName('Formulaire')[0];
  6040. if(form) {
  6041. if(!form.getAttribute('onsubmit')) {
  6042. form.setAttribute('onsubmit','return true;');
  6043. }
  6044. form.addEventListener('submit', newsubmitTP, true);
  6045. }
  6046. }
  6047.  
  6048.  
  6049. /*-[functions]---------------- Partie Principale -----------------------------*/
  6050.  
  6051. function do_move() {
  6052. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  6053. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  6054. changeValidation();
  6055. //}
  6056. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  6057. // changeButtonValidate();
  6058. //}
  6059. }
  6060.  
  6061. /*******************************************************************************
  6062. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  6063. * Mountyzilla is free software; provided under the GNU General Public License *
  6064. *******************************************************************************/
  6065.  
  6066. // x~x news
  6067.  
  6068. // Nombre de news à afficher & nb max de caractères par news:
  6069. const nbItems = 5;
  6070. const maxCarDescription = 300;
  6071.  
  6072. /*-[functions]------------------- Utilitaires --------------------------------*/
  6073.  
  6074. // Ne semble avoir strictement aucun effet:
  6075. String.prototype.epureDescription = function() {
  6076. return this.replace(/\\(.)/g,"$1");
  6077. }
  6078.  
  6079. function appendTitledTable(node,titre,description) {
  6080. // Crée les tables contenant les infos (avec titre)
  6081. var table = document.createElement('table');
  6082. table.border = 0;
  6083. table.className = 'mh_tdborder';
  6084. table.cellSpacing = 1;
  6085. table.cellPadding = 1;
  6086. table.style.maxWidth = '98%';
  6087. table.style.marginLeft = 'auto';
  6088. table.style.marginRight = 'auto';
  6089. var tbody = document.createElement('tbody');
  6090. table.appendChild(tbody);
  6091. var tr = appendTr(tbody,'mh_tdtitre');
  6092. var td = appendTdCenter(tr,2);
  6093. var span = document.createElement('span');
  6094. appendText(span,titre,true);
  6095. if(description) {
  6096. span.title = description;
  6097. }
  6098. td.appendChild(span);
  6099. node.appendChild(table);
  6100. return tbody;
  6101. }
  6102.  
  6103. function testCertif(paramURL, callbackOnError) {
  6104. try {
  6105. FF_XMLHttpRequest({
  6106. method: 'GET',
  6107. url: paramURL,
  6108. onload: function(responseDetails) {
  6109. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  6110. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  6111. }
  6112. });
  6113. } catch(e) {
  6114. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  6115. callbackOnError();
  6116. }
  6117. }
  6118.  
  6119. function createOrGetGrandCadre() {
  6120. var grandCadre = document.getElementById('grandCadre');
  6121. if (grandCadre) return grandCadre;
  6122. try {
  6123. var rappels = document.evaluate(
  6124. "//p[contains(a/text(),'messagerie')]",
  6125. document, null, 9, null).singleNodeValue;
  6126. }
  6127. catch(e) {
  6128. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  6129. grandCadre = document.createElement('div');
  6130. return grandCadre;
  6131. }
  6132. grandCadre = document.createElement('div');
  6133. grandCadre.id = 'grandCadre';
  6134. var sousCadre = document.createElement('div');
  6135. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  6136. sousCadre.style.textAlign = 'center';
  6137. sousCadre.style.fontSize = 'xx-large';
  6138. grandCadre.appendChild(sousCadre);
  6139.  
  6140. grandCadre.style.border = 'solid 5px red';
  6141. grandCadre.style.width = 'auto';
  6142. insertBefore(rappels,grandCadre);
  6143. return grandCadre;
  6144. }
  6145.  
  6146. function showHttpsErrorCadre1() {
  6147. window.console.log('[MZ] showHttpsErrorCadre1');
  6148. var grandCadre = createOrGetGrandCadre();
  6149. var sousCadre = document.createElement('div');
  6150. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  6151. + '<br />Cela empêchera Moutyzilla de fonctionner'
  6152. + '<br /><a style="color:blue;font-size: inherits;" href="'
  6153. + URL_CertifRaistlin1
  6154. + '" target="raistlin">clique ici</a>'
  6155. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6156. + ' « Confirmer l\'exception de sécurité »'
  6157. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6158. sousCadre.style.width = 'auto';
  6159. sousCadre.style.fontSize = 'large';
  6160. sousCadre.style.border = 'solid 1px black';
  6161. sousCadre.style.backgroundColor = 'red';
  6162. grandCadre.appendChild(sousCadre);
  6163. }
  6164.  
  6165. function showHttpsErrorCadre2() {
  6166. window.console.log('[MZ] showHttpsErrorCadre2');
  6167. var grandCadre = createOrGetGrandCadre();
  6168. var sousCadre = document.createElement('div');
  6169. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  6170. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  6171. + '<a style="color:blue;font-size: inherits;" href="'
  6172. + URL_CertifRaistlin2
  6173. + '" target="raistlin">clique ici</a>'
  6174. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6175. + ' « Confirmer l\'exception de sécurité »'
  6176. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  6177. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6178. sousCadre.style.width = 'auto';
  6179. sousCadre.style.fontSize = 'large';
  6180. sousCadre.style.border = 'solid 1px black';
  6181. sousCadre.style.backgroundColor = 'red';
  6182. grandCadre.appendChild(sousCadre);
  6183. }
  6184.  
  6185. function showHttpsErrorContenuMixte() {
  6186. window.console.log('[MZ] showHttpsErrorContenuMixte');
  6187. var grandCadre = createOrGetGrandCadre();
  6188. var sousCadre = document.createElement('div');
  6189. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  6190. + '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)'
  6191. + '<ul>'
  6192. + '<li>Interface Bricol\'Troll</li>'
  6193. + '<li>Nouveautés de Mountyzilla</li>'
  6194. + '</ul>'
  6195. + '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 />'
  6196. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  6197. sousCadre.style.width = 'auto';
  6198. sousCadre.style.fontSize = 'large';
  6199. sousCadre.style.border = 'solid 1px black';
  6200. grandCadre.appendChild(sousCadre);
  6201. }
  6202.  
  6203. /*-[functions]------------------- Jubilaires ---------------------------------*/
  6204.  
  6205. function traiterJubilaires() {
  6206. // à faire
  6207. }
  6208.  
  6209. function traiterJubilaires_a_supprimer() { // ancienne méthode
  6210. try {
  6211. FF_XMLHttpRequest({
  6212. method: 'GET',
  6213. url: URL_anniv,
  6214. headers: {
  6215. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  6216. 'Accept': 'application/xml,text/xml',
  6217. },
  6218. onload: function(responseDetails) {
  6219. if ((responseDetails.status == 0) && isHTTPS) {
  6220. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  6221. //showHttpsErrorContenuMixte();
  6222. return;
  6223. }
  6224. var listeTrolls = responseDetails.responseText.split('\n');
  6225. if(!listeTrolls || listeTrolls.length==0) {
  6226. return;
  6227. }
  6228. afficherJubilaires(listeTrolls);
  6229. },
  6230. });
  6231. }
  6232. catch(e) {
  6233. if (isHTTPS) {
  6234. window.console.log(traceStack(e, 'appel jubilaires'));
  6235. showHttpsErrorContenuMixte();
  6236. } else {
  6237. window.alert('Erreur Jubilaires:\n'+e);
  6238. }
  6239. }
  6240. }
  6241.  
  6242. function afficherJubilaires(listeTrolls) {
  6243. try {
  6244. var rappels = document.evaluate(
  6245. "//p[contains(a/text(),'messagerie')]",
  6246. document, null, 9, null).singleNodeValue;
  6247. }
  6248. catch(e) {
  6249. return;
  6250. }
  6251. var p = document.createElement('p');
  6252. var tbody = appendTitledTable(p,
  6253. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  6254. 'Envoyez leur un message ou un cadeau !'
  6255. );
  6256. tr = appendTr(tbody,'mh_tdpage');
  6257. td = appendTdCenter(tr);
  6258. var small = document.createElement('small');
  6259. td.appendChild(small);
  6260. var first = true;
  6261. for(var i=0 ; i<listeTrolls.length ; i++) {
  6262. var infos = listeTrolls[i].split(';');
  6263. if(infos.length!=3 || infos[2]==='0') {
  6264. continue;
  6265. }
  6266. if(first) {
  6267. first = false;
  6268. }
  6269. else {
  6270. appendText(small,', ');
  6271. }
  6272. var a = document.createElement('a');
  6273. a.href = 'javascript:EPV('+infos[0]+')';
  6274. appendText(a,infos[1]);
  6275. small.appendChild(a);
  6276. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  6277. }
  6278. insertBefore(rappels,p);
  6279. }
  6280.  
  6281.  
  6282. /*-[functions]--------------------- News MZ ----------------------------------*/
  6283.  
  6284. function traiterNouvelles() {
  6285. var news = new Array;
  6286. news.push(['15/11/2019', '<span style="color:red">Refonte des calculs tactiques dans la vue. Affichage du niveau du monstre à tout coup (ou presque).</span>']);
  6287. 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 ;).']);
  6288. afficherNouvelles(news);
  6289. }
  6290.  
  6291. function afficherNouvelles(items) {
  6292. var footer = document.getElementById('footer1');
  6293. if(!footer) {
  6294. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  6295. return;
  6296. }
  6297. var p = document.createElement('p');
  6298. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  6299. var div = document.createElement('div');
  6300. div.style.position = 'absolute';
  6301. div.style.right = 0;
  6302. div.style.top = 0;
  6303. div.style.paddingRight = '3px';
  6304. div.style.whiteSpace = 'nowrap';
  6305. appendText(div, '(version ' + GM_info.script.version + ')');
  6306. tbody.rows[0].cells[0].style.position = 'relative';
  6307. tbody.rows[0].cells[0].appendChild(div);
  6308. for(var i=0 ; i<items.length ; i++) {
  6309. var tr = appendTr(tbody,'mh_tdpage');
  6310. var td = appendTdCenter(tr);
  6311. td.style.verticalAlign = 'top'; // semble sans effet
  6312. appendText(td,items[i][0],true);
  6313. td = appendTd(tr);
  6314. td.innerHTML = items[i][1];
  6315. }
  6316. insertBefore(footer,p);
  6317.  
  6318. // changelog
  6319. var p = document.createElement('p');
  6320. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  6321. tbody.rows[0].cells[0].style.cursor = 'pointer';
  6322. tbody.rows[0].cells[0].onclick = function() {
  6323. try {
  6324. tbody.rows[0].cells[0].onclick = undefined;
  6325. tbody.rows[0].cells[0].style.cursor = '';
  6326. var tr = appendTr(tbody,'mh_tdpage');
  6327. var td = appendTd(tr);
  6328. td.colSpan = 2;
  6329. var pre = document.createElement('pre');
  6330. appendText(pre,MZ_changeLog.join("\n"));
  6331. td.appendChild(pre);
  6332. } catch (e) {
  6333. window.console.log('[MZ] affichage changeLog', e);
  6334. }
  6335. };
  6336. insertBefore(footer,p);
  6337.  
  6338. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  6339. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  6340. if (isHTTPS) {
  6341. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  6342. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6343. } else {
  6344. window.console.log('[MZ test] début switch to https');
  6345. window.sessionStorage.setItem('xxx', "test session trans https");
  6346. window.parent.xxx = "autre test";
  6347. var url = document.location.href;
  6348. window.console.log('[MZ test] url=' + url);
  6349. url = url.replace(/http:\/\//i, 'https://')
  6350. window.console.log('[MZ test] switched url=' + url);
  6351. document.location.href = url;
  6352. }
  6353. }
  6354. if (false) { // version par utilisation d'un IFrame en https
  6355. if (isHTTPS) {
  6356. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  6357. //window.console.log('[MZ test] window.name=' + window.name);
  6358. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  6359. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6360. var txt = window.name;
  6361. var tabtxt = txt.split(/µ/);
  6362. for (var i = 0; i < tabtxt.length; i++) {
  6363. window.console.log('[MZ test]config https ' + tabtxt[i]);
  6364. }
  6365. } else {
  6366. var txt = '';
  6367. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6368. var k = localStorage.key(i);
  6369. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6370. txt += k + "£" + localStorage.getItem(k) + "µ";
  6371. }
  6372. var iframe = document.createElement('iframe');
  6373. var url = document.location.href;
  6374. //window.console.log('[MZ test] url=' + url);
  6375. url = url.replace(/http:\/\//i, 'https://')
  6376. //window.console.log('[MZ test] switched url=' + url);
  6377. //iframe.xxx = "truc en plume";
  6378. iframe.name = txt;
  6379. //window.xxx = "machin";
  6380. iframe.src = url;
  6381. //iframe.document.xxx = "truc en plume";
  6382. document.body.appendChild(iframe);
  6383. iframe.style.display = 'none';
  6384. }
  6385. }
  6386. }
  6387. }
  6388.  
  6389.  
  6390. /*---------------------------------- Main ------------------------------------*/
  6391.  
  6392. function do_news() {
  6393. start_script();
  6394.  
  6395. traiterJubilaires();
  6396. traiterNouvelles();
  6397.  
  6398. /* plus besoin, le certificat est "officiel"
  6399. if (isHTTPS) {
  6400. // test si les certificats raistlin ont été acceptés
  6401. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  6402. var infoit = MY_getValue(numTroll+'.INFOSIT');
  6403. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  6404. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  6405. }
  6406. }
  6407. */
  6408.  
  6409. displayScriptTime();
  6410. }
  6411.  
  6412. /*********************************************************************************
  6413. * This file is part of Mountyzilla. *
  6414. * *
  6415. * Mountyzilla is free software; you can redistribute it and/or modify *
  6416. * it under the terms of the GNU General Public License as published by *
  6417. * the Free Software Foundation; either version 2 of the License, or *
  6418. * (at your option) any later version. *
  6419. * *
  6420. * Mountyzilla is distributed in the hope that it will be useful, *
  6421. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6422. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6423. * GNU General Public License for more details. *
  6424. * *
  6425. * You should have received a copy of the GNU General Public License *
  6426. * along with Mountyzilla; if not, write to the Free Software *
  6427. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6428. *********************************************************************************/
  6429.  
  6430. // x~x tabcompo
  6431.  
  6432. var popup;
  6433.  
  6434. function initPopupTabcompo() {
  6435. popup = document.createElement('div');
  6436. popup.setAttribute('id', 'popup');
  6437. popup.setAttribute('class', 'mh_textbox');
  6438. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  6439. + 'display: inline; z-index: 3; max-width: 400px;');
  6440. document.body.appendChild(popup);
  6441. }
  6442.  
  6443. function showPopup(evt) {
  6444. var texte = this.getAttribute("texteinfo");
  6445. popup.innerHTML = texte;
  6446. popup.style.left = evt.pageX + 15 + 'px';
  6447. popup.style.top = evt.pageY + 'px';
  6448. popup.style.visibility = "visible";
  6449. }
  6450.  
  6451. // roule 16/03/2016, existe déjà ailleurs
  6452. // function hidePopup() {
  6453. // popup.style.visibility = 'hidden';
  6454. // }
  6455.  
  6456. function createPopupImage(url, text)
  6457. {
  6458. var img = document.createElement('img');
  6459. img.setAttribute('src',url);
  6460. img.setAttribute('align','ABSMIDDLE');
  6461. img.setAttribute("texteinfo",text);
  6462. img.addEventListener("mouseover", showPopup,true);
  6463. img.addEventListener("mouseout", hidePopup,true);
  6464. return img;
  6465. }
  6466.  
  6467. function formateTexte(texte)
  6468. {
  6469. texte = texte.replace(/\n/g,"<br/>");
  6470. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  6471. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  6472. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  6473. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  6474. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  6475. return texte;
  6476. }
  6477.  
  6478. function arrondi(x) {
  6479. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  6480. }
  6481.  
  6482. function traiteMinerai() {
  6483. if (currentURL.indexOf("as_type=Divers")==-1) return;
  6484. try {
  6485. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  6486. +" and contains(./tr/th/text(),'Minerai')]",
  6487. document, null, 9, null).singleNodeValue;
  6488. node = node.nextSibling.nextSibling;
  6489. }
  6490. catch(e) {return;}
  6491.  
  6492. var trlist = document.evaluate('./tr', node, null, 7, null);
  6493. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  6494. var node = trlist.snapshotItem(i);
  6495. var nature = node.childNodes[5].textContent;
  6496. var caracs = node.childNodes[7].textContent;
  6497. var taille = caracs.match(/\d+/)[0];
  6498. var coef = 1;
  6499. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  6500. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  6501. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  6502. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6503. if (nature.indexOf('Mithril')!=-1) {
  6504. coef = 0.2*coef;
  6505. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  6506. }
  6507. else {
  6508. coef = 0.75*coef+1.25;
  6509. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6510. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  6511. }
  6512. }
  6513. }
  6514.  
  6515. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  6516. function treateComposants() {
  6517. if (currentURL.indexOf("as_type=Compo")==-1) return;
  6518. //On récupère les composants
  6519. var nodes = document.evaluate(
  6520. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6521. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6522. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  6523. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6524. if (nodes.snapshotLength == 0) {
  6525. //window.console.log('[MZ] treateComposants DOWN');
  6526. return;
  6527. }
  6528. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  6529.  
  6530. var texte = "";
  6531. for (var i = 0; i < nodes.snapshotLength; i++) {
  6532. var n1 = nodes.snapshotItem(i).childNodes[1];
  6533. var n3 = nodes.snapshotItem(i).childNodes[3];
  6534. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6535. var prix = n3.childNodes[0].nodeValue;
  6536. if (!prix)
  6537. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6538. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6539. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6540. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6541. + prix.replace(/\n/g, '') + "\n";
  6542. }
  6543.  
  6544. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6545. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6546. var id_taniere = c.snapshotItem(0).nodeValue;
  6547. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  6548.  
  6549. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6550. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  6551. if (form)
  6552. {
  6553. if(document.getElementsByTagName('form').length>0)
  6554. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6555. else
  6556. {
  6557. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6558. insertBefore(thisP, form);
  6559. }
  6560. }
  6561. }
  6562.  
  6563. function treateAllComposants() {
  6564. if(currentURL.indexOf("as_type=Compo")==-1) return;
  6565.  
  6566. //On récupère les composants
  6567. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  6568. document, null, 0, null ).numberValue;
  6569. var c = (categ == 0 ? 3 : 4);
  6570. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  6571. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  6572. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  6573. + "td["+c+"]/text()[1] = '\240-\240' "
  6574. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  6575. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  6576. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  6577. + "and td[1]/img/@alt = 'Identifié']",
  6578. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6579. if (nodes.snapshotLength == 0) {
  6580. // window.alert('treateAllComposants DOWN');
  6581. return;
  6582. }
  6583.  
  6584. var texte = "";
  6585. for (var i = 0; i < nodes.snapshotLength; i++) {
  6586. var n1 = nodes.snapshotItem(i).childNodes[1];
  6587. var n3 = nodes.snapshotItem(i).childNodes[3];
  6588. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6589. var prix = n3.childNodes[0].nodeValue;
  6590. if (!prix)
  6591. {
  6592. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  6593. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6594. }
  6595. else
  6596. {
  6597. prix= prix.replace(/[\240 ]/g, "");
  6598. if(prix=="-")
  6599. prix=null;
  6600. }
  6601. if(prix)
  6602. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6603. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6604. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6605. + prix.replace(/\n/g, '') + "\n";
  6606. else
  6607. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6608. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6609. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  6610. }
  6611.  
  6612. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6613. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6614. var id_taniere = c.snapshotItem(0).nodeValue;
  6615. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  6616.  
  6617. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6618. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  6619. if (form)
  6620. {
  6621. if(document.getElementsByTagName('form').length>0)
  6622. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6623. else
  6624. {
  6625. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6626. insertBefore(thisP, form);
  6627. }
  6628. }
  6629. }
  6630.  
  6631. function treateEM()
  6632. {
  6633. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  6634. if(currentURL.indexOf("as_type=Compo")==-1)
  6635. return false;
  6636. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  6637. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  6638. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6639. if (nodes.snapshotLength == 0)
  6640. return false;
  6641. for (var i = 0; i < nodes.snapshotLength; i++) {
  6642. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  6643. var link = desc[2].firstChild ;
  6644. var nomCompoTotal = desc[2].textContent ;
  6645. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6646. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6647. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  6648. var locqual = desc[3].textContent ;
  6649. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  6650. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  6651. if(isEM(nomMonstre).length>0)
  6652. {
  6653. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  6654. if(infos.length>0)
  6655. {
  6656. var shortDescr = "Variable";
  6657. var bold = 0;
  6658. if(infos != "Composant variable")
  6659. {
  6660. shortDescr = infos.substring(0,infos.indexOf(" "));
  6661. if(parseInt(shortDescr)>=0)
  6662. bold=1;
  6663. }
  6664. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  6665. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  6666. }
  6667. }
  6668.  
  6669. }
  6670. }
  6671.  
  6672. function treateChampi() {
  6673. if (currentURL.indexOf('as_type=Champi')==-1)
  6674. return false;
  6675. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  6676. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6677. if (nodes.snapshotLength == 0)
  6678. return false;
  6679.  
  6680. for (var i = 0; i < nodes.snapshotLength; i++) {
  6681. var node = nodes.snapshotItem(i);
  6682. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  6683. if (moisChampi[nomChampi])
  6684. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  6685. }
  6686. }
  6687.  
  6688. function treateEnchant()
  6689. {
  6690. if(currentURL.indexOf("as_type=Compo")==-1)
  6691. return false;
  6692. try
  6693. {
  6694. if(!listeMonstreEnchantement)
  6695. computeCompoEnchantement();
  6696. var nodes = document.evaluate(
  6697. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6698. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6699. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6700. if (nodes.snapshotLength == 0)
  6701. return false;
  6702. var urlImg = URL_MZimg + "enchant.png";
  6703. for (var i = 0; i < nodes.snapshotLength; i++) {
  6704. var link = nodes.snapshotItem(i);
  6705. var nomCompoTotal = link.firstChild.nodeValue;
  6706. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6707. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6708. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  6709. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  6710. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  6711. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  6712. if(isEnchant(nomMonstre).length>0)
  6713. {
  6714. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  6715. if(infos.length>0)
  6716. {
  6717. link.parentNode.appendChild(createImage(urlImg,infos));
  6718. }
  6719. }
  6720. }
  6721. }
  6722. catch(e)
  6723. {
  6724. window.alert(e);
  6725. }
  6726. }
  6727.  
  6728. function treateEquipEnchant()
  6729. {
  6730. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  6731. return false;
  6732. initPopupTabcompo();
  6733. computeEnchantementEquipement(createPopupImage,formateTexte);
  6734. }
  6735.  
  6736. function do_tancompo() {
  6737. start_script();
  6738.  
  6739. treateAllComposants();
  6740. treateComposants();
  6741. traiteMinerai();
  6742. if (MY_getValue('NOINFOEM')!='true') {
  6743. treateChampi();
  6744. treateEM();
  6745. }
  6746. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  6747. treateEnchant();
  6748. treateEquipEnchant();
  6749. }
  6750.  
  6751. displayScriptTime();
  6752. }
  6753.  
  6754. /*******************************************************************************
  6755. * This file is part of Mountyzilla. *
  6756. * *
  6757. * Mountyzilla is free software; you can redistribute it and/or modify *
  6758. * it under the terms of the GNU General Public License as published by *
  6759. * the Free Software Foundation; either version 2 of the License, or *
  6760. * (at your option) any later version. *
  6761. * *
  6762. * Mountyzilla is distributed in the hope that it will be useful, *
  6763. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6764. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6765. * GNU General Public License for more details. *
  6766. * *
  6767. * You should have received a copy of the GNU General Public License *
  6768. * along with Mountyzilla; if not, write to the Free Software *
  6769. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6770. *******************************************************************************/
  6771.  
  6772. // x~x pjview
  6773.  
  6774. /* TODO
  6775. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  6776. */
  6777.  
  6778. // Bulle d'infos
  6779. var DivInfo;
  6780. // Booléen stockant l'état de freezing de la bulle
  6781. var freezed = false;
  6782.  
  6783. // liste du matos
  6784. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  6785. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6786. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  6787. var mh_caracs = {
  6788. 'anneau de protection':
  6789. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  6790. "armure d'anneaux":
  6791. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  6792. 'armure de bois':
  6793. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  6794. 'armure de cuir':
  6795. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  6796. 'armure de peaux':
  6797. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  6798. 'armure de pierre':
  6799. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  6800. 'armure de plates':
  6801. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  6802. 'baton lesté':
  6803. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6804. 'bâtons de parade':
  6805. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6806. 'bottes':
  6807. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6808. 'bouclier à pointes':
  6809. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6810. 'boulet et chaîne':
  6811. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6812. 'cagoule':
  6813. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  6814. 'casque à cornes':
  6815. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6816. 'casque à pointes':
  6817. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  6818. 'casque en cuir':
  6819. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  6820. 'casque en métal':
  6821. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6822. 'chaîne cloutée':
  6823. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6824. 'chapeau pointu':
  6825. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  6826. 'collier de dents':
  6827. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  6828. 'collier de pierre':
  6829. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6830. 'collier à pointes':
  6831. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6832. 'cotte de mailles':
  6833. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  6834. 'couronne de cristal':
  6835. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  6836. "couronne d'obsidienne":
  6837. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  6838. "coutelas d'obsidienne":
  6839. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  6840. 'coutelas en os':
  6841. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  6842. 'crochet':
  6843. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6844. 'cuir bouilli':
  6845. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  6846. "cuirasse d'ossements":
  6847. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  6848. "cuirasse d'écailles":
  6849. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  6850. 'culotte en cuir':
  6851. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6852. 'dague':
  6853. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6854. 'epée courte':
  6855. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6856. 'epée longue':
  6857. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6858. 'espadon':
  6859. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6860. 'fouet':
  6861. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6862. 'fourrures':
  6863. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  6864. 'gantelet':
  6865. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6866. 'gorgeron en cuir':
  6867. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6868. 'gorgeron en métal':
  6869. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  6870. 'gourdin':
  6871. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6872. 'gourdin clouté':
  6873. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6874. 'grimoire':
  6875. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  6876. "gros'porte":
  6877. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  6878. 'grosse racine':
  6879. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6880. 'grosse stalagmite':
  6881. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  6882. 'hache de bataille':
  6883. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6884. 'hache de guerre en os':
  6885. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  6886. 'hache de guerre en pierre':
  6887. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  6888. "hache à deux mains d'obsidienne":
  6889. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  6890. 'hallebarde':
  6891. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  6892. "haubert d'écailles":
  6893. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  6894. 'haubert de mailles':
  6895. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  6896. 'heaume':
  6897. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  6898. 'jambières en cuir':
  6899. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6900. 'jambières en fourrure':
  6901. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  6902. 'jambières en maille':
  6903. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6904. 'jambières en métal':
  6905. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  6906. 'jambières en os':
  6907. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6908. "lame d'obsidienne":
  6909. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  6910. 'lame en os':
  6911. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6912. 'lame en pierre':
  6913. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6914. 'lorgnons':
  6915. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  6916. 'machette':
  6917. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6918. "masse d'arme":
  6919. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6920. 'pagne de mailles':
  6921. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6922. 'pagne en cuir':
  6923. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6924. 'robe de mage':
  6925. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  6926. 'rondache en bois':
  6927. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6928. 'rondache en métal':
  6929. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  6930. 'sandales':
  6931. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6932. 'souliers dorés':
  6933. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6934. "talisman d'obsidienne":
  6935. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  6936. 'talisman de pierre':
  6937. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  6938. 'targe':
  6939. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6940. 'torche':
  6941. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  6942. 'torque de pierre':
  6943. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  6944. 'tunique':
  6945. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6946. "tunique d'écailles":
  6947. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  6948. 'turban':
  6949. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  6950. }
  6951.  
  6952. // liste des templates
  6953. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  6954. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6955. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  6956. var mh_templates = {
  6957. 'de Feu':
  6958. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6959. 'de Résistance':
  6960. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  6961. "de l'Aigle":
  6962. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  6963. 'de la Salamandre':
  6964. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6965. 'des Cyclopes':
  6966. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  6967. 'des Enragés':
  6968. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  6969. 'des Tortues':
  6970. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  6971. 'des Vampires':
  6972. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6973. 'du Glacier':
  6974. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  6975. 'du Rat':
  6976. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6977. 'du Roc':
  6978. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  6979. 'du Temps':
  6980. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  6981. 'du Vent':
  6982. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6983. 'en Mithril':
  6984. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6985. 'des Anciens':
  6986. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6987. 'des Champions':
  6988. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6989. 'des Duellistes':
  6990. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6991. 'de la Terre':
  6992. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  6993. "de l'Orage":
  6994. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  6995. "de l'Ours":
  6996. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  6997. 'des Béhémoths':
  6998. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  6999. 'des Mages':
  7000. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  7001. 'du Pic':
  7002. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  7003. 'du Sable':
  7004. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  7005. 'acéré':
  7006. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7007. 'acérée':
  7008. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7009. 'équilibré':
  7010. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7011. 'équilibrée':
  7012. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7013. 'léger':
  7014. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7015. 'légère':
  7016. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7017. 'renforcé':
  7018. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7019. 'renforcée':
  7020. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7021. 'robuste':
  7022. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  7023. }
  7024.  
  7025. function clone(arr) {
  7026. // Clonage rapide
  7027. return arr.slice(0);
  7028. }
  7029.  
  7030. function addArray(arr1,arr2) {
  7031. // Somme matricielle
  7032. var res = clone(arr1);
  7033. for(i=res.length-1 ; i>=0 ; i--) {
  7034. res[i] += arr2[i];
  7035. }
  7036. return res;
  7037. }
  7038.  
  7039. function getTemplates(nomItem) {
  7040. // Déstructure le nom de l'item en array [nom, template1, ...]
  7041. var tempFound = true;
  7042. var str = nomItem.trim();
  7043. var arr = [];
  7044. while(tempFound) {
  7045. tempFound = false;
  7046. for(var temp in mh_templates) {
  7047. // on teste la fin du nom contre chaque template
  7048. if(str.slice(-temp.length)!=temp) { continue; }
  7049. tempFound = true;
  7050. str = str.slice(0,-temp.length-1);
  7051. arr.unshift(temp);
  7052. if(str.slice(-3)==' et') {
  7053. str = str.slice(0,-3);
  7054. }
  7055. }
  7056. }
  7057. arr.unshift(str);
  7058. return arr;
  7059. }
  7060.  
  7061. function addMithril(arrayCaracs,typeItem) {
  7062. // Ajoute l'effet du Mithril sur les caracs
  7063. if(typeItem=='arme') {
  7064. if(arrayCaracs[0]<0) {
  7065. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  7066. }
  7067. }
  7068. else {
  7069. if(arrayCaracs[4]<0) {
  7070. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  7071. }
  7072. }
  7073. arrayCaracs[15] /= 2;
  7074. arrayCaracs[16] /= 2;
  7075. return arrayCaracs;
  7076. }
  7077.  
  7078. function addRenfort(arrayCaracs,template) {
  7079. // Ajoute l'effet des pseudo-templates sur les caracs
  7080. // S'applique APRÈS le mithril
  7081. // WARNING - Cette formule n'a rien d'officiel, gare !
  7082. var coef = 0;
  7083. if(/^lég[e,è]re?$/.test(template)) {
  7084. coef = -1;
  7085. }
  7086. else if(/^renforcée?$/.test(template)
  7087. || template==='robuste') {
  7088. coef = 1;
  7089. }
  7090. if(coef) {
  7091. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  7092. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  7093. }
  7094. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  7095. return arrayCaracs;
  7096. }
  7097.  
  7098. function getCaracs(item) {
  7099. // Calcule les caractéristiques de l'item
  7100. var templates = getTemplates(item);
  7101. if(!mh_caracs[templates[0]]) {
  7102. // Si l'item est inconnu
  7103. return [];
  7104. }
  7105. var caracs = clone(mh_caracs[templates[0]]);
  7106. var typeItem = caracs[0];
  7107. caracs.shift();
  7108. templates.shift();
  7109. if(templates[templates.length-1]=='en Mithril') {
  7110. caracs = addMithril(caracs,typeItem);
  7111. templates.pop();
  7112. }
  7113. if(/^acérée?$/.test(templates[0])
  7114. || /^équilibrée?$/.test(templates[0])
  7115. || /^lég[e,è]re?$/.test(templates[0])
  7116. || /^renforcée?$/.test(templates[0])
  7117. || templates[0]=='robuste') {
  7118. caracs = addRenfort(caracs,templates[0]);
  7119. templates.shift();
  7120. }
  7121. for(var i=templates.length-1 ; i>=0 ; i--) {
  7122. caracs = addArray(caracs,mh_templates[templates[i]]);
  7123. }
  7124. return caracs;
  7125. }
  7126.  
  7127. function getLine(tab) {
  7128. // Préparation de la ligne à afficher lors d'un mouseover
  7129. var str = '';
  7130. if(tab[0]!=0 || tab[1]!=0) {
  7131. str += '<b>Att : </b>'+aff(tab[0]);
  7132. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  7133. str += ' | ';
  7134. }
  7135. if(tab[4]!=0) {
  7136. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  7137. }
  7138. if(tab[2]!=0 || tab[3]!=0) {
  7139. str += '<b>Deg : </b>'+aff(tab[2]);
  7140. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  7141. str += ' | ';
  7142. }
  7143. if(tab[8]!=0) {
  7144. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  7145. }
  7146. if(tab[7]!=0) {
  7147. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  7148. }
  7149. if(tab[5]!=0 || tab[6]!=0) {
  7150. str += '<b>Arm : </b>'+aff(tab[5]);
  7151. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  7152. str += ' | ';
  7153. }
  7154. if(tab[9]!=0 || tab[10]!=0) {
  7155. str += '<b>RM : </b>'+aff(tab[9])+'%';
  7156. if(tab[9]!=tab[10]) {
  7157. str += '/'+aff(tab[10])+'%';
  7158. }
  7159. str += ' | ';
  7160. }
  7161. if(tab[11]!=0 || tab[12]!=0) {
  7162. str += '<b>MM : </b>'+aff(tab[11])+'%';
  7163. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  7164. str += ' | ';
  7165. }
  7166. if(tab[13]!=0) {
  7167. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  7168. }
  7169. if(tab[14]!=0) {
  7170. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  7171. }
  7172. str += '<b>Poids : </b>'+tab[15]+' min';
  7173. if(tab[15]!=tab[16]) {
  7174. str += ' / '+tab[16]+' min';
  7175. }
  7176. return str;
  7177. }
  7178.  
  7179. function toolTipInit() {
  7180. DivInfo = document.createElement('div');
  7181. DivInfo.id = 'infosVue';
  7182. DivInfo.className = 'mh_textbox';
  7183. DivInfo.style =
  7184. 'position: absolute;'
  7185. +'border: 1px solid #000000;'
  7186. +'visibility:hidden;'
  7187. +'display:inline;'
  7188. +'z-index:99;';
  7189. document.body.appendChild(DivInfo);
  7190. document.onmousemove = getXY;
  7191. document.onclick = changeFreezeStatus;
  7192. }
  7193.  
  7194. function getXY(evt) {
  7195. if(!freezed && DivInfo.style.visibility=='visible') {
  7196. DivInfo.style.left = evt.pageX+'px';
  7197. DivInfo.style.top = evt.pageY+10+'px';
  7198. }
  7199. }
  7200.  
  7201. function changeFreezeStatus() {
  7202. if(DivInfo.style.visibility=='visible') {
  7203. freezed = !freezed;
  7204. if(!freezed) { hideInfos(); }
  7205. }
  7206. }
  7207.  
  7208. function showInfos() {
  7209. if(freezed) { return; }
  7210. var currentInfos = this.infos;
  7211. DivInfo.innerHTML = currentInfos;
  7212. DivInfo.style.visibility = 'visible';
  7213. }
  7214.  
  7215. function hideInfos() {
  7216. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  7217. }
  7218.  
  7219. function treateEquipement() {
  7220. // Extrait les données du matos et réinjecte les infos déduites
  7221. if(MY_getValue('INFOCARAC')=='false') { return; }
  7222.  
  7223. var faireLigne = false;
  7224. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  7225. var nodes = document.evaluate(
  7226. "//td/b[text()='Equipement Utilisé']/../../"
  7227. +"td[2]/img[contains(@src,bullet)]",
  7228. document, null, 7, null);
  7229. if(nodes.snapshotLength>0) {
  7230. // Si CSS de base
  7231. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7232. var node = nodes.snapshotItem(i);
  7233. var next = node.nextSibling;
  7234. var nnext = next.nextSibling;
  7235. var nom = next.nodeValue.toLowerCase();
  7236. if(nnext.childNodes.length==1) {
  7237. nom += nnext.firstChild.nodeValue;
  7238. }
  7239. nom = nom.trim();
  7240. // gestion winpostrophe
  7241. var c = String.fromCharCode(180);
  7242. while(nom.indexOf(c)!=-1) {
  7243. nom = nom.replace(c,"'");
  7244. }
  7245. var arr = getCaracs(nom);
  7246. if(arr.length>0) {
  7247. faireLigne = true;
  7248. caracs = addArray(caracs,arr);
  7249. var span = document.createElement('span');
  7250. span.appendChild(next);
  7251. span.appendChild(nnext);
  7252. span.infos = getLine(arr);
  7253. span.onmouseover = showInfos;
  7254. span.onmouseout = hideInfos;
  7255. insertBefore(node.nextSibling,span);
  7256. }
  7257. }
  7258.  
  7259. if(faireLigne) {
  7260. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  7261. document, null, 9, null).singleNodeValue;
  7262. node.infos = getLine(caracs);
  7263. node.onmouseover = showInfos;
  7264. node.onmouseout = hideInfos;
  7265. }
  7266. }
  7267. else {
  7268. // Si CSS avancée
  7269. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  7270. document, null, 7, null);
  7271. if(nodes.snapshotLength>0) {
  7272. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7273. var node = nodes.snapshotItem(i);
  7274. var nom = node.firstChild.nodeValue.toLowerCase();
  7275. if(node.childNodes.length>1) {
  7276. nom += node.childNodes[1].firstChild.nodeValue;
  7277. }
  7278. nom = nom.trim();
  7279. // gestion winpostrophe
  7280. var c = String.fromCharCode(180);
  7281. while(nom.indexOf(c)!=-1) {
  7282. nom = nom.replace(c,"'");
  7283. }
  7284. var arr = getCaracs(nom);
  7285. if(arr.length!=0) {
  7286. caracs = addArray(caracs,arr);
  7287. node.infos = getLine(arr);
  7288. node.onmouseover = showInfos;
  7289. node.onmouseout = hideInfos;
  7290. }
  7291. }
  7292. var nodes = document.evaluate("//dt[@class='equipement']",
  7293. document, null, 7, null);
  7294. var node = nodes.snapshotItem(0);
  7295. node.infos = getLine(caracs);
  7296. node.onmouseover = showInfos;
  7297. node.onmouseout = hideInfos;
  7298. }
  7299. }
  7300. }
  7301.  
  7302. function do_pjview() {
  7303. treateEquipement();
  7304. toolTipInit();
  7305. }
  7306.  
  7307. /*******************************************************************************
  7308. * This file is part of Mountyzilla. *
  7309. * *
  7310. * Mountyzilla is free software; you can redistribute it and/or modify *
  7311. * it under the terms of the GNU General Public License as published by *
  7312. * the Free Software Foundation; either version 2 of the License, or *
  7313. * (at your option) any later version. *
  7314. * *
  7315. * Mountyzilla is distributed in the hope that it will be useful, *
  7316. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7317. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7318. * GNU General Public License for more details. *
  7319. * *
  7320. * You should have received a copy of the GNU General Public License *
  7321. * along with Mountyzilla; if not, write to the Free Software *
  7322. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7323. *******************************************************************************/
  7324.  
  7325. // x~x option
  7326.  
  7327. /* TODO
  7328. * Passer le HTML injecté aux conventions HTML5
  7329. */
  7330.  
  7331.  
  7332. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  7333.  
  7334. function saveITData() {
  7335. var IT = document.getElementById('itSelect').value;
  7336. if(IT=='bricol') {
  7337. var nBricol = 1;
  7338. for (var iBricol = 0; ; iBricol++) {
  7339. var extClef = nBricol == 1 ? '' : nBricol;
  7340. var eltSystem = document.getElementById('urlbricol'+iBricol);
  7341. if (eltSystem == undefined) break;
  7342. var system = eltSystem.value;
  7343. window.console.log("[MZ] saveITData system=" + system);
  7344. var login = document.getElementById('loginbricol'+iBricol).value;
  7345. var pass = document.getElementById('passbricol'+iBricol).value;
  7346. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  7347. if(system && login) {
  7348. if (pass) {
  7349. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  7350. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  7351. //window.console.log('v=' + v);
  7352. } else {
  7353. // vérif que rien n'a changé
  7354. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  7355. if(str) {
  7356. var arr = str.split('$');
  7357. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  7358. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  7359. }
  7360. }
  7361. }
  7362. nBricol++;
  7363. }
  7364. }
  7365. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  7366. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  7367. }
  7368. else {
  7369. MY_removeValue(numTroll+'.INFOSIT');
  7370. }
  7371. }
  7372.  
  7373. function saveLinks() {
  7374. var numLinks = document.getElementById('linksBody').childNodes.length;
  7375. var data=[ [] ];
  7376. /* Récupération et tri des liens */
  7377. for(var i=1 ; i<=numLinks ; i++) {
  7378. MY_removeValue('URL'+i);
  7379. MY_removeValue('URL'+i+'.nom');
  7380. MY_removeValue('URL'+i+'.ico');
  7381. var url = document.getElementById('url'+i).value;
  7382. var nom = document.getElementById('nom'+i).value;
  7383. var ico = document.getElementById('ico'+i).value;
  7384. if(url && (nom || ico) ) {
  7385. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  7386. }
  7387. }
  7388. /* Sauvegarde */
  7389. for(var i=1 ; i<data.length ; i++) {
  7390. MY_setValue('URL'+i,data[i][0]);
  7391. MY_setValue('URL'+i+'.nom',data[i][1]);
  7392. MY_setValue('URL'+i+'.ico',data[i][2]);
  7393. }
  7394. }
  7395.  
  7396. function saveAll() {
  7397. try {
  7398. var urlIco = document.getElementById('icoMenuIco').value;
  7399. if(urlIco) {
  7400. MY_setValue(numTroll+'.ICOMENU', urlIco );
  7401. }
  7402. else {
  7403. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  7404. document.getElementById('icoMenuIco').value = '';
  7405. }
  7406. saveLinks();
  7407. refreshLinks();
  7408.  
  7409. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  7410.  
  7411. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  7412. if(maxcdm) {
  7413. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  7414. }
  7415. else {
  7416. MY_removeValue(numTroll+'.MAXCDM');
  7417. document.getElementById('maxcdm').value = '';
  7418. }
  7419.  
  7420. MY_setValue('NOINFOEM',
  7421. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  7422.  
  7423. // Pourquoi Tilk stockait-il tout en str ?
  7424. // -> parce que les booléens c'est foireux (vérifié)
  7425. MY_setValue(numTroll+'.USECSS',
  7426. document.getElementById('usecss').checked ? 'true':'false');
  7427. MY_setValue('INFOCARAC',
  7428. document.getElementById('infocarac').checked ? 'true' : 'false');
  7429. //MY_setValue(numTroll+'.SEND_IDT',
  7430. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  7431. // Fonctionnalité désactivée
  7432.  
  7433. MY_setValue(numTroll+'.AUTOCDM',
  7434. document.getElementById('autoCdM').checked ? 'true' : 'false');
  7435. // MY_setValue('VUECARAC', // Roule 12/12/2019 ça ne fait plus rien
  7436. // document.getElementById('vueCarac').checked ? 'true' : 'false');
  7437. MY_setValue('CONFIRMEDECALAGE',
  7438. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  7439.  
  7440. /* SCIZ */
  7441. var sciz_jwt = document.getElementById('sciz_jwt').value;
  7442. if (sciz_jwt) {
  7443. sciz_jwt = sciz_jwt.replace(new RegExp('[^a-zA-Z0-9\._\-]','g'), '');
  7444. MY_setValue(numTroll + '.SCIZJWT', sciz_jwt);
  7445. }
  7446.  
  7447. saveITData();
  7448. } catch (e) {
  7449. var bouton = document.getElementById('saveAll');
  7450. window.console.log(e);
  7451. bouton.value = "il y a eu une erreur";
  7452. return;
  7453. }
  7454.  
  7455. var bouton = document.getElementById('saveAll');
  7456. bouton.value = (bouton.value=='Sauvegardé !') ?
  7457. 'Re-sauvegardé !' : 'Sauvegardé !';
  7458. }
  7459.  
  7460.  
  7461. /*-[functions]----------------- EventListeners -------------------------------*/
  7462.  
  7463. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  7464. var itBody = document.getElementById('itBody');
  7465. var nTr = itBody.rows.length;
  7466. // enlever tous les "+" des lignes précédentes
  7467. for (var iTr = 0; iTr < nTr; iTr++) {
  7468. var td = itBody.rows[iTr].cells[0];
  7469. td.innerHTML = '';
  7470. td.title = '';
  7471. td.style.cursor = 'default';
  7472. }
  7473. // ajouter une ligne
  7474. var tr = appendTr(itBody,'mh_tdpage')
  7475. var td = appendTd(tr);
  7476. if (bLast) {
  7477. td.style.whiteSpace = 'nowrap';
  7478. appendText(td, '+');
  7479. td.style.cursor = 'pointer';
  7480. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  7481. td.onclick = function (e) {
  7482. addBricolIT(undefined, undefined, undefined, false, true);
  7483. }
  7484. }
  7485. var td = appendTd(tr);
  7486. td.style.whiteSpace = 'nowrap';
  7487. appendText(td,'Nom du système : ');
  7488. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  7489. td = appendTd(tr);
  7490. td.style.whiteSpace = 'nowrap';
  7491. appendText(td,'Login du compte : ');
  7492. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  7493. td = appendTd(tr);
  7494. td.style.whiteSpace = 'nowrap';
  7495. appendText(td,'Mot de passe du compte : ');
  7496. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  7497. td = appendTd(tr);
  7498. if (bFirst) {
  7499. td.style.whiteSpace = 'nowrap';
  7500. appendText(td,'Affichage des Trõlls hors vue : ');
  7501. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  7502. }
  7503. }
  7504.  
  7505. function onChangeIT() {
  7506. var IT = document.getElementById('itSelect').value;
  7507. var itBody = document.getElementById('itBody');
  7508. itBody.innerHTML = '';
  7509. var tabStr = new Array();
  7510. if(IT=='bricol') {
  7511. for (var iBricol = 1; ; iBricol++) {
  7512. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  7513. //window.console.log('onChangeIT str=' + str);
  7514. if(str) {
  7515. tabStr.push(str);
  7516. } else {
  7517. break;
  7518. }
  7519. }
  7520. if (tabStr.length == 0) {
  7521. addBricolIT('', '', 0, true, true)
  7522. } else {
  7523. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  7524. var arr = tabStr[iBricol].split('$');
  7525. var system = arr[1];
  7526. var login = arr[2];
  7527. var affhv = arr[4];
  7528. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  7529. }
  7530. }
  7531. }
  7532. }
  7533.  
  7534. function refreshLinks() {
  7535. document.getElementById('linksBody').innerHTML = '';
  7536. var anotherURL = MY_getValue('URL1');
  7537. if(!anotherURL) { addLinkField(); }
  7538. var i=1;
  7539. while(anotherURL && i<99) {
  7540. addLinkField(i,anotherURL,
  7541. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  7542. i++;
  7543. anotherURL = MY_getValue('URL'+i);
  7544. }
  7545. }
  7546.  
  7547. function addLinkField(i,url,nom,ico) {
  7548. var linksBody = document.getElementById('linksBody');
  7549. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  7550. var tr = appendTr(linksBody);
  7551. var td = appendTdCenter(tr);
  7552. appendText(td,'Lien '+i+' : ');
  7553. appendTextbox(td,'text','url'+i,40,150,url);
  7554. td = appendTdCenter(tr);
  7555. appendText(td,'Nom : ');
  7556. appendTextbox(td,'text','nom'+i,20,150,nom);
  7557. td = appendTdCenter(tr);
  7558. appendText(td,'Icône : ');
  7559. appendTextbox(td,'text','ico'+i,40,150,ico);
  7560. }
  7561.  
  7562. function removeLinkField() {
  7563. var linksBody = document.getElementById('linksBody');
  7564. var i = linksBody.childNodes.length;
  7565. MY_removeValue('URL'+i);
  7566. MY_removeValue('URL'+i+'.nom');
  7567. MY_removeValue('URL'+i+'.ico');
  7568. linksBody.removeChild(linksBody.lastChild);
  7569. if(linksBody.childNodes.length==0) { addLinkField(); }
  7570. }
  7571.  
  7572. function resetMainIco() {
  7573. document.getElementById('icoMenuIco').value=
  7574. URL_MZimg + 'mz_logo_small.png';
  7575. }
  7576.  
  7577.  
  7578. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  7579.  
  7580. function insertTitle(next,txt) {
  7581. var div = document.createElement('div');
  7582. div.className = 'titre2';
  7583. appendText(div,txt);
  7584. insertBefore(next,div);
  7585. return div;
  7586. }
  7587.  
  7588. function insertMainTable(next) {
  7589. var table = document.createElement('table');
  7590. table.width = '98%';
  7591. table.border = 0;
  7592. table.align = 'center';
  7593. table.cellPadding = 2;
  7594. table.cellSpacing = 1;
  7595. table.className = 'mh_tdborder';
  7596. var tbody = document.createElement('tbody');
  7597. table.appendChild(tbody);
  7598. insertBefore(next,table);
  7599. return tbody;
  7600. }
  7601.  
  7602. function appendSubTable(node) {
  7603. var table = document.createElement('table');
  7604. table.width = '100%';
  7605. var tbody = document.createElement('tbody');
  7606. table.appendChild(tbody);
  7607. node.appendChild(table);
  7608. return tbody;
  7609. }
  7610.  
  7611. function insertOptionTable(insertPt) {
  7612. var mainBody = insertMainTable(insertPt);
  7613.  
  7614. /* Liens dans le Menu */
  7615. var tr = appendTr(mainBody,'mh_tdtitre');
  7616. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  7617. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7618. appendText(td,'Icône du Menu: ');
  7619. var url = MY_getValue(numTroll+'.ICOMENU');
  7620. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  7621. url = URL_MZimg + 'mz_logo_small.png';
  7622. }
  7623. appendTextbox(td,'text','icoMenuIco',50,200,url);
  7624. appendButton(td,'Réinitialiser',resetMainIco);
  7625.  
  7626. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7627. var tbody = appendSubTable(td);
  7628. tbody.id = 'linksBody';
  7629. refreshLinks();
  7630.  
  7631. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  7632. appendButton(td,'Ajouter',addLinkField);
  7633. appendButton(td,'Supprimer',removeLinkField);
  7634.  
  7635. /* Options de la Vue : vue externe, nb de CdM, etc */
  7636. tr = appendTr(mainBody,'mh_tdtitre');
  7637. appendTdText(tr,'Options de la Vue :',true);
  7638. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7639. tbody = appendSubTable(td);
  7640.  
  7641. tr = appendTr(tbody);
  7642. td = appendTdText(tr,'Vue externe : ');
  7643. var select = document.createElement('select');
  7644. select.id = 'vueext';
  7645. td.appendChild(select);
  7646. var listeVues2D = [
  7647. 'Bricol\' Vue',
  7648. 'Vue du CCM',
  7649. 'Vue Gloumfs 2D',
  7650. 'Vue Gloumfs 3D',
  7651. 'Grouky Vue!'
  7652. ];
  7653. for(var i=0 ; i<listeVues2D.length ; i++) {
  7654. appendOption(select,listeVues2D[i],listeVues2D[i]);
  7655. }
  7656. if(MY_getValue('VUEEXT')) {
  7657. select.value = MY_getValue('VUEEXT');
  7658. }
  7659.  
  7660. td = appendTd(tr);
  7661. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  7662. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  7663.  
  7664. tr = appendTr(tbody);
  7665. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  7666. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  7667.  
  7668. td = appendTd(tr);
  7669. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  7670. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  7671.  
  7672. /* Interface Tactique */
  7673. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7674. appendText(td,'Interface Tactique : ',true);
  7675. select = document.createElement('select');
  7676. select.id = 'itSelect';
  7677. appendOption(select,'none','Aucune');
  7678. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  7679. // seule interface supportée !
  7680. td.appendChild(select);
  7681.  
  7682. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7683. tbody = appendSubTable(td);
  7684. tbody.id = 'itBody';
  7685. select.onchange = onChangeIT;
  7686. var str = MY_getValue(numTroll+'.INFOSIT');
  7687. if(str) {
  7688. select.value = str.slice(0,str.indexOf('$'));
  7689. onChangeIT();
  7690. }
  7691.  
  7692. /* SCIZ */
  7693. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7694. appendText(td,'SCIZ :',true);
  7695. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7696. td = appendTdText(td,'JWT : ');
  7697. appendTextbox(td,'text','sciz_jwt',150,500, MY_getValue(numTroll+'.SCIZJWT'));
  7698.  
  7699. /* Options diverses */
  7700. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7701. appendText(td,'Options diverses :',true);
  7702. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7703. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  7704. appendText(td,
  7705. ' Afficher les caractéristiques des équipements des autres Trõlls');
  7706.  
  7707. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7708. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  7709. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  7710.  
  7711. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7712. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  7713. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  7714.  
  7715. // td = appendTd(appendTr(mainBody,'mh_tdpage')); // Roule 12/12/2019 ça ne fait plus rien
  7716. // appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  7717. // appendText(td,' Afficher la Vue avec les caractéristiques dans le Profil');
  7718.  
  7719. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7720. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  7721. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  7722.  
  7723. /* Bouton SaveAll */
  7724. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  7725. input = appendButton(td,'Sauvegarder',saveAll);
  7726. input.id = 'saveAll';
  7727. }
  7728.  
  7729. function insertCreditsTable(insertPt) {
  7730. var tbody = insertMainTable(insertPt);
  7731.  
  7732. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  7733. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  7734. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  7735.  
  7736. var ul = document.createElement('ul');
  7737. td.appendChild(ul);
  7738. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  7739. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  7740. appendLI(ul,'Reivax (4234) pour les infos bulles');
  7741. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  7742. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  7743. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  7744. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  7745. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  7746. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  7747. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  7748. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  7749. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  7750. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  7751. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  7752. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  7753. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  7754. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  7755. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  7756. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  7757. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  7758. }
  7759.  
  7760.  
  7761. /* [functions] Obsolètes */
  7762. function deleteEnchantement()
  7763. {
  7764. try
  7765. {
  7766. var idEquipement = this.getAttribute('name');
  7767. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  7768. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  7769. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  7770. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  7771. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  7772. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7773. var string = "";
  7774. for(var i=0;i<listeEquipement.length;i++)
  7775. {
  7776. if(listeEquipement[i]!=idEquipement)
  7777. if(string=="")
  7778. string = listeEquipement[i];
  7779. else
  7780. string += ";"+listeEquipement[i];
  7781. }
  7782. if(string=="")
  7783. {
  7784. MY_removeValue(numTroll+".enchantement.liste");
  7785. var table = this.parentNode.parentNode.parentNode.parentNode;
  7786. var parent = table.parentNode;
  7787. for(var i=0;i<parent.childNodes.length;i++)
  7788. {
  7789. if(parent.childNodes[i]==table)
  7790. {
  7791. parent.removeChild(parent.childNodes[i-1]);
  7792. parent.removeChild(parent.childNodes[i-1]);
  7793. parent.removeChild(parent.childNodes[i-1]);
  7794. break;
  7795. }
  7796. }
  7797. }
  7798. else
  7799. {
  7800. MY_getValue(numTroll+".enchantement.liste",string);
  7801. this.parentNode.parentNode.parentNode
  7802. .removeChild(this.parentNode.parentNode);
  7803. }
  7804. }
  7805. catch(e)
  7806. {
  7807. window.alert(e);
  7808. }
  7809. }
  7810. /* [functions] fin Obsolètes */
  7811.  
  7812. /*-[functions]---------------- Partie principale -----------------------------*/
  7813.  
  7814. function do_option() {
  7815. start_script(712);
  7816. var insertPoint = document.getElementById('footer1');
  7817. insertBefore(insertPoint,document.createElement('p'));
  7818. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  7819. ti.onclick = function (e) {
  7820. var evt = e || window.event;
  7821. if (evt.shiftKey) {
  7822. var txt = '';
  7823. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  7824. var k = localStorage.key(i);
  7825. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  7826. txt += k + "\t" + localStorage.getItem(k) + "\n";
  7827. }
  7828. copyTextToClipboard(txt);
  7829. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  7830. } else if (evt.ctrlKey) {
  7831. var tabK= [];
  7832. var sMatch = numTroll + '.';
  7833. var lMatch = sMatch.length;
  7834. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  7835. var k = localStorage.key(i);
  7836. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  7837. }
  7838. for (var i = 0; i < tabK.length; ++i ) {
  7839. MY_removeValue(tabK[i]);
  7840. }
  7841. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  7842. }
  7843. }
  7844. ti.title = 'Version ' + GM_info.script.version;
  7845. insertOptionTable(insertPoint);
  7846. /* insertion enchantements ici
  7847. if(...)
  7848. insertEnchantementTable();
  7849. */
  7850. insertBefore(insertPoint,document.createElement('p'));
  7851. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  7852. ti.onclick = function (e) {
  7853. var evt = e || window.event;
  7854. if (!evt.shiftKey) return;
  7855. var oldDev = MY_getValue('MZ_dev');
  7856. if (oldDev) {
  7857. MY_removeValue('MZ_dev');
  7858. } else {
  7859. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  7860. MY_setValue('MZ_dev', 1);
  7861. }
  7862. document.location.href = document.location.href;
  7863. }
  7864. insertCreditsTable(insertPoint);
  7865. insertBefore(insertPoint,document.createElement('p'));
  7866.  
  7867. /* [zone] Obsolète ?? */
  7868. if(MY_getValue(numTroll+".enchantement.liste")
  7869. && MY_getValue(numTroll+".enchantement.liste")!="" )
  7870. {
  7871. insertTitle(insertPoint, 'Les Enchantements en cours');
  7872. table = document.createElement('table');
  7873. table.setAttribute('width', '98%');
  7874. table.setAttribute('border', '0');
  7875. table.setAttribute('align', 'center');
  7876. table.setAttribute('cellpadding', '2');
  7877. table.setAttribute('cellspacing', '1');
  7878. table.setAttribute('class', 'mh_tdborder');
  7879.  
  7880. tbody = document.createElement('tbody');
  7881. table.appendChild(tbody);
  7882.  
  7883. tr = appendTr(tbody, 'mh_tdtitre');
  7884. appendTdText(tr, 'Equipement',1);
  7885. appendTdText(tr, 'Composants',1);
  7886. appendTdText(tr, 'Enchanteur',1);
  7887. appendTdText(tr, 'Action',1);
  7888.  
  7889. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7890. for(var i=0;i<listeEquipement.length;i++)
  7891. {
  7892. try
  7893. {
  7894. var idEquipement = listeEquipement[i];
  7895. var nomEquipement = MY_getValue(numTroll+".enchantement."
  7896. +idEquipement+".objet");
  7897. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  7898. +idEquipement+".enchanteur").split(";");
  7899. var ul = document.createElement('UL');
  7900. for(var j=0;j<3;j++)
  7901. {
  7902. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  7903. var v = MY_getValue(k);
  7904. if (v == null) { // protection Roule 26/08/2017
  7905. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  7906. continue;
  7907. }
  7908. var infoComposant = v.split(';');
  7909. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  7910. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  7911. continue;
  7912. }
  7913. var texte = infoComposant[4].replace("Ril ","Œil ");
  7914. for(var k=5;k<infoComposant.length;k++)
  7915. {
  7916. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  7917. }
  7918. li = appendLI(ul,texte);
  7919. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  7920. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  7921. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  7922. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  7923. string+= '<input type="hidden" name="q" value="min" />';
  7924. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  7925. 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>';
  7926.  
  7927. string+= '</form>';
  7928. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  7929. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  7930. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  7931. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  7932. li.innerHTML += string;
  7933. }
  7934. tr = appendTr(tbody, 'mh_tdpage');
  7935.  
  7936. td = appendTdText(tr, nomEquipement);
  7937. td.setAttribute('valign', 'center');
  7938.  
  7939. td = document.createElement('td');
  7940. td.appendChild(ul);
  7941. tr.appendChild(td);
  7942. td.setAttribute('valign', 'center');
  7943.  
  7944. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  7945. td.setAttribute('valign', 'center');
  7946.  
  7947. td = document.createElement('td');
  7948. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  7949. input.setAttribute('name', idEquipement);
  7950. tr.appendChild(td);
  7951. td.setAttribute('valign', 'center');
  7952. }
  7953. catch(e)
  7954. {
  7955. }
  7956. }
  7957. insertBefore(insertPoint, table);
  7958. insertBefore(insertPoint, document.createElement('p'));
  7959. }
  7960. /* [zone] fin Obsolète ?? */
  7961.  
  7962.  
  7963. displayScriptTime();
  7964. }
  7965.  
  7966. /*******************************************************************************
  7967. * This file is part of Mountyzilla. *
  7968. * *
  7969. * Mountyzilla is free software; you can redistribute it and/or modify *
  7970. * it under the terms of the GNU General Public License as published by *
  7971. * the Free Software Foundation; either version 2 of the License, or *
  7972. * (at your option) any later version. *
  7973. * *
  7974. * Mountyzilla is distributed in the hope that it will be useful, *
  7975. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7976. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7977. * GNU General Public License for more details. *
  7978. * *
  7979. * You should have received a copy of the GNU General Public License *
  7980. * along with Mountyzilla; if not, write to the Free Software *
  7981. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7982. *******************************************************************************/
  7983.  
  7984. // x~x equip
  7985.  
  7986. /**
  7987. * 2014-02-08 - v2.0a (from scratch)
  7988. * 2014-02-18 - v2.0a0
  7989. * - ajout calcul Carats / UM des minerais + totaux
  7990. * 2014-03-06 - v2.0a1
  7991. * - retour Infos EM des Champis
  7992. * TODO
  7993. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  7994. */
  7995.  
  7996. function traiteChampis() {
  7997. try{
  7998. var tr = document.getElementById('mh_objet_hidden_Champignon');
  7999. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8000. }
  8001. catch(e){return;}
  8002. if(trlist.length<=0) return;
  8003. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8004. var node = trlist.snapshotItem(i).childNodes[7];
  8005. var str = node.textContent.trim();
  8006. var type = str.slice(0,str.lastIndexOf(' '));
  8007. var mundi = mundiChampi[type];
  8008. if(!mundi) continue;
  8009. var urlImg = URL_MZimg
  8010. +'Competences/ecritureMagique.png';
  8011. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  8012. appendText(node,' ');
  8013. node.appendChild(img);
  8014. }
  8015. }
  8016.  
  8017. function traiteCompos() {
  8018. try {
  8019. var tr = document.getElementById('mh_objet_hidden_Composant');
  8020. var tbody = document.evaluate("./td/table/tbody",
  8021. tr, null, 9, null).singleNodeValue;
  8022. }
  8023. catch(e) {return;}
  8024. insererInfosEM(tbody);
  8025. }
  8026.  
  8027. function traiteMinerai() {
  8028. try{
  8029. var tr = document.getElementById('mh_objet_hidden_Minerai');
  8030. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8031. }
  8032. catch(e){return;}
  8033. if(trlist.length<=0) return;
  8034. var totaux = {};
  8035. var str;
  8036. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8037. var node = trlist.snapshotItem(i);
  8038. var nature = node.childNodes[7].textContent,
  8039. caracs = node.childNodes[9].textContent;
  8040. var taille = Number(caracs.match(/\d+/)[0]);
  8041. var coef = 1;
  8042. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  8043. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  8044. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  8045. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  8046. if(nature.indexOf('Mithril')!=-1) {
  8047. coef = 0.2*coef;
  8048. str = ' | UM: ';
  8049. }
  8050. else {
  8051. coef = 0.75*coef+1.25;
  8052. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  8053. str = ' | Carats: ';
  8054. }
  8055. var carats = Math.round(taille*coef)
  8056. appendText(node.childNodes[9], str+carats );
  8057. if(!totaux[nature]) {
  8058. totaux[nature] = [taille,carats];
  8059. }
  8060. else {
  8061. totaux[nature][0] += taille;
  8062. totaux[nature][1] += carats;
  8063. }
  8064. }
  8065. str = 'Total : ';
  8066. for(var nature in totaux) {
  8067. if(str.length>8) str += ', ';
  8068. if(nature.indexOf('Mithril')!=-1) {
  8069. str += nature+totaux[nature][1]+' UM';
  8070. }
  8071. else {
  8072. str += nature+totaux[nature][0]+'U/'
  8073. +totaux[nature][1]+'c';
  8074. }
  8075. }
  8076. /*var node = document.getElementById('mh_plus_Minerai');
  8077. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  8078. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  8079. if(!titre) return;*/
  8080. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  8081. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  8082. td.colSpan = 7;
  8083. }
  8084.  
  8085. function do_equip() {
  8086. start_script();
  8087.  
  8088. traiteChampis();
  8089. traiteCompos();
  8090. traiteMinerai();
  8091.  
  8092. displayScriptTime();
  8093. }
  8094.  
  8095. /*******************************************************************************
  8096. * This file is part of Mountyzilla. *
  8097. * *
  8098. * Mountyzilla is free software; you can redistribute it and/or modify *
  8099. * it under the terms of the GNU General Public License as published by *
  8100. * the Free Software Foundation; either version 2 of the License, or *
  8101. * (at your option) any later version. *
  8102. * *
  8103. * Mountyzilla is distributed in the hope that it will be useful, *
  8104. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8105. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8106. * GNU General Public License for more details. *
  8107. * *
  8108. * You should have received a copy of the GNU General Public License *
  8109. * along with Mountyzilla; if not, write to the Free Software *
  8110. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8111. *******************************************************************************/
  8112.  
  8113. // x~x diplo
  8114.  
  8115. /*
  8116. TODO:
  8117. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  8118. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  8119. V Étape 3: Ajout de la diplo perso
  8120. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  8121. V Étape 5: Ajout des fioritures (preview de la couleur...)
  8122.  
  8123. Options Globales:
  8124. Actuelles:
  8125. numTroll.USECSS,
  8126. numTroll.NODIPLO
  8127. NOMYTH
  8128. Nouvelles:
  8129. TODO numTroll.USECSS
  8130. numTroll.diplo.off (remplace NODIPLO)
  8131. numTroll.diplo.guilde
  8132. numTroll.diplo.perso
  8133.  
  8134. Structure de diplo.guilde:
  8135. isOn: 'true' ou 'false'
  8136. isDetailOn: 'true' ou 'false'
  8137. guilde
  8138. > id
  8139. > couleur
  8140. AllAmis,AllEnnemis: couleur
  8141. Amis0,...,Ennemis5
  8142. > Troll: idTroll1;...;
  8143. > Guilde: idGuilde1;...;
  8144. > titre
  8145. > couleur
  8146.  
  8147. Structure de diplo.perso:
  8148. isOn: 'true' ou 'false'
  8149. mythiques: couleur
  8150. Troll,Guilde,Monstre:
  8151. > id
  8152. > couleur
  8153. > description
  8154. */
  8155.  
  8156. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8157.  
  8158. function couleurAleatoire() {
  8159. var alph = '0123456789ABCDEF'.split('');
  8160. var clr = '#';
  8161. for (var i=0; i<6; i++) {
  8162. clr+=alph[ Math.floor(16*Math.random()) ];
  8163. }
  8164. return clr;
  8165. }
  8166.  
  8167. function isCouleur(str) {
  8168. return /^#[0-9A-F]{6}$/i.test(str);
  8169. }
  8170.  
  8171. /*-[functions]---------------- Analyse de la page ----------------------------*/
  8172.  
  8173. function appendChoixCouleur(node,id) {
  8174. var span = document.createElement('span');
  8175. span.id = 'span'+id;
  8176. if(isDetailOn) {
  8177. span.style.display = 'none';
  8178. }
  8179. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  8180. if(diploGuilde[id]) {
  8181. couleur = diploGuilde[id];
  8182. }
  8183. appendText(span,' - Couleur HTML: ');
  8184. var input = appendTextbox(span,'text',id,7,7,couleur);
  8185. input.onkeyup = previewCouleur;
  8186. input.onchange = previewCouleur;
  8187. input.onkeyup();
  8188. node.appendChild(span);
  8189. }
  8190.  
  8191. function insertChoixCouleur(node,id) {
  8192. var span = document.createElement('span');
  8193. span.id = 'span'+id;
  8194. // La couleur détaillée passera à une valeur aléatoire
  8195. // si toggle vers isDetailOn
  8196. var couleur = couleurAleatoire();
  8197. if(!isDetailOn) {
  8198. span.style.display = 'none';
  8199. } else if(diploGuilde[id]) {
  8200. couleur = diploGuilde[id].couleur;
  8201. }
  8202. appendText(span,' - Couleur HTML: ');
  8203. var input = appendTextbox(span,'text',id,7,7,couleur);
  8204. input.onkeyup = previewCouleur;
  8205. input.onchange = previewCouleur;
  8206. input.onkeyup();
  8207. insertBefore(node,span);
  8208. }
  8209.  
  8210. function setChoixCouleurs() {
  8211. try {
  8212. //var form = document.getElementsByName('ActionForm')[0];
  8213. var form = document.getElementById('mhPlay');
  8214. var nodesAE = document.evaluate(
  8215. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  8216. "./table/tbody/tr/th[@class='mh_tdtitre']",
  8217. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  8218. form, null, 7, null
  8219. );
  8220. var nodes = document.evaluate(
  8221. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  8222. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  8223. form, null, 7, null
  8224. );
  8225. } catch(e) {
  8226. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  8227. return false;
  8228. };
  8229. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  8230. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  8231. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  8232. for(var i=0 ; i<5 ; i++) {
  8233. nodes.snapshotItem(i).id = 'tdAmis'+i;
  8234. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  8235. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  8236. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  8237. }
  8238. return true;
  8239. }
  8240.  
  8241. function fetchDiploGuilde() {
  8242. try {
  8243. for(var AE in {Amis:0,Ennemis:0}) {
  8244. for(var i=0 ; i<5 ; i++) {
  8245. /* Récup des A/E de rang i */
  8246. var td = document.getElementById('td'+AE+i);
  8247. var ligne = td.getElementsByTagName('table')[0].rows;
  8248. var titre = trim(td.firstChild.textContent);
  8249. // On laisse la gestion des couleurs à setChoixCouleurs:
  8250. var couleur = document.getElementById(AE+i).value;
  8251. diploGuilde[AE+i] = {
  8252. Troll:'',
  8253. Guilde:'',
  8254. titre: titre,
  8255. couleur: couleur
  8256. };
  8257. for(var j=1 ; j<ligne.length ; j++) {
  8258. var str = trim(ligne[j].cells[0].textContent);
  8259. var idx = str.lastIndexOf('(');
  8260. var num = str.slice(idx+1,-1);
  8261. var type = trim(ligne[j].cells[1].textContent);
  8262. diploGuilde[AE+i][type] += num+';';
  8263. }
  8264. }
  8265. }
  8266. } catch(e) {
  8267. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  8268. return false;
  8269. }
  8270. return true;
  8271. }
  8272.  
  8273.  
  8274. /*-[functions]--------------------- Handlers ---------------------------------*/
  8275.  
  8276. function toggleDetails() {
  8277. isDetailOn = !isDetailOn;
  8278. for(var AE in {Amis:0,Ennemis:0}) {
  8279. document.getElementById('spanAll'+AE).style.display =
  8280. (isDetailOn?'none':'');
  8281. for(var i=0 ; i<5 ; i++) {
  8282. document.getElementById('span'+AE+i).style.display =
  8283. (isDetailOn?'':'none');
  8284. }
  8285. }
  8286. }
  8287.  
  8288. function toggleMythiques() {
  8289. isMythiquesOn = !isMythiquesOn;
  8290. document.getElementById('spanMythiques').style.display =
  8291. (isMythiquesOn?'':'none');
  8292. }
  8293.  
  8294. function previewCouleur() {
  8295. var value = this.value;
  8296. if(isCouleur(value)) {
  8297. this.style.backgroundColor = value;
  8298. this.title = '';
  8299. } else {
  8300. this.style.backgroundColor = '';
  8301. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  8302. }
  8303. }
  8304.  
  8305. function appendMenuType(node,duType) {
  8306. var select = document.createElement('select');
  8307. select.className = 'SelectboxV2';
  8308. var type = ['Guilde','Troll','Monstre'];
  8309. for(var i=0 ; i<3 ; i++) {
  8310. appendOption(select,type[i],type[i]);
  8311. if(type[i]==duType) { select.selectedIndex=i; }
  8312. }
  8313. node.appendChild(select);
  8314. }
  8315.  
  8316. function ajouteChamp(type,num,couleur,descr) {
  8317. var champs = document.getElementById('diploPerso');
  8318. var nb = champs.rows.length;
  8319. var tr = champs.insertRow(-1);
  8320. var td = appendTd(tr);
  8321. appendMenuType(td,type);
  8322. td = appendTd(tr);
  8323. appendText(td,' n°');
  8324. appendTextbox(td,'text','num'+nb,6,15,num);
  8325. td = appendTd(tr);
  8326. appendText(td,' couleur HTML:');
  8327. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  8328. input.onkeyup = previewCouleur;
  8329. input.onchange = previewCouleur;
  8330. input.onkeyup();
  8331. td = appendTd(tr);
  8332. appendText(td,' Description:');
  8333. appendTextbox(td,'text','descr'+nb,30,150,descr);
  8334. td = appendTd(tr);
  8335. var span = document.createElement('span');
  8336. appendText(span,'[ok!]',true);
  8337. span.style.visibility = 'hidden';
  8338. td.appendChild(span);
  8339. td = appendTd(tr);
  8340. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  8341. }
  8342.  
  8343. function retireCeChamp() {
  8344. var thisTr = this.parentNode.parentNode;
  8345. thisTr.parentNode.removeChild(thisTr);
  8346. var champs = document.getElementById('diploPerso');
  8347. if(champs.rows.length==0) { ajouteChamp(); }
  8348. }
  8349.  
  8350. function valideChamp(champ) {
  8351. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  8352. isCouleur(champ.cells[2].childNodes[1].value);
  8353. if(isValide) {
  8354. champ.cells[4].firstChild.style.visibility = 'visible';
  8355. } else {
  8356. champ.cells[4].firstChild.style.visibility = 'hidden';
  8357. }
  8358. return isValide;
  8359. }
  8360.  
  8361. function sauvegarderTout() {
  8362. /* Diplo de guilde */
  8363. diploGuilde.isOn =
  8364. document.getElementById('isGuildeOn').checked?'true':'false';
  8365. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  8366. var numGuilde = Number(document.getElementById('numGuilde').value);
  8367. var couleur = document.getElementById('couleurGuilde').value;
  8368. if(numGuilde) {
  8369. diploGuilde.guilde = {
  8370. id: numGuilde,
  8371. couleur: couleur
  8372. };
  8373. } else {
  8374. delete diploGuilde.guilde;
  8375. }
  8376. for(var AE in {Amis:0,Ennemis:0}) {
  8377. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  8378. for(var i=0 ; i<5 ; i++) {
  8379. if(isDetailOn) {
  8380. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  8381. } else {
  8382. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  8383. }
  8384. }
  8385. }
  8386. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  8387.  
  8388. /* Diplo personnelle (ex-fonction saveChamps) */
  8389. var champs = document.getElementById('diploPerso');
  8390. diploPerso = {
  8391. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  8392. Guilde: {},
  8393. Troll: {},
  8394. Monstre: {}
  8395. };
  8396. if(isMythiquesOn &&
  8397. isCouleur(document.getElementById('couleurMythiques').value)) {
  8398. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  8399. }
  8400. for(var i=0 ; i<champs.rows.length ; i++) {
  8401. if(valideChamp(champs.rows[i])) {
  8402. var type = champs.rows[i].cells[0].firstChild.value;
  8403. var num = champs.rows[i].cells[1].childNodes[1].value;
  8404. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  8405. var descr = champs.rows[i].cells[3].childNodes[1].value;
  8406. diploPerso[type][num] = {
  8407. couleur: couleur
  8408. };
  8409. if(descr) {
  8410. diploPerso[type][num].titre = descr;
  8411. }
  8412. }
  8413. }
  8414. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  8415.  
  8416. avertissement('Données sauvegardées');
  8417. }
  8418.  
  8419.  
  8420. /*-[functions]------------- Modifications de la page -------------------------*/
  8421.  
  8422. function creeTablePrincipale() {
  8423. var insertPt = document.getElementById('insertPt');
  8424.  
  8425. /* Titre + bouton de Sauvegarde */
  8426. var tr = insertTr(insertPt,'mh_tdtitre');
  8427. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  8428. appendButton(td,'Sauvegarder',sauvegarderTout);
  8429.  
  8430. /* Options fixes */
  8431. tr = insertTr(insertPt,'mh_tdpage');
  8432. td = appendTdText(tr,'Diplomatie de guilde:',true);
  8433. appendBr(td);
  8434. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  8435. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  8436. appendBr(td);
  8437. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  8438. appendText(td,'Utiliser des couleurs détaillées (10)');
  8439.  
  8440. /* Diplo personnelle */
  8441. tr = insertTr(insertPt,'mh_tdpage');
  8442. td = appendTdText(tr,'Diplomatie personnelle:',true);
  8443. appendBr(td);
  8444. // Diplo Mythiques
  8445. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  8446. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  8447. var span = document.createElement('span');
  8448. span.id = 'spanMythiques';
  8449. if(!isMythiquesOn) {
  8450. span.style.display = 'none';
  8451. }
  8452. var couleur = '#FFAAAA';
  8453. if(diploPerso.mythiques) {
  8454. couleur = diploPerso.mythiques;
  8455. }
  8456. appendText(span,' - couleur HTML:');
  8457. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  8458. input.onkeyup = previewCouleur;
  8459. input.onchange = previewCouleur;
  8460. input.onkeyup();
  8461. td.appendChild(span);
  8462. appendBr(td);
  8463. // Diplo éditable
  8464. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  8465. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  8466. appendBr(td);
  8467. var table = document.createElement('table');
  8468. table.id = 'diploPerso'
  8469. td.appendChild(table);
  8470. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8471. for(var num in diploPerso[type]) {
  8472. ajouteChamp(
  8473. type,
  8474. num,
  8475. diploPerso[type][num].couleur,
  8476. diploPerso[type][num].titre
  8477. );
  8478. }
  8479. }
  8480. if(table.rows.length==0) {
  8481. ajouteChamp();
  8482. }
  8483. appendButton(td,'Ajouter',ajouteChamp)
  8484. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  8485. appendText(td,' ');
  8486. appendButton(td,
  8487. 'Exemples de couleur',
  8488. function() {
  8489. var fenetre = window.open(
  8490. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  8491. 'Divers',
  8492. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  8493. 'status=0,menubar=0,resizable=1,scrollbars=1'
  8494. );
  8495. fenetre.focus();
  8496. }
  8497. );
  8498.  
  8499. /* Couleur de Guilde */
  8500. tr = insertTr(insertPt,'mh_tdtitre');
  8501. td = appendTdText(tr,'GUILDE',true);
  8502. appendText(td,' - n°');
  8503. appendTextbox(td,'text','numGuilde',5,10,
  8504. diploGuilde.guilde && diploGuilde.guilde.id ?
  8505. diploGuilde.guilde.id : ''
  8506. );
  8507. appendText(td,' - Couleur HTML: ');
  8508. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  8509. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  8510. diploGuilde.guilde.couleur : '#BBBBFF'
  8511. );
  8512. input.onkeyup = previewCouleur;
  8513. input.onchange = previewCouleur;
  8514. input.onkeyup();
  8515. }
  8516.  
  8517.  
  8518. /*-[functions]----------------------- Main -----------------------------------*/
  8519.  
  8520. function initDiplo(sType) {
  8521. var sDiplo = MY_getValue(numTroll + '.diplo.' + sType)
  8522. //console.log('sDiplo' + sType + '=' + sDiplo);
  8523. if (sDiplo && (sDiplo != 'null')) { // le stockage JSON nous donne parfois 'null'
  8524. return JSON.parse(sDiplo);
  8525. } else {
  8526. return {};
  8527. }
  8528. }
  8529. var diploGuilde = initDiplo('guilde');
  8530. var diploPerso = initDiplo('perso');
  8531. var isDetailOn = diploGuilde.isDetailOn=='true';
  8532. var isMythiquesOn = diploPerso.mythiques!=undefined;
  8533.  
  8534. function do_diplo() {
  8535. if(setChoixCouleurs() && fetchDiploGuilde()) {
  8536. creeTablePrincipale();
  8537. }
  8538. }
  8539.  
  8540. /*******************************************************************************
  8541. * This file is part of Mountyzilla. *
  8542. * *
  8543. * Mountyzilla is free software; you can redistribute it and/or modify *
  8544. * it under the terms of the GNU General Public License as published by *
  8545. * the Free Software Foundation; either version 2 of the License, or *
  8546. * (at your option) any later version. *
  8547. * *
  8548. * Mountyzilla is distributed in the hope that it will be useful, *
  8549. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8550. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8551. * GNU General Public License for more details. *
  8552. * *
  8553. * You should have received a copy of the GNU General Public License *
  8554. * along with Mountyzilla; if not, write to the Free Software *
  8555. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8556. *******************************************************************************/
  8557.  
  8558. // x~x cdmcomp
  8559.  
  8560. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  8561.  
  8562. function getNonNegInts(str) {
  8563. var nbrs = str.match(/\d+/g);
  8564. for(var i=0 ; i<nbrs.length ; i++) {
  8565. nbrs[i] = Number(nbrs[i]);
  8566. }
  8567. return nbrs;
  8568. }
  8569.  
  8570. function traiteCdMcomp() {
  8571. try {
  8572. var msgEffet = document.getElementById('msgEffet');
  8573. } catch(e) {
  8574. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  8575. return;
  8576. }
  8577.  
  8578. // Début de récupération de la CdM
  8579. cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  8580. if (MY_DEBUG) window.console.log('cdm=' + cdm);
  8581.  
  8582. // Teste si ce message du bot est un message de CdM
  8583. if (cdm.indexOf('Famille du monstre') < 0) {
  8584. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  8585. return;
  8586. }
  8587.  
  8588. // envoi au serveur (PHP) d'un objet avec
  8589. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  8590. // tstamp: l'horodatage
  8591. var tabCdM = new Array();
  8592. var etimestamp = document.getElementById('hserveur');
  8593. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  8594. var txtBlessure;
  8595. var txtPv;
  8596. for (var iElt = 0; iElt < msgEffet.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  8597. var eHTML = msgEffet.childNodes[iElt];
  8598. switch (eHTML.nodeName) {
  8599. case '#text':
  8600. var s = eHTML.nodeValue.trim();
  8601. if (s != '') tabCdM.push(s);
  8602. break;
  8603. case 'P':
  8604. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8605. s = s.trim();
  8606. if (s != '') tabCdM.push(s);
  8607. break;
  8608. case 'TABLE':
  8609. var s = 'table';
  8610. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  8611. var eTr = eHTML.rows[iTr];
  8612. var tabTd = new Array();
  8613. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  8614. var eTd = eTr.cells[iTd];
  8615. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  8616. s = s.trim();
  8617. tabTd.push(s);
  8618. }
  8619. if (tabTd.length >= 2) {
  8620. if (tabTd[0].match(/Blessure/i)) {
  8621. txtBlessure = tabTd[1]
  8622. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  8623. txtPv = tabTd[1]
  8624. }
  8625. }
  8626. tabCdM.push(tabTd);
  8627. }
  8628. break;
  8629. default:
  8630. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  8631. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8632. if (s != '') tabCdM.push(s);
  8633. break;
  8634. }
  8635. }
  8636. var oData = {};
  8637. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  8638. oData.idTroll = numTroll;
  8639. oData.tabCdM = tabCdM;
  8640. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  8641.  
  8642. // envoi d'une CdM issue de compte-rendu de compétence
  8643. // fonction définie ici pour avoir vue sur la variable tabCdM
  8644. var sendInfoCDM = function () {
  8645. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  8646. var buttonCDM = this;
  8647. var texte = '';
  8648. FF_XMLHttpRequest({
  8649. method: 'POST',
  8650. url: URL_pageDispatcherV2,
  8651. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8652. headers : {
  8653. /* inutile, à supprimer
  8654. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8655. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8656. */
  8657. 'Content-type':'application/x-www-form-urlencoded',
  8658. },
  8659. trace: 'envoi CdM',
  8660. onload: function(responseDetails) {
  8661. texte = responseDetails.responseText;
  8662. buttonCDM.value = texte;
  8663. if (!isDEV) buttonCDM.disabled = true;
  8664. }
  8665. });
  8666. }
  8667.  
  8668. // Envoi auto ou insertion bouton envoi (suivant option)
  8669. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  8670. sendInfoCDM();
  8671. var p = document.createElement('p');
  8672. p.style.color = 'green';
  8673. appendText(p,'CdM envoyée vers la base MountyZilla !');
  8674. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  8675. } else {
  8676. insertButtonCdm('as_Action', sendInfoCDM);
  8677. }
  8678.  
  8679. // Insertion de l'estimation des PV restants
  8680. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  8681. if (txtBlessure !== undefined && txtPv !== undefined) {
  8682. var pv = getPVsRestants(txtPv,txtBlessure);
  8683. if (MY_DEBUG) window.console.log('pv=' + pv);
  8684. if (pv) { // pv null si le monstre n'est pas blessé
  8685. var trBless = document.evaluate(
  8686. "//tr[contains(th/text(),'Blessure')]",
  8687. msgEffet, null, 9, null).singleNodeValue;
  8688. var tr = document.createElement('tr');
  8689. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  8690. appendTr(trBless);
  8691. var th = appendThText(tr, pv[0], false);
  8692. th.className = trBless.cells[0].className;
  8693. var td = appendTdText(tr, pv[1], false);
  8694. var eSpan = document.createElement('span');
  8695. appendText(eSpan, ' (Calculé par Mountyzilla)');
  8696. eSpan.style.fontSize = "small";
  8697. eSpan.style.fontStyle = "italic";
  8698. td.appendChild(eSpan);
  8699. }
  8700. }
  8701. }
  8702.  
  8703. function do_cdmcomp() {
  8704. start_script(31);
  8705. traiteCdMcomp();
  8706. displayScriptTime();
  8707. }
  8708.  
  8709. /*********************************************************************************
  8710. * This file is part of Mountyzilla. *
  8711. * *
  8712. * Mountyzilla is free software; you can redistribute it and/or modify *
  8713. * it under the terms of the GNU General Public License as published by *
  8714. * the Free Software Foundation; either version 2 of the License, or *
  8715. * (at your option) any later version. *
  8716. * *
  8717. * Mountyzilla is distributed in the hope that it will be useful, *
  8718. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8719. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8720. * GNU General Public License for more details. *
  8721. * *
  8722. * You should have received a copy of the GNU General Public License *
  8723. * along with Mountyzilla; if not, write to the Free Software *
  8724. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8725. *********************************************************************************/
  8726.  
  8727. // x~x cmdbot
  8728.  
  8729. /* v0.2 by Dab - 2013-08-20
  8730. * - patch dégueu pour gérer la décomposition P/M de l'armure
  8731. */
  8732.  
  8733. var buttonCDM;
  8734.  
  8735. /*******************************************************************************************
  8736. CDM :
  8737. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  8738.  
  8739. Il ne vous est pas possible d'améliorer cette compétence.
  8740.  
  8741. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  8742. Niveau : Inimaginable (entre 49 et 51)
  8743. Points de Vie : Surtrollesque (entre 450 et 470)
  8744. Blessure (Approximatif) : 0 %
  8745. Dés d'Attaque : Impressionnant (entre 30 et 32)
  8746. Dés d'Esquive : Impressionnant (entre 28 et 30)
  8747. Dés de Dégat : Très Fort (entre 18 et 20)
  8748. Dés de Régénération : Excellent (égal à 13)
  8749. Armure Physique : Moyen (entre 10 et 12)
  8750. Armure Magique : Faible (inférieur à 6)
  8751. Vue : Moyen (entre 9 et 11)
  8752. Maitrise Magique : Inimaginable (supérieur à 6000)
  8753. Résistance Magique : Inimaginable (supérieur à 6000)
  8754. Nombre d'attaques : 1
  8755. Vitesse de Déplacement : Normale
  8756. Voir le Caché : Oui
  8757. Attaque à distance : Non
  8758. Attaque magique : Oui
  8759. Vole : Non
  8760. Sang froid : Inexistant
  8761. DLA : Milieu
  8762. Durée Tour : Remarquable (entre 9 et 11)
  8763. Chargement : Vide
  8764. Bonus Malus : Aucun
  8765.  
  8766. Vous avez également gagné 1 PX pour la réussite.
  8767. *******************************************************************************************
  8768. BOT :
  8769. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  8770.  
  8771. Le Monstre ciblé fait partie des : Mort-Vivant
  8772.  
  8773. Niveau : Incroyable (entre 36 et 38)
  8774. *******************************************************************************************/
  8775.  
  8776. function getNNInt(str) {
  8777. var nbrs = str.match(/\d+/g);
  8778. for (var i=0 ; i<nbrs.length ; i++)
  8779. nbrs[i] = parseInt(nbrs[i]);
  8780. return nbrs;
  8781. }
  8782.  
  8783. // envoi d'une CdM issue d'un message du BOT
  8784. function sendCDM() {
  8785. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  8786. document, null, 9, null).singleNodeValue;
  8787. /* ancienne version à supprimer
  8788. cdm = td.innerHTML;
  8789. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  8790. "$3$4 ($1 - N°$2)<br>");
  8791. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  8792. 'Blessure : XX % (approximativement)');
  8793. // Supprime la décomposition P/M de l'Armure
  8794. var bgn = cdm.indexOf('Armure Physique');
  8795. if (bgn!=-1) {
  8796. var end = cdm.indexOf('Vue')-2;
  8797. var lines = cdm.substring(bgn,end).split('<br>');
  8798. var armp = getNNInt(lines[0]);
  8799. var armm = getNNInt(lines[1]);
  8800. if (lines[0].indexOf('(inf')!=-1)
  8801. armp = [0,armp[0]];
  8802. if (lines[1].indexOf('(inf')!=-1)
  8803. armm = [0,armm[0]];
  8804. var insrt = 'Armure : ';
  8805. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  8806. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  8807. else
  8808. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  8809. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  8810. }
  8811. cdm = cdm.replace(/<br>/g,'\n');
  8812. */
  8813.  
  8814. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  8815. //window.console.log(tdTxt);
  8816. var oData = {};
  8817. oData.tabCdM = tdTxt.split(/\n/);
  8818. // nettoyage entête : enlève le premier élément tant que
  8819. // - suite de *
  8820. // - "MOUNTYHALL - La Terre des Trõlls"
  8821. // - ligne vide (la première expression régulière matche les lignes vides)
  8822. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  8823. // 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
  8824. var iLigneNonVide;
  8825. for (var i = 0; i < oData.tabCdM.length; i++) {
  8826. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  8827. if (iLigneNonVide === undefined)
  8828. oData.tabCdM.splice(i);
  8829. else
  8830. oData.tabCdM.splice(iLigneNonVide+1);
  8831. break;
  8832. }
  8833. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  8834. }
  8835. //window.console.log(JSON.stringify(oData));
  8836.  
  8837. FF_XMLHttpRequest({
  8838. method: 'POST',
  8839. url: URL_pageDispatcherV2,
  8840. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8841. headers : {
  8842. /* inutile, à supprimer
  8843. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8844. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8845. */
  8846. 'Content-type':'application/x-www-form-urlencoded',
  8847. },
  8848. trace: 'envoi CdM msg du bot',
  8849. onload: function(responseDetails) {
  8850. buttonCDM.value=responseDetails.responseText;
  8851. buttonCDM.disabled = true;
  8852. }
  8853. });
  8854. }
  8855.  
  8856. function traiteCdMmsg() {
  8857. // Teste si ce message du bot est un message de CdM
  8858. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  8859. document, null, 9, null).singleNodeValue;
  8860. if (!td) return false;
  8861.  
  8862. cdm = td.innerHTML;
  8863.  
  8864. // Insertion de l'estimation des PV restants
  8865. var des = cdm.indexOf('Dés');
  8866. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  8867. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  8868. if(pv)
  8869. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  8870.  
  8871. // Insertion bouton envoi + espace
  8872. buttonCDM = insertButtonCdm('bClose',sendCDM);
  8873. }
  8874.  
  8875. /*function traitePouvoir() {
  8876. // Teste si ce message du bot est un message de CdM
  8877. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  8878. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  8879. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8880. if (!td)
  8881. return false;
  8882.  
  8883. var infos = td.innerHTML;
  8884. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  8885. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  8886. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  8887. var date = /alors : ([^<]+)\./.exec(infos)[1];
  8888. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  8889. var effetPouvoir="";
  8890. var full=false;
  8891. if(infos.indexOf("REDUIT")!=-1) {
  8892. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  8893. }
  8894. else {
  8895. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  8896. full=true;
  8897. }
  8898. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  8899. // On insère le bouton et un espace
  8900. //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));
  8901. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  8902. if(!MY_getValue('AUTOSENDPOUV'))
  8903. {
  8904. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  8905. button.setAttribute("onClick", "window.open('" + url
  8906. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  8907. + "this.value='Merci de votre participation'; this.disabled = true;");
  8908. }
  8909. else
  8910. {
  8911. FF_XMLHttpRequest({
  8912. method: 'GET',
  8913. url: url,
  8914. headers : {
  8915. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8916. 'Accept': 'application/atom+xml,application/xml,text/xml'
  8917. }});
  8918. }
  8919. }*/
  8920.  
  8921. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  8922. traiteCdMmsg();
  8923. }
  8924. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  8925.  
  8926. /*******************************************************************************
  8927. * This file is part of Mountyzilla. *
  8928. * *
  8929. * Mountyzilla is free software; you can redistribute it and/or modify *
  8930. * it under the terms of the GNU General Public License as published by *
  8931. * the Free Software Foundation; either version 2 of the License, or *
  8932. * (at your option) any later version. *
  8933. * *
  8934. * Mountyzilla is distributed in the hope that it will be useful, *
  8935. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8936. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8937. * GNU General Public License for more details. *
  8938. * *
  8939. * You should have received a copy of the GNU General Public License *
  8940. * along with Mountyzilla; if not, write to the Free Software *
  8941. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8942. *******************************************************************************/
  8943.  
  8944. // x~x menu
  8945. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  8946.  
  8947. var menuRac, mainIco;
  8948.  
  8949. // met à jour les carac sauvegardées (position, DLA, etc.)
  8950. function updateData() {
  8951. var inputs = document.getElementsByTagName('input');
  8952. var divs = document.getElementsByTagName('div');
  8953.  
  8954. //window.console.log('inputs=' + JSON.stringify(inputs));
  8955. if (inputs && inputs.length > 0) {
  8956. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  8957. numTroll = inputs[0].value;
  8958. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  8959. MY_setValue('NUM_TROLL', numTroll);
  8960. MY_setValue('NIV_TROLL',inputs[1].value);
  8961. if(!MY_getValue(numTroll+'.caracs.rm')) {
  8962. MY_setValue(numTroll+'.caracs.rm',0);
  8963. // assure l'init des 4 var de libs
  8964. }
  8965. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  8966. } else {
  8967. // onclick="EnterPJView(91305,750,550)"
  8968. var tabA = document.getElementsByTagName('a');
  8969. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  8970. var s = tabA[0].onclick.toString();;
  8971. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  8972. var m = s.match(/\((\d+) *,/);
  8973. //window.console.log('m=' + JSON.stringify(m));
  8974. numTroll = parseInt(m[1]);
  8975. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  8976. MY_setValue('NUM_TROLL', numTroll);
  8977. } else {
  8978. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  8979. }
  8980. }
  8981.  
  8982. var DLA = new Date(
  8983. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  8984. );
  8985. if(MY_getValue(numTroll+'.DLA.encours')) {
  8986. var DLAstockee = new Date(
  8987. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  8988. );
  8989. if(DLA>DLAstockee) {
  8990. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  8991. // Pose un pb en cas de décalage de DLA
  8992. }
  8993. }
  8994. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  8995.  
  8996. try {
  8997. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  8998. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  8999. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  9000. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  9001. } catch(e) {
  9002. 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, '‹'));
  9003. }
  9004. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  9005. }
  9006.  
  9007. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9008. function initRaccourcis() {
  9009. var anotherURL = MY_getValue('URL1');
  9010. if(!anotherURL) { return; }
  9011.  
  9012. /* Création de l'icône faisant apparaître le menu */
  9013. mainIco = document.createElement('img');
  9014. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  9015. if(!urlIco) {
  9016. urlIco =
  9017. URL_MZimg + 'mz_logo_small.png';
  9018. }
  9019. mainIco.src = urlIco;
  9020. mainIco.alt = 'MZ';
  9021. mainIco.style = 'position:fixed; top:0px; left:0px';
  9022. mainIco.onmouseover = afficheMenu;
  9023. document.body.appendChild(mainIco);
  9024.  
  9025. /* Création du menu des Raccourcis */
  9026. menuRac = document.createElement('div');
  9027. menuRac.className = 'mh_textbox';
  9028. menuRac.style =
  9029. 'position:fixed; top:10px; left:10px;'+
  9030. 'max-width:190px;'+
  9031. 'border-radius: 4px; padding: 4px;'+
  9032. 'z-index: 500;'+
  9033. 'visibility: hidden;';
  9034. document.body.appendChild(menuRac);
  9035. document.addEventListener('mousemove',cacheMenu,false);
  9036. var i=1;
  9037. while(anotherURL) {
  9038. var a = document.createElement('a');
  9039. var url = MY_getValue('URL'+i);
  9040. var nom = MY_getValue('URL'+i+'.nom');
  9041. var ico = MY_getValue('URL'+i+'.ico');
  9042. a.href = url;
  9043. a.target = '_blank';
  9044. if(ico) {
  9045. var txt = nom ? nom : '';
  9046. var img = createImage(ico,txt);
  9047. a.appendChild(img);
  9048. }
  9049. else {
  9050. appendText(a,'['+nom+']');
  9051. }
  9052. menuRac.appendChild(a);
  9053. appendBr(menuRac);
  9054. i++;
  9055. anotherURL = MY_getValue('URL'+i);
  9056. }
  9057. }
  9058.  
  9059. function afficheMenu() {
  9060. menuRac.style.visibility = 'visible';
  9061. }
  9062.  
  9063. function cacheMenu(e) {
  9064. if(menuRac.style.visibility=='hidden') { return; }
  9065. // Position souris
  9066. var ptX = e.clientX;
  9067. var ptY = e.clientY;
  9068. // On recalcule en live les BoundingBox pour mainIco et menuRac
  9069. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  9070. var menuRect = menuRac.getBoundingClientRect();
  9071. var icoRect = mainIco.getBoundingClientRect();
  9072. if((ptX>icoRect.width || ptY>icoRect.height) &&
  9073. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  9074. menuRac.style.visibility = 'hidden';
  9075. }
  9076. }
  9077.  
  9078. // ajout de l'icône, branchée sur un refresh
  9079. function initUpdateCoordGauche() {
  9080. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  9081. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  9082. var img = document.createElement('img');
  9083. img.src = URL_MZimg + 'recycl.png'
  9084. img.onclick = function(evt) {
  9085. document.location.href = document.location.href;
  9086. };
  9087. img.title = 'Mise à jour de la localisation';
  9088. img.style.cursor = 'pointer';
  9089. img.style.position = 'absolute';
  9090. img.style.bottom = 0;
  9091. img.style.left = 0;
  9092. div.appendChild(img);
  9093. }
  9094.  
  9095. function do_menu() {
  9096. // met à jour les carac sauvegardées (position, DLA, etc.)
  9097. updateData();
  9098. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9099. initRaccourcis();
  9100. // Ajout bouton de mise à jour coordonnées
  9101. initUpdateCoordGauche();
  9102. }
  9103.  
  9104. /*******************************************************************************
  9105. * This file is part of Mountyzilla. *
  9106. * *
  9107. * Mountyzilla is free software; you can redistribute it and/or modify *
  9108. * it under the terms of the GNU General Public License as published by *
  9109. * the Free Software Foundation; either version 2 of the License, or *
  9110. * (at your option) any later version. *
  9111. * *
  9112. * Mountyzilla is distributed in the hope that it will be useful, *
  9113. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9114. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9115. * GNU General Public License for more details. *
  9116. * *
  9117. * You should have received a copy of the GNU General Public License *
  9118. * along with Mountyzilla; if not, write to the Free Software *
  9119. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9120. *******************************************************************************/
  9121.  
  9122. // x~x vue
  9123.  
  9124. /* TODO
  9125. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  9126. * prévoir fix ("delete infos")
  9127. */
  9128.  
  9129. /*--------------------------- Variables Globales -----------------------------*/
  9130.  
  9131. // Position actuelle
  9132. var currentPosition=[0,0,0];
  9133.  
  9134. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  9135. var porteeVue=[0,0,0,0];
  9136.  
  9137. // Fenêtres déplaçables
  9138. var winCurr = null;
  9139. var offsetX, offsetY;
  9140.  
  9141. // Diplomatie
  9142. var Diplo = {
  9143. Guilde: {},
  9144. Troll: {},
  9145. Monstre: {}
  9146. // .mythiques: uniquement si option activée
  9147. };
  9148. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  9149.  
  9150. // Infos tactiques
  9151. var popup;
  9152.  
  9153.  
  9154.  
  9155. // Utilisé pour supprimer les monstres "engagés"
  9156. var listeEngages = {};
  9157. var isEngagesComputed = false;
  9158. var cursorOnLink = false; // DEBUG: wtf ?
  9159.  
  9160. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  9161. && MY_getValue(numTroll+'.enchantement.liste')!='';
  9162.  
  9163. // Checkboxes de filtrage
  9164. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  9165. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  9166. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  9167. comboBoxNiveauMin, comboBoxNiveauMax, comboBoxFamille;
  9168.  
  9169. /* Acquisition & Stockage des données de DB */
  9170. const typesAFetcher = {
  9171. 'monstres':1,
  9172. 'trolls':1,
  9173. 'tresors':1,
  9174. 'champignons':1,
  9175. 'lieux':1
  9176. }
  9177.  
  9178. var MZ_EtatCdMs = { // zone où sont stockées les variables "globales" pour la gestion des cdM et infos tactiques
  9179. nbMonstres: 0,
  9180. tr_monstres: [],
  9181. lastIndexDone: 0,
  9182. isCDMsRetrieved: false, // = si les CdM ont déjà été DL
  9183. listeCDM: [],
  9184. // Gère l'affichage en cascade des popups de CdM
  9185. yIndexCDM: 0,
  9186. tdWitdh: 110,
  9187. };
  9188.  
  9189. var tr_trolls = {}, tr_tresors = {},
  9190. tr_champignons = {}, tr_lieux = {};
  9191. var nbTrolls = 0, nbTresors = 0,
  9192. nbChampignons = 0, nbLieux = 0;
  9193.  
  9194. function fetchData(type) {
  9195. try {
  9196. var node = document.getElementById('mh_vue_hidden_'+type);
  9197. // this = MZ.global = sandBox de travail de MZ
  9198. // On définit donc des variables MZ-globales
  9199. this['tr_'+type] = node.getElementsByTagName('tr');
  9200. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  9201. } catch(e) {
  9202. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  9203. }
  9204. }
  9205.  
  9206.  
  9207. /*---------------------------------- DEBUG -----------------------------------*/
  9208. var mainTabs = document.getElementsByClassName('mh_tdborder');
  9209. var x_monstres = MZ_EtatCdMs.tr_monstres;
  9210. var x_trolls = tr_trolls;
  9211. var x_tresors = tr_tresors;
  9212. var x_champis = tr_champignons;
  9213. var x_lieux = tr_lieux;
  9214. /*-------------------------------- FIN DEBUG ---------------------------------*/
  9215.  
  9216.  
  9217. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  9218.  
  9219. function positionToString(arr) {
  9220. return arr.join(';');
  9221. }
  9222.  
  9223. function savePosition() {
  9224. // Stocke la position (à jour) de la vue pour les autres scripts
  9225. // DEBUG: Lesquels et pourquoi?
  9226. var pos = getPosition();
  9227. MY_setValue(numTroll+'.position.X',pos[0]);
  9228. MY_setValue(numTroll+'.position.Y',pos[1]);
  9229. MY_setValue(numTroll+'.position.N',pos[2]);
  9230. }
  9231.  
  9232.  
  9233. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  9234. /* INFOS :
  9235. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  9236. * sont identifiables via leur Name
  9237. * les tables-listings sont identifiables via l'ID du tr conteneur
  9238. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  9239. */
  9240.  
  9241. /* [functions] Récup données Utilisateur */
  9242. function getPosition() {
  9243. // Pour rétrocompatibilité
  9244. return currentPosition;
  9245. }
  9246.  
  9247. function getPorteVue() {
  9248. // Pour rétrocompatibilité
  9249. return porteeVue;
  9250. }
  9251.  
  9252. function getVue() {
  9253. // Retourne [vueHpure, vueVpure]
  9254. var vues = getPorteVue();
  9255. return [ vues[0], vues[1] ];
  9256. }
  9257.  
  9258. // Roule 11/03/2016
  9259. /* [functions] Récup données monstres, trolls, etc. */
  9260. function getXxxDistance(xxx, i) {
  9261. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  9262. }
  9263. function getXxxPosition(xxx, i) {
  9264. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  9265. var l = tds.length;
  9266. return [
  9267. parseInt(tds[l-3].textContent),
  9268. parseInt(tds[l-2].textContent),
  9269. parseInt(tds[l-1].textContent)
  9270. ];
  9271. }
  9272.  
  9273.  
  9274. /* [functions] Récup données monstres */
  9275. function getMonstreDistance(i) {
  9276. //debugMZ('getMonstreDistance, i=' + i + ', tr=' + MZ_EtatCdMs.tr_monstres[i].innerHTML);
  9277. return parseInt(MZ_EtatCdMs.tr_monstres[i].cells[0].textContent);
  9278. }
  9279.  
  9280. function getMonstreID(i) {
  9281. return Number(MZ_EtatCdMs.tr_monstres[i].cells[2].firstChild.nodeValue);
  9282. }
  9283.  
  9284. function getMonstreIDByTR(tr) {
  9285. return tr.cells[2].firstChild.nodeValue;
  9286. }
  9287.  
  9288. function getMonstreLevelNode(i) {
  9289. return MZ_EtatCdMs.tr_monstres[i].cells[3];
  9290. }
  9291.  
  9292. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  9293. if(!MZ_EtatCdMs.isCDMsRetrieved) return false;
  9294. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  9295. if (!donneesMonstre) return false;
  9296. var niv = donneesMonstre.niv;
  9297. if (niv == undefined) return false;
  9298. if (limitMin > 0 && niv.max && niv.max < limitMin) return true;
  9299. if (limitMax > 0 && niv.min && niv.min > limitMax) return true;
  9300. return false;
  9301. }
  9302.  
  9303. function getMonstreNomNode(i) {
  9304. try {
  9305. var td = document.evaluate(
  9306. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  9307. MZ_EtatCdMs.tr_monstres[i], null, 9, null
  9308. ).singleNodeValue;
  9309. return td;
  9310. } catch(e) {
  9311. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  9312. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  9313. }
  9314. }
  9315.  
  9316. function getMonstreNom(i) {
  9317. return getMonstreNomByTR(MZ_EtatCdMs.tr_monstres[i]);
  9318. }
  9319.  
  9320. function getMonstreNomByTR(tr) {
  9321. try {
  9322. var nom = document.evaluate(
  9323. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  9324. tr, null, 2, null
  9325. ).stringValue;
  9326. return nom;
  9327. } catch(e) {
  9328. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  9329. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  9330. }
  9331. }
  9332.  
  9333. function getMonstrePosition(i) {
  9334. var tds = MZ_EtatCdMs.tr_monstres[i].childNodes;
  9335. var l = tds.length;
  9336. return [
  9337. parseInt(tds[l-3].textContent),
  9338. parseInt(tds[l-2].textContent),
  9339. parseInt(tds[l-1].textContent)
  9340. ];
  9341. }
  9342.  
  9343. function appendMonstres(txt) {
  9344. for(var i=1; i<=MZ_EtatCdMs.nbMonstres ; i++)
  9345. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  9346. return txt;
  9347. }
  9348.  
  9349. function getMonstres() {
  9350. var vue = getVue();
  9351. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9352. }
  9353.  
  9354. function bddMonstres(start,stop) {
  9355. if(!start) { var start = 1; }
  9356. if(!stop) { var stop = MZ_EtatCdMs.nbMonstres; }
  9357. stop = Math.min(MZ_EtatCdMs.nbMonstres,stop);
  9358. var txt='';
  9359. for(var i=start ; i<=stop ; i++) {
  9360. txt += getMonstreID(i)+';'+
  9361. getMonstreNom(i)+';'+
  9362. positionToString(getMonstrePosition(i))+'\n';
  9363. }
  9364. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  9365. }
  9366.  
  9367. /* [functions] Récup données Trolls */
  9368.  
  9369. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  9370. const COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  9371.  
  9372. function getTrollDistance(i) {
  9373. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  9374. }
  9375.  
  9376. var MZ_cache_col_TrollID;
  9377. var MZ_cache_col_TrollNOM;
  9378. var MZ_cache_col_TrollGUILDE;
  9379. var MZ_cache_col_TrollNIV;
  9380.  
  9381. function MZ_find_col_titre(trs, titre) {
  9382. var l = titre.length;
  9383. for (var i=0; i < trs[0].cells.length; i++)
  9384. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  9385. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  9386. return 0;
  9387. }
  9388.  
  9389. function getTrollID(i) {
  9390. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  9391. // Roule 08/03/2017 protection
  9392. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  9393. if (isNaN(iTroll)) return;
  9394. if (iTroll == 0) return;
  9395. return iTroll;
  9396. }
  9397.  
  9398. function getTrollNomNode(i) {
  9399. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  9400. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  9401. }
  9402.  
  9403. function getTrollNivNode(i) {
  9404. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  9405. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  9406. }
  9407.  
  9408. function getTrollGuilde(i) {
  9409. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9410. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  9411. }
  9412.  
  9413. function getTrollGuildeID(i) {
  9414. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9415. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  9416. var href;
  9417. try {
  9418. 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"
  9419. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  9420. } catch(e) { // debug pb remonté par Marsak
  9421. window.console.error(traceStack(e, 'getTrollGuildeID')
  9422. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  9423. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  9424. return -1;
  9425. }
  9426. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  9427. }
  9428. return -1;
  9429. }
  9430.  
  9431. function getTrollPosition(i) {
  9432. var tds = tr_trolls[i].childNodes;
  9433. var l = tds.length;
  9434. return [
  9435. parseInt(tds[l-3].textContent),
  9436. parseInt(tds[l-2].textContent),
  9437. parseInt(tds[l-1].textContent)
  9438. ];
  9439. }
  9440.  
  9441. function bddTrolls() {
  9442. var txt='#DEBUT TROLLS\n'+
  9443. numTroll+';'+positionToString(getPosition())+'\n';
  9444. for(var i=1 ; i<=nbTrolls ; i++) {
  9445. txt += getTrollID(i)+';'+
  9446. positionToString(getTrollPosition(i))+'\n';
  9447. }
  9448. return txt+'#FIN TROLLS';
  9449. }
  9450.  
  9451. /* [functions] Récup données Trésors */
  9452. function getTresorDistance(i) {
  9453. return tr_tresors[i].cells[0].firstChild.nodeValue;
  9454. }
  9455.  
  9456. function getTresorID(i) {
  9457. return trim(tr_tresors[i].cells[2].textContent);
  9458. }
  9459.  
  9460. function getTresorNom(i) {
  9461. // Utilisation de textContent pour régler le "bug de Pollux"
  9462. return trim(tr_tresors[i].cells[3].textContent);
  9463. }
  9464.  
  9465. function getTresorPosition(i) {
  9466. var tds = tr_tresors[i].childNodes;
  9467. var l = tds.length;
  9468. return [
  9469. parseInt(tds[l-3].textContent),
  9470. parseInt(tds[l-2].textContent),
  9471. parseInt(tds[l-1].textContent),
  9472. ];
  9473. }
  9474.  
  9475. function bddTresors(dmin,start,stop) {
  9476. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  9477. if(!dmin) { var dmin = 0; }
  9478. if(!start) { var start = 1; }
  9479. if(!stop) { var stop = nbTresors; }
  9480. stop = Math.min(nbTresors,stop);
  9481. var txt='';
  9482. for(var i=start ; i<=stop ; i++) {
  9483. if(getTresorDistance(i)>=dmin) {
  9484. txt += getTresorID(i)+';'+
  9485. getTresorNom(i)+';'+
  9486. positionToString(getTresorPosition(i))+'\n';
  9487. }
  9488. }
  9489. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  9490. }
  9491.  
  9492. /* [functions] Récup données Champignons */
  9493. // DEBUG: Pas de colonne "Référence" sur serveur de test
  9494. function getChampignonNom(i) {
  9495. return trim(tr_champignons[i].cells[2].textContent);
  9496. }
  9497.  
  9498. function getChampignonPosition(i) {
  9499. var tds = tr_champignons[i].childNodes;
  9500. var l = tds.length;
  9501. return [
  9502. parseInt(tds[l-3].textContent),
  9503. parseInt(tds[l-2].textContent),
  9504. parseInt(tds[l-1].textContent)
  9505. ];
  9506. }
  9507.  
  9508. function bddChampignons() {
  9509. var txt='';
  9510. for(var i=1 ; i<=nbChampignons ; i++) {
  9511. txt += ';'+ // Les champis n'ont pas de Référence
  9512. getChampignonNom(i)+';'+
  9513. positionToString(getChampignonPosition(i))+'\n';
  9514. }
  9515. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  9516. }
  9517.  
  9518. /* [functions] Récup données Lieux */
  9519. function getLieuDistance(i) {
  9520. return parseInt(tr_lieux[i].cells[0].textContent);
  9521. }
  9522.  
  9523. function getLieuID(i) {
  9524. return parseInt(tr_lieux[i].cells[2].textContent);
  9525. }
  9526.  
  9527. function getLieuNom(i) {
  9528. // Conversion ASCII pour éviter les bugs des Vues externes
  9529. return trim(tr_lieux[i].cells[3].textContent);
  9530. }
  9531.  
  9532. function getLieuPosition(i) {
  9533. var tds = tr_lieux[i].childNodes;
  9534. var l = tds.length;
  9535. return [
  9536. parseInt(tds[l-3].textContent),
  9537. parseInt(tds[l-2].textContent),
  9538. parseInt(tds[l-1].textContent)
  9539. ];
  9540. }
  9541.  
  9542. function appendLieux(txt) {
  9543. for(var i = 1; i < nbLieux+1; i++) {
  9544. var tds = x_lieux[i].childNodes;
  9545. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  9546. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  9547. }
  9548. return txt;
  9549. }
  9550.  
  9551. function getLieux() {
  9552. var vue = getVue();
  9553. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9554. }
  9555.  
  9556. function bddLieux(start,stop) {
  9557. if(!start) { var start = 1; }
  9558. if(!stop) { var stop = nbLieux; }
  9559. stop = Math.min(nbLieux,stop);
  9560. var txt='';
  9561. for(var i=start ; i<=stop ; i++) {
  9562. txt += getLieuID(i)+';'+
  9563. epure(getLieuNom(i))+';'+
  9564. positionToString(getLieuPosition(i))+'\n';
  9565. }
  9566. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  9567. }
  9568.  
  9569.  
  9570. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  9571.  
  9572. function saveCheckBox(chkbo, pref) {
  9573. // Enregistre et retourne l'état d'une CheckBox
  9574. var etat = chkbo.checked;
  9575. MY_setValue(pref, etat ? 'true' : 'false' );
  9576. return etat;
  9577. }
  9578.  
  9579. function recallCheckBox(chkbox, pref) {
  9580. // Restitue l'état d'une CheckBox
  9581. chkbox.checked = (MY_getValue(pref)=='true');
  9582. }
  9583.  
  9584. function saveComboBox(cbb, pref) {
  9585. // Enregistre et retourne l'état d'une ComboBox
  9586. var opt = cbb.options[cbb.selectedIndex];
  9587. if (!opt) return;
  9588. var etat = cbb.options[cbb.selectedIndex].value;
  9589. MY_setValue(pref, etat);
  9590. return etat;
  9591. }
  9592.  
  9593. function recallComboBox(cbb, pref) {
  9594. // Restitue l'état d'une ComboBox
  9595. var nb = MY_getValue(pref);
  9596. if(nb) cbb.value = nb;
  9597. return nb;
  9598. }
  9599.  
  9600. function synchroniseFiltres() {
  9601. // Récupération de toutes les options de la vue
  9602. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9603. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  9604. numBool = recallComboBox(comboBoxFamille,'FAMILLEMONSTRE') || numBool;
  9605. if(numBool) {
  9606. debutFiltrage('Monstres');
  9607. }
  9608. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9609. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9610. recallCheckBox(checkBoxMythiques,'NOMYTH');
  9611. recallCheckBox(checkBoxEngages,'NOENGAGE');
  9612. recallCheckBox(checkBoxLevels,'NOLEVEL');
  9613. recallCheckBox(checkBoxIntangibles,'NOINT');
  9614. recallCheckBox(checkBoxGG,'NOGG');
  9615. recallCheckBox(checkBoxCompos,'NOCOMP');
  9616. recallCheckBox(checkBoxBidouilles,'NOBID');
  9617. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  9618. recallCheckBox(checkBoxTrou,'NOTROU');
  9619. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9620. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  9621. if(MY_getValue('NOINFOEM')!='true')
  9622. recallCheckBox(checkBoxEM,'NOEM');
  9623. }
  9624.  
  9625.  
  9626. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  9627.  
  9628. function getVueScript() {
  9629. try {
  9630. var txt = bddTrolls()+
  9631. bddMonstres()+
  9632. bddChampignons()+
  9633. bddTresors()+
  9634. bddLieux()+
  9635. '#DEBUT ORIGINE\n'+
  9636. getPorteVue()[2]+';'+positionToString(getPosition())+
  9637. '\n#FIN ORIGINE\n';
  9638. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  9639. return txt;
  9640. } catch(e) {
  9641. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  9642. window.console.error(traceStack(e, 'getVueScript'))
  9643. }
  9644. }
  9645.  
  9646. /* [functions] Menu Vue 2D */
  9647. var vue2Ddata = {
  9648. 'Bricol\' Vue': {
  9649. url: URL_bricol_mountyhall + 'vue_form.php',
  9650. paramid: 'vue',
  9651. func: getVueScript,
  9652. extra_params: {
  9653. 'mode': 'vue_SP_Vue2',
  9654. 'screen_width': window.screen.width
  9655. }
  9656. },
  9657. 'Vue du CCM': {
  9658. url: URL_vue_CCM,
  9659. paramid: 'vue',
  9660. func: getVueScript,
  9661. extra_params: {
  9662. 'id': numTroll+';'+positionToString(getPosition())
  9663. }
  9664. },
  9665. 'Vue Gloumfs 2D': {
  9666. url: URL_vue_Gloumfs2D,
  9667. paramid: 'vue_mountyzilla',
  9668. func: getVueScript,
  9669. extra_params: {}
  9670. },
  9671. 'Vue Gloumfs 3D': {
  9672. url: URL_vue_Gloumfs3D,
  9673. paramid: 'vue_mountyzilla',
  9674. func: getVueScript,
  9675. extra_params: {}
  9676. },
  9677. 'Grouky Vue!': {
  9678. url: URL_vue_Grouky,
  9679. paramid: 'vue',
  9680. func: getVueScript,
  9681. extra_params: {
  9682. 'type_vue': 'V5b1'
  9683. }
  9684. },
  9685. /*'DEBUG': {
  9686. url: 'http://weblocal/testeur.php',
  9687. paramid: 'vue',
  9688. func: getVueScript,
  9689. extra_params: {}
  9690. }*/
  9691. };
  9692.  
  9693. function refresh2DViewButton() {
  9694. // = EventListener menu+bouton vue 2D
  9695. var vueext = document.getElementById('selectVue2D').value;
  9696. MY_setValue('VUEEXT',vueext);
  9697. var form = document.getElementById('viewForm');
  9698. form.innerHTML = '';
  9699. form.method = 'post';
  9700. form.action = vue2Ddata[vueext].url;
  9701. form.target = '_blank';
  9702. appendHidden(form, vue2Ddata[vueext].paramid, '');
  9703. for(var key in vue2Ddata[vueext].extra_params) {
  9704. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  9705. }
  9706. appendSubmit(form, 'Voir',
  9707. function() {
  9708. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  9709. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  9710. vue2Ddata[vueext].func();
  9711. }
  9712. );
  9713. }
  9714.  
  9715. function set2DViewSystem() {
  9716. // Initialise le système de vue 2D
  9717. // Recherche du point d'insertion
  9718. var center;
  9719. try {
  9720. // Roule 09/03/2019, encore un changement MH, je fais suivre comme je peux
  9721. center = document.getElementById('titre2');
  9722. // version initiale "pré-Roule"
  9723. if (!center) center = document.evaluate(
  9724. "//h2[@id='titre2']/following-sibling::center",
  9725. document, null, 9, null
  9726. ).singleNodeValue;
  9727. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  9728. if (!center) center = document.evaluate(
  9729. "//h2[@id='titre2']/following-sibling::div",
  9730. document, null, 9, null
  9731. ).singleNodeValue;
  9732.  
  9733. } catch(e) {
  9734. avertissement("Erreur d'initialisation du système de vue 2D");
  9735. window.console.error(traceStack(e, 'set2DViewSystem'));
  9736. return;
  9737. }
  9738.  
  9739. // Récupération de la dernière vue utilisée
  9740. var vueext = MY_getValue('VUEEXT');
  9741. if(!vueext || !vue2Ddata[vueext]) {
  9742. // sinon, la vue Bricol'Trolls est employée par défaut
  9743. vueext = 'Bricol\' Vue';
  9744. }
  9745.  
  9746. try {
  9747. // Création du sélecteur de vue externe
  9748. selectVue2D = document.createElement('select');
  9749. selectVue2D.id = 'selectVue2D';
  9750. selectVue2D.className = 'SelectboxV2';
  9751. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  9752. for(var view in vue2Ddata) {
  9753. appendOption(selectVue2D, view, view);
  9754. }
  9755. selectVue2D.value = vueext;
  9756. selectVue2D.onchange = refresh2DViewButton;
  9757.  
  9758. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  9759. var form = document.createElement('form');
  9760. form.id = 'viewForm';
  9761.  
  9762. // Insertion du système de vue
  9763. var table = document.createElement('table');
  9764. var tr = appendTr(table);
  9765. var td = appendTd(tr);
  9766. td.appendChild(selectVue2D);
  9767. td = appendTd(tr);
  9768. td.style.fontSize = '0px'; // gère le bug de l'extra character
  9769. td.appendChild(form);
  9770. if (center.id == 'titre2') { // 09/03/2019 nouvelle méthode
  9771. var eDiv = document.createElement('div');
  9772. eDiv.appendChild(table);
  9773. eDiv.style.witdth = '100%';
  9774. eDiv.style.textAlign = 'center';
  9775. table.style.width = '180px';
  9776. table.style.margin = '0 auto';
  9777. center.parentNode.insertBefore(eDiv,center.nextSibling);
  9778. } else { // ancienne méthode
  9779. center.insertBefore(table,center.firstChild);
  9780. insertBr(center.childNodes[1]);
  9781. }
  9782.  
  9783. // Appelle le handler pour initialiser le bouton de submit
  9784. refresh2DViewButton();
  9785. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  9786. } catch(e) {
  9787. avertissement("Erreur de traitement du système de vue 2D");
  9788. window.console.error(traceStack(e, 'set2DViewSystem'));
  9789. }
  9790. }
  9791.  
  9792. /* [functions] Tableau d'Infos */
  9793. function initialiseInfos() {
  9794. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  9795. var
  9796. infoTab = document.getElementsByName('LimitViewForm')[0].
  9797. getElementsByTagName('table')[0],
  9798. tbody = infoTab.tBodies[0],
  9799. thead = infoTab.createTHead(),
  9800. tr = appendTr(thead,'mh_tdtitre'),
  9801. td = appendTdText(tr,'INFORMATIONS',true),
  9802. span = document.createElement('span');
  9803.  
  9804. // Récupération de la position du joueur
  9805. try {
  9806. var strPos = document.evaluate(
  9807. ".//li/b/text()[contains(.,'X = ')]",
  9808. infoTab, null, 9, null
  9809. ).singleNodeValue.nodeValue;
  9810. // ***INIT GLOBALE*** currentPosition
  9811. currentPosition = getNumbers(strPos);
  9812. debugMZ("retrievePosition(): "+currentPosition);
  9813. } catch(e) {
  9814. // Si on ne trouve pas le "X ="
  9815. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  9816. }
  9817.  
  9818. // Récupération des portées (max et limitée) de la vue
  9819. try {
  9820. var
  9821. nodes = document.evaluate(
  9822. ".//li/b/text()[contains(.,'horizontalement') "+
  9823. "or contains(.,'verticalement')]",
  9824. infoTab, null, 7, null
  9825. ),
  9826. array = [];
  9827. for(var i=0 ; i<4 ; i++) {
  9828. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  9829. }
  9830. // ***INIT GLOBALE*** porteeVue
  9831. porteeVue = array;
  9832. } catch(e) {
  9833. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  9834. }
  9835.  
  9836. infoTab.id = 'infoTab'; // Pour scripts externes
  9837. tbody.id = 'corpsInfoTab';
  9838. tbody.rows[0].cells[0].colSpan = 2;
  9839. td.colSpan = 3;
  9840. td.onmouseover = function() {
  9841. this.style.cursor = 'pointer';
  9842. this.className = 'mh_tdpage';
  9843. };
  9844. td.onmouseout = function() {
  9845. this.className = 'mh_tdtitre';
  9846. };
  9847. td.onclick = function() {
  9848. toggleTableauInfos(false);
  9849. };
  9850.  
  9851. span.id = 'msgInfoTab';
  9852. span.style.display = 'none';
  9853. appendText(
  9854. span,
  9855. ' => Position : X = '+currentPosition[0]+
  9856. ', Y = '+currentPosition[1]+
  9857. ', N = '+currentPosition[2]+
  9858. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  9859. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  9860. true
  9861. );
  9862. td.appendChild(span);
  9863.  
  9864. tr = appendTr(tbody,'mh_tdpage');
  9865. td = appendTdText(tr,'EFFACER : ',true);
  9866. td.align = 'center';
  9867. td.className = 'mh_tdtitre';
  9868. td.width = 100;
  9869. td = appendTdCenter(tr,2);
  9870. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  9871. checkBoxGG = appendCheckBoxSpan(
  9872. td,'delgg',filtreTresors," Les GG'"
  9873. ).firstChild;
  9874. checkBoxCompos = appendCheckBoxSpan(
  9875. td,'delcomp',filtreTresors,' Les Compos'
  9876. ).firstChild;
  9877. checkBoxBidouilles = appendCheckBoxSpan(
  9878. td,'delbid',filtreTresors,' Les Bidouilles'
  9879. ).firstChild;
  9880. checkBoxIntangibles = appendCheckBoxSpan(
  9881. td,'delint',filtreTrolls,' Les Intangibles'
  9882. ).firstChild;
  9883. checkBoxGowapsA = appendCheckBoxSpan(
  9884. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  9885. ).firstChild;
  9886. checkBoxGowapsS = appendCheckBoxSpan(
  9887. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  9888. ).firstChild;
  9889. checkBoxEngages = appendCheckBoxSpan(
  9890. td,'delengage',filtreMonstres,' Les Engagés'
  9891. ).firstChild;
  9892. checkBoxLevels = appendCheckBoxSpan(
  9893. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  9894. ).firstChild;
  9895. checkBoxDiplo = appendCheckBoxSpan(
  9896. td,'delDiplo',refreshDiplo,' La Diplomatie'
  9897. ).firstChild;
  9898. checkBoxTrou = appendCheckBoxSpan(
  9899. td,'deltrou',filtreLieux,' Les Trous'
  9900. ).firstChild;
  9901. checkBoxMythiques = appendCheckBoxSpan(
  9902. td,'delmyth',filtreMonstres,' Les Mythiques'
  9903. ).firstChild;
  9904. if(MY_getValue('NOINFOEM')!='true') {
  9905. checkBoxEM = appendCheckBoxSpan(
  9906. td,'delem',filtreMonstres,' Les Composants EM'
  9907. ).firstChild;
  9908. }
  9909. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  9910. td,'deltres',filtreTresors,' Les Trésors non libres'
  9911. ).firstChild;
  9912. checkBoxTactique = appendCheckBoxSpan(
  9913. td,'deltactique',updateTactique,' Les Infos tactiques'
  9914. ).firstChild;
  9915.  
  9916. if(MY_getValue('INFOPLIE')) {
  9917. toggleTableauInfos(true);
  9918. }
  9919. }
  9920.  
  9921. function toggleTableauInfos(firstRun) {
  9922. var
  9923. msg = document.getElementById('msgInfoTab'),
  9924. corps = document.getElementById('corpsInfoTab'),
  9925. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9926. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  9927. if(!firstRun) {
  9928. infoplie = !infoplie;
  9929. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9930. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  9931. }
  9932. if(infoplie) {
  9933. msg.style.display = '';
  9934. corps.style.display = 'none';
  9935. } else {
  9936. msg.style.display = 'none';
  9937. corps.style.display = '';
  9938. }
  9939. }
  9940.  
  9941. /* [functions] Filtres */
  9942. function prepareFiltrage(ref,width) {
  9943. // = Initialise le filtre 'ref'
  9944. try {
  9945. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  9946. } catch(e) {
  9947. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  9948. return false;
  9949. }
  9950. if(width) { tdTitre.width = width; }
  9951. // Ajout du tr de Filtrage (masqué)
  9952. var tbody = tdTitre.parentNode.parentNode;
  9953. var tr = appendTr(tbody,'mh_tdpage');
  9954. tr.style.display = 'none';
  9955. tr.id = 'trFiltre'+ref;
  9956. var td = appendTd(tr);
  9957. td.colSpan = 5;
  9958. // Ajout du bouton de gestion de Filtrage
  9959. var tdBtn = insertAfterTd(tdTitre);
  9960. tdBtn.id = 'tdInsert'+ref;
  9961. var btn = appendButton(tdBtn,'Filtrer');
  9962. btn.id = 'btnFiltre'+ref;
  9963. btn.onclick = function() {
  9964. debutFiltrage(ref)
  9965. };
  9966. return td;
  9967. }
  9968.  
  9969. function debutFiltrage(ref) {
  9970. // = Handler de début de filtrage (filtre 'ref')
  9971. document.getElementById('trFiltre'+ref).style.display = '';
  9972. var btn = document.getElementById('btnFiltre'+ref);
  9973. btn.value = 'Annuler Filtre';
  9974. btn.onclick = function() {
  9975. finFiltrage(ref);
  9976. };
  9977. }
  9978.  
  9979. function finFiltrage(ref) {
  9980. // = Handler de fin de filtrage (filtre 'ref')
  9981. /* On réassigne le bouton 'Filtrer' */
  9982. document.getElementById('trFiltre'+ref).style.display = 'none';
  9983. var btn = document.getElementById('btnFiltre'+ref);
  9984. btn.value = 'Filtrer';
  9985. btn.onclick = function() {
  9986. debutFiltrage(ref);
  9987. };
  9988. /* Réinitialisation filtres */
  9989. document.getElementById('str'+ref).value = '';
  9990. switch(ref) {
  9991. case 'Monstres':
  9992. document.getElementById('nivMinMonstres').value = 0;
  9993. document.getElementById('nivMaxMonstres').value = 0;
  9994. document.getElementById('FamilleMonstres').value = 0;
  9995. break;
  9996. case 'Trolls':
  9997. document.getElementById('strGuildes').value = '';
  9998. }
  9999. /* Nettoyage (=lance le filtre) */
  10000. // Ici this = MZ.global = sandBox de travail de MZ
  10001. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  10002. //this['filtre'+ref]();
  10003. switch (ref) {
  10004. case 'Monstres':
  10005. filtreMonstres();
  10006. break;
  10007. case 'Trolls':
  10008. filtreTrolls();
  10009. break;
  10010. case 'Tresors':
  10011. filtreTresors();
  10012. break;
  10013. case 'Lieux':
  10014. filtreLieux();
  10015. break;
  10016. default:
  10017. window.console.log('cas incongru dans finFiltrage : ' + ref);
  10018. break;
  10019. }
  10020. }
  10021.  
  10022. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  10023. var bouton = appendButton(td,nomBouton,onClick);
  10024. appendText(td,'\u00a0');
  10025. var textbox = appendTextbox(td,'text',id,15,30);
  10026. textbox.onkeypress = function(event) {
  10027. try {
  10028. if(event.keyCode==13) {
  10029. event.preventDefault();
  10030. bouton.click();
  10031. }
  10032. }
  10033. catch(e){
  10034. window.alert(e)
  10035. }
  10036. };
  10037. }
  10038.  
  10039. function ajoutFiltreMenu(tr,id,onChange,liste) {
  10040. var select = document.createElement('select');
  10041. select.id = id;
  10042. select.onchange = onChange;
  10043. appendOption(select,0,'Aucun');
  10044. if (liste == undefined) {
  10045. for(var i=1 ; i<=60 ; i++) {
  10046. appendOption(select,i,i);
  10047. }
  10048. } else {
  10049. liste.forEach(function(f) {appendOption(select,f,f);});
  10050. }
  10051. tr.appendChild(select);
  10052. return select;
  10053. }
  10054.  
  10055. function ajoutDesFiltres() {
  10056. /* Monstres */
  10057. var td = prepareFiltrage('Monstres',120);
  10058. if(td) {
  10059. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  10060. appendText(td,'\u00a0\u00a0\u00a0');
  10061. appendText(td,'Niveau Min: ');
  10062. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  10063. appendText(td,'\u00a0');
  10064. appendText(td,'Niveau Max: ');
  10065. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  10066. appendText(td,'\u00a0');
  10067. appendText(td,'Famille: ');
  10068. comboBoxFamille = ajoutFiltreMenu(td,'FamilleMonstres',filtreMonstres,['Animal', 'Insecte','Démon','Humanoide','Monstre','Mort-Vivant']);
  10069. }
  10070. /* Trõlls */
  10071. td = prepareFiltrage('Trolls',50);
  10072. if(td) {
  10073. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  10074. appendText(td,'\u00a0\u00a0\u00a0');
  10075. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  10076. }
  10077. /* Trésors */
  10078. td = prepareFiltrage('Tresors',55);
  10079. if(td) {
  10080. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  10081. }
  10082. /* Lieux */
  10083. td = prepareFiltrage('Lieux',40);
  10084. if(td) {
  10085. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  10086. }
  10087. }
  10088.  
  10089. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  10090.  
  10091. /* [functions] Affichage de la colonne des niveaux */
  10092. function insertLevelColumn() {
  10093. // Appelé dans le code attaché à la page de vue et au click/unclick de la checkbox
  10094.  
  10095. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  10096. td.width = 25;
  10097. td.id = 'MZ_TITRE_NIVEAU_MONSTRE';
  10098. for(var i=1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10099. //window.console.log('nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', MZ_EtatCdMs.tr_monstres.length=' + MZ_EtatCdMs.tr_monstres.length); // debug Roule
  10100. td = insertTdText(getMonstreLevelNode(i), '-');
  10101. td.style = 'font-weight:bold;text-align:center;';
  10102. }
  10103. }
  10104.  
  10105. function toggleLevelColumn() { // Appelé par le code attaché à la page de vue et au click/unclick de la checkbox NOCDM
  10106. var eltMZ_TITRE_NIVEAU_MONSTRE = document.getElementById('MZ_TITRE_NIVEAU_MONSTRE'); // test si la colonne a déjà été ajoutée
  10107. if(saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  10108. if (!eltMZ_TITRE_NIVEAU_MONSTRE) return; // rien à faire si la colonne n'existe pas. C'est le cas à l'ouverture de la page avec NOCMD coché
  10109. // cacher tous les td
  10110. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10111. getMonstreLevelNode(i).style.display = 'none';
  10112. }
  10113. } else {
  10114. if (!eltMZ_TITRE_NIVEAU_MONSTRE) {
  10115. insertLevelColumn();
  10116. retrieveCDMs();
  10117. } else {
  10118. // afficher tous les td
  10119. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10120. getMonstreLevelNode(i).style.display = '';
  10121. }
  10122. }
  10123. }
  10124. }
  10125.  
  10126. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  10127. function basculeCDM(nom,id) {
  10128. // = Bascule l'affichage des popups CdM
  10129. if(MZ_EtatCdMs.listeCDM[id]) {
  10130. if(!document.getElementById('popupCDM'+id)) {
  10131. afficherCDM(nom, id);
  10132. } else {
  10133. cacherPopupCDM('popupCDM'+id);
  10134. }
  10135. } else {
  10136. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  10137. window.console.log("pas de CdM pour id=" + id + ', nom=' + nom);
  10138. }
  10139. }
  10140.  
  10141. function cacherPopupCDM(titre) {
  10142. var popup = document.getElementById(titre);
  10143. popup.parentNode.removeChild(popup);
  10144. }
  10145.  
  10146. function removeTableFromClickEvent() { // "this" est supposé être un <td> ou <th> d'une <table>
  10147. var table = this.parentNode.parentNode.parentNode; // <tr><tbody/thead/tfoot><table>
  10148. table.parentNode.removeChild(table);
  10149. }
  10150.  
  10151. /* DEBUG: Section à mettre à jour */
  10152. var selectionFunction;
  10153.  
  10154. function startDrag(evt) {
  10155. winCurr = this.parentNode;
  10156. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  10157. offsetX = evt.pageX - parseInt( winCurr.style.left );
  10158. offsetY = evt.pageY - parseInt( winCurr.style.top );
  10159. selectionFunction = document.body.style.MozUserSelect;
  10160. document.body.style.MozUserSelect = 'none';
  10161. winCurr.style.MozUserSelect = 'none';
  10162. return false;
  10163. }
  10164.  
  10165. function stopDrag(evt) {
  10166. winCurr.style.MozUserSelect = selectionFunction;
  10167. document.body.style.MozUserSelect = selectionFunction;
  10168. winCurr = null;
  10169. }
  10170.  
  10171. function drag(evt) {
  10172. if(winCurr==null) { return; }
  10173. evt = evt || window.event;
  10174. winCurr.style.left = (evt.pageX - offsetX)+'px';
  10175. winCurr.style.top = (evt.pageY - offsetY)+'px';
  10176. return false;
  10177. }
  10178. /* FIN DEBUG */
  10179. if(!isPage("MH_Play/Play_equipement")) {
  10180. // Conflit overlib/Tout_MZ:
  10181. // Double définition du "onmousemove" sur la page d'équipement
  10182. document.onmousemove = drag;
  10183. }
  10184.  
  10185. function afficherCDM(nom,id) {
  10186. // Crée la table de CdM du mob n° id
  10187. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10188. /* Début création table */
  10189. var table = createCDMTable(id,nom,donneesMonstre, removeTableFromClickEvent);
  10190. /* Ajout du titre avec gestion Drag & Drop */
  10191. var tr = table.firstChild;
  10192. tr.style.cursor = 'move';
  10193. tr.onmousedown = startDrag;
  10194. tr.onmouseup = stopDrag;
  10195. /* à supprimer, remplacé par un "x" sur l'entête
  10196. // Ajout du bouton "Fermer"
  10197. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  10198. tr.style.cursor = 'pointer';
  10199. tr.onmouseover = function() {
  10200. this.className = 'mh_tdpage';
  10201. };
  10202. tr.onmouseout = function() {
  10203. this.className = 'mh_tdtitre';
  10204. };
  10205. tr.idcdm = id;
  10206. tr.onclick = function() {
  10207. cacherPopupCDM('popupCDM'+this.idcdm);
  10208. this.className = 'mh_tdtitre';
  10209. };
  10210. td = appendTdText(tr,'Fermer',true);
  10211. td.colSpan = 2;
  10212. td.style = 'text-align:center;';
  10213. */
  10214. table.id = 'popupCDM'+id;
  10215. table.style.position = 'fixed';
  10216. table.style.zIndex = 1;
  10217. //var topY = +(300+(30*MZ_EtatCdMs.yIndexCDM))%(30*Math.floor((window.innerHeight-400)/30));
  10218. table.style.left = +(window.innerWidth-365)+'px';
  10219. table.style.width = '300px';
  10220. /* Fin création table & Affichage */
  10221. document.body.appendChild(table);
  10222. var topY = 90 + (30*MZ_EtatCdMs.yIndexCDM);
  10223. //window.console.log('topY=' + topY + ', offsetHeight=' + table.offsetHeight + ', innerHeight=' + window.innerHeight);
  10224. if ((topY + table.offsetHeight) > window.innerHeight) {
  10225. MZ_EtatCdMs.yIndexCDM = 0; // on se repositionne en haut s'il n'y a pas assez de place
  10226. topY = 90;
  10227. } else {
  10228. MZ_EtatCdMs.yIndexCDM++; // décalage pour la fois suivante
  10229. }
  10230. table.style.top = topY + 'px';
  10231. }
  10232.  
  10233. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  10234. function initPopupVue() {
  10235. popup = document.createElement('div');
  10236. popup.id = 'popup';
  10237. popup.className = 'mh_textbox';
  10238. popup.style =
  10239. 'position: absolute;'+
  10240. 'border: 1px solid #000000;'+
  10241. 'visibility: hidden;'+
  10242. 'display: inline;'+
  10243. 'z-index: 3;'+
  10244. 'max-width: 400px;';
  10245. document.body.appendChild(popup);
  10246. }
  10247.  
  10248. function showPopupError(sHTML) {
  10249. window.console.log('[MZ] affichage PopupError ' + sHTML);
  10250. var divpopup = document.createElement('div');
  10251. divpopup.id = 'divpopup';
  10252. divpopup.style =
  10253. 'position: fixed;'+
  10254. 'border: 3px solid #000000;'+
  10255. 'top: 300px;left: 10px;'+
  10256. 'background-color: red;'+
  10257. 'color: white;'+
  10258. 'font-size: xx-large;'+
  10259. 'z-index: 200;';
  10260. divpopup.innerHTML = sHTML;
  10261. var divcroix = document.createElement('div');
  10262. divcroix.style =
  10263. 'position: absolute;'+
  10264. 'top: 0;right: 0;'+
  10265. 'color: inherit;'+
  10266. 'font-size: inherit;'+
  10267. 'cursor: pointer;'+
  10268. 'z-index: 201;';
  10269. divcroix.innerHTML = "X";
  10270. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  10271. document.body.appendChild(divpopup);
  10272. divpopup.appendChild(divcroix);
  10273. }
  10274.  
  10275. function retrieveCDMs() {
  10276. // Récupère les CdM disponibles dans la BDD
  10277. // Lancé uniquement sur toggleLevelColumn
  10278. if(checkBoxLevels.checked) return;
  10279. // Roule, message si l'utilisateur a décoché "Menu d'actions contextuelles"
  10280. if (!MZ_EtatCdMs.tr_monstres[0].cells[2].innerHTML.match(/r[eéè]f/i)) {
  10281. 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);
  10282. return;
  10283. }
  10284. if (MZ_EtatCdMs.nbMonstres < 1) return;
  10285.  
  10286. var tReq = [];
  10287. var nbReq = 0;
  10288. var prevLastIndexDone = MZ_EtatCdMs.lastIndexDone;
  10289. for (var i=prevLastIndexDone+1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10290. //tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  10291. // ne pas demander pour les Gowaps
  10292. var nom = getMonstreNom(i);
  10293. if (nom.match(/^[^\[]*Gowap/i)) { // le mot Gowap peut être précédé par un template (qui ne contient donc pas [)
  10294. getMonstreLevelNode(i).innerHTML = '';
  10295. continue;
  10296. }
  10297. tReq.push({'index':i, 'id':getMonstreID(i), 'nom':nom});
  10298. nbReq++;
  10299. if (nbReq >= 500) break; // limitation pour ne pas faire attendre, et aussi car on a un dépassement mémoire coté serveur si c'est trop gros
  10300. }
  10301. MZ_EtatCdMs.lastIndexDone = i;
  10302. var startAjaxCdM = new Date();
  10303. window.console.log('[MZ] ' + MZ_formatDateMS() + ' lancement AJAX ' + nbReq + ' demandes niveaux monstres V2');
  10304.  
  10305. FF_XMLHttpRequest({
  10306. method: 'POST',
  10307. url: URL_MZgetCaracMonstre,
  10308. headers : {
  10309. 'Content-type':'application/x-www-form-urlencoded'
  10310. },
  10311. //data: 'l=' + tReq.join("\n"),
  10312. data: 'l=' + JSON.stringify(tReq),
  10313. trace: 'demande niveaux monstres V2',
  10314. onload: function(responseDetails) {
  10315. try {
  10316. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  10317. if (responseDetails.status == 0) return;
  10318. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  10319. var texte = responseDetails.responseText;
  10320. var infos = JSON.parse(texte);
  10321. displayScriptTime(new Date().getTime()-date_debut.getTime(), 'Analyse des CdM MZ');
  10322. if(infos.length==0) return;
  10323.  
  10324. // ajouter les styles CSS pour les popup
  10325. var mystyle = document.createElement('style');
  10326. mystyle.type = 'text/css';
  10327. var sCSS = '.MZtooltip {position: relative;color:red;text-align:center;}\n';
  10328. sCSS += '.MZtooltip .MZtooltiptext {visibility: hidden;width: 250px;padding: 5px 0;border:solid 1px;position: absolute;z-index: 1;color:black;background-color:white}\n';
  10329. sCSS += '.MZtooltip:hover .MZtooltiptext {visibility: visible;}\n';
  10330. mystyle.innerHTML = sCSS;
  10331. document.getElementsByTagName('head')[0].appendChild(mystyle);
  10332.  
  10333. // if (MY_DEBUG) {
  10334. // for (var i = 0; i < 20; i++) window.console.log('infos[' + i + ']=' + JSON.stringify(infos[i]));
  10335. // }
  10336. var begin2, end2, index;
  10337. for(var j=0 ; j<infos.length ; j++) {
  10338. var info = infos[j];
  10339. if (info.index == undefined) continue;
  10340. var eTdLevel = getMonstreLevelNode(info.index)
  10341. this.className = 'mh_tdpage';
  10342. var myColor = undefined;
  10343. if (info.niv != undefined && info.niv.max == -1 && info.Mode != 'cdm') {
  10344. eTdLevel.className = "MZtooltip";
  10345. eTdLevel.style.color = "black";
  10346. eTdLevel.innerHTML = 'Var.<span class="MZtooltiptext">Ce monstre est variable.<br />On ne peut pas avoir d\'information sans CdM.</span>';
  10347. } else if (!(info && info.esq)) {
  10348. //if (MY_DEBUG) window.console.log("pas d'esquive id=" + info.id + ", index=" + info.index);
  10349. eTdLevel.className = "MZtooltip";
  10350. eTdLevel.innerHTML = mkMinMaxHTML(info.niv) + '<span class="MZtooltiptext">Désolé, pas de CdM dans MZ pour ce type de monstre (même âge, même template).<br />Vous pouvez aider en envoyant une CdM à MZ.</span>';
  10351. } else {
  10352. eTdLevel.innerHTML = mkMinMaxHTML(info.niv);
  10353. //info.iTR = info.index; // Roule 29/04/2017 permet de récupérer la position du monstres dans analyseTactique (pour calcul de distance pour le PM). 15/11/2019 index contient l'info
  10354. myColor = MZ_CdMColorFromMode(info);
  10355. eTdLevel.style.cursor = 'pointer';
  10356. eTdLevel.onclick = function() {
  10357. basculeCDM(
  10358. getMonstreNomByTR(this.parentNode),
  10359. getMonstreIDByTR(this.parentNode)
  10360. );
  10361. };
  10362. }
  10363. MZ_EtatCdMs.listeCDM[info.id] = info;
  10364. if (myColor) eTdLevel.style.color = myColor;
  10365. /* Roule' à étudier plus tard, cette différence de style selon la diplo...
  10366. eTdLevel.onmouseover = function() {
  10367. this.className = 'mh_tdtitre';
  10368. };
  10369. eTdLevel.onmouseout = function() {
  10370. if(this.parentNode.diploActive=='oui') {
  10371. this.className = '';
  10372. } else {
  10373. this.className = 'mh_tdpage';
  10374. }
  10375. };
  10376. */
  10377. }
  10378. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  10379. computeMission(prevLastIndexDone+1, MZ_EtatCdMs.nbMonstres);
  10380. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  10381. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  10382. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  10383. } catch(e) {
  10384. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZgetCaracMonstre+'\n'+texte);
  10385. }
  10386. //if (MY_DEBUG) window.console.log('id=6376829, info=' + JSON.stringify(MZ_EtatCdMs.listeCDM[6376829]));
  10387. MZ_EtatCdMs.isCDMsRetrieved=true;
  10388. // afficher/supprimer le bouton pour demander la suite
  10389. var eltBoutonSuite = document.getElementById('MZ_boutonSuiteCdM');
  10390. window.console.log('[MZ] lastIndexDone=' + MZ_EtatCdMs.lastIndexDone + ', nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', eltBoutonSuite=' + eltBoutonSuite);
  10391. if (MZ_EtatCdMs.lastIndexDone < MZ_EtatCdMs.nbMonstres) {
  10392. if (eltBoutonSuite) {
  10393. while (eltBoutonSuite.firstChild) eltBoutonSuite.removeChild(eltBoutonSuite.firstChild); // vider
  10394. appendText(eltBoutonSuite, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10395. retrieveCDMs(); // lancer la suite
  10396. } else {
  10397. eltBoutonSuite = document.createElement('div');
  10398. eltBoutonSuite.id = 'MZ_boutonSuiteCdM';
  10399. eltBoutonSuite.style.position = 'fixed';
  10400. eltBoutonSuite.style.border = '1px solid black';
  10401. eltBoutonSuite.style.top = '10px';
  10402. eltBoutonSuite.style.right = '10px';
  10403. //eltBoutonSuite.style.backgroundColor = 'white';
  10404. eltBoutonSuite.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/fond/fond2.jpg")';
  10405. eltBoutonSuite.style.color = 'black';
  10406. eltBoutonSuite.style.fontSize = 'large';
  10407. eltBoutonSuite.style.padding = '5px';
  10408. eltBoutonSuite.style.borderRadius = '10px';
  10409. eltBoutonSuite.style.cursor = 'pointer';
  10410. eltBoutonSuite.style.zIndex = '500';
  10411. appendText(eltBoutonSuite, nbReq + ' CdM(s) récupérées');
  10412. appendBr(eltBoutonSuite); // C'est plus classe que d'utiliser innerHTML ☺
  10413. appendText(eltBoutonSuite, 'Cliquer ici pour demander les CdMs');
  10414. appendBr(eltBoutonSuite);
  10415. appendText(eltBoutonSuite, 'des ' + MZ_EtatCdMs.nbMonstres + ' monstres');
  10416. eltBoutonSuite.title = 'Shift-Click pour faire disparaitre ce bouton sans demander les CdMs';
  10417. eltBoutonSuite.onclick = MZ_SuiteCdMs;
  10418. document.body.appendChild(eltBoutonSuite);
  10419. }
  10420. } else {
  10421. if (eltBoutonSuite) eltBoutonSuite.parentNode.removeChild(eltBoutonSuite);
  10422. }
  10423. },
  10424. });
  10425. //str = '';
  10426. //begin = i+1;
  10427. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  10428. }
  10429.  
  10430. function MZ_CdMColorFromMode(info) {
  10431. switch (info.Mode) {
  10432. case 'cdm':
  10433. return 'blue';
  10434. case 'stat':
  10435. return 'purple';
  10436. case 'statV1':
  10437. return 'orange';
  10438. }
  10439. }
  10440.  
  10441. function MZ_SuiteCdMs(e) { // handler du click sur le bouton pour demander la suite des CdMs
  10442. var evt = e || window.event;
  10443. if (evt.shiftKey) {
  10444. this.parentNode.removeChild(this);
  10445. return;
  10446. }
  10447. while (this.firstChild) this.removeChild(this.firstChild); // vider
  10448. appendText(this, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10449. this.title = 'Shift-Click pour faire disparaitre ce bouton';
  10450. this.style.cursor = ''; // default
  10451. this.onclick = MZ_SupprBoutonCdMs;
  10452. retrieveCDMs();
  10453. }
  10454.  
  10455. function MZ_SupprBoutonCdMs(e) {
  10456. var evt = e || window.event;
  10457. if (evt.shiftKey) {
  10458. this.parentNode.removeChild(this);
  10459. }
  10460. }
  10461.  
  10462. function mkMinMaxHTML(oMM) {
  10463. if (oMM == undefined) return '';
  10464. if (oMM.min == undefined) {
  10465. if (oMM.max == undefined) {
  10466. return;
  10467. } else {
  10468. return "\u2A7D" + oMM.max; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  10469. }
  10470. } else {
  10471. if (oMM.max == undefined) {
  10472. return "\u2A7E" + oMM.min; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  10473. } else if (oMM.min == oMM.max) {
  10474. return oMM.min;
  10475. } else if (oMM.min < oMM.max) {
  10476. return oMM.min + '-' + oMM.max;
  10477. } else {
  10478. return '<span style="color:red">' + oMM.min + '-' + oMM.max + '</span>';
  10479. }
  10480. }
  10481. }
  10482.  
  10483. function computeMission(begin,end) {
  10484. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  10485. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  10486. computeVLC(begin,end);
  10487. //+++window.console.log('computeMission, après computeVLC');
  10488. if(!begin) begin=1;
  10489. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10490. var str = MY_getValue(numTroll+'.MISSIONS');
  10491. if(!str) { return; }
  10492.  
  10493. var urlImg = URL_MZimg+'mission.png';
  10494. var obMissions = JSON.parse(str);
  10495.  
  10496. for(var i=end ; i>=begin ; i--) {
  10497. var mess = '';
  10498. var bPeutEtreIcone = false;
  10499. for(var num in obMissions) {
  10500. var mobMission = false;
  10501. var mobMissionPeutEtre = undefined;
  10502. switch(obMissions[num].type) {
  10503. case 'Race':
  10504. var race = epure(obMissions[num].race.toLowerCase());
  10505. var nom = epure(getMonstreNom(i).toLowerCase());
  10506. if(nom.indexOf(race)!=-1) {
  10507. if (race == 'crasc') {
  10508. if (nom.indexOf('medius')!=-1) {
  10509. // pas éligible
  10510. } else if (nom.indexOf('maexus')!=-1) {
  10511. // pas éligible
  10512. } else if (nom.indexOf('parasitus')!=-1) {
  10513. if (nom.match(/^crasc parasitus \[/ui)) {
  10514. // on ne peut pas savoir
  10515. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10516. + 'Faire une CdM. Si la portée de pouvoir est "automatique", il s\'agit d\'un "Crasc", si elle est "au toucher", il s\'agit d\'un "Crasc Parasitus"';
  10517. } else {
  10518. // c'est un monstre de la race des Crasc Parasitus
  10519. mobMission = false;
  10520. }
  10521. } else {
  10522. mobMission = true;
  10523. }
  10524. } else if (race == 'crasc parasitus') {
  10525. if (nom.match(/^crasc parasitus \[/ui)) {
  10526. // on ne peut pas savoir
  10527. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10528. + 'Faire une CdM. Si la portée de pouvoir est "automatique", il s\'agit d\'un "Crasc", si elle est "au toucher", il s\'agit d\'un "Crasc Parasitus"';
  10529. } else {
  10530. // c'est un monstre de la race des Crasc Parasitus
  10531. mobMission = true;
  10532. }
  10533. } else if (race == 'shai') {
  10534. if (nom.match(/abishai/ui)) {
  10535. mobMission = false;
  10536. } else {
  10537. mobMission = true;
  10538. }
  10539. } else if (race == 'ombre') {
  10540. if (nom.match(/roche/ui)) {
  10541. mobMission = false;
  10542. } else {
  10543. mobMission = true;
  10544. }
  10545. } else if (race == 'geck\'oo') {
  10546. if (nom.match(/majestueux/ui)) {
  10547. mobMission = false;
  10548. } else {
  10549. mobMission = true;
  10550. }
  10551. } else if (race == 'bouj\'dla') {
  10552. if (nom.match(/placide/ui)) {
  10553. mobMission = false;
  10554. } else {
  10555. mobMission = true;
  10556. }
  10557. } else {
  10558. mobMission = true;
  10559. }
  10560. }
  10561. break;
  10562. case 'Niveau':
  10563. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10564. if (donneesMonstre) {
  10565. var nivMimi = Number(obMissions[num].niveau);
  10566. var mod = obMissions[num].mod; // mission nivMimi±mod si mod est numérique, sinon, c'est >= nivMimi
  10567. if (isNaN(mod)) {
  10568. var minMimi = nivMimi;
  10569. var maxMimi = nivMimi + 999999;
  10570. } else {
  10571. var minMimi = nivMimi - mod;
  10572. var maxMimi = nivMimi + mod;
  10573. }
  10574. if (donneesMonstre.niv) { // nouveau mode
  10575. if (donneesMonstre.niv.max && donneesMonstre.niv.min) {
  10576. if (donneesMonstre.niv.max <= maxMimi && donneesMonstre.niv.min >= minMimi) {
  10577. mobMission = true;
  10578. } else if (!(donneesMonstre.niv.max < minMimi || donneesMonstre.niv.min > maxMimi)) {
  10579. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10580. if (isDEV) mobMissionPeutEtre += '\nMonstre=(' + donneesMonstre.niv.min + ', ' + donneesMonstre.niv.max + '), mimi=(' + minMimi + ', ' + maxMimi + ')'
  10581. }
  10582. } else if (donneesMonstre.niv.max) {
  10583. if (donneesMonstre.niv.max >= minMimi) {
  10584. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10585. }
  10586. } else if (donneesMonstre.niv.min) {
  10587. if (donneesMonstre.niv.min <= maxMimi) {
  10588. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10589. }
  10590. }
  10591. }
  10592. }
  10593. break;
  10594. case 'Famille':
  10595. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10596. if(donneesMonstre && donneesMonstre.fam) {
  10597. var familleMimi = epure(obMissions[num].famille.toLowerCase()).replace(/[']/g,''); // Roule 27/02/2019 simple quote dans les familles
  10598. var familleMob = epure(donneesMonstre.fam.toLowerCase());
  10599. if(familleMob.indexOf(familleMimi)!=-1) {
  10600. mobMission = true;
  10601. }
  10602. }
  10603. break;
  10604. case 'Pouvoir':
  10605. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10606. if(donneesMonstre && donneesMonstre.pouv) {
  10607. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  10608. var pvrMob = epure(donneesMonstre.pouv.toLowerCase());
  10609. if(pvrMob.indexOf(pvrMimi)!=-1) {
  10610. mobMission = true;
  10611. }
  10612. }
  10613. }
  10614. if(mobMission) {
  10615. mess += mess ? '\n\n' : '';
  10616. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  10617. } else if (mobMissionPeutEtre !== undefined) {
  10618. mess += mess ? '\n\n' : '';
  10619. mess += mobMissionPeutEtre + '\n';
  10620. bPeutEtreIcone = true;
  10621. mess += 'Mission '+ num + ' :\n'+obMissions[num].libelle;
  10622. }
  10623. }
  10624. if(mess) {
  10625. var td = getMonstreNomNode(i);
  10626. appendText(td,' ');
  10627. var myURL;
  10628. if (bPeutEtreIcone) {
  10629. myURL = URL_MZimg+'missionX.png';
  10630. } else {
  10631. myURL = urlImg;
  10632. }
  10633. td.appendChild(createImage(myURL,mess));
  10634. }
  10635. }
  10636. }
  10637.  
  10638. function computeVLC(begin,end) {
  10639. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  10640. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  10641. computeTactique(begin,end);
  10642. //+++window.console.log('computeVLC, après computeTactique');
  10643. if(!begin) begin=1;
  10644. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10645. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  10646. if(!cache)
  10647. return false;
  10648. var urlImg = URL_MZimg + "oeil.png";
  10649. for(var i = end; i >= begin;i--)
  10650. {
  10651. var id = getMonstreID(i);
  10652. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10653. var vlc = false;
  10654. /* ancien mode à supprimer
  10655. if(donneesMonstre && donneesMonstre.length>12)
  10656. {
  10657. if(donneesMonstre[12]==1) vlc = 1;
  10658. }
  10659. // */
  10660. // nouveau mode
  10661. if (donneesMonstre && donneesMonstre.vlc) {
  10662. //if (donneesMonstre) window.console.log('computeVLC i=' + i + ' id=' + id + ' ' + JSON.stringify(donneesMonstre));
  10663. var td = getMonstreNomNode(i);
  10664. td.appendChild(document.createTextNode(" "));
  10665. td.appendChild(createImage(urlImg, "Voit le caché"));
  10666. }
  10667. if (donneesMonstre && donneesMonstre.gen) {
  10668. switch (donneesMonstre.gen) {
  10669. case 1:
  10670. var imgPh = URL_MZimg + "Phoenix1.png";
  10671. var txtPh = 'Phœnix de première génération';
  10672. break;
  10673. case 2:
  10674. var imgPh = URL_MZimg + "Phoenix2.png";
  10675. var txtPh = 'Phœnix de deuxième génération';
  10676. break;
  10677. case 3:
  10678. var imgPh = URL_MZimg + "Phoenix3.png";
  10679. var txtPh = 'Phœnix de troisième génération';
  10680. break;
  10681. case 23:
  10682. var imgPh = URL_MZimg + "Phoenix23.png";
  10683. var txtPh = 'Phœnix de deuxième ou troisième génération';
  10684. break;
  10685. }
  10686. var td = getMonstreNomNode(i);
  10687. td.appendChild(document.createTextNode(" "));
  10688. var img = td.appendChild(createImage(imgPh, txtPh));
  10689. img.style.height = '15px';
  10690. img.style.width = 'auto';
  10691. }
  10692. }
  10693. }
  10694.  
  10695. /* appelé
  10696. par updateTactique
  10697. par initialiseInfos
  10698. par do_vue
  10699. par computeVLC
  10700. par computeMission
  10701. par filtreMonstres
  10702. par retrieveCDMs
  10703. */
  10704. function computeTactique(begin, end) {
  10705. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  10706. try {
  10707. if(!begin) begin = 1;
  10708. if(!end) end = MZ_EtatCdMs.nbMonstres;
  10709. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  10710. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10711. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  10712. if(noTactique || !isProfilActif()) return;
  10713. //+++window.console.log('computeTactique, après isProfilActif');
  10714.  
  10715. for(var j=end ; j>=begin ; j--) {
  10716. var id = getMonstreID(j);
  10717. var nom = getMonstreNom(j);
  10718. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10719. var bShowTactique = false;
  10720. //if (isDEV) {
  10721. if (donneesMonstre && donneesMonstre.esq) bShowTactique = true;
  10722. // } else {
  10723. // if(donneesMonstre && nom.indexOf('Gowap')==-1) bShowTactique = true;
  10724. // }
  10725. if (bShowTactique) {
  10726. var td = getMonstreNomNode(j);
  10727. appendText(td,' ');
  10728. td.appendChild(
  10729. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  10730. );
  10731. }
  10732. }
  10733. }
  10734. catch(e) {
  10735. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  10736. }
  10737. filtreMonstres();
  10738. }
  10739.  
  10740. function updateTactique() {
  10741. // = Handler checkBox noTactique
  10742. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10743. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  10744. if(!MZ_EtatCdMs.isCDMsRetrieved) return;
  10745. //+++window.console.log('updateTactique, isCDMsRetrieved=' + MZ_EtatCdMs.isCDMsRetrieved);
  10746.  
  10747. if(noTactique) {
  10748. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  10749. var tr = getMonstreNomNode(i);
  10750. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  10751. tr, null, 9, null).singleNodeValue;
  10752. if(img) {
  10753. img.parentNode.removeChild(img.previousSibling);
  10754. img.parentNode.removeChild(img);
  10755. }
  10756. }
  10757. }
  10758. else
  10759. computeTactique();
  10760. }
  10761.  
  10762. function filtreMonstres() {
  10763. // = Handler universel pour les fonctions liées aux monstres
  10764. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  10765. urlEnchantImg = URL_MZimg+'enchant.png';
  10766.  
  10767. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  10768. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  10769. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  10770. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  10771. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  10772. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  10773. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  10774. var famille = saveComboBox(comboBoxFamille,'FAMILLEMONSTRE');
  10775. // old/new : détermine s'il faut ou non nettoyer les tr
  10776. var oldNOEM = true, noEM = true;
  10777. if(MY_getValue('NOINFOEM')!='true') {
  10778. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  10779. }
  10780. // Filtrage par nom
  10781. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  10782. // Génère la liste des mobs engagés (si filtrés)
  10783. if(noEngages && !isEngagesComputed) {
  10784. for(var i=nbTrolls ; i>0 ; i--) {
  10785. var pos = getTrollPosition(i);
  10786. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  10787. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  10788. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  10789. }
  10790. isEngagesComputed = true;
  10791. }
  10792.  
  10793. /*** FILTRAGE ***/
  10794. /* À computer :
  10795. * - EM (nom suffit)
  10796. * - Enchant (nom suffit)
  10797. * - Mission (nécessite CdM)
  10798. * - mob VlC (nécessite CdM)
  10799. * Sans computation :
  10800. * - Gowap ? engagé ?
  10801. */
  10802. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  10803. var pos = getMonstrePosition(i);
  10804. var nom = getMonstreNom(i).toLowerCase();
  10805. if(noEM!=oldNOEM) {
  10806. if(noEM) {
  10807. // Si noEM passe de false à true, on nettoie les td "Nom"
  10808. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  10809. var tr = getMonstreNomNode(i);
  10810. while(tr.childNodes.length>1) {
  10811. tr.removeChild(tr.childNodes[1]);
  10812. }
  10813. } else {
  10814. var tr = getMonstreNomNode(i);
  10815. var TypeMonstre=getEM(nom);
  10816. if(TypeMonstre!='') {
  10817. var infosCompo=compoMobEM(TypeMonstre);
  10818. if(infosCompo.length>0) {
  10819. tr.appendChild(document.createTextNode(' '));
  10820. tr.appendChild(createImage(urlImg, infosCompo));
  10821. }
  10822. }
  10823. }
  10824. }
  10825. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  10826. var texte = getInfoEnchantementFromMonstre(nom);
  10827. if(texte!='') {
  10828. var td = getMonstreNomNode(i);
  10829. td.appendChild(document.createTextNode(' '));
  10830. td.appendChild(createImage(urlEnchantImg, texte));
  10831. }
  10832. }
  10833.  
  10834. var dataV2 = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10835. MZ_EtatCdMs.tr_monstres[i].style.display = (
  10836. noGowapsS &&
  10837. nom.indexOf('gowap sauvage')!=-1 &&
  10838. getMonstreDistance(i)>1
  10839. ) || (
  10840. noGowapsA &&
  10841. nom.indexOf('gowap apprivoisé')!=-1 &&
  10842. getMonstreDistance(i)>1
  10843. ) || (
  10844. noEngages &&
  10845. getMonstreDistance(i)!=0 &&
  10846. listeEngages[pos[0]] &&
  10847. listeEngages[pos[0]][pos[1]] &&
  10848. listeEngages[pos[0]][pos[1]][pos[2]]
  10849. ) || (
  10850. strMonstre!='' &&
  10851. nom.indexOf(strMonstre)==-1
  10852. ) || (
  10853. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  10854. getMonstreDistance(i)>1 &&
  10855. nom.toLowerCase().indexOf("kilamo")==-1
  10856. ) || (
  10857. famille!='0' &&
  10858. dataV2 &&
  10859. dataV2.fam &&
  10860. dataV2.fam != famille
  10861. ) ? 'none' : '';
  10862. }
  10863.  
  10864. if(MY_getValue('NOINFOEM')!='true') {
  10865. if(noEM != oldNOEM) {
  10866. if(noEM && MZ_EtatCdMs.isCDMsRetrieved) computeMission();
  10867. }
  10868. oldNOEM = noEM;
  10869. }
  10870.  
  10871. needComputeEnchantement = false;
  10872. }
  10873.  
  10874.  
  10875. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  10876.  
  10877. function filtreTrolls() {
  10878. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  10879. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  10880. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  10881. for(var i=1 ; i<=nbTrolls ; i++) {
  10882. tr_trolls[i].style.display = (
  10883. noIntangibles &&
  10884. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  10885. ) || (
  10886. strTroll!='' &&
  10887. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  10888. ) || (
  10889. strGuilde!='' &&
  10890. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  10891. ) ? 'none' : '';
  10892. }
  10893. }
  10894.  
  10895. /* [functions] Bulle PX Trolls */
  10896. var bulle;
  10897.  
  10898. function initPXTroll() {
  10899. bulle = document.createElement('div');
  10900. bulle.id = 'bulle';
  10901. bulle.className = 'mh_textbox';
  10902. bulle.style =
  10903. 'position: absolute;'+
  10904. 'border: 1px solid #000000;'+
  10905. 'visibility: hidden;'+
  10906. 'display: inline;'+
  10907. 'z-index: 2;';
  10908. document.body.appendChild(bulle);
  10909.  
  10910. for(var i=nbTrolls ; i>0 ; i--) {
  10911. var td_niv = getTrollNivNode(i);
  10912. td_niv.onmouseover = showPXTroll;
  10913. td_niv.onmouseout = hidePXTroll;
  10914. }
  10915. }
  10916.  
  10917. function showPXTroll(evt) {
  10918. var lvl = this.firstChild.nodeValue;
  10919. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  10920. bulle.style.left = evt.pageX+15+'px';
  10921. bulle.style.top = evt.pageY+'px';
  10922. bulle.style.visibility = 'visible';
  10923. }
  10924.  
  10925. function hidePXTroll() {
  10926. bulle.style.visibility = 'hidden';
  10927. }
  10928.  
  10929. /* [functions] Envoi PX / MP */
  10930. function putBoutonPXMP() {
  10931. // Bouton d'initialisation du mode Envoi
  10932. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  10933. var td = document.getElementById('tdInsertTrolls');
  10934. if(!td) { return; }
  10935. td.width = 100;
  10936. td = insertAfterTd(td);
  10937. td.style.verticalAlign = 'top';
  10938. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  10939. bouton.id = 'btnEnvoi';
  10940. }
  10941.  
  10942. function prepareEnvoi() {
  10943. // = 1er Handler du bouton d'envoi
  10944.  
  10945. /* Ajout de la colonne des CheckBoxes */
  10946. var td = insertTdText(getTrollNomNode(0),'');
  10947. td.width = 5;
  10948. for(var i=nbTrolls ; i>0 ; i--) {
  10949. td = insertTd(getTrollNomNode(i));
  10950. appendCheckBox(td,'envoi'+i);
  10951. }
  10952.  
  10953. /* Ajout du radio de choix PX ou MP */
  10954. var btnEnvoi = document.getElementById('btnEnvoi');
  10955. if(!btnEnvoi) { return; }
  10956. var tdEnvoi = btnEnvoi.parentNode;
  10957. appendText(tdEnvoi,' ');
  10958. var span = document.createElement('span');
  10959. span.style.whiteSpace = 'nowrap';
  10960. var radioElt = document.createElement('input');
  10961. radioElt.type = 'radio';
  10962. radioElt.name = 'envoiPXMP';
  10963. radioElt.id = 'radioPX';
  10964. span.appendChild(radioElt);
  10965. appendText(span,' des PX ');
  10966. radioElt = document.createElement('input');
  10967. radioElt.type = 'radio';
  10968. radioElt.name = 'envoiPXMP';
  10969. radioElt.checked = true;
  10970. span.appendChild(radioElt);
  10971. appendText(span,' un MP');
  10972. tdEnvoi.appendChild(span);
  10973.  
  10974. /* Insertion du bouton Annuler */
  10975. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  10976.  
  10977. /* Modification de l'effet du bouton Envoi */
  10978. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  10979. }
  10980.  
  10981. function annuleEnvoi() {
  10982. // = Handler bouton Annuler
  10983. /* Nettoyage du td du bouton Envoi */
  10984. var btnEnvoi = document.getElementById('btnEnvoi');
  10985. var tdEnvoi = btnEnvoi.parentNode;
  10986. while(tdEnvoi.firstChild) {
  10987. tdEnvoi.removeChild(tdEnvoi.firstChild);
  10988. }
  10989. /* Retour à l'effet de base du bouton Envoi */
  10990. btnEnvoi.onclick = prepareEnvoi;
  10991. tdEnvoi.appendChild(btnEnvoi);
  10992. /* Suppression CheckBoxes */
  10993. for(var i=nbTrolls ; i>=0 ; i--) {
  10994. var td = getTrollNomNode(i);
  10995. td.parentNode.removeChild(td);
  10996. }
  10997. }
  10998.  
  10999. function effectueEnvoi() {
  11000. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  11001. var str='';
  11002. var errID = false;
  11003. for(var i=nbTrolls ; i>0 ; i--) {
  11004. var chb = document.getElementById('envoi'+i);
  11005. if(chb.checked) {
  11006. var idTroll = getTrollID(i);
  11007. if (idTroll == undefined) {
  11008. errID = true;
  11009. } else {
  11010. str += (str ? ',' : '') + idTroll;
  11011. }
  11012. }
  11013. }
  11014. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  11015. var PXchecked = document.getElementById('radioPX').checked;
  11016. if(PXchecked) {
  11017. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  11018. } else {
  11019. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  11020. }
  11021. }
  11022.  
  11023. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  11024.  
  11025. function filtreTresors() {
  11026. // += Handler checkboxes : gg, compos, bidouilles, non libres
  11027. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  11028. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  11029. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  11030. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  11031. if(noEngages && !isEngagesComputed) {
  11032. for(var i=nbTrolls ; i>0 ; i--) {
  11033. var pos = getTrollPosition(i);
  11034. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  11035. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  11036. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  11037. }
  11038. isEngagesComputed = true;
  11039. }
  11040. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  11041. for(var i=nbTresors ; i>0 ; i--) {
  11042. var nom = getTresorNom(i);
  11043. var pos = getTresorPosition(i);
  11044. tr_tresors[i].style.display = (
  11045. noGG &&
  11046. nom.indexOf('Gigots de Gob')!=-1
  11047. ) || (
  11048. noCompos &&
  11049. nom.indexOf('Composant')!=-1
  11050. ) || (
  11051. noEngages &&
  11052. listeEngages[pos[2]] &&
  11053. listeEngages[pos[2]][pos[1]] &&
  11054. listeEngages[pos[2]][pos[1]][pos[0]] &&
  11055. getTresorDistance(i)>0
  11056. ) || (
  11057. strTresor!='' &&
  11058. nom.toLowerCase().indexOf(strTresor)==-1
  11059. ) || (
  11060. noBidouilles &&
  11061. nom.indexOf('Bidouille')!=-1
  11062. ) ? 'none' : '';
  11063. }
  11064. }
  11065.  
  11066.  
  11067. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  11068.  
  11069. function filtreLieux() {
  11070. // += Handler checkbox trous
  11071. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  11072. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  11073. for(var i=nbLieux ; i>0 ; i--) {
  11074. tr_lieux[i].style.display = (
  11075. strLieu &&
  11076. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  11077. ) || (
  11078. noTrou &&
  11079. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  11080. getLieuDistance(i)>1
  11081. ) ? 'none' : '';
  11082. }
  11083. }
  11084.  
  11085.  
  11086. /*-[functions]-------------------- Diplomatie --------------------------------*/
  11087.  
  11088. function refreshDiplo() {
  11089. MY_setValue(numTroll+'.diplo.off',
  11090. checkBoxDiplo.checked?'true':'false'
  11091. );
  11092. if(isDiploRaw) { computeDiplo(); }
  11093. appliqueDiplo();
  11094. }
  11095.  
  11096. function computeDiplo() {
  11097. // On extrait les données de couleur et on les stocke par id
  11098. // Ordre de préséance :
  11099. // source Guilde < source Perso
  11100. // guilde cible < troll cible
  11101.  
  11102. /* Diplo de Guilde */
  11103. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  11104. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  11105. if(diploGuilde && diploGuilde.isOn=='true') {
  11106. // Guilde perso
  11107. if(diploGuilde.guilde) {
  11108. Diplo.Guilde[diploGuilde.guilde.id] = {
  11109. couleur: diploGuilde.guilde.couleur,
  11110. titre: 'Ma Guilde'
  11111. };
  11112. }
  11113. // Guildes/Trolls A/E
  11114. for(var AE in {Amis:0,Ennemis:0}) {
  11115. for(var i=0 ; i<5 ; i++) {
  11116. if(diploGuilde[AE+i]) {
  11117. for(var type in {Guilde:0,Troll:0}) {
  11118. var liste = diploGuilde[AE+i][type].split(';');
  11119. for(var j=liste.length-2 ; j>=0 ; j--) {
  11120. Diplo[type][liste[j]] = {
  11121. couleur: diploGuilde[AE+i].couleur,
  11122. titre: diploGuilde[AE+i].titre
  11123. };
  11124. }
  11125. }
  11126. }
  11127. }
  11128. }
  11129. }
  11130.  
  11131. /* Diplo Perso */
  11132. //var diploPerso = MY_getValue(numTroll+'.diplo.perso') ? JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {}; // déjà chargé
  11133. if(diploPerso && diploPerso.isOn=='true') {
  11134. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  11135. for(var id in diploPerso[type]) {
  11136. Diplo[type][id] = diploPerso[type][id];
  11137. }
  11138. }
  11139. }
  11140. if(diploPerso.mythiques) {
  11141. Diplo.mythiques = diploPerso.mythiques;
  11142. }
  11143.  
  11144. isDiploRaw = false;
  11145. }
  11146.  
  11147. function appliqueDiplo() {
  11148. var aAppliquer = Diplo;
  11149. if(checkBoxDiplo.checked) {
  11150. // Pour retour à l'affichage basique sur désactivation de la diplo
  11151. aAppliquer = {
  11152. Guilde: {},
  11153. Troll: {},
  11154. Monstre: {}
  11155. };
  11156. }
  11157.  
  11158. /* On applique "aAppliquer" */
  11159. // Diplo Trõlls
  11160. for(var i=nbTrolls ; i>0 ; i--) {
  11161. var idG = getTrollGuildeID(i);
  11162. var idT = getTrollID(i);
  11163. var tr = tr_trolls[i];
  11164. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  11165. if(aAppliquer.Troll[idT]) {
  11166. tr.className = '';
  11167. var descr = aAppliquer.Troll[idT].titre;
  11168. if(descr) {
  11169. getTrollNomNode(i).title = descr
  11170. }
  11171. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  11172. } else if(aAppliquer.Guilde[idG]) {
  11173. tr.className = '';
  11174. var descr = aAppliquer.Guilde[idG].titre;
  11175. if(descr) {
  11176. getTrollNomNode(i).title = descr
  11177. }
  11178. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  11179. } else {
  11180. tr.className = 'mh_tdpage';
  11181. getTrollNomNode(i).title = '';
  11182. }
  11183. }
  11184.  
  11185. // Diplo Monstres
  11186. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  11187. var id = getMonstreID(i);
  11188. var nom = getMonstreNom(i).toLowerCase();
  11189. var tr = MZ_EtatCdMs.tr_monstres[i];
  11190. if(aAppliquer.Monstre[id]) {
  11191. tr.className = '';
  11192. tr.style.backgroundColor = aAppliquer.Monstre[id].couleur;
  11193. tr.diploActive = 'oui';
  11194. var descr = aAppliquer.Monstre[id].titre;
  11195. if(descr) {
  11196. getMonstreNomNode(i).title = descr;
  11197. }
  11198. } else if(aAppliquer.mythiques &&
  11199. (nom.indexOf('liche')==0 ||
  11200. nom.indexOf('hydre')==0 ||
  11201. nom.indexOf('balrog')==0 ||
  11202. nom.indexOf('beholder')==0)) {
  11203. tr.className = '';
  11204. tr.style.backgroundColor = aAppliquer.mythiques;
  11205. tr.diploActive = 'oui';
  11206. getMonstreNomNode(i).title = 'Monstre Mythique';
  11207. } else {
  11208. tr.className = 'mh_tdpage';
  11209. tr.diploActive = '';
  11210. }
  11211. }
  11212. }
  11213.  
  11214.  
  11215. /*-[functions]---------------- Actions à distance ----------------------------*/
  11216.  
  11217. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  11218. var monN = parseInt(getPosition()[2]);
  11219.  
  11220. for(var type in keltypes) {
  11221. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  11222. for(var i=this['nb'+type] ; i>0 ; i--) {
  11223. var tr = this['tr_'+type.toLowerCase()][i];
  11224. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  11225. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  11226. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  11227. var sonN = getXxxPosition(type, i)[2];
  11228. var d = getXxxDistance(type, i);
  11229.  
  11230. if(sonN==monN && d>=dmin && d<=dmax) {
  11231. var iconeAction = document.evaluate(
  11232. "./descendant::img[@alt='"+alt+"']",
  11233. tr, null, 9, null
  11234. ).singleNodeValue;
  11235. if(iconeAction) {
  11236. if(iconeAction.title) {
  11237. iconeAction.title += "\n"+message;
  11238. } else {
  11239. iconeAction.title = message;
  11240. }
  11241. iconeAction.src = urlIcon;
  11242. } else {
  11243. var tdAction = tr.getElementsByTagName('td')[1];
  11244. var icon = document.createElement('img');
  11245. icon.src = urlIcon;
  11246. icon.height = 20;
  11247. icon.alt = alt;
  11248. icon.title = message;
  11249. tdAction.appendChild(icon);
  11250. }
  11251. }
  11252. }
  11253. }
  11254. }
  11255.  
  11256. function computeCharge() {
  11257. computeActionDistante(1,
  11258. getPortee__Vue(
  11259. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  11260. MY_getValue(numTroll+".caracs.regeneration")
  11261. ),
  11262. {'Monstres':1, 'Trolls':1},
  11263. 'Attaquer',
  11264. MHicons+'E_Metal09.png',
  11265. 'Cible à portée de Charge'
  11266. );
  11267. }
  11268.  
  11269. function computeProjo() {
  11270. computeActionDistante(0,
  11271. getPortee__Vue(
  11272. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11273. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11274. ),
  11275. {'Monstres':1, 'Trolls':1},
  11276. 'Attaquer',
  11277. MHicons+'S_Fire05.png',
  11278. 'Cible à portée de Projo'
  11279. );
  11280. }
  11281.  
  11282. function computeTelek() {
  11283. computeActionDistante(0,
  11284. Math.floor((
  11285. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11286. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11287. )/2),
  11288. {'Tresors':1},
  11289. 'Telek',
  11290. MHicons+'S_Magic04.png',
  11291. 'Trésor à portée de Télékinésie'
  11292. );
  11293. }
  11294.  
  11295. function computeLdP() {
  11296. computeActionDistante(0,
  11297. 2+Math.floor((
  11298. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11299. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11300. )/5),
  11301. {'Monstres':1, 'Trolls':1},
  11302. 'self',
  11303. MHicons+'P_Red01.png',
  11304. 'Cible à portée de Lancer de Potions'
  11305. );
  11306. }
  11307.  
  11308.  
  11309. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  11310.  
  11311. function putScriptExterne(sInfo) {
  11312. for (var iBricol = 1; ; iBricol++) {
  11313. var extClef = iBricol == 1 ? '' : iBricol;
  11314. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  11315. if (!sInfo) break;
  11316. putScriptExterneOneIT(sInfo);
  11317. }
  11318. }
  11319.  
  11320. function putScriptExterneOneIT(sInfo) {
  11321. if(!sInfo || sInfo=='') return;
  11322.  
  11323. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  11324. if(nomit=='bricol') {
  11325. var data = sInfo.split('$');
  11326. try {
  11327. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  11328. // appendNewScript(URL_bricol+data[1]
  11329. // +'/mz.php?login='+data[2]
  11330. // +'&password='+data[3]
  11331. // );
  11332. FF_XMLHttpRequest({
  11333. method: 'GET',
  11334. url: URL_bricol+data[1]
  11335. +'/mz_json.php?login='+encodeURIComponent(data[2])
  11336. +'&password='+data[3],
  11337. trace: 'bricolTroll',
  11338. onload: function(responseDetails) {
  11339. try {
  11340. if (responseDetails.status == 0) {
  11341. window.console.log('status=0 à l\'appel bricol\'troll');
  11342. if (isHTTPS) {
  11343. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  11344. } else {
  11345. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  11346. }
  11347. return;
  11348. }
  11349. var ratibusData;
  11350. try {
  11351. ratibusData = JSON.parse(responseDetails.responseText);
  11352. } catch(e) {}
  11353. if (ratibusData === undefined) {
  11354. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  11355. return;
  11356. }
  11357. if (ratibusData.error) {
  11358. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  11359. } else {
  11360. putInfosTrolls(ratibusData.data.trolls, data[1]);
  11361. }
  11362. } catch(e) {
  11363. window.console.log(traceStack(e, 'retour bricol\'troll'));
  11364. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  11365. }
  11366. }
  11367. });
  11368. } catch(e) {
  11369. if (isHTTPS) {
  11370. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  11371. } else {
  11372. window.console.log(traceStack(e, 'appel bricol\'troll'));
  11373. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  11374. }
  11375. }
  11376. }
  11377. }
  11378.  
  11379. /*
  11380. * Roule 07/11/2016, on utilise mz_json qui envoie
  11381. {
  11382. "data": {
  11383. "trolls": {
  11384. "59424": {
  11385. "id": 59424,
  11386. "pv": xx,
  11387. "pv_max": xx,
  11388. "updated_at": "2016-10-31 07:28:40",
  11389. "dla": "2016-10-05 07:28:04",
  11390. "pa": 0
  11391. },
  11392. }
  11393. }
  11394. }
  11395. */
  11396.  
  11397. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  11398. function corrigeBricolTrolls(infosTrolls) {
  11399. for(var i in infosTrolls) {
  11400. var pv = infosTrolls[i][0];
  11401. var pvmax = infosTrolls[i][1];
  11402. var pvmem = MY_getValue(i+'.caracs.pv.max');
  11403. if(pvmem && pvmem>pvmax) {
  11404. infosTrolls[i][1] = pvmem;
  11405. pvmax = pvmem;
  11406. }
  11407. if(pv>pvmax) {
  11408. var newpvmax = 5*Math.ceil(pv/5);
  11409. MY_setValue(i+'.caracs.pv.max',newpvmax);
  11410. infosTrolls[i][1] = newpvmax;
  11411. }
  11412. }
  11413. }
  11414.  
  11415. // insère 2 TD avant nextTD avec les infos venant de l'IT
  11416. function addTdInfosTroll(infos, TR, itName) {
  11417. /* cadre barre PV */
  11418. var tab = document.createElement('div');
  11419. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  11420. /* barre PV */
  11421. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  11422. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  11423. .vieContainer {
  11424. background-color: #CCC;
  11425. width: 50px;
  11426. height: 6px;
  11427. border: 1px solid #000;
  11428. text-align: left;
  11429. }
  11430. */
  11431. tab.style.width = '100px';
  11432. tab.style.height = '10px';
  11433. tab.style.border = '1px solid #000';
  11434. tab.style.textAlign = 'left';
  11435. var div2 = document.createElement('div');
  11436. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  11437. var dateLimite = new Date();
  11438. dateLimite.setDate(dateLimite.getDate() - 7);
  11439. if (infos.oUpdatedAt < dateLimite) {
  11440. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  11441. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  11442. } else if (pourcentVie > 66) {
  11443. div2.style.backgroundColor = '#77EE77';
  11444. } else if (pourcentVie > 33) {
  11445. div2.style.backgroundColor = '#EEEE77';
  11446. } else {
  11447. div2.style.backgroundColor = '#FF0000';
  11448. }
  11449. div2.style.width = pourcentVie + '%';
  11450. div2.style.height = '10px';
  11451. tab.appendChild(div2);
  11452. /* ancienne méthode par img, à supprimer
  11453. var img = document.createElement('img');
  11454. img.src = '../Images/Interface/milieu.gif';
  11455. img.height = 10;
  11456. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  11457. tab.appendChild(img);
  11458. */
  11459.  
  11460. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  11461. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  11462. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  11463. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  11464.  
  11465. /* lien vers l'IT */
  11466. var lien = document.createElement('a');
  11467. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  11468. lien.href = URL_bricol+itName+'/index.php';
  11469. lien.target = '_blank';
  11470. lien.appendChild(tab);
  11471. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11472. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  11473. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  11474. //insertTdElement(tdGuilde,lien);
  11475. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  11476. /* PAs dispos */
  11477. var span = document.createElement('span');
  11478. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  11479. appendText(span, infos.pa +' PA' );
  11480. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  11481. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  11482. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  11483. span.style.backgroundColor = 'B8EEB8';
  11484. }
  11485. //insertTdElement(tdGuilde, span);
  11486. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  11487. }
  11488.  
  11489. var MZ_tabTrTrollById;
  11490. function putInfosTrolls(infosTrolls, itName) {
  11491. try {
  11492. if (MZ_tabTrTrollById === undefined) {
  11493. MZ_tabTrTrollById = new Array;
  11494. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  11495. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11496. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  11497. td.width = 40;
  11498. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  11499. td.width = 105;
  11500. for(i=nbTrolls ; i>0 ; i--) {
  11501. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11502. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11503. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  11504. }
  11505. }
  11506.  
  11507.  
  11508. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  11509. //corrigeBricolTrolls(infosTrolls);
  11510.  
  11511. // supression des infos trop vieilles (un mois)
  11512. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  11513. var dateLimite = new Date();
  11514. dateLimite.setMonth(dateLimite.getMonth() - 1);
  11515.  
  11516. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  11517. var str = MY_getValue(numTroll+'.INFOSIT');
  11518. var bAjoutTrollInvi = false;
  11519. if (str) {
  11520. var arr = str.split('$');
  11521. bAjoutTrollInvi = arr[4]>0;
  11522. }
  11523.  
  11524.  
  11525. var tBody = tr_trolls[0].parentNode;
  11526. if (tr_trolls[1] !== undefined)
  11527. tBody = tr_trolls[1].parentNode;
  11528.  
  11529. //window.console.log('nb Troll IT : ' + IDs.length);
  11530. var pos = getPosition();
  11531.  
  11532. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  11533. for (var idTroll in infosTrolls) {
  11534. var infos = infosTrolls[idTroll];
  11535. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  11536. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  11537. if (idTroll == numTroll) continue; // pas nous-même
  11538. var tr;
  11539. if (idTroll in MZ_tabTrTrollById) {
  11540. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  11541. tr = MZ_tabTrTrollById[idTroll];
  11542. } else {
  11543. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  11544. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  11545. // trouver où insérer ce Troll
  11546. var next = undefined;
  11547. for(var j=0 ; j<tr_trolls.length ; j++) {
  11548. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  11549. if (thisDist > distance) {
  11550. next = tr_trolls[j]
  11551. break;
  11552. }
  11553. }
  11554. if (next !== undefined) {
  11555. tr = insertTr(next,'mh_tdpage')
  11556. } else {
  11557. tr = appendTr(tBody,'mh_tdpage');
  11558. }
  11559. tr.style.color = 'orange';
  11560. var td = appendTd(tr); // distance
  11561. appendText(td, distance);
  11562. td = appendTd(tr); // actions
  11563. td = appendTd(tr); // ID
  11564. appendText(td, idTroll);
  11565. td = appendTd(tr); // Nom
  11566. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  11567. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  11568. td = appendTd(tr); // PV
  11569. td = appendTd(tr); // PA
  11570. td = appendTd(tr); // Guilde
  11571. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  11572. td = appendTd(tr); // Niveau
  11573. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  11574. td.align = 'center';
  11575. td = appendTd(tr); // Race
  11576. if (infos.race) appendText(td, infos.race);
  11577. td = appendTd(tr); // X
  11578. td.align = 'center';
  11579. if (infos.x !== undefined) appendText(td, infos.x);
  11580. td = appendTd(tr); // Y
  11581. td.align = 'center';
  11582. if (infos.y !== undefined) appendText(td, infos.y);
  11583. td = appendTd(tr); // N
  11584. td.align = 'center';
  11585. if (infos.n !== undefined) appendText(td, infos.n);
  11586. MZ_tabTrTrollById[idTroll] = tr;
  11587. }
  11588. if (!tr.done) {
  11589. addTdInfosTroll(infos, tr, itName);
  11590. tr.done = true;
  11591. }
  11592. }
  11593. } catch(e) {
  11594. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  11595. window.console.error(traceStack(e, 'putInfosTrolls'));
  11596. }
  11597. }
  11598.  
  11599.  
  11600. /* Mode Tétalanvert! ---------------------------------------------------------*/
  11601.  
  11602. function calculeDistance(maPos,posArr) {
  11603. return Math.max(
  11604. Math.abs(maPos[0]-posArr[0]),
  11605. Math.abs(maPos[1]-posArr[1]),
  11606. Math.abs(maPos[2]-posArr[2])
  11607. );
  11608. }
  11609.  
  11610. function inversionCoord() {
  11611. var maPos = getPosition();
  11612. var listeOffsets = {
  11613. 'monstres':checkBoxLevels.checked?4:3,
  11614. 'trolls':6,
  11615. };
  11616. for(var type in listeOffsets) {
  11617. var trList = this['tr_'+type];
  11618. var offset = listeOffsets[type];
  11619. for(var i=trList.length-1 ; i>0 ; i--) {
  11620. var oldX = parseInt(trList[i].cells[offset].textContent);
  11621. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  11622. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  11623. trList[i].cells[offset].innerHTML = oldY;
  11624. trList[i].cells[offset+1].innerHTML = oldX;
  11625. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  11626. }
  11627. }
  11628. }
  11629.  
  11630.  
  11631. /* Partie principale */
  11632. function do_vue() {
  11633. for(var type in typesAFetcher) {
  11634. fetchData(type);
  11635. }
  11636.  
  11637. // roule' 11/03/2016
  11638. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  11639. // je fais une recopie :(
  11640. MZ_EtatCdMs.tr_monstres = this['tr_monstres'];
  11641. tr_trolls = this['tr_trolls'];
  11642. tr_tresors = this['tr_tresors'];
  11643. tr_champignons = this['tr_champignons'];
  11644. tr_lieux = this['tr_lieux'];
  11645.  
  11646. MZ_EtatCdMs.nbMonstres = this['nbMonstres'];
  11647. nbTrolls = this['nbTrolls'];
  11648. nbTresors = this['nbTresors'];
  11649. nbChampignons = this['nbChampignons'];
  11650. nbLieux = this['nbLieux'];
  11651.  
  11652. try {
  11653. start_script(31);
  11654.  
  11655. initialiseInfos();
  11656. savePosition();
  11657.  
  11658. // Fonctionnalité "Têtalenvert" cachée, en test :
  11659. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  11660. inversionCoord();
  11661. }
  11662.  
  11663. ajoutDesFiltres();
  11664. set2DViewSystem();
  11665. //putBoutonTroogle();
  11666. putBoutonPXMP();
  11667.  
  11668. synchroniseFiltres();
  11669. toggleLevelColumn(); // appel des CdM, ne fait rien si la checkbox NOCDM est cochée
  11670.  
  11671. refreshDiplo();
  11672.  
  11673. //400 ms
  11674. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  11675. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  11676. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  11677. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  11678. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  11679. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  11680. var noTresorsEngages =
  11681. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  11682. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  11683. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  11684. filtreMonstres();
  11685. if(noIntangibles) {
  11686. filtreTrolls();
  11687. }
  11688. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  11689. filtreTresors();
  11690. }
  11691. if(noTrou) {
  11692. filtreLieux();
  11693. }
  11694.  
  11695. initPopupVue();
  11696. initPXTroll();
  11697.  
  11698. if(getTalent("Projectile Magique")!=0) {
  11699. computeProjo();
  11700. }
  11701. if(getTalent("Charger")!=0) {
  11702. computeCharge();
  11703. }
  11704. if(getTalent("Télékinésie")!=0) {
  11705. computeTelek();
  11706. }
  11707. if(getTalent("Lancer de Potions")!=0) {
  11708. computeLdP();
  11709. }
  11710.  
  11711. putScriptExterne();
  11712.  
  11713. displayScriptTime();
  11714. } catch(e) {
  11715. window.console.error(traceStack(e, 'vue'));
  11716. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite (seriez-vous sous l'effet d'un Fumeux ?).");
  11717. }
  11718. }
  11719.  
  11720.  
  11721.  
  11722. /*******************************************************************************
  11723. * This file is part of Mountyzilla. *
  11724. * *
  11725. * Mountyzilla is free software; you can redistribute it and/or modify *
  11726. * it under the terms of the GNU General Public License as published by *
  11727. * the Free Software Foundation; either version 2 of the License, or *
  11728. * (at your option) any later version. *
  11729. * *
  11730. * Mountyzilla is distributed in the hope that it will be useful, *
  11731. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11732. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11733. * GNU General Public License for more details. *
  11734. * *
  11735. * You should have received a copy of the GNU General Public License *
  11736. * along with Mountyzilla; if not, write to the Free Software *
  11737. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11738. *******************************************************************************/
  11739.  
  11740. // x~x profil2
  11741.  
  11742. /*---------------------------- Variables globales ----------------------------*/
  11743.  
  11744. var
  11745. // Anatrolliseur
  11746. urlAnatrolliseur,
  11747. // Infobulles talents
  11748. hauteur = 50, bulleStyle = null,
  11749. // Caracteristiques
  11750. // Infos troll
  11751. race, niv, idtroll, datecrea,
  11752. idguilde, nomguilde,
  11753. // Etats du troll
  11754. fatigue, bmfatigue,
  11755.  
  11756. // Experience, Pi, ...
  11757. pxdistribuables, pxperso,
  11758. piutilisable, pitotal,
  11759. nbmeurtres, nbmorts,
  11760. // utilisee pour les moyennes MM/jour, kill/jour, etc
  11761. NBjours,
  11762. // calcul des DLA suivantes
  11763. DLA, DLAsuiv, HeureServeur,
  11764. // details duree du tour (calcul pvdispo) :
  11765. dtb, pdm, bmt, adb, dpt,
  11766. //posale
  11767. posX, posY, posN,
  11768. // caracs physiques
  11769. vue, vuebp, vuebm, vuetotale,
  11770. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  11771. reg, regbp, regbm, regmoy,
  11772. att, attbp, attbm, attmoy, atttourD, atttour, attmoytour,
  11773. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  11774. deg, degbp, degbm, degmoy, degmoycrit, degtour, degmoytour, degmoycrittour,
  11775. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  11776. rm, rmbp, rmbm, rmtotale,
  11777. mm, mmbp, mmbm, mmtotale,
  11778.  
  11779. // Variables speciales Kastars
  11780. pvActuelKastar, minParPV, overDLA,
  11781. // id pour edition manuelle de lastDLA :
  11782. inJour, inMois, inAn, inHr, inMin, inSec,
  11783. // id pour auto-refresh lastDLA :
  11784. lastDLAZone, maxAMZone, cumulZone,
  11785. lastDLA, DLAaccel;
  11786.  
  11787.  
  11788. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  11789.  
  11790. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  11791. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  11792. function getUniqueValueBySelector(selector, defaultValue){
  11793. var valNode = document.querySelector(selector);
  11794. if(valNode!=null){
  11795. if(valNode.hasChildNodes()) {
  11796. return valNode.childNodes[0].nodeValue;
  11797. }else{
  11798. return defaultValue;
  11799. }
  11800. } else{
  11801. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  11802. return defaultValue;
  11803. }
  11804. }
  11805. function getUniqueStringValueBySelector(selector){
  11806. return getUniqueValueBySelector(selector,"");
  11807. }
  11808. function getUniqueIntValueBySelector(selector){
  11809. var ret = getUniqueValueBySelector(selector,0);
  11810. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  11811. ret = 0;
  11812. }
  11813. return parseInt(ret);
  11814. }
  11815. function getUniqueFloatValueBySelector(selector){
  11816. var ret = getUniqueValueBySelector(selector,0.0);
  11817. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  11818. ret = 0.0;
  11819. }
  11820. return parseFloat(ret);
  11821. }
  11822.  
  11823.  
  11824. function resiste(Ddeg,bm) {
  11825. // version naive mais compréhensible ^^
  11826. // DEBUG: à revoir
  11827. if(!bm) {
  11828. return 2*Math.floor(Ddeg/2);
  11829. }
  11830. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  11831. }
  11832.  
  11833. function retourAZero(fatig) {
  11834. var fat = fatig, raz = 0;
  11835. while(fat>0) {
  11836. raz++;
  11837. fat = Math.floor(fat/1.25);
  11838. }
  11839. return raz;
  11840. }
  11841.  
  11842. function coefDecumul(i) {
  11843. switch(i) {
  11844. case 2: return 0.67;
  11845. case 3: return 0.4;
  11846. case 4: return 0.25;
  11847. case 5: return 0.15;
  11848. default: return 0.1;
  11849. }
  11850. }
  11851.  
  11852. function dureeHM(dmin) {
  11853. var ret = "";
  11854. dmin = Math.floor(dmin);
  11855. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  11856. var mins = dmin%60;
  11857. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  11858. return (ret) ? ret : "-";
  11859. }
  11860.  
  11861. // extraction d'une durée
  11862. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  11863. // c'est protégé (rend 0 si l'élément est absent)
  11864. // Roule' 24/12/2016
  11865. function extractionDuree(selecteur) {
  11866. var s = getUniqueStringValueBySelector(selecteur);
  11867. if (!s) return 0;
  11868. var tabN = getNumbers(s);
  11869. if (tabN.length < 2) return 0;
  11870. return tabN[0] * 60 + tabN[1];
  11871. }
  11872.  
  11873. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  11874.  
  11875. function extractionDonnees() {
  11876. // Variables temporaires
  11877. var Nbrs = {};
  11878.  
  11879. // *********************
  11880. // Cadre "Description"
  11881. // *********************
  11882. race = getUniqueStringValueBySelector('#descr #race');
  11883. debugMZ("Race : " + race);
  11884. idtroll = getUniqueStringValueBySelector('#descr #id');
  11885. debugMZ("Id troll : " + idtroll);
  11886. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  11887. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  11888. datecrea = new Date(StringToDate(strDateCrea));
  11889. debugMZ("Date creation : " + datecrea);
  11890. // Guilde
  11891. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  11892. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  11893. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  11894.  
  11895. // *******************
  11896. // Cadre "Experience"
  11897. // *******************
  11898. // Niveau de troll
  11899. niv = getUniqueIntValueBySelector('#exp #niv');
  11900. nivTroll = niv;
  11901. debugMZ("Niveau : " + niv);
  11902. // PX
  11903. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  11904. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  11905. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  11906. // PI
  11907. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  11908. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  11909. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  11910. // Meutres/Morts
  11911. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  11912. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  11913. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  11914.  
  11915. // *********************
  11916. // Cadre "Tour de Jeu"
  11917. // *********************
  11918. // DLA
  11919. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  11920. DLA = new Date(StringToDate(Nbrs["dla"]));
  11921. debugMZ("DLA: " + DLA);
  11922. // DLA suivante
  11923. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  11924. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  11925. debugMZ("DLAsuiv: " + DLAsuiv);
  11926. // Duree normale de mon Tour
  11927. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  11928. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  11929. dtb = extractionDuree("#dla #tour");
  11930. debugMZ("Duree normale de mon Tour : " + dtb);
  11931. // Bonus/Malus sur la duree
  11932. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  11933. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  11934. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  11935. debugMZ("Bonus/Malus sur la duree : " + bmt);
  11936. // Augmentation due aux blessures
  11937. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  11938. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  11939. adb = extractionDuree("#dla #blessure");
  11940. debugMZ("Augmentation due aux blessures : " + adb);
  11941. // Poids de l'equipement
  11942. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  11943. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  11944. pdm = extractionDuree("#dla #poids");
  11945. debugMZ("Poids de l'equipement : " + pdm);
  11946. // Duree de mon prochain Tour
  11947. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  11948. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  11949. dpt = extractionDuree("#dla #duree>b");
  11950. debugMZ('Duree de mon prochain Tour : ' + dpt);
  11951.  
  11952. // ****************
  11953. // Cadre "Etats"
  11954. // ****************
  11955. // Position du troll :
  11956. posX = getUniqueIntValueBySelector('#pos #x');
  11957. posY = getUniqueIntValueBySelector('#pos #y');
  11958. posN = getUniqueIntValueBySelector('#pos #n');
  11959. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  11960. // PV actuel
  11961. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  11962. pvActuelKastar = pvcourant;
  11963. debugMZ("PV actuel : " + pvcourant)
  11964. // Fatigue
  11965. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  11966. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  11967. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  11968.  
  11969. // **************************
  11970. // Cadre "Caracteristiques"
  11971. // **************************
  11972. // Attaque
  11973. att = getUniqueIntValueBySelector('#carac #att');
  11974. attbp = getUniqueIntValueBySelector('#carac #att_p');
  11975. attbm = getUniqueIntValueBySelector('#carac #att_m');
  11976. atttour = getUniqueIntValueBySelector('#carac #att_tour'); // % bonus AdA
  11977. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d'); // malus Parade
  11978. attmoy = 3.5*att + attbp + attbm;
  11979. var DAttBonus = Math.floor(((att+atttourD)*atttour/100)); // À vérifier
  11980. attmoytour = 3.5*(att+DAttBonus) + attbp + attbm;
  11981. debugMZ(
  11982. "ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+
  11983. "; BM Dé att/tour:("+atttourD+"D;"+atttour+"%) "+(atttourD+DAttBonus)+
  11984. "D ;AttMoyTour:"+attmoytour
  11985. );
  11986. // Esquive
  11987. esq = getUniqueIntValueBySelector('#carac #esq');
  11988. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  11989. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  11990. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  11991. esqmoy = 3.5*esq + esqbp+esqbm;
  11992. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  11993. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  11994. // Degat
  11995. deg = getUniqueIntValueBySelector('#carac #deg');
  11996. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  11997. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  11998. degtour = getUniqueIntValueBySelector('#carac #deg_tour'); // % bonus AdD
  11999. degmoy = 2*deg + degbp + degbm;
  12000. degmoycrit = 2*(deg+Math.floor(deg/2)) + degbp + degbm;
  12001. var DDegBonus = Math.floor(deg*degtour/100);
  12002. degmoytour = 2*(deg + DDegBonus) + degbp + degbm;
  12003. degmoycrittour = degmoytour + 2*Math.floor(deg/2);
  12004. debugMZ(
  12005. "DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+
  12006. " ;deg/tour:("+degtour+"%) "+DDegBonus+
  12007. "D; DegMoyTour:"+degmoytour+"/"+degmoycrittour
  12008. );
  12009. // PV
  12010. pvbase = getUniqueIntValueBySelector('#carac #pv');
  12011. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  12012. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  12013. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  12014. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  12015. // Regeneration
  12016. reg = getUniqueIntValueBySelector('#carac #reg');
  12017. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  12018. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  12019. regmoy = 2 * reg + regbp + regbm; // D3
  12020. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  12021. // Armure
  12022. arm = getUniqueIntValueBySelector('#carac #arm');
  12023. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  12024. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  12025. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  12026. armmoy = 2*arm + armbp+armbm;
  12027. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  12028. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  12029. // TODO : D d'armure non active
  12030. // Vue
  12031. vue = getUniqueIntValueBySelector('#carac #vue');
  12032. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  12033. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  12034. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  12035. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  12036. // RM
  12037. rm = getUniqueIntValueBySelector('#carac #rm');
  12038. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  12039. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  12040. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  12041. rmTroll = rmtotale;
  12042. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  12043. // MM
  12044. mm = getUniqueIntValueBySelector('#carac #mm');
  12045. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  12046. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  12047. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  12048. mmTroll = mmtotale;
  12049. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  12050.  
  12051. // Heure Serveur
  12052. try {
  12053. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  12054. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  12055. HeureServeur = new Date(StringToDate(heureServeurSTR));
  12056. } catch (e) {
  12057. window.console.warn(
  12058. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  12059. );
  12060. HeureServeur = new Date();
  12061. }
  12062. debugMZ("HeureServeur: " + HeureServeur);
  12063.  
  12064. // ***INIT GLOBALE*** NBjours
  12065. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  12066.  
  12067. // Calcul debut lien anatroliseur avec les caracteristiques connues
  12068. var amelio_dtb = function(dtb) {
  12069. if(dtb>555) {
  12070. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  12071. }
  12072. return 10+Math.ceil((555-dtb)/2.5);
  12073. },
  12074. amelio_pv = Math.floor(pvbase/10)-3,
  12075. amelio_vue = vue-3,
  12076. amelio_att = att-3,
  12077. amelio_esq = esq-3,
  12078. amelio_deg = deg-3,
  12079. amelio_reg = reg-1,
  12080. amelio_arm = arm-1;
  12081. if(race==="Darkling"){amelio_reg--; }
  12082. if(race==="Durakuir"){amelio_pv-- ; }
  12083. if(race==="Kastar") {amelio_deg--; }
  12084. if(race==="Skrim") {amelio_att--; }
  12085. if(race==="Tomawak") {amelio_vue--; }
  12086.  
  12087. urlAnatrolliseur = URL_AnatrolDispas
  12088. +"outils_anatrolliseur.php?anatrolliseur=v8"
  12089. +"|r="+race.toLowerCase()
  12090. +"|dla="+amelio_dtb(dtb)
  12091. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  12092. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  12093. +"|att="+amelio_att+","+attbp+","+attbm
  12094. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  12095. +"|deg="+amelio_deg+","+degbp+","+degbm
  12096. +"|reg="+amelio_reg+","+regbp+","+regbm
  12097. +"|arm="+amelio_arm+","+armbp+","+armbm
  12098. +"|mm="+mmtotale
  12099. +"|rm="+rmtotale+"|";
  12100. }
  12101.  
  12102. function saveProfil() {
  12103. MY_setValue(idtroll+'.caracs.attaque',att);
  12104. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  12105. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  12106. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  12107. if(atttourD||atttour) {
  12108. var DAttBonus = atttourD + Math.floor((att+atttourD)*atttour/100);
  12109. MY_setValue(idtroll+'.bonus.DAttM',DAttBonus);
  12110. } else {
  12111. MY_removeValue(idtroll+'.bonus.DAttM');
  12112. }
  12113. MY_setValue(idtroll+'.caracs.esquive',esq);
  12114. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  12115. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  12116. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  12117. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  12118. MY_setValue(idtroll+'.caracs.degats',deg);
  12119. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  12120. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  12121. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  12122. if(degtour) {
  12123. var DDegBonus = Math.floor(deg*degtour/100);
  12124. MY_setValue(idtroll+'.bonus.DDeg',DDegBonus);
  12125. } else {
  12126. MY_removeValue(idtroll+'.bonus.DDeg');
  12127. }
  12128. MY_setValue(idtroll+'.caracs.regeneration',reg);
  12129. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  12130. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  12131. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  12132. MY_setValue(idtroll+'.caracs.vue',vue);
  12133. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  12134. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  12135. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  12136. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  12137. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  12138. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  12139. MY_setValue(idtroll+'.caracs.rm',rm);
  12140. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  12141. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  12142. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  12143. MY_setValue(idtroll+'.caracs.mm',mm);
  12144. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  12145. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  12146. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  12147. MY_setValue(idtroll+'.caracs.armure',arm);
  12148. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  12149. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  12150. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  12151. MY_setValue(idtroll+'.position.X',posX);
  12152. MY_setValue(idtroll+'.position.Y',posY);
  12153. MY_setValue(idtroll+'.position.N',posN);
  12154. MY_setValue(idtroll+'.race',race);
  12155. MY_setValue(idtroll+'.niveau',niv);
  12156. MY_setValue(idtroll+'.idguilde',idguilde);
  12157. MY_setValue(idtroll+'.nomguilde',nomguilde);
  12158. }
  12159.  
  12160.  
  12161. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  12162.  
  12163. function setInfosCaracteristiques() {
  12164. // Modification de l'entete
  12165. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  12166. thTotal.innerHTML+='|<i>Moyenne</i>';
  12167. thTotal.title="Moyenne (Moyenne ce tour)";
  12168.  
  12169. // Ajout des informations calculees
  12170. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  12171. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  12172. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  12173.  
  12174. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  12175. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  12176. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  12177.  
  12178. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  12179. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  12180. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  12181.  
  12182. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  12183. var tdRegTotal = trRegeneration.children[5];
  12184. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  12185. // Temps recupere par reg (propale R')
  12186. var regmoyTemp = Math.max(0, regmoy);
  12187. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  12188. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  12189. if (sec != 0) {
  12190. regTitle += " " + sec + " sec";
  12191. }
  12192. trRegeneration.title = regTitle;
  12193.  
  12194. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  12195. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  12196. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  12197.  
  12198. var trRM=document.querySelector("table#caracs #rm").parentElement;
  12199. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  12200. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  12201.  
  12202.  
  12203. var trMM=document.querySelector("table#caracs #mm").parentElement;
  12204. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  12205. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  12206.  
  12207. var tdRefl=document.querySelector("#refl");
  12208. // TODO : prendre en compte bonus/malus D esq du tour ?
  12209. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + esqbp + esqbm;
  12210. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  12211. }
  12212.  
  12213. function setLienAnatrolliseur(){
  12214. var pTableAmelio = document.querySelector("#carac>div>p");
  12215. pTableAmelio.innerHTML+=" - ";
  12216. var aElt = document.createElement("a");
  12217. aElt.setAttribute("href",urlAnatrolliseur);
  12218. aElt.setAttribute("target","_blank");
  12219. aElt.className="AllLinks";
  12220. aElt.innerHTML="Anatrolliser";
  12221. pTableAmelio.appendChild(aElt);
  12222. }
  12223. function setInfoDescription() {
  12224. var txtDateCrea = (NBjours!=1) ?
  12225. " ("+NBjours+" jours dans le hall)" :
  12226. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  12227. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  12228. }
  12229.  
  12230. function setInfosEtatLieux() {
  12231. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  12232. '?search=position&orderBy=distance&posx='+
  12233. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  12234. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  12235. appendBr(tdPosition);
  12236. var aElt = document.createElement("a");
  12237. aElt.setAttribute("href",urlBricol);
  12238. aElt.setAttribute("target","_blank");
  12239. aElt.className="AllLinks";
  12240. aElt.innerHTML="Lieux à proximité";
  12241. tdPosition.appendChild(aElt);
  12242. }
  12243.  
  12244. function setInfosEtatPV() { // pour AM et Sacro
  12245. var
  12246. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  12247. sec = Math.floor(15000/pvtotal)%60,
  12248. lifebar = document.querySelector("#pos .barre-vie");
  12249. if(sec!=0) { txt += " "+sec+" sec"; }
  12250. if(lifebar) { lifebar.title = txt; }
  12251. if(pvcourant<=0) { return; }
  12252.  
  12253. // Difference PV p/r a equilibre de temps (propale R')
  12254. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  12255. // ***INIT GLOBALE*** pvdispo
  12256. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  12257. var span = document.createElement("span");
  12258. span.title = txt;
  12259. span.style.fontStyle = "italic";
  12260. if(bmt+pdm>=0) {
  12261. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  12262. } else if(pvdispo>0) {
  12263. txt = "Vous pouvez encore perdre "+
  12264. Math.min(pvdispo,pvcourant)+
  12265. " PV sans malus de temps.";
  12266. } else if(pvdispo<0) {
  12267. txt = "Il vous manque "
  12268. +(-pvdispo)
  12269. +" PV pour ne plus avoir de malus de temps.";
  12270. } else {
  12271. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  12272. }
  12273. appendText(span,txt);
  12274. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  12275. }
  12276.  
  12277. // Complete le cadre "Experience"
  12278. function setInfosExp() {
  12279. var tdNiv = document.querySelector("#exp #niv");
  12280.  
  12281. // Calcul niveau monstre/troll min pour gain PX
  12282. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  12283. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  12284.  
  12285. // Calcul PX restant
  12286. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  12287. if (pxRestant >= 0) {
  12288. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  12289. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  12290. }
  12291.  
  12292. // Calul pi/jour
  12293. var
  12294. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  12295. tdPi = document.querySelector("#exp #pi").parentElement;
  12296. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  12297. tdPi.title = tdPiTotal.title;
  12298.  
  12299. // Rapports meurtres,morts
  12300. var tdKill = document.querySelector("#exp #kill");
  12301. tdKill.setAttribute("colspan", 1);
  12302. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  12303.  
  12304. var tdMort = document.querySelector("#exp #mort");
  12305. tdMort.setAttribute("colspan", 1);
  12306. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  12307.  
  12308. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  12309. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  12310. }
  12311.  
  12312.  
  12313. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  12314.  
  12315. function minParPVsac(fat,bm) {
  12316. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  12317. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  12318. var out = [];
  12319. out[0] = (fat>4) ?
  12320. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  12321. 30;
  12322. if(bm && bm>0) {
  12323. var totalfat=fat+bm;
  12324. out[1] = (totalfat>4) ?
  12325. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  12326. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  12327. }
  12328. return out;
  12329. }
  12330.  
  12331. function toInt(str) {
  12332. str = parseInt(str);
  12333. return (str) ? str : 0;
  12334. }
  12335.  
  12336. function saveLastDLA() {
  12337. // pour les calculs d'AM max
  12338. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  12339. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  12340. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  12341. lastDLA = new Date( StringToDate(str) );
  12342. MY_setValue(numTroll+'.DLA.ancienne',str);
  12343. lastDLAZone.innerHTML = '';
  12344. var b = document.createElement('b');
  12345. b.addEventListener('click',inputMode,false);
  12346. appendText(b,str);
  12347. lastDLAZone.appendChild(b);
  12348. refreshAccel();
  12349. }
  12350.  
  12351. function inputMode() {
  12352. // Edition manuelle lastDLA
  12353. var date;
  12354. if(lastDLA)
  12355. date = new Date( lastDLA );
  12356. else
  12357. date = new Date( DLAaccel );
  12358. lastDLAZone.innerHTML = '';
  12359. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  12360. appendText(lastDLAZone,'/');
  12361. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  12362. appendText(lastDLAZone,'/');
  12363. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  12364. appendText(lastDLAZone,' - ');
  12365. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  12366. appendText(lastDLAZone,':');
  12367. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  12368. appendText(lastDLAZone,':');
  12369. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  12370. appendText(lastDLAZone,' - ');
  12371. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  12372. }
  12373.  
  12374. function setAccel() {
  12375. var
  12376. BMfrais=false,
  12377. fat=fatigue, listeBmFat=[],
  12378. tr, th, insertPt;
  12379.  
  12380. // Creation ligne speciale pour AM dans le cadre "Etat"
  12381. tr = document.createElement('tr');
  12382. th = document.createElement('th');
  12383. appendText(th,'Fatigue et AM',true);
  12384. tr.appendChild(th);
  12385. insertPt = document.createElement('td');
  12386. tr.appendChild(insertPt);
  12387. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  12388.  
  12389. // Est-on en over-DLA ?
  12390. // ***INIT GLOBALE*** overDLA
  12391. overDLA = (HeureServeur>DLA.getTime()+3e5);
  12392. if(overDLA) {
  12393. fat=Math.floor(fatigue/1.25);
  12394. }
  12395.  
  12396. // Gestion des BM de fatigue
  12397. if(bmfatigue>0) {
  12398. // On tente de recuperer les BM de fatigue de la page des BM
  12399. if(MY_getValue(numTroll+'.bm.fatigue')) {
  12400. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  12401. BMmemoire.pop();
  12402. var tour = 0;
  12403. for(var i=0 ; i<BMmemoire.length ; i++) {
  12404. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  12405. while(tour<=parseInt(nbrs[0])) {
  12406. listeBmFat[tour]=parseInt(nbrs[1]);
  12407. tour++;
  12408. }
  12409. }
  12410. }
  12411. if(listeBmFat[0]==bmfatigue) {
  12412. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  12413. BMfrais = true;
  12414. MY_removeValue(numTroll+".bm.fatigue");
  12415. }
  12416. } else {
  12417. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  12418. BMfrais = true;
  12419. }
  12420. if(!BMfrais && bmfatigue>0) {
  12421. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  12422. if(bmfatigue==15) {
  12423. listeBmFat = [15,15,15];
  12424. } else {
  12425. listeBmFat = [30,30,15];
  12426. }
  12427. }
  12428. if(overDLA) {
  12429. // Si on est en over-DLA, on decale les bm d'un tour
  12430. listeBmFat.shift();
  12431. }
  12432.  
  12433. // Tableau des fatigues et accel futures
  12434. var
  12435. minppv = minParPVsac(fat,listeBmFat[0]),
  12436. table, tbody,
  12437. ligneTour, ligneFat, ligneMin,
  12438. col;
  12439. // ***INIT GLOBALE*** minParPV
  12440. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  12441. if(fat>0 || listeBmFat[0]>0) {
  12442. table = document.createElement('table');
  12443. table.className = 'mh_tdborder';
  12444. table.border = 0;
  12445. table.cellSpacing = 1;
  12446. table.cellPadding = 1;
  12447. table.style.textAlign = "center";
  12448. tbody = document.createElement('tbody');
  12449. table.appendChild(tbody);
  12450. insertPt.appendChild(table);
  12451.  
  12452. ligneTour = appendTr(tbody,'mh_tdtitre');
  12453. ligneTour.style.fontWeight = "bold";
  12454. var td = appendTdText(ligneTour,'Tour :',true);
  12455. td.align = 'left';
  12456. ligneFat = appendTr(tbody,'mh_tdpage');
  12457. td = appendTdText(ligneFat,'Fatigue :',true);
  12458. td.className = 'mh_tdtitre';
  12459. td.align = 'left';
  12460. ligneMin = appendTr(tbody,'mh_tdpage');
  12461. td = appendTdText(ligneMin,'1 PV =',true);
  12462. td.className = 'mh_tdtitre';
  12463. td.align = 'left';
  12464. col=0;
  12465. while(col<9 && (fat>0 || listeBmFat[col])) {
  12466. if(col==0) {
  12467. if(overDLA) {
  12468. var i = document.createElement('i');
  12469. appendText(i,'A activer');
  12470. ligneTour.appendChild(i);
  12471. } else {
  12472. appendTdText(ligneTour,'En cours');
  12473. }
  12474. } else {
  12475. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12476. }
  12477. if(listeBmFat[col]) {
  12478. if(BMfrais || (!overDLA && col==0)) {
  12479. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  12480. appendTdText(ligneMin,minppv[1]+'\'');
  12481. } else {
  12482. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  12483. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  12484. }
  12485. } else {
  12486. appendTdText(ligneFat,fat);
  12487. appendTdText(ligneMin,minppv[0]+'\'');
  12488. }
  12489. col++;
  12490. fat = Math.floor(fat / 1.25);
  12491. minppv = minParPVsac(fat,listeBmFat[col]);
  12492. }
  12493. if(fat>1 || (fat==1 && !overDLA)) {
  12494. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  12495. appendTdText(ligneFat,'-');
  12496. appendTdText(ligneMin,'-');
  12497. }
  12498. col = (overDLA) ?
  12499. Math.max(retourAZero(fatigue)-1,col) :
  12500. Math.max(retourAZero(fatigue),col);
  12501. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12502. appendTdText(ligneFat,'0');
  12503. appendTdText(ligneMin,'30\'');
  12504.  
  12505. if(!BMfrais && bmfatigue) {
  12506. // si les BM n'ont pas ete rafraichis, on signale:
  12507. appendText(
  12508. insertPt,
  12509. '/!\\ Visitez la page des Bonus/Malus '+
  12510. 'pour mettre à jour votre fatigue. /!\\',
  12511. true
  12512. );
  12513. appendBr(insertPt);
  12514. }
  12515. appendBr(insertPt);
  12516. }
  12517.  
  12518. if(pvcourant<=0) {
  12519. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  12520. return;
  12521. }
  12522.  
  12523. if(fatigue>30) {
  12524. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  12525. return;
  12526. }
  12527.  
  12528. // Setup lastDLAZone
  12529. if(overDLA) {
  12530. // bypass des infos de "menu_FF.js" en cas d'overDLA
  12531. DLAaccel = new Date( DLAsuiv );
  12532. lastDLA = new Date( DLA );
  12533. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  12534. // ***INIT GLOBALE*** pvActuelKastar
  12535. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  12536. appendText(
  12537. insertPt,
  12538. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  12539. true
  12540. );
  12541. appendBr(insertPt);
  12542. } else {
  12543. DLAaccel = new Date( DLA );
  12544. pvActuelKastar = pvcourant;
  12545. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  12546. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  12547. } else {
  12548. lastDLA = false;
  12549. }
  12550. }
  12551. appendText(insertPt,'Dernière DLA enregistrée : ');
  12552. lastDLAZone = document.createElement('span');
  12553. lastDLAZone.style.cursor = 'pointer';
  12554. var b = document.createElement('b');
  12555. b.onclick = inputMode;
  12556. lastDLAZone.appendChild(b);
  12557. insertPt.appendChild(lastDLAZone);
  12558. if(lastDLA) {
  12559. appendText(b,DateToString(lastDLA));
  12560. } else {
  12561. appendText(b,'aucune');
  12562. }
  12563. appendBr(insertPt);
  12564.  
  12565. // Setup maxAMZone et cumulZone
  12566. appendText(insertPt,'Accélération maximale possible : ');
  12567. maxAMZone = document.createElement('b');
  12568. insertPt.appendChild(maxAMZone);
  12569. appendBr(insertPt);
  12570. cumulZone = document.createElement('span');
  12571. insertPt.appendChild(cumulZone);
  12572.  
  12573. refreshAccel();
  12574. }
  12575.  
  12576. function refreshAccel() {
  12577. var pvs, pvsmax;
  12578.  
  12579. // Acceleration pour cumul instantane
  12580. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  12581. if(lastDLA) {
  12582. pvsmax = Math.min(
  12583. pvActuelKastar-1,
  12584. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  12585. );
  12586. maxAMZone.innerHTML = pvsmax+" PV";
  12587. } else {
  12588. pvsmax = pvActuelKastar-1;
  12589. maxAMZone.innerHTML = "inconnue";
  12590. }
  12591.  
  12592. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  12593. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  12594. cumulZone.innerHTML = '';
  12595. if(pvs<=pvsmax) {
  12596. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  12597. appendText(cumulZone,pvs+' PV', true);
  12598. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  12599. if(pvs!=1) {
  12600. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  12601. -(pvs-1)*60*minParPV;
  12602. appendText(
  12603. cumulZone,
  12604. ' ('+(pvs-1)+' PV dans '+
  12605. Math.floor(gainSec/60)+'min'+
  12606. addZero(gainSec%60)+'s)'
  12607. );
  12608. }
  12609. } else {
  12610. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  12611. appendText(
  12612. cumulZone,
  12613. 'Après votre accélération maximale, il vous faudra encore attendre '+
  12614. dureeHM(avantDLA/6e4)+
  12615. ' avant de réactiver.'
  12616. );
  12617. }
  12618. }
  12619.  
  12620.  
  12621. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  12622.  
  12623. function traitementTalents() {
  12624. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  12625. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  12626. removeAllTalents();
  12627. var totalComp = injecteInfosBulles(trCompetence,'competences');
  12628. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  12629. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  12630. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  12631. }
  12632.  
  12633. function injecteInfosBulles(liste,fonction) {
  12634. var totalpc = 0;
  12635. // on parse la liste des talents du type 'fonction'
  12636. for(var i=0 ; i<liste.length ; i++) {
  12637. var
  12638. trTalent=liste[i],
  12639. node=trTalent.cells[1].querySelector('a'),
  12640. nomTalent=epure(trim(node.textContent)),
  12641. indiceTDniveaux=7,
  12642. indiceTDSousCompetence=2,
  12643. sousCompetences=undefined;
  12644. if(fonction=="competences"){
  12645. // un TD en plus pour des information complementaire liees a la comp
  12646. indiceTDniveaux++;
  12647. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  12648. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  12649. for (var j=0; j < sousCompetences.length; j++) {
  12650. sousCompetences[j] = sousCompetences[j].epure().trim();
  12651. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  12652. }
  12653. }
  12654. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  12655. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  12656. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  12657. totalpc += niveauxMaitrisesTalentArray[1];
  12658.  
  12659. // stockage des niveaux inferieurs du talent si presents
  12660. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  12661. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  12662. totalpc+=niveauxMaitrisesTalentArray[j+1];
  12663. }
  12664. }
  12665. return totalpc;
  12666. }
  12667.  
  12668. function setInfos(node,nom,fonction,niveau) {
  12669. node.nom = nom;
  12670. node.fonction = fonction;
  12671. node.niveau = niveau;
  12672. node.onmouseover = setBulle;
  12673. node.onmouseout = cacherBulle;
  12674. }
  12675.  
  12676. var arrayModifAnatroll = {
  12677. 'Glue':'Glu',
  12678. 'PuM':'PuiM',
  12679. 'HE':'Hurlement',
  12680. //'Insultes':'Insu',
  12681. 'Pistage':'Pist',
  12682. 'PuC':'Planter',
  12683. 'Golemo':'Golem',
  12684. }
  12685.  
  12686. function setTalent(nom,pc,niveau,sousCompetences) {
  12687. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  12688. // (et pas les % dont osf) ne serait pas plus rentable
  12689. var nomEnBase = arrayTalents[epure(nom)];
  12690. if(!nomEnBase) {
  12691. debugMZ("setTalent: le talent "+nom+" n'est pas dans la base MZ");
  12692. return;
  12693. }
  12694. if(!niveau) { niveau = 1; }
  12695.  
  12696. switch(nomEnBase) {
  12697. case 'Insultes':
  12698. urlAnatrolliseur += 'Insu'+niveau+'|';
  12699. case 'IdT':
  12700. nomEnBase += niveau;
  12701. break;
  12702. case 'Piege':
  12703. for (var i=0 ; i < sousCompetences.length ; i++) {
  12704. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  12705. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  12706. }
  12707. break;
  12708. case 'AP':
  12709. case 'Baroufle':
  12710. case 'CdB':
  12711. case 'CdM':
  12712. case 'Parer':
  12713. case 'Retraite':
  12714. case 'RB':
  12715. case 'SInterposer':
  12716. nomEnBase += niveau;
  12717. default:
  12718. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  12719. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  12720. }
  12721. //debugMZ("setTalent: nom=" + nom + ", pc=" + pc + ", niveau=" + niveau + ", sousCompetences=" + JSON.stringify(sousCompetences) + "=>setValue(" + numTroll+'.talent.'+nomEnBase+", " + pc + ")");
  12722. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  12723. }
  12724.  
  12725. function creerBulleVide() {
  12726. var table = document.createElement('table');
  12727. table.id = 'bulle';
  12728. table.className = 'mh_tdborder';
  12729. table.width = 300;
  12730. table.border = 0;
  12731. table.cellPadding = 5;
  12732. table.cellSpacing = 1;
  12733. table.style =
  12734. 'position:absolute;'
  12735. +'visibility:hidden;'
  12736. +'z-index:800;'
  12737. +'height:auto;';
  12738. var tr = appendTr(table,'mh_tdtitre');
  12739. appendTdText(tr,'Titre');
  12740. tr = appendTr(table,'mh_tdpage');
  12741. appendTdText(tr,'Contenu');
  12742. var aList = document.getElementsByTagName('a');
  12743. aList[aList.length-1].parentNode.appendChild(table);
  12744. }
  12745.  
  12746. function cacherBulle() {
  12747. if(bulleStyle)
  12748. bulleStyle.visibility = 'hidden';
  12749. }
  12750.  
  12751. function setBulle(evt) {
  12752. var nom = this.nom;
  12753. var fonction = this.fonction;
  12754. var niveau = parseInt(this.niveau);
  12755. var str='';
  12756. if(fonction=='competences'){
  12757. str=competences(nom,niveau);
  12758. } else if(fonction=='sortileges') {
  12759. str=sortileges(nom);
  12760. }
  12761. if(str=='') return;
  12762. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  12763.  
  12764. var xfenetre, yfenetre, xpage, ypage, element = null;
  12765. var offset = 15;
  12766. var bulleWidth = 300;
  12767. if(!hauteur) hauteur = 50;
  12768. element = document.getElementById('bulle');
  12769. xfenetre = evt.clientX;
  12770. yfenetre = evt.clientY;
  12771. xpage = xfenetre;
  12772. ypage = yfenetre;
  12773. if(evt.pageX) xpage = evt.pageX;
  12774. if(evt.pageY) ypage = evt.pageY;
  12775. if(element) {
  12776. bulleStyle = element.style;
  12777. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  12778. element.childNodes[1].firstChild.innerHTML = str;
  12779. }
  12780. if(bulleStyle) {
  12781. if(xfenetre>bulleWidth+offset)
  12782. xpage -= bulleWidth+offset;
  12783. else
  12784. xpage += offset;
  12785. if(yfenetre>hauteur+offset)
  12786. ypage -= hauteur + offset;
  12787. bulleStyle.width = bulleWidth;
  12788. bulleStyle.left = xpage + 'px';
  12789. bulleStyle.top = ypage + 'px';
  12790. bulleStyle.visibility = 'visible';
  12791. }
  12792. }
  12793.  
  12794.  
  12795. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  12796.  
  12797. function competences(comp,niveau) {
  12798. var
  12799. modA = atttour?Math.floor((att+atttourD)*atttour/100):0,
  12800. modD = degtour?Math.floor(deg*degtour/100):0,
  12801. texte = "";
  12802.  
  12803. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  12804. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  12805. if(minParPV>1) texte += 's';
  12806. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  12807. } else if(comp.indexOf("Attaque Precise")!=-1) {
  12808. var
  12809. i, pc,
  12810. lastmax=0,
  12811. jetatt, espatt=0,
  12812. notMaxedOut = false;
  12813.  
  12814. for(i=niveau ; i>0 ; i--) {
  12815. pc = getTalent(comp,i);
  12816. if(lastmax!=0 && pc<=lastmax) {
  12817. // Si %AP(i)<%AP(i+1), on passe AP(i)
  12818. continue;
  12819. }
  12820. jetatt = Math.round(3.5*(
  12821. Math.min(Math.floor(1.5*att), att+3*i) + modA
  12822. )) + attbp+attbm;
  12823. espatt += (pc-lastmax)*jetatt;
  12824. texte += "Attaque niv. "+i +
  12825. " ("+(pc-lastmax)+"%) : <b>" +
  12826. Math.min(Math.floor(att*1.5), att+3*i)+"</b> D6 ";
  12827. if(modA) {
  12828. texte += "<i>"+aff(modA)+"D6</i> ";
  12829. }
  12830. texte += aff(attbp+attbm)+" => <b>"+jetatt+"</b><br>";
  12831. lastmax = pc;
  12832. if(i<niveau) {
  12833. // Si l'un des % de niveau inf est > % nivmax,
  12834. // on affiche l'espérance à la fin
  12835. notMaxedOut = true;
  12836. }
  12837. }
  12838. if(notMaxedOut) {
  12839. texte += "<i>Attaque moyenne (si réussite) : <b>" +
  12840. Math.floor(10*espatt/lastmax)/10+"</b></i><br>";
  12841. }
  12842. texte += "Dégâts : <b>"+deg+"</b> D3 ";
  12843. if(modD) {
  12844. texte += "<i>"+aff(modD)+"D3</i> ";
  12845. }
  12846. texte += aff(degbp+degbm) +
  12847. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  12848. } else if(comp.indexOf("Balayage")!=-1) {
  12849. texte = "Déstabilisation : <b>"+att+"</b> D6 ";
  12850. if(modA) {
  12851. texte += "<i>"+aff(modA)+"D6</i> ";
  12852. }
  12853. texte += aff(attbp+attbm) +
  12854. " => <b>"+attmoytour+"</b><br>" +
  12855. "Effet : <b>Met à terre l'adversaire</b>";
  12856. } else if(comp.indexOf('Bidouille')!=-1)
  12857. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  12858. +'de votre inventaire avec le texte de votre choix.';
  12859. else if(comp.indexOf('Baroufle')!=-1){
  12860. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  12861. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  12862. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  12863. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  12864. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  12865. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  12866. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  12867. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  12868. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  12869. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  12870. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  12871. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  12872. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  12873. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  12874. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  12875. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  12876. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  12877. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  12878. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  12879. '</tbody></table>';
  12880. } else if(comp.indexOf("Botte Secrete")!=-1) {
  12881. modA = atttour?Math.floor(Math.floor(2*att/3)*atttour/100):0;
  12882. modD = degtour?Math.floor(Math.floor(att/2)*degtour/100):0;
  12883. texte = "Attaque : <b>"+Math.floor(2*att/3)+"</b> D6 ";
  12884. if(modA) {
  12885. texte += "<i>"+aff(modA)+"D6</i> ";
  12886. }
  12887. texte += aff(Math.floor((attbp+attbm)/2)) +
  12888. " => <b>"+Math.round(
  12889. 3.5*(Math.floor(2*att/3)+modA)+Math.floor((attbp+attbm)/2)
  12890. )+"</b><br/>Dégâts : <b>"+Math.floor(att/2)+"</b> D3 ";
  12891. if(modD) {
  12892. texte += "<i>"+aff(modD)+"D3</i> ";
  12893. }
  12894. texte += aff(Math.floor((degbp+degbm)/2))+" => <b>" +
  12895. (2*(Math.floor(att/2)+modD)+Math.floor((degbp+degbm)/2)) +
  12896. "/"+(
  12897. 2*(Math.floor(1.5*Math.floor(att/2))+modD) +
  12898. Math.floor((degbp+degbm)/2)
  12899. )+"</b>";
  12900. } else if(comp.indexOf('Camouflage')!=-1) {
  12901. var camou = getTalent('Camouflage');
  12902. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  12903. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  12904. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  12905. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  12906. } else if(comp.indexOf("Charger")!=-1) {
  12907. if(pvcourant<=0) {
  12908. // N'est plus censé se produire : activation obligatoire si mort
  12909. return "<i>On ne peut charger personne quand on est mort !</i>";
  12910. }
  12911. var portee = Math.min(
  12912. Math.max(
  12913. getPortee__Profil(reg+Math.floor(pvcourant/10)) -
  12914. Math.floor((fatigue+bmfatigue)/5),
  12915. 1
  12916. ),
  12917. vuetotale
  12918. );
  12919. if(portee<1) {
  12920. return "<b>Impossible de charger</b>";
  12921. }
  12922. texte = "Attaque : <b>"+att+"</b> D6 ";
  12923. if(modA) {
  12924. texte += "<i>"+aff(modA)+"D6</i> ";
  12925. }
  12926. texte += aff(attbp+attbm) +
  12927. " => <b>"+attmoytour+"</b><br>" +
  12928. "Dégâts : <b>"+deg+"</b> D3 ";
  12929. if(modD) {
  12930. texte += "<i>"+aff(modD)+"D3</i> ";
  12931. }
  12932. texte += aff(degbp+degbm) +
  12933. " => <b>"+degmoytour+"/"+degmoycrittour+"</b><br>" +
  12934. "Portée : <b>"+portee+"</b> case";
  12935. if(portee>1) { texte += "s"; }
  12936. } else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  12937. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  12938. if(vuetotale>1) texte += 's';
  12939. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  12940. if(vuetotale>2) texte += 's';
  12941. }
  12942. else if(comp.indexOf('Piege')!=-1) {
  12943. texte = 'Piège à Glue :<ul><li>Et si vous colliez vos adversaires au sol ?</li></ul>';
  12944. texte += 'Piège à Feu: <ul><li>À moins que vous ne préfériez les envoyer en l\'air !</li>';
  12945. texte += '<li>Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  12946. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b></li></ul>';
  12947. } else if(comp.indexOf("Contre-Attaquer")!=-1) {
  12948. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  12949. texte = "Attaque : <b>"+Math.floor(att/2)+"</b> D6 ";
  12950. if(modA) {
  12951. texte += "<i>"+aff(modA)+"D6</i> ";
  12952. }
  12953. texte += aff(Math.floor((attbp+attbm)/2)) +
  12954. " => <b>"+Math.round(
  12955. 3.5*(Math.floor(att/2)+modA)+Math.floor((attbp+attbm)/2)
  12956. )+"</b><br>" +
  12957. "Dégâts : <b>"+deg+"</b> D3 ";
  12958. if(modD) {
  12959. texte += "<i>"+aff(modD)+"D3</i> ";
  12960. }
  12961. texte += aff(degbp+degbm) +
  12962. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  12963. } else if(comp.indexOf("Coup de Butoir")!=-1) {
  12964. var
  12965. i, pc,
  12966. lastmax=0,
  12967. jetdeg, espdeg=0,
  12968. notMaxedOut = false;
  12969.  
  12970. texte = "Attaque : <b>"+att+"</b> D6 ";
  12971. if(modA) {
  12972. texte += "<i>"+aff(modA)+"D6</i> ";
  12973. }
  12974. texte += aff(attbp+attbm) +
  12975. " => <b>"+attmoytour+"</b>";
  12976. for(i=niveau ; i>0 ; i--) {
  12977. pc = getTalent(comp,i);
  12978. if(lastmax!=0 && pc<=lastmax) {
  12979. // Si %CdB(i)<%CdB(i+1), on passe CdB(i)
  12980. continue;
  12981. }
  12982. jetdeg = 2*(
  12983. Math.min(Math.floor(1.5*deg), deg+3*i) + modD
  12984. ) + degbp+degbm;
  12985. espdeg += (pc-lastmax)*jetdeg;
  12986. texte += "<br>Dégâts niv. "+i+" ("+(pc-lastmax)+"%) : <b>" +
  12987. Math.min(Math.floor(deg*1.5),deg+3*i)+"</b> D3 ";
  12988. if(modD) {
  12989. texte += "<i>"+aff(modD)+"D3</i> ";
  12990. }
  12991. texte += aff(degbp+degbm) +
  12992. " => <b>"+jetdeg +
  12993. "/"+(jetdeg+2*Math.floor(deg/2))+"</b>";
  12994. lastmax = pc;
  12995. if(i<niveau) {
  12996. // Si l'un des % de niveau inf est > % nivmax,
  12997. // on affiche l'espérance à la fin
  12998. notMaxedOut = true;
  12999. }
  13000. }
  13001. if(notMaxedOut) {
  13002. texte += "<br><i>Dégâts moyens (si réussite) : <b>" +
  13003. Math.floor(10*espdeg/lastmax)/10+"/" +
  13004. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2)) +
  13005. "</b></i>";
  13006. }
  13007. } else if(comp.indexOf('Course')!=-1)
  13008. texte = 'Déplacement gratuit : <b>'
  13009. +Math.floor(getTalent('Course')/2)
  13010. +' %</b> de chance';
  13011. else if(comp.indexOf('Deplacement Eclair')!=-1)
  13012. texte = 'Permet d\'économiser <b>1</b> PA '
  13013. +'par rapport au déplacement classique';
  13014. else if(comp.indexOf('Dressage')!=-1)
  13015. texte = 'Le dressage permet d\'apprivoiser un Gowap redevenu sauvage, un Mouch\'oo Sauvage '
  13016. +'ou un Gnu Sauvage. La portée est de une case.';
  13017. else if(comp.indexOf('Ecriture Magique')!=-1)
  13018. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  13019. +'la formule nécessite de réunir les composants de cette formule, '
  13020. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  13021. +'un champignon adéquat pour confectionner l\'encre.';
  13022. else if(comp.indexOf('Frenesie')!=-1) {
  13023. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  13024. +' => <b>'+attmoy+'</b><br/>'
  13025. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  13026. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  13027. }
  13028. else if(comp.indexOf('Golem')!=-1)
  13029. texte = 'Animez votre golem en assemblant divers matériaux '
  13030. +'autour d\'un cerveau minéral.'
  13031. else if(comp.indexOf('Grattage')!=-1) {
  13032. texte = 'Permet de confectionner un Parchemin Vierge '
  13033. +'à partir de composants et de Gigots de Gob\'.';
  13034. }
  13035. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  13036. texte = 'Fait fuir un monstre si tout se passe bien.'
  13037. +'<br/>Lui donne de gros bonus sinon...';
  13038. else if(comp.indexOf('Identification des Champignons')!=-1) {
  13039. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  13040. if(vuetotale>2) texte += 's';
  13041. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  13042. if(vuetotale>4) texte += 's';
  13043. }
  13044. else if(comp.indexOf('Insultes')!=-1)
  13045. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  13046. else if(comp.indexOf('interposer')!=-1)
  13047. texte = 'Jet de réflexe : <b>'
  13048. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  13049. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  13050. else if(comp.indexOf('Lancer de Potions') != -1)
  13051. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  13052. else if(comp.indexOf('Marquage')!=-1)
  13053. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  13054. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  13055. +'se trouver dans la même caverne que le monstre pour le marquer.';
  13056. else if(comp.indexOf('Melange Magique')!=-1)
  13057. texte = 'Cette Compétence permet de combiner deux Potions pour '
  13058. +'en réaliser une nouvelle dont l\'effet est la somme '
  13059. +'des effets des potions initiales.';
  13060. else if(comp.indexOf('Travail de la Pierre')!=-1)
  13061. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  13062. +2*vuetotale+'</b> cases</li>'
  13063. +'<li>Portée verticale (officieuse) : <b>'
  13064. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  13065. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  13066. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  13067. else if(comp.indexOf('Necromancie')!=-1)
  13068. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  13069. +'de faire "revivre" ce monstre.';
  13070. else if(comp.indexOf('Painthure de Guerre')!=-1)
  13071. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  13072. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  13073. +'pour s\'inspirer, et laissez parler votre créativité.'
  13074. else if(comp.indexOf("Parer")!=-1) {
  13075. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  13076. texte = "Jet de parade : <b>"+Math.floor(att/2)+"</b> D6 ";
  13077. if(modA) {
  13078. texte += "<i>"+aff(modA)+"D6</i> ";
  13079. }
  13080. texte += aff(Math.floor((attbp+attbm)/2)) +
  13081. " => <b>"+Math.round(
  13082. 3.5*(Math.floor(att/2)+modA) +
  13083. Math.floor((attbp+attbm)/2)
  13084. )+"</b><hr>Equivalent esquive : <b>" +
  13085. (Math.floor(att/2)+esq)+"</b> D6 ";
  13086. if(modA) {
  13087. texte += "<i>"+aff(modA)+"D6</i> ";
  13088. }
  13089. texte += aff(Math.floor((attbp+attbm)/2)+esqbp+esqbm) +
  13090. " => <b>"+(Math.round(
  13091. 3.5*(Math.floor(att/2)+modA+esq) +
  13092. Math.floor((attbp+attbm)/2)
  13093. )+esqbp+esqbm)+"</b></i>";
  13094. } else if(comp.indexOf('Pistage')!=-1)
  13095. texte = 'Portée horizontale : <b>'
  13096. +2*vuetotale+'</b> cases<br/>'
  13097. +'Portée verticale : <b>'
  13098. +2*Math.ceil(vuetotale/2)+'</b> cases';
  13099. else if(comp.indexOf('Planter un Champignon')!=-1)
  13100. texte = 'Planter un Champignon est une compétence qui vous permet de '
  13101. +'créer des colonies d\'une variété donnée de champignon à partir de '
  13102. +'quelques exemplaires préalablement enterrés.';
  13103. else if(comp.indexOf('Regeneration Accrue')!=-1)
  13104. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  13105. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  13106. else if(comp.indexOf('Reparation')!=-1)
  13107. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  13108. +'et réparez vous-même votre matériel !';
  13109. else if(comp.indexOf('Retraite')!=-1)
  13110. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  13111. +'préférable de préparer un repli stratégique pour déconcerter '
  13112. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  13113. +'Quelle intelligence démoniaque.';
  13114. else if(comp.indexOf("RotoBaffe")!=-1) {
  13115. var
  13116. Datt = att, vattbm = attbp+attbm,
  13117. Ddeg = deg, vdegbm = degbp+degbm;
  13118. for(var i=1 ; i<niveau+2 ; i++) {
  13119. texte += "<b>Attaque n°"+i+" :</b><br>" +
  13120. "Attaque : <b>"+Datt+"</b> D6 ";
  13121. if(modA) {
  13122. texte += "<i>"+aff(modA)+"D6</i> ";
  13123. }
  13124. texte += aff(vattbm) +
  13125. " => <b>"+(Math.round(3.5*(Datt+modA))+vattbm)+"</b><br>" +
  13126. "Dégâts : <b>"+Ddeg+"</b> D3 ";
  13127. if(modD) {
  13128. texte += "<i>"+aff(modD)+"D3</i> ";
  13129. }
  13130. texte += aff(vdegbm) +
  13131. " => <b>"+(2*(Ddeg+modD)+vdegbm) +
  13132. "/"+(2*(Math.floor(1.5*Ddeg)+modD)+vdegbm)+"</b>";
  13133. Datt = Math.floor(0.75*Datt);
  13134. modA = atttour?Math.floor((Datt+atttourD)*atttour/100):0;
  13135. vattbm = Math.floor(0.75*vattbm);
  13136. Ddeg = Math.floor(0.75*Ddeg);
  13137. modD = degtour?Math.floor(Ddeg*degtour/100):0;
  13138. vdegbm = Math.floor(0.75*vdegbm);
  13139. if(i<niveau+1) { texte += "<hr>"; }
  13140. }
  13141. } else if(comp.indexOf('Shamaner')!=-1)
  13142. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  13143. +'des monstres en utilisant des champignons (de 1 à 3).';
  13144. return texte;
  13145. }
  13146.  
  13147. function sortileges(sort) {
  13148. var
  13149. // Fonctions utiles uniquement à "sortileges"
  13150. decumul_buff = function(nom,str,buff) {
  13151. // Décumul des sorts de buff (old school)
  13152. var
  13153. txt = "1<sup>ere</sup>"+nom+" : <b>"+str+" +"+buff+"</b>",
  13154. dec = buff,
  13155. total = buff,
  13156. i=1;
  13157. while(i<6) {
  13158. i++;
  13159. dec = Math.floor(coefDecumul(i)*buff);
  13160. if(dec<=1 || i==6) break;
  13161. total += dec;
  13162. txt += "<br/><i>"+i+"<sup>e</sup> "+nom+" : "+
  13163. str+" +"+dec+" (+"+total+")</i>";
  13164. }
  13165. txt += "<br/><i>"+i+"<sup>e</sup> et + : "+str+" +"+dec+"</i>";
  13166. return txt;
  13167. },
  13168. nbrAdX = function(pc) {
  13169. // Détermine le nombre d'AdX actifs à partir du % de D
  13170. switch(Number(pc)) {
  13171. case 0 : return 0;
  13172. case 20: return 1;
  13173. case 33: return 2;
  13174. case 41: return 3;
  13175. case 46: return 4;
  13176. default: return Math.floor((Number(pc)-39)/2);
  13177. }
  13178. },
  13179. decumulPc = function(n) {
  13180. // Détermine le % de D décumulé du n-ième AdX
  13181. switch(Number(n)) {
  13182. case 0: return 0;
  13183. case 1: return 20;
  13184. case 2: return 13;
  13185. case 3: return 8;
  13186. case 4: return 5;
  13187. case 5: return 3;
  13188. default: return 2;
  13189. }
  13190. },
  13191. decumulFixe = function(bm, n) {
  13192. // Détermine le bonus fixe décumulé du n-ième AdX
  13193. switch(Number(n)) {
  13194. case 0: return 0;
  13195. case 1: return Math.max(1,bm);
  13196. case 2: return Math.max(1,Math.round(bm*6.7)/10);
  13197. case 3: return Math.max(1,Math.round(bm*4)/10);
  13198. default: return 1; // Sous les 1 de moyenne même en D6
  13199. }
  13200. },
  13201. texte = "";
  13202.  
  13203. if (sort.indexOf('Analyse Anatomique') != -1) {
  13204. texte = 'Portée horizontale : <b>'
  13205. + Math.floor(vuetotale / 2) + '</b> case';
  13206. if (vuetotale > 3){ texte += 's'; }
  13207. texte += '<br/>Portée verticale : <b>'
  13208. + Math.floor((vuetotale+1)/4)+'</b> case';
  13209. if (vuetotale > 7){ texte += 's'; }
  13210. } else if (sort.indexOf('Armure Etheree') != -1) {
  13211. texte = decumul_buff('AE', 'Armure magique', reg);
  13212. } else if (sort.indexOf("Augmentation")!=-1 && sort.indexOf("Attaque")!=-1) {
  13213. var
  13214. categoriesAdA = {
  13215. "attx1": {
  13216. // Affichage: code MZ (cf arrayTalents)
  13217. "AN": true,
  13218. "AP": "AP1",
  13219. "Balayage": "Balayage",
  13220. "Charge": "Charger",
  13221. "CdB": "CdB1",
  13222. "Frénésie": "Frenesie",
  13223. "RB": "RB1",
  13224. "GdS": "GdS",
  13225. "Siphon": "Siphon"
  13226. },
  13227. "attx2/3": {
  13228. "Botte Secrète": "BS"
  13229. },
  13230. "attx1/2": {
  13231. "CA": "CA",
  13232. "Parer": "Parer1"
  13233. },
  13234. "degx2/3": {
  13235. "Vampirisme": "Vampi"
  13236. },
  13237. "vuex1": {
  13238. "Projectile Magique": "Projo"
  13239. }
  13240. },
  13241. baseAdA = {
  13242. "attx1" : att,
  13243. "attx2/3": Math.floor(2*att/3),
  13244. "attx1/2": Math.floor(att/2),
  13245. "degx2/3": Math.floor(2*deg/3),
  13246. "vuex1" : vue
  13247. },
  13248. pc = atttour,
  13249. pcInit = pc,
  13250. nbrAdA = nbrAdX(pc),
  13251. categorie, talent, newTalent,
  13252. i, DSup, fixe=0;
  13253.  
  13254. i=nbrAdA;
  13255. while(i++<nbrAdA+3) {
  13256. pc += decumulPc(i);
  13257. fixe += decumulFixe(3.5,i);
  13258. if(texte) { texte += "<hr>"; }
  13259. texte += "<b>"+i+"<sup>e</sup> AdA : " +
  13260. aff(pc)+"% de Dés d'attaque :</b><br>";
  13261. for(categorie in categoriesAdA) {
  13262. // On génére la liste: "talent1, talent2"
  13263. DSup = Math.floor(baseAdA[categorie]*pc/100) -
  13264. Math.floor(baseAdA[categorie]*pcInit/100);
  13265. newTalent = false;
  13266. for(var talent in categoriesAdA[categorie]) {
  13267. if(getTalent(categoriesAdA[categorie][talent])) {
  13268. if(newTalent) { texte += ", "; }
  13269. texte += talent;
  13270. newTalent = true;
  13271. }
  13272. }
  13273. if(newTalent) {
  13274. // Si le trõll a au moins un talent dans la catégorie :
  13275. texte += ": <b>+"+DSup+"D6 +"+Math.floor(fixe)+"</b> <i>(+" +
  13276. Math.floor(3.5*DSup+fixe) +")</i><br>";
  13277. }
  13278. }
  13279. }
  13280. } else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1) {
  13281. texte = decumul_buff('AdE', 'Esquive', Math.floor((esq-1)/2));
  13282. } else if (sort.indexOf("Augmentation des Degats")!=-1) {
  13283. var
  13284. categoriesAdD = {
  13285. "attx1/2": {
  13286. "Botte Secrète": "BS"
  13287. },
  13288. "degx1": {
  13289. "AN": true,
  13290. "AP": "AP1",
  13291. "Charge": "Charger",
  13292. "CA": "CA",
  13293. "CdB": "CdB1",
  13294. "Frénésie": "Frenesie",
  13295. "RB": "RB1",
  13296. "Rafale": "Rafale",
  13297. "Vampi": "Vampi"
  13298. },
  13299. "degx1/2": {
  13300. "Griffe du Sorcier": "GdS"
  13301. },
  13302. "vuex1/2": {
  13303. "Projectile Magique": "Projo"
  13304. },
  13305. "regx1": {
  13306. "Siphon des Âmes": "Siphon"
  13307. }
  13308. },
  13309. baseAdD = {
  13310. "attx1/2": Math.floor(att/2),
  13311. "degx1" : deg,
  13312. "degx1/2": Math.floor(deg/2),
  13313. "vuex1/2": Math.floor(vue/2),
  13314. "regx1" : reg
  13315. },
  13316. pc = degtour,
  13317. pcInit = pc,
  13318. nbrAdD = nbrAdX(pc),
  13319. categorie, talent, newTalent,
  13320. i, DSup, fixe=0;
  13321.  
  13322. i=nbrAdD;
  13323. while(i++<nbrAdD+3) {
  13324. pc += decumulPc(i);
  13325. fixe += decumulFixe(2,i);
  13326. if(texte) { texte += "<hr>"; }
  13327. texte += "<b>"+i+"<sup>e</sup> AdD : " +
  13328. aff(pc)+"% de Dés de dégâts :</b><br>";
  13329. for(categorie in categoriesAdD) {
  13330. // On génére la liste: "talent1, talent2"
  13331. DSup = Math.floor(baseAdD[categorie]*pc/100) -
  13332. Math.floor(baseAdD[categorie]*pcInit/100);
  13333. newTalent = false;
  13334. for(var talent in categoriesAdD[categorie]) {
  13335. if(getTalent(categoriesAdD[categorie][talent])) {
  13336. if(newTalent) { texte += ", "; }
  13337. texte += talent;
  13338. newTalent = true;
  13339. }
  13340. }
  13341. if(newTalent) {
  13342. // Si le trõll a au moins un talent dans la catégorie :
  13343. texte += ": <b>+"+DSup+"D3 +"+Math.floor(fixe) +
  13344. "</b> <i>(+"+Math.floor(2*DSup+fixe) +
  13345. ")</i><br>";
  13346. }
  13347. }
  13348. }
  13349. } else if(sort.indexOf('Bulle Anti-Magie')!=-1) {
  13350. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  13351. }
  13352. else if(sort.indexOf('Bulle Magique')!=-1){
  13353. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  13354. }
  13355. else if(sort.indexOf('Explosion')!=-1){
  13356. texte = 'Dégâts : <b>'
  13357. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  13358. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  13359. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  13360. }
  13361. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  13362. if(pvcourant<=0)
  13363. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  13364. texte = 'Portée horizontale : <b>'
  13365. +Math.min(1,vuetotale)+'</b> case<br/>'
  13366. +'Dégâts physiques : <b>-'
  13367. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  13368. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  13369. +'Dégâts magiques : <b>-'
  13370. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  13371. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  13372. }
  13373. else if(sort.indexOf('Flash Aveuglant')!=-1){
  13374. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  13375. }
  13376. else if(sort.indexOf('Glue')!=-1) {
  13377. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  13378. if(vuetotale>2) texte += 's';
  13379. } else if(sort.indexOf("Griffe du Sorcier")!=-1) {
  13380. var
  13381. modD =0,
  13382. addVenin = function(type, effet, duree) {
  13383. var
  13384. ret = "<b>Venin "+type+" : </b><br/><b>" +
  13385. effet+"</b> D3" +
  13386. " pendant <b>"+duree+"</b> tour",
  13387. dureeReduite = Math.max(Math.floor(duree/2),1);
  13388. if(duree>1) {
  13389. ret += "s";
  13390. }
  13391. return ret +
  13392. " => <b>"+2*effet+" x "+duree+" = "+2*effet*duree +
  13393. "</b> ("+2*effet+" x "+dureeReduite+" = " +
  13394. 2*effet*dureeReduite+")";
  13395. },
  13396. effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  13397. // Frappe
  13398. texte = "Attaque : <b>"+att+"</b> D6 ";
  13399. if(atttour!=0) {
  13400. modD = Math.floor(att*atttour/100);
  13401. texte += "<i>"+aff(modD)+"D6</i> ";
  13402. }
  13403. texte += aff(attbm)
  13404. +" => <b>"+(Math.round(3.5*(att+modD))+attbm)+"</b><br/>"
  13405. +"Dégâts : <b>"+Math.floor(deg/2)+"</b> D3 ";
  13406. if(degtour!=0) {
  13407. modD = Math.floor(Math.floor(deg/2)*degtour/100);
  13408. texte += "<i>"+aff(modD)+"D3</i> ";
  13409. } else {
  13410. modD = 0;
  13411. }
  13412. texte += aff(degbm) +
  13413. " => <b>"+(2*(Math.floor(deg/2)+modD)+degbm) +
  13414. "/"+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm) +
  13415. " ("+resiste(Math.floor(deg/2)+modD,degbm) +
  13416. "/"+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm) +
  13417. ")</b>";
  13418. // Venins
  13419. texte += "<hr>"+addVenin("insidieux",effet,2+Math.floor(vue/5));
  13420. effet = Math.floor(1.5*effet);
  13421. texte += "<hr>"+addVenin("virulent",effet,1+Math.floor(vue/10));
  13422. } else if(sort.indexOf('Hypnotisme')!=-1)
  13423. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  13424. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  13425. else if(sort.indexOf('Identification des Tresors')!=-1)
  13426. texte = 'Permet de connaitre les caractéristiques et effets précis '
  13427. +'d\'un trésor.';
  13428. else if(sort.indexOf('Invisibilite')!=-1)
  13429. texte = 'Un troll invisible est indétectable même quand on se trouve '
  13430. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  13431. +'fait disparaître l\'invisibilité.';
  13432. else if(sort.indexOf('Levitation')!=-1)
  13433. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  13434. +'Comme les pièges ou les trous par exemple...';
  13435. else if(sort.indexOf("Projectile Magique")!=-1) {
  13436. var
  13437. modD = 0,
  13438. portee = getPortee__Profil(vuetotale);
  13439. // Att
  13440. texte = "Attaque : <b>"+vue+"</b> D6 ";
  13441. if(atttour!=0) {
  13442. modD = Math.floor(vue*atttour/100);
  13443. texte += "<i>"+aff(modD)+"D6</i> ";
  13444. }
  13445. texte += aff(attbm) +
  13446. " => <b>"+(Math.round(3.5*(vue+modD))+attbm)+"</b><br>" +
  13447. "Dégâts : <b>"+Math.floor(vue/2)+"</b> D3 ";
  13448. // Deg
  13449. if(degtour!=0) {
  13450. modD = Math.floor(Math.floor(vue/2)*degtour/100);
  13451. texte += "<i>"+aff(modD)+"D3</i> ";
  13452. } else {
  13453. modD = 0;
  13454. }
  13455. texte += aff(degbm) +
  13456. " => <b>"+(2*(Math.floor(vue/2)+modD)+degbm) +
  13457. "/"+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm) +
  13458. " ("+resiste(Math.floor(vue/2)+modD,degbm) +
  13459. "/"+resiste(1.5*Math.floor(vue/2)+modD,degbm) +
  13460. ") (+ 1D3 par bonus de portée)</b>";
  13461. // Portée
  13462. texte += "<br/>Portée : <b>"+portee+"</b> case";
  13463. if(portee>1) texte += "s";
  13464. } else if(sort.indexOf('Projection')!=-1) {
  13465. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  13466. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  13467. +'Si le jet de résistance de la victime est réussi:<br/>'
  13468. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  13469. } else if(sort.indexOf("Rafale Psychique")!=-1) {
  13470. var modD = 0;
  13471. texte = "Dégâts : <b>"+deg+"</b> D3 ";
  13472. if(degtour!=0) {
  13473. modD = Math.floor(deg*degtour/100);
  13474. texte += "<i>"+aff(modD)+"D3</i> ";
  13475. }
  13476. texte += aff(degbm) +
  13477. " => <b>"+(2*(deg+modD)+degbm) +
  13478. " ("+resiste(deg+modD,degbm)+")</b><br>" +
  13479. "Malus : régénération <b>-"+(deg+modD)+"</b>";
  13480. } else if(sort.indexOf("Sacrifice")!=-1) {
  13481. if(pvcourant<=0) {
  13482. // N'est plus censé se produire : activation obligatoire si mort
  13483. return "<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>";
  13484. }
  13485. var
  13486. perteSacro = function(sac) {
  13487. return " (-"+(sac+2*(1+Math.floor(sac/5)))+" PV)";
  13488. },
  13489. sac = Math.floor((pvcourant-1)/2),
  13490. pvdispoSansMalusTemps =
  13491. pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  13492.  
  13493. texte = "Portée horizontale : <b>" +
  13494. Math.min(1,vuetotale)+"</b> case<br>" +
  13495. "Soin maximal : <b>"+sac+"</b> PV"+perteSacro(sac);
  13496. // Sacros max et optimal sans malus (propale R')
  13497. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  13498. if(sac>0) {
  13499. texte += "<hr>Soin maximum limitant les risques de malus " +
  13500. "de temps : <b>" +sac+"</b> PV"+perteSacro(sac);
  13501. } else {
  13502. texte += "<hr>Vous ne pouvez pas compenser de blessures " +
  13503. "dues à un sacrifice";
  13504. }
  13505. } else if(sort.indexOf("Siphon")!=-1) {
  13506. var modD = 0;
  13507. texte = "Attaque : <b>"+att+"</b> D6 ";
  13508. if(atttour!=0) {
  13509. modD = Math.floor(att*atttour/100);
  13510. texte += "<i>"+aff(modD)+"D6</i> ";
  13511. }
  13512. texte += aff(attbm) +
  13513. " => <b>"+Math.round(3.5*(att+modD)+attbm)+"</b><br>" +
  13514. "Dégâts : <b>"+reg+"</b> D3 ";
  13515. if(degtour!=0) {
  13516. modD = Math.floor(reg*degtour/100);
  13517. texte += "<i>"+aff(modD)+"D3</i> ";
  13518. } else {
  13519. modD = 0;
  13520. }
  13521. texte += aff(degbm) +
  13522. " => <b>"+(2*(reg+modD)+degbm) +
  13523. "/" + (2*(Math.floor(1.5*reg)+modD)+degbm) +
  13524. " ("+resiste(reg+modD,degbm) +
  13525. "/"+resiste(1.5*reg+modD,degbm)+")</b>";
  13526. texte += "<br>Nécrose : attaque magique <b>-"+(reg+modD)+"</b>";
  13527. } else if(sort.indexOf('Telekinesie')!=-1) {
  13528. texte = 'Portée horizontale :';
  13529. var vt = Math.floor(vuetotale/2)+2;
  13530. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  13531. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  13532. for(var i=0 ; i<5 ; i++) {
  13533. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  13534. if(vt>1) texte += 's';
  13535. vt=Math.max(0,vt-1);
  13536. }
  13537. }
  13538. else if(sort.indexOf('Teleportation')!=-1) {
  13539. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  13540. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  13541. var pmh = (20+vue+portee);
  13542. var pmv = 3+Math.floor(portee/3);
  13543. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  13544. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  13545. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  13546. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  13547. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  13548. } else if(sort.indexOf('Vampirisme')!=-1) {
  13549. var modD = 0;
  13550. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  13551. if(atttour!=0) {
  13552. modD = Math.floor(Math.floor(2*deg/3)*atttour/100);
  13553. texte += '<i>'+aff(modD)+'D6</i> ';
  13554. }
  13555. texte += aff(attbm) +
  13556. ' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm) +
  13557. '</b><br/>Dégâts : <b>'+deg+'</b> D3 ';
  13558. if(degtour!=0) {
  13559. modD = Math.floor(deg*degtour/100);
  13560. texte += '<i>'+aff(modD)+'D3</i> ';
  13561. } else {
  13562. modD = 0;
  13563. }
  13564. texte += aff(degbm) +
  13565. ' => <b>'+(2*(deg+modD)+degbm) +
  13566. '/'+(2*(Math.floor(1.5*deg)+modD)+degbm) +
  13567. ' ('+resiste(deg+modD,degbm) +
  13568. '/'+resiste(1.5*deg+modD,degbm)+')</b>';
  13569. } else if(sort.indexOf('Vision Accrue')!=-1)
  13570. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  13571. else if(sort.indexOf('Vision lointaine')!=-1)
  13572. texte = 'En ciblant une zone située n\'importe où dans le '
  13573. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  13574. else if(sort.indexOf('Voir le Cache')!=-1)
  13575. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  13576. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  13577. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  13578. +getPortee__Profil(vuetotale)+'</b> cases';
  13579. else if(sort.indexOf('Vue Troublee')!=-1)
  13580. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  13581. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  13582. return texte;
  13583. }
  13584.  
  13585.  
  13586. /*---------------------------------- Main ------------------------------------*/
  13587.  
  13588. function do_profil2()
  13589. {
  13590. try {
  13591. start_script(31);
  13592.  
  13593. extractionDonnees();
  13594. setInfosCaracteristiques();
  13595. setInfoDescription();
  13596. setInfosEtatLieux();
  13597. setInfosEtatPV();
  13598. setInfosExp();
  13599.  
  13600. creerBulleVide();
  13601. traitementTalents();
  13602. setLienAnatrolliseur();
  13603.  
  13604. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  13605. if(race=='Kastar'){ setAccel(); }
  13606. saveProfil();
  13607. displayScriptTime();
  13608. } catch(e) {
  13609. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  13610. window.console.error(traceStack(e, 'profil2'));
  13611. }
  13612. }
  13613.  
  13614. /*******************************************************************************
  13615. * This file is part of Mountyzilla. *
  13616. * *
  13617. * Mountyzilla is free software; you can redistribute it and/or modify *
  13618. * it under the terms of the GNU General Public License as published by *
  13619. * the Free Software Foundation; either version 2 of the License, or *
  13620. * (at your option) any later version. *
  13621. * *
  13622. * Mountyzilla is distributed in the hope that it will be useful, *
  13623. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13624. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13625. * GNU General Public License for more details. *
  13626. * *
  13627. * You should have received a copy of the GNU General Public License *
  13628. * along with Mountyzilla; if not, write to the Free Software *
  13629. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  13630. *******************************************************************************/
  13631.  
  13632. // x~x script_principal
  13633.  
  13634. // x~x md5.js
  13635. /*
  13636. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  13637. * Digest Algorithm, as defined in RFC 1321.
  13638. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  13639. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  13640. * Distributed under the BSD License
  13641. * See http://pajhome.org.uk/crypt/md5 for more info.
  13642. */
  13643.  
  13644. /*
  13645. * Configurable variables. You may need to tweak these to be compatible with
  13646. * the server-side, but the defaults work in most cases.
  13647. */
  13648. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  13649. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  13650. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  13651.  
  13652. /*
  13653. * These are the functions you'll usually want to call
  13654. * They take string arguments and return either hex or base-64 encoded strings
  13655. */
  13656. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  13657. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  13658. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  13659. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  13660. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  13661. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  13662.  
  13663. /*
  13664. * Perform a simple self-test to see if the VM is working
  13665. */
  13666. function md5_vm_test()
  13667. {
  13668. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  13669. }
  13670.  
  13671. /*
  13672. * Calculate the MD5 of an array of little-endian words, and a bit length
  13673. */
  13674. function core_md5(x, len)
  13675. {
  13676. /* append padding */
  13677. x[len >> 5] |= 0x80 << ((len) % 32);
  13678. x[(((len + 64) >>> 9) << 4) + 14] = len;
  13679.  
  13680. var a = 1732584193;
  13681. var b = -271733879;
  13682. var c = -1732584194;
  13683. var d = 271733878;
  13684.  
  13685. for(var i = 0; i < x.length; i += 16)
  13686. {
  13687. var olda = a;
  13688. var oldb = b;
  13689. var oldc = c;
  13690. var oldd = d;
  13691.  
  13692. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  13693. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  13694. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  13695. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  13696. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  13697. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  13698. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  13699. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  13700. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  13701. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  13702. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  13703. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  13704. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  13705. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  13706. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  13707. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  13708.  
  13709. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  13710. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  13711. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  13712. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  13713. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  13714. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  13715. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  13716. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  13717. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  13718. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  13719. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  13720. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  13721. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  13722. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  13723. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  13724. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  13725.  
  13726. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  13727. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  13728. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  13729. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  13730. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  13731. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  13732. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  13733. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  13734. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  13735. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  13736. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  13737. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  13738. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  13739. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  13740. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  13741. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  13742.  
  13743. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  13744. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  13745. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  13746. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  13747. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  13748. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  13749. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  13750. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  13751. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  13752. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  13753. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  13754. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  13755. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  13756. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  13757. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  13758. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  13759.  
  13760. a = safe_add(a, olda);
  13761. b = safe_add(b, oldb);
  13762. c = safe_add(c, oldc);
  13763. d = safe_add(d, oldd);
  13764. }
  13765. return Array(a, b, c, d);
  13766.  
  13767. }
  13768.  
  13769. /*
  13770. * These functions implement the four basic operations the algorithm uses.
  13771. */
  13772. function md5_cmn(q, a, b, x, s, t)
  13773. {
  13774. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  13775. }
  13776. function md5_ff(a, b, c, d, x, s, t)
  13777. {
  13778. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  13779. }
  13780. function md5_gg(a, b, c, d, x, s, t)
  13781. {
  13782. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  13783. }
  13784. function md5_hh(a, b, c, d, x, s, t)
  13785. {
  13786. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  13787. }
  13788. function md5_ii(a, b, c, d, x, s, t)
  13789. {
  13790. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  13791. }
  13792.  
  13793. /*
  13794. * Calculate the HMAC-MD5, of a key and some data
  13795. */
  13796. function core_hmac_md5(key, data)
  13797. {
  13798. var bkey = str2binl(key);
  13799. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  13800.  
  13801. var ipad = Array(16), opad = Array(16);
  13802. for(var i = 0; i < 16; i++)
  13803. {
  13804. ipad[i] = bkey[i] ^ 0x36363636;
  13805. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  13806. }
  13807.  
  13808. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  13809. return core_md5(opad.concat(hash), 512 + 128);
  13810. }
  13811.  
  13812. /*
  13813. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  13814. * to work around bugs in some JS interpreters.
  13815. */
  13816. function safe_add(x, y)
  13817. {
  13818. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  13819. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  13820. return (msw << 16) | (lsw & 0xFFFF);
  13821. }
  13822.  
  13823. /*
  13824. * Bitwise rotate a 32-bit number to the left.
  13825. */
  13826. function bit_rol(num, cnt)
  13827. {
  13828. return (num << cnt) | (num >>> (32 - cnt));
  13829. }
  13830.  
  13831. /*
  13832. * Convert a string to an array of little-endian words
  13833. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  13834. */
  13835. function str2binl(str)
  13836. {
  13837. var bin = Array();
  13838. var mask = (1 << chrsz) - 1;
  13839. for(var i = 0; i < str.length * chrsz; i += chrsz)
  13840. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  13841. return bin;
  13842. }
  13843.  
  13844. /*
  13845. * Convert an array of little-endian words to a string
  13846. */
  13847. function binl2str(bin)
  13848. {
  13849. var str = "";
  13850. var mask = (1 << chrsz) - 1;
  13851. for(var i = 0; i < bin.length * 32; i += chrsz)
  13852. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  13853. return str;
  13854. }
  13855.  
  13856. /*
  13857. * Convert an array of little-endian words to a hex string.
  13858. */
  13859. function binl2hex(binarray)
  13860. {
  13861. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  13862. var str = "";
  13863. for(var i = 0; i < binarray.length * 4; i++)
  13864. {
  13865. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  13866. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  13867. }
  13868. return str;
  13869. }
  13870.  
  13871. /*
  13872. * Convert an array of little-endian words to a base-64 string
  13873. */
  13874. function binl2b64(binarray)
  13875. {
  13876. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  13877. var str = "";
  13878. for(var i = 0; i < binarray.length * 4; i += 3)
  13879. {
  13880. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  13881. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  13882. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  13883. for(var j = 0; j < 4; j++)
  13884. {
  13885. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  13886. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  13887. }
  13888. }
  13889. return str;
  13890. }
  13891.  
  13892. ///////////////////////////////////////////
  13893. // debug cartes capitan Roule 07/12/2016
  13894. ///////////////////////////////////
  13895. // essais : objet
  13896. // .mode : description
  13897. // .essais : tableau d'objets essai
  13898. // .mode : description
  13899. // .essais : tableau de cartes
  13900. // .noCarte : id de la carte
  13901. // .essais : tableau d'essais, [x, y, n, nb]
  13902. function AfficheEssais(essais, sMode) {
  13903. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  13904. if (!eBigDiv) {
  13905. var insertPoint = document.getElementById('footer1');
  13906. eBigDiv = document.createElement('table');
  13907. eBigDiv.id = 'ListeEssaiCapitan';
  13908. insertBefore(insertPoint, document.createElement('p'));
  13909. insertTitle(insertPoint,'Capitan : Liste des essais');
  13910. insertBefore(insertPoint, eBigDiv);
  13911. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  13912. }
  13913. if (!essais) {
  13914. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  13915. return;
  13916. }
  13917. var carte;
  13918. for (carte in essais) {
  13919. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  13920. }
  13921. if (carte === undefined) {
  13922. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  13923. }
  13924. }
  13925.  
  13926. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  13927. var tr = appendTr(eTable);
  13928. var td = appendTd(tr);
  13929. appendText(td, sMode, bBold);
  13930. td = appendTd(tr);
  13931. appendText(td, sCarte, bBold);
  13932. td = appendTd(tr);
  13933. appendText(td, sText, bBold);
  13934. }
  13935.  
  13936. function getEssaiV1_0() {
  13937. try {
  13938. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  13939. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  13940. var tabK, nK;
  13941. prefs.getChildList('', nK, tabK);
  13942. window.console.log('getEssaiV1_0, nb key : ' + nK);
  13943. //window.console.log('getEssaiV1_0, ' + nK);
  13944. return;
  13945. //return r;
  13946. } catch (e) {
  13947. window.console.log(traceStack(e, 'getEssaiV1_0'));
  13948. }
  13949. }
  13950.  
  13951. function getEssaiV1_1() {
  13952. var locSto = window.localStorage;
  13953. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  13954. var r = [];
  13955. for (var i = 0; i < locSto.length; i++) {
  13956. var k = locSto.key(i);
  13957. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  13958. var t = k.split(/\./);
  13959. if (t[0] !== 'capitan') continue;
  13960. if (t[2] !== 'essai') continue;
  13961. var carte = 'carte n°' + t[1];
  13962. if (r[carte]) r[carte]++;
  13963. else r[carte] = 1;
  13964. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  13965. }
  13966. return r;
  13967. }
  13968.  
  13969. function showEssaiCartes() {
  13970. window.console.log('début showEssai Tout_MZ');
  13971. var essais = getEssaiV1_0();
  13972. AfficheEssais(essais, 'V1.0');
  13973. essais = getEssaiV1_1();
  13974. AfficheEssais(essais, 'V1.1');
  13975. window.console.log('fin showEssai Tout_MZ');
  13976. }
  13977.  
  13978. function testBoolLocalStorage() {
  13979. var b = true;
  13980. var key = 'MZ_essai_bool';
  13981. GM_setValue(key, b);
  13982. window.localStorage[key] = b;
  13983. var v = GM_getValue(key);
  13984. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  13985. var v = window.localStorage.getItem(key);
  13986. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  13987.  
  13988. var b = false;
  13989. GM_setValue(key, b);
  13990. window.localStorage[key] = b;
  13991. var v = GM_getValue(key);
  13992. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  13993. var v = window.localStorage.getItem(key);
  13994. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  13995.  
  13996. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  13997. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  13998. var y = GM_getValue('654654897894654654');
  13999. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  14000. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  14001. }
  14002.  
  14003. /*--------------------------------- Création liste trolligion ---------------------------------*/
  14004. function export_trolligion() {
  14005. try {
  14006. var tabDl = document.getElementsByTagName('dl');
  14007. if ((!tabDl) || !tabDl[0]) {
  14008. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  14009. return;
  14010. }
  14011. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  14012. // nom : string
  14013. // rayonnement : entier
  14014. // grades : table d'objets (une occurence par grade)
  14015. // nom : string
  14016. // trolls : table d'objets (un par Trõll)
  14017. // id
  14018. // nom
  14019. // idguilde
  14020. // guilde
  14021. // race
  14022. // niveau
  14023. // ferveur
  14024. var currentDieu;
  14025. var currentGrade;
  14026. for (var iChild1 in tabDl[0].children) {
  14027. var eChild1 = tabDl[0].children[iChild1];
  14028. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  14029. case 'dd': // Trõll
  14030. var oTroll = {};
  14031. export_trolligion_analyse(oTroll, eChild1);
  14032. currentGrade.trolls.push(oTroll);
  14033. break;
  14034. case 'dt':
  14035. var tabH3 = eChild1.getElementsByTagName('h3');
  14036. if (tabH3 && tabH3[0]) { // changement de dieu
  14037. currentDieu = {
  14038. nom: tabH3[0].innerText || tabH3[0].textContent
  14039. , grades: []};
  14040. var txt = eChild1.innerText || eChild1.textContent;
  14041. var m = txt.match(/yon*ement *:* *(\d+)/);
  14042. if (m) currentDieu.rayonnement = parseInt(m[1]);
  14043. currentGrade = undefined;
  14044. tabDieux.push(currentDieu);
  14045. break;
  14046. }
  14047. var tabH4 = eChild1.getElementsByTagName('h4');
  14048. if (tabH4 && tabH4[0]) { // changement de grade
  14049. var grade;
  14050. var txt = tabH4[0].innerText || tabH4[0].textContent;
  14051. tabI = tabH4[0].getElementsByTagName('i');
  14052. if (tabI && tabI[0]) {
  14053. grade = tabI[0].innerText || tabI[0].textContent;
  14054. grade = grade.replace(/"/g, '');
  14055. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  14056. if (m) grade += ' (' + m[1] + ')';
  14057. } else {
  14058. grade = txt.replace(/"/g, '');
  14059. }
  14060. currentGrade = {nom: grade, trolls: []};
  14061. currentDieu.grades.push(currentGrade);
  14062. break;
  14063. }
  14064. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  14065. break;
  14066. default:
  14067. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  14068. }
  14069. }
  14070.  
  14071. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  14072. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  14073. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  14074. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  14075. for (var iDieu in tabDieux) {
  14076. var oDieu = tabDieux[iDieu];
  14077. for (var iGrade in oDieu.grades) {
  14078. var oGrade = oDieu.grades[iGrade];
  14079. for (var iTroll in oGrade.trolls) {
  14080. var oTroll = oGrade.trolls[iTroll];
  14081. var t = [oDieu.nom, oDieu.rayonnement
  14082. , oGrade.nom
  14083. , oTroll.id, oTroll.nom
  14084. , oTroll.idguilde, oTroll.guilde
  14085. , oTroll.race, oTroll.niveau
  14086. , oTroll.ferveur];
  14087. for (var iParam in t) {
  14088. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14089. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14090. }
  14091. txt += t.join("\t") + "\n";
  14092. }
  14093. }
  14094. var t = [oDieu.nom, oDieu.rayonnement];
  14095. for (var iParam in t) {
  14096. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14097. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14098. }
  14099. txt2 += t.join("\t") + "\n";
  14100. }
  14101. txt += "\n" + txt2;
  14102. } catch (e) {
  14103. window.alert("Échec à l'extraction\n" + e);
  14104. }
  14105. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  14106. try {
  14107. if (copyTextToClipboard(txt)) {
  14108. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  14109. + "Collez dans Calc\n"
  14110. + "ou, au pire, dans EXCEL®");
  14111. } else {
  14112. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  14113. }
  14114. } catch(e) {
  14115. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  14116. }
  14117. }
  14118.  
  14119. function export_trolligion_analyse(oTroll, eChild1) {
  14120. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  14121. var eChild2 = eChild1.childNodes[iChild2];
  14122. if (eChild2.nodeType === undefined) continue; // properties
  14123. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  14124. switch (eChild2.nodeType) {
  14125. case 1: //ELEMENT_NODE:
  14126. switch (eChild2.nodeName.toLowerCase()) {
  14127. case 'a':
  14128. var m;
  14129. if (!eChild2.href) {
  14130. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  14131. break;
  14132. }
  14133. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  14134. if (m) {
  14135. oTroll.id = parseInt(m[1]);
  14136. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  14137. break;
  14138. }
  14139. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  14140. if (m) {
  14141. var idGuilde = parseInt(m[1]);
  14142. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  14143. oTroll.idguilde = parseInt(m[1]);
  14144. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  14145. }
  14146. break;
  14147. }
  14148. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  14149. break;
  14150. case 'br': // ignore
  14151. case 'style': // ignore
  14152. case 'img': // ignore
  14153. break;
  14154. case 'div': // barre de vie
  14155. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  14156. eChild3 = eChild2.children[0];
  14157. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  14158. var eChild4 = eChild3.children[0];
  14159. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  14160. break;
  14161. }
  14162. }
  14163. //window.console.log(eChild2.innerHTML);
  14164. export_trolligion_analyse(oTroll, eChild2);
  14165. break;
  14166. default:
  14167. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  14168. break;
  14169. }
  14170. break;
  14171. case 3: //TEXT_NODE:
  14172. var txt = eChild2.nodeValue.trim();
  14173. if (txt === '') break;
  14174. var m = txt.match(/(.*) *\((\d+)\)/);
  14175. if (m) {
  14176. oTroll.race = m[1].trim();
  14177. oTroll.niveau = parseInt(m[2]);
  14178. } else {
  14179. oTroll.race = txt;
  14180. }
  14181. break;
  14182. default: // ne devrait pas arriver
  14183. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  14184. break;
  14185. }
  14186. }
  14187. }
  14188.  
  14189. function do_trolligion() {
  14190. var divpopup = document.createElement('div');
  14191. divpopup.id = 'MZ_divCopier';
  14192. divpopup.style.position = 'fixed';
  14193. divpopup.style.top = '2px';
  14194. divpopup.style.left = '2px;';
  14195. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  14196. divpopup.style.cursor = 'pointer';
  14197. divpopup.style.zIndex = 200;
  14198. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  14199. divpopup.onclick = export_trolligion;
  14200. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  14201. divpopup.appendChild(img);
  14202. document.body.appendChild(divpopup);
  14203. }
  14204.  
  14205. /*--------------------------------- Dispatch ---------------------------------*/
  14206.  
  14207. //chargerScriptDev("libs");
  14208. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  14209. //if (isDEV) testBoolLocalStorage();
  14210.  
  14211. // Détection de la page à traiter
  14212. if(isPage("Messagerie/ViewMessageBot")) {
  14213. do_cdmbot();
  14214. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  14215. do_cdmcomp();
  14216. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  14217. do_cdmcomp();
  14218. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  14219. do_cdmcomp();
  14220. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  14221. do_diplo();
  14222. } else if(isPage("MH_Play/Play_equipement")) {
  14223. do_equip();
  14224. } else if(isPage("MH_Play/Play_menu")) {
  14225. do_menu();
  14226. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  14227. do_option();
  14228. //showEssaiCartes();
  14229. } else if(isPage("View/PJView_Events")) {
  14230. /* SCIZ */
  14231. do_scizOverwriteEvents();
  14232. } else if(isPage("View/PJView")) {
  14233. do_pjview();
  14234. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  14235. do_profil();
  14236. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  14237. do_tancompo();
  14238. } else if(isPage("MH_Play/Play_vue")) {
  14239. do_vue();
  14240. } else if(isPage("MH_Play/Play_news")) {
  14241. do_news();
  14242. } else if(isPage("MH_Play/Play_evenement")) {
  14243. /* SCIZ */
  14244. do_scizOverwriteEvents();
  14245. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  14246. do_move();
  14247. } else if(isPage("MH_Missions/Mission_Etape")) {
  14248. do_mission();
  14249. } else if(isPage("View/MonsterView")) {
  14250. do_infomonstre();
  14251. /* SCIZ */
  14252. do_scizOverwriteEvents();
  14253. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  14254. do_attaque();
  14255. } else if(isPage("MH_Play/Play_e_follo.php")) {
  14256. do_listegowap();
  14257. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  14258. do_lieuDescription();
  14259. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  14260. do_lieuTeleport();
  14261. } else if(isPage("MH_Follower/FO_Ordres")) {
  14262. do_ordresgowap();
  14263. } else if(isPage("MH_Follower/FO_Equipement")) {
  14264. do_equipgowap();
  14265. } else if(isPage("MH_Play/Play_mouche")) {
  14266. do_mouches();
  14267. } else if(isPage("MH_Play/Play_BM")) {
  14268. do_malus();
  14269. } else if(isPage("MH_Play/Play_evenement")) {
  14270. do_myevent();
  14271. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  14272. do_enchant();
  14273. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  14274. do_pre_enchant();
  14275. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  14276. do_actions();
  14277. } 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')) {
  14278. do_mission_liste();
  14279. } else if(isPage('MH_Play/Play_action')) {
  14280. do_actions();
  14281. } else if(isPage('MH_Play/Play_profil2')) {
  14282. do_profil2();
  14283. } else if(isPage('View/TrolligionView.php')) {
  14284. do_trolligion();
  14285. }
  14286. } catch(e) {
  14287. try {
  14288. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  14289. } catch(e2) {
  14290. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  14291. }
  14292. }