Tout_MZ

Client MountyZilla

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

  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.18
  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.18 19/01/2020",
  39. " Correctif pour les icônes d'action à distance dans la vue",
  40. "V1.3.0.17 16/01/2020",
  41. " Correctif pour le recall du filtre des Monstres",
  42. "V1.3.0.16 10/01/2020",
  43. " Amélioration du support SCIZ (Fix sur le prettyprint)",
  44. "V1.3.0.15 10/01/2020",
  45. " Amélioration du support SCIZ (Fix sur les événements de zone)",
  46. "V1.3.0.14 06/01/2020",
  47. " Correction filtre par famille piur les monstres variables et sans cdm",
  48. "V1.3.0.13 06/01/2020",
  49. " Ajout du filtre sur la famille des monstres",
  50. "V1.3.0.12 28/12/2019",
  51. " Fixed bug fix pour SCIZ (JWT)",
  52. "V1.3.0.11 28/12/2019",
  53. " Bug fix pour SCIZ (JWT)",
  54. "V1.3.0.10 22/12/2019",
  55. " Corrections mineures pour SCIZ",
  56. "V1.3.0.9 19/12/2019",
  57. " Amélioration du support SCIZ (Fixes + AdvancedCSS + SwitchEvent)",
  58. "V1.3.0.8 16/12/2019",
  59. " Amélioration du support SCIZ (Fixes + Play_evenement + PJView_Events)",
  60. "V1.3.0.7 12/12/2019",
  61. " correction cibles des missions 'famille', 'pouvoir' et cas particulier de 'race'",
  62. "V1.3.0.6 11/12/2019",
  63. " 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",
  64. "V1.3.0.5 11/12/2019",
  65. " Première interconnexion avec SCIZ (Options + MonsterView)",
  66. "V1.3.0.4 29/11/2019",
  67. " Ajout des déciles",
  68. "V1.3.0.3 29/11/2019",
  69. " Affichage d'une icône pour les Phœnix dont la génération est connue",
  70. "V1.3.0.2 24/11/2019",
  71. " Réduction taille info CdM",
  72. "V1.3.0.1 22/11/2019",
  73. " Ajustements sur les infos tactiques",
  74. "V1.3.0 15/11/2019",
  75. " Refonte calculs tactiques de la vue - beta",
  76. "V1.2.20.6 09/11/2019",
  77. " Correction de la formule d'AdD dans le profil",
  78. "V1.2.20.5 16/10/2019",
  79. " Mutualisation analyse ordres suivants MZ_analyse_page_ordre_suivant",
  80. "V1.2.20.4 03/10/2019",
  81. " Adaptation modif MH de la page des suivants",
  82. "V1.2.20.3 02/09/2019",
  83. " Compétence golem vers l'anatroliseur",
  84. "V1.2.20.2 25/05/2019",
  85. " Gestion des Parasitus pour les missions",
  86. "V1.2.20.1 25/05/2019",
  87. " Correction de la cible en cas de mission demandant un kill de Crasc + message d'alerte en cas de fumeux",
  88. "V1.2.20.0 25/05/2019",
  89. " Adaptation aux modifications des CdM par MH",
  90. "V1.2.19.2 16/04/2019",
  91. " Correction majuscules dans les talents",
  92. "V1.2.19.1 14/04/2019",
  93. " Prise en compte des nouvelles AdX dans profil2",
  94. "V1.2.18.15 29/03/2019",
  95. " Correction simple quote dans toutes les missions",
  96. "V1.2.18.14 09/03/2019",
  97. " Correction affichage vues 2D externes suite à une modif MH",
  98. "V1.2.18.13 27/02/2019",
  99. " Correction simple quote dans les familles de monstre des missions",
  100. "V1.2.18.12 23/12/2018",
  101. " Message si \"Menu d'actions contextuelles\" est décoché",
  102. "V1.2.18.11 21/11/2018",
  103. " Correction it bricol'troll, login avec accent",
  104. "V1.2.18.10 08/08/2018",
  105. " Correction boulette sDiplo",
  106. "V1.2.18.09 04/08/2018",
  107. " Protection contre diplomatie mal initialisée",
  108. "V1.2.18.08 11/07/2018",
  109. " Correction pour fonctionnement hors GM",
  110. "V1.2.18.07 18/05/2018",
  111. " prise en compte bonus magique d'esquive dans le profil, correction gestion de la souris dans la page d'équipement [Dabihul, welcome back]",
  112. "V1.2.18.06 28/01/2018",
  113. " Protection malus Crasc sans durée",
  114. "V1.2.18.05 18/11/2017",
  115. " Désactivation MZ V2 en mode dev pour les tests d'adaptation violentmonkey",
  116. "V1.2.18.04 04/09/2017",
  117. " retour version 1.2.18.02 avec GM 3.17",
  118. "V1.2.18.03 01/09/2017",
  119. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  120. "V1.2.18.02 26/08/2017",
  121. " correction boulette sur le compos d'enchantement",
  122. "V1.2.18.01 25/08/2017",
  123. " Suppression des messages sur les certificats en https",
  124. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  125. "V1.2.17.19 23/08/2017",
  126. " Possibilité de plusieurs IT Bricol'Troll",
  127. "V1.2.17.18 22/08/2017",
  128. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  129. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  130. "V1.2.17.17 16/07/2017",
  131. " modification du mécanisme de filtrage pour contourner un pb",
  132. "V1.2.17.16 16/07/2017",
  133. " Ajout de messages de debug sur les retours AJAX",
  134. "V1.2.17.15 15/07/2017",
  135. " modification du mécanisme de filtrage pour contourner un pb",
  136. "V1.2.17.14 14/07/2017",
  137. " correction dans la gestion des étapes de mission",
  138. "V1.2.17.13 12/07/2017",
  139. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  140. "V1.2.17.12 16/06/2017",
  141. " Correction mauvais compte de PX quand on change de Trõll",
  142. "V1.2.17.11 01/05/2017",
  143. " Travail sur le fonctionnement hors Greasemonkey",
  144. "V1.2.17.10 30/04/2017",
  145. " Protection dans la récupération d'erreur",
  146. "V1.2.17.9 30/04/2017",
  147. " Correction récupération d'erreur IT Bricol'Troll",
  148. "V1.2.17.8 29/04/2017",
  149. " Correction Bonus/Malus cas +0\+10 (AE)",
  150. " Correction portée IdC",
  151. " Prise en compte du bonus de portée PM dans le calcul tactique",
  152. "V1.2.17.7 26/04/2017",
  153. " Version compatible hors GreaseMonkey",
  154. "V1.2.17.6 23/04/2017",
  155. " Correction gestion des missions en cas de réinstallation",
  156. "V1.2.17.5 20/04/2017",
  157. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  158. "V1.2.17.4 08/04/2017",
  159. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  160. " Adaptation de la diplomatie à une modification de la page MH",
  161. "V1.2.17.3 04/04/2017",
  162. " Messages console en cas de cadre d'erreur",
  163. " Trolls de l'IT mais pas dans le vue en orange",
  164. "V1.2.17.2 20/03/2017",
  165. " Correction des PV restants",
  166. "V1.2.17.1 20/03/2017",
  167. " Blocage des PV restants en attendant résolution de bug",
  168. "V1.2.17 19/03/2017",
  169. " Refonte de l'envoi des CdM",
  170. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  171. "V1.2.16.4 08/03/2017",
  172. " correction ID de troll en envoi de PX/MP",
  173. "V1.2.16.3 27/02/2017",
  174. " correction bonus/malus FP",
  175. "V1.2.16.2 24/02/2017",
  176. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  177. "V1.2.16.1 21/02/2017",
  178. " corrige bug sur Fx 38.8 ESR",
  179. "V1.2.16 21/02/2017",
  180. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  181. " possibilité de masquer les Gowaps Sauvages dans la vue",
  182. " calcul des caractéristiques du siphon des âmes",
  183. "V1.2.15.2 02/02/2017",
  184. " adaptation décumul VlC (page des bonus/malus)",
  185. "V1.2.15.1 29/01/2017",
  186. " carte sur la page de description du lieu TP",
  187. "V1.2.15 25/01/2017",
  188. " mise en place des nouvelles cartes (suivants, TP)",
  189. "V1.2.14.3 25/01/2017",
  190. " résumé dans l'export des données Trõlligion",
  191. "V1.2.14.2 20/01/2017",
  192. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  193. "V1.2.14.1 20/01/2017",
  194. " réécriture filtrage des monstres par niveau dans la vue",
  195. " Changelog dans la page des news MZ",
  196. "V1.2.14 20/01/2017",
  197. " Ajout de l'export des données Trõlligion",
  198. "V1.2.13.7 10/01/2017",
  199. " Exclusion Bricoll'troll dans l'entête GM",
  200. "V1.2.13.6 08/01/2017",
  201. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  202. "V1.2.13.5 07/01/2017",
  203. " Correction bug qui se manisfestait sous LINUX",
  204. "V1.2.13.4 07/01/2017",
  205. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  206. "V1.2.13.3 07/01/2017",
  207. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  208. "V1.2.13.2 07/01/2017",
  209. " Correction missions, recherche troogle (familles et types de monstres)",
  210. "V1.2.13.1 06/01/2017",
  211. " Suppression oldSchoolProfile qui n'existe plus",
  212. " Ajout du 'refresh' du cadre de gauche",
  213. "V1.2.13 01/01/2017",
  214. " homogénéisation des messages d'erreur",
  215. " Ajout du lien Troogle sur les étapes de mission monstre",
  216. "V1.2.12.2 30/12/2016",
  217. " retour en mode normal (http si jeu en http)",
  218. "V1.2.12.1 27/12/2016",
  219. " Correction mode IP",
  220. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  221. "V1.2.12 24/12/2016",
  222. " Nettoyage des URL",
  223. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  224. " Interface bricoll'Troll en https",
  225. " Remise en marche des cartes des trajets des gowaps",
  226. "V1.2.11.5 à 7 20 & 21/12/2016",
  227. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  228. "V1.2.11.4 19/12/2016",
  229. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  230. "V1.2.11.3 19/12/2016",
  231. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  232. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  233. "V1.2.11.2 18/12/2016",
  234. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  235. "V1.2.11.1 17/12/2016",
  236. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  237. "V1.2.11 13/12/2016",
  238. " Passage sur BdD Raistlin \\o/",
  239. "V1.2.10.4 12/12/2016",
  240. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  241. "V1.2.10.3 09/12/2016",
  242. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  243. "V1.2.10.2 09/12/2016",
  244. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  245. "V1.2.10.1 08/12/2016",
  246. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  247. "V1.2.10 07/12/2016",
  248. " correction décumul des bonus/malus",
  249. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  250. "V1.2.9 16/11/2016",
  251. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  252. "V1.2.8 10/11/2016",
  253. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  254. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  255. "V1.2.7 07/11/2016",
  256. " remise en route de l'interface avec l'IT bricol'Troll",
  257. "V1.2.6 19/10/2016",
  258. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  259. " stockage idguilde et nomguilde",
  260. "V1.2.5 17/10/2016",
  261. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  262. " remise en route de la gestion des options avec intégration md5 dans ce script",
  263. "V1.2.4 14/10/2016",
  264. " utilisation du relai raistlin pour l'envoi des CdM",
  265. "V1.2.3 :",
  266. " suppression ancien profil",
  267. " nettoyage doublon sur getPortee",
  268. " adaptation portee TP basée sur les PI",
  269. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  270. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  271. "V1.2.1 :",
  272. " include des URLs MH alternatives",
  273. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  274. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  275. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  276. "V1.1 : regroupement en un gros paquet sale",
  277. ];
  278.  
  279. /**********************************************************
  280. À faire / propositions d'évolutions
  281.  
  282. Bireli-Gravos 08/12/2018
  283. FAIT faire un warning si l'utilisateur a désactivé la case "Menu d'actions contextuelles" dans la fenêtre "limiter la vue"
  284. breizhou13 20/12/2016
  285. envoyer les données à l'IT (Bricol'Trolls) aussi
  286. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  287. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  288. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  289. Akkila le boeuf le 26-03-2017 à 15:56
  290. - bouton pour rafraîchir les infos des trolls de son groupe
  291. Roule'
  292. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  293. Réactiver les jubilaires
  294. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  295. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  296. - voir l'intérêt de refaire fonctionner
  297. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  298. FAIT : ambiguité sur le nom de monstres de mission : Shai, Ombre, Geck'oo et Boujd'la
  299. Sans doute à corriger, la compétence Baroufle pour le lien vers l'anatroliseur
  300. Prévision des DLA de monstre
  301. FAIT Niveau des monstres à la méthode Roule'
  302. Raistlin
  303. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  304. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  305. 80117 - Héra
  306. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  307. 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)
  308. FAIT Possibilité de plusieurs systèmes Bricol'troll
  309. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  310. ?
  311. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  312. Alanae/Gnu
  313. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  314. Kali
  315. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  316. **********************************************************/
  317.  
  318. /**********************************************************
  319. **** Début de zone à déplacer dans une bibli commune ******
  320. **********************************************************/
  321.  
  322. // URL de base serveur MZ
  323. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  324. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  325. //var URL_MZ = 'http://192.99.225.92/mz';
  326.  
  327. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  328. // à supprimer
  329. const newCarte = true;
  330. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  331.  
  332. // URLs externes redirection (pas de souci CORS)
  333. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  334. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  335. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  336. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  337. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  338. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  339. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  340. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  341. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  342.  
  343. // URLs de test HTTPS
  344. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  345. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  346.  
  347. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  348. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  349. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  350.  
  351. // x~x Libs
  352.  
  353. /* ancien TODO
  354. * - revoir la gestion des CdM --> nott armure magique
  355. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  356. * - vérfier la gestion des enchants
  357. */
  358.  
  359. // Roule 04/09/2016 switch extern URLs to https if available
  360. var isHTTPS = false;
  361. if (window.location.protocol.indexOf('https') === 0) {
  362. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  363. URL_bricol = URL_bricol_https;
  364. isHTTPS = true;
  365. }
  366.  
  367. // Roule 23/12/2016 mode dev
  368. var isDEV = false;
  369. if (window.localStorage.getItem('MZ_dev')
  370. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  371. || window.location.href.indexOf('mzdev.mh') >= 0) {
  372. URL_MZ = URL_MZ.replace(/$/, 'dev');
  373. isDEV = true;
  374. }
  375.  
  376. // Images (pas de souci CORS)
  377. var URL_MZimg = URL_MZ + '/img/';
  378. // URLs externes ajax (CORS OK)
  379. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  380. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  381. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  382.  
  383. // liens externes déduits
  384. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  385.  
  386. var MHicons = '/mountyhall/Images/Icones/';
  387. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  388. var MY_DEBUG = false;
  389.  
  390. var horsGM = false;
  391. try { // à partir du 11/07/2018, (GM_getValue === undefined) provoque une exception
  392. horsGM = (GM_getValue === undefined);
  393. } catch (e2) {
  394. horsGM = true;
  395. //window.console.log('test GM_getValue, exception=' + e2);
  396. }
  397. if (horsGM) { // éviter le blocage si pas sous GM
  398. window.console.log('Fonctionnement hors Greasemonkey');
  399. // Roule 18/11/2017 il ne faut pas de "var" dans les ligne précédente. Ça fonctionnait sous Greasemonkey mais plus sous Violentmonkey
  400. GM_getValue = function(key) {};
  401. GM_setValue = function(key, val) {};
  402. GM_deleteValue = function(key) {};
  403. GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  404. }
  405.  
  406. /* Utilisation de la gestion de l'enregistrement des données de
  407. GreaseMonkey, avec partage entre scripts via le localStorage, par
  408. Vapulabehemot (82169) 07/02/2017 */
  409. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  410. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  411. function MY_getValue(key) {
  412. var v = window.localStorage.getItem(key);
  413. vGM = GM_getValue(key);
  414. if ((vGM == null)
  415. || (v != null && v != vGM)){
  416. GM_setValue(key, v);
  417. } else if (v == null && vGM != null) {
  418. v = vGM;
  419. window.localStorage[key] = vGM;
  420. }
  421. return v;
  422. }
  423. function MY_removeValue(key) {
  424. GM_deleteValue(key);
  425. window.localStorage.removeItem(key);
  426. }
  427. function MY_setValue(key, val) {
  428. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  429. val = 1;
  430. else if (val === false)
  431. val = 0;
  432. try {
  433. GM_setValue(key, val);
  434. } catch(e) {
  435. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  436. }
  437. try {
  438. window.localStorage[key] = val;
  439. } catch(e) {
  440. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  441. }
  442. }
  443.  
  444. /*---------------- mise à jour de variables globales utiles ------------------*/
  445. // utilisé pour accès bdd (un peu partout) :
  446. var numTroll = MY_getValue('NUM_TROLL');
  447. // utilisé dans vue pour PX :
  448. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  449. var nivTroll; // = MY_getValue('NIV_TROLL');
  450. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  451. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  452. // utilisés dans actions et vue (calculs SR) :
  453. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  454. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  455. var currentURL = window.location.href;
  456.  
  457. /*-[functions]------------ Fonctions durée de script -------------------------*/
  458. var date_debut = null;
  459.  
  460. function start_script(nbJours_exp) {
  461. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  462. if(date_debut) return;
  463. date_debut = new Date();
  464. // Créé la variable expdate si demandé
  465. if(nbJours_exp) {
  466. expdate = new Date();
  467. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  468. }
  469. }
  470.  
  471. function displayScriptTime(duree, texte) {
  472. var footerNode = document.getElementById('footer2');
  473. if(!footerNode) return;
  474. try{
  475. var node = document.evaluate(
  476. ".//text()[contains(.,'Page générée en')]/../br",
  477. footerNode,null,9,null).singleNodeValue;
  478. }
  479. catch(e){return;}
  480. if (duree) {
  481. insertText(node,
  482. ' - [' + texte + ' en ' + (duree/1000) +' sec.]');
  483. return;
  484. }
  485. insertText(node,
  486. ' - [Script MZ exécuté en '
  487. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  488. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  489. }
  490.  
  491. function traceStack(e, sModule) {
  492. var version = '';
  493. if (GM_info && GM_info.script && GM_info.script.version)
  494. version = ' ' + GM_info.script.version;
  495. sRet = '[MZ' + version + ']'
  496. if (sModule) sRet += ' {' + sModule + '}';
  497. try {
  498. if (e.message) sRet += ' ' + e.message;
  499. } catch (e2) {
  500. sRet += ' <exception acces message>';//+ e2.message;
  501. }
  502. try {
  503. if (e.stack) {
  504. var sStack = e.stack;
  505. // enlever les infos confidentielles
  506. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  507. }
  508. } catch (e2) {
  509. sRet += ' <exception acces stack>'; // + e2.message;
  510. }
  511. return sRet;
  512. }
  513.  
  514. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  515.  
  516. function debugMZ(str){
  517. if(MY_DEBUG){
  518. window.console.debug('[MZ_DEBUG] '+str);
  519. if(typeof str === "object"){
  520. window.console.debug(str);
  521. }
  522. }
  523. }
  524.  
  525. if("function" != typeof isPage) {
  526. function isPage(url) {
  527. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  528. }
  529. }
  530.  
  531. function FF_XMLHttpRequest(MY_XHR_Ob) {
  532. var request = new XMLHttpRequest();
  533. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  534. for(var head in MY_XHR_Ob.headers) {
  535. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  536. }
  537. request.onreadystatechange = function() {
  538. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  539. if(request.readyState!=4) { return; }
  540. if(request.error) {
  541. if(MY_XHR_Ob.onerror) {
  542. MY_XHR_Ob.onerror(request);
  543. }
  544. return;
  545. }
  546. if ((request.status == 0)) {
  547. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  548. if (isDEV) {
  549. var grandCadre = createOrGetGrandCadre();
  550. var sousCadre = document.createElement('div');
  551. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  552. sousCadre.style.width = 'auto';
  553. sousCadre.style.fontSize = 'large';
  554. sousCadre.style.border = 'solid 1px black';
  555. grandCadre.appendChild(sousCadre);
  556. }
  557. //showHttpsErrorContenuMixte();
  558. return;
  559. }
  560. if(MY_XHR_Ob.onload) {
  561. var version;
  562. if (MY_XHR_Ob.trace) {
  563. version = '';
  564. if (GM_info && GM_info.script && GM_info.script.version)
  565. version = ' ' + GM_info.script.version;
  566. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  567. }
  568. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  569. MY_XHR_Ob.onload(request);
  570. if (MY_XHR_Ob.trace)
  571. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  572. }
  573. };
  574. request.send(MY_XHR_Ob.data);
  575. }
  576.  
  577. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  578. function MZ_formatDateMS(d, sansMicroSecondes) {
  579. if (d === undefined) d = new Date();
  580. var day = d.getDate();
  581. var month = d.getMonth()+1;
  582. var year = d.getFullYear();
  583. var hours = d.getHours();
  584. var minutes = d.getMinutes();
  585. var seconds = d.getSeconds();
  586. if (day < 10) {day = "0"+day;}
  587. if (month < 10) {month = "0"+month;}
  588. if (hours < 10) {hours = "0"+hours;}
  589. if (minutes < 10) {minutes = "0"+minutes;}
  590. if (seconds < 10) {seconds = "0"+seconds;}
  591. if (sansMicroSecondes) {
  592. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds;
  593. } else {
  594. var ms = d.getMilliseconds();
  595. ms = ('000' + ms).substr(-3, 3);
  596. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  597. }
  598. }
  599.  
  600. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  601.  
  602. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  603. function copyTextToClipboard(text) {
  604. var textArea = document.createElement("textarea");
  605.  
  606. //
  607. // *** This styling is an extra step which is likely not required. ***
  608. //
  609. // Why is it here? To ensure:
  610. // 1. the element is able to have focus and selection.
  611. // 2. if element was to flash render it has minimal visual impact.
  612. // 3. less flakyness with selection and copying which **might** occur if
  613. // the textarea element is not visible.
  614. //
  615. // The likelihood is the element won't even render, not even a flash,
  616. // so some of these are just precautions. However in IE the element
  617. // is visible whilst the popup box asking the user for permission for
  618. // the web page to copy to the clipboard.
  619. //
  620.  
  621. // Place in top-left corner of screen regardless of scroll position.
  622. textArea.style.position = 'fixed';
  623. textArea.style.top = 0;
  624. textArea.style.left = 0;
  625.  
  626. // Ensure it has a small width and height. Setting to 1px / 1em
  627. // doesn't work as this gives a negative w/h on some browsers.
  628. textArea.style.width = '2em';
  629. textArea.style.height = '2em';
  630.  
  631. // We don't need padding, reducing the size if it does flash render.
  632. textArea.style.padding = 0;
  633.  
  634. // Clean up any borders.
  635. textArea.style.border = 'none';
  636. textArea.style.outline = 'none';
  637. textArea.style.boxShadow = 'none';
  638.  
  639. // Avoid flash of white box if rendered for any reason.
  640. textArea.style.background = 'transparent';
  641.  
  642. textArea.value = text;
  643.  
  644. document.body.appendChild(textArea);
  645.  
  646. textArea.select();
  647.  
  648. var successful = document.execCommand('copy');
  649.  
  650. document.body.removeChild(textArea);
  651. return successful;
  652. }
  653.  
  654. function avertissement(txt,duree) {
  655. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  656. if(!duree) duree = 15000;
  657. var div = document.createElement('div');
  658. // On numérote les avertissements pour destruction sélective
  659. var num = document.getElementsByName('avertissement').length;
  660. div.num = num;
  661. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  662. div.setAttribute('name','avertissement');
  663. div.className = 'mh_textbox';
  664. div.style.position = 'fixed';
  665. div.style.top = (10+15*num)+'px';
  666. div.style.left = (10+5*num)+'px';
  667. div.style.border = '5px solid red';
  668. div.style.zIndex = 2+num;
  669. div.style.cursor = 'pointer';
  670. div.style.fontSize = 'large';
  671. div.innerHTML = txt;
  672. div.onclick=function(){ tueAvertissement(this.num) };
  673.  
  674. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  675. var divcroix = document.createElement('div');
  676. divcroix.style.position = 'absolute';
  677. divcroix.style.top = 0;
  678. divcroix.style.right = 0;
  679. divcroix.style.color = 'black';
  680. divcroix.style.fontSize = 'inherit';
  681. divcroix.style.cursor = 'pointer'
  682. divcroix.style.zIndex = 2+num;
  683. divcroix.innerHTML = "X";
  684. div.appendChild(divcroix);
  685.  
  686. document.body.appendChild(div);
  687. // Destruction automatique de l'avertissement après "un certain temps"
  688. window.setTimeout(function(){ tueAvertissement(num) },duree);
  689. }
  690.  
  691. function tueAvertissement(num) {
  692. var divs = document.getElementsByName('avertissement');
  693. if(divs.length==0) { return; }
  694. for(var i=0 ; i<divs.length ; i++) {
  695. if(divs[i].num==num) {
  696. divs[i].parentNode.removeChild(divs[i]);
  697. return;
  698. }
  699. }
  700. }
  701.  
  702.  
  703. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  704.  
  705. function insertBefore(next,el) {
  706. next.parentNode.insertBefore(el,next);
  707. }
  708.  
  709. function appendTr(tbody,clas) {
  710. var tr = document.createElement('tr');
  711. if(clas) tr.className = clas;
  712. tbody.appendChild(tr);
  713. return tr;
  714. }
  715.  
  716. function insertTr(next,clas) {
  717. var tr = document.createElement('tr');
  718. if(clas) tr.className = clas;
  719. insertBefore(next,tr);
  720. return tr;
  721. }
  722.  
  723. function appendTd(tr) {
  724. var td = document.createElement('td');
  725. if(tr) tr.appendChild(td);
  726. return td;
  727. }
  728.  
  729. function insertTd(next) {
  730. var td = document.createElement('td');
  731. insertBefore(next,td);
  732. return td;
  733. }
  734.  
  735. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  736. function insertAfterTd(eTd) {
  737. var newTd = document.createElement('td');
  738. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  739. return newTd;
  740. }
  741.  
  742. function appendTdCenter(tr,colspan) {
  743. var td = appendTd(tr);
  744. td.align = 'center'; // WARNING - Obsolete
  745. if(colspan) td.colSpan = colspan;
  746. return td;
  747. }
  748.  
  749. function insertTdElement(next,el) {
  750. var td = insertTd(next);
  751. if(el) td.appendChild(el);
  752. return td;
  753. }
  754.  
  755. function appendA(paren,href,cssClass,text) {
  756. var a = document.createElement('a');
  757. if (href) a.href = href;
  758. if (cssClass) a.className = cssClass;
  759. if (text) a.appendChild(document.createTextNode(text));
  760. paren.appendChild(a);
  761. }
  762.  
  763. function appendText(paren,text,bold) {
  764. if(bold) {
  765. var b = document.createElement('b');
  766. b.appendChild(document.createTextNode(text));
  767. paren.appendChild(b);
  768. }
  769. else
  770. paren.appendChild(document.createTextNode(text));
  771. }
  772.  
  773. function insertText(next,text,bold) {
  774. if(bold) {
  775. var b = document.createElement('b');
  776. appendText(b,text);
  777. insertBefore(next,b);
  778. }
  779. else
  780. insertBefore(next,document.createTextNode(text));
  781. }
  782.  
  783. function appendThText(tr,text,bold) {
  784. var th = document.createElement('th');
  785. if(tr) tr.appendChild(th);
  786. th.appendChild(document.createTextNode(text));
  787. if (bold) th.style.fontWeight = 'bold';
  788. return th;
  789. }
  790.  
  791. function appendTdText(tr,text,bold) {
  792. var td = appendTd(tr);
  793. td.appendChild(document.createTextNode(text));
  794. if (bold) td.style.fontWeight = 'bold';
  795. return td;
  796. }
  797.  
  798. function insertTdText(next,text,bold) {
  799. var td = insertTd(next);
  800. appendText(td,text,bold);
  801. return td;
  802. }
  803.  
  804. function appendBr(paren) {
  805. paren.appendChild(document.createElement('br'));
  806. }
  807.  
  808. function insertBr(next) {
  809. insertBefore(next,document.createElement('br'));
  810. }
  811.  
  812. function appendLI(ul,text) {
  813. // uniquement utilisé dans les options (crédits)
  814. var li = document.createElement('li');
  815. appendText(li,text);
  816. ul.appendChild(li);
  817. return li;
  818. }
  819.  
  820. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  821. var input = document.createElement('input');
  822. input.className = 'TextboxV2';
  823. input.type = type;
  824. input.name = nam;
  825. if (sId === undefined) input.id = nam;
  826. else input.id = sId;
  827. input.size = size;
  828. input.maxLength = maxlength;
  829. if(value) input.value = value;
  830. paren.appendChild(input);
  831. return input;
  832. }
  833.  
  834. function appendCheckBox(paren,nam,checked,onClick) {
  835. var input = document.createElement('input');
  836. input.type = 'checkbox';
  837. input.name = nam;
  838. input.id = nam;
  839. if(checked) input.checked = true;
  840. if(onClick) input.onclick = onClick;
  841. paren.appendChild(input);
  842. return input;
  843. }
  844.  
  845. function appendNobr(paren,id,delgg,text) {
  846. var nobr = document.createElement('nobr');
  847. appendCheckBox(nobr,id,null,delgg);
  848. appendText(nobr,text);
  849. paren.appendChild(nobr);
  850. appendText(paren,' ');
  851. return nobr;
  852. }
  853.  
  854. function appendCheckBoxSpan(paren,id,onClick,text) {
  855. var span = document.createElement('span');
  856. span.style.whiteSpace = 'nowrap';
  857. appendCheckBox(span,id,false,onClick);
  858. var label = document.createElement('label');
  859. appendText(label,text);
  860. label.htmlFor = id;
  861. label.style.marginLeft = '-5px';
  862. span.appendChild(label);
  863. span.style.marginRight = '3px';
  864. paren.appendChild(span);
  865. appendText(paren, ' ');
  866. return span;
  867. }
  868.  
  869. function appendOption(select,value,text) {
  870. var option = document.createElement('option');
  871. option.value = value;
  872. appendText(option,text);
  873. select.appendChild(option);
  874. return option;
  875. }
  876.  
  877. function appendHidden(form,nam,value) {
  878. var input = document.createElement('input');
  879. input.type = 'hidden';
  880. input.name = nam;
  881. input.id = nam;
  882. input.value = value;
  883. form.appendChild(input);
  884. }
  885.  
  886. function appendButton(paren,value,onClick) {
  887. var input = document.createElement('input');
  888. input.type = 'button';
  889. input.className = 'mh_form_submit';
  890. input.value = value;
  891. input.onmouseover = function(){this.style.cursor='pointer';};
  892. if(onClick) input.onclick = onClick;
  893. paren.appendChild(input);
  894. return input;
  895. }
  896.  
  897. function insertButton(next,value,onClick) {
  898. var input = document.createElement('input');
  899. input.type = 'button';
  900. input.className = 'mh_form_submit';
  901. input.value = value;
  902. input.onmouseover = function(){this.style.cursor='pointer';};
  903. input.onclick = onClick;
  904. insertBefore(next,input);
  905. return input;
  906. }
  907.  
  908. function appendSubmit(paren,value,onClick) {
  909. var input = document.createElement('input');
  910. input.type = 'submit';
  911. input.className = 'mh_form_submit';
  912. input.value = value;
  913. input.onmouseover = function(){this.style.cursor='pointer';};
  914. if(onClick) input.onclick = onClick;
  915. paren.appendChild(input);
  916. return input;
  917. }
  918.  
  919. function createImage(url,title,style) {
  920. var img = document.createElement('img');
  921. img.src = url;
  922. img.title = title;
  923. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  924. if (style) img.style = style;
  925. return img;
  926. }
  927.  
  928. function createAltImage(url,alt,title) {
  929. var img = document.createElement('img');
  930. img.src = url;
  931. img.alt = alt;
  932. if (title) img.title = title;
  933. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  934. return img;
  935. }
  936.  
  937. function createImageSpan(url,alt,title,text,bold) {
  938. var span = document.createElement('span');
  939. span.title = title;
  940. var img = document.createElement('img');
  941. img.src = url;
  942. img.alt = alt;
  943. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  944. span.appendChild(img);
  945. appendText(span,text,bold);
  946. return span;
  947. }
  948.  
  949. function createCase(titre,table,width) {
  950. if(!width) width=120;
  951. var tr = appendTr(table,'mh_tdpage');
  952.  
  953. var td = appendTdText(tr,titre,true);
  954. td.className = 'mh_tdtitre';
  955. td.width = width;
  956.  
  957. td = appendTdText(tr,'');
  958. td.className = 'mh_tdpage';
  959. return td;
  960. }
  961.  
  962. function getMyID(e) {
  963. var parent = e.parentNode;
  964. for(var i=0 ; i<parent.childNodes.length ; i++) {
  965. if(e==parent.childNodes[i])
  966. return i;
  967. }
  968. return -1;
  969. }
  970.  
  971. function insertAfter(elt,newElt) {
  972. var id = getMyID(elt);
  973. if(id==-1) return;
  974. if(id<elt.parentNode.childNodes.length-1)
  975. insertBefore(elt.nextSibling,newElt);
  976. else
  977. elt.parentNode.appendChild(newElt);
  978. }
  979.  
  980.  
  981. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  982.  
  983. function aff(nb) {
  984. return (nb>=0) ? '+'+nb : nb;
  985. }
  986.  
  987. function getNumber(str) {
  988. var nbr = str.match(/\d+/);
  989. return nbr ? Number(nbr[0]) : Number.NaN;
  990. }
  991.  
  992. function getNumbers(str) {
  993. var nbrs = str.match(/-?\d+/g);
  994. if (!nbrs) return [];
  995. for(var i=0 ; i<nbrs.length ; i++)
  996. nbrs[i] = Number(nbrs[i]);
  997. return nbrs;
  998. }
  999.  
  1000. function trim(str) {
  1001. return str.replace(/(^\s*)|(\s*$)/g,'');
  1002. }
  1003.  
  1004. String.prototype.trim = function() {
  1005. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  1006. }
  1007.  
  1008. function epure(texte) {
  1009. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1010. .replace(/[ç]/g,'c')
  1011. .replace(/[éêèë]/g,'e')
  1012. .replace(/[ïî]/g,'i')
  1013. .replace(/[ôöõ]/g,'o')
  1014. .replace(/[ùûü]/g,'u');
  1015. }
  1016.  
  1017. String.prototype.epure = function () {
  1018. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1019. .replace(/[ç]/g,'c')
  1020. .replace(/[éêèë]/g,'e')
  1021. .replace(/[ïî]/g,'i')
  1022. .replace(/[ôöõ]/g,'o')
  1023. .replace(/[ùûü]/g,'u');
  1024. }
  1025.  
  1026. function bbcode(texte) {
  1027. return texte.replace(/&/g,'&amp;')
  1028. .replace(/"/g,'&quot;')
  1029. .replace(/</g,'&lt;')
  1030. .replace(/>/g,'&gt;')
  1031. .replace(/'/g,'&#146;')
  1032. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  1033. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  1034. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  1035. }
  1036.  
  1037.  
  1038. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  1039.  
  1040. function addZero(i) {
  1041. return (i<10) ? '0'+i : i;
  1042. }
  1043.  
  1044. function DateToString(date) {
  1045. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  1046. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  1047. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  1048. }
  1049.  
  1050. function StringToDate(str) {
  1051. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  1052. }
  1053.  
  1054. // fonctionne aussi avec datetime
  1055. function SQLDateToFrench(str) {
  1056. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  1057. }
  1058.  
  1059. // ... et ajoute un "à" du plus bel effet
  1060. function SQLDateToFrenchTime(str) {
  1061. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  1062. }
  1063.  
  1064. // SQLDate vers objet date Javascript
  1065. function SQLDateToObject(str) {
  1066. var t = str.split(/[- :]/);
  1067. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  1068. }
  1069.  
  1070. var mz_ie = (window.attachEvent)? true:false;
  1071. if ("function" !== typeof addEvent) {
  1072. if (mz_ie) {
  1073. function addEvent(obj, typ, fn, sens) {
  1074. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  1075. obj["e"+typ+fn]( window.event );
  1076. }
  1077. obj.attachEvent("on"+typ, obj[typ+fn] );
  1078. }
  1079. }
  1080. else {
  1081. function addEvent(obj, typ, fn, sens) {
  1082. obj.addEventListener(typ, fn, sens);
  1083. }
  1084. }
  1085. }
  1086.  
  1087. /**********************
  1088. * glissière en mode objet
  1089. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  1090. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  1091. *
  1092. * Usage:
  1093. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  1094. * ref : utilisé pour diversifier les IDs HTML
  1095. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  1096. * target : peut être de 3 types
  1097. * - élément HTML : l'élément HTML à zoomer
  1098. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  1099. * - function : callback quand le curseur bouge
  1100. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  1101. * dans le mode dynamique, la callback est appelée sur mouseMove
  1102. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  1103. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  1104. * autres méthodes
  1105. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  1106. **********************/
  1107.  
  1108. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  1109. try {
  1110. var mouseDown = false;
  1111. var div_gliss = document.createElement("div"); // la DIV mère
  1112. div_gliss.id = "MZ_gliss_"+ref;
  1113. var div_label = document.createElement("span"); // le label
  1114. div_label.innerHTML = labelHTML;
  1115. div_gliss.appendChild(div_label);
  1116. div_gliss.className = "choix_zoom";
  1117. var dessin = document.createElement("canvas"); // le dessin lui-même
  1118. dessin.id = "MZ_gliss_dessin_"+ref;
  1119. dessin.style.cursor = "pointer";
  1120. dessin.width = 104;
  1121. dessin.height = 12;
  1122. dessin.style.marginLeft = '2px';
  1123. dessin.style.marginRight = '2px';
  1124. div_gliss.appendChild(dessin);
  1125. var pourcent = document.createElement("span"); // le pourcentage
  1126. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1127. var pourcent_text = document.createTextNode('');
  1128. var previousVal;
  1129. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1130.  
  1131. // alignement vertical
  1132. dessin.style.verticalAlign = 'middle';
  1133. div_label.style.verticalAlign = 'middle';
  1134. pourcent.style.verticalAlign = 'middle';
  1135.  
  1136. pourcent.appendChild(pourcent_text);
  1137. div_gliss.appendChild(pourcent);
  1138.  
  1139. var bulle_pourcent = document.createElement("div"); // la bulle
  1140. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1141. bulle_pourcent.style.display = 'block';
  1142. bulle_pourcent.style.visibility = 'hidden';
  1143. bulle_pourcent.style.position = 'absolute';
  1144. bulle_pourcent.style.zIndex = 3500;
  1145. bulle_pourcent.style.border = '1px solid #a1927f';
  1146. var bulle_pourcent_text = document.createTextNode('');
  1147. bulle_pourcent.appendChild(bulle_pourcent_text);
  1148. document.body.appendChild(bulle_pourcent);
  1149.  
  1150. this.getElt = function() {return div_gliss;};
  1151.  
  1152. ////////////////////////////////////
  1153. // dessine et redessine le curseur
  1154. ////////////////////////////////////
  1155. var dessine_glissiere = function(val) {
  1156. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1157. var ctx = dessin.getContext('2d');
  1158. ctx.clearRect(0, 0,104, 12);
  1159. ctx.fillStyle = "rgb(0,0,0)";
  1160. ctx.fillRect(0,0,2,12);
  1161. ctx.fillRect(102,0,2,12);
  1162. ctx.fillRect(0,5,104,2);
  1163.  
  1164. ctx.fillStyle = "rgb(80,80,80)";
  1165. ctx.fillRect(pos_0_100,0,5,12);
  1166. ctx.fillStyle = "rgb(200,200,200)";
  1167. ctx.fillRect(pos_0_100+1,1,3,10);
  1168. pourcent_text.nodeValue = val+'%';
  1169. previousVal = parseInt(val);
  1170. };
  1171.  
  1172. ////////////////////////////////////
  1173. // action sur mousedown et mousemove
  1174. // stocker la nouvelle valeur
  1175. // redessiner
  1176. // afficher la nouvelle valeur
  1177. // action selon ce qui a été demandé
  1178. ////////////////////////////////////
  1179. var doCallback_glissiere = function (evt) {
  1180. try {
  1181. if (evt.type === 'mousedown') mouseDown = true;
  1182. if (evt.offsetX) {
  1183. var xsouris = evt.offsetX;
  1184. var xpos = evt.clientX;
  1185. var ypos = evt.clientY + document.body.scrollTop;
  1186. }
  1187. else {
  1188. var xsouris = evt.layerX;
  1189. var xpos = evt.pageX;
  1190. var ypos = evt.pageY;
  1191. }
  1192. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1193. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1194. // afficher la nouvelle valeur dans la bulle
  1195. bulle_pourcent_text.nodeValue = val + '%';
  1196. bulle_pourcent.style.top = (ypos+3)+'px';
  1197. bulle_pourcent.style.left = (xpos+16)+'px';
  1198. if (evt.buttons === undefined) {
  1199. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1200. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1201. } else {
  1202. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1203. }
  1204. // stocker la nouvelle valeur
  1205. MY_setValue("MZ_glissiere_" + ref, val);
  1206. // redessiner la glissière avec le curseur où il faut
  1207. dessine_glissiere(val);
  1208. // action selon ce qui a été demandé
  1209. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1210. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1211. if (typeof paramTarget === 'object') {
  1212. var elt = paramTarget;
  1213. } else if (typeof paramTarget === 'string') {
  1214. var elt = document.getElementById(paramTarget);
  1215. } else if (typeof paramTarget === 'function') {
  1216. paramTarget(val);
  1217. return;
  1218. }
  1219. if (elt.setZoom != undefined) elt.setZoom(val);
  1220. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1221. };
  1222.  
  1223. ////////////////////////////////////
  1224. // event mousedown et mousemove : redessiner et callback
  1225. ////////////////////////////////////
  1226. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1227. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1228. ////////////////////////////////////
  1229. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1230. ////////////////////////////////////
  1231. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1232. ////////////////////////////////////
  1233. // event mouseout & mouseover : afficher/cacher la bulle
  1234. ////////////////////////////////////
  1235. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1236. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1237.  
  1238. ////////////////////////////////////
  1239. // dessiner la première fois
  1240. ////////////////////////////////////
  1241. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1242. if (val_init === undefined) val_init = valDef;
  1243. dessine_glissiere(val_init);
  1244. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1245. }
  1246.  
  1247. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1248. // reçoit 2 objets avec des propriétés x et y
  1249. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1250. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1251. var deltaX = locArrivee.x - locDepart.x;
  1252. if (deltaX == 0) return; // pas de point intermédiaire
  1253. var deltaY = locArrivee.y - locDepart.y;
  1254. if (deltaY == 0) return; // pas de point intermédiaire
  1255. var absDeltaX = Math.abs(deltaX);
  1256. var absDeltaY = Math.abs(deltaY);
  1257. if (absDeltaX > absDeltaY) {
  1258. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1259. } else if (absDeltaY > absDeltaX) {
  1260. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1261. } else {
  1262. return; // égalité, pas de point intermédiaire
  1263. }
  1264. }
  1265.  
  1266. /**********************
  1267. * carte en mode objet
  1268. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1269. *
  1270. * Usage:
  1271. * carte = new carte_MZ(ref, tabDepl);
  1272. * ref : utilisé pour diversifier les IDs HTML
  1273. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1274. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1275. * autres méthodes
  1276. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1277. **********************/
  1278.  
  1279. function carte_MZ(ref, tabDepl) {
  1280. try {
  1281. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1282. div1_carte.id = "MZ_carte_"+ref;
  1283. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1284. div1_carte.style.backgroundImage = 'none';
  1285. div1_carte.style.backgroundColor = 'transparent';
  1286. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1287. div2_carte.className = "carte_MZ";
  1288. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1289. var dessin = document.createElement("canvas"); // le dessin lui-même
  1290. dessin.id = "MZ_carte_dessin_"+ref;
  1291. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1292. div1_carte.appendChild(div2_carte);
  1293. div2_carte.appendChild(dessin);
  1294.  
  1295. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1296. , [-66.5, -37.5, 2, 1.5, -69]
  1297. , [-63.5, 8.5, 2, 1.5, -69]
  1298. , [-59.5, -32.5, 2, 1.5, -69]
  1299. , [-52, 57, 0.25, 0.8, -59]
  1300. , [-50.5, -22.5, 2, 1.5, -69]
  1301. , [-35.5, -51.5, 2, 1.5, -69]
  1302. , [-34.5, 14.5, 2, 1.5, -69]
  1303. , [-34.5, 64.5, 2, 1.5, -69]
  1304. , [-11.5, 72.5, 2, 1.5, -69]
  1305. , [5.5, -49.5, 2, 1.5, -69]
  1306. , [5.5, 31.5, 2, 1.5, -69]
  1307. , [10.5, 63.5, 2, 1.5, -69]
  1308. , [12, -15, 0.25, 0.8, -59]
  1309. , [21.5, 35.5, 2, 1.5, -69]
  1310. , [30, -52, 0.25, 0.8, -59]
  1311. , [46.5, 51.5, 2, 1.5, -69]
  1312. , [48, -39, 0.25, 0.8, -59]
  1313. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1314. , [56.5, 23.5, 75, 8.7, -99]
  1315. , [64, 70, 0.25, 0.8, -59]
  1316. , [74.5, 31.5, 2, 1.5, -69]];
  1317.  
  1318. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1319. var couleur_cible = 'rgba(0,0,0,0.5)';
  1320. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1321. var couleur_trou = 'rgb(200,0,0)';
  1322.  
  1323. var coord_x = function(val) {
  1324. return decalh+coeff*(val+100);
  1325. };
  1326. var coord_y = function(val) {
  1327. return decalv+coeff*(100-val);
  1328. };
  1329.  
  1330. var ctx = dessin.getContext('2d');
  1331. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1332. if (coeff) coeff /= 50;
  1333. else coeff = 2;
  1334. var decalv=30, decalh=30;
  1335.  
  1336. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1337. //var res = false
  1338. var x0 = pos0.x;
  1339. var y0 = pos0.x;
  1340. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1341. var px = Math.sign(pos1.x - pos0.x);
  1342. var py = Math.sign(pos1.y - pos0.y);
  1343. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1344. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1345.  
  1346. for(var k in position_trous_MZ) {
  1347. a = parseFloat(px*px+py*py);
  1348. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1349. 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]);
  1350. delta = b*b-a*c
  1351. if(delta >= 0) {
  1352. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1353. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1354. if(t0 <= tmax && t1 >= 0) {
  1355. // 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
  1356. //res = true;
  1357. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1358. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1359. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1360. // Roule : pas utile pour nous
  1361. //res = true;
  1362. //chute.push([x0+l*px, y0+l*py]);
  1363. return true;
  1364. }
  1365. }
  1366. }
  1367. }
  1368. //return res;
  1369. return false;
  1370. };
  1371.  
  1372. var dessine_carte = function () {
  1373. dessin.width = 200*coeff+2*decalh;
  1374. dessin.height = 200*coeff+2*decalv;
  1375.  
  1376. //repere
  1377. ctx.beginPath();
  1378. ctx.moveTo(coord_x(0), coord_y(100));
  1379. ctx.lineTo(coord_x(0), coord_y(-100));
  1380. ctx.moveTo(coord_x(-100), coord_y(0));
  1381. ctx.lineTo(coord_x(100), coord_y(0));
  1382. ctx.stroke();
  1383. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1384.  
  1385. //trous
  1386. ctx.fillStyle = couleur_trou;
  1387. for(var i in position_trous_MZ) {
  1388. ctx.beginPath();
  1389. 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);
  1390. ctx.fill();
  1391. }
  1392. // trajets
  1393. ctx.lineCap = "round";
  1394. ctx.lineJoin = "round";
  1395. for (var iSuivant in tabDepl) {
  1396. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1397. var tabDeplOneSuivant = tabDepl[iSuivant];
  1398. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1399. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1400. // La "cible" au départ
  1401. var typeDepart = tabDeplOneSuivant[0].typ;
  1402. switch (typeDepart) {
  1403. case 'tp':
  1404. ctx.beginPath();
  1405. ctx.lineWidth = 2;
  1406. ctx.strokeStyle = couleur_cible;
  1407. ctx.fillStyle = couleur_cible;
  1408. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1409. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1410. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1411. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1412. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1413. ctx.moveTo(x0 + coeff * 3, y0);
  1414. ctx.lineTo(x0 - coeff * 3, y0);
  1415. ctx.moveTo(x0, y0 + coeff * 3);
  1416. ctx.lineTo(x0, y0 - coeff * 3);
  1417. ctx.stroke();
  1418. break;
  1419. default:
  1420. ctx.beginPath();
  1421. ctx.lineWidth = 1;
  1422. ctx.strokeStyle = couleur_cible;
  1423. ctx.fillStyle = couleur_cible;
  1424. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1425. ctx.moveTo(x0 + coeff * 4, y0);
  1426. ctx.lineTo(x0 - coeff * 4, y0);
  1427. ctx.moveTo(x0, y0 + coeff * 4);
  1428. ctx.lineTo(x0, y0 - coeff * 4);
  1429. ctx.stroke();
  1430. break;
  1431. }
  1432. // les segments
  1433. var nb_pts = tabDeplOneSuivant.length;
  1434. var pointPrecedent = tabDeplOneSuivant[0];
  1435. for (var i=1; i<nb_pts; i++) {
  1436. ctx.beginPath();
  1437. ctx.lineWidth = coeff;
  1438. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1439. ctx.strokeStyle = couleur_depl_normal;
  1440. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1441. if (pointIntermediaire === undefined) {
  1442. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1443. ctx.strokeStyle = couleur_depl_collision_trou;
  1444. else
  1445. ctx.strokeStyle = couleur_depl_normal;
  1446. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1447. } else {
  1448. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1449. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1450. ctx.strokeStyle = couleur_depl_collision_trou;
  1451. else
  1452. ctx.strokeStyle = couleur_depl_normal;
  1453. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1454. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1455. }
  1456. pointPrecedent = tabDeplOneSuivant[i];
  1457. ctx.stroke();
  1458. }
  1459. // Les points à chaque étape
  1460. ctx.fillStyle = couleur_depl_normal;
  1461. for (var i=1; i<nb_pts; i++) {
  1462. ctx.beginPath();
  1463. var x = coord_x(tabDeplOneSuivant[i].x);
  1464. var y = coord_y(tabDeplOneSuivant[i].y);
  1465. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1466. ctx.fill();
  1467. }
  1468. }
  1469. }
  1470.  
  1471. this.setZoom = function (val) {
  1472. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1473. coeff = val / 50;
  1474. dessine_carte();
  1475. }
  1476.  
  1477. // glissiere
  1478. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1479. var eGliss = gliss.getElt();
  1480. eGliss.style.position = 'absolute';
  1481. eGliss.style.top = (coeff * 2) + 'px';
  1482. eGliss.style.left = decalh + 'px';
  1483. dessin.style.position = 'relative';
  1484. div2_carte.style.position = 'relative';
  1485. eGliss.style.zIndex = 9000;
  1486. div2_carte.appendChild(eGliss);
  1487.  
  1488. // affichage au survol de la souris
  1489. var bulle = document.createElement('div');
  1490. bulle.style.visibility = 'hidden';
  1491. bulle.style.position = 'absolute';
  1492. bulle.style.zIndex = 3100;
  1493. bulle.style.border = 'solid 1px #a1927f';
  1494. bulle.className = 'mh_tdpage';
  1495. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1496. var bulleHaut = document.createElement('div');
  1497. bulleHaut.style.display = 'block';
  1498. bulleHaut.style.paddingRight = '3px';
  1499. bulleHaut.className = 'mh_tdtitre';
  1500. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1501. bulle.appendChild(bulleHaut);
  1502. var bulleBas = document.createElement('div');
  1503. bulleBas.style.display = 'block';
  1504. bulleBas.style.whiteSpace = "nowrap";
  1505. bulleBas.style.paddingRight = '3px';
  1506.  
  1507. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1508. bulle.appendChild(bulleBas);
  1509. div2_carte.appendChild(bulle);
  1510. var affichePosition = function(evt) {
  1511. if (evt.offsetX) {
  1512. var xsouris = evt.offsetX;
  1513. var ysouris = evt.offsetY;
  1514. var xpos = evt.clientX;
  1515. var ypos = evt.clientY + document.body.scrollTop;
  1516. }
  1517. else {
  1518. var xsouris = evt.layerX;
  1519. var ysouris = evt.layerY;
  1520. var xpos = evt.pageX;
  1521. var ypos = evt.pageY;
  1522. }
  1523. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1524. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1525. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1526. var tabHTMLbas = [];
  1527. // message pour les trous
  1528. for (var i in position_trous_MZ) {
  1529. var ceTrou = position_trous_MZ[i];
  1530. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1531. if(dist <= 0) {
  1532. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1533. break;
  1534. }
  1535. }
  1536. // messages pour les suivants
  1537. for (var i in tabDepl) {
  1538. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1539. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1540. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1541. }
  1542. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1543. bulle.style.top = (ysouris+8) + 'px';
  1544. bulle.style.left = (xsouris+16) + 'px';
  1545. };
  1546. addEvent(dessin, "mousemove", affichePosition, true);
  1547. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1548. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1549.  
  1550. // dessin initial
  1551. dessine_carte();
  1552.  
  1553. this.getElt = function() {return div1_carte;};
  1554.  
  1555. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1556. }
  1557.  
  1558.  
  1559. /**********************************************************
  1560. **** Fin de zone à déplacer dans une bibli commune ********
  1561. **********************************************************/
  1562.  
  1563. /* DEBUG: NETTOYAGE TAGS */
  1564. if(MY_getValue(numTroll+'.TAGSURL')) {
  1565. MY_removeValue(numTroll+'.TAGSURL');
  1566. }
  1567.  
  1568. // Alerte si mode dev
  1569. if (isDEV) {
  1570. var divpopup = document.createElement('div');
  1571. divpopup.id = 'divDEV';
  1572. divpopup.style =
  1573. 'position: fixed;'+
  1574. 'border: 15px solid red;'+
  1575. 'top: 10px;right: 10px;'+
  1576. 'background-color: white;'+
  1577. 'color: black;'+
  1578. 'font-size: large;'+
  1579. 'padding: 5px'+
  1580. 'z-index: 200;';
  1581. appendText(divpopup, '[MZ] Mode DEV');
  1582. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1583. document.body.appendChild(divpopup);
  1584. }
  1585.  
  1586. /*---------- regroupement des getPortee() ------------------------------------*/
  1587. // issu des script profil et profil2
  1588. function getPortee__Profil(param) {
  1589. param = Math.max(0,Number(param));
  1590. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1591. // ça devrait être floor, +10.25, -2.5
  1592. }
  1593.  
  1594. // issu du script vue
  1595. function getPortee__Vue(param) {
  1596. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1597. }
  1598.  
  1599.  
  1600. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1601.  
  1602. function getPXKill(niv) {
  1603. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1604. return Math.max(0,10+3*niv-2*nivTroll);
  1605. }
  1606.  
  1607. function getPXDeath(niv) {
  1608. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1609. return Math.max(0,10+3*nivTroll-2*niv);
  1610. }
  1611.  
  1612. function analysePX(niv) {
  1613. niv = niv+'';
  1614. var i = niv.indexOf('+');
  1615. if(i!=-1) // si niv = 'XX+' ??
  1616. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1617. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1618. if(i!=-1) {
  1619. var max = getPXKill(niv.slice(i+2));
  1620. if(max==0)
  1621. return ' --> <b>0</b> PX';
  1622. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1623. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1624. }
  1625. i = niv.indexOf('='); // ???
  1626. if(i!=-1) {
  1627. var max = getPXKill(niv.slice(i+1));
  1628. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1629. }
  1630. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1631. }
  1632.  
  1633. function analysePXTroll(niv) {
  1634. var str = analysePX(niv);
  1635. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1636. return str;
  1637. }
  1638.  
  1639.  
  1640. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1641. // Refonte totale du code de Zorya
  1642.  
  1643. // Elements à implémenter en dur dans MZ2.0
  1644. var numQualite = {
  1645. 'Très Mauvaise':1,
  1646. 'Mauvaise':2,
  1647. 'Moyenne':3,
  1648. 'Bonne':4,
  1649. 'Très Bonne':5
  1650. };
  1651.  
  1652. var qualiteNum = [
  1653. '_dummy_',
  1654. 'Très Mauvaise',
  1655. 'Mauvaise',
  1656. 'Moyenne',
  1657. 'Bonne',
  1658. 'Très Bonne'
  1659. ];
  1660.  
  1661. var nival = {
  1662. 'Abishaii Bleu':19,
  1663. 'Abishaii Noir':10,
  1664. 'Abishaii Rouge':23,
  1665. 'Abishaii Vert':15,
  1666. 'Ame-en-peine':8,
  1667. 'Amibe Geante':9,
  1668. 'Anaconda des Catacombes':8,
  1669. 'Ankheg':10,
  1670. 'Anoploure Purpurin':36,
  1671. 'Araignee Geante':2,
  1672. 'Ashashin':35,
  1673. 'Balrog':50,
  1674. 'Banshee':16,
  1675. 'Barghest':36,
  1676. 'Basilisk':11,
  1677. 'Behemoth':34,
  1678. 'Behir':14,
  1679. 'Beholder':50,
  1680. 'Boggart':3,
  1681. 'Bondin':9,
  1682. "Bouj'Dla Placide":37,
  1683. "Bouj'Dla":19,
  1684. 'Bulette':19,
  1685. 'Caillouteux':1,
  1686. 'Capitan':35,
  1687. 'Carnosaure':25,
  1688. 'Champi-Glouton':3,
  1689. 'Chauve-Souris Geante':4,
  1690. 'Cheval a Dents de Sabre':23,
  1691. 'Chevalier du Chaos':20,
  1692. 'Chimere':13,
  1693. 'Chonchon':24,
  1694. 'Coccicruelle':22,
  1695. 'Cockatrice':5,
  1696. 'Crasc Medius':17,
  1697. 'Crasc Maexus':25,
  1698. 'Crasc':10,
  1699. 'Croquemitaine':6,
  1700. 'Cube Gelatineux':32,
  1701. 'Daemonite':27,
  1702. 'Diablotin':5,
  1703. 'Dindon du Chaos':1,
  1704. 'Djinn':29,
  1705. 'Ectoplasme':18,
  1706. 'Effrit':27,
  1707. "Elementaire d'Air":23,
  1708. "Elementaire d'Eau":17,
  1709. 'Elementaire de Feu':21,
  1710. 'Elementaire de Terre':21,
  1711. 'Elementaire du Chaos':26,
  1712. 'Erinyes':7,
  1713. 'Esprit-Follet':16,
  1714. 'Essaim Craterien':30,
  1715. 'Essaim Sanguinaire':25,
  1716. 'Ettin':8,
  1717. 'Familier':1,
  1718. 'Fantome':24,
  1719. 'Feu Follet':20,
  1720. 'Flagelleur Mental':33,
  1721. 'Foudroyeur':38,
  1722. 'Fumeux':22,
  1723. 'Fungus Geant':9,
  1724. 'Fungus Violet':4,
  1725. 'Furgolin':10,
  1726. 'Gargouille':3,
  1727. 'Geant de Pierre':13,
  1728. 'Geant des Gouffres':22,
  1729. "Geck'oo Majestueux":40,
  1730. "Geck'oo":15,
  1731. 'Glouton':20,
  1732. 'Gnoll':5,
  1733. 'Gnu Domestique':1,
  1734. 'Gnu Sauvage':1,
  1735. 'Goblin':4,
  1736. 'Goblours':4,
  1737. "Golem d'Argile":15,
  1738. 'Golem de cuir':1,
  1739. 'Golem de Chair':8,
  1740. 'Golem de Fer':31,
  1741. 'Golem de mithril':1,
  1742. 'Golem de metal':1,
  1743. 'Golem de papier':1,
  1744. 'Golem de Pierre':23,
  1745. 'Gorgone':11,
  1746. 'Goule':4,
  1747. 'Gowap Apprivoise':1,
  1748. 'Gowap Sauvage':1,
  1749. 'Gremlins':3,
  1750. 'Gritche':39,
  1751. 'Grouilleux':4,
  1752. 'Grylle':31,
  1753. 'Harpie':4,
  1754. 'Hellrot':18,
  1755. 'Homme-Lezard':4,
  1756. 'Hurleur':8,
  1757. 'Hydre':50,
  1758. 'Incube':13,
  1759. 'Kobold':2,
  1760. 'Labeilleux':26,
  1761. 'Lezard Geant':5,
  1762. 'Liche':50,
  1763. 'Limace Geante':10,
  1764. 'Loup-Garou':8,
  1765. 'Lutin':4,
  1766. 'Mante Fulcreuse':30,
  1767. 'Manticore':9,
  1768. 'Marilith':33,
  1769. 'Meduse':6,
  1770. 'Megacephale':38,
  1771. 'Mille-Pattes Geant':14,
  1772. 'Mimique':6,
  1773. 'Minotaure':7,
  1774. 'Molosse Satanique':8,
  1775. 'Momie':4,
  1776. 'Monstre Rouilleur':3,
  1777. "Mouch'oo Domestique":14,
  1778. "Mouch'oo Majestueux Sauvage":33,
  1779. "Mouch'oo Sauvage":14,
  1780. 'Na-Haniym-Heee':0,
  1781. 'Necrochore':37,
  1782. 'Necromant':39,
  1783. 'Necrophage':8,
  1784. 'Naga':10,
  1785. 'Nuee de Vermine':13,
  1786. "Nuage d'Insectes":7,
  1787. 'Ogre':7,
  1788. 'Ombre de Roches':13,
  1789. 'Ombre':2,
  1790. 'Orque':3,
  1791. 'Ours-Garou':18,
  1792. 'Palefroi Infernal':29,
  1793. 'Phoenix':32,
  1794. 'Pititabeille':0,
  1795. 'Plante Carnivore':4,
  1796. 'Pseudo-Dragon':5,
  1797. 'Rat Geant':2,
  1798. 'Rat-Garou':3,
  1799. 'Rocketeux':5,
  1800. 'Sagouin':3,
  1801. 'Scarabee Geant':4,
  1802. 'Scorpion Geant':10,
  1803. 'Shai':28,
  1804. 'Sirene':8,
  1805. 'Slaad':5,
  1806. 'Sorciere':17,
  1807. 'Spectre':14,
  1808. 'Sphinx':30,
  1809. 'Squelette':1,
  1810. 'Strige':2,
  1811. 'Succube':13,
  1812. 'Tertre Errant':20,
  1813. 'Thri-kreen':10,
  1814. 'Tigre-Garou':12,
  1815. 'Titan':26,
  1816. 'Trancheur':35,
  1817. 'Tubercule Tueur':14,
  1818. 'Tutoki':4,
  1819. 'Vampire':29,
  1820. 'Ver Carnivore Geant':12,
  1821. 'Ver Carnivore':11,
  1822. 'Veskan Du Chaos':14,
  1823. 'Vouivre':33,
  1824. 'Worg':5,
  1825. 'Xorn':14,
  1826. 'Yeti':8,
  1827. 'Yuan-ti':15,
  1828. 'Zombie':2
  1829. }
  1830.  
  1831. var tabEM = {
  1832. //Monstre: [Compo exact, Sort, Position, Localisation]
  1833. // AA
  1834. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1835. // AE
  1836. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1837. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1838. // AdA
  1839. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1840. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1841. // AdE
  1842. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1843. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1844. // AdD
  1845. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1846. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1847. // BAM
  1848. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1849. // BuM
  1850. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1851. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1852. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1853. // Explo
  1854. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1855. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1856. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1857. // FP
  1858. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1859. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1860. // FA
  1861. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1862. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1863. // Glue
  1864. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1865. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1866. // GdS
  1867. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1868. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1869. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1870. // Invi
  1871. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1872. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1873. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1874. // Lévitation
  1875. // ???
  1876. // PréM :
  1877. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1878. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1879. // Proj
  1880. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1881. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1882. // PuM :
  1883. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1884. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1885. // Sacro
  1886. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1887. // Télék
  1888. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1889. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1890. // TP
  1891. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1892. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1893. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1894. // VA
  1895. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1896. // VL
  1897. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1898. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1899. // VlC
  1900. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1901. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1902. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1903. // VT
  1904. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1905. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1906. // Variables
  1907. 'Rat':["d'un"],
  1908. 'Rat Géant':["d'un"],
  1909. 'Dindon':["d'un"],
  1910. 'Goblin':["d'un"],
  1911. 'Limace':["d'une"],
  1912. 'Limace Géante':["d'une"],
  1913. 'Ver':["d'un"],
  1914. 'Ver Carnivore':["d'un"],
  1915. 'Ver Carnivore Géant':["d'un"],
  1916. 'Fungus':["d'un"],
  1917. 'Vouivre':["d'une"],
  1918. 'Gnu':["d'un"],
  1919. 'Scarabée':["d'un"]
  1920. };
  1921.  
  1922. var mundiChampi = {
  1923. 'Préscientus Reguis':'du Phoenix',
  1924. 'Amanite Trolloïde':'de la Mouche',
  1925. 'Girolle Sanglante':'du Dindon',
  1926. 'Horreur Des Prés':'du Gobelin',
  1927. 'Bolet Péteur':'du Démon',
  1928. 'Pied Jaune':'de la Limace',
  1929. 'Agaric Sous-Terrain':'du Rat',
  1930. 'Suinte Cadavre':"de l'Hydre",
  1931. 'Cèpe Lumineux':'du Ver',
  1932. 'Fungus Rampant':'du Fungus',
  1933. 'Nez Noir':'de la Vouivre',
  1934. 'Pleurote Pleureuse':'du Gnu',
  1935. 'Phytomassus Xilénique':'du Scarabée'
  1936. };
  1937.  
  1938. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1939. appendText(node,' ');
  1940. var urlImg = URL_MZimg
  1941. +'Competences/melangeMagique.png';
  1942. var text = ' [-'+(niv+effetQ)+' %]';
  1943. var str = '';
  1944. switch(mob[0]) {
  1945. case 'A':
  1946. case 'E':
  1947. case 'I':
  1948. case 'O':
  1949. case 'U':
  1950. str = "Compo d'";
  1951. break;
  1952. default:
  1953. str = 'Compo de ';
  1954. }
  1955. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1956. var span = createImageSpan(urlImg,'MM:',title,text);
  1957. node.appendChild(span);
  1958. }
  1959.  
  1960. function addInfoEM(node,mob,compo,qualite,localisation) {
  1961. if(!tabEM[mob]) return;
  1962. var title = 'Composant variable', texte = 'Variable';
  1963. var bold = false;
  1964. if(tabEM[mob].length>1) {
  1965. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1966. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1967. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1968. if(pc<-20) return;
  1969. if(pc>=0) bold = true;
  1970. texte = aff(pc)+'%';
  1971. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1972. }
  1973. var urlImg = URL_MZimg
  1974. +'Competences/ecritureMagique.png';
  1975. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1976. node.appendChild(span);
  1977. }
  1978.  
  1979. function insererInfosEM(tbody) {
  1980. // lancé par equip, equipgowap
  1981. var trCompos = document.evaluate(
  1982. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1983. tbody,null,7,null);
  1984. var strCompos = '';
  1985. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1986. var node = trCompos.snapshotItem(i).childNodes[7];
  1987. var str = node.firstChild.textContent;
  1988. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1989. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1990. // Si non-EM on stoppe le traitement
  1991. if(!tabEM[mob]) continue;
  1992. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1993. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1994. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1995. addInfoEM(node,mob,compo,qualite,localisation);
  1996. }
  1997. }
  1998.  
  1999. function getQualite(qualite) {
  2000. var nb = numQualite[qualite];
  2001. return nb ? nb-1 : -1;
  2002. }
  2003.  
  2004. function getEM(nom) {
  2005. if(nom.indexOf('[')!=-1)
  2006. nom = trim(nom.substring(0,nom.indexOf('[')));
  2007. if(tabEM[nom]) return nom;
  2008. return '';
  2009. }
  2010.  
  2011. // DEBUG ex-fonction composantEM
  2012. function compoMobEM(mob) {
  2013. if(!tabEM[mob]) return '';
  2014. if(tabEM[mob].length==1)
  2015. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  2016. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  2017. +") pour l'écriture de "+tabEM[mob][1];
  2018. }
  2019.  
  2020. // DEBUG ex-fonction compoEM
  2021. function titreCompoEM(mob,compo,localisation,qualite) {
  2022. if(!tabEM[mob]) return '';
  2023. if(tabEM[mob].length==1) return 'Composant variable';
  2024.  
  2025. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  2026. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  2027. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  2028.  
  2029. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  2030. return '';
  2031. }
  2032.  
  2033. // DEBUG - rétrocompatibilité
  2034. function compoEM(mob) {
  2035. // appelé dans libs, vue
  2036. return compoMobEM(mob);
  2037. }
  2038. function composantEM(mob,compo,localisation,qualite) {
  2039. // appelé dans libs, tancompo
  2040. return titreCompoEM(mob,compo,localisation,qualite);
  2041. }
  2042. //
  2043.  
  2044.  
  2045. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  2046.  
  2047. arrayTalents = {
  2048. /* Compétences */
  2049. 'Acceleration du Metabolisme':'AM',
  2050. 'Attaque Precise':'AP',
  2051. 'Balayage':'Balayage',
  2052. //'Balluchonnage':'Ballu',
  2053. 'Baroufle':'Baroufle',
  2054. 'Bidouille':'Bidouille',
  2055. 'Botte Secrete':'BS',
  2056. 'Camouflage':'Camou',
  2057. 'Charger':'Charger',
  2058. 'Connaissance des Monstres':'CdM',
  2059. 'Construire un Piege':'Piege',
  2060. 'Piege a Feu':'PiegeFeu',
  2061. 'Piege a Glue':'PiegeGlue',
  2062. 'Contre-Attaquer':'CA',
  2063. 'Coup de Butoir':'CdB',
  2064. 'Course':'Course',
  2065. 'Deplacement Eclair':'DE',
  2066. 'Dressage':'Dressage',
  2067. 'Ecriture Magique':'EM',
  2068. 'Frenesie':'Frenesie',
  2069. 'Golemologie':'Golemo',
  2070. 'Golem de cuir':'GolemCuir',
  2071. 'Golem de metal':'GolemMetal',
  2072. 'Golem de mithril':'GolemMithril',
  2073. 'Golem de papier':'GolemPapier',
  2074. 'Grattage':'Grattage',
  2075. 'Hurlement Effrayant':'HE',
  2076. 'Identification des Champignons':'IdC',
  2077. 'Insultes':'Insultes',
  2078. 'Lancer de Potions':'LdP',
  2079. 'Marquage':'Marquage',
  2080. 'Melange Magique':'Melange',
  2081. 'Miner':'Miner',
  2082. 'Travail de la Pierre':'Pierre',
  2083. 'Necromancie':'Necro',
  2084. 'Painthure de Guerre':'PG',
  2085. 'Parer':'Parer',
  2086. 'Pistage':'Pistage',
  2087. 'Planter un Champignon':'PuC',
  2088. 'Regeneration Accrue':'RA',
  2089. 'Reparation':'Reparation',
  2090. 'Retraite':'Retraite',
  2091. 'RotoBaffe':'RB',
  2092. 'Shamaner':'Shamaner',
  2093. "S'interposer":'SInterposer',
  2094. 'Tailler':'Tailler',
  2095. //'Vol':'Vol',
  2096. /* Sortilèges */
  2097. 'Analyse Anatomique':'AA',
  2098. 'Armure Etheree':'AE',
  2099. 'Augmentation de l´Attaque':'AdA', // obsolète?
  2100. "Augmentation de l'Attaque":'AdA',
  2101. 'Augmentation de l´Esquive':'AdE',
  2102. 'Augmentation des Degats':'AdD',
  2103. 'Bulle Anti-Magie':'BAM',
  2104. 'Bulle Magique':'BuM',
  2105. 'Explosion':'Explo',
  2106. 'Faiblesse Passagere':'FP',
  2107. 'Flash Aveuglant':'FA',
  2108. 'Glue':'Glue',
  2109. 'Griffe du Sorcier':'GdS',
  2110. 'Hypnotisme':'Hypno',
  2111. 'Identification des Tresors':'IdT',
  2112. 'Invisibilite':'Invi',
  2113. 'Levitation':'Levitation',
  2114. 'Precision Magique':'PreM',
  2115. 'Projectile Magique':'Projo',
  2116. 'Projection':'Proj',
  2117. 'Puissance Magique':'PuM',
  2118. 'Rafale Psychique':'Rafale',
  2119. 'Sacrifice':'Sacro',
  2120. 'Siphon des ames':'Siphon',
  2121. 'Telekinesie':'Telek',
  2122. 'Teleportation':'TP',
  2123. 'Vampirisme':'Vampi',
  2124. 'Vision Accrue':'VA',
  2125. 'Vision lointaine':'VL',
  2126. 'Voir le Cache':'VlC',
  2127. 'Vue Troublee':'VT'
  2128. //'':''
  2129. }
  2130.  
  2131. // DEBUG - Pour rétrocompatibilité
  2132. function getSortComp(nom,niveau) {
  2133. return getTalent(nom,niveau);
  2134. }
  2135. //
  2136.  
  2137. function getTalent(nom,niveau) {
  2138. if(nom===true) return true;
  2139. var nomEnBase = arrayTalents[epure(nom)];
  2140. if(!nomEnBase) nomEnBase=nom;
  2141. if(!niveau) var niveau = '';
  2142. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2143. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  2144. return 0;
  2145. }
  2146.  
  2147. function removeAllTalents() {
  2148. for(var talent in arrayTalents) {
  2149. var nomEnBase = arrayTalents[talent];
  2150. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2151. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2152. continue;
  2153. }
  2154. var niveau = 1;
  2155. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2156. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2157. niveau++;
  2158. }
  2159. }
  2160. }
  2161.  
  2162. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2163. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2164. var att = MY_getValue(numTroll+'.caracs.attaque');
  2165. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2166. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2167. var mm = MY_getValue(numTroll+'.caracs.mm');
  2168. var deg = MY_getValue(numTroll+'.caracs.degats');
  2169. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2170. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2171. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2172. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2173. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2174. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2175. return false;
  2176. return true;
  2177. } catch(e) {
  2178. return false;
  2179. }
  2180. }
  2181.  
  2182.  
  2183. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2184.  
  2185. function getPVsRestants(pv,bless,vue) {
  2186. bless = Number(bless.match(/\d+/)[0]);
  2187. if(bless==0) return null;
  2188. var pvminmax = pv.match(/\d+/g);
  2189. var oMinMaxPV = {min: pvminmax[0], max: pvminmax[1]};
  2190. var oMinMaxPVRestant = MZ_getPVsRestants(oMinMaxPV, bless);
  2191. return vue ? ' ('+oMinMaxPVRestant.min+'-'+oMinMaxPVRestant.max+')' :
  2192. ['Points de Vie restants : ','Entre '+oMinMaxPVRestant.min+' et '+oMinMaxPVRestant.max];
  2193. /* à supprimer
  2194. if(bless==95) {
  2195. var pvb = 1;
  2196. var pvh = Math.floor( pvminmax[1]/20 );
  2197. }
  2198. else if(bless==5) {
  2199. var pvb = Math.floor( pvminmax[0]*19/20 );
  2200. var pvh = pvminmax[1];
  2201. }
  2202. else {
  2203. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2204. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2205. }
  2206. return vue ? ' ('+pvb+'-'+pvh+')' :
  2207. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2208. }
  2209. */
  2210. }
  2211.  
  2212. function MZ_getPVsRestants(oMinMaxPV, bless) { // rend un objet minmax
  2213. if(bless==95) {
  2214. return {min: 1, max:Math.floor( oMinMaxPV.max/20 )};
  2215. } else if(bless==5) {
  2216. return {min: Math.floor( oMinMaxPV.min*19/20 ), max: oMinMaxPV.max};
  2217. } else {
  2218. return {min: Math.ceil( oMinMaxPV.min*(95-bless) / 100 ), max: Math.floor( oMinMaxPV.max*(105-bless) / 100 )};
  2219. }
  2220. }
  2221.  
  2222. function insertButtonCdm(nextName,onClick,texte) {
  2223. if(texte==null) texte = 'Participer au bestiaire';
  2224. var nextNode = document.getElementsByName(nextName)[0];
  2225.  
  2226. var espace = document.createTextNode('\t');
  2227. insertBefore(nextNode,espace);
  2228.  
  2229. var button = document.createElement('input');
  2230. button.type = 'button';
  2231. button.className = 'mh_form_submit';
  2232. button.value = texte;
  2233. button.onmouseover = function(){this.style.cursor='pointer';};
  2234. if(onClick) button.onclick = onClick;
  2235. insertBefore(espace,button);
  2236. return button;
  2237. }
  2238.  
  2239. /* appelé par
  2240. createCDMTable (dans le popup DcM)
  2241. computeTactique (à coté du nom des monstres dans la vue et dans la page de détail des monstres)
  2242. */
  2243. function createImageTactique(url,id,nom) {
  2244. var img = document.createElement('img');
  2245. img.src = url;
  2246. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  2247. img.id = id;
  2248. img.nom = nom;
  2249. img.onmouseover = showPopupTactique;
  2250. img.onmouseout = hidePopup;
  2251. return img;
  2252. }
  2253.  
  2254. function createCDMTable(id,nom,donneesMonstre, closeFunct) { // rend un Élément Table
  2255. try {
  2256. var table = document.createElement('table');
  2257. var profilActif = isProfilActif();
  2258. table.className = 'mh_tdborder';
  2259. table.border = 0;
  2260. table.cellSpacing = 1;
  2261. table.cellPadding = 4;
  2262.  
  2263. var thead = document.createElement('thead');
  2264. var tr = appendTr(thead,'mh_tdtitre');
  2265. var td = appendTdText(tr, 'CDM de ' + nom + ' (N° '+ id + ')', false);
  2266. td.style.fontWeight = 'bold';
  2267. if (closeFunct) {
  2268. td.colSpan = 2;
  2269. td.style.borderRight = 'none';
  2270. td = appendTdText(tr, 'X', false);
  2271. td.style.cursor = 'pointer';
  2272. td.style.textAlign = 'right';
  2273. td.style.fontWeight = 'bold';
  2274. td.style.width = '1%';
  2275. td.style.borderLeft = 'none';
  2276. td.onclick = closeFunct;
  2277. } else {
  2278. td.colSpan = 3;
  2279. }
  2280. table.appendChild(thead);
  2281. var tbody = document.createElement('tbody');
  2282. table.appendChild(tbody);
  2283.  
  2284. // calcul des PX gagnés
  2285. var ominmaxPX = {};
  2286. if (donneesMonstre.niv) {
  2287. if (donneesMonstre.niv.min) ominmaxPX.min = getPXKill(donneesMonstre.niv.min);
  2288. if (donneesMonstre.niv.max) ominmaxPX.max = getPXKill(donneesMonstre.niv.max);
  2289. }
  2290.  
  2291. MZ_tab_carac_add_tr_minmax2(tbody, 'Niveau', donneesMonstre.niv, 'PX', ominmaxPX);
  2292. MZ_tab_carac_add_tr_texte(tbody, 'Famille', donneesMonstre.fam, '');
  2293. //MZ_tab_carac_add_tr_texte(tbody, 'Génération', donneesMonstre.gen == 23 ? '2 ou 3' : donneesMonstre.gen, ''); // remplacé par une icône
  2294. MZ_tab_carac_add_tr_texte(tbody, 'Blessure', MZ_tab_carac_mkBlessureTexte(donneesMonstre), '');
  2295. MZ_tab_carac_add_tr_minmax(tbody, 'Points de Vie', donneesMonstre.pv, 'PV');
  2296. MZ_tab_carac_add_tr_minmax(tbody, 'Attaque', donneesMonstre.att, 'D6');
  2297. MZ_tab_carac_add_tr_minmax(tbody, 'Esquive', donneesMonstre.esq, 'D6');
  2298. MZ_tab_carac_add_tr_minmax(tbody, 'Dégâts', donneesMonstre.deg, 'D3');
  2299. MZ_tab_carac_add_tr_minmax(tbody, 'Régénération', donneesMonstre.reg, 'D3');
  2300. MZ_tab_carac_add_tr_minmax(tbody, 'Armure physique', donneesMonstre.armP, '');
  2301. MZ_tab_carac_add_tr_minmax(tbody, 'Armure magique', donneesMonstre.armM, '');
  2302. MZ_tab_carac_add_tr_minmax(tbody, 'Armure totale', donneesMonstre.arm, '');
  2303. MZ_tab_carac_add_tr_minmax(tbody, 'Vue', donneesMonstre.vue, 'Case(s)');
  2304. MZ_tab_carac_add_tr_minmax(tbody, 'MM', donneesMonstre.MM, '');
  2305. MZ_tab_carac_add_tr_minmax(tbody, 'RM', donneesMonstre.RM, '');
  2306. MZ_tab_carac_add_tr_minmax(tbody, 'Durée du tour', donneesMonstre.duree, ' heures');
  2307. MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre);
  2308. MZ_tab_carac_add_tr_autres(tbody, donneesMonstre, id, nom);
  2309. /* à supprimer, remplacé par un "title" sur le 3e td de "autres"
  2310. var msgInfo = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2311. if (msgInfo) MZ_tab_carac_add_tr_sansTitre(tbody, msgInfo, 0, true);
  2312. */
  2313. return table;
  2314. }
  2315. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2316. }
  2317.  
  2318. function MZ_tab_carac_mkBlessureTexte(donneesMonstre) {
  2319. if (donneesMonstre.bless === undefined) return;
  2320. var texte = donneesMonstre.bless + '%';
  2321. if (donneesMonstre.bless > 0 && donneesMonstre.pv && donneesMonstre.pv.min && donneesMonstre.pv.max) {
  2322. ominmax = MZ_getPVsRestants(donneesMonstre.pv, donneesMonstre.bless);
  2323. texte += ' (' + ominmax.min + '-' + ominmax.max + ')';
  2324. }
  2325. if (donneesMonstre.timegmt) {
  2326. texte += ' le ' + MZ_formatDateMS(new Date(donneesMonstre.timegmt * 1000), true);
  2327. }
  2328. return texte;
  2329. }
  2330.  
  2331. function MZ_tab_carac_add_tr_sansTitre(table, msg, bItalic) {
  2332. if (!msg) return;
  2333. var tr = appendTr(table,'mh_tdpage');
  2334. td = appendTdText(tr,msg);
  2335. td.colSpan = 3;
  2336. if (bItalic) td.style.fontStyle = 'italic';
  2337. td.className = 'mh_tdpage';
  2338. return td;
  2339. }
  2340.  
  2341. function MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre) {
  2342. if (!donneesMonstre.pouv) return;
  2343. var td = MZ_tab_carac_add_tr_texte(tbody, 'Pouvoir', donneesMonstre.pouv + ' ', '', 0);
  2344. var tabImg = [];
  2345. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.portpouv, {
  2346. 'de zone': ["zone.gif","Pouvoir de zone"],
  2347. 'automatique': ["automatique.gif","Pouvoir automatique"],
  2348. 'au toucher': ["toucher.gif","Pouvoir au toucher"]});
  2349. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2350. var thisImg = tabImg[iImg];
  2351. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2352. }
  2353. }
  2354.  
  2355. function MZ_tab_carac_add_tr_autres(table, donneesMonstre, id, nom) {
  2356. var tabImg = [];
  2357. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attd, {
  2358. '1': ["distance.gif","Attaque à distance"],
  2359. '~': ["cac.gif","Corps à corps"]}); // si absent
  2360. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.nb_att, {
  2361. '1': ["1.gif","1 attaque par tour"],
  2362. '2': ["2.gif","2 attaques par tour"],
  2363. '3': ["3.gif","3 attaques par tour"],
  2364. '4': ["4.gif","4 attaques par tour"],
  2365. '5': ["5.gif","5 attaques par tour"],
  2366. '6': ["6.gif","6 attaques par tour"],
  2367. '999': ["plus.gif","Beaucoup d'attaques par tour"]});
  2368. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attm, {
  2369. '1': ["magic-wand.png","Attaque magique"]});
  2370. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vit, {
  2371. 'lente': ["lent.gif","Lent à se déplacer"],
  2372. 'normale': ["normal.gif","Vitesse normale de déplacement"],
  2373. 'rapide': ["rapide.gif","Déplacement rapide"]});
  2374. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.charg, {
  2375. 'vide': [null,null],
  2376. '~': ["charge2.gif", "Possède de l'équipement (" + donneesMonstre.charg + ")"]});
  2377. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vlc, {
  2378. '1': ["oeil.gif","Voit le caché"]});
  2379. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.gen, {
  2380. '1': ["Phoenix1.png","Phœnix de première génération"],
  2381. '2': ["Phoenix2.png","Phœnix de deuxième génération"],
  2382. '3': ["Phoenix3.png","Phœnix de troisième génération"],
  2383. '23': ["Phoenix23.png","Phœnix de deuxième ou troisième génération"],
  2384. });
  2385.  
  2386. var tr = appendTr(table,'mh_tdpage');
  2387. var td = appendTdText(tr,'Autres',true);
  2388. td.className = 'mh_tdtitre';
  2389. td.width = MZ_EtatCdMs.tdWitdh;
  2390.  
  2391. td = appendTd(tr);
  2392. td.className = 'mh_tdpage';
  2393. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2394. var thisImg = tabImg[iImg];
  2395. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2396. }
  2397. if (donneesMonstre.esq != undefined) td.appendChild(createImageTactique(URL_MZimg+"calc.png", id, nom), null);
  2398.  
  2399. var txt = String.fromCharCode(160); // blanc insécable
  2400. if (donneesMonstre.nCdM) txt = donneesMonstre.nCdM;
  2401. var td2 = appendTdText(tr, txt);
  2402. td2.title = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2403. td2.style.width = '1%';
  2404. var myColor = MZ_CdMColorFromMode(donneesMonstre);
  2405. if (myColor) {
  2406. td2.style.backgroundColor = myColor;
  2407. td2.style.color = 'white';
  2408. }
  2409.  
  2410. return td;
  2411. }
  2412.  
  2413. function MZ_tab_carac_add_tr_one_img(tabImg, val, listCas) {
  2414. if (val == undefined) return;
  2415. //console.log('MZ_tab_carac_add_tr_one_img: val=' + val);
  2416. var lVal = (val + '').toLowerCase(); // astuce : transformer le nombre en string (beurk !)
  2417. if (listCas[lVal]) {
  2418. var t = listCas[lVal];
  2419. if (t[0] == null) return;
  2420. tabImg.push(t);
  2421. } else if (listCas['~']) {
  2422. tabImg.push(listCas['~']);
  2423. }
  2424. }
  2425.  
  2426. function MZ_tab_carac_add_tr_texte(table, titre, msg, unit) {
  2427. if (!msg) return;
  2428. var tr = appendTr(table,'mh_tdpage');
  2429.  
  2430. var td = appendTdText(tr,titre,true);
  2431. td.className = 'mh_tdtitre';
  2432. td.width = MZ_EtatCdMs.tdWitdh;
  2433.  
  2434. var texte = msg;
  2435. if (unit) texte += ' ' + unit;
  2436. td = appendTdText(tr,texte);
  2437. td.colSpan = 2;
  2438. td.className = 'mh_tdpage';
  2439. return td;
  2440. }
  2441.  
  2442. function MZ_tab_carac_add_tr_minmax(table, titre, ominmax, unit) {
  2443. if (!ominmax) return;
  2444. if (!(ominmax.min || ominmax.max)) return;
  2445.  
  2446. var tr = appendTr(table,'mh_tdpage');
  2447.  
  2448. var td = appendTdText(tr,titre,true);
  2449. td.className = 'mh_tdtitre';
  2450. td.width = MZ_EtatCdMs.tdWitdh;
  2451.  
  2452. if ((!ominmax.min) || ominmax.min == 0) {
  2453. var texte = '\u2A7D' + ominmax.max + '\u00A0' + unit; // <= (mais plus beau)
  2454. } else if (!ominmax.max) {
  2455. var texte = '\u2A7E' + ominmax.min + '\u00A0' + unit; // >=
  2456. } else {
  2457. var texte = '';
  2458. if (ominmax.min != ominmax.max) {
  2459. var texte = ominmax.min + '-' + ominmax.max + '\u00A0-->\u00A0';
  2460. if (ominmax.min > ominmax.min) {
  2461. td.style.color = 'red';
  2462. unit += ' *** erreur ***';
  2463. }
  2464. }
  2465. texte += ((ominmax.min + ominmax.max)/2) + '\u00A0' + unit;
  2466. }
  2467. td = appendTdText(tr,texte);
  2468. if (ominmax.min2 || ominmax.max2) { // affichage de l'intervalle de confiance à 80%
  2469. if (!ominmax.min2) {
  2470. var txt2 = '\u2A7D' + ominmax.max2; // <= (mais plus beau)
  2471. } else if (!ominmax.max2) {
  2472. var txt2 = '\u2A7E' + ominmax.min2; // >=
  2473. } else {
  2474. var txt2 = ominmax.min2 + '-' + ominmax.max2;
  2475. }
  2476. var span = document.createElement('span');
  2477. span.appendChild(document.createTextNode(txt2));
  2478. span.style.float = 'right';
  2479. span.style.textAlign = 'right';
  2480. span.style.background = 'yellow';
  2481. td.insertBefore(span, td.firstChild);
  2482. table.title = "En jaune : intervalle de confiance à 80%";
  2483. }
  2484. td.colSpan = 2;
  2485. td.className = 'mh_tdpage';
  2486. return td;
  2487. }
  2488.  
  2489. function MZ_tab_carac_add_tr_minmax2(table, titre, ominmax, unit, ominmaxUnit) {
  2490. if (!ominmax) return;
  2491. if (!(ominmax.min || ominmax.max)) return;
  2492.  
  2493. var tr = appendTr(table,'mh_tdpage');
  2494.  
  2495. var td = appendTdText(tr,titre,true);
  2496. td.className = 'mh_tdtitre';
  2497. td.width = MZ_EtatCdMs.tdWitdh;
  2498.  
  2499. if ((!ominmax.min) || ominmax.min == 0) {
  2500. var texte = '\u2A7D' + ominmax.max;
  2501. } else if (!ominmax.max) {
  2502. var texte = '\u2A7E' + ominmax.min;
  2503. } else {
  2504. var texte = '';
  2505. if (ominmax.min != ominmax.max) {
  2506. var texte = ominmax.min + '-' + ominmax.max;
  2507. if (ominmax.min > ominmax.max) {
  2508. td.style.color = 'red';
  2509. texte += ' *** erreur ***';
  2510. }
  2511. } else {
  2512. var texte = ominmax.min;
  2513. }
  2514. }
  2515.  
  2516. if (ominmaxUnit.min === undefined) {
  2517. if (ominmaxUnit.max === undefined) {
  2518. // ignore (ne devrait pas arriver)
  2519. } else {
  2520. texte += ' --> ' + unit + '\u2A7D' + ominmaxUnit.max;
  2521. }
  2522. } else {
  2523. if (ominmaxUnit.max === undefined) {
  2524. texte += ' --> ' + unit + '\u2A7E' + ominmaxUnit.min;
  2525. } else if (ominmaxUnit.min != ominmaxUnit.max) {
  2526. texte += ' --> ' + ominmaxUnit.min + '\u2A7D' + unit + '\u2A7D' + ominmaxUnit.max;
  2527. if (ominmaxUnit.min > ominmaxUnit.max) {
  2528. td.style.color = 'red';
  2529. texte += ' *** erreur ***';
  2530. }
  2531. } else if (isNaN(ominmaxUnit.min)) {
  2532. texte += ' --> ' + ominmaxUnit.min;
  2533. } else {
  2534. texte += ' --> ' + ominmaxUnit.max + '\u00A0' + unit;
  2535. }
  2536. }
  2537.  
  2538. td = appendTdText(tr,texte);
  2539. td.colSpan = 2;
  2540. td.className = 'mh_tdpage';
  2541. return td;
  2542. }
  2543.  
  2544.  
  2545. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2546.  
  2547. var listeMonstreEnchantement = null,
  2548. listeEquipementEnchantement = null,
  2549. listeInfoEnchantement = null;
  2550.  
  2551. function computeCompoEnchantement()
  2552. {
  2553. listeMonstreEnchantement = new Array();
  2554. listeInfoEnchantement = new Array();
  2555. listeEquipementEnchantement = new Array();
  2556. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2557. for(var i=0;i<liste.length;i++)
  2558. {
  2559. var idEquipement = liste[i]*1;
  2560. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2561. continue;
  2562. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2563. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2564. var texteGlobal='';
  2565. for(var j=0;j<3;j++)
  2566. {
  2567. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2568. var v = MY_getValue(k);
  2569. var infoComposant = MY_getValue().split(';');
  2570. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2571. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2572. continue;
  2573. }
  2574. listeMonstreEnchantement[infoComposant[2]] = 1;
  2575. var array = new Array();
  2576. array[0]=infoComposant[0].replace("Ril","Œil");
  2577. array[1]=infoComposant[1];
  2578. array[2]=infoComposant[2];
  2579. array[3]=getQualite(infoComposant[3]);
  2580. var texte = infoComposant[4].replace("Ril","Œil");
  2581. for(var k=5;k<infoComposant.length;k++)
  2582. {
  2583. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2584. }
  2585. texteGlobal+=texte+'\n';
  2586. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2587. array[4]=texte;
  2588. listeInfoEnchantement.push(array);
  2589. }
  2590. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2591. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2592. }
  2593.  
  2594. }
  2595.  
  2596. function isEnchant(nom) {
  2597. var monstreEnchant = '';
  2598. for(j in listeInfoEnchantement) {
  2599. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2600. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2601. monstreEnchant=monstre;
  2602. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2603. }
  2604. }
  2605. return trim(monstreEnchant);
  2606. }
  2607.  
  2608. function getInfoEnchantementFromMonstre(nom)
  2609. {
  2610. try
  2611. {
  2612. if(!listeMonstreEnchantement)
  2613. {
  2614. computeCompoEnchantement();
  2615. }
  2616. var infosEnchant = '';
  2617. for(j in listeInfoEnchantement) {
  2618. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2619. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2620. if(infosEnchant=='')
  2621. infosEnchant=listeInfoEnchantement[j][4];
  2622. else
  2623. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2624. }
  2625. }
  2626. return trim(infosEnchant);
  2627. }
  2628. catch(e)
  2629. {
  2630. window.alert(e);
  2631. }
  2632. }
  2633.  
  2634. function composantEnchant(Monstre,composant,localisation,qualite) {
  2635. var compo='';
  2636. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2637. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2638. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2639. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2640. listeInfoEnchantement[i][3]<=qualite
  2641. ) {
  2642. return listeInfoEnchantement[i][4];
  2643. }
  2644. }
  2645. return compo;
  2646. }
  2647.  
  2648. function insertEnchantInfos(tbody) {
  2649. try
  2650. {
  2651. if(!listeMonstreEnchantement)
  2652. computeCompoEnchantement();
  2653. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2654. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2655. if(nodes.snapshotLength == 0)
  2656. return false;
  2657. var urlImg = URL_MZimg + 'enchant.png';
  2658. for(var i = 0; i < nodes.snapshotLength; i++) {
  2659. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2660. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2661. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2662. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2663. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2664. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2665. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2666. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2667. if(isEnchant(nomMonstre).length>0)
  2668. {
  2669. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2670. if(infos.length>0)
  2671. {
  2672. if(link.parentNode == link.nextSibling.parentNode)
  2673. {
  2674. var tmp = link.nextSibling;
  2675. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2676. }
  2677. else
  2678. {
  2679. link.parentNode.appendChild(createImage(urlImg,infos));
  2680. }
  2681. }
  2682. }
  2683. }
  2684. }
  2685. catch(e)
  2686. {
  2687. window.alert(e);
  2688. }
  2689. }
  2690.  
  2691. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2692. {
  2693. try
  2694. {
  2695. if(!listeMonstreEnchantement)
  2696. computeCompoEnchantement();
  2697. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2698. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2699. if(nodes.snapshotLength == 0)
  2700. return false;
  2701. var urlImg = URL_MZimg + 'enchant.png';
  2702. for(var i = 0; i < nodes.snapshotLength; i++)
  2703. {
  2704. var link = nodes.snapshotItem(i);
  2705. var idEquipement = link.getAttribute('href');
  2706. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2707. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2708. var nomEquipement = trim(link.firstChild.nodeValue);
  2709. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2710. if(!enchanteur || enchanteur == '')
  2711. continue;
  2712. var infos = listeEquipementEnchantement[idEquipement];
  2713. infos=formateTexte(infos);
  2714. if(infos.length>0)
  2715. {
  2716. if(link.parentNode == link.nextSibling.parentNode)
  2717. {
  2718. var tmp = link.nextSibling;
  2719. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2720. }
  2721. else
  2722. {
  2723. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2724. }
  2725. }
  2726. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2727. }
  2728. }
  2729. catch(e)
  2730. {
  2731. window.alert(e);
  2732. }
  2733. }
  2734.  
  2735. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2736.  
  2737.  
  2738. // Les % de toucher
  2739. var c = new Array();
  2740.  
  2741. // coefficients binomiaux
  2742. function cnp(n,k)
  2743. {
  2744. if(c[n] != null && c[n][k] != null)
  2745. return c[n][k];
  2746. if(c[n] == null)
  2747. c[n] = new Array();
  2748. if(k==0)
  2749. {
  2750. c[n][k] = 1;
  2751. return 1;
  2752. }
  2753. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2754. c[n][k] = result;
  2755. // Roule debug
  2756. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2757. return result;
  2758. }
  2759.  
  2760. // by Dab, à comparer
  2761. function binom(n,p) {
  2762. if(p<0 || p>n) return 0;
  2763.  
  2764. if(c[n])
  2765. if(c[n][p]) return c[n][p];
  2766. else {
  2767. c[n]=[1];
  2768. c[n][n]=1;
  2769. if(p==0 || p==n) return 1;
  2770. }
  2771.  
  2772. if(2*p>n)
  2773. c[n][p]=binom(n,n-p);
  2774. else
  2775. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2776.  
  2777. return c[n][p];
  2778. }
  2779.  
  2780. var coeff = new Array();
  2781.  
  2782. function coef(n,p)
  2783. {
  2784. if(n==0 && p==0)
  2785. return 1;
  2786. if(p>n*3.5)
  2787. p = 7*n-p
  2788. // roule désactive cache
  2789. if(coeff[n] != null && coeff[n][p] !=null)
  2790. return coeff[n][p];
  2791. if(coeff[n] == null)
  2792. coeff[n] = new Array();
  2793. var kmax = Math.floor((p-n)/6);
  2794. var x=0;
  2795. for(var k=0;k<=kmax;k++)
  2796. {
  2797. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2798. }
  2799. coeff[n][p] = x;
  2800. // Roule debug
  2801. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2802. return x;
  2803. }
  2804.  
  2805. function chanceEsquiveParfaite(a,d,ba,bd)
  2806. {
  2807. var win = 0;
  2808. var los = 0;
  2809. if(ba==null)
  2810. ba=0;
  2811. if(bd==null)
  2812. bd=0;
  2813. /* if(6*a+ba<2*(d+bd))
  2814. return 100;
  2815. if(a+ba>2*(6*d+bd))
  2816. return 0;*/
  2817. for(var ds=d;ds<=6*d;ds++)
  2818. {
  2819. var cd = coef(d,ds);
  2820. for(var as=a;as<=6*a;as++)
  2821. {
  2822. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2823. win += cd * coef(a,as);
  2824. else
  2825. los += cd * coef(a,as);
  2826. }
  2827. }
  2828. // roule debug
  2829. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2830. return Math.round(100*win/(win+los));
  2831. }
  2832.  
  2833. function chanceTouche(a,d,ba,bd)
  2834. {
  2835. var win = 0;
  2836. var los = 0;
  2837. if(ba==null)
  2838. ba=0;
  2839. if(bd==null)
  2840. bd=0;
  2841. if(a+ba>6*d+bd)
  2842. return 100;
  2843. if(6*a+ba<d+bd)
  2844. return 0;
  2845. for(var ds=d;ds<=6*d;ds++)
  2846. {
  2847. var cd = coef(d,ds);
  2848. for(var as=a;as<=6*a;as++)
  2849. {
  2850. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2851. win += cd * coef(a,as);
  2852. else
  2853. los += cd * coef(a,as);
  2854. }
  2855. }
  2856. return Math.round(100*win/(win+los));
  2857. }
  2858.  
  2859. function chanceCritique(a,d,ba,bd)
  2860. {
  2861. var win = 0;
  2862. var los = 0;
  2863. if(ba==null)
  2864. ba=0;
  2865. if(bd==null)
  2866. bd=0;
  2867. if(a+ba>2*(6*d+bd))
  2868. return 100;
  2869. if(6*a+ba<2*(d+bd))
  2870. return 0;
  2871. for(var ds=d;ds<=6*d;ds++)
  2872. {
  2873. var cd = coef(d,ds);
  2874. for(var as=a;as<=6*a;as++)
  2875. {
  2876. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2877. win += cd * coef(a,as);
  2878. else
  2879. los += cd * coef(a,as);
  2880. }
  2881. }
  2882. return Math.round(100*win/(win+los));
  2883. }
  2884.  
  2885. /***********************************************
  2886. Analyse tactique
  2887. ***********************************************/
  2888.  
  2889. function getTexteAnalyse(modificateur,chiffre)
  2890. {
  2891. if(chiffre==0)
  2892. return chiffre;
  2893. return modificateur+ chiffre;
  2894. }
  2895.  
  2896. // rend le HTML pour le tableau de la "calculette"
  2897. function getAnalyseTactique(id,nom) {
  2898. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  2899. var needAutres=false;
  2900. var i;
  2901. if(donneesMonstre == null)
  2902. return;
  2903. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2904. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2905. if(array==null)
  2906. return "";
  2907. 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>";
  2908. for(i=0;i<array.length;i++)
  2909. {
  2910. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2911. {
  2912. needAutres=true;
  2913. break;
  2914. }
  2915. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2916. 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>";
  2917. else if(i==0) // attaque du monstre sur le Trõll => italique
  2918. 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>";
  2919. else // autre, pas de décoration
  2920. 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>";
  2921. }
  2922. if(needAutres)
  2923. {
  2924. if(i==array.length-1)
  2925. 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>";
  2926. else if(i==1)
  2927. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2928. else
  2929. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2930. }
  2931. var txtCdM = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2932. if (txtCdM) str += '<tr class="mh_tdpage"><td colspan="5" style="font-style: italic;">' + txtCdM + '</td></tr>';
  2933. return str+"</table>";
  2934. }
  2935.  
  2936. function MZ_carac_build_nb_cmd_msg(donneesMonstre) {
  2937. if (!donneesMonstre) return;
  2938. if (!donneesMonstre.Mode) return;
  2939. switch (donneesMonstre.Mode) {
  2940. case 'cdm':
  2941. return 'fondé sur ' + (+donneesMonstre.nCdM) + ' CdM' + (donneesMonstre.nCdM > 1 ? 's' : '') + ' de ce monstre à cet âge';
  2942. case 'stat':
  2943. 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)';
  2944. case 'statV1':
  2945. return 'fondé sur les statistiques anciennes (MZ V1)';
  2946. case 'nom':
  2947. return 'fondé sur le nom du monstre, pas de CdM';
  2948. }
  2949. return 'Mode ' + donneesMonstre.Mode;
  2950. }
  2951.  
  2952. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2953. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2954. function analyseTactique(donneesMonstre,nom) {
  2955. try
  2956. {
  2957. var listeAttaques = [];
  2958. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2959. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2960. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2961. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2962. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2963. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2964. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2965. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2966. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2967. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2968. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2969. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2970. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2971. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2972. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2973. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2974. var modificateurEsquive = '';
  2975. var modificateurArmure = '';
  2976. var modificateurMagie = '';
  2977. var modificateurEsquiveM = '';
  2978. var modificateurArmureM = '';
  2979. var pasDeSR=false;
  2980. var esqM=0,attM=0,armM_mag=0,armM_tot=0,degM=0;
  2981. 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)
  2982. return null;
  2983.  
  2984. if (MY_DEBUG) window.console.log('analyseTactique nom=' + nom + ' ' + JSON.stringify(donneesMonstre));
  2985. if (donneesMonstre.index == undefined) {
  2986. // à supprimer
  2987. var td = document.createElement('td')
  2988. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2989. var esqM = 0;
  2990. try
  2991. {
  2992. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2993. }
  2994. catch(e)
  2995. {
  2996. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  2997. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2998. modificateurEsquive = '<';
  2999. modificateurArmure = '<';
  3000. modificateurMagie = '<';
  3001. }
  3002.  
  3003. td.innerHTML = bbcode(donneesMonstre[3]);
  3004. var attM = 0;
  3005. try
  3006. {
  3007. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3008. }
  3009. catch(e)
  3010. {
  3011. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  3012. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3013. modificateurEsquiveM = '>';
  3014. modificateurArmureM = '>';
  3015. }
  3016.  
  3017. td.innerHTML = bbcode(donneesMonstre[5]);
  3018. var degM = 0;
  3019. try
  3020. {
  3021. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3022. }
  3023. catch(e)
  3024. {
  3025. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  3026. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3027. modificateurArmureM = '>';
  3028. }
  3029.  
  3030. td.innerHTML = bbcode(donneesMonstre[7]);
  3031. try
  3032. {
  3033. armM_tot=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3034. armM_mag=armM_tot; // compatibilité avec ancien calcul
  3035. }
  3036. catch(e)
  3037. {
  3038. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  3039. armM_tot=Math.ceil(parseInt(td.firstChild.nodeValue));
  3040. armM_mag=armM_tot;
  3041. modificateurArmure = '<';
  3042. }
  3043.  
  3044. var coeffSeuil = 0.95;
  3045. try
  3046. {
  3047. td.innerHTML = bbcode(donneesMonstre[9]);
  3048. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  3049. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3050. var v = (rm / mm);
  3051. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3052. coeffSeuil = (200-seuil)/200;
  3053. }
  3054. catch(e)
  3055. {
  3056. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  3057. modificateurMagie = '<';
  3058. pasDeSR = true;
  3059. }
  3060. } else {
  3061. //calcul de modificateurEsquive, modificateurArmure, modificateurMagie, modificateurEsquiveM, modificateurArmureM, pasDeSR, esqM, attM, armM_mag, armM_tot, degM;
  3062. if (donneesMonstre.esq) {
  3063. if (donneesMonstre.esq.min && donneesMonstre.esq.max) {
  3064. esqM = Math.ceil((donneesMonstre.esq.min + donneesMonstre.esq.max) / 2);
  3065. } else if (donneesMonstre.esq.max) {
  3066. esqM = donneesMonstre.esq.max;
  3067. modificateurEsquive = '<';
  3068. modificateurArmure = '<';
  3069. modificateurMagie = '<';
  3070. }
  3071. }
  3072.  
  3073. if (donneesMonstre.att) {
  3074. if (donneesMonstre.att.min && donneesMonstre.att.max) {
  3075. attM = Math.ceil((donneesMonstre.att.min + donneesMonstre.att.max) / 2);
  3076. } else if (donneesMonstre.att.max) {
  3077. attM = donneesMonstre.att.max;
  3078. modificateurEsquiveM = '>';
  3079. modificateurArmureM = '>';
  3080. }
  3081. }
  3082.  
  3083. if (donneesMonstre.armM) {
  3084. if (donneesMonstre.armM.min && donneesMonstre.armM.max) {
  3085. armM_mag = Math.ceil((donneesMonstre.armM.min + donneesMonstre.armM.max) / 2);
  3086. } else if (donneesMonstre.armM.max) {
  3087. armM_mag = donneesMonstre.armM.max;
  3088. modificateurArmure = '<';
  3089. }
  3090. if (donneesMonstre.armP) {
  3091. if (donneesMonstre.armP.min && donneesMonstre.armP.max) {
  3092. armM_phy = Math.ceil((donneesMonstre.armP.min + donneesMonstre.armP.max) / 2);
  3093. } else if (donneesMonstre.armP.max) {
  3094. armM_phy = donneesMonstre.armP.max;
  3095. modificateurArmure = '<';
  3096. }
  3097. armM_tot = armM_mag + armM_phy;
  3098. } else { // ça ne devrait pas arriver
  3099. armM_tot = armM_mag;
  3100. }
  3101. } else if (donneesMonstre.arm) {
  3102. if (donneesMonstre.arm.min && donneesMonstre.arm.max) {
  3103. armM_tot = Math.ceil((donneesMonstre.arm.min + donneesMonstre.arm.max) / 2);
  3104. armM_mag=armM_tot; // worst case
  3105. } else if (donneesMonstre.arm.max) {
  3106. armM_tot = donneesMonstre.arm.max;
  3107. armM_mag=armM_tot;
  3108. modificateurArmure = '<';
  3109. }
  3110. }
  3111.  
  3112. if (donneesMonstre.deg) {
  3113. if (donneesMonstre.deg.min && donneesMonstre.deg.max) {
  3114. degM = Math.ceil((donneesMonstre.deg.min + donneesMonstre.deg.max) / 2);
  3115. } else if (donneesMonstre.deg.max) {
  3116. degM = donneesMonstre.deg.max;
  3117. modificateurArmureM = '>';
  3118. }
  3119. }
  3120.  
  3121. var coeffSeuil = 0.95;
  3122. if (donneesMonstre.RM) {
  3123. if (donneesMonstre.RM.min && donneesMonstre.RM.max) {
  3124. var rmM = Math.ceil((donneesMonstre.RM.min + donneesMonstre.RM.max) / 2);
  3125. var v = (rmM / mm);
  3126. var seuil = (rmM < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3127. coeffSeuil = (200-seuil)/200;
  3128. } else if (donneesMonstre.deg.max) {
  3129. }
  3130. modificateurMagie = '<';
  3131. pasDeSR = true;
  3132. }
  3133. }
  3134. 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);
  3135.  
  3136. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  3137. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  3138. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  3139. // roule debug
  3140. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  3141. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  3142. 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);
  3143. //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);
  3144. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3145. if(getSortComp("Vampirisme")>0)
  3146. {
  3147. var pour = getSortComp("Vampirisme");
  3148. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3149. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3150. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3151. 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;
  3152. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3153. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3154. }
  3155. if(getSortComp("Siphon des âmes")>0)
  3156. {
  3157. var pour = getSortComp("Siphon des âmes");
  3158. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3159. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3160. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3161. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm-armM_mag,1))/100);
  3162. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3163. }
  3164. if(getSortComp("Botte Secrète")>0)
  3165. {
  3166. var pour = getSortComp("Botte Secrète");
  3167. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3168. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3169. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3170. 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;
  3171. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3172. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3173. }
  3174. if(getSortComp("Rafale Psychique")>0)
  3175. {
  3176. var pour = getSortComp("Rafale Psychique");
  3177. chanceDEsquiveParfaite = 0;
  3178. chanceDeTouche = Math.round(100*pour/100);
  3179. chanceDeCritique = Math.round(0*pour/100);
  3180. 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;
  3181. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3182. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3183. }
  3184. if(getSortComp("Explosion")>0)
  3185. {
  3186. var pour = getSortComp("Explosion");
  3187. chanceDEsquiveParfaite = 0;
  3188. chanceDeTouche = Math.round(100*pour/100);
  3189. chanceDeCritique = Math.round(0*pour/100);
  3190. 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;
  3191. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3192. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3193. }
  3194. if(getSortComp("Projectile Magique")>0)
  3195. {
  3196. var pour = getSortComp("Projectile Magique");
  3197. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  3198. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  3199. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  3200. // distance troll - monstre
  3201. 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;
  3202. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3203. if (donneesMonstre.index !== undefined && MZ_EtatCdMs.tr_monstres !== undefined && MZ_EtatCdMs.tr_monstres[donneesMonstre.index] !== undefined) {
  3204. var dist = getMonstreDistance(donneesMonstre.index);
  3205. //if (isDEV) window.console.log('Dist pour PM=' + dist);
  3206. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  3207. var portee = getPortee__Profil(vue+vue_bm);
  3208. if (dist <= portee) {
  3209. degats = Math.round((degats + 2 * (portee-dist)) * 100) / 100;
  3210. } else {
  3211. degats += ' (plus bonus de portée)';
  3212. }
  3213. debugMZ('analyseTactique, iTR= ' + donneesMonstre.index + ', dist=' + dist + ', porteePM=' + portee);
  3214. } else {
  3215. degats += ' (plus bonus de portée)';
  3216. }
  3217. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3218. }
  3219. if(getSortComp("Frénésie")>0)
  3220. {
  3221. var pour = getSortComp("Frénésie");
  3222. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3223. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3224. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3225. 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;
  3226. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3227. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3228. }
  3229. if(getSortComp("Charger")>0)
  3230. {
  3231. var pour = getSortComp("Charger");
  3232. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3233. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3234. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3235. 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;
  3236. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3237. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3238. }
  3239. if(getSortComp("Griffe du Sorcier")>0)
  3240. {
  3241. var pour = getSortComp("Griffe du Sorcier");
  3242. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3243. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3244. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3245. 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;
  3246. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3247. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3248. }
  3249. if(getSortComp("Attaque Précise",1)>0)
  3250. {
  3251. var niveau = 5;
  3252. var oldPour = 0;
  3253. var chanceDEsquiveParfaite = 0;
  3254. var chanceDeTouche = 0;
  3255. var chanceDeCritique = 0;
  3256. degats = 0;
  3257. while(niveau>0)
  3258. {
  3259. var pour = getSortComp("Attaque Précise",niveau);
  3260. if(pour>oldPour)
  3261. {
  3262. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3263. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3264. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3265. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3266. chanceDeTouche += chanceDeToucheNiveau;
  3267. chanceDeCritique += chanceDeCritiqueNiveau;
  3268. 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);
  3269. oldPour = pour;
  3270. }
  3271. niveau--;
  3272. }
  3273. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3274. 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));
  3275. }
  3276. if(getSortComp("Coup de Butoir",1)>0)
  3277. {
  3278. var niveau = 5;
  3279. var oldPour =0;
  3280. var chanceDEsquiveParfaite = 0;
  3281. var chanceDeTouche=0;
  3282. var chanceDeCritique=0;
  3283. degats=0;
  3284. while(niveau>0)
  3285. {
  3286. var pour = getSortComp("Coup de Butoir",niveau);
  3287. if(pour>oldPour)
  3288. {
  3289. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3290. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3291. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3292. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3293. chanceDeTouche += chanceDeToucheNiveau;
  3294. chanceDeCritique += chanceDeCritiqueNiveau;
  3295. 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);
  3296. oldPour = pour;
  3297. }
  3298. niveau--;
  3299. }
  3300. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3301. 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));
  3302. }
  3303. 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;});
  3304. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  3305. {
  3306. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  3307. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  3308. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  3309. }
  3310. else
  3311. {
  3312. chanceDEsquiveParfaite = 0;
  3313. chanceDeTouche = 100;
  3314. chanceDeCritique = 0;
  3315. }
  3316. 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;
  3317.  
  3318. 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));
  3319. return listeAttaques;
  3320. }
  3321. catch(e) {
  3322. window.console.error(traceStack(e, 'analyseTactique'));
  3323. window.alert(e);
  3324. }
  3325. }
  3326.  
  3327. // x~~x marque pour s'y retrouver sous l'éditeur
  3328.  
  3329. /*
  3330. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  3331. * published under GNU License v2.
  3332. *
  3333. * Patch :
  3334. * gestion des missions terminées
  3335. */
  3336.  
  3337. // x~x mission_liste
  3338.  
  3339. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  3340. try {
  3341. var titresMimis = document.evaluate(
  3342. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  3343. document, null, 7, null
  3344. );
  3345. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3346. } catch(e) {
  3347. window.console.error(traceStack(e, 'mission_liste initialisation'));
  3348. return;
  3349. }
  3350.  
  3351. var enCours = {};
  3352. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  3353. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  3354. enCours[num] = true;
  3355. }
  3356.  
  3357. for(var numMimi in obMissions) {
  3358. if(!enCours[numMimi]) {
  3359. delete obMissions[numMimi];
  3360. }
  3361. }
  3362. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3363. }
  3364.  
  3365. function do_mission_liste() {
  3366. checkLesMimis();
  3367. }
  3368.  
  3369. /*******************************************************************************
  3370. * This file is part of Mountyzilla. *
  3371. * *
  3372. * Mountyzilla is free software; you can redistribute it and/or modify *
  3373. * it under the terms of the GNU General Public License as published by *
  3374. * the Free Software Foundation; either version 2 of the License, or *
  3375. * (at your option) any later version. *
  3376. * *
  3377. * Mountyzilla is distributed in the hope that it will be useful, *
  3378. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3379. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3380. * GNU General Public License for more details. *
  3381. * *
  3382. * You should have received a copy of the GNU General Public License *
  3383. * along with Mountyzilla; if not, write to the Free Software *
  3384. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3385. *******************************************************************************/
  3386.  
  3387. // x~x actions
  3388.  
  3389. /* TODO
  3390. * getLvl pour Explo, Rotobaffe et cie
  3391. */
  3392.  
  3393.  
  3394.  
  3395. /* Page de combat */
  3396.  
  3397. function getLevel() {
  3398. var divList = document.getElementsByTagName('div');
  3399. if(divList.length <= 2)
  3400. return;
  3401.  
  3402. // On essaie de voir si cette action était une attaque
  3403. var pList = document.getElementsByTagName('p');
  3404. var nomM = '';
  3405. // Modification pour Frénésie by TetDure
  3406. var numAtt = 0;
  3407. for (var i = 0; i < pList.length; i++) {
  3408. if(pList[i].firstChild) {
  3409. nomM = pList[i].firstChild.nodeValue;
  3410. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3411. numAtt++;
  3412. }
  3413. }
  3414.  
  3415. if(nomM == '')
  3416. return;
  3417.  
  3418. // Si c'est une attaque normale, un seul PX
  3419. var comPX = 1;
  3420. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3421. comPX++;
  3422.  
  3423. // Extraction des infos du monstre attaqué
  3424. var idM;
  3425. var male;
  3426. if(nomM.slice(20, 21) == 'e') {
  3427. male = false;
  3428. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3429. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3430. }
  3431. else {
  3432. male = true;
  3433. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3434. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3435. }
  3436.  
  3437. if(idM == '')
  3438. return;
  3439.  
  3440. var bList = document.getElementsByTagName('b');
  3441. var niveau = '';
  3442. for (var i = 0; i < bList.length; i++) {
  3443. var b = bList[i];
  3444. if(b.childNodes[0].nodeValue != "TUÉ")
  3445. continue;
  3446. var nbPX = "";
  3447. for (i++; i < bList.length; i++) {
  3448. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3449. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3450. return;
  3451. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3452. nbPX = bList[i].childNodes[0].nodeValue;
  3453. break;
  3454. }
  3455. }
  3456. if(nbPX == '')
  3457. return;
  3458. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3459. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3460. if(!nbPX)
  3461. nbPX = 0;
  3462. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3463. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3464. if(comPX > nbPX) {
  3465. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3466. niveau = "";
  3467. } else if(Math.floor(niveau) == niveau) {
  3468. chaine += niveau + ".";
  3469. } else {
  3470. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3471. niveau = "";
  3472. }
  3473. insertBr(b.nextSibling.nextSibling.nextSibling);
  3474. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3475. }
  3476.  
  3477. if(niveau != '') {
  3478. var button = insertButtonCdm('as_Action');
  3479. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3480. + escape(nomM) + "&niveau=" + escape(niveau)
  3481. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3482. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3483. }
  3484. }
  3485.  
  3486.  
  3487. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3488.  
  3489. function insertInfoMagie(node, intitule, magie) {
  3490. if(node.nextSibling) {
  3491. node = node.nextSibling;
  3492. insertBr(node);
  3493. insertText(node, intitule);
  3494. insertText(node, magie, true);
  3495. } else {
  3496. node = node.parentNode;
  3497. appendBr(node);
  3498. appendText(node, intitule);
  3499. appendText(node, magie, true);
  3500. }
  3501. }
  3502.  
  3503. function getMM(sr) {
  3504. if(rmTroll<=0) {
  3505. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3506. }
  3507. sr = Number(sr.match(/\d+/)[0]);
  3508. if(sr==10) {
  3509. return '\u2265 '+5*rmTroll;
  3510. }
  3511. if(sr<=50) {
  3512. return Math.round(50*rmTroll/sr);
  3513. }
  3514. if(sr<90) {
  3515. return Math.round((100-sr)*rmTroll/50);
  3516. }
  3517. return '\u2264 '+Math.round(rmTroll/5);
  3518. }
  3519.  
  3520. function traiteMM() {
  3521. var node = document.evaluate(
  3522. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3523. document, null, 9, null).singleNodeValue;
  3524.  
  3525. if(node) {
  3526. var mm = getMM(node.nodeValue);
  3527. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3528. } else {
  3529. var node = document.evaluate(
  3530. "//p/text()[contains(., 'Seuil de Résistance')]",
  3531. document, null, 9, null).singleNodeValue;
  3532. if(!node) {
  3533. return;
  3534. }
  3535. var mm = getMM(node.nodeValue);
  3536. node = node.nextSibling.nextSibling;
  3537. }
  3538. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3539. }
  3540.  
  3541. function getRM(sr) {
  3542. if(mmTroll<=0) {
  3543. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3544. }
  3545. sr = Number(sr.match(/\d+/)[0]);
  3546. if(sr==10) {
  3547. return '\u2264 '+Math.round(mmTroll/5);
  3548. }
  3549. if(sr<=50) {
  3550. return Math.round(sr*mmTroll/50);
  3551. }
  3552. if(sr<90) {
  3553. return Math.round(50*mmTroll/(100-sr));
  3554. }
  3555. return '\u2265 '+5*mmTroll;
  3556. }
  3557.  
  3558. function traiteRM() {
  3559. var nodes = document.evaluate(
  3560. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3561. document, null, 7, null);
  3562. if(nodes.snapshotLength==0) {
  3563. return;
  3564. }
  3565.  
  3566. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3567. var node = nodes.snapshotItem(i);
  3568. var rm = getRM(node.nodeValue);
  3569. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3570. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3571. }
  3572. }
  3573.  
  3574.  
  3575. /* Fonction stats IdT par Raistlin */
  3576.  
  3577. /*function getIdt() {
  3578. if(MY_getValue("SEND_IDT") == "non")
  3579. return false;
  3580.  
  3581. var regExpBeginning = /^\s+/;
  3582. var regExpEnd = /\s+$/;
  3583.  
  3584. var nomIdt = document.evaluate(
  3585. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3586. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3587. if(!nomIdt)
  3588. return false;
  3589.  
  3590. var caracIdt;
  3591. if(nomIdt.indexOf("Malédiction !") != -1) {
  3592. caracIdt = "";
  3593. nomIdt = "Mission maudite";
  3594. } else {
  3595. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3596. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3597. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3598. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3599. }
  3600. FF_XMLHttpRequest({
  3601. method: 'GET',
  3602. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3603. headers : {
  3604. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3605. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3606. }
  3607. });
  3608. return true;
  3609. }*/
  3610.  
  3611.  
  3612. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3613.  
  3614. function confirmeDecalage() {
  3615. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3616. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3617. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3618.  
  3619. var newDLA = new Date( oldDLA );
  3620. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3621. return window.confirm(
  3622. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3623. +'\nConfirmez-vous ce décalage ?'
  3624. );
  3625. }
  3626.  
  3627. function newsubmitDLA(evt) {
  3628. evt.stopPropagation();
  3629. evt.preventDefault();
  3630. if(confirmeDecalage()) {
  3631. this.submit();
  3632. }
  3633. }
  3634.  
  3635. function changeActionDecalage() {
  3636. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3637. return;
  3638. }
  3639. try {
  3640. // On récupère le contenu du script JS MH de calcul du décalage
  3641. var scriptTxt = document.evaluate(
  3642. ".//script[ not(@src) ]",
  3643. document, null, 9, null
  3644. ).singleNodeValue.textContent;
  3645. // On en extrait la DLA courante
  3646. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3647. scriptTxt = scriptTxt.split('\n')[0];
  3648. var nbs = scriptTxt.match(/\d+/g);
  3649. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3650. } catch(e) {
  3651. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3652. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3653. return;
  3654. }
  3655. var form = document.getElementsByName('ActionForm')[0];
  3656. if(form) {
  3657. form.addEventListener('submit', newsubmitDLA, true);
  3658. } else {
  3659. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3660. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3661. }
  3662. }
  3663.  
  3664. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3665.  
  3666. function prochainMundi() {
  3667. try {
  3668. var node;
  3669. node = document.evaluate(
  3670. "//div[@class='dateAction']/b",
  3671. document, null, 9, null
  3672. ).singleNodeValue;
  3673. if (document.evaluate) {
  3674. } else { // repli en JQuery
  3675. //node = $(
  3676. }
  3677. } catch(e) {
  3678. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3679. return;
  3680. }
  3681. if(!node) { return; }
  3682.  
  3683. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3684. var jour = longueurMois+1-getNumber(node.textContent);
  3685. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3686. var txt = '[Prochain Mundidey ';
  3687. if(jour>1) {
  3688. txt += 'dans '+jour+' jours]';
  3689. } else {
  3690. txt += 'demain]';
  3691. }
  3692. insertText(node.parentNode.nextSibling,txt,true);
  3693. }
  3694.  
  3695.  
  3696. /* Fonction principale */
  3697.  
  3698. function dispatch() {
  3699. if(isPage('MH_Play/Play_action')) {
  3700. prochainMundi();
  3701. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3702. var oldDLA;
  3703. changeActionDecalage();
  3704. } else if(isPage('MH_Play/Actions')) {
  3705. if(document.evaluate(
  3706. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3707. document, null, 2, null
  3708. ).stringValue) {
  3709. traiteMM();
  3710. } else if(document.evaluate(
  3711. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3712. document, null, 2, null
  3713. ).stringValue) {
  3714. //getIdt();
  3715. traiteRM();
  3716. } /*else {
  3717. // Est censé se lancer sur quoi *précisément* ?
  3718. traiteRM();
  3719. getLevel();
  3720. }*/
  3721. } else {
  3722. /* Traitement des messages du bot */
  3723. var messageTitle = document.evaluate(
  3724. "//form/table/tbody/tr[1]/td[1]/"
  3725. +"descendant::text()[contains(.,'[MountyHall]')]",
  3726. document, null, 2, null
  3727. ).stringValue;
  3728. if(messageTitle.indexOf('Attaquant') != -1 &&
  3729. messageTitle.indexOf('sur') != -1) {
  3730. getLevel();
  3731. traiteRM();
  3732. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3733. messageTitle.indexOf('Défenseur') != -1) {
  3734. traiteMM();
  3735. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3736. // à replacer avec Attaque après révision getLvl :
  3737. messageTitle.indexOf('Explosion') != -1 ||
  3738. messageTitle.indexOf('Insulte') != -1) {
  3739. traiteRM();
  3740. }
  3741. }
  3742. }
  3743.  
  3744. function do_actions() {
  3745. start_script(31);
  3746. dispatch();
  3747. displayScriptTime();
  3748. }
  3749.  
  3750. /*********************************************************************************
  3751. * This file is part of Mountyzilla. *
  3752. * *
  3753. * Mountyzilla is free software; you can redistribute it and/or modify *
  3754. * it under the terms of the GNU General Public License as published by *
  3755. * the Free Software Foundation; either version 2 of the License, or *
  3756. * (at your option) any later version. *
  3757. * *
  3758. * Mountyzilla is distributed in the hope that it will be useful, *
  3759. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3760. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3761. * GNU General Public License for more details. *
  3762. * *
  3763. * You should have received a copy of the GNU General Public License *
  3764. * along with Mountyzilla; if not, write to the Free Software *
  3765. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3766. *********************************************************************************/
  3767.  
  3768. // x~x pre-enchant
  3769.  
  3770. /* 2013-08-19 : correction auto syntaxe alert */
  3771.  
  3772. var combobox=null;
  3773.  
  3774. function changeObject()
  3775. {
  3776. if(!combobox)
  3777. return ;
  3778. var id = combobox.options[combobox.selectedIndex].value;
  3779. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3780. if(!id || id=="")
  3781. {
  3782. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3783. return;
  3784. }
  3785. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3786. }
  3787.  
  3788. function treatePreEnchantement() {
  3789. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3790. if(!input || input.getAttribute("type")=="hidden")
  3791. {
  3792. return false;
  3793. }
  3794. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3795. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3796. if(!combobox)
  3797. {
  3798. return true;
  3799. }
  3800. combobox.addEventListener('change', changeObject, true);
  3801. return true;
  3802. }
  3803.  
  3804. function treateEnchantement_pre() {
  3805. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3806. if(!input || input.getAttribute("type")!="hidden")
  3807. {
  3808. return false;
  3809. }
  3810. var idEquipement = input.getAttribute("value");
  3811. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3812. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3813. if(enchanteur && enchanteur != null)
  3814. return true;
  3815. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3816. if(!input || input.getAttribute("type")!="hidden")
  3817. {
  3818. return false;
  3819. }
  3820. var idEnchanteur = input.getAttribute("value");
  3821.  
  3822. var nodes = document.evaluate(
  3823. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3824. if (nodes.snapshotLength != 3)
  3825. return;
  3826. for(var i=0;i<3;i++)
  3827. {
  3828. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3829. texte = texte.replace(" d'une "," d'un ");
  3830. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3831. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3832. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3833. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3834. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3835. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3836. }
  3837. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3838. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3839. var liste = MY_getValue(numTroll+".enchantement.liste");
  3840. if(!liste || liste=="")
  3841. {
  3842. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3843. }
  3844. else
  3845. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3846. }
  3847.  
  3848. function do_pre_enchant() {
  3849. start_script(60);
  3850. if(!treatePreEnchantement())
  3851. treateEnchantement_pre();
  3852. displayScriptTime();
  3853. }
  3854.  
  3855. /*********************************************************************************
  3856. * This file is part of Mountyzilla. *
  3857. * *
  3858. * Mountyzilla is free software; you can redistribute it and/or modify *
  3859. * it under the terms of the GNU General Public License as published by *
  3860. * the Free Software Foundation; either version 2 of the License, or *
  3861. * (at your option) any later version. *
  3862. * *
  3863. * Mountyzilla is distributed in the hope that it will be useful, *
  3864. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3865. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3866. * GNU General Public License for more details. *
  3867. * *
  3868. * You should have received a copy of the GNU General Public License *
  3869. * along with Mountyzilla; if not, write to the Free Software *
  3870. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3871. *********************************************************************************/
  3872.  
  3873. // x~x enchant
  3874.  
  3875. /* 2013-08-19 : correction auto syntaxe alert */
  3876.  
  3877. function treateEnchantement() {
  3878. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3879. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3880. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3881. return;
  3882. var tab = infoEquipement.split(";");
  3883. if(tab.length<2)
  3884. return;
  3885. var idEquipement = tab[0];
  3886. var nomEquipement = tab[1];
  3887. for(var i=2;i<tab.length;i++)
  3888. nomEquipement += ";"+tab[i];
  3889.  
  3890. var nodes = document.evaluate(
  3891. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3892. if (nodes.snapshotLength != 3)
  3893. return;
  3894. for(var i=0;i<3;i++)
  3895. {
  3896. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3897. texte = texte.replace(" d'une "," d'un ");
  3898. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3899. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3900. monstre = monstre.replace(/ Géante?/,"");
  3901. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3902. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3903. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3904. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3905. }
  3906. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3907. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3908. var liste = MY_getValue(numTroll+".enchantement.liste");
  3909. if(!liste || liste=="")
  3910. {
  3911. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3912. }
  3913. else
  3914. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3915. }
  3916.  
  3917. function do_enchant() {
  3918. start_script(60);
  3919.  
  3920. treateEnchantement();
  3921. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3922. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3923. displayScriptTime();
  3924. }
  3925.  
  3926. /*********************************************************************************
  3927. * This file is part of Mountyzilla. *
  3928. * *
  3929. * Mountyzilla is free software; you can redistribute it and/or modify *
  3930. * it under the terms of the GNU General Public License as published by *
  3931. * the Free Software Foundation; either version 2 of the License, or *
  3932. * (at your option) any later version. *
  3933. * *
  3934. * Mountyzilla is distributed in the hope that it will be useful, *
  3935. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3936. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3937. * GNU General Public License for more details. *
  3938. * *
  3939. * You should have received a copy of the GNU General Public License *
  3940. * along with Mountyzilla; if not, write to the Free Software *
  3941. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3942. *********************************************************************************/
  3943.  
  3944. // x~x myevent
  3945.  
  3946. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3947. function do_myevent() {
  3948. }
  3949.  
  3950. /*********************************************************************************
  3951. * This file is part of Mountyzilla. *
  3952. * *
  3953. * Mountyzilla is free software; you can redistribute it and/or modify *
  3954. * it under the terms of the GNU General Public License as published by *
  3955. * the Free Software Foundation; either version 2 of the License, or *
  3956. * (at your option) any later version. *
  3957. * *
  3958. * Mountyzilla is distributed in the hope that it will be useful, *
  3959. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3960. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3961. * GNU General Public License for more details. *
  3962. * *
  3963. * You should have received a copy of the GNU General Public License *
  3964. * along with Mountyzilla; if not, write to the Free Software *
  3965. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3966. *********************************************************************************/
  3967.  
  3968. // x~x malus
  3969.  
  3970. /* v1.4 - 2014-01-06
  3971. * - Gestion des sorts double composante
  3972. * v1.4.1 - 2014-01-22
  3973. * - Correction décumul
  3974. * TODO
  3975. * - Identifier la position de "PV" dans l'ordre MH
  3976. */
  3977.  
  3978. var listeBM;
  3979.  
  3980.  
  3981. /* [functions] Utilitaires */
  3982.  
  3983. function decumul(bmt,nbr) {
  3984. var bmr;
  3985. if(!nbr || nbr<2) bmr = bmt;
  3986. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3987. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3988. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3989. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3990. else bmr = parseInt(0.1*bmt);
  3991. if(bmt<0) return Math.min(-1,bmr);
  3992. return Math.max(1,bmr);
  3993. }
  3994.  
  3995. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3996. // Roule 23/11/2016 ajout PV
  3997. switch( a ) {
  3998. case 'ATT':
  3999. return -1;
  4000. case 'ESQ':
  4001. if(b=='ATT') return 1;
  4002. return -1;
  4003. case 'DEG':
  4004. switch( b ) {
  4005. case 'ATT':
  4006. case 'ESQ':
  4007. return 1;
  4008. default:
  4009. return -1;
  4010. }
  4011. case 'REG':
  4012. switch( b ) {
  4013. case 'ATT':
  4014. case 'ESQ':
  4015. case 'DEG':
  4016. return 1;
  4017. default:
  4018. return -1;
  4019. }
  4020. case 'Vue':
  4021. switch( b ) {
  4022. case 'ATT':
  4023. case 'ESQ':
  4024. case 'DEG':
  4025. case 'REG':
  4026. return 1;
  4027. default:
  4028. return -1;
  4029. }
  4030. case 'TOUR':
  4031. switch( b ) {
  4032. case 'ATT':
  4033. case 'ESQ':
  4034. case 'DEG':
  4035. case 'REG':
  4036. case 'Vue':
  4037. return 1;
  4038. default:
  4039. return -1;
  4040. }
  4041. case 'PV':
  4042. switch( b ) {
  4043. case 'ATT':
  4044. case 'ESQ':
  4045. case 'DEG':
  4046. case 'REG':
  4047. case 'Vue':
  4048. case 'TOUR':
  4049. return 1;
  4050. default:
  4051. return -1;
  4052. }
  4053. case 'Armure':
  4054. switch( b ) {
  4055. case 'ATT':
  4056. case 'ESQ':
  4057. case 'DEG':
  4058. case 'REG':
  4059. case 'Vue':
  4060. case 'TOUR':
  4061. case 'PV':
  4062. return 1;
  4063. default:
  4064. return -1;
  4065. }
  4066. case 'RM':
  4067. switch( b ) {
  4068. case 'ATT':
  4069. case 'ESQ':
  4070. case 'DEG':
  4071. case 'REG':
  4072. case 'Vue':
  4073. case 'TOUR':
  4074. case 'PV':
  4075. case 'Armure':
  4076. return 1;
  4077. default:
  4078. return -1;
  4079. }
  4080. case 'MM':
  4081. switch( b ) {
  4082. case 'ATT':
  4083. case 'ESQ':
  4084. case 'DEG':
  4085. case 'REG':
  4086. case 'Vue':
  4087. case 'TOUR':
  4088. case 'PV':
  4089. case 'Armure':
  4090. case 'RM':
  4091. return 1;
  4092. default:
  4093. return -1;
  4094. }
  4095. case 'Concentration':
  4096. switch( b ) {
  4097. case 'ATT':
  4098. case 'ESQ':
  4099. case 'DEG':
  4100. case 'REG':
  4101. case 'Vue':
  4102. case 'TOUR':
  4103. case 'PV':
  4104. case 'Armure':
  4105. case 'RM':
  4106. case 'MM':
  4107. return 1;
  4108. default:
  4109. return -1;
  4110. }
  4111. case 'Fatigue':
  4112. switch( b ) {
  4113. case 'ATT':
  4114. case 'ESQ':
  4115. case 'DEG':
  4116. case 'REG':
  4117. case 'Vue':
  4118. case 'TOUR':
  4119. case 'PV':
  4120. case 'Armure':
  4121. case 'RM':
  4122. case 'MM':
  4123. case 'Concentration':
  4124. return 1;
  4125. default:
  4126. return -1;
  4127. }
  4128. case "Dés d'attaque":
  4129. switch( b ) {
  4130. case 'ATT':
  4131. case 'ESQ':
  4132. case 'DEG':
  4133. case 'REG':
  4134. case 'Vue':
  4135. case 'TOUR':
  4136. case 'PV':
  4137. case 'Armure':
  4138. case 'RM':
  4139. case 'MM':
  4140. case 'Concentration':
  4141. case 'Fatigue':
  4142. return 1;
  4143. default:
  4144. return -1;
  4145. }
  4146. case 'Dés de dégâts':
  4147. switch( b ) {
  4148. case 'ATT':
  4149. case 'ESQ':
  4150. case 'DEG':
  4151. case 'REG':
  4152. case 'Vue':
  4153. case 'TOUR':
  4154. case 'PV':
  4155. case 'Armure':
  4156. case 'RM':
  4157. case 'MM':
  4158. case 'Concentration':
  4159. case 'Fatigue':
  4160. case "Dés d'attaque":
  4161. return 1;
  4162. default:
  4163. return -1;
  4164. }
  4165. default :
  4166. switch( b ) {
  4167. case 'ATT':
  4168. case 'ESQ':
  4169. case 'DEG':
  4170. case 'REG':
  4171. case 'Vue':
  4172. case 'TOUR':
  4173. case 'PV':
  4174. case 'Armure':
  4175. case 'RM':
  4176. case 'MM':
  4177. case 'Concentration':
  4178. case 'Fatigue':
  4179. case "Dés d'attaque":
  4180. case 'Dés de dégâts':
  4181. return 1;
  4182. default:
  4183. return -1;
  4184. }
  4185. }
  4186. }
  4187.  
  4188.  
  4189. /* [functions] Fonctions hide / display */
  4190.  
  4191. function toggleDetailsBM() {
  4192. if(MY_getValue('BMDETAIL')!='false') {
  4193. MY_setValue('BMDETAIL','false');
  4194. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4195. for(var i=0 ; i<trlist.length ; i++)
  4196. trlist[i].style.display = 'none';
  4197. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4198. for(var i=0 ; i<trlist.length ; i++)
  4199. trlist[i].style = '';
  4200. }
  4201. else {
  4202. MY_setValue('BMDETAIL','true');
  4203. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4204. for(var i=0 ; i<trlist.length ; i++)
  4205. trlist[i].style.display = 'none';
  4206. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4207. for(var i=0 ; i<trlist.length ; i++)
  4208. trlist[i].style = '';
  4209. }
  4210. }
  4211.  
  4212. function toggleBMList() {
  4213. if(MY_getValue('BMHIDELIST')=='true') {
  4214. MY_setValue('BMHIDELIST','false');
  4215. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4216. listeBM.snapshotItem(i).style = '';
  4217. document.getElementsByTagName('thead')[0].style = '';
  4218. document.getElementById('trhelp').style = '';
  4219. }
  4220. else {
  4221. MY_setValue('BMHIDELIST','true');
  4222. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4223. listeBM.snapshotItem(i).style.display = 'none';
  4224. document.getElementsByTagName('thead')[0].style.display = 'none';
  4225. document.getElementById('trhelp').style.display = 'none';
  4226. }
  4227. }
  4228.  
  4229. function setDisplayBM() {
  4230. if(!listeBM) return;
  4231.  
  4232. var titre = document.getElementById('titre2');
  4233. if(titre) {
  4234. titre.style.cursor = 'pointer';
  4235. titre.onclick = toggleBMList;
  4236. }
  4237.  
  4238. var tfoot = document.getElementsByTagName('tfoot')[0];
  4239. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  4240. tfoot, null, 9, null).singleNodeValue;
  4241. tr.id = 'trhelp';
  4242.  
  4243. if(MY_getValue('BMHIDELIST')=='true') {
  4244. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4245. listeBM.snapshotItem(i).style.display = 'none';
  4246. document.getElementsByTagName('thead')[0].style.display = 'none';
  4247. tr.style.display = 'none';
  4248. }
  4249. }
  4250.  
  4251.  
  4252. /* [functions] Fonction principale */
  4253.  
  4254. function traiteMalus() {
  4255. var mainTab = document.getElementsByTagName('table')[0];
  4256. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4257. if(listeBM.snapshotLength==0) return;
  4258.  
  4259. /* Suppression des BM de fatigue stockés */
  4260. if(MY_getValue(numTroll+'.bm.fatigue'))
  4261. MY_removeValue(numTroll+'.bm.fatigue');
  4262.  
  4263. /* Extraction des données */
  4264. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  4265. var nb = 0;
  4266. while(nb<listeBM.snapshotLength) {
  4267. tr = listeBM.snapshotItem(nb); nb++;
  4268. var effetsT = tr.childNodes[5].textContent.split(' | ');
  4269. var phymag = tr.childNodes[9].textContent;
  4270. var duree = tr.childNodes[11].textContent.match(/\d+/);
  4271. if (duree == null) { // Roule 28/01/2018 protection malus Crasc sans durée
  4272. duree = 1;
  4273. } else {
  4274. duree = Number(duree[0]);
  4275. }
  4276. var type = tr.childNodes[3].textContent, nom;
  4277. // si c'est un type à décumul
  4278. /*
  4279. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  4280. switch(type) {
  4281. case 'Potion':
  4282. case 'Parchemin':
  4283. case 'Sortilège':
  4284. case 'Capacité Spéciale':
  4285. nom = tr.childNodes[1].textContent+phymag;
  4286. break;
  4287. default:
  4288. nom = 'pasdedecumul';
  4289. }
  4290. */
  4291. nom = tr.childNodes[1].textContent+phymag;
  4292. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  4293. nom = 'pasdedecumul';
  4294.  
  4295. uniListe[nb] = {
  4296. 'duree':duree,
  4297. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  4298. 'caracs':{}
  4299. }
  4300. for(var i=0 ; i<effetsT.length ; i++) {
  4301. if(effetsT[i].indexOf(':')==-1) continue;
  4302. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  4303. // nom = 'pasdedecumul' si pas de décumul
  4304. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  4305. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  4306. uniListe[nb]['type'] = phymag;
  4307. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  4308. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  4309. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  4310. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  4311. uniListe[nb]['caracs'][carac] = bm;
  4312. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  4313. listeDurees[duree] = true;
  4314. }
  4315. } // fin boucle sur les lignes de bonus/malus
  4316.  
  4317. /* Gestion des décumuls et cumuls des durées */
  4318. var toursGeres = [];
  4319. for(var d in listeDurees) toursGeres.push(d);
  4320. toursGeres.sort( function (a,b){return b-a;} );
  4321. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  4322. // pour sauvegarder les bm de fatigue
  4323. var strfat = '';
  4324. // Pour affichage & adpatation à footable.js (statique)
  4325. var thead = document.getElementsByTagName('thead')[0];
  4326. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  4327. thead, null, 7, null).snapshotLength;
  4328. var tfoot = document.getElementsByTagName('tfoot')[0];
  4329.  
  4330. for(var i=0 ; i<toursGeres.length ; i++) {
  4331. var tour = toursGeres[i];
  4332. var effetsCeTour = {}; decumulsCeTour = {};
  4333. for(var nb=1 ; nb<uniListe.length ; nb++) {
  4334. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  4335. continue;
  4336. var nom = uniListe[nb]['nom'];
  4337. if(nom!='pasdedecumul') {
  4338. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  4339. decumulsCeTour[nom]++;
  4340. }
  4341. for(var carac in uniListe[nb]['caracs']) {
  4342. var bm = uniListe[nb]['caracs'][carac];
  4343. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  4344. var type = uniListe[nb]['type'];
  4345. if(!effetsCeTour[carac])
  4346. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  4347. var thisBm;
  4348. if(nom=='pasdedecumul')
  4349. thisBm = bm;
  4350. else
  4351. thisBm = decumul(bm,decumulsCeTour[nom]);
  4352. effetsCeTour[carac][type] += thisBm;
  4353. 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]);
  4354. } else {
  4355. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  4356. var thisBm;
  4357. if(nom=='pasdedecumul' || carac=='Fatigue')
  4358. thisBm = bm;
  4359. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  4360. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  4361. else
  4362. thisBm = decumul(bm,decumulsCeTour[nom]);
  4363. effetsCeTour[carac] += thisBm;
  4364. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  4365. }
  4366. } // fin boucle sur les caractéristiques
  4367. } // fin boucle sur les bonus/malus
  4368.  
  4369. /* Création du bilan du tour */
  4370. var texteD = '', texteS = '';
  4371. var caracGerees = [];
  4372. for(var k in effetsCeTour) caracGerees.push(k);
  4373. caracGerees.sort( triecaracs );
  4374.  
  4375. for(var j=0 ; j<caracGerees.length ; j++) {
  4376. var carac = caracGerees[j], str = '';
  4377.  
  4378. switch( carac ) {
  4379. case 'ATT':
  4380. case 'DEG':
  4381. case 'Armure':
  4382. var phy = effetsCeTour[carac]['Physique'];
  4383. var mag = effetsCeTour[carac]['Magie'];
  4384. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  4385. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  4386. break;
  4387. case 'TOUR':
  4388. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  4389. break;
  4390. case 'Fatigue':
  4391. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  4392. case 'PV':
  4393. case 'ESQ':
  4394. case 'REG':
  4395. case 'Vue':
  4396. case 'Voir le Caché':
  4397. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  4398. break;
  4399. default:
  4400. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  4401. }
  4402. if(str) {
  4403. texteD += str;
  4404. texteS += str;
  4405. }
  4406. } // fin boucle sur les caractéristiques
  4407.  
  4408. /* Affichage */
  4409. // Si rien à afficher on passe
  4410. if(!texteD) continue;
  4411. // Si BMM+BMP=0
  4412. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  4413. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  4414. if(MY_getValue('BMDETAIL')=='false')
  4415. tr.style.display = 'none';
  4416. var td = appendTdText(tr,texteD.substring(3));
  4417. td.colSpan = 5-nbHidden;
  4418. var txttour = toursGeres[i]+' Tour';
  4419. if(toursGeres[i]>1) txttour += 's';
  4420. appendTdText(tr,txttour);
  4421.  
  4422. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  4423. if(MY_getValue('BMDETAIL')!='false')
  4424. tr.style.display = 'none';
  4425. td = appendTdText(tr,texteS);
  4426. td.colSpan = 5-nbHidden;
  4427. appendTdText(tr,txttour);
  4428. } // fin boucle sur les tours générés
  4429.  
  4430. /* mise en place toggleDetails */
  4431. tfoot.style.cursor = 'pointer';
  4432. tfoot.onclick = toggleDetailsBM;
  4433.  
  4434. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4435. if(strfat)
  4436. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4437. }
  4438.  
  4439. function do_malus() {
  4440. try {
  4441. start_script();
  4442. traiteMalus();
  4443. setDisplayBM();
  4444. displayScriptTime();
  4445. }
  4446. catch(e) {window.alert(e)};
  4447. }
  4448.  
  4449. /*******************************************************************************
  4450. * This file is part of Mountyzilla. *
  4451. * *
  4452. * Mountyzilla is free software; you can redistribute it and/or modify *
  4453. * it under the terms of the GNU General Public License as published by *
  4454. * the Free Software Foundation; either version 2 of the License, or *
  4455. * (at your option) any later version. *
  4456. * *
  4457. * Mountyzilla is distributed in the hope that it will be useful, *
  4458. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4459. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4460. * GNU General Public License for more details. *
  4461. * *
  4462. * You should have received a copy of the GNU General Public License *
  4463. * along with Mountyzilla; if not, write to the Free Software *
  4464. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4465. *******************************************************************************/
  4466.  
  4467. // x~x mouches
  4468.  
  4469. var mainTab, tr_mouches;
  4470.  
  4471. function initialiseMouches() {
  4472. // Lanceur global
  4473. try {
  4474. mainTab = document.getElementById('mouches');
  4475. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4476. } catch(e) {
  4477. avertissement('Erreur MZ:<br />Consulter la console.');
  4478. window.console.error(traceStack(e, 'mouches'));
  4479. return;
  4480. }
  4481. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4482.  
  4483. setDisplayMouches();
  4484. traiteMouches();
  4485. }
  4486.  
  4487. function setDisplayMouches() {
  4488. // Initialise l'affichage / l'effacement du détail des mouches
  4489. var titre = document.getElementById('titre2');
  4490. if(titre) {
  4491. titre.style.cursor = 'pointer';
  4492. titre.onclick = toggleMouches;
  4493. }
  4494.  
  4495. var tfoot = document.getElementsByTagName('tfoot')[0];
  4496. if(tfoot) {
  4497. tfoot.style.cursor = 'pointer';
  4498. tfoot.onclick = toggleMouches;
  4499. }
  4500.  
  4501. if(MY_getValue('HIDEMOUCHES')=='true') {
  4502. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4503. tr_mouches.snapshotItem(i).style.display = 'none';
  4504. }
  4505. document.getElementsByTagName('thead')[0].style.display = 'none';
  4506. }
  4507. }
  4508.  
  4509. function toggleMouches() {
  4510. // Handler pour afficher / masquer les détasil
  4511. if(MY_getValue('HIDEMOUCHES')=='true') {
  4512. MY_setValue('HIDEMOUCHES','false');
  4513. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4514. tr_mouches.snapshotItem(i).style.display = '';
  4515. }
  4516. document.getElementsByTagName('thead')[0].style.display = '';
  4517. } else {
  4518. MY_setValue('HIDEMOUCHES','true');
  4519. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4520. tr_mouches.snapshotItem(i).style.display = 'none';
  4521. }
  4522. document.getElementsByTagName('thead')[0].style.display = 'none';
  4523. }
  4524. }
  4525.  
  4526. function traiteMouches() {
  4527. // Traitement complet: présence et effets des mouches
  4528. var listeTypes = {}, effetsActifs = {};
  4529.  
  4530. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4531. var tr = tr_mouches.snapshotItem(i);
  4532.  
  4533. // La mouche est-elle présente?
  4534. var etat = document.evaluate(
  4535. './img',
  4536. tr.cells[6], null, 9, null
  4537. ).singleNodeValue.alt;
  4538. if(etat!='La Mouche est là') { continue; }
  4539. // Extraction du type de mouche
  4540. var type = trim(tr.cells[3].textContent);
  4541. if(!listeTypes[type]) {
  4542. listeTypes[type] = 1;
  4543. } else {
  4544. listeTypes[type]++;
  4545. }
  4546.  
  4547. // La mouche a-t-elle un effet?
  4548. var effet = trim(tr.cells[2].textContent);
  4549. if(etat!='La Mouche est là' || !effet) { continue; }
  4550. // Si oui, extraction des effets (multiples pour pogées)
  4551. var caracs = effet.split(' | ');
  4552. for(var j=0 ; j<caracs.length ; j++) {
  4553. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4554. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4555. if(effetsActifs[carac]===void(0)) {
  4556. effetsActifs[carac] = valeur;
  4557. } else {
  4558. effetsActifs[carac] += valeur;
  4559. }
  4560. }
  4561. }
  4562.  
  4563. // Extraction Effet total et affichage des différences à la normale
  4564. var tfoot = document.getElementsByTagName('tfoot')[0];
  4565. if(!tfoot) { return; }
  4566. var nodeTotal = document.evaluate(
  4567. ".//b[contains(./text(),'Effet total')]",
  4568. tfoot, null, 9, null
  4569. ).singleNodeValue.nextSibling;
  4570. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4571. var texte = ' ';
  4572. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4573. if(texte.length>1) { texte += ' | '; }
  4574. var carac = trim(
  4575. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4576. );
  4577. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4578. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4579. texte += effetsTheoriques[i];
  4580. } else {
  4581. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4582. if(carac=='TOUR') { texte += ' min'; }
  4583. texte += '</b>';
  4584. }
  4585. }
  4586. var span = document.createElement('span');
  4587. span.innerHTML = texte;
  4588. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4589.  
  4590. // Affichage des différences du nombre de mouches de chaque type
  4591. var mouchesParType = document.evaluate(
  4592. "./tr/td/ul/li/text()",
  4593. tfoot, null, 7, null
  4594. );
  4595. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4596. var node = mouchesParType.snapshotItem(i);
  4597. var mots = node.nodeValue.split(' ');
  4598. var type = mots.pop();
  4599. if(!listeTypes[type]) {
  4600. node.nodeValue += ' (0 présente)';
  4601. } else if(mots[0]!=listeTypes[type]) {
  4602. if(listeTypes[type]==1) {
  4603. node.nodeValue += ' (1 présente)';
  4604. } else {
  4605. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4606. }
  4607. }
  4608. }
  4609. }
  4610.  
  4611. function do_mouches() {
  4612. start_script();
  4613. initialiseMouches();
  4614. displayScriptTime();
  4615. }
  4616.  
  4617. /*********************************************************************************
  4618. * This file is part of Mountyzilla. *
  4619. * *
  4620. * Mountyzilla is free software; you can redistribute it and/or modify *
  4621. * it under the terms of the GNU General Public License as published by *
  4622. * the Free Software Foundation; either version 2 of the License, or *
  4623. * (at your option) any later version. *
  4624. * *
  4625. * Mountyzilla is distributed in the hope that it will be useful, *
  4626. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4627. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4628. * GNU General Public License for more details. *
  4629. * *
  4630. * You should have received a copy of the GNU General Public License *
  4631. * along with Mountyzilla; if not, write to the Free Software *
  4632. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4633. *********************************************************************************/
  4634.  
  4635. // x~x equipgowap
  4636.  
  4637. var popup;
  4638.  
  4639. function initPopupEquipgowap() {
  4640. popup = document.createElement('div');
  4641. popup.setAttribute('id', 'popup');
  4642. popup.setAttribute('class', 'mh_textbox');
  4643. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4644. 'display: inline; z-index: 3; max-width: 400px;');
  4645. document.body.appendChild(popup);
  4646. }
  4647.  
  4648. function showPopupEquipgowap(evt) {
  4649. var texte = this.getAttribute("texteinfo");
  4650. popup.innerHTML = texte;
  4651. popup.style.left = evt.pageX + 15 + 'px';
  4652. popup.style.top = evt.pageY + 'px';
  4653. popup.style.visibility = "visible";
  4654. }
  4655.  
  4656. function hidePopup() {
  4657. popup.style.visibility = "hidden";
  4658. }
  4659.  
  4660. function createPopupImage(url, text)
  4661. {
  4662. var img = document.createElement('img');
  4663. img.setAttribute('src',url);
  4664. img.setAttribute('align','ABSMIDDLE');
  4665. img.setAttribute("texteinfo",text);
  4666. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4667. img.addEventListener("mouseout", hidePopup,true);
  4668. return img;
  4669. }
  4670.  
  4671. function formateTexte(texte)
  4672. {
  4673. texte = texte.replace(/\n/g,"<br/>");
  4674. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4675. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4676. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4677. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4678. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4679. return texte;
  4680. }
  4681.  
  4682.  
  4683. function treateGowaps() {
  4684. //On récupère les gowaps possédants des composants
  4685. var tbodys = document.evaluate(
  4686. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4687. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4688. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4689. var tbody = tbodys.snapshotItem(j);
  4690. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4691. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4692. if(MY_getValue("NOINFOEM") != "true")
  4693. insertEMInfos(tbody);
  4694. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4695. insertEnchantInfos(tbody);
  4696. }
  4697. }
  4698.  
  4699. function treateChampi() {
  4700. if(MY_getValue("NOINFOEM") == "true")
  4701. return false;
  4702. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4703. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4704. if (nodes.snapshotLength == 0)
  4705. return false;
  4706.  
  4707. for (var i = 0; i < nodes.snapshotLength; i++) {
  4708. var node = nodes.snapshotItem(i);
  4709. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4710. if(texte.indexOf("*")!=-1)
  4711. texte = texte.substring(0,texte.lastIndexOf(" "));
  4712. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4713. if(moisChampi[nomChampi])
  4714. {
  4715. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4716. }
  4717.  
  4718. }
  4719. }
  4720.  
  4721. function do_equipgowap() {
  4722. start_script();
  4723.  
  4724. treateGowaps();
  4725. treateChampi();
  4726. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4727. {
  4728. initPopupEquipgowap();
  4729. computeEnchantementEquipement(createPopupImage,formateTexte);
  4730. }
  4731.  
  4732. displayScriptTime();
  4733. }
  4734.  
  4735. /*********************************************************************************
  4736. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4737. *********************************************************************************/
  4738.  
  4739. // x~x ordresgowap
  4740.  
  4741. var MZ_analyse_page_ordre_suivant;
  4742. if (MZ_analyse_page_ordre_suivant === undefined && isPage("MH_Follower/FO_Ordres")) {
  4743. // Roule 07/10/2019
  4744. // Fonction réutilisée dans MZ, dans Trajet_canvas et dans une extension perso ☺
  4745. // rend un object, par exemple
  4746. var MZ_analyse_page_ordre_suivant = {
  4747. 'result': {ordres: []},
  4748. 'init': function() {
  4749. // façon blindée de tester la variable MY_DEBUG
  4750. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('start MZ_analyse_page_ordre_suivant.init');
  4751. try {
  4752. var eTitle = document.getElementById('titre2');
  4753. // au 07/10/2019, on peut se baser sur les <tr> de l'élément HTML parent 'titre2'
  4754. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('eTitle.nextSibling=' + eTitle.parentNode);
  4755. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4756. for(var i=0 ; i<lignes.length ; i++) {
  4757. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + ' className=' + lignes[i].className);
  4758. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + lignes[i].innerHTML);
  4759. if(lignes[i].className == 'mh_tdtitre_fo') {
  4760. var tds = lignes[i].getElementsByTagName('div');
  4761. for (var j=0; j < tds.length; j++) {
  4762. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant div ' + j + ' ' + tds[j].innerText);
  4763. var tabmatch = tds[j].innerText.match(/(\d+) *\.* *(.*\[.*\].*)$/);
  4764. if (tabmatch) {
  4765. // ID, Nom
  4766. this.result.id = tabmatch[1].trim();
  4767. this.result.nom = tabmatch[2].trim();
  4768. }
  4769. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-?\d+).*Y = (-?\d+).*N = (-?\d+)/i);
  4770. if (tabmatch) {
  4771. // PA, x, y, n
  4772. this.result.PA = parseInt(tabmatch[1]);
  4773. this.result.x = parseInt(tabmatch[2]);
  4774. this.result.y = parseInt(tabmatch[3]);
  4775. this.result.n = parseInt(tabmatch[4]);
  4776. // Trajet_canvas a besoin d'un pointeur vers cette div
  4777. this.result.eltPos = tds[j];
  4778. }
  4779. }
  4780. }
  4781. if(lignes[i].className == 'mh_tdpage_fo') {
  4782. var etd = lignes[i].getElementsByTagName('td')[0];
  4783. if (etd !== undefined) { // undefined dans le cas des Golems
  4784. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant etd ' + etd.firstChild.nodeValue);
  4785. var tabmatch = etd.firstChild.nodeValue.match(/^(.*)X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4786. if (tabmatch) {
  4787. this.result.ordres.push({ordre: tabmatch[1].trim(), x: parseInt(tabmatch[2]), y: parseInt(tabmatch[3]), n: parseInt(tabmatch[4])});
  4788. } else {
  4789. this.result.ordres.push({ordre: etd.firstChild.nodeValue.trim()});
  4790. }
  4791. }
  4792. }
  4793. }
  4794. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('fin MZ_analyse_page_ordre_suivant ' + JSON.stringify(this.result));
  4795. } catch(e) {
  4796. window.console.log('Exception dans MZ_analyse_page_ordre_suivant.init ' + e);
  4797. }
  4798. }
  4799. }
  4800. MZ_analyse_page_ordre_suivant.init();
  4801. }
  4802.  
  4803. // version Roule' janvier 2017
  4804. function MZ_setCarteUnGogoHTML5() {
  4805. // fabriquer la liste des positions successives
  4806. var listeDepl = []; // ce sera un tableau d'objets
  4807. listeDepl = MZ_analyse_page_ordre_suivant.result.ordres.slice(0); // clone array
  4808. 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
  4809.  
  4810. /* à supprimer, remplacé par MZ_analyse_page_ordre_suivant
  4811. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  4812. , y: parseInt(tabPos[3])
  4813. , n: parseInt(tabPos[4])
  4814. , nom: tabNomID[2]
  4815. , id: tabNomID[1]});
  4816.  
  4817. // position courante
  4818. var eTitle = document.getElementById('titre2');
  4819. // déplacements
  4820. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4821. for(var i=0 ; i<lignes.length ; i++) {
  4822. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + ' className=' + lignes[i].className);
  4823. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + lignes[i].innerHTML);
  4824. if(lignes[i].className == 'mh_tdtitre_fo') {
  4825. var tds = lignes[i].getElementsByTagName('div');
  4826. for (var j=0; j < tds.length; j++) {
  4827. tabmatch = tds[j].innerText.match(/(\d+) *(.*\[.*\].*)$/);
  4828. if (tabmatch) var tabNomID = tabmatch;
  4829. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-.\d+).*Y = (-.\d+).*N = (-.\d+)/i);
  4830. if (tabmatch) var tabPos = tabmatch;
  4831. }
  4832. if (tabPos != undefined && tabNomID != undefined) { // null dans le cas des Golems
  4833. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  4834. , y: parseInt(tabPos[3])
  4835. , n: parseInt(tabPos[4])
  4836. , nom: tabNomID[2]
  4837. , id: tabNomID[1]});
  4838. } else {
  4839. return;
  4840. }
  4841. }
  4842. if(lignes[i].className == 'mh_tdpage_fo') {
  4843. var etd = lignes[i].getElementsByTagName('td')[0];
  4844. if (etd === undefined) return; // cas des Golems
  4845. var point = etd.firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4846. if (point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4847. }
  4848. }
  4849. */
  4850. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4851. }
  4852.  
  4853. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4854. function MZ_showCarteBottom(listeSuiv) {
  4855. // générer la carte
  4856. var carte = new carte_MZ('cartegogo', listeSuiv);
  4857. // positionner la carte
  4858. var eCarte = carte.getElt();
  4859. eCarte.style.textAlign = 'left';
  4860. eCarte.style.marginTop = '2px';
  4861. var footer = document.getElementById('footer1');
  4862. // Lieu_Teleport.php n'a pas de footer1 :(
  4863. if (!footer) footer = document.getElementById('footer2');
  4864. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4865. else document.body.appendChild(eCarte);
  4866. }
  4867.  
  4868. function MZ_setCarteTousGogoHTML5() {
  4869. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4870. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4871. var suivants = [];
  4872. for (var i=0;i<ligne.length;i++) {
  4873. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4874. var cas = ligne[i].getElementsByTagName("td")[0];
  4875. //if (cas.className == "mh_tdtitre") {
  4876. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4877. var oGogo = {};
  4878. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4879. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4880. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4881. oGogo.x = parseInt(point[1]);
  4882. oGogo.y = parseInt(point[2]);
  4883. oGogo.n = parseInt(point[3]);
  4884. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4885. }
  4886. }
  4887. if (suivants.length == 0) return;
  4888. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4889. }
  4890.  
  4891. function MZ_setCarteTP() {
  4892. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4893. 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);
  4894. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4895. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4896. }
  4897.  
  4898. /* v0.2 by Dab - 2013-08-31
  4899. * - correction acquisition posale initiale
  4900. * - correction tare et affichage mire
  4901. */
  4902.  
  4903. function setCarteGogo() {
  4904. try {
  4905. //var pars = document.getElementsByTagName('p');
  4906. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4907. var eTitle = document.getElementById('titre2');
  4908. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4909. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4910. var serv_img_cible = URL_MZimg + "rep.png";
  4911.  
  4912. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4913. //var lignes = pars[0].getElementsByTagName('tr');
  4914. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4915. var nbpt = 0;
  4916. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4917. for(var i=0 ; i<lignes.length ; i++) {
  4918. if(lignes[i].className == 'mh_tdpage_fo') {
  4919. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4920. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4921. if(point) {
  4922. nbpt++;
  4923. trajet += point[1]+','+point[2]+','+point[3]+',';
  4924. }
  4925. }
  4926. }
  4927. }
  4928. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4929. 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'/>";
  4930. var base = [-229,-5];
  4931. if (nbpt>0) {
  4932. base = [-684,-5];
  4933. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4934. }
  4935. 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;'/>";
  4936.  
  4937. nvdiv += '<map name="coord_trou">'+
  4938. '<area shape="circle" href="#" coords="260,333,3" title="X=5, Y=-49" >'+
  4939. '<area shape="circle" href="#" coords="262,335,3" title="X=6, Y=-50" >'+
  4940. '<area shape="circle" href="#" coords="260,335,3" title="X=5, Y=-50" >'+
  4941. '<area shape="circle" href="#" coords="262,333,3" title="X=6, Y=-49" >'+
  4942. '<area shape="circle" href="#" coords="294,163,3" title="X=22, Y=36" >'+
  4943. '<area shape="circle" href="#" coords="292,163,3" title="X=21, Y=36" >'+
  4944. '<area shape="circle" href="#" coords="294,165,3" title="X=22, Y=35" >'+
  4945. '<area shape="circle" href="#" coords="292,165,3" title="X=21, Y=35" >'+
  4946. '<area shape="circle" href="#" coords="124,217,3" title="X=-63, Y=9" >'+
  4947. '<area shape="circle" href="#" coords="122,217,3" title="X=-64, Y=9" >'+
  4948. '<area shape="circle" href="#" coords="124,219,3" title="X=-63, Y=8" >'+
  4949. '<area shape="circle" href="#" coords="122,219,3" title="X=-64, Y=8" >'+
  4950. '<area shape="circle" href="#" coords="378,95,3" title="X=64, Y=70" >'+
  4951. '<area shape="circle" href="#" coords="146,121,3" title="X=-52, Y=57" >'+
  4952. '<area shape="circle" href="#" coords="346,313,3" title="X=48, Y=-39" >'+
  4953. '<area shape="circle" href="#" coords="310,339,3" title="X=30, Y=-52" >'+
  4954. '<area shape="circle" href="#" coords="274,265,3" title="X=12, Y=-15" >'+
  4955. '<area shape="circle" href="#" coords="360,95,3" title="X=55, Y=70" >'+
  4956. '<area shape="circle" href="#" coords="224,91,3" title="X=-13, Y=72" >'+
  4957. '<area shape="circle" href="#" coords="226,91,3" title="X=-12, Y=72" >'+
  4958. '<area shape="circle" href="#" coords="224,89,3" title="X=-13, Y=73" >'+
  4959. '<area shape="circle" href="#" coords="226,89,3" title="X=-12, Y=73" >'+
  4960. '<area shape="circle" href="#" coords="148,281,3" title="X=-51, Y=-23" >'+
  4961. '<area shape="circle" href="#" coords="150,281,3" title="X=-50, Y=-23" >'+
  4962. '<area shape="circle" href="#" coords="148,279,3" title="X=-51, Y=-22" >'+
  4963. '<area shape="circle" href="#" coords="150,279,3" title="X=-50, Y=-22" >'+
  4964. '<area shape="circle" href="#" coords="130,301,3" title="X=-60, Y=-33" >'+
  4965. '<area shape="circle" href="#" coords="132,301,3" title="X=-59, Y=-33" >'+
  4966. '<area shape="circle" href="#" coords="130,299,3" title="X=-60, Y=-32" >'+
  4967. '<area shape="circle" href="#" coords="132,299,3" title="X=-59, Y=-32" >'+
  4968. '<area shape="circle" href="#" coords="116,311,3" title="X=-67, Y=-38" >'+
  4969. '<area shape="circle" href="#" coords="118,311,3" title="X=-66, Y=-38" >'+
  4970. '<area shape="circle" href="#" coords="116,309,3" title="X=-67, Y=-37" >'+
  4971. '<area shape="circle" href="#" coords="118,309,3" title="X=-66, Y=-37" >'+
  4972. '<area shape="circle" href="#" coords="260,173,3" title="X=5, Y=31" >'+
  4973. '<area shape="circle" href="#" coords="262,173,3" title="X=6, Y=31" >'+
  4974. '<area shape="circle" href="#" coords="260,171,3" title="X=5, Y=32" >'+
  4975. '<area shape="circle" href="#" coords="262,171,3" title="X=6, Y=32" >'+
  4976. '<area shape="circle" href="#" coords="178,339,3" title="X=-36, Y=-52" >'+
  4977. '<area shape="circle" href="#" coords="180,339,3" title="X=-35, Y=-52" >'+
  4978. '<area shape="circle" href="#" coords="178,337,3" title="X=-36, Y=-51" >'+
  4979. '<area shape="circle" href="#" coords="180,337,3" title="X=-35, Y=-51" >'+
  4980. '<area shape="circle" href="#" coords="182,107,3" title="X=-34, Y=64" >'+
  4981. '<area shape="circle" href="#" coords="182,105,3" title="X=-34, Y=65" >'+
  4982. '<area shape="circle" href="#" coords="270,109,3" title="X=10, Y=63" >'+
  4983. '<area shape="circle" href="#" coords="272,109,3" title="X=11, Y=63" >'+
  4984. '<area shape="circle" href="#" coords="270,107,3" title="X=10, Y=64" >'+
  4985. '<area shape="circle" href="#" coords="272,107,3" title="X=11, Y=64" >'+
  4986. '<area shape="circle" href="#" coords="180,207,3" title="X=-35, Y=14" >'+
  4987. '<area shape="circle" href="#" coords="182,207,3" title="X=-34, Y=14" >'+
  4988. '<area shape="circle" href="#" coords="180,205,3" title="X=-35, Y=15" >'+
  4989. '<area shape="circle" href="#" coords="182,205,3" title="X=-34, Y=15" >'+
  4990. '<area shape="circle" href="#" coords="398,173,3" title="X=74, Y=31" >'+
  4991. '<area shape="circle" href="#" coords="400,173,3" title="X=75, Y=31" >'+
  4992. '<area shape="circle" href="#" coords="398,171,3" title="X=74, Y=32" >'+
  4993. '<area shape="circle" href="#" coords="400,171,3" title="X=75, Y=32" >'+
  4994. '<area shape="circle" href="#" coords="342,133,3" title="X=46, Y=51" >'+
  4995. '<area shape="circle" href="#" coords="344,133,3" title="X=47, Y=51" >'+
  4996. '<area shape="circle" href="#" coords="342,131,3" title="X=46, Y=52" >'+
  4997. '<area shape="circle" href="#" coords="344,131,3" title="X=47, Y=52" >'+
  4998. '<area shape="circle" href="#" coords="180,107,3" title="X=-35, Y=64" >'+
  4999. '<area shape="circle" href="#" coords="180,105,3" title="X=-35, Y=65" >'+
  5000. '<area shape="circle" href="#" coords="108,251,3" title="X=-71, Y=-8" >'+
  5001. '<area shape="circle" href="#" coords="110,251,3" title="X=-70, Y=-8" >'+
  5002. '<area shape="circle" href="#" coords="108,249,3" title="X=-71, Y=-7" >'+
  5003. '<area shape="circle" href="#" coords="110,249,3" title="X=-70, Y=-7" >'+
  5004. '<area shape="circle" href="#" coords="346,191,3" title="X=48, Y=22" >'+
  5005. '<area shape="circle" href="#" coords="346,189,3" title="X=48, Y=23" >'+
  5006. '<area shape="circle" href="#" coords="346,187,3" title="X=48, Y=24" >'+
  5007. '<area shape="circle" href="#" coords="346,185,3" title="X=48, Y=25" >'+
  5008. '<area shape="circle" href="#" coords="348,195,3" title="X=49, Y=20" >'+
  5009. '<area shape="circle" href="#" coords="348,193,3" title="X=49, Y=21" >'+
  5010. '<area shape="circle" href="#" coords="348,191,3" title="X=49, Y=22" >'+
  5011. '<area shape="circle" href="#" coords="348,189,3" title="X=49, Y=23" >'+
  5012. '<area shape="circle" href="#" coords="348,187,3" title="X=49, Y=24" >'+
  5013. '<area shape="circle" href="#" coords="348,185,3" title="X=49, Y=25" >'+
  5014. '<area shape="circle" href="#" coords="348,183,3" title="X=49, Y=26" >'+
  5015. '<area shape="circle" href="#" coords="348,181,3" title="X=49, Y=27" >'+
  5016. '<area shape="circle" href="#" coords="350,199,3" title="X=50, Y=18" >'+
  5017. '<area shape="circle" href="#" coords="350,197,3" title="X=50, Y=19" >'+
  5018. '<area shape="circle" href="#" coords="350,195,3" title="X=50, Y=20" >'+
  5019. '<area shape="circle" href="#" coords="350,193,3" title="X=50, Y=21" >'+
  5020. '<area shape="circle" href="#" coords="350,191,3" title="X=50, Y=22" >'+
  5021. '<area shape="circle" href="#" coords="350,189,3" title="X=50, Y=23" >'+
  5022. '<area shape="circle" href="#" coords="350,187,3" title="X=50, Y=24" >'+
  5023. '<area shape="circle" href="#" coords="350,185,3" title="X=50, Y=25" >'+
  5024. '<area shape="circle" href="#" coords="350,183,3" title="X=50, Y=26" >'+
  5025. '<area shape="circle" href="#" coords="350,181,3" title="X=50, Y=27" >'+
  5026. '<area shape="circle" href="#" coords="350,179,3" title="X=50, Y=28" >'+
  5027. '<area shape="circle" href="#" coords="350,177,3" title="X=50, Y=29" >'+
  5028. '<area shape="circle" href="#" coords="352,201,3" title="X=51, Y=17" >'+
  5029. '<area shape="circle" href="#" coords="352,199,3" title="X=51, Y=18" >'+
  5030. '<area shape="circle" href="#" coords="352,197,3" title="X=51, Y=19" >'+
  5031. '<area shape="circle" href="#" coords="352,195,3" title="X=51, Y=20" >'+
  5032. '<area shape="circle" href="#" coords="352,193,3" title="X=51, Y=21" >'+
  5033. '<area shape="circle" href="#" coords="352,191,3" title="X=51, Y=22" >'+
  5034. '<area shape="circle" href="#" coords="352,189,3" title="X=51, Y=23" >'+
  5035. '<area shape="circle" href="#" coords="352,187,3" title="X=51, Y=24" >'+
  5036. '<area shape="circle" href="#" coords="352,185,3" title="X=51, Y=25" >'+
  5037. '<area shape="circle" href="#" coords="352,183,3" title="X=51, Y=26" >'+
  5038. '<area shape="circle" href="#" coords="352,181,3" title="X=51, Y=27" >'+
  5039. '<area shape="circle" href="#" coords="352,179,3" title="X=51, Y=28" >'+
  5040. '<area shape="circle" href="#" coords="352,177,3" title="X=51, Y=29" >'+
  5041. '<area shape="circle" href="#" coords="352,175,3" title="X=51, Y=30" >'+
  5042. '<area shape="circle" href="#" coords="354,201,3" title="X=52, Y=17" >'+
  5043. '<area shape="circle" href="#" coords="354,199,3" title="X=52, Y=18" >'+
  5044. '<area shape="circle" href="#" coords="354,197,3" title="X=52, Y=19" >'+
  5045. '<area shape="circle" href="#" coords="354,195,3" title="X=52, Y=20" >'+
  5046. '<area shape="circle" href="#" coords="354,193,3" title="X=52, Y=21" >'+
  5047. '<area shape="circle" href="#" coords="354,191,3" title="X=52, Y=22" >'+
  5048. '<area shape="circle" href="#" coords="354,189,3" title="X=52, Y=23" >'+
  5049. '<area shape="circle" href="#" coords="354,187,3" title="X=52, Y=24" >'+
  5050. '<area shape="circle" href="#" coords="354,185,3" title="X=52, Y=25" >'+
  5051. '<area shape="circle" href="#" coords="354,183,3" title="X=52, Y=26" >'+
  5052. '<area shape="circle" href="#" coords="354,181,3" title="X=52, Y=27" >'+
  5053. '<area shape="circle" href="#" coords="354,179,3" title="X=52, Y=28" >'+
  5054. '<area shape="circle" href="#" coords="354,177,3" title="X=52, Y=29" >'+
  5055. '<area shape="circle" href="#" coords="354,175,3" title="X=52, Y=30" >'+
  5056. '<area shape="circle" href="#" coords="356,203,3" title="X=53, Y=16" >'+
  5057. '<area shape="circle" href="#" coords="356,201,3" title="X=53, Y=17" >'+
  5058. '<area shape="circle" href="#" coords="356,199,3" title="X=53, Y=18" >'+
  5059. '<area shape="circle" href="#" coords="356,197,3" title="X=53, Y=19" >'+
  5060. '<area shape="circle" href="#" coords="356,195,3" title="X=53, Y=20" >'+
  5061. '<area shape="circle" href="#" coords="356,193,3" title="X=53, Y=21" >'+
  5062. '<area shape="circle" href="#" coords="356,191,3" title="X=53, Y=22" >'+
  5063. '<area shape="circle" href="#" coords="356,189,3" title="X=53, Y=23" >'+
  5064. '<area shape="circle" href="#" coords="356,187,3" title="X=53, Y=24" >'+
  5065. '<area shape="circle" href="#" coords="356,185,3" title="X=53, Y=25" >'+
  5066. '<area shape="circle" href="#" coords="356,183,3" title="X=53, Y=26" >'+
  5067. '<area shape="circle" href="#" coords="356,181,3" title="X=53, Y=27" >'+
  5068. '<area shape="circle" href="#" coords="356,179,3" title="X=53, Y=28" >'+
  5069. '<area shape="circle" href="#" coords="356,177,3" title="X=53, Y=29" >'+
  5070. '<area shape="circle" href="#" coords="356,175,3" title="X=53, Y=30" >'+
  5071. '<area shape="circle" href="#" coords="356,173,3" title="X=53, Y=31" >'+
  5072. '<area shape="circle" href="#" coords="358,203,3" title="X=54, Y=16" >'+
  5073. '<area shape="circle" href="#" coords="358,201,3" title="X=54, Y=17" >'+
  5074. '<area shape="circle" href="#" coords="358,199,3" title="X=54, Y=18" >'+
  5075. '<area shape="circle" href="#" coords="358,197,3" title="X=54, Y=19" >'+
  5076. '<area shape="circle" href="#" coords="358,195,3" title="X=54, Y=20" >'+
  5077. '<area shape="circle" href="#" coords="358,193,3" title="X=54, Y=21" >'+
  5078. '<area shape="circle" href="#" coords="358,191,3" title="X=54, Y=22" >'+
  5079. '<area shape="circle" href="#" coords="358,189,3" title="X=54, Y=23" >'+
  5080. '<area shape="circle" href="#" coords="358,187,3" title="X=54, Y=24" >'+
  5081. '<area shape="circle" href="#" coords="358,185,3" title="X=54, Y=25" >'+
  5082. '<area shape="circle" href="#" coords="358,183,3" title="X=54, Y=26" >'+
  5083. '<area shape="circle" href="#" coords="358,181,3" title="X=54, Y=27" >'+
  5084. '<area shape="circle" href="#" coords="358,179,3" title="X=54, Y=28" >'+
  5085. '<area shape="circle" href="#" coords="358,177,3" title="X=54, Y=29" >'+
  5086. '<area shape="circle" href="#" coords="358,175,3" title="X=54, Y=30" >'+
  5087. '<area shape="circle" href="#" coords="358,173,3" title="X=54, Y=31" >'+
  5088. '<area shape="circle" href="#" coords="360,205,3" title="X=55, Y=15" >'+
  5089. '<area shape="circle" href="#" coords="360,203,3" title="X=55, Y=16" >'+
  5090. '<area shape="circle" href="#" coords="360,201,3" title="X=55, Y=17" >'+
  5091. '<area shape="circle" href="#" coords="360,199,3" title="X=55, Y=18" >'+
  5092. '<area shape="circle" href="#" coords="360,197,3" title="X=55, Y=19" >'+
  5093. '<area shape="circle" href="#" coords="360,195,3" title="X=55, Y=20" >'+
  5094. '<area shape="circle" href="#" coords="360,193,3" title="X=55, Y=21" >'+
  5095. '<area shape="circle" href="#" coords="360,191,3" title="X=55, Y=22" >'+
  5096. '<area shape="circle" href="#" coords="360,189,3" title="X=55, Y=23" >'+
  5097. '<area shape="circle" href="#" coords="360,187,3" title="X=55, Y=24" >'+
  5098. '<area shape="circle" href="#" coords="360,185,3" title="X=55, Y=25" >'+
  5099. '<area shape="circle" href="#" coords="360,183,3" title="X=55, Y=26" >'+
  5100. '<area shape="circle" href="#" coords="360,181,3" title="X=55, Y=27" >'+
  5101. '<area shape="circle" href="#" coords="360,179,3" title="X=55, Y=28" >'+
  5102. '<area shape="circle" href="#" coords="360,177,3" title="X=55, Y=29" >'+
  5103. '<area shape="circle" href="#" coords="360,175,3" title="X=55, Y=30" >'+
  5104. '<area shape="circle" href="#" coords="360,173,3" title="X=55, Y=31" >'+
  5105. '<area shape="circle" href="#" coords="360,171,3" title="X=55, Y=32" >'+
  5106. '<area shape="circle" href="#" coords="362,205,3" title="X=56, Y=15" >'+
  5107. '<area shape="circle" href="#" coords="362,203,3" title="X=56, Y=16" >'+
  5108. '<area shape="circle" href="#" coords="362,201,3" title="X=56, Y=17" >'+
  5109. '<area shape="circle" href="#" coords="362,199,3" title="X=56, Y=18" >'+
  5110. '<area shape="circle" href="#" coords="362,197,3" title="X=56, Y=19" >'+
  5111. '<area shape="circle" href="#" coords="362,195,3" title="X=56, Y=20" >'+
  5112. '<area shape="circle" href="#" coords="362,193,3" title="X=56, Y=21" >'+
  5113. '<area shape="circle" href="#" coords="362,191,3" title="X=56, Y=22" >'+
  5114. '<area shape="circle" href="#" coords="362,189,3" title="X=56, Y=23" >'+
  5115. '<area shape="circle" href="#" coords="362,187,3" title="X=56, Y=24" >'+
  5116. '<area shape="circle" href="#" coords="362,185,3" title="X=56, Y=25" >'+
  5117. '<area shape="circle" href="#" coords="362,183,3" title="X=56, Y=26" >'+
  5118. '<area shape="circle" href="#" coords="362,181,3" title="X=56, Y=27" >'+
  5119. '<area shape="circle" href="#" coords="362,179,3" title="X=56, Y=28" >'+
  5120. '<area shape="circle" href="#" coords="362,177,3" title="X=56, Y=29" >'+
  5121. '<area shape="circle" href="#" coords="362,175,3" title="X=56, Y=30" >'+
  5122. '<area shape="circle" href="#" coords="362,173,3" title="X=56, Y=31" >'+
  5123. '<area shape="circle" href="#" coords="362,171,3" title="X=56, Y=32" >'+
  5124. '<area shape="circle" href="#" coords="364,205,3" title="X=57, Y=15" >'+
  5125. '<area shape="circle" href="#" coords="364,203,3" title="X=57, Y=16" >'+
  5126. '<area shape="circle" href="#" coords="364,201,3" title="X=57, Y=17" >'+
  5127. '<area shape="circle" href="#" coords="364,199,3" title="X=57, Y=18" >'+
  5128. '<area shape="circle" href="#" coords="364,197,3" title="X=57, Y=19" >'+
  5129. '<area shape="circle" href="#" coords="364,195,3" title="X=57, Y=20" >'+
  5130. '<area shape="circle" href="#" coords="364,193,3" title="X=57, Y=21" >'+
  5131. '<area shape="circle" href="#" coords="364,191,3" title="X=57, Y=22" >'+
  5132. '<area shape="circle" href="#" coords="364,189,3" title="X=57, Y=23" >'+
  5133. '<area shape="circle" href="#" coords="364,187,3" title="X=57, Y=24" >'+
  5134. '<area shape="circle" href="#" coords="364,185,3" title="X=57, Y=25" >'+
  5135. '<area shape="circle" href="#" coords="364,183,3" title="X=57, Y=26" >'+
  5136. '<area shape="circle" href="#" coords="364,181,3" title="X=57, Y=27" >'+
  5137. '<area shape="circle" href="#" coords="364,179,3" title="X=57, Y=28" >'+
  5138. '<area shape="circle" href="#" coords="364,177,3" title="X=57, Y=29" >'+
  5139. '<area shape="circle" href="#" coords="364,175,3" title="X=57, Y=30" >'+
  5140. '<area shape="circle" href="#" coords="364,173,3" title="X=57, Y=31" >'+
  5141. '<area shape="circle" href="#" coords="364,171,3" title="X=57, Y=32" >'+
  5142. '<area shape="circle" href="#" coords="366,205,3" title="X=58, Y=15" >'+
  5143. '<area shape="circle" href="#" coords="366,203,3" title="X=58, Y=16" >'+
  5144. '<area shape="circle" href="#" coords="366,201,3" title="X=58, Y=17" >'+
  5145. '<area shape="circle" href="#" coords="366,199,3" title="X=58, Y=18" >'+
  5146. '<area shape="circle" href="#" coords="366,197,3" title="X=58, Y=19" >'+
  5147. '<area shape="circle" href="#" coords="366,195,3" title="X=58, Y=20" >'+
  5148. '<area shape="circle" href="#" coords="366,193,3" title="X=58, Y=21" >'+
  5149. '<area shape="circle" href="#" coords="366,191,3" title="X=58, Y=22" >'+
  5150. '<area shape="circle" href="#" coords="366,189,3" title="X=58, Y=23" >'+
  5151. '<area shape="circle" href="#" coords="366,187,3" title="X=58, Y=24" >'+
  5152. '<area shape="circle" href="#" coords="366,185,3" title="X=58, Y=25" >'+
  5153. '<area shape="circle" href="#" coords="366,183,3" title="X=58, Y=26" >'+
  5154. '<area shape="circle" href="#" coords="366,181,3" title="X=58, Y=27" >'+
  5155. '<area shape="circle" href="#" coords="366,179,3" title="X=58, Y=28" >'+
  5156. '<area shape="circle" href="#" coords="366,177,3" title="X=58, Y=29" >'+
  5157. '<area shape="circle" href="#" coords="366,175,3" title="X=58, Y=30" >'+
  5158. '<area shape="circle" href="#" coords="366,173,3" title="X=58, Y=31" >'+
  5159. '<area shape="circle" href="#" coords="366,171,3" title="X=58, Y=32" >'+
  5160. '<area shape="circle" href="#" coords="368,203,3" title="X=59, Y=16" >'+
  5161. '<area shape="circle" href="#" coords="368,201,3" title="X=59, Y=17" >'+
  5162. '<area shape="circle" href="#" coords="368,199,3" title="X=59, Y=18" >'+
  5163. '<area shape="circle" href="#" coords="368,197,3" title="X=59, Y=19" >'+
  5164. '<area shape="circle" href="#" coords="368,195,3" title="X=59, Y=20" >'+
  5165. '<area shape="circle" href="#" coords="368,193,3" title="X=59, Y=21" >'+
  5166. '<area shape="circle" href="#" coords="368,191,3" title="X=59, Y=22" >'+
  5167. '<area shape="circle" href="#" coords="368,189,3" title="X=59, Y=23" >'+
  5168. '<area shape="circle" href="#" coords="368,187,3" title="X=59, Y=24" >'+
  5169. '<area shape="circle" href="#" coords="368,185,3" title="X=59, Y=25" >'+
  5170. '<area shape="circle" href="#" coords="368,183,3" title="X=59, Y=26" >'+
  5171. '<area shape="circle" href="#" coords="368,181,3" title="X=59, Y=27" >'+
  5172. '<area shape="circle" href="#" coords="368,179,3" title="X=59, Y=28" >'+
  5173. '<area shape="circle" href="#" coords="368,177,3" title="X=59, Y=29" >'+
  5174. '<area shape="circle" href="#" coords="368,175,3" title="X=59, Y=30" >'+
  5175. '<area shape="circle" href="#" coords="368,173,3" title="X=59, Y=31" >'+
  5176. '<area shape="circle" href="#" coords="370,203,3" title="X=60, Y=16" >'+
  5177. '<area shape="circle" href="#" coords="370,201,3" title="X=60, Y=17" >'+
  5178. '<area shape="circle" href="#" coords="370,199,3" title="X=60, Y=18" >'+
  5179. '<area shape="circle" href="#" coords="370,197,3" title="X=60, Y=19" >'+
  5180. '<area shape="circle" href="#" coords="370,195,3" title="X=60, Y=20" >'+
  5181. '<area shape="circle" href="#" coords="370,193,3" title="X=60, Y=21" >'+
  5182. '<area shape="circle" href="#" coords="370,191,3" title="X=60, Y=22" >'+
  5183. '<area shape="circle" href="#" coords="370,189,3" title="X=60, Y=23" >'+
  5184. '<area shape="circle" href="#" coords="370,187,3" title="X=60, Y=24" >'+
  5185. '<area shape="circle" href="#" coords="370,185,3" title="X=60, Y=25" >'+
  5186. '<area shape="circle" href="#" coords="370,183,3" title="X=60, Y=26" >'+
  5187. '<area shape="circle" href="#" coords="370,181,3" title="X=60, Y=27" >'+
  5188. '<area shape="circle" href="#" coords="370,179,3" title="X=60, Y=28" >'+
  5189. '<area shape="circle" href="#" coords="370,177,3" title="X=60, Y=29" >'+
  5190. '<area shape="circle" href="#" coords="370,175,3" title="X=60, Y=30" >'+
  5191. '<area shape="circle" href="#" coords="370,173,3" title="X=60, Y=31" >'+
  5192. '<area shape="circle" href="#" coords="372,201,3" title="X=61, Y=17" >'+
  5193. '<area shape="circle" href="#" coords="372,199,3" title="X=61, Y=18" >'+
  5194. '<area shape="circle" href="#" coords="372,197,3" title="X=61, Y=19" >'+
  5195. '<area shape="circle" href="#" coords="372,195,3" title="X=61, Y=20" >'+
  5196. '<area shape="circle" href="#" coords="372,193,3" title="X=61, Y=21" >'+
  5197. '<area shape="circle" href="#" coords="372,191,3" title="X=61, Y=22" >'+
  5198. '<area shape="circle" href="#" coords="372,189,3" title="X=61, Y=23" >'+
  5199. '<area shape="circle" href="#" coords="372,187,3" title="X=61, Y=24" >'+
  5200. '<area shape="circle" href="#" coords="372,185,3" title="X=61, Y=25" >'+
  5201. '<area shape="circle" href="#" coords="372,183,3" title="X=61, Y=26" >'+
  5202. '<area shape="circle" href="#" coords="372,181,3" title="X=61, Y=27" >'+
  5203. '<area shape="circle" href="#" coords="372,179,3" title="X=61, Y=28" >'+
  5204. '<area shape="circle" href="#" coords="372,177,3" title="X=61, Y=29" >'+
  5205. '<area shape="circle" href="#" coords="372,175,3" title="X=61, Y=30" >'+
  5206. '<area shape="circle" href="#" coords="374,201,3" title="X=62, Y=17" >'+
  5207. '<area shape="circle" href="#" coords="374,199,3" title="X=62, Y=18" >'+
  5208. '<area shape="circle" href="#" coords="374,197,3" title="X=62, Y=19" >'+
  5209. '<area shape="circle" href="#" coords="374,195,3" title="X=62, Y=20" >'+
  5210. '<area shape="circle" href="#" coords="374,193,3" title="X=62, Y=21" >'+
  5211. '<area shape="circle" href="#" coords="374,191,3" title="X=62, Y=22" >'+
  5212. '<area shape="circle" href="#" coords="374,189,3" title="X=62, Y=23" >'+
  5213. '<area shape="circle" href="#" coords="374,187,3" title="X=62, Y=24" >'+
  5214. '<area shape="circle" href="#" coords="374,185,3" title="X=62, Y=25" >'+
  5215. '<area shape="circle" href="#" coords="374,183,3" title="X=62, Y=26" >'+
  5216. '<area shape="circle" href="#" coords="374,181,3" title="X=62, Y=27" >'+
  5217. '<area shape="circle" href="#" coords="374,179,3" title="X=62, Y=28" >'+
  5218. '<area shape="circle" href="#" coords="374,177,3" title="X=62, Y=29" >'+
  5219. '<area shape="circle" href="#" coords="374,175,3" title="X=62, Y=30" >'+
  5220. '<area shape="circle" href="#" coords="376,199,3" title="X=63, Y=18" >'+
  5221. '<area shape="circle" href="#" coords="376,197,3" title="X=63, Y=19" >'+
  5222. '<area shape="circle" href="#" coords="376,195,3" title="X=63, Y=20" >'+
  5223. '<area shape="circle" href="#" coords="376,193,3" title="X=63, Y=21" >'+
  5224. '<area shape="circle" href="#" coords="376,191,3" title="X=63, Y=22" >'+
  5225. '<area shape="circle" href="#" coords="376,189,3" title="X=63, Y=23" >'+
  5226. '<area shape="circle" href="#" coords="376,187,3" title="X=63, Y=24" >'+
  5227. '<area shape="circle" href="#" coords="376,185,3" title="X=63, Y=25" >'+
  5228. '<area shape="circle" href="#" coords="376,183,3" title="X=63, Y=26" >'+
  5229. '<area shape="circle" href="#" coords="376,181,3" title="X=63, Y=27" >'+
  5230. '<area shape="circle" href="#" coords="376,179,3" title="X=63, Y=28" >'+
  5231. '<area shape="circle" href="#" coords="376,177,3" title="X=63, Y=29" >'+
  5232. '<area shape="circle" href="#" coords="378,195,3" title="X=64, Y=20" >'+
  5233. '<area shape="circle" href="#" coords="378,193,3" title="X=64, Y=21" >'+
  5234. '<area shape="circle" href="#" coords="378,191,3" title="X=64, Y=22" >'+
  5235. '<area shape="circle" href="#" coords="378,189,3" title="X=64, Y=23" >'+
  5236. '<area shape="circle" href="#" coords="378,187,3" title="X=64, Y=24" >'+
  5237. '<area shape="circle" href="#" coords="378,185,3" title="X=64, Y=25" >'+
  5238. '<area shape="circle" href="#" coords="378,183,3" title="X=64, Y=26" >'+
  5239. '<area shape="circle" href="#" coords="378,181,3" title="X=64, Y=27" >'+
  5240. '<area shape="circle" href="#" coords="380,191,3" title="X=65, Y=22" >'+
  5241. '<area shape="circle" href="#" coords="380,189,3" title="X=65, Y=23" >'+
  5242. '<area shape="circle" href="#" coords="380,187,3" title="X=65, Y=24" >'+
  5243. '<area shape="circle" href="#" coords="380,185,3" title="X=65, Y=25" >'+
  5244. '</map>';
  5245.  
  5246. var nvspan = document.createElement('div');
  5247. nvspan.align = 'center';
  5248. nvspan.id = 'mz_mapdiv';
  5249. nvspan.valign = 'top';
  5250. nvspan.innerHTML = nvdiv;
  5251. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  5252. var footer = document.getElementById('footer1');
  5253. footer.parentNode.insertBefore(nvspan,footer);
  5254. }
  5255.  
  5256. function testeGlissiere() {
  5257. try {
  5258. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  5259. var footer = document.getElementById('footer1');
  5260. footer.parentNode.insertBefore(gliss.getElt(), footer);
  5261. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  5262. }
  5263.  
  5264. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  5265. if (x0 !== undefined) {
  5266. // ouais, récursif une fois
  5267. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  5268. if (PtInterm === undefined)
  5269. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  5270. else
  5271. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  5272. return;
  5273. }
  5274. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  5275. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  5276. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  5277. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  5278. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  5279. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  5280. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  5281. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  5282. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  5283. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  5284. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  5285. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  5286. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  5287. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  5288. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  5289. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  5290. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  5291. }
  5292.  
  5293. function do_ordresgowap() {
  5294. if (newCarte) {
  5295. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  5296. //testeGlissiere();
  5297. //MZ_testsUnitairesCalculIntermediaire();
  5298. } else {
  5299. setCarteGogo(); // Via script des trouillots
  5300. }
  5301. }
  5302.  
  5303. function do_listegowap() {
  5304. if (!newCarte) return;
  5305. MZ_setCarteTousGogoHTML5();
  5306. }
  5307.  
  5308. function do_lieuDescription() {
  5309. if (!newCarte) return;
  5310. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  5311. MZ_setCarteTP();
  5312. }
  5313.  
  5314. function do_lieuTeleport() {
  5315. changeButtonValidate();
  5316. if (!newCarte) return;
  5317. MZ_setCarteTP();
  5318. }
  5319.  
  5320. /*********************************************************************************
  5321. * This file is part of Mountyzilla. *
  5322. * *
  5323. * Mountyzilla is free software; you can redistribute it and/or modify *
  5324. * it under the terms of the GNU General Public License as published by *
  5325. * the Free Software Foundation; either version 2 of the License, or *
  5326. * (at your option) any later version. *
  5327. * *
  5328. * Mountyzilla is distributed in the hope that it will be useful, *
  5329. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5330. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5331. * GNU General Public License for more details. *
  5332. * *
  5333. * You should have received a copy of the GNU General Public License *
  5334. * along with Mountyzilla; if not, write to the Free Software *
  5335. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5336. *********************************************************************************/
  5337.  
  5338. // x~x attaque
  5339.  
  5340. // Script désactivé en attendant la màj vers le nouveau système de missions.
  5341.  
  5342. function do_attaque() {
  5343. }
  5344.  
  5345. /*******************************************************************************
  5346. * This file is part of Mountyzilla. *
  5347. * *
  5348. * Mountyzilla is free software; you can redistribute it and/or modify *
  5349. * it under the terms of the GNU General Public License as published by *
  5350. * the Free Software Foundation; either version 2 of the License, or *
  5351. * (at your option) any later version. *
  5352. * *
  5353. * Mountyzilla is distributed in the hope that it will be useful, *
  5354. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5355. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5356. * GNU General Public License for more details. *
  5357. * *
  5358. * You should have received a copy of the GNU General Public License *
  5359. * along with Mountyzilla; if not, write to the Free Software *
  5360. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5361. *******************************************************************************/
  5362.  
  5363. // x~x infomonstre
  5364.  
  5365. // DEBUG
  5366. var nomMonstre='';
  5367. var idMonstre=-1;
  5368. //var tbody;
  5369. var popup;
  5370.  
  5371. function traiteMonstre() {
  5372. try {
  5373. var nodeTitre = document.evaluate(
  5374. "//div[@class='titre2' and contains(text(),'(')]",
  5375. document, null, 9, null
  5376. ).singleNodeValue;
  5377. var texte = nodeTitre.firstChild.nodeValue;
  5378. } catch(e) {
  5379. window.console.log(traceStack(e, 'traiteMonstre'));
  5380. return;
  5381. }
  5382.  
  5383. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  5384. if(nomMonstre.indexOf(']')!=-1) {
  5385. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  5386. }
  5387. idMonstre = texte.match(/\d+/)[0];
  5388. var tReq = [{'index':1, 'id':+idMonstre, 'nom':nomMonstre}]; // "+" pour forcer du numérique
  5389. FF_XMLHttpRequest({
  5390. method: 'POST',
  5391. url: URL_MZgetCaracMonstre,
  5392. headers : {
  5393. 'Content-type':'application/x-www-form-urlencoded'
  5394. },
  5395. data: 'l=' + JSON.stringify(tReq),
  5396. trace: 'demande niveaux monstres V2, MonsterView',
  5397. onload: function(responseDetails) {
  5398. try {
  5399. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  5400. if (responseDetails.status == 0) return;
  5401. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  5402. var texte = responseDetails.responseText;
  5403. var infosRet = JSON.parse(texte);
  5404. if(infosRet.length==0) return;
  5405. var info = infosRet[0];
  5406. MZ_EtatCdMs.listeCDM[idMonstre]=info;
  5407. try {
  5408. var nodeInsert = document.evaluate(
  5409. "//div[@class = 'titre3']",
  5410. document, null, 9, null
  5411. ).singleNodeValue;
  5412. } catch(e) {
  5413. window.console.log(traceStack(e, 'recherche node pour info CdM'));
  5414. return;
  5415. }
  5416. var table = createCDMTable(idMonstre,nomMonstre,info);
  5417. table.align = 'center';
  5418. var tbody = table.childNodes[1];
  5419. var thead = table.childNodes[0];
  5420. var tdEntete = thead.firstChild.firstChild;
  5421. tdEntete.onclick = toggleTableau;
  5422. tdEntete.style.cursor = 'pointer';
  5423. thead.firstChild.style = 'mh_tdpage';
  5424. tbody.style.display = 'none';
  5425. table.style.width = '350px';
  5426. insertBefore(nodeInsert,table);
  5427. } catch(e) {
  5428. window.console.log(e);
  5429. }
  5430. },
  5431. });
  5432. }
  5433.  
  5434. function initPopupInfomonstre() {
  5435. // Initialise le popup tactique (calculs att/deg)
  5436. popup = document.createElement('div');
  5437. popup.id = 'popup';
  5438. popup.className = 'mh_textbox';
  5439. popup.style =
  5440. 'position: absolute;'+
  5441. 'border: 1px solid #000000;'+
  5442. 'visibility: hidden;'+
  5443. 'display: inline;'+
  5444. 'z-index: 3;'+
  5445. 'max-width: 400px;';
  5446. document.body.appendChild(popup);
  5447. }
  5448.  
  5449. function showPopupTactique(evt) {
  5450. try {
  5451. var id = this.id;
  5452. var nom = this.nom;
  5453. var texte = getAnalyseTactique(id,nom);
  5454. if(texte==undefined || texte=='') { return; }
  5455. popup.innerHTML = texte;
  5456. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  5457. if(isPage("View/MonsterView")) {
  5458. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  5459. } else {
  5460. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  5461. }
  5462. popup.style.top = evt.pageY+15+'px';
  5463. popup.style.visibility = 'visible';
  5464. } catch(e) {
  5465. //window.alert(e);
  5466. window.console.log(e);
  5467. }
  5468. }
  5469.  
  5470. function toggleTableau() { // click sur un td de thead
  5471. var tbody = this.parentNode.parentNode.parentNode.childNodes[1];
  5472. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  5473. }
  5474.  
  5475. function do_infomonstre() {
  5476. start_script();
  5477. try {
  5478. initPopupInfomonstre();
  5479. traiteMonstre();
  5480. } catch(e) {
  5481. window.console.error(traceStack(e, 'do_infomonstre'));
  5482. window.alert('Erreur infoMonstre:\n'+e);
  5483. }
  5484. displayScriptTime();
  5485. }
  5486.  
  5487. /***
  5488. *** SCIZ
  5489. ***/
  5490. var scizGlobal = {
  5491. events: []
  5492. };
  5493.  
  5494. function scizPrettyPrintEvent(e) {
  5495. 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
  5496. e.message = e.message.replace(/\n\s*\n*/g, '<br/>');
  5497. 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]];
  5498. beings.forEach(b => {
  5499. if (b[0] && b[1]) {
  5500. b[1] = b[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  5501. if (b[0].toString().length > 6) {
  5502. // Mob
  5503. b[1] = b[1].replace(/^une?\s/g, '');
  5504. e.message = e.message.replace(new RegExp('(' + b[1] + ')','gi'), '<b><a href="/mountyhall/View/MonsterView.php?ai_IDPJ=' + b[0] + '" rel="modal:open" class="mh_monstres">\$1</a></b>');
  5505. } else {
  5506. // Troll
  5507. e.message = e.message.replace(new RegExp('(' + b[1] + ')','gi'), '<b><a href="javascript:EPV(\'' + b[0] + '\')" class="mh_trolls_1">\$1</a></b>');
  5508. }
  5509. }
  5510. });
  5511. return e;
  5512. }
  5513.  
  5514. function do_scizOverwriteEvents() {
  5515. scizGlobal.events = [];
  5516. var eventTableNode = null;
  5517.  
  5518. // Ensure we have a JWT setup for the current user
  5519. jwt = MY_getValue(numTroll + '.SCIZJWT');
  5520. if (!jwt) { return; }
  5521.  
  5522. // Retrieve being ID
  5523. const url = new URL(window.location.href);
  5524. var id = url.searchParams.get('ai_IDPJ');
  5525. id = (!id) ? numTroll : id;
  5526.  
  5527. // Check for advanced profil
  5528. const advanced = document.querySelector("[href*='MH_Style_ProfilAvance.css']") !== null;
  5529. const xPathQuery = (advanced) ? "//*/table[@id='events']/tbody/tr" : "//*/tr[@class='mh_tdpage']";
  5530.  
  5531. // Retrieve local events
  5532. var xPathEvents = document.evaluate(xPathQuery, document, null, 0, null);
  5533. while (xPathEvent = xPathEvents.iterateNext()) {
  5534. scizGlobal.events.push({
  5535. 'time': Date.parse(StringToDate(xPathEvent.children[0].innerHTML)),
  5536. 'type': xPathEvent.children[1].innerHTML,
  5537. 'desc': xPathEvent.children[2].innerHTML,
  5538. 'sciz_desc': null,
  5539. 'node': xPathEvent,
  5540. });
  5541. if (eventTableNode === null) {
  5542. eventTableNode = xPathEvent.parentNode.parentNode;
  5543. }
  5544. }
  5545. const interval = 5000; // Maximum interval (seconds) for matching some events
  5546. const startTime = Math.min.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) - interval;
  5547. const endTime = Math.max.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) + interval;
  5548.  
  5549. // Check if events have been found in the page
  5550. if (scizGlobal.events.length < 1) {
  5551. window.console.log('ERREUR - MZ/SCIZ - Aucun événement trouvé sur la page...');
  5552. return;
  5553. }
  5554.  
  5555. // Call SCIZ
  5556. var sciz_url = 'https://www.sciz.fr/api/hook/events/' + id + '/' + startTime + '/' + endTime;
  5557. const eventType = url.searchParams.get('as_EventType'); // Retrieve event type filter
  5558. sciz_url += (eventType !== null && eventType !== '') ? '/' + eventType.split(' ')[0] : '' // Only the first word used for filtering ("MORT par monstre" => "MORT");
  5559. FF_XMLHttpRequest({
  5560. method: 'GET',
  5561. url: sciz_url,
  5562. headers : { 'Authorization': jwt },
  5563. // trace: 'Appel à SCIZ pour l'entité ' + id,
  5564. onload: function(responseDetails) {
  5565. try {
  5566. if (responseDetails.status == 0) {
  5567. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5568. window.console.log(responseDetails);
  5569. return;
  5570. }
  5571. var events = JSON.parse(responseDetails.responseText);
  5572. if (events.events.length < 1) {
  5573. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5574. return;
  5575. }
  5576. // Look for events to overwrite (based on timestamps)
  5577. events.events.forEach(e => {
  5578. if (e.message.includes(id)) { // Exclude any event we were not looking for...
  5579. const t = Date.parse(StringToDate(e.time));
  5580. // Look for the best event matching and not already replaced
  5581. var i = -1;
  5582. var lastDelta = Infinity;
  5583. for (j = 0; j < scizGlobal.events.length; j++) {
  5584. if (scizGlobal.events[j].sciz_desc === null) {
  5585. var delta = Math.abs(t - scizGlobal.events[j].time);
  5586. if (delta <= interval && delta < lastDelta) {
  5587. lastDelta = delta;
  5588. i = j;
  5589. }
  5590. }
  5591. }
  5592. if (i > -1) {
  5593. // PrettyPrint
  5594. e = scizPrettyPrintEvent(e);
  5595. // Store the SCIZ event
  5596. scizGlobal.events[i].sciz_desc = e.message;
  5597. // Actual display overwrite
  5598. scizGlobal.events[i].node.children[2].innerHTML = scizGlobal.events[i].sciz_desc;
  5599. }
  5600. }
  5601. });
  5602. // Add the switch button
  5603. if (eventTableNode !== null) {
  5604. var img = document.createElement('img');
  5605. img.src = 'https://www.sciz.fr/static/104126/sciz-logo-quarter.png';
  5606. img.alt = 'SCIZ logo';
  5607. img.style = 'height: 50px; cursor: pointer;';
  5608. img.onclick = do_scizSwitchEvents;
  5609. var div = document.createElement('div');
  5610. div.style = 'text-align: center;';
  5611. div.appendChild(img);
  5612. eventTableNode.parentNode.insertBefore(div, eventTableNode.nextSibling);
  5613. }
  5614. } catch(e) {
  5615. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5616. window.console.log(e);
  5617. }
  5618. }
  5619. });
  5620. }
  5621.  
  5622. function do_scizSwitchEvents() {
  5623. scizGlobal.events.forEach((e) => {
  5624. const currentDesc = e.node.children[2].innerHTML;
  5625. e.node.children[2].innerHTML = (currentDesc === e.desc) ? ((e.sciz_desc !== null) ? e.sciz_desc : e.desc) : e.desc;
  5626. });
  5627. }
  5628.  
  5629. /*******************************************************************************
  5630. * This file is part of Mountyzilla. *
  5631. * *
  5632. * Mountyzilla is free software; you can redistribute it and/or modify *
  5633. * it under the terms of the GNU General Public License as published by *
  5634. * the Free Software Foundation; either version 2 of the License, or *
  5635. * (at your option) any later version. *
  5636. * *
  5637. * Mountyzilla is distributed in the hope that it will be useful, *
  5638. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5639. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5640. * GNU General Public License for more details. *
  5641. * *
  5642. * You should have received a copy of the GNU General Public License *
  5643. * along with Mountyzilla; if not, write to the Free Software *
  5644. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5645. *******************************************************************************/
  5646.  
  5647. // x~x mission
  5648.  
  5649. /* TODO
  5650. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  5651. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  5652. *
  5653. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  5654. */
  5655. function isArray(a) {
  5656. return (!!a) && (a.constructor === Array);
  5657. }
  5658.  
  5659. function saveMission(num,obEtape) {
  5660. var obMissions;
  5661. if(MY_getValue(numTroll+'.MISSIONS')) {
  5662. try {
  5663. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5664. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  5665. } catch(e) {
  5666. window.console.error(traceStack(e, 'Mission parsage'));
  5667. return;
  5668. }
  5669. }
  5670. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  5671. if (obMissions == undefined) obMissions = new Object(); // protection
  5672. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  5673. if(obEtape) {
  5674. obMissions[num] = obEtape;
  5675. } else if(obMissions[num]) {
  5676. delete obMissions[num];
  5677. }
  5678. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  5679. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5680. }
  5681.  
  5682. function addtroogle(tdLibelle, sRestrict) {
  5683. var img = document.createElement('img');
  5684. img.src = URL_MZimg + 'troogle.ico';
  5685. img.alt = 'Troogle logo';
  5686. var a = document.createElement('a');
  5687. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  5688. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  5689. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  5690. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  5691. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  5692. a.href = url;
  5693. a.title = 'Chercher sur Troogle';
  5694. a.target = 'troogle';
  5695. a.appendChild(img);
  5696. tdLibelle.appendChild(a);
  5697. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  5698. }
  5699.  
  5700. function traiteMission() {
  5701. try {
  5702. var titreMission = document.getElementsByClassName('titre2')[0];
  5703. var numMission = titreMission.textContent.match(/\d+/)[0];
  5704. var missionForm = document.getElementsByName('ActionForm')[0];
  5705. var tdLibelle = document.evaluate(
  5706. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  5707. missionForm, null, 9, null).singleNodeValue;
  5708. } catch(e) {
  5709. window.console.error(traceStack(e, 'récupération mission'));
  5710. return;
  5711. }
  5712. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  5713. try {
  5714. if(!tdLibelle) {
  5715. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  5716. debugMZ('traiteMission, la mission semble terminée');
  5717. saveMission(numMission,false);
  5718. return;
  5719. }
  5720.  
  5721. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  5722. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  5723. // debug Roule'
  5724. if (MY_DEBUG) {
  5725. for (var i =0; i < tdLibelle.childNodes.length; i++)
  5726. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  5727. }
  5728. if(libelle.indexOf('niveau égal à')!=-1) {
  5729. var nbKills = 1, niveau, mod;
  5730. // exemples :
  5731. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  5732. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  5733. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  5734. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  5735. if (tdLibelle.childNodes.length == 1) {
  5736. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  5737. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  5738. if (m) {
  5739. niveau = Number(m[1]);
  5740. mod = 'plus'
  5741. } else {
  5742. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  5743. if (m) {
  5744. niveau = Number(m[1]);
  5745. mod = Number(m[2]);
  5746. } else {
  5747. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  5748. return;
  5749. }
  5750. }
  5751. } else {
  5752. // ancienne méthode (multi childnode)
  5753. // à supprimer un jour peut-être
  5754. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  5755. // Étape de kill multiple de niveau donné
  5756. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5757. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  5758. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5759. niveau = Number(mod[0]);
  5760. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5761. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  5762. } else {
  5763. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  5764. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5765. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  5766. mod = mod ? Number(mod[0]) : 'plus';
  5767. }
  5768. } else {
  5769. // Étape de kill unique de niveau donné
  5770. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  5771. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5772. mod = mod ? Number(mod[0]) : 'plus';
  5773. }
  5774. }
  5775. // if (isDEV) {
  5776. // niveau = 35; // pour les tests Roule
  5777. // alert('niveau forcé à 35 pour test');
  5778. // }
  5779. // debug Roule'
  5780. if (MY_DEBUG) {
  5781. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  5782. }
  5783. saveMission(numMission,{
  5784. type: 'Niveau',
  5785. niveau: niveau,
  5786. mod: mod,
  5787. mundidey: siMundidey,
  5788. libelle: libelle
  5789. });
  5790. if (mod == 'plus')
  5791. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  5792. else
  5793. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  5794. } else if(libelle.indexOf('de la race')!=-1) {
  5795. var nbKills = 1, race;
  5796. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  5797. // Étape de kill multiple de race donnée
  5798. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5799. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5800. } else {
  5801. // Étape de kill unique de race donnée
  5802. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5803. }
  5804. race = race.replace(/\"/g,'');
  5805. race = removeEnclosingSimpleCote(race); // Roule 29/03/2019 Maintenant, on a des '
  5806. saveMission(numMission,{
  5807. type: 'Race',
  5808. race: race,
  5809. mundidey: siMundidey,
  5810. libelle: libelle
  5811. });
  5812. addtroogle(tdLibelle, '@monstre ' + race);
  5813. } else if(libelle.indexOf('de la famille')!=-1) {
  5814. var nbKills = 1, famille;
  5815. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  5816. // Étape de kill multiple de famille donnée
  5817. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5818. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5819. } else {
  5820. // Étape de kill unique de famille donnée
  5821. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5822. }
  5823. famille = famille.replace(/\"/g,'');
  5824. famille = removeEnclosingSimpleCote(famille); // Roule 29/03/2019 Maintenant, on a des '
  5825. saveMission(numMission,{
  5826. type: 'Famille',
  5827. famille: famille,
  5828. mundidey: siMundidey,
  5829. libelle: libelle
  5830. });
  5831. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  5832. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  5833. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  5834. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  5835. debugMZ('traiteMission étape capacité spéciale');
  5836. pouvoir = removeEnclosingSimpleCote(pouvoir); // Roule 29/03/2019 Maintenant, on a des '
  5837. saveMission(numMission,{
  5838. type: 'Pouvoir',
  5839. pouvoir: pouvoir,
  5840. libelle: libelle
  5841. });
  5842. } else {
  5843. debugMZ('traiteMission étape pas pour troogle');
  5844. saveMission(numMission,false);
  5845. }
  5846. } catch(e) {
  5847. window.console.error(traceStack(e, 'récupération étape mission'));
  5848. return;
  5849. }
  5850. }
  5851.  
  5852. function removeEnclosingSimpleCote(x) { // Roule 29/03/2019
  5853. return x.replace(/'$/, '').replace(/^'/, '');
  5854. }
  5855.  
  5856. function do_mission() {
  5857. start_script(60);
  5858.  
  5859. traiteMission();
  5860.  
  5861. displayScriptTime();
  5862. }
  5863.  
  5864. /*******************************************************************************
  5865. * This file is part of Mountyzilla. *
  5866. * *
  5867. * Mountyzilla is free software; you can redistribute it and/or modify *
  5868. * it under the terms of the GNU General Public License as published by *
  5869. * the Free Software Foundation; either version 2 of the License, or *
  5870. * (at your option) any later version. *
  5871. * *
  5872. * Mountyzilla is distributed in the hope that it will be useful, *
  5873. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5874. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5875. * GNU General Public License for more details. *
  5876. * *
  5877. * You should have received a copy of the GNU General Public License *
  5878. * along with Mountyzilla; if not, write to the Free Software *
  5879. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5880. *******************************************************************************/
  5881.  
  5882. // x~x move
  5883.  
  5884. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  5885.  
  5886. var petitsTrous = {
  5887. '-52;57': true,
  5888. '55;70': true,
  5889. '64;70': true,
  5890. '12;-15': true,
  5891. '30;-52': true,
  5892. '48;-39': true
  5893. };
  5894.  
  5895. var grosTrous = {
  5896. '-35;65': true,
  5897. '-13;73': true,
  5898. '-64;9': true,
  5899. '-35;15': true,
  5900. '5;32': true,
  5901. '10;64': true,
  5902. '21;36': true,
  5903. '46;52': true,
  5904. '74;32': true,
  5905. '-71;-7': true,
  5906. '-67;-37': true,
  5907. '-60;-32': true,
  5908. '-51;-22': true,
  5909. '-36;-51': true,
  5910. '5;-49': true
  5911. };
  5912.  
  5913. var centreCarmine_X = 56.5;
  5914. var centreCarmine_Y = 23.5;
  5915. var rayonCarmine = 8.7;
  5916.  
  5917. function isTrou(x,y,n) {
  5918. if(petitsTrous[x+';'+y]) {
  5919. return n<0 && n>-60;
  5920. }
  5921. if(grosTrous[x+';'+y]
  5922. || grosTrous[x-1+';'+y]
  5923. || grosTrous[x+';'+y+1]
  5924. || grosTrous[x-1+';'+y+1]) {
  5925. return n<0 && n>-70;
  5926. }
  5927. if(Math.sqrt(
  5928. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  5929. )<=rayonCarmine) {
  5930. return n<0 && n>-100;
  5931. }
  5932. return false;
  5933. }
  5934.  
  5935. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  5936.  
  5937. function validateDestination() {
  5938. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  5939. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  5940. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  5941. var form = document.getElementsByName('ActionForm')[0];
  5942. if(form) {
  5943. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  5944. if(document.getElementsByName('ai_DeplX')[i].checked) {
  5945. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  5946. }
  5947. }
  5948. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  5949. if(document.getElementsByName('ai_DeplY')[i].checked) {
  5950. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  5951. }
  5952. }
  5953. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  5954. if(document.getElementsByName('ai_DeplN')[i].checked) {
  5955. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  5956. }
  5957. }
  5958. if(isTrou(x,y,n)) {
  5959. return window.confirm(
  5960. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  5961. +'Vous allez tomber dans un trou de météorite.\n'
  5962. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  5963. );
  5964. }
  5965. }
  5966. return true;
  5967. }
  5968.  
  5969. function newsubmitDE(event) {
  5970. event.stopPropagation();
  5971. event.preventDefault();
  5972. if(validateDestination()) {
  5973. this.submit();
  5974. }
  5975. }
  5976.  
  5977. function changeValidation() {
  5978. var form = document.getElementsByName('ActionForm')[0];
  5979. if(form) {
  5980. form.addEventListener('submit', newsubmitDE, true);
  5981. }
  5982. }
  5983.  
  5984.  
  5985. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  5986.  
  5987. function validateTPDestination() {
  5988. try {
  5989. var text = document.getElementsByTagName('B')[0];
  5990. var a = text.firstChild.nodeValue.split('|');
  5991. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  5992. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  5993. var pos_n = a[2].substring(5, a[2].length) * 1;
  5994.  
  5995. var nbtrous = 0;
  5996. for(var signX=-1 ; signX<=1 ; signX+=2) {
  5997. for(var x=0 ; x<=2 ; x++) {
  5998. for(var signY=-1 ; signY<=1 ; signY+=2) {
  5999. for(var y=0 ; y<=2 ; y++) {
  6000. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  6001. for(var n = 0 ; n <= 1 ; n++) {
  6002. if(isTrou(
  6003. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  6004. )) {
  6005. nbtrous++;
  6006. }
  6007. }
  6008. }
  6009. }
  6010. }
  6011. }
  6012. }
  6013. if(nbtrous>0 && nbtrous<72) {
  6014. return window.confirm(
  6015. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  6016. +'Vous avez '+Math.floor((100*nbtrous)/144)
  6017. +'% de risque de tomber dans un trou de météorite.\n'
  6018. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  6019. );
  6020. }
  6021. else if(nbtrous>=72) {
  6022. return window.confirm(
  6023. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  6024. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  6025. +'% de risque de tomber dans un trou de météorite !\n'
  6026. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  6027. );
  6028. }
  6029. return true;
  6030. }
  6031. catch(e) {
  6032. window.alert(e)
  6033. }
  6034. }
  6035.  
  6036. function newsubmitTP(event) {
  6037. event.stopPropagation();
  6038. event.preventDefault();
  6039. if(validateTPDestination()) {
  6040. this.submit();
  6041. }
  6042. }
  6043.  
  6044. function changeButtonValidate() {
  6045. var form = document.getElementsByName('Formulaire')[0];
  6046. if(form) {
  6047. if(!form.getAttribute('onsubmit')) {
  6048. form.setAttribute('onsubmit','return true;');
  6049. }
  6050. form.addEventListener('submit', newsubmitTP, true);
  6051. }
  6052. }
  6053.  
  6054.  
  6055. /*-[functions]---------------- Partie Principale -----------------------------*/
  6056.  
  6057. function do_move() {
  6058. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  6059. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  6060. changeValidation();
  6061. //}
  6062. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  6063. // changeButtonValidate();
  6064. //}
  6065. }
  6066.  
  6067. /*******************************************************************************
  6068. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  6069. * Mountyzilla is free software; provided under the GNU General Public License *
  6070. *******************************************************************************/
  6071.  
  6072. // x~x news
  6073.  
  6074. // Nombre de news à afficher & nb max de caractères par news:
  6075. const nbItems = 5;
  6076. const maxCarDescription = 300;
  6077.  
  6078. /*-[functions]------------------- Utilitaires --------------------------------*/
  6079.  
  6080. // Ne semble avoir strictement aucun effet:
  6081. String.prototype.epureDescription = function() {
  6082. return this.replace(/\\(.)/g,"$1");
  6083. }
  6084.  
  6085. function appendTitledTable(node,titre,description) {
  6086. // Crée les tables contenant les infos (avec titre)
  6087. var table = document.createElement('table');
  6088. table.border = 0;
  6089. table.className = 'mh_tdborder';
  6090. table.cellSpacing = 1;
  6091. table.cellPadding = 1;
  6092. table.style.maxWidth = '98%';
  6093. table.style.marginLeft = 'auto';
  6094. table.style.marginRight = 'auto';
  6095. var tbody = document.createElement('tbody');
  6096. table.appendChild(tbody);
  6097. var tr = appendTr(tbody,'mh_tdtitre');
  6098. var td = appendTdCenter(tr,2);
  6099. var span = document.createElement('span');
  6100. appendText(span,titre,true);
  6101. if(description) {
  6102. span.title = description;
  6103. }
  6104. td.appendChild(span);
  6105. node.appendChild(table);
  6106. return tbody;
  6107. }
  6108.  
  6109. function testCertif(paramURL, callbackOnError) {
  6110. try {
  6111. FF_XMLHttpRequest({
  6112. method: 'GET',
  6113. url: paramURL,
  6114. onload: function(responseDetails) {
  6115. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  6116. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  6117. }
  6118. });
  6119. } catch(e) {
  6120. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  6121. callbackOnError();
  6122. }
  6123. }
  6124.  
  6125. function createOrGetGrandCadre() {
  6126. var grandCadre = document.getElementById('grandCadre');
  6127. if (grandCadre) return grandCadre;
  6128. try {
  6129. var rappels = document.evaluate(
  6130. "//p[contains(a/text(),'messagerie')]",
  6131. document, null, 9, null).singleNodeValue;
  6132. }
  6133. catch(e) {
  6134. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  6135. grandCadre = document.createElement('div');
  6136. return grandCadre;
  6137. }
  6138. grandCadre = document.createElement('div');
  6139. grandCadre.id = 'grandCadre';
  6140. var sousCadre = document.createElement('div');
  6141. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  6142. sousCadre.style.textAlign = 'center';
  6143. sousCadre.style.fontSize = 'xx-large';
  6144. grandCadre.appendChild(sousCadre);
  6145.  
  6146. grandCadre.style.border = 'solid 5px red';
  6147. grandCadre.style.width = 'auto';
  6148. insertBefore(rappels,grandCadre);
  6149. return grandCadre;
  6150. }
  6151.  
  6152. function showHttpsErrorCadre1() {
  6153. window.console.log('[MZ] showHttpsErrorCadre1');
  6154. var grandCadre = createOrGetGrandCadre();
  6155. var sousCadre = document.createElement('div');
  6156. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  6157. + '<br />Cela empêchera Moutyzilla de fonctionner'
  6158. + '<br /><a style="color:blue;font-size: inherits;" href="'
  6159. + URL_CertifRaistlin1
  6160. + '" target="raistlin">clique ici</a>'
  6161. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6162. + ' « Confirmer l\'exception de sécurité »'
  6163. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6164. sousCadre.style.width = 'auto';
  6165. sousCadre.style.fontSize = 'large';
  6166. sousCadre.style.border = 'solid 1px black';
  6167. sousCadre.style.backgroundColor = 'red';
  6168. grandCadre.appendChild(sousCadre);
  6169. }
  6170.  
  6171. function showHttpsErrorCadre2() {
  6172. window.console.log('[MZ] showHttpsErrorCadre2');
  6173. var grandCadre = createOrGetGrandCadre();
  6174. var sousCadre = document.createElement('div');
  6175. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  6176. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  6177. + '<a style="color:blue;font-size: inherits;" href="'
  6178. + URL_CertifRaistlin2
  6179. + '" target="raistlin">clique ici</a>'
  6180. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6181. + ' « Confirmer l\'exception de sécurité »'
  6182. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  6183. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6184. sousCadre.style.width = 'auto';
  6185. sousCadre.style.fontSize = 'large';
  6186. sousCadre.style.border = 'solid 1px black';
  6187. sousCadre.style.backgroundColor = 'red';
  6188. grandCadre.appendChild(sousCadre);
  6189. }
  6190.  
  6191. function showHttpsErrorContenuMixte() {
  6192. window.console.log('[MZ] showHttpsErrorContenuMixte');
  6193. var grandCadre = createOrGetGrandCadre();
  6194. var sousCadre = document.createElement('div');
  6195. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  6196. + '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)'
  6197. + '<ul>'
  6198. + '<li>Interface Bricol\'Troll</li>'
  6199. + '<li>Nouveautés de Mountyzilla</li>'
  6200. + '</ul>'
  6201. + '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 />'
  6202. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  6203. sousCadre.style.width = 'auto';
  6204. sousCadre.style.fontSize = 'large';
  6205. sousCadre.style.border = 'solid 1px black';
  6206. grandCadre.appendChild(sousCadre);
  6207. }
  6208.  
  6209. /*-[functions]------------------- Jubilaires ---------------------------------*/
  6210.  
  6211. function traiterJubilaires() {
  6212. // à faire
  6213. }
  6214.  
  6215. function traiterJubilaires_a_supprimer() { // ancienne méthode
  6216. try {
  6217. FF_XMLHttpRequest({
  6218. method: 'GET',
  6219. url: URL_anniv,
  6220. headers: {
  6221. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  6222. 'Accept': 'application/xml,text/xml',
  6223. },
  6224. onload: function(responseDetails) {
  6225. if ((responseDetails.status == 0) && isHTTPS) {
  6226. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  6227. //showHttpsErrorContenuMixte();
  6228. return;
  6229. }
  6230. var listeTrolls = responseDetails.responseText.split('\n');
  6231. if(!listeTrolls || listeTrolls.length==0) {
  6232. return;
  6233. }
  6234. afficherJubilaires(listeTrolls);
  6235. },
  6236. });
  6237. }
  6238. catch(e) {
  6239. if (isHTTPS) {
  6240. window.console.log(traceStack(e, 'appel jubilaires'));
  6241. showHttpsErrorContenuMixte();
  6242. } else {
  6243. window.alert('Erreur Jubilaires:\n'+e);
  6244. }
  6245. }
  6246. }
  6247.  
  6248. function afficherJubilaires(listeTrolls) {
  6249. try {
  6250. var rappels = document.evaluate(
  6251. "//p[contains(a/text(),'messagerie')]",
  6252. document, null, 9, null).singleNodeValue;
  6253. }
  6254. catch(e) {
  6255. return;
  6256. }
  6257. var p = document.createElement('p');
  6258. var tbody = appendTitledTable(p,
  6259. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  6260. 'Envoyez leur un message ou un cadeau !'
  6261. );
  6262. tr = appendTr(tbody,'mh_tdpage');
  6263. td = appendTdCenter(tr);
  6264. var small = document.createElement('small');
  6265. td.appendChild(small);
  6266. var first = true;
  6267. for(var i=0 ; i<listeTrolls.length ; i++) {
  6268. var infos = listeTrolls[i].split(';');
  6269. if(infos.length!=3 || infos[2]==='0') {
  6270. continue;
  6271. }
  6272. if(first) {
  6273. first = false;
  6274. }
  6275. else {
  6276. appendText(small,', ');
  6277. }
  6278. var a = document.createElement('a');
  6279. a.href = 'javascript:EPV('+infos[0]+')';
  6280. appendText(a,infos[1]);
  6281. small.appendChild(a);
  6282. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  6283. }
  6284. insertBefore(rappels,p);
  6285. }
  6286.  
  6287.  
  6288. /*-[functions]--------------------- News MZ ----------------------------------*/
  6289.  
  6290. function traiterNouvelles() {
  6291. var news = new Array;
  6292. news.push(['15/11/2019', 'Refonte des calculs tactiques dans la vue. Affichage du niveau du monstre à tout coup (ou presque).']);
  6293. 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 ;).']);
  6294. afficherNouvelles(news);
  6295. }
  6296.  
  6297. function afficherNouvelles(items) {
  6298. var footer = document.getElementById('footer1');
  6299. if(!footer) {
  6300. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  6301. return;
  6302. }
  6303. var p = document.createElement('p');
  6304. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  6305. var div = document.createElement('div');
  6306. div.style.position = 'absolute';
  6307. div.style.right = 0;
  6308. div.style.top = 0;
  6309. div.style.paddingRight = '3px';
  6310. div.style.whiteSpace = 'nowrap';
  6311. appendText(div, '(version ' + GM_info.script.version + ')');
  6312. tbody.rows[0].cells[0].style.position = 'relative';
  6313. tbody.rows[0].cells[0].appendChild(div);
  6314. for(var i=0 ; i<items.length ; i++) {
  6315. var tr = appendTr(tbody,'mh_tdpage');
  6316. var td = appendTdCenter(tr);
  6317. td.style.verticalAlign = 'top'; // semble sans effet
  6318. appendText(td,items[i][0],true);
  6319. td = appendTd(tr);
  6320. td.innerHTML = items[i][1];
  6321. }
  6322. insertBefore(footer,p);
  6323.  
  6324. // changelog
  6325. var p = document.createElement('p');
  6326. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  6327. tbody.rows[0].cells[0].style.cursor = 'pointer';
  6328. tbody.rows[0].cells[0].onclick = function() {
  6329. try {
  6330. tbody.rows[0].cells[0].onclick = undefined;
  6331. tbody.rows[0].cells[0].style.cursor = '';
  6332. var tr = appendTr(tbody,'mh_tdpage');
  6333. var td = appendTd(tr);
  6334. td.colSpan = 2;
  6335. var pre = document.createElement('pre');
  6336. appendText(pre,MZ_changeLog.join("\n"));
  6337. td.appendChild(pre);
  6338. } catch (e) {
  6339. window.console.log('[MZ] affichage changeLog', e);
  6340. }
  6341. };
  6342. insertBefore(footer,p);
  6343.  
  6344. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  6345. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  6346. if (isHTTPS) {
  6347. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  6348. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6349. } else {
  6350. window.console.log('[MZ test] début switch to https');
  6351. window.sessionStorage.setItem('xxx', "test session trans https");
  6352. window.parent.xxx = "autre test";
  6353. var url = document.location.href;
  6354. window.console.log('[MZ test] url=' + url);
  6355. url = url.replace(/http:\/\//i, 'https://')
  6356. window.console.log('[MZ test] switched url=' + url);
  6357. document.location.href = url;
  6358. }
  6359. }
  6360. if (false) { // version par utilisation d'un IFrame en https
  6361. if (isHTTPS) {
  6362. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  6363. //window.console.log('[MZ test] window.name=' + window.name);
  6364. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  6365. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6366. var txt = window.name;
  6367. var tabtxt = txt.split(/µ/);
  6368. for (var i = 0; i < tabtxt.length; i++) {
  6369. window.console.log('[MZ test]config https ' + tabtxt[i]);
  6370. }
  6371. } else {
  6372. var txt = '';
  6373. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6374. var k = localStorage.key(i);
  6375. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6376. txt += k + "£" + localStorage.getItem(k) + "µ";
  6377. }
  6378. var iframe = document.createElement('iframe');
  6379. var url = document.location.href;
  6380. //window.console.log('[MZ test] url=' + url);
  6381. url = url.replace(/http:\/\//i, 'https://')
  6382. //window.console.log('[MZ test] switched url=' + url);
  6383. //iframe.xxx = "truc en plume";
  6384. iframe.name = txt;
  6385. //window.xxx = "machin";
  6386. iframe.src = url;
  6387. //iframe.document.xxx = "truc en plume";
  6388. document.body.appendChild(iframe);
  6389. iframe.style.display = 'none';
  6390. }
  6391. }
  6392. }
  6393. }
  6394.  
  6395.  
  6396. /*---------------------------------- Main ------------------------------------*/
  6397.  
  6398. function do_news() {
  6399. start_script();
  6400.  
  6401. traiterJubilaires();
  6402. traiterNouvelles();
  6403.  
  6404. /* plus besoin, le certificat est "officiel"
  6405. if (isHTTPS) {
  6406. // test si les certificats raistlin ont été acceptés
  6407. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  6408. var infoit = MY_getValue(numTroll+'.INFOSIT');
  6409. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  6410. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  6411. }
  6412. }
  6413. */
  6414.  
  6415. displayScriptTime();
  6416. }
  6417.  
  6418. /*********************************************************************************
  6419. * This file is part of Mountyzilla. *
  6420. * *
  6421. * Mountyzilla is free software; you can redistribute it and/or modify *
  6422. * it under the terms of the GNU General Public License as published by *
  6423. * the Free Software Foundation; either version 2 of the License, or *
  6424. * (at your option) any later version. *
  6425. * *
  6426. * Mountyzilla is distributed in the hope that it will be useful, *
  6427. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6428. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6429. * GNU General Public License for more details. *
  6430. * *
  6431. * You should have received a copy of the GNU General Public License *
  6432. * along with Mountyzilla; if not, write to the Free Software *
  6433. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6434. *********************************************************************************/
  6435.  
  6436. // x~x tabcompo
  6437.  
  6438. var popup;
  6439.  
  6440. function initPopupTabcompo() {
  6441. popup = document.createElement('div');
  6442. popup.setAttribute('id', 'popup');
  6443. popup.setAttribute('class', 'mh_textbox');
  6444. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  6445. + 'display: inline; z-index: 3; max-width: 400px;');
  6446. document.body.appendChild(popup);
  6447. }
  6448.  
  6449. function showPopup(evt) {
  6450. var texte = this.getAttribute("texteinfo");
  6451. popup.innerHTML = texte;
  6452. popup.style.left = evt.pageX + 15 + 'px';
  6453. popup.style.top = evt.pageY + 'px';
  6454. popup.style.visibility = "visible";
  6455. }
  6456.  
  6457. // roule 16/03/2016, existe déjà ailleurs
  6458. // function hidePopup() {
  6459. // popup.style.visibility = 'hidden';
  6460. // }
  6461.  
  6462. function createPopupImage_tabcompo(url, text)
  6463. {
  6464. var img = document.createElement('img');
  6465. img.setAttribute('src',url);
  6466. img.setAttribute('align','ABSMIDDLE');
  6467. img.setAttribute("texteinfo",text);
  6468. img.addEventListener("mouseover", showPopup,true);
  6469. img.addEventListener("mouseout", hidePopup,true);
  6470. return img;
  6471. }
  6472.  
  6473. function formateTexte_tabcompo(texte)
  6474. {
  6475. texte = texte.replace(/\n/g,"<br/>");
  6476. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  6477. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  6478. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  6479. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  6480. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  6481. return texte;
  6482. }
  6483.  
  6484. function arrondi(x) {
  6485. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  6486. }
  6487.  
  6488. function traiteMinerai_tabcompo() {
  6489. if (currentURL.indexOf("as_type=Divers")==-1) return;
  6490. try {
  6491. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  6492. +" and contains(./tr/th/text(),'Minerai')]",
  6493. document, null, 9, null).singleNodeValue;
  6494. node = node.nextSibling.nextSibling;
  6495. }
  6496. catch(e) {return;}
  6497.  
  6498. var trlist = document.evaluate('./tr', node, null, 7, null);
  6499. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  6500. var node = trlist.snapshotItem(i);
  6501. var nature = node.childNodes[5].textContent;
  6502. var caracs = node.childNodes[7].textContent;
  6503. var taille = caracs.match(/\d+/)[0];
  6504. var coef = 1;
  6505. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  6506. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  6507. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  6508. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6509. if (nature.indexOf('Mithril')!=-1) {
  6510. coef = 0.2*coef;
  6511. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  6512. }
  6513. else {
  6514. coef = 0.75*coef+1.25;
  6515. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6516. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  6517. }
  6518. }
  6519. }
  6520.  
  6521. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  6522. function treateComposants() {
  6523. if (currentURL.indexOf("as_type=Compo")==-1) return;
  6524. //On récupère les composants
  6525. var nodes = document.evaluate(
  6526. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6527. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6528. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  6529. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6530. if (nodes.snapshotLength == 0) {
  6531. //window.console.log('[MZ] treateComposants DOWN');
  6532. return;
  6533. }
  6534. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  6535.  
  6536. var texte = "";
  6537. for (var i = 0; i < nodes.snapshotLength; i++) {
  6538. var n1 = nodes.snapshotItem(i).childNodes[1];
  6539. var n3 = nodes.snapshotItem(i).childNodes[3];
  6540. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6541. var prix = n3.childNodes[0].nodeValue;
  6542. if (!prix)
  6543. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6544. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6545. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6546. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6547. + prix.replace(/\n/g, '') + "\n";
  6548. }
  6549.  
  6550. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6551. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6552. var id_taniere = c.snapshotItem(0).nodeValue;
  6553. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  6554.  
  6555. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6556. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  6557. if (form)
  6558. {
  6559. if(document.getElementsByTagName('form').length>0)
  6560. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6561. else
  6562. {
  6563. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6564. insertBefore(thisP, form);
  6565. }
  6566. }
  6567. }
  6568.  
  6569. function treateAllComposants() {
  6570. if(currentURL.indexOf("as_type=Compo")==-1) return;
  6571.  
  6572. //On récupère les composants
  6573. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  6574. document, null, 0, null ).numberValue;
  6575. var c = (categ == 0 ? 3 : 4);
  6576. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  6577. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  6578. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  6579. + "td["+c+"]/text()[1] = '\u0040-\u0040' "
  6580. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  6581. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  6582. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  6583. + "and td[1]/img/@alt = 'Identifié']",
  6584. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6585. if (nodes.snapshotLength == 0) {
  6586. // window.alert('treateAllComposants DOWN');
  6587. return;
  6588. }
  6589.  
  6590. var texte = "";
  6591. for (var i = 0; i < nodes.snapshotLength; i++) {
  6592. var n1 = nodes.snapshotItem(i).childNodes[1];
  6593. var n3 = nodes.snapshotItem(i).childNodes[3];
  6594. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6595. var prix = n3.childNodes[0].nodeValue;
  6596. if (!prix)
  6597. {
  6598. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  6599. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6600. }
  6601. else
  6602. {
  6603. prix= prix.replace(/[\240 ]/g, "");
  6604. if(prix=="-")
  6605. prix=null;
  6606. }
  6607. if(prix)
  6608. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6609. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6610. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6611. + prix.replace(/\n/g, '') + "\n";
  6612. else
  6613. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6614. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6615. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  6616. }
  6617.  
  6618. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6619. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6620. var id_taniere = c.snapshotItem(0).nodeValue;
  6621. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  6622.  
  6623. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6624. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  6625. if (form)
  6626. {
  6627. if(document.getElementsByTagName('form').length>0)
  6628. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6629. else
  6630. {
  6631. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6632. insertBefore(thisP, form);
  6633. }
  6634. }
  6635. }
  6636.  
  6637. function treateEM()
  6638. {
  6639. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  6640. if(currentURL.indexOf("as_type=Compo")==-1)
  6641. return false;
  6642. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  6643. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  6644. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6645. if (nodes.snapshotLength == 0)
  6646. return false;
  6647. for (var i = 0; i < nodes.snapshotLength; i++) {
  6648. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  6649. var link = desc[2].firstChild ;
  6650. var nomCompoTotal = desc[2].textContent ;
  6651. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6652. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6653. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  6654. var locqual = desc[3].textContent ;
  6655. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  6656. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  6657. if(isEM(nomMonstre).length>0)
  6658. {
  6659. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  6660. if(infos.length>0)
  6661. {
  6662. var shortDescr = "Variable";
  6663. var bold = 0;
  6664. if(infos != "Composant variable")
  6665. {
  6666. shortDescr = infos.substring(0,infos.indexOf(" "));
  6667. if(parseInt(shortDescr)>=0)
  6668. bold=1;
  6669. }
  6670. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  6671. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  6672. }
  6673. }
  6674.  
  6675. }
  6676. }
  6677.  
  6678. function treateChampi_tabcompo() {
  6679. if (currentURL.indexOf('as_type=Champi')==-1)
  6680. return false;
  6681. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  6682. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6683. if (nodes.snapshotLength == 0)
  6684. return false;
  6685.  
  6686. for (var i = 0; i < nodes.snapshotLength; i++) {
  6687. var node = nodes.snapshotItem(i);
  6688. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  6689. if (moisChampi[nomChampi])
  6690. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  6691. }
  6692. }
  6693.  
  6694. function treateEnchant()
  6695. {
  6696. if(currentURL.indexOf("as_type=Compo")==-1)
  6697. return false;
  6698. try
  6699. {
  6700. if(!listeMonstreEnchantement)
  6701. computeCompoEnchantement();
  6702. var nodes = document.evaluate(
  6703. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6704. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6705. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6706. if (nodes.snapshotLength == 0)
  6707. return false;
  6708. var urlImg = URL_MZimg + "enchant.png";
  6709. for (var i = 0; i < nodes.snapshotLength; i++) {
  6710. var link = nodes.snapshotItem(i);
  6711. var nomCompoTotal = link.firstChild.nodeValue;
  6712. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6713. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6714. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  6715. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  6716. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  6717. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  6718. if(isEnchant(nomMonstre).length>0)
  6719. {
  6720. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  6721. if(infos.length>0)
  6722. {
  6723. link.parentNode.appendChild(createImage(urlImg,infos));
  6724. }
  6725. }
  6726. }
  6727. }
  6728. catch(e)
  6729. {
  6730. window.alert(e);
  6731. }
  6732. }
  6733.  
  6734. function treateEquipEnchant()
  6735. {
  6736. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  6737. return false;
  6738. initPopupTabcompo();
  6739. computeEnchantementEquipement(createPopupImage_tabcompo,formateTexte_tabcompo);
  6740. }
  6741.  
  6742. function do_tancompo() {
  6743. start_script();
  6744.  
  6745. treateAllComposants();
  6746. treateComposants();
  6747. traiteMinerai_tabcompo();
  6748. if (MY_getValue('NOINFOEM')!='true') {
  6749. treateChampi_tabcompo();
  6750. treateEM();
  6751. }
  6752. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  6753. treateEnchant();
  6754. treateEquipEnchant();
  6755. }
  6756.  
  6757. displayScriptTime();
  6758. }
  6759.  
  6760. /*******************************************************************************
  6761. * This file is part of Mountyzilla. *
  6762. * *
  6763. * Mountyzilla is free software; you can redistribute it and/or modify *
  6764. * it under the terms of the GNU General Public License as published by *
  6765. * the Free Software Foundation; either version 2 of the License, or *
  6766. * (at your option) any later version. *
  6767. * *
  6768. * Mountyzilla is distributed in the hope that it will be useful, *
  6769. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6770. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6771. * GNU General Public License for more details. *
  6772. * *
  6773. * You should have received a copy of the GNU General Public License *
  6774. * along with Mountyzilla; if not, write to the Free Software *
  6775. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6776. *******************************************************************************/
  6777.  
  6778. // x~x pjview
  6779.  
  6780. /* TODO
  6781. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  6782. */
  6783.  
  6784. // Bulle d'infos
  6785. var DivInfo;
  6786. // Booléen stockant l'état de freezing de la bulle
  6787. var freezed = false;
  6788.  
  6789. // liste du matos
  6790. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  6791. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6792. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  6793. var mh_caracs = {
  6794. 'anneau de protection':
  6795. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  6796. "armure d'anneaux":
  6797. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  6798. 'armure de bois':
  6799. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  6800. 'armure de cuir':
  6801. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  6802. 'armure de peaux':
  6803. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  6804. 'armure de pierre':
  6805. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  6806. 'armure de plates':
  6807. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  6808. 'baton lesté':
  6809. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6810. 'bâtons de parade':
  6811. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6812. 'bottes':
  6813. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6814. 'bouclier à pointes':
  6815. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6816. 'boulet et chaîne':
  6817. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6818. 'cagoule':
  6819. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  6820. 'casque à cornes':
  6821. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6822. 'casque à pointes':
  6823. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  6824. 'casque en cuir':
  6825. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  6826. 'casque en métal':
  6827. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6828. 'chaîne cloutée':
  6829. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6830. 'chapeau pointu':
  6831. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  6832. 'collier de dents':
  6833. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  6834. 'collier de pierre':
  6835. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6836. 'collier à pointes':
  6837. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6838. 'cotte de mailles':
  6839. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  6840. 'couronne de cristal':
  6841. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  6842. "couronne d'obsidienne":
  6843. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  6844. "coutelas d'obsidienne":
  6845. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  6846. 'coutelas en os':
  6847. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  6848. 'crochet':
  6849. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6850. 'cuir bouilli':
  6851. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  6852. "cuirasse d'ossements":
  6853. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  6854. "cuirasse d'écailles":
  6855. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  6856. 'culotte en cuir':
  6857. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6858. 'dague':
  6859. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6860. 'epée courte':
  6861. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6862. 'epée longue':
  6863. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6864. 'espadon':
  6865. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6866. 'fouet':
  6867. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6868. 'fourrures':
  6869. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  6870. 'gantelet':
  6871. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6872. 'gorgeron en cuir':
  6873. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6874. 'gorgeron en métal':
  6875. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  6876. 'gourdin':
  6877. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6878. 'gourdin clouté':
  6879. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6880. 'grimoire':
  6881. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  6882. "gros'porte":
  6883. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  6884. 'grosse racine':
  6885. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6886. 'grosse stalagmite':
  6887. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  6888. 'hache de bataille':
  6889. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6890. 'hache de guerre en os':
  6891. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  6892. 'hache de guerre en pierre':
  6893. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  6894. "hache à deux mains d'obsidienne":
  6895. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  6896. 'hallebarde':
  6897. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  6898. "haubert d'écailles":
  6899. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  6900. 'haubert de mailles':
  6901. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  6902. 'heaume':
  6903. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  6904. 'jambières en cuir':
  6905. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6906. 'jambières en fourrure':
  6907. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  6908. 'jambières en maille':
  6909. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6910. 'jambières en métal':
  6911. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  6912. 'jambières en os':
  6913. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6914. "lame d'obsidienne":
  6915. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  6916. 'lame en os':
  6917. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6918. 'lame en pierre':
  6919. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6920. 'lorgnons':
  6921. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  6922. 'machette':
  6923. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6924. "masse d'arme":
  6925. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6926. 'pagne de mailles':
  6927. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6928. 'pagne en cuir':
  6929. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6930. 'robe de mage':
  6931. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  6932. 'rondache en bois':
  6933. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6934. 'rondache en métal':
  6935. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  6936. 'sandales':
  6937. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6938. 'souliers dorés':
  6939. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6940. "talisman d'obsidienne":
  6941. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  6942. 'talisman de pierre':
  6943. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  6944. 'targe':
  6945. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6946. 'torche':
  6947. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  6948. 'torque de pierre':
  6949. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  6950. 'tunique':
  6951. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6952. "tunique d'écailles":
  6953. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  6954. 'turban':
  6955. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  6956. }
  6957.  
  6958. // liste des templates
  6959. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  6960. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6961. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  6962. var mh_templates = {
  6963. 'de Feu':
  6964. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6965. 'de Résistance':
  6966. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  6967. "de l'Aigle":
  6968. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  6969. 'de la Salamandre':
  6970. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6971. 'des Cyclopes':
  6972. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  6973. 'des Enragés':
  6974. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  6975. 'des Tortues':
  6976. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  6977. 'des Vampires':
  6978. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  6979. 'du Glacier':
  6980. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  6981. 'du Rat':
  6982. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6983. 'du Roc':
  6984. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  6985. 'du Temps':
  6986. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  6987. 'du Vent':
  6988. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  6989. 'en Mithril':
  6990. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6991. 'des Anciens':
  6992. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6993. 'des Champions':
  6994. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6995. 'des Duellistes':
  6996. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  6997. 'de la Terre':
  6998. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  6999. "de l'Orage":
  7000. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  7001. "de l'Ours":
  7002. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  7003. 'des Béhémoths':
  7004. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  7005. 'des Mages':
  7006. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  7007. 'du Pic':
  7008. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  7009. 'du Sable':
  7010. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  7011. 'acéré':
  7012. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7013. 'acérée':
  7014. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7015. 'équilibré':
  7016. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7017. 'équilibrée':
  7018. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7019. 'léger':
  7020. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7021. 'légère':
  7022. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7023. 'renforcé':
  7024. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7025. 'renforcée':
  7026. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7027. 'robuste':
  7028. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  7029. }
  7030.  
  7031. function clone(arr) {
  7032. // Clonage rapide
  7033. return arr.slice(0);
  7034. }
  7035.  
  7036. function addArray(arr1,arr2) {
  7037. // Somme matricielle
  7038. var res = clone(arr1);
  7039. for(i=res.length-1 ; i>=0 ; i--) {
  7040. res[i] += arr2[i];
  7041. }
  7042. return res;
  7043. }
  7044.  
  7045. function getTemplates(nomItem) {
  7046. // Déstructure le nom de l'item en array [nom, template1, ...]
  7047. var tempFound = true;
  7048. var str = nomItem.trim();
  7049. var arr = [];
  7050. while(tempFound) {
  7051. tempFound = false;
  7052. for(var temp in mh_templates) {
  7053. // on teste la fin du nom contre chaque template
  7054. if(str.slice(-temp.length)!=temp) { continue; }
  7055. tempFound = true;
  7056. str = str.slice(0,-temp.length-1);
  7057. arr.unshift(temp);
  7058. if(str.slice(-3)==' et') {
  7059. str = str.slice(0,-3);
  7060. }
  7061. }
  7062. }
  7063. arr.unshift(str);
  7064. return arr;
  7065. }
  7066.  
  7067. function addMithril(arrayCaracs,typeItem) {
  7068. // Ajoute l'effet du Mithril sur les caracs
  7069. if(typeItem=='arme') {
  7070. if(arrayCaracs[0]<0) {
  7071. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  7072. }
  7073. }
  7074. else {
  7075. if(arrayCaracs[4]<0) {
  7076. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  7077. }
  7078. }
  7079. arrayCaracs[15] /= 2;
  7080. arrayCaracs[16] /= 2;
  7081. return arrayCaracs;
  7082. }
  7083.  
  7084. function addRenfort(arrayCaracs,template) {
  7085. // Ajoute l'effet des pseudo-templates sur les caracs
  7086. // S'applique APRÈS le mithril
  7087. // WARNING - Cette formule n'a rien d'officiel, gare !
  7088. var coef = 0;
  7089. if(/^lég[e,è]re?$/.test(template)) {
  7090. coef = -1;
  7091. }
  7092. else if(/^renforcée?$/.test(template)
  7093. || template==='robuste') {
  7094. coef = 1;
  7095. }
  7096. if(coef) {
  7097. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  7098. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  7099. }
  7100. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  7101. return arrayCaracs;
  7102. }
  7103.  
  7104. function getCaracs(item) {
  7105. // Calcule les caractéristiques de l'item
  7106. var templates = getTemplates(item);
  7107. if(!mh_caracs[templates[0]]) {
  7108. // Si l'item est inconnu
  7109. return [];
  7110. }
  7111. var caracs = clone(mh_caracs[templates[0]]);
  7112. var typeItem = caracs[0];
  7113. caracs.shift();
  7114. templates.shift();
  7115. if(templates[templates.length-1]=='en Mithril') {
  7116. caracs = addMithril(caracs,typeItem);
  7117. templates.pop();
  7118. }
  7119. if(/^acérée?$/.test(templates[0])
  7120. || /^équilibrée?$/.test(templates[0])
  7121. || /^lég[e,è]re?$/.test(templates[0])
  7122. || /^renforcée?$/.test(templates[0])
  7123. || templates[0]=='robuste') {
  7124. caracs = addRenfort(caracs,templates[0]);
  7125. templates.shift();
  7126. }
  7127. for(var i=templates.length-1 ; i>=0 ; i--) {
  7128. caracs = addArray(caracs,mh_templates[templates[i]]);
  7129. }
  7130. return caracs;
  7131. }
  7132.  
  7133. function getLine(tab) {
  7134. // Préparation de la ligne à afficher lors d'un mouseover
  7135. var str = '';
  7136. if(tab[0]!=0 || tab[1]!=0) {
  7137. str += '<b>Att : </b>'+aff(tab[0]);
  7138. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  7139. str += ' | ';
  7140. }
  7141. if(tab[4]!=0) {
  7142. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  7143. }
  7144. if(tab[2]!=0 || tab[3]!=0) {
  7145. str += '<b>Deg : </b>'+aff(tab[2]);
  7146. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  7147. str += ' | ';
  7148. }
  7149. if(tab[8]!=0) {
  7150. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  7151. }
  7152. if(tab[7]!=0) {
  7153. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  7154. }
  7155. if(tab[5]!=0 || tab[6]!=0) {
  7156. str += '<b>Arm : </b>'+aff(tab[5]);
  7157. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  7158. str += ' | ';
  7159. }
  7160. if(tab[9]!=0 || tab[10]!=0) {
  7161. str += '<b>RM : </b>'+aff(tab[9])+'%';
  7162. if(tab[9]!=tab[10]) {
  7163. str += '/'+aff(tab[10])+'%';
  7164. }
  7165. str += ' | ';
  7166. }
  7167. if(tab[11]!=0 || tab[12]!=0) {
  7168. str += '<b>MM : </b>'+aff(tab[11])+'%';
  7169. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  7170. str += ' | ';
  7171. }
  7172. if(tab[13]!=0) {
  7173. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  7174. }
  7175. if(tab[14]!=0) {
  7176. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  7177. }
  7178. str += '<b>Poids : </b>'+tab[15]+' min';
  7179. if(tab[15]!=tab[16]) {
  7180. str += ' / '+tab[16]+' min';
  7181. }
  7182. return str;
  7183. }
  7184.  
  7185. function toolTipInit() {
  7186. DivInfo = document.createElement('div');
  7187. DivInfo.id = 'infosVue';
  7188. DivInfo.className = 'mh_textbox';
  7189. DivInfo.style =
  7190. 'position: absolute;'
  7191. +'border: 1px solid #000000;'
  7192. +'visibility:hidden;'
  7193. +'display:inline;'
  7194. +'z-index:99;';
  7195. document.body.appendChild(DivInfo);
  7196. document.onmousemove = getXY;
  7197. document.onclick = changeFreezeStatus;
  7198. }
  7199.  
  7200. function getXY(evt) {
  7201. if(!freezed && DivInfo.style.visibility=='visible') {
  7202. DivInfo.style.left = evt.pageX+'px';
  7203. DivInfo.style.top = evt.pageY+10+'px';
  7204. }
  7205. }
  7206.  
  7207. function changeFreezeStatus() {
  7208. if(DivInfo.style.visibility=='visible') {
  7209. freezed = !freezed;
  7210. if(!freezed) { hideInfos(); }
  7211. }
  7212. }
  7213.  
  7214. function showInfos() {
  7215. if(freezed) { return; }
  7216. var currentInfos = this.infos;
  7217. DivInfo.innerHTML = currentInfos;
  7218. DivInfo.style.visibility = 'visible';
  7219. }
  7220.  
  7221. function hideInfos() {
  7222. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  7223. }
  7224.  
  7225. function treateEquipement() {
  7226. // Extrait les données du matos et réinjecte les infos déduites
  7227. if(MY_getValue('INFOCARAC')=='false') { return; }
  7228.  
  7229. var faireLigne = false;
  7230. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  7231. var nodes = document.evaluate(
  7232. "//td/b[text()='Equipement Utilisé']/../../"
  7233. +"td[2]/img[contains(@src,bullet)]",
  7234. document, null, 7, null);
  7235. if(nodes.snapshotLength>0) {
  7236. // Si CSS de base
  7237. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7238. var node = nodes.snapshotItem(i);
  7239. var next = node.nextSibling;
  7240. var nnext = next.nextSibling;
  7241. var nom = next.nodeValue.toLowerCase();
  7242. if(nnext.childNodes.length==1) {
  7243. nom += nnext.firstChild.nodeValue;
  7244. }
  7245. nom = nom.trim();
  7246. // gestion winpostrophe
  7247. var c = String.fromCharCode(180);
  7248. while(nom.indexOf(c)!=-1) {
  7249. nom = nom.replace(c,"'");
  7250. }
  7251. var arr = getCaracs(nom);
  7252. if(arr.length>0) {
  7253. faireLigne = true;
  7254. caracs = addArray(caracs,arr);
  7255. var span = document.createElement('span');
  7256. span.appendChild(next);
  7257. span.appendChild(nnext);
  7258. span.infos = getLine(arr);
  7259. span.onmouseover = showInfos;
  7260. span.onmouseout = hideInfos;
  7261. insertBefore(node.nextSibling,span);
  7262. }
  7263. }
  7264.  
  7265. if(faireLigne) {
  7266. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  7267. document, null, 9, null).singleNodeValue;
  7268. node.infos = getLine(caracs);
  7269. node.onmouseover = showInfos;
  7270. node.onmouseout = hideInfos;
  7271. }
  7272. }
  7273. else {
  7274. // Si CSS avancée
  7275. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  7276. document, null, 7, null);
  7277. if(nodes.snapshotLength>0) {
  7278. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7279. var node = nodes.snapshotItem(i);
  7280. var nom = node.firstChild.nodeValue.toLowerCase();
  7281. if(node.childNodes.length>1) {
  7282. nom += node.childNodes[1].firstChild.nodeValue;
  7283. }
  7284. nom = nom.trim();
  7285. // gestion winpostrophe
  7286. var c = String.fromCharCode(180);
  7287. while(nom.indexOf(c)!=-1) {
  7288. nom = nom.replace(c,"'");
  7289. }
  7290. var arr = getCaracs(nom);
  7291. if(arr.length!=0) {
  7292. caracs = addArray(caracs,arr);
  7293. node.infos = getLine(arr);
  7294. node.onmouseover = showInfos;
  7295. node.onmouseout = hideInfos;
  7296. }
  7297. }
  7298. var nodes = document.evaluate("//dt[@class='equipement']",
  7299. document, null, 7, null);
  7300. var node = nodes.snapshotItem(0);
  7301. node.infos = getLine(caracs);
  7302. node.onmouseover = showInfos;
  7303. node.onmouseout = hideInfos;
  7304. }
  7305. }
  7306. }
  7307.  
  7308. function do_pjview() {
  7309. treateEquipement();
  7310. toolTipInit();
  7311. }
  7312.  
  7313. /*******************************************************************************
  7314. * This file is part of Mountyzilla. *
  7315. * *
  7316. * Mountyzilla is free software; you can redistribute it and/or modify *
  7317. * it under the terms of the GNU General Public License as published by *
  7318. * the Free Software Foundation; either version 2 of the License, or *
  7319. * (at your option) any later version. *
  7320. * *
  7321. * Mountyzilla is distributed in the hope that it will be useful, *
  7322. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7323. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7324. * GNU General Public License for more details. *
  7325. * *
  7326. * You should have received a copy of the GNU General Public License *
  7327. * along with Mountyzilla; if not, write to the Free Software *
  7328. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7329. *******************************************************************************/
  7330.  
  7331. // x~x option
  7332.  
  7333. /* TODO
  7334. * Passer le HTML injecté aux conventions HTML5
  7335. */
  7336.  
  7337.  
  7338. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  7339.  
  7340. function saveITData() {
  7341. var IT = document.getElementById('itSelect').value;
  7342. if(IT=='bricol') {
  7343. var nBricol = 1;
  7344. for (var iBricol = 0; ; iBricol++) {
  7345. var extClef = nBricol == 1 ? '' : nBricol;
  7346. var eltSystem = document.getElementById('urlbricol'+iBricol);
  7347. if (eltSystem == undefined) break;
  7348. var system = eltSystem.value;
  7349. window.console.log("[MZ] saveITData system=" + system);
  7350. var login = document.getElementById('loginbricol'+iBricol).value;
  7351. var pass = document.getElementById('passbricol'+iBricol).value;
  7352. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  7353. if(system && login) {
  7354. if (pass) {
  7355. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  7356. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  7357. //window.console.log('v=' + v);
  7358. } else {
  7359. // vérif que rien n'a changé
  7360. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  7361. if(str) {
  7362. var arr = str.split('$');
  7363. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  7364. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  7365. }
  7366. }
  7367. }
  7368. nBricol++;
  7369. }
  7370. }
  7371. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  7372. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  7373. }
  7374. else {
  7375. MY_removeValue(numTroll+'.INFOSIT');
  7376. }
  7377. }
  7378.  
  7379. function saveLinks() {
  7380. var numLinks = document.getElementById('linksBody').childNodes.length;
  7381. var data=[ [] ];
  7382. /* Récupération et tri des liens */
  7383. for(var i=1 ; i<=numLinks ; i++) {
  7384. MY_removeValue('URL'+i);
  7385. MY_removeValue('URL'+i+'.nom');
  7386. MY_removeValue('URL'+i+'.ico');
  7387. var url = document.getElementById('url'+i).value;
  7388. var nom = document.getElementById('nom'+i).value;
  7389. var ico = document.getElementById('ico'+i).value;
  7390. if(url && (nom || ico) ) {
  7391. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  7392. }
  7393. }
  7394. /* Sauvegarde */
  7395. for(var i=1 ; i<data.length ; i++) {
  7396. MY_setValue('URL'+i,data[i][0]);
  7397. MY_setValue('URL'+i+'.nom',data[i][1]);
  7398. MY_setValue('URL'+i+'.ico',data[i][2]);
  7399. }
  7400. }
  7401.  
  7402. function saveAll() {
  7403. try {
  7404. var urlIco = document.getElementById('icoMenuIco').value;
  7405. if(urlIco) {
  7406. MY_setValue(numTroll+'.ICOMENU', urlIco );
  7407. }
  7408. else {
  7409. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  7410. document.getElementById('icoMenuIco').value = '';
  7411. }
  7412. saveLinks();
  7413. refreshLinks();
  7414.  
  7415. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  7416.  
  7417. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  7418. if(maxcdm) {
  7419. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  7420. }
  7421. else {
  7422. MY_removeValue(numTroll+'.MAXCDM');
  7423. document.getElementById('maxcdm').value = '';
  7424. }
  7425.  
  7426. MY_setValue('NOINFOEM',
  7427. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  7428.  
  7429. // Pourquoi Tilk stockait-il tout en str ?
  7430. // -> parce que les booléens c'est foireux (vérifié)
  7431. MY_setValue(numTroll+'.USECSS',
  7432. document.getElementById('usecss').checked ? 'true':'false');
  7433. MY_setValue('INFOCARAC',
  7434. document.getElementById('infocarac').checked ? 'true' : 'false');
  7435. //MY_setValue(numTroll+'.SEND_IDT',
  7436. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  7437. // Fonctionnalité désactivée
  7438.  
  7439. MY_setValue(numTroll+'.AUTOCDM',
  7440. document.getElementById('autoCdM').checked ? 'true' : 'false');
  7441. // MY_setValue('VUECARAC', // Roule 12/12/2019 ça ne fait plus rien
  7442. // document.getElementById('vueCarac').checked ? 'true' : 'false');
  7443. MY_setValue('CONFIRMEDECALAGE',
  7444. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  7445.  
  7446. /* SCIZ */
  7447. var sciz_jwt = document.getElementById('sciz_jwt').value;
  7448. if (sciz_jwt) {
  7449. sciz_jwt = sciz_jwt.replace(new RegExp('[^a-zA-Z0-9\._\-]','g'), '');
  7450. MY_setValue(numTroll + '.SCIZJWT', sciz_jwt);
  7451. }
  7452.  
  7453. saveITData();
  7454. } catch (e) {
  7455. var bouton = document.getElementById('saveAll');
  7456. window.console.log(e);
  7457. bouton.value = "il y a eu une erreur";
  7458. return;
  7459. }
  7460.  
  7461. var bouton = document.getElementById('saveAll');
  7462. bouton.value = (bouton.value=='Sauvegardé !') ?
  7463. 'Re-sauvegardé !' : 'Sauvegardé !';
  7464. }
  7465.  
  7466.  
  7467. /*-[functions]----------------- EventListeners -------------------------------*/
  7468.  
  7469. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  7470. var itBody = document.getElementById('itBody');
  7471. var nTr = itBody.rows.length;
  7472. // enlever tous les "+" des lignes précédentes
  7473. for (var iTr = 0; iTr < nTr; iTr++) {
  7474. var td = itBody.rows[iTr].cells[0];
  7475. td.innerHTML = '';
  7476. td.title = '';
  7477. td.style.cursor = 'default';
  7478. }
  7479. // ajouter une ligne
  7480. var tr = appendTr(itBody,'mh_tdpage')
  7481. var td = appendTd(tr);
  7482. if (bLast) {
  7483. td.style.whiteSpace = 'nowrap';
  7484. appendText(td, '+');
  7485. td.style.cursor = 'pointer';
  7486. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  7487. td.onclick = function (e) {
  7488. addBricolIT(undefined, undefined, undefined, false, true);
  7489. }
  7490. }
  7491. var td = appendTd(tr);
  7492. td.style.whiteSpace = 'nowrap';
  7493. appendText(td,'Nom du système : ');
  7494. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  7495. td = appendTd(tr);
  7496. td.style.whiteSpace = 'nowrap';
  7497. appendText(td,'Login du compte : ');
  7498. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  7499. td = appendTd(tr);
  7500. td.style.whiteSpace = 'nowrap';
  7501. appendText(td,'Mot de passe du compte : ');
  7502. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  7503. td = appendTd(tr);
  7504. if (bFirst) {
  7505. td.style.whiteSpace = 'nowrap';
  7506. appendText(td,'Affichage des Trõlls hors vue : ');
  7507. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  7508. }
  7509. }
  7510.  
  7511. function onChangeIT() {
  7512. var IT = document.getElementById('itSelect').value;
  7513. var itBody = document.getElementById('itBody');
  7514. itBody.innerHTML = '';
  7515. var tabStr = new Array();
  7516. if(IT=='bricol') {
  7517. for (var iBricol = 1; ; iBricol++) {
  7518. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  7519. //window.console.log('onChangeIT str=' + str);
  7520. if(str) {
  7521. tabStr.push(str);
  7522. } else {
  7523. break;
  7524. }
  7525. }
  7526. if (tabStr.length == 0) {
  7527. addBricolIT('', '', 0, true, true)
  7528. } else {
  7529. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  7530. var arr = tabStr[iBricol].split('$');
  7531. var system = arr[1];
  7532. var login = arr[2];
  7533. var affhv = arr[4];
  7534. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  7535. }
  7536. }
  7537. }
  7538. }
  7539.  
  7540. function refreshLinks() {
  7541. document.getElementById('linksBody').innerHTML = '';
  7542. var anotherURL = MY_getValue('URL1');
  7543. if(!anotherURL) { addLinkField(); }
  7544. var i=1;
  7545. while(anotherURL && i<99) {
  7546. addLinkField(i,anotherURL,
  7547. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  7548. i++;
  7549. anotherURL = MY_getValue('URL'+i);
  7550. }
  7551. }
  7552.  
  7553. function addLinkField(i,url,nom,ico) {
  7554. var linksBody = document.getElementById('linksBody');
  7555. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  7556. var tr = appendTr(linksBody);
  7557. var td = appendTdCenter(tr);
  7558. appendText(td,'Lien '+i+' : ');
  7559. appendTextbox(td,'text','url'+i,40,150,url);
  7560. td = appendTdCenter(tr);
  7561. appendText(td,'Nom : ');
  7562. appendTextbox(td,'text','nom'+i,20,150,nom);
  7563. td = appendTdCenter(tr);
  7564. appendText(td,'Icône : ');
  7565. appendTextbox(td,'text','ico'+i,40,150,ico);
  7566. }
  7567.  
  7568. function removeLinkField() {
  7569. var linksBody = document.getElementById('linksBody');
  7570. var i = linksBody.childNodes.length;
  7571. MY_removeValue('URL'+i);
  7572. MY_removeValue('URL'+i+'.nom');
  7573. MY_removeValue('URL'+i+'.ico');
  7574. linksBody.removeChild(linksBody.lastChild);
  7575. if(linksBody.childNodes.length==0) { addLinkField(); }
  7576. }
  7577.  
  7578. function resetMainIco() {
  7579. document.getElementById('icoMenuIco').value=
  7580. URL_MZimg + 'mz_logo_small.png';
  7581. }
  7582.  
  7583.  
  7584. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  7585.  
  7586. function insertTitle(next,txt) {
  7587. var div = document.createElement('div');
  7588. div.className = 'titre2';
  7589. appendText(div,txt);
  7590. insertBefore(next,div);
  7591. return div;
  7592. }
  7593.  
  7594. function insertMainTable(next) {
  7595. var table = document.createElement('table');
  7596. table.width = '98%';
  7597. table.border = 0;
  7598. table.align = 'center';
  7599. table.cellPadding = 2;
  7600. table.cellSpacing = 1;
  7601. table.className = 'mh_tdborder';
  7602. var tbody = document.createElement('tbody');
  7603. table.appendChild(tbody);
  7604. insertBefore(next,table);
  7605. return tbody;
  7606. }
  7607.  
  7608. function appendSubTable(node) {
  7609. var table = document.createElement('table');
  7610. table.width = '100%';
  7611. var tbody = document.createElement('tbody');
  7612. table.appendChild(tbody);
  7613. node.appendChild(table);
  7614. return tbody;
  7615. }
  7616.  
  7617. function insertOptionTable(insertPt) {
  7618. var mainBody = insertMainTable(insertPt);
  7619.  
  7620. /* Liens dans le Menu */
  7621. var tr = appendTr(mainBody,'mh_tdtitre');
  7622. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  7623. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7624. appendText(td,'Icône du Menu: ');
  7625. var url = MY_getValue(numTroll+'.ICOMENU');
  7626. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  7627. url = URL_MZimg + 'mz_logo_small.png';
  7628. }
  7629. appendTextbox(td,'text','icoMenuIco',50,200,url);
  7630. appendButton(td,'Réinitialiser',resetMainIco);
  7631.  
  7632. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7633. var tbody = appendSubTable(td);
  7634. tbody.id = 'linksBody';
  7635. refreshLinks();
  7636.  
  7637. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  7638. appendButton(td,'Ajouter',addLinkField);
  7639. appendButton(td,'Supprimer',removeLinkField);
  7640.  
  7641. /* Options de la Vue : vue externe, nb de CdM, etc */
  7642. tr = appendTr(mainBody,'mh_tdtitre');
  7643. appendTdText(tr,'Options de la Vue :',true);
  7644. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7645. tbody = appendSubTable(td);
  7646.  
  7647. tr = appendTr(tbody);
  7648. td = appendTdText(tr,'Vue externe : ');
  7649. var select = document.createElement('select');
  7650. select.id = 'vueext';
  7651. td.appendChild(select);
  7652. var listeVues2D = [
  7653. 'Bricol\' Vue',
  7654. 'Vue du CCM',
  7655. 'Vue Gloumfs 2D',
  7656. 'Vue Gloumfs 3D',
  7657. 'Grouky Vue!'
  7658. ];
  7659. for(var i=0 ; i<listeVues2D.length ; i++) {
  7660. appendOption(select,listeVues2D[i],listeVues2D[i]);
  7661. }
  7662. if(MY_getValue('VUEEXT')) {
  7663. select.value = MY_getValue('VUEEXT');
  7664. }
  7665.  
  7666. td = appendTd(tr);
  7667. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  7668. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  7669.  
  7670. tr = appendTr(tbody);
  7671. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  7672. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  7673.  
  7674. td = appendTd(tr);
  7675. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  7676. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  7677.  
  7678. /* Interface Tactique */
  7679. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7680. appendText(td,'Interface Tactique : ',true);
  7681. select = document.createElement('select');
  7682. select.id = 'itSelect';
  7683. appendOption(select,'none','Aucune');
  7684. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  7685. // seule interface supportée !
  7686. td.appendChild(select);
  7687.  
  7688. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7689. tbody = appendSubTable(td);
  7690. tbody.id = 'itBody';
  7691. select.onchange = onChangeIT;
  7692. var str = MY_getValue(numTroll+'.INFOSIT');
  7693. if(str) {
  7694. select.value = str.slice(0,str.indexOf('$'));
  7695. onChangeIT();
  7696. }
  7697.  
  7698. /* SCIZ */
  7699. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7700. appendText(td,'SCIZ :',true);
  7701. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7702. td = appendTdText(td,'JWT : ');
  7703. appendTextbox(td,'text','sciz_jwt',150,500, MY_getValue(numTroll+'.SCIZJWT'));
  7704.  
  7705. /* Options diverses */
  7706. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7707. appendText(td,'Options diverses :',true);
  7708. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7709. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  7710. appendText(td,
  7711. ' Afficher les caractéristiques des équipements des autres Trõlls');
  7712.  
  7713. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7714. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  7715. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  7716.  
  7717. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7718. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  7719. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  7720.  
  7721. // td = appendTd(appendTr(mainBody,'mh_tdpage')); // Roule 12/12/2019 ça ne fait plus rien
  7722. // appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  7723. // appendText(td,' Afficher la Vue avec les caractéristiques dans le Profil');
  7724.  
  7725. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7726. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  7727. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  7728.  
  7729. /* Bouton SaveAll */
  7730. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  7731. input = appendButton(td,'Sauvegarder',saveAll);
  7732. input.id = 'saveAll';
  7733. }
  7734.  
  7735. function insertCreditsTable(insertPt) {
  7736. var tbody = insertMainTable(insertPt);
  7737.  
  7738. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  7739. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  7740. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  7741.  
  7742. var ul = document.createElement('ul');
  7743. td.appendChild(ul);
  7744. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  7745. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  7746. appendLI(ul,'Reivax (4234) pour les infos bulles');
  7747. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  7748. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  7749. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  7750. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  7751. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  7752. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  7753. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  7754. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  7755. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  7756. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  7757. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  7758. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  7759. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  7760. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  7761. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  7762. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  7763. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  7764. }
  7765.  
  7766.  
  7767. /* [functions] Obsolètes */
  7768. function deleteEnchantement()
  7769. {
  7770. try
  7771. {
  7772. var idEquipement = this.getAttribute('name');
  7773. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  7774. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  7775. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  7776. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  7777. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  7778. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7779. var string = "";
  7780. for(var i=0;i<listeEquipement.length;i++)
  7781. {
  7782. if(listeEquipement[i]!=idEquipement)
  7783. if(string=="")
  7784. string = listeEquipement[i];
  7785. else
  7786. string += ";"+listeEquipement[i];
  7787. }
  7788. if(string=="")
  7789. {
  7790. MY_removeValue(numTroll+".enchantement.liste");
  7791. var table = this.parentNode.parentNode.parentNode.parentNode;
  7792. var parent = table.parentNode;
  7793. for(var i=0;i<parent.childNodes.length;i++)
  7794. {
  7795. if(parent.childNodes[i]==table)
  7796. {
  7797. parent.removeChild(parent.childNodes[i-1]);
  7798. parent.removeChild(parent.childNodes[i-1]);
  7799. parent.removeChild(parent.childNodes[i-1]);
  7800. break;
  7801. }
  7802. }
  7803. }
  7804. else
  7805. {
  7806. MY_getValue(numTroll+".enchantement.liste",string);
  7807. this.parentNode.parentNode.parentNode
  7808. .removeChild(this.parentNode.parentNode);
  7809. }
  7810. }
  7811. catch(e)
  7812. {
  7813. window.alert(e);
  7814. }
  7815. }
  7816. /* [functions] fin Obsolètes */
  7817.  
  7818. /*-[functions]---------------- Partie principale -----------------------------*/
  7819.  
  7820. function do_option() {
  7821. start_script(712);
  7822. var insertPoint = document.getElementById('footer1');
  7823. insertBefore(insertPoint,document.createElement('p'));
  7824. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  7825. ti.onclick = function (e) {
  7826. var evt = e || window.event;
  7827. if (evt.shiftKey) {
  7828. var txt = '';
  7829. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  7830. var k = localStorage.key(i);
  7831. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  7832. txt += k + "\t" + localStorage.getItem(k) + "\n";
  7833. }
  7834. copyTextToClipboard(txt);
  7835. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  7836. } else if (evt.ctrlKey) {
  7837. var tabK= [];
  7838. var sMatch = numTroll + '.';
  7839. var lMatch = sMatch.length;
  7840. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  7841. var k = localStorage.key(i);
  7842. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  7843. }
  7844. for (var i = 0; i < tabK.length; ++i ) {
  7845. MY_removeValue(tabK[i]);
  7846. }
  7847. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  7848. }
  7849. }
  7850. ti.title = 'Version ' + GM_info.script.version;
  7851. insertOptionTable(insertPoint);
  7852. /* insertion enchantements ici
  7853. if(...)
  7854. insertEnchantementTable();
  7855. */
  7856. insertBefore(insertPoint,document.createElement('p'));
  7857. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  7858. ti.onclick = function (e) {
  7859. var evt = e || window.event;
  7860. if (!evt.shiftKey) return;
  7861. var oldDev = MY_getValue('MZ_dev');
  7862. if (oldDev) {
  7863. MY_removeValue('MZ_dev');
  7864. } else {
  7865. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  7866. MY_setValue('MZ_dev', 1);
  7867. }
  7868. document.location.href = document.location.href;
  7869. }
  7870. insertCreditsTable(insertPoint);
  7871. insertBefore(insertPoint,document.createElement('p'));
  7872.  
  7873. /* [zone] Obsolète ?? */
  7874. if(MY_getValue(numTroll+".enchantement.liste")
  7875. && MY_getValue(numTroll+".enchantement.liste")!="" )
  7876. {
  7877. insertTitle(insertPoint, 'Les Enchantements en cours');
  7878. table = document.createElement('table');
  7879. table.setAttribute('width', '98%');
  7880. table.setAttribute('border', '0');
  7881. table.setAttribute('align', 'center');
  7882. table.setAttribute('cellpadding', '2');
  7883. table.setAttribute('cellspacing', '1');
  7884. table.setAttribute('class', 'mh_tdborder');
  7885.  
  7886. tbody = document.createElement('tbody');
  7887. table.appendChild(tbody);
  7888.  
  7889. tr = appendTr(tbody, 'mh_tdtitre');
  7890. appendTdText(tr, 'Equipement',1);
  7891. appendTdText(tr, 'Composants',1);
  7892. appendTdText(tr, 'Enchanteur',1);
  7893. appendTdText(tr, 'Action',1);
  7894.  
  7895. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7896. for(var i=0;i<listeEquipement.length;i++)
  7897. {
  7898. try
  7899. {
  7900. var idEquipement = listeEquipement[i];
  7901. var nomEquipement = MY_getValue(numTroll+".enchantement."
  7902. +idEquipement+".objet");
  7903. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  7904. +idEquipement+".enchanteur").split(";");
  7905. var ul = document.createElement('UL');
  7906. for(var j=0;j<3;j++)
  7907. {
  7908. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  7909. var v = MY_getValue(k);
  7910. if (v == null) { // protection Roule 26/08/2017
  7911. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  7912. continue;
  7913. }
  7914. var infoComposant = v.split(';');
  7915. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  7916. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  7917. continue;
  7918. }
  7919. var texte = infoComposant[4].replace("Ril ","Œil ");
  7920. for(var k=5;k<infoComposant.length;k++)
  7921. {
  7922. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  7923. }
  7924. li = appendLI(ul,texte);
  7925. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  7926. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  7927. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  7928. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  7929. string+= '<input type="hidden" name="q" value="min" />';
  7930. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  7931. 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>';
  7932.  
  7933. string+= '</form>';
  7934. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  7935. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  7936. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  7937. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  7938. li.innerHTML += string;
  7939. }
  7940. tr = appendTr(tbody, 'mh_tdpage');
  7941.  
  7942. td = appendTdText(tr, nomEquipement);
  7943. td.setAttribute('valign', 'center');
  7944.  
  7945. td = document.createElement('td');
  7946. td.appendChild(ul);
  7947. tr.appendChild(td);
  7948. td.setAttribute('valign', 'center');
  7949.  
  7950. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  7951. td.setAttribute('valign', 'center');
  7952.  
  7953. td = document.createElement('td');
  7954. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  7955. input.setAttribute('name', idEquipement);
  7956. tr.appendChild(td);
  7957. td.setAttribute('valign', 'center');
  7958. }
  7959. catch(e)
  7960. {
  7961. }
  7962. }
  7963. insertBefore(insertPoint, table);
  7964. insertBefore(insertPoint, document.createElement('p'));
  7965. }
  7966. /* [zone] fin Obsolète ?? */
  7967.  
  7968.  
  7969. displayScriptTime();
  7970. }
  7971.  
  7972. /*******************************************************************************
  7973. * This file is part of Mountyzilla. *
  7974. * *
  7975. * Mountyzilla is free software; you can redistribute it and/or modify *
  7976. * it under the terms of the GNU General Public License as published by *
  7977. * the Free Software Foundation; either version 2 of the License, or *
  7978. * (at your option) any later version. *
  7979. * *
  7980. * Mountyzilla is distributed in the hope that it will be useful, *
  7981. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7982. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7983. * GNU General Public License for more details. *
  7984. * *
  7985. * You should have received a copy of the GNU General Public License *
  7986. * along with Mountyzilla; if not, write to the Free Software *
  7987. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7988. *******************************************************************************/
  7989.  
  7990. // x~x equip
  7991.  
  7992. /**
  7993. * 2014-02-08 - v2.0a (from scratch)
  7994. * 2014-02-18 - v2.0a0
  7995. * - ajout calcul Carats / UM des minerais + totaux
  7996. * 2014-03-06 - v2.0a1
  7997. * - retour Infos EM des Champis
  7998. * TODO
  7999. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  8000. */
  8001.  
  8002. function traiteChampis() {
  8003. try{
  8004. var tr = document.getElementById('mh_objet_hidden_Champignon');
  8005. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8006. }
  8007. catch(e){return;}
  8008. if(trlist.length<=0) return;
  8009. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8010. var node = trlist.snapshotItem(i).childNodes[7];
  8011. var str = node.textContent.trim();
  8012. var type = str.slice(0,str.lastIndexOf(' '));
  8013. var mundi = mundiChampi[type];
  8014. if(!mundi) continue;
  8015. var urlImg = URL_MZimg
  8016. +'Competences/ecritureMagique.png';
  8017. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  8018. appendText(node,' ');
  8019. node.appendChild(img);
  8020. }
  8021. }
  8022.  
  8023. function traiteCompos() {
  8024. try {
  8025. var tr = document.getElementById('mh_objet_hidden_Composant');
  8026. var tbody = document.evaluate("./td/table/tbody",
  8027. tr, null, 9, null).singleNodeValue;
  8028. }
  8029. catch(e) {return;}
  8030. insererInfosEM(tbody);
  8031. }
  8032.  
  8033. function traiteMinerai() {
  8034. try{
  8035. var tr = document.getElementById('mh_objet_hidden_Minerai');
  8036. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8037. }
  8038. catch(e){return;}
  8039. if(trlist.length<=0) return;
  8040. var totaux = {};
  8041. var str;
  8042. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8043. var node = trlist.snapshotItem(i);
  8044. var nature = node.childNodes[7].textContent,
  8045. caracs = node.childNodes[9].textContent;
  8046. var taille = Number(caracs.match(/\d+/)[0]);
  8047. var coef = 1;
  8048. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  8049. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  8050. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  8051. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  8052. if(nature.indexOf('Mithril')!=-1) {
  8053. coef = 0.2*coef;
  8054. str = ' | UM: ';
  8055. }
  8056. else {
  8057. coef = 0.75*coef+1.25;
  8058. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  8059. str = ' | Carats: ';
  8060. }
  8061. var carats = Math.round(taille*coef)
  8062. appendText(node.childNodes[9], str+carats );
  8063. if(!totaux[nature]) {
  8064. totaux[nature] = [taille,carats];
  8065. }
  8066. else {
  8067. totaux[nature][0] += taille;
  8068. totaux[nature][1] += carats;
  8069. }
  8070. }
  8071. str = 'Total : ';
  8072. for(var nature in totaux) {
  8073. if(str.length>8) str += ', ';
  8074. if(nature.indexOf('Mithril')!=-1) {
  8075. str += nature+totaux[nature][1]+' UM';
  8076. }
  8077. else {
  8078. str += nature+totaux[nature][0]+'U/'
  8079. +totaux[nature][1]+'c';
  8080. }
  8081. }
  8082. /*var node = document.getElementById('mh_plus_Minerai');
  8083. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  8084. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  8085. if(!titre) return;*/
  8086. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  8087. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  8088. td.colSpan = 7;
  8089. }
  8090.  
  8091. function do_equip() {
  8092. start_script();
  8093.  
  8094. traiteChampis();
  8095. traiteCompos();
  8096. traiteMinerai();
  8097.  
  8098. displayScriptTime();
  8099. }
  8100.  
  8101. /*******************************************************************************
  8102. * This file is part of Mountyzilla. *
  8103. * *
  8104. * Mountyzilla is free software; you can redistribute it and/or modify *
  8105. * it under the terms of the GNU General Public License as published by *
  8106. * the Free Software Foundation; either version 2 of the License, or *
  8107. * (at your option) any later version. *
  8108. * *
  8109. * Mountyzilla is distributed in the hope that it will be useful, *
  8110. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8111. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8112. * GNU General Public License for more details. *
  8113. * *
  8114. * You should have received a copy of the GNU General Public License *
  8115. * along with Mountyzilla; if not, write to the Free Software *
  8116. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8117. *******************************************************************************/
  8118.  
  8119. // x~x diplo
  8120.  
  8121. /*
  8122. TODO:
  8123. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  8124. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  8125. V Étape 3: Ajout de la diplo perso
  8126. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  8127. V Étape 5: Ajout des fioritures (preview de la couleur...)
  8128.  
  8129. Options Globales:
  8130. Actuelles:
  8131. numTroll.USECSS,
  8132. numTroll.NODIPLO
  8133. NOMYTH
  8134. Nouvelles:
  8135. TODO numTroll.USECSS
  8136. numTroll.diplo.off (remplace NODIPLO)
  8137. numTroll.diplo.guilde
  8138. numTroll.diplo.perso
  8139.  
  8140. Structure de diplo.guilde:
  8141. isOn: 'true' ou 'false'
  8142. isDetailOn: 'true' ou 'false'
  8143. guilde
  8144. > id
  8145. > couleur
  8146. AllAmis,AllEnnemis: couleur
  8147. Amis0,...,Ennemis5
  8148. > Troll: idTroll1;...;
  8149. > Guilde: idGuilde1;...;
  8150. > titre
  8151. > couleur
  8152.  
  8153. Structure de diplo.perso:
  8154. isOn: 'true' ou 'false'
  8155. mythiques: couleur
  8156. Troll,Guilde,Monstre:
  8157. > id
  8158. > couleur
  8159. > description
  8160. */
  8161.  
  8162. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8163.  
  8164. function couleurAleatoire() {
  8165. var alph = '0123456789ABCDEF'.split('');
  8166. var clr = '#';
  8167. for (var i=0; i<6; i++) {
  8168. clr+=alph[ Math.floor(16*Math.random()) ];
  8169. }
  8170. return clr;
  8171. }
  8172.  
  8173. function isCouleur(str) {
  8174. return /^#[0-9A-F]{6}$/i.test(str);
  8175. }
  8176.  
  8177. /*-[functions]---------------- Analyse de la page ----------------------------*/
  8178.  
  8179. function appendChoixCouleur(node,id) {
  8180. var span = document.createElement('span');
  8181. span.id = 'span'+id;
  8182. if(isDetailOn) {
  8183. span.style.display = 'none';
  8184. }
  8185. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  8186. if(diploGuilde[id]) {
  8187. couleur = diploGuilde[id];
  8188. }
  8189. appendText(span,' - Couleur HTML: ');
  8190. var input = appendTextbox(span,'text',id,7,7,couleur);
  8191. input.onkeyup = previewCouleur;
  8192. input.onchange = previewCouleur;
  8193. input.onkeyup();
  8194. node.appendChild(span);
  8195. }
  8196.  
  8197. function insertChoixCouleur(node,id) {
  8198. var span = document.createElement('span');
  8199. span.id = 'span'+id;
  8200. // La couleur détaillée passera à une valeur aléatoire
  8201. // si toggle vers isDetailOn
  8202. var couleur = couleurAleatoire();
  8203. if(!isDetailOn) {
  8204. span.style.display = 'none';
  8205. } else if(diploGuilde[id]) {
  8206. couleur = diploGuilde[id].couleur;
  8207. }
  8208. appendText(span,' - Couleur HTML: ');
  8209. var input = appendTextbox(span,'text',id,7,7,couleur);
  8210. input.onkeyup = previewCouleur;
  8211. input.onchange = previewCouleur;
  8212. input.onkeyup();
  8213. insertBefore(node,span);
  8214. }
  8215.  
  8216. function setChoixCouleurs() {
  8217. try {
  8218. //var form = document.getElementsByName('ActionForm')[0];
  8219. var form = document.getElementById('mhPlay');
  8220. var nodesAE = document.evaluate(
  8221. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  8222. "./table/tbody/tr/th[@class='mh_tdtitre']",
  8223. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  8224. form, null, 7, null
  8225. );
  8226. var nodes = document.evaluate(
  8227. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  8228. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  8229. form, null, 7, null
  8230. );
  8231. } catch(e) {
  8232. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  8233. return false;
  8234. };
  8235. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  8236. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  8237. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  8238. for(var i=0 ; i<5 ; i++) {
  8239. nodes.snapshotItem(i).id = 'tdAmis'+i;
  8240. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  8241. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  8242. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  8243. }
  8244. return true;
  8245. }
  8246.  
  8247. function fetchDiploGuilde() {
  8248. try {
  8249. for(var AE in {Amis:0,Ennemis:0}) {
  8250. for(var i=0 ; i<5 ; i++) {
  8251. /* Récup des A/E de rang i */
  8252. var td = document.getElementById('td'+AE+i);
  8253. var ligne = td.getElementsByTagName('table')[0].rows;
  8254. var titre = trim(td.firstChild.textContent);
  8255. // On laisse la gestion des couleurs à setChoixCouleurs:
  8256. var couleur = document.getElementById(AE+i).value;
  8257. diploGuilde[AE+i] = {
  8258. Troll:'',
  8259. Guilde:'',
  8260. titre: titre,
  8261. couleur: couleur
  8262. };
  8263. for(var j=1 ; j<ligne.length ; j++) {
  8264. var str = trim(ligne[j].cells[0].textContent);
  8265. var idx = str.lastIndexOf('(');
  8266. var num = str.slice(idx+1,-1);
  8267. var type = trim(ligne[j].cells[1].textContent);
  8268. diploGuilde[AE+i][type] += num+';';
  8269. }
  8270. }
  8271. }
  8272. } catch(e) {
  8273. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  8274. return false;
  8275. }
  8276. return true;
  8277. }
  8278.  
  8279.  
  8280. /*-[functions]--------------------- Handlers ---------------------------------*/
  8281.  
  8282. function toggleDetails() {
  8283. isDetailOn = !isDetailOn;
  8284. for(var AE in {Amis:0,Ennemis:0}) {
  8285. document.getElementById('spanAll'+AE).style.display =
  8286. (isDetailOn?'none':'');
  8287. for(var i=0 ; i<5 ; i++) {
  8288. document.getElementById('span'+AE+i).style.display =
  8289. (isDetailOn?'':'none');
  8290. }
  8291. }
  8292. }
  8293.  
  8294. function toggleMythiques() {
  8295. isMythiquesOn = !isMythiquesOn;
  8296. document.getElementById('spanMythiques').style.display =
  8297. (isMythiquesOn?'':'none');
  8298. }
  8299.  
  8300. function previewCouleur() {
  8301. var value = this.value;
  8302. if(isCouleur(value)) {
  8303. this.style.backgroundColor = value;
  8304. this.title = '';
  8305. } else {
  8306. this.style.backgroundColor = '';
  8307. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  8308. }
  8309. }
  8310.  
  8311. function appendMenuType(node,duType) {
  8312. var select = document.createElement('select');
  8313. select.className = 'SelectboxV2';
  8314. var type = ['Guilde','Troll','Monstre'];
  8315. for(var i=0 ; i<3 ; i++) {
  8316. appendOption(select,type[i],type[i]);
  8317. if(type[i]==duType) { select.selectedIndex=i; }
  8318. }
  8319. node.appendChild(select);
  8320. }
  8321.  
  8322. function ajouteChamp(type,num,couleur,descr) {
  8323. var champs = document.getElementById('diploPerso');
  8324. var nb = champs.rows.length;
  8325. var tr = champs.insertRow(-1);
  8326. var td = appendTd(tr);
  8327. appendMenuType(td,type);
  8328. td = appendTd(tr);
  8329. appendText(td,' n°');
  8330. appendTextbox(td,'text','num'+nb,6,15,num);
  8331. td = appendTd(tr);
  8332. appendText(td,' couleur HTML:');
  8333. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  8334. input.onkeyup = previewCouleur;
  8335. input.onchange = previewCouleur;
  8336. input.onkeyup();
  8337. td = appendTd(tr);
  8338. appendText(td,' Description:');
  8339. appendTextbox(td,'text','descr'+nb,30,150,descr);
  8340. td = appendTd(tr);
  8341. var span = document.createElement('span');
  8342. appendText(span,'[ok!]',true);
  8343. span.style.visibility = 'hidden';
  8344. td.appendChild(span);
  8345. td = appendTd(tr);
  8346. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  8347. }
  8348.  
  8349. function retireCeChamp() {
  8350. var thisTr = this.parentNode.parentNode;
  8351. thisTr.parentNode.removeChild(thisTr);
  8352. var champs = document.getElementById('diploPerso');
  8353. if(champs.rows.length==0) { ajouteChamp(); }
  8354. }
  8355.  
  8356. function valideChamp(champ) {
  8357. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  8358. isCouleur(champ.cells[2].childNodes[1].value);
  8359. if(isValide) {
  8360. champ.cells[4].firstChild.style.visibility = 'visible';
  8361. } else {
  8362. champ.cells[4].firstChild.style.visibility = 'hidden';
  8363. }
  8364. return isValide;
  8365. }
  8366.  
  8367. function sauvegarderTout() {
  8368. /* Diplo de guilde */
  8369. diploGuilde.isOn =
  8370. document.getElementById('isGuildeOn').checked?'true':'false';
  8371. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  8372. var numGuilde = Number(document.getElementById('numGuilde').value);
  8373. var couleur = document.getElementById('couleurGuilde').value;
  8374. if(numGuilde) {
  8375. diploGuilde.guilde = {
  8376. id: numGuilde,
  8377. couleur: couleur
  8378. };
  8379. } else {
  8380. delete diploGuilde.guilde;
  8381. }
  8382. for(var AE in {Amis:0,Ennemis:0}) {
  8383. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  8384. for(var i=0 ; i<5 ; i++) {
  8385. if(isDetailOn) {
  8386. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  8387. } else {
  8388. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  8389. }
  8390. }
  8391. }
  8392. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  8393.  
  8394. /* Diplo personnelle (ex-fonction saveChamps) */
  8395. var champs = document.getElementById('diploPerso');
  8396. diploPerso = {
  8397. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  8398. Guilde: {},
  8399. Troll: {},
  8400. Monstre: {}
  8401. };
  8402. if(isMythiquesOn &&
  8403. isCouleur(document.getElementById('couleurMythiques').value)) {
  8404. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  8405. }
  8406. for(var i=0 ; i<champs.rows.length ; i++) {
  8407. if(valideChamp(champs.rows[i])) {
  8408. var type = champs.rows[i].cells[0].firstChild.value;
  8409. var num = champs.rows[i].cells[1].childNodes[1].value;
  8410. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  8411. var descr = champs.rows[i].cells[3].childNodes[1].value;
  8412. diploPerso[type][num] = {
  8413. couleur: couleur
  8414. };
  8415. if(descr) {
  8416. diploPerso[type][num].titre = descr;
  8417. }
  8418. }
  8419. }
  8420. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  8421.  
  8422. avertissement('Données sauvegardées');
  8423. }
  8424.  
  8425.  
  8426. /*-[functions]------------- Modifications de la page -------------------------*/
  8427.  
  8428. function creeTablePrincipale() {
  8429. var insertPt = document.getElementById('insertPt');
  8430.  
  8431. /* Titre + bouton de Sauvegarde */
  8432. var tr = insertTr(insertPt,'mh_tdtitre');
  8433. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  8434. appendButton(td,'Sauvegarder',sauvegarderTout);
  8435.  
  8436. /* Options fixes */
  8437. tr = insertTr(insertPt,'mh_tdpage');
  8438. td = appendTdText(tr,'Diplomatie de guilde:',true);
  8439. appendBr(td);
  8440. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  8441. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  8442. appendBr(td);
  8443. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  8444. appendText(td,'Utiliser des couleurs détaillées (10)');
  8445.  
  8446. /* Diplo personnelle */
  8447. tr = insertTr(insertPt,'mh_tdpage');
  8448. td = appendTdText(tr,'Diplomatie personnelle:',true);
  8449. appendBr(td);
  8450. // Diplo Mythiques
  8451. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  8452. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  8453. var span = document.createElement('span');
  8454. span.id = 'spanMythiques';
  8455. if(!isMythiquesOn) {
  8456. span.style.display = 'none';
  8457. }
  8458. var couleur = '#FFAAAA';
  8459. if(diploPerso.mythiques) {
  8460. couleur = diploPerso.mythiques;
  8461. }
  8462. appendText(span,' - couleur HTML:');
  8463. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  8464. input.onkeyup = previewCouleur;
  8465. input.onchange = previewCouleur;
  8466. input.onkeyup();
  8467. td.appendChild(span);
  8468. appendBr(td);
  8469. // Diplo éditable
  8470. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  8471. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  8472. appendBr(td);
  8473. var table = document.createElement('table');
  8474. table.id = 'diploPerso'
  8475. td.appendChild(table);
  8476. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8477. for(var num in diploPerso[type]) {
  8478. ajouteChamp(
  8479. type,
  8480. num,
  8481. diploPerso[type][num].couleur,
  8482. diploPerso[type][num].titre
  8483. );
  8484. }
  8485. }
  8486. if(table.rows.length==0) {
  8487. ajouteChamp();
  8488. }
  8489. appendButton(td,'Ajouter',ajouteChamp)
  8490. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  8491. appendText(td,' ');
  8492. appendButton(td,
  8493. 'Exemples de couleur',
  8494. function() {
  8495. var fenetre = window.open(
  8496. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  8497. 'Divers',
  8498. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  8499. 'status=0,menubar=0,resizable=1,scrollbars=1'
  8500. );
  8501. fenetre.focus();
  8502. }
  8503. );
  8504.  
  8505. /* Couleur de Guilde */
  8506. tr = insertTr(insertPt,'mh_tdtitre');
  8507. td = appendTdText(tr,'GUILDE',true);
  8508. appendText(td,' - n°');
  8509. appendTextbox(td,'text','numGuilde',5,10,
  8510. diploGuilde.guilde && diploGuilde.guilde.id ?
  8511. diploGuilde.guilde.id : ''
  8512. );
  8513. appendText(td,' - Couleur HTML: ');
  8514. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  8515. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  8516. diploGuilde.guilde.couleur : '#BBBBFF'
  8517. );
  8518. input.onkeyup = previewCouleur;
  8519. input.onchange = previewCouleur;
  8520. input.onkeyup();
  8521. }
  8522.  
  8523.  
  8524. /*-[functions]----------------------- Main -----------------------------------*/
  8525.  
  8526. function initDiplo(sType) {
  8527. var sDiplo = MY_getValue(numTroll + '.diplo.' + sType)
  8528. //console.log('sDiplo' + sType + '=' + sDiplo);
  8529. if (sDiplo && (sDiplo != 'null')) { // le stockage JSON nous donne parfois 'null'
  8530. return JSON.parse(sDiplo);
  8531. } else {
  8532. return {};
  8533. }
  8534. }
  8535. var diploGuilde = initDiplo('guilde');
  8536. var diploPerso = initDiplo('perso');
  8537. var isDetailOn = diploGuilde.isDetailOn=='true';
  8538. var isMythiquesOn = diploPerso.mythiques!=undefined;
  8539.  
  8540. function do_diplo() {
  8541. if(setChoixCouleurs() && fetchDiploGuilde()) {
  8542. creeTablePrincipale();
  8543. }
  8544. }
  8545.  
  8546. /*******************************************************************************
  8547. * This file is part of Mountyzilla. *
  8548. * *
  8549. * Mountyzilla is free software; you can redistribute it and/or modify *
  8550. * it under the terms of the GNU General Public License as published by *
  8551. * the Free Software Foundation; either version 2 of the License, or *
  8552. * (at your option) any later version. *
  8553. * *
  8554. * Mountyzilla is distributed in the hope that it will be useful, *
  8555. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8556. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8557. * GNU General Public License for more details. *
  8558. * *
  8559. * You should have received a copy of the GNU General Public License *
  8560. * along with Mountyzilla; if not, write to the Free Software *
  8561. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8562. *******************************************************************************/
  8563.  
  8564. // x~x cdmcomp
  8565.  
  8566. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  8567.  
  8568. function getNonNegInts(str) {
  8569. var nbrs = str.match(/\d+/g);
  8570. for(var i=0 ; i<nbrs.length ; i++) {
  8571. nbrs[i] = Number(nbrs[i]);
  8572. }
  8573. return nbrs;
  8574. }
  8575.  
  8576. function traiteCdMcomp() {
  8577. try {
  8578. var msgEffet = document.getElementById('msgEffet');
  8579. } catch(e) {
  8580. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  8581. return;
  8582. }
  8583.  
  8584. // Début de récupération de la CdM
  8585. cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  8586. if (MY_DEBUG) window.console.log('cdm=' + cdm);
  8587.  
  8588. // Teste si ce message du bot est un message de CdM
  8589. if (cdm.indexOf('Famille du monstre') < 0) {
  8590. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  8591. return;
  8592. }
  8593.  
  8594. // envoi au serveur (PHP) d'un objet avec
  8595. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  8596. // tstamp: l'horodatage
  8597. var tabCdM = new Array();
  8598. var etimestamp = document.getElementById('hserveur');
  8599. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  8600. var txtBlessure;
  8601. var txtPv;
  8602. for (var iElt = 0; iElt < msgEffet.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  8603. var eHTML = msgEffet.childNodes[iElt];
  8604. switch (eHTML.nodeName) {
  8605. case '#text':
  8606. var s = eHTML.nodeValue.trim();
  8607. if (s != '') tabCdM.push(s);
  8608. break;
  8609. case 'P':
  8610. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8611. s = s.trim();
  8612. if (s != '') tabCdM.push(s);
  8613. break;
  8614. case 'TABLE':
  8615. var s = 'table';
  8616. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  8617. var eTr = eHTML.rows[iTr];
  8618. var tabTd = new Array();
  8619. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  8620. var eTd = eTr.cells[iTd];
  8621. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  8622. s = s.trim();
  8623. tabTd.push(s);
  8624. }
  8625. if (tabTd.length >= 2) {
  8626. if (tabTd[0].match(/Blessure/i)) {
  8627. txtBlessure = tabTd[1]
  8628. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  8629. txtPv = tabTd[1]
  8630. }
  8631. }
  8632. tabCdM.push(tabTd);
  8633. }
  8634. break;
  8635. default:
  8636. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  8637. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8638. if (s != '') tabCdM.push(s);
  8639. break;
  8640. }
  8641. }
  8642. var oData = {};
  8643. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  8644. oData.idTroll = numTroll;
  8645. oData.tabCdM = tabCdM;
  8646. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  8647.  
  8648. // envoi d'une CdM issue de compte-rendu de compétence
  8649. // fonction définie ici pour avoir vue sur la variable tabCdM
  8650. var sendInfoCDM = function () {
  8651. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  8652. var buttonCDM = this;
  8653. var texte = '';
  8654. FF_XMLHttpRequest({
  8655. method: 'POST',
  8656. url: URL_pageDispatcherV2,
  8657. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8658. headers : {
  8659. /* inutile, à supprimer
  8660. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8661. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8662. */
  8663. 'Content-type':'application/x-www-form-urlencoded',
  8664. },
  8665. trace: 'envoi CdM',
  8666. onload: function(responseDetails) {
  8667. texte = responseDetails.responseText;
  8668. buttonCDM.value = texte;
  8669. if (!isDEV) buttonCDM.disabled = true;
  8670. }
  8671. });
  8672. }
  8673.  
  8674. // Envoi auto ou insertion bouton envoi (suivant option)
  8675. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  8676. sendInfoCDM();
  8677. var p = document.createElement('p');
  8678. p.style.color = 'green';
  8679. appendText(p,'CdM envoyée vers la base MountyZilla !');
  8680. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  8681. } else {
  8682. insertButtonCdm('as_Action', sendInfoCDM);
  8683. }
  8684.  
  8685. // Insertion de l'estimation des PV restants
  8686. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  8687. if (txtBlessure !== undefined && txtPv !== undefined) {
  8688. var pv = getPVsRestants(txtPv,txtBlessure);
  8689. if (MY_DEBUG) window.console.log('pv=' + pv);
  8690. if (pv) { // pv null si le monstre n'est pas blessé
  8691. var trBless = document.evaluate(
  8692. "//tr[contains(th/text(),'Blessure')]",
  8693. msgEffet, null, 9, null).singleNodeValue;
  8694. var tr = document.createElement('tr');
  8695. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  8696. appendTr(trBless);
  8697. var th = appendThText(tr, pv[0], false);
  8698. th.className = trBless.cells[0].className;
  8699. var td = appendTdText(tr, pv[1], false);
  8700. var eSpan = document.createElement('span');
  8701. appendText(eSpan, ' (Calculé par Mountyzilla)');
  8702. eSpan.style.fontSize = "small";
  8703. eSpan.style.fontStyle = "italic";
  8704. td.appendChild(eSpan);
  8705. }
  8706. }
  8707. }
  8708.  
  8709. function do_cdmcomp() {
  8710. start_script(31);
  8711. traiteCdMcomp();
  8712. displayScriptTime();
  8713. }
  8714.  
  8715. /*********************************************************************************
  8716. * This file is part of Mountyzilla. *
  8717. * *
  8718. * Mountyzilla is free software; you can redistribute it and/or modify *
  8719. * it under the terms of the GNU General Public License as published by *
  8720. * the Free Software Foundation; either version 2 of the License, or *
  8721. * (at your option) any later version. *
  8722. * *
  8723. * Mountyzilla is distributed in the hope that it will be useful, *
  8724. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8725. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8726. * GNU General Public License for more details. *
  8727. * *
  8728. * You should have received a copy of the GNU General Public License *
  8729. * along with Mountyzilla; if not, write to the Free Software *
  8730. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8731. *********************************************************************************/
  8732.  
  8733. // x~x cmdbot
  8734.  
  8735. /* v0.2 by Dab - 2013-08-20
  8736. * - patch dégueu pour gérer la décomposition P/M de l'armure
  8737. */
  8738.  
  8739. var buttonCDM;
  8740.  
  8741. /*******************************************************************************************
  8742. CDM :
  8743. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  8744.  
  8745. Il ne vous est pas possible d'améliorer cette compétence.
  8746.  
  8747. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  8748. Niveau : Inimaginable (entre 49 et 51)
  8749. Points de Vie : Surtrollesque (entre 450 et 470)
  8750. Blessure (Approximatif) : 0 %
  8751. Dés d'Attaque : Impressionnant (entre 30 et 32)
  8752. Dés d'Esquive : Impressionnant (entre 28 et 30)
  8753. Dés de Dégat : Très Fort (entre 18 et 20)
  8754. Dés de Régénération : Excellent (égal à 13)
  8755. Armure Physique : Moyen (entre 10 et 12)
  8756. Armure Magique : Faible (inférieur à 6)
  8757. Vue : Moyen (entre 9 et 11)
  8758. Maitrise Magique : Inimaginable (supérieur à 6000)
  8759. Résistance Magique : Inimaginable (supérieur à 6000)
  8760. Nombre d'attaques : 1
  8761. Vitesse de Déplacement : Normale
  8762. Voir le Caché : Oui
  8763. Attaque à distance : Non
  8764. Attaque magique : Oui
  8765. Vole : Non
  8766. Sang froid : Inexistant
  8767. DLA : Milieu
  8768. Durée Tour : Remarquable (entre 9 et 11)
  8769. Chargement : Vide
  8770. Bonus Malus : Aucun
  8771.  
  8772. Vous avez également gagné 1 PX pour la réussite.
  8773. *******************************************************************************************
  8774. BOT :
  8775. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  8776.  
  8777. Le Monstre ciblé fait partie des : Mort-Vivant
  8778.  
  8779. Niveau : Incroyable (entre 36 et 38)
  8780. *******************************************************************************************/
  8781.  
  8782. function getNNInt(str) {
  8783. var nbrs = str.match(/\d+/g);
  8784. for (var i=0 ; i<nbrs.length ; i++)
  8785. nbrs[i] = parseInt(nbrs[i]);
  8786. return nbrs;
  8787. }
  8788.  
  8789. // envoi d'une CdM issue d'un message du BOT
  8790. function sendCDM() {
  8791. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  8792. document, null, 9, null).singleNodeValue;
  8793. /* ancienne version à supprimer
  8794. cdm = td.innerHTML;
  8795. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  8796. "$3$4 ($1 - N°$2)<br>");
  8797. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  8798. 'Blessure : XX % (approximativement)');
  8799. // Supprime la décomposition P/M de l'Armure
  8800. var bgn = cdm.indexOf('Armure Physique');
  8801. if (bgn!=-1) {
  8802. var end = cdm.indexOf('Vue')-2;
  8803. var lines = cdm.substring(bgn,end).split('<br>');
  8804. var armp = getNNInt(lines[0]);
  8805. var armm = getNNInt(lines[1]);
  8806. if (lines[0].indexOf('(inf')!=-1)
  8807. armp = [0,armp[0]];
  8808. if (lines[1].indexOf('(inf')!=-1)
  8809. armm = [0,armm[0]];
  8810. var insrt = 'Armure : ';
  8811. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  8812. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  8813. else
  8814. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  8815. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  8816. }
  8817. cdm = cdm.replace(/<br>/g,'\n');
  8818. */
  8819.  
  8820. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  8821. //window.console.log(tdTxt);
  8822. var oData = {};
  8823. oData.tabCdM = tdTxt.split(/\n/);
  8824. // nettoyage entête : enlève le premier élément tant que
  8825. // - suite de *
  8826. // - "MOUNTYHALL - La Terre des Trõlls"
  8827. // - ligne vide (la première expression régulière matche les lignes vides)
  8828. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  8829. // 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
  8830. var iLigneNonVide;
  8831. for (var i = 0; i < oData.tabCdM.length; i++) {
  8832. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  8833. if (iLigneNonVide === undefined)
  8834. oData.tabCdM.splice(i);
  8835. else
  8836. oData.tabCdM.splice(iLigneNonVide+1);
  8837. break;
  8838. }
  8839. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  8840. }
  8841. //window.console.log(JSON.stringify(oData));
  8842.  
  8843. FF_XMLHttpRequest({
  8844. method: 'POST',
  8845. url: URL_pageDispatcherV2,
  8846. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8847. headers : {
  8848. /* inutile, à supprimer
  8849. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8850. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8851. */
  8852. 'Content-type':'application/x-www-form-urlencoded',
  8853. },
  8854. trace: 'envoi CdM msg du bot',
  8855. onload: function(responseDetails) {
  8856. buttonCDM.value=responseDetails.responseText;
  8857. buttonCDM.disabled = true;
  8858. }
  8859. });
  8860. }
  8861.  
  8862. function traiteCdMmsg() {
  8863. // Teste si ce message du bot est un message de CdM
  8864. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  8865. document, null, 9, null).singleNodeValue;
  8866. if (!td) return false;
  8867.  
  8868. cdm = td.innerHTML;
  8869.  
  8870. // Insertion de l'estimation des PV restants
  8871. var des = cdm.indexOf('Dés');
  8872. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  8873. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  8874. if(pv)
  8875. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  8876.  
  8877. // Insertion bouton envoi + espace
  8878. buttonCDM = insertButtonCdm('bClose',sendCDM);
  8879. }
  8880.  
  8881. /*function traitePouvoir() {
  8882. // Teste si ce message du bot est un message de CdM
  8883. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  8884. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  8885. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  8886. if (!td)
  8887. return false;
  8888.  
  8889. var infos = td.innerHTML;
  8890. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  8891. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  8892. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  8893. var date = /alors : ([^<]+)\./.exec(infos)[1];
  8894. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  8895. var effetPouvoir="";
  8896. var full=false;
  8897. if(infos.indexOf("REDUIT")!=-1) {
  8898. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  8899. }
  8900. else {
  8901. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  8902. full=true;
  8903. }
  8904. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  8905. // On insère le bouton et un espace
  8906. //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));
  8907. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  8908. if(!MY_getValue('AUTOSENDPOUV'))
  8909. {
  8910. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  8911. button.setAttribute("onClick", "window.open('" + url
  8912. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  8913. + "this.value='Merci de votre participation'; this.disabled = true;");
  8914. }
  8915. else
  8916. {
  8917. FF_XMLHttpRequest({
  8918. method: 'GET',
  8919. url: url,
  8920. headers : {
  8921. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8922. 'Accept': 'application/atom+xml,application/xml,text/xml'
  8923. }});
  8924. }
  8925. }*/
  8926.  
  8927. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  8928. traiteCdMmsg();
  8929. }
  8930. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  8931.  
  8932. /*******************************************************************************
  8933. * This file is part of Mountyzilla. *
  8934. * *
  8935. * Mountyzilla is free software; you can redistribute it and/or modify *
  8936. * it under the terms of the GNU General Public License as published by *
  8937. * the Free Software Foundation; either version 2 of the License, or *
  8938. * (at your option) any later version. *
  8939. * *
  8940. * Mountyzilla is distributed in the hope that it will be useful, *
  8941. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8942. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8943. * GNU General Public License for more details. *
  8944. * *
  8945. * You should have received a copy of the GNU General Public License *
  8946. * along with Mountyzilla; if not, write to the Free Software *
  8947. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8948. *******************************************************************************/
  8949.  
  8950. // x~x menu
  8951. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  8952.  
  8953. var menuRac, mainIco;
  8954.  
  8955. // met à jour les carac sauvegardées (position, DLA, etc.)
  8956. function updateData() {
  8957. var inputs = document.getElementsByTagName('input');
  8958. var divs = document.getElementsByTagName('div');
  8959.  
  8960. //window.console.log('inputs=' + JSON.stringify(inputs));
  8961. if (inputs && inputs.length > 0) {
  8962. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  8963. numTroll = inputs[0].value;
  8964. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  8965. MY_setValue('NUM_TROLL', numTroll);
  8966. MY_setValue('NIV_TROLL',inputs[1].value);
  8967. if(!MY_getValue(numTroll+'.caracs.rm')) {
  8968. MY_setValue(numTroll+'.caracs.rm',0);
  8969. // assure l'init des 4 var de libs
  8970. }
  8971. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  8972. } else {
  8973. // onclick="EnterPJView(91305,750,550)"
  8974. var tabA = document.getElementsByTagName('a');
  8975. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  8976. var s = tabA[0].onclick.toString();;
  8977. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  8978. var m = s.match(/\((\d+) *,/);
  8979. //window.console.log('m=' + JSON.stringify(m));
  8980. numTroll = parseInt(m[1]);
  8981. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  8982. MY_setValue('NUM_TROLL', numTroll);
  8983. } else {
  8984. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  8985. }
  8986. }
  8987.  
  8988. var DLA = new Date(
  8989. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  8990. );
  8991. if(MY_getValue(numTroll+'.DLA.encours')) {
  8992. var DLAstockee = new Date(
  8993. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  8994. );
  8995. if(DLA>DLAstockee) {
  8996. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  8997. // Pose un pb en cas de décalage de DLA
  8998. }
  8999. }
  9000. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  9001.  
  9002. try {
  9003. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  9004. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  9005. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  9006. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  9007. } catch(e) {
  9008. 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, '‹'));
  9009. }
  9010. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  9011. }
  9012.  
  9013. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9014. function initRaccourcis() {
  9015. var anotherURL = MY_getValue('URL1');
  9016. if(!anotherURL) { return; }
  9017.  
  9018. /* Création de l'icône faisant apparaître le menu */
  9019. mainIco = document.createElement('img');
  9020. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  9021. if(!urlIco) {
  9022. urlIco =
  9023. URL_MZimg + 'mz_logo_small.png';
  9024. }
  9025. mainIco.src = urlIco;
  9026. mainIco.alt = 'MZ';
  9027. mainIco.style = 'position:fixed; top:0px; left:0px';
  9028. mainIco.onmouseover = afficheMenu;
  9029. document.body.appendChild(mainIco);
  9030.  
  9031. /* Création du menu des Raccourcis */
  9032. menuRac = document.createElement('div');
  9033. menuRac.className = 'mh_textbox';
  9034. menuRac.style =
  9035. 'position:fixed; top:10px; left:10px;'+
  9036. 'max-width:190px;'+
  9037. 'border-radius: 4px; padding: 4px;'+
  9038. 'z-index: 500;'+
  9039. 'visibility: hidden;';
  9040. document.body.appendChild(menuRac);
  9041. document.addEventListener('mousemove',cacheMenu,false);
  9042. var i=1;
  9043. while(anotherURL) {
  9044. var a = document.createElement('a');
  9045. var url = MY_getValue('URL'+i);
  9046. var nom = MY_getValue('URL'+i+'.nom');
  9047. var ico = MY_getValue('URL'+i+'.ico');
  9048. a.href = url;
  9049. a.target = '_blank';
  9050. if(ico) {
  9051. var txt = nom ? nom : '';
  9052. var img = createImage(ico,txt);
  9053. a.appendChild(img);
  9054. }
  9055. else {
  9056. appendText(a,'['+nom+']');
  9057. }
  9058. menuRac.appendChild(a);
  9059. appendBr(menuRac);
  9060. i++;
  9061. anotherURL = MY_getValue('URL'+i);
  9062. }
  9063. }
  9064.  
  9065. function afficheMenu() {
  9066. menuRac.style.visibility = 'visible';
  9067. }
  9068.  
  9069. function cacheMenu(e) {
  9070. if(menuRac.style.visibility=='hidden') { return; }
  9071. // Position souris
  9072. var ptX = e.clientX;
  9073. var ptY = e.clientY;
  9074. // On recalcule en live les BoundingBox pour mainIco et menuRac
  9075. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  9076. var menuRect = menuRac.getBoundingClientRect();
  9077. var icoRect = mainIco.getBoundingClientRect();
  9078. if((ptX>icoRect.width || ptY>icoRect.height) &&
  9079. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  9080. menuRac.style.visibility = 'hidden';
  9081. }
  9082. }
  9083.  
  9084. // ajout de l'icône, branchée sur un refresh
  9085. function initUpdateCoordGauche() {
  9086. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  9087. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  9088. var img = document.createElement('img');
  9089. img.src = URL_MZimg + 'recycl.png'
  9090. img.onclick = function(evt) {
  9091. document.location.href = document.location.href;
  9092. };
  9093. img.title = 'Mise à jour de la localisation';
  9094. img.style.cursor = 'pointer';
  9095. img.style.position = 'absolute';
  9096. img.style.bottom = 0;
  9097. img.style.left = 0;
  9098. div.appendChild(img);
  9099. }
  9100.  
  9101. function do_menu() {
  9102. // met à jour les carac sauvegardées (position, DLA, etc.)
  9103. updateData();
  9104. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9105. initRaccourcis();
  9106. // Ajout bouton de mise à jour coordonnées
  9107. initUpdateCoordGauche();
  9108. }
  9109.  
  9110. /*******************************************************************************
  9111. * This file is part of Mountyzilla. *
  9112. * *
  9113. * Mountyzilla is free software; you can redistribute it and/or modify *
  9114. * it under the terms of the GNU General Public License as published by *
  9115. * the Free Software Foundation; either version 2 of the License, or *
  9116. * (at your option) any later version. *
  9117. * *
  9118. * Mountyzilla is distributed in the hope that it will be useful, *
  9119. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9120. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9121. * GNU General Public License for more details. *
  9122. * *
  9123. * You should have received a copy of the GNU General Public License *
  9124. * along with Mountyzilla; if not, write to the Free Software *
  9125. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9126. *******************************************************************************/
  9127.  
  9128. // x~x vue
  9129.  
  9130. /* TODO
  9131. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  9132. * prévoir fix ("delete infos")
  9133. */
  9134.  
  9135. /*--------------------------- Variables Globales -----------------------------*/
  9136.  
  9137. // Position actuelle
  9138. var currentPosition=[0,0,0];
  9139.  
  9140. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  9141. var porteeVue=[0,0,0,0];
  9142.  
  9143. // Fenêtres déplaçables
  9144. var winCurr = null;
  9145. var offsetX, offsetY;
  9146.  
  9147. // Diplomatie
  9148. var Diplo = {
  9149. Guilde: {},
  9150. Troll: {},
  9151. Monstre: {}
  9152. // .mythiques: uniquement si option activée
  9153. };
  9154. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  9155.  
  9156. // Infos tactiques
  9157. var popup;
  9158.  
  9159.  
  9160.  
  9161. // Utilisé pour supprimer les monstres "engagés"
  9162. var listeEngages = {};
  9163. var isEngagesComputed = false;
  9164. var cursorOnLink = false; // DEBUG: wtf ?
  9165.  
  9166. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  9167. && MY_getValue(numTroll+'.enchantement.liste')!='';
  9168.  
  9169. // Checkboxes de filtrage
  9170. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  9171. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  9172. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  9173. comboBoxNiveauMin, comboBoxNiveauMax, comboBoxFamille;
  9174.  
  9175. /* Acquisition & Stockage des données de DB */
  9176. const typesAFetcher = {
  9177. 'monstres':1,
  9178. 'trolls':1,
  9179. 'tresors':1,
  9180. 'champignons':1,
  9181. 'lieux':1
  9182. }
  9183.  
  9184. var MZ_EtatCdMs = { // zone où sont stockées les variables "globales" pour la gestion des cdM et infos tactiques
  9185. nbMonstres: 0,
  9186. tr_monstres: [],
  9187. lastIndexDone: 0,
  9188. isCDMsRetrieved: false, // = si les CdM ont déjà été DL
  9189. listeCDM: [],
  9190. // Gère l'affichage en cascade des popups de CdM
  9191. yIndexCDM: 0,
  9192. tdWitdh: 110,
  9193. };
  9194.  
  9195. var VueContext = {};
  9196. var tr_trolls = {}, tr_tresors = {},
  9197. tr_champignons = {}, tr_lieux = {};
  9198. var nbTrolls = 0, nbTresors = 0,
  9199. nbChampignons = 0, nbLieux = 0;
  9200.  
  9201. function fetchData(type) {
  9202. var node;
  9203. try {
  9204. node = document.getElementById('mh_vue_hidden_'+type);
  9205. VueContext['tr_'+type] = node.getElementsByTagName('tr');
  9206. VueContext['nb'+type[0].toUpperCase()+type.slice(1)] = VueContext['tr_'+type].length-1;
  9207. } catch(e) {
  9208. window.console.warn('[MZ Vue] Erreur acquisition type '+type, e);
  9209. }
  9210. }
  9211.  
  9212. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  9213.  
  9214. function positionToString(arr) {
  9215. return arr.join(';');
  9216. }
  9217.  
  9218. function savePosition() {
  9219. // Stocke la position (à jour) de la vue pour les autres scripts
  9220. // DEBUG: Lesquels et pourquoi?
  9221. var pos = getPosition();
  9222. MY_setValue(numTroll+'.position.X',pos[0]);
  9223. MY_setValue(numTroll+'.position.Y',pos[1]);
  9224. MY_setValue(numTroll+'.position.N',pos[2]);
  9225. }
  9226.  
  9227.  
  9228. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  9229. /* INFOS :
  9230. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  9231. * sont identifiables via leur Name
  9232. * les tables-listings sont identifiables via l'ID du tr conteneur
  9233. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  9234. */
  9235.  
  9236. /* [functions] Récup données Utilisateur */
  9237. function getPosition() {
  9238. // Pour rétrocompatibilité
  9239. return currentPosition;
  9240. }
  9241.  
  9242. function getPorteVue() {
  9243. // Pour rétrocompatibilité
  9244. return porteeVue;
  9245. }
  9246.  
  9247. function getVue() {
  9248. // Retourne [vueHpure, vueVpure]
  9249. var vues = getPorteVue();
  9250. return [ vues[0], vues[1] ];
  9251. }
  9252.  
  9253. // Roule 11/03/2016
  9254. /* [functions] Récup données monstres, trolls, etc. */
  9255. function getXxxDistance(xxx, i) {
  9256. return parseInt(VueContext['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  9257. }
  9258. function getXxxPosition(xxx, i) {
  9259. var tds = VueContext['tr_' + xxx.toLowerCase()][i].childNodes;
  9260. var l = tds.length;
  9261. return [
  9262. parseInt(tds[l-3].textContent),
  9263. parseInt(tds[l-2].textContent),
  9264. parseInt(tds[l-1].textContent)
  9265. ];
  9266. }
  9267.  
  9268.  
  9269. /* [functions] Récup données monstres */
  9270. function getMonstreDistance(i) {
  9271. //debugMZ('getMonstreDistance, i=' + i + ', tr=' + MZ_EtatCdMs.tr_monstres[i].innerHTML);
  9272. return parseInt(MZ_EtatCdMs.tr_monstres[i].cells[0].textContent);
  9273. }
  9274.  
  9275. function getMonstreID(i) {
  9276. return Number(MZ_EtatCdMs.tr_monstres[i].cells[2].firstChild.nodeValue);
  9277. }
  9278.  
  9279. function getMonstreIDByTR(tr) {
  9280. return tr.cells[2].firstChild.nodeValue;
  9281. }
  9282.  
  9283. function getMonstreLevelNode(i) {
  9284. return MZ_EtatCdMs.tr_monstres[i].cells[3];
  9285. }
  9286.  
  9287. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  9288. if(!MZ_EtatCdMs.isCDMsRetrieved) return false;
  9289. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  9290. if (!donneesMonstre) return false;
  9291. var niv = donneesMonstre.niv;
  9292. if (niv == undefined) return false;
  9293. if (limitMin > 0 && niv.max && niv.max < limitMin) return true;
  9294. if (limitMax > 0 && niv.min && niv.min > limitMax) return true;
  9295. return false;
  9296. }
  9297.  
  9298. function getMonstreNomNode(i) {
  9299. try {
  9300. var td = document.evaluate(
  9301. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  9302. MZ_EtatCdMs.tr_monstres[i], null, 9, null
  9303. ).singleNodeValue;
  9304. return td;
  9305. } catch(e) {
  9306. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  9307. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  9308. }
  9309. }
  9310.  
  9311. function getMonstreNom(i) {
  9312. return getMonstreNomByTR(MZ_EtatCdMs.tr_monstres[i]);
  9313. }
  9314.  
  9315. function getMonstreNomByTR(tr) {
  9316. try {
  9317. var nom = document.evaluate(
  9318. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  9319. tr, null, 2, null
  9320. ).stringValue;
  9321. return nom;
  9322. } catch(e) {
  9323. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  9324. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  9325. }
  9326. }
  9327.  
  9328. function getMonstrePosition(i) {
  9329. var tds = MZ_EtatCdMs.tr_monstres[i].childNodes;
  9330. var l = tds.length;
  9331. return [
  9332. parseInt(tds[l-3].textContent),
  9333. parseInt(tds[l-2].textContent),
  9334. parseInt(tds[l-1].textContent)
  9335. ];
  9336. }
  9337.  
  9338. function appendMonstres(txt) {
  9339. for(var i=1; i<=MZ_EtatCdMs.nbMonstres ; i++)
  9340. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  9341. return txt;
  9342. }
  9343.  
  9344. function getMonstres() {
  9345. var vue = getVue();
  9346. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9347. }
  9348.  
  9349. function bddMonstres(start,stop) {
  9350. if(!start) { var start = 1; }
  9351. if(!stop) { var stop = MZ_EtatCdMs.nbMonstres; }
  9352. stop = Math.min(MZ_EtatCdMs.nbMonstres,stop);
  9353. var txt='';
  9354. for(var i=start ; i<=stop ; i++) {
  9355. txt += getMonstreID(i)+';'+
  9356. getMonstreNom(i)+';'+
  9357. positionToString(getMonstrePosition(i))+'\n';
  9358. }
  9359. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  9360. }
  9361.  
  9362. /* [functions] Récup données Trolls */
  9363.  
  9364. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  9365. const COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  9366.  
  9367. function getTrollDistance(i) {
  9368. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  9369. }
  9370.  
  9371. var MZ_cache_col_TrollID;
  9372. var MZ_cache_col_TrollNOM;
  9373. var MZ_cache_col_TrollGUILDE;
  9374. var MZ_cache_col_TrollNIV;
  9375.  
  9376. function MZ_find_col_titre(trs, titre) {
  9377. var l = titre.length;
  9378. for (var i=0; i < trs[0].cells.length; i++)
  9379. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  9380. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  9381. return 0;
  9382. }
  9383.  
  9384. function getTrollID(i) {
  9385. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  9386. // Roule 08/03/2017 protection
  9387. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  9388. if (isNaN(iTroll)) return;
  9389. if (iTroll == 0) return;
  9390. return iTroll;
  9391. }
  9392.  
  9393. function getTrollNomNode(i) {
  9394. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  9395. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  9396. }
  9397.  
  9398. function getTrollNivNode(i) {
  9399. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  9400. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  9401. }
  9402.  
  9403. function getTrollGuilde(i) {
  9404. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9405. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  9406. }
  9407.  
  9408. function getTrollGuildeID(i) {
  9409. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9410. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  9411. var href;
  9412. try {
  9413. 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"
  9414. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  9415. } catch(e) { // debug pb remonté par Marsak
  9416. window.console.error(traceStack(e, 'getTrollGuildeID')
  9417. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  9418. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  9419. return -1;
  9420. }
  9421. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  9422. }
  9423. return -1;
  9424. }
  9425.  
  9426. function getTrollPosition(i) {
  9427. var tds = tr_trolls[i].childNodes;
  9428. var l = tds.length;
  9429. return [
  9430. parseInt(tds[l-3].textContent),
  9431. parseInt(tds[l-2].textContent),
  9432. parseInt(tds[l-1].textContent)
  9433. ];
  9434. }
  9435.  
  9436. function bddTrolls() {
  9437. var txt='#DEBUT TROLLS\n'+
  9438. numTroll+';'+positionToString(getPosition())+'\n';
  9439. for(var i=1 ; i<=nbTrolls ; i++) {
  9440. txt += getTrollID(i)+';'+
  9441. positionToString(getTrollPosition(i))+'\n';
  9442. }
  9443. return txt+'#FIN TROLLS';
  9444. }
  9445.  
  9446. /* [functions] Récup données Trésors */
  9447. function getTresorDistance(i) {
  9448. return tr_tresors[i].cells[0].firstChild.nodeValue;
  9449. }
  9450.  
  9451. function getTresorID(i) {
  9452. return trim(tr_tresors[i].cells[2].textContent);
  9453. }
  9454.  
  9455. function getTresorNom(i) {
  9456. // Utilisation de textContent pour régler le "bug de Pollux"
  9457. return trim(tr_tresors[i].cells[3].textContent);
  9458. }
  9459.  
  9460. function getTresorPosition(i) {
  9461. var tds = tr_tresors[i].childNodes;
  9462. var l = tds.length;
  9463. return [
  9464. parseInt(tds[l-3].textContent),
  9465. parseInt(tds[l-2].textContent),
  9466. parseInt(tds[l-1].textContent),
  9467. ];
  9468. }
  9469.  
  9470. function bddTresors(dmin,start,stop) {
  9471. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  9472. if(!dmin) { var dmin = 0; }
  9473. if(!start) { var start = 1; }
  9474. if(!stop) { var stop = nbTresors; }
  9475. stop = Math.min(nbTresors,stop);
  9476. var txt='';
  9477. for(var i=start ; i<=stop ; i++) {
  9478. if(getTresorDistance(i)>=dmin) {
  9479. txt += getTresorID(i)+';'+
  9480. getTresorNom(i)+';'+
  9481. positionToString(getTresorPosition(i))+'\n';
  9482. }
  9483. }
  9484. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  9485. }
  9486.  
  9487. /* [functions] Récup données Champignons */
  9488. // DEBUG: Pas de colonne "Référence" sur serveur de test
  9489. function getChampignonNom(i) {
  9490. return trim(tr_champignons[i].cells[2].textContent);
  9491. }
  9492.  
  9493. function getChampignonPosition(i) {
  9494. var tds = tr_champignons[i].childNodes;
  9495. var l = tds.length;
  9496. return [
  9497. parseInt(tds[l-3].textContent),
  9498. parseInt(tds[l-2].textContent),
  9499. parseInt(tds[l-1].textContent)
  9500. ];
  9501. }
  9502.  
  9503. function bddChampignons() {
  9504. var txt='';
  9505. for(var i=1 ; i<=nbChampignons ; i++) {
  9506. txt += ';'+ // Les champis n'ont pas de Référence
  9507. getChampignonNom(i)+';'+
  9508. positionToString(getChampignonPosition(i))+'\n';
  9509. }
  9510. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  9511. }
  9512.  
  9513. /* [functions] Récup données Lieux */
  9514. function getLieuDistance(i) {
  9515. return parseInt(tr_lieux[i].cells[0].textContent);
  9516. }
  9517.  
  9518. function getLieuID(i) {
  9519. return parseInt(tr_lieux[i].cells[2].textContent);
  9520. }
  9521.  
  9522. function getLieuNom(i) {
  9523. // Conversion ASCII pour éviter les bugs des Vues externes
  9524. return trim(tr_lieux[i].cells[3].textContent);
  9525. }
  9526.  
  9527. function getLieuPosition(i) {
  9528. var tds = tr_lieux[i].childNodes;
  9529. var l = tds.length;
  9530. return [
  9531. parseInt(tds[l-3].textContent),
  9532. parseInt(tds[l-2].textContent),
  9533. parseInt(tds[l-1].textContent)
  9534. ];
  9535. }
  9536.  
  9537. function appendLieux(txt) {
  9538. for(var i = 1; i < nbLieux+1; i++) {
  9539. var tds = x_lieux[i].childNodes;
  9540. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  9541. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  9542. }
  9543. return txt;
  9544. }
  9545.  
  9546. function getLieux() {
  9547. var vue = getVue();
  9548. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9549. }
  9550.  
  9551. function bddLieux(start,stop) {
  9552. if(!start) { var start = 1; }
  9553. if(!stop) { var stop = nbLieux; }
  9554. stop = Math.min(nbLieux,stop);
  9555. var txt='';
  9556. for(var i=start ; i<=stop ; i++) {
  9557. txt += getLieuID(i)+';'+
  9558. epure(getLieuNom(i))+';'+
  9559. positionToString(getLieuPosition(i))+'\n';
  9560. }
  9561. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  9562. }
  9563.  
  9564.  
  9565. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  9566.  
  9567. function saveCheckBox(chkbox, pref) {
  9568. // Enregistre et retourne l'état d'une CheckBox
  9569. var etat = chkbox.checked;
  9570. MY_setValue(pref, etat ? 'true' : 'false' );
  9571. return etat;
  9572. }
  9573.  
  9574. function recallCheckBox(chkbox, pref) {
  9575. // Restitue l'état d'une CheckBox
  9576. chkbox.checked = (MY_getValue(pref)=='true');
  9577. }
  9578.  
  9579. function saveComboBox(cbb, pref) {
  9580. // Enregistre et retourne l'état d'une ComboBox
  9581. var opt = cbb.options[cbb.selectedIndex];
  9582. if (!opt) return;
  9583. var etat = cbb.options[cbb.selectedIndex].value;
  9584. MY_setValue(pref, etat);
  9585. return etat;
  9586. }
  9587.  
  9588. function recallComboBox(cbb, pref) {
  9589. // Restitue l'état d'une ComboBox
  9590. var nb = MY_getValue(pref);
  9591. if(nb) cbb.value = nb;
  9592. return nb;
  9593. }
  9594.  
  9595. function synchroniseFiltres() {
  9596. // Récupération de toutes les options de la vue
  9597. var wasActive =
  9598. Number(recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE')) +
  9599. Number(recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE')) +
  9600. Number(recallComboBox(comboBoxFamille,'FAMILLEMONSTRE'));
  9601. if(wasActive>0) {
  9602. debutFiltrage('Monstres');
  9603. }
  9604. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9605. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9606. recallCheckBox(checkBoxMythiques,'NOMYTH');
  9607. recallCheckBox(checkBoxEngages,'NOENGAGE');
  9608. recallCheckBox(checkBoxLevels,'NOLEVEL');
  9609. recallCheckBox(checkBoxIntangibles,'NOINT');
  9610. recallCheckBox(checkBoxGG,'NOGG');
  9611. recallCheckBox(checkBoxCompos,'NOCOMP');
  9612. recallCheckBox(checkBoxBidouilles,'NOBID');
  9613. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  9614. recallCheckBox(checkBoxTrou,'NOTROU');
  9615. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9616. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  9617. if(MY_getValue('NOINFOEM')!='true')
  9618. recallCheckBox(checkBoxEM,'NOEM');
  9619. }
  9620.  
  9621.  
  9622. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  9623.  
  9624. function getVueScript() {
  9625. try {
  9626. var txt = bddTrolls()+
  9627. bddMonstres()+
  9628. bddChampignons()+
  9629. bddTresors()+
  9630. bddLieux()+
  9631. '#DEBUT ORIGINE\n'+
  9632. getPorteVue()[2]+';'+positionToString(getPosition())+
  9633. '\n#FIN ORIGINE\n';
  9634. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  9635. return txt;
  9636. } catch(e) {
  9637. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  9638. window.console.error(traceStack(e, 'getVueScript'))
  9639. }
  9640. }
  9641.  
  9642. /* [functions] Menu Vue 2D */
  9643. var vue2Ddata = {
  9644. 'Bricol\' Vue': {
  9645. url: URL_bricol_mountyhall + 'vue_form.php',
  9646. paramid: 'vue',
  9647. func: getVueScript,
  9648. extra_params: {
  9649. 'mode': 'vue_SP_Vue2',
  9650. 'screen_width': window.screen.width
  9651. }
  9652. },
  9653. 'Vue du CCM': {
  9654. url: URL_vue_CCM,
  9655. paramid: 'vue',
  9656. func: getVueScript,
  9657. extra_params: {
  9658. 'id': numTroll+';'+positionToString(getPosition())
  9659. }
  9660. },
  9661. 'Vue Gloumfs 2D': {
  9662. url: URL_vue_Gloumfs2D,
  9663. paramid: 'vue_mountyzilla',
  9664. func: getVueScript,
  9665. extra_params: {}
  9666. },
  9667. 'Vue Gloumfs 3D': {
  9668. url: URL_vue_Gloumfs3D,
  9669. paramid: 'vue_mountyzilla',
  9670. func: getVueScript,
  9671. extra_params: {}
  9672. },
  9673. 'Grouky Vue!': {
  9674. url: URL_vue_Grouky,
  9675. paramid: 'vue',
  9676. func: getVueScript,
  9677. extra_params: {
  9678. 'type_vue': 'V5b1'
  9679. }
  9680. },
  9681. /*'DEBUG': {
  9682. url: 'http://weblocal/testeur.php',
  9683. paramid: 'vue',
  9684. func: getVueScript,
  9685. extra_params: {}
  9686. }*/
  9687. };
  9688.  
  9689. function refresh2DViewButton() {
  9690. // = EventListener menu+bouton vue 2D
  9691. var vueext = document.getElementById('selectVue2D').value;
  9692. MY_setValue('VUEEXT',vueext);
  9693. var form = document.getElementById('viewForm');
  9694. form.innerHTML = '';
  9695. form.method = 'post';
  9696. form.action = vue2Ddata[vueext].url;
  9697. form.target = '_blank';
  9698. appendHidden(form, vue2Ddata[vueext].paramid, '');
  9699. for(var key in vue2Ddata[vueext].extra_params) {
  9700. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  9701. }
  9702. appendSubmit(form, 'Voir',
  9703. function() {
  9704. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  9705. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  9706. vue2Ddata[vueext].func();
  9707. }
  9708. );
  9709. }
  9710.  
  9711. function set2DViewSystem() {
  9712. // Initialise le système de vue 2D
  9713. // Recherche du point d'insertion
  9714. var center;
  9715. try {
  9716. // Roule 09/03/2019, encore un changement MH, je fais suivre comme je peux
  9717. center = document.getElementById('titre2');
  9718. // version initiale "pré-Roule"
  9719. if (!center) center = document.evaluate(
  9720. "//h2[@id='titre2']/following-sibling::center",
  9721. document, null, 9, null
  9722. ).singleNodeValue;
  9723. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  9724. if (!center) center = document.evaluate(
  9725. "//h2[@id='titre2']/following-sibling::div",
  9726. document, null, 9, null
  9727. ).singleNodeValue;
  9728.  
  9729. } catch(e) {
  9730. avertissement("Erreur d'initialisation du système de vue 2D");
  9731. window.console.error(traceStack(e, 'set2DViewSystem'));
  9732. return;
  9733. }
  9734.  
  9735. // Récupération de la dernière vue utilisée
  9736. var vueext = MY_getValue('VUEEXT');
  9737. if(!vueext || !vue2Ddata[vueext]) {
  9738. // sinon, la vue Bricol'Trolls est employée par défaut
  9739. vueext = 'Bricol\' Vue';
  9740. }
  9741.  
  9742. try {
  9743. // Création du sélecteur de vue externe
  9744. selectVue2D = document.createElement('select');
  9745. selectVue2D.id = 'selectVue2D';
  9746. selectVue2D.className = 'SelectboxV2';
  9747. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  9748. for(var view in vue2Ddata) {
  9749. appendOption(selectVue2D, view, view);
  9750. }
  9751. selectVue2D.value = vueext;
  9752. selectVue2D.onchange = refresh2DViewButton;
  9753.  
  9754. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  9755. var form = document.createElement('form');
  9756. form.id = 'viewForm';
  9757.  
  9758. // Insertion du système de vue
  9759. var table = document.createElement('table');
  9760. var tr = appendTr(table);
  9761. var td = appendTd(tr);
  9762. td.appendChild(selectVue2D);
  9763. td = appendTd(tr);
  9764. td.style.fontSize = '0px'; // gère le bug de l'extra character
  9765. td.appendChild(form);
  9766. if (center.id == 'titre2') { // 09/03/2019 nouvelle méthode
  9767. var eDiv = document.createElement('div');
  9768. eDiv.appendChild(table);
  9769. eDiv.style.witdth = '100%';
  9770. eDiv.style.textAlign = 'center';
  9771. table.style.width = '180px';
  9772. table.style.margin = '0 auto';
  9773. center.parentNode.insertBefore(eDiv,center.nextSibling);
  9774. } else { // ancienne méthode
  9775. center.insertBefore(table,center.firstChild);
  9776. insertBr(center.childNodes[1]);
  9777. }
  9778.  
  9779. // Appelle le handler pour initialiser le bouton de submit
  9780. refresh2DViewButton();
  9781. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  9782. } catch(e) {
  9783. avertissement("Erreur de traitement du système de vue 2D");
  9784. window.console.error(traceStack(e, 'set2DViewSystem'));
  9785. }
  9786. }
  9787.  
  9788. /* [functions] Tableau d'Infos */
  9789. function initialiseInfos() {
  9790. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  9791. var
  9792. infoTab = document.getElementsByName('LimitViewForm')[0].
  9793. getElementsByTagName('table')[0],
  9794. tbody = infoTab.tBodies[0],
  9795. thead = infoTab.createTHead(),
  9796. tr = appendTr(thead,'mh_tdtitre'),
  9797. td = appendTdText(tr,'INFORMATIONS',true),
  9798. span = document.createElement('span');
  9799.  
  9800. // Récupération de la position du joueur
  9801. try {
  9802. var strPos = document.evaluate(
  9803. ".//li/b/text()[contains(.,'X = ')]",
  9804. infoTab, null, 9, null
  9805. ).singleNodeValue.nodeValue;
  9806. // ***INIT GLOBALE*** currentPosition
  9807. currentPosition = getNumbers(strPos);
  9808. debugMZ("retrievePosition(): "+currentPosition);
  9809. } catch(e) {
  9810. // Si on ne trouve pas le "X ="
  9811. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  9812. }
  9813.  
  9814. // Récupération des portées (max et limitée) de la vue
  9815. try {
  9816. var
  9817. nodes = document.evaluate(
  9818. ".//li/b/text()[contains(.,'horizontalement') "+
  9819. "or contains(.,'verticalement')]",
  9820. infoTab, null, 7, null
  9821. ),
  9822. array = [];
  9823. for(var i=0 ; i<4 ; i++) {
  9824. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  9825. }
  9826. // ***INIT GLOBALE*** porteeVue
  9827. porteeVue = array;
  9828. } catch(e) {
  9829. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  9830. }
  9831.  
  9832. infoTab.id = 'infoTab'; // Pour scripts externes
  9833. tbody.id = 'corpsInfoTab';
  9834. tbody.rows[0].cells[0].colSpan = 2;
  9835. td.colSpan = 3;
  9836. td.onmouseover = function() {
  9837. this.style.cursor = 'pointer';
  9838. this.className = 'mh_tdpage';
  9839. };
  9840. td.onmouseout = function() {
  9841. this.className = 'mh_tdtitre';
  9842. };
  9843. td.onclick = function() {
  9844. toggleTableauInfos(false);
  9845. };
  9846.  
  9847. span.id = 'msgInfoTab';
  9848. span.style.display = 'none';
  9849. appendText(
  9850. span,
  9851. ' => Position : X = '+currentPosition[0]+
  9852. ', Y = '+currentPosition[1]+
  9853. ', N = '+currentPosition[2]+
  9854. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  9855. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  9856. true
  9857. );
  9858. td.appendChild(span);
  9859.  
  9860. tr = appendTr(tbody,'mh_tdpage');
  9861. td = appendTdText(tr,'EFFACER : ',true);
  9862. td.align = 'center';
  9863. td.className = 'mh_tdtitre';
  9864. td.width = 100;
  9865. td = appendTdCenter(tr,2);
  9866. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  9867. checkBoxGG = appendCheckBoxSpan(
  9868. td,'delgg',filtreTresors," Les GG'"
  9869. ).firstChild;
  9870. checkBoxCompos = appendCheckBoxSpan(
  9871. td,'delcomp',filtreTresors,' Les Compos'
  9872. ).firstChild;
  9873. checkBoxBidouilles = appendCheckBoxSpan(
  9874. td,'delbid',filtreTresors,' Les Bidouilles'
  9875. ).firstChild;
  9876. checkBoxIntangibles = appendCheckBoxSpan(
  9877. td,'delint',filtreTrolls,' Les Intangibles'
  9878. ).firstChild;
  9879. checkBoxGowapsA = appendCheckBoxSpan(
  9880. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  9881. ).firstChild;
  9882. checkBoxGowapsS = appendCheckBoxSpan(
  9883. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  9884. ).firstChild;
  9885. checkBoxEngages = appendCheckBoxSpan(
  9886. td,'delengage',filtreMonstres,' Les Engagés'
  9887. ).firstChild;
  9888. checkBoxLevels = appendCheckBoxSpan(
  9889. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  9890. ).firstChild;
  9891. checkBoxDiplo = appendCheckBoxSpan(
  9892. td,'delDiplo',refreshDiplo,' La Diplomatie'
  9893. ).firstChild;
  9894. checkBoxTrou = appendCheckBoxSpan(
  9895. td,'deltrou',filtreLieux,' Les Trous'
  9896. ).firstChild;
  9897. checkBoxMythiques = appendCheckBoxSpan(
  9898. td,'delmyth',filtreMonstres,' Les Mythiques'
  9899. ).firstChild;
  9900. if(MY_getValue('NOINFOEM')!='true') {
  9901. checkBoxEM = appendCheckBoxSpan(
  9902. td,'delem',filtreMonstres,' Les Composants EM'
  9903. ).firstChild;
  9904. }
  9905. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  9906. td,'deltres',filtreTresors,' Les Trésors non libres'
  9907. ).firstChild;
  9908. checkBoxTactique = appendCheckBoxSpan(
  9909. td,'deltactique',updateTactique,' Les Infos tactiques'
  9910. ).firstChild;
  9911.  
  9912. if(MY_getValue('INFOPLIE')) {
  9913. toggleTableauInfos(true);
  9914. }
  9915. }
  9916.  
  9917. function toggleTableauInfos(firstRun) {
  9918. var
  9919. msg = document.getElementById('msgInfoTab'),
  9920. corps = document.getElementById('corpsInfoTab'),
  9921. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9922. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  9923. if(!firstRun) {
  9924. infoplie = !infoplie;
  9925. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  9926. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  9927. }
  9928. if(infoplie) {
  9929. msg.style.display = '';
  9930. corps.style.display = 'none';
  9931. } else {
  9932. msg.style.display = 'none';
  9933. corps.style.display = '';
  9934. }
  9935. }
  9936.  
  9937. /* [functions] Filtres */
  9938. function prepareFiltrage(ref,width) {
  9939. // = Initialise le filtre 'ref'
  9940. try {
  9941. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  9942. } catch(e) {
  9943. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée', e);
  9944. return false;
  9945. }
  9946. if(width) { tdTitre.width = width+'px'; }
  9947. // Ajout du tr de Filtrage (masqué)
  9948. var tbody = tdTitre.parentNode.parentNode;
  9949. var tr = appendTr(tbody,'mh_tdpage');
  9950. tr.style.display = 'none';
  9951. tr.id = 'trFiltre'+ref;
  9952. var td = appendTd(tr);
  9953. td.colSpan = 5;
  9954. // Ajout du bouton de gestion de Filtrage
  9955. var tdBtn = insertAfterTd(tdTitre);
  9956. tdBtn.id = 'tdInsert'+ref;
  9957. var btn = appendButton(tdBtn,'Filtrer');
  9958. btn.id = 'btnFiltre'+ref;
  9959. btn.onclick = function() {
  9960. debutFiltrage(ref);
  9961. };
  9962. return td;
  9963. }
  9964.  
  9965. function debutFiltrage(ref) {
  9966. // = Handler de début de filtrage (filtre 'ref')
  9967. document.getElementById('trFiltre'+ref).style.display = '';
  9968. var btn = document.getElementById('btnFiltre'+ref);
  9969. btn.value = 'Annuler Filtre';
  9970. btn.onclick = function() {
  9971. finFiltrage(ref);
  9972. };
  9973. }
  9974.  
  9975. function finFiltrage(ref) {
  9976. // = Handler de fin de filtrage (filtre 'ref')
  9977. /* On réassigne le bouton 'Filtrer' */
  9978. document.getElementById('trFiltre'+ref).style.display = 'none';
  9979. var btn = document.getElementById('btnFiltre'+ref);
  9980. btn.value = 'Filtrer';
  9981. btn.onclick = function() {
  9982. debutFiltrage(ref);
  9983. };
  9984. /* Réinitialisation filtres */
  9985. document.getElementById('str'+ref).value = '';
  9986. switch(ref) {
  9987. case 'Monstres':
  9988. document.getElementById('nivMinMonstres').value = 0;
  9989. document.getElementById('nivMaxMonstres').value = 0;
  9990. document.getElementById('FamilleMonstres').value = 0;
  9991. break;
  9992. case 'Trolls':
  9993. document.getElementById('strGuildes').value = '';
  9994. }
  9995. /* Nettoyage (=lance le filtre) */
  9996. // Ici this = MZ.global = sandBox de travail de MZ
  9997. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  9998. //this['filtre'+ref]();
  9999. switch (ref) {
  10000. case 'Monstres':
  10001. filtreMonstres();
  10002. break;
  10003. case 'Trolls':
  10004. filtreTrolls();
  10005. break;
  10006. case 'Tresors':
  10007. filtreTresors();
  10008. break;
  10009. case 'Lieux':
  10010. filtreLieux();
  10011. break;
  10012. default:
  10013. window.console.log('cas incongru dans finFiltrage : ' + ref);
  10014. break;
  10015. }
  10016. }
  10017.  
  10018. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  10019. var bouton = appendButton(td,nomBouton,onClick);
  10020. appendText(td,'\u00a0');
  10021. var textbox = appendTextbox(td,'text',id,15,30);
  10022. textbox.onkeypress = function(event) {
  10023. try {
  10024. if(event.keyCode==13) {
  10025. event.preventDefault();
  10026. bouton.click();
  10027. }
  10028. }
  10029. catch(e){
  10030. window.alert(e)
  10031. }
  10032. };
  10033. }
  10034.  
  10035. function ajoutFiltreMenu(tr,id,onChange,liste) {
  10036. var select = document.createElement('select');
  10037. select.id = id;
  10038. select.onchange = onChange;
  10039. appendOption(select,0,'Aucun');
  10040. if (liste == undefined) {
  10041. for(var i=1 ; i<=60 ; i++) {
  10042. appendOption(select,i,i);
  10043. }
  10044. } else {
  10045. liste.forEach(function(f) {appendOption(select,f,f);});
  10046. }
  10047. tr.appendChild(select);
  10048. return select;
  10049. }
  10050.  
  10051. function ajoutDesFiltres() {
  10052. /* Monstres */
  10053. var td = prepareFiltrage('Monstres',130);
  10054. if(td) {
  10055. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  10056. appendText(td,'\u00a0\u00a0\u00a0');
  10057. appendText(td,'Niveau Min: ');
  10058. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  10059. appendText(td,'\u00a0');
  10060. appendText(td,'Niveau Max: ');
  10061. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  10062. appendText(td,'\u00a0');
  10063. appendText(td,'Famille: ');
  10064. comboBoxFamille = ajoutFiltreMenu(td,'FamilleMonstres',filtreMonstres,['Animal', 'Insecte','Démon','Humanoide','Monstre','Mort-Vivant']);
  10065. }
  10066. /* Trõlls */
  10067. td = prepareFiltrage('Trolls',50);
  10068. if(td) {
  10069. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  10070. appendText(td,'\u00a0\u00a0\u00a0');
  10071. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  10072. }
  10073. /* Trésors */
  10074. td = prepareFiltrage('Tresors',55);
  10075. if(td) {
  10076. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  10077. }
  10078. /* Lieux */
  10079. td = prepareFiltrage('Lieux',40);
  10080. if(td) {
  10081. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  10082. }
  10083. }
  10084.  
  10085. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  10086.  
  10087. /* [functions] Affichage de la colonne des niveaux */
  10088. function insertLevelColumn() {
  10089. // Appelé dans le code attaché à la page de vue et au click/unclick de la checkbox
  10090.  
  10091. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  10092. td.width = 25;
  10093. td.id = 'MZ_TITRE_NIVEAU_MONSTRE';
  10094. for(var i=1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10095. //window.console.log('nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', MZ_EtatCdMs.tr_monstres.length=' + MZ_EtatCdMs.tr_monstres.length); // debug Roule
  10096. td = insertTdText(getMonstreLevelNode(i), '-');
  10097. td.style = 'font-weight:bold;text-align:center;';
  10098. }
  10099. }
  10100.  
  10101. function toggleLevelColumn() { // Appelé par le code attaché à la page de vue et au click/unclick de la checkbox NOCDM
  10102. var eltMZ_TITRE_NIVEAU_MONSTRE = document.getElementById('MZ_TITRE_NIVEAU_MONSTRE'); // test si la colonne a déjà été ajoutée
  10103. if(saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  10104. 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é
  10105. // cacher tous les td
  10106. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10107. getMonstreLevelNode(i).style.display = 'none';
  10108. }
  10109. } else {
  10110. if (!eltMZ_TITRE_NIVEAU_MONSTRE) {
  10111. insertLevelColumn();
  10112. retrieveCDMs();
  10113. } else {
  10114. // afficher tous les td
  10115. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10116. getMonstreLevelNode(i).style.display = '';
  10117. }
  10118. }
  10119. }
  10120. }
  10121.  
  10122. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  10123. function basculeCDM(nom,id) {
  10124. // = Bascule l'affichage des popups CdM
  10125. if(MZ_EtatCdMs.listeCDM[id]) {
  10126. if(!document.getElementById('popupCDM'+id)) {
  10127. afficherCDM(nom, id);
  10128. } else {
  10129. cacherPopupCDM('popupCDM'+id);
  10130. }
  10131. } else {
  10132. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  10133. window.console.log("pas de CdM pour id=" + id + ', nom=' + nom);
  10134. }
  10135. }
  10136.  
  10137. function cacherPopupCDM(titre) {
  10138. var popup = document.getElementById(titre);
  10139. popup.parentNode.removeChild(popup);
  10140. }
  10141.  
  10142. function removeTableFromClickEvent() { // "this" est supposé être un <td> ou <th> d'une <table>
  10143. var table = this.parentNode.parentNode.parentNode; // <tr><tbody/thead/tfoot><table>
  10144. table.parentNode.removeChild(table);
  10145. }
  10146.  
  10147. /* DEBUG: Section à mettre à jour */
  10148. var selectionFunction;
  10149.  
  10150. function startDrag(evt) {
  10151. winCurr = this.parentNode;
  10152. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  10153. offsetX = evt.pageX - parseInt( winCurr.style.left );
  10154. offsetY = evt.pageY - parseInt( winCurr.style.top );
  10155. selectionFunction = document.body.style.MozUserSelect;
  10156. document.body.style.MozUserSelect = 'none';
  10157. winCurr.style.MozUserSelect = 'none';
  10158. return false;
  10159. }
  10160.  
  10161. function stopDrag(evt) {
  10162. winCurr.style.MozUserSelect = selectionFunction;
  10163. document.body.style.MozUserSelect = selectionFunction;
  10164. winCurr = null;
  10165. }
  10166.  
  10167. function drag(evt) {
  10168. if(winCurr==null) { return; }
  10169. evt = evt || window.event;
  10170. winCurr.style.left = (evt.pageX - offsetX)+'px';
  10171. winCurr.style.top = (evt.pageY - offsetY)+'px';
  10172. return false;
  10173. }
  10174. /* FIN DEBUG */
  10175. if(!isPage("MH_Play/Play_equipement")) {
  10176. // Conflit overlib/Tout_MZ:
  10177. // Double définition du "onmousemove" sur la page d'équipement
  10178. document.onmousemove = drag;
  10179. }
  10180.  
  10181. function afficherCDM(nom,id) {
  10182. // Crée la table de CdM du mob n° id
  10183. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10184. /* Début création table */
  10185. var table = createCDMTable(id,nom,donneesMonstre, removeTableFromClickEvent);
  10186. /* Ajout du titre avec gestion Drag & Drop */
  10187. var tr = table.firstChild;
  10188. tr.style.cursor = 'move';
  10189. tr.onmousedown = startDrag;
  10190. tr.onmouseup = stopDrag;
  10191. /* à supprimer, remplacé par un "x" sur l'entête
  10192. // Ajout du bouton "Fermer"
  10193. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  10194. tr.style.cursor = 'pointer';
  10195. tr.onmouseover = function() {
  10196. this.className = 'mh_tdpage';
  10197. };
  10198. tr.onmouseout = function() {
  10199. this.className = 'mh_tdtitre';
  10200. };
  10201. tr.idcdm = id;
  10202. tr.onclick = function() {
  10203. cacherPopupCDM('popupCDM'+this.idcdm);
  10204. this.className = 'mh_tdtitre';
  10205. };
  10206. td = appendTdText(tr,'Fermer',true);
  10207. td.colSpan = 2;
  10208. td.style = 'text-align:center;';
  10209. */
  10210. table.id = 'popupCDM'+id;
  10211. table.style.position = 'fixed';
  10212. table.style.zIndex = 1;
  10213. //var topY = +(300+(30*MZ_EtatCdMs.yIndexCDM))%(30*Math.floor((window.innerHeight-400)/30));
  10214. table.style.left = +(window.innerWidth-365)+'px';
  10215. table.style.width = '300px';
  10216. /* Fin création table & Affichage */
  10217. document.body.appendChild(table);
  10218. var topY = 90 + (30*MZ_EtatCdMs.yIndexCDM);
  10219. //window.console.log('topY=' + topY + ', offsetHeight=' + table.offsetHeight + ', innerHeight=' + window.innerHeight);
  10220. if ((topY + table.offsetHeight) > window.innerHeight) {
  10221. MZ_EtatCdMs.yIndexCDM = 0; // on se repositionne en haut s'il n'y a pas assez de place
  10222. topY = 90;
  10223. } else {
  10224. MZ_EtatCdMs.yIndexCDM++; // décalage pour la fois suivante
  10225. }
  10226. table.style.top = topY + 'px';
  10227. }
  10228.  
  10229. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  10230. function initPopupVue() {
  10231. popup = document.createElement('div');
  10232. popup.id = 'popup';
  10233. popup.className = 'mh_textbox';
  10234. popup.style =
  10235. 'position: absolute;'+
  10236. 'border: 1px solid #000000;'+
  10237. 'visibility: hidden;'+
  10238. 'display: inline;'+
  10239. 'z-index: 3;'+
  10240. 'max-width: 400px;';
  10241. document.body.appendChild(popup);
  10242. }
  10243.  
  10244. function showPopupError(sHTML) {
  10245. window.console.log('[MZ] affichage PopupError ' + sHTML);
  10246. var divpopup = document.createElement('div');
  10247. divpopup.id = 'divpopup';
  10248. divpopup.style =
  10249. 'position: fixed;'+
  10250. 'border: 3px solid #000000;'+
  10251. 'top: 300px;left: 10px;'+
  10252. 'background-color: red;'+
  10253. 'color: white;'+
  10254. 'font-size: xx-large;'+
  10255. 'z-index: 200;';
  10256. divpopup.innerHTML = sHTML;
  10257. var divcroix = document.createElement('div');
  10258. divcroix.style =
  10259. 'position: absolute;'+
  10260. 'top: 0;right: 0;'+
  10261. 'color: inherit;'+
  10262. 'font-size: inherit;'+
  10263. 'cursor: pointer;'+
  10264. 'z-index: 201;';
  10265. divcroix.innerHTML = "X";
  10266. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  10267. document.body.appendChild(divpopup);
  10268. divpopup.appendChild(divcroix);
  10269. }
  10270.  
  10271. function retrieveCDMs() {
  10272. // Récupère les CdM disponibles dans la BDD
  10273. // Lancé uniquement sur toggleLevelColumn
  10274. if(checkBoxLevels.checked) return;
  10275. // Roule, message si l'utilisateur a décoché "Menu d'actions contextuelles"
  10276. if (!MZ_EtatCdMs.tr_monstres[0].cells[2].innerHTML.match(/r[eéè]f/i)) {
  10277. 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);
  10278. return;
  10279. }
  10280. if (MZ_EtatCdMs.nbMonstres < 1) return;
  10281.  
  10282. var tReq = [];
  10283. var nbReq = 0;
  10284. var prevLastIndexDone = MZ_EtatCdMs.lastIndexDone;
  10285. for (var i=prevLastIndexDone+1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10286. //tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  10287. // ne pas demander pour les Gowaps
  10288. var nom = getMonstreNom(i);
  10289. if (nom.match(/^[^\[]*Gowap/i)) { // le mot Gowap peut être précédé par un template (qui ne contient donc pas [)
  10290. getMonstreLevelNode(i).innerHTML = '';
  10291. continue;
  10292. }
  10293. tReq.push({'index':i, 'id':getMonstreID(i), 'nom':nom});
  10294. nbReq++;
  10295. 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
  10296. }
  10297. MZ_EtatCdMs.lastIndexDone = i;
  10298. var startAjaxCdM = new Date();
  10299. window.console.log('[MZ] ' + MZ_formatDateMS() + ' lancement AJAX ' + nbReq + ' demandes niveaux monstres V2');
  10300.  
  10301. FF_XMLHttpRequest({
  10302. method: 'POST',
  10303. url: URL_MZgetCaracMonstre,
  10304. headers : {
  10305. 'Content-type':'application/x-www-form-urlencoded'
  10306. },
  10307. //data: 'l=' + tReq.join("\n"),
  10308. data: 'l=' + JSON.stringify(tReq),
  10309. trace: 'demande niveaux monstres V2',
  10310. onload: function(responseDetails) {
  10311. try {
  10312. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  10313. if (responseDetails.status == 0) return;
  10314. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  10315. var texte = responseDetails.responseText;
  10316. var infos = JSON.parse(texte);
  10317. displayScriptTime(new Date().getTime()-date_debut.getTime(), 'Analyse des CdM MZ');
  10318. if(infos.length==0) return;
  10319.  
  10320. // ajouter les styles CSS pour les popup
  10321. var mystyle = document.createElement('style');
  10322. mystyle.type = 'text/css';
  10323. var sCSS = '.MZtooltip {position: relative;color:red;text-align:center;}\n';
  10324. sCSS += '.MZtooltip .MZtooltiptext {visibility: hidden;width: 250px;padding: 5px 0;border:solid 1px;position: absolute;z-index: 1;color:black;background-color:white}\n';
  10325. sCSS += '.MZtooltip:hover .MZtooltiptext {visibility: visible;}\n';
  10326. mystyle.innerHTML = sCSS;
  10327. document.getElementsByTagName('head')[0].appendChild(mystyle);
  10328.  
  10329. // if (MY_DEBUG) {
  10330. // for (var i = 0; i < 20; i++) window.console.log('infos[' + i + ']=' + JSON.stringify(infos[i]));
  10331. // }
  10332. var begin2, end2, index;
  10333. for(var j=0 ; j<infos.length ; j++) {
  10334. var info = infos[j];
  10335. if (info.index == undefined) continue;
  10336. var eTdLevel = getMonstreLevelNode(info.index)
  10337. this.className = 'mh_tdpage';
  10338. var myColor = undefined;
  10339. if (info.niv != undefined && info.niv.max == -1 && info.Mode != 'cdm') {
  10340. eTdLevel.className = "MZtooltip";
  10341. eTdLevel.style.color = "black";
  10342. eTdLevel.innerHTML = 'Var.<span class="MZtooltiptext">Ce monstre est variable.<br />On ne peut pas avoir d\'information sans CdM.</span>';
  10343. } else if (!(info && info.esq)) {
  10344. //if (MY_DEBUG) window.console.log("pas d'esquive id=" + info.id + ", index=" + info.index);
  10345. eTdLevel.className = "MZtooltip";
  10346. 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>';
  10347. } else {
  10348. eTdLevel.innerHTML = mkMinMaxHTML(info.niv);
  10349. //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
  10350. myColor = MZ_CdMColorFromMode(info);
  10351. eTdLevel.style.cursor = 'pointer';
  10352. eTdLevel.onclick = function() {
  10353. basculeCDM(
  10354. getMonstreNomByTR(this.parentNode),
  10355. getMonstreIDByTR(this.parentNode)
  10356. );
  10357. };
  10358. }
  10359. MZ_EtatCdMs.listeCDM[info.id] = info;
  10360. if (myColor) eTdLevel.style.color = myColor;
  10361. /* Roule' à étudier plus tard, cette différence de style selon la diplo...
  10362. eTdLevel.onmouseover = function() {
  10363. this.className = 'mh_tdtitre';
  10364. };
  10365. eTdLevel.onmouseout = function() {
  10366. if(this.parentNode.diploActive=='oui') {
  10367. this.className = '';
  10368. } else {
  10369. this.className = 'mh_tdpage';
  10370. }
  10371. };
  10372. */
  10373. }
  10374. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  10375. computeMission(prevLastIndexDone+1, MZ_EtatCdMs.nbMonstres);
  10376. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  10377. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  10378. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  10379. } catch(e) {
  10380. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZgetCaracMonstre+'\n'+texte);
  10381. }
  10382. //if (MY_DEBUG) window.console.log('id=6376829, info=' + JSON.stringify(MZ_EtatCdMs.listeCDM[6376829]));
  10383. MZ_EtatCdMs.isCDMsRetrieved=true;
  10384. // afficher/supprimer le bouton pour demander la suite
  10385. var eltBoutonSuite = document.getElementById('MZ_boutonSuiteCdM');
  10386. window.console.log('[MZ] lastIndexDone=' + MZ_EtatCdMs.lastIndexDone + ', nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', eltBoutonSuite=' + eltBoutonSuite);
  10387. if (MZ_EtatCdMs.lastIndexDone < MZ_EtatCdMs.nbMonstres) {
  10388. if (eltBoutonSuite) {
  10389. while (eltBoutonSuite.firstChild) eltBoutonSuite.removeChild(eltBoutonSuite.firstChild); // vider
  10390. appendText(eltBoutonSuite, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10391. retrieveCDMs(); // lancer la suite
  10392. } else {
  10393. eltBoutonSuite = document.createElement('div');
  10394. eltBoutonSuite.id = 'MZ_boutonSuiteCdM';
  10395. eltBoutonSuite.style.position = 'fixed';
  10396. eltBoutonSuite.style.border = '1px solid black';
  10397. eltBoutonSuite.style.top = '10px';
  10398. eltBoutonSuite.style.right = '10px';
  10399. //eltBoutonSuite.style.backgroundColor = 'white';
  10400. eltBoutonSuite.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/fond/fond2.jpg")';
  10401. eltBoutonSuite.style.color = 'black';
  10402. eltBoutonSuite.style.fontSize = 'large';
  10403. eltBoutonSuite.style.padding = '5px';
  10404. eltBoutonSuite.style.borderRadius = '10px';
  10405. eltBoutonSuite.style.cursor = 'pointer';
  10406. eltBoutonSuite.style.zIndex = '500';
  10407. appendText(eltBoutonSuite, nbReq + ' CdM(s) récupérées');
  10408. appendBr(eltBoutonSuite); // C'est plus classe que d'utiliser innerHTML ☺
  10409. appendText(eltBoutonSuite, 'Cliquer ici pour demander les CdMs');
  10410. appendBr(eltBoutonSuite);
  10411. appendText(eltBoutonSuite, 'des ' + MZ_EtatCdMs.nbMonstres + ' monstres');
  10412. eltBoutonSuite.title = 'Shift-Click pour faire disparaitre ce bouton sans demander les CdMs';
  10413. eltBoutonSuite.onclick = MZ_SuiteCdMs;
  10414. document.body.appendChild(eltBoutonSuite);
  10415. }
  10416. } else {
  10417. if (eltBoutonSuite) eltBoutonSuite.parentNode.removeChild(eltBoutonSuite);
  10418. }
  10419. },
  10420. });
  10421. //str = '';
  10422. //begin = i+1;
  10423. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  10424. }
  10425.  
  10426. function MZ_CdMColorFromMode(info) {
  10427. switch (info.Mode) {
  10428. case 'cdm':
  10429. return 'blue';
  10430. case 'stat':
  10431. return 'purple';
  10432. case 'statV1':
  10433. return 'orange';
  10434. }
  10435. }
  10436.  
  10437. function MZ_SuiteCdMs(e) { // handler du click sur le bouton pour demander la suite des CdMs
  10438. var evt = e || window.event;
  10439. if (evt.shiftKey) {
  10440. this.parentNode.removeChild(this);
  10441. return;
  10442. }
  10443. while (this.firstChild) this.removeChild(this.firstChild); // vider
  10444. appendText(this, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10445. this.title = 'Shift-Click pour faire disparaitre ce bouton';
  10446. this.style.cursor = ''; // default
  10447. this.onclick = MZ_SupprBoutonCdMs;
  10448. retrieveCDMs();
  10449. }
  10450.  
  10451. function MZ_SupprBoutonCdMs(e) {
  10452. var evt = e || window.event;
  10453. if (evt.shiftKey) {
  10454. this.parentNode.removeChild(this);
  10455. }
  10456. }
  10457.  
  10458. function mkMinMaxHTML(oMM) {
  10459. if (oMM == undefined) return '';
  10460. if (oMM.min == undefined) {
  10461. if (oMM.max == undefined) {
  10462. return;
  10463. } else {
  10464. return "\u2A7D" + oMM.max; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  10465. }
  10466. } else {
  10467. if (oMM.max == undefined) {
  10468. return "\u2A7E" + oMM.min; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  10469. } else if (oMM.min == oMM.max) {
  10470. return oMM.min;
  10471. } else if (oMM.min < oMM.max) {
  10472. return oMM.min + '-' + oMM.max;
  10473. } else {
  10474. return '<span style="color:red">' + oMM.min + '-' + oMM.max + '</span>';
  10475. }
  10476. }
  10477. }
  10478.  
  10479. function computeMission(begin,end) {
  10480. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  10481. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  10482. computeVLC(begin,end);
  10483. //+++window.console.log('computeMission, après computeVLC');
  10484. if(!begin) begin=1;
  10485. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10486. var str = MY_getValue(numTroll+'.MISSIONS');
  10487. if(!str) { return; }
  10488.  
  10489. var urlImg = URL_MZimg+'mission.png';
  10490. var obMissions = JSON.parse(str);
  10491.  
  10492. for(var i=end ; i>=begin ; i--) {
  10493. var mess = '';
  10494. var bPeutEtreIcone = false;
  10495. for(var num in obMissions) {
  10496. var mobMission = false;
  10497. var mobMissionPeutEtre = undefined;
  10498. switch(obMissions[num].type) {
  10499. case 'Race':
  10500. var race = epure(obMissions[num].race.toLowerCase());
  10501. var nom = epure(getMonstreNom(i).toLowerCase());
  10502. if(nom.indexOf(race)!=-1) {
  10503. if (race == 'crasc') {
  10504. if (nom.indexOf('medius')!=-1) {
  10505. // pas éligible
  10506. } else if (nom.indexOf('maexus')!=-1) {
  10507. // pas éligible
  10508. } else if (nom.indexOf('parasitus')!=-1) {
  10509. if (nom.match(/^crasc parasitus \[/ui)) {
  10510. // on ne peut pas savoir
  10511. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10512. + '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"';
  10513. } else {
  10514. // c'est un monstre de la race des Crasc Parasitus
  10515. mobMission = false;
  10516. }
  10517. } else {
  10518. mobMission = true;
  10519. }
  10520. } else if (race == 'crasc parasitus') {
  10521. if (nom.match(/^crasc parasitus \[/ui)) {
  10522. // on ne peut pas savoir
  10523. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10524. + '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"';
  10525. } else {
  10526. // c'est un monstre de la race des Crasc Parasitus
  10527. mobMission = true;
  10528. }
  10529. } else if (race == 'shai') {
  10530. if (nom.match(/abishai/ui)) {
  10531. mobMission = false;
  10532. } else {
  10533. mobMission = true;
  10534. }
  10535. } else if (race == 'ombre') {
  10536. if (nom.match(/roche/ui)) {
  10537. mobMission = false;
  10538. } else {
  10539. mobMission = true;
  10540. }
  10541. } else if (race == 'geck\'oo') {
  10542. if (nom.match(/majestueux/ui)) {
  10543. mobMission = false;
  10544. } else {
  10545. mobMission = true;
  10546. }
  10547. } else if (race == 'bouj\'dla') {
  10548. if (nom.match(/placide/ui)) {
  10549. mobMission = false;
  10550. } else {
  10551. mobMission = true;
  10552. }
  10553. } else {
  10554. mobMission = true;
  10555. }
  10556. }
  10557. break;
  10558. case 'Niveau':
  10559. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10560. if (donneesMonstre) {
  10561. var nivMimi = Number(obMissions[num].niveau);
  10562. var mod = obMissions[num].mod; // mission nivMimi±mod si mod est numérique, sinon, c'est >= nivMimi
  10563. if (isNaN(mod)) {
  10564. var minMimi = nivMimi;
  10565. var maxMimi = nivMimi + 999999;
  10566. } else {
  10567. var minMimi = nivMimi - mod;
  10568. var maxMimi = nivMimi + mod;
  10569. }
  10570. if (donneesMonstre.niv) { // nouveau mode
  10571. if (donneesMonstre.niv.max && donneesMonstre.niv.min) {
  10572. if (donneesMonstre.niv.max <= maxMimi && donneesMonstre.niv.min >= minMimi) {
  10573. mobMission = true;
  10574. } else if (!(donneesMonstre.niv.max < minMimi || donneesMonstre.niv.min > maxMimi)) {
  10575. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10576. if (isDEV) mobMissionPeutEtre += '\nMonstre=(' + donneesMonstre.niv.min + ', ' + donneesMonstre.niv.max + '), mimi=(' + minMimi + ', ' + maxMimi + ')'
  10577. }
  10578. } else if (donneesMonstre.niv.max) {
  10579. if (donneesMonstre.niv.max >= minMimi) {
  10580. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10581. }
  10582. } else if (donneesMonstre.niv.min) {
  10583. if (donneesMonstre.niv.min <= maxMimi) {
  10584. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10585. }
  10586. }
  10587. }
  10588. }
  10589. break;
  10590. case 'Famille':
  10591. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10592. if(donneesMonstre && donneesMonstre.fam) {
  10593. var familleMimi = epure(obMissions[num].famille.toLowerCase()).replace(/[']/g,''); // Roule 27/02/2019 simple quote dans les familles
  10594. var familleMob = epure(donneesMonstre.fam.toLowerCase());
  10595. if(familleMob.indexOf(familleMimi)!=-1) {
  10596. mobMission = true;
  10597. }
  10598. }
  10599. break;
  10600. case 'Pouvoir':
  10601. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10602. if(donneesMonstre && donneesMonstre.pouv) {
  10603. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  10604. var pvrMob = epure(donneesMonstre.pouv.toLowerCase());
  10605. if(pvrMob.indexOf(pvrMimi)!=-1) {
  10606. mobMission = true;
  10607. }
  10608. }
  10609. }
  10610. if(mobMission) {
  10611. mess += mess ? '\n\n' : '';
  10612. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  10613. } else if (mobMissionPeutEtre !== undefined) {
  10614. mess += mess ? '\n\n' : '';
  10615. mess += mobMissionPeutEtre + '\n';
  10616. bPeutEtreIcone = true;
  10617. mess += 'Mission '+ num + ' :\n'+obMissions[num].libelle;
  10618. }
  10619. }
  10620. if(mess) {
  10621. var td = getMonstreNomNode(i);
  10622. appendText(td,' ');
  10623. var myURL;
  10624. if (bPeutEtreIcone) {
  10625. myURL = URL_MZimg+'missionX.png';
  10626. } else {
  10627. myURL = urlImg;
  10628. }
  10629. td.appendChild(createImage(myURL,mess));
  10630. }
  10631. }
  10632. }
  10633.  
  10634. function computeVLC(begin,end) {
  10635. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  10636. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  10637. computeTactique(begin,end);
  10638. //+++window.console.log('computeVLC, après computeTactique');
  10639. if(!begin) begin=1;
  10640. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10641. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  10642. if(!cache)
  10643. return false;
  10644. var urlImg = URL_MZimg + "oeil.png";
  10645. for(var i = end; i >= begin;i--)
  10646. {
  10647. var id = getMonstreID(i);
  10648. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10649. var vlc = false;
  10650. /* ancien mode à supprimer
  10651. if(donneesMonstre && donneesMonstre.length>12)
  10652. {
  10653. if(donneesMonstre[12]==1) vlc = 1;
  10654. }
  10655. // */
  10656. // nouveau mode
  10657. if (donneesMonstre && donneesMonstre.vlc) {
  10658. //if (donneesMonstre) window.console.log('computeVLC i=' + i + ' id=' + id + ' ' + JSON.stringify(donneesMonstre));
  10659. var td = getMonstreNomNode(i);
  10660. td.appendChild(document.createTextNode(" "));
  10661. td.appendChild(createImage(urlImg, "Voit le caché"));
  10662. }
  10663. if (donneesMonstre && donneesMonstre.gen) {
  10664. switch (donneesMonstre.gen) {
  10665. case 1:
  10666. var imgPh = URL_MZimg + "Phoenix1.png";
  10667. var txtPh = 'Phœnix de première génération';
  10668. break;
  10669. case 2:
  10670. var imgPh = URL_MZimg + "Phoenix2.png";
  10671. var txtPh = 'Phœnix de deuxième génération';
  10672. break;
  10673. case 3:
  10674. var imgPh = URL_MZimg + "Phoenix3.png";
  10675. var txtPh = 'Phœnix de troisième génération';
  10676. break;
  10677. case 23:
  10678. var imgPh = URL_MZimg + "Phoenix23.png";
  10679. var txtPh = 'Phœnix de deuxième ou troisième génération';
  10680. break;
  10681. }
  10682. var td = getMonstreNomNode(i);
  10683. td.appendChild(document.createTextNode(" "));
  10684. var img = td.appendChild(createImage(imgPh, txtPh));
  10685. img.style.height = '15px';
  10686. img.style.width = 'auto';
  10687. }
  10688. }
  10689. }
  10690.  
  10691. /* appelé
  10692. par updateTactique
  10693. par initialiseInfos
  10694. par do_vue
  10695. par computeVLC
  10696. par computeMission
  10697. par filtreMonstres
  10698. par retrieveCDMs
  10699. */
  10700. function computeTactique(begin, end) {
  10701. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  10702. try {
  10703. if(!begin) begin = 1;
  10704. if(!end) end = MZ_EtatCdMs.nbMonstres;
  10705. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  10706. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10707. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  10708. if(noTactique || !isProfilActif()) return;
  10709. //+++window.console.log('computeTactique, après isProfilActif');
  10710.  
  10711. for(var j=end ; j>=begin ; j--) {
  10712. var id = getMonstreID(j);
  10713. var nom = getMonstreNom(j);
  10714. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10715. var bShowTactique = false;
  10716. //if (isDEV) {
  10717. if (donneesMonstre && donneesMonstre.esq) bShowTactique = true;
  10718. // } else {
  10719. // if(donneesMonstre && nom.indexOf('Gowap')==-1) bShowTactique = true;
  10720. // }
  10721. if (bShowTactique) {
  10722. var td = getMonstreNomNode(j);
  10723. appendText(td,' ');
  10724. td.appendChild(
  10725. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  10726. );
  10727. }
  10728. }
  10729. }
  10730. catch(e) {
  10731. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  10732. }
  10733. filtreMonstres();
  10734. }
  10735.  
  10736. function updateTactique() {
  10737. // = Handler checkBox noTactique
  10738. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10739. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  10740. if(!MZ_EtatCdMs.isCDMsRetrieved) return;
  10741. //+++window.console.log('updateTactique, isCDMsRetrieved=' + MZ_EtatCdMs.isCDMsRetrieved);
  10742.  
  10743. if(noTactique) {
  10744. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  10745. var tr = getMonstreNomNode(i);
  10746. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  10747. tr, null, 9, null).singleNodeValue;
  10748. if(img) {
  10749. img.parentNode.removeChild(img.previousSibling);
  10750. img.parentNode.removeChild(img);
  10751. }
  10752. }
  10753. }
  10754. else
  10755. computeTactique();
  10756. }
  10757.  
  10758. function filtreMonstres() {
  10759. // = Handler universel pour les fonctions liées aux monstres
  10760. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  10761. urlEnchantImg = URL_MZimg+'enchant.png';
  10762.  
  10763. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  10764. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  10765. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  10766. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  10767. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  10768. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  10769. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  10770. var famille = saveComboBox(comboBoxFamille,'FAMILLEMONSTRE');
  10771. // old/new : détermine s'il faut ou non nettoyer les tr
  10772. var oldNOEM = true, noEM = true;
  10773. if(MY_getValue('NOINFOEM')!='true') {
  10774. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  10775. }
  10776. // Filtrage par nom
  10777. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  10778. // Génère la liste des mobs engagés (si filtrés)
  10779. if(noEngages && !isEngagesComputed) {
  10780. for(var i=nbTrolls ; i>0 ; i--) {
  10781. var pos = getTrollPosition(i);
  10782. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  10783. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  10784. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  10785. }
  10786. isEngagesComputed = true;
  10787. }
  10788.  
  10789. /*** FILTRAGE ***/
  10790. /* À computer :
  10791. * - EM (nom suffit)
  10792. * - Enchant (nom suffit)
  10793. * - Mission (nécessite CdM)
  10794. * - mob VlC (nécessite CdM)
  10795. * Sans computation :
  10796. * - Gowap ? engagé ?
  10797. */
  10798. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  10799. var pos = getMonstrePosition(i);
  10800. var nom = getMonstreNom(i).toLowerCase();
  10801. if(noEM!=oldNOEM) {
  10802. if(noEM) {
  10803. // Si noEM passe de false à true, on nettoie les td "Nom"
  10804. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  10805. var tr = getMonstreNomNode(i);
  10806. while(tr.childNodes.length>1) {
  10807. tr.removeChild(tr.childNodes[1]);
  10808. }
  10809. } else {
  10810. var tr = getMonstreNomNode(i);
  10811. var TypeMonstre=getEM(nom);
  10812. if(TypeMonstre!='') {
  10813. var infosCompo=compoMobEM(TypeMonstre);
  10814. if(infosCompo.length>0) {
  10815. tr.appendChild(document.createTextNode(' '));
  10816. tr.appendChild(createImage(urlImg, infosCompo));
  10817. }
  10818. }
  10819. }
  10820. }
  10821. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  10822. var texte = getInfoEnchantementFromMonstre(nom);
  10823. if(texte!='') {
  10824. var td = getMonstreNomNode(i);
  10825. td.appendChild(document.createTextNode(' '));
  10826. td.appendChild(createImage(urlEnchantImg, texte));
  10827. }
  10828. }
  10829.  
  10830. var dataV2 = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10831. MZ_EtatCdMs.tr_monstres[i].style.display = (
  10832. noGowapsS &&
  10833. nom.indexOf('gowap sauvage')!=-1 &&
  10834. getMonstreDistance(i)>1
  10835. ) || (
  10836. noGowapsA &&
  10837. nom.indexOf('gowap apprivoisé')!=-1 &&
  10838. getMonstreDistance(i)>1
  10839. ) || (
  10840. noEngages &&
  10841. getMonstreDistance(i)!=0 &&
  10842. listeEngages[pos[0]] &&
  10843. listeEngages[pos[0]][pos[1]] &&
  10844. listeEngages[pos[0]][pos[1]][pos[2]]
  10845. ) || (
  10846. strMonstre!='' &&
  10847. nom.indexOf(strMonstre)==-1
  10848. ) || (
  10849. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  10850. getMonstreDistance(i)>1 &&
  10851. nom.toLowerCase().indexOf("kilamo")==-1
  10852. ) || (
  10853. famille!='0' &&
  10854. dataV2 &&
  10855. dataV2.fam &&
  10856. dataV2.fam != famille
  10857. ) ? 'none' : '';
  10858. }
  10859.  
  10860. if(MY_getValue('NOINFOEM')!='true') {
  10861. if(noEM != oldNOEM) {
  10862. if(noEM && MZ_EtatCdMs.isCDMsRetrieved) computeMission();
  10863. }
  10864. oldNOEM = noEM;
  10865. }
  10866.  
  10867. needComputeEnchantement = false;
  10868. }
  10869.  
  10870.  
  10871. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  10872.  
  10873. function filtreTrolls() {
  10874. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  10875. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  10876. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  10877. for(var i=1 ; i<=nbTrolls ; i++) {
  10878. tr_trolls[i].style.display = (
  10879. noIntangibles &&
  10880. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  10881. ) || (
  10882. strTroll!='' &&
  10883. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  10884. ) || (
  10885. strGuilde!='' &&
  10886. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  10887. ) ? 'none' : '';
  10888. }
  10889. }
  10890.  
  10891. /* [functions] Bulle PX Trolls */
  10892. var bulle;
  10893.  
  10894. function initPXTroll() {
  10895. bulle = document.createElement('div');
  10896. bulle.id = 'bulle';
  10897. bulle.className = 'mh_textbox';
  10898. bulle.style =
  10899. 'position: absolute;'+
  10900. 'border: 1px solid #000000;'+
  10901. 'visibility: hidden;'+
  10902. 'display: inline;'+
  10903. 'z-index: 2;';
  10904. document.body.appendChild(bulle);
  10905.  
  10906. for(var i=nbTrolls ; i>0 ; i--) {
  10907. var td_niv = getTrollNivNode(i);
  10908. td_niv.onmouseover = showPXTroll;
  10909. td_niv.onmouseout = hidePXTroll;
  10910. }
  10911. }
  10912.  
  10913. function showPXTroll(evt) {
  10914. var lvl = this.firstChild.nodeValue;
  10915. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  10916. bulle.style.left = evt.pageX+15+'px';
  10917. bulle.style.top = evt.pageY+'px';
  10918. bulle.style.visibility = 'visible';
  10919. }
  10920.  
  10921. function hidePXTroll() {
  10922. bulle.style.visibility = 'hidden';
  10923. }
  10924.  
  10925. /* [functions] Envoi PX / MP */
  10926. function putBoutonPXMP() {
  10927. // Bouton d'initialisation du mode Envoi
  10928. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  10929. var td = document.getElementById('tdInsertTrolls');
  10930. if(!td) { return; }
  10931. td.width = 100;
  10932. td = insertAfterTd(td);
  10933. td.style.verticalAlign = 'top';
  10934. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  10935. bouton.id = 'btnEnvoi';
  10936. }
  10937.  
  10938. function prepareEnvoi() {
  10939. // = 1er Handler du bouton d'envoi
  10940.  
  10941. /* Ajout de la colonne des CheckBoxes */
  10942. var td = insertTdText(getTrollNomNode(0),'');
  10943. td.width = 5;
  10944. for(var i=nbTrolls ; i>0 ; i--) {
  10945. td = insertTd(getTrollNomNode(i));
  10946. appendCheckBox(td,'envoi'+i);
  10947. }
  10948.  
  10949. /* Ajout du radio de choix PX ou MP */
  10950. var btnEnvoi = document.getElementById('btnEnvoi');
  10951. if(!btnEnvoi) { return; }
  10952. var tdEnvoi = btnEnvoi.parentNode;
  10953. appendText(tdEnvoi,' ');
  10954. var span = document.createElement('span');
  10955. span.style.whiteSpace = 'nowrap';
  10956. var radioElt = document.createElement('input');
  10957. radioElt.type = 'radio';
  10958. radioElt.name = 'envoiPXMP';
  10959. radioElt.id = 'radioPX';
  10960. span.appendChild(radioElt);
  10961. appendText(span,' des PX ');
  10962. radioElt = document.createElement('input');
  10963. radioElt.type = 'radio';
  10964. radioElt.name = 'envoiPXMP';
  10965. radioElt.checked = true;
  10966. span.appendChild(radioElt);
  10967. appendText(span,' un MP');
  10968. tdEnvoi.appendChild(span);
  10969.  
  10970. /* Insertion du bouton Annuler */
  10971. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  10972.  
  10973. /* Modification de l'effet du bouton Envoi */
  10974. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  10975. }
  10976.  
  10977. function annuleEnvoi() {
  10978. // = Handler bouton Annuler
  10979. /* Nettoyage du td du bouton Envoi */
  10980. var btnEnvoi = document.getElementById('btnEnvoi');
  10981. var tdEnvoi = btnEnvoi.parentNode;
  10982. while(tdEnvoi.firstChild) {
  10983. tdEnvoi.removeChild(tdEnvoi.firstChild);
  10984. }
  10985. /* Retour à l'effet de base du bouton Envoi */
  10986. btnEnvoi.onclick = prepareEnvoi;
  10987. tdEnvoi.appendChild(btnEnvoi);
  10988. /* Suppression CheckBoxes */
  10989. for(var i=nbTrolls ; i>=0 ; i--) {
  10990. var td = getTrollNomNode(i);
  10991. td.parentNode.removeChild(td);
  10992. }
  10993. }
  10994.  
  10995. function effectueEnvoi() {
  10996. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  10997. var str='';
  10998. var errID = false;
  10999. for(var i=nbTrolls ; i>0 ; i--) {
  11000. var chb = document.getElementById('envoi'+i);
  11001. if(chb.checked) {
  11002. var idTroll = getTrollID(i);
  11003. if (idTroll == undefined) {
  11004. errID = true;
  11005. } else {
  11006. str += (str ? ',' : '') + idTroll;
  11007. }
  11008. }
  11009. }
  11010. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  11011. var PXchecked = document.getElementById('radioPX').checked;
  11012. if(PXchecked) {
  11013. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  11014. } else {
  11015. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  11016. }
  11017. }
  11018.  
  11019. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  11020.  
  11021. function filtreTresors() {
  11022. // += Handler checkboxes : gg, compos, bidouilles, non libres
  11023. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  11024. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  11025. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  11026. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  11027. if(noEngages && !isEngagesComputed) {
  11028. for(var i=nbTrolls ; i>0 ; i--) {
  11029. var pos = getTrollPosition(i);
  11030. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  11031. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  11032. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  11033. }
  11034. isEngagesComputed = true;
  11035. }
  11036. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  11037. for(var i=nbTresors ; i>0 ; i--) {
  11038. var nom = getTresorNom(i);
  11039. var pos = getTresorPosition(i);
  11040. tr_tresors[i].style.display = (
  11041. noGG &&
  11042. nom.indexOf('Gigots de Gob')!=-1
  11043. ) || (
  11044. noCompos &&
  11045. nom.indexOf('Composant')!=-1
  11046. ) || (
  11047. noEngages &&
  11048. listeEngages[pos[2]] &&
  11049. listeEngages[pos[2]][pos[1]] &&
  11050. listeEngages[pos[2]][pos[1]][pos[0]] &&
  11051. getTresorDistance(i)>0
  11052. ) || (
  11053. strTresor!='' &&
  11054. nom.toLowerCase().indexOf(strTresor)==-1
  11055. ) || (
  11056. noBidouilles &&
  11057. nom.indexOf('Bidouille')!=-1
  11058. ) ? 'none' : '';
  11059. }
  11060. }
  11061.  
  11062.  
  11063. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  11064.  
  11065. function filtreLieux() {
  11066. // += Handler checkbox trous
  11067. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  11068. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  11069. for(var i=nbLieux ; i>0 ; i--) {
  11070. tr_lieux[i].style.display = (
  11071. strLieu &&
  11072. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  11073. ) || (
  11074. noTrou &&
  11075. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  11076. getLieuDistance(i)>1
  11077. ) ? 'none' : '';
  11078. }
  11079. }
  11080.  
  11081.  
  11082. /*-[functions]-------------------- Diplomatie --------------------------------*/
  11083.  
  11084. function refreshDiplo() {
  11085. MY_setValue(numTroll+'.diplo.off',
  11086. checkBoxDiplo.checked?'true':'false'
  11087. );
  11088. if(isDiploRaw) { computeDiplo(); }
  11089. appliqueDiplo();
  11090. }
  11091.  
  11092. function computeDiplo() {
  11093. // On extrait les données de couleur et on les stocke par id
  11094. // Ordre de préséance :
  11095. // source Guilde < source Perso
  11096. // guilde cible < troll cible
  11097.  
  11098. /* Diplo de Guilde */
  11099. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  11100. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  11101. if(diploGuilde && diploGuilde.isOn=='true') {
  11102. // Guilde perso
  11103. if(diploGuilde.guilde) {
  11104. Diplo.Guilde[diploGuilde.guilde.id] = {
  11105. couleur: diploGuilde.guilde.couleur,
  11106. titre: 'Ma Guilde'
  11107. };
  11108. }
  11109. // Guildes/Trolls A/E
  11110. for(var AE in {Amis:0,Ennemis:0}) {
  11111. for(var i=0 ; i<5 ; i++) {
  11112. if(diploGuilde[AE+i]) {
  11113. for(var type in {Guilde:0,Troll:0}) {
  11114. var liste = diploGuilde[AE+i][type].split(';');
  11115. for(var j=liste.length-2 ; j>=0 ; j--) {
  11116. Diplo[type][liste[j]] = {
  11117. couleur: diploGuilde[AE+i].couleur,
  11118. titre: diploGuilde[AE+i].titre
  11119. };
  11120. }
  11121. }
  11122. }
  11123. }
  11124. }
  11125. }
  11126.  
  11127. /* Diplo Perso */
  11128. //var diploPerso = MY_getValue(numTroll+'.diplo.perso') ? JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {}; // déjà chargé
  11129. if(diploPerso && diploPerso.isOn=='true') {
  11130. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  11131. for(var id in diploPerso[type]) {
  11132. Diplo[type][id] = diploPerso[type][id];
  11133. }
  11134. }
  11135. }
  11136. if(diploPerso.mythiques) {
  11137. Diplo.mythiques = diploPerso.mythiques;
  11138. }
  11139.  
  11140. isDiploRaw = false;
  11141. }
  11142.  
  11143. function appliqueDiplo() {
  11144. var aAppliquer = Diplo;
  11145. if(checkBoxDiplo.checked) {
  11146. // Pour retour à l'affichage basique sur désactivation de la diplo
  11147. aAppliquer = {
  11148. Guilde: {},
  11149. Troll: {},
  11150. Monstre: {}
  11151. };
  11152. }
  11153.  
  11154. /* On applique "aAppliquer" */
  11155. // Diplo Trõlls
  11156. for(var i=nbTrolls ; i>0 ; i--) {
  11157. var idG = getTrollGuildeID(i);
  11158. var idT = getTrollID(i);
  11159. var tr = tr_trolls[i];
  11160. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  11161. if(aAppliquer.Troll[idT]) {
  11162. tr.className = '';
  11163. var descr = aAppliquer.Troll[idT].titre;
  11164. if(descr) {
  11165. getTrollNomNode(i).title = descr
  11166. }
  11167. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  11168. } else if(aAppliquer.Guilde[idG]) {
  11169. tr.className = '';
  11170. var descr = aAppliquer.Guilde[idG].titre;
  11171. if(descr) {
  11172. getTrollNomNode(i).title = descr
  11173. }
  11174. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  11175. } else {
  11176. tr.className = 'mh_tdpage';
  11177. getTrollNomNode(i).title = '';
  11178. }
  11179. }
  11180.  
  11181. // Diplo Monstres
  11182. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  11183. var id = getMonstreID(i);
  11184. var nom = getMonstreNom(i).toLowerCase();
  11185. var tr = MZ_EtatCdMs.tr_monstres[i];
  11186. if(aAppliquer.Monstre[id]) {
  11187. tr.className = '';
  11188. tr.style.backgroundColor = aAppliquer.Monstre[id].couleur;
  11189. tr.diploActive = 'oui';
  11190. var descr = aAppliquer.Monstre[id].titre;
  11191. if(descr) {
  11192. getMonstreNomNode(i).title = descr;
  11193. }
  11194. } else if(aAppliquer.mythiques &&
  11195. (nom.indexOf('liche')==0 ||
  11196. nom.indexOf('hydre')==0 ||
  11197. nom.indexOf('balrog')==0 ||
  11198. nom.indexOf('beholder')==0)) {
  11199. tr.className = '';
  11200. tr.style.backgroundColor = aAppliquer.mythiques;
  11201. tr.diploActive = 'oui';
  11202. getMonstreNomNode(i).title = 'Monstre Mythique';
  11203. } else {
  11204. tr.className = 'mh_tdpage';
  11205. tr.diploActive = '';
  11206. }
  11207. }
  11208. }
  11209.  
  11210.  
  11211. /*-[functions]---------------- Actions à distance ----------------------------*/
  11212.  
  11213. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  11214. var monN = parseInt(getPosition()[2]);
  11215.  
  11216. for(var type in keltypes) {
  11217. if (MY_DEBUG) window.console.log('MZ computeActionDistante(' + dmin + ', ' + dmax + ', ' + oussa + ', ' + urlIcon+ ', ' + message + ') type=' + type);
  11218. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  11219. for(var i=VueContext['nb'+type] ; i>0 ; i--) {
  11220. var tr = VueContext['tr_'+type.toLowerCase()][i];
  11221. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  11222. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  11223. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  11224. var sonN = getXxxPosition(type, i)[2];
  11225. var d = getXxxDistance(type, i);
  11226.  
  11227. if(sonN==monN && d>=dmin && d<=dmax) {
  11228. var iconeAction = document.evaluate(
  11229. "./descendant::img[@alt='"+alt+"']",
  11230. tr, null, 9, null
  11231. ).singleNodeValue;
  11232. if(iconeAction) {
  11233. if(iconeAction.title) {
  11234. iconeAction.title += "\n"+message;
  11235. } else {
  11236. iconeAction.title = message;
  11237. }
  11238. iconeAction.src = urlIcon;
  11239. } else {
  11240. var tdAction = tr.getElementsByTagName('td')[1];
  11241. var icon = document.createElement('img');
  11242. icon.src = urlIcon;
  11243. icon.height = 20;
  11244. icon.alt = alt;
  11245. icon.title = message;
  11246. tdAction.appendChild(icon);
  11247. }
  11248. }
  11249. }
  11250. }
  11251. }
  11252.  
  11253. function computeCharge() {
  11254. computeActionDistante(1,
  11255. getPortee__Vue(
  11256. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  11257. MY_getValue(numTroll+".caracs.regeneration")
  11258. ),
  11259. {'Monstres':1, 'Trolls':1},
  11260. 'Attaquer',
  11261. MHicons+'E_Metal09.png',
  11262. 'Cible à portée de Charge'
  11263. );
  11264. }
  11265.  
  11266. function computeProjo() {
  11267. computeActionDistante(0,
  11268. getPortee__Vue(
  11269. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11270. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11271. ),
  11272. {'Monstres':1, 'Trolls':1},
  11273. 'Attaquer',
  11274. MHicons+'S_Fire05.png',
  11275. 'Cible à portée de Projo'
  11276. );
  11277. }
  11278.  
  11279. function computeTelek() {
  11280. computeActionDistante(0,
  11281. Math.floor((
  11282. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11283. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11284. )/2),
  11285. {'Tresors':1},
  11286. 'Telek',
  11287. MHicons+'S_Magic04.png',
  11288. 'Trésor à portée de Télékinésie'
  11289. );
  11290. }
  11291.  
  11292. function computeLdP() {
  11293. computeActionDistante(0,
  11294. 2+Math.floor((
  11295. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11296. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11297. )/5),
  11298. {'Monstres':1, 'Trolls':1},
  11299. 'self',
  11300. MHicons+'P_Red01.png',
  11301. 'Cible à portée de Lancer de Potions'
  11302. );
  11303. }
  11304.  
  11305.  
  11306. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  11307.  
  11308. function putScriptExterne(sInfo) {
  11309. for (var iBricol = 1; ; iBricol++) {
  11310. var extClef = iBricol == 1 ? '' : iBricol;
  11311. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  11312. if (!sInfo) break;
  11313. putScriptExterneOneIT(sInfo);
  11314. }
  11315. }
  11316.  
  11317. function putScriptExterneOneIT(sInfo) {
  11318. if(!sInfo || sInfo=='') return;
  11319.  
  11320. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  11321. if(nomit=='bricol') {
  11322. var data = sInfo.split('$');
  11323. try {
  11324. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  11325. // appendNewScript(URL_bricol+data[1]
  11326. // +'/mz.php?login='+data[2]
  11327. // +'&password='+data[3]
  11328. // );
  11329. FF_XMLHttpRequest({
  11330. method: 'GET',
  11331. url: URL_bricol+data[1]
  11332. +'/mz_json.php?login='+encodeURIComponent(data[2])
  11333. +'&password='+data[3],
  11334. trace: 'bricolTroll',
  11335. onload: function(responseDetails) {
  11336. try {
  11337. if (responseDetails.status == 0) {
  11338. window.console.log('status=0 à l\'appel bricol\'troll');
  11339. if (isHTTPS) {
  11340. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  11341. } else {
  11342. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  11343. }
  11344. return;
  11345. }
  11346. var ratibusData;
  11347. try {
  11348. ratibusData = JSON.parse(responseDetails.responseText);
  11349. } catch(e) {}
  11350. if (ratibusData === undefined) {
  11351. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  11352. return;
  11353. }
  11354. if (ratibusData.error) {
  11355. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  11356. } else {
  11357. putInfosTrolls(ratibusData.data.trolls, data[1]);
  11358. }
  11359. } catch(e) {
  11360. window.console.log(traceStack(e, 'retour bricol\'troll'));
  11361. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  11362. }
  11363. }
  11364. });
  11365. } catch(e) {
  11366. if (isHTTPS) {
  11367. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  11368. } else {
  11369. window.console.log(traceStack(e, 'appel bricol\'troll'));
  11370. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  11371. }
  11372. }
  11373. }
  11374. }
  11375.  
  11376. /*
  11377. * Roule 07/11/2016, on utilise mz_json qui envoie
  11378. {
  11379. "data": {
  11380. "trolls": {
  11381. "59424": {
  11382. "id": 59424,
  11383. "pv": xx,
  11384. "pv_max": xx,
  11385. "updated_at": "2016-10-31 07:28:40",
  11386. "dla": "2016-10-05 07:28:04",
  11387. "pa": 0
  11388. },
  11389. }
  11390. }
  11391. }
  11392. */
  11393.  
  11394. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  11395. function corrigeBricolTrolls(infosTrolls) {
  11396. for(var i in infosTrolls) {
  11397. var pv = infosTrolls[i][0];
  11398. var pvmax = infosTrolls[i][1];
  11399. var pvmem = MY_getValue(i+'.caracs.pv.max');
  11400. if(pvmem && pvmem>pvmax) {
  11401. infosTrolls[i][1] = pvmem;
  11402. pvmax = pvmem;
  11403. }
  11404. if(pv>pvmax) {
  11405. var newpvmax = 5*Math.ceil(pv/5);
  11406. MY_setValue(i+'.caracs.pv.max',newpvmax);
  11407. infosTrolls[i][1] = newpvmax;
  11408. }
  11409. }
  11410. }
  11411.  
  11412. // insère 2 TD avant nextTD avec les infos venant de l'IT
  11413. function addTdInfosTroll(infos, TR, itName) {
  11414. /* cadre barre PV */
  11415. var tab = document.createElement('div');
  11416. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  11417. /* barre PV */
  11418. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  11419. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  11420. .vieContainer {
  11421. background-color: #CCC;
  11422. width: 50px;
  11423. height: 6px;
  11424. border: 1px solid #000;
  11425. text-align: left;
  11426. }
  11427. */
  11428. tab.style.width = '100px';
  11429. tab.style.height = '10px';
  11430. tab.style.border = '1px solid #000';
  11431. tab.style.textAlign = 'left';
  11432. var div2 = document.createElement('div');
  11433. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  11434. var dateLimite = new Date();
  11435. dateLimite.setDate(dateLimite.getDate() - 7);
  11436. if (infos.oUpdatedAt < dateLimite) {
  11437. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  11438. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  11439. } else if (pourcentVie > 66) {
  11440. div2.style.backgroundColor = '#77EE77';
  11441. } else if (pourcentVie > 33) {
  11442. div2.style.backgroundColor = '#EEEE77';
  11443. } else {
  11444. div2.style.backgroundColor = '#FF0000';
  11445. }
  11446. div2.style.width = pourcentVie + '%';
  11447. div2.style.height = '10px';
  11448. tab.appendChild(div2);
  11449. /* ancienne méthode par img, à supprimer
  11450. var img = document.createElement('img');
  11451. img.src = '../Images/Interface/milieu.gif';
  11452. img.height = 10;
  11453. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  11454. tab.appendChild(img);
  11455. */
  11456.  
  11457. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  11458. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  11459. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  11460. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  11461.  
  11462. /* lien vers l'IT */
  11463. var lien = document.createElement('a');
  11464. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  11465. lien.href = URL_bricol+itName+'/index.php';
  11466. lien.target = '_blank';
  11467. lien.appendChild(tab);
  11468. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11469. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  11470. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  11471. //insertTdElement(tdGuilde,lien);
  11472. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  11473. /* PAs dispos */
  11474. var span = document.createElement('span');
  11475. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  11476. appendText(span, infos.pa +' PA' );
  11477. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  11478. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  11479. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  11480. span.style.backgroundColor = 'B8EEB8';
  11481. }
  11482. //insertTdElement(tdGuilde, span);
  11483. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  11484. }
  11485.  
  11486. var MZ_tabTrTrollById;
  11487. function putInfosTrolls(infosTrolls, itName) {
  11488. try {
  11489. if (MZ_tabTrTrollById === undefined) {
  11490. MZ_tabTrTrollById = new Array;
  11491. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  11492. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11493. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  11494. td.width = 40;
  11495. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  11496. td.width = 105;
  11497. for(i=nbTrolls ; i>0 ; i--) {
  11498. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11499. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11500. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  11501. }
  11502. }
  11503.  
  11504.  
  11505. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  11506. //corrigeBricolTrolls(infosTrolls);
  11507.  
  11508. // supression des infos trop vieilles (un mois)
  11509. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  11510. var dateLimite = new Date();
  11511. dateLimite.setMonth(dateLimite.getMonth() - 1);
  11512.  
  11513. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  11514. var str = MY_getValue(numTroll+'.INFOSIT');
  11515. var bAjoutTrollInvi = false;
  11516. if (str) {
  11517. var arr = str.split('$');
  11518. bAjoutTrollInvi = arr[4]>0;
  11519. }
  11520.  
  11521.  
  11522. var tBody = tr_trolls[0].parentNode;
  11523. if (tr_trolls[1] !== undefined)
  11524. tBody = tr_trolls[1].parentNode;
  11525.  
  11526. //window.console.log('nb Troll IT : ' + IDs.length);
  11527. var pos = getPosition();
  11528.  
  11529. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  11530. for (var idTroll in infosTrolls) {
  11531. var infos = infosTrolls[idTroll];
  11532. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  11533. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  11534. if (idTroll == numTroll) continue; // pas nous-même
  11535. var tr;
  11536. if (idTroll in MZ_tabTrTrollById) {
  11537. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  11538. tr = MZ_tabTrTrollById[idTroll];
  11539. } else {
  11540. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  11541. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  11542. // trouver où insérer ce Troll
  11543. var next = undefined;
  11544. for(var j=0 ; j<tr_trolls.length ; j++) {
  11545. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  11546. if (thisDist > distance) {
  11547. next = tr_trolls[j]
  11548. break;
  11549. }
  11550. }
  11551. if (next !== undefined) {
  11552. tr = insertTr(next,'mh_tdpage')
  11553. } else {
  11554. tr = appendTr(tBody,'mh_tdpage');
  11555. }
  11556. tr.style.color = 'orange';
  11557. var td = appendTd(tr); // distance
  11558. appendText(td, distance);
  11559. td = appendTd(tr); // actions
  11560. td = appendTd(tr); // ID
  11561. appendText(td, idTroll);
  11562. td = appendTd(tr); // Nom
  11563. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  11564. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  11565. td = appendTd(tr); // PV
  11566. td = appendTd(tr); // PA
  11567. td = appendTd(tr); // Guilde
  11568. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  11569. td = appendTd(tr); // Niveau
  11570. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  11571. td.align = 'center';
  11572. td = appendTd(tr); // Race
  11573. if (infos.race) appendText(td, infos.race);
  11574. td = appendTd(tr); // X
  11575. td.align = 'center';
  11576. if (infos.x !== undefined) appendText(td, infos.x);
  11577. td = appendTd(tr); // Y
  11578. td.align = 'center';
  11579. if (infos.y !== undefined) appendText(td, infos.y);
  11580. td = appendTd(tr); // N
  11581. td.align = 'center';
  11582. if (infos.n !== undefined) appendText(td, infos.n);
  11583. MZ_tabTrTrollById[idTroll] = tr;
  11584. }
  11585. if (!tr.done) {
  11586. addTdInfosTroll(infos, tr, itName);
  11587. tr.done = true;
  11588. }
  11589. }
  11590. } catch(e) {
  11591. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  11592. window.console.error(traceStack(e, 'putInfosTrolls'));
  11593. }
  11594. }
  11595.  
  11596.  
  11597. /* Mode Tétalanvert! ---------------------------------------------------------*/
  11598.  
  11599. function calculeDistance(maPos,posArr) {
  11600. return Math.max(
  11601. Math.abs(maPos[0]-posArr[0]),
  11602. Math.abs(maPos[1]-posArr[1]),
  11603. Math.abs(maPos[2]-posArr[2])
  11604. );
  11605. }
  11606.  
  11607. function inversionCoord() {
  11608. var maPos = getPosition();
  11609. var listeOffsets = {
  11610. 'monstres':checkBoxLevels.checked?4:3,
  11611. 'trolls':6,
  11612. };
  11613. for(var type in listeOffsets) {
  11614. var trList = VueContext['tr_'+type];
  11615. var offset = listeOffsets[type];
  11616. for(var i=trList.length-1 ; i>0 ; i--) {
  11617. var oldX = parseInt(trList[i].cells[offset].textContent);
  11618. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  11619. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  11620. trList[i].cells[offset].innerHTML = oldY;
  11621. trList[i].cells[offset+1].innerHTML = oldX;
  11622. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  11623. }
  11624. }
  11625. }
  11626.  
  11627.  
  11628. /* Partie principale */
  11629. function do_vue() {
  11630. for(var type in typesAFetcher) {
  11631. fetchData(type);
  11632. }
  11633.  
  11634. // roule' 11/03/2016
  11635. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  11636. // je fais une recopie :(
  11637. MZ_EtatCdMs.tr_monstres = VueContext.tr_monstres;
  11638. tr_trolls = VueContext.tr_trolls;
  11639. tr_tresors = VueContext.tr_tresors;
  11640. tr_champignons = VueContext.tr_champignons;
  11641. tr_lieux = VueContext.tr_lieux;
  11642.  
  11643. MZ_EtatCdMs.nbMonstres = VueContext.nbMonstres;
  11644. nbTrolls = VueContext.nbTrolls;
  11645. nbTresors = VueContext.nbTresors;
  11646. nbChampignons = VueContext.nbChampignons;
  11647. nbLieux = VueContext.nbLieux;
  11648.  
  11649. try {
  11650. start_script(31);
  11651.  
  11652. initialiseInfos();
  11653. savePosition();
  11654.  
  11655. // Fonctionnalité "Têtalenvert" cachée, en test :
  11656. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  11657. inversionCoord();
  11658. }
  11659.  
  11660. ajoutDesFiltres();
  11661. set2DViewSystem();
  11662. //putBoutonTroogle();
  11663. putBoutonPXMP();
  11664.  
  11665. synchroniseFiltres();
  11666. toggleLevelColumn(); // appel des CdM, ne fait rien si la checkbox NOCDM est cochée
  11667.  
  11668. refreshDiplo();
  11669.  
  11670. //400 ms
  11671. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  11672. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  11673. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  11674. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  11675. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  11676. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  11677. var noTresorsEngages =
  11678. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  11679. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  11680. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  11681. filtreMonstres();
  11682. if(noIntangibles) {
  11683. filtreTrolls();
  11684. }
  11685. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  11686. filtreTresors();
  11687. }
  11688. if(noTrou) {
  11689. filtreLieux();
  11690. }
  11691.  
  11692. initPopupVue();
  11693. initPXTroll();
  11694.  
  11695. if(getTalent("Projectile Magique")!=0) {
  11696. computeProjo();
  11697. }
  11698. if(getTalent("Charger")!=0) {
  11699. computeCharge();
  11700. }
  11701. if(getTalent("Télékinésie")!=0) {
  11702. computeTelek();
  11703. }
  11704. if(getTalent("Lancer de Potions")!=0) {
  11705. computeLdP();
  11706. }
  11707.  
  11708. putScriptExterne();
  11709.  
  11710. displayScriptTime();
  11711. } catch(e) {
  11712. window.console.error(traceStack(e, 'vue'));
  11713. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite (seriez-vous sous l'effet d'un Fumeux ?).");
  11714. }
  11715. }
  11716.  
  11717.  
  11718.  
  11719. /*******************************************************************************
  11720. * This file is part of Mountyzilla. *
  11721. * *
  11722. * Mountyzilla is free software; you can redistribute it and/or modify *
  11723. * it under the terms of the GNU General Public License as published by *
  11724. * the Free Software Foundation; either version 2 of the License, or *
  11725. * (at your option) any later version. *
  11726. * *
  11727. * Mountyzilla is distributed in the hope that it will be useful, *
  11728. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11729. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11730. * GNU General Public License for more details. *
  11731. * *
  11732. * You should have received a copy of the GNU General Public License *
  11733. * along with Mountyzilla; if not, write to the Free Software *
  11734. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11735. *******************************************************************************/
  11736.  
  11737. // x~x profil2
  11738.  
  11739. /*---------------------------- Variables globales ----------------------------*/
  11740.  
  11741. var
  11742. // Anatrolliseur
  11743. urlAnatrolliseur,
  11744. // Infobulles talents
  11745. hauteur = 50, bulleStyle = null,
  11746. // Caracteristiques
  11747. // Infos troll
  11748. race, niv, idtroll, datecrea,
  11749. idguilde, nomguilde,
  11750. // Etats du troll
  11751. fatigue, bmfatigue,
  11752.  
  11753. // Experience, Pi, ...
  11754. pxdistribuables, pxperso,
  11755. piutilisable, pitotal,
  11756. nbmeurtres, nbmorts,
  11757. // utilisee pour les moyennes MM/jour, kill/jour, etc
  11758. NBjours,
  11759. // calcul des DLA suivantes
  11760. DLA, DLAsuiv, HeureServeur,
  11761. // details duree du tour (calcul pvdispo) :
  11762. dtb, pdm, bmt, adb, dpt,
  11763. //posale
  11764. posX, posY, posN,
  11765. // caracs physiques
  11766. vue, vuebp, vuebm, vuetotale,
  11767. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  11768. reg, regbp, regbm, regmoy,
  11769. att, attbp, attbm, attmoy, atttourD, atttour, attmoytour,
  11770. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  11771. deg, degbp, degbm, degmoy, degmoycrit, degtour, degmoytour, degmoycrittour,
  11772. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  11773. rm, rmbp, rmbm, rmtotale,
  11774. mm, mmbp, mmbm, mmtotale,
  11775.  
  11776. // Variables speciales Kastars
  11777. pvActuelKastar, minParPV, overDLA,
  11778. // id pour edition manuelle de lastDLA :
  11779. inJour, inMois, inAn, inHr, inMin, inSec,
  11780. // id pour auto-refresh lastDLA :
  11781. lastDLAZone, maxAMZone, cumulZone,
  11782. lastDLA, DLAaccel;
  11783.  
  11784.  
  11785. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  11786.  
  11787. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  11788. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  11789. function getUniqueValueBySelector(selector, defaultValue){
  11790. var valNode = document.querySelector(selector);
  11791. if(valNode!=null){
  11792. if(valNode.hasChildNodes()) {
  11793. return valNode.childNodes[0].nodeValue;
  11794. }else{
  11795. return defaultValue;
  11796. }
  11797. } else{
  11798. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  11799. return defaultValue;
  11800. }
  11801. }
  11802. function getUniqueStringValueBySelector(selector){
  11803. return getUniqueValueBySelector(selector,"");
  11804. }
  11805. function getUniqueIntValueBySelector(selector){
  11806. var ret = getUniqueValueBySelector(selector,0);
  11807. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  11808. ret = 0;
  11809. }
  11810. return parseInt(ret);
  11811. }
  11812. function getUniqueFloatValueBySelector(selector){
  11813. var ret = getUniqueValueBySelector(selector,0.0);
  11814. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  11815. ret = 0.0;
  11816. }
  11817. return parseFloat(ret);
  11818. }
  11819.  
  11820.  
  11821. function resiste(Ddeg,bm) {
  11822. // version naive mais compréhensible ^^
  11823. // DEBUG: à revoir
  11824. if(!bm) {
  11825. return 2*Math.floor(Ddeg/2);
  11826. }
  11827. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  11828. }
  11829.  
  11830. function retourAZero(fatig) {
  11831. var fat = fatig, raz = 0;
  11832. while(fat>0) {
  11833. raz++;
  11834. fat = Math.floor(fat/1.25);
  11835. }
  11836. return raz;
  11837. }
  11838.  
  11839. function coefDecumul(i) {
  11840. switch(i) {
  11841. case 2: return 0.67;
  11842. case 3: return 0.4;
  11843. case 4: return 0.25;
  11844. case 5: return 0.15;
  11845. default: return 0.1;
  11846. }
  11847. }
  11848.  
  11849. function dureeHM(dmin) {
  11850. var ret = "";
  11851. dmin = Math.floor(dmin);
  11852. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  11853. var mins = dmin%60;
  11854. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  11855. return (ret) ? ret : "-";
  11856. }
  11857.  
  11858. // extraction d'une durée
  11859. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  11860. // c'est protégé (rend 0 si l'élément est absent)
  11861. // Roule' 24/12/2016
  11862. function extractionDuree(selecteur) {
  11863. var s = getUniqueStringValueBySelector(selecteur);
  11864. if (!s) return 0;
  11865. var tabN = getNumbers(s);
  11866. if (tabN.length < 2) return 0;
  11867. return tabN[0] * 60 + tabN[1];
  11868. }
  11869.  
  11870. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  11871.  
  11872. function extractionDonnees() {
  11873. // Variables temporaires
  11874. var Nbrs = {};
  11875.  
  11876. // *********************
  11877. // Cadre "Description"
  11878. // *********************
  11879. race = getUniqueStringValueBySelector('#descr #race');
  11880. debugMZ("Race : " + race);
  11881. idtroll = getUniqueStringValueBySelector('#descr #id');
  11882. debugMZ("Id troll : " + idtroll);
  11883. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  11884. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  11885. datecrea = new Date(StringToDate(strDateCrea));
  11886. debugMZ("Date creation : " + datecrea);
  11887. // Guilde
  11888. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  11889. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  11890. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  11891.  
  11892. // *******************
  11893. // Cadre "Experience"
  11894. // *******************
  11895. // Niveau de troll
  11896. niv = getUniqueIntValueBySelector('#exp #niv');
  11897. nivTroll = niv;
  11898. debugMZ("Niveau : " + niv);
  11899. // PX
  11900. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  11901. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  11902. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  11903. // PI
  11904. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  11905. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  11906. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  11907. // Meutres/Morts
  11908. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  11909. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  11910. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  11911.  
  11912. // *********************
  11913. // Cadre "Tour de Jeu"
  11914. // *********************
  11915. // DLA
  11916. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  11917. DLA = new Date(StringToDate(Nbrs["dla"]));
  11918. debugMZ("DLA: " + DLA);
  11919. // DLA suivante
  11920. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  11921. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  11922. debugMZ("DLAsuiv: " + DLAsuiv);
  11923. // Duree normale de mon Tour
  11924. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  11925. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  11926. dtb = extractionDuree("#dla #tour");
  11927. debugMZ("Duree normale de mon Tour : " + dtb);
  11928. // Bonus/Malus sur la duree
  11929. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  11930. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  11931. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  11932. debugMZ("Bonus/Malus sur la duree : " + bmt);
  11933. // Augmentation due aux blessures
  11934. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  11935. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  11936. adb = extractionDuree("#dla #blessure");
  11937. debugMZ("Augmentation due aux blessures : " + adb);
  11938. // Poids de l'equipement
  11939. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  11940. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  11941. pdm = extractionDuree("#dla #poids");
  11942. debugMZ("Poids de l'equipement : " + pdm);
  11943. // Duree de mon prochain Tour
  11944. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  11945. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  11946. dpt = extractionDuree("#dla #duree>b");
  11947. debugMZ('Duree de mon prochain Tour : ' + dpt);
  11948.  
  11949. // ****************
  11950. // Cadre "Etats"
  11951. // ****************
  11952. // Position du troll :
  11953. posX = getUniqueIntValueBySelector('#pos #x');
  11954. posY = getUniqueIntValueBySelector('#pos #y');
  11955. posN = getUniqueIntValueBySelector('#pos #n');
  11956. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  11957. // PV actuel
  11958. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  11959. pvActuelKastar = pvcourant;
  11960. debugMZ("PV actuel : " + pvcourant)
  11961. // Fatigue
  11962. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  11963. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  11964. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  11965.  
  11966. // **************************
  11967. // Cadre "Caracteristiques"
  11968. // **************************
  11969. // Attaque
  11970. att = getUniqueIntValueBySelector('#carac #att');
  11971. attbp = getUniqueIntValueBySelector('#carac #att_p');
  11972. attbm = getUniqueIntValueBySelector('#carac #att_m');
  11973. atttour = getUniqueIntValueBySelector('#carac #att_tour'); // % bonus AdA
  11974. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d'); // malus Parade
  11975. attmoy = 3.5*att + attbp + attbm;
  11976. var DAttBonus = Math.floor(((att+atttourD)*atttour/100)); // À vérifier
  11977. attmoytour = 3.5*(att+DAttBonus) + attbp + attbm;
  11978. debugMZ(
  11979. "ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+
  11980. "; BM Dé att/tour:("+atttourD+"D;"+atttour+"%) "+(atttourD+DAttBonus)+
  11981. "D ;AttMoyTour:"+attmoytour
  11982. );
  11983. // Esquive
  11984. esq = getUniqueIntValueBySelector('#carac #esq');
  11985. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  11986. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  11987. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  11988. esqmoy = 3.5*esq + esqbp+esqbm;
  11989. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  11990. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  11991. // Degat
  11992. deg = getUniqueIntValueBySelector('#carac #deg');
  11993. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  11994. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  11995. degtour = getUniqueIntValueBySelector('#carac #deg_tour'); // % bonus AdD
  11996. degmoy = 2*deg + degbp + degbm;
  11997. degmoycrit = 2*(deg+Math.floor(deg/2)) + degbp + degbm;
  11998. var DDegBonus = Math.floor(deg*degtour/100);
  11999. degmoytour = 2*(deg + DDegBonus) + degbp + degbm;
  12000. degmoycrittour = degmoytour + 2*Math.floor(deg/2);
  12001. debugMZ(
  12002. "DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+
  12003. " ;deg/tour:("+degtour+"%) "+DDegBonus+
  12004. "D; DegMoyTour:"+degmoytour+"/"+degmoycrittour
  12005. );
  12006. // PV
  12007. pvbase = getUniqueIntValueBySelector('#carac #pv');
  12008. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  12009. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  12010. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  12011. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  12012. // Regeneration
  12013. reg = getUniqueIntValueBySelector('#carac #reg');
  12014. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  12015. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  12016. regmoy = 2 * reg + regbp + regbm; // D3
  12017. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  12018. // Armure
  12019. arm = getUniqueIntValueBySelector('#carac #arm');
  12020. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  12021. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  12022. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  12023. armmoy = 2*arm + armbp+armbm;
  12024. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  12025. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  12026. // TODO : D d'armure non active
  12027. // Vue
  12028. vue = getUniqueIntValueBySelector('#carac #vue');
  12029. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  12030. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  12031. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  12032. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  12033. // RM
  12034. rm = getUniqueIntValueBySelector('#carac #rm');
  12035. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  12036. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  12037. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  12038. rmTroll = rmtotale;
  12039. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  12040. // MM
  12041. mm = getUniqueIntValueBySelector('#carac #mm');
  12042. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  12043. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  12044. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  12045. mmTroll = mmtotale;
  12046. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  12047.  
  12048. // Heure Serveur
  12049. try {
  12050. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  12051. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  12052. HeureServeur = new Date(StringToDate(heureServeurSTR));
  12053. } catch (e) {
  12054. window.console.warn(
  12055. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  12056. );
  12057. HeureServeur = new Date();
  12058. }
  12059. debugMZ("HeureServeur: " + HeureServeur);
  12060.  
  12061. // ***INIT GLOBALE*** NBjours
  12062. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  12063.  
  12064. // Calcul debut lien anatroliseur avec les caracteristiques connues
  12065. var amelio_dtb = function(dtb) {
  12066. if(dtb>555) {
  12067. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  12068. }
  12069. return 10+Math.ceil((555-dtb)/2.5);
  12070. },
  12071. amelio_pv = Math.floor(pvbase/10)-3,
  12072. amelio_vue = vue-3,
  12073. amelio_att = att-3,
  12074. amelio_esq = esq-3,
  12075. amelio_deg = deg-3,
  12076. amelio_reg = reg-1,
  12077. amelio_arm = arm-1;
  12078. if(race==="Darkling"){amelio_reg--; }
  12079. if(race==="Durakuir"){amelio_pv-- ; }
  12080. if(race==="Kastar") {amelio_deg--; }
  12081. if(race==="Skrim") {amelio_att--; }
  12082. if(race==="Tomawak") {amelio_vue--; }
  12083.  
  12084. urlAnatrolliseur = URL_AnatrolDispas
  12085. +"outils_anatrolliseur.php?anatrolliseur=v8"
  12086. +"|r="+race.toLowerCase()
  12087. +"|dla="+amelio_dtb(dtb)
  12088. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  12089. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  12090. +"|att="+amelio_att+","+attbp+","+attbm
  12091. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  12092. +"|deg="+amelio_deg+","+degbp+","+degbm
  12093. +"|reg="+amelio_reg+","+regbp+","+regbm
  12094. +"|arm="+amelio_arm+","+armbp+","+armbm
  12095. +"|mm="+mmtotale
  12096. +"|rm="+rmtotale+"|";
  12097. }
  12098.  
  12099. function saveProfil() {
  12100. MY_setValue(idtroll+'.caracs.attaque',att);
  12101. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  12102. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  12103. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  12104. if(atttourD||atttour) {
  12105. var DAttBonus = atttourD + Math.floor((att+atttourD)*atttour/100);
  12106. MY_setValue(idtroll+'.bonus.DAttM',DAttBonus);
  12107. } else {
  12108. MY_removeValue(idtroll+'.bonus.DAttM');
  12109. }
  12110. MY_setValue(idtroll+'.caracs.esquive',esq);
  12111. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  12112. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  12113. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  12114. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  12115. MY_setValue(idtroll+'.caracs.degats',deg);
  12116. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  12117. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  12118. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  12119. if(degtour) {
  12120. var DDegBonus = Math.floor(deg*degtour/100);
  12121. MY_setValue(idtroll+'.bonus.DDeg',DDegBonus);
  12122. } else {
  12123. MY_removeValue(idtroll+'.bonus.DDeg');
  12124. }
  12125. MY_setValue(idtroll+'.caracs.regeneration',reg);
  12126. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  12127. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  12128. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  12129. MY_setValue(idtroll+'.caracs.vue',vue);
  12130. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  12131. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  12132. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  12133. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  12134. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  12135. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  12136. MY_setValue(idtroll+'.caracs.rm',rm);
  12137. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  12138. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  12139. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  12140. MY_setValue(idtroll+'.caracs.mm',mm);
  12141. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  12142. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  12143. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  12144. MY_setValue(idtroll+'.caracs.armure',arm);
  12145. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  12146. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  12147. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  12148. MY_setValue(idtroll+'.position.X',posX);
  12149. MY_setValue(idtroll+'.position.Y',posY);
  12150. MY_setValue(idtroll+'.position.N',posN);
  12151. MY_setValue(idtroll+'.race',race);
  12152. MY_setValue(idtroll+'.niveau',niv);
  12153. MY_setValue(idtroll+'.idguilde',idguilde);
  12154. MY_setValue(idtroll+'.nomguilde',nomguilde);
  12155. }
  12156.  
  12157.  
  12158. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  12159.  
  12160. function setInfosCaracteristiques() {
  12161. // Modification de l'entete
  12162. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  12163. thTotal.innerHTML+='|<i>Moyenne</i>';
  12164. thTotal.title="Moyenne (Moyenne ce tour)";
  12165.  
  12166. // Ajout des informations calculees
  12167. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  12168. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  12169. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  12170.  
  12171. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  12172. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  12173. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  12174.  
  12175. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  12176. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  12177. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  12178.  
  12179. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  12180. var tdRegTotal = trRegeneration.children[5];
  12181. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  12182. // Temps recupere par reg (propale R')
  12183. var regmoyTemp = Math.max(0, regmoy);
  12184. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  12185. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  12186. if (sec != 0) {
  12187. regTitle += " " + sec + " sec";
  12188. }
  12189. trRegeneration.title = regTitle;
  12190.  
  12191. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  12192. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  12193. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  12194.  
  12195. var trRM=document.querySelector("table#caracs #rm").parentElement;
  12196. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  12197. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  12198.  
  12199.  
  12200. var trMM=document.querySelector("table#caracs #mm").parentElement;
  12201. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  12202. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  12203.  
  12204. var tdRefl=document.querySelector("#refl");
  12205. // TODO : prendre en compte bonus/malus D esq du tour ?
  12206. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + esqbp + esqbm;
  12207. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  12208. }
  12209.  
  12210. function setLienAnatrolliseur(){
  12211. var pTableAmelio = document.querySelector("#carac>div>p");
  12212. pTableAmelio.innerHTML+=" - ";
  12213. var aElt = document.createElement("a");
  12214. aElt.setAttribute("href",urlAnatrolliseur);
  12215. aElt.setAttribute("target","_blank");
  12216. aElt.className="AllLinks";
  12217. aElt.innerHTML="Anatrolliser";
  12218. pTableAmelio.appendChild(aElt);
  12219. }
  12220. function setInfoDescription() {
  12221. var txtDateCrea = (NBjours!=1) ?
  12222. " ("+NBjours+" jours dans le hall)" :
  12223. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  12224. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  12225. }
  12226.  
  12227. function setInfosEtatLieux() {
  12228. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  12229. '?search=position&orderBy=distance&posx='+
  12230. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  12231. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  12232. appendBr(tdPosition);
  12233. var aElt = document.createElement("a");
  12234. aElt.setAttribute("href",urlBricol);
  12235. aElt.setAttribute("target","_blank");
  12236. aElt.className="AllLinks";
  12237. aElt.innerHTML="Lieux à proximité";
  12238. tdPosition.appendChild(aElt);
  12239. }
  12240.  
  12241. function setInfosEtatPV() { // pour AM et Sacro
  12242. var
  12243. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  12244. sec = Math.floor(15000/pvtotal)%60,
  12245. lifebar = document.querySelector("#pos .barre-vie");
  12246. if(sec!=0) { txt += " "+sec+" sec"; }
  12247. if(lifebar) { lifebar.title = txt; }
  12248. if(pvcourant<=0) { return; }
  12249.  
  12250. // Difference PV p/r a equilibre de temps (propale R')
  12251. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  12252. // ***INIT GLOBALE*** pvdispo
  12253. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  12254. var span = document.createElement("span");
  12255. span.title = txt;
  12256. span.style.fontStyle = "italic";
  12257. if(bmt+pdm>=0) {
  12258. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  12259. } else if(pvdispo>0) {
  12260. txt = "Vous pouvez encore perdre "+
  12261. Math.min(pvdispo,pvcourant)+
  12262. " PV sans malus de temps.";
  12263. } else if(pvdispo<0) {
  12264. txt = "Il vous manque "
  12265. +(-pvdispo)
  12266. +" PV pour ne plus avoir de malus de temps.";
  12267. } else {
  12268. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  12269. }
  12270. appendText(span,txt);
  12271. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  12272. }
  12273.  
  12274. // Complete le cadre "Experience"
  12275. function setInfosExp() {
  12276. var tdNiv = document.querySelector("#exp #niv");
  12277.  
  12278. // Calcul niveau monstre/troll min pour gain PX
  12279. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  12280. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  12281.  
  12282. // Calcul PX restant
  12283. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  12284. if (pxRestant >= 0) {
  12285. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  12286. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  12287. }
  12288.  
  12289. // Calul pi/jour
  12290. var
  12291. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  12292. tdPi = document.querySelector("#exp #pi").parentElement;
  12293. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  12294. tdPi.title = tdPiTotal.title;
  12295.  
  12296. // Rapports meurtres,morts
  12297. var tdKill = document.querySelector("#exp #kill");
  12298. tdKill.setAttribute("colspan", 1);
  12299. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  12300.  
  12301. var tdMort = document.querySelector("#exp #mort");
  12302. tdMort.setAttribute("colspan", 1);
  12303. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  12304.  
  12305. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  12306. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  12307. }
  12308.  
  12309.  
  12310. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  12311.  
  12312. function minParPVsac(fat,bm) {
  12313. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  12314. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  12315. var out = [];
  12316. out[0] = (fat>4) ?
  12317. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  12318. 30;
  12319. if(bm && bm>0) {
  12320. var totalfat=fat+bm;
  12321. out[1] = (totalfat>4) ?
  12322. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  12323. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  12324. }
  12325. return out;
  12326. }
  12327.  
  12328. function toInt(str) {
  12329. str = parseInt(str);
  12330. return (str) ? str : 0;
  12331. }
  12332.  
  12333. function saveLastDLA() {
  12334. // pour les calculs d'AM max
  12335. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  12336. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  12337. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  12338. lastDLA = new Date( StringToDate(str) );
  12339. MY_setValue(numTroll+'.DLA.ancienne',str);
  12340. lastDLAZone.innerHTML = '';
  12341. var b = document.createElement('b');
  12342. b.addEventListener('click',inputMode,false);
  12343. appendText(b,str);
  12344. lastDLAZone.appendChild(b);
  12345. refreshAccel();
  12346. }
  12347.  
  12348. function inputMode() {
  12349. // Edition manuelle lastDLA
  12350. var date;
  12351. if(lastDLA)
  12352. date = new Date( lastDLA );
  12353. else
  12354. date = new Date( DLAaccel );
  12355. lastDLAZone.innerHTML = '';
  12356. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  12357. appendText(lastDLAZone,'/');
  12358. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  12359. appendText(lastDLAZone,'/');
  12360. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  12361. appendText(lastDLAZone,' - ');
  12362. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  12363. appendText(lastDLAZone,':');
  12364. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  12365. appendText(lastDLAZone,':');
  12366. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  12367. appendText(lastDLAZone,' - ');
  12368. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  12369. }
  12370.  
  12371. function setAccel() {
  12372. var
  12373. BMfrais=false,
  12374. fat=fatigue, listeBmFat=[],
  12375. tr, th, insertPt;
  12376.  
  12377. // Creation ligne speciale pour AM dans le cadre "Etat"
  12378. tr = document.createElement('tr');
  12379. th = document.createElement('th');
  12380. appendText(th,'Fatigue et AM',true);
  12381. tr.appendChild(th);
  12382. insertPt = document.createElement('td');
  12383. tr.appendChild(insertPt);
  12384. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  12385.  
  12386. // Est-on en over-DLA ?
  12387. // ***INIT GLOBALE*** overDLA
  12388. overDLA = (HeureServeur>DLA.getTime()+3e5);
  12389. if(overDLA) {
  12390. fat=Math.floor(fatigue/1.25);
  12391. }
  12392.  
  12393. // Gestion des BM de fatigue
  12394. if(bmfatigue>0) {
  12395. // On tente de recuperer les BM de fatigue de la page des BM
  12396. if(MY_getValue(numTroll+'.bm.fatigue')) {
  12397. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  12398. BMmemoire.pop();
  12399. var tour = 0;
  12400. for(var i=0 ; i<BMmemoire.length ; i++) {
  12401. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  12402. while(tour<=parseInt(nbrs[0])) {
  12403. listeBmFat[tour]=parseInt(nbrs[1]);
  12404. tour++;
  12405. }
  12406. }
  12407. }
  12408. if(listeBmFat[0]==bmfatigue) {
  12409. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  12410. BMfrais = true;
  12411. MY_removeValue(numTroll+".bm.fatigue");
  12412. }
  12413. } else {
  12414. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  12415. BMfrais = true;
  12416. }
  12417. if(!BMfrais && bmfatigue>0) {
  12418. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  12419. if(bmfatigue==15) {
  12420. listeBmFat = [15,15,15];
  12421. } else {
  12422. listeBmFat = [30,30,15];
  12423. }
  12424. }
  12425. if(overDLA) {
  12426. // Si on est en over-DLA, on decale les bm d'un tour
  12427. listeBmFat.shift();
  12428. }
  12429.  
  12430. // Tableau des fatigues et accel futures
  12431. var
  12432. minppv = minParPVsac(fat,listeBmFat[0]),
  12433. table, tbody,
  12434. ligneTour, ligneFat, ligneMin,
  12435. col;
  12436. // ***INIT GLOBALE*** minParPV
  12437. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  12438. if(fat>0 || listeBmFat[0]>0) {
  12439. table = document.createElement('table');
  12440. table.className = 'mh_tdborder';
  12441. table.border = 0;
  12442. table.cellSpacing = 1;
  12443. table.cellPadding = 1;
  12444. table.style.textAlign = "center";
  12445. tbody = document.createElement('tbody');
  12446. table.appendChild(tbody);
  12447. insertPt.appendChild(table);
  12448.  
  12449. ligneTour = appendTr(tbody,'mh_tdtitre');
  12450. ligneTour.style.fontWeight = "bold";
  12451. var td = appendTdText(ligneTour,'Tour :',true);
  12452. td.align = 'left';
  12453. ligneFat = appendTr(tbody,'mh_tdpage');
  12454. td = appendTdText(ligneFat,'Fatigue :',true);
  12455. td.className = 'mh_tdtitre';
  12456. td.align = 'left';
  12457. ligneMin = appendTr(tbody,'mh_tdpage');
  12458. td = appendTdText(ligneMin,'1 PV =',true);
  12459. td.className = 'mh_tdtitre';
  12460. td.align = 'left';
  12461. col=0;
  12462. while(col<9 && (fat>0 || listeBmFat[col])) {
  12463. if(col==0) {
  12464. if(overDLA) {
  12465. var i = document.createElement('i');
  12466. appendText(i,'A activer');
  12467. ligneTour.appendChild(i);
  12468. } else {
  12469. appendTdText(ligneTour,'En cours');
  12470. }
  12471. } else {
  12472. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12473. }
  12474. if(listeBmFat[col]) {
  12475. if(BMfrais || (!overDLA && col==0)) {
  12476. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  12477. appendTdText(ligneMin,minppv[1]+'\'');
  12478. } else {
  12479. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  12480. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  12481. }
  12482. } else {
  12483. appendTdText(ligneFat,fat);
  12484. appendTdText(ligneMin,minppv[0]+'\'');
  12485. }
  12486. col++;
  12487. fat = Math.floor(fat / 1.25);
  12488. minppv = minParPVsac(fat,listeBmFat[col]);
  12489. }
  12490. if(fat>1 || (fat==1 && !overDLA)) {
  12491. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  12492. appendTdText(ligneFat,'-');
  12493. appendTdText(ligneMin,'-');
  12494. }
  12495. col = (overDLA) ?
  12496. Math.max(retourAZero(fatigue)-1,col) :
  12497. Math.max(retourAZero(fatigue),col);
  12498. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12499. appendTdText(ligneFat,'0');
  12500. appendTdText(ligneMin,'30\'');
  12501.  
  12502. if(!BMfrais && bmfatigue) {
  12503. // si les BM n'ont pas ete rafraichis, on signale:
  12504. appendText(
  12505. insertPt,
  12506. '/!\\ Visitez la page des Bonus/Malus '+
  12507. 'pour mettre à jour votre fatigue. /!\\',
  12508. true
  12509. );
  12510. appendBr(insertPt);
  12511. }
  12512. appendBr(insertPt);
  12513. }
  12514.  
  12515. if(pvcourant<=0) {
  12516. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  12517. return;
  12518. }
  12519.  
  12520. if(fatigue>30) {
  12521. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  12522. return;
  12523. }
  12524.  
  12525. // Setup lastDLAZone
  12526. if(overDLA) {
  12527. // bypass des infos de "menu_FF.js" en cas d'overDLA
  12528. DLAaccel = new Date( DLAsuiv );
  12529. lastDLA = new Date( DLA );
  12530. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  12531. // ***INIT GLOBALE*** pvActuelKastar
  12532. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  12533. appendText(
  12534. insertPt,
  12535. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  12536. true
  12537. );
  12538. appendBr(insertPt);
  12539. } else {
  12540. DLAaccel = new Date( DLA );
  12541. pvActuelKastar = pvcourant;
  12542. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  12543. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  12544. } else {
  12545. lastDLA = false;
  12546. }
  12547. }
  12548. appendText(insertPt,'Dernière DLA enregistrée : ');
  12549. lastDLAZone = document.createElement('span');
  12550. lastDLAZone.style.cursor = 'pointer';
  12551. var b = document.createElement('b');
  12552. b.onclick = inputMode;
  12553. lastDLAZone.appendChild(b);
  12554. insertPt.appendChild(lastDLAZone);
  12555. if(lastDLA) {
  12556. appendText(b,DateToString(lastDLA));
  12557. } else {
  12558. appendText(b,'aucune');
  12559. }
  12560. appendBr(insertPt);
  12561.  
  12562. // Setup maxAMZone et cumulZone
  12563. appendText(insertPt,'Accélération maximale possible : ');
  12564. maxAMZone = document.createElement('b');
  12565. insertPt.appendChild(maxAMZone);
  12566. appendBr(insertPt);
  12567. cumulZone = document.createElement('span');
  12568. insertPt.appendChild(cumulZone);
  12569.  
  12570. refreshAccel();
  12571. }
  12572.  
  12573. function refreshAccel() {
  12574. var pvs, pvsmax;
  12575.  
  12576. // Acceleration pour cumul instantane
  12577. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  12578. if(lastDLA) {
  12579. pvsmax = Math.min(
  12580. pvActuelKastar-1,
  12581. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  12582. );
  12583. maxAMZone.innerHTML = pvsmax+" PV";
  12584. } else {
  12585. pvsmax = pvActuelKastar-1;
  12586. maxAMZone.innerHTML = "inconnue";
  12587. }
  12588.  
  12589. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  12590. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  12591. cumulZone.innerHTML = '';
  12592. if(pvs<=pvsmax) {
  12593. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  12594. appendText(cumulZone,pvs+' PV', true);
  12595. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  12596. if(pvs!=1) {
  12597. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  12598. -(pvs-1)*60*minParPV;
  12599. appendText(
  12600. cumulZone,
  12601. ' ('+(pvs-1)+' PV dans '+
  12602. Math.floor(gainSec/60)+'min'+
  12603. addZero(gainSec%60)+'s)'
  12604. );
  12605. }
  12606. } else {
  12607. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  12608. appendText(
  12609. cumulZone,
  12610. 'Après votre accélération maximale, il vous faudra encore attendre '+
  12611. dureeHM(avantDLA/6e4)+
  12612. ' avant de réactiver.'
  12613. );
  12614. }
  12615. }
  12616.  
  12617.  
  12618. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  12619.  
  12620. function traitementTalents() {
  12621. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  12622. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  12623. removeAllTalents();
  12624. var totalComp = injecteInfosBulles(trCompetence,'competences');
  12625. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  12626. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  12627. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  12628. }
  12629.  
  12630. function injecteInfosBulles(liste,fonction) {
  12631. var totalpc = 0;
  12632. // on parse la liste des talents du type 'fonction'
  12633. for(var i=0 ; i<liste.length ; i++) {
  12634. var
  12635. trTalent=liste[i],
  12636. node=trTalent.cells[1].querySelector('a'),
  12637. nomTalent=epure(trim(node.textContent)),
  12638. indiceTDniveaux=7,
  12639. indiceTDSousCompetence=2,
  12640. sousCompetences=undefined;
  12641. if(fonction=="competences"){
  12642. // un TD en plus pour des information complementaire liees a la comp
  12643. indiceTDniveaux++;
  12644. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  12645. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  12646. for (var j=0; j < sousCompetences.length; j++) {
  12647. sousCompetences[j] = sousCompetences[j].epure().trim();
  12648. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  12649. }
  12650. }
  12651. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  12652. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  12653. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  12654. totalpc += niveauxMaitrisesTalentArray[1];
  12655.  
  12656. // stockage des niveaux inferieurs du talent si presents
  12657. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  12658. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  12659. totalpc+=niveauxMaitrisesTalentArray[j+1];
  12660. }
  12661. }
  12662. return totalpc;
  12663. }
  12664.  
  12665. function setInfos(node,nom,fonction,niveau) {
  12666. node.nom = nom;
  12667. node.fonction = fonction;
  12668. node.niveau = niveau;
  12669. node.onmouseover = setBulle;
  12670. node.onmouseout = cacherBulle;
  12671. }
  12672.  
  12673. var arrayModifAnatroll = {
  12674. 'Glue':'Glu',
  12675. 'PuM':'PuiM',
  12676. 'HE':'Hurlement',
  12677. //'Insultes':'Insu',
  12678. 'Pistage':'Pist',
  12679. 'PuC':'Planter',
  12680. 'Golemo':'Golem',
  12681. }
  12682.  
  12683. function setTalent(nom,pc,niveau,sousCompetences) {
  12684. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  12685. // (et pas les % dont osf) ne serait pas plus rentable
  12686. var nomEnBase = arrayTalents[epure(nom)];
  12687. if(!nomEnBase) {
  12688. debugMZ("setTalent: le talent "+nom+" n'est pas dans la base MZ");
  12689. return;
  12690. }
  12691. if(!niveau) { niveau = 1; }
  12692.  
  12693. switch(nomEnBase) {
  12694. case 'Insultes':
  12695. urlAnatrolliseur += 'Insu'+niveau+'|';
  12696. case 'IdT':
  12697. nomEnBase += niveau;
  12698. break;
  12699. case 'Piege':
  12700. for (var i=0 ; i < sousCompetences.length ; i++) {
  12701. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  12702. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  12703. }
  12704. break;
  12705. case 'AP':
  12706. case 'Baroufle':
  12707. case 'CdB':
  12708. case 'CdM':
  12709. case 'Parer':
  12710. case 'Retraite':
  12711. case 'RB':
  12712. case 'SInterposer':
  12713. nomEnBase += niveau;
  12714. default:
  12715. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  12716. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  12717. }
  12718. //debugMZ("setTalent: nom=" + nom + ", pc=" + pc + ", niveau=" + niveau + ", sousCompetences=" + JSON.stringify(sousCompetences) + "=>setValue(" + numTroll+'.talent.'+nomEnBase+", " + pc + ")");
  12719. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  12720. }
  12721.  
  12722. function creerBulleVide() {
  12723. var table = document.createElement('table');
  12724. table.id = 'bulle';
  12725. table.className = 'mh_tdborder';
  12726. table.width = 300;
  12727. table.border = 0;
  12728. table.cellPadding = 5;
  12729. table.cellSpacing = 1;
  12730. table.style =
  12731. 'position:absolute;'
  12732. +'visibility:hidden;'
  12733. +'z-index:800;'
  12734. +'height:auto;';
  12735. var tr = appendTr(table,'mh_tdtitre');
  12736. appendTdText(tr,'Titre');
  12737. tr = appendTr(table,'mh_tdpage');
  12738. appendTdText(tr,'Contenu');
  12739. var aList = document.getElementsByTagName('a');
  12740. aList[aList.length-1].parentNode.appendChild(table);
  12741. }
  12742.  
  12743. function cacherBulle() {
  12744. if(bulleStyle)
  12745. bulleStyle.visibility = 'hidden';
  12746. }
  12747.  
  12748. function setBulle(evt) {
  12749. var nom = this.nom;
  12750. var fonction = this.fonction;
  12751. var niveau = parseInt(this.niveau);
  12752. var str='';
  12753. if(fonction=='competences'){
  12754. str=competences(nom,niveau);
  12755. } else if(fonction=='sortileges') {
  12756. str=sortileges(nom);
  12757. }
  12758. if(str=='') return;
  12759. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  12760.  
  12761. var xfenetre, yfenetre, xpage, ypage, element = null;
  12762. var offset = 15;
  12763. var bulleWidth = 300;
  12764. if(!hauteur) hauteur = 50;
  12765. element = document.getElementById('bulle');
  12766. xfenetre = evt.clientX;
  12767. yfenetre = evt.clientY;
  12768. xpage = xfenetre;
  12769. ypage = yfenetre;
  12770. if(evt.pageX) xpage = evt.pageX;
  12771. if(evt.pageY) ypage = evt.pageY;
  12772. if(element) {
  12773. bulleStyle = element.style;
  12774. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  12775. element.childNodes[1].firstChild.innerHTML = str;
  12776. }
  12777. if(bulleStyle) {
  12778. if(xfenetre>bulleWidth+offset)
  12779. xpage -= bulleWidth+offset;
  12780. else
  12781. xpage += offset;
  12782. if(yfenetre>hauteur+offset)
  12783. ypage -= hauteur + offset;
  12784. bulleStyle.width = bulleWidth;
  12785. bulleStyle.left = xpage + 'px';
  12786. bulleStyle.top = ypage + 'px';
  12787. bulleStyle.visibility = 'visible';
  12788. }
  12789. }
  12790.  
  12791.  
  12792. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  12793.  
  12794. function competences(comp,niveau) {
  12795. var
  12796. modA = atttour?Math.floor((att+atttourD)*atttour/100):0,
  12797. modD = degtour?Math.floor(deg*degtour/100):0,
  12798. texte = "";
  12799.  
  12800. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  12801. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  12802. if(minParPV>1) texte += 's';
  12803. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  12804. } else if(comp.indexOf("Attaque Precise")!=-1) {
  12805. var
  12806. i, pc,
  12807. lastmax=0,
  12808. jetatt, espatt=0,
  12809. notMaxedOut = false;
  12810.  
  12811. for(i=niveau ; i>0 ; i--) {
  12812. pc = getTalent(comp,i);
  12813. if(lastmax!=0 && pc<=lastmax) {
  12814. // Si %AP(i)<%AP(i+1), on passe AP(i)
  12815. continue;
  12816. }
  12817. jetatt = Math.round(3.5*(
  12818. Math.min(Math.floor(1.5*att), att+3*i) + modA
  12819. )) + attbp+attbm;
  12820. espatt += (pc-lastmax)*jetatt;
  12821. texte += "Attaque niv. "+i +
  12822. " ("+(pc-lastmax)+"%) : <b>" +
  12823. Math.min(Math.floor(att*1.5), att+3*i)+"</b> D6 ";
  12824. if(modA) {
  12825. texte += "<i>"+aff(modA)+"D6</i> ";
  12826. }
  12827. texte += aff(attbp+attbm)+" => <b>"+jetatt+"</b><br>";
  12828. lastmax = pc;
  12829. if(i<niveau) {
  12830. // Si l'un des % de niveau inf est > % nivmax,
  12831. // on affiche l'espérance à la fin
  12832. notMaxedOut = true;
  12833. }
  12834. }
  12835. if(notMaxedOut) {
  12836. texte += "<i>Attaque moyenne (si réussite) : <b>" +
  12837. Math.floor(10*espatt/lastmax)/10+"</b></i><br>";
  12838. }
  12839. texte += "Dégâts : <b>"+deg+"</b> D3 ";
  12840. if(modD) {
  12841. texte += "<i>"+aff(modD)+"D3</i> ";
  12842. }
  12843. texte += aff(degbp+degbm) +
  12844. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  12845. } else if(comp.indexOf("Balayage")!=-1) {
  12846. texte = "Déstabilisation : <b>"+att+"</b> D6 ";
  12847. if(modA) {
  12848. texte += "<i>"+aff(modA)+"D6</i> ";
  12849. }
  12850. texte += aff(attbp+attbm) +
  12851. " => <b>"+attmoytour+"</b><br>" +
  12852. "Effet : <b>Met à terre l'adversaire</b>";
  12853. } else if(comp.indexOf('Bidouille')!=-1)
  12854. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  12855. +'de votre inventaire avec le texte de votre choix.';
  12856. else if(comp.indexOf('Baroufle')!=-1){
  12857. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  12858. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  12859. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  12860. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  12861. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  12862. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  12863. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  12864. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  12865. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  12866. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  12867. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  12868. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  12869. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  12870. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  12871. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  12872. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  12873. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  12874. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  12875. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  12876. '</tbody></table>';
  12877. } else if(comp.indexOf("Botte Secrete")!=-1) {
  12878. modA = atttour?Math.floor(Math.floor(2*att/3)*atttour/100):0;
  12879. modD = degtour?Math.floor(Math.floor(att/2)*degtour/100):0;
  12880. texte = "Attaque : <b>"+Math.floor(2*att/3)+"</b> D6 ";
  12881. if(modA) {
  12882. texte += "<i>"+aff(modA)+"D6</i> ";
  12883. }
  12884. texte += aff(Math.floor((attbp+attbm)/2)) +
  12885. " => <b>"+Math.round(
  12886. 3.5*(Math.floor(2*att/3)+modA)+Math.floor((attbp+attbm)/2)
  12887. )+"</b><br/>Dégâts : <b>"+Math.floor(att/2)+"</b> D3 ";
  12888. if(modD) {
  12889. texte += "<i>"+aff(modD)+"D3</i> ";
  12890. }
  12891. texte += aff(Math.floor((degbp+degbm)/2))+" => <b>" +
  12892. (2*(Math.floor(att/2)+modD)+Math.floor((degbp+degbm)/2)) +
  12893. "/"+(
  12894. 2*(Math.floor(1.5*Math.floor(att/2))+modD) +
  12895. Math.floor((degbp+degbm)/2)
  12896. )+"</b>";
  12897. } else if(comp.indexOf('Camouflage')!=-1) {
  12898. var camou = getTalent('Camouflage');
  12899. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  12900. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  12901. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  12902. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  12903. } else if(comp.indexOf("Charger")!=-1) {
  12904. if(pvcourant<=0) {
  12905. // N'est plus censé se produire : activation obligatoire si mort
  12906. return "<i>On ne peut charger personne quand on est mort !</i>";
  12907. }
  12908. var portee = Math.min(
  12909. Math.max(
  12910. getPortee__Profil(reg+Math.floor(pvcourant/10)) -
  12911. Math.floor((fatigue+bmfatigue)/5),
  12912. 1
  12913. ),
  12914. vuetotale
  12915. );
  12916. if(portee<1) {
  12917. return "<b>Impossible de charger</b>";
  12918. }
  12919. texte = "Attaque : <b>"+att+"</b> D6 ";
  12920. if(modA) {
  12921. texte += "<i>"+aff(modA)+"D6</i> ";
  12922. }
  12923. texte += aff(attbp+attbm) +
  12924. " => <b>"+attmoytour+"</b><br>" +
  12925. "Dégâts : <b>"+deg+"</b> D3 ";
  12926. if(modD) {
  12927. texte += "<i>"+aff(modD)+"D3</i> ";
  12928. }
  12929. texte += aff(degbp+degbm) +
  12930. " => <b>"+degmoytour+"/"+degmoycrittour+"</b><br>" +
  12931. "Portée : <b>"+portee+"</b> case";
  12932. if(portee>1) { texte += "s"; }
  12933. } else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  12934. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  12935. if(vuetotale>1) texte += 's';
  12936. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  12937. if(vuetotale>2) texte += 's';
  12938. }
  12939. else if(comp.indexOf('Piege')!=-1) {
  12940. texte = 'Piège à Glue :<ul><li>Et si vous colliez vos adversaires au sol ?</li></ul>';
  12941. texte += 'Piège à Feu: <ul><li>À moins que vous ne préfériez les envoyer en l\'air !</li>';
  12942. texte += '<li>Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  12943. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b></li></ul>';
  12944. } else if(comp.indexOf("Contre-Attaquer")!=-1) {
  12945. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  12946. texte = "Attaque : <b>"+Math.floor(att/2)+"</b> D6 ";
  12947. if(modA) {
  12948. texte += "<i>"+aff(modA)+"D6</i> ";
  12949. }
  12950. texte += aff(Math.floor((attbp+attbm)/2)) +
  12951. " => <b>"+Math.round(
  12952. 3.5*(Math.floor(att/2)+modA)+Math.floor((attbp+attbm)/2)
  12953. )+"</b><br>" +
  12954. "Dégâts : <b>"+deg+"</b> D3 ";
  12955. if(modD) {
  12956. texte += "<i>"+aff(modD)+"D3</i> ";
  12957. }
  12958. texte += aff(degbp+degbm) +
  12959. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  12960. } else if(comp.indexOf("Coup de Butoir")!=-1) {
  12961. var
  12962. i, pc,
  12963. lastmax=0,
  12964. jetdeg, espdeg=0,
  12965. notMaxedOut = false;
  12966.  
  12967. texte = "Attaque : <b>"+att+"</b> D6 ";
  12968. if(modA) {
  12969. texte += "<i>"+aff(modA)+"D6</i> ";
  12970. }
  12971. texte += aff(attbp+attbm) +
  12972. " => <b>"+attmoytour+"</b>";
  12973. for(i=niveau ; i>0 ; i--) {
  12974. pc = getTalent(comp,i);
  12975. if(lastmax!=0 && pc<=lastmax) {
  12976. // Si %CdB(i)<%CdB(i+1), on passe CdB(i)
  12977. continue;
  12978. }
  12979. jetdeg = 2*(
  12980. Math.min(Math.floor(1.5*deg), deg+3*i) + modD
  12981. ) + degbp+degbm;
  12982. espdeg += (pc-lastmax)*jetdeg;
  12983. texte += "<br>Dégâts niv. "+i+" ("+(pc-lastmax)+"%) : <b>" +
  12984. Math.min(Math.floor(deg*1.5),deg+3*i)+"</b> D3 ";
  12985. if(modD) {
  12986. texte += "<i>"+aff(modD)+"D3</i> ";
  12987. }
  12988. texte += aff(degbp+degbm) +
  12989. " => <b>"+jetdeg +
  12990. "/"+(jetdeg+2*Math.floor(deg/2))+"</b>";
  12991. lastmax = pc;
  12992. if(i<niveau) {
  12993. // Si l'un des % de niveau inf est > % nivmax,
  12994. // on affiche l'espérance à la fin
  12995. notMaxedOut = true;
  12996. }
  12997. }
  12998. if(notMaxedOut) {
  12999. texte += "<br><i>Dégâts moyens (si réussite) : <b>" +
  13000. Math.floor(10*espdeg/lastmax)/10+"/" +
  13001. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2)) +
  13002. "</b></i>";
  13003. }
  13004. } else if(comp.indexOf('Course')!=-1)
  13005. texte = 'Déplacement gratuit : <b>'
  13006. +Math.floor(getTalent('Course')/2)
  13007. +' %</b> de chance';
  13008. else if(comp.indexOf('Deplacement Eclair')!=-1)
  13009. texte = 'Permet d\'économiser <b>1</b> PA '
  13010. +'par rapport au déplacement classique';
  13011. else if(comp.indexOf('Dressage')!=-1)
  13012. texte = 'Le dressage permet d\'apprivoiser un Gowap redevenu sauvage, un Mouch\'oo Sauvage '
  13013. +'ou un Gnu Sauvage. La portée est de une case.';
  13014. else if(comp.indexOf('Ecriture Magique')!=-1)
  13015. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  13016. +'la formule nécessite de réunir les composants de cette formule, '
  13017. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  13018. +'un champignon adéquat pour confectionner l\'encre.';
  13019. else if(comp.indexOf('Frenesie')!=-1) {
  13020. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  13021. +' => <b>'+attmoy+'</b><br/>'
  13022. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  13023. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  13024. }
  13025. else if(comp.indexOf('Golem')!=-1)
  13026. texte = 'Animez votre golem en assemblant divers matériaux '
  13027. +'autour d\'un cerveau minéral.'
  13028. else if(comp.indexOf('Grattage')!=-1) {
  13029. texte = 'Permet de confectionner un Parchemin Vierge '
  13030. +'à partir de composants et de Gigots de Gob\'.';
  13031. }
  13032. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  13033. texte = 'Fait fuir un monstre si tout se passe bien.'
  13034. +'<br/>Lui donne de gros bonus sinon...';
  13035. else if(comp.indexOf('Identification des Champignons')!=-1) {
  13036. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  13037. if(vuetotale>2) texte += 's';
  13038. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  13039. if(vuetotale>4) texte += 's';
  13040. }
  13041. else if(comp.indexOf('Insultes')!=-1)
  13042. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  13043. else if(comp.indexOf('interposer')!=-1)
  13044. texte = 'Jet de réflexe : <b>'
  13045. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  13046. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  13047. else if(comp.indexOf('Lancer de Potions') != -1)
  13048. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  13049. else if(comp.indexOf('Marquage')!=-1)
  13050. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  13051. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  13052. +'se trouver dans la même caverne que le monstre pour le marquer.';
  13053. else if(comp.indexOf('Melange Magique')!=-1)
  13054. texte = 'Cette Compétence permet de combiner deux Potions pour '
  13055. +'en réaliser une nouvelle dont l\'effet est la somme '
  13056. +'des effets des potions initiales.';
  13057. else if(comp.indexOf('Travail de la Pierre')!=-1)
  13058. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  13059. +2*vuetotale+'</b> cases</li>'
  13060. +'<li>Portée verticale (officieuse) : <b>'
  13061. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  13062. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  13063. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  13064. else if(comp.indexOf('Necromancie')!=-1)
  13065. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  13066. +'de faire "revivre" ce monstre.';
  13067. else if(comp.indexOf('Painthure de Guerre')!=-1)
  13068. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  13069. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  13070. +'pour s\'inspirer, et laissez parler votre créativité.'
  13071. else if(comp.indexOf("Parer")!=-1) {
  13072. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  13073. texte = "Jet de parade : <b>"+Math.floor(att/2)+"</b> D6 ";
  13074. if(modA) {
  13075. texte += "<i>"+aff(modA)+"D6</i> ";
  13076. }
  13077. texte += aff(Math.floor((attbp+attbm)/2)) +
  13078. " => <b>"+Math.round(
  13079. 3.5*(Math.floor(att/2)+modA) +
  13080. Math.floor((attbp+attbm)/2)
  13081. )+"</b><hr>Equivalent esquive : <b>" +
  13082. (Math.floor(att/2)+esq)+"</b> D6 ";
  13083. if(modA) {
  13084. texte += "<i>"+aff(modA)+"D6</i> ";
  13085. }
  13086. texte += aff(Math.floor((attbp+attbm)/2)+esqbp+esqbm) +
  13087. " => <b>"+(Math.round(
  13088. 3.5*(Math.floor(att/2)+modA+esq) +
  13089. Math.floor((attbp+attbm)/2)
  13090. )+esqbp+esqbm)+"</b></i>";
  13091. } else if(comp.indexOf('Pistage')!=-1)
  13092. texte = 'Portée horizontale : <b>'
  13093. +2*vuetotale+'</b> cases<br/>'
  13094. +'Portée verticale : <b>'
  13095. +2*Math.ceil(vuetotale/2)+'</b> cases';
  13096. else if(comp.indexOf('Planter un Champignon')!=-1)
  13097. texte = 'Planter un Champignon est une compétence qui vous permet de '
  13098. +'créer des colonies d\'une variété donnée de champignon à partir de '
  13099. +'quelques exemplaires préalablement enterrés.';
  13100. else if(comp.indexOf('Regeneration Accrue')!=-1)
  13101. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  13102. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  13103. else if(comp.indexOf('Reparation')!=-1)
  13104. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  13105. +'et réparez vous-même votre matériel !';
  13106. else if(comp.indexOf('Retraite')!=-1)
  13107. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  13108. +'préférable de préparer un repli stratégique pour déconcerter '
  13109. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  13110. +'Quelle intelligence démoniaque.';
  13111. else if(comp.indexOf("RotoBaffe")!=-1) {
  13112. var
  13113. Datt = att, vattbm = attbp+attbm,
  13114. Ddeg = deg, vdegbm = degbp+degbm;
  13115. for(var i=1 ; i<niveau+2 ; i++) {
  13116. texte += "<b>Attaque n°"+i+" :</b><br>" +
  13117. "Attaque : <b>"+Datt+"</b> D6 ";
  13118. if(modA) {
  13119. texte += "<i>"+aff(modA)+"D6</i> ";
  13120. }
  13121. texte += aff(vattbm) +
  13122. " => <b>"+(Math.round(3.5*(Datt+modA))+vattbm)+"</b><br>" +
  13123. "Dégâts : <b>"+Ddeg+"</b> D3 ";
  13124. if(modD) {
  13125. texte += "<i>"+aff(modD)+"D3</i> ";
  13126. }
  13127. texte += aff(vdegbm) +
  13128. " => <b>"+(2*(Ddeg+modD)+vdegbm) +
  13129. "/"+(2*(Math.floor(1.5*Ddeg)+modD)+vdegbm)+"</b>";
  13130. Datt = Math.floor(0.75*Datt);
  13131. modA = atttour?Math.floor((Datt+atttourD)*atttour/100):0;
  13132. vattbm = Math.floor(0.75*vattbm);
  13133. Ddeg = Math.floor(0.75*Ddeg);
  13134. modD = degtour?Math.floor(Ddeg*degtour/100):0;
  13135. vdegbm = Math.floor(0.75*vdegbm);
  13136. if(i<niveau+1) { texte += "<hr>"; }
  13137. }
  13138. } else if(comp.indexOf('Shamaner')!=-1)
  13139. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  13140. +'des monstres en utilisant des champignons (de 1 à 3).';
  13141. return texte;
  13142. }
  13143.  
  13144. function sortileges(sort) {
  13145. var
  13146. // Fonctions utiles uniquement à "sortileges"
  13147. decumul_buff = function(nom,str,buff) {
  13148. // Décumul des sorts de buff (old school)
  13149. var
  13150. txt = "1<sup>ere</sup>"+nom+" : <b>"+str+" +"+buff+"</b>",
  13151. dec = buff,
  13152. total = buff,
  13153. i=1;
  13154. while(i<6) {
  13155. i++;
  13156. dec = Math.floor(coefDecumul(i)*buff);
  13157. if(dec<=1 || i==6) break;
  13158. total += dec;
  13159. txt += "<br/><i>"+i+"<sup>e</sup> "+nom+" : "+
  13160. str+" +"+dec+" (+"+total+")</i>";
  13161. }
  13162. txt += "<br/><i>"+i+"<sup>e</sup> et + : "+str+" +"+dec+"</i>";
  13163. return txt;
  13164. },
  13165. nbrAdX = function(pc) {
  13166. // Détermine le nombre d'AdX actifs à partir du % de D
  13167. switch(Number(pc)) {
  13168. case 0 : return 0;
  13169. case 20: return 1;
  13170. case 33: return 2;
  13171. case 41: return 3;
  13172. case 46: return 4;
  13173. default: return Math.floor((Number(pc)-39)/2);
  13174. }
  13175. },
  13176. decumulPc = function(n) {
  13177. // Détermine le % de D décumulé du n-ième AdX
  13178. switch(Number(n)) {
  13179. case 0: return 0;
  13180. case 1: return 20;
  13181. case 2: return 13;
  13182. case 3: return 8;
  13183. case 4: return 5;
  13184. case 5: return 3;
  13185. default: return 2;
  13186. }
  13187. },
  13188. decumulFixe = function(bm, n) {
  13189. // Détermine le bonus fixe décumulé du n-ième AdX
  13190. switch(Number(n)) {
  13191. case 0: return 0;
  13192. case 1: return Math.max(1,bm);
  13193. case 2: return Math.max(1,Math.round(bm*6.7)/10);
  13194. case 3: return Math.max(1,Math.round(bm*4)/10);
  13195. default: return 1; // Sous les 1 de moyenne même en D6
  13196. }
  13197. },
  13198. texte = "";
  13199.  
  13200. if (sort.indexOf('Analyse Anatomique') != -1) {
  13201. texte = 'Portée horizontale : <b>'
  13202. + Math.floor(vuetotale / 2) + '</b> case';
  13203. if (vuetotale > 3){ texte += 's'; }
  13204. texte += '<br/>Portée verticale : <b>'
  13205. + Math.floor((vuetotale+1)/4)+'</b> case';
  13206. if (vuetotale > 7){ texte += 's'; }
  13207. } else if (sort.indexOf('Armure Etheree') != -1) {
  13208. texte = decumul_buff('AE', 'Armure magique', reg);
  13209. } else if (sort.indexOf("Augmentation")!=-1 && sort.indexOf("Attaque")!=-1) {
  13210. var
  13211. categoriesAdA = {
  13212. "attx1": {
  13213. // Affichage: code MZ (cf arrayTalents)
  13214. "AN": true,
  13215. "AP": "AP1",
  13216. "Balayage": "Balayage",
  13217. "Charge": "Charger",
  13218. "CdB": "CdB1",
  13219. "Frénésie": "Frenesie",
  13220. "RB": "RB1",
  13221. "GdS": "GdS",
  13222. "Siphon": "Siphon"
  13223. },
  13224. "attx2/3": {
  13225. "Botte Secrète": "BS"
  13226. },
  13227. "attx1/2": {
  13228. "CA": "CA",
  13229. "Parer": "Parer1"
  13230. },
  13231. "degx2/3": {
  13232. "Vampirisme": "Vampi"
  13233. },
  13234. "vuex1": {
  13235. "Projectile Magique": "Projo"
  13236. }
  13237. },
  13238. baseAdA = {
  13239. "attx1" : att,
  13240. "attx2/3": Math.floor(2*att/3),
  13241. "attx1/2": Math.floor(att/2),
  13242. "degx2/3": Math.floor(2*deg/3),
  13243. "vuex1" : vue
  13244. },
  13245. pc = atttour,
  13246. pcInit = pc,
  13247. nbrAdA = nbrAdX(pc),
  13248. categorie, talent, newTalent,
  13249. i, DSup, fixe=0;
  13250.  
  13251. i=nbrAdA;
  13252. while(i++<nbrAdA+3) {
  13253. pc += decumulPc(i);
  13254. fixe += decumulFixe(3.5,i);
  13255. if(texte) { texte += "<hr>"; }
  13256. texte += "<b>"+i+"<sup>e</sup> AdA : " +
  13257. aff(pc)+"% de Dés d'attaque :</b><br>";
  13258. for(categorie in categoriesAdA) {
  13259. // On génére la liste: "talent1, talent2"
  13260. DSup = Math.floor(baseAdA[categorie]*pc/100) -
  13261. Math.floor(baseAdA[categorie]*pcInit/100);
  13262. newTalent = false;
  13263. for(var talent in categoriesAdA[categorie]) {
  13264. if(getTalent(categoriesAdA[categorie][talent])) {
  13265. if(newTalent) { texte += ", "; }
  13266. texte += talent;
  13267. newTalent = true;
  13268. }
  13269. }
  13270. if(newTalent) {
  13271. // Si le trõll a au moins un talent dans la catégorie :
  13272. texte += ": <b>+"+DSup+"D6 +"+Math.floor(fixe)+"</b> <i>(+" +
  13273. Math.floor(3.5*DSup+fixe) +")</i><br>";
  13274. }
  13275. }
  13276. }
  13277. } else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1) {
  13278. texte = decumul_buff('AdE', 'Esquive', Math.floor((esq-1)/2));
  13279. } else if (sort.indexOf("Augmentation des Degats")!=-1) {
  13280. var
  13281. categoriesAdD = {
  13282. "attx1/2": {
  13283. "Botte Secrète": "BS"
  13284. },
  13285. "degx1": {
  13286. "AN": true,
  13287. "AP": "AP1",
  13288. "Charge": "Charger",
  13289. "CA": "CA",
  13290. "CdB": "CdB1",
  13291. "Frénésie": "Frenesie",
  13292. "RB": "RB1",
  13293. "Rafale": "Rafale",
  13294. "Vampi": "Vampi"
  13295. },
  13296. "degx1/2": {
  13297. "Griffe du Sorcier": "GdS"
  13298. },
  13299. "vuex1/2": {
  13300. "Projectile Magique": "Projo"
  13301. },
  13302. "regx1": {
  13303. "Siphon des Âmes": "Siphon"
  13304. }
  13305. },
  13306. baseAdD = {
  13307. "attx1/2": Math.floor(att/2),
  13308. "degx1" : deg,
  13309. "degx1/2": Math.floor(deg/2),
  13310. "vuex1/2": Math.floor(vue/2),
  13311. "regx1" : reg
  13312. },
  13313. pc = degtour,
  13314. pcInit = pc,
  13315. nbrAdD = nbrAdX(pc),
  13316. categorie, talent, newTalent,
  13317. i, DSup, fixe=0;
  13318.  
  13319. i=nbrAdD;
  13320. while(i++<nbrAdD+3) {
  13321. pc += decumulPc(i);
  13322. fixe += decumulFixe(2,i);
  13323. if(texte) { texte += "<hr>"; }
  13324. texte += "<b>"+i+"<sup>e</sup> AdD : " +
  13325. aff(pc)+"% de Dés de dégâts :</b><br>";
  13326. for(categorie in categoriesAdD) {
  13327. // On génére la liste: "talent1, talent2"
  13328. DSup = Math.floor(baseAdD[categorie]*pc/100) -
  13329. Math.floor(baseAdD[categorie]*pcInit/100);
  13330. newTalent = false;
  13331. for(var talent in categoriesAdD[categorie]) {
  13332. if(getTalent(categoriesAdD[categorie][talent])) {
  13333. if(newTalent) { texte += ", "; }
  13334. texte += talent;
  13335. newTalent = true;
  13336. }
  13337. }
  13338. if(newTalent) {
  13339. // Si le trõll a au moins un talent dans la catégorie :
  13340. texte += ": <b>+"+DSup+"D3 +"+Math.floor(fixe) +
  13341. "</b> <i>(+"+Math.floor(2*DSup+fixe) +
  13342. ")</i><br>";
  13343. }
  13344. }
  13345. }
  13346. } else if(sort.indexOf('Bulle Anti-Magie')!=-1) {
  13347. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  13348. }
  13349. else if(sort.indexOf('Bulle Magique')!=-1){
  13350. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  13351. }
  13352. else if(sort.indexOf('Explosion')!=-1){
  13353. texte = 'Dégâts : <b>'
  13354. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  13355. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  13356. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  13357. }
  13358. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  13359. if(pvcourant<=0)
  13360. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  13361. texte = 'Portée horizontale : <b>'
  13362. +Math.min(1,vuetotale)+'</b> case<br/>'
  13363. +'Dégâts physiques : <b>-'
  13364. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  13365. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  13366. +'Dégâts magiques : <b>-'
  13367. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  13368. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  13369. }
  13370. else if(sort.indexOf('Flash Aveuglant')!=-1){
  13371. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  13372. }
  13373. else if(sort.indexOf('Glue')!=-1) {
  13374. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  13375. if(vuetotale>2) texte += 's';
  13376. } else if(sort.indexOf("Griffe du Sorcier")!=-1) {
  13377. var
  13378. modD =0,
  13379. addVenin = function(type, effet, duree) {
  13380. var
  13381. ret = "<b>Venin "+type+" : </b><br/><b>" +
  13382. effet+"</b> D3" +
  13383. " pendant <b>"+duree+"</b> tour",
  13384. dureeReduite = Math.max(Math.floor(duree/2),1);
  13385. if(duree>1) {
  13386. ret += "s";
  13387. }
  13388. return ret +
  13389. " => <b>"+2*effet+" x "+duree+" = "+2*effet*duree +
  13390. "</b> ("+2*effet+" x "+dureeReduite+" = " +
  13391. 2*effet*dureeReduite+")";
  13392. },
  13393. effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  13394. // Frappe
  13395. texte = "Attaque : <b>"+att+"</b> D6 ";
  13396. if(atttour!=0) {
  13397. modD = Math.floor(att*atttour/100);
  13398. texte += "<i>"+aff(modD)+"D6</i> ";
  13399. }
  13400. texte += aff(attbm)
  13401. +" => <b>"+(Math.round(3.5*(att+modD))+attbm)+"</b><br/>"
  13402. +"Dégâts : <b>"+Math.floor(deg/2)+"</b> D3 ";
  13403. if(degtour!=0) {
  13404. modD = Math.floor(Math.floor(deg/2)*degtour/100);
  13405. texte += "<i>"+aff(modD)+"D3</i> ";
  13406. } else {
  13407. modD = 0;
  13408. }
  13409. texte += aff(degbm) +
  13410. " => <b>"+(2*(Math.floor(deg/2)+modD)+degbm) +
  13411. "/"+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm) +
  13412. " ("+resiste(Math.floor(deg/2)+modD,degbm) +
  13413. "/"+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm) +
  13414. ")</b>";
  13415. // Venins
  13416. texte += "<hr>"+addVenin("insidieux",effet,2+Math.floor(vue/5));
  13417. effet = Math.floor(1.5*effet);
  13418. texte += "<hr>"+addVenin("virulent",effet,1+Math.floor(vue/10));
  13419. } else if(sort.indexOf('Hypnotisme')!=-1)
  13420. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  13421. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  13422. else if(sort.indexOf('Identification des Tresors')!=-1)
  13423. texte = 'Permet de connaitre les caractéristiques et effets précis '
  13424. +'d\'un trésor.';
  13425. else if(sort.indexOf('Invisibilite')!=-1)
  13426. texte = 'Un troll invisible est indétectable même quand on se trouve '
  13427. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  13428. +'fait disparaître l\'invisibilité.';
  13429. else if(sort.indexOf('Levitation')!=-1)
  13430. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  13431. +'Comme les pièges ou les trous par exemple...';
  13432. else if(sort.indexOf("Projectile Magique")!=-1) {
  13433. var
  13434. modD = 0,
  13435. portee = getPortee__Profil(vuetotale);
  13436. // Att
  13437. texte = "Attaque : <b>"+vue+"</b> D6 ";
  13438. if(atttour!=0) {
  13439. modD = Math.floor(vue*atttour/100);
  13440. texte += "<i>"+aff(modD)+"D6</i> ";
  13441. }
  13442. texte += aff(attbm) +
  13443. " => <b>"+(Math.round(3.5*(vue+modD))+attbm)+"</b><br>" +
  13444. "Dégâts : <b>"+Math.floor(vue/2)+"</b> D3 ";
  13445. // Deg
  13446. if(degtour!=0) {
  13447. modD = Math.floor(Math.floor(vue/2)*degtour/100);
  13448. texte += "<i>"+aff(modD)+"D3</i> ";
  13449. } else {
  13450. modD = 0;
  13451. }
  13452. texte += aff(degbm) +
  13453. " => <b>"+(2*(Math.floor(vue/2)+modD)+degbm) +
  13454. "/"+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm) +
  13455. " ("+resiste(Math.floor(vue/2)+modD,degbm) +
  13456. "/"+resiste(1.5*Math.floor(vue/2)+modD,degbm) +
  13457. ") (+ 1D3 par bonus de portée)</b>";
  13458. // Portée
  13459. texte += "<br/>Portée : <b>"+portee+"</b> case";
  13460. if(portee>1) texte += "s";
  13461. } else if(sort.indexOf('Projection')!=-1) {
  13462. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  13463. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  13464. +'Si le jet de résistance de la victime est réussi:<br/>'
  13465. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  13466. } else if(sort.indexOf("Rafale Psychique")!=-1) {
  13467. var modD = 0;
  13468. texte = "Dégâts : <b>"+deg+"</b> D3 ";
  13469. if(degtour!=0) {
  13470. modD = Math.floor(deg*degtour/100);
  13471. texte += "<i>"+aff(modD)+"D3</i> ";
  13472. }
  13473. texte += aff(degbm) +
  13474. " => <b>"+(2*(deg+modD)+degbm) +
  13475. " ("+resiste(deg+modD,degbm)+")</b><br>" +
  13476. "Malus : régénération <b>-"+(deg+modD)+"</b>";
  13477. } else if(sort.indexOf("Sacrifice")!=-1) {
  13478. if(pvcourant<=0) {
  13479. // N'est plus censé se produire : activation obligatoire si mort
  13480. return "<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>";
  13481. }
  13482. var
  13483. perteSacro = function(sac) {
  13484. return " (-"+(sac+2*(1+Math.floor(sac/5)))+" PV)";
  13485. },
  13486. sac = Math.floor((pvcourant-1)/2),
  13487. pvdispoSansMalusTemps =
  13488. pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  13489.  
  13490. texte = "Portée horizontale : <b>" +
  13491. Math.min(1,vuetotale)+"</b> case<br>" +
  13492. "Soin maximal : <b>"+sac+"</b> PV"+perteSacro(sac);
  13493. // Sacros max et optimal sans malus (propale R')
  13494. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  13495. if(sac>0) {
  13496. texte += "<hr>Soin maximum limitant les risques de malus " +
  13497. "de temps : <b>" +sac+"</b> PV"+perteSacro(sac);
  13498. } else {
  13499. texte += "<hr>Vous ne pouvez pas compenser de blessures " +
  13500. "dues à un sacrifice";
  13501. }
  13502. } else if(sort.indexOf("Siphon")!=-1) {
  13503. var modD = 0;
  13504. texte = "Attaque : <b>"+att+"</b> D6 ";
  13505. if(atttour!=0) {
  13506. modD = Math.floor(att*atttour/100);
  13507. texte += "<i>"+aff(modD)+"D6</i> ";
  13508. }
  13509. texte += aff(attbm) +
  13510. " => <b>"+Math.round(3.5*(att+modD)+attbm)+"</b><br>" +
  13511. "Dégâts : <b>"+reg+"</b> D3 ";
  13512. if(degtour!=0) {
  13513. modD = Math.floor(reg*degtour/100);
  13514. texte += "<i>"+aff(modD)+"D3</i> ";
  13515. } else {
  13516. modD = 0;
  13517. }
  13518. texte += aff(degbm) +
  13519. " => <b>"+(2*(reg+modD)+degbm) +
  13520. "/" + (2*(Math.floor(1.5*reg)+modD)+degbm) +
  13521. " ("+resiste(reg+modD,degbm) +
  13522. "/"+resiste(1.5*reg+modD,degbm)+")</b>";
  13523. texte += "<br>Nécrose : attaque magique <b>-"+(reg+modD)+"</b>";
  13524. } else if(sort.indexOf('Telekinesie')!=-1) {
  13525. texte = 'Portée horizontale :';
  13526. var vt = Math.floor(vuetotale/2)+2;
  13527. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  13528. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  13529. for(var i=0 ; i<5 ; i++) {
  13530. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  13531. if(vt>1) texte += 's';
  13532. vt=Math.max(0,vt-1);
  13533. }
  13534. }
  13535. else if(sort.indexOf('Teleportation')!=-1) {
  13536. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  13537. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  13538. var pmh = (20+vue+portee);
  13539. var pmv = 3+Math.floor(portee/3);
  13540. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  13541. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  13542. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  13543. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  13544. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  13545. } else if(sort.indexOf('Vampirisme')!=-1) {
  13546. var modD = 0;
  13547. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  13548. if(atttour!=0) {
  13549. modD = Math.floor(Math.floor(2*deg/3)*atttour/100);
  13550. texte += '<i>'+aff(modD)+'D6</i> ';
  13551. }
  13552. texte += aff(attbm) +
  13553. ' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm) +
  13554. '</b><br/>Dégâts : <b>'+deg+'</b> D3 ';
  13555. if(degtour!=0) {
  13556. modD = Math.floor(deg*degtour/100);
  13557. texte += '<i>'+aff(modD)+'D3</i> ';
  13558. } else {
  13559. modD = 0;
  13560. }
  13561. texte += aff(degbm) +
  13562. ' => <b>'+(2*(deg+modD)+degbm) +
  13563. '/'+(2*(Math.floor(1.5*deg)+modD)+degbm) +
  13564. ' ('+resiste(deg+modD,degbm) +
  13565. '/'+resiste(1.5*deg+modD,degbm)+')</b>';
  13566. } else if(sort.indexOf('Vision Accrue')!=-1)
  13567. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  13568. else if(sort.indexOf('Vision lointaine')!=-1)
  13569. texte = 'En ciblant une zone située n\'importe où dans le '
  13570. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  13571. else if(sort.indexOf('Voir le Cache')!=-1)
  13572. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  13573. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  13574. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  13575. +getPortee__Profil(vuetotale)+'</b> cases';
  13576. else if(sort.indexOf('Vue Troublee')!=-1)
  13577. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  13578. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  13579. return texte;
  13580. }
  13581.  
  13582.  
  13583. /*---------------------------------- Main ------------------------------------*/
  13584.  
  13585. function do_profil2()
  13586. {
  13587. try {
  13588. start_script(31);
  13589.  
  13590. extractionDonnees();
  13591. setInfosCaracteristiques();
  13592. setInfoDescription();
  13593. setInfosEtatLieux();
  13594. setInfosEtatPV();
  13595. setInfosExp();
  13596.  
  13597. creerBulleVide();
  13598. traitementTalents();
  13599. setLienAnatrolliseur();
  13600.  
  13601. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  13602. if(race=='Kastar'){ setAccel(); }
  13603. saveProfil();
  13604. displayScriptTime();
  13605. } catch(e) {
  13606. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  13607. window.console.error(traceStack(e, 'profil2'));
  13608. }
  13609. }
  13610.  
  13611. /*******************************************************************************
  13612. * This file is part of Mountyzilla. *
  13613. * *
  13614. * Mountyzilla is free software; you can redistribute it and/or modify *
  13615. * it under the terms of the GNU General Public License as published by *
  13616. * the Free Software Foundation; either version 2 of the License, or *
  13617. * (at your option) any later version. *
  13618. * *
  13619. * Mountyzilla is distributed in the hope that it will be useful, *
  13620. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13621. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13622. * GNU General Public License for more details. *
  13623. * *
  13624. * You should have received a copy of the GNU General Public License *
  13625. * along with Mountyzilla; if not, write to the Free Software *
  13626. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  13627. *******************************************************************************/
  13628.  
  13629. // x~x script_principal
  13630.  
  13631. // x~x md5.js
  13632. /*
  13633. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  13634. * Digest Algorithm, as defined in RFC 1321.
  13635. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  13636. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  13637. * Distributed under the BSD License
  13638. * See http://pajhome.org.uk/crypt/md5 for more info.
  13639. */
  13640.  
  13641. /*
  13642. * Configurable variables. You may need to tweak these to be compatible with
  13643. * the server-side, but the defaults work in most cases.
  13644. */
  13645. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  13646. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  13647. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  13648.  
  13649. /*
  13650. * These are the functions you'll usually want to call
  13651. * They take string arguments and return either hex or base-64 encoded strings
  13652. */
  13653. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  13654. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  13655. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  13656. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  13657. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  13658. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  13659.  
  13660. /*
  13661. * Perform a simple self-test to see if the VM is working
  13662. */
  13663. function md5_vm_test()
  13664. {
  13665. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  13666. }
  13667.  
  13668. /*
  13669. * Calculate the MD5 of an array of little-endian words, and a bit length
  13670. */
  13671. function core_md5(x, len)
  13672. {
  13673. /* append padding */
  13674. x[len >> 5] |= 0x80 << ((len) % 32);
  13675. x[(((len + 64) >>> 9) << 4) + 14] = len;
  13676.  
  13677. var a = 1732584193;
  13678. var b = -271733879;
  13679. var c = -1732584194;
  13680. var d = 271733878;
  13681.  
  13682. for(var i = 0; i < x.length; i += 16)
  13683. {
  13684. var olda = a;
  13685. var oldb = b;
  13686. var oldc = c;
  13687. var oldd = d;
  13688.  
  13689. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  13690. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  13691. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  13692. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  13693. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  13694. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  13695. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  13696. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  13697. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  13698. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  13699. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  13700. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  13701. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  13702. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  13703. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  13704. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  13705.  
  13706. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  13707. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  13708. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  13709. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  13710. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  13711. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  13712. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  13713. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  13714. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  13715. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  13716. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  13717. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  13718. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  13719. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  13720. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  13721. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  13722.  
  13723. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  13724. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  13725. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  13726. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  13727. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  13728. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  13729. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  13730. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  13731. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  13732. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  13733. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  13734. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  13735. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  13736. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  13737. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  13738. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  13739.  
  13740. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  13741. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  13742. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  13743. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  13744. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  13745. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  13746. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  13747. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  13748. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  13749. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  13750. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  13751. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  13752. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  13753. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  13754. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  13755. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  13756.  
  13757. a = safe_add(a, olda);
  13758. b = safe_add(b, oldb);
  13759. c = safe_add(c, oldc);
  13760. d = safe_add(d, oldd);
  13761. }
  13762. return Array(a, b, c, d);
  13763.  
  13764. }
  13765.  
  13766. /*
  13767. * These functions implement the four basic operations the algorithm uses.
  13768. */
  13769. function md5_cmn(q, a, b, x, s, t)
  13770. {
  13771. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  13772. }
  13773. function md5_ff(a, b, c, d, x, s, t)
  13774. {
  13775. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  13776. }
  13777. function md5_gg(a, b, c, d, x, s, t)
  13778. {
  13779. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  13780. }
  13781. function md5_hh(a, b, c, d, x, s, t)
  13782. {
  13783. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  13784. }
  13785. function md5_ii(a, b, c, d, x, s, t)
  13786. {
  13787. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  13788. }
  13789.  
  13790. /*
  13791. * Calculate the HMAC-MD5, of a key and some data
  13792. */
  13793. function core_hmac_md5(key, data)
  13794. {
  13795. var bkey = str2binl(key);
  13796. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  13797.  
  13798. var ipad = Array(16), opad = Array(16);
  13799. for(var i = 0; i < 16; i++)
  13800. {
  13801. ipad[i] = bkey[i] ^ 0x36363636;
  13802. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  13803. }
  13804.  
  13805. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  13806. return core_md5(opad.concat(hash), 512 + 128);
  13807. }
  13808.  
  13809. /*
  13810. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  13811. * to work around bugs in some JS interpreters.
  13812. */
  13813. function safe_add(x, y)
  13814. {
  13815. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  13816. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  13817. return (msw << 16) | (lsw & 0xFFFF);
  13818. }
  13819.  
  13820. /*
  13821. * Bitwise rotate a 32-bit number to the left.
  13822. */
  13823. function bit_rol(num, cnt)
  13824. {
  13825. return (num << cnt) | (num >>> (32 - cnt));
  13826. }
  13827.  
  13828. /*
  13829. * Convert a string to an array of little-endian words
  13830. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  13831. */
  13832. function str2binl(str)
  13833. {
  13834. var bin = Array();
  13835. var mask = (1 << chrsz) - 1;
  13836. for(var i = 0; i < str.length * chrsz; i += chrsz)
  13837. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  13838. return bin;
  13839. }
  13840.  
  13841. /*
  13842. * Convert an array of little-endian words to a string
  13843. */
  13844. function binl2str(bin)
  13845. {
  13846. var str = "";
  13847. var mask = (1 << chrsz) - 1;
  13848. for(var i = 0; i < bin.length * 32; i += chrsz)
  13849. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  13850. return str;
  13851. }
  13852.  
  13853. /*
  13854. * Convert an array of little-endian words to a hex string.
  13855. */
  13856. function binl2hex(binarray)
  13857. {
  13858. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  13859. var str = "";
  13860. for(var i = 0; i < binarray.length * 4; i++)
  13861. {
  13862. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  13863. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  13864. }
  13865. return str;
  13866. }
  13867.  
  13868. /*
  13869. * Convert an array of little-endian words to a base-64 string
  13870. */
  13871. function binl2b64(binarray)
  13872. {
  13873. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  13874. var str = "";
  13875. for(var i = 0; i < binarray.length * 4; i += 3)
  13876. {
  13877. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  13878. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  13879. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  13880. for(var j = 0; j < 4; j++)
  13881. {
  13882. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  13883. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  13884. }
  13885. }
  13886. return str;
  13887. }
  13888.  
  13889. ///////////////////////////////////////////
  13890. // debug cartes capitan Roule 07/12/2016
  13891. ///////////////////////////////////
  13892. // essais : objet
  13893. // .mode : description
  13894. // .essais : tableau d'objets essai
  13895. // .mode : description
  13896. // .essais : tableau de cartes
  13897. // .noCarte : id de la carte
  13898. // .essais : tableau d'essais, [x, y, n, nb]
  13899. function AfficheEssais(essais, sMode) {
  13900. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  13901. if (!eBigDiv) {
  13902. var insertPoint = document.getElementById('footer1');
  13903. eBigDiv = document.createElement('table');
  13904. eBigDiv.id = 'ListeEssaiCapitan';
  13905. insertBefore(insertPoint, document.createElement('p'));
  13906. insertTitle(insertPoint,'Capitan : Liste des essais');
  13907. insertBefore(insertPoint, eBigDiv);
  13908. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  13909. }
  13910. if (!essais) {
  13911. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  13912. return;
  13913. }
  13914. var carte;
  13915. for (carte in essais) {
  13916. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  13917. }
  13918. if (carte === undefined) {
  13919. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  13920. }
  13921. }
  13922.  
  13923. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  13924. var tr = appendTr(eTable);
  13925. var td = appendTd(tr);
  13926. appendText(td, sMode, bBold);
  13927. td = appendTd(tr);
  13928. appendText(td, sCarte, bBold);
  13929. td = appendTd(tr);
  13930. appendText(td, sText, bBold);
  13931. }
  13932.  
  13933. function getEssaiV1_0() {
  13934. try {
  13935. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  13936. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  13937. var tabK, nK;
  13938. prefs.getChildList('', nK, tabK);
  13939. window.console.log('getEssaiV1_0, nb key : ' + nK);
  13940. //window.console.log('getEssaiV1_0, ' + nK);
  13941. return;
  13942. //return r;
  13943. } catch (e) {
  13944. window.console.log(traceStack(e, 'getEssaiV1_0'));
  13945. }
  13946. }
  13947.  
  13948. function getEssaiV1_1() {
  13949. var locSto = window.localStorage;
  13950. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  13951. var r = [];
  13952. for (var i = 0; i < locSto.length; i++) {
  13953. var k = locSto.key(i);
  13954. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  13955. var t = k.split(/\./);
  13956. if (t[0] !== 'capitan') continue;
  13957. if (t[2] !== 'essai') continue;
  13958. var carte = 'carte n°' + t[1];
  13959. if (r[carte]) r[carte]++;
  13960. else r[carte] = 1;
  13961. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  13962. }
  13963. return r;
  13964. }
  13965.  
  13966. function showEssaiCartes() {
  13967. window.console.log('début showEssai Tout_MZ');
  13968. var essais = getEssaiV1_0();
  13969. AfficheEssais(essais, 'V1.0');
  13970. essais = getEssaiV1_1();
  13971. AfficheEssais(essais, 'V1.1');
  13972. window.console.log('fin showEssai Tout_MZ');
  13973. }
  13974.  
  13975. function testBoolLocalStorage() {
  13976. var b = true;
  13977. var key = 'MZ_essai_bool';
  13978. GM_setValue(key, b);
  13979. window.localStorage[key] = b;
  13980. var v = GM_getValue(key);
  13981. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  13982. var v = window.localStorage.getItem(key);
  13983. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  13984.  
  13985. var b = false;
  13986. GM_setValue(key, b);
  13987. window.localStorage[key] = b;
  13988. var v = GM_getValue(key);
  13989. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  13990. var v = window.localStorage.getItem(key);
  13991. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  13992.  
  13993. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  13994. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  13995. var y = GM_getValue('654654897894654654');
  13996. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  13997. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  13998. }
  13999.  
  14000. /*--------------------------------- Création liste trolligion ---------------------------------*/
  14001. function export_trolligion() {
  14002. try {
  14003. var tabDl = document.getElementsByTagName('dl');
  14004. if ((!tabDl) || !tabDl[0]) {
  14005. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  14006. return;
  14007. }
  14008. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  14009. // nom : string
  14010. // rayonnement : entier
  14011. // grades : table d'objets (une occurence par grade)
  14012. // nom : string
  14013. // trolls : table d'objets (un par Trõll)
  14014. // id
  14015. // nom
  14016. // idguilde
  14017. // guilde
  14018. // race
  14019. // niveau
  14020. // ferveur
  14021. var currentDieu;
  14022. var currentGrade;
  14023. for (var iChild1 in tabDl[0].children) {
  14024. var eChild1 = tabDl[0].children[iChild1];
  14025. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  14026. case 'dd': // Trõll
  14027. var oTroll = {};
  14028. export_trolligion_analyse(oTroll, eChild1);
  14029. currentGrade.trolls.push(oTroll);
  14030. break;
  14031. case 'dt':
  14032. var tabH3 = eChild1.getElementsByTagName('h3');
  14033. if (tabH3 && tabH3[0]) { // changement de dieu
  14034. currentDieu = {
  14035. nom: tabH3[0].innerText || tabH3[0].textContent
  14036. , grades: []};
  14037. var txt = eChild1.innerText || eChild1.textContent;
  14038. var m = txt.match(/yon*ement *:* *(\d+)/);
  14039. if (m) currentDieu.rayonnement = parseInt(m[1]);
  14040. currentGrade = undefined;
  14041. tabDieux.push(currentDieu);
  14042. break;
  14043. }
  14044. var tabH4 = eChild1.getElementsByTagName('h4');
  14045. if (tabH4 && tabH4[0]) { // changement de grade
  14046. var grade;
  14047. var txt = tabH4[0].innerText || tabH4[0].textContent;
  14048. tabI = tabH4[0].getElementsByTagName('i');
  14049. if (tabI && tabI[0]) {
  14050. grade = tabI[0].innerText || tabI[0].textContent;
  14051. grade = grade.replace(/"/g, '');
  14052. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  14053. if (m) grade += ' (' + m[1] + ')';
  14054. } else {
  14055. grade = txt.replace(/"/g, '');
  14056. }
  14057. currentGrade = {nom: grade, trolls: []};
  14058. currentDieu.grades.push(currentGrade);
  14059. break;
  14060. }
  14061. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  14062. break;
  14063. default:
  14064. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  14065. }
  14066. }
  14067.  
  14068. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  14069. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  14070. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  14071. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  14072. for (var iDieu in tabDieux) {
  14073. var oDieu = tabDieux[iDieu];
  14074. for (var iGrade in oDieu.grades) {
  14075. var oGrade = oDieu.grades[iGrade];
  14076. for (var iTroll in oGrade.trolls) {
  14077. var oTroll = oGrade.trolls[iTroll];
  14078. var t = [oDieu.nom, oDieu.rayonnement
  14079. , oGrade.nom
  14080. , oTroll.id, oTroll.nom
  14081. , oTroll.idguilde, oTroll.guilde
  14082. , oTroll.race, oTroll.niveau
  14083. , oTroll.ferveur];
  14084. for (var iParam in t) {
  14085. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14086. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14087. }
  14088. txt += t.join("\t") + "\n";
  14089. }
  14090. }
  14091. var t = [oDieu.nom, oDieu.rayonnement];
  14092. for (var iParam in t) {
  14093. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14094. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14095. }
  14096. txt2 += t.join("\t") + "\n";
  14097. }
  14098. txt += "\n" + txt2;
  14099. } catch (e) {
  14100. window.alert("Échec à l'extraction\n" + e);
  14101. }
  14102. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  14103. try {
  14104. if (copyTextToClipboard(txt)) {
  14105. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  14106. + "Collez dans Calc\n"
  14107. + "ou, au pire, dans EXCEL®");
  14108. } else {
  14109. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  14110. }
  14111. } catch(e) {
  14112. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  14113. }
  14114. }
  14115.  
  14116. function export_trolligion_analyse(oTroll, eChild1) {
  14117. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  14118. var eChild2 = eChild1.childNodes[iChild2];
  14119. if (eChild2.nodeType === undefined) continue; // properties
  14120. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  14121. switch (eChild2.nodeType) {
  14122. case 1: //ELEMENT_NODE:
  14123. switch (eChild2.nodeName.toLowerCase()) {
  14124. case 'a':
  14125. var m;
  14126. if (!eChild2.href) {
  14127. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  14128. break;
  14129. }
  14130. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  14131. if (m) {
  14132. oTroll.id = parseInt(m[1]);
  14133. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  14134. break;
  14135. }
  14136. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  14137. if (m) {
  14138. var idGuilde = parseInt(m[1]);
  14139. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  14140. oTroll.idguilde = parseInt(m[1]);
  14141. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  14142. }
  14143. break;
  14144. }
  14145. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  14146. break;
  14147. case 'br': // ignore
  14148. case 'style': // ignore
  14149. case 'img': // ignore
  14150. break;
  14151. case 'div': // barre de vie
  14152. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  14153. eChild3 = eChild2.children[0];
  14154. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  14155. var eChild4 = eChild3.children[0];
  14156. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  14157. break;
  14158. }
  14159. }
  14160. //window.console.log(eChild2.innerHTML);
  14161. export_trolligion_analyse(oTroll, eChild2);
  14162. break;
  14163. default:
  14164. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  14165. break;
  14166. }
  14167. break;
  14168. case 3: //TEXT_NODE:
  14169. var txt = eChild2.nodeValue.trim();
  14170. if (txt === '') break;
  14171. var m = txt.match(/(.*) *\((\d+)\)/);
  14172. if (m) {
  14173. oTroll.race = m[1].trim();
  14174. oTroll.niveau = parseInt(m[2]);
  14175. } else {
  14176. oTroll.race = txt;
  14177. }
  14178. break;
  14179. default: // ne devrait pas arriver
  14180. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  14181. break;
  14182. }
  14183. }
  14184. }
  14185.  
  14186. function do_trolligion() {
  14187. var divpopup = document.createElement('div');
  14188. divpopup.id = 'MZ_divCopier';
  14189. divpopup.style.position = 'fixed';
  14190. divpopup.style.top = '2px';
  14191. divpopup.style.left = '2px;';
  14192. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  14193. divpopup.style.cursor = 'pointer';
  14194. divpopup.style.zIndex = 200;
  14195. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  14196. divpopup.onclick = export_trolligion;
  14197. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  14198. divpopup.appendChild(img);
  14199. document.body.appendChild(divpopup);
  14200. }
  14201.  
  14202. /*--------------------------------- Dispatch ---------------------------------*/
  14203.  
  14204. //chargerScriptDev("libs");
  14205. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  14206. //if (isDEV) testBoolLocalStorage();
  14207.  
  14208. // Détection de la page à traiter
  14209. if(isPage("Messagerie/ViewMessageBot")) {
  14210. do_cdmbot();
  14211. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  14212. do_cdmcomp();
  14213. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  14214. do_cdmcomp();
  14215. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  14216. do_cdmcomp();
  14217. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  14218. do_diplo();
  14219. } else if(isPage("MH_Play/Play_equipement")) {
  14220. do_equip();
  14221. } else if(isPage("MH_Play/Play_menu")) {
  14222. do_menu();
  14223. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  14224. do_option();
  14225. //showEssaiCartes();
  14226. } else if(isPage("View/PJView_Events")) {
  14227. /* SCIZ */
  14228. do_scizOverwriteEvents();
  14229. } else if(isPage("View/PJView")) {
  14230. do_pjview();
  14231. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  14232. do_profil();
  14233. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  14234. do_tancompo();
  14235. } else if(isPage("MH_Play/Play_vue")) {
  14236. do_vue();
  14237. } else if(isPage("MH_Play/Play_news")) {
  14238. do_news();
  14239. } else if(isPage("MH_Play/Play_evenement")) {
  14240. /* SCIZ */
  14241. do_scizOverwriteEvents();
  14242. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  14243. do_move();
  14244. } else if(isPage("MH_Missions/Mission_Etape")) {
  14245. do_mission();
  14246. } else if(isPage("View/MonsterView")) {
  14247. do_infomonstre();
  14248. /* SCIZ */
  14249. do_scizOverwriteEvents();
  14250. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  14251. do_attaque();
  14252. } else if(isPage("MH_Play/Play_e_follo.php")) {
  14253. do_listegowap();
  14254. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  14255. do_lieuDescription();
  14256. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  14257. do_lieuTeleport();
  14258. } else if(isPage("MH_Follower/FO_Ordres")) {
  14259. do_ordresgowap();
  14260. } else if(isPage("MH_Follower/FO_Equipement")) {
  14261. do_equipgowap();
  14262. } else if(isPage("MH_Play/Play_mouche")) {
  14263. do_mouches();
  14264. } else if(isPage("MH_Play/Play_BM")) {
  14265. do_malus();
  14266. } else if(isPage("MH_Play/Play_evenement")) {
  14267. do_myevent();
  14268. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  14269. do_enchant();
  14270. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  14271. do_pre_enchant();
  14272. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  14273. do_actions();
  14274. } 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')) {
  14275. do_mission_liste();
  14276. } else if(isPage('MH_Play/Play_action')) {
  14277. do_actions();
  14278. } else if(isPage('MH_Play/Play_profil2')) {
  14279. do_profil2();
  14280. } else if(isPage('View/TrolligionView.php')) {
  14281. do_trolligion();
  14282. }
  14283. } catch(e) {
  14284. try {
  14285. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  14286. } catch(e2) {
  14287. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  14288. }
  14289. }