Tout_MZ

Client MountyZilla

当前为 2020-07-08 提交的版本,查看 最新版本

  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 *mhp.mh.raistlin.fr*
  10. // @exclude *mzdev.mh.raistlin.fr*
  11. // @version 1.3.0.51
  12. // @grant GM_getValue
  13. // @grant GM_deleteValue
  14. // @grant GM_setValue
  15. // ==/UserScript==
  16.  
  17. // vérif UTF-8 ş
  18.  
  19. /*******************************************************************************
  20. * This file is part of Mountyzilla. *
  21. * *
  22. * Mountyzilla is free software; you can redistribute it and/or modify *
  23. * it under the terms of the GNU General Public License as published by *
  24. * the Free Software Foundation; either version 2 of the License, or *
  25. * (at your option) any later version. *
  26. * *
  27. * Mountyzilla is distributed in the hope that it will be useful, *
  28. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  29. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  30. * GNU General Public License for more details. *
  31. * *
  32. * You should have received a copy of the GNU General Public License *
  33. * along with Mountyzilla; if not, write to the Free Software *
  34. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  35. *******************************************************************************/
  36.  
  37. try {
  38. var MZ_changeLog = [
  39. "V1.3.0.51 23/06/2020",
  40. " Correction de la vue",
  41. "V1.3.0.47 23/06/2020",
  42. " Correction blessure",
  43. "V1.3.0.46 23/06/2020",
  44. " Adaptation réserve de temps",
  45. "V1.3.0.45 17/06/2020",
  46. " Pas de reset (erroné ?) fatigue en affichage profil",
  47. "V1.3.0.44 13/06/2020",
  48. " Remplacement CONST par VAR à cause de IOS (bug ?)", // voir https://stackoverflow.com/questions/37228892/why-is-my-javascript-not-working-correctly-in-strict-mode-on-safari
  49. "V1.3.0.43 11/06/2020",
  50. " Affichage callstack en erreur profil",
  51. "V1.3.0.42 18/05/2020",
  52. " Amélioration du support SCIZ (Mise en option des fonctionnalités)",
  53. "V1.3.0.41 15/05/2020",
  54. " Amélioration du support SCIZ (Vie des trolls de la coterie)",
  55. "V1.3.0.40 13/05/2020",
  56. " Correction ARM dans le cas d'un grosse perte pour le tour",
  57. "V1.3.0.39 08/05/2020",
  58. " Correction erreur sur le profil en mode smartphone",
  59. "V1.3.0.38 25/04/2020",
  60. " Amélioration du support SCIZ (Gestion des trésors cachés)",
  61. "V1.3.0.37 19/04/2020",
  62. " Suite travail sur l'envoi de CdM en mode smartphone",
  63. "V1.3.0.36 20/04/2020",
  64. " Amélioration du support SCIZ (Icônes pour les événements !)",
  65. "V1.3.0.35 19/04/2020",
  66. " Ignorer l'absence de date/heure des CdM et gestion smartphone",
  67. "V1.3.0.33 14/04/2020",
  68. " Correction fausse reconnaissance de CdM sur les autres compétences",
  69. "V1.3.0.32 14/04/2020",
  70. " Adaptation page des ordres des suivant + [état et callback] pour les scripts tiers (voir doc sur le mot clef MZ_callback_init)",
  71. "V1.3.0.31 22/03/2020",
  72. " Envoi des CdM à partir du message du Bot",
  73. "V1.3.0.30 22/03/2020",
  74. " Amélioration du support SCIZ (Trésors dans la vue !)",
  75. "V1.3.0.29 14/03/2020",
  76. " Fix calcul PV après blessure en cas de maxPV inconnu",
  77. "V1.3.0.28 13/03/2020",
  78. " Fix la détection incohérence CdM et affichage en rouge",
  79. "V1.3.0.27 20/02/2020",
  80. " Ajout de la probabilité de toucher avec Lancer de Potion dans la Vue",
  81. "V1.3.0.26 08/02/2020",
  82. " Lisibilité CdM en mode smartphone",
  83. "V1.3.0.25 07/02/2020",
  84. " Adaptation basique au profil modifié",
  85. "V1.3.0.23 30/01/2020",
  86. " Correction affichage filtre monstre",
  87. "V1.3.0.22 23/01/2020",
  88. " Re-adaptation re-modif MH (affichage des durées négatives)",
  89. "V1.3.0.21 21/01/2020",
  90. " Adaptation à une modif MH dans la page des suivants",
  91. "V1.3.0.20 21/01/2020",
  92. " Adaptation modif MH (affichage des durées négatives)",
  93. "V1.3.0.19 19/01/2020",
  94. " Centralisation des éléments tactiques",
  95. "V1.3.0.18 19/01/2020",
  96. " Correctif pour les icônes d'action à distance dans la vue",
  97. "V1.3.0.17 16/01/2020",
  98. " Correctif pour le recall du filtre des Monstres",
  99. "V1.3.0.16 10/01/2020",
  100. " Amélioration du support SCIZ (Fix sur le prettyprint)",
  101. "V1.3.0.15 10/01/2020",
  102. " Amélioration du support SCIZ (Fix sur les événements de zone)",
  103. "V1.3.0.14 06/01/2020",
  104. " Correction filtre par famille pour les monstres variables et sans cdm",
  105. "V1.3.0.13 06/01/2020",
  106. " Ajout du filtre sur la famille des monstres",
  107. "V1.3.0.12 28/12/2019",
  108. " Fixed bug fix pour SCIZ (JWT)",
  109. "V1.3.0.11 28/12/2019",
  110. " Bug fix pour SCIZ (JWT)",
  111. "V1.3.0.10 22/12/2019",
  112. " Corrections mineures pour SCIZ",
  113. "V1.3.0.9 19/12/2019",
  114. " Amélioration du support SCIZ (Fixes + AdvancedCSS + SwitchEvent)",
  115. "V1.3.0.8 16/12/2019",
  116. " Amélioration du support SCIZ (Fixes + Play_evenement + PJView_Events)",
  117. "V1.3.0.7 12/12/2019",
  118. " correction cibles des missions 'famille', 'pouvoir' et cas particulier de 'race'",
  119. "V1.3.0.6 11/12/2019",
  120. " 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",
  121. "V1.3.0.5 11/12/2019",
  122. " Première interconnexion avec SCIZ (Options + MonsterView)",
  123. "V1.3.0.4 29/11/2019",
  124. " Ajout des déciles",
  125. "V1.3.0.3 29/11/2019",
  126. " Affichage d'une icône pour les Phœnix dont la génération est connue",
  127. "V1.3.0.2 24/11/2019",
  128. " Réduction taille info CdM",
  129. "V1.3.0.1 22/11/2019",
  130. " Ajustements sur les infos tactiques",
  131. "V1.3.0 15/11/2019",
  132. " Refonte calculs tactiques de la vue - beta",
  133. "V1.2.20.6 09/11/2019",
  134. " Correction de la formule d'AdD dans le profil",
  135. "V1.2.20.5 16/10/2019",
  136. " Mutualisation analyse ordres suivants MZ_analyse_page_ordre_suivant",
  137. "V1.2.20.4 03/10/2019",
  138. " Adaptation modif MH de la page des suivants",
  139. "V1.2.20.3 02/09/2019",
  140. " Compétence golem vers l'anatroliseur",
  141. "V1.2.20.2 25/05/2019",
  142. " Gestion des Parasitus pour les missions",
  143. "V1.2.20.1 25/05/2019",
  144. " Correction de la cible en cas de mission demandant un kill de Crasc + message d'alerte en cas de fumeux",
  145. "V1.2.20.0 25/05/2019",
  146. " Adaptation aux modifications des CdM par MH",
  147. "V1.2.19.2 16/04/2019",
  148. " Correction majuscules dans les talents",
  149. "V1.2.19.1 14/04/2019",
  150. " Prise en compte des nouvelles AdX dans profil2",
  151. "V1.2.18.15 29/03/2019",
  152. " Correction simple quote dans toutes les missions",
  153. "V1.2.18.14 09/03/2019",
  154. " Correction affichage vues 2D externes suite à une modif MH",
  155. "V1.2.18.13 27/02/2019",
  156. " Correction simple quote dans les familles de monstre des missions",
  157. "V1.2.18.12 23/12/2018",
  158. " Message si \"Menu d'actions contextuelles\" est décoché",
  159. "V1.2.18.11 21/11/2018",
  160. " Correction it bricol'troll, login avec accent",
  161. "V1.2.18.10 08/08/2018",
  162. " Correction boulette sDiplo",
  163. "V1.2.18.09 04/08/2018",
  164. " Protection contre diplomatie mal initialisée",
  165. "V1.2.18.08 11/07/2018",
  166. " Correction pour fonctionnement hors GM",
  167. "V1.2.18.07 18/05/2018",
  168. " prise en compte bonus magique d'esquive dans le profil, correction gestion de la souris dans la page d'équipement [Dabihul, welcome back]",
  169. "V1.2.18.06 28/01/2018",
  170. " Protection malus Crasc sans durée",
  171. "V1.2.18.05 18/11/2017",
  172. " Désactivation MZ V2 en mode dev pour les tests d'adaptation violentmonkey",
  173. "V1.2.18.04 04/09/2017",
  174. " retour version 1.2.18.02 avec GM 3.17",
  175. "V1.2.18.03 01/09/2017",
  176. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  177. "V1.2.18.02 26/08/2017",
  178. " correction boulette sur le compos d'enchantement",
  179. "V1.2.18.01 25/08/2017",
  180. " Suppression des messages sur les certificats en https",
  181. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  182. "V1.2.17.19 23/08/2017",
  183. " Possibilité de plusieurs IT Bricol'Troll",
  184. "V1.2.17.18 22/08/2017",
  185. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  186. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  187. "V1.2.17.17 16/07/2017",
  188. " modification du mécanisme de filtrage pour contourner un pb",
  189. "V1.2.17.16 16/07/2017",
  190. " Ajout de messages de debug sur les retours AJAX",
  191. "V1.2.17.15 15/07/2017",
  192. " modification du mécanisme de filtrage pour contourner un pb",
  193. "V1.2.17.14 14/07/2017",
  194. " correction dans la gestion des étapes de mission",
  195. "V1.2.17.13 12/07/2017",
  196. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  197. "V1.2.17.12 16/06/2017",
  198. " Correction mauvais compte de PX quand on change de Trõll",
  199. "V1.2.17.11 01/05/2017",
  200. " Travail sur le fonctionnement hors Greasemonkey",
  201. "V1.2.17.10 30/04/2017",
  202. " Protection dans la récupération d'erreur",
  203. "V1.2.17.9 30/04/2017",
  204. " Correction récupération d'erreur IT Bricol'Troll",
  205. "V1.2.17.8 29/04/2017",
  206. " Correction Bonus/Malus cas +0\+10 (AE)",
  207. " Correction portée IdC",
  208. " Prise en compte du bonus de portée PM dans le calcul tactique",
  209. "V1.2.17.7 26/04/2017",
  210. " Version compatible hors GreaseMonkey",
  211. "V1.2.17.6 23/04/2017",
  212. " Correction gestion des missions en cas de réinstallation",
  213. "V1.2.17.5 20/04/2017",
  214. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  215. "V1.2.17.4 08/04/2017",
  216. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  217. " Adaptation de la diplomatie à une modification de la page MH",
  218. "V1.2.17.3 04/04/2017",
  219. " Messages console en cas de cadre d'erreur",
  220. " Trolls de l'IT mais pas dans le vue en orange",
  221. "V1.2.17.2 20/03/2017",
  222. " Correction des PV restants",
  223. "V1.2.17.1 20/03/2017",
  224. " Blocage des PV restants en attendant résolution de bug",
  225. "V1.2.17 19/03/2017",
  226. " Refonte de l'envoi des CdM",
  227. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  228. "V1.2.16.4 08/03/2017",
  229. " correction ID de troll en envoi de PX/MP",
  230. "V1.2.16.3 27/02/2017",
  231. " correction bonus/malus FP",
  232. "V1.2.16.2 24/02/2017",
  233. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  234. "V1.2.16.1 21/02/2017",
  235. " corrige bug sur Fx 38.8 ESR",
  236. "V1.2.16 21/02/2017",
  237. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  238. " possibilité de masquer les Gowaps Sauvages dans la vue",
  239. " calcul des caractéristiques du siphon des âmes",
  240. "V1.2.15.2 02/02/2017",
  241. " adaptation décumul VlC (page des bonus/malus)",
  242. "V1.2.15.1 29/01/2017",
  243. " carte sur la page de description du lieu TP",
  244. "V1.2.15 25/01/2017",
  245. " mise en place des nouvelles cartes (suivants, TP)",
  246. "V1.2.14.3 25/01/2017",
  247. " résumé dans l'export des données Trõlligion",
  248. "V1.2.14.2 20/01/2017",
  249. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  250. "V1.2.14.1 20/01/2017",
  251. " réécriture filtrage des monstres par niveau dans la vue",
  252. " Changelog dans la page des news MZ",
  253. "V1.2.14 20/01/2017",
  254. " Ajout de l'export des données Trõlligion",
  255. "V1.2.13.7 10/01/2017",
  256. " Exclusion Bricoll'troll dans l'entête GM",
  257. "V1.2.13.6 08/01/2017",
  258. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  259. "V1.2.13.5 07/01/2017",
  260. " Correction bug qui se manisfestait sous LINUX",
  261. "V1.2.13.4 07/01/2017",
  262. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  263. "V1.2.13.3 07/01/2017",
  264. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  265. "V1.2.13.2 07/01/2017",
  266. " Correction missions, recherche troogle (familles et types de monstres)",
  267. "V1.2.13.1 06/01/2017",
  268. " Suppression oldSchoolProfile qui n'existe plus",
  269. " Ajout du 'refresh' du cadre de gauche",
  270. "V1.2.13 01/01/2017",
  271. " homogénéisation des messages d'erreur",
  272. " Ajout du lien Troogle sur les étapes de mission monstre",
  273. "V1.2.12.2 30/12/2016",
  274. " retour en mode normal (http si jeu en http)",
  275. "V1.2.12.1 27/12/2016",
  276. " Correction mode IP",
  277. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  278. "V1.2.12 24/12/2016",
  279. " Nettoyage des URL",
  280. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  281. " Interface bricoll'Troll en https",
  282. " Remise en marche des cartes des trajets des gowaps",
  283. "V1.2.11.5 à 7 20 & 21/12/2016",
  284. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  285. "V1.2.11.4 19/12/2016",
  286. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  287. "V1.2.11.3 19/12/2016",
  288. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  289. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  290. "V1.2.11.2 18/12/2016",
  291. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  292. "V1.2.11.1 17/12/2016",
  293. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  294. "V1.2.11 13/12/2016",
  295. " Passage sur BdD Raistlin \\o/",
  296. "V1.2.10.4 12/12/2016",
  297. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  298. "V1.2.10.3 09/12/2016",
  299. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  300. "V1.2.10.2 09/12/2016",
  301. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  302. "V1.2.10.1 08/12/2016",
  303. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  304. "V1.2.10 07/12/2016",
  305. " correction décumul des bonus/malus",
  306. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  307. "V1.2.9 16/11/2016",
  308. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  309. "V1.2.8 10/11/2016",
  310. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  311. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  312. "V1.2.7 07/11/2016",
  313. " remise en route de l'interface avec l'IT bricol'Troll",
  314. "V1.2.6 19/10/2016",
  315. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  316. " stockage idguilde et nomguilde",
  317. "V1.2.5 17/10/2016",
  318. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  319. " remise en route de la gestion des options avec intégration md5 dans ce script",
  320. "V1.2.4 14/10/2016",
  321. " utilisation du relai raistlin pour l'envoi des CdM",
  322. "V1.2.3 :",
  323. " suppression ancien profil",
  324. " nettoyage doublon sur getPortee",
  325. " adaptation portee TP basée sur les PI",
  326. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  327. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  328. "V1.2.1 :",
  329. " include des URLs MH alternatives",
  330. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  331. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  332. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  333. "V1.1 : regroupement en un gros paquet sale",
  334. ];
  335.  
  336. /**********************************************************
  337. À faire / propositions d'évolutions
  338.  
  339. H2P 08/07/2020
  340. * dans la vue des minerais, ça devrait a priori afficher, sur base des formules de mountypedia, le nombre de carats de chaque pépite de minerai
  341. Bireli-Gravos 08/12/2018
  342. FAIT faire un warning si l'utilisateur a désactivé la case "Menu d'actions contextuelles" dans la fenêtre "limiter la vue"
  343. breizhou13 20/12/2016
  344. envoyer les données à l'IT (Bricol'Trolls) aussi
  345. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  346. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  347. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  348. Akkila le boeuf le 26-03-2017 à 15:56
  349. - bouton pour rafraîchir les infos des trolls de son groupe
  350. Roule'
  351. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  352. Réactiver les jubilaires
  353. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  354. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  355. - voir l'intérêt de refaire fonctionner
  356. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  357. FAIT : ambiguité sur le nom de monstres de mission : Shai, Ombre, Geck'oo et Boujd'la
  358. Sans doute à corriger, la compétence Baroufle pour le lien vers l'anatroliseur
  359. Prévision des DLA de monstre
  360. FAIT Niveau des monstres à la méthode Roule'
  361. Raistlin
  362. * et si la popup des compétences s'affichait aussi au survol des raccourcis ?
  363. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  364. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  365. 80117 - Héra
  366. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  367. 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)
  368. FAIT Possibilité de plusieurs systèmes Bricol'troll
  369. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  370. ?
  371. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  372. Alanae/Gnu/Pen-Hiss
  373. * popup d'erreur js en mode smartphone sur un TP (pb trajet_canvas)
  374. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  375. Kali
  376. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  377. **********************************************************/
  378.  
  379. /**********************************************************
  380. Doc État et Callback pour l'utilisation par les scripts tiers
  381. MZ met à jour la propriété document.body.dataset.MZ_Etat
  382. 1 à la fin de l'initialisation (tout le code MZ s'est déroulé mais il peut y avoir des appels AJAX en cours)
  383. 2 (uniquement sur l'onglet de la vue) quand l'onglet a été mis à jour avec les niveaux, etc.
  384. ATTENTION, l'utilisateur peut demander un complément de CdM s'il voit plus de 500 monstres
  385. MZ appelle les callback définies dans les tableaux suivants, si ces tableaux existent
  386. document.body.MZ_Callback_init: fonctions que MZ appellera quand MZ aura fini sont initialisation
  387. ATTENTION, si MZ est chargé avant le script tiers, cette fonction ne sera jamais appelée. Le script tiers doit donc tester l'état document.body.dataset.MZ_Etat et faire l'appel à la callback lui-même si l'état est déjà défini, ce qui signifie que MZ est déjà initialisé.
  388. document.body.MZ_Callback_fin_vue: fonctions que MZ appellera quand MZ aura fini son premier traitement des CdM dans la vue
  389. ATTENTION document.body.MZ_Callback_init et document.body.MZ_Callback_fin_vue sont des tableaux.
  390. Vous n'êtes pas seuls au monde. Un autre script externe peut s'être déjà enregistré en callback
  391. Voici un exemple de code pour enregistrer une callback
  392. if (document.body.MZ_Callback_init === undefined) {
  393. document.body.MZ_Callback_init = [myCallback];
  394. } else {
  395. document.body.MZ_Callback_init.push(myCallback);
  396. }
  397. **********************************************************/
  398.  
  399. /**********************************************************
  400. **** Début de zone à déplacer dans une bibli commune ******
  401. **********************************************************/
  402.  
  403. // URL de base serveur MZ
  404. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  405. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  406. //var URL_MZ = 'http://192.99.225.92/mz';
  407.  
  408. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  409. // On dirait qu'il n'y en a plus...
  410.  
  411. // URLs externes redirection (pas de souci CORS)
  412. var URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  413. var URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  414. var URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  415. var URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  416. var URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  417. var URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  418. var URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  419. var URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  420. var URL_troogle = 'http://troogle.iktomi.eu/entities/';
  421.  
  422. // URLs de test HTTPS
  423. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  424. var URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  425.  
  426. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  427. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  428. var URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  429.  
  430. // x~x Libs
  431.  
  432. /* ancien TODO
  433. * - revoir la gestion des CdM --> nott armure magique
  434. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  435. * - vérfier la gestion des enchants
  436. */
  437.  
  438. // Roule 04/09/2016 switch extern URLs to https if available
  439. var isHTTPS = false;
  440. if (window.location.protocol.indexOf('https') === 0) {
  441. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  442. URL_bricol = URL_bricol_https;
  443. isHTTPS = true;
  444. }
  445.  
  446. // Roule 23/12/2016 mode dev
  447. var isDEV = false;
  448. if (window.localStorage.getItem('MZ_dev')
  449. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  450. || window.location.href.indexOf('mzdev.mh') >= 0) {
  451. URL_MZ = URL_MZ.replace(/$/, 'dev');
  452. isDEV = true;
  453. }
  454.  
  455. // Images (pas de souci CORS)
  456. var URL_MZimg = URL_MZ + '/img/';
  457. // URLs externes ajax (CORS OK)
  458. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  459. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  460. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  461.  
  462. // liens externes déduits
  463. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  464.  
  465. var MHicons = '/mountyhall/Images/Icones/';
  466. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  467. var MY_DEBUG = false;
  468.  
  469. var horsGM = false;
  470. try { // à partir du 11/07/2018, (GM_getValue === undefined) provoque une exception
  471. horsGM = (GM_getValue === undefined);
  472. } catch (e2) {
  473. horsGM = true;
  474. //window.console.log('test GM_getValue, exception=' + e2);
  475. }
  476. if (horsGM) { // éviter le blocage si pas sous GM
  477. window.console.log('Fonctionnement hors Greasemonkey');
  478. // Roule 18/11/2017 il ne faut pas de "var" dans les ligne précédente. Ça fonctionnait sous Greasemonkey mais plus sous Violentmonkey
  479. GM_getValue = function(key) {};
  480. GM_setValue = function(key, val) {};
  481. GM_deleteValue = function(key) {};
  482. GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  483. }
  484.  
  485. /* Utilisation de la gestion de l'enregistrement des données de
  486. GreaseMonkey, avec partage entre scripts via le localStorage, par
  487. Vapulabehemot (82169) 07/02/2017 */
  488. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  489. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  490. function MY_getValue(key) {
  491. var v = window.localStorage.getItem(key);
  492. vGM = GM_getValue(key);
  493. if ((vGM == null)
  494. || (v != null && v != vGM)){
  495. GM_setValue(key, v);
  496. } else if (v == null && vGM != null) {
  497. v = vGM;
  498. window.localStorage[key] = vGM;
  499. }
  500. return v;
  501. }
  502. function MY_removeValue(key) {
  503. GM_deleteValue(key);
  504. window.localStorage.removeItem(key);
  505. }
  506. function MY_setValue(key, val) {
  507. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  508. val = 1;
  509. else if (val === false)
  510. val = 0;
  511. try {
  512. GM_setValue(key, val);
  513. } catch(e) {
  514. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  515. }
  516. try {
  517. window.localStorage[key] = val;
  518. } catch(e) {
  519. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  520. }
  521. }
  522.  
  523. /*---------------- mise à jour de variables globales utiles ------------------*/
  524. // utilisé pour accès bdd (un peu partout) :
  525. var numTroll = MY_getValue('NUM_TROLL');
  526. // utilisé dans vue pour PX :
  527. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  528. var nivTroll; // = MY_getValue('NIV_TROLL');
  529. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  530. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  531. // utilisés dans actions et vue (calculs SR) :
  532. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  533. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  534. var currentURL = window.location.href;
  535.  
  536. /*-[functions]------------ Fonctions durée de script -------------------------*/
  537. var date_debut = null;
  538.  
  539. function start_script(nbJours_exp) {
  540. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  541. if(date_debut) return;
  542. date_debut = new Date();
  543. // Créé la variable expdate si demandé
  544. if(nbJours_exp) {
  545. expdate = new Date();
  546. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  547. }
  548. }
  549.  
  550. function displayScriptTime(duree, texte) {
  551. var footerNode = document.getElementById('footer2');
  552. if(!footerNode) return;
  553. try{
  554. var node = document.evaluate(
  555. ".//text()[contains(.,'Page générée en')]/../br",
  556. footerNode,null,9,null).singleNodeValue;
  557. }
  558. catch(e){return;}
  559. if (duree) {
  560. insertText(node,
  561. ' - [' + texte + ' en ' + (duree/1000) +' sec.]');
  562. return;
  563. }
  564. insertText(node,
  565. ' - [Script MZ exécuté en '
  566. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  567. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  568. }
  569.  
  570. function traceStack(e, sModule) {
  571. var version = '';
  572. if (GM_info && GM_info.script && GM_info.script.version)
  573. version = ' ' + GM_info.script.version;
  574. sRet = '[MZ' + version + ']'
  575. if (sModule) sRet += ' {' + sModule + '}';
  576. try {
  577. if (e.message) sRet += ' ' + e.message;
  578. } catch (e2) {
  579. sRet += ' <exception acces message>';//+ e2.message;
  580. }
  581. try {
  582. if (e.stack) {
  583. var sStack = e.stack;
  584. // enlever les infos confidentielles
  585. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  586. }
  587. } catch (e2) {
  588. sRet += ' <exception acces stack>'; // + e2.message;
  589. }
  590. return sRet;
  591. }
  592.  
  593. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  594.  
  595. function debugMZ(str){
  596. if(MY_DEBUG){
  597. window.console.debug('[MZ_DEBUG] '+str);
  598. if(typeof str === "object"){
  599. window.console.debug(str);
  600. }
  601. }
  602. }
  603.  
  604. if("function" != typeof isPage) {
  605. function isPage(url) {
  606. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  607. }
  608. }
  609.  
  610. function FF_XMLHttpRequest(MY_XHR_Ob) {
  611. var request = new XMLHttpRequest();
  612. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  613. for(var head in MY_XHR_Ob.headers) {
  614. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  615. }
  616. request.onreadystatechange = function() {
  617. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  618. if(request.readyState!=4) { return; }
  619. if(request.error) {
  620. if(MY_XHR_Ob.onerror) {
  621. MY_XHR_Ob.onerror(request);
  622. }
  623. return;
  624. }
  625. if ((request.status == 0)) {
  626. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  627. if (isDEV) {
  628. var grandCadre = createOrGetGrandCadre();
  629. var sousCadre = document.createElement('div');
  630. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  631. sousCadre.style.width = 'auto';
  632. sousCadre.style.fontSize = 'large';
  633. sousCadre.style.border = 'solid 1px black';
  634. grandCadre.appendChild(sousCadre);
  635. }
  636. if (MY_XHR_Ob.onerror) MY_XHR_Ob.onerror(request);
  637. //showHttpsErrorContenuMixte();
  638. return;
  639. }
  640. if(MY_XHR_Ob.onload) {
  641. var version;
  642. if (MY_XHR_Ob.trace) {
  643. version = '';
  644. if (GM_info && GM_info.script && GM_info.script.version)
  645. version = ' ' + GM_info.script.version;
  646. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  647. }
  648. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  649. MY_XHR_Ob.onload(request);
  650. if (MY_XHR_Ob.trace)
  651. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  652. }
  653. };
  654. request.send(MY_XHR_Ob.data);
  655. }
  656.  
  657. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  658. function MZ_formatDateMS(d, sansMicroSecondes) {
  659. if (d === undefined) d = new Date();
  660. var day = d.getDate();
  661. var month = d.getMonth()+1;
  662. var year = d.getFullYear();
  663. var hours = d.getHours();
  664. var minutes = d.getMinutes();
  665. var seconds = d.getSeconds();
  666. if (day < 10) {day = "0"+day;}
  667. if (month < 10) {month = "0"+month;}
  668. if (hours < 10) {hours = "0"+hours;}
  669. if (minutes < 10) {minutes = "0"+minutes;}
  670. if (seconds < 10) {seconds = "0"+seconds;}
  671. if (sansMicroSecondes) {
  672. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds;
  673. } else {
  674. var ms = d.getMilliseconds();
  675. ms = ('000' + ms).substr(-3, 3);
  676. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  677. }
  678. }
  679.  
  680. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  681.  
  682. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  683. function copyTextToClipboard(text) {
  684. var textArea = document.createElement("textarea");
  685.  
  686. //
  687. // *** This styling is an extra step which is likely not required. ***
  688. //
  689. // Why is it here? To ensure:
  690. // 1. the element is able to have focus and selection.
  691. // 2. if element was to flash render it has minimal visual impact.
  692. // 3. less flakyness with selection and copying which **might** occur if
  693. // the textarea element is not visible.
  694. //
  695. // The likelihood is the element won't even render, not even a flash,
  696. // so some of these are just precautions. However in IE the element
  697. // is visible whilst the popup box asking the user for permission for
  698. // the web page to copy to the clipboard.
  699. //
  700.  
  701. // Place in top-left corner of screen regardless of scroll position.
  702. textArea.style.position = 'fixed';
  703. textArea.style.top = 0;
  704. textArea.style.left = 0;
  705.  
  706. // Ensure it has a small width and height. Setting to 1px / 1em
  707. // doesn't work as this gives a negative w/h on some browsers.
  708. textArea.style.width = '2em';
  709. textArea.style.height = '2em';
  710.  
  711. // We don't need padding, reducing the size if it does flash render.
  712. textArea.style.padding = 0;
  713.  
  714. // Clean up any borders.
  715. textArea.style.border = 'none';
  716. textArea.style.outline = 'none';
  717. textArea.style.boxShadow = 'none';
  718.  
  719. // Avoid flash of white box if rendered for any reason.
  720. textArea.style.background = 'transparent';
  721.  
  722. textArea.value = text;
  723.  
  724. document.body.appendChild(textArea);
  725.  
  726. textArea.select();
  727.  
  728. var successful = document.execCommand('copy');
  729.  
  730. document.body.removeChild(textArea);
  731. return successful;
  732. }
  733.  
  734. function avertissement(txt,duree,bBloque) {
  735. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  736. if(!duree) duree = 15000;
  737. var div = document.createElement('div');
  738. // On numérote les avertissements pour destruction sélective
  739. var num = document.getElementsByName('avertissement').length;
  740. div.num = num;
  741. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  742. div.setAttribute('name','avertissement');
  743. div.className = 'mh_textbox';
  744. div.style.position = 'fixed';
  745. div.style.top = (10+15*num)+'px';
  746. div.style.left = (10+5*num)+'px';
  747. div.style.border = '5px solid red';
  748. div.style.zIndex = 2+num;
  749. div.style.cursor = 'pointer';
  750. div.style.fontSize = 'large';
  751. div.innerHTML = txt;
  752. if (!bBloque) div.onclick=function(){ tueAvertissement(this.num) };
  753.  
  754. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  755. var divcroix = document.createElement('div');
  756. divcroix.style.position = 'absolute';
  757. divcroix.style.top = 0;
  758. divcroix.style.right = 0;
  759. divcroix.style.color = 'black';
  760. divcroix.style.fontSize = 'inherit';
  761. divcroix.style.cursor = 'pointer'
  762. divcroix.style.zIndex = 2+num;
  763. divcroix.innerHTML = "X";
  764. div.appendChild(divcroix);
  765.  
  766. document.body.appendChild(div);
  767. // Destruction automatique de l'avertissement après "un certain temps"
  768. window.setTimeout(function(){ tueAvertissement(num) },duree);
  769. }
  770.  
  771. function tueAvertissement(num) {
  772. var divs = document.getElementsByName('avertissement');
  773. if(divs.length==0) { return; }
  774. for(var i=0 ; i<divs.length ; i++) {
  775. if(divs[i].num==num) {
  776. divs[i].parentNode.removeChild(divs[i]);
  777. return;
  778. }
  779. }
  780. }
  781.  
  782.  
  783. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  784.  
  785. function insertBefore(next,el) {
  786. next.parentNode.insertBefore(el,next);
  787. }
  788.  
  789. function appendTr(tbody,clas) {
  790. var tr = document.createElement('tr');
  791. if(clas) tr.className = clas;
  792. tbody.appendChild(tr);
  793. return tr;
  794. }
  795.  
  796. function insertTr(next,clas) {
  797. var tr = document.createElement('tr');
  798. if(clas) tr.className = clas;
  799. insertBefore(next,tr);
  800. return tr;
  801. }
  802.  
  803. function appendTd(tr) {
  804. var td = document.createElement('td');
  805. if(tr) tr.appendChild(td);
  806. return td;
  807. }
  808.  
  809. function insertTd(next) {
  810. var td = document.createElement('td');
  811. insertBefore(next,td);
  812. return td;
  813. }
  814.  
  815. function insertTh(next) {
  816. var th = document.createElement('th');
  817. insertBefore(next,th);
  818. return th;
  819. }
  820.  
  821. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  822. function insertAfterTd(eTd) {
  823. var newTd = document.createElement('td');
  824. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  825. return newTd;
  826. }
  827.  
  828. function appendTdCenter(tr,colspan) {
  829. var td = appendTd(tr);
  830. td.align = 'center'; // WARNING - Obsolete
  831. if(colspan) td.colSpan = colspan;
  832. return td;
  833. }
  834.  
  835. function insertTdElement(next,el) {
  836. var td = insertTd(next);
  837. if(el) td.appendChild(el);
  838. return td;
  839. }
  840.  
  841. function appendA(paren,href,cssClass,text) {
  842. var a = document.createElement('a');
  843. if (href) a.href = href;
  844. if (cssClass) a.className = cssClass;
  845. if (text) a.appendChild(document.createTextNode(text));
  846. paren.appendChild(a);
  847. }
  848.  
  849. function appendText(paren,text,bold) {
  850. if(bold) {
  851. var b = document.createElement('b');
  852. b.appendChild(document.createTextNode(text));
  853. paren.appendChild(b);
  854. }
  855. else
  856. paren.appendChild(document.createTextNode(text));
  857. }
  858.  
  859. function insertText(next,text,bold) {
  860. if(bold) {
  861. var b = document.createElement('b');
  862. appendText(b,text);
  863. insertBefore(next,b);
  864. }
  865. else
  866. insertBefore(next,document.createTextNode(text));
  867. }
  868.  
  869. function appendThText(tr,text,bold) {
  870. var th = document.createElement('th');
  871. if(tr) tr.appendChild(th);
  872. th.appendChild(document.createTextNode(text));
  873. if (bold) th.style.fontWeight = 'bold';
  874. return th;
  875. }
  876.  
  877. function appendTdText(tr,text,bold) {
  878. var td = appendTd(tr);
  879. td.appendChild(document.createTextNode(text));
  880. if (bold) td.style.fontWeight = 'bold';
  881. return td;
  882. }
  883.  
  884. function insertThText(next,text,bold) {
  885. var th = insertTh(next);
  886. appendText(th,text,bold);
  887. return th;
  888. }
  889.  
  890. function insertTdText(next,text,bold) {
  891. var td = insertTd(next);
  892. appendText(td,text,bold);
  893. return td;
  894. }
  895.  
  896. function appendBr(paren) {
  897. paren.appendChild(document.createElement('br'));
  898. }
  899.  
  900. function insertBr(next) {
  901. insertBefore(next,document.createElement('br'));
  902. }
  903.  
  904. function appendLI(ul,text) {
  905. // uniquement utilisé dans les options (crédits)
  906. var li = document.createElement('li');
  907. appendText(li,text);
  908. ul.appendChild(li);
  909. return li;
  910. }
  911.  
  912. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  913. var input = document.createElement('input');
  914. input.className = 'TextboxV2';
  915. input.type = type;
  916. input.name = nam;
  917. if (sId === undefined) input.id = nam;
  918. else input.id = sId;
  919. input.size = size;
  920. input.maxLength = maxlength;
  921. if(value) input.value = value;
  922. paren.appendChild(input);
  923. return input;
  924. }
  925.  
  926. function appendCheckBox(paren,nam,checked,onClick) {
  927. var input = document.createElement('input');
  928. input.type = 'checkbox';
  929. input.name = nam;
  930. input.id = nam;
  931. if(checked) input.checked = true;
  932. if(onClick) input.onclick = onClick;
  933. paren.appendChild(input);
  934. return input;
  935. }
  936.  
  937. function appendNobr(paren,id,delgg,text) {
  938. var nobr = document.createElement('nobr');
  939. appendCheckBox(nobr,id,null,delgg);
  940. appendText(nobr,text);
  941. paren.appendChild(nobr);
  942. appendText(paren,' ');
  943. return nobr;
  944. }
  945.  
  946. function appendCheckBoxSpan(paren,id,onClick,text) {
  947. var span = document.createElement('span');
  948. span.style.whiteSpace = 'nowrap';
  949. appendCheckBox(span,id,false,onClick);
  950. var label = document.createElement('label');
  951. appendText(label,text);
  952. label.htmlFor = id;
  953. label.style.marginLeft = '-5px';
  954. span.appendChild(label);
  955. span.style.marginRight = '3px';
  956. paren.appendChild(span);
  957. appendText(paren, ' ');
  958. return span;
  959. }
  960.  
  961. function appendOption(select,value,text) {
  962. var option = document.createElement('option');
  963. option.value = value;
  964. appendText(option,text);
  965. select.appendChild(option);
  966. return option;
  967. }
  968.  
  969. function appendHidden(form,nam,value) {
  970. var input = document.createElement('input');
  971. input.type = 'hidden';
  972. input.name = nam;
  973. input.id = nam;
  974. input.value = value;
  975. form.appendChild(input);
  976. }
  977.  
  978. function appendButton(paren,value,onClick) {
  979. var input = document.createElement('input');
  980. input.type = 'button';
  981. input.className = 'mh_form_submit';
  982. input.value = value;
  983. input.onmouseover = function(){this.style.cursor='pointer';};
  984. if(onClick) input.onclick = onClick;
  985. paren.appendChild(input);
  986. return input;
  987. }
  988.  
  989. function insertButton(next,value,onClick) {
  990. var input = document.createElement('input');
  991. input.type = 'button';
  992. input.className = 'mh_form_submit';
  993. input.value = value;
  994. input.onmouseover = function(){this.style.cursor='pointer';};
  995. input.onclick = onClick;
  996. insertBefore(next,input);
  997. return input;
  998. }
  999.  
  1000. function appendSubmit(paren,value,onClick) {
  1001. var input = document.createElement('input');
  1002. input.type = 'submit';
  1003. input.className = 'mh_form_submit';
  1004. input.value = value;
  1005. input.onmouseover = function(){this.style.cursor='pointer';};
  1006. if(onClick) input.onclick = onClick;
  1007. paren.appendChild(input);
  1008. return input;
  1009. }
  1010.  
  1011. function createImage(url,title,style) {
  1012. var img = document.createElement('img');
  1013. img.src = url;
  1014. img.title = title;
  1015. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  1016. if (style) img.style = style;
  1017. return img;
  1018. }
  1019.  
  1020. function createAltImage(url,alt,title) {
  1021. var img = document.createElement('img');
  1022. img.src = url;
  1023. img.alt = alt;
  1024. if (title) img.title = title;
  1025. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  1026. return img;
  1027. }
  1028.  
  1029. function createImageSpan(url,alt,title,text,bold) {
  1030. var span = document.createElement('span');
  1031. span.title = title;
  1032. var img = document.createElement('img');
  1033. img.src = url;
  1034. img.alt = alt;
  1035. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  1036. span.appendChild(img);
  1037. appendText(span,text,bold);
  1038. return span;
  1039. }
  1040.  
  1041. function createCase(titre,table,width) {
  1042. if(!width) width=120;
  1043. var tr = appendTr(table,'mh_tdpage');
  1044.  
  1045. var td = appendTdText(tr,titre,true);
  1046. td.className = 'mh_tdtitre';
  1047. td.width = width;
  1048.  
  1049. td = appendTdText(tr,'');
  1050. td.className = 'mh_tdpage';
  1051. return td;
  1052. }
  1053.  
  1054. function getMyID(e) {
  1055. var parent = e.parentNode;
  1056. for(var i=0 ; i<parent.childNodes.length ; i++) {
  1057. if(e==parent.childNodes[i])
  1058. return i;
  1059. }
  1060. return -1;
  1061. }
  1062.  
  1063. function insertAfter(elt,newElt) {
  1064. var id = getMyID(elt);
  1065. if(id==-1) return;
  1066. if(id<elt.parentNode.childNodes.length-1)
  1067. insertBefore(elt.nextSibling,newElt);
  1068. else
  1069. elt.parentNode.appendChild(newElt);
  1070. }
  1071.  
  1072.  
  1073. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  1074.  
  1075. function aff(nb) {
  1076. return (nb >= 0) ? '+' + nb : nb;
  1077. }
  1078.  
  1079. function getNumber(str) {
  1080. var nbr = str.match(/\d+/);
  1081. return nbr ? Number(nbr[0]) : Number.NaN;
  1082. }
  1083.  
  1084. function getNumbers(str) {
  1085. var nbrs = str.match(/\d+/g);
  1086. if (!nbrs) return [];
  1087. for (var i = 0; i < nbrs.length; i++) {
  1088. nbrs[i] = Number(nbrs[i]);
  1089. }
  1090. return nbrs;
  1091. }
  1092.  
  1093. function getIntegers(str) {
  1094. var nbrs = str.match(/-?\d+/g);
  1095. if (!nbrs) return [];
  1096. for(var i=0 ; i<nbrs.length ; i++) {
  1097. nbrs[i] = Number(nbrs[i]);
  1098. }
  1099. return nbrs;
  1100. }
  1101.  
  1102. function trim(str) {
  1103. return str.replace(/(^\s*)|(\s*$)/g, '');
  1104. }
  1105.  
  1106. if (typeof String.prototype.trim != 'function') {
  1107. // Intégré depuis ES5, pour rétrocompatibilité
  1108. String.prototype.trim = function() {
  1109. return this.replace(/^\s+/, '').replace(/\s+$/, '');
  1110. }
  1111. }
  1112.  
  1113. function epure(texte) {
  1114. return texte
  1115. .replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1116. .replace(/[ç]/g,'c')
  1117. .replace(/[éêèë]/g,'e')
  1118. .replace(/[ïî]/g,'i')
  1119. .replace(/[ôöõ]/g,'o')
  1120. .replace(/[ùûü]/g,'u');
  1121. }
  1122.  
  1123. // WARNING Modifier des constantes, c'est mal
  1124. String.prototype.epure = function() {
  1125. return this
  1126. .replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1127. .replace(/[ç]/g,'c')
  1128. .replace(/[éêèë]/g,'e')
  1129. .replace(/[ïî]/g,'i')
  1130. .replace(/[ôöõ]/g,'o')
  1131. .replace(/[ùûü]/g,'u');
  1132. }
  1133.  
  1134. function bbcode(texte) {
  1135. return texte
  1136. .replace(/&/g, '&amp;')
  1137. .replace(/"/g, '&quot;')
  1138. .replace(/</g, '&lt;')
  1139. .replace(/>/g, '&gt;')
  1140. .replace(/'/g, '&#146;')
  1141. .replace(/\[b\](.*?)\[\/b\]/g, '<b>$1</b>')
  1142. .replace(/\[i\](.*?)\[\/i\]/g, '<i>$1</i>')
  1143. .replace(/\[img\]([^"]*?)\[\/img\]/g, '<img src="$1" />');
  1144. }
  1145.  
  1146. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  1147.  
  1148. function addZero(i) {
  1149. return (i<10) ? '0'+i : i;
  1150. }
  1151.  
  1152. function DateToString(date) {
  1153. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  1154. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  1155. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  1156. }
  1157.  
  1158. function StringToDate(str) {
  1159. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  1160. }
  1161.  
  1162. // fonctionne aussi avec datetime
  1163. function SQLDateToFrench(str) {
  1164. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  1165. }
  1166.  
  1167. // ... et ajoute un "à" du plus bel effet
  1168. function SQLDateToFrenchTime(str) {
  1169. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  1170. }
  1171.  
  1172. // SQLDate vers objet date Javascript
  1173. function SQLDateToObject(str) {
  1174. var t = str.split(/[- :]/);
  1175. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  1176. }
  1177.  
  1178. var mz_ie = (window.attachEvent)? true:false;
  1179. if ("function" !== typeof addEvent) {
  1180. if (mz_ie) {
  1181. function addEvent(obj, typ, fn, sens) {
  1182. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  1183. obj["e"+typ+fn]( window.event );
  1184. }
  1185. obj.attachEvent("on"+typ, obj[typ+fn] );
  1186. }
  1187. }
  1188. else {
  1189. function addEvent(obj, typ, fn, sens) {
  1190. obj.addEventListener(typ, fn, sens);
  1191. }
  1192. }
  1193. }
  1194.  
  1195. /**********************
  1196. * glissière en mode objet
  1197. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  1198. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  1199. *
  1200. * Usage:
  1201. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  1202. * ref : utilisé pour diversifier les IDs HTML
  1203. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  1204. * target : peut être de 3 types
  1205. * - élément HTML : l'élément HTML à zoomer
  1206. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  1207. * - function : callback quand le curseur bouge
  1208. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  1209. * dans le mode dynamique, la callback est appelée sur mouseMove
  1210. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  1211. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  1212. * autres méthodes
  1213. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  1214. **********************/
  1215.  
  1216. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  1217. try {
  1218. var mouseDown = false;
  1219. var div_gliss = document.createElement("div"); // la DIV mère
  1220. div_gliss.id = "MZ_gliss_"+ref;
  1221. var div_label = document.createElement("span"); // le label
  1222. div_label.innerHTML = labelHTML;
  1223. div_gliss.appendChild(div_label);
  1224. div_gliss.className = "choix_zoom";
  1225. var dessin = document.createElement("canvas"); // le dessin lui-même
  1226. dessin.id = "MZ_gliss_dessin_"+ref;
  1227. dessin.style.cursor = "pointer";
  1228. dessin.width = 104;
  1229. dessin.height = 12;
  1230. dessin.style.marginLeft = '2px';
  1231. dessin.style.marginRight = '2px';
  1232. div_gliss.appendChild(dessin);
  1233. var pourcent = document.createElement("span"); // le pourcentage
  1234. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1235. var pourcent_text = document.createTextNode('');
  1236. var previousVal;
  1237. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1238.  
  1239. // alignement vertical
  1240. dessin.style.verticalAlign = 'middle';
  1241. div_label.style.verticalAlign = 'middle';
  1242. pourcent.style.verticalAlign = 'middle';
  1243.  
  1244. pourcent.appendChild(pourcent_text);
  1245. div_gliss.appendChild(pourcent);
  1246.  
  1247. var bulle_pourcent = document.createElement("div"); // la bulle
  1248. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1249. bulle_pourcent.style.display = 'block';
  1250. bulle_pourcent.style.visibility = 'hidden';
  1251. bulle_pourcent.style.position = 'absolute';
  1252. bulle_pourcent.style.zIndex = 3500;
  1253. bulle_pourcent.style.border = '1px solid #a1927f';
  1254. var bulle_pourcent_text = document.createTextNode('');
  1255. bulle_pourcent.appendChild(bulle_pourcent_text);
  1256. document.body.appendChild(bulle_pourcent);
  1257.  
  1258. this.getElt = function() {return div_gliss;};
  1259.  
  1260. ////////////////////////////////////
  1261. // dessine et redessine le curseur
  1262. ////////////////////////////////////
  1263. var dessine_glissiere = function(val) {
  1264. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1265. var ctx = dessin.getContext('2d');
  1266. ctx.clearRect(0, 0,104, 12);
  1267. ctx.fillStyle = "rgb(0,0,0)";
  1268. ctx.fillRect(0,0,2,12);
  1269. ctx.fillRect(102,0,2,12);
  1270. ctx.fillRect(0,5,104,2);
  1271.  
  1272. ctx.fillStyle = "rgb(80,80,80)";
  1273. ctx.fillRect(pos_0_100,0,5,12);
  1274. ctx.fillStyle = "rgb(200,200,200)";
  1275. ctx.fillRect(pos_0_100+1,1,3,10);
  1276. pourcent_text.nodeValue = val+'%';
  1277. previousVal = parseInt(val);
  1278. };
  1279.  
  1280. ////////////////////////////////////
  1281. // action sur mousedown et mousemove
  1282. // stocker la nouvelle valeur
  1283. // redessiner
  1284. // afficher la nouvelle valeur
  1285. // action selon ce qui a été demandé
  1286. ////////////////////////////////////
  1287. var doCallback_glissiere = function (evt) {
  1288. try {
  1289. if (evt.type === 'mousedown') mouseDown = true;
  1290. if (evt.offsetX) {
  1291. var xsouris = evt.offsetX;
  1292. var xpos = evt.clientX;
  1293. var ypos = evt.clientY + document.body.scrollTop;
  1294. }
  1295. else {
  1296. var xsouris = evt.layerX;
  1297. var xpos = evt.pageX;
  1298. var ypos = evt.pageY;
  1299. }
  1300. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1301. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1302. // afficher la nouvelle valeur dans la bulle
  1303. bulle_pourcent_text.nodeValue = val + '%';
  1304. bulle_pourcent.style.top = (ypos+3)+'px';
  1305. bulle_pourcent.style.left = (xpos+16)+'px';
  1306. if (evt.buttons === undefined) {
  1307. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1308. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1309. } else {
  1310. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1311. }
  1312. // stocker la nouvelle valeur
  1313. MY_setValue("MZ_glissiere_" + ref, val);
  1314. // redessiner la glissière avec le curseur où il faut
  1315. dessine_glissiere(val);
  1316. // action selon ce qui a été demandé
  1317. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1318. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1319. if (typeof paramTarget === 'object') {
  1320. var elt = paramTarget;
  1321. } else if (typeof paramTarget === 'string') {
  1322. var elt = document.getElementById(paramTarget);
  1323. } else if (typeof paramTarget === 'function') {
  1324. paramTarget(val);
  1325. return;
  1326. }
  1327. if (elt.setZoom != undefined) elt.setZoom(val);
  1328. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1329. };
  1330.  
  1331. ////////////////////////////////////
  1332. // event mousedown et mousemove : redessiner et callback
  1333. ////////////////////////////////////
  1334. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1335. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1336. ////////////////////////////////////
  1337. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1338. ////////////////////////////////////
  1339. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1340. ////////////////////////////////////
  1341. // event mouseout & mouseover : afficher/cacher la bulle
  1342. ////////////////////////////////////
  1343. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1344. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1345.  
  1346. ////////////////////////////////////
  1347. // dessiner la première fois
  1348. ////////////////////////////////////
  1349. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1350. if (val_init === undefined) val_init = valDef;
  1351. dessine_glissiere(val_init);
  1352. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1353. }
  1354.  
  1355. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1356. // reçoit 2 objets avec des propriétés x et y
  1357. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1358. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1359. var deltaX = locArrivee.x - locDepart.x;
  1360. if (deltaX == 0) return; // pas de point intermédiaire
  1361. var deltaY = locArrivee.y - locDepart.y;
  1362. if (deltaY == 0) return; // pas de point intermédiaire
  1363. var absDeltaX = Math.abs(deltaX);
  1364. var absDeltaY = Math.abs(deltaY);
  1365. if (absDeltaX > absDeltaY) {
  1366. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1367. } else if (absDeltaY > absDeltaX) {
  1368. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1369. } else {
  1370. return; // égalité, pas de point intermédiaire
  1371. }
  1372. }
  1373.  
  1374. /**********************
  1375. * carte en mode objet
  1376. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1377. *
  1378. * Usage:
  1379. * carte = new carte_MZ(ref, tabDepl);
  1380. * ref : utilisé pour diversifier les IDs HTML
  1381. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1382. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1383. * autres méthodes
  1384. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1385. **********************/
  1386.  
  1387. function carte_MZ(ref, tabDepl) {
  1388. try {
  1389. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1390. div1_carte.id = "MZ_carte_"+ref;
  1391. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1392. div1_carte.style.backgroundImage = 'none';
  1393. div1_carte.style.backgroundColor = 'transparent';
  1394. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1395. div2_carte.className = "carte_MZ";
  1396. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1397. var dessin = document.createElement("canvas"); // le dessin lui-même
  1398. dessin.id = "MZ_carte_dessin_"+ref;
  1399. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1400. div1_carte.appendChild(div2_carte);
  1401. div2_carte.appendChild(dessin);
  1402.  
  1403. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1404. , [-66.5, -37.5, 2, 1.5, -69]
  1405. , [-63.5, 8.5, 2, 1.5, -69]
  1406. , [-59.5, -32.5, 2, 1.5, -69]
  1407. , [-52, 57, 0.25, 0.8, -59]
  1408. , [-50.5, -22.5, 2, 1.5, -69]
  1409. , [-35.5, -51.5, 2, 1.5, -69]
  1410. , [-34.5, 14.5, 2, 1.5, -69]
  1411. , [-34.5, 64.5, 2, 1.5, -69]
  1412. , [-11.5, 72.5, 2, 1.5, -69]
  1413. , [5.5, -49.5, 2, 1.5, -69]
  1414. , [5.5, 31.5, 2, 1.5, -69]
  1415. , [10.5, 63.5, 2, 1.5, -69]
  1416. , [12, -15, 0.25, 0.8, -59]
  1417. , [21.5, 35.5, 2, 1.5, -69]
  1418. , [30, -52, 0.25, 0.8, -59]
  1419. , [46.5, 51.5, 2, 1.5, -69]
  1420. , [48, -39, 0.25, 0.8, -59]
  1421. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1422. , [56.5, 23.5, 75, 8.7, -99]
  1423. , [64, 70, 0.25, 0.8, -59]
  1424. , [74.5, 31.5, 2, 1.5, -69]];
  1425.  
  1426. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1427. var couleur_cible = 'rgba(0,0,0,0.5)';
  1428. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1429. var couleur_trou = 'rgb(200,0,0)';
  1430.  
  1431. var coord_x = function(val) {
  1432. return decalh+coeff*(val+100);
  1433. };
  1434. var coord_y = function(val) {
  1435. return decalv+coeff*(100-val);
  1436. };
  1437.  
  1438. var ctx = dessin.getContext('2d');
  1439. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1440. if (coeff) coeff /= 50;
  1441. else coeff = 2;
  1442. var decalv=30, decalh=30;
  1443.  
  1444. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1445. //var res = false
  1446. var x0 = pos0.x;
  1447. var y0 = pos0.x;
  1448. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1449. var px = Math.sign(pos1.x - pos0.x);
  1450. var py = Math.sign(pos1.y - pos0.y);
  1451. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1452. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1453.  
  1454. for(var k in position_trous_MZ) {
  1455. a = parseFloat(px*px+py*py);
  1456. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1457. 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]);
  1458. delta = b*b-a*c
  1459. if(delta >= 0) {
  1460. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1461. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1462. if(t0 <= tmax && t1 >= 0) {
  1463. // 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
  1464. //res = true;
  1465. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1466. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1467. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1468. // Roule : pas utile pour nous
  1469. //res = true;
  1470. //chute.push([x0+l*px, y0+l*py]);
  1471. return true;
  1472. }
  1473. }
  1474. }
  1475. }
  1476. //return res;
  1477. return false;
  1478. };
  1479.  
  1480. var dessine_carte = function () {
  1481. dessin.width = 200*coeff+2*decalh;
  1482. dessin.height = 200*coeff+2*decalv;
  1483.  
  1484. //repere
  1485. ctx.beginPath();
  1486. ctx.moveTo(coord_x(0), coord_y(100));
  1487. ctx.lineTo(coord_x(0), coord_y(-100));
  1488. ctx.moveTo(coord_x(-100), coord_y(0));
  1489. ctx.lineTo(coord_x(100), coord_y(0));
  1490. ctx.stroke();
  1491. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1492.  
  1493. //trous
  1494. ctx.fillStyle = couleur_trou;
  1495. for(var i in position_trous_MZ) {
  1496. ctx.beginPath();
  1497. 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);
  1498. ctx.fill();
  1499. }
  1500. // trajets
  1501. ctx.lineCap = "round";
  1502. ctx.lineJoin = "round";
  1503. for (var iSuivant in tabDepl) {
  1504. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1505. var tabDeplOneSuivant = tabDepl[iSuivant];
  1506. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1507. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1508. // La "cible" au départ
  1509. var typeDepart = tabDeplOneSuivant[0].typ;
  1510. switch (typeDepart) {
  1511. case 'tp':
  1512. ctx.beginPath();
  1513. ctx.lineWidth = 2;
  1514. ctx.strokeStyle = couleur_cible;
  1515. ctx.fillStyle = couleur_cible;
  1516. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1517. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1518. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1519. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1520. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1521. ctx.moveTo(x0 + coeff * 3, y0);
  1522. ctx.lineTo(x0 - coeff * 3, y0);
  1523. ctx.moveTo(x0, y0 + coeff * 3);
  1524. ctx.lineTo(x0, y0 - coeff * 3);
  1525. ctx.stroke();
  1526. break;
  1527. default:
  1528. ctx.beginPath();
  1529. ctx.lineWidth = 1;
  1530. ctx.strokeStyle = couleur_cible;
  1531. ctx.fillStyle = couleur_cible;
  1532. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1533. ctx.moveTo(x0 + coeff * 4, y0);
  1534. ctx.lineTo(x0 - coeff * 4, y0);
  1535. ctx.moveTo(x0, y0 + coeff * 4);
  1536. ctx.lineTo(x0, y0 - coeff * 4);
  1537. ctx.stroke();
  1538. break;
  1539. }
  1540. // les segments
  1541. var nb_pts = tabDeplOneSuivant.length;
  1542. var pointPrecedent = tabDeplOneSuivant[0];
  1543. for (var i=1; i<nb_pts; i++) {
  1544. ctx.beginPath();
  1545. ctx.lineWidth = coeff;
  1546. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1547. ctx.strokeStyle = couleur_depl_normal;
  1548. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1549. if (pointIntermediaire === undefined) {
  1550. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1551. ctx.strokeStyle = couleur_depl_collision_trou;
  1552. else
  1553. ctx.strokeStyle = couleur_depl_normal;
  1554. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1555. } else {
  1556. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1557. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1558. ctx.strokeStyle = couleur_depl_collision_trou;
  1559. else
  1560. ctx.strokeStyle = couleur_depl_normal;
  1561. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1562. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1563. }
  1564. pointPrecedent = tabDeplOneSuivant[i];
  1565. ctx.stroke();
  1566. }
  1567. // Les points à chaque étape
  1568. ctx.fillStyle = couleur_depl_normal;
  1569. for (var i=1; i<nb_pts; i++) {
  1570. ctx.beginPath();
  1571. var x = coord_x(tabDeplOneSuivant[i].x);
  1572. var y = coord_y(tabDeplOneSuivant[i].y);
  1573. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1574. ctx.fill();
  1575. }
  1576. }
  1577. }
  1578.  
  1579. this.setZoom = function (val) {
  1580. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1581. coeff = val / 50;
  1582. dessine_carte();
  1583. }
  1584.  
  1585. // glissiere
  1586. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1587. var eGliss = gliss.getElt();
  1588. eGliss.style.position = 'absolute';
  1589. eGliss.style.top = (coeff * 2) + 'px';
  1590. eGliss.style.left = decalh + 'px';
  1591. dessin.style.position = 'relative';
  1592. div2_carte.style.position = 'relative';
  1593. eGliss.style.zIndex = 9000;
  1594. div2_carte.appendChild(eGliss);
  1595.  
  1596. // affichage au survol de la souris
  1597. var bulle = document.createElement('div');
  1598. bulle.style.visibility = 'hidden';
  1599. bulle.style.position = 'absolute';
  1600. bulle.style.zIndex = 3100;
  1601. bulle.style.border = 'solid 1px #a1927f';
  1602. bulle.className = 'mh_tdpage';
  1603. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1604. var bulleHaut = document.createElement('div');
  1605. bulleHaut.style.display = 'block';
  1606. bulleHaut.style.paddingRight = '3px';
  1607. bulleHaut.className = 'mh_tdtitre';
  1608. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1609. bulle.appendChild(bulleHaut);
  1610. var bulleBas = document.createElement('div');
  1611. bulleBas.style.display = 'block';
  1612. bulleBas.style.whiteSpace = "nowrap";
  1613. bulleBas.style.paddingRight = '3px';
  1614.  
  1615. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1616. bulle.appendChild(bulleBas);
  1617. div2_carte.appendChild(bulle);
  1618. var affichePosition = function(evt) {
  1619. if (evt.offsetX) {
  1620. var xsouris = evt.offsetX;
  1621. var ysouris = evt.offsetY;
  1622. var xpos = evt.clientX;
  1623. var ypos = evt.clientY + document.body.scrollTop;
  1624. }
  1625. else {
  1626. var xsouris = evt.layerX;
  1627. var ysouris = evt.layerY;
  1628. var xpos = evt.pageX;
  1629. var ypos = evt.pageY;
  1630. }
  1631. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1632. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1633. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1634. var tabHTMLbas = [];
  1635. // message pour les trous
  1636. for (var i in position_trous_MZ) {
  1637. var ceTrou = position_trous_MZ[i];
  1638. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1639. if(dist <= 0) {
  1640. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1641. break;
  1642. }
  1643. }
  1644. // messages pour les suivants
  1645. for (var i in tabDepl) {
  1646. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1647. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1648. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1649. }
  1650. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1651. bulle.style.top = (ysouris+8) + 'px';
  1652. bulle.style.left = (xsouris+16) + 'px';
  1653. };
  1654. addEvent(dessin, "mousemove", affichePosition, true);
  1655. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1656. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1657.  
  1658. // dessin initial
  1659. dessine_carte();
  1660.  
  1661. this.getElt = function() {return div1_carte;};
  1662.  
  1663. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1664. }
  1665.  
  1666.  
  1667. /**********************************************************
  1668. **** Fin de zone à déplacer dans une bibli commune ********
  1669. **********************************************************/
  1670.  
  1671. /* DEBUG: NETTOYAGE TAGS */
  1672. if(MY_getValue(numTroll+'.TAGSURL')) {
  1673. MY_removeValue(numTroll+'.TAGSURL');
  1674. }
  1675.  
  1676. // Alerte si mode dev
  1677. if (isDEV) {
  1678. var divpopup = document.createElement('div');
  1679. divpopup.id = 'divDEV';
  1680. divpopup.style =
  1681. 'position: fixed;'+
  1682. 'border: 15px solid red;'+
  1683. 'top: 10px;right: 10px;'+
  1684. 'background-color: white;'+
  1685. 'color: black;'+
  1686. 'font-size: large;'+
  1687. 'padding: 5px'+
  1688. 'z-index: 200;';
  1689. appendText(divpopup, '[MZ] Mode DEV');
  1690. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1691. document.body.appendChild(divpopup);
  1692. }
  1693.  
  1694. /*---------- regroupement des getPortee() ------------------------------------*/
  1695.  
  1696. function getPortee(param) {
  1697. param = Math.max(0,Number(param));
  1698. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1699. // ça devrait être floor, +10.25, -2.5
  1700. }
  1701.  
  1702. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1703.  
  1704. function getPXKill(niv) {
  1705. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1706. return Math.max(0,10+3*niv-2*nivTroll);
  1707. }
  1708.  
  1709. function getPXDeath(niv) {
  1710. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1711. return Math.max(0,10+3*nivTroll-2*niv);
  1712. }
  1713.  
  1714. function analysePX(niv) {
  1715. niv = niv+'';
  1716. var i = niv.indexOf('+');
  1717. if(i!=-1) // si niv = 'XX+' ??
  1718. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1719. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1720. if(i!=-1) {
  1721. var max = getPXKill(niv.slice(i+2));
  1722. if(max==0)
  1723. return ' --> <b>0</b> PX';
  1724. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1725. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1726. }
  1727. i = niv.indexOf('='); // ???
  1728. if(i!=-1) {
  1729. var max = getPXKill(niv.slice(i+1));
  1730. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1731. }
  1732. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1733. }
  1734.  
  1735. function analysePXTroll(niv) {
  1736. var str = analysePX(niv);
  1737. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1738. return str;
  1739. }
  1740.  
  1741.  
  1742. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1743. // Refonte totale du code de Zorya
  1744.  
  1745. // Elements à implémenter en dur dans MZ2.0
  1746. var numQualite = {
  1747. 'Très Mauvaise':1,
  1748. 'Mauvaise':2,
  1749. 'Moyenne':3,
  1750. 'Bonne':4,
  1751. 'Très Bonne':5
  1752. };
  1753.  
  1754. var qualiteNum = [
  1755. '_dummy_',
  1756. 'Très Mauvaise',
  1757. 'Mauvaise',
  1758. 'Moyenne',
  1759. 'Bonne',
  1760. 'Très Bonne'
  1761. ];
  1762.  
  1763. var nival = {
  1764. 'Abishaii Bleu':19,
  1765. 'Abishaii Noir':10,
  1766. 'Abishaii Rouge':23,
  1767. 'Abishaii Vert':15,
  1768. 'Ame-en-peine':8,
  1769. 'Amibe Geante':9,
  1770. 'Anaconda des Catacombes':8,
  1771. 'Ankheg':10,
  1772. 'Anoploure Purpurin':36,
  1773. 'Araignee Geante':2,
  1774. 'Ashashin':35,
  1775. 'Balrog':50,
  1776. 'Banshee':16,
  1777. 'Barghest':36,
  1778. 'Basilisk':11,
  1779. 'Behemoth':34,
  1780. 'Behir':14,
  1781. 'Beholder':50,
  1782. 'Boggart':3,
  1783. 'Bondin':9,
  1784. "Bouj'Dla Placide":37,
  1785. "Bouj'Dla":19,
  1786. 'Bulette':19,
  1787. 'Caillouteux':1,
  1788. 'Capitan':35,
  1789. 'Carnosaure':25,
  1790. 'Champi-Glouton':3,
  1791. 'Chauve-Souris Geante':4,
  1792. 'Cheval a Dents de Sabre':23,
  1793. 'Chevalier du Chaos':20,
  1794. 'Chimere':13,
  1795. 'Chonchon':24,
  1796. 'Coccicruelle':22,
  1797. 'Cockatrice':5,
  1798. 'Crasc Medius':17,
  1799. 'Crasc Maexus':25,
  1800. 'Crasc':10,
  1801. 'Croquemitaine':6,
  1802. 'Cube Gelatineux':32,
  1803. 'Daemonite':27,
  1804. 'Diablotin':5,
  1805. 'Dindon du Chaos':1,
  1806. 'Djinn':29,
  1807. 'Ectoplasme':18,
  1808. 'Effrit':27,
  1809. "Elementaire d'Air":23,
  1810. "Elementaire d'Eau":17,
  1811. 'Elementaire de Feu':21,
  1812. 'Elementaire de Terre':21,
  1813. 'Elementaire du Chaos':26,
  1814. 'Erinyes':7,
  1815. 'Esprit-Follet':16,
  1816. 'Essaim Craterien':30,
  1817. 'Essaim Sanguinaire':25,
  1818. 'Ettin':8,
  1819. 'Familier':1,
  1820. 'Fantome':24,
  1821. 'Feu Follet':20,
  1822. 'Flagelleur Mental':33,
  1823. 'Foudroyeur':38,
  1824. 'Fumeux':22,
  1825. 'Fungus Geant':9,
  1826. 'Fungus Violet':4,
  1827. 'Furgolin':10,
  1828. 'Gargouille':3,
  1829. 'Geant de Pierre':13,
  1830. 'Geant des Gouffres':22,
  1831. "Geck'oo Majestueux":40,
  1832. "Geck'oo":15,
  1833. 'Glouton':20,
  1834. 'Gnoll':5,
  1835. 'Gnu Domestique':1,
  1836. 'Gnu Sauvage':1,
  1837. 'Goblin':4,
  1838. 'Goblours':4,
  1839. "Golem d'Argile":15,
  1840. 'Golem de cuir':1,
  1841. 'Golem de Chair':8,
  1842. 'Golem de Fer':31,
  1843. 'Golem de mithril':1,
  1844. 'Golem de metal':1,
  1845. 'Golem de papier':1,
  1846. 'Golem de Pierre':23,
  1847. 'Gorgone':11,
  1848. 'Goule':4,
  1849. 'Gowap Apprivoise':1,
  1850. 'Gowap Sauvage':1,
  1851. 'Gremlins':3,
  1852. 'Gritche':39,
  1853. 'Grouilleux':4,
  1854. 'Grylle':31,
  1855. 'Harpie':4,
  1856. 'Hellrot':18,
  1857. 'Homme-Lezard':4,
  1858. 'Hurleur':8,
  1859. 'Hydre':50,
  1860. 'Incube':13,
  1861. 'Kobold':2,
  1862. 'Labeilleux':26,
  1863. 'Lezard Geant':5,
  1864. 'Liche':50,
  1865. 'Limace Geante':10,
  1866. 'Loup-Garou':8,
  1867. 'Lutin':4,
  1868. 'Mante Fulcreuse':30,
  1869. 'Manticore':9,
  1870. 'Marilith':33,
  1871. 'Meduse':6,
  1872. 'Megacephale':38,
  1873. 'Mille-Pattes Geant':14,
  1874. 'Mimique':6,
  1875. 'Minotaure':7,
  1876. 'Molosse Satanique':8,
  1877. 'Momie':4,
  1878. 'Monstre Rouilleur':3,
  1879. "Mouch'oo Domestique":14,
  1880. "Mouch'oo Majestueux Sauvage":33,
  1881. "Mouch'oo Sauvage":14,
  1882. 'Na-Haniym-Heee':0,
  1883. 'Necrochore':37,
  1884. 'Necromant':39,
  1885. 'Necrophage':8,
  1886. 'Naga':10,
  1887. 'Nuee de Vermine':13,
  1888. "Nuage d'Insectes":7,
  1889. 'Ogre':7,
  1890. 'Ombre de Roches':13,
  1891. 'Ombre':2,
  1892. 'Orque':3,
  1893. 'Ours-Garou':18,
  1894. 'Palefroi Infernal':29,
  1895. 'Phoenix':32,
  1896. 'Pititabeille':0,
  1897. 'Plante Carnivore':4,
  1898. 'Pseudo-Dragon':5,
  1899. 'Rat Geant':2,
  1900. 'Rat-Garou':3,
  1901. 'Rocketeux':5,
  1902. 'Sagouin':3,
  1903. 'Scarabee Geant':4,
  1904. 'Scorpion Geant':10,
  1905. 'Shai':28,
  1906. 'Sirene':8,
  1907. 'Slaad':5,
  1908. 'Sorciere':17,
  1909. 'Spectre':14,
  1910. 'Sphinx':30,
  1911. 'Squelette':1,
  1912. 'Strige':2,
  1913. 'Succube':13,
  1914. 'Tertre Errant':20,
  1915. 'Thri-kreen':10,
  1916. 'Tigre-Garou':12,
  1917. 'Titan':26,
  1918. 'Trancheur':35,
  1919. 'Tubercule Tueur':14,
  1920. 'Tutoki':4,
  1921. 'Vampire':29,
  1922. 'Ver Carnivore Geant':12,
  1923. 'Ver Carnivore':11,
  1924. 'Veskan Du Chaos':14,
  1925. 'Vouivre':33,
  1926. 'Worg':5,
  1927. 'Xorn':14,
  1928. 'Yeti':8,
  1929. 'Yuan-ti':15,
  1930. 'Zombie':2
  1931. }
  1932.  
  1933. var tabEM = {
  1934. //Monstre: [Compo exact, Sort, Position, Localisation]
  1935. // AA
  1936. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1937. // AE
  1938. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1939. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1940. // AdA
  1941. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1942. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1943. // AdE
  1944. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1945. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1946. // AdD
  1947. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1948. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1949. // BAM
  1950. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1951. // BuM
  1952. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1953. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1954. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1955. // Explo
  1956. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1957. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1958. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1959. // FP
  1960. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1961. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1962. // FA
  1963. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1964. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1965. // Glue
  1966. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1967. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1968. // GdS
  1969. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1970. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1971. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1972. // Invi
  1973. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1974. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1975. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1976. // Lévitation
  1977. // ???
  1978. // PréM :
  1979. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1980. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1981. // Proj
  1982. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1983. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1984. // PuM :
  1985. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1986. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1987. // Sacro
  1988. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1989. // Télék
  1990. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1991. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1992. // TP
  1993. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1994. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1995. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1996. // VA
  1997. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1998. // VL
  1999. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  2000. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  2001. // VlC
  2002. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  2003. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  2004. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  2005. // VT
  2006. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  2007. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  2008. // Variables
  2009. 'Rat':["d'un"],
  2010. 'Rat Géant':["d'un"],
  2011. 'Dindon':["d'un"],
  2012. 'Goblin':["d'un"],
  2013. 'Limace':["d'une"],
  2014. 'Limace Géante':["d'une"],
  2015. 'Ver':["d'un"],
  2016. 'Ver Carnivore':["d'un"],
  2017. 'Ver Carnivore Géant':["d'un"],
  2018. 'Fungus':["d'un"],
  2019. 'Vouivre':["d'une"],
  2020. 'Gnu':["d'un"],
  2021. 'Scarabée':["d'un"]
  2022. };
  2023.  
  2024. var mundiChampi = {
  2025. 'Préscientus Reguis':'du Phoenix',
  2026. 'Amanite Trolloïde':'de la Mouche',
  2027. 'Girolle Sanglante':'du Dindon',
  2028. 'Horreur Des Prés':'du Gobelin',
  2029. 'Bolet Péteur':'du Démon',
  2030. 'Pied Jaune':'de la Limace',
  2031. 'Agaric Sous-Terrain':'du Rat',
  2032. 'Suinte Cadavre':"de l'Hydre",
  2033. 'Cèpe Lumineux':'du Ver',
  2034. 'Fungus Rampant':'du Fungus',
  2035. 'Nez Noir':'de la Vouivre',
  2036. 'Pleurote Pleureuse':'du Gnu',
  2037. 'Phytomassus Xilénique':'du Scarabée'
  2038. };
  2039.  
  2040. function addInfoMM(node,mob,niv,qualite,effetQ) {
  2041. appendText(node,' ');
  2042. var urlImg = URL_MZimg
  2043. +'Competences/melangeMagique.png';
  2044. var text = ' [-'+(niv+effetQ)+' %]';
  2045. var str = '';
  2046. switch(mob[0]) {
  2047. case 'A':
  2048. case 'E':
  2049. case 'I':
  2050. case 'O':
  2051. case 'U':
  2052. str = "Compo d'";
  2053. break;
  2054. default:
  2055. str = 'Compo de ';
  2056. }
  2057. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  2058. var span = createImageSpan(urlImg,'MM:',title,text);
  2059. node.appendChild(span);
  2060. }
  2061.  
  2062. function addInfoEM(node,mob,compo,qualite,localisation) {
  2063. if(!tabEM[mob]) return;
  2064. var title = 'Composant variable', texte = 'Variable';
  2065. var bold = false;
  2066. if(tabEM[mob].length>1) {
  2067. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  2068. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  2069. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  2070. if(pc<-20) return;
  2071. if(pc>=0) bold = true;
  2072. texte = aff(pc)+'%';
  2073. title = texte+" pour l'écriture de "+tabEM[mob][1];
  2074. }
  2075. var urlImg = URL_MZimg
  2076. +'Competences/ecritureMagique.png';
  2077. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  2078. node.appendChild(span);
  2079. }
  2080.  
  2081. function insererInfosEM(tbody) {
  2082. // lancé par equip, equipgowap
  2083. var trCompos = document.evaluate(
  2084. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  2085. tbody,null,7,null);
  2086. var strCompos = '';
  2087. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  2088. var node = trCompos.snapshotItem(i).childNodes[7];
  2089. var str = node.firstChild.textContent;
  2090. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  2091. var mob = trim(str.slice(str.indexOf("d'un")+5));
  2092. // Si non-EM on stoppe le traitement
  2093. if(!tabEM[mob]) continue;
  2094. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  2095. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  2096. var localisation = trim(str.slice(0,str.indexOf(' |')));
  2097. addInfoEM(node,mob,compo,qualite,localisation);
  2098. }
  2099. }
  2100.  
  2101. function getQualite(qualite) {
  2102. var nb = numQualite[qualite];
  2103. return nb ? nb-1 : -1;
  2104. }
  2105.  
  2106. function getEM(nom) {
  2107. if(nom.indexOf('[')!=-1)
  2108. nom = trim(nom.substring(0,nom.indexOf('[')));
  2109. if(tabEM[nom]) return nom;
  2110. return '';
  2111. }
  2112.  
  2113. // DEBUG ex-fonction composantEM
  2114. function compoMobEM(mob) {
  2115. if(!tabEM[mob]) return '';
  2116. if(tabEM[mob].length==1)
  2117. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  2118. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  2119. +") pour l'écriture de "+tabEM[mob][1];
  2120. }
  2121.  
  2122. // DEBUG ex-fonction compoEM
  2123. function titreCompoEM(mob,compo,localisation,qualite) {
  2124. if(!tabEM[mob]) return '';
  2125. if(tabEM[mob].length==1) return 'Composant variable';
  2126.  
  2127. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  2128. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  2129. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  2130.  
  2131. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  2132. return '';
  2133. }
  2134.  
  2135. // DEBUG - rétrocompatibilité
  2136. function compoEM(mob) {
  2137. // appelé dans libs, vue
  2138. return compoMobEM(mob);
  2139. }
  2140. function composantEM(mob,compo,localisation,qualite) {
  2141. // appelé dans libs, tancompo
  2142. return titreCompoEM(mob,compo,localisation,qualite);
  2143. }
  2144. //
  2145.  
  2146.  
  2147. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  2148.  
  2149. arrayTalents = {
  2150. /* Compétences */
  2151. 'Acceleration du Metabolisme':'AM',
  2152. 'Attaque Precise':'AP',
  2153. 'Balayage':'Balayage',
  2154. //'Balluchonnage':'Ballu',
  2155. 'Baroufle':'Baroufle',
  2156. 'Bidouille':'Bidouille',
  2157. 'Botte Secrete':'BS',
  2158. 'Camouflage':'Camou',
  2159. 'Charger':'Charger',
  2160. 'Connaissance des Monstres':'CdM',
  2161. 'Construire un Piege':'Piege',
  2162. 'Piege a Feu':'PiegeFeu',
  2163. 'Piege a Glue':'PiegeGlue',
  2164. 'Contre-Attaquer':'CA',
  2165. 'Coup de Butoir':'CdB',
  2166. 'Course':'Course',
  2167. 'Deplacement Eclair':'DE',
  2168. 'Dressage':'Dressage',
  2169. 'Ecriture Magique':'EM',
  2170. 'Frenesie':'Frenesie',
  2171. 'Golemologie':'Golemo',
  2172. 'Golem de cuir':'GolemCuir',
  2173. 'Golem de metal':'GolemMetal',
  2174. 'Golem de mithril':'GolemMithril',
  2175. 'Golem de papier':'GolemPapier',
  2176. 'Grattage':'Grattage',
  2177. 'Hurlement Effrayant':'HE',
  2178. 'Identification des Champignons':'IdC',
  2179. 'Insultes':'Insultes',
  2180. 'Lancer de Potions':'LdP',
  2181. 'Marquage':'Marquage',
  2182. 'Melange Magique':'Melange',
  2183. 'Miner':'Miner',
  2184. 'Travail de la Pierre':'Pierre',
  2185. 'Necromancie':'Necro',
  2186. 'Painthure de Guerre':'PG',
  2187. 'Parer':'Parer',
  2188. 'Pistage':'Pistage',
  2189. 'Planter un Champignon':'PuC',
  2190. 'Regeneration Accrue':'RA',
  2191. 'Reparation':'Reparation',
  2192. 'Retraite':'Retraite',
  2193. 'RotoBaffe':'RB',
  2194. 'Shamaner':'Shamaner',
  2195. "S'interposer":'SInterposer',
  2196. 'Tailler':'Tailler',
  2197. //'Vol':'Vol',
  2198. /* Sortilèges */
  2199. 'Analyse Anatomique':'AA',
  2200. 'Armure Etheree':'AE',
  2201. 'Augmentation de l´Attaque':'AdA', // obsolète?
  2202. "Augmentation de l'Attaque":'AdA',
  2203. 'Augmentation de l´Esquive':'AdE',
  2204. 'Augmentation des Degats':'AdD',
  2205. 'Bulle Anti-Magie':'BAM',
  2206. 'Bulle Magique':'BuM',
  2207. 'Explosion':'Explo',
  2208. 'Faiblesse Passagere':'FP',
  2209. 'Flash Aveuglant':'FA',
  2210. 'Glue':'Glue',
  2211. 'Griffe du Sorcier':'GdS',
  2212. 'Hypnotisme':'Hypno',
  2213. 'Identification des Tresors':'IdT',
  2214. 'Invisibilite':'Invi',
  2215. 'Levitation':'Levitation',
  2216. 'Precision Magique':'PreM',
  2217. 'Projectile Magique':'Projo',
  2218. 'Projection':'Proj',
  2219. 'Puissance Magique':'PuM',
  2220. 'Rafale Psychique':'Rafale',
  2221. 'Sacrifice':'Sacro',
  2222. 'Siphon des ames':'Siphon',
  2223. 'Telekinesie':'Telek',
  2224. 'Teleportation':'TP',
  2225. 'Vampirisme':'Vampi',
  2226. 'Vision Accrue':'VA',
  2227. 'Vision lointaine':'VL',
  2228. 'Voir le Cache':'VlC',
  2229. 'Vue Troublee':'VT'
  2230. //'':''
  2231. }
  2232.  
  2233. // DEBUG - Pour rétrocompatibilité
  2234. function getSortComp(nom,niveau) {
  2235. return getTalent(nom,niveau);
  2236. }
  2237. //
  2238.  
  2239. function getTalent(nom,niveau) {
  2240. if(nom===true) return true;
  2241. var nomEnBase = arrayTalents[epure(nom)];
  2242. if(!nomEnBase) nomEnBase=nom;
  2243. if(!niveau) var niveau = '';
  2244. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2245. return Number(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau));
  2246. return 0;
  2247. }
  2248.  
  2249. function removeAllTalents() {
  2250. for(var talent in arrayTalents) {
  2251. var nomEnBase = arrayTalents[talent];
  2252. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2253. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2254. continue;
  2255. }
  2256. var niveau = 1;
  2257. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2258. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2259. niveau++;
  2260. }
  2261. }
  2262. }
  2263.  
  2264. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2265. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2266. var att = MY_getValue(numTroll+'.caracs.attaque');
  2267. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2268. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2269. var mm = MY_getValue(numTroll+'.caracs.mm');
  2270. var deg = MY_getValue(numTroll+'.caracs.degats');
  2271. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2272. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2273. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2274. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2275. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2276. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2277. return false;
  2278. return true;
  2279. } catch(e) {
  2280. return false;
  2281. }
  2282. }
  2283.  
  2284.  
  2285. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2286.  
  2287. function getPVsRestants(pv,bless,vue) {
  2288. bless = Number(bless.match(/\d+/)[0]);
  2289. if(bless==0) return null;
  2290. var pvminmax = pv.match(/\d+/g);
  2291. var oMinMaxPV = {min: pvminmax[0], max: pvminmax[1]};
  2292. var oMinMaxPVRestant = MZ_getPVsRestants(oMinMaxPV, bless);
  2293. if (vue) {
  2294. if (oMinMaxPVRestant.min) {
  2295. if (oMinMaxPVRestant.max) {
  2296. return ' (' + oMinMaxPVRestant.min + '-' + oMinMaxPVRestant.max + ')';
  2297. } else {
  2298. return " (\u2A7E" + oMinMaxPVRestant.min + ')'; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  2299. }
  2300. } else {
  2301. if (oMinMaxPVRestant.max) {
  2302. return " (\u2A7D" + oMinMaxPVRestant.max + ')'; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  2303. } else {
  2304. return '';
  2305. }
  2306. }
  2307. }
  2308. var oRet = ['Points de Vie restants : '];
  2309. if (oMinMaxPVRestant.min) {
  2310. if (oMinMaxPVRestant.max) {
  2311. oRet[1] = 'Entre '+oMinMaxPVRestant.min+' et '+oMinMaxPVRestant.max;
  2312. } else {
  2313. oRet[1] = "\u2A7E" + oMinMaxPVRestant.min; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  2314. }
  2315. } else {
  2316. if (oMinMaxPVRestant.max) {
  2317. oRet[1] = "\u2A7D" + oMinMaxPVRestant.max; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  2318. } else {
  2319. oRet[1] = 'inconnu';
  2320. }
  2321. }
  2322. return oRet;
  2323. /* à supprimer
  2324. if(bless==95) {
  2325. var pvb = 1;
  2326. var pvh = Math.floor( pvminmax[1]/20 );
  2327. }
  2328. else if(bless==5) {
  2329. var pvb = Math.floor( pvminmax[0]*19/20 );
  2330. var pvh = pvminmax[1];
  2331. }
  2332. else {
  2333. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2334. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2335. }
  2336. return vue ? ' ('+pvb+'-'+pvh+')' :
  2337. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2338. }
  2339. */
  2340. }
  2341.  
  2342. function MZ_getPVsRestants(oMinMaxPV, bless) { // rend un objet minmax
  2343. var oRet = {};
  2344. if(bless==95) {
  2345. oRet.min = 1;
  2346. if (oMinMaxPV.max) oRet.max = Math.floor( oMinMaxPV.max/20);
  2347. } else if(bless==5) {
  2348. if (oMinMaxPV.min) oRet.min = Math.floor( oMinMaxPV.min*19/20);
  2349. if (oMinMaxPV.max) oRet.max = oMinMaxPV.max;
  2350. } else {
  2351. if (oMinMaxPV.min) oRet.min = Math.ceil( oMinMaxPV.min*(95-bless) / 100);
  2352. if (oMinMaxPV.max) oRet.max = Math.floor( oMinMaxPV.max*(105-bless) / 100);
  2353. }
  2354. return oRet;
  2355. }
  2356.  
  2357. /* tentative via jQuery abandonnée
  2358. function insertButtonCdmSmartphone_to_delete(nextName,onClick,texte) {
  2359. if (window.jQuery == undefined) return;
  2360. //window.console.log('jQuery OK');
  2361. var eInput = $('[name="' + nextName + '"]');
  2362. if (!eInput) return;
  2363. //window.console.log('eInput OK');
  2364. var eDiv = eInput.closest("div");
  2365. if (!eDiv) return;
  2366. //window.console.log('eDiv OK');
  2367. var newDiv = eDiv.clone();
  2368. var newSpan = newDiv.children('span');
  2369. newSpan.children(':first-child').text(texte);
  2370. var newInput = newDiv.children('input');
  2371. newInput.removeAttr('onclick');
  2372. newInput.click(onClick);
  2373. newInput.val(texte);
  2374. newInput.removeAttr("type").attr("type", "button");
  2375. var eForm = eDiv.parent();
  2376. window.console.log("insertButtonCdmSmartphone tag newdiv=" + newDiv.prop('tagName') + ', parent tag=' + eForm.prop('tagName'));
  2377. eForm.prepend(newDiv);
  2378. return true;
  2379. }
  2380.  
  2381. function insertButtonCdmSmartphone(nextName,onClick,texte) {
  2382. var tabInput = document.getElementsByName(nextName);
  2383. if (!tabInput) return;
  2384. var eInput = tabInput[0];
  2385. if (!eInput) return;
  2386. //window.console.log('eInput OK');
  2387. var eDiv = eInput.parentNode;
  2388. if (!eDiv) return;
  2389. window.console.log('eDiv.outerHTML=' + eDiv.outerHTML);
  2390. var eNewDiv = eDiv.cloneNode(true);
  2391. window.console.log('eNewDiv.outerHTML=' + eNewDiv.outerHTML);
  2392. var tabNewSpan = eNewDiv.getElementsByTagName('span');
  2393. if (!tabNewSpan) return;
  2394. window.console.log('tabNewSpan lg=' + tabNewSpan.length);
  2395. if (tabNewSpan.length == 0) return;
  2396. tabNewSpan.forEach(function(pSpan) {
  2397. if (pSpan.getElementsByTagName('span').length > 0) return;
  2398. window.console.log('newSpan old text=' + pSpan.innerText);
  2399. while (pSpan.firstChild) pSpan.removeChild(pSpan.firstChild); // vider
  2400. pSpan.appendChild(document.createTextNode(texte));
  2401. });
  2402. var tabNewInput = eNewDiv.getElementsByTagName('input');
  2403. if (!tabNewInput) return;
  2404. var eNewInput = tabNewInput[0];
  2405. if (!eNewInput) return;
  2406. eNewInput.removeAttr('onclick');
  2407. eNewInput.onClick = onClick;
  2408. eNewInput.value = texte;
  2409. eNewInput.type = "button";
  2410. var eForm = eDiv.parentNode;
  2411. window.console.log("insertButtonCdmSmartphone tag eNewDiv=" + eNewDiv.nodeName + ', parent tag=' + eForm.nodeName);
  2412. eForm.insertBefore(eNewDiv, eForm.firstChild);
  2413. return true;
  2414. }
  2415. */
  2416.  
  2417. function insertButtonCdm(nextName,onClick,texte) {
  2418. if (texte==null) texte = 'Participer au bestiaire';
  2419. //if (insertButtonCdmSmartphone(nextName,onClick,texte)) return;
  2420.  
  2421. var nextNode = document.getElementsByName(nextName)[0];
  2422. var espace = document.createTextNode('\t');
  2423. insertBefore(nextNode,espace);
  2424.  
  2425. var button = document.createElement('input');
  2426. button.type = 'button';
  2427. button.className = 'mh_form_submit';
  2428. button.value = texte;
  2429. button.onmouseover = function(){this.style.cursor='pointer';};
  2430. if (onClick) button.onclick = onClick;
  2431. insertBefore(espace,button);
  2432. return button;
  2433. }
  2434.  
  2435. function createCDMTable(id,nom,donneesMonstre, closeFunct) { // rend un Élément Table
  2436. try {
  2437. var table = document.createElement('table');
  2438. var profilActif = isProfilActif();
  2439. table.className = 'mh_tdborder';
  2440. table.border = 0;
  2441. table.cellSpacing = 1;
  2442. table.cellPadding = 4;
  2443.  
  2444. var thead = document.createElement('thead');
  2445. var tr = appendTr(thead,'mh_tdtitre');
  2446. var td = appendTdText(tr, 'CDM de ' + nom + ' (N° '+ id + ')', false);
  2447. td.style.fontWeight = 'bold';
  2448. if (closeFunct) {
  2449. td.colSpan = 2;
  2450. td.style.borderRight = 'none';
  2451. td = appendTdText(tr, 'X', false);
  2452. td.style.cursor = 'pointer';
  2453. td.style.textAlign = 'right';
  2454. td.style.fontWeight = 'bold';
  2455. td.style.width = '1%';
  2456. td.style.borderLeft = 'none';
  2457. td.onclick = closeFunct;
  2458. } else {
  2459. td.colSpan = 3;
  2460. }
  2461. table.appendChild(thead);
  2462. var tbody = document.createElement('tbody');
  2463. table.appendChild(tbody);
  2464.  
  2465. // calcul des PX gagnés
  2466. var ominmaxPX = {};
  2467. if (donneesMonstre.niv) {
  2468. if (donneesMonstre.niv.min) ominmaxPX.min = getPXKill(donneesMonstre.niv.min);
  2469. if (donneesMonstre.niv.max) ominmaxPX.max = getPXKill(donneesMonstre.niv.max);
  2470. }
  2471.  
  2472. MZ_tab_carac_add_tr_minmax2(tbody, 'Niveau', donneesMonstre.niv, 'PX', ominmaxPX);
  2473. MZ_tab_carac_add_tr_texte(tbody, 'Famille', donneesMonstre.fam, '');
  2474. //MZ_tab_carac_add_tr_texte(tbody, 'Génération', donneesMonstre.gen == 23 ? '2 ou 3' : donneesMonstre.gen, ''); // remplacé par une icône
  2475. MZ_tab_carac_add_tr_texte(tbody, 'Blessure', MZ_tab_carac_mkBlessureTexte(donneesMonstre), '');
  2476. MZ_tab_carac_add_tr_minmax(tbody, 'Points de Vie', donneesMonstre.pv, 'PV');
  2477. MZ_tab_carac_add_tr_minmax(tbody, 'Attaque', donneesMonstre.att, 'D6');
  2478. MZ_tab_carac_add_tr_minmax(tbody, 'Esquive', donneesMonstre.esq, 'D6');
  2479. MZ_tab_carac_add_tr_minmax(tbody, 'Dégâts', donneesMonstre.deg, 'D3');
  2480. MZ_tab_carac_add_tr_minmax(tbody, 'Régénération', donneesMonstre.reg, 'D3');
  2481. MZ_tab_carac_add_tr_minmax(tbody, 'Armure physique', donneesMonstre.armP, '');
  2482. MZ_tab_carac_add_tr_minmax(tbody, 'Armure magique', donneesMonstre.armM, '');
  2483. MZ_tab_carac_add_tr_minmax(tbody, 'Armure totale', donneesMonstre.arm, '');
  2484. MZ_tab_carac_add_tr_minmax(tbody, 'Vue', donneesMonstre.vue, 'Case(s)');
  2485. MZ_tab_carac_add_tr_minmax(tbody, 'MM', donneesMonstre.MM, '');
  2486. MZ_tab_carac_add_tr_minmax(tbody, 'RM', donneesMonstre.RM, '');
  2487. MZ_tab_carac_add_tr_minmax(tbody, 'Durée du tour', donneesMonstre.duree, ' heures');
  2488. MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre);
  2489. MZ_tab_carac_add_tr_autres(tbody, donneesMonstre, id, nom);
  2490. /* à supprimer, remplacé par un "title" sur le 3e td de "autres"
  2491. var msgInfo = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2492. if (msgInfo) MZ_tab_carac_add_tr_sansTitre(tbody, msgInfo, 0, true);
  2493. */
  2494. return table;
  2495. }
  2496. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2497. }
  2498.  
  2499. function MZ_tab_carac_mkBlessureTexte(donneesMonstre) {
  2500. if (donneesMonstre.bless === undefined) return;
  2501. var texte = donneesMonstre.bless + '%';
  2502. if (donneesMonstre.bless > 0 && donneesMonstre.pv && donneesMonstre.pv.min && donneesMonstre.pv.max) {
  2503. ominmax = MZ_getPVsRestants(donneesMonstre.pv, donneesMonstre.bless);
  2504. texte += ' (' + ominmax.min + '-' + ominmax.max + ')';
  2505. }
  2506. if (donneesMonstre.timegmt) {
  2507. texte += ' le ' + MZ_formatDateMS(new Date(donneesMonstre.timegmt * 1000), true);
  2508. }
  2509. return texte;
  2510. }
  2511.  
  2512. function MZ_tab_carac_add_tr_sansTitre(table, msg, bItalic) {
  2513. if (!msg) return;
  2514. var tr = appendTr(table,'mh_tdpage');
  2515. td = appendTdText(tr,msg);
  2516. td.colSpan = 3;
  2517. if (bItalic) td.style.fontStyle = 'italic';
  2518. td.className = 'mh_tdpage';
  2519. return td;
  2520. }
  2521.  
  2522. function MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre) {
  2523. if (!donneesMonstre.pouv) return;
  2524. var td = MZ_tab_carac_add_tr_texte(tbody, 'Pouvoir', donneesMonstre.pouv + ' ', '', 0);
  2525. var tabImg = [];
  2526. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.portpouv, {
  2527. 'de zone': ["zone.gif","Pouvoir de zone"],
  2528. 'automatique': ["automatique.gif","Pouvoir automatique"],
  2529. 'au toucher': ["toucher.gif","Pouvoir au toucher"]});
  2530. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2531. var thisImg = tabImg[iImg];
  2532. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2533. }
  2534. }
  2535.  
  2536. function MZ_tab_carac_add_tr_autres(table, donneesMonstre, id, nom) {
  2537. var tabImg = [];
  2538. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attd, {
  2539. '1': ["distance.gif","Attaque à distance"],
  2540. '~': ["cac.gif","Corps à corps"]}); // si absent
  2541. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.nb_att, {
  2542. '1': ["1.gif","1 attaque par tour"],
  2543. '2': ["2.gif","2 attaques par tour"],
  2544. '3': ["3.gif","3 attaques par tour"],
  2545. '4': ["4.gif","4 attaques par tour"],
  2546. '5': ["5.gif","5 attaques par tour"],
  2547. '6': ["6.gif","6 attaques par tour"],
  2548. '999': ["plus.gif","Beaucoup d'attaques par tour"]});
  2549. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attm, {
  2550. '1': ["magic-wand.png","Attaque magique"]});
  2551. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vit, {
  2552. 'lente': ["lent.gif","Lent à se déplacer"],
  2553. 'normale': ["normal.gif","Vitesse normale de déplacement"],
  2554. 'rapide': ["rapide.gif","Déplacement rapide"]});
  2555. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.charg, {
  2556. 'vide': [null,null],
  2557. '~': ["charge2.gif", "Possède de l'équipement (" + donneesMonstre.charg + ")"]});
  2558. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vlc, {
  2559. '1': ["oeil.gif","Voit le caché"]});
  2560. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.gen, {
  2561. '1': ["Phoenix1.png","Phœnix de première génération"],
  2562. '2': ["Phoenix2.png","Phœnix de deuxième génération"],
  2563. '3': ["Phoenix3.png","Phœnix de troisième génération"],
  2564. '23': ["Phoenix23.png","Phœnix de deuxième ou troisième génération"],
  2565. });
  2566.  
  2567. var tr = appendTr(table,'mh_tdpage');
  2568. var td = appendTdText(tr,'Autres',true);
  2569. td.className = 'mh_tdtitre';
  2570. td.width = MZ_EtatCdMs.tdWitdh;
  2571.  
  2572. td = appendTd(tr);
  2573. td.className = 'mh_tdpage';
  2574. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2575. var thisImg = tabImg[iImg];
  2576. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2577. }
  2578. if (donneesMonstre.esq != undefined) {
  2579. td.appendChild(MZ_Tactique.createImage(id, nom));
  2580. }
  2581.  
  2582. var txt = String.fromCharCode(160); // blanc insécable
  2583. if (donneesMonstre.nCdM) txt = donneesMonstre.nCdM;
  2584. var td2 = appendTdText(tr, txt);
  2585. td2.title = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2586. td2.style.width = '1%';
  2587. var myColor = MZ_CdMColorFromMode(donneesMonstre);
  2588. if (myColor) {
  2589. td2.style.backgroundColor = myColor;
  2590. td2.style.color = 'white';
  2591. }
  2592.  
  2593. return td;
  2594. }
  2595.  
  2596. function MZ_tab_carac_add_tr_one_img(tabImg, val, listCas) {
  2597. if (val == undefined) return;
  2598. //console.log('MZ_tab_carac_add_tr_one_img: val=' + val);
  2599. var lVal = (val + '').toLowerCase(); // astuce : transformer le nombre en string (beurk !)
  2600. if (listCas[lVal]) {
  2601. var t = listCas[lVal];
  2602. if (t[0] == null) return;
  2603. tabImg.push(t);
  2604. } else if (listCas['~']) {
  2605. tabImg.push(listCas['~']);
  2606. }
  2607. }
  2608.  
  2609. function MZ_tab_carac_add_tr_texte(table, titre, msg, unit) {
  2610. if (!msg) return;
  2611. var tr = appendTr(table,'mh_tdpage');
  2612.  
  2613. var td = appendTdText(tr,titre,true);
  2614. td.className = 'mh_tdtitre';
  2615. td.width = MZ_EtatCdMs.tdWitdh;
  2616.  
  2617. var texte = msg;
  2618. if (unit) texte += ' ' + unit;
  2619. td = appendTdText(tr,texte);
  2620. td.colSpan = 2;
  2621. td.className = 'mh_tdpage';
  2622. return td;
  2623. }
  2624.  
  2625. function MZ_tab_carac_add_tr_minmax(table, titre, ominmax, unit) {
  2626. if (!ominmax) return;
  2627. if (!(ominmax.min || ominmax.max)) return;
  2628.  
  2629. var tr = appendTr(table,'mh_tdpage');
  2630.  
  2631. var td = appendTdText(tr,titre,true);
  2632. td.className = 'mh_tdtitre';
  2633. td.width = MZ_EtatCdMs.tdWitdh;
  2634.  
  2635. if ((!ominmax.min) || ominmax.min == 0) {
  2636. var texte = '\u2A7D' + ominmax.max + '\u00A0' + unit; // <= (mais plus beau)
  2637. } else if (!ominmax.max) {
  2638. var texte = '\u2A7E' + ominmax.min + '\u00A0' + unit; // >=
  2639. } else {
  2640. var texte = '';
  2641. if (ominmax.min != ominmax.max) {
  2642. var texte = ominmax.min + '-' + ominmax.max + '\u00A0-->\u00A0';
  2643. if (ominmax.min > ominmax.max) {
  2644. td.style.color = 'red';
  2645. unit += ' *** erreur ***';
  2646. }
  2647. }
  2648. texte += ((ominmax.min + ominmax.max)/2) + '\u00A0' + unit;
  2649. }
  2650. td = appendTdText(tr,texte);
  2651. if (ominmax.min2 || ominmax.max2) { // affichage de l'intervalle de confiance à 80%
  2652. if (!ominmax.min2) {
  2653. var txt2 = '\u2A7D' + ominmax.max2; // <= (mais plus beau)
  2654. } else if (!ominmax.max2) {
  2655. var txt2 = '\u2A7E' + ominmax.min2; // >=
  2656. } else {
  2657. var txt2 = ominmax.min2 + '-' + ominmax.max2;
  2658. }
  2659. var span = document.createElement('span');
  2660. span.appendChild(document.createTextNode(txt2));
  2661. span.style.float = 'right';
  2662. span.style.textAlign = 'right';
  2663. span.style.background = 'yellow';
  2664. td.insertBefore(span, td.firstChild);
  2665. table.title = 'En jaune : intervalle de confiance à 80%';
  2666. }
  2667. td.colSpan = 2;
  2668. td.className = 'mh_tdpage';
  2669. return td;
  2670. }
  2671.  
  2672. function MZ_tab_carac_add_tr_minmax2(table, titre, ominmax, unit, ominmaxUnit) {
  2673. if (!ominmax) return;
  2674. if (!(ominmax.min || ominmax.max)) return;
  2675.  
  2676. var tr = appendTr(table,'mh_tdpage');
  2677.  
  2678. var td = appendTdText(tr,titre,true);
  2679. td.className = 'mh_tdtitre';
  2680. td.width = MZ_EtatCdMs.tdWitdh;
  2681.  
  2682. if ((!ominmax.min) || ominmax.min == 0) {
  2683. var texte = '\u2A7D' + ominmax.max;
  2684. } else if (!ominmax.max) {
  2685. var texte = '\u2A7E' + ominmax.min;
  2686. } else {
  2687. var texte = '';
  2688. if (ominmax.min != ominmax.max) {
  2689. var texte = ominmax.min + '-' + ominmax.max;
  2690. if (ominmax.min > ominmax.max) {
  2691. td.style.color = 'red';
  2692. texte += ' *** erreur ***';
  2693. }
  2694. } else {
  2695. var texte = ominmax.min;
  2696. }
  2697. }
  2698.  
  2699. if (ominmaxUnit.min === undefined) {
  2700. if (ominmaxUnit.max === undefined) {
  2701. // ignore (ne devrait pas arriver)
  2702. } else {
  2703. texte += ' --> ' + unit + '\u2A7D' + ominmaxUnit.max;
  2704. }
  2705. } else {
  2706. if (ominmaxUnit.max === undefined) {
  2707. texte += ' --> ' + unit + '\u2A7E' + ominmaxUnit.min;
  2708. } else if (ominmaxUnit.min != ominmaxUnit.max) {
  2709. texte += ' --> ' + ominmaxUnit.min + '\u2A7D' + unit + '\u2A7D' + ominmaxUnit.max;
  2710. if (ominmaxUnit.min > ominmaxUnit.max) {
  2711. td.style.color = 'red';
  2712. texte += ' *** erreur ***';
  2713. }
  2714. } else if (isNaN(ominmaxUnit.min)) {
  2715. texte += ' --> ' + ominmaxUnit.min;
  2716. } else {
  2717. texte += ' --> ' + ominmaxUnit.max + '\u00A0' + unit;
  2718. }
  2719. }
  2720.  
  2721. td = appendTdText(tr,texte);
  2722. td.colSpan = 2;
  2723. td.className = 'mh_tdpage';
  2724. return td;
  2725. }
  2726.  
  2727.  
  2728. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2729.  
  2730. var listeMonstreEnchantement = null,
  2731. listeEquipementEnchantement = null,
  2732. listeInfoEnchantement = null;
  2733.  
  2734. function computeCompoEnchantement()
  2735. {
  2736. listeMonstreEnchantement = new Array();
  2737. listeInfoEnchantement = new Array();
  2738. listeEquipementEnchantement = new Array();
  2739. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2740. for(var i=0;i<liste.length;i++)
  2741. {
  2742. var idEquipement = liste[i]*1;
  2743. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2744. continue;
  2745. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2746. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2747. var texteGlobal='';
  2748. for(var j=0;j<3;j++)
  2749. {
  2750. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2751. var v = MY_getValue(k);
  2752. var infoComposant = MY_getValue().split(';');
  2753. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2754. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2755. continue;
  2756. }
  2757. listeMonstreEnchantement[infoComposant[2]] = 1;
  2758. var array = new Array();
  2759. array[0]=infoComposant[0].replace("Ril","Œil");
  2760. array[1]=infoComposant[1];
  2761. array[2]=infoComposant[2];
  2762. array[3]=getQualite(infoComposant[3]);
  2763. var texte = infoComposant[4].replace("Ril","Œil");
  2764. for(var k=5;k<infoComposant.length;k++)
  2765. {
  2766. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2767. }
  2768. texteGlobal+=texte+'\n';
  2769. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2770. array[4]=texte;
  2771. listeInfoEnchantement.push(array);
  2772. }
  2773. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2774. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2775. }
  2776.  
  2777. }
  2778.  
  2779. function isEnchant(nom) {
  2780. var monstreEnchant = '';
  2781. for(j in listeInfoEnchantement) {
  2782. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2783. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2784. monstreEnchant=monstre;
  2785. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2786. }
  2787. }
  2788. return trim(monstreEnchant);
  2789. }
  2790.  
  2791. function getInfoEnchantementFromMonstre(nom)
  2792. {
  2793. try
  2794. {
  2795. if(!listeMonstreEnchantement)
  2796. {
  2797. computeCompoEnchantement();
  2798. }
  2799. var infosEnchant = '';
  2800. for(j in listeInfoEnchantement) {
  2801. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2802. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2803. if(infosEnchant=='')
  2804. infosEnchant=listeInfoEnchantement[j][4];
  2805. else
  2806. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2807. }
  2808. }
  2809. return trim(infosEnchant);
  2810. }
  2811. catch(e)
  2812. {
  2813. window.alert(e);
  2814. }
  2815. }
  2816.  
  2817. function composantEnchant(Monstre,composant,localisation,qualite) {
  2818. var compo='';
  2819. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2820. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2821. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2822. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2823. listeInfoEnchantement[i][3]<=qualite
  2824. ) {
  2825. return listeInfoEnchantement[i][4];
  2826. }
  2827. }
  2828. return compo;
  2829. }
  2830.  
  2831. function insertEnchantInfos(tbody) {
  2832. try
  2833. {
  2834. if(!listeMonstreEnchantement)
  2835. computeCompoEnchantement();
  2836. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2837. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2838. if(nodes.snapshotLength == 0)
  2839. return false;
  2840. var urlImg = URL_MZimg + 'enchant.png';
  2841. for(var i = 0; i < nodes.snapshotLength; i++) {
  2842. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2843. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2844. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2845. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2846. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2847. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2848. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2849. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2850. if(isEnchant(nomMonstre).length>0)
  2851. {
  2852. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2853. if(infos.length>0)
  2854. {
  2855. if(link.parentNode == link.nextSibling.parentNode)
  2856. {
  2857. var tmp = link.nextSibling;
  2858. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2859. }
  2860. else
  2861. {
  2862. link.parentNode.appendChild(createImage(urlImg,infos));
  2863. }
  2864. }
  2865. }
  2866. }
  2867. }
  2868. catch(e)
  2869. {
  2870. window.alert(e);
  2871. }
  2872. }
  2873.  
  2874. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2875. {
  2876. try
  2877. {
  2878. if(!listeMonstreEnchantement)
  2879. computeCompoEnchantement();
  2880. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2881. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2882. if(nodes.snapshotLength == 0)
  2883. return false;
  2884. var urlImg = URL_MZimg + 'enchant.png';
  2885. for(var i = 0; i < nodes.snapshotLength; i++)
  2886. {
  2887. var link = nodes.snapshotItem(i);
  2888. var idEquipement = link.getAttribute('href');
  2889. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2890. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2891. var nomEquipement = trim(link.firstChild.nodeValue);
  2892. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2893. if(!enchanteur || enchanteur == '')
  2894. continue;
  2895. var infos = listeEquipementEnchantement[idEquipement];
  2896. infos=formateTexte(infos);
  2897. if(infos.length>0)
  2898. {
  2899. if(link.parentNode == link.nextSibling.parentNode)
  2900. {
  2901. var tmp = link.nextSibling;
  2902. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2903. }
  2904. else
  2905. {
  2906. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2907. }
  2908. }
  2909. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2910. }
  2911. }
  2912. catch(e)
  2913. {
  2914. window.alert(e);
  2915. }
  2916. }
  2917.  
  2918. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2919. // Cette section est commune à InfoMonstre et Vue
  2920.  
  2921. var MZ_Tactique = {
  2922. // Variables
  2923. popup: null,
  2924.  
  2925. // Méthodes
  2926. createImage: function(id, nom) {
  2927. // Création de l'image portant le popup tactique
  2928. var img = document.createElement('img');
  2929. img.src = URL_MZimg +
  2930. (isPage('View/MonsterView') ? 'calc.png' : 'calc2.png');
  2931. img.id = id;
  2932. img.nom = nom;
  2933. img.style.verticalAlign = 'middle';
  2934. img.onmouseover = MZ_Tactique.showPopup;
  2935. img.onmouseout = MZ_Tactique.hidePopup;
  2936. return img;
  2937. },
  2938.  
  2939. hidePopup: function() {
  2940. // Masquage du popup tactique
  2941. MZ_Tactique.popup.style.display = 'none';
  2942. },
  2943.  
  2944. initPopup: function() {
  2945. /** @mandatory Initialisation du popup tactique */
  2946. MZ_Tactique.popup = document.createElement('div');
  2947. MZ_Tactique.popup.id = 'MZ_Tactique.popup';
  2948. MZ_Tactique.popup.className = 'mh_textbox';
  2949. MZ_Tactique.popup.style =
  2950. 'position: absolute;' +
  2951. 'border: 1px solid #000000;' +
  2952. 'display: none;' +
  2953. 'z-index: 3;' +
  2954. 'max-width: 400px;';
  2955. document.body.appendChild(MZ_Tactique.popup);
  2956. },
  2957.  
  2958. showPopup: function(evt) {
  2959. // Affichage du popup tactique
  2960. try {
  2961. var id = this.id;
  2962. var nom = this.nom;
  2963. var texte = getAnalyseTactique(id, nom);
  2964. if (texte == undefined || texte == '') return;
  2965. MZ_Tactique.popup.innerHTML = texte;
  2966. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  2967. if (isPage('View/MonsterView')) {
  2968. MZ_Tactique.popup.style.left = Math.min(evt.pageX - 120, window.innerWidth - 300) + 'px';
  2969. } else {
  2970. MZ_Tactique.popup.style.left = Math.min(evt.pageX + 15, window.innerWidth - 400) + 'px';
  2971. }
  2972. MZ_Tactique.popup.style.top = evt.pageY + 15 + 'px';
  2973. MZ_Tactique.popup.style.display = 'block';
  2974. } catch (e) {
  2975. // window.alert(e);
  2976. window.console.error(e);
  2977. }
  2978. }
  2979. };
  2980.  
  2981. // Les % de toucher
  2982. var c = new Array();
  2983.  
  2984. // coefficients binomiaux
  2985. function cnp(n,k)
  2986. {
  2987. if(c[n] != null && c[n][k] != null)
  2988. return c[n][k];
  2989. if(c[n] == null)
  2990. c[n] = new Array();
  2991. if(k==0)
  2992. {
  2993. c[n][k] = 1;
  2994. return 1;
  2995. }
  2996. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2997. c[n][k] = result;
  2998. // Roule debug
  2999. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  3000. return result;
  3001. }
  3002.  
  3003. // by Dab, à comparer
  3004. function binom(n,p) {
  3005. if(p<0 || p>n) return 0;
  3006.  
  3007. if(c[n])
  3008. if(c[n][p]) return c[n][p];
  3009. else {
  3010. c[n]=[1];
  3011. c[n][n]=1;
  3012. if(p==0 || p==n) return 1;
  3013. }
  3014.  
  3015. if(2*p>n)
  3016. c[n][p]=binom(n,n-p);
  3017. else
  3018. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  3019.  
  3020. return c[n][p];
  3021. }
  3022.  
  3023. var coeff = new Array();
  3024.  
  3025. function coef(n,p)
  3026. {
  3027. if(n==0 && p==0)
  3028. return 1;
  3029. if(p>n*3.5)
  3030. p = 7*n-p
  3031. // roule désactive cache
  3032. if(coeff[n] != null && coeff[n][p] !=null)
  3033. return coeff[n][p];
  3034. if(coeff[n] == null)
  3035. coeff[n] = new Array();
  3036. var kmax = Math.floor((p-n)/6);
  3037. var x=0;
  3038. for(var k=0;k<=kmax;k++)
  3039. {
  3040. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  3041. }
  3042. coeff[n][p] = x;
  3043. // Roule debug
  3044. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  3045. return x;
  3046. }
  3047.  
  3048. function chanceEsquiveParfaite(a,d,ba,bd)
  3049. {
  3050. var win = 0;
  3051. var los = 0;
  3052. if(ba==null)
  3053. ba=0;
  3054. if(bd==null)
  3055. bd=0;
  3056. /* if(6*a+ba<2*(d+bd))
  3057. return 100;
  3058. if(a+ba>2*(6*d+bd))
  3059. return 0;*/
  3060. for(var ds=d;ds<=6*d;ds++)
  3061. {
  3062. var cd = coef(d,ds);
  3063. for(var as=a;as<=6*a;as++)
  3064. {
  3065. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  3066. win += cd * coef(a,as);
  3067. else
  3068. los += cd * coef(a,as);
  3069. }
  3070. }
  3071. // roule debug
  3072. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  3073. return Math.round(100*win/(win+los));
  3074. }
  3075.  
  3076. function chanceTouche(a,d,ba,bd)
  3077. {
  3078. var win = 0;
  3079. var los = 0;
  3080. if(ba==null)
  3081. ba=0;
  3082. if(bd==null)
  3083. bd=0;
  3084. if(a+ba>6*d+bd)
  3085. return 100;
  3086. if(6*a+ba<d+bd)
  3087. return 0;
  3088. for(var ds=d;ds<=6*d;ds++)
  3089. {
  3090. var cd = coef(d,ds);
  3091. for(var as=a;as<=6*a;as++)
  3092. {
  3093. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  3094. win += cd * coef(a,as);
  3095. else
  3096. los += cd * coef(a,as);
  3097. }
  3098. }
  3099. return Math.round(100*win/(win+los));
  3100. }
  3101.  
  3102. function chanceCritique(a,d,ba,bd)
  3103. {
  3104. var win = 0;
  3105. var los = 0;
  3106. if(ba==null)
  3107. ba=0;
  3108. if(bd==null)
  3109. bd=0;
  3110. if(a+ba>2*(6*d+bd))
  3111. return 100;
  3112. if(6*a+ba<2*(d+bd))
  3113. return 0;
  3114. for(var ds=d;ds<=6*d;ds++)
  3115. {
  3116. var cd = coef(d,ds);
  3117. for(var as=a;as<=6*a;as++)
  3118. {
  3119. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  3120. win += cd * coef(a,as);
  3121. else
  3122. los += cd * coef(a,as);
  3123. }
  3124. }
  3125. return Math.round(100*win/(win+los));
  3126. }
  3127.  
  3128. /***********************************************
  3129. Analyse tactique
  3130. ***********************************************/
  3131.  
  3132. function getTexteAnalyse(modificateur,chiffre)
  3133. {
  3134. if(chiffre==0)
  3135. return chiffre;
  3136. return modificateur+ chiffre;
  3137. }
  3138.  
  3139. // rend le HTML pour le tableau de la "calculette"
  3140. function getAnalyseTactique(id,nom) {
  3141. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  3142. var needAutres=false;
  3143. var i;
  3144. if(donneesMonstre == null)
  3145. return;
  3146. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  3147. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  3148. if(array==null)
  3149. return "";
  3150. var str = "<table class='mh_tdborder' border='0' cellspacing='1' cellpadding='4' style='background-color:rgb(229, 222, 203)'><tr class='mh_tdtitre'><td>Attaque</td><td>Esq. Parfaite</td><td>Touché</td><td>Critique</td><td>Dégâts</td></tr>";
  3151. for(i=0;i<array.length;i++)
  3152. {
  3153. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  3154. {
  3155. needAutres=true;
  3156. break;
  3157. }
  3158. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  3159. 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>";
  3160. else if(i==0) // attaque du monstre sur le Trõll => italique
  3161. 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>";
  3162. else // autre, pas de décoration
  3163. 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>";
  3164. }
  3165. if(needAutres)
  3166. {
  3167. if(i==array.length-1)
  3168. 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>";
  3169. else if(i==1)
  3170. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  3171. else
  3172. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  3173. }
  3174. var txtCdM = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  3175. if (txtCdM) str += '<tr class="mh_tdpage"><td colspan="5" style="font-style: italic;">' + txtCdM + '</td></tr>';
  3176. return str+"</table>";
  3177. }
  3178.  
  3179. function MZ_carac_build_nb_cmd_msg(donneesMonstre) {
  3180. if (!donneesMonstre) return;
  3181. if (!donneesMonstre.Mode) return;
  3182. switch (donneesMonstre.Mode) {
  3183. case 'cdm':
  3184. return 'fondé sur ' + (+donneesMonstre.nCdM) + ' CdM' + (donneesMonstre.nCdM > 1 ? 's' : '') + ' de ce monstre à cet âge';
  3185. case 'stat':
  3186. 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)';
  3187. case 'statV1':
  3188. return 'fondé sur les statistiques anciennes (MZ V1)';
  3189. case 'nom':
  3190. return 'fondé sur le nom du monstre, pas de CdM';
  3191. }
  3192. return 'Mode ' + donneesMonstre.Mode;
  3193. }
  3194.  
  3195. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  3196. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  3197. function analyseTactique(donneesMonstre,nom) {
  3198. try
  3199. {
  3200. var listeAttaques = [];
  3201. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  3202. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  3203. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  3204. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  3205. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  3206. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  3207. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  3208. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  3209. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  3210. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  3211. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  3212. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  3213. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  3214. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  3215. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  3216. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  3217. var modificateurEsquive = '';
  3218. var modificateurArmure = '';
  3219. var modificateurMagie = '';
  3220. var modificateurEsquiveM = '';
  3221. var modificateurArmureM = '';
  3222. var pasDeSR=false;
  3223. var esqM=0,attM=0,armM_mag=0,armM_tot=0,degM=0;
  3224. 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)
  3225. return null;
  3226.  
  3227. if (MY_DEBUG) window.console.log('analyseTactique nom=' + nom + ' ' + JSON.stringify(donneesMonstre));
  3228. if (donneesMonstre.index == undefined) {
  3229. // à supprimer
  3230. var td = document.createElement('td')
  3231. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  3232. var esqM = 0;
  3233. try
  3234. {
  3235. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3236. }
  3237. catch(e)
  3238. {
  3239. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  3240. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3241. modificateurEsquive = '<';
  3242. modificateurArmure = '<';
  3243. modificateurMagie = '<';
  3244. }
  3245.  
  3246. td.innerHTML = bbcode(donneesMonstre[3]);
  3247. var attM = 0;
  3248. try
  3249. {
  3250. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3251. }
  3252. catch(e)
  3253. {
  3254. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  3255. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3256. modificateurEsquiveM = '>';
  3257. modificateurArmureM = '>';
  3258. }
  3259.  
  3260. td.innerHTML = bbcode(donneesMonstre[5]);
  3261. var degM = 0;
  3262. try
  3263. {
  3264. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3265. }
  3266. catch(e)
  3267. {
  3268. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  3269. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3270. modificateurArmureM = '>';
  3271. }
  3272.  
  3273. td.innerHTML = bbcode(donneesMonstre[7]);
  3274. try
  3275. {
  3276. armM_tot=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3277. armM_mag=armM_tot; // compatibilité avec ancien calcul
  3278. }
  3279. catch(e)
  3280. {
  3281. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  3282. armM_tot=Math.ceil(parseInt(td.firstChild.nodeValue));
  3283. armM_mag=armM_tot;
  3284. modificateurArmure = '<';
  3285. }
  3286.  
  3287. var coeffSeuil = 0.95;
  3288. try
  3289. {
  3290. td.innerHTML = bbcode(donneesMonstre[9]);
  3291. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  3292. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3293. var v = (rm / mm);
  3294. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3295. coeffSeuil = (200-seuil)/200;
  3296. }
  3297. catch(e)
  3298. {
  3299. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  3300. modificateurMagie = '<';
  3301. pasDeSR = true;
  3302. }
  3303. } else {
  3304. //calcul de modificateurEsquive, modificateurArmure, modificateurMagie, modificateurEsquiveM, modificateurArmureM, pasDeSR, esqM, attM, armM_mag, armM_tot, degM;
  3305. if (donneesMonstre.esq) {
  3306. if (donneesMonstre.esq.min && donneesMonstre.esq.max) {
  3307. esqM = Math.ceil((donneesMonstre.esq.min + donneesMonstre.esq.max) / 2);
  3308. } else if (donneesMonstre.esq.max) {
  3309. esqM = donneesMonstre.esq.max;
  3310. modificateurEsquive = '<';
  3311. modificateurArmure = '<';
  3312. modificateurMagie = '<';
  3313. }
  3314. }
  3315.  
  3316. if (donneesMonstre.att) {
  3317. if (donneesMonstre.att.min && donneesMonstre.att.max) {
  3318. attM = Math.ceil((donneesMonstre.att.min + donneesMonstre.att.max) / 2);
  3319. } else if (donneesMonstre.att.max) {
  3320. attM = donneesMonstre.att.max;
  3321. modificateurEsquiveM = '>';
  3322. modificateurArmureM = '>';
  3323. }
  3324. }
  3325.  
  3326. if (donneesMonstre.armM) {
  3327. if (donneesMonstre.armM.min && donneesMonstre.armM.max) {
  3328. armM_mag = Math.ceil((donneesMonstre.armM.min + donneesMonstre.armM.max) / 2);
  3329. } else if (donneesMonstre.armM.max) {
  3330. armM_mag = donneesMonstre.armM.max;
  3331. modificateurArmure = '<';
  3332. }
  3333. if (donneesMonstre.armP) {
  3334. if (donneesMonstre.armP.min && donneesMonstre.armP.max) {
  3335. armM_phy = Math.ceil((donneesMonstre.armP.min + donneesMonstre.armP.max) / 2);
  3336. } else if (donneesMonstre.armP.max) {
  3337. armM_phy = donneesMonstre.armP.max;
  3338. modificateurArmure = '<';
  3339. }
  3340. armM_tot = armM_mag + armM_phy;
  3341. } else { // ça ne devrait pas arriver
  3342. armM_tot = armM_mag;
  3343. }
  3344. } else if (donneesMonstre.arm) {
  3345. if (donneesMonstre.arm.min && donneesMonstre.arm.max) {
  3346. armM_tot = Math.ceil((donneesMonstre.arm.min + donneesMonstre.arm.max) / 2);
  3347. armM_mag=armM_tot; // worst case
  3348. } else if (donneesMonstre.arm.max) {
  3349. armM_tot = donneesMonstre.arm.max;
  3350. armM_mag=armM_tot;
  3351. modificateurArmure = '<';
  3352. }
  3353. }
  3354.  
  3355. if (donneesMonstre.deg) {
  3356. if (donneesMonstre.deg.min && donneesMonstre.deg.max) {
  3357. degM = Math.ceil((donneesMonstre.deg.min + donneesMonstre.deg.max) / 2);
  3358. } else if (donneesMonstre.deg.max) {
  3359. degM = donneesMonstre.deg.max;
  3360. modificateurArmureM = '>';
  3361. }
  3362. }
  3363.  
  3364. var coeffSeuil = 0.95;
  3365. if (donneesMonstre.RM) {
  3366. if (donneesMonstre.RM.min && donneesMonstre.RM.max) {
  3367. var rmM = Math.ceil((donneesMonstre.RM.min + donneesMonstre.RM.max) / 2);
  3368. var v = (rmM / mm);
  3369. var seuil = (rmM < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3370. coeffSeuil = (200-seuil)/200;
  3371. } else if (donneesMonstre.deg.max) {
  3372. }
  3373. modificateurMagie = '<';
  3374. pasDeSR = true;
  3375. }
  3376. }
  3377. 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);
  3378.  
  3379. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  3380. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  3381. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  3382. // roule debug
  3383. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  3384. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  3385. 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);
  3386. //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);
  3387. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3388. if(getSortComp("Vampirisme")>0)
  3389. {
  3390. var pour = getSortComp("Vampirisme");
  3391. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3392. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3393. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3394. 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;
  3395. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3396. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3397. }
  3398. if(getSortComp("Siphon des âmes")>0)
  3399. {
  3400. var pour = getSortComp("Siphon des âmes");
  3401. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3402. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3403. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3404. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm-armM_mag,1))/100);
  3405. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3406. }
  3407. if(getSortComp("Botte Secrète")>0)
  3408. {
  3409. var pour = getSortComp("Botte Secrète");
  3410. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3411. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3412. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3413. 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;
  3414. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3415. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3416. }
  3417. if(getSortComp("Rafale Psychique")>0)
  3418. {
  3419. var pour = getSortComp("Rafale Psychique");
  3420. chanceDEsquiveParfaite = 0;
  3421. chanceDeTouche = Math.round(100*pour/100);
  3422. chanceDeCritique = Math.round(0*pour/100);
  3423. 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;
  3424. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3425. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3426. }
  3427. if(getSortComp("Explosion")>0)
  3428. {
  3429. var pour = getSortComp("Explosion");
  3430. chanceDEsquiveParfaite = 0;
  3431. chanceDeTouche = Math.round(100*pour/100);
  3432. chanceDeCritique = Math.round(0*pour/100);
  3433. 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;
  3434. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3435. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3436. }
  3437. if(getSortComp("Projectile Magique")>0)
  3438. {
  3439. var pour = getSortComp("Projectile Magique");
  3440. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  3441. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  3442. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  3443. // distance troll - monstre
  3444. 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;
  3445. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3446. if (donneesMonstre.index !== undefined && MZ_EtatCdMs.tr_monstres !== undefined && MZ_EtatCdMs.tr_monstres[donneesMonstre.index] !== undefined) {
  3447. var dist = getMonstreDistance(donneesMonstre.index);
  3448. //if (isDEV) window.console.log('Dist pour PM=' + dist);
  3449. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  3450. var portee = getPortee(vue+vue_bm);
  3451. if (dist <= portee) {
  3452. degats = Math.round((degats + 2 * (portee-dist)) * 100) / 100;
  3453. } else {
  3454. degats += ' (plus bonus de portée)';
  3455. }
  3456. debugMZ('analyseTactique, iTR= ' + donneesMonstre.index + ', dist=' + dist + ', porteePM=' + portee);
  3457. } else {
  3458. degats += ' (plus bonus de portée)';
  3459. }
  3460. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3461. }
  3462. if(getSortComp("Frénésie")>0)
  3463. {
  3464. var pour = getSortComp("Frénésie");
  3465. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3466. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3467. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3468. 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;
  3469. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3470. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3471. }
  3472. if(getSortComp("Charger")>0)
  3473. {
  3474. var pour = getSortComp("Charger");
  3475. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3476. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3477. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3478. 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;
  3479. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3480. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3481. }
  3482. if(getSortComp("Griffe du Sorcier")>0)
  3483. {
  3484. var pour = getSortComp("Griffe du Sorcier");
  3485. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3486. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3487. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3488. 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;
  3489. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3490. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3491. }
  3492. if(getSortComp("Attaque Précise",1)>0)
  3493. {
  3494. var niveau = 5;
  3495. var oldPour = 0;
  3496. var chanceDEsquiveParfaite = 0;
  3497. var chanceDeTouche = 0;
  3498. var chanceDeCritique = 0;
  3499. degats = 0;
  3500. while(niveau>0)
  3501. {
  3502. var pour = getSortComp("Attaque Précise",niveau);
  3503. if(pour>oldPour)
  3504. {
  3505. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3506. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3507. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3508. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3509. chanceDeTouche += chanceDeToucheNiveau;
  3510. chanceDeCritique += chanceDeCritiqueNiveau;
  3511. 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);
  3512. oldPour = pour;
  3513. }
  3514. niveau--;
  3515. }
  3516. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3517. 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));
  3518. }
  3519. if(getSortComp("Coup de Butoir",1)>0)
  3520. {
  3521. var niveau = 5;
  3522. var oldPour =0;
  3523. var chanceDEsquiveParfaite = 0;
  3524. var chanceDeTouche=0;
  3525. var chanceDeCritique=0;
  3526. degats=0;
  3527. while(niveau>0)
  3528. {
  3529. var pour = getSortComp("Coup de Butoir",niveau);
  3530. if(pour>oldPour)
  3531. {
  3532. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3533. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3534. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3535. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3536. chanceDeTouche += chanceDeToucheNiveau;
  3537. chanceDeCritique += chanceDeCritiqueNiveau;
  3538. 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);
  3539. oldPour = pour;
  3540. }
  3541. niveau--;
  3542. }
  3543. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3544. 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));
  3545. }
  3546. 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;});
  3547. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  3548. {
  3549. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  3550. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  3551. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  3552. }
  3553. else
  3554. {
  3555. chanceDEsquiveParfaite = 0;
  3556. chanceDeTouche = 100;
  3557. chanceDeCritique = 0;
  3558. }
  3559. 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;
  3560.  
  3561. 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));
  3562. return listeAttaques;
  3563. }
  3564. catch(e) {
  3565. window.console.error(traceStack(e, 'analyseTactique'));
  3566. window.alert(e);
  3567. }
  3568. }
  3569.  
  3570. // x~~x marque pour s'y retrouver sous l'éditeur
  3571.  
  3572. /*
  3573. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  3574. * published under GNU License v2.
  3575. *
  3576. * Patch :
  3577. * gestion des missions terminées
  3578. */
  3579.  
  3580. // x~x mission_liste
  3581.  
  3582. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  3583. try {
  3584. var titresMimis = document.evaluate(
  3585. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  3586. document, null, 7, null
  3587. );
  3588. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3589. } catch(e) {
  3590. window.console.error(traceStack(e, 'mission_liste initialisation'));
  3591. return;
  3592. }
  3593.  
  3594. var enCours = {};
  3595. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  3596. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  3597. enCours[num] = true;
  3598. }
  3599.  
  3600. for(var numMimi in obMissions) {
  3601. if(!enCours[numMimi]) {
  3602. delete obMissions[numMimi];
  3603. }
  3604. }
  3605. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3606. }
  3607.  
  3608. function do_mission_liste() {
  3609. checkLesMimis();
  3610. }
  3611.  
  3612. /*******************************************************************************
  3613. * This file is part of Mountyzilla. *
  3614. * *
  3615. * Mountyzilla is free software; you can redistribute it and/or modify *
  3616. * it under the terms of the GNU General Public License as published by *
  3617. * the Free Software Foundation; either version 2 of the License, or *
  3618. * (at your option) any later version. *
  3619. * *
  3620. * Mountyzilla is distributed in the hope that it will be useful, *
  3621. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3622. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3623. * GNU General Public License for more details. *
  3624. * *
  3625. * You should have received a copy of the GNU General Public License *
  3626. * along with Mountyzilla; if not, write to the Free Software *
  3627. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3628. *******************************************************************************/
  3629.  
  3630. // x~x actions
  3631.  
  3632. /* TODO
  3633. * getLvl pour Explo, Rotobaffe et cie
  3634. */
  3635.  
  3636.  
  3637.  
  3638. /* Page de combat */
  3639.  
  3640. function getLevel() {
  3641. var divList = document.getElementsByTagName('div');
  3642. if(divList.length <= 2)
  3643. return;
  3644.  
  3645. // On essaie de voir si cette action était une attaque
  3646. var pList = document.getElementsByTagName('p');
  3647. var nomM = '';
  3648. // Modification pour Frénésie by TetDure
  3649. var numAtt = 0;
  3650. for (var i = 0; i < pList.length; i++) {
  3651. if(pList[i].firstChild) {
  3652. nomM = pList[i].firstChild.nodeValue;
  3653. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3654. numAtt++;
  3655. }
  3656. }
  3657.  
  3658. if(nomM == '')
  3659. return;
  3660.  
  3661. // Si c'est une attaque normale, un seul PX
  3662. var comPX = 1;
  3663. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3664. comPX++;
  3665.  
  3666. // Extraction des infos du monstre attaqué
  3667. var idM;
  3668. var male;
  3669. if(nomM.slice(20, 21) == 'e') {
  3670. male = false;
  3671. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3672. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3673. }
  3674. else {
  3675. male = true;
  3676. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3677. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3678. }
  3679.  
  3680. if(idM == '')
  3681. return;
  3682.  
  3683. var bList = document.getElementsByTagName('b');
  3684. var niveau = '';
  3685. for (var i = 0; i < bList.length; i++) {
  3686. var b = bList[i];
  3687. if(b.childNodes[0].nodeValue != "TUÉ")
  3688. continue;
  3689. var nbPX = "";
  3690. for (i++; i < bList.length; i++) {
  3691. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3692. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3693. return;
  3694. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3695. nbPX = bList[i].childNodes[0].nodeValue;
  3696. break;
  3697. }
  3698. }
  3699. if(nbPX == '')
  3700. return;
  3701. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3702. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3703. if(!nbPX)
  3704. nbPX = 0;
  3705. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3706. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3707. if(comPX > nbPX) {
  3708. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3709. niveau = "";
  3710. } else if(Math.floor(niveau) == niveau) {
  3711. chaine += niveau + ".";
  3712. } else {
  3713. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3714. niveau = "";
  3715. }
  3716. insertBr(b.nextSibling.nextSibling.nextSibling);
  3717. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3718. }
  3719.  
  3720. if(niveau != '') {
  3721. var button = insertButtonCdm('as_Action');
  3722. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3723. + escape(nomM) + "&niveau=" + escape(niveau)
  3724. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3725. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3726. }
  3727. }
  3728.  
  3729.  
  3730. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3731.  
  3732. function insertInfoMagie(node, intitule, magie) {
  3733. if(node.nextSibling) {
  3734. node = node.nextSibling;
  3735. insertBr(node);
  3736. insertText(node, intitule);
  3737. insertText(node, magie, true);
  3738. } else {
  3739. node = node.parentNode;
  3740. appendBr(node);
  3741. appendText(node, intitule);
  3742. appendText(node, magie, true);
  3743. }
  3744. }
  3745.  
  3746. function getMM(sr) {
  3747. if(rmTroll<=0) {
  3748. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3749. }
  3750. sr = Number(sr.match(/\d+/)[0]);
  3751. if(sr==10) {
  3752. return '\u2265 '+5*rmTroll;
  3753. }
  3754. if(sr<=50) {
  3755. return Math.round(50*rmTroll/sr);
  3756. }
  3757. if(sr<90) {
  3758. return Math.round((100-sr)*rmTroll/50);
  3759. }
  3760. return '\u2264 '+Math.round(rmTroll/5);
  3761. }
  3762.  
  3763. function traiteMM() {
  3764. var node = document.evaluate(
  3765. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3766. document, null, 9, null).singleNodeValue;
  3767.  
  3768. if(node) {
  3769. var mm = getMM(node.nodeValue);
  3770. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3771. } else {
  3772. var node = document.evaluate(
  3773. "//p/text()[contains(., 'Seuil de Résistance')]",
  3774. document, null, 9, null).singleNodeValue;
  3775. if(!node) {
  3776. return;
  3777. }
  3778. var mm = getMM(node.nodeValue);
  3779. node = node.nextSibling.nextSibling;
  3780. }
  3781. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3782. }
  3783.  
  3784. function getRM(sr) {
  3785. if(mmTroll<=0) {
  3786. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3787. }
  3788. sr = Number(sr.match(/\d+/)[0]);
  3789. if(sr==10) {
  3790. return '\u2264 '+Math.round(mmTroll/5);
  3791. }
  3792. if(sr<=50) {
  3793. return Math.round(sr*mmTroll/50);
  3794. }
  3795. if(sr<90) {
  3796. return Math.round(50*mmTroll/(100-sr));
  3797. }
  3798. return '\u2265 '+5*mmTroll;
  3799. }
  3800.  
  3801. function traiteRM() {
  3802. var nodes = document.evaluate(
  3803. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3804. document, null, 7, null);
  3805. if(nodes.snapshotLength==0) {
  3806. return;
  3807. }
  3808.  
  3809. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3810. var node = nodes.snapshotItem(i);
  3811. var rm = getRM(node.nodeValue);
  3812. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3813. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3814. }
  3815. }
  3816.  
  3817.  
  3818. /* Fonction stats IdT par Raistlin */
  3819.  
  3820. /*function getIdt() {
  3821. if(MY_getValue("SEND_IDT") == "non")
  3822. return false;
  3823.  
  3824. var regExpBeginning = /^\s+/;
  3825. var regExpEnd = /\s+$/;
  3826.  
  3827. var nomIdt = document.evaluate(
  3828. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3829. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3830. if(!nomIdt)
  3831. return false;
  3832.  
  3833. var caracIdt;
  3834. if(nomIdt.indexOf("Malédiction !") != -1) {
  3835. caracIdt = "";
  3836. nomIdt = "Mission maudite";
  3837. } else {
  3838. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3839. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3840. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3841. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3842. }
  3843. FF_XMLHttpRequest({
  3844. method: 'GET',
  3845. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3846. headers : {
  3847. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3848. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3849. }
  3850. });
  3851. return true;
  3852. }*/
  3853.  
  3854.  
  3855. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3856.  
  3857. function confirmeDecalage() {
  3858. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3859. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3860. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3861.  
  3862. var newDLA = new Date( oldDLA );
  3863. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3864. return window.confirm(
  3865. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3866. +'\nConfirmez-vous ce décalage ?'
  3867. );
  3868. }
  3869.  
  3870. function newsubmitDLA(evt) {
  3871. evt.stopPropagation();
  3872. evt.preventDefault();
  3873. if(confirmeDecalage()) {
  3874. this.submit();
  3875. }
  3876. }
  3877.  
  3878. function changeActionDecalage() {
  3879. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3880. return;
  3881. }
  3882. try {
  3883. // On récupère le contenu du script JS MH de calcul du décalage
  3884. var scriptTxt = document.evaluate(
  3885. ".//script[ not(@src) ]",
  3886. document, null, 9, null
  3887. ).singleNodeValue.textContent;
  3888. // On en extrait la DLA courante
  3889. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3890. scriptTxt = scriptTxt.split('\n')[0];
  3891. var nbs = scriptTxt.match(/\d+/g);
  3892. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3893. } catch(e) {
  3894. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3895. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3896. return;
  3897. }
  3898. var form = document.getElementsByName('ActionForm')[0];
  3899. if(form) {
  3900. form.addEventListener('submit', newsubmitDLA, true);
  3901. } else {
  3902. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3903. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3904. }
  3905. }
  3906.  
  3907. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3908.  
  3909. function prochainMundi() {
  3910. try {
  3911. var node;
  3912. node = document.evaluate(
  3913. "//div[@class='dateAction']/b",
  3914. document, null, 9, null
  3915. ).singleNodeValue;
  3916. if (document.evaluate) {
  3917. } else { // repli en JQuery
  3918. //node = $(
  3919. }
  3920. } catch(e) {
  3921. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3922. return;
  3923. }
  3924. if(!node) { return; }
  3925.  
  3926. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3927. var jour = longueurMois+1-getNumber(node.textContent);
  3928. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3929. var txt = '[Prochain Mundidey ';
  3930. if(jour>1) {
  3931. txt += 'dans '+jour+' jours]';
  3932. } else {
  3933. txt += 'demain]';
  3934. }
  3935. insertText(node.parentNode.nextSibling,txt,true);
  3936. }
  3937.  
  3938.  
  3939. /* Fonction principale */
  3940.  
  3941. function dispatch() {
  3942. if(isPage('MH_Play/Play_action')) {
  3943. prochainMundi();
  3944. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3945. var oldDLA;
  3946. changeActionDecalage();
  3947. } else if(isPage('MH_Play/Actions')) {
  3948. if(document.evaluate(
  3949. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3950. document, null, 2, null
  3951. ).stringValue) {
  3952. traiteMM();
  3953. } else if(document.evaluate(
  3954. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3955. document, null, 2, null
  3956. ).stringValue) {
  3957. //getIdt();
  3958. traiteRM();
  3959. } /*else {
  3960. // Est censé se lancer sur quoi *précisément* ?
  3961. traiteRM();
  3962. getLevel();
  3963. }*/
  3964. } else {
  3965. /* Traitement des messages du bot */
  3966. var messageTitle = document.evaluate(
  3967. "//form/table/tbody/tr[1]/td[1]/"
  3968. +"descendant::text()[contains(.,'[MountyHall]')]",
  3969. document, null, 2, null
  3970. ).stringValue;
  3971. if(messageTitle.indexOf('Attaquant') != -1 &&
  3972. messageTitle.indexOf('sur') != -1) {
  3973. getLevel();
  3974. traiteRM();
  3975. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3976. messageTitle.indexOf('Défenseur') != -1) {
  3977. traiteMM();
  3978. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3979. // à replacer avec Attaque après révision getLvl :
  3980. messageTitle.indexOf('Explosion') != -1 ||
  3981. messageTitle.indexOf('Insulte') != -1) {
  3982. traiteRM();
  3983. }
  3984. }
  3985. }
  3986.  
  3987. function do_actions() {
  3988. start_script(31);
  3989. dispatch();
  3990. displayScriptTime();
  3991. }
  3992.  
  3993. /*********************************************************************************
  3994. * This file is part of Mountyzilla. *
  3995. * *
  3996. * Mountyzilla is free software; you can redistribute it and/or modify *
  3997. * it under the terms of the GNU General Public License as published by *
  3998. * the Free Software Foundation; either version 2 of the License, or *
  3999. * (at your option) any later version. *
  4000. * *
  4001. * Mountyzilla is distributed in the hope that it will be useful, *
  4002. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4003. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4004. * GNU General Public License for more details. *
  4005. * *
  4006. * You should have received a copy of the GNU General Public License *
  4007. * along with Mountyzilla; if not, write to the Free Software *
  4008. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4009. *********************************************************************************/
  4010.  
  4011. // x~x pre-enchant
  4012.  
  4013. /* 2013-08-19 : correction auto syntaxe alert */
  4014.  
  4015. var combobox=null;
  4016.  
  4017. function changeObject()
  4018. {
  4019. if(!combobox)
  4020. return ;
  4021. var id = combobox.options[combobox.selectedIndex].value;
  4022. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  4023. if(!id || id=="")
  4024. {
  4025. MY_removeValue(numTroll+".enchantement.lastEquipement");
  4026. return;
  4027. }
  4028. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  4029. }
  4030.  
  4031. function treatePreEnchantement() {
  4032. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4033. if(!input || input.getAttribute("type")=="hidden")
  4034. {
  4035. return false;
  4036. }
  4037. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  4038. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4039. if(!combobox)
  4040. {
  4041. return true;
  4042. }
  4043. combobox.addEventListener('change', changeObject, true);
  4044. return true;
  4045. }
  4046.  
  4047. function treateEnchantement_pre() {
  4048. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4049. if(!input || input.getAttribute("type")!="hidden")
  4050. {
  4051. return false;
  4052. }
  4053. var idEquipement = input.getAttribute("value");
  4054. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  4055. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  4056. if(enchanteur && enchanteur != null)
  4057. return true;
  4058. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4059. if(!input || input.getAttribute("type")!="hidden")
  4060. {
  4061. return false;
  4062. }
  4063. var idEnchanteur = input.getAttribute("value");
  4064.  
  4065. var nodes = document.evaluate(
  4066. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4067. if (nodes.snapshotLength != 3)
  4068. return;
  4069. for(var i=0;i<3;i++)
  4070. {
  4071. var texte = trim(nodes.snapshotItem(i).nodeValue);
  4072. texte = texte.replace(" d'une "," d'un ");
  4073. var compo = texte.substring(0,texte.indexOf(" d'un "));
  4074. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  4075. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  4076. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  4077. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  4078. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  4079. }
  4080. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  4081. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  4082. var liste = MY_getValue(numTroll+".enchantement.liste");
  4083. if(!liste || liste=="")
  4084. {
  4085. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  4086. }
  4087. else
  4088. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  4089. }
  4090.  
  4091. function do_pre_enchant() {
  4092. start_script(60);
  4093. if(!treatePreEnchantement())
  4094. treateEnchantement_pre();
  4095. displayScriptTime();
  4096. }
  4097.  
  4098. /*********************************************************************************
  4099. * This file is part of Mountyzilla. *
  4100. * *
  4101. * Mountyzilla is free software; you can redistribute it and/or modify *
  4102. * it under the terms of the GNU General Public License as published by *
  4103. * the Free Software Foundation; either version 2 of the License, or *
  4104. * (at your option) any later version. *
  4105. * *
  4106. * Mountyzilla is distributed in the hope that it will be useful, *
  4107. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4108. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4109. * GNU General Public License for more details. *
  4110. * *
  4111. * You should have received a copy of the GNU General Public License *
  4112. * along with Mountyzilla; if not, write to the Free Software *
  4113. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4114. *********************************************************************************/
  4115.  
  4116. // x~x enchant
  4117.  
  4118. /* 2013-08-19 : correction auto syntaxe alert */
  4119.  
  4120. function treateEnchantement() {
  4121. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  4122. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  4123. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  4124. return;
  4125. var tab = infoEquipement.split(";");
  4126. if(tab.length<2)
  4127. return;
  4128. var idEquipement = tab[0];
  4129. var nomEquipement = tab[1];
  4130. for(var i=2;i<tab.length;i++)
  4131. nomEquipement += ";"+tab[i];
  4132.  
  4133. var nodes = document.evaluate(
  4134. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4135. if (nodes.snapshotLength != 3)
  4136. return;
  4137. for(var i=0;i<3;i++)
  4138. {
  4139. var texte = trim(nodes.snapshotItem(i).nodeValue);
  4140. texte = texte.replace(" d'une "," d'un ");
  4141. var compo = texte.substring(0,texte.indexOf(" d'un "));
  4142. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  4143. monstre = monstre.replace(/ Géante?/,"");
  4144. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  4145. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  4146. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  4147. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  4148. }
  4149. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  4150. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  4151. var liste = MY_getValue(numTroll+".enchantement.liste");
  4152. if(!liste || liste=="")
  4153. {
  4154. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  4155. }
  4156. else
  4157. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  4158. }
  4159.  
  4160. function do_enchant() {
  4161. start_script(60);
  4162.  
  4163. treateEnchantement();
  4164. MY_removeValue(numTroll+".enchantement.lastEquipement");
  4165. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  4166. displayScriptTime();
  4167. }
  4168.  
  4169. /*********************************************************************************
  4170. * This file is part of Mountyzilla. *
  4171. * *
  4172. * Mountyzilla is free software; you can redistribute it and/or modify *
  4173. * it under the terms of the GNU General Public License as published by *
  4174. * the Free Software Foundation; either version 2 of the License, or *
  4175. * (at your option) any later version. *
  4176. * *
  4177. * Mountyzilla is distributed in the hope that it will be useful, *
  4178. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4179. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4180. * GNU General Public License for more details. *
  4181. * *
  4182. * You should have received a copy of the GNU General Public License *
  4183. * along with Mountyzilla; if not, write to the Free Software *
  4184. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4185. *********************************************************************************/
  4186.  
  4187. // x~x myevent
  4188.  
  4189. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4190. function do_myevent() {
  4191. }
  4192.  
  4193. /*********************************************************************************
  4194. * This file is part of Mountyzilla. *
  4195. * *
  4196. * Mountyzilla is free software; you can redistribute it and/or modify *
  4197. * it under the terms of the GNU General Public License as published by *
  4198. * the Free Software Foundation; either version 2 of the License, or *
  4199. * (at your option) any later version. *
  4200. * *
  4201. * Mountyzilla is distributed in the hope that it will be useful, *
  4202. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4203. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4204. * GNU General Public License for more details. *
  4205. * *
  4206. * You should have received a copy of the GNU General Public License *
  4207. * along with Mountyzilla; if not, write to the Free Software *
  4208. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4209. *********************************************************************************/
  4210.  
  4211. // x~x malus
  4212.  
  4213. /* v1.4 - 2014-01-06
  4214. * - Gestion des sorts double composante
  4215. * v1.4.1 - 2014-01-22
  4216. * - Correction décumul
  4217. * TODO
  4218. * - Identifier la position de "PV" dans l'ordre MH
  4219. */
  4220.  
  4221. var listeBM;
  4222.  
  4223.  
  4224. /* [functions] Utilitaires */
  4225.  
  4226. function decumul(bmt,nbr) {
  4227. var bmr;
  4228. if(!nbr || nbr<2) bmr = bmt;
  4229. else if(nbr==2) bmr = parseInt(0.67*bmt);
  4230. else if(nbr==3) bmr = parseInt(0.40*bmt);
  4231. else if(nbr==4) bmr = parseInt(0.25*bmt);
  4232. else if(nbr==5) bmr = parseInt(0.15*bmt);
  4233. else bmr = parseInt(0.1*bmt);
  4234. if(bmt<0) return Math.min(-1,bmr);
  4235. return Math.max(1,bmr);
  4236. }
  4237.  
  4238. function triecaracs(a,b) { // version Yoyor, mod by Dab
  4239. // Roule 23/11/2016 ajout PV
  4240. switch( a ) {
  4241. case 'ATT':
  4242. return -1;
  4243. case 'ESQ':
  4244. if(b=='ATT') return 1;
  4245. return -1;
  4246. case 'DEG':
  4247. switch( b ) {
  4248. case 'ATT':
  4249. case 'ESQ':
  4250. return 1;
  4251. default:
  4252. return -1;
  4253. }
  4254. case 'REG':
  4255. switch( b ) {
  4256. case 'ATT':
  4257. case 'ESQ':
  4258. case 'DEG':
  4259. return 1;
  4260. default:
  4261. return -1;
  4262. }
  4263. case 'Vue':
  4264. switch( b ) {
  4265. case 'ATT':
  4266. case 'ESQ':
  4267. case 'DEG':
  4268. case 'REG':
  4269. return 1;
  4270. default:
  4271. return -1;
  4272. }
  4273. case 'TOUR':
  4274. switch( b ) {
  4275. case 'ATT':
  4276. case 'ESQ':
  4277. case 'DEG':
  4278. case 'REG':
  4279. case 'Vue':
  4280. return 1;
  4281. default:
  4282. return -1;
  4283. }
  4284. case 'PV':
  4285. switch( b ) {
  4286. case 'ATT':
  4287. case 'ESQ':
  4288. case 'DEG':
  4289. case 'REG':
  4290. case 'Vue':
  4291. case 'TOUR':
  4292. return 1;
  4293. default:
  4294. return -1;
  4295. }
  4296. case 'Armure':
  4297. switch( b ) {
  4298. case 'ATT':
  4299. case 'ESQ':
  4300. case 'DEG':
  4301. case 'REG':
  4302. case 'Vue':
  4303. case 'TOUR':
  4304. case 'PV':
  4305. return 1;
  4306. default:
  4307. return -1;
  4308. }
  4309. case 'RM':
  4310. switch( b ) {
  4311. case 'ATT':
  4312. case 'ESQ':
  4313. case 'DEG':
  4314. case 'REG':
  4315. case 'Vue':
  4316. case 'TOUR':
  4317. case 'PV':
  4318. case 'Armure':
  4319. return 1;
  4320. default:
  4321. return -1;
  4322. }
  4323. case 'MM':
  4324. switch( b ) {
  4325. case 'ATT':
  4326. case 'ESQ':
  4327. case 'DEG':
  4328. case 'REG':
  4329. case 'Vue':
  4330. case 'TOUR':
  4331. case 'PV':
  4332. case 'Armure':
  4333. case 'RM':
  4334. return 1;
  4335. default:
  4336. return -1;
  4337. }
  4338. case 'Concentration':
  4339. switch( b ) {
  4340. case 'ATT':
  4341. case 'ESQ':
  4342. case 'DEG':
  4343. case 'REG':
  4344. case 'Vue':
  4345. case 'TOUR':
  4346. case 'PV':
  4347. case 'Armure':
  4348. case 'RM':
  4349. case 'MM':
  4350. return 1;
  4351. default:
  4352. return -1;
  4353. }
  4354. case 'Fatigue':
  4355. switch( b ) {
  4356. case 'ATT':
  4357. case 'ESQ':
  4358. case 'DEG':
  4359. case 'REG':
  4360. case 'Vue':
  4361. case 'TOUR':
  4362. case 'PV':
  4363. case 'Armure':
  4364. case 'RM':
  4365. case 'MM':
  4366. case 'Concentration':
  4367. return 1;
  4368. default:
  4369. return -1;
  4370. }
  4371. case "Dés d'attaque":
  4372. switch( b ) {
  4373. case 'ATT':
  4374. case 'ESQ':
  4375. case 'DEG':
  4376. case 'REG':
  4377. case 'Vue':
  4378. case 'TOUR':
  4379. case 'PV':
  4380. case 'Armure':
  4381. case 'RM':
  4382. case 'MM':
  4383. case 'Concentration':
  4384. case 'Fatigue':
  4385. return 1;
  4386. default:
  4387. return -1;
  4388. }
  4389. case 'Dés de dégâts':
  4390. switch( b ) {
  4391. case 'ATT':
  4392. case 'ESQ':
  4393. case 'DEG':
  4394. case 'REG':
  4395. case 'Vue':
  4396. case 'TOUR':
  4397. case 'PV':
  4398. case 'Armure':
  4399. case 'RM':
  4400. case 'MM':
  4401. case 'Concentration':
  4402. case 'Fatigue':
  4403. case "Dés d'attaque":
  4404. return 1;
  4405. default:
  4406. return -1;
  4407. }
  4408. default :
  4409. switch( b ) {
  4410. case 'ATT':
  4411. case 'ESQ':
  4412. case 'DEG':
  4413. case 'REG':
  4414. case 'Vue':
  4415. case 'TOUR':
  4416. case 'PV':
  4417. case 'Armure':
  4418. case 'RM':
  4419. case 'MM':
  4420. case 'Concentration':
  4421. case 'Fatigue':
  4422. case "Dés d'attaque":
  4423. case 'Dés de dégâts':
  4424. return 1;
  4425. default:
  4426. return -1;
  4427. }
  4428. }
  4429. }
  4430.  
  4431.  
  4432. /* [functions] Fonctions hide / display */
  4433.  
  4434. function toggleDetailsBM() {
  4435. if(MY_getValue('BMDETAIL')!='false') {
  4436. MY_setValue('BMDETAIL','false');
  4437. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4438. for(var i=0 ; i<trlist.length ; i++)
  4439. trlist[i].style.display = 'none';
  4440. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4441. for(var i=0 ; i<trlist.length ; i++)
  4442. trlist[i].style = '';
  4443. }
  4444. else {
  4445. MY_setValue('BMDETAIL','true');
  4446. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4447. for(var i=0 ; i<trlist.length ; i++)
  4448. trlist[i].style.display = 'none';
  4449. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4450. for(var i=0 ; i<trlist.length ; i++)
  4451. trlist[i].style = '';
  4452. }
  4453. }
  4454.  
  4455. function toggleBMList() {
  4456. if(MY_getValue('BMHIDELIST')=='true') {
  4457. MY_setValue('BMHIDELIST','false');
  4458. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4459. listeBM.snapshotItem(i).style = '';
  4460. document.getElementsByTagName('thead')[0].style = '';
  4461. document.getElementById('trhelp').style = '';
  4462. }
  4463. else {
  4464. MY_setValue('BMHIDELIST','true');
  4465. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4466. listeBM.snapshotItem(i).style.display = 'none';
  4467. document.getElementsByTagName('thead')[0].style.display = 'none';
  4468. document.getElementById('trhelp').style.display = 'none';
  4469. }
  4470. }
  4471.  
  4472. function setDisplayBM() {
  4473. if(!listeBM) return;
  4474.  
  4475. var titre = document.getElementById('titre2');
  4476. if(titre) {
  4477. titre.style.cursor = 'pointer';
  4478. titre.onclick = toggleBMList;
  4479. }
  4480.  
  4481. var tfoot = document.getElementsByTagName('tfoot')[0];
  4482. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  4483. tfoot, null, 9, null).singleNodeValue;
  4484. tr.id = 'trhelp';
  4485.  
  4486. if(MY_getValue('BMHIDELIST')=='true') {
  4487. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4488. listeBM.snapshotItem(i).style.display = 'none';
  4489. document.getElementsByTagName('thead')[0].style.display = 'none';
  4490. tr.style.display = 'none';
  4491. }
  4492. }
  4493.  
  4494.  
  4495. /* [functions] Fonction principale */
  4496.  
  4497. function traiteMalus() {
  4498. var mainTab = document.getElementsByTagName('table')[0];
  4499. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4500. if(listeBM.snapshotLength==0) return;
  4501.  
  4502. /* Suppression des BM de fatigue stockés */
  4503. if(MY_getValue(numTroll+'.bm.fatigue'))
  4504. MY_removeValue(numTroll+'.bm.fatigue');
  4505.  
  4506. /* Extraction des données */
  4507. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  4508. var nb = 0;
  4509. while(nb<listeBM.snapshotLength) {
  4510. tr = listeBM.snapshotItem(nb); nb++;
  4511. var effetsT = tr.childNodes[5].textContent.split(' | ');
  4512. var phymag = tr.childNodes[9].textContent;
  4513. var duree = tr.childNodes[11].textContent.match(/\d+/);
  4514. if (duree == null) { // Roule 28/01/2018 protection malus Crasc sans durée
  4515. duree = 1;
  4516. } else {
  4517. duree = Number(duree[0]);
  4518. }
  4519. var type = tr.childNodes[3].textContent, nom;
  4520. // si c'est un type à décumul
  4521. /*
  4522. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  4523. switch(type) {
  4524. case 'Potion':
  4525. case 'Parchemin':
  4526. case 'Sortilège':
  4527. case 'Capacité Spéciale':
  4528. nom = tr.childNodes[1].textContent+phymag;
  4529. break;
  4530. default:
  4531. nom = 'pasdedecumul';
  4532. }
  4533. */
  4534. nom = tr.childNodes[1].textContent+phymag;
  4535. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  4536. nom = 'pasdedecumul';
  4537.  
  4538. uniListe[nb] = {
  4539. 'duree':duree,
  4540. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  4541. 'caracs':{}
  4542. }
  4543. for(var i=0 ; i<effetsT.length ; i++) {
  4544. if(effetsT[i].indexOf(':')==-1) continue;
  4545. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  4546. // nom = 'pasdedecumul' si pas de décumul
  4547. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  4548. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  4549. uniListe[nb]['type'] = phymag;
  4550. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  4551. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  4552. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  4553. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  4554. uniListe[nb]['caracs'][carac] = bm;
  4555. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  4556. listeDurees[duree] = true;
  4557. }
  4558. } // fin boucle sur les lignes de bonus/malus
  4559.  
  4560. /* Gestion des décumuls et cumuls des durées */
  4561. var toursGeres = [];
  4562. for(var d in listeDurees) toursGeres.push(d);
  4563. toursGeres.sort( function (a,b){return b-a;} );
  4564. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  4565. // pour sauvegarder les bm de fatigue
  4566. var strfat = '';
  4567. // Pour affichage & adpatation à footable.js (statique)
  4568. var thead = document.getElementsByTagName('thead')[0];
  4569. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  4570. thead, null, 7, null).snapshotLength;
  4571. var tfoot = document.getElementsByTagName('tfoot')[0];
  4572.  
  4573. for(var i=0 ; i<toursGeres.length ; i++) {
  4574. var tour = toursGeres[i];
  4575. var effetsCeTour = {}; decumulsCeTour = {};
  4576. for(var nb=1 ; nb<uniListe.length ; nb++) {
  4577. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  4578. continue;
  4579. var nom = uniListe[nb]['nom'];
  4580. if(nom!='pasdedecumul') {
  4581. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  4582. decumulsCeTour[nom]++;
  4583. }
  4584. for(var carac in uniListe[nb]['caracs']) {
  4585. var bm = uniListe[nb]['caracs'][carac];
  4586. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  4587. var type = uniListe[nb]['type'];
  4588. if(!effetsCeTour[carac])
  4589. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  4590. var thisBm;
  4591. if(nom=='pasdedecumul')
  4592. thisBm = bm;
  4593. else
  4594. thisBm = decumul(bm,decumulsCeTour[nom]);
  4595. effetsCeTour[carac][type] += thisBm;
  4596. 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]);
  4597. } else {
  4598. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  4599. var thisBm;
  4600. if(nom=='pasdedecumul' || carac=='Fatigue')
  4601. thisBm = bm;
  4602. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  4603. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  4604. else
  4605. thisBm = decumul(bm,decumulsCeTour[nom]);
  4606. effetsCeTour[carac] += thisBm;
  4607. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  4608. }
  4609. } // fin boucle sur les caractéristiques
  4610. } // fin boucle sur les bonus/malus
  4611.  
  4612. /* Création du bilan du tour */
  4613. var texteD = '', texteS = '';
  4614. var caracGerees = [];
  4615. for(var k in effetsCeTour) caracGerees.push(k);
  4616. caracGerees.sort( triecaracs );
  4617.  
  4618. for(var j=0 ; j<caracGerees.length ; j++) {
  4619. var carac = caracGerees[j], str = '';
  4620. if (MY_DEBUG) window.console.log('MZ traiteMalus, j=' + j + ', carac=' + carac + ', effetsCeTour=' + effetsCeTour[carac] + ', toursGeres=' + toursGeres[i]);
  4621.  
  4622. switch( carac ) {
  4623. case 'ATT':
  4624. case 'DEG':
  4625. case 'Armure':
  4626. var phy = effetsCeTour[carac]['Physique'];
  4627. var mag = effetsCeTour[carac]['Magie'];
  4628. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  4629. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  4630. break;
  4631. case 'TOUR':
  4632. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  4633. break;
  4634. case 'Fatigue':
  4635. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  4636. case 'PV':
  4637. case 'ESQ':
  4638. case 'REG':
  4639. case 'Vue':
  4640. case 'Voir le Caché':
  4641. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  4642. break;
  4643. default:
  4644. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  4645. }
  4646. if(str) {
  4647. texteD += str;
  4648. texteS += str;
  4649. }
  4650. if (MY_DEBUG) window.console.log('MZ traiteMalus, j=' + j + ', strfat=' + strfat);
  4651. } // fin boucle sur les caractéristiques
  4652.  
  4653. /* Affichage */
  4654. // Si rien à afficher on passe
  4655. if(!texteD) continue;
  4656. // Si BMM+BMP=0
  4657. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  4658. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  4659. if(MY_getValue('BMDETAIL')=='false')
  4660. tr.style.display = 'none';
  4661. var td = appendTdText(tr,texteD.substring(3));
  4662. td.colSpan = 5-nbHidden;
  4663. var txttour = toursGeres[i]+' Tour';
  4664. if(toursGeres[i]>1) txttour += 's';
  4665. appendTdText(tr,txttour);
  4666.  
  4667. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  4668. if(MY_getValue('BMDETAIL')!='false')
  4669. tr.style.display = 'none';
  4670. td = appendTdText(tr,texteS);
  4671. td.colSpan = 5-nbHidden;
  4672. appendTdText(tr,txttour);
  4673. } // fin boucle sur les tours générés
  4674.  
  4675. /* mise en place toggleDetails */
  4676. tfoot.style.cursor = 'pointer';
  4677. tfoot.onclick = toggleDetailsBM;
  4678.  
  4679. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4680. if(strfat)
  4681. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4682. }
  4683.  
  4684. function do_malus() {
  4685. try {
  4686. start_script();
  4687. traiteMalus();
  4688. setDisplayBM();
  4689. displayScriptTime();
  4690. }
  4691. catch(e) {window.alert(e)};
  4692. }
  4693.  
  4694. /*******************************************************************************
  4695. * This file is part of Mountyzilla. *
  4696. * *
  4697. * Mountyzilla is free software; you can redistribute it and/or modify *
  4698. * it under the terms of the GNU General Public License as published by *
  4699. * the Free Software Foundation; either version 2 of the License, or *
  4700. * (at your option) any later version. *
  4701. * *
  4702. * Mountyzilla is distributed in the hope that it will be useful, *
  4703. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4704. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4705. * GNU General Public License for more details. *
  4706. * *
  4707. * You should have received a copy of the GNU General Public License *
  4708. * along with Mountyzilla; if not, write to the Free Software *
  4709. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4710. *******************************************************************************/
  4711.  
  4712. // x~x mouches
  4713.  
  4714. var mainTab, tr_mouches;
  4715.  
  4716. function initialiseMouches() {
  4717. // Lanceur global
  4718. try {
  4719. mainTab = document.getElementById('mouches');
  4720. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4721. } catch(e) {
  4722. avertissement('Erreur MZ:<br />Consulter la console.');
  4723. window.console.error(traceStack(e, 'mouches'));
  4724. return;
  4725. }
  4726. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4727.  
  4728. setDisplayMouches();
  4729. traiteMouches();
  4730. }
  4731.  
  4732. function setDisplayMouches() {
  4733. // Initialise l'affichage / l'effacement du détail des mouches
  4734. var titre = document.getElementById('titre2');
  4735. if(titre) {
  4736. titre.style.cursor = 'pointer';
  4737. titre.onclick = toggleMouches;
  4738. }
  4739.  
  4740. var tfoot = document.getElementsByTagName('tfoot')[0];
  4741. if(tfoot) {
  4742. tfoot.style.cursor = 'pointer';
  4743. tfoot.onclick = toggleMouches;
  4744. }
  4745.  
  4746. if(MY_getValue('HIDEMOUCHES')=='true') {
  4747. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4748. tr_mouches.snapshotItem(i).style.display = 'none';
  4749. }
  4750. document.getElementsByTagName('thead')[0].style.display = 'none';
  4751. }
  4752. }
  4753.  
  4754. function toggleMouches() {
  4755. // Handler pour afficher / masquer les détasil
  4756. if(MY_getValue('HIDEMOUCHES')=='true') {
  4757. MY_setValue('HIDEMOUCHES','false');
  4758. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4759. tr_mouches.snapshotItem(i).style.display = '';
  4760. }
  4761. document.getElementsByTagName('thead')[0].style.display = '';
  4762. } else {
  4763. MY_setValue('HIDEMOUCHES','true');
  4764. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4765. tr_mouches.snapshotItem(i).style.display = 'none';
  4766. }
  4767. document.getElementsByTagName('thead')[0].style.display = 'none';
  4768. }
  4769. }
  4770.  
  4771. function traiteMouches() {
  4772. // Traitement complet: présence et effets des mouches
  4773. var listeTypes = {}, effetsActifs = {};
  4774.  
  4775. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4776. var tr = tr_mouches.snapshotItem(i);
  4777.  
  4778. // La mouche est-elle présente?
  4779. var etat = document.evaluate(
  4780. './img',
  4781. tr.cells[6], null, 9, null
  4782. ).singleNodeValue.alt;
  4783. if(etat!='La Mouche est là') { continue; }
  4784. // Extraction du type de mouche
  4785. var type = trim(tr.cells[3].textContent);
  4786. if(!listeTypes[type]) {
  4787. listeTypes[type] = 1;
  4788. } else {
  4789. listeTypes[type]++;
  4790. }
  4791.  
  4792. // La mouche a-t-elle un effet?
  4793. var effet = trim(tr.cells[2].textContent);
  4794. if(etat!='La Mouche est là' || !effet) { continue; }
  4795. // Si oui, extraction des effets (multiples pour pogées)
  4796. var caracs = effet.split(' | ');
  4797. for(var j=0 ; j<caracs.length ; j++) {
  4798. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4799. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4800. if(effetsActifs[carac]===void(0)) {
  4801. effetsActifs[carac] = valeur;
  4802. } else {
  4803. effetsActifs[carac] += valeur;
  4804. }
  4805. }
  4806. }
  4807.  
  4808. // Extraction Effet total et affichage des différences à la normale
  4809. var tfoot = document.getElementsByTagName('tfoot')[0];
  4810. if(!tfoot) { return; }
  4811. var nodeTotal = document.evaluate(
  4812. ".//b[contains(./text(),'Effet total')]",
  4813. tfoot, null, 9, null
  4814. ).singleNodeValue.nextSibling;
  4815. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4816. var texte = ' ';
  4817. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4818. if(texte.length>1) { texte += ' | '; }
  4819. var carac = trim(
  4820. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4821. );
  4822. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4823. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4824. texte += effetsTheoriques[i];
  4825. } else {
  4826. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4827. if(carac=='TOUR') { texte += ' min'; }
  4828. texte += '</b>';
  4829. }
  4830. }
  4831. var span = document.createElement('span');
  4832. span.innerHTML = texte;
  4833. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4834.  
  4835. // Affichage des différences du nombre de mouches de chaque type
  4836. var mouchesParType = document.evaluate(
  4837. "./tr/td/ul/li/text()",
  4838. tfoot, null, 7, null
  4839. );
  4840. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4841. var node = mouchesParType.snapshotItem(i);
  4842. var mots = node.nodeValue.split(' ');
  4843. var type = mots.pop();
  4844. if(!listeTypes[type]) {
  4845. node.nodeValue += ' (0 présente)';
  4846. } else if(mots[0]!=listeTypes[type]) {
  4847. if(listeTypes[type]==1) {
  4848. node.nodeValue += ' (1 présente)';
  4849. } else {
  4850. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4851. }
  4852. }
  4853. }
  4854. }
  4855.  
  4856. function do_mouches() {
  4857. start_script();
  4858. initialiseMouches();
  4859. displayScriptTime();
  4860. }
  4861.  
  4862. /*********************************************************************************
  4863. * This file is part of Mountyzilla. *
  4864. * *
  4865. * Mountyzilla is free software; you can redistribute it and/or modify *
  4866. * it under the terms of the GNU General Public License as published by *
  4867. * the Free Software Foundation; either version 2 of the License, or *
  4868. * (at your option) any later version. *
  4869. * *
  4870. * Mountyzilla is distributed in the hope that it will be useful, *
  4871. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4872. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4873. * GNU General Public License for more details. *
  4874. * *
  4875. * You should have received a copy of the GNU General Public License *
  4876. * along with Mountyzilla; if not, write to the Free Software *
  4877. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4878. *********************************************************************************/
  4879.  
  4880. // x~x equipgowap
  4881.  
  4882. var popup;
  4883.  
  4884. function initPopupEquipgowap() {
  4885. popup = document.createElement('div');
  4886. popup.setAttribute('id', 'popup');
  4887. popup.setAttribute('class', 'mh_textbox');
  4888. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4889. 'display: inline; z-index: 3; max-width: 400px;');
  4890. document.body.appendChild(popup);
  4891. }
  4892.  
  4893. function showPopupEquipgowap(evt) {
  4894. var texte = this.getAttribute("texteinfo");
  4895. popup.innerHTML = texte;
  4896. popup.style.left = evt.pageX + 15 + 'px';
  4897. popup.style.top = evt.pageY + 'px';
  4898. popup.style.visibility = "visible";
  4899. }
  4900.  
  4901. function hidePopup() {
  4902. popup.style.visibility = "hidden";
  4903. }
  4904.  
  4905. function createPopupImage(url, text)
  4906. {
  4907. var img = document.createElement('img');
  4908. img.setAttribute('src',url);
  4909. img.setAttribute('align','ABSMIDDLE');
  4910. img.setAttribute("texteinfo",text);
  4911. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4912. img.addEventListener("mouseout", hidePopup,true);
  4913. return img;
  4914. }
  4915.  
  4916. function formateTexte(texte)
  4917. {
  4918. texte = texte.replace(/\n/g,"<br/>");
  4919. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4920. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4921. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4922. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4923. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4924. return texte;
  4925. }
  4926.  
  4927.  
  4928. function treateGowaps() {
  4929. //On récupère les gowaps possédants des composants
  4930. var tbodys = document.evaluate(
  4931. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4932. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4933. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4934. var tbody = tbodys.snapshotItem(j);
  4935. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4936. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4937. if(MY_getValue("NOINFOEM") != "true")
  4938. insertEMInfos(tbody);
  4939. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4940. insertEnchantInfos(tbody);
  4941. }
  4942. }
  4943.  
  4944. function treateChampi() {
  4945. if(MY_getValue("NOINFOEM") == "true")
  4946. return false;
  4947. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4948. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4949. if (nodes.snapshotLength == 0)
  4950. return false;
  4951.  
  4952. for (var i = 0; i < nodes.snapshotLength; i++) {
  4953. var node = nodes.snapshotItem(i);
  4954. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4955. if(texte.indexOf("*")!=-1)
  4956. texte = texte.substring(0,texte.lastIndexOf(" "));
  4957. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4958. if(moisChampi[nomChampi])
  4959. {
  4960. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4961. }
  4962.  
  4963. }
  4964. }
  4965.  
  4966. function do_equipgowap() {
  4967. start_script();
  4968.  
  4969. treateGowaps();
  4970. treateChampi();
  4971. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4972. {
  4973. initPopupEquipgowap();
  4974. computeEnchantementEquipement(createPopupImage,formateTexte);
  4975. }
  4976.  
  4977. displayScriptTime();
  4978. }
  4979.  
  4980. /*********************************************************************************
  4981. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4982. *********************************************************************************/
  4983.  
  4984. // x~x ordresgowap
  4985.  
  4986. var MZ_analyse_page_ordre_suivant;
  4987. if (MZ_analyse_page_ordre_suivant === undefined && isPage("MH_Follower/FO_Ordres")) {
  4988. // Roule 07/10/2019
  4989. // Fonction réutilisée dans MZ, dans Trajet_canvas et dans une extension perso ☺
  4990. // rend un object, par exemple
  4991. var MZ_analyse_page_ordre_suivant = {
  4992. 'result': {ordres: []},
  4993. 'init': function() {
  4994. // façon blindée de tester la variable MY_DEBUG
  4995. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('start MZ_analyse_page_ordre_suivant.init');
  4996. try {
  4997. var eTitle = document.getElementById('titre2');
  4998. // au 07/10/2019, on peut se baser sur les <tr> de l'élément HTML parent 'titre2'
  4999. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('eTitle.nextSibling=' + eTitle.parentNode);
  5000. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  5001. for(var i=0 ; i<lignes.length ; i++) {
  5002. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + ' className=' + lignes[i].className);
  5003. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + lignes[i].innerHTML);
  5004. if(lignes[i].className == 'mh_tdtitre_fo') {
  5005. var tds = lignes[i].getElementsByTagName('div');
  5006. for (var j=0; j < tds.length; j++) {
  5007. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant div ' + j + ' ' + tds[j].innerText);
  5008. var tabmatch = tds[j].innerText.match(/(\d+) *\.* *(.*\[.*\].*)$/);
  5009. if (tabmatch) {
  5010. // ID, Nom
  5011. this.result.id = tabmatch[1].trim();
  5012. this.result.nom = tabmatch[2].trim();
  5013. }
  5014. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-?\d+).*Y = (-?\d+).*N = (-?\d+)/i);
  5015. if (tabmatch) {
  5016. // PA, x, y, n
  5017. this.result.PA = parseInt(tabmatch[1]);
  5018. this.result.x = parseInt(tabmatch[2]);
  5019. this.result.y = parseInt(tabmatch[3]);
  5020. this.result.n = parseInt(tabmatch[4]);
  5021. // Trajet_canvas a besoin d'un pointeur vers cette div
  5022. this.result.eltPos = tds[j];
  5023. }
  5024. }
  5025. }
  5026. if(lignes[i].className == 'mh_tdpage_fo') {
  5027. var etd = lignes[i].getElementsByTagName('td')[0];
  5028. if (etd !== undefined) { // undefined dans le cas des Golems
  5029. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant td[0]=' + etd.textContent);
  5030. var tabmatch = etd.textContent.match(/^(.*)X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  5031. if (tabmatch) {
  5032. this.result.ordres.push({ordre: tabmatch[1].trim(), x: parseInt(tabmatch[2]), y: parseInt(tabmatch[3]), n: parseInt(tabmatch[4])});
  5033. } else {
  5034. this.result.ordres.push({ordre: etd.textContent.trim()});
  5035. }
  5036. }
  5037. }
  5038. }
  5039. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('fin MZ_analyse_page_ordre_suivant ' + JSON.stringify(this.result));
  5040. } catch(e) {
  5041. window.console.log('Exception dans MZ_analyse_page_ordre_suivant.init ' + e);
  5042. }
  5043. }
  5044. }
  5045. MZ_analyse_page_ordre_suivant.init();
  5046. }
  5047.  
  5048. // version Roule' janvier 2017
  5049. function MZ_setCarteUnGogoHTML5() {
  5050. // fabriquer la liste des positions successives
  5051. var listeDepl = []; // ce sera un tableau d'objets
  5052. listeDepl = MZ_analyse_page_ordre_suivant.result.ordres.slice(0); // clone array
  5053. 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
  5054.  
  5055. /* à supprimer, remplacé par MZ_analyse_page_ordre_suivant
  5056. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  5057. , y: parseInt(tabPos[3])
  5058. , n: parseInt(tabPos[4])
  5059. , nom: tabNomID[2]
  5060. , id: tabNomID[1]});
  5061.  
  5062. // position courante
  5063. var eTitle = document.getElementById('titre2');
  5064. // déplacements
  5065. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  5066. for(var i=0 ; i<lignes.length ; i++) {
  5067. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + ' className=' + lignes[i].className);
  5068. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + lignes[i].innerHTML);
  5069. if(lignes[i].className == 'mh_tdtitre_fo') {
  5070. var tds = lignes[i].getElementsByTagName('div');
  5071. for (var j=0; j < tds.length; j++) {
  5072. tabmatch = tds[j].innerText.match(/(\d+) *(.*\[.*\].*)$/);
  5073. if (tabmatch) var tabNomID = tabmatch;
  5074. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-.\d+).*Y = (-.\d+).*N = (-.\d+)/i);
  5075. if (tabmatch) var tabPos = tabmatch;
  5076. }
  5077. if (tabPos != undefined && tabNomID != undefined) { // null dans le cas des Golems
  5078. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  5079. , y: parseInt(tabPos[3])
  5080. , n: parseInt(tabPos[4])
  5081. , nom: tabNomID[2]
  5082. , id: tabNomID[1]});
  5083. } else {
  5084. return;
  5085. }
  5086. }
  5087. if(lignes[i].className == 'mh_tdpage_fo') {
  5088. var etd = lignes[i].getElementsByTagName('td')[0];
  5089. if (etd === undefined) return; // cas des Golems
  5090. var point = etd.firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  5091. if (point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  5092. }
  5093. }
  5094. */
  5095. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  5096. }
  5097.  
  5098. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  5099. function MZ_showCarteBottom(listeSuiv) {
  5100. // générer la carte
  5101. var carte = new carte_MZ('cartegogo', listeSuiv);
  5102. // positionner la carte
  5103. var eCarte = carte.getElt();
  5104. eCarte.style.textAlign = 'left';
  5105. eCarte.style.marginTop = '2px';
  5106. var footer = document.getElementById('footer1');
  5107. // Lieu_Teleport.php n'a pas de footer1 :(
  5108. if (!footer) footer = document.getElementById('footer2');
  5109. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  5110. else document.body.appendChild(eCarte);
  5111. }
  5112.  
  5113. function MZ_setCarteTousGogoHTML5() {
  5114. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  5115. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  5116. var suivants = [];
  5117. for (var i=0;i<ligne.length;i++) {
  5118. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  5119. var cas = ligne[i].getElementsByTagName("td")[0];
  5120. //if (cas.className == "mh_tdtitre") {
  5121. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  5122. var oGogo = {};
  5123. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  5124. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  5125. var point = cas.innerHTML.match(/X[ \n\r]+=[ \n\r]+(-?\d+)[ \n\r]+\|[ \n\r]+Y[ \n\r]+=[ \n\r]+(-?\d+)[ \n\r]+\|[ \n\r]+N =[ \n\r]+(-?\d+)/); // Roule 21/01/2020 des espaces multiples et un saut de ligne sont apparus entre "Y" et "="
  5126. oGogo.x = parseInt(point[1]);
  5127. oGogo.y = parseInt(point[2]);
  5128. oGogo.n = parseInt(point[3]);
  5129. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  5130. }
  5131. }
  5132. if (suivants.length == 0) return;
  5133. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  5134. }
  5135.  
  5136. function MZ_setCarteTP() {
  5137. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  5138. 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);
  5139. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  5140. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  5141. }
  5142.  
  5143. function testeGlissiere() {
  5144. try {
  5145. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  5146. var footer = document.getElementById('footer1');
  5147. footer.parentNode.insertBefore(gliss.getElt(), footer);
  5148. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  5149. }
  5150.  
  5151. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  5152. if (x0 !== undefined) {
  5153. // ouais, récursif une fois
  5154. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  5155. if (PtInterm === undefined)
  5156. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  5157. else
  5158. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  5159. return;
  5160. }
  5161. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  5162. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  5163. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  5164. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  5165. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  5166. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  5167. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  5168. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  5169. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  5170. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  5171. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  5172. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  5173. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  5174. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  5175. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  5176. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  5177. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  5178. }
  5179.  
  5180. function do_ordresgowap() {
  5181. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  5182. //testeGlissiere();
  5183. //MZ_testsUnitairesCalculIntermediaire();
  5184. }
  5185.  
  5186. function do_listegowap() {
  5187. if (!newCarte) return;
  5188. MZ_setCarteTousGogoHTML5();
  5189. }
  5190.  
  5191. function do_lieuDescription() {
  5192. if (!newCarte) return;
  5193. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  5194. MZ_setCarteTP();
  5195. }
  5196.  
  5197. function do_lieuTeleport() {
  5198. changeButtonValidate();
  5199. if (!newCarte) return;
  5200. MZ_setCarteTP();
  5201. }
  5202.  
  5203. /*******************************************************************************
  5204. * This file is part of Mountyzilla. *
  5205. * *
  5206. * Mountyzilla is free software; you can redistribute it and/or modify *
  5207. * it under the terms of the GNU General Public License as published by *
  5208. * the Free Software Foundation; either version 2 of the License, or *
  5209. * (at your option) any later version. *
  5210. * *
  5211. * Mountyzilla is distributed in the hope that it will be useful, *
  5212. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5213. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5214. * GNU General Public License for more details. *
  5215. * *
  5216. * You should have received a copy of the GNU General Public License *
  5217. * along with Mountyzilla; if not, write to the Free Software *
  5218. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5219. *******************************************************************************/
  5220.  
  5221. // x~x infomonstre
  5222.  
  5223. // DEBUG
  5224. var nomMonstre='';
  5225. var idMonstre=-1;
  5226. //var tbody;
  5227. // var popup; // NOTE Linter : already defined
  5228.  
  5229. function traiteMonstre() {
  5230. try {
  5231. var nodeTitre = document.evaluate(
  5232. "//div[@class='titre2' and contains(text(),'(')]",
  5233. document, null, 9, null
  5234. ).singleNodeValue;
  5235. var texte = nodeTitre.firstChild.nodeValue;
  5236. } catch(e) {
  5237. window.console.log(traceStack(e, 'traiteMonstre'));
  5238. return;
  5239. }
  5240.  
  5241. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  5242. if(nomMonstre.indexOf(']')!=-1) {
  5243. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  5244. }
  5245. idMonstre = texte.match(/\d+/)[0];
  5246. var tReq = [{'index':1, 'id':+idMonstre, 'nom':nomMonstre}]; // "+" pour forcer du numérique
  5247. FF_XMLHttpRequest({
  5248. method: 'POST',
  5249. url: URL_MZgetCaracMonstre,
  5250. headers : {
  5251. 'Content-type':'application/x-www-form-urlencoded'
  5252. },
  5253. data: 'l=' + JSON.stringify(tReq),
  5254. trace: 'demande niveaux monstres V2, MonsterView',
  5255. onload: function(responseDetails) {
  5256. try {
  5257. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  5258. if (responseDetails.status == 0) return;
  5259. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  5260. var texte = responseDetails.responseText;
  5261. var infosRet = JSON.parse(texte);
  5262. if(infosRet.length==0) return;
  5263. var info = infosRet[0];
  5264. // QUESTION Quelle est l'utilité de ceci?
  5265. // Roule 19/01/2020 Il doit y avoir un endroit "au fond du trou" où le code va chercher les infos à partir de l'ID. Est-ce que c'est propre ? : non
  5266. MZ_EtatCdMs.listeCDM[idMonstre] = info;
  5267. try {
  5268. var nodeInsert = document.evaluate(
  5269. "//div[@class = 'titre3']",
  5270. document, null, 9, null
  5271. ).singleNodeValue;
  5272. } catch(e) {
  5273. window.console.log(traceStack(e, 'recherche node pour info CdM'));
  5274. return;
  5275. }
  5276. var table = createCDMTable(idMonstre,nomMonstre,info);
  5277. table.align = 'center';
  5278. var tbody = table.childNodes[1];
  5279. var thead = table.childNodes[0];
  5280. var tdEntete = thead.firstChild.firstChild;
  5281. tdEntete.onclick = toggleTableau;
  5282. tdEntete.style.cursor = 'pointer';
  5283. thead.firstChild.style = 'mh_tdpage';
  5284. tbody.style.display = 'none';
  5285. table.style.width = '350px';
  5286. insertBefore(nodeInsert,table);
  5287. } catch(e) {
  5288. window.console.log(e);
  5289. }
  5290. },
  5291. });
  5292. }
  5293.  
  5294. function toggleTableau() { // click sur un td de thead
  5295. var tbody = this.parentNode.parentNode.parentNode.childNodes[1];
  5296. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  5297. }
  5298.  
  5299. function do_infomonstre() {
  5300. start_script();
  5301. try {
  5302. MZ_Tactique.initPopup();
  5303. traiteMonstre();
  5304. } catch(e) {
  5305. window.console.error(traceStack(e, 'do_infomonstre'));
  5306. window.alert('Erreur infoMonstre:\n'+e);
  5307. }
  5308. displayScriptTime();
  5309. }
  5310.  
  5311. /***
  5312. *** SCIZ
  5313. ***/
  5314.  
  5315. const scizSetup = {
  5316. // Maximum interval (seconds) for matching some events
  5317. eventsMaxMatchingInterval: 5000,
  5318. // Maximum number of treasures to enhanced in the view
  5319. viewMaxEnhancedTreasure: 100
  5320. };
  5321.  
  5322. var scizGlobal = {
  5323. events: [],
  5324. trolls: [],
  5325. treasures: []
  5326. };
  5327.  
  5328. function scizAddCSS() {
  5329. // SCIZ style
  5330. var scizStyle = `
  5331. .sciz-progress-bar-wrapper {
  5332. width: 100px;
  5333. text-align: center;
  5334. display: inline-block;
  5335. }
  5336. .sciz-progress-bar {
  5337. width: 100%;
  5338. background-color: #e0e0e0;
  5339. padding: 1px;
  5340. border-radius: 1px;
  5341. box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2);
  5342. }
  5343. .sciz-progress-bar-fill {
  5344. display: block;
  5345. height: 5px;
  5346. border-radius: 1px;
  5347. transition: width 500ms ease-in-out;
  5348. }
  5349. `;
  5350. // Actually add the SCIZ style
  5351. var scizStyleSheet = document.createElement('style');
  5352. scizStyleSheet.type = 'text/css';
  5353. if (scizStyleSheet.styleSheet) {
  5354. scizStyleSheet.styleSheet.cssText = scizStyle;
  5355. } else {
  5356. scizStyleSheet.appendChild(document.createTextNode(scizStyle));
  5357. }
  5358. document.getElementsByTagName('head')[0].appendChild(scizStyleSheet);
  5359. }
  5360.  
  5361. function scizCreateClickable(height, display, callbackOnClick) {
  5362. var img = document.createElement('img');
  5363. img.src = 'https://www.sciz.fr/static/sciz-logo-quarter.png';
  5364. img.alt = 'SCIZ logo';
  5365. img.style = 'height: ' + height + 'px; cursor: pointer;';
  5366. img.onclick = callbackOnClick;
  5367. var div = document.createElement('div');
  5368. div.style = 'text-align: center;display: ' + display;
  5369. div.appendChild(img);
  5370. return div;
  5371. };
  5372.  
  5373. function scizCreateIcon(height, display, icon) {
  5374. var img = document.createElement('img');
  5375. img.src = 'https://www.sciz.fr/static/' + icon;
  5376. img.alt = 'SCIZ icon';
  5377. img.style = 'height: ' + height + 'px;';
  5378. var div = document.createElement('div');
  5379. div.style = 'text-align: center;display: ' + display;
  5380. div.appendChild(img);
  5381. return div;
  5382. };
  5383.  
  5384. /* SCIZ - View */
  5385.  
  5386. function scizPrettyPrintTroll(t) {
  5387. var res = '';
  5388. // SCIZ progress bar
  5389. var pbPercent = (t.pdv !== null && t.pdv_max !== null) ? t.pdv / t.pdv_max * 100 : -1;
  5390. var pbColor = (pbPercent === -1) ? '#424242' : ((pbPercent < 40) ? '#ff5252' : ((pbPercent < 80) ? '#fb8c00' : '#4caf50'));
  5391. t.pdv_max = (t.pdv_max === null) ? '?' : t.pdv_max;
  5392. res = '<div class="sciz-progress-bar-wrapper">' + t.pdv + ' / ' + t.pdv_max + '<div class="sciz-progress-bar"><span class="sciz-progress-bar-fill" style="background-color: ' + pbColor + ';;width: ' + pbPercent + '%;"></span></div></div>';
  5393. // SCIZ other view enhancement...
  5394. return res;
  5395. }
  5396.  
  5397. function scizPrettyPrintTreasure(t) {
  5398. var res = '';
  5399. res += /* t.type + ' - ' + */ t.nom;
  5400. if (t.templates) { res += ' <b>' + t.templates + '</b>' };
  5401. if (t.mithril) { res += ' <b>en Mithril</b>' };
  5402. if (t.effet) { res += ' (' + t.effet + ')' };
  5403. return res;
  5404. }
  5405.  
  5406. function do_scizEnhanceView() {
  5407. scizGlobal.treasures = [];
  5408.  
  5409. // Ensure we have a JWT setup for the current user
  5410. jwt = MY_getValue(numTroll + '.SCIZJWT');
  5411. if (!jwt) { return; }
  5412.  
  5413. scizAddCSS();
  5414.  
  5415. /* SCIZ View - TROLLS */
  5416. cbx = MY_getValue(numTroll + '.SCIZ_CB_VIEW_TROLLS');
  5417. if (cbx !== '0') {
  5418. // Retrieve trolls
  5419. var ids = [];
  5420. const xPathTrollQuery = "//*/table[@id='VueTROLL']/tbody/tr";
  5421. var xPathTrolls = document.evaluate(xPathTrollQuery, document, null, 0, null);
  5422. while (xPathTroll = xPathTrolls.iterateNext()) {
  5423. scizGlobal.trolls.push({
  5424. 'id': parseInt(xPathTroll.children[2].innerHTML),
  5425. 'name': xPathTroll.children[3].innerHTML,
  5426. 'sciz_desc': null,
  5427. 'node': xPathTroll,
  5428. });
  5429. ids.push(xPathTroll.children[2].innerHTML);
  5430. }
  5431.  
  5432. // Add the new column for the SCIZ troll view
  5433. const xPathHeaderTrollQuery = "//*/table[@id='VueTROLL']/thead/tr";
  5434. var xPathHeaderTrolls = document.evaluate(xPathHeaderTrollQuery, document, null, 0, null).iterateNext();
  5435. var th = document.createElement('th');
  5436. th.align = 'center';
  5437. th.appendChild(scizCreateIcon('25', 'block', 'sciz-logo-quarter.png'));
  5438. xPathHeaderTrolls.insertBefore(th, xPathHeaderTrolls.children[4]);
  5439. for (i = 0; i < scizGlobal.trolls.length; i++) {
  5440. var td = document.createElement('td');
  5441. td.align = 'center';
  5442. scizGlobal.trolls[i].node.insertBefore(td, scizGlobal.trolls[i].node.children[4]);
  5443. }
  5444.  
  5445. // Call SCIZ
  5446. var sciz_url = 'https://www.sciz.fr/api/hook/trolls';
  5447. FF_XMLHttpRequest({
  5448. method: 'POST',
  5449. url: sciz_url,
  5450. headers: { 'Authorization': jwt, 'Content-type': 'application/json'},
  5451. data: JSON.stringify({'ids': ids}),
  5452. onload: function(responseDetails) {
  5453. try {
  5454. if (responseDetails.status == 0) {
  5455. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5456. window.console.log(responseDetails);
  5457. return;
  5458. }
  5459. var trolls = JSON.parse(responseDetails.responseText);
  5460. if (trolls.trolls.length < 1) {
  5461. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5462. return;
  5463. }
  5464. // Look for trolls to enhanced
  5465. trolls.trolls.forEach(t => {
  5466. for (i = 0; i < scizGlobal.trolls.length; i++) {
  5467. if (scizGlobal.trolls[i].id === t.id) {
  5468. // PrettyPrint
  5469. t = scizPrettyPrintTroll(t);
  5470. // Store the SCIZ troll desc
  5471. scizGlobal.trolls[i].sciz_desc = t;
  5472. // Add the SCIZ view
  5473. scizGlobal.trolls[i].node.children[4].innerHTML = t;
  5474. }
  5475. }
  5476. });
  5477. } catch(e) {
  5478. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5479. window.console.log(e);
  5480. }
  5481. }
  5482. });
  5483. }
  5484.  
  5485. cbx = MY_getValue(numTroll + '.SCIZ_CB_VIEW_TREASURES');
  5486. if (cbx !== '0') {
  5487. // Retrieve treasures
  5488. var ids = [];
  5489. const xPathQuery = "//*/table[@id='VueTRESOR']/tbody/tr";
  5490. var xPathEvents = document.evaluate(xPathQuery, document, null, 0, null);
  5491. while (xPathEvent = xPathEvents.iterateNext()) {
  5492. scizGlobal.treasures.push({
  5493. 'id': parseInt(xPathEvent.children[2].innerHTML),
  5494. 'type': xPathEvent.children[3].innerHTML,
  5495. 'sciz_desc': null,
  5496. 'buried': xPathEvent.children[3].innerHTML.includes('Enterré'),
  5497. 'node': xPathEvent,
  5498. });
  5499. ids.push(xPathEvent.children[2].innerHTML)
  5500. if (scizGlobal.treasures.length >= scizSetup.viewMaxEnhancedTreasure) { break; }
  5501. }
  5502.  
  5503. // Call SCIZ
  5504. var sciz_url = 'https://www.sciz.fr/api/hook/treasures';
  5505. FF_XMLHttpRequest({
  5506. method: 'POST',
  5507. url: sciz_url,
  5508. headers: { 'Authorization': jwt, 'Content-type': 'application/json'},
  5509. data: JSON.stringify({'ids': ids}),
  5510. onload: function(responseDetails) {
  5511. try {
  5512. if (responseDetails.status == 0) {
  5513. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5514. window.console.log(responseDetails);
  5515. return;
  5516. }
  5517. var treasures = JSON.parse(responseDetails.responseText);
  5518. if (treasures.treasures.length < 1) {
  5519. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5520. return;
  5521. }
  5522. // Look for treasures to enhanced
  5523. treasures.treasures.forEach(t => {
  5524. for (i = 0; i < scizGlobal.treasures.length; i++) {
  5525. if (scizGlobal.treasures[i].id === t.id) {
  5526. // PrettyPrint
  5527. t = scizPrettyPrintTreasure(t);
  5528. // Store the SCIZ treasure desc
  5529. scizGlobal.treasures[i].sciz_desc = t;
  5530. // Adapt the sciz type (delete the buried marker, the do_scizSwitchTreasures will handle it)
  5531. scizGlobal.treasures[i].type = scizGlobal.treasures[i].node.children[3].firstChild.textContent;
  5532. }
  5533. }
  5534. });
  5535. } catch(e) {
  5536. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5537. window.console.log(e);
  5538. }
  5539. // Do the display overwrite and add the switches
  5540. do_scizSwitchTreasures();
  5541. }
  5542. });
  5543. }
  5544. }
  5545.  
  5546. function do_scizSwitchTreasures() {
  5547. scizGlobal.treasures.forEach((t) => {
  5548. if (t.sciz_desc !== null) {
  5549. // Do the switch
  5550. const currentDesc = t.node.children[3].firstChild.textContent;
  5551. t.node.children[3].innerHTML = (currentDesc === t.type) ? ((t.sciz_desc !== null) ? t.sciz_desc : t.type) : t.type;
  5552. if (t.buried) {
  5553. t.node.children[3].innerHTML += '<img src="/mountyhall/Images/hidden.png" alt="[Enterré]" title="Enterré" width="15" height="15">';
  5554. }
  5555. // Add the SCIZ switcher
  5556. t.node.children[3].appendChild(scizCreateClickable('15', 'inline', do_scizSwitchTreasures));
  5557. }
  5558. });
  5559. }
  5560.  
  5561. /* SCIZ - Events */
  5562.  
  5563. function scizPrettyPrintEvent(e) {
  5564. 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}/g, ''); // Delete date
  5565. e.message = e.message.replace(/\n\s*\n*/g, '<br/>');
  5566. 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]];
  5567. beings.forEach(b => {
  5568. if (b[0] && b[1]) {
  5569. b[1] = b[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  5570. if (b[0].toString().length > 6) {
  5571. // Mob
  5572. b[1] = b[1].replace(/^une?\s/g, '');
  5573. 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>');
  5574. } else {
  5575. // Troll
  5576. e.message = e.message.replace(new RegExp('(' + b[1] + ')','gi'), '<b><a href="javascript:EPV(\'' + b[0] + '\')" class="mh_trolls_1">\$1</a></b>');
  5577. }
  5578. }
  5579. });
  5580. return e;
  5581. }
  5582.  
  5583. function do_scizOverwriteEvents() {
  5584. scizGlobal.events = [];
  5585. var eventTableNode = null;
  5586.  
  5587. // Ensure we have a JWT setup for the current user
  5588. jwt = MY_getValue(numTroll + '.SCIZJWT');
  5589. cbx = MY_getValue(numTroll + '.SCIZ_CB_EVENTS');
  5590. if (!jwt || cbx === '0') { return; }
  5591.  
  5592. // Retrieve being ID
  5593. const url = new URL(window.location.href);
  5594. var id = url.searchParams.get('ai_IDPJ');
  5595. id = (!id) ? numTroll : id;
  5596.  
  5597. // Check for advanced profil
  5598. const advanced = document.querySelector("[href*='MH_Style_ProfilAvance.css']") !== null;
  5599. const xPathQuery = (advanced) ? "//*/table[@id='events']/tbody/tr" : "//*/tr[@class='mh_tdpage']";
  5600.  
  5601. // Retrieve local events
  5602. var xPathEvents = document.evaluate(xPathQuery, document, null, 0, null);
  5603. while (xPathEvent = xPathEvents.iterateNext()) {
  5604. scizGlobal.events.push({
  5605. 'time': Date.parse(StringToDate(xPathEvent.children[0].innerHTML)),
  5606. 'type': xPathEvent.children[1].innerHTML,
  5607. 'desc': xPathEvent.children[2].innerHTML,
  5608. 'sciz_type': null,
  5609. 'sciz_desc': null,
  5610. 'node': xPathEvent,
  5611. });
  5612. if (eventTableNode === null) {
  5613. eventTableNode = xPathEvent.parentNode.parentNode;
  5614. }
  5615. }
  5616.  
  5617. const startTime = Math.min.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) - scizSetup.eventsMaxMatchingInterval;
  5618. const endTime = Math.max.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) + scizSetup.eventsMaxMatchingInterval;
  5619.  
  5620. // Check if events have been found in the page
  5621. if (scizGlobal.events.length < 1) {
  5622. window.console.log('ERREUR - MZ/SCIZ - Aucun événement trouvé sur la page...');
  5623. return;
  5624. }
  5625.  
  5626. // Call SCIZ
  5627. var sciz_url = 'https://www.sciz.fr/api/hook/events/' + id + '/' + startTime + '/' + endTime;
  5628. const eventType = url.searchParams.get('as_EventType'); // Retrieve event type filter
  5629. sciz_url += (eventType !== null && eventType !== '') ? '/' + eventType.split(' ')[0] : '' // Only the first word used for filtering ("MORT par monstre" => "MORT");
  5630. FF_XMLHttpRequest({
  5631. method: 'GET',
  5632. url: sciz_url,
  5633. headers: { 'Authorization': jwt },
  5634. // trace: 'Appel à SCIZ pour l'entité ' + id,
  5635. onload: function(responseDetails) {
  5636. try {
  5637. if (responseDetails.status == 0) {
  5638. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5639. window.console.log(responseDetails);
  5640. return;
  5641. }
  5642. var events = JSON.parse(responseDetails.responseText);
  5643. if (events.events.length < 1) {
  5644. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5645. return;
  5646. }
  5647. // Look for events to overwrite (based on timestamps)
  5648. events.events.forEach(e => {
  5649. if (e.message.includes(id)) { // Exclude any event we were not looking for...
  5650. const t = Date.parse(StringToDate(e.time));
  5651. // Look for the best event matching and not already replaced
  5652. var i = -1;
  5653. var lastDelta = Infinity;
  5654. for (j = 0; j < scizGlobal.events.length; j++) {
  5655. if (scizGlobal.events[j].sciz_desc === null) {
  5656. var delta = Math.abs(t - scizGlobal.events[j].time);
  5657. if (delta <= scizSetup.eventsMaxMatchingInterval && delta < lastDelta) {
  5658. lastDelta = delta;
  5659. i = j;
  5660. }
  5661. }
  5662. }
  5663. if (i > -1) {
  5664. // PrettyPrint
  5665. e = scizPrettyPrintEvent(e);
  5666. // Store the SCIZ event and icon
  5667. var div = scizCreateIcon('25', 'block', e.icon);
  5668. scizGlobal.events[i].sciz_type = div.outerHTML;
  5669. scizGlobal.events[i].sciz_desc = e.message;
  5670. // Actual display overwrite
  5671. scizGlobal.events[i].node.children[1].setAttribute("valign", "middle");
  5672. scizGlobal.events[i].node.children[2].setAttribute("valign", "middle");
  5673. scizGlobal.events[i].node.children[1].innerHTML = scizGlobal.events[i].sciz_type;
  5674. scizGlobal.events[i].node.children[2].innerHTML = scizGlobal.events[i].sciz_desc;
  5675. }
  5676. }
  5677. });
  5678. // Add the switch button
  5679. if (eventTableNode !== null) {
  5680. var div = scizCreateClickable('50', 'block', do_scizSwitchEvents);
  5681. eventTableNode.parentNode.insertBefore(div, eventTableNode.nextSibling);
  5682. }
  5683. } catch(e) {
  5684. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5685. window.console.log(e);
  5686. }
  5687. }
  5688. });
  5689. }
  5690.  
  5691. function do_scizSwitchEvents() {
  5692. scizGlobal.events.forEach((e) => {
  5693. const currentType = e.node.children[1].innerHTML;
  5694. e.node.children[1].innerHTML = (currentType === e.type) ? ((e.sciz_type !== null) ? e.sciz_type : e.type) : e.type;
  5695. const currentDesc = e.node.children[2].innerHTML;
  5696. e.node.children[2].innerHTML = (currentDesc === e.desc) ? ((e.sciz_desc !== null) ? e.sciz_desc : e.desc) : e.desc;
  5697. });
  5698. }
  5699.  
  5700. /*******************************************************************************
  5701. * This file is part of Mountyzilla. *
  5702. * *
  5703. * Mountyzilla is free software; you can redistribute it and/or modify *
  5704. * it under the terms of the GNU General Public License as published by *
  5705. * the Free Software Foundation; either version 2 of the License, or *
  5706. * (at your option) any later version. *
  5707. * *
  5708. * Mountyzilla is distributed in the hope that it will be useful, *
  5709. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5710. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5711. * GNU General Public License for more details. *
  5712. * *
  5713. * You should have received a copy of the GNU General Public License *
  5714. * along with Mountyzilla; if not, write to the Free Software *
  5715. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5716. *******************************************************************************/
  5717.  
  5718. // x~x mission
  5719.  
  5720. /* TODO
  5721. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  5722. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  5723. *
  5724. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  5725. */
  5726. function isArray(a) {
  5727. return (!!a) && (a.constructor === Array);
  5728. }
  5729.  
  5730. function saveMission(num,obEtape) {
  5731. var obMissions;
  5732. if(MY_getValue(numTroll+'.MISSIONS')) {
  5733. try {
  5734. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5735. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  5736. } catch(e) {
  5737. window.console.error(traceStack(e, 'Mission parsage'));
  5738. return;
  5739. }
  5740. }
  5741. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  5742. if (obMissions == undefined) obMissions = new Object(); // protection
  5743. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  5744. if(obEtape) {
  5745. obMissions[num] = obEtape;
  5746. } else if(obMissions[num]) {
  5747. delete obMissions[num];
  5748. }
  5749. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  5750. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5751. }
  5752.  
  5753. function addtroogle(tdLibelle, sRestrict) {
  5754. var img = document.createElement('img');
  5755. img.src = URL_MZimg + 'troogle.ico';
  5756. img.alt = 'Troogle logo';
  5757. var a = document.createElement('a');
  5758. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  5759. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  5760. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  5761. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  5762. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  5763. a.href = url;
  5764. a.title = 'Chercher sur Troogle';
  5765. a.target = 'troogle';
  5766. a.appendChild(img);
  5767. tdLibelle.appendChild(a);
  5768. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  5769. }
  5770.  
  5771. function traiteMission() {
  5772. try {
  5773. var titreMission = document.getElementsByClassName('titre2')[0];
  5774. var numMission = titreMission.textContent.match(/\d+/)[0];
  5775. var missionForm = document.getElementsByName('ActionForm')[0];
  5776. var tdLibelle = document.evaluate(
  5777. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  5778. missionForm, null, 9, null).singleNodeValue;
  5779. } catch(e) {
  5780. window.console.error(traceStack(e, 'récupération mission'));
  5781. return;
  5782. }
  5783. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  5784. try {
  5785. if(!tdLibelle) {
  5786. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  5787. debugMZ('traiteMission, la mission semble terminée');
  5788. saveMission(numMission,false);
  5789. return;
  5790. }
  5791.  
  5792. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  5793. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  5794. // debug Roule'
  5795. if (MY_DEBUG) {
  5796. for (var i =0; i < tdLibelle.childNodes.length; i++)
  5797. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  5798. }
  5799. if(libelle.indexOf('niveau égal à')!=-1) {
  5800. var nbKills = 1, niveau, mod;
  5801. // exemples :
  5802. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  5803. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  5804. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  5805. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  5806. if (tdLibelle.childNodes.length == 1) {
  5807. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  5808. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  5809. if (m) {
  5810. niveau = Number(m[1]);
  5811. mod = 'plus'
  5812. } else {
  5813. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  5814. if (m) {
  5815. niveau = Number(m[1]);
  5816. mod = Number(m[2]);
  5817. } else {
  5818. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  5819. return;
  5820. }
  5821. }
  5822. } else {
  5823. // ancienne méthode (multi childnode)
  5824. // à supprimer un jour peut-être
  5825. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  5826. // Étape de kill multiple de niveau donné
  5827. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5828. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  5829. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5830. niveau = Number(mod[0]);
  5831. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5832. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  5833. } else {
  5834. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  5835. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5836. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  5837. mod = mod ? Number(mod[0]) : 'plus';
  5838. }
  5839. } else {
  5840. // Étape de kill unique de niveau donné
  5841. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  5842. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5843. mod = mod ? Number(mod[0]) : 'plus';
  5844. }
  5845. }
  5846. // if (isDEV) {
  5847. // niveau = 35; // pour les tests Roule
  5848. // alert('niveau forcé à 35 pour test');
  5849. // }
  5850. // debug Roule'
  5851. if (MY_DEBUG) {
  5852. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  5853. }
  5854. saveMission(numMission,{
  5855. type: 'Niveau',
  5856. niveau: niveau,
  5857. mod: mod,
  5858. mundidey: siMundidey,
  5859. libelle: libelle
  5860. });
  5861. if (mod == 'plus')
  5862. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  5863. else
  5864. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  5865. } else if(libelle.indexOf('de la race')!=-1) {
  5866. var nbKills = 1, race;
  5867. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  5868. // Étape de kill multiple de race donnée
  5869. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5870. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5871. } else {
  5872. // Étape de kill unique de race donnée
  5873. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5874. }
  5875. race = race.replace(/\"/g,'');
  5876. race = removeEnclosingSimpleCote(race); // Roule 29/03/2019 Maintenant, on a des '
  5877. saveMission(numMission,{
  5878. type: 'Race',
  5879. race: race,
  5880. mundidey: siMundidey,
  5881. libelle: libelle
  5882. });
  5883. addtroogle(tdLibelle, '@monstre ' + race);
  5884. } else if(libelle.indexOf('de la famille')!=-1) {
  5885. var nbKills = 1, famille;
  5886. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  5887. // Étape de kill multiple de famille donnée
  5888. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5889. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5890. } else {
  5891. // Étape de kill unique de famille donnée
  5892. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5893. }
  5894. famille = famille.replace(/\"/g,'');
  5895. famille = removeEnclosingSimpleCote(famille); // Roule 29/03/2019 Maintenant, on a des '
  5896. saveMission(numMission,{
  5897. type: 'Famille',
  5898. famille: famille,
  5899. mundidey: siMundidey,
  5900. libelle: libelle
  5901. });
  5902. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  5903. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  5904. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  5905. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  5906. debugMZ('traiteMission étape capacité spéciale');
  5907. pouvoir = removeEnclosingSimpleCote(pouvoir); // Roule 29/03/2019 Maintenant, on a des '
  5908. saveMission(numMission,{
  5909. type: 'Pouvoir',
  5910. pouvoir: pouvoir,
  5911. libelle: libelle
  5912. });
  5913. } else {
  5914. debugMZ('traiteMission étape pas pour troogle');
  5915. saveMission(numMission,false);
  5916. }
  5917. } catch(e) {
  5918. window.console.error(traceStack(e, 'récupération étape mission'));
  5919. return;
  5920. }
  5921. }
  5922.  
  5923. function removeEnclosingSimpleCote(x) { // Roule 29/03/2019
  5924. return x.replace(/'$/, '').replace(/^'/, '');
  5925. }
  5926.  
  5927. function do_mission() {
  5928. start_script(60);
  5929.  
  5930. traiteMission();
  5931.  
  5932. displayScriptTime();
  5933. }
  5934.  
  5935. /*******************************************************************************
  5936. * This file is part of Mountyzilla. *
  5937. * *
  5938. * Mountyzilla is free software; you can redistribute it and/or modify *
  5939. * it under the terms of the GNU General Public License as published by *
  5940. * the Free Software Foundation; either version 2 of the License, or *
  5941. * (at your option) any later version. *
  5942. * *
  5943. * Mountyzilla is distributed in the hope that it will be useful, *
  5944. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5945. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5946. * GNU General Public License for more details. *
  5947. * *
  5948. * You should have received a copy of the GNU General Public License *
  5949. * along with Mountyzilla; if not, write to the Free Software *
  5950. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5951. *******************************************************************************/
  5952.  
  5953. // x~x move
  5954.  
  5955. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  5956.  
  5957. var petitsTrous = {
  5958. '-52;57': true,
  5959. '55;70': true,
  5960. '64;70': true,
  5961. '12;-15': true,
  5962. '30;-52': true,
  5963. '48;-39': true
  5964. };
  5965.  
  5966. var grosTrous = {
  5967. '-35;65': true,
  5968. '-13;73': true,
  5969. '-64;9': true,
  5970. '-35;15': true,
  5971. '5;32': true,
  5972. '10;64': true,
  5973. '21;36': true,
  5974. '46;52': true,
  5975. '74;32': true,
  5976. '-71;-7': true,
  5977. '-67;-37': true,
  5978. '-60;-32': true,
  5979. '-51;-22': true,
  5980. '-36;-51': true,
  5981. '5;-49': true
  5982. };
  5983.  
  5984. var centreCarmine_X = 56.5;
  5985. var centreCarmine_Y = 23.5;
  5986. var rayonCarmine = 8.7;
  5987.  
  5988. function isTrou(x,y,n) {
  5989. if(petitsTrous[x+';'+y]) {
  5990. return n<0 && n>-60;
  5991. }
  5992. if(grosTrous[x+';'+y]
  5993. || grosTrous[x-1+';'+y]
  5994. || grosTrous[x+';'+y+1]
  5995. || grosTrous[x-1+';'+y+1]) {
  5996. return n<0 && n>-70;
  5997. }
  5998. if(Math.sqrt(
  5999. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  6000. )<=rayonCarmine) {
  6001. return n<0 && n>-100;
  6002. }
  6003. return false;
  6004. }
  6005.  
  6006. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  6007.  
  6008. function validateDestination() {
  6009. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  6010. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  6011. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  6012. var form = document.getElementsByName('ActionForm')[0];
  6013. if(form) {
  6014. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  6015. if(document.getElementsByName('ai_DeplX')[i].checked) {
  6016. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  6017. }
  6018. }
  6019. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  6020. if(document.getElementsByName('ai_DeplY')[i].checked) {
  6021. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  6022. }
  6023. }
  6024. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  6025. if(document.getElementsByName('ai_DeplN')[i].checked) {
  6026. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  6027. }
  6028. }
  6029. if(isTrou(x,y,n)) {
  6030. return window.confirm(
  6031. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  6032. +'Vous allez tomber dans un trou de météorite.\n'
  6033. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  6034. );
  6035. }
  6036. }
  6037. return true;
  6038. }
  6039.  
  6040. function newsubmitDE(event) {
  6041. event.stopPropagation();
  6042. event.preventDefault();
  6043. if(validateDestination()) {
  6044. this.submit();
  6045. }
  6046. }
  6047.  
  6048. function changeValidation() {
  6049. var form = document.getElementsByName('ActionForm')[0];
  6050. if(form) {
  6051. form.addEventListener('submit', newsubmitDE, true);
  6052. }
  6053. }
  6054.  
  6055.  
  6056. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  6057.  
  6058. function validateTPDestination() {
  6059. try {
  6060. var text = document.getElementsByTagName('B')[0];
  6061. var a = text.firstChild.nodeValue.split('|');
  6062. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  6063. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  6064. var pos_n = a[2].substring(5, a[2].length) * 1;
  6065.  
  6066. var nbtrous = 0;
  6067. for(var signX=-1 ; signX<=1 ; signX+=2) {
  6068. for(var x=0 ; x<=2 ; x++) {
  6069. for(var signY=-1 ; signY<=1 ; signY+=2) {
  6070. for(var y=0 ; y<=2 ; y++) {
  6071. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  6072. for(var n = 0 ; n <= 1 ; n++) {
  6073. if(isTrou(
  6074. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  6075. )) {
  6076. nbtrous++;
  6077. }
  6078. }
  6079. }
  6080. }
  6081. }
  6082. }
  6083. }
  6084. if(nbtrous>0 && nbtrous<72) {
  6085. return window.confirm(
  6086. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  6087. +'Vous avez '+Math.floor((100*nbtrous)/144)
  6088. +'% de risque de tomber dans un trou de météorite.\n'
  6089. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  6090. );
  6091. }
  6092. else if(nbtrous>=72) {
  6093. return window.confirm(
  6094. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  6095. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  6096. +'% de risque de tomber dans un trou de météorite !\n'
  6097. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  6098. );
  6099. }
  6100. return true;
  6101. }
  6102. catch(e) {
  6103. window.alert(e)
  6104. }
  6105. }
  6106.  
  6107. function newsubmitTP(event) {
  6108. event.stopPropagation();
  6109. event.preventDefault();
  6110. if(validateTPDestination()) {
  6111. this.submit();
  6112. }
  6113. }
  6114.  
  6115. function changeButtonValidate() {
  6116. var form = document.getElementsByName('Formulaire')[0];
  6117. if(form) {
  6118. if(!form.getAttribute('onsubmit')) {
  6119. form.setAttribute('onsubmit','return true;');
  6120. }
  6121. form.addEventListener('submit', newsubmitTP, true);
  6122. }
  6123. }
  6124.  
  6125.  
  6126. /*-[functions]---------------- Partie Principale -----------------------------*/
  6127.  
  6128. function do_move() {
  6129. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  6130. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  6131. changeValidation();
  6132. //}
  6133. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  6134. // changeButtonValidate();
  6135. //}
  6136. }
  6137.  
  6138. /*******************************************************************************
  6139. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  6140. * Mountyzilla is free software; provided under the GNU General Public License *
  6141. *******************************************************************************/
  6142.  
  6143. // x~x news
  6144.  
  6145. // Nombre de news à afficher & nb max de caractères par news:
  6146. var nbItems = 5;
  6147. var maxCarDescription = 300;
  6148.  
  6149. /*-[functions]------------------- Utilitaires --------------------------------*/
  6150.  
  6151. // Ne semble avoir strictement aucun effet:
  6152. String.prototype.epureDescription = function() {
  6153. return this.replace(/\\(.)/g,"$1");
  6154. }
  6155.  
  6156. function appendTitledTable(node,titre,description) {
  6157. // Crée les tables contenant les infos (avec titre)
  6158. var table = document.createElement('table');
  6159. table.border = 0;
  6160. table.className = 'mh_tdborder';
  6161. table.cellSpacing = 1;
  6162. table.cellPadding = 1;
  6163. table.style.maxWidth = '98%';
  6164. table.style.marginLeft = 'auto';
  6165. table.style.marginRight = 'auto';
  6166. var tbody = document.createElement('tbody');
  6167. table.appendChild(tbody);
  6168. var tr = appendTr(tbody,'mh_tdtitre');
  6169. var td = appendTdCenter(tr,2);
  6170. var span = document.createElement('span');
  6171. appendText(span,titre,true);
  6172. if(description) {
  6173. span.title = description;
  6174. }
  6175. td.appendChild(span);
  6176. node.appendChild(table);
  6177. return tbody;
  6178. }
  6179.  
  6180. function testCertif(paramURL, callbackOnError) {
  6181. try {
  6182. FF_XMLHttpRequest({
  6183. method: 'GET',
  6184. url: paramURL,
  6185. onload: function(responseDetails) {
  6186. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  6187. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  6188. }
  6189. });
  6190. } catch(e) {
  6191. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  6192. callbackOnError();
  6193. }
  6194. }
  6195.  
  6196. function createOrGetGrandCadre() {
  6197. var grandCadre = document.getElementById('grandCadre');
  6198. if (grandCadre) return grandCadre;
  6199. try {
  6200. var rappels = document.evaluate(
  6201. "//p[contains(a/text(),'messagerie')]",
  6202. document, null, 9, null).singleNodeValue;
  6203. }
  6204. catch(e) {
  6205. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  6206. grandCadre = document.createElement('div');
  6207. return grandCadre;
  6208. }
  6209. grandCadre = document.createElement('div');
  6210. grandCadre.id = 'grandCadre';
  6211. var sousCadre = document.createElement('div');
  6212. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  6213. sousCadre.style.textAlign = 'center';
  6214. sousCadre.style.fontSize = 'xx-large';
  6215. grandCadre.appendChild(sousCadre);
  6216.  
  6217. grandCadre.style.border = 'solid 5px red';
  6218. grandCadre.style.width = 'auto';
  6219. insertBefore(rappels,grandCadre);
  6220. return grandCadre;
  6221. }
  6222.  
  6223. function showHttpsErrorCadre1() {
  6224. window.console.log('[MZ] showHttpsErrorCadre1');
  6225. var grandCadre = createOrGetGrandCadre();
  6226. var sousCadre = document.createElement('div');
  6227. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  6228. + '<br />Cela empêchera Moutyzilla de fonctionner'
  6229. + '<br /><a style="color:blue;font-size: inherits;" href="'
  6230. + URL_CertifRaistlin1
  6231. + '" target="raistlin">clique ici</a>'
  6232. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6233. + ' « Confirmer l\'exception de sécurité »'
  6234. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6235. sousCadre.style.width = 'auto';
  6236. sousCadre.style.fontSize = 'large';
  6237. sousCadre.style.border = 'solid 1px black';
  6238. sousCadre.style.backgroundColor = 'red';
  6239. grandCadre.appendChild(sousCadre);
  6240. }
  6241.  
  6242. function showHttpsErrorCadre2() {
  6243. window.console.log('[MZ] showHttpsErrorCadre2');
  6244. var grandCadre = createOrGetGrandCadre();
  6245. var sousCadre = document.createElement('div');
  6246. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  6247. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  6248. + '<a style="color:blue;font-size: inherits;" href="'
  6249. + URL_CertifRaistlin2
  6250. + '" target="raistlin">clique ici</a>'
  6251. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6252. + ' « Confirmer l\'exception de sécurité »'
  6253. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  6254. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6255. sousCadre.style.width = 'auto';
  6256. sousCadre.style.fontSize = 'large';
  6257. sousCadre.style.border = 'solid 1px black';
  6258. sousCadre.style.backgroundColor = 'red';
  6259. grandCadre.appendChild(sousCadre);
  6260. }
  6261.  
  6262. function showHttpsErrorContenuMixte() {
  6263. window.console.log('[MZ] showHttpsErrorContenuMixte');
  6264. var grandCadre = createOrGetGrandCadre();
  6265. var sousCadre = document.createElement('div');
  6266. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  6267. + '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)'
  6268. + '<ul>'
  6269. + '<li>Interface Bricol\'Troll</li>'
  6270. + '<li>Nouveautés de Mountyzilla</li>'
  6271. + '</ul>'
  6272. + '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 />'
  6273. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  6274. sousCadre.style.width = 'auto';
  6275. sousCadre.style.fontSize = 'large';
  6276. sousCadre.style.border = 'solid 1px black';
  6277. grandCadre.appendChild(sousCadre);
  6278. }
  6279.  
  6280. /*-[functions]------------------- Jubilaires ---------------------------------*/
  6281.  
  6282. function traiterJubilaires() {
  6283. // à faire
  6284. }
  6285.  
  6286. function traiterJubilaires_a_supprimer() { // ancienne méthode
  6287. try {
  6288. FF_XMLHttpRequest({
  6289. method: 'GET',
  6290. url: URL_anniv,
  6291. headers: {
  6292. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  6293. 'Accept': 'application/xml,text/xml',
  6294. },
  6295. onload: function(responseDetails) {
  6296. if ((responseDetails.status == 0) && isHTTPS) {
  6297. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  6298. //showHttpsErrorContenuMixte();
  6299. return;
  6300. }
  6301. var listeTrolls = responseDetails.responseText.split('\n');
  6302. if(!listeTrolls || listeTrolls.length==0) {
  6303. return;
  6304. }
  6305. afficherJubilaires(listeTrolls);
  6306. },
  6307. });
  6308. }
  6309. catch(e) {
  6310. if (isHTTPS) {
  6311. window.console.log(traceStack(e, 'appel jubilaires'));
  6312. showHttpsErrorContenuMixte();
  6313. } else {
  6314. window.alert('Erreur Jubilaires:\n'+e);
  6315. }
  6316. }
  6317. }
  6318.  
  6319. function afficherJubilaires(listeTrolls) {
  6320. try {
  6321. var rappels = document.evaluate(
  6322. "//p[contains(a/text(),'messagerie')]",
  6323. document, null, 9, null).singleNodeValue;
  6324. }
  6325. catch(e) {
  6326. return;
  6327. }
  6328. var p = document.createElement('p');
  6329. var tbody = appendTitledTable(p,
  6330. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  6331. 'Envoyez leur un message ou un cadeau !'
  6332. );
  6333. tr = appendTr(tbody,'mh_tdpage');
  6334. td = appendTdCenter(tr);
  6335. var small = document.createElement('small');
  6336. td.appendChild(small);
  6337. var first = true;
  6338. for(var i=0 ; i<listeTrolls.length ; i++) {
  6339. var infos = listeTrolls[i].split(';');
  6340. if(infos.length!=3 || infos[2]==='0') {
  6341. continue;
  6342. }
  6343. if(first) {
  6344. first = false;
  6345. }
  6346. else {
  6347. appendText(small,', ');
  6348. }
  6349. var a = document.createElement('a');
  6350. a.href = 'javascript:EPV('+infos[0]+')';
  6351. appendText(a,infos[1]);
  6352. small.appendChild(a);
  6353. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  6354. }
  6355. insertBefore(rappels,p);
  6356. }
  6357.  
  6358.  
  6359. /*-[functions]--------------------- News MZ ----------------------------------*/
  6360.  
  6361. function traiterNouvelles() {
  6362. var news = new Array;
  6363. news.push(['15/11/2019', 'Refonte des calculs tactiques dans la vue. Affichage du niveau du monstre à tout coup (ou presque).']);
  6364. 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 ;).']);
  6365. afficherNouvelles(news);
  6366. }
  6367.  
  6368. function afficherNouvelles(items) {
  6369. var footer = document.getElementById('footer1');
  6370. if(!footer) {
  6371. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  6372. return;
  6373. }
  6374. var p = document.createElement('p');
  6375. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  6376. var div = document.createElement('div');
  6377. div.style.position = 'absolute';
  6378. div.style.right = 0;
  6379. div.style.top = 0;
  6380. div.style.paddingRight = '3px';
  6381. div.style.whiteSpace = 'nowrap';
  6382. appendText(div, '(version ' + GM_info.script.version + ')');
  6383. tbody.rows[0].cells[0].style.position = 'relative';
  6384. tbody.rows[0].cells[0].appendChild(div);
  6385. for(var i=0 ; i<items.length ; i++) {
  6386. var tr = appendTr(tbody,'mh_tdpage');
  6387. var td = appendTdCenter(tr);
  6388. td.style.verticalAlign = 'top'; // semble sans effet
  6389. appendText(td,items[i][0],true);
  6390. td = appendTd(tr);
  6391. td.innerHTML = items[i][1];
  6392. }
  6393. insertBefore(footer,p);
  6394.  
  6395. // changelog
  6396. var p = document.createElement('p');
  6397. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  6398. tbody.rows[0].cells[0].style.cursor = 'pointer';
  6399. tbody.rows[0].cells[0].onclick = function() {
  6400. try {
  6401. tbody.rows[0].cells[0].onclick = undefined;
  6402. tbody.rows[0].cells[0].style.cursor = '';
  6403. var tr = appendTr(tbody,'mh_tdpage');
  6404. var td = appendTd(tr);
  6405. td.colSpan = 2;
  6406. var pre = document.createElement('pre');
  6407. appendText(pre,MZ_changeLog.join("\n"));
  6408. td.appendChild(pre);
  6409. } catch (e) {
  6410. window.console.log('[MZ] affichage changeLog', e);
  6411. }
  6412. };
  6413. insertBefore(footer,p);
  6414.  
  6415. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  6416. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  6417. if (isHTTPS) {
  6418. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  6419. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6420. } else {
  6421. window.console.log('[MZ test] début switch to https');
  6422. window.sessionStorage.setItem('xxx', "test session trans https");
  6423. window.parent.xxx = "autre test";
  6424. var url = document.location.href;
  6425. window.console.log('[MZ test] url=' + url);
  6426. url = url.replace(/http:\/\//i, 'https://')
  6427. window.console.log('[MZ test] switched url=' + url);
  6428. document.location.href = url;
  6429. }
  6430. }
  6431. if (false) { // version par utilisation d'un IFrame en https
  6432. if (isHTTPS) {
  6433. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  6434. //window.console.log('[MZ test] window.name=' + window.name);
  6435. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  6436. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6437. var txt = window.name;
  6438. var tabtxt = txt.split(/µ/);
  6439. for (var i = 0; i < tabtxt.length; i++) {
  6440. window.console.log('[MZ test]config https ' + tabtxt[i]);
  6441. }
  6442. } else {
  6443. var txt = '';
  6444. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6445. var k = localStorage.key(i);
  6446. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6447. txt += k + "£" + localStorage.getItem(k) + "µ";
  6448. }
  6449. var iframe = document.createElement('iframe');
  6450. var url = document.location.href;
  6451. //window.console.log('[MZ test] url=' + url);
  6452. url = url.replace(/http:\/\//i, 'https://')
  6453. //window.console.log('[MZ test] switched url=' + url);
  6454. //iframe.xxx = "truc en plume";
  6455. iframe.name = txt;
  6456. //window.xxx = "machin";
  6457. iframe.src = url;
  6458. //iframe.document.xxx = "truc en plume";
  6459. document.body.appendChild(iframe);
  6460. iframe.style.display = 'none';
  6461. }
  6462. }
  6463. }
  6464. }
  6465.  
  6466.  
  6467. /*---------------------------------- Main ------------------------------------*/
  6468.  
  6469. function do_news() {
  6470. start_script();
  6471.  
  6472. traiterJubilaires();
  6473. traiterNouvelles();
  6474.  
  6475. /* plus besoin, le certificat est "officiel"
  6476. if (isHTTPS) {
  6477. // test si les certificats raistlin ont été acceptés
  6478. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  6479. var infoit = MY_getValue(numTroll+'.INFOSIT');
  6480. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  6481. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  6482. }
  6483. }
  6484. */
  6485.  
  6486. displayScriptTime();
  6487. }
  6488.  
  6489. /*********************************************************************************
  6490. * This file is part of Mountyzilla. *
  6491. * *
  6492. * Mountyzilla is free software; you can redistribute it and/or modify *
  6493. * it under the terms of the GNU General Public License as published by *
  6494. * the Free Software Foundation; either version 2 of the License, or *
  6495. * (at your option) any later version. *
  6496. * *
  6497. * Mountyzilla is distributed in the hope that it will be useful, *
  6498. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6499. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6500. * GNU General Public License for more details. *
  6501. * *
  6502. * You should have received a copy of the GNU General Public License *
  6503. * along with Mountyzilla; if not, write to the Free Software *
  6504. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6505. *********************************************************************************/
  6506.  
  6507. // x~x tabcompo
  6508.  
  6509. var popup;
  6510.  
  6511. function initPopupTabcompo() {
  6512. popup = document.createElement('div');
  6513. popup.setAttribute('id', 'popup');
  6514. popup.setAttribute('class', 'mh_textbox');
  6515. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  6516. + 'display: inline; z-index: 3; max-width: 400px;');
  6517. document.body.appendChild(popup);
  6518. }
  6519.  
  6520. function showPopup(evt) {
  6521. var texte = this.getAttribute("texteinfo");
  6522. popup.innerHTML = texte;
  6523. popup.style.left = evt.pageX + 15 + 'px';
  6524. popup.style.top = evt.pageY + 'px';
  6525. popup.style.visibility = "visible";
  6526. }
  6527.  
  6528. // roule 16/03/2016, existe déjà ailleurs
  6529. // function hidePopup() {
  6530. // popup.style.visibility = 'hidden';
  6531. // }
  6532.  
  6533. function createPopupImage_tabcompo(url, text)
  6534. {
  6535. var img = document.createElement('img');
  6536. img.setAttribute('src',url);
  6537. img.setAttribute('align','ABSMIDDLE');
  6538. img.setAttribute("texteinfo",text);
  6539. img.addEventListener("mouseover", showPopup,true);
  6540. img.addEventListener("mouseout", hidePopup,true);
  6541. return img;
  6542. }
  6543.  
  6544. function formateTexte_tabcompo(texte)
  6545. {
  6546. texte = texte.replace(/\n/g,"<br/>");
  6547. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  6548. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  6549. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  6550. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  6551. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  6552. return texte;
  6553. }
  6554.  
  6555. function arrondi(x) {
  6556. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  6557. }
  6558.  
  6559. function traiteMinerai_tabcompo() {
  6560. if (currentURL.indexOf("as_type=Divers")==-1) return;
  6561. try {
  6562. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  6563. +" and contains(./tr/th/text(),'Minerai')]",
  6564. document, null, 9, null).singleNodeValue;
  6565. node = node.nextSibling.nextSibling;
  6566. }
  6567. catch(e) {return;}
  6568.  
  6569. var trlist = document.evaluate('./tr', node, null, 7, null);
  6570. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  6571. var node = trlist.snapshotItem(i);
  6572. var nature = node.childNodes[5].textContent;
  6573. var caracs = node.childNodes[7].textContent;
  6574. var taille = caracs.match(/\d+/)[0];
  6575. var coef = 1;
  6576. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  6577. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  6578. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  6579. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6580. if (nature.indexOf('Mithril')!=-1) {
  6581. coef = 0.2*coef;
  6582. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  6583. }
  6584. else {
  6585. coef = 0.75*coef+1.25;
  6586. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6587. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  6588. }
  6589. }
  6590. }
  6591.  
  6592. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  6593. function treateComposants() {
  6594. if (currentURL.indexOf("as_type=Compo")==-1) return;
  6595. //On récupère les composants
  6596. var nodes = document.evaluate(
  6597. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6598. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6599. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  6600. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6601. if (nodes.snapshotLength == 0) {
  6602. //window.console.log('[MZ] treateComposants DOWN');
  6603. return;
  6604. }
  6605. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  6606.  
  6607. var texte = "";
  6608. for (var i = 0; i < nodes.snapshotLength; i++) {
  6609. var n1 = nodes.snapshotItem(i).childNodes[1];
  6610. var n3 = nodes.snapshotItem(i).childNodes[3];
  6611. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6612. var prix = n3.childNodes[0].nodeValue;
  6613. if (!prix)
  6614. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6615. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6616. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6617. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6618. + prix.replace(/\n/g, '') + "\n";
  6619. }
  6620.  
  6621. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6622. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6623. var id_taniere = c.snapshotItem(0).nodeValue;
  6624. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  6625.  
  6626. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6627. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  6628. if (form)
  6629. {
  6630. if(document.getElementsByTagName('form').length>0)
  6631. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6632. else
  6633. {
  6634. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6635. insertBefore(thisP, form);
  6636. }
  6637. }
  6638. }
  6639.  
  6640. function treateAllComposants() {
  6641. if(currentURL.indexOf("as_type=Compo")==-1) return;
  6642.  
  6643. //On récupère les composants
  6644. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  6645. document, null, 0, null ).numberValue;
  6646. var c = (categ == 0 ? 3 : 4);
  6647. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  6648. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  6649. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  6650. + "td["+c+"]/text()[1] = '\u0040-\u0040' "
  6651. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  6652. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  6653. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  6654. + "and td[1]/img/@alt = 'Identifié']",
  6655. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6656. if (nodes.snapshotLength == 0) {
  6657. // window.alert('treateAllComposants DOWN');
  6658. return;
  6659. }
  6660.  
  6661. var texte = "";
  6662. for (var i = 0; i < nodes.snapshotLength; i++) {
  6663. var n1 = nodes.snapshotItem(i).childNodes[1];
  6664. var n3 = nodes.snapshotItem(i).childNodes[3];
  6665. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6666. var prix = n3.childNodes[0].nodeValue;
  6667. if (!prix)
  6668. {
  6669. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  6670. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6671. }
  6672. else
  6673. {
  6674. prix= prix.replace(/[\240 ]/g, "");
  6675. if(prix=="-")
  6676. prix=null;
  6677. }
  6678. if(prix)
  6679. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6680. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6681. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6682. + prix.replace(/\n/g, '') + "\n";
  6683. else
  6684. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6685. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6686. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  6687. }
  6688.  
  6689. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6690. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6691. var id_taniere = c.snapshotItem(0).nodeValue;
  6692. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  6693.  
  6694. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6695. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  6696. if (form)
  6697. {
  6698. if(document.getElementsByTagName('form').length>0)
  6699. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6700. else
  6701. {
  6702. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6703. insertBefore(thisP, form);
  6704. }
  6705. }
  6706. }
  6707.  
  6708. function treateEM()
  6709. {
  6710. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  6711. if(currentURL.indexOf("as_type=Compo")==-1)
  6712. return false;
  6713. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  6714. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  6715. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6716. if (nodes.snapshotLength == 0)
  6717. return false;
  6718. for (var i = 0; i < nodes.snapshotLength; i++) {
  6719. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  6720. var link = desc[2].firstChild ;
  6721. var nomCompoTotal = desc[2].textContent ;
  6722. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6723. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6724. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  6725. var locqual = desc[3].textContent ;
  6726. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  6727. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  6728. if(isEM(nomMonstre).length>0)
  6729. {
  6730. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  6731. if(infos.length>0)
  6732. {
  6733. var shortDescr = "Variable";
  6734. var bold = 0;
  6735. if(infos != "Composant variable")
  6736. {
  6737. shortDescr = infos.substring(0,infos.indexOf(" "));
  6738. if(parseInt(shortDescr)>=0)
  6739. bold=1;
  6740. }
  6741. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  6742. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  6743. }
  6744. }
  6745.  
  6746. }
  6747. }
  6748.  
  6749. function treateChampi_tabcompo() {
  6750. if (currentURL.indexOf('as_type=Champi')==-1)
  6751. return false;
  6752. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  6753. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6754. if (nodes.snapshotLength == 0)
  6755. return false;
  6756.  
  6757. for (var i = 0; i < nodes.snapshotLength; i++) {
  6758. var node = nodes.snapshotItem(i);
  6759. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  6760. if (moisChampi[nomChampi])
  6761. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  6762. }
  6763. }
  6764.  
  6765. function treateEnchant()
  6766. {
  6767. if(currentURL.indexOf("as_type=Compo")==-1)
  6768. return false;
  6769. try
  6770. {
  6771. if(!listeMonstreEnchantement)
  6772. computeCompoEnchantement();
  6773. var nodes = document.evaluate(
  6774. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6775. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6776. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6777. if (nodes.snapshotLength == 0)
  6778. return false;
  6779. var urlImg = URL_MZimg + "enchant.png";
  6780. for (var i = 0; i < nodes.snapshotLength; i++) {
  6781. var link = nodes.snapshotItem(i);
  6782. var nomCompoTotal = link.firstChild.nodeValue;
  6783. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6784. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6785. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  6786. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  6787. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  6788. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  6789. if(isEnchant(nomMonstre).length>0)
  6790. {
  6791. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  6792. if(infos.length>0)
  6793. {
  6794. link.parentNode.appendChild(createImage(urlImg,infos));
  6795. }
  6796. }
  6797. }
  6798. }
  6799. catch(e)
  6800. {
  6801. window.alert(e);
  6802. }
  6803. }
  6804.  
  6805. function treateEquipEnchant()
  6806. {
  6807. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  6808. return false;
  6809. initPopupTabcompo();
  6810. computeEnchantementEquipement(createPopupImage_tabcompo,formateTexte_tabcompo);
  6811. }
  6812.  
  6813. function do_tancompo() {
  6814. start_script();
  6815.  
  6816. treateAllComposants();
  6817. treateComposants();
  6818. traiteMinerai_tabcompo();
  6819. if (MY_getValue('NOINFOEM')!='true') {
  6820. treateChampi_tabcompo();
  6821. treateEM();
  6822. }
  6823. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  6824. treateEnchant();
  6825. treateEquipEnchant();
  6826. }
  6827.  
  6828. displayScriptTime();
  6829. }
  6830.  
  6831. /*******************************************************************************
  6832. * This file is part of Mountyzilla. *
  6833. * *
  6834. * Mountyzilla is free software; you can redistribute it and/or modify *
  6835. * it under the terms of the GNU General Public License as published by *
  6836. * the Free Software Foundation; either version 2 of the License, or *
  6837. * (at your option) any later version. *
  6838. * *
  6839. * Mountyzilla is distributed in the hope that it will be useful, *
  6840. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6841. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6842. * GNU General Public License for more details. *
  6843. * *
  6844. * You should have received a copy of the GNU General Public License *
  6845. * along with Mountyzilla; if not, write to the Free Software *
  6846. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6847. *******************************************************************************/
  6848.  
  6849. // x~x pjview
  6850.  
  6851. /* TODO
  6852. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  6853. */
  6854.  
  6855. // Bulle d'infos
  6856. var DivInfo;
  6857. // Booléen stockant l'état de freezing de la bulle
  6858. var freezed = false;
  6859.  
  6860. // liste du matos
  6861. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  6862. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6863. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  6864. var mh_caracs = {
  6865. 'anneau de protection':
  6866. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  6867. "armure d'anneaux":
  6868. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  6869. 'armure de bois':
  6870. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  6871. 'armure de cuir':
  6872. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  6873. 'armure de peaux':
  6874. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  6875. 'armure de pierre':
  6876. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  6877. 'armure de plates':
  6878. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  6879. 'baton lesté':
  6880. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6881. 'bâtons de parade':
  6882. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6883. 'bottes':
  6884. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6885. 'bouclier à pointes':
  6886. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6887. 'boulet et chaîne':
  6888. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6889. 'cagoule':
  6890. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  6891. 'casque à cornes':
  6892. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6893. 'casque à pointes':
  6894. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  6895. 'casque en cuir':
  6896. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  6897. 'casque en métal':
  6898. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6899. 'chaîne cloutée':
  6900. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6901. 'chapeau pointu':
  6902. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  6903. 'collier de dents':
  6904. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  6905. 'collier de pierre':
  6906. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6907. 'collier à pointes':
  6908. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6909. 'cotte de mailles':
  6910. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  6911. 'couronne de cristal':
  6912. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  6913. "couronne d'obsidienne":
  6914. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  6915. "coutelas d'obsidienne":
  6916. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  6917. 'coutelas en os':
  6918. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  6919. 'crochet':
  6920. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6921. 'cuir bouilli':
  6922. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  6923. "cuirasse d'ossements":
  6924. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  6925. "cuirasse d'écailles":
  6926. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  6927. 'culotte en cuir':
  6928. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6929. 'dague':
  6930. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6931. 'epée courte':
  6932. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6933. 'epée longue':
  6934. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6935. 'espadon':
  6936. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6937. 'fouet':
  6938. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6939. 'fourrures':
  6940. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  6941. 'gantelet':
  6942. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6943. 'gorgeron en cuir':
  6944. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6945. 'gorgeron en métal':
  6946. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  6947. 'gourdin':
  6948. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6949. 'gourdin clouté':
  6950. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6951. 'grimoire':
  6952. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  6953. "gros'porte":
  6954. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  6955. 'grosse racine':
  6956. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6957. 'grosse stalagmite':
  6958. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  6959. 'hache de bataille':
  6960. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6961. 'hache de guerre en os':
  6962. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  6963. 'hache de guerre en pierre':
  6964. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  6965. "hache à deux mains d'obsidienne":
  6966. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  6967. 'hallebarde':
  6968. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  6969. "haubert d'écailles":
  6970. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  6971. 'haubert de mailles':
  6972. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  6973. 'heaume':
  6974. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  6975. 'jambières en cuir':
  6976. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6977. 'jambières en fourrure':
  6978. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  6979. 'jambières en maille':
  6980. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6981. 'jambières en métal':
  6982. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  6983. 'jambières en os':
  6984. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6985. "lame d'obsidienne":
  6986. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  6987. 'lame en os':
  6988. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6989. 'lame en pierre':
  6990. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6991. 'lorgnons':
  6992. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  6993. 'machette':
  6994. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6995. "masse d'arme":
  6996. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6997. 'pagne de mailles':
  6998. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6999. 'pagne en cuir':
  7000. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  7001. 'robe de mage':
  7002. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  7003. 'rondache en bois':
  7004. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  7005. 'rondache en métal':
  7006. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  7007. 'sandales':
  7008. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  7009. 'souliers dorés':
  7010. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  7011. "talisman d'obsidienne":
  7012. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  7013. 'talisman de pierre':
  7014. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  7015. 'targe':
  7016. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  7017. 'torche':
  7018. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  7019. 'torque de pierre':
  7020. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  7021. 'tunique':
  7022. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  7023. "tunique d'écailles":
  7024. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  7025. 'turban':
  7026. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  7027. }
  7028.  
  7029. // liste des templates
  7030. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  7031. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  7032. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  7033. var mh_templates = {
  7034. 'de Feu':
  7035. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7036. 'de Résistance':
  7037. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  7038. "de l'Aigle":
  7039. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  7040. 'de la Salamandre':
  7041. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  7042. 'des Cyclopes':
  7043. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  7044. 'des Enragés':
  7045. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  7046. 'des Tortues':
  7047. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  7048. 'des Vampires':
  7049. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  7050. 'du Glacier':
  7051. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  7052. 'du Rat':
  7053. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  7054. 'du Roc':
  7055. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  7056. 'du Temps':
  7057. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  7058. 'du Vent':
  7059. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  7060. 'en Mithril':
  7061. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7062. 'des Anciens':
  7063. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7064. 'des Champions':
  7065. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7066. 'des Duellistes':
  7067. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7068. 'de la Terre':
  7069. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  7070. "de l'Orage":
  7071. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  7072. "de l'Ours":
  7073. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  7074. 'des Béhémoths':
  7075. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  7076. 'des Mages':
  7077. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  7078. 'du Pic':
  7079. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  7080. 'du Sable':
  7081. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  7082. 'acéré':
  7083. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7084. 'acérée':
  7085. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7086. 'équilibré':
  7087. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7088. 'équilibrée':
  7089. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7090. 'léger':
  7091. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7092. 'légère':
  7093. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7094. 'renforcé':
  7095. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7096. 'renforcée':
  7097. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7098. 'robuste':
  7099. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  7100. }
  7101.  
  7102. function clone(arr) {
  7103. // Clonage rapide
  7104. return arr.slice(0);
  7105. }
  7106.  
  7107. function addArray(arr1,arr2) {
  7108. // Somme matricielle
  7109. var res = clone(arr1);
  7110. for(i=res.length-1 ; i>=0 ; i--) {
  7111. res[i] += arr2[i];
  7112. }
  7113. return res;
  7114. }
  7115.  
  7116. function getTemplates(nomItem) {
  7117. // Déstructure le nom de l'item en array [nom, template1, ...]
  7118. var tempFound = true;
  7119. var str = nomItem.trim();
  7120. var arr = [];
  7121. while(tempFound) {
  7122. tempFound = false;
  7123. for(var temp in mh_templates) {
  7124. // on teste la fin du nom contre chaque template
  7125. if(str.slice(-temp.length)!=temp) { continue; }
  7126. tempFound = true;
  7127. str = str.slice(0,-temp.length-1);
  7128. arr.unshift(temp);
  7129. if(str.slice(-3)==' et') {
  7130. str = str.slice(0,-3);
  7131. }
  7132. }
  7133. }
  7134. arr.unshift(str);
  7135. return arr;
  7136. }
  7137.  
  7138. function addMithril(arrayCaracs,typeItem) {
  7139. // Ajoute l'effet du Mithril sur les caracs
  7140. if(typeItem=='arme') {
  7141. if(arrayCaracs[0]<0) {
  7142. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  7143. }
  7144. }
  7145. else {
  7146. if(arrayCaracs[4]<0) {
  7147. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  7148. }
  7149. }
  7150. arrayCaracs[15] /= 2;
  7151. arrayCaracs[16] /= 2;
  7152. return arrayCaracs;
  7153. }
  7154.  
  7155. function addRenfort(arrayCaracs,template) {
  7156. // Ajoute l'effet des pseudo-templates sur les caracs
  7157. // S'applique APRÈS le mithril
  7158. // WARNING - Cette formule n'a rien d'officiel, gare !
  7159. var coef = 0;
  7160. if(/^lég[e,è]re?$/.test(template)) {
  7161. coef = -1;
  7162. }
  7163. else if(/^renforcée?$/.test(template)
  7164. || template==='robuste') {
  7165. coef = 1;
  7166. }
  7167. if(coef) {
  7168. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  7169. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  7170. }
  7171. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  7172. return arrayCaracs;
  7173. }
  7174.  
  7175. function getCaracs(item) {
  7176. // Calcule les caractéristiques de l'item
  7177. var templates = getTemplates(item);
  7178. if(!mh_caracs[templates[0]]) {
  7179. // Si l'item est inconnu
  7180. return [];
  7181. }
  7182. var caracs = clone(mh_caracs[templates[0]]);
  7183. var typeItem = caracs[0];
  7184. caracs.shift();
  7185. templates.shift();
  7186. if(templates[templates.length-1]=='en Mithril') {
  7187. caracs = addMithril(caracs,typeItem);
  7188. templates.pop();
  7189. }
  7190. if(/^acérée?$/.test(templates[0])
  7191. || /^équilibrée?$/.test(templates[0])
  7192. || /^lég[e,è]re?$/.test(templates[0])
  7193. || /^renforcée?$/.test(templates[0])
  7194. || templates[0]=='robuste') {
  7195. caracs = addRenfort(caracs,templates[0]);
  7196. templates.shift();
  7197. }
  7198. for(var i=templates.length-1 ; i>=0 ; i--) {
  7199. caracs = addArray(caracs,mh_templates[templates[i]]);
  7200. }
  7201. return caracs;
  7202. }
  7203.  
  7204. function getLine(tab) {
  7205. // Préparation de la ligne à afficher lors d'un mouseover
  7206. var str = '';
  7207. if(tab[0]!=0 || tab[1]!=0) {
  7208. str += '<b>Att : </b>'+aff(tab[0]);
  7209. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  7210. str += ' | ';
  7211. }
  7212. if(tab[4]!=0) {
  7213. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  7214. }
  7215. if(tab[2]!=0 || tab[3]!=0) {
  7216. str += '<b>Deg : </b>'+aff(tab[2]);
  7217. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  7218. str += ' | ';
  7219. }
  7220. if(tab[8]!=0) {
  7221. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  7222. }
  7223. if(tab[7]!=0) {
  7224. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  7225. }
  7226. if(tab[5]!=0 || tab[6]!=0) {
  7227. str += '<b>Arm : </b>'+aff(tab[5]);
  7228. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  7229. str += ' | ';
  7230. }
  7231. if(tab[9]!=0 || tab[10]!=0) {
  7232. str += '<b>RM : </b>'+aff(tab[9])+'%';
  7233. if(tab[9]!=tab[10]) {
  7234. str += '/'+aff(tab[10])+'%';
  7235. }
  7236. str += ' | ';
  7237. }
  7238. if(tab[11]!=0 || tab[12]!=0) {
  7239. str += '<b>MM : </b>'+aff(tab[11])+'%';
  7240. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  7241. str += ' | ';
  7242. }
  7243. if(tab[13]!=0) {
  7244. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  7245. }
  7246. if(tab[14]!=0) {
  7247. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  7248. }
  7249. str += '<b>Poids : </b>'+tab[15]+' min';
  7250. if(tab[15]!=tab[16]) {
  7251. str += ' / '+tab[16]+' min';
  7252. }
  7253. return str;
  7254. }
  7255.  
  7256. function toolTipInit() {
  7257. DivInfo = document.createElement('div');
  7258. DivInfo.id = 'infosVue';
  7259. DivInfo.className = 'mh_textbox';
  7260. DivInfo.style =
  7261. 'position: absolute;'
  7262. +'border: 1px solid #000000;'
  7263. +'visibility:hidden;'
  7264. +'display:inline;'
  7265. +'z-index:99;';
  7266. document.body.appendChild(DivInfo);
  7267. document.onmousemove = getXY;
  7268. document.onclick = changeFreezeStatus;
  7269. }
  7270.  
  7271. function getXY(evt) {
  7272. if(!freezed && DivInfo.style.visibility=='visible') {
  7273. DivInfo.style.left = evt.pageX+'px';
  7274. DivInfo.style.top = evt.pageY+10+'px';
  7275. }
  7276. }
  7277.  
  7278. function changeFreezeStatus() {
  7279. if(DivInfo.style.visibility=='visible') {
  7280. freezed = !freezed;
  7281. if(!freezed) { hideInfos(); }
  7282. }
  7283. }
  7284.  
  7285. function showInfos() {
  7286. if(freezed) { return; }
  7287. var currentInfos = this.infos;
  7288. DivInfo.innerHTML = currentInfos;
  7289. DivInfo.style.visibility = 'visible';
  7290. }
  7291.  
  7292. function hideInfos() {
  7293. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  7294. }
  7295.  
  7296. function treateEquipement() {
  7297. // Extrait les données du matos et réinjecte les infos déduites
  7298. if(MY_getValue('INFOCARAC')=='false') { return; }
  7299.  
  7300. var faireLigne = false;
  7301. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  7302. var nodes = document.evaluate(
  7303. "//td/b[text()='Equipement Utilisé']/../../"
  7304. +"td[2]/img[contains(@src,bullet)]",
  7305. document, null, 7, null);
  7306. if(nodes.snapshotLength>0) {
  7307. // Si CSS de base
  7308. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7309. var node = nodes.snapshotItem(i);
  7310. var next = node.nextSibling;
  7311. var nnext = next.nextSibling;
  7312. var nom = next.nodeValue.toLowerCase();
  7313. if(nnext.childNodes.length==1) {
  7314. nom += nnext.firstChild.nodeValue;
  7315. }
  7316. nom = nom.trim();
  7317. // gestion winpostrophe
  7318. var c = String.fromCharCode(180);
  7319. while(nom.indexOf(c)!=-1) {
  7320. nom = nom.replace(c,"'");
  7321. }
  7322. var arr = getCaracs(nom);
  7323. if(arr.length>0) {
  7324. faireLigne = true;
  7325. caracs = addArray(caracs,arr);
  7326. var span = document.createElement('span');
  7327. span.appendChild(next);
  7328. span.appendChild(nnext);
  7329. span.infos = getLine(arr);
  7330. span.onmouseover = showInfos;
  7331. span.onmouseout = hideInfos;
  7332. insertBefore(node.nextSibling,span);
  7333. }
  7334. }
  7335.  
  7336. if(faireLigne) {
  7337. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  7338. document, null, 9, null).singleNodeValue;
  7339. node.infos = getLine(caracs);
  7340. node.onmouseover = showInfos;
  7341. node.onmouseout = hideInfos;
  7342. }
  7343. }
  7344. else {
  7345. // Si CSS avancée
  7346. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  7347. document, null, 7, null);
  7348. if(nodes.snapshotLength>0) {
  7349. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7350. var node = nodes.snapshotItem(i);
  7351. var nom = node.firstChild.nodeValue.toLowerCase();
  7352. if(node.childNodes.length>1) {
  7353. nom += node.childNodes[1].firstChild.nodeValue;
  7354. }
  7355. nom = nom.trim();
  7356. // gestion winpostrophe
  7357. var c = String.fromCharCode(180);
  7358. while(nom.indexOf(c)!=-1) {
  7359. nom = nom.replace(c,"'");
  7360. }
  7361. var arr = getCaracs(nom);
  7362. if(arr.length!=0) {
  7363. caracs = addArray(caracs,arr);
  7364. node.infos = getLine(arr);
  7365. node.onmouseover = showInfos;
  7366. node.onmouseout = hideInfos;
  7367. }
  7368. }
  7369. var nodes = document.evaluate("//dt[@class='equipement']",
  7370. document, null, 7, null);
  7371. var node = nodes.snapshotItem(0);
  7372. node.infos = getLine(caracs);
  7373. node.onmouseover = showInfos;
  7374. node.onmouseout = hideInfos;
  7375. }
  7376. }
  7377. }
  7378.  
  7379. function do_pjview() {
  7380. treateEquipement();
  7381. toolTipInit();
  7382. }
  7383.  
  7384. /*******************************************************************************
  7385. * This file is part of Mountyzilla. *
  7386. * *
  7387. * Mountyzilla is free software; you can redistribute it and/or modify *
  7388. * it under the terms of the GNU General Public License as published by *
  7389. * the Free Software Foundation; either version 2 of the License, or *
  7390. * (at your option) any later version. *
  7391. * *
  7392. * Mountyzilla is distributed in the hope that it will be useful, *
  7393. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7394. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7395. * GNU General Public License for more details. *
  7396. * *
  7397. * You should have received a copy of the GNU General Public License *
  7398. * along with Mountyzilla; if not, write to the Free Software *
  7399. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7400. *******************************************************************************/
  7401.  
  7402. // x~x option
  7403.  
  7404. /* TODO
  7405. * Passer le HTML injecté aux conventions HTML5
  7406. */
  7407.  
  7408.  
  7409. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  7410.  
  7411. function saveITData() {
  7412. var IT = document.getElementById('itSelect').value;
  7413. if(IT=='bricol') {
  7414. var nBricol = 1;
  7415. for (var iBricol = 0; ; iBricol++) {
  7416. var extClef = nBricol == 1 ? '' : nBricol;
  7417. var eltSystem = document.getElementById('urlbricol'+iBricol);
  7418. if (eltSystem == undefined) break;
  7419. var system = eltSystem.value;
  7420. window.console.log("[MZ] saveITData system=" + system);
  7421. var login = document.getElementById('loginbricol'+iBricol).value;
  7422. var pass = document.getElementById('passbricol'+iBricol).value;
  7423. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  7424. if(system && login) {
  7425. if (pass) {
  7426. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  7427. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  7428. //window.console.log('v=' + v);
  7429. } else {
  7430. // vérif que rien n'a changé
  7431. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  7432. if(str) {
  7433. var arr = str.split('$');
  7434. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  7435. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  7436. }
  7437. }
  7438. }
  7439. nBricol++;
  7440. }
  7441. }
  7442. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  7443. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  7444. }
  7445. else {
  7446. MY_removeValue(numTroll+'.INFOSIT');
  7447. }
  7448. }
  7449.  
  7450. function saveLinks() {
  7451. var numLinks = document.getElementById('linksBody').childNodes.length;
  7452. var data=[ [] ];
  7453. /* Récupération et tri des liens */
  7454. for(var i=1 ; i<=numLinks ; i++) {
  7455. MY_removeValue('URL'+i);
  7456. MY_removeValue('URL'+i+'.nom');
  7457. MY_removeValue('URL'+i+'.ico');
  7458. var url = document.getElementById('url'+i).value;
  7459. var nom = document.getElementById('nom'+i).value;
  7460. var ico = document.getElementById('ico'+i).value;
  7461. if(url && (nom || ico) ) {
  7462. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  7463. }
  7464. }
  7465. /* Sauvegarde */
  7466. for(var i=1 ; i<data.length ; i++) {
  7467. MY_setValue('URL'+i,data[i][0]);
  7468. MY_setValue('URL'+i+'.nom',data[i][1]);
  7469. MY_setValue('URL'+i+'.ico',data[i][2]);
  7470. }
  7471. }
  7472.  
  7473. function saveAll() {
  7474. try {
  7475. var urlIco = document.getElementById('icoMenuIco').value;
  7476. if(urlIco) {
  7477. MY_setValue(numTroll+'.ICOMENU', urlIco );
  7478. }
  7479. else {
  7480. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  7481. document.getElementById('icoMenuIco').value = '';
  7482. }
  7483. saveLinks();
  7484. refreshLinks();
  7485.  
  7486. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  7487.  
  7488. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  7489. if(maxcdm) {
  7490. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  7491. }
  7492. else {
  7493. MY_removeValue(numTroll+'.MAXCDM');
  7494. document.getElementById('maxcdm').value = '';
  7495. }
  7496.  
  7497. MY_setValue('NOINFOEM',
  7498. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  7499.  
  7500. // Pourquoi Tilk stockait-il tout en str ?
  7501. // -> parce que les booléens c'est foireux (vérifié)
  7502. MY_setValue(numTroll+'.USECSS',
  7503. document.getElementById('usecss').checked ? 'true':'false');
  7504. MY_setValue('INFOCARAC',
  7505. document.getElementById('infocarac').checked ? 'true' : 'false');
  7506. //MY_setValue(numTroll+'.SEND_IDT',
  7507. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  7508. // Fonctionnalité désactivée
  7509.  
  7510. MY_setValue(numTroll+'.AUTOCDM',
  7511. document.getElementById('autoCdM').checked ? 'true' : 'false');
  7512. // MY_setValue('VUECARAC', // Roule 12/12/2019 ça ne fait plus rien
  7513. // document.getElementById('vueCarac').checked ? 'true' : 'false');
  7514. MY_setValue('CONFIRMEDECALAGE',
  7515. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  7516.  
  7517. /* SCIZ */
  7518. var sciz_jwt = document.getElementById('sciz_jwt').value;
  7519. if (sciz_jwt) {
  7520. sciz_jwt = sciz_jwt.replace(new RegExp('[^a-zA-Z0-9\._\-]','g'), '');
  7521. MY_setValue(numTroll + '.SCIZJWT', sciz_jwt);
  7522. }
  7523. var sciz_cb_events = document.getElementById('sciz_cb_events').checked;
  7524. sciz_cb_events = (sciz_cb_events !== null) ? sciz_cb_events : true;
  7525. MY_setValue(numTroll + '.SCIZ_CB_EVENTS', sciz_cb_events);
  7526. var sciz_cb_view_treasures = document.getElementById('sciz_cb_view_treasures').checked;
  7527. sciz_cb_view_treasures = (sciz_cb_view_treasures !== null) ? sciz_cb_view_treasures : true;
  7528. MY_setValue(numTroll + '.SCIZ_CB_VIEW_TREASURES', sciz_cb_view_treasures);
  7529. var sciz_cb_view_trolls = document.getElementById('sciz_cb_view_trolls').checked;
  7530. sciz_cb_view_trolls = (sciz_cb_view_trolls !== null) ? sciz_cb_view_trolls : true;
  7531. MY_setValue(numTroll + '.SCIZ_CB_VIEW_TROLLS', sciz_cb_view_trolls);
  7532.  
  7533. saveITData();
  7534. } catch (e) {
  7535. var bouton = document.getElementById('saveAll');
  7536. window.console.log(e);
  7537. bouton.value = "il y a eu une erreur";
  7538. return;
  7539. }
  7540.  
  7541. var bouton = document.getElementById('saveAll');
  7542. bouton.value = (bouton.value=='Sauvegardé !') ?
  7543. 'Re-sauvegardé !' : 'Sauvegardé !';
  7544. }
  7545.  
  7546.  
  7547. /*-[functions]----------------- EventListeners -------------------------------*/
  7548.  
  7549. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  7550. var itBody = document.getElementById('itBody');
  7551. var nTr = itBody.rows.length;
  7552. // enlever tous les "+" des lignes précédentes
  7553. for (var iTr = 0; iTr < nTr; iTr++) {
  7554. var td = itBody.rows[iTr].cells[0];
  7555. td.innerHTML = '';
  7556. td.title = '';
  7557. td.style.cursor = 'default';
  7558. }
  7559. // ajouter une ligne
  7560. var tr = appendTr(itBody,'mh_tdpage')
  7561. var td = appendTd(tr);
  7562. if (bLast) {
  7563. td.style.whiteSpace = 'nowrap';
  7564. appendText(td, '+');
  7565. td.style.cursor = 'pointer';
  7566. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  7567. td.onclick = function (e) {
  7568. addBricolIT(undefined, undefined, undefined, false, true);
  7569. }
  7570. }
  7571. var td = appendTd(tr);
  7572. td.style.whiteSpace = 'nowrap';
  7573. appendText(td,'Nom du système : ');
  7574. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  7575. td = appendTd(tr);
  7576. td.style.whiteSpace = 'nowrap';
  7577. appendText(td,'Login du compte : ');
  7578. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  7579. td = appendTd(tr);
  7580. td.style.whiteSpace = 'nowrap';
  7581. appendText(td,'Mot de passe du compte : ');
  7582. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  7583. td = appendTd(tr);
  7584. if (bFirst) {
  7585. td.style.whiteSpace = 'nowrap';
  7586. appendText(td,'Affichage des Trõlls hors vue : ');
  7587. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  7588. }
  7589. }
  7590.  
  7591. function onChangeIT() {
  7592. var IT = document.getElementById('itSelect').value;
  7593. var itBody = document.getElementById('itBody');
  7594. itBody.innerHTML = '';
  7595. var tabStr = new Array();
  7596. if(IT=='bricol') {
  7597. for (var iBricol = 1; ; iBricol++) {
  7598. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  7599. //window.console.log('onChangeIT str=' + str);
  7600. if(str) {
  7601. tabStr.push(str);
  7602. } else {
  7603. break;
  7604. }
  7605. }
  7606. if (tabStr.length == 0) {
  7607. addBricolIT('', '', 0, true, true)
  7608. } else {
  7609. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  7610. var arr = tabStr[iBricol].split('$');
  7611. var system = arr[1];
  7612. var login = arr[2];
  7613. var affhv = arr[4];
  7614. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  7615. }
  7616. }
  7617. }
  7618. }
  7619.  
  7620. function refreshLinks() {
  7621. document.getElementById('linksBody').innerHTML = '';
  7622. var anotherURL = MY_getValue('URL1');
  7623. if(!anotherURL) { addLinkField(); }
  7624. var i=1;
  7625. while(anotherURL && i<99) {
  7626. addLinkField(i,anotherURL,
  7627. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  7628. i++;
  7629. anotherURL = MY_getValue('URL'+i);
  7630. }
  7631. }
  7632.  
  7633. function addLinkField(i,url,nom,ico) {
  7634. var linksBody = document.getElementById('linksBody');
  7635. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  7636. var tr = appendTr(linksBody);
  7637. var td = appendTdCenter(tr);
  7638. appendText(td,'Lien '+i+' : ');
  7639. appendTextbox(td,'text','url'+i,40,150,url);
  7640. td = appendTdCenter(tr);
  7641. appendText(td,'Nom : ');
  7642. appendTextbox(td,'text','nom'+i,20,150,nom);
  7643. td = appendTdCenter(tr);
  7644. appendText(td,'Icône : ');
  7645. appendTextbox(td,'text','ico'+i,40,150,ico);
  7646. }
  7647.  
  7648. function removeLinkField() {
  7649. var linksBody = document.getElementById('linksBody');
  7650. var i = linksBody.childNodes.length;
  7651. MY_removeValue('URL'+i);
  7652. MY_removeValue('URL'+i+'.nom');
  7653. MY_removeValue('URL'+i+'.ico');
  7654. linksBody.removeChild(linksBody.lastChild);
  7655. if(linksBody.childNodes.length==0) { addLinkField(); }
  7656. }
  7657.  
  7658. function resetMainIco() {
  7659. document.getElementById('icoMenuIco').value=
  7660. URL_MZimg + 'mz_logo_small.png';
  7661. }
  7662.  
  7663.  
  7664. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  7665.  
  7666. function insertTitle(next,txt) {
  7667. var div = document.createElement('div');
  7668. div.className = 'titre2';
  7669. appendText(div,txt);
  7670. insertBefore(next,div);
  7671. return div;
  7672. }
  7673.  
  7674. function insertMainTable(next) {
  7675. var table = document.createElement('table');
  7676. table.width = '98%';
  7677. table.border = 0;
  7678. table.align = 'center';
  7679. table.cellPadding = 2;
  7680. table.cellSpacing = 1;
  7681. table.className = 'mh_tdborder';
  7682. var tbody = document.createElement('tbody');
  7683. table.appendChild(tbody);
  7684. insertBefore(next,table);
  7685. return tbody;
  7686. }
  7687.  
  7688. function appendSubTable(node) {
  7689. var table = document.createElement('table');
  7690. table.width = '100%';
  7691. var tbody = document.createElement('tbody');
  7692. table.appendChild(tbody);
  7693. node.appendChild(table);
  7694. return tbody;
  7695. }
  7696.  
  7697. function insertOptionTable(insertPt) {
  7698. var mainBody = insertMainTable(insertPt);
  7699.  
  7700. /* Liens dans le Menu */
  7701. var tr = appendTr(mainBody,'mh_tdtitre');
  7702. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  7703. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7704. appendText(td,'Icône du Menu: ');
  7705. var url = MY_getValue(numTroll+'.ICOMENU');
  7706. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  7707. url = URL_MZimg + 'mz_logo_small.png';
  7708. }
  7709. appendTextbox(td,'text','icoMenuIco',50,200,url);
  7710. appendButton(td,'Réinitialiser',resetMainIco);
  7711.  
  7712. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7713. var tbody = appendSubTable(td);
  7714. tbody.id = 'linksBody';
  7715. refreshLinks();
  7716.  
  7717. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  7718. appendButton(td,'Ajouter',addLinkField);
  7719. appendButton(td,'Supprimer',removeLinkField);
  7720.  
  7721. /* Options de la Vue : vue externe, nb de CdM, etc */
  7722. tr = appendTr(mainBody,'mh_tdtitre');
  7723. appendTdText(tr,'Options de la Vue :',true);
  7724. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7725. tbody = appendSubTable(td);
  7726.  
  7727. tr = appendTr(tbody);
  7728. td = appendTdText(tr,'Vue externe : ');
  7729. var select = document.createElement('select');
  7730. select.id = 'vueext';
  7731. td.appendChild(select);
  7732. var listeVues2D = [
  7733. 'Bricol\' Vue',
  7734. 'Vue du CCM',
  7735. 'Vue Gloumfs 2D',
  7736. 'Vue Gloumfs 3D',
  7737. 'Grouky Vue!'
  7738. ];
  7739. for(var i=0 ; i<listeVues2D.length ; i++) {
  7740. appendOption(select,listeVues2D[i],listeVues2D[i]);
  7741. }
  7742. if(MY_getValue('VUEEXT')) {
  7743. select.value = MY_getValue('VUEEXT');
  7744. }
  7745.  
  7746. td = appendTd(tr);
  7747. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  7748. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  7749.  
  7750. tr = appendTr(tbody);
  7751. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  7752. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  7753.  
  7754. td = appendTd(tr);
  7755. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  7756. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  7757.  
  7758. /* Interface Tactique */
  7759. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7760. appendText(td,'Interface Tactique : ',true);
  7761. select = document.createElement('select');
  7762. select.id = 'itSelect';
  7763. appendOption(select,'none','Aucune');
  7764. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  7765. // seule interface supportée !
  7766. td.appendChild(select);
  7767.  
  7768. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7769. tbody = appendSubTable(td);
  7770. tbody.id = 'itBody';
  7771. select.onchange = onChangeIT;
  7772. var str = MY_getValue(numTroll+'.INFOSIT');
  7773. if(str) {
  7774. select.value = str.slice(0,str.indexOf('$'));
  7775. onChangeIT();
  7776. }
  7777.  
  7778. /* SCIZ */
  7779. // JWT
  7780. td = appendTd(appendTr(mainBody, 'mh_tdtitre'));
  7781. appendText(td, 'SCIZ :', true);
  7782. td = appendTd(appendTr(mainBody, 'mh_tdpage'));
  7783. td = appendTdText(td, 'JWT : ');
  7784. appendTextbox(td, 'text', 'sciz_jwt', 150, 500, MY_getValue(numTroll + '.SCIZJWT'));
  7785. // Event checkbox
  7786. td = appendTd(appendTr(mainBody, 'mh_tdpage'));
  7787. tbody = appendSubTable(td);
  7788. tr = appendTr(tbody)
  7789. td = appendTd(tr);
  7790. td.setAttribute('align', 'center');
  7791. appendCheckBox(td, 'sciz_cb_events', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_EVENTS')));
  7792. appendText(td, ' Surcharger les événementsde ma coterie');
  7793. // Treasure checkbox
  7794. td = appendTd(tr);
  7795. td.setAttribute('align', 'center');
  7796. appendCheckBox(td, 'sciz_cb_view_treasures', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_VIEW_TREASURES')));
  7797. appendText(td, ' Afficher les trésors identifiés par ma coterie dans la vue');
  7798. // Trolls data
  7799. td = appendTd(tr);
  7800. td.setAttribute('align', 'center');
  7801. appendCheckBox(td, 'sciz_cb_view_trolls', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_VIEW_TROLLS')));
  7802. appendText(td, ' Afficher les données des trolls de ma coterie dans la vue');
  7803.  
  7804. /* Options diverses */
  7805. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7806. appendText(td,'Options diverses :',true);
  7807. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7808. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  7809. appendText(td,
  7810. ' Afficher les caractéristiques des équipements des autres Trõlls');
  7811.  
  7812. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7813. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  7814. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  7815.  
  7816. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7817. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  7818. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  7819.  
  7820. // td = appendTd(appendTr(mainBody,'mh_tdpage')); // Roule 12/12/2019 ça ne fait plus rien
  7821. // appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  7822. // appendText(td,' Afficher la Vue avec les caractéristiques dans le Profil');
  7823.  
  7824. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7825. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  7826. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  7827.  
  7828. /* Bouton SaveAll */
  7829. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  7830. input = appendButton(td,'Sauvegarder',saveAll);
  7831. input.id = 'saveAll';
  7832. }
  7833.  
  7834. function insertCreditsTable(insertPt) {
  7835. var tbody = insertMainTable(insertPt);
  7836.  
  7837. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  7838. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  7839. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  7840.  
  7841. var ul = document.createElement('ul');
  7842. td.appendChild(ul);
  7843. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  7844. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  7845. appendLI(ul,'Reivax (4234) pour les infos bulles');
  7846. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  7847. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  7848. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  7849. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  7850. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  7851. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  7852. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  7853. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  7854. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  7855. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  7856. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  7857. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  7858. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  7859. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  7860. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  7861. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  7862. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  7863. }
  7864.  
  7865.  
  7866. /* [functions] Obsolètes */
  7867. function deleteEnchantement()
  7868. {
  7869. try
  7870. {
  7871. var idEquipement = this.getAttribute('name');
  7872. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  7873. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  7874. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  7875. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  7876. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  7877. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7878. var string = "";
  7879. for(var i=0;i<listeEquipement.length;i++)
  7880. {
  7881. if(listeEquipement[i]!=idEquipement)
  7882. if(string=="")
  7883. string = listeEquipement[i];
  7884. else
  7885. string += ";"+listeEquipement[i];
  7886. }
  7887. if(string=="")
  7888. {
  7889. MY_removeValue(numTroll+".enchantement.liste");
  7890. var table = this.parentNode.parentNode.parentNode.parentNode;
  7891. var parent = table.parentNode;
  7892. for(var i=0;i<parent.childNodes.length;i++)
  7893. {
  7894. if(parent.childNodes[i]==table)
  7895. {
  7896. parent.removeChild(parent.childNodes[i-1]);
  7897. parent.removeChild(parent.childNodes[i-1]);
  7898. parent.removeChild(parent.childNodes[i-1]);
  7899. break;
  7900. }
  7901. }
  7902. }
  7903. else
  7904. {
  7905. MY_getValue(numTroll+".enchantement.liste",string);
  7906. this.parentNode.parentNode.parentNode
  7907. .removeChild(this.parentNode.parentNode);
  7908. }
  7909. }
  7910. catch(e)
  7911. {
  7912. window.alert(e);
  7913. }
  7914. }
  7915. /* [functions] fin Obsolètes */
  7916.  
  7917. /*-[functions]---------------- Partie principale -----------------------------*/
  7918.  
  7919. function do_option() {
  7920. start_script(712);
  7921. var insertPoint = document.getElementById('footer1');
  7922. insertBefore(insertPoint,document.createElement('p'));
  7923. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  7924. ti.onclick = function (e) {
  7925. var evt = e || window.event;
  7926. if (evt.shiftKey) {
  7927. var txt = '';
  7928. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  7929. var k = localStorage.key(i);
  7930. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  7931. txt += k + "\t" + localStorage.getItem(k) + "\n";
  7932. }
  7933. copyTextToClipboard(txt);
  7934. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  7935. } else if (evt.ctrlKey) {
  7936. var tabK= [];
  7937. var sMatch = numTroll + '.';
  7938. var lMatch = sMatch.length;
  7939. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  7940. var k = localStorage.key(i);
  7941. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  7942. }
  7943. for (var i = 0; i < tabK.length; ++i ) {
  7944. MY_removeValue(tabK[i]);
  7945. }
  7946. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  7947. }
  7948. }
  7949. ti.title = 'Version ' + GM_info.script.version;
  7950. insertOptionTable(insertPoint);
  7951. /* insertion enchantements ici
  7952. if(...)
  7953. insertEnchantementTable();
  7954. */
  7955. insertBefore(insertPoint,document.createElement('p'));
  7956. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  7957. ti.onclick = function (e) {
  7958. var evt = e || window.event;
  7959. if (!evt.shiftKey) return;
  7960. var oldDev = MY_getValue('MZ_dev');
  7961. if (oldDev) {
  7962. MY_removeValue('MZ_dev');
  7963. } else {
  7964. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  7965. MY_setValue('MZ_dev', 1);
  7966. }
  7967. document.location.href = document.location.href;
  7968. }
  7969. insertCreditsTable(insertPoint);
  7970. insertBefore(insertPoint,document.createElement('p'));
  7971.  
  7972. /* [zone] Obsolète ?? */
  7973. if(MY_getValue(numTroll+".enchantement.liste")
  7974. && MY_getValue(numTroll+".enchantement.liste")!="" )
  7975. {
  7976. insertTitle(insertPoint, 'Les Enchantements en cours');
  7977. table = document.createElement('table');
  7978. table.setAttribute('width', '98%');
  7979. table.setAttribute('border', '0');
  7980. table.setAttribute('align', 'center');
  7981. table.setAttribute('cellpadding', '2');
  7982. table.setAttribute('cellspacing', '1');
  7983. table.setAttribute('class', 'mh_tdborder');
  7984.  
  7985. tbody = document.createElement('tbody');
  7986. table.appendChild(tbody);
  7987.  
  7988. tr = appendTr(tbody, 'mh_tdtitre');
  7989. appendTdText(tr, 'Equipement',1);
  7990. appendTdText(tr, 'Composants',1);
  7991. appendTdText(tr, 'Enchanteur',1);
  7992. appendTdText(tr, 'Action',1);
  7993.  
  7994. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7995. for(var i=0;i<listeEquipement.length;i++)
  7996. {
  7997. try
  7998. {
  7999. var idEquipement = listeEquipement[i];
  8000. var nomEquipement = MY_getValue(numTroll+".enchantement."
  8001. +idEquipement+".objet");
  8002. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  8003. +idEquipement+".enchanteur").split(";");
  8004. var ul = document.createElement('UL');
  8005. for(var j=0;j<3;j++)
  8006. {
  8007. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  8008. var v = MY_getValue(k);
  8009. if (v == null) { // protection Roule 26/08/2017
  8010. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  8011. continue;
  8012. }
  8013. var infoComposant = v.split(';');
  8014. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  8015. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  8016. continue;
  8017. }
  8018. var texte = infoComposant[4].replace("Ril ","Œil ");
  8019. for(var k=5;k<infoComposant.length;k++)
  8020. {
  8021. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  8022. }
  8023. li = appendLI(ul,texte);
  8024. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  8025. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  8026. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  8027. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  8028. string+= '<input type="hidden" name="q" value="min" />';
  8029. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  8030. 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>';
  8031.  
  8032. string+= '</form>';
  8033. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  8034. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  8035. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  8036. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  8037. li.innerHTML += string;
  8038. }
  8039. tr = appendTr(tbody, 'mh_tdpage');
  8040.  
  8041. td = appendTdText(tr, nomEquipement);
  8042. td.setAttribute('valign', 'center');
  8043.  
  8044. td = document.createElement('td');
  8045. td.appendChild(ul);
  8046. tr.appendChild(td);
  8047. td.setAttribute('valign', 'center');
  8048.  
  8049. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  8050. td.setAttribute('valign', 'center');
  8051.  
  8052. td = document.createElement('td');
  8053. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  8054. input.setAttribute('name', idEquipement);
  8055. tr.appendChild(td);
  8056. td.setAttribute('valign', 'center');
  8057. }
  8058. catch(e)
  8059. {
  8060. }
  8061. }
  8062. insertBefore(insertPoint, table);
  8063. insertBefore(insertPoint, document.createElement('p'));
  8064. }
  8065. /* [zone] fin Obsolète ?? */
  8066.  
  8067.  
  8068. displayScriptTime();
  8069. }
  8070.  
  8071. /*******************************************************************************
  8072. * This file is part of Mountyzilla. *
  8073. * *
  8074. * Mountyzilla is free software; you can redistribute it and/or modify *
  8075. * it under the terms of the GNU General Public License as published by *
  8076. * the Free Software Foundation; either version 2 of the License, or *
  8077. * (at your option) any later version. *
  8078. * *
  8079. * Mountyzilla is distributed in the hope that it will be useful, *
  8080. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8081. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8082. * GNU General Public License for more details. *
  8083. * *
  8084. * You should have received a copy of the GNU General Public License *
  8085. * along with Mountyzilla; if not, write to the Free Software *
  8086. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8087. *******************************************************************************/
  8088.  
  8089. // x~x equip
  8090.  
  8091. /**
  8092. * 2014-02-08 - v2.0a (from scratch)
  8093. * 2014-02-18 - v2.0a0
  8094. * - ajout calcul Carats / UM des minerais + totaux
  8095. * 2014-03-06 - v2.0a1
  8096. * - retour Infos EM des Champis
  8097. * TODO
  8098. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  8099. */
  8100.  
  8101. function traiteChampis() {
  8102. try{
  8103. var tr = document.getElementById('mh_objet_hidden_Champignon');
  8104. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8105. }
  8106. catch(e){return;}
  8107. if(trlist.length<=0) return;
  8108. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8109. var node = trlist.snapshotItem(i).childNodes[7];
  8110. var str = node.textContent.trim();
  8111. var type = str.slice(0,str.lastIndexOf(' '));
  8112. var mundi = mundiChampi[type];
  8113. if(!mundi) continue;
  8114. var urlImg = URL_MZimg
  8115. +'Competences/ecritureMagique.png';
  8116. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  8117. appendText(node,' ');
  8118. node.appendChild(img);
  8119. }
  8120. }
  8121.  
  8122. function traiteCompos() {
  8123. try {
  8124. var tr = document.getElementById('mh_objet_hidden_Composant');
  8125. var tbody = document.evaluate("./td/table/tbody",
  8126. tr, null, 9, null).singleNodeValue;
  8127. }
  8128. catch(e) {return;}
  8129. insererInfosEM(tbody);
  8130. }
  8131.  
  8132. function traiteMinerai() {
  8133. try{
  8134. var tr = document.getElementById('mh_objet_hidden_Minerai');
  8135. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8136. }
  8137. catch(e){return;}
  8138. if(trlist.length<=0) return;
  8139. var totaux = {};
  8140. var str;
  8141. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8142. var node = trlist.snapshotItem(i);
  8143. var nature = node.childNodes[7].textContent,
  8144. caracs = node.childNodes[9].textContent;
  8145. var taille = Number(caracs.match(/\d+/)[0]);
  8146. var coef = 1;
  8147. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  8148. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  8149. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  8150. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  8151. if(nature.indexOf('Mithril')!=-1) {
  8152. coef = 0.2*coef;
  8153. str = ' | UM: ';
  8154. }
  8155. else {
  8156. coef = 0.75*coef+1.25;
  8157. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  8158. str = ' | Carats: ';
  8159. }
  8160. var carats = Math.round(taille*coef)
  8161. appendText(node.childNodes[9], str+carats );
  8162. if(!totaux[nature]) {
  8163. totaux[nature] = [taille,carats];
  8164. }
  8165. else {
  8166. totaux[nature][0] += taille;
  8167. totaux[nature][1] += carats;
  8168. }
  8169. }
  8170. str = 'Total : ';
  8171. for(var nature in totaux) {
  8172. if(str.length>8) str += ', ';
  8173. if(nature.indexOf('Mithril')!=-1) {
  8174. str += nature+totaux[nature][1]+' UM';
  8175. }
  8176. else {
  8177. str += nature+totaux[nature][0]+'U/'
  8178. +totaux[nature][1]+'c';
  8179. }
  8180. }
  8181. /*var node = document.getElementById('mh_plus_Minerai');
  8182. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  8183. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  8184. if(!titre) return;*/
  8185. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  8186. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  8187. td.colSpan = 7;
  8188. }
  8189.  
  8190. function do_equip() {
  8191. start_script();
  8192.  
  8193. traiteChampis();
  8194. traiteCompos();
  8195. traiteMinerai();
  8196.  
  8197. displayScriptTime();
  8198. }
  8199.  
  8200. /*******************************************************************************
  8201. * This file is part of Mountyzilla. *
  8202. * *
  8203. * Mountyzilla is free software; you can redistribute it and/or modify *
  8204. * it under the terms of the GNU General Public License as published by *
  8205. * the Free Software Foundation; either version 2 of the License, or *
  8206. * (at your option) any later version. *
  8207. * *
  8208. * Mountyzilla is distributed in the hope that it will be useful, *
  8209. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8210. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8211. * GNU General Public License for more details. *
  8212. * *
  8213. * You should have received a copy of the GNU General Public License *
  8214. * along with Mountyzilla; if not, write to the Free Software *
  8215. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8216. *******************************************************************************/
  8217.  
  8218. // x~x diplo
  8219.  
  8220. /*
  8221. TODO:
  8222. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  8223. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  8224. V Étape 3: Ajout de la diplo perso
  8225. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  8226. V Étape 5: Ajout des fioritures (preview de la couleur...)
  8227.  
  8228. Options Globales:
  8229. Actuelles:
  8230. numTroll.USECSS,
  8231. numTroll.NODIPLO
  8232. NOMYTH
  8233. Nouvelles:
  8234. TODO numTroll.USECSS
  8235. numTroll.diplo.off (remplace NODIPLO)
  8236. numTroll.diplo.guilde
  8237. numTroll.diplo.perso
  8238.  
  8239. Structure de diplo.guilde:
  8240. isOn: 'true' ou 'false'
  8241. isDetailOn: 'true' ou 'false'
  8242. guilde
  8243. > id
  8244. > couleur
  8245. AllAmis,AllEnnemis: couleur
  8246. Amis0,...,Ennemis5
  8247. > Troll: idTroll1;...;
  8248. > Guilde: idGuilde1;...;
  8249. > titre
  8250. > couleur
  8251.  
  8252. Structure de diplo.perso:
  8253. isOn: 'true' ou 'false'
  8254. mythiques: couleur
  8255. Troll,Guilde,Monstre:
  8256. > id
  8257. > couleur
  8258. > description
  8259. */
  8260.  
  8261. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8262.  
  8263. function couleurAleatoire() {
  8264. var alph = '0123456789ABCDEF'.split('');
  8265. var clr = '#';
  8266. for (var i=0; i<6; i++) {
  8267. clr+=alph[ Math.floor(16*Math.random()) ];
  8268. }
  8269. return clr;
  8270. }
  8271.  
  8272. function isCouleur(str) {
  8273. return /^#[0-9A-F]{6}$/i.test(str);
  8274. }
  8275.  
  8276. /*-[functions]---------------- Analyse de la page ----------------------------*/
  8277.  
  8278. function appendChoixCouleur(node,id) {
  8279. var span = document.createElement('span');
  8280. span.id = 'span'+id;
  8281. if(isDetailOn) {
  8282. span.style.display = 'none';
  8283. }
  8284. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  8285. if(diploGuilde[id]) {
  8286. couleur = diploGuilde[id];
  8287. }
  8288. appendText(span,' - Couleur HTML: ');
  8289. var input = appendTextbox(span,'text',id,7,7,couleur);
  8290. input.onkeyup = previewCouleur;
  8291. input.onchange = previewCouleur;
  8292. input.onkeyup();
  8293. node.appendChild(span);
  8294. }
  8295.  
  8296. function insertChoixCouleur(node,id) {
  8297. var span = document.createElement('span');
  8298. span.id = 'span'+id;
  8299. // La couleur détaillée passera à une valeur aléatoire
  8300. // si toggle vers isDetailOn
  8301. var couleur = couleurAleatoire();
  8302. if(!isDetailOn) {
  8303. span.style.display = 'none';
  8304. } else if(diploGuilde[id]) {
  8305. couleur = diploGuilde[id].couleur;
  8306. }
  8307. appendText(span,' - Couleur HTML: ');
  8308. var input = appendTextbox(span,'text',id,7,7,couleur);
  8309. input.onkeyup = previewCouleur;
  8310. input.onchange = previewCouleur;
  8311. input.onkeyup();
  8312. insertBefore(node,span);
  8313. }
  8314.  
  8315. function setChoixCouleurs() {
  8316. try {
  8317. //var form = document.getElementsByName('ActionForm')[0];
  8318. var form = document.getElementById('mhPlay');
  8319. var nodesAE = document.evaluate(
  8320. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  8321. "./table/tbody/tr/th[@class='mh_tdtitre']",
  8322. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  8323. form, null, 7, null
  8324. );
  8325. var nodes = document.evaluate(
  8326. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  8327. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  8328. form, null, 7, null
  8329. );
  8330. } catch(e) {
  8331. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  8332. return false;
  8333. };
  8334. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  8335. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  8336. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  8337. for(var i=0 ; i<5 ; i++) {
  8338. nodes.snapshotItem(i).id = 'tdAmis'+i;
  8339. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  8340. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  8341. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  8342. }
  8343. return true;
  8344. }
  8345.  
  8346. function fetchDiploGuilde() {
  8347. try {
  8348. for(var AE in {Amis:0,Ennemis:0}) {
  8349. for(var i=0 ; i<5 ; i++) {
  8350. /* Récup des A/E de rang i */
  8351. var td = document.getElementById('td'+AE+i);
  8352. var ligne = td.getElementsByTagName('table')[0].rows;
  8353. var titre = trim(td.firstChild.textContent);
  8354. // On laisse la gestion des couleurs à setChoixCouleurs:
  8355. var couleur = document.getElementById(AE+i).value;
  8356. diploGuilde[AE+i] = {
  8357. Troll:'',
  8358. Guilde:'',
  8359. titre: titre,
  8360. couleur: couleur
  8361. };
  8362. for(var j=1 ; j<ligne.length ; j++) {
  8363. var str = trim(ligne[j].cells[0].textContent);
  8364. var idx = str.lastIndexOf('(');
  8365. var num = str.slice(idx+1,-1);
  8366. var type = trim(ligne[j].cells[1].textContent);
  8367. diploGuilde[AE+i][type] += num+';';
  8368. }
  8369. }
  8370. }
  8371. } catch(e) {
  8372. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  8373. return false;
  8374. }
  8375. return true;
  8376. }
  8377.  
  8378.  
  8379. /*-[functions]--------------------- Handlers ---------------------------------*/
  8380.  
  8381. function toggleDetails() {
  8382. isDetailOn = !isDetailOn;
  8383. for(var AE in {Amis:0,Ennemis:0}) {
  8384. document.getElementById('spanAll'+AE).style.display =
  8385. (isDetailOn?'none':'');
  8386. for(var i=0 ; i<5 ; i++) {
  8387. document.getElementById('span'+AE+i).style.display =
  8388. (isDetailOn?'':'none');
  8389. }
  8390. }
  8391. }
  8392.  
  8393. function toggleMythiques() {
  8394. isMythiquesOn = !isMythiquesOn;
  8395. document.getElementById('spanMythiques').style.display =
  8396. (isMythiquesOn?'':'none');
  8397. }
  8398.  
  8399. function previewCouleur() {
  8400. var value = this.value;
  8401. if(isCouleur(value)) {
  8402. this.style.backgroundColor = value;
  8403. this.title = '';
  8404. } else {
  8405. this.style.backgroundColor = '';
  8406. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  8407. }
  8408. }
  8409.  
  8410. function appendMenuType(node,duType) {
  8411. var select = document.createElement('select');
  8412. select.className = 'SelectboxV2';
  8413. var type = ['Guilde','Troll','Monstre'];
  8414. for(var i=0 ; i<3 ; i++) {
  8415. appendOption(select,type[i],type[i]);
  8416. if(type[i]==duType) { select.selectedIndex=i; }
  8417. }
  8418. node.appendChild(select);
  8419. }
  8420.  
  8421. function ajouteChamp(type,num,couleur,descr) {
  8422. var champs = document.getElementById('diploPerso');
  8423. var nb = champs.rows.length;
  8424. var tr = champs.insertRow(-1);
  8425. var td = appendTd(tr);
  8426. appendMenuType(td,type);
  8427. td = appendTd(tr);
  8428. appendText(td,' n°');
  8429. appendTextbox(td,'text','num'+nb,6,15,num);
  8430. td = appendTd(tr);
  8431. appendText(td,' couleur HTML:');
  8432. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  8433. input.onkeyup = previewCouleur;
  8434. input.onchange = previewCouleur;
  8435. input.onkeyup();
  8436. td = appendTd(tr);
  8437. appendText(td,' Description:');
  8438. appendTextbox(td,'text','descr'+nb,30,150,descr);
  8439. td = appendTd(tr);
  8440. var span = document.createElement('span');
  8441. appendText(span,'[ok!]',true);
  8442. span.style.visibility = 'hidden';
  8443. td.appendChild(span);
  8444. td = appendTd(tr);
  8445. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  8446. }
  8447.  
  8448. function retireCeChamp() {
  8449. var thisTr = this.parentNode.parentNode;
  8450. thisTr.parentNode.removeChild(thisTr);
  8451. var champs = document.getElementById('diploPerso');
  8452. if(champs.rows.length==0) { ajouteChamp(); }
  8453. }
  8454.  
  8455. function valideChamp(champ) {
  8456. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  8457. isCouleur(champ.cells[2].childNodes[1].value);
  8458. if(isValide) {
  8459. champ.cells[4].firstChild.style.visibility = 'visible';
  8460. } else {
  8461. champ.cells[4].firstChild.style.visibility = 'hidden';
  8462. }
  8463. return isValide;
  8464. }
  8465.  
  8466. function sauvegarderTout() {
  8467. /* Diplo de guilde */
  8468. diploGuilde.isOn =
  8469. document.getElementById('isGuildeOn').checked?'true':'false';
  8470. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  8471. var numGuilde = Number(document.getElementById('numGuilde').value);
  8472. var couleur = document.getElementById('couleurGuilde').value;
  8473. if(numGuilde) {
  8474. diploGuilde.guilde = {
  8475. id: numGuilde,
  8476. couleur: couleur
  8477. };
  8478. } else {
  8479. delete diploGuilde.guilde;
  8480. }
  8481. for(var AE in {Amis:0,Ennemis:0}) {
  8482. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  8483. for(var i=0 ; i<5 ; i++) {
  8484. if(isDetailOn) {
  8485. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  8486. } else {
  8487. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  8488. }
  8489. }
  8490. }
  8491. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  8492.  
  8493. /* Diplo personnelle (ex-fonction saveChamps) */
  8494. var champs = document.getElementById('diploPerso');
  8495. diploPerso = {
  8496. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  8497. Guilde: {},
  8498. Troll: {},
  8499. Monstre: {}
  8500. };
  8501. if(isMythiquesOn &&
  8502. isCouleur(document.getElementById('couleurMythiques').value)) {
  8503. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  8504. }
  8505. for(var i=0 ; i<champs.rows.length ; i++) {
  8506. if(valideChamp(champs.rows[i])) {
  8507. var type = champs.rows[i].cells[0].firstChild.value;
  8508. var num = champs.rows[i].cells[1].childNodes[1].value;
  8509. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  8510. var descr = champs.rows[i].cells[3].childNodes[1].value;
  8511. diploPerso[type][num] = {
  8512. couleur: couleur
  8513. };
  8514. if(descr) {
  8515. diploPerso[type][num].titre = descr;
  8516. }
  8517. }
  8518. }
  8519. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  8520.  
  8521. avertissement('Données sauvegardées');
  8522. }
  8523.  
  8524.  
  8525. /*-[functions]------------- Modifications de la page -------------------------*/
  8526.  
  8527. function creeTablePrincipale() {
  8528. var insertPt = document.getElementById('insertPt');
  8529.  
  8530. /* Titre + bouton de Sauvegarde */
  8531. var tr = insertTr(insertPt,'mh_tdtitre');
  8532. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  8533. appendButton(td,'Sauvegarder',sauvegarderTout);
  8534.  
  8535. /* Options fixes */
  8536. tr = insertTr(insertPt,'mh_tdpage');
  8537. td = appendTdText(tr,'Diplomatie de guilde:',true);
  8538. appendBr(td);
  8539. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  8540. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  8541. appendBr(td);
  8542. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  8543. appendText(td,'Utiliser des couleurs détaillées (10)');
  8544.  
  8545. /* Diplo personnelle */
  8546. tr = insertTr(insertPt,'mh_tdpage');
  8547. td = appendTdText(tr,'Diplomatie personnelle:',true);
  8548. appendBr(td);
  8549. // Diplo Mythiques
  8550. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  8551. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  8552. var span = document.createElement('span');
  8553. span.id = 'spanMythiques';
  8554. if(!isMythiquesOn) {
  8555. span.style.display = 'none';
  8556. }
  8557. var couleur = '#FFAAAA';
  8558. if(diploPerso.mythiques) {
  8559. couleur = diploPerso.mythiques;
  8560. }
  8561. appendText(span,' - couleur HTML:');
  8562. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  8563. input.onkeyup = previewCouleur;
  8564. input.onchange = previewCouleur;
  8565. input.onkeyup();
  8566. td.appendChild(span);
  8567. appendBr(td);
  8568. // Diplo éditable
  8569. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  8570. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  8571. appendBr(td);
  8572. var table = document.createElement('table');
  8573. table.id = 'diploPerso'
  8574. td.appendChild(table);
  8575. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8576. for(var num in diploPerso[type]) {
  8577. ajouteChamp(
  8578. type,
  8579. num,
  8580. diploPerso[type][num].couleur,
  8581. diploPerso[type][num].titre
  8582. );
  8583. }
  8584. }
  8585. if(table.rows.length==0) {
  8586. ajouteChamp();
  8587. }
  8588. appendButton(td,'Ajouter',ajouteChamp)
  8589. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  8590. appendText(td,' ');
  8591. appendButton(td,
  8592. 'Exemples de couleur',
  8593. function() {
  8594. var fenetre = window.open(
  8595. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  8596. 'Divers',
  8597. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  8598. 'status=0,menubar=0,resizable=1,scrollbars=1'
  8599. );
  8600. fenetre.focus();
  8601. }
  8602. );
  8603.  
  8604. /* Couleur de Guilde */
  8605. tr = insertTr(insertPt,'mh_tdtitre');
  8606. td = appendTdText(tr,'GUILDE',true);
  8607. appendText(td,' - n°');
  8608. appendTextbox(td,'text','numGuilde',5,10,
  8609. diploGuilde.guilde && diploGuilde.guilde.id ?
  8610. diploGuilde.guilde.id : ''
  8611. );
  8612. appendText(td,' - Couleur HTML: ');
  8613. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  8614. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  8615. diploGuilde.guilde.couleur : '#BBBBFF'
  8616. );
  8617. input.onkeyup = previewCouleur;
  8618. input.onchange = previewCouleur;
  8619. input.onkeyup();
  8620. }
  8621.  
  8622.  
  8623. /*-[functions]----------------------- Main -----------------------------------*/
  8624.  
  8625. function initDiplo(sType) {
  8626. var sDiplo = MY_getValue(numTroll + '.diplo.' + sType)
  8627. //console.log('sDiplo' + sType + '=' + sDiplo);
  8628. if (sDiplo && (sDiplo != 'null')) { // le stockage JSON nous donne parfois 'null'
  8629. return JSON.parse(sDiplo);
  8630. } else {
  8631. return {};
  8632. }
  8633. }
  8634. var diploGuilde = initDiplo('guilde');
  8635. var diploPerso = initDiplo('perso');
  8636. var isDetailOn = diploGuilde.isDetailOn=='true';
  8637. var isMythiquesOn = diploPerso.mythiques!=undefined;
  8638.  
  8639. function do_diplo() {
  8640. if(setChoixCouleurs() && fetchDiploGuilde()) {
  8641. creeTablePrincipale();
  8642. }
  8643. }
  8644.  
  8645. /*******************************************************************************
  8646. * This file is part of Mountyzilla. *
  8647. * *
  8648. * Mountyzilla is free software; you can redistribute it and/or modify *
  8649. * it under the terms of the GNU General Public License as published by *
  8650. * the Free Software Foundation; either version 2 of the License, or *
  8651. * (at your option) any later version. *
  8652. * *
  8653. * Mountyzilla is distributed in the hope that it will be useful, *
  8654. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8655. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8656. * GNU General Public License for more details. *
  8657. * *
  8658. * You should have received a copy of the GNU General Public License *
  8659. * along with Mountyzilla; if not, write to the Free Software *
  8660. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8661. *******************************************************************************/
  8662.  
  8663. // x~x cdmcomp
  8664.  
  8665. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  8666.  
  8667. function getNonNegInts(str) {
  8668. var nbrs = str.match(/\d+/g);
  8669. for(var i=0 ; i<nbrs.length ; i++) {
  8670. nbrs[i] = Number(nbrs[i]);
  8671. }
  8672. return nbrs;
  8673. }
  8674.  
  8675. function MZ_comp_traiteCdMcomp() {
  8676. // envoi au serveur (PHP) d'un objet avec
  8677. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  8678. // tstamp: l'horodatage
  8679. var oContexteCdM = MZ_analyseCdM('msgEffet', true); // analyse de la CdM, prépare l'envoi, prépare l'ajout de PV min/max selon blessure
  8680. oContexteCdM.nameBut = 'as_Action'; // nom du bouton avant lequel insérer le bouton ou les textes
  8681. if (!oContexteCdM.ok) {
  8682. if (oContexteCdM.error) {
  8683. window.console.log('MZ_comp_traiteCdMcomp, ' + oContexteCdM.error);
  8684. MZ_comp_addMessage(oContexteCdM, 'Erreur MZ, ' + oContexteCdM.error);
  8685. }
  8686. return;
  8687. }
  8688. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify( oContexteCdM.oData));
  8689.  
  8690. MZ_comp_addPvRestant(oContexteCdM);
  8691.  
  8692. var etimestamp = document.getElementById('hserveur');
  8693. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  8694. if (tstamp == undefined) {
  8695. /* dans le cas de la comp, le serveur se repliera sur la date/heure courrante
  8696. window.console.log('MZ_comp_traiteCdMcomp, pas de date/heure');
  8697. MZ_comp_addMessage(oContexteCdM, 'Impossible d\'envoyer la CdM à MZ, pas de date/heure');
  8698. return;
  8699. */
  8700. } else {
  8701. oContexteCdM.oData.tstamp = tstamp.replace(/\]/, '').trim();
  8702. }
  8703.  
  8704. // Envoi auto ou insertion bouton envoi (suivant option)
  8705. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  8706. oContexteCdM.sendInfoCDM();
  8707. MZ_comp_addMessage(oContexteCdM, 'CdM envoyée vers la base MountyZilla !');
  8708. } else {
  8709. insertButtonCdm('as_Action', oContexteCdM.sendInfoCDM);
  8710. }
  8711. }
  8712.  
  8713. function MZ_comp_addMessage(oContexteCdM, msg) {
  8714. var eBefore = document.getElementsByName(oContexteCdM.nameBut)[0].parentNode;
  8715. if (!eBefore) {
  8716. window.console.log('MZ_comp_addMessage, pas de ' + oContexteCdM.nameBut);
  8717. return;
  8718. }
  8719. var p = document.createElement('p');
  8720. p.style.color = 'green';
  8721. appendText(p, msg);
  8722. insertBefore(eBefore, p);
  8723. }
  8724.  
  8725. function MZ_analyseCdM(idHTMLCdM, bIgnoreEltAbsent) { // rend un contexte
  8726. var eltCdM = document.getElementById(idHTMLCdM);
  8727. var oRet = {};
  8728. if (!eltCdM) {
  8729. oRet.ok = false;
  8730. if (!bIgnoreEltAbsent) oRet.error = 'Pas d\'elt ' + idHTMLCdM;
  8731. return oRet;
  8732. }
  8733.  
  8734. // le contexte contiendra
  8735. // txtHeure : le texte de l'heure de la CdM
  8736. // trBlessure : le <tr> de la ligne "blessure"
  8737. // txtBlessure : le texte donnant le % de blessure
  8738. // txtPv : le texte donnant les PV
  8739. // ok : 1 si on a bien reconnu une CdM
  8740. // oData : les data à envoyer en JSON au serveur MZ
  8741. oRet.oData = {}
  8742. oRet.oData.tabCdM = new Array();
  8743. for (var iElt = 0; iElt < eltCdM.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  8744. var eHTML = eltCdM.childNodes[iElt];
  8745. var s = undefined;
  8746. switch (eHTML.nodeName) {
  8747. case '#text':
  8748. s = eHTML.nodeValue;
  8749. // suite : même code que <B> ou <p>
  8750. case 'P':
  8751. case 'B':
  8752. if (s === undefined) s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8753. s = s.trim();
  8754. if (s != '') {
  8755. if (s.match(/aux *alentours* *de/i)) oRet.txtHeure = s;
  8756. if (s.match(/Connaissance *des* *Monstres/i)) oRet.ok = true;
  8757. oRet.oData.tabCdM.push(s);
  8758. }
  8759. break;
  8760. case 'TABLE':
  8761. var s = 'table';
  8762. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  8763. var eTr = eHTML.rows[iTr];
  8764. var tabTd = new Array();
  8765. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  8766. var eTd = eTr.cells[iTd];
  8767. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  8768. s = s.trim();
  8769. tabTd.push(s);
  8770. }
  8771. if (tabTd.length >= 2) {
  8772. if (tabTd[0].match(/Blessure/i)) {
  8773. oRet.trBlessure = eTr;
  8774. oRet.txtBlessure = tabTd[1]
  8775. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  8776. oRet.txtPv = tabTd[1]
  8777. }
  8778. }
  8779. oRet.oData.tabCdM.push(tabTd);
  8780. }
  8781. break;
  8782. case 'BR':
  8783. break; // ignore
  8784. default:
  8785. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8786. if (s != '') oRet.oData.tabCdM.push(s);
  8787. window.console.log('[MZ ' + GM_info.script.version + '] MZ_analyseCdM, type d\'élément non traité : ' + eHTML.nodeName + ' ' + s);
  8788. break;
  8789. }
  8790. }
  8791. oRet.oData.idTroll = numTroll;
  8792.  
  8793. // préparation de l'envoi d'une CdM issue de compte-rendu de compétence
  8794. // fonction définie ici pour avoir vue sur la variable tabCdM
  8795. oRet.sendInfoCDM = function () {
  8796. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  8797. var buttonCDM = this;
  8798. var texte = '';
  8799. FF_XMLHttpRequest({
  8800. method: 'POST',
  8801. url: URL_pageDispatcherV2,
  8802. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oRet.oData)),
  8803. headers : {
  8804. 'Content-type':'application/x-www-form-urlencoded',
  8805. },
  8806. trace: 'envoi CdM',
  8807. onload: function(responseDetails) {
  8808. texte = responseDetails.responseText;
  8809. buttonCDM.value = texte;
  8810. //window.console.log('buttonCDM.parentNode.firstChild.nodeName=' + buttonCDM.parentNode.firstChild.nodeName);
  8811. if (buttonCDM.parentNode.firstChild.nodeName == 'SPAN') { // smartphone
  8812. buttonCDM.parentNode.firstChild.innerHTML = texte;
  8813. }
  8814. if (!isDEV) buttonCDM.disabled = true;
  8815. },
  8816. onerror: function(responseDetails) {
  8817. var msgError = 'inconnue';
  8818. if (responseDetails.status == 0) msgError = ' HTTPS ou CORS'
  8819. if (responseDetails.error) msgError = responseDetails.error;
  8820. msgError = 'Erreur MZ ' + msgError;
  8821. buttonCDM.value = msgError;
  8822. if (buttonCDM.parentNode.firstChild.nodeName == 'SPAN') { // smartphone
  8823. buttonCDM.parentNode.firstChild.innerHTML = msgError;
  8824. }
  8825. },
  8826. });
  8827. }
  8828. return oRet;
  8829. }
  8830.  
  8831. function MZ_comp_addPvRestant(oContexteCdM) {
  8832. // Insertion de l'estimation des PV restants
  8833. if (MY_DEBUG) window.console.log('txtBlessure=' + oContexteCdM.txtBlessure + ', txtPv=' + oContexteCdM.txtPv);
  8834. if (oContexteCdM.txtBlessure === undefined || oContexteCdM.txtPv === undefined) return;
  8835. var pv = getPVsRestants(oContexteCdM.txtPv, oContexteCdM.txtBlessure);
  8836. if (MY_DEBUG) window.console.log('pv=' + pv);
  8837. if (!pv) return; // pv null si le monstre n'est pas blessé
  8838. var tr = document.createElement('tr');
  8839. oContexteCdM.trBlessure.parentNode.insertBefore(tr, oContexteCdM.trBlessure.nextSibling);
  8840. var th = appendThText(tr, pv[0], false);
  8841. th.className = oContexteCdM.trBlessure.cells[0].className;
  8842. var td = appendTdText(tr, pv[1], false);
  8843. var eSpan = document.createElement('span');
  8844. appendText(eSpan, ' (Calculé par Mountyzilla)');
  8845. eSpan.style.fontSize = "small";
  8846. eSpan.style.fontStyle = "italic";
  8847. td.appendChild(eSpan);
  8848. }
  8849.  
  8850. function do_cdmcomp() {
  8851. start_script(31);
  8852. MZ_comp_traiteCdMcomp();
  8853. displayScriptTime();
  8854. }
  8855.  
  8856. /*********************************************************************************
  8857. * This file is part of Mountyzilla. *
  8858. * *
  8859. * Mountyzilla is free software; you can redistribute it and/or modify *
  8860. * it under the terms of the GNU General Public License as published by *
  8861. * the Free Software Foundation; either version 2 of the License, or *
  8862. * (at your option) any later version. *
  8863. * *
  8864. * Mountyzilla is distributed in the hope that it will be useful, *
  8865. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8866. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8867. * GNU General Public License for more details. *
  8868. * *
  8869. * You should have received a copy of the GNU General Public License *
  8870. * along with Mountyzilla; if not, write to the Free Software *
  8871. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8872. *********************************************************************************/
  8873.  
  8874. // x~x cmdbot
  8875.  
  8876. /* v0.2 by Dab - 2013-08-20
  8877. * - patch dégueu pour gérer la décomposition P/M de l'armure
  8878. */
  8879.  
  8880. var buttonCDM;
  8881.  
  8882. /*******************************************************************************************
  8883. CDM :
  8884. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  8885.  
  8886. Il ne vous est pas possible d'améliorer cette compétence.
  8887.  
  8888. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  8889. Niveau : Inimaginable (entre 49 et 51)
  8890. Points de Vie : Surtrollesque (entre 450 et 470)
  8891. Blessure (Approximatif) : 0 %
  8892. Dés d'Attaque : Impressionnant (entre 30 et 32)
  8893. Dés d'Esquive : Impressionnant (entre 28 et 30)
  8894. Dés de Dégat : Très Fort (entre 18 et 20)
  8895. Dés de Régénération : Excellent (égal à 13)
  8896. Armure Physique : Moyen (entre 10 et 12)
  8897. Armure Magique : Faible (inférieur à 6)
  8898. Vue : Moyen (entre 9 et 11)
  8899. Maitrise Magique : Inimaginable (supérieur à 6000)
  8900. Résistance Magique : Inimaginable (supérieur à 6000)
  8901. Nombre d'attaques : 1
  8902. Vitesse de Déplacement : Normale
  8903. Voir le Caché : Oui
  8904. Attaque à distance : Non
  8905. Attaque magique : Oui
  8906. Vole : Non
  8907. Sang froid : Inexistant
  8908. DLA : Milieu
  8909. Durée Tour : Remarquable (entre 9 et 11)
  8910. Chargement : Vide
  8911. Bonus Malus : Aucun
  8912.  
  8913. Vous avez également gagné 1 PX pour la réussite.
  8914. *******************************************************************************************
  8915. BOT :
  8916. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  8917.  
  8918. Le Monstre ciblé fait partie des : Mort-Vivant
  8919.  
  8920. Niveau : Incroyable (entre 36 et 38)
  8921. *******************************************************************************************/
  8922.  
  8923. function getNNInt(str) {
  8924. var nbrs = str.match(/\d+/g);
  8925. for (var i=0 ; i<nbrs.length ; i++)
  8926. nbrs[i] = parseInt(nbrs[i]);
  8927. return nbrs;
  8928. }
  8929.  
  8930. // envoi d'une CdM issue d'un message du BOT
  8931. function sendCDM() {
  8932. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  8933. document, null, 9, null).singleNodeValue;
  8934. /* ancienne version à supprimer
  8935. cdm = td.innerHTML;
  8936. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  8937. "$3$4 ($1 - N°$2)<br>");
  8938. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  8939. 'Blessure : XX % (approximativement)');
  8940. // Supprime la décomposition P/M de l'Armure
  8941. var bgn = cdm.indexOf('Armure Physique');
  8942. if (bgn!=-1) {
  8943. var end = cdm.indexOf('Vue')-2;
  8944. var lines = cdm.substring(bgn,end).split('<br>');
  8945. var armp = getNNInt(lines[0]);
  8946. var armm = getNNInt(lines[1]);
  8947. if (lines[0].indexOf('(inf')!=-1)
  8948. armp = [0,armp[0]];
  8949. if (lines[1].indexOf('(inf')!=-1)
  8950. armm = [0,armm[0]];
  8951. var insrt = 'Armure : ';
  8952. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  8953. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  8954. else
  8955. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  8956. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  8957. }
  8958. cdm = cdm.replace(/<br>/g,'\n');
  8959. */
  8960.  
  8961. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  8962. //window.console.log(tdTxt);
  8963. var oData = {};
  8964. oData.tabCdM = tdTxt.split(/\n/);
  8965. // nettoyage entête : enlève le premier élément tant que
  8966. // - suite de *
  8967. // - "MOUNTYHALL - La Terre des Trõlls"
  8968. // - ligne vide (la première expression régulière matche les lignes vides)
  8969. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  8970. // 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
  8971. var iLigneNonVide;
  8972. for (var i = 0; i < oData.tabCdM.length; i++) {
  8973. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  8974. if (iLigneNonVide === undefined)
  8975. oData.tabCdM.splice(i);
  8976. else
  8977. oData.tabCdM.splice(iLigneNonVide+1);
  8978. break;
  8979. }
  8980. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  8981. }
  8982. //window.console.log(JSON.stringify(oData));
  8983.  
  8984. FF_XMLHttpRequest({
  8985. method: 'POST',
  8986. url: URL_pageDispatcherV2,
  8987. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8988. headers : {
  8989. /* inutile, à supprimer
  8990. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8991. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8992. */
  8993. 'Content-type':'application/x-www-form-urlencoded',
  8994. },
  8995. trace: 'envoi CdM msg du bot',
  8996. onload: function(responseDetails) {
  8997. buttonCDM.value=responseDetails.responseText;
  8998. buttonCDM.disabled = true;
  8999. }
  9000. });
  9001. }
  9002.  
  9003. function MZ_traiteCdMmsg() {
  9004. var oContexteCdM = MZ_analyseCdM('messageContent'); // analyse de la CdM, prépare l'envoi, prépare l'ajout de PV min/max selon blessure
  9005. oContexteCdM.nameBut = 'bForward'; // nom du bouton avant lequel insérer le bouton ou les textes
  9006. if (!oContexteCdM.ok) {
  9007. if (oContexteCdM.error) {
  9008. window.console.log('MZ_traiteCdMmsg, ' + oContexteCdM.error);
  9009. MZ_comp_addMessage(oContexteCdM, 'Erreur MZ, ' + oContexteCdM.error);
  9010. }
  9011. return;
  9012. }
  9013. if (MY_DEBUG) window.console.log('oContexteCdM=' + JSON.stringify( oContexteCdM));
  9014.  
  9015. MZ_comp_addPvRestant(oContexteCdM);
  9016.  
  9017. if (oContexteCdM.txtHeure) {
  9018. var m = oContexteCdM.txtHeure.match(/\d+\/\d+\/\d+ +\d+:\d+:\d+/);
  9019. if (m) var tstamp = m[0];
  9020. }
  9021. if (tstamp == undefined) {
  9022. window.console.log('MZ_traiteCdMmsg, pas de date/heure');
  9023. MZ_comp_addMessage(oContexteCdM, 'Impossible d\'envoyer la CdM à MZ, pas de date/heure');
  9024. return;
  9025. }
  9026. oContexteCdM.oData.tstamp = tstamp.trim();
  9027. oContexteCdM.oData.bMsgBot = 1;
  9028.  
  9029. // Insertion bouton envoi
  9030. insertButtonCdm(oContexteCdM.nameBut, oContexteCdM.sendInfoCDM);
  9031.  
  9032. /* à supprimer
  9033. // Teste si ce message du bot est un message de CdM
  9034. var tdMessageContent = document.getElementById('messageContent');
  9035. if (!tdMessageContent) return;
  9036.  
  9037. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  9038. document, null, 9, null).singleNodeValue;
  9039. if (!td) return false;
  9040.  
  9041. cdm = td.innerHTML;
  9042.  
  9043. // Insertion de l'estimation des PV restants
  9044. var des = cdm.indexOf('Dés');
  9045. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  9046. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  9047. if(pv)
  9048. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  9049.  
  9050. // Insertion bouton envoi + espace
  9051. buttonCDM = insertButtonCdm('bClose',sendCDM);
  9052. */
  9053. }
  9054.  
  9055. /*function traitePouvoir() {
  9056. // Teste si ce message du bot est un message de CdM
  9057. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  9058. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  9059. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  9060. if (!td)
  9061. return false;
  9062.  
  9063. var infos = td.innerHTML;
  9064. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  9065. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  9066. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  9067. var date = /alors : ([^<]+)\./.exec(infos)[1];
  9068. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  9069. var effetPouvoir="";
  9070. var full=false;
  9071. if(infos.indexOf("REDUIT")!=-1) {
  9072. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  9073. }
  9074. else {
  9075. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  9076. full=true;
  9077. }
  9078. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  9079. // On insère le bouton et un espace
  9080. //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));
  9081. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  9082. if(!MY_getValue('AUTOSENDPOUV'))
  9083. {
  9084. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  9085. button.setAttribute("onClick", "window.open('" + url
  9086. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  9087. + "this.value='Merci de votre participation'; this.disabled = true;");
  9088. }
  9089. else
  9090. {
  9091. FF_XMLHttpRequest({
  9092. method: 'GET',
  9093. url: url,
  9094. headers : {
  9095. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9096. 'Accept': 'application/atom+xml,application/xml,text/xml'
  9097. }});
  9098. }
  9099. }*/
  9100.  
  9101. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  9102. MZ_traiteCdMmsg();
  9103. }
  9104. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  9105.  
  9106. /*******************************************************************************
  9107. * This file is part of Mountyzilla. *
  9108. * *
  9109. * Mountyzilla is free software; you can redistribute it and/or modify *
  9110. * it under the terms of the GNU General Public License as published by *
  9111. * the Free Software Foundation; either version 2 of the License, or *
  9112. * (at your option) any later version. *
  9113. * *
  9114. * Mountyzilla is distributed in the hope that it will be useful, *
  9115. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9116. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9117. * GNU General Public License for more details. *
  9118. * *
  9119. * You should have received a copy of the GNU General Public License *
  9120. * along with Mountyzilla; if not, write to the Free Software *
  9121. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9122. *******************************************************************************/
  9123.  
  9124. // x~x menu
  9125. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  9126.  
  9127. var menuRac, mainIco;
  9128.  
  9129. // met à jour les carac sauvegardées (position, DLA, etc.)
  9130. function updateData() {
  9131. var inputs = document.getElementsByTagName('input');
  9132. var divs = document.getElementsByTagName('div');
  9133.  
  9134. //window.console.log('inputs=' + JSON.stringify(inputs));
  9135. if (inputs && inputs.length > 0) {
  9136. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  9137. numTroll = inputs[0].value;
  9138. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  9139. MY_setValue('NUM_TROLL', numTroll);
  9140. MY_setValue('NIV_TROLL',inputs[1].value);
  9141. if(!MY_getValue(numTroll+'.caracs.rm')) {
  9142. MY_setValue(numTroll+'.caracs.rm',0);
  9143. // assure l'init des 4 var de libs
  9144. }
  9145. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  9146. } else {
  9147. // onclick="EnterPJView(91305,750,550)"
  9148. var tabA = document.getElementsByTagName('a');
  9149. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  9150. var s = tabA[0].onclick.toString();;
  9151. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  9152. var m = s.match(/\((\d+) *,/);
  9153. //window.console.log('m=' + JSON.stringify(m));
  9154. numTroll = parseInt(m[1]);
  9155. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  9156. MY_setValue('NUM_TROLL', numTroll);
  9157. } else {
  9158. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  9159. }
  9160. }
  9161.  
  9162. var DLA = new Date(
  9163. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  9164. );
  9165. if(MY_getValue(numTroll+'.DLA.encours')) {
  9166. var DLAstockee = new Date(
  9167. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  9168. );
  9169. if(DLA>DLAstockee) {
  9170. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  9171. // Pose un pb en cas de décalage de DLA
  9172. }
  9173. }
  9174. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  9175.  
  9176. try {
  9177. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  9178. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  9179. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  9180. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  9181. } catch(e) {
  9182. 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, '‹'));
  9183. }
  9184. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  9185. }
  9186.  
  9187. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9188. function initRaccourcis() {
  9189. var anotherURL = MY_getValue('URL1');
  9190. if(!anotherURL) { return; }
  9191.  
  9192. /* Création de l'icône faisant apparaître le menu */
  9193. mainIco = document.createElement('img');
  9194. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  9195. if(!urlIco) {
  9196. urlIco =
  9197. URL_MZimg + 'mz_logo_small.png';
  9198. }
  9199. mainIco.src = urlIco;
  9200. mainIco.alt = 'MZ';
  9201. mainIco.style = 'position:fixed; top:0px; left:0px';
  9202. mainIco.onmouseover = afficheMenu;
  9203. document.body.appendChild(mainIco);
  9204.  
  9205. /* Création du menu des Raccourcis */
  9206. menuRac = document.createElement('div');
  9207. menuRac.className = 'mh_textbox';
  9208. menuRac.style =
  9209. 'position:fixed; top:10px; left:10px;'+
  9210. 'max-width:190px;'+
  9211. 'border-radius: 4px; padding: 4px;'+
  9212. 'z-index: 500;'+
  9213. 'visibility: hidden;';
  9214. document.body.appendChild(menuRac);
  9215. document.addEventListener('mousemove',cacheMenu,false);
  9216. var i=1;
  9217. while(anotherURL) {
  9218. var a = document.createElement('a');
  9219. var url = MY_getValue('URL'+i);
  9220. var nom = MY_getValue('URL'+i+'.nom');
  9221. var ico = MY_getValue('URL'+i+'.ico');
  9222. a.href = url;
  9223. a.target = '_blank';
  9224. if(ico) {
  9225. var txt = nom ? nom : '';
  9226. var img = createImage(ico,txt);
  9227. a.appendChild(img);
  9228. }
  9229. else {
  9230. appendText(a,'['+nom+']');
  9231. }
  9232. menuRac.appendChild(a);
  9233. appendBr(menuRac);
  9234. i++;
  9235. anotherURL = MY_getValue('URL'+i);
  9236. }
  9237. }
  9238.  
  9239. function afficheMenu() {
  9240. menuRac.style.visibility = 'visible';
  9241. }
  9242.  
  9243. function cacheMenu(e) {
  9244. if(menuRac.style.visibility=='hidden') { return; }
  9245. // Position souris
  9246. var ptX = e.clientX;
  9247. var ptY = e.clientY;
  9248. // On recalcule en live les BoundingBox pour mainIco et menuRac
  9249. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  9250. var menuRect = menuRac.getBoundingClientRect();
  9251. var icoRect = mainIco.getBoundingClientRect();
  9252. if((ptX>icoRect.width || ptY>icoRect.height) &&
  9253. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  9254. menuRac.style.visibility = 'hidden';
  9255. }
  9256. }
  9257.  
  9258. // ajout de l'icône, branchée sur un refresh
  9259. function initUpdateCoordGauche() {
  9260. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  9261. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  9262. var img = document.createElement('img');
  9263. img.src = URL_MZimg + 'recycl.png'
  9264. img.onclick = function(evt) {
  9265. document.location.href = document.location.href;
  9266. };
  9267. img.title = 'Mise à jour de la localisation';
  9268. img.style.cursor = 'pointer';
  9269. img.style.position = 'absolute';
  9270. img.style.bottom = 0;
  9271. img.style.left = 0;
  9272. div.appendChild(img);
  9273. }
  9274.  
  9275. // ajout sur les raccoucis des mêmes popup que dans le profil
  9276. function MZ_initPopupFrameGauche() {
  9277. var eListeFavoris = document.getElementById('listeFavori');
  9278. if (!eListeFavoris) {
  9279. window.console.log('MZ **erreur** pas de listeFavori dans la frame de gauche');
  9280. return;
  9281. }
  9282. var tabA = eListeFavoris.getElementsByTagName('A');
  9283. for (var i = 0; i < tabA.length; i++) {
  9284. var a = tabA[i];
  9285. setInfos(a,epure(trim(a.textContent)),'*',1);
  9286. }
  9287. }
  9288.  
  9289. function do_menu() {
  9290. // met à jour les carac sauvegardées (position, DLA, etc.)
  9291. updateData();
  9292. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9293. initRaccourcis();
  9294. // Ajout bouton de mise à jour coordonnées
  9295. initUpdateCoordGauche();
  9296. // Ajout popup sur les raccourcis des actions
  9297. //MZ_initPopupFrameGauche();
  9298. }
  9299.  
  9300. /*******************************************************************************
  9301. * This file is part of Mountyzilla. *
  9302. * *
  9303. * Mountyzilla is free software; you can redistribute it and/or modify *
  9304. * it under the terms of the GNU General Public License as published by *
  9305. * the Free Software Foundation; either version 2 of the License, or *
  9306. * (at your option) any later version. *
  9307. * *
  9308. * Mountyzilla is distributed in the hope that it will be useful, *
  9309. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9310. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9311. * GNU General Public License for more details. *
  9312. * *
  9313. * You should have received a copy of the GNU General Public License *
  9314. * along with Mountyzilla; if not, write to the Free Software *
  9315. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9316. *******************************************************************************/
  9317.  
  9318. // x~x vue
  9319.  
  9320. /* TODO
  9321. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  9322. * prévoir fix ("delete infos")
  9323. */
  9324.  
  9325. /*--------------------------- Variables Globales -----------------------------*/
  9326.  
  9327. // Position actuelle
  9328. var currentPosition=[0,0,0];
  9329.  
  9330. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  9331. var porteeVue=[0,0,0,0];
  9332.  
  9333. // Fenêtres déplaçables
  9334. var winCurr = null;
  9335. var offsetX, offsetY;
  9336.  
  9337. // Diplomatie
  9338. var Diplo = {
  9339. Guilde: {},
  9340. Troll: {},
  9341. Monstre: {}
  9342. // .mythiques: uniquement si option activée
  9343. };
  9344. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  9345.  
  9346. // Infos tactiques
  9347. // => MZ_Tactique.popup
  9348.  
  9349. // Utilisé pour supprimer les monstres "engagés"
  9350. var listeEngages = {};
  9351. var isEngagesComputed = false;
  9352. var cursorOnLink = false; // DEBUG: wtf ?
  9353.  
  9354. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  9355. && MY_getValue(numTroll+'.enchantement.liste')!='';
  9356.  
  9357. // Checkboxes de filtrage
  9358. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  9359. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  9360. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  9361. comboBoxNiveauMin, comboBoxNiveauMax, comboBoxFamille;
  9362.  
  9363. /* Acquisition & Stockage des données de DB */
  9364. var typesAFetcher = {
  9365. 'monstres':1,
  9366. 'trolls':1,
  9367. 'tresors':1,
  9368. 'champignons':1,
  9369. 'lieux':1
  9370. }
  9371.  
  9372. var MZ_EtatCdMs = { // zone où sont stockées les variables "globales" pour la gestion des cdM et infos tactiques
  9373. nbMonstres: 0,
  9374. tr_monstres: [],
  9375. lastIndexDone: 0,
  9376. isCDMsRetrieved: false, // = si les CdM ont déjà été DL
  9377. listeCDM: [],
  9378. // Gère l'affichage en cascade des popups de CdM
  9379. yIndexCDM: 0,
  9380. tdWitdh: 110,
  9381. };
  9382.  
  9383. var VueContext = {};
  9384. var tr_trolls = {}, tr_tresors = {},
  9385. tr_champignons = {}, tr_lieux = {};
  9386. var nbTrolls = 0, nbTresors = 0,
  9387. nbChampignons = 0, nbLieux = 0;
  9388.  
  9389. function fetchData(type) {
  9390. var node;
  9391. try {
  9392. node = document.getElementById('mh_vue_hidden_'+type);
  9393. VueContext['tr_'+type] = node.getElementsByTagName('tr');
  9394. VueContext['nb'+type[0].toUpperCase()+type.slice(1)] = VueContext['tr_'+type].length-1;
  9395. } catch(e) {
  9396. window.console.warn('[MZ Vue] Erreur acquisition type '+type, e);
  9397. }
  9398. }
  9399.  
  9400. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  9401.  
  9402. function positionToString(arr) {
  9403. return arr.join(';');
  9404. }
  9405.  
  9406. function savePosition() {
  9407. // Stocke la position (à jour) de la vue pour les autres scripts
  9408. // DEBUG: Lesquels et pourquoi?
  9409. var pos = getPosition();
  9410. MY_setValue(numTroll+'.position.X',pos[0]);
  9411. MY_setValue(numTroll+'.position.Y',pos[1]);
  9412. MY_setValue(numTroll+'.position.N',pos[2]);
  9413. }
  9414.  
  9415.  
  9416. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  9417. /* INFOS :
  9418. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  9419. * sont identifiables via leur Name
  9420. * les tables-listings sont identifiables via l'ID du tr conteneur
  9421. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  9422. */
  9423.  
  9424. /* [functions] Récup données Utilisateur */
  9425. function getPosition() {
  9426. // Pour rétrocompatibilité
  9427. return currentPosition;
  9428. }
  9429.  
  9430. function getPorteVue() {
  9431. // Pour rétrocompatibilité
  9432. return porteeVue;
  9433. }
  9434.  
  9435. function getVue() {
  9436. // Retourne [vueHpure, vueVpure]
  9437. var vues = getPorteVue();
  9438. return [ vues[0], vues[1] ];
  9439. }
  9440.  
  9441. // Roule 11/03/2016
  9442. /* [functions] Récup données monstres, trolls, etc. */
  9443. function getXxxDistance(xxx, i) {
  9444. return parseInt(VueContext['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  9445. }
  9446. function getXxxPosition(xxx, i) {
  9447. var tds = VueContext['tr_' + xxx.toLowerCase()][i].childNodes;
  9448. var l = tds.length;
  9449. return [
  9450. parseInt(tds[l-3].textContent),
  9451. parseInt(tds[l-2].textContent),
  9452. parseInt(tds[l-1].textContent)
  9453. ];
  9454. }
  9455.  
  9456.  
  9457. /* [functions] Récup données monstres */
  9458. function getMonstreDistance(i) {
  9459. //debugMZ('getMonstreDistance, i=' + i + ', tr=' + MZ_EtatCdMs.tr_monstres[i].innerHTML);
  9460. return parseInt(MZ_EtatCdMs.tr_monstres[i].cells[0].textContent);
  9461. }
  9462.  
  9463. function getMonstreID(i) {
  9464. return Number(MZ_EtatCdMs.tr_monstres[i].cells[2].firstChild.nodeValue);
  9465. }
  9466.  
  9467. function getMonstreIDByTR(tr) {
  9468. return tr.cells[2].firstChild.nodeValue;
  9469. }
  9470.  
  9471. function getMonstreLevelNode(i) {
  9472. return MZ_EtatCdMs.tr_monstres[i].cells[3];
  9473. }
  9474.  
  9475. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  9476. if(!MZ_EtatCdMs.isCDMsRetrieved) return false;
  9477. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  9478. if (!donneesMonstre) return false;
  9479. var niv = donneesMonstre.niv;
  9480. if (niv == undefined) return false;
  9481. if (limitMin > 0 && niv.max && niv.max < limitMin) return true;
  9482. if (limitMax > 0 && niv.min && niv.min > limitMax) return true;
  9483. return false;
  9484. }
  9485.  
  9486. function getMonstreNomNode(i) {
  9487. try {
  9488. var td = document.evaluate(
  9489. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  9490. MZ_EtatCdMs.tr_monstres[i], null, 9, null
  9491. ).singleNodeValue;
  9492. return td;
  9493. } catch(e) {
  9494. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  9495. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  9496. }
  9497. }
  9498.  
  9499. function getMonstreNom(i) {
  9500. return getMonstreNomByTR(MZ_EtatCdMs.tr_monstres[i]);
  9501. }
  9502.  
  9503. function getMonstreNomByTR(tr) {
  9504. try {
  9505. var nom = document.evaluate(
  9506. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  9507. tr, null, 2, null
  9508. ).stringValue;
  9509. return nom;
  9510. } catch(e) {
  9511. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  9512. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  9513. }
  9514. }
  9515.  
  9516. function getMonstrePosition(i) {
  9517. var tds = MZ_EtatCdMs.tr_monstres[i].childNodes;
  9518. var l = tds.length;
  9519. return [
  9520. parseInt(tds[l-3].textContent),
  9521. parseInt(tds[l-2].textContent),
  9522. parseInt(tds[l-1].textContent)
  9523. ];
  9524. }
  9525.  
  9526. function appendMonstres(txt) {
  9527. for(var i=1; i<=MZ_EtatCdMs.nbMonstres ; i++)
  9528. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  9529. return txt;
  9530. }
  9531.  
  9532. function getMonstres() {
  9533. var vue = getVue();
  9534. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9535. }
  9536.  
  9537. function bddMonstres(start,stop) {
  9538. if(!start) { var start = 1; }
  9539. if(!stop) { var stop = MZ_EtatCdMs.nbMonstres; }
  9540. stop = Math.min(MZ_EtatCdMs.nbMonstres,stop);
  9541. var txt='';
  9542. for(var i=start ; i<=stop ; i++) {
  9543. txt += getMonstreID(i)+';'+
  9544. getMonstreNom(i)+';'+
  9545. positionToString(getMonstrePosition(i))+'\n';
  9546. }
  9547. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  9548. }
  9549.  
  9550. /* [functions] Récup données Trolls */
  9551.  
  9552. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  9553. var COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  9554.  
  9555. function getTrollDistance(i) {
  9556. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  9557. }
  9558.  
  9559. var MZ_cache_col_TrollID;
  9560. var MZ_cache_col_TrollNOM;
  9561. var MZ_cache_col_TrollGUILDE;
  9562. var MZ_cache_col_TrollNIV;
  9563.  
  9564. function MZ_find_col_titre(trs, titre) {
  9565. var l = titre.length;
  9566. for (var i=0; i < trs[0].cells.length; i++)
  9567. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  9568. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  9569. return 0;
  9570. }
  9571.  
  9572. function getTrollID(i) {
  9573. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  9574. // Roule 08/03/2017 protection
  9575. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  9576. if (isNaN(iTroll)) return;
  9577. if (iTroll == 0) return;
  9578. return iTroll;
  9579. }
  9580.  
  9581. function getTrollNomNode(i) {
  9582. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  9583. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  9584. }
  9585.  
  9586. function getTrollNivNode(i) {
  9587. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  9588. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  9589. }
  9590.  
  9591. function getTrollGuilde(i) {
  9592. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9593. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  9594. }
  9595.  
  9596. function getTrollGuildeID(i) {
  9597. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9598. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  9599. var href;
  9600. try {
  9601. 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"
  9602. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  9603. } catch(e) { // debug pb remonté par Marsak
  9604. window.console.error(traceStack(e, 'getTrollGuildeID')
  9605. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  9606. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  9607. return -1;
  9608. }
  9609. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  9610. }
  9611. return -1;
  9612. }
  9613.  
  9614. function getTrollPosition(i) {
  9615. var tds = tr_trolls[i].childNodes;
  9616. var l = tds.length;
  9617. return [
  9618. parseInt(tds[l-3].textContent),
  9619. parseInt(tds[l-2].textContent),
  9620. parseInt(tds[l-1].textContent)
  9621. ];
  9622. }
  9623.  
  9624. function bddTrolls() {
  9625. var txt='#DEBUT TROLLS\n'+
  9626. numTroll+';'+positionToString(getPosition())+'\n';
  9627. for(var i=1 ; i<=nbTrolls ; i++) {
  9628. txt += getTrollID(i)+';'+
  9629. positionToString(getTrollPosition(i))+'\n';
  9630. }
  9631. return txt+'#FIN TROLLS';
  9632. }
  9633.  
  9634. /* [functions] Récup données Trésors */
  9635. function getTresorDistance(i) {
  9636. return tr_tresors[i].cells[0].firstChild.nodeValue;
  9637. }
  9638.  
  9639. function getTresorID(i) {
  9640. return trim(tr_tresors[i].cells[2].textContent);
  9641. }
  9642.  
  9643. function getTresorNom(i) {
  9644. // Utilisation de textContent pour régler le "bug de Pollux"
  9645. return trim(tr_tresors[i].cells[3].textContent);
  9646. }
  9647.  
  9648. function getTresorPosition(i) {
  9649. var tds = tr_tresors[i].childNodes;
  9650. var l = tds.length;
  9651. return [
  9652. parseInt(tds[l-3].textContent),
  9653. parseInt(tds[l-2].textContent),
  9654. parseInt(tds[l-1].textContent),
  9655. ];
  9656. }
  9657.  
  9658. function bddTresors(dmin,start,stop) {
  9659. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  9660. if(!dmin) { var dmin = 0; }
  9661. if(!start) { var start = 1; }
  9662. if(!stop) { var stop = nbTresors; }
  9663. stop = Math.min(nbTresors,stop);
  9664. var txt='';
  9665. for(var i=start ; i<=stop ; i++) {
  9666. if(getTresorDistance(i)>=dmin) {
  9667. txt += getTresorID(i)+';'+
  9668. getTresorNom(i)+';'+
  9669. positionToString(getTresorPosition(i))+'\n';
  9670. }
  9671. }
  9672. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  9673. }
  9674.  
  9675. /* [functions] Récup données Champignons */
  9676. // DEBUG: Pas de colonne "Référence" sur serveur de test
  9677. function getChampignonNom(i) {
  9678. return trim(tr_champignons[i].cells[2].textContent);
  9679. }
  9680.  
  9681. function getChampignonPosition(i) {
  9682. var tds = tr_champignons[i].childNodes;
  9683. var l = tds.length;
  9684. return [
  9685. parseInt(tds[l-3].textContent),
  9686. parseInt(tds[l-2].textContent),
  9687. parseInt(tds[l-1].textContent)
  9688. ];
  9689. }
  9690.  
  9691. function bddChampignons() {
  9692. var txt='';
  9693. for(var i=1 ; i<=nbChampignons ; i++) {
  9694. txt += ';'+ // Les champis n'ont pas de Référence
  9695. getChampignonNom(i)+';'+
  9696. positionToString(getChampignonPosition(i))+'\n';
  9697. }
  9698. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  9699. }
  9700.  
  9701. /* [functions] Récup données Lieux */
  9702. function getLieuDistance(i) {
  9703. return parseInt(tr_lieux[i].cells[0].textContent);
  9704. }
  9705.  
  9706. function getLieuID(i) {
  9707. return parseInt(tr_lieux[i].cells[2].textContent);
  9708. }
  9709.  
  9710. function getLieuNom(i) {
  9711. // Conversion ASCII pour éviter les bugs des Vues externes
  9712. return trim(tr_lieux[i].cells[3].textContent);
  9713. }
  9714.  
  9715. function getLieuPosition(i) {
  9716. var tds = tr_lieux[i].childNodes;
  9717. var l = tds.length;
  9718. return [
  9719. parseInt(tds[l-3].textContent),
  9720. parseInt(tds[l-2].textContent),
  9721. parseInt(tds[l-1].textContent)
  9722. ];
  9723. }
  9724.  
  9725. function appendLieux(txt) {
  9726. for(var i = 1; i < nbLieux+1; i++) {
  9727. var tds = x_lieux[i].childNodes;
  9728. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  9729. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  9730. }
  9731. return txt;
  9732. }
  9733.  
  9734. function getLieux() {
  9735. var vue = getVue();
  9736. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9737. }
  9738.  
  9739. function bddLieux(start,stop) {
  9740. if(!start) { var start = 1; }
  9741. if(!stop) { var stop = nbLieux; }
  9742. stop = Math.min(nbLieux,stop);
  9743. var txt='';
  9744. for(var i=start ; i<=stop ; i++) {
  9745. txt += getLieuID(i)+';'+
  9746. epure(getLieuNom(i))+';'+
  9747. positionToString(getLieuPosition(i))+'\n';
  9748. }
  9749. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  9750. }
  9751.  
  9752.  
  9753. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  9754.  
  9755. function saveCheckBox(chkbox, pref) {
  9756. // Enregistre et retourne l'état d'une CheckBox
  9757. var etat = chkbox.checked;
  9758. MY_setValue(pref, etat ? 'true' : 'false' );
  9759. return etat;
  9760. }
  9761.  
  9762. function recallCheckBox(chkbox, pref) {
  9763. // Restitue l'état d'une CheckBox
  9764. chkbox.checked = (MY_getValue(pref)=='true');
  9765. }
  9766.  
  9767. function saveComboBox(cbb, pref) {
  9768. // Enregistre et retourne l'état d'une ComboBox
  9769. var opt = cbb.options[cbb.selectedIndex];
  9770. if (!opt) return;
  9771. var etat = cbb.options[cbb.selectedIndex].value;
  9772. MY_setValue(pref, etat);
  9773. return etat;
  9774. }
  9775.  
  9776. function recallComboBox(cbb, pref) {
  9777. // Restitue l'état d'une ComboBox
  9778. var nb = MY_getValue(pref);
  9779. if(nb) cbb.value = nb;
  9780. return nb;
  9781. }
  9782.  
  9783. function synchroniseFiltres() {
  9784. // Récupération de toutes les options de la vue
  9785. var wasActive =
  9786. Number(recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE')) +
  9787. Number(recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE')) +
  9788. (recallComboBox(comboBoxFamille,'FAMILLEMONSTRE') == 0 ? 0 : 1); // Roule 30/01/2020 on obtient du non numérique si il y a filtre par famille
  9789. if(wasActive>0) {
  9790. debutFiltrage('Monstres');
  9791. }
  9792. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9793. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9794. recallCheckBox(checkBoxMythiques,'NOMYTH');
  9795. recallCheckBox(checkBoxEngages,'NOENGAGE');
  9796. recallCheckBox(checkBoxLevels,'NOLEVEL');
  9797. recallCheckBox(checkBoxIntangibles,'NOINT');
  9798. recallCheckBox(checkBoxGG,'NOGG');
  9799. recallCheckBox(checkBoxCompos,'NOCOMP');
  9800. recallCheckBox(checkBoxBidouilles,'NOBID');
  9801. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  9802. recallCheckBox(checkBoxTrou,'NOTROU');
  9803. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9804. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  9805. if(MY_getValue('NOINFOEM')!='true')
  9806. recallCheckBox(checkBoxEM,'NOEM');
  9807. }
  9808.  
  9809.  
  9810. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  9811.  
  9812. function getVueScript() {
  9813. try {
  9814. var txt = bddTrolls()+
  9815. bddMonstres()+
  9816. bddChampignons()+
  9817. bddTresors()+
  9818. bddLieux()+
  9819. '#DEBUT ORIGINE\n'+
  9820. getPorteVue()[2]+';'+positionToString(getPosition())+
  9821. '\n#FIN ORIGINE\n';
  9822. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  9823. return txt;
  9824. } catch(e) {
  9825. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  9826. window.console.error(traceStack(e, 'getVueScript'))
  9827. }
  9828. }
  9829.  
  9830. /* [functions] Menu Vue 2D */
  9831. var vue2Ddata = {
  9832. 'Bricol\' Vue': {
  9833. url: URL_bricol_mountyhall + 'vue_form.php',
  9834. paramid: 'vue',
  9835. func: getVueScript,
  9836. extra_params: {
  9837. 'mode': 'vue_SP_Vue2',
  9838. 'screen_width': window.screen.width
  9839. }
  9840. },
  9841. 'Vue du CCM': {
  9842. url: URL_vue_CCM,
  9843. paramid: 'vue',
  9844. func: getVueScript,
  9845. extra_params: {
  9846. 'id': numTroll+';'+positionToString(getPosition())
  9847. }
  9848. },
  9849. 'Vue Gloumfs 2D': {
  9850. url: URL_vue_Gloumfs2D,
  9851. paramid: 'vue_mountyzilla',
  9852. func: getVueScript,
  9853. extra_params: {}
  9854. },
  9855. 'Vue Gloumfs 3D': {
  9856. url: URL_vue_Gloumfs3D,
  9857. paramid: 'vue_mountyzilla',
  9858. func: getVueScript,
  9859. extra_params: {}
  9860. },
  9861. 'Grouky Vue!': {
  9862. url: URL_vue_Grouky,
  9863. paramid: 'vue',
  9864. func: getVueScript,
  9865. extra_params: {
  9866. 'type_vue': 'V5b1'
  9867. }
  9868. },
  9869. /*'DEBUG': {
  9870. url: 'http://weblocal/testeur.php',
  9871. paramid: 'vue',
  9872. func: getVueScript,
  9873. extra_params: {}
  9874. }*/
  9875. };
  9876.  
  9877. function refresh2DViewButton() {
  9878. // = EventListener menu+bouton vue 2D
  9879. var vueext = document.getElementById('selectVue2D').value;
  9880. MY_setValue('VUEEXT',vueext);
  9881. var form = document.getElementById('viewForm');
  9882. form.innerHTML = '';
  9883. form.method = 'post';
  9884. form.action = vue2Ddata[vueext].url;
  9885. form.target = '_blank';
  9886. appendHidden(form, vue2Ddata[vueext].paramid, '');
  9887. for(var key in vue2Ddata[vueext].extra_params) {
  9888. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  9889. }
  9890. appendSubmit(form, 'Voir',
  9891. function() {
  9892. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  9893. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  9894. vue2Ddata[vueext].func();
  9895. }
  9896. );
  9897. }
  9898.  
  9899. function set2DViewSystem() {
  9900. // Initialise le système de vue 2D
  9901. // Recherche du point d'insertion
  9902. var center;
  9903. try {
  9904. // Roule 09/03/2019, encore un changement MH, je fais suivre comme je peux
  9905. center = document.getElementById('titre2');
  9906. // version initiale "pré-Roule"
  9907. if (!center) center = document.evaluate(
  9908. "//h2[@id='titre2']/following-sibling::center",
  9909. document, null, 9, null
  9910. ).singleNodeValue;
  9911. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  9912. if (!center) center = document.evaluate(
  9913. "//h2[@id='titre2']/following-sibling::div",
  9914. document, null, 9, null
  9915. ).singleNodeValue;
  9916.  
  9917. } catch(e) {
  9918. avertissement("Erreur d'initialisation du système de vue 2D");
  9919. window.console.error(traceStack(e, 'set2DViewSystem'));
  9920. return;
  9921. }
  9922.  
  9923. // Récupération de la dernière vue utilisée
  9924. var vueext = MY_getValue('VUEEXT');
  9925. if(!vueext || !vue2Ddata[vueext]) {
  9926. // sinon, la vue Bricol'Trolls est employée par défaut
  9927. vueext = 'Bricol\' Vue';
  9928. }
  9929.  
  9930. try {
  9931. // Création du sélecteur de vue externe
  9932. selectVue2D = document.createElement('select');
  9933. selectVue2D.id = 'selectVue2D';
  9934. selectVue2D.className = 'SelectboxV2';
  9935. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  9936. for(var view in vue2Ddata) {
  9937. appendOption(selectVue2D, view, view);
  9938. }
  9939. selectVue2D.value = vueext;
  9940. selectVue2D.onchange = refresh2DViewButton;
  9941.  
  9942. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  9943. var form = document.createElement('form');
  9944. form.id = 'viewForm';
  9945.  
  9946. // Insertion du système de vue
  9947. var table = document.createElement('table');
  9948. var tr = appendTr(table);
  9949. var td = appendTd(tr);
  9950. td.appendChild(selectVue2D);
  9951. td = appendTd(tr);
  9952. td.style.fontSize = '0px'; // gère le bug de l'extra character
  9953. td.appendChild(form);
  9954. if (center.id == 'titre2') { // 09/03/2019 nouvelle méthode
  9955. var eDiv = document.createElement('div');
  9956. eDiv.appendChild(table);
  9957. eDiv.style.witdth = '100%';
  9958. eDiv.style.textAlign = 'center';
  9959. table.style.width = '180px';
  9960. table.style.margin = '0 auto';
  9961. center.parentNode.insertBefore(eDiv,center.nextSibling);
  9962. } else { // ancienne méthode
  9963. center.insertBefore(table,center.firstChild);
  9964. insertBr(center.childNodes[1]);
  9965. }
  9966.  
  9967. // Appelle le handler pour initialiser le bouton de submit
  9968. refresh2DViewButton();
  9969. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  9970. } catch(e) {
  9971. avertissement("Erreur de traitement du système de vue 2D");
  9972. window.console.error(traceStack(e, 'set2DViewSystem'));
  9973. }
  9974. }
  9975.  
  9976. /* [functions] Tableau d'Infos */
  9977. function initialiseInfos() {
  9978. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  9979. var
  9980. infoTab = document.getElementsByName('LimitViewForm')[0].
  9981. getElementsByTagName('table')[0],
  9982. tbody = infoTab.tBodies[0],
  9983. thead = infoTab.createTHead(),
  9984. tr = appendTr(thead,'mh_tdtitre'),
  9985. td = appendTdText(tr,'INFORMATIONS',true),
  9986. span = document.createElement('span');
  9987.  
  9988. // Récupération de la position du joueur
  9989. try {
  9990. var strPos = document.evaluate(
  9991. ".//li/b/text()[contains(.,'X = ')]",
  9992. infoTab, null, 9, null
  9993. ).singleNodeValue.nodeValue;
  9994. // ***INIT GLOBALE*** currentPosition
  9995. currentPosition = getIntegers(strPos);
  9996. debugMZ("retrievePosition(): "+currentPosition);
  9997. } catch(e) {
  9998. // Si on ne trouve pas le "X ="
  9999. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  10000. }
  10001.  
  10002. // Récupération des portées (max et limitée) de la vue
  10003. try {
  10004. var
  10005. nodes = document.evaluate(
  10006. ".//li/b/text()[contains(.,'horizontalement') "+
  10007. "or contains(.,'verticalement')]",
  10008. infoTab, null, 7, null
  10009. ),
  10010. array = [];
  10011. for(var i=0 ; i<4 ; i++) {
  10012. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  10013. }
  10014. // ***INIT GLOBALE*** porteeVue
  10015. porteeVue = array;
  10016. } catch(e) {
  10017. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  10018. }
  10019.  
  10020. infoTab.id = 'infoTab'; // Pour scripts externes
  10021. tbody.id = 'corpsInfoTab';
  10022. tbody.rows[0].cells[0].colSpan = 2;
  10023. td.colSpan = 3;
  10024. td.onmouseover = function() {
  10025. this.style.cursor = 'pointer';
  10026. this.className = 'mh_tdpage';
  10027. };
  10028. td.onmouseout = function() {
  10029. this.className = 'mh_tdtitre';
  10030. };
  10031. td.onclick = function() {
  10032. toggleTableauInfos(false);
  10033. };
  10034.  
  10035. span.id = 'msgInfoTab';
  10036. span.style.display = 'none';
  10037. appendText(
  10038. span,
  10039. ' => Position : X = '+currentPosition[0]+
  10040. ', Y = '+currentPosition[1]+
  10041. ', N = '+currentPosition[2]+
  10042. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  10043. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  10044. true
  10045. );
  10046. td.appendChild(span);
  10047.  
  10048. tr = appendTr(tbody,'mh_tdpage');
  10049. td = appendTdText(tr,'EFFACER : ',true);
  10050. td.align = 'center';
  10051. td.className = 'mh_tdtitre';
  10052. td.width = 100;
  10053. td = appendTdCenter(tr,2);
  10054. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  10055. checkBoxGG = appendCheckBoxSpan(
  10056. td,'delgg',filtreTresors," Les GG'"
  10057. ).firstChild;
  10058. checkBoxCompos = appendCheckBoxSpan(
  10059. td,'delcomp',filtreTresors,' Les Compos'
  10060. ).firstChild;
  10061. checkBoxBidouilles = appendCheckBoxSpan(
  10062. td,'delbid',filtreTresors,' Les Bidouilles'
  10063. ).firstChild;
  10064. checkBoxIntangibles = appendCheckBoxSpan(
  10065. td,'delint',filtreTrolls,' Les Intangibles'
  10066. ).firstChild;
  10067. checkBoxGowapsA = appendCheckBoxSpan(
  10068. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  10069. ).firstChild;
  10070. checkBoxGowapsS = appendCheckBoxSpan(
  10071. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  10072. ).firstChild;
  10073. checkBoxEngages = appendCheckBoxSpan(
  10074. td,'delengage',filtreMonstres,' Les Engagés'
  10075. ).firstChild;
  10076. checkBoxLevels = appendCheckBoxSpan(
  10077. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  10078. ).firstChild;
  10079. checkBoxDiplo = appendCheckBoxSpan(
  10080. td,'delDiplo',refreshDiplo,' La Diplomatie'
  10081. ).firstChild;
  10082. checkBoxTrou = appendCheckBoxSpan(
  10083. td,'deltrou',filtreLieux,' Les Trous'
  10084. ).firstChild;
  10085. checkBoxMythiques = appendCheckBoxSpan(
  10086. td,'delmyth',filtreMonstres,' Les Mythiques'
  10087. ).firstChild;
  10088. if(MY_getValue('NOINFOEM')!='true') {
  10089. checkBoxEM = appendCheckBoxSpan(
  10090. td,'delem',filtreMonstres,' Les Composants EM'
  10091. ).firstChild;
  10092. }
  10093. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  10094. td,'deltres',filtreTresors,' Les Trésors non libres'
  10095. ).firstChild;
  10096. checkBoxTactique = appendCheckBoxSpan(
  10097. td,'deltactique',updateTactique,' Les Infos tactiques'
  10098. ).firstChild;
  10099.  
  10100. if(MY_getValue('INFOPLIE')) {
  10101. toggleTableauInfos(true);
  10102. }
  10103. }
  10104.  
  10105. function toggleTableauInfos(firstRun) {
  10106. var
  10107. msg = document.getElementById('msgInfoTab'),
  10108. corps = document.getElementById('corpsInfoTab'),
  10109. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  10110. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  10111. if(!firstRun) {
  10112. infoplie = !infoplie;
  10113. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  10114. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  10115. }
  10116. if(infoplie) {
  10117. msg.style.display = '';
  10118. corps.style.display = 'none';
  10119. } else {
  10120. msg.style.display = 'none';
  10121. corps.style.display = '';
  10122. }
  10123. }
  10124.  
  10125. /* [functions] Filtres */
  10126. function prepareFiltrage(ref,width) {
  10127. // = Initialise le filtre 'ref'
  10128. try {
  10129. var tdTitre = document.getElementById(ref.toLowerCase()).closest('td');
  10130. } catch(e) {
  10131. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée', e);
  10132. return false;
  10133. }
  10134. if(width) { tdTitre.width = width+'px'; }
  10135. // Ajout du tr de Filtrage (masqué)
  10136. var tbody = tdTitre.parentNode.parentNode;
  10137. var tr = appendTr(tbody,'mh_tdpage');
  10138. tr.style.display = 'none';
  10139. tr.id = 'trFiltre'+ref;
  10140. var td = appendTd(tr);
  10141. td.colSpan = 5;
  10142. // Ajout du bouton de gestion de Filtrage
  10143. var tdBtn = insertAfterTd(tdTitre);
  10144. tdBtn.id = 'tdInsert'+ref;
  10145. var btn = appendButton(tdBtn,'Filtrer');
  10146. btn.id = 'btnFiltre'+ref;
  10147. btn.onclick = function() {
  10148. debutFiltrage(ref);
  10149. };
  10150. return td;
  10151. }
  10152.  
  10153. function debutFiltrage(ref) {
  10154. // = Handler de début de filtrage (filtre 'ref')
  10155. document.getElementById('trFiltre'+ref).style.display = '';
  10156. var btn = document.getElementById('btnFiltre'+ref);
  10157. btn.value = 'Annuler Filtre';
  10158. btn.onclick = function() {
  10159. finFiltrage(ref);
  10160. };
  10161. }
  10162.  
  10163. function finFiltrage(ref) {
  10164. // = Handler de fin de filtrage (filtre 'ref')
  10165. /* On réassigne le bouton 'Filtrer' */
  10166. document.getElementById('trFiltre'+ref).style.display = 'none';
  10167. var btn = document.getElementById('btnFiltre'+ref);
  10168. btn.value = 'Filtrer';
  10169. btn.onclick = function() {
  10170. debutFiltrage(ref);
  10171. };
  10172. /* Réinitialisation filtres */
  10173. document.getElementById('str'+ref).value = '';
  10174. switch(ref) {
  10175. case 'Monstres':
  10176. document.getElementById('nivMinMonstres').value = 0;
  10177. document.getElementById('nivMaxMonstres').value = 0;
  10178. document.getElementById('FamilleMonstres').value = 0;
  10179. break;
  10180. case 'Trolls':
  10181. document.getElementById('strGuildes').value = '';
  10182. }
  10183. /* Nettoyage (=lance le filtre) */
  10184. // Ici this = MZ.global = sandBox de travail de MZ
  10185. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  10186. //this['filtre'+ref]();
  10187. switch (ref) {
  10188. case 'Monstres':
  10189. filtreMonstres();
  10190. break;
  10191. case 'Trolls':
  10192. filtreTrolls();
  10193. break;
  10194. case 'Tresors':
  10195. filtreTresors();
  10196. break;
  10197. case 'Lieux':
  10198. filtreLieux();
  10199. break;
  10200. default:
  10201. window.console.log('cas incongru dans finFiltrage : ' + ref);
  10202. break;
  10203. }
  10204. }
  10205.  
  10206. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  10207. var bouton = appendButton(td,nomBouton,onClick);
  10208. appendText(td,'\u00a0');
  10209. var textbox = appendTextbox(td,'text',id,15,30);
  10210. textbox.onkeypress = function(event) {
  10211. try {
  10212. if(event.keyCode==13) {
  10213. event.preventDefault();
  10214. bouton.click();
  10215. }
  10216. }
  10217. catch(e){
  10218. window.alert(e)
  10219. }
  10220. };
  10221. }
  10222.  
  10223. function ajoutFiltreMenu(tr,id,onChange,liste) {
  10224. var select = document.createElement('select');
  10225. select.id = id;
  10226. select.onchange = onChange;
  10227. appendOption(select,0,'Aucun');
  10228. if (liste == undefined) {
  10229. for(var i=1 ; i<=60 ; i++) {
  10230. appendOption(select,i,i);
  10231. }
  10232. } else {
  10233. liste.forEach(function(f) {appendOption(select,f,f);});
  10234. }
  10235. tr.appendChild(select);
  10236. return select;
  10237. }
  10238.  
  10239. function ajoutDesFiltres() {
  10240. /* Monstres */
  10241. var td = prepareFiltrage('Monstres',130);
  10242. if(td) {
  10243. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  10244. appendText(td,'\u00a0\u00a0\u00a0');
  10245. appendText(td,'Niveau Min: ');
  10246. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  10247. appendText(td,'\u00a0');
  10248. appendText(td,'Niveau Max: ');
  10249. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  10250. appendText(td,'\u00a0');
  10251. appendText(td,'Famille: ');
  10252. comboBoxFamille = ajoutFiltreMenu(td,'FamilleMonstres',filtreMonstres,['Animal', 'Insecte','Démon','Humanoide','Monstre','Mort-Vivant']);
  10253. }
  10254. /* Trõlls */
  10255. td = prepareFiltrage('Trolls',50);
  10256. if(td) {
  10257. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  10258. appendText(td,'\u00a0\u00a0\u00a0');
  10259. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  10260. }
  10261. /* Trésors */
  10262. td = prepareFiltrage('Tresors',55);
  10263. if(td) {
  10264. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  10265. }
  10266. /* Lieux */
  10267. td = prepareFiltrage('Lieux',40);
  10268. if(td) {
  10269. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  10270. }
  10271. }
  10272.  
  10273. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  10274.  
  10275. /* [functions] Affichage de la colonne des niveaux */
  10276. function insertLevelColumn() {
  10277. // Appelé dans le code attaché à la page de vue et au click/unclick de la checkbox
  10278.  
  10279. var td = insertThText(getMonstreLevelNode(0),'Niv.',false);
  10280. //td.width = 25;
  10281.  
  10282. /* plus de colgroup le 08/07/2020. Mais comme ça pourait revenir, je laisse le bout de code en commentaire (Roule)
  10283. var eColGroup = getMonstreLevelNode(0).closest('table').getElementsByTagName('colgroup')[0];
  10284. var eCol = document.createElement('col');
  10285. eCol.style.width= '35px';
  10286. insertBefore(eColGroup.children[3],eCol);
  10287. */
  10288.  
  10289. var monsterStyle = document.getElementById('mh_vue_hidden_monstres').getElementsByTagName('style')[0];
  10290. monsterStyle.innerHTML =
  10291. '.mh_tdborder.footable#VueMONSTRE th:nth-child(1), ' +
  10292. '.mh_tdborder.footable#VueMONSTRE td:nth-child(1) { width: 40px; text-align: right; }' +
  10293. '.mh_tdborder.footable#VueMONSTRE th:nth-child(2) { width: 33px; }' +
  10294. '.mh_tdborder.footable#VueMONSTRE th:nth-child(3), ' +
  10295. '.mh_tdborder.footable#VueMONSTRE td:nth-child(3) { width: 50px; text-align: right; }' +
  10296. '.mh_tdborder.footable#VueMONSTRE th:nth-child(4) { width: 35px; text-align: center; }' +
  10297. '.mh_tdborder.footable#VueMONSTRE th:nth-child(6), ' +
  10298. '.mh_tdborder.footable#VueMONSTRE td:nth-child(6), ' +
  10299. '.mh_tdborder.footable#VueMONSTRE th:nth-child(7), ' +
  10300. '.mh_tdborder.footable#VueMONSTRE td:nth-child(7), ' +
  10301. '.mh_tdborder.footable#VueMONSTRE th:nth-child(8), ' +
  10302. '.mh_tdborder.footable#VueMONSTRE td:nth-child(8) { width: 30px; text-align: center; }';
  10303. /* version MH hors MZ
  10304. .mh_tdborder.footable#VueMONSTRE th:nth-child(1),
  10305. .mh_tdborder.footable#VueMONSTRE td:nth-child(1) { width: 40px; text-align: right; }
  10306. .mh_tdborder.footable#VueMONSTRE th:nth-child(2) { width: 33px; }
  10307. .mh_tdborder.footable#VueMONSTRE th:nth-child(3) { width: 50px; }
  10308. .mh_tdborder.footable#VueMONSTRE th:nth-child(5),
  10309. .mh_tdborder.footable#VueMONSTRE td:nth-child(5),
  10310. .mh_tdborder.footable#VueMONSTRE th:nth-child(6),
  10311. .mh_tdborder.footable#VueMONSTRE td:nth-child(6),
  10312. .mh_tdborder.footable#VueMONSTRE th:nth-child(7),
  10313. .mh_tdborder.footable#VueMONSTRE td:nth-child(7) { width: 30px; text-align: center; }
  10314. */
  10315.  
  10316. td.id = 'MZ_TITRE_NIVEAU_MONSTRE';
  10317. for(var i=1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10318. //window.console.log('nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', MZ_EtatCdMs.tr_monstres.length=' + MZ_EtatCdMs.tr_monstres.length); // debug Roule
  10319. td = insertTdText(getMonstreLevelNode(i), '-');
  10320. td.style = 'font-weight:bold;text-align:center;';
  10321. }
  10322. }
  10323.  
  10324. function toggleLevelColumn() { // Appelé par le code attaché à la page de vue et au click/unclick de la checkbox NOCDM
  10325. var eltMZ_TITRE_NIVEAU_MONSTRE = document.getElementById('MZ_TITRE_NIVEAU_MONSTRE'); // test si la colonne a déjà été ajoutée
  10326. if(saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  10327. 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é
  10328. // cacher tous les td
  10329. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10330. getMonstreLevelNode(i).style.display = 'none';
  10331. }
  10332. } else {
  10333. if (!eltMZ_TITRE_NIVEAU_MONSTRE) {
  10334. insertLevelColumn();
  10335. retrieveCDMs();
  10336. } else {
  10337. // afficher tous les td
  10338. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10339. getMonstreLevelNode(i).style.display = '';
  10340. }
  10341. }
  10342. }
  10343. }
  10344.  
  10345. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  10346. function basculeCDM(nom,id) {
  10347. // = Bascule l'affichage des popups CdM
  10348. if(MZ_EtatCdMs.listeCDM[id]) {
  10349. if(!document.getElementById('popupCDM'+id)) {
  10350. afficherCDM(nom, id);
  10351. } else {
  10352. cacherPopupCDM('popupCDM'+id);
  10353. }
  10354. } else {
  10355. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  10356. window.console.log("pas de CdM pour id=" + id + ', nom=' + nom);
  10357. }
  10358. }
  10359.  
  10360. function cacherPopupCDM(titre) {
  10361. var popup = document.getElementById(titre);
  10362. popup.parentNode.removeChild(popup);
  10363. }
  10364.  
  10365. function removeTableFromClickEvent() { // "this" est supposé être un <td> ou <th> d'une <table>
  10366. var table = this.parentNode.parentNode.parentNode; // <tr><tbody/thead/tfoot><table>
  10367. table.parentNode.removeChild(table);
  10368. }
  10369.  
  10370. /* DEBUG: Section à mettre à jour */
  10371. var selectionFunction;
  10372.  
  10373. function startDrag(evt) {
  10374. winCurr = this.parentNode;
  10375. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  10376. offsetX = evt.pageX - parseInt( winCurr.style.left );
  10377. offsetY = evt.pageY - parseInt( winCurr.style.top );
  10378. selectionFunction = document.body.style.MozUserSelect;
  10379. document.body.style.MozUserSelect = 'none';
  10380. winCurr.style.MozUserSelect = 'none';
  10381. return false;
  10382. }
  10383.  
  10384. function stopDrag(evt) {
  10385. winCurr.style.MozUserSelect = selectionFunction;
  10386. document.body.style.MozUserSelect = selectionFunction;
  10387. winCurr = null;
  10388. }
  10389.  
  10390. function drag(evt) {
  10391. if(winCurr==null) { return; }
  10392. evt = evt || window.event;
  10393. winCurr.style.left = (evt.pageX - offsetX)+'px';
  10394. winCurr.style.top = (evt.pageY - offsetY)+'px';
  10395. return false;
  10396. }
  10397. /* FIN DEBUG */
  10398. if(!isPage("MH_Play/Play_equipement")) {
  10399. // Conflit overlib/Tout_MZ:
  10400. // Double définition du "onmousemove" sur la page d'équipement
  10401. document.onmousemove = drag;
  10402. }
  10403.  
  10404. function afficherCDM(nom,id) {
  10405. // Crée la table de CdM du mob n° id
  10406. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10407. /* Début création table */
  10408. var table = createCDMTable(id,nom,donneesMonstre, removeTableFromClickEvent);
  10409. /* Ajout du titre avec gestion Drag & Drop */
  10410. var tr = table.firstChild;
  10411. tr.style.cursor = 'move';
  10412. tr.onmousedown = startDrag;
  10413. tr.onmouseup = stopDrag;
  10414. /* à supprimer, remplacé par un "x" sur l'entête
  10415. // Ajout du bouton "Fermer"
  10416. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  10417. tr.style.cursor = 'pointer';
  10418. tr.onmouseover = function() {
  10419. this.className = 'mh_tdpage';
  10420. };
  10421. tr.onmouseout = function() {
  10422. this.className = 'mh_tdtitre';
  10423. };
  10424. tr.idcdm = id;
  10425. tr.onclick = function() {
  10426. cacherPopupCDM('popupCDM'+this.idcdm);
  10427. this.className = 'mh_tdtitre';
  10428. };
  10429. td = appendTdText(tr,'Fermer',true);
  10430. td.colSpan = 2;
  10431. td.style = 'text-align:center;';
  10432. */
  10433. table.id = 'popupCDM'+id;
  10434. table.style.position = 'fixed';
  10435. table.style.backgroundColor = 'rgb(229, 222, 203)';
  10436. table.style.zIndex = 1;
  10437. //var topY = +(300+(30*MZ_EtatCdMs.yIndexCDM))%(30*Math.floor((window.innerHeight-400)/30));
  10438. table.style.left = +(window.innerWidth-365)+'px';
  10439. table.style.width = '300px';
  10440. /* Fin création table & Affichage */
  10441. document.body.appendChild(table);
  10442. var topY = 90 + (30*MZ_EtatCdMs.yIndexCDM);
  10443. //window.console.log('topY=' + topY + ', offsetHeight=' + table.offsetHeight + ', innerHeight=' + window.innerHeight);
  10444. if ((topY + table.offsetHeight) > window.innerHeight) {
  10445. MZ_EtatCdMs.yIndexCDM = 0; // on se repositionne en haut s'il n'y a pas assez de place
  10446. topY = 90;
  10447. } else {
  10448. MZ_EtatCdMs.yIndexCDM++; // décalage pour la fois suivante
  10449. }
  10450. table.style.top = topY + 'px';
  10451. }
  10452.  
  10453. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  10454. function showPopupError(sHTML) {
  10455. window.console.log('[MZ] affichage PopupError ' + sHTML);
  10456. var divpopup = document.createElement('div');
  10457. divpopup.id = 'divpopup';
  10458. divpopup.style =
  10459. 'position: fixed;'+
  10460. 'border: 3px solid #000000;'+
  10461. 'top: 300px;left: 10px;'+
  10462. 'background-color: red;'+
  10463. 'color: white;'+
  10464. 'font-size: xx-large;'+
  10465. 'z-index: 200;';
  10466. divpopup.innerHTML = sHTML;
  10467. var divcroix = document.createElement('div');
  10468. divcroix.style =
  10469. 'position: absolute;'+
  10470. 'top: 0;right: 0;'+
  10471. 'color: inherit;'+
  10472. 'font-size: inherit;'+
  10473. 'cursor: pointer;'+
  10474. 'z-index: 201;';
  10475. divcroix.innerHTML = "X";
  10476. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  10477. document.body.appendChild(divpopup);
  10478. divpopup.appendChild(divcroix);
  10479. }
  10480.  
  10481. function retrieveCDMs() {
  10482. // Récupère les CdM disponibles dans la BDD
  10483. // Lancé uniquement sur toggleLevelColumn
  10484. if(checkBoxLevels.checked) return;
  10485. // Roule, message si l'utilisateur a décoché "Menu d'actions contextuelles"
  10486. if (!MZ_EtatCdMs.tr_monstres[0].cells[2].innerHTML.match(/r[eéè]f/i)) {
  10487. 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);
  10488. return;
  10489. }
  10490. if (MZ_EtatCdMs.nbMonstres < 1) return;
  10491.  
  10492. var tReq = [];
  10493. var nbReq = 0;
  10494. var prevLastIndexDone = MZ_EtatCdMs.lastIndexDone;
  10495. for (var i=prevLastIndexDone+1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10496. //tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  10497. // ne pas demander pour les Gowaps
  10498. var nom = getMonstreNom(i);
  10499. if (nom.match(/^[^\[]*Gowap/i)) { // le mot Gowap peut être précédé par un template (qui ne contient donc pas [)
  10500. getMonstreLevelNode(i).innerHTML = '';
  10501. continue;
  10502. }
  10503. tReq.push({'index':i, 'id':getMonstreID(i), 'nom':nom});
  10504. nbReq++;
  10505. 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
  10506. }
  10507. MZ_EtatCdMs.lastIndexDone = i;
  10508. var startAjaxCdM = new Date();
  10509. window.console.log('[MZ] ' + MZ_formatDateMS() + ' lancement AJAX ' + nbReq + ' demandes niveaux monstres V2');
  10510.  
  10511. FF_XMLHttpRequest({
  10512. method: 'POST',
  10513. url: URL_MZgetCaracMonstre,
  10514. headers : {
  10515. 'Content-type':'application/x-www-form-urlencoded'
  10516. },
  10517. //data: 'l=' + tReq.join("\n"),
  10518. data: 'l=' + JSON.stringify(tReq),
  10519. trace: 'demande niveaux monstres V2',
  10520. onload: function(responseDetails) {
  10521. try {
  10522. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  10523. if (responseDetails.status == 0) return;
  10524. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  10525. var texte = responseDetails.responseText;
  10526. var infos = JSON.parse(texte);
  10527. displayScriptTime(new Date().getTime()-date_debut.getTime(), 'Analyse des CdM MZ');
  10528. if(infos.length==0) return;
  10529.  
  10530. // ajouter les styles CSS pour les popup
  10531. var mystyle = document.createElement('style');
  10532. mystyle.type = 'text/css';
  10533. var sCSS = '.MZtooltip {position: relative;color:red;text-align:center;}\n';
  10534. sCSS += '.MZtooltip .MZtooltiptext {visibility: hidden;width: 250px;padding: 5px 0;border:solid 1px;position: absolute;z-index: 1;color:black;background-color:white}\n';
  10535. sCSS += '.MZtooltip:hover .MZtooltiptext {visibility: visible;}\n';
  10536. mystyle.innerHTML = sCSS;
  10537. document.getElementsByTagName('head')[0].appendChild(mystyle);
  10538.  
  10539. // if (MY_DEBUG) {
  10540. // for (var i = 0; i < 20; i++) window.console.log('infos[' + i + ']=' + JSON.stringify(infos[i]));
  10541. // }
  10542. var begin2, end2, index;
  10543. for(var j=0 ; j<infos.length ; j++) {
  10544. var info = infos[j];
  10545. if (info.index == undefined) continue;
  10546. var eTdLevel = getMonstreLevelNode(info.index)
  10547. this.className = 'mh_tdpage';
  10548. var myColor = undefined;
  10549. if (info.niv != undefined && info.niv.max == -1 && info.Mode != 'cdm') {
  10550. eTdLevel.className = "MZtooltip";
  10551. eTdLevel.style.color = "black";
  10552. eTdLevel.innerHTML = 'Var.<span class="MZtooltiptext">Ce monstre est variable.<br />On ne peut pas avoir d\'information sans CdM.</span>';
  10553. } else if (!(info && info.esq)) {
  10554. //if (MY_DEBUG) window.console.log("pas d'esquive id=" + info.id + ", index=" + info.index);
  10555. eTdLevel.className = "MZtooltip";
  10556. 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>';
  10557. } else {
  10558. eTdLevel.innerHTML = mkMinMaxHTML(info.niv);
  10559. //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
  10560. myColor = MZ_CdMColorFromMode(info);
  10561. eTdLevel.style.cursor = 'pointer';
  10562. eTdLevel.onclick = function() {
  10563. basculeCDM(
  10564. getMonstreNomByTR(this.parentNode),
  10565. getMonstreIDByTR(this.parentNode)
  10566. );
  10567. };
  10568. }
  10569. MZ_EtatCdMs.listeCDM[info.id] = info;
  10570. if (myColor) eTdLevel.style.color = myColor;
  10571. /* Roule' à étudier plus tard, cette différence de style selon la diplo...
  10572. eTdLevel.onmouseover = function() {
  10573. this.className = 'mh_tdtitre';
  10574. };
  10575. eTdLevel.onmouseout = function() {
  10576. if(this.parentNode.diploActive=='oui') {
  10577. this.className = '';
  10578. } else {
  10579. this.className = 'mh_tdpage';
  10580. }
  10581. };
  10582. */
  10583. }
  10584. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  10585. computeMission(prevLastIndexDone+1, MZ_EtatCdMs.nbMonstres);
  10586. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  10587. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  10588. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  10589. document.body.dataset.MZ_Etat = 2; // indiquer aux scripts tiers qu'on a récupéré les carac
  10590. if (document.body.MZ_Callback_fin_vue !== undefined) {
  10591. for (var iCallback = 0; iCallback < document.body.MZ_Callback_fin_vue.length; iCallback++) {
  10592. document.body.MZ_Callback_fin_vue[iCallback]();
  10593. }
  10594. }
  10595. } catch(e) {
  10596. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZgetCaracMonstre+'\n'+texte);
  10597. }
  10598. //if (MY_DEBUG) window.console.log('id=6376829, info=' + JSON.stringify(MZ_EtatCdMs.listeCDM[6376829]));
  10599. MZ_EtatCdMs.isCDMsRetrieved=true;
  10600. // afficher/supprimer le bouton pour demander la suite
  10601. var eltBoutonSuite = document.getElementById('MZ_boutonSuiteCdM');
  10602. window.console.log('[MZ] lastIndexDone=' + MZ_EtatCdMs.lastIndexDone + ', nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', eltBoutonSuite=' + eltBoutonSuite);
  10603. if (MZ_EtatCdMs.lastIndexDone < MZ_EtatCdMs.nbMonstres) {
  10604. if (eltBoutonSuite) {
  10605. while (eltBoutonSuite.firstChild) eltBoutonSuite.removeChild(eltBoutonSuite.firstChild); // vider
  10606. appendText(eltBoutonSuite, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10607. retrieveCDMs(); // lancer la suite
  10608. } else {
  10609. eltBoutonSuite = document.createElement('div');
  10610. eltBoutonSuite.id = 'MZ_boutonSuiteCdM';
  10611. eltBoutonSuite.style.position = 'fixed';
  10612. eltBoutonSuite.style.border = '1px solid black';
  10613. eltBoutonSuite.style.top = '10px';
  10614. eltBoutonSuite.style.right = '10px';
  10615. //eltBoutonSuite.style.backgroundColor = 'white';
  10616. eltBoutonSuite.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/fond/fond2.jpg")';
  10617. eltBoutonSuite.style.color = 'black';
  10618. eltBoutonSuite.style.fontSize = 'large';
  10619. eltBoutonSuite.style.padding = '5px';
  10620. eltBoutonSuite.style.borderRadius = '10px';
  10621. eltBoutonSuite.style.cursor = 'pointer';
  10622. eltBoutonSuite.style.zIndex = '500';
  10623. appendText(eltBoutonSuite, nbReq + ' CdM(s) récupérées');
  10624. appendBr(eltBoutonSuite); // C'est plus classe que d'utiliser innerHTML ☺
  10625. appendText(eltBoutonSuite, 'Cliquer ici pour demander les CdMs');
  10626. appendBr(eltBoutonSuite);
  10627. appendText(eltBoutonSuite, 'des ' + MZ_EtatCdMs.nbMonstres + ' monstres');
  10628. eltBoutonSuite.title = 'Shift-Click pour faire disparaitre ce bouton sans demander les CdMs';
  10629. eltBoutonSuite.onclick = MZ_SuiteCdMs;
  10630. document.body.appendChild(eltBoutonSuite);
  10631. }
  10632. } else {
  10633. if (eltBoutonSuite) eltBoutonSuite.parentNode.removeChild(eltBoutonSuite);
  10634. }
  10635. },
  10636. });
  10637. //str = '';
  10638. //begin = i+1;
  10639. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  10640. }
  10641.  
  10642. function MZ_CdMColorFromMode(info) {
  10643. switch (info.Mode) {
  10644. case 'cdm':
  10645. return 'blue';
  10646. case 'stat':
  10647. return 'purple';
  10648. case 'statV1':
  10649. return 'orange';
  10650. }
  10651. }
  10652.  
  10653. function MZ_SuiteCdMs(e) { // handler du click sur le bouton pour demander la suite des CdMs
  10654. var evt = e || window.event;
  10655. if (evt.shiftKey) {
  10656. this.parentNode.removeChild(this);
  10657. return;
  10658. }
  10659. while (this.firstChild) this.removeChild(this.firstChild); // vider
  10660. appendText(this, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10661. this.title = 'Shift-Click pour faire disparaitre ce bouton';
  10662. this.style.cursor = ''; // default
  10663. this.onclick = MZ_SupprBoutonCdMs;
  10664. retrieveCDMs();
  10665. }
  10666.  
  10667. function MZ_SupprBoutonCdMs(e) {
  10668. var evt = e || window.event;
  10669. if (evt.shiftKey) {
  10670. this.parentNode.removeChild(this);
  10671. }
  10672. }
  10673.  
  10674. function mkMinMaxHTML(oMM) {
  10675. if (oMM == undefined) return '';
  10676. if (oMM.min == undefined) {
  10677. if (oMM.max == undefined) {
  10678. return;
  10679. } else {
  10680. return "\u2A7D" + oMM.max; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  10681. }
  10682. } else {
  10683. if (oMM.max == undefined) {
  10684. return "\u2A7E" + oMM.min; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  10685. } else if (oMM.min == oMM.max) {
  10686. return oMM.min;
  10687. } else if (oMM.min < oMM.max) {
  10688. return oMM.min + '-' + oMM.max;
  10689. } else {
  10690. return '<span style="color:red">' + oMM.min + '-' + oMM.max + '</span>';
  10691. }
  10692. }
  10693. }
  10694.  
  10695. function computeMission(begin,end) {
  10696. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  10697. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  10698. computeVLC(begin,end);
  10699. //+++window.console.log('computeMission, après computeVLC');
  10700. if(!begin) begin=1;
  10701. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10702. var str = MY_getValue(numTroll+'.MISSIONS');
  10703. if(!str) { return; }
  10704.  
  10705. var urlImg = URL_MZimg+'mission.png';
  10706. var obMissions = JSON.parse(str);
  10707.  
  10708. for(var i=end ; i>=begin ; i--) {
  10709. var mess = '';
  10710. var bPeutEtreIcone = false;
  10711. for(var num in obMissions) {
  10712. var mobMission = false;
  10713. var mobMissionPeutEtre = undefined;
  10714. switch(obMissions[num].type) {
  10715. case 'Race':
  10716. var race = epure(obMissions[num].race.toLowerCase());
  10717. var nom = epure(getMonstreNom(i).toLowerCase());
  10718. if(nom.indexOf(race)!=-1) {
  10719. if (race == 'crasc') {
  10720. if (nom.indexOf('medius')!=-1) {
  10721. // pas éligible
  10722. } else if (nom.indexOf('maexus')!=-1) {
  10723. // pas éligible
  10724. } else if (nom.indexOf('parasitus')!=-1) {
  10725. if (nom.match(/^crasc parasitus \[/ui)) {
  10726. // on ne peut pas savoir
  10727. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10728. + '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"';
  10729. } else {
  10730. // c'est un monstre de la race des Crasc Parasitus
  10731. mobMission = false;
  10732. }
  10733. } else {
  10734. mobMission = true;
  10735. }
  10736. } else if (race == 'crasc parasitus') {
  10737. if (nom.match(/^crasc parasitus \[/ui)) {
  10738. // on ne peut pas savoir
  10739. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10740. + '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"';
  10741. } else {
  10742. // c'est un monstre de la race des Crasc Parasitus
  10743. mobMission = true;
  10744. }
  10745. } else if (race == 'shai') {
  10746. if (nom.match(/abishai/ui)) {
  10747. mobMission = false;
  10748. } else {
  10749. mobMission = true;
  10750. }
  10751. } else if (race == 'ombre') {
  10752. if (nom.match(/roche/ui)) {
  10753. mobMission = false;
  10754. } else {
  10755. mobMission = true;
  10756. }
  10757. } else if (race == 'geck\'oo') {
  10758. if (nom.match(/majestueux/ui)) {
  10759. mobMission = false;
  10760. } else {
  10761. mobMission = true;
  10762. }
  10763. } else if (race == 'bouj\'dla') {
  10764. if (nom.match(/placide/ui)) {
  10765. mobMission = false;
  10766. } else {
  10767. mobMission = true;
  10768. }
  10769. } else {
  10770. mobMission = true;
  10771. }
  10772. }
  10773. break;
  10774. case 'Niveau':
  10775. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10776. if (donneesMonstre) {
  10777. var nivMimi = Number(obMissions[num].niveau);
  10778. var mod = obMissions[num].mod; // mission nivMimi±mod si mod est numérique, sinon, c'est >= nivMimi
  10779. if (isNaN(mod)) {
  10780. var minMimi = nivMimi;
  10781. var maxMimi = nivMimi + 999999;
  10782. } else {
  10783. var minMimi = nivMimi - mod;
  10784. var maxMimi = nivMimi + mod;
  10785. }
  10786. if (donneesMonstre.niv) { // nouveau mode
  10787. if (donneesMonstre.niv.max && donneesMonstre.niv.min) {
  10788. if (donneesMonstre.niv.max <= maxMimi && donneesMonstre.niv.min >= minMimi) {
  10789. mobMission = true;
  10790. } else if (!(donneesMonstre.niv.max < minMimi || donneesMonstre.niv.min > maxMimi)) {
  10791. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10792. if (isDEV) mobMissionPeutEtre += '\nMonstre=(' + donneesMonstre.niv.min + ', ' + donneesMonstre.niv.max + '), mimi=(' + minMimi + ', ' + maxMimi + ')'
  10793. }
  10794. } else if (donneesMonstre.niv.max) {
  10795. if (donneesMonstre.niv.max >= minMimi) {
  10796. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10797. }
  10798. } else if (donneesMonstre.niv.min) {
  10799. if (donneesMonstre.niv.min <= maxMimi) {
  10800. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10801. }
  10802. }
  10803. }
  10804. }
  10805. break;
  10806. case 'Famille':
  10807. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10808. if(donneesMonstre && donneesMonstre.fam) {
  10809. var familleMimi = epure(obMissions[num].famille.toLowerCase()).replace(/[']/g,''); // Roule 27/02/2019 simple quote dans les familles
  10810. var familleMob = epure(donneesMonstre.fam.toLowerCase());
  10811. if(familleMob.indexOf(familleMimi)!=-1) {
  10812. mobMission = true;
  10813. }
  10814. }
  10815. break;
  10816. case 'Pouvoir':
  10817. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10818. if(donneesMonstre && donneesMonstre.pouv) {
  10819. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  10820. var pvrMob = epure(donneesMonstre.pouv.toLowerCase());
  10821. if(pvrMob.indexOf(pvrMimi)!=-1) {
  10822. mobMission = true;
  10823. }
  10824. }
  10825. }
  10826. if(mobMission) {
  10827. mess += mess ? '\n\n' : '';
  10828. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  10829. } else if (mobMissionPeutEtre !== undefined) {
  10830. mess += mess ? '\n\n' : '';
  10831. mess += mobMissionPeutEtre + '\n';
  10832. bPeutEtreIcone = true;
  10833. mess += 'Mission '+ num + ' :\n'+obMissions[num].libelle;
  10834. }
  10835. }
  10836. if(mess) {
  10837. var td = getMonstreNomNode(i);
  10838. appendText(td,' ');
  10839. var myURL;
  10840. if (bPeutEtreIcone) {
  10841. myURL = URL_MZimg+'missionX.png';
  10842. } else {
  10843. myURL = urlImg;
  10844. }
  10845. td.appendChild(createImage(myURL,mess));
  10846. }
  10847. }
  10848. }
  10849.  
  10850. function computeVLC(begin,end) {
  10851. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  10852. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  10853. computeTactique(begin,end);
  10854. //+++window.console.log('computeVLC, après computeTactique');
  10855. if(!begin) begin=1;
  10856. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10857. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  10858. if(!cache)
  10859. return false;
  10860. var urlImg = URL_MZimg + "oeil.png";
  10861. for(var i = end; i >= begin;i--)
  10862. {
  10863. var id = getMonstreID(i);
  10864. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10865. var vlc = false;
  10866. /* ancien mode à supprimer
  10867. if(donneesMonstre && donneesMonstre.length>12)
  10868. {
  10869. if(donneesMonstre[12]==1) vlc = 1;
  10870. }
  10871. // */
  10872. // nouveau mode
  10873. if (donneesMonstre && donneesMonstre.vlc) {
  10874. //if (donneesMonstre) window.console.log('computeVLC i=' + i + ' id=' + id + ' ' + JSON.stringify(donneesMonstre));
  10875. var td = getMonstreNomNode(i);
  10876. td.appendChild(document.createTextNode(" "));
  10877. td.appendChild(createImage(urlImg, "Voit le caché"));
  10878. }
  10879. if (donneesMonstre && donneesMonstre.gen) {
  10880. switch (donneesMonstre.gen) {
  10881. case 1:
  10882. var imgPh = URL_MZimg + "Phoenix1.png";
  10883. var txtPh = 'Phœnix de première génération';
  10884. break;
  10885. case 2:
  10886. var imgPh = URL_MZimg + "Phoenix2.png";
  10887. var txtPh = 'Phœnix de deuxième génération';
  10888. break;
  10889. case 3:
  10890. var imgPh = URL_MZimg + "Phoenix3.png";
  10891. var txtPh = 'Phœnix de troisième génération';
  10892. break;
  10893. case 23:
  10894. var imgPh = URL_MZimg + "Phoenix23.png";
  10895. var txtPh = 'Phœnix de deuxième ou troisième génération';
  10896. break;
  10897. }
  10898. var td = getMonstreNomNode(i);
  10899. td.appendChild(document.createTextNode(" "));
  10900. var img = td.appendChild(createImage(imgPh, txtPh));
  10901. img.style.height = '15px';
  10902. img.style.width = 'auto';
  10903. }
  10904. }
  10905. }
  10906.  
  10907. /* appelé
  10908. par updateTactique
  10909. par initialiseInfos
  10910. par do_vue
  10911. par computeVLC
  10912. par computeMission
  10913. par filtreMonstres
  10914. par retrieveCDMs
  10915. */
  10916. function computeTactique(begin, end) {
  10917. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  10918. try {
  10919. if(!begin) begin = 1;
  10920. if(!end) end = MZ_EtatCdMs.nbMonstres;
  10921. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  10922. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10923. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  10924. if(noTactique || !isProfilActif()) return;
  10925. //+++window.console.log('computeTactique, après isProfilActif');
  10926.  
  10927. for(var j=end ; j>=begin ; j--) {
  10928. var id = getMonstreID(j);
  10929. var nom = getMonstreNom(j);
  10930. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10931. var bShowTactique = false;
  10932. //if (isDEV) {
  10933. if (donneesMonstre && donneesMonstre.esq) bShowTactique = true;
  10934. // } else {
  10935. // if(donneesMonstre && nom.indexOf('Gowap')==-1) bShowTactique = true;
  10936. // }
  10937. if (bShowTactique) {
  10938. var td = getMonstreNomNode(j);
  10939. appendText(td,' ');
  10940. td.appendChild(MZ_Tactique.createImage(id, nom));
  10941. }
  10942. }
  10943. }
  10944. catch(e) {
  10945. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  10946. }
  10947. filtreMonstres();
  10948. }
  10949.  
  10950. function updateTactique() {
  10951. // = Handler checkBox noTactique
  10952. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10953. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  10954. if(!MZ_EtatCdMs.isCDMsRetrieved) return;
  10955. //+++window.console.log('updateTactique, isCDMsRetrieved=' + MZ_EtatCdMs.isCDMsRetrieved);
  10956.  
  10957. if(noTactique) {
  10958. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  10959. var tr = getMonstreNomNode(i);
  10960. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  10961. tr, null, 9, null).singleNodeValue;
  10962. if(img) {
  10963. img.parentNode.removeChild(img.previousSibling);
  10964. img.parentNode.removeChild(img);
  10965. }
  10966. }
  10967. }
  10968. else
  10969. computeTactique();
  10970. }
  10971.  
  10972. function filtreMonstres() {
  10973. // = Handler universel pour les fonctions liées aux monstres
  10974. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  10975. urlEnchantImg = URL_MZimg+'enchant.png';
  10976.  
  10977. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  10978. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  10979. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  10980. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  10981. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  10982. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  10983. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  10984. var famille = saveComboBox(comboBoxFamille,'FAMILLEMONSTRE');
  10985. // old/new : détermine s'il faut ou non nettoyer les tr
  10986. var oldNOEM = true, noEM = true;
  10987. if(MY_getValue('NOINFOEM')!='true') {
  10988. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  10989. }
  10990. // Filtrage par nom
  10991. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  10992. // Génère la liste des mobs engagés (si filtrés)
  10993. if(noEngages && !isEngagesComputed) {
  10994. for(var i=nbTrolls ; i>0 ; i--) {
  10995. var pos = getTrollPosition(i);
  10996. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  10997. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  10998. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  10999. }
  11000. isEngagesComputed = true;
  11001. }
  11002.  
  11003. /*** FILTRAGE ***/
  11004. /* À computer :
  11005. * - EM (nom suffit)
  11006. * - Enchant (nom suffit)
  11007. * - Mission (nécessite CdM)
  11008. * - mob VlC (nécessite CdM)
  11009. * Sans computation :
  11010. * - Gowap ? engagé ?
  11011. */
  11012. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  11013. var pos = getMonstrePosition(i);
  11014. var nom = getMonstreNom(i).toLowerCase();
  11015. if(noEM!=oldNOEM) {
  11016. if(noEM) {
  11017. // Si noEM passe de false à true, on nettoie les td "Nom"
  11018. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  11019. var tr = getMonstreNomNode(i);
  11020. while(tr.childNodes.length>1) {
  11021. tr.removeChild(tr.childNodes[1]);
  11022. }
  11023. } else {
  11024. var tr = getMonstreNomNode(i);
  11025. var TypeMonstre=getEM(nom);
  11026. if(TypeMonstre!='') {
  11027. var infosCompo=compoMobEM(TypeMonstre);
  11028. if(infosCompo.length>0) {
  11029. tr.appendChild(document.createTextNode(' '));
  11030. tr.appendChild(createImage(urlImg, infosCompo));
  11031. }
  11032. }
  11033. }
  11034. }
  11035. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  11036. var texte = getInfoEnchantementFromMonstre(nom);
  11037. if(texte!='') {
  11038. var td = getMonstreNomNode(i);
  11039. td.appendChild(document.createTextNode(' '));
  11040. td.appendChild(createImage(urlEnchantImg, texte));
  11041. }
  11042. }
  11043.  
  11044. var dataV2 = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  11045. MZ_EtatCdMs.tr_monstres[i].style.display = (
  11046. noGowapsS &&
  11047. nom.indexOf('gowap sauvage')!=-1 &&
  11048. getMonstreDistance(i)>1
  11049. ) || (
  11050. noGowapsA &&
  11051. nom.indexOf('gowap apprivoisé')!=-1 &&
  11052. getMonstreDistance(i)>1
  11053. ) || (
  11054. noEngages &&
  11055. getMonstreDistance(i)!=0 &&
  11056. listeEngages[pos[0]] &&
  11057. listeEngages[pos[0]][pos[1]] &&
  11058. listeEngages[pos[0]][pos[1]][pos[2]]
  11059. ) || (
  11060. strMonstre!='' &&
  11061. nom.indexOf(strMonstre)==-1
  11062. ) || (
  11063. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  11064. getMonstreDistance(i)>1 &&
  11065. nom.toLowerCase().indexOf("kilamo")==-1
  11066. ) || (
  11067. famille!='0' &&
  11068. dataV2 &&
  11069. dataV2.fam &&
  11070. dataV2.fam != famille
  11071. ) ? 'none' : '';
  11072. }
  11073.  
  11074. if(MY_getValue('NOINFOEM')!='true') {
  11075. if(noEM != oldNOEM) {
  11076. if(noEM && MZ_EtatCdMs.isCDMsRetrieved) computeMission();
  11077. }
  11078. oldNOEM = noEM;
  11079. }
  11080.  
  11081. needComputeEnchantement = false;
  11082. }
  11083.  
  11084.  
  11085. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  11086.  
  11087. function filtreTrolls() {
  11088. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  11089. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  11090. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  11091. for(var i=1 ; i<=nbTrolls ; i++) {
  11092. tr_trolls[i].style.display = (
  11093. noIntangibles &&
  11094. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  11095. ) || (
  11096. strTroll!='' &&
  11097. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  11098. ) || (
  11099. strGuilde!='' &&
  11100. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  11101. ) ? 'none' : '';
  11102. }
  11103. }
  11104.  
  11105. /* [functions] Bulle PX Trolls */
  11106. var bulle;
  11107.  
  11108. function initPXTroll() {
  11109. bulle = document.createElement('div');
  11110. bulle.id = 'bulle';
  11111. bulle.className = 'mh_textbox';
  11112. bulle.style =
  11113. 'position: absolute;'+
  11114. 'border: 1px solid #000000;'+
  11115. 'visibility: hidden;'+
  11116. 'display: inline;'+
  11117. 'z-index: 2;';
  11118. document.body.appendChild(bulle);
  11119.  
  11120. for(var i=nbTrolls ; i>0 ; i--) {
  11121. var td_niv = getTrollNivNode(i);
  11122. td_niv.onmouseover = showPXTroll;
  11123. td_niv.onmouseout = hidePXTroll;
  11124. }
  11125. }
  11126.  
  11127. function showPXTroll(evt) {
  11128. var lvl = this.firstChild.nodeValue;
  11129. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  11130. bulle.style.left = evt.pageX+15+'px';
  11131. bulle.style.top = evt.pageY+'px';
  11132. bulle.style.visibility = 'visible';
  11133. }
  11134.  
  11135. function hidePXTroll() {
  11136. bulle.style.visibility = 'hidden';
  11137. }
  11138.  
  11139. /* [functions] Envoi PX / MP */
  11140. function putBoutonPXMP() {
  11141. // Bouton d'initialisation du mode Envoi
  11142. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  11143. var td = document.getElementById('tdInsertTrolls');
  11144. if(!td) { return; }
  11145. td.width = 100;
  11146. td = insertAfterTd(td);
  11147. td.style.verticalAlign = 'top';
  11148. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  11149. bouton.id = 'btnEnvoi';
  11150. }
  11151.  
  11152. function prepareEnvoi() {
  11153. // = 1er Handler du bouton d'envoi
  11154.  
  11155. /* Ajout de la colonne des CheckBoxes */
  11156. var td = insertTdText(getTrollNomNode(0),'');
  11157. td.width = 5;
  11158. for(var i=nbTrolls ; i>0 ; i--) {
  11159. td = insertTd(getTrollNomNode(i));
  11160. appendCheckBox(td,'envoi'+i);
  11161. }
  11162.  
  11163. /* Ajout du radio de choix PX ou MP */
  11164. var btnEnvoi = document.getElementById('btnEnvoi');
  11165. if(!btnEnvoi) { return; }
  11166. var tdEnvoi = btnEnvoi.parentNode;
  11167. appendText(tdEnvoi,' ');
  11168. var span = document.createElement('span');
  11169. span.style.whiteSpace = 'nowrap';
  11170. var radioElt = document.createElement('input');
  11171. radioElt.type = 'radio';
  11172. radioElt.name = 'envoiPXMP';
  11173. radioElt.id = 'radioPX';
  11174. span.appendChild(radioElt);
  11175. appendText(span,' des PX ');
  11176. radioElt = document.createElement('input');
  11177. radioElt.type = 'radio';
  11178. radioElt.name = 'envoiPXMP';
  11179. radioElt.checked = true;
  11180. span.appendChild(radioElt);
  11181. appendText(span,' un MP');
  11182. tdEnvoi.appendChild(span);
  11183.  
  11184. /* Insertion du bouton Annuler */
  11185. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  11186.  
  11187. /* Modification de l'effet du bouton Envoi */
  11188. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  11189. }
  11190.  
  11191. function annuleEnvoi() {
  11192. // = Handler bouton Annuler
  11193. /* Nettoyage du td du bouton Envoi */
  11194. var btnEnvoi = document.getElementById('btnEnvoi');
  11195. var tdEnvoi = btnEnvoi.parentNode;
  11196. while(tdEnvoi.firstChild) {
  11197. tdEnvoi.removeChild(tdEnvoi.firstChild);
  11198. }
  11199. /* Retour à l'effet de base du bouton Envoi */
  11200. btnEnvoi.onclick = prepareEnvoi;
  11201. tdEnvoi.appendChild(btnEnvoi);
  11202. /* Suppression CheckBoxes */
  11203. for(var i=nbTrolls ; i>=0 ; i--) {
  11204. var td = getTrollNomNode(i);
  11205. td.parentNode.removeChild(td);
  11206. }
  11207. }
  11208.  
  11209. function effectueEnvoi() {
  11210. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  11211. var str='';
  11212. var errID = false;
  11213. for(var i=nbTrolls ; i>0 ; i--) {
  11214. var chb = document.getElementById('envoi'+i);
  11215. if(chb.checked) {
  11216. var idTroll = getTrollID(i);
  11217. if (idTroll == undefined) {
  11218. errID = true;
  11219. } else {
  11220. str += (str ? ',' : '') + idTroll;
  11221. }
  11222. }
  11223. }
  11224. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  11225. var PXchecked = document.getElementById('radioPX').checked;
  11226. if(PXchecked) {
  11227. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  11228. } else {
  11229. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  11230. }
  11231. }
  11232.  
  11233. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  11234.  
  11235. function filtreTresors() {
  11236. // += Handler checkboxes : gg, compos, bidouilles, non libres
  11237. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  11238. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  11239. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  11240. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  11241. if(noEngages && !isEngagesComputed) {
  11242. for(var i=nbTrolls ; i>0 ; i--) {
  11243. var pos = getTrollPosition(i);
  11244. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  11245. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  11246. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  11247. }
  11248. isEngagesComputed = true;
  11249. }
  11250. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  11251. for(var i=nbTresors ; i>0 ; i--) {
  11252. var nom = getTresorNom(i);
  11253. var pos = getTresorPosition(i);
  11254. tr_tresors[i].style.display = (
  11255. noGG &&
  11256. nom.indexOf('Gigots de Gob')!=-1
  11257. ) || (
  11258. noCompos &&
  11259. nom.indexOf('Composant')!=-1
  11260. ) || (
  11261. noEngages &&
  11262. listeEngages[pos[2]] &&
  11263. listeEngages[pos[2]][pos[1]] &&
  11264. listeEngages[pos[2]][pos[1]][pos[0]] &&
  11265. getTresorDistance(i)>0
  11266. ) || (
  11267. strTresor!='' &&
  11268. nom.toLowerCase().indexOf(strTresor)==-1
  11269. ) || (
  11270. noBidouilles &&
  11271. nom.indexOf('Bidouille')!=-1
  11272. ) ? 'none' : '';
  11273. }
  11274. }
  11275.  
  11276.  
  11277. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  11278.  
  11279. function filtreLieux() {
  11280. // += Handler checkbox trous
  11281. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  11282. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  11283. for(var i=nbLieux ; i>0 ; i--) {
  11284. tr_lieux[i].style.display = (
  11285. strLieu &&
  11286. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  11287. ) || (
  11288. noTrou &&
  11289. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  11290. getLieuDistance(i)>1
  11291. ) ? 'none' : '';
  11292. }
  11293. }
  11294.  
  11295.  
  11296. /*-[functions]-------------------- Diplomatie --------------------------------*/
  11297.  
  11298. function refreshDiplo() {
  11299. MY_setValue(numTroll+'.diplo.off',
  11300. checkBoxDiplo.checked?'true':'false'
  11301. );
  11302. if(isDiploRaw) { computeDiplo(); }
  11303. appliqueDiplo();
  11304. }
  11305.  
  11306. function computeDiplo() {
  11307. // On extrait les données de couleur et on les stocke par id
  11308. // Ordre de préséance :
  11309. // source Guilde < source Perso
  11310. // guilde cible < troll cible
  11311.  
  11312. /* Diplo de Guilde */
  11313. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  11314. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  11315. if(diploGuilde && diploGuilde.isOn=='true') {
  11316. // Guilde perso
  11317. if(diploGuilde.guilde) {
  11318. Diplo.Guilde[diploGuilde.guilde.id] = {
  11319. couleur: diploGuilde.guilde.couleur,
  11320. titre: 'Ma Guilde'
  11321. };
  11322. }
  11323. // Guildes/Trolls A/E
  11324. for(var AE in {Amis:0,Ennemis:0}) {
  11325. for(var i=0 ; i<5 ; i++) {
  11326. if(diploGuilde[AE+i]) {
  11327. for(var type in {Guilde:0,Troll:0}) {
  11328. var liste = diploGuilde[AE+i][type].split(';');
  11329. for(var j=liste.length-2 ; j>=0 ; j--) {
  11330. Diplo[type][liste[j]] = {
  11331. couleur: diploGuilde[AE+i].couleur,
  11332. titre: diploGuilde[AE+i].titre
  11333. };
  11334. }
  11335. }
  11336. }
  11337. }
  11338. }
  11339. }
  11340.  
  11341. /* Diplo Perso */
  11342. //var diploPerso = MY_getValue(numTroll+'.diplo.perso') ? JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {}; // déjà chargé
  11343. if(diploPerso && diploPerso.isOn=='true') {
  11344. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  11345. for(var id in diploPerso[type]) {
  11346. Diplo[type][id] = diploPerso[type][id];
  11347. }
  11348. }
  11349. }
  11350. if(diploPerso.mythiques) {
  11351. Diplo.mythiques = diploPerso.mythiques;
  11352. }
  11353.  
  11354. isDiploRaw = false;
  11355. }
  11356.  
  11357. function appliqueDiplo() {
  11358. var aAppliquer = Diplo;
  11359. if(checkBoxDiplo.checked) {
  11360. // Pour retour à l'affichage basique sur désactivation de la diplo
  11361. aAppliquer = {
  11362. Guilde: {},
  11363. Troll: {},
  11364. Monstre: {}
  11365. };
  11366. }
  11367.  
  11368. /* On applique "aAppliquer" */
  11369. // Diplo Trõlls
  11370. for(var i=nbTrolls ; i>0 ; i--) {
  11371. var idG = getTrollGuildeID(i);
  11372. var idT = getTrollID(i);
  11373. var tr = tr_trolls[i];
  11374. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  11375. if(aAppliquer.Troll[idT]) {
  11376. tr.className = '';
  11377. var descr = aAppliquer.Troll[idT].titre;
  11378. if(descr) {
  11379. getTrollNomNode(i).title = descr
  11380. }
  11381. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  11382. } else if(aAppliquer.Guilde[idG]) {
  11383. tr.className = '';
  11384. var descr = aAppliquer.Guilde[idG].titre;
  11385. if(descr) {
  11386. getTrollNomNode(i).title = descr
  11387. }
  11388. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  11389. } else {
  11390. tr.className = 'mh_tdpage';
  11391. getTrollNomNode(i).title = '';
  11392. }
  11393. }
  11394.  
  11395. // Diplo Monstres
  11396. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  11397. var id = getMonstreID(i);
  11398. var nom = getMonstreNom(i).toLowerCase();
  11399. var tr = MZ_EtatCdMs.tr_monstres[i];
  11400. if(aAppliquer.Monstre[id]) {
  11401. tr.className = '';
  11402. tr.style.backgroundColor = aAppliquer.Monstre[id].couleur;
  11403. tr.diploActive = 'oui';
  11404. var descr = aAppliquer.Monstre[id].titre;
  11405. if(descr) {
  11406. getMonstreNomNode(i).title = descr;
  11407. }
  11408. } else if(aAppliquer.mythiques &&
  11409. (nom.indexOf('liche')==0 ||
  11410. nom.indexOf('hydre')==0 ||
  11411. nom.indexOf('balrog')==0 ||
  11412. nom.indexOf('beholder')==0)) {
  11413. tr.className = '';
  11414. tr.style.backgroundColor = aAppliquer.mythiques;
  11415. tr.diploActive = 'oui';
  11416. getMonstreNomNode(i).title = 'Monstre Mythique';
  11417. } else {
  11418. tr.className = 'mh_tdpage';
  11419. tr.diploActive = '';
  11420. }
  11421. }
  11422. }
  11423.  
  11424.  
  11425. /*-[functions]---------------- Actions à distance ----------------------------*/
  11426.  
  11427. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  11428. var
  11429. monN = parseInt(getPosition()[2]),
  11430. isLdP = oussa=='self';
  11431.  
  11432. for(var type in keltypes) {
  11433. if (MY_DEBUG) {
  11434. window.console.log(
  11435. 'MZ computeActionDistante(' + dmin + ', ' + dmax + ', ' +
  11436. oussa + ', ' + urlIcon+ ', ' + message + ') type=' + type
  11437. );
  11438. }
  11439. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  11440. for(var i=VueContext['nb'+type] ; i>0 ; i--) {
  11441. var tr = VueContext['tr_'+type.toLowerCase()][i];
  11442. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  11443. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  11444. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  11445. var sonN = getXxxPosition(type, i)[2];
  11446. var d = getXxxDistance(type, i);
  11447. var thismessage = message;
  11448. if (isLdP) {
  11449. var chanceToucher = getTalent("Lancer de Potions") + Math.min(10,
  11450. 10 - 10 * d +
  11451. parseInt(MY_getValue(numTroll+".caracs.vue")) +
  11452. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11453. );
  11454. thismessage += ' (' + chanceToucher + '%)';
  11455. }
  11456.  
  11457. if(sonN==monN && d>=dmin && d<=dmax) {
  11458. var iconeAction = document.evaluate(
  11459. "./descendant::img[@alt='"+alt+"']",
  11460. tr, null, 9, null
  11461. ).singleNodeValue;
  11462. if(iconeAction) {
  11463. if(iconeAction.title) {
  11464. iconeAction.title += "\n"+thismessage;
  11465. } else {
  11466. iconeAction.title = thismessage;
  11467. }
  11468. iconeAction.src = urlIcon;
  11469. } else {
  11470. var tdAction = tr.getElementsByTagName('td')[1];
  11471. var icon = document.createElement('img');
  11472. icon.src = urlIcon;
  11473. icon.height = 20;
  11474. icon.alt = alt;
  11475. icon.title = thismessage;
  11476. tdAction.appendChild(icon);
  11477. }
  11478. }
  11479. }
  11480. }
  11481. }
  11482.  
  11483. function computeCharge() {
  11484. computeActionDistante(1,
  11485. getPortee(
  11486. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  11487. MY_getValue(numTroll+".caracs.regeneration")
  11488. ),
  11489. {'Monstres':1, 'Trolls':1},
  11490. 'Attaquer',
  11491. MHicons+'E_Metal09.png',
  11492. 'Cible à portée de Charge'
  11493. );
  11494. }
  11495.  
  11496. function computeProjo() {
  11497. computeActionDistante(0,
  11498. getPortee(
  11499. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11500. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11501. ),
  11502. {'Monstres':1, 'Trolls':1},
  11503. 'Attaquer',
  11504. MHicons+'S_Fire05.png',
  11505. 'Cible à portée de Projo'
  11506. );
  11507. }
  11508.  
  11509. function computeTelek() {
  11510. computeActionDistante(0,
  11511. Math.floor((
  11512. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11513. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11514. )/2),
  11515. {'Tresors':1},
  11516. 'Telek',
  11517. MHicons+'S_Magic04.png',
  11518. 'Trésor à portée de Télékinésie'
  11519. );
  11520. }
  11521.  
  11522. function computeLdP() {
  11523. computeActionDistante(0,
  11524. 2+Math.floor((
  11525. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11526. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11527. )/5),
  11528. {'Monstres':1, 'Trolls':1},
  11529. 'self',
  11530. MHicons+'P_Red01.png',
  11531. 'Cible à portée de Lancer de Potions'
  11532. );
  11533. }
  11534.  
  11535.  
  11536. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  11537.  
  11538. function putScriptExterne(sInfo) {
  11539. for (var iBricol = 1; ; iBricol++) {
  11540. var extClef = iBricol == 1 ? '' : iBricol;
  11541. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  11542. if (!sInfo) break;
  11543. putScriptExterneOneIT(sInfo);
  11544. }
  11545. }
  11546.  
  11547. function putScriptExterneOneIT(sInfo) {
  11548. if(!sInfo || sInfo=='') return;
  11549.  
  11550. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  11551. if(nomit=='bricol') {
  11552. var data = sInfo.split('$');
  11553. try {
  11554. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  11555. // appendNewScript(URL_bricol+data[1]
  11556. // +'/mz.php?login='+data[2]
  11557. // +'&password='+data[3]
  11558. // );
  11559. FF_XMLHttpRequest({
  11560. method: 'GET',
  11561. url: URL_bricol+data[1]
  11562. +'/mz_json.php?login='+encodeURIComponent(data[2])
  11563. +'&password='+data[3],
  11564. trace: 'bricolTroll',
  11565. onload: function(responseDetails) {
  11566. try {
  11567. if (responseDetails.status == 0) {
  11568. window.console.log('status=0 à l\'appel bricol\'troll');
  11569. if (isHTTPS) {
  11570. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  11571. } else {
  11572. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  11573. }
  11574. return;
  11575. }
  11576. var ratibusData;
  11577. try {
  11578. ratibusData = JSON.parse(responseDetails.responseText);
  11579. } catch(e) {}
  11580. if (ratibusData === undefined) {
  11581. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  11582. return;
  11583. }
  11584. if (ratibusData.error) {
  11585. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  11586. } else {
  11587. putInfosTrolls(ratibusData.data.trolls, data[1]);
  11588. }
  11589. } catch(e) {
  11590. window.console.log(traceStack(e, 'retour bricol\'troll'));
  11591. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  11592. }
  11593. }
  11594. });
  11595. } catch(e) {
  11596. if (isHTTPS) {
  11597. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  11598. } else {
  11599. window.console.log(traceStack(e, 'appel bricol\'troll'));
  11600. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  11601. }
  11602. }
  11603. }
  11604. }
  11605.  
  11606. /*
  11607. * Roule 07/11/2016, on utilise mz_json qui envoie
  11608. {
  11609. "data": {
  11610. "trolls": {
  11611. "59424": {
  11612. "id": 59424,
  11613. "pv": xx,
  11614. "pv_max": xx,
  11615. "updated_at": "2016-10-31 07:28:40",
  11616. "dla": "2016-10-05 07:28:04",
  11617. "pa": 0
  11618. },
  11619. }
  11620. }
  11621. }
  11622. */
  11623.  
  11624. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  11625. function corrigeBricolTrolls(infosTrolls) {
  11626. for(var i in infosTrolls) {
  11627. var pv = infosTrolls[i][0];
  11628. var pvmax = infosTrolls[i][1];
  11629. var pvmem = MY_getValue(i+'.caracs.pv.max');
  11630. if(pvmem && pvmem>pvmax) {
  11631. infosTrolls[i][1] = pvmem;
  11632. pvmax = pvmem;
  11633. }
  11634. if(pv>pvmax) {
  11635. var newpvmax = 5*Math.ceil(pv/5);
  11636. MY_setValue(i+'.caracs.pv.max',newpvmax);
  11637. infosTrolls[i][1] = newpvmax;
  11638. }
  11639. }
  11640. }
  11641.  
  11642. // insère 2 TD avant nextTD avec les infos venant de l'IT
  11643. function addTdInfosTroll(infos, TR, itName) {
  11644. /* cadre barre PV */
  11645. var tab = document.createElement('div');
  11646. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  11647. /* barre PV */
  11648. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  11649. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  11650. .vieContainer {
  11651. background-color: #CCC;
  11652. width: 50px;
  11653. height: 6px;
  11654. border: 1px solid #000;
  11655. text-align: left;
  11656. }
  11657. */
  11658. tab.style.width = '100px';
  11659. tab.style.height = '10px';
  11660. tab.style.border = '1px solid #000';
  11661. tab.style.textAlign = 'left';
  11662. var div2 = document.createElement('div');
  11663. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  11664. var dateLimite = new Date();
  11665. dateLimite.setDate(dateLimite.getDate() - 7);
  11666. if (infos.oUpdatedAt < dateLimite) {
  11667. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  11668. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  11669. } else if (pourcentVie > 66) {
  11670. div2.style.backgroundColor = '#77EE77';
  11671. } else if (pourcentVie > 33) {
  11672. div2.style.backgroundColor = '#EEEE77';
  11673. } else {
  11674. div2.style.backgroundColor = '#FF0000';
  11675. }
  11676. div2.style.width = pourcentVie + '%';
  11677. div2.style.height = '10px';
  11678. tab.appendChild(div2);
  11679. /* ancienne méthode par img, à supprimer
  11680. var img = document.createElement('img');
  11681. img.src = '../Images/Interface/milieu.gif';
  11682. img.height = 10;
  11683. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  11684. tab.appendChild(img);
  11685. */
  11686.  
  11687. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  11688. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  11689. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  11690. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  11691.  
  11692. /* lien vers l'IT */
  11693. var lien = document.createElement('a');
  11694. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  11695. lien.href = URL_bricol+itName+'/index.php';
  11696. lien.target = '_blank';
  11697. lien.appendChild(tab);
  11698. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11699. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  11700. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  11701. //insertTdElement(tdGuilde,lien);
  11702. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  11703. /* PAs dispos */
  11704. var span = document.createElement('span');
  11705. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  11706. appendText(span, infos.pa +' PA' );
  11707. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  11708. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  11709. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  11710. span.style.backgroundColor = 'B8EEB8';
  11711. }
  11712. //insertTdElement(tdGuilde, span);
  11713. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  11714. }
  11715.  
  11716. var MZ_tabTrTrollById;
  11717. function putInfosTrolls(infosTrolls, itName) {
  11718. try {
  11719. if (MZ_tabTrTrollById === undefined) {
  11720. MZ_tabTrTrollById = new Array;
  11721. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  11722. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11723. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  11724. td.width = 40;
  11725. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  11726. td.width = 105;
  11727. for(i=nbTrolls ; i>0 ; i--) {
  11728. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11729. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11730. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  11731. }
  11732. }
  11733.  
  11734.  
  11735. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  11736. //corrigeBricolTrolls(infosTrolls);
  11737.  
  11738. // supression des infos trop vieilles (un mois)
  11739. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  11740. var dateLimite = new Date();
  11741. dateLimite.setMonth(dateLimite.getMonth() - 1);
  11742.  
  11743. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  11744. var str = MY_getValue(numTroll+'.INFOSIT');
  11745. var bAjoutTrollInvi = false;
  11746. if (str) {
  11747. var arr = str.split('$');
  11748. bAjoutTrollInvi = arr[4]>0;
  11749. }
  11750.  
  11751.  
  11752. var tBody = tr_trolls[0].parentNode;
  11753. if (tr_trolls[1] !== undefined)
  11754. tBody = tr_trolls[1].parentNode;
  11755.  
  11756. //window.console.log('nb Troll IT : ' + IDs.length);
  11757. var pos = getPosition();
  11758.  
  11759. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  11760. for (var idTroll in infosTrolls) {
  11761. var infos = infosTrolls[idTroll];
  11762. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  11763. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  11764. if (idTroll == numTroll) continue; // pas nous-même
  11765. var tr;
  11766. if (idTroll in MZ_tabTrTrollById) {
  11767. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  11768. tr = MZ_tabTrTrollById[idTroll];
  11769. } else {
  11770. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  11771. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  11772. // trouver où insérer ce Troll
  11773. var next = undefined;
  11774. for(var j=0 ; j<tr_trolls.length ; j++) {
  11775. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  11776. if (thisDist > distance) {
  11777. next = tr_trolls[j]
  11778. break;
  11779. }
  11780. }
  11781. if (next !== undefined) {
  11782. tr = insertTr(next,'mh_tdpage')
  11783. } else {
  11784. tr = appendTr(tBody,'mh_tdpage');
  11785. }
  11786. tr.style.color = 'orange';
  11787. var td = appendTd(tr); // distance
  11788. appendText(td, distance);
  11789. td = appendTd(tr); // actions
  11790. td = appendTd(tr); // ID
  11791. appendText(td, idTroll);
  11792. td = appendTd(tr); // Nom
  11793. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  11794. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  11795. td = appendTd(tr); // PV
  11796. td = appendTd(tr); // PA
  11797. td = appendTd(tr); // Guilde
  11798. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  11799. td = appendTd(tr); // Niveau
  11800. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  11801. td.align = 'center';
  11802. td = appendTd(tr); // Race
  11803. if (infos.race) appendText(td, infos.race);
  11804. td = appendTd(tr); // X
  11805. td.align = 'center';
  11806. if (infos.x !== undefined) appendText(td, infos.x);
  11807. td = appendTd(tr); // Y
  11808. td.align = 'center';
  11809. if (infos.y !== undefined) appendText(td, infos.y);
  11810. td = appendTd(tr); // N
  11811. td.align = 'center';
  11812. if (infos.n !== undefined) appendText(td, infos.n);
  11813. MZ_tabTrTrollById[idTroll] = tr;
  11814. }
  11815. if (!tr.done) {
  11816. addTdInfosTroll(infos, tr, itName);
  11817. tr.done = true;
  11818. }
  11819. }
  11820. } catch(e) {
  11821. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  11822. window.console.error(traceStack(e, 'putInfosTrolls'));
  11823. }
  11824. }
  11825.  
  11826.  
  11827. /* Mode Tétalanvert! ---------------------------------------------------------*/
  11828.  
  11829. function calculeDistance(maPos,posArr) {
  11830. return Math.max(
  11831. Math.abs(maPos[0]-posArr[0]),
  11832. Math.abs(maPos[1]-posArr[1]),
  11833. Math.abs(maPos[2]-posArr[2])
  11834. );
  11835. }
  11836.  
  11837. function inversionCoord() {
  11838. var maPos = getPosition();
  11839. var listeOffsets = {
  11840. 'monstres':checkBoxLevels.checked?4:3,
  11841. 'trolls':6,
  11842. };
  11843. for(var type in listeOffsets) {
  11844. var trList = VueContext['tr_'+type];
  11845. var offset = listeOffsets[type];
  11846. for(var i=trList.length-1 ; i>0 ; i--) {
  11847. var oldX = parseInt(trList[i].cells[offset].textContent);
  11848. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  11849. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  11850. trList[i].cells[offset].innerHTML = oldY;
  11851. trList[i].cells[offset+1].innerHTML = oldX;
  11852. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  11853. }
  11854. }
  11855. }
  11856.  
  11857.  
  11858. /* Partie principale */
  11859. function do_vue() {
  11860. for(var type in typesAFetcher) {
  11861. fetchData(type);
  11862. }
  11863.  
  11864. // roule' 11/03/2016
  11865. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  11866. // je fais une recopie :(
  11867. MZ_EtatCdMs.tr_monstres = VueContext.tr_monstres;
  11868. tr_trolls = VueContext.tr_trolls;
  11869. tr_tresors = VueContext.tr_tresors;
  11870. tr_champignons = VueContext.tr_champignons;
  11871. tr_lieux = VueContext.tr_lieux;
  11872.  
  11873. MZ_EtatCdMs.nbMonstres = VueContext.nbMonstres;
  11874. nbTrolls = VueContext.nbTrolls;
  11875. nbTresors = VueContext.nbTresors;
  11876. nbChampignons = VueContext.nbChampignons;
  11877. nbLieux = VueContext.nbLieux;
  11878.  
  11879. try {
  11880. start_script(31);
  11881.  
  11882. initialiseInfos();
  11883. savePosition();
  11884.  
  11885. // Fonctionnalité "Têtalenvert" cachée, en test :
  11886. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  11887. inversionCoord();
  11888. }
  11889.  
  11890. ajoutDesFiltres();
  11891. set2DViewSystem();
  11892. //putBoutonTroogle();
  11893. putBoutonPXMP();
  11894.  
  11895. synchroniseFiltres();
  11896. toggleLevelColumn(); // appel des CdM, ne fait rien si la checkbox NOCDM est cochée
  11897.  
  11898. refreshDiplo();
  11899.  
  11900. //400 ms
  11901. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  11902. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  11903. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  11904. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  11905. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  11906. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  11907. var noTresorsEngages =
  11908. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  11909. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  11910. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  11911. filtreMonstres();
  11912. if(noIntangibles) {
  11913. filtreTrolls();
  11914. }
  11915. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  11916. filtreTresors();
  11917. }
  11918. if(noTrou) {
  11919. filtreLieux();
  11920. }
  11921.  
  11922. MZ_Tactique.initPopup();
  11923. initPXTroll();
  11924.  
  11925. if(getTalent("Projectile Magique")) {
  11926. computeProjo();
  11927. }
  11928. if(getTalent("Charger")) {
  11929. computeCharge();
  11930. }
  11931. if(getTalent("Télékinésie")) {
  11932. computeTelek();
  11933. }
  11934. if(getTalent("Lancer de Potions")) {
  11935. computeLdP();
  11936. }
  11937.  
  11938. putScriptExterne();
  11939.  
  11940. displayScriptTime();
  11941. } catch(e) {
  11942. window.console.error(traceStack(e, 'vue'));
  11943. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite (seriez-vous sous l'effet d'un Fumeux ?).");
  11944. }
  11945. }
  11946.  
  11947.  
  11948.  
  11949. /*******************************************************************************
  11950. * This file is part of Mountyzilla. *
  11951. * *
  11952. * Mountyzilla is free software; you can redistribute it and/or modify *
  11953. * it under the terms of the GNU General Public License as published by *
  11954. * the Free Software Foundation; either version 2 of the License, or *
  11955. * (at your option) any later version. *
  11956. * *
  11957. * Mountyzilla is distributed in the hope that it will be useful, *
  11958. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11959. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11960. * GNU General Public License for more details. *
  11961. * *
  11962. * You should have received a copy of the GNU General Public License *
  11963. * along with Mountyzilla; if not, write to the Free Software *
  11964. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11965. *******************************************************************************/
  11966.  
  11967. // x~x profil2
  11968.  
  11969. /*---------------------------- Variables globales ----------------------------*/
  11970.  
  11971. var
  11972. // Anatrolliseur
  11973. urlAnatrolliseur,
  11974. // Infobulles talents
  11975. hauteur = 50, bulleStyle = null,
  11976. // Caracteristiques
  11977. // Infos troll
  11978. race, niv, idtroll, datecrea,
  11979. idguilde, nomguilde,
  11980. // Etats du troll
  11981. fatigue, bmfatigue,
  11982.  
  11983. // Experience, Pi, ...
  11984. pxdistribuables, pxperso,
  11985. piutilisable, pitotal,
  11986. nbmeurtres, nbmorts,
  11987. // utilisee pour les moyennes MM/jour, kill/jour, etc
  11988. NBjours,
  11989. // calcul des DLA suivantes
  11990. DLA, DLAsuiv, HeureServeur,
  11991. // details duree du tour (calcul pvdispo) :
  11992. dtb, pdm, bmt, adb, dpt,
  11993. //posale
  11994. posX, posY, posN,
  11995. // caracs physiques
  11996. vue, vuebp, vuebm, vuetotale,
  11997. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  11998. reg, regbp, regbm, regmoy,
  11999. att, attbp, attbm, attmoy, atttourD, atttour, attmoytour,
  12000. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  12001. deg, degbp, degbm, degmoy, degmoycrit, degtour, degmoytour, degmoycrittour,
  12002. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  12003. rm, rmbp, rmbm, rmtotale,
  12004. mm, mmbp, mmbm, mmtotale,
  12005.  
  12006. // Variables speciales Kastars
  12007. pvActuelKastar, minParPV, overDLA,
  12008. // id pour edition manuelle de lastDLA :
  12009. inJour, inMois, inAn, inHr, inMin, inSec,
  12010. // id pour auto-refresh lastDLA :
  12011. lastDLAZone, maxAMZone, cumulZone,
  12012. lastDLA, DLAaccel;
  12013.  
  12014.  
  12015. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  12016.  
  12017. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  12018. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  12019. function getUniqueValueBySelector(selector, defaultValue){
  12020. var valNode = document.querySelector(selector);
  12021. if(valNode!=null){
  12022. if(valNode.hasChildNodes()) {
  12023. return valNode.childNodes[0].nodeValue;
  12024. }else{
  12025. return defaultValue;
  12026. }
  12027. } else{
  12028. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  12029. return defaultValue;
  12030. }
  12031. }
  12032. function getUniqueStringValueBySelector(selector){
  12033. return getUniqueValueBySelector(selector,"");
  12034. }
  12035. function getUniqueIntValueBySelector(selector){
  12036. var ret = getUniqueValueBySelector(selector,0);
  12037. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  12038. ret = 0;
  12039. }
  12040. return parseInt(ret);
  12041. }
  12042. function getUniqueFloatValueBySelector(selector){
  12043. var ret = getUniqueValueBySelector(selector,0.0);
  12044. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  12045. ret = 0.0;
  12046. }
  12047. return parseFloat(ret);
  12048. }
  12049.  
  12050.  
  12051. function resiste(Ddeg,bm) {
  12052. // version naive mais compréhensible ^^
  12053. // DEBUG: à revoir
  12054. if(!bm) {
  12055. return 2*Math.floor(Ddeg/2);
  12056. }
  12057. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  12058. }
  12059.  
  12060. function retourAZero(fatig) {
  12061. var fat = fatig, raz = 0;
  12062. while(fat>0) {
  12063. raz++;
  12064. fat = Math.floor(fat/1.25);
  12065. }
  12066. return raz;
  12067. }
  12068.  
  12069. function coefDecumul(i) {
  12070. switch(i) {
  12071. case 2: return 0.67;
  12072. case 3: return 0.4;
  12073. case 4: return 0.25;
  12074. case 5: return 0.15;
  12075. default: return 0.1;
  12076. }
  12077. }
  12078.  
  12079. function dureeHM(dmin) {
  12080. var ret = "";
  12081. dmin = Math.floor(dmin);
  12082. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  12083. var mins = dmin%60;
  12084. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  12085. return (ret) ? ret : "-";
  12086. }
  12087.  
  12088. // extraction d'une durée
  12089. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "- 2 h 30 m"
  12090. // c'est protégé (rend 0 si l'élément est absent)
  12091. // Roule' 24/12/2016
  12092. function extractionDuree(selecteur) {
  12093. var s = getUniqueStringValueBySelector(selecteur);
  12094. if (!s) return 0;
  12095. var tabN = getNumbers(s);
  12096. if (tabN.length < 2) return 0;
  12097. if (s.includes('-')) {
  12098. return - tabN[0] * 60 - tabN[1];
  12099. }
  12100. return tabN[0] * 60 + tabN[1];
  12101. }
  12102.  
  12103. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  12104.  
  12105. function extractionDonnees() {
  12106. // Variables temporaires
  12107. var Nbrs = {};
  12108.  
  12109. // *********************
  12110. // Cadre "Description"
  12111. // *********************
  12112. race = getUniqueStringValueBySelector('#descr #race');
  12113. debugMZ("Race : " + race);
  12114. idtroll = getUniqueStringValueBySelector('#descr #id');
  12115. debugMZ("Id troll : " + idtroll);
  12116. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  12117. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  12118. datecrea = new Date(StringToDate(strDateCrea));
  12119. debugMZ("Date creation : " + datecrea);
  12120. // Guilde
  12121. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  12122. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  12123. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  12124.  
  12125. // *******************
  12126. // Cadre "Experience"
  12127. // *******************
  12128. // Niveau de troll
  12129. niv = getUniqueIntValueBySelector('#exp #niv');
  12130. nivTroll = niv;
  12131. debugMZ("Niveau : " + niv);
  12132. // PX
  12133. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  12134. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  12135. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  12136. // PI
  12137. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  12138. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  12139. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  12140. // Meutres/Morts
  12141. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  12142. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  12143. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  12144.  
  12145. // *********************
  12146. // Cadre "Tour de Jeu"
  12147. // *********************
  12148. // DLA
  12149. Nbrs['dla'] = getUniqueStringValueBySelector('#dla #dla>b');
  12150. DLA = new Date(StringToDate(Nbrs['dla']));
  12151. debugMZ('DLA: ' + DLA);
  12152. // DLA suivante
  12153. Nbrs['dlasuiv'] = getUniqueStringValueBySelector('#dla #dla_next');
  12154. DLAsuiv = new Date(StringToDate(Nbrs['dlasuiv']));
  12155. debugMZ('DLAsuiv: ' + DLAsuiv);
  12156. // Duree normale de mon Tour
  12157. dtb = extractionDuree('#dla #tour');
  12158. debugMZ('Duree normale de mon Tour : ' + dtb);
  12159. // Réserve
  12160. dtreserve = extractionDuree('#dla #reserve');
  12161. debugMZ('Durée de réserve : ' + dtreserve);
  12162. // Poids de l'equipement
  12163. pdm = extractionDuree('#dla #poids');
  12164. debugMZ('Poids de l\'equipement : ' + pdm);
  12165. // Bonus/Malus equipemente
  12166. bmt = extractionDuree('#dla #bmequipement'); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  12167. debugMZ('Bonus/Malus sur la duree : ' + bmt);
  12168. // Augmentation due aux blessures
  12169. adb = extractionDuree('#dla #blessure');
  12170. debugMZ('Augmentation due aux blessures : ' + adb);
  12171. // Mouches
  12172. bmmouche = extractionDuree('#dla #mouche');
  12173. debugMZ('Bonus des mouches : ' + bmmouche);
  12174. // Duree de mon prochain Tour
  12175. dpt = extractionDuree('#dla #duree>b');
  12176. debugMZ('Duree de mon prochain Tour : ' + dpt);
  12177.  
  12178. // ****************
  12179. // Cadre "Etats"
  12180. // ****************
  12181. // Position du troll :
  12182. posX = getUniqueIntValueBySelector('#pos #x');
  12183. posY = getUniqueIntValueBySelector('#pos #y');
  12184. posN = getUniqueIntValueBySelector('#pos #n');
  12185. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  12186. // PV actuel
  12187. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  12188. pvActuelKastar = pvcourant;
  12189. debugMZ("PV actuel : " + pvcourant)
  12190. // Fatigue
  12191. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  12192. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  12193. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  12194.  
  12195. // **************************
  12196. // Cadre "Caracteristiques"
  12197. // **************************
  12198. // Attaque
  12199. att = getUniqueIntValueBySelector('#carac #att');
  12200. attbp = getUniqueIntValueBySelector('#carac #att_p');
  12201. attbm = getUniqueIntValueBySelector('#carac #att_m');
  12202. atttour = getUniqueIntValueBySelector('#carac #att_tour'); // % bonus AdA
  12203. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d'); // malus Parade
  12204. attmoy = 3.5*att + attbp + attbm;
  12205. var DAttBonus = Math.floor(((att+atttourD)*atttour/100)); // À vérifier
  12206. attmoytour = 3.5*(att+DAttBonus) + attbp + attbm;
  12207. debugMZ(
  12208. "ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+
  12209. "; BM Dé att/tour:("+atttourD+"D;"+atttour+"%) "+(atttourD+DAttBonus)+
  12210. "D ;AttMoyTour:"+attmoytour
  12211. );
  12212. // Esquive
  12213. esq = getUniqueIntValueBySelector('#carac #esq');
  12214. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  12215. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  12216. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  12217. esqmoy = 3.5*esq + esqbp+esqbm;
  12218. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  12219. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  12220. // Degat
  12221. deg = getUniqueIntValueBySelector('#carac #deg');
  12222. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  12223. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  12224. degtour = getUniqueIntValueBySelector('#carac #deg_tour'); // % bonus AdD
  12225. degmoy = 2*deg + degbp + degbm;
  12226. degmoycrit = 2*(deg+Math.floor(deg/2)) + degbp + degbm;
  12227. var DDegBonus = Math.floor(deg*degtour/100);
  12228. degmoytour = 2*(deg + DDegBonus) + degbp + degbm;
  12229. degmoycrittour = degmoytour + 2*Math.floor(deg/2);
  12230. debugMZ(
  12231. "DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+
  12232. " ;deg/tour:("+degtour+"%) "+DDegBonus+
  12233. "D; DegMoyTour:"+degmoytour+"/"+degmoycrittour
  12234. );
  12235. // PV
  12236. pvbase = getUniqueIntValueBySelector('#carac #pv');
  12237. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  12238. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  12239. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  12240. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  12241. // Regeneration
  12242. reg = getUniqueIntValueBySelector('#carac #reg');
  12243. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  12244. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  12245. regmoy = 2 * reg + regbp + regbm; // D3
  12246. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  12247. // Armure
  12248. arm = getUniqueIntValueBySelector('#carac #arm');
  12249. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  12250. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  12251. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  12252. armmoy = 2*arm + armbp+armbm;
  12253. armmoytour = 2*Math.max(arm+armtourD, 0) + armbp+armbm;
  12254. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  12255. // TODO : D d'armure non active
  12256. // Vue
  12257. vue = getUniqueIntValueBySelector('#carac #vue');
  12258. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  12259. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  12260. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  12261. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  12262. // RM
  12263. rm = getUniqueIntValueBySelector('#carac #rm');
  12264. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  12265. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  12266. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  12267. rmTroll = rmtotale;
  12268. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  12269. // MM
  12270. mm = getUniqueIntValueBySelector('#carac #mm');
  12271. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  12272. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  12273. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  12274. mmTroll = mmtotale;
  12275. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  12276.  
  12277. // Heure Serveur
  12278. try {
  12279. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  12280. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  12281. HeureServeur = new Date(StringToDate(heureServeurSTR));
  12282. } catch (e) {
  12283. window.console.warn(
  12284. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  12285. );
  12286. HeureServeur = new Date();
  12287. }
  12288. debugMZ("HeureServeur: " + HeureServeur);
  12289.  
  12290. // ***INIT GLOBALE*** NBjours
  12291. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  12292.  
  12293. // Calcul debut lien anatroliseur avec les caracteristiques connues
  12294. var amelio_dtb = function(dtb) {
  12295. if(dtb>555) {
  12296. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  12297. }
  12298. return 10+Math.ceil((555-dtb)/2.5);
  12299. },
  12300. amelio_pv = Math.floor(pvbase/10)-3,
  12301. amelio_vue = vue-3,
  12302. amelio_att = att-3,
  12303. amelio_esq = esq-3,
  12304. amelio_deg = deg-3,
  12305. amelio_reg = reg-1,
  12306. amelio_arm = arm-1;
  12307. if(race==="Darkling"){amelio_reg--; }
  12308. if(race==="Durakuir"){amelio_pv-- ; }
  12309. if(race==="Kastar") {amelio_deg--; }
  12310. if(race==="Skrim") {amelio_att--; }
  12311. if(race==="Tomawak") {amelio_vue--; }
  12312.  
  12313. urlAnatrolliseur = URL_AnatrolDispas
  12314. +"outils_anatrolliseur.php?anatrolliseur=v8"
  12315. +"|r="+race.toLowerCase()
  12316. +"|dla="+amelio_dtb(dtb)
  12317. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  12318. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  12319. +"|att="+amelio_att+","+attbp+","+attbm
  12320. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  12321. +"|deg="+amelio_deg+","+degbp+","+degbm
  12322. +"|reg="+amelio_reg+","+regbp+","+regbm
  12323. +"|arm="+amelio_arm+","+armbp+","+armbm
  12324. +"|mm="+mmtotale
  12325. +"|rm="+rmtotale+"|";
  12326. }
  12327.  
  12328. function saveProfil() {
  12329. MY_setValue(idtroll+'.caracs.attaque',att);
  12330. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  12331. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  12332. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  12333. if(atttourD||atttour) {
  12334. var DAttBonus = atttourD + Math.floor((att+atttourD)*atttour/100);
  12335. MY_setValue(idtroll+'.bonus.DAttM',DAttBonus);
  12336. } else {
  12337. MY_removeValue(idtroll+'.bonus.DAttM');
  12338. }
  12339. MY_setValue(idtroll+'.caracs.esquive',esq);
  12340. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  12341. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  12342. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  12343. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  12344. MY_setValue(idtroll+'.caracs.degats',deg);
  12345. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  12346. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  12347. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  12348. if(degtour) {
  12349. var DDegBonus = Math.floor(deg*degtour/100);
  12350. MY_setValue(idtroll+'.bonus.DDeg',DDegBonus);
  12351. } else {
  12352. MY_removeValue(idtroll+'.bonus.DDeg');
  12353. }
  12354. MY_setValue(idtroll+'.caracs.regeneration',reg);
  12355. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  12356. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  12357. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  12358. MY_setValue(idtroll+'.caracs.vue',vue);
  12359. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  12360. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  12361. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  12362. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  12363. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  12364. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  12365. MY_setValue(idtroll+'.caracs.rm',rm);
  12366. MY_setValue(idtroll+'.caracs.rm.bm',(rmtotale));
  12367. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  12368. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  12369. MY_setValue(idtroll+'.caracs.mm',mm);
  12370. MY_setValue(idtroll+'.caracs.mm.bm',(mmtotale));
  12371. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  12372. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  12373. MY_setValue(idtroll+'.caracs.armure',arm);
  12374. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  12375. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  12376. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  12377. MY_setValue(idtroll+'.position.X',posX);
  12378. MY_setValue(idtroll+'.position.Y',posY);
  12379. MY_setValue(idtroll+'.position.N',posN);
  12380. MY_setValue(idtroll+'.race',race);
  12381. MY_setValue(idtroll+'.niveau',niv);
  12382. MY_setValue(idtroll+'.idguilde',idguilde);
  12383. MY_setValue(idtroll+'.nomguilde',nomguilde);
  12384. }
  12385.  
  12386.  
  12387. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  12388.  
  12389. function setInfosCaracteristiques() {
  12390. // Modification de l'entete
  12391. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  12392. thTotal.innerHTML+='|<i>Moyenne</i>';
  12393. thTotal.title="Moyenne (Moyenne ce tour)";
  12394.  
  12395. // Ajout des informations calculees
  12396. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  12397. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  12398. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  12399.  
  12400. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  12401. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  12402. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  12403.  
  12404. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  12405. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  12406. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  12407.  
  12408. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  12409. var tdRegTotal = trRegeneration.children[5];
  12410. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  12411. // Temps recupere par reg (propale R')
  12412. var regmoyTemp = Math.max(0, regmoy);
  12413. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  12414. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  12415. if (sec != 0) {
  12416. regTitle += " " + sec + " sec";
  12417. }
  12418. trRegeneration.title = regTitle;
  12419.  
  12420. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  12421. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  12422. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  12423.  
  12424. var trRM=document.querySelector("table#caracs #rm").parentElement;
  12425. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  12426. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  12427.  
  12428.  
  12429. var trMM=document.querySelector("table#caracs #mm").parentElement;
  12430. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  12431. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  12432.  
  12433. var tdRefl=document.querySelector("#refl");
  12434. // TODO : prendre en compte bonus/malus D esq du tour ?
  12435. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + esqbp + esqbm;
  12436. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  12437. }
  12438.  
  12439. function setLienAnatrolliseur(){
  12440. var pTableAmelio = document.querySelector("#carac>div>p");
  12441. if (!pTableAmelio) pTableAmelio = document.querySelector("#carac>div>div>p");
  12442. if (!pTableAmelio) return;
  12443. pTableAmelio.appendChild(document.createTextNode(' - '));
  12444. var aElt = document.createElement("a");
  12445. aElt.setAttribute("href",urlAnatrolliseur);
  12446. aElt.setAttribute("target","_blank");
  12447. aElt.className="AllLinks";
  12448. aElt.innerHTML="Anatrolliser";
  12449. pTableAmelio.appendChild(aElt);
  12450. }
  12451. function setInfoDescription() {
  12452. var txtDateCrea = (NBjours!=1) ?
  12453. " ("+NBjours+" jours dans le hall)" :
  12454. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  12455. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  12456. }
  12457.  
  12458. function setInfosEtatLieux() {
  12459. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  12460. '?search=position&orderBy=distance&posx='+
  12461. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  12462. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  12463. appendBr(tdPosition);
  12464. var aElt = document.createElement("a");
  12465. aElt.setAttribute("href",urlBricol);
  12466. aElt.setAttribute("target","_blank");
  12467. aElt.className="AllLinks";
  12468. aElt.innerHTML="Lieux à proximité";
  12469. tdPosition.appendChild(aElt);
  12470. }
  12471.  
  12472. function setInfosEtatPV() { // pour AM et Sacro
  12473. var
  12474. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  12475. sec = Math.floor(15000/pvtotal)%60,
  12476. lifebar = document.querySelector("#pos .barre-vie");
  12477. if(sec!=0) { txt += " "+sec+" sec"; }
  12478. if(lifebar) { lifebar.title = txt; }
  12479. if(pvcourant<=0) { return; }
  12480.  
  12481. // Difference PV p/r a equilibre de temps (propale R')
  12482. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(dtreserve + pdm + bmt + bmmouche))
  12483. // ***INIT GLOBALE*** pvdispo
  12484. var bmPVHorsBlessure = dtreserve + pdm + bmt + bmmouche;
  12485. var pvdispo = pvcourant-pvtotal-Math.ceil(bmPVHorsBlessure*pvtotal/250);
  12486. var span = document.createElement("span");
  12487. span.title = txt;
  12488. span.style.fontStyle = "italic";
  12489. if(bmPVHorsBlessure>=0) {
  12490. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  12491. } else if(pvdispo>0) {
  12492. txt = "Vous pouvez encore perdre "+
  12493. Math.min(pvdispo,pvcourant)+
  12494. " PV sans malus de temps.";
  12495. } else if(pvdispo<0) {
  12496. txt = "Il vous manque "
  12497. +(-pvdispo)
  12498. +" PV pour ne plus avoir de malus de temps.";
  12499. } else {
  12500. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  12501. }
  12502. appendText(span,txt);
  12503. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  12504. }
  12505.  
  12506. // Complete le cadre "Experience"
  12507. function setInfosExp() {
  12508. var tdNiv = document.querySelector("#exp #niv");
  12509.  
  12510. // Calcul niveau monstre/troll min pour gain PX
  12511. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  12512. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  12513.  
  12514. // Calcul PX restant
  12515. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  12516. if (pxRestant >= 0) {
  12517. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  12518. if (tdinfoEntrainement) tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  12519. }
  12520.  
  12521. // Calul pi/jour
  12522. var
  12523. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  12524. tdPi = document.querySelector("#exp #pi").parentElement;
  12525. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  12526. tdPi.title = tdPiTotal.title;
  12527.  
  12528. // Rapports meurtres,morts
  12529. var tdKill = document.querySelector("#exp #kill");
  12530. tdKill.setAttribute("colspan", 1);
  12531. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  12532.  
  12533. var tdMort = document.querySelector("#exp #mort");
  12534. tdMort.setAttribute("colspan", 1);
  12535. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  12536.  
  12537. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  12538. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  12539. }
  12540.  
  12541.  
  12542. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  12543.  
  12544. function minParPVsac(fat,bm) {
  12545. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  12546. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  12547. var out = [];
  12548. out[0] = (fat>4) ?
  12549. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  12550. 30;
  12551. if(bm && bm>0) {
  12552. var totalfat=fat+bm;
  12553. out[1] = (totalfat>4) ?
  12554. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  12555. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  12556. }
  12557. return out;
  12558. }
  12559.  
  12560. function toInt(str) {
  12561. str = parseInt(str);
  12562. return (str) ? str : 0;
  12563. }
  12564.  
  12565. function saveLastDLA() {
  12566. // pour les calculs d'AM max
  12567. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  12568. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  12569. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  12570. lastDLA = new Date( StringToDate(str) );
  12571. MY_setValue(numTroll+'.DLA.ancienne',str);
  12572. lastDLAZone.innerHTML = '';
  12573. var b = document.createElement('b');
  12574. b.addEventListener('click',inputMode,false);
  12575. appendText(b,str);
  12576. lastDLAZone.appendChild(b);
  12577. refreshAccel();
  12578. }
  12579.  
  12580. function inputMode() {
  12581. // Edition manuelle lastDLA
  12582. var date;
  12583. if(lastDLA)
  12584. date = new Date( lastDLA );
  12585. else
  12586. date = new Date( DLAaccel );
  12587. lastDLAZone.innerHTML = '';
  12588. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  12589. appendText(lastDLAZone,'/');
  12590. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  12591. appendText(lastDLAZone,'/');
  12592. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  12593. appendText(lastDLAZone,' - ');
  12594. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  12595. appendText(lastDLAZone,':');
  12596. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  12597. appendText(lastDLAZone,':');
  12598. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  12599. appendText(lastDLAZone,' - ');
  12600. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  12601. }
  12602.  
  12603. function setAccel() {
  12604. var
  12605. BMfrais=false,
  12606. fat=fatigue, listeBmFat=[],
  12607. tr, th, insertPt;
  12608.  
  12609. // Creation ligne speciale pour AM dans le cadre "Etat"
  12610. tr = document.createElement('tr');
  12611. th = document.createElement('th');
  12612. appendText(th,'Fatigue et AM',true);
  12613. tr.appendChild(th);
  12614. insertPt = document.createElement('td');
  12615. tr.appendChild(insertPt);
  12616. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  12617.  
  12618. // Est-on en over-DLA ?
  12619. // ***INIT GLOBALE*** overDLA
  12620. overDLA = (HeureServeur>DLA.getTime()+3e5);
  12621. if(overDLA) {
  12622. fat=Math.floor(fatigue/1.25);
  12623. }
  12624.  
  12625. // Gestion des BM de fatigue
  12626. if(bmfatigue>0) {
  12627. if (MY_DEBUG) window.console.log('MZE setAccel, bmfatigue=' + bmfatigue + ', ' + numTroll+'.bm.fatigue=' + MY_getValue(numTroll+'.bm.fatigue'));
  12628. // On tente de recuperer les BM de fatigue de la page des BM
  12629. if(MY_getValue(numTroll+'.bm.fatigue')) {
  12630. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  12631. BMmemoire.pop();
  12632. var tour = 0;
  12633. for(var i=0 ; i<BMmemoire.length ; i++) {
  12634. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  12635. while(tour<=parseInt(nbrs[0])) {
  12636. listeBmFat[tour]=parseInt(nbrs[1]);
  12637. tour++;
  12638. }
  12639. }
  12640. }
  12641. if(listeBmFat[0]==bmfatigue) {
  12642. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  12643. BMfrais = true;
  12644. // Roule 17/06/2020 je ne vois pas du tout pourquoi on viderait xxx;bm.fatigue ici. Et ça fait que la fatigue des Kastars affiche une erreur la 2e fois qu'on va sur le profil... J'enlève
  12645. //MY_removeValue(numTroll+".bm.fatigue");
  12646. }
  12647. } else {
  12648. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  12649. BMfrais = true;
  12650. }
  12651. if(!BMfrais && bmfatigue>0) {
  12652. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  12653. if(bmfatigue==15) {
  12654. listeBmFat = [15,15,15];
  12655. } else {
  12656. listeBmFat = [30,30,15];
  12657. }
  12658. }
  12659. if(overDLA) {
  12660. // Si on est en over-DLA, on decale les bm d'un tour
  12661. listeBmFat.shift();
  12662. }
  12663.  
  12664. // Tableau des fatigues et accel futures
  12665. var
  12666. minppv = minParPVsac(fat,listeBmFat[0]),
  12667. table, tbody,
  12668. ligneTour, ligneFat, ligneMin,
  12669. col;
  12670. // ***INIT GLOBALE*** minParPV
  12671. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  12672. if(fat>0 || listeBmFat[0]>0) {
  12673. table = document.createElement('table');
  12674. table.className = 'mh_tdborder';
  12675. table.border = 0;
  12676. table.cellSpacing = 1;
  12677. table.cellPadding = 1;
  12678. table.style.textAlign = "center";
  12679. tbody = document.createElement('tbody');
  12680. table.appendChild(tbody);
  12681. insertPt.appendChild(table);
  12682.  
  12683. ligneTour = appendTr(tbody,'mh_tdtitre');
  12684. ligneTour.style.fontWeight = "bold";
  12685. var td = appendTdText(ligneTour,'Tour :',true);
  12686. td.align = 'left';
  12687. ligneFat = appendTr(tbody,'mh_tdpage');
  12688. td = appendTdText(ligneFat,'Fatigue :',true);
  12689. td.className = 'mh_tdtitre';
  12690. td.align = 'left';
  12691. ligneMin = appendTr(tbody,'mh_tdpage');
  12692. td = appendTdText(ligneMin,'1 PV =',true);
  12693. td.className = 'mh_tdtitre';
  12694. td.align = 'left';
  12695. col=0;
  12696. while(col<9 && (fat>0 || listeBmFat[col])) {
  12697. if(col==0) {
  12698. if(overDLA) {
  12699. var i = document.createElement('i');
  12700. appendText(i,'A activer');
  12701. ligneTour.appendChild(i);
  12702. } else {
  12703. appendTdText(ligneTour,'En cours');
  12704. }
  12705. } else {
  12706. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12707. }
  12708. if(listeBmFat[col]) {
  12709. if(BMfrais || (!overDLA && col==0)) {
  12710. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  12711. appendTdText(ligneMin,minppv[1]+'\'');
  12712. } else {
  12713. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  12714. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  12715. }
  12716. } else {
  12717. appendTdText(ligneFat,fat);
  12718. appendTdText(ligneMin,minppv[0]+'\'');
  12719. }
  12720. col++;
  12721. fat = Math.floor(fat / 1.25);
  12722. minppv = minParPVsac(fat,listeBmFat[col]);
  12723. }
  12724. if(fat>1 || (fat==1 && !overDLA)) {
  12725. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  12726. appendTdText(ligneFat,'-');
  12727. appendTdText(ligneMin,'-');
  12728. }
  12729. col = (overDLA) ?
  12730. Math.max(retourAZero(fatigue)-1,col) :
  12731. Math.max(retourAZero(fatigue),col);
  12732. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12733. appendTdText(ligneFat,'0');
  12734. appendTdText(ligneMin,'30\'');
  12735.  
  12736. if(!BMfrais && bmfatigue) {
  12737. // si les BM n'ont pas ete rafraichis, on signale:
  12738. appendText(
  12739. insertPt,
  12740. '/!\\ Visitez la page des Bonus/Malus '+
  12741. 'pour mettre à jour votre fatigue. /!\\',
  12742. true
  12743. );
  12744. appendBr(insertPt);
  12745. }
  12746. appendBr(insertPt);
  12747. }
  12748.  
  12749. if(pvcourant<=0) {
  12750. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  12751. return;
  12752. }
  12753.  
  12754. if(fatigue>30) {
  12755. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  12756. return;
  12757. }
  12758.  
  12759. // Setup lastDLAZone
  12760. if(overDLA) {
  12761. // bypass des infos de "menu_FF.js" en cas d'overDLA
  12762. DLAaccel = new Date( DLAsuiv );
  12763. lastDLA = new Date( DLA );
  12764. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  12765. // ***INIT GLOBALE*** pvActuelKastar
  12766. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  12767. appendText(
  12768. insertPt,
  12769. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  12770. true
  12771. );
  12772. appendBr(insertPt);
  12773. } else {
  12774. DLAaccel = new Date( DLA );
  12775. pvActuelKastar = pvcourant;
  12776. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  12777. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  12778. } else {
  12779. lastDLA = false;
  12780. }
  12781. }
  12782. appendText(insertPt,'Dernière DLA enregistrée : ');
  12783. lastDLAZone = document.createElement('span');
  12784. lastDLAZone.style.cursor = 'pointer';
  12785. var b = document.createElement('b');
  12786. b.onclick = inputMode;
  12787. lastDLAZone.appendChild(b);
  12788. insertPt.appendChild(lastDLAZone);
  12789. if(lastDLA) {
  12790. appendText(b,DateToString(lastDLA));
  12791. } else {
  12792. appendText(b,'aucune');
  12793. }
  12794. appendBr(insertPt);
  12795.  
  12796. // Setup maxAMZone et cumulZone
  12797. appendText(insertPt,'Accélération maximale possible : ');
  12798. maxAMZone = document.createElement('b');
  12799. insertPt.appendChild(maxAMZone);
  12800. appendBr(insertPt);
  12801. cumulZone = document.createElement('span');
  12802. insertPt.appendChild(cumulZone);
  12803.  
  12804. refreshAccel();
  12805. }
  12806.  
  12807. function refreshAccel() {
  12808. var pvs, pvsmax;
  12809.  
  12810. // Acceleration pour cumul instantane
  12811. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  12812. if(lastDLA) {
  12813. pvsmax = Math.min(
  12814. pvActuelKastar-1,
  12815. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  12816. );
  12817. maxAMZone.innerHTML = pvsmax+" PV";
  12818. } else {
  12819. pvsmax = pvActuelKastar-1;
  12820. maxAMZone.innerHTML = "inconnue";
  12821. }
  12822.  
  12823. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  12824. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  12825. cumulZone.innerHTML = '';
  12826. if(pvs<=pvsmax) {
  12827. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  12828. appendText(cumulZone,pvs+' PV', true);
  12829. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  12830. if(pvs!=1) {
  12831. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  12832. -(pvs-1)*60*minParPV;
  12833. appendText(
  12834. cumulZone,
  12835. ' ('+(pvs-1)+' PV dans '+
  12836. Math.floor(gainSec/60)+'min'+
  12837. addZero(gainSec%60)+'s)'
  12838. );
  12839. }
  12840. } else {
  12841. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  12842. appendText(
  12843. cumulZone,
  12844. 'Après votre accélération maximale, il vous faudra encore attendre '+
  12845. dureeHM(avantDLA/6e4)+
  12846. ' avant de réactiver.'
  12847. );
  12848. }
  12849. }
  12850.  
  12851.  
  12852. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  12853.  
  12854. function traitementTalents() {
  12855. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  12856. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  12857. removeAllTalents();
  12858. var totalComp = injecteInfosBulles(trCompetence,'competences');
  12859. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  12860. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  12861. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  12862. }
  12863.  
  12864. function injecteInfosBulles(liste,fonction) {
  12865. var totalpc = 0;
  12866. // on parse la liste des talents du type 'fonction'
  12867. for(var i=0 ; i<liste.length ; i++) {
  12868. var
  12869. trTalent=liste[i],
  12870. node=trTalent.cells[1].querySelector('a'),
  12871. nomTalent=epure(trim(node.textContent)),
  12872. indiceTDniveaux=7,
  12873. indiceTDSousCompetence=2,
  12874. sousCompetences=undefined;
  12875. if(fonction=="competences"){
  12876. // un TD en plus pour des information complementaire liees a la comp
  12877. indiceTDniveaux++;
  12878. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  12879. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  12880. for (var j=0; j < sousCompetences.length; j++) {
  12881. sousCompetences[j] = sousCompetences[j].epure().trim();
  12882. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  12883. }
  12884. }
  12885. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  12886. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  12887. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  12888. totalpc += niveauxMaitrisesTalentArray[1];
  12889.  
  12890. // stockage des niveaux inferieurs du talent si presents
  12891. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  12892. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  12893. totalpc+=niveauxMaitrisesTalentArray[j+1];
  12894. }
  12895. }
  12896. return totalpc;
  12897. }
  12898.  
  12899. function setInfos(node,nom,fonction,niveau) {
  12900. node.nom = nom;
  12901. node.fonction = fonction;
  12902. node.niveau = niveau;
  12903. node.onmouseover = setBulle;
  12904. node.onmouseout = cacherBulle;
  12905. }
  12906.  
  12907. var arrayModifAnatroll = {
  12908. 'Glue':'Glu',
  12909. 'PuM':'PuiM',
  12910. 'HE':'Hurlement',
  12911. //'Insultes':'Insu',
  12912. 'Pistage':'Pist',
  12913. 'PuC':'Planter',
  12914. 'Golemo':'Golem',
  12915. }
  12916.  
  12917. function setTalent(nom,pc,niveau,sousCompetences) {
  12918. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  12919. // (et pas les % dont osf) ne serait pas plus rentable
  12920. var nomEnBase = arrayTalents[epure(nom)];
  12921. if(!nomEnBase) {
  12922. debugMZ("setTalent: le talent "+nom+" n'est pas dans la base MZ");
  12923. return;
  12924. }
  12925. if(!niveau) { niveau = 1; }
  12926.  
  12927. switch(nomEnBase) {
  12928. case 'Insultes':
  12929. urlAnatrolliseur += 'Insu'+niveau+'|';
  12930. case 'IdT':
  12931. nomEnBase += niveau;
  12932. break;
  12933. case 'Piege':
  12934. for (var i=0 ; i < sousCompetences.length ; i++) {
  12935. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  12936. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  12937. }
  12938. break;
  12939. case 'AP':
  12940. case 'Baroufle':
  12941. case 'CdB':
  12942. case 'CdM':
  12943. case 'Parer':
  12944. case 'Retraite':
  12945. case 'RB':
  12946. case 'SInterposer':
  12947. nomEnBase += niveau;
  12948. default:
  12949. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  12950. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  12951. }
  12952. //debugMZ("setTalent: nom=" + nom + ", pc=" + pc + ", niveau=" + niveau + ", sousCompetences=" + JSON.stringify(sousCompetences) + "=>setValue(" + numTroll+'.talent.'+nomEnBase+", " + pc + ")");
  12953. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  12954. }
  12955.  
  12956. function creerBulleVide() {
  12957. var table = document.createElement('table');
  12958. table.id = 'bulle';
  12959. table.className = 'mh_tdborder';
  12960. table.width = 300;
  12961. table.border = 0;
  12962. table.cellPadding = 5;
  12963. table.cellSpacing = 1;
  12964. table.style =
  12965. 'position:absolute;'
  12966. +'visibility:hidden;'
  12967. +'z-index:800;'
  12968. +'height:auto;';
  12969. var tr = appendTr(table,'mh_tdtitre');
  12970. appendTdText(tr,'Titre');
  12971. tr = appendTr(table,'mh_tdpage');
  12972. appendTdText(tr,'Contenu');
  12973. var aList = document.getElementsByTagName('a');
  12974. aList[aList.length-1].parentNode.appendChild(table);
  12975. return table;
  12976. }
  12977.  
  12978. function cacherBulle() {
  12979. if(bulleStyle)
  12980. bulleStyle.visibility = 'hidden';
  12981. }
  12982.  
  12983. function setBulle(evt) {
  12984. var nom = this.nom;
  12985. var fonction = this.fonction;
  12986. var niveau = parseInt(this.niveau);
  12987. var str='';
  12988. if(fonction=='competences'){
  12989. str=competences(nom,niveau);
  12990. } else if(fonction=='sortileges') {
  12991. str=sortileges(nom);
  12992. } else if (fonction == '*') { // pour les raccourcis de la frame de gauche : on ne sait pas si c'est compétence ou sort
  12993. str=competences(nom,niveau);
  12994. if (str == '') str=sortileges(nom);
  12995. }
  12996. if(str=='') {
  12997. if (MY_DEBUG) window.console.log('MZ setBulle, pas de description sur ' + nom);
  12998. return;
  12999. }
  13000. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  13001.  
  13002. var xfenetre, yfenetre, xpage, ypage, element = null;
  13003. var offset = 15;
  13004. var bulleWidth = 300;
  13005. if(!hauteur) hauteur = 50;
  13006. element = document.getElementById('bulle');
  13007. if (!element) element = creerBulleVide();
  13008. xfenetre = evt.clientX;
  13009. yfenetre = evt.clientY;
  13010. xpage = xfenetre;
  13011. ypage = yfenetre;
  13012. if(evt.pageX) xpage = evt.pageX;
  13013. if(evt.pageY) ypage = evt.pageY;
  13014. if(element) {
  13015. bulleStyle = element.style;
  13016. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  13017. element.childNodes[1].firstChild.innerHTML = str;
  13018. }
  13019. if(bulleStyle) {
  13020. if(xfenetre>bulleWidth+offset)
  13021. xpage -= bulleWidth+offset;
  13022. else
  13023. xpage += offset;
  13024. if(yfenetre>hauteur+offset)
  13025. ypage -= hauteur + offset;
  13026. bulleStyle.width = bulleWidth;
  13027. bulleStyle.left = xpage + 'px';
  13028. bulleStyle.top = ypage + 'px';
  13029. bulleStyle.visibility = 'visible';
  13030. }
  13031. }
  13032.  
  13033.  
  13034. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  13035.  
  13036. function competences(comp,niveau) {
  13037. var
  13038. modA = atttour?Math.floor((att+atttourD)*atttour/100):0,
  13039. modD = degtour?Math.floor(deg*degtour/100):0,
  13040. texte = "";
  13041.  
  13042. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  13043. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  13044. if(minParPV>1) texte += 's';
  13045. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  13046. } else if(comp.indexOf("Attaque Precise")!=-1) {
  13047. var
  13048. i, pc,
  13049. lastmax=0,
  13050. jetatt, espatt=0,
  13051. notMaxedOut = false;
  13052.  
  13053. for(i=niveau ; i>0 ; i--) {
  13054. pc = getTalent(comp,i);
  13055. if(lastmax!=0 && pc<=lastmax) {
  13056. // Si %AP(i)<%AP(i+1), on passe AP(i)
  13057. continue;
  13058. }
  13059. jetatt = Math.round(3.5*(
  13060. Math.min(Math.floor(1.5*att), att+3*i) + modA
  13061. )) + attbp+attbm;
  13062. espatt += (pc-lastmax)*jetatt;
  13063. texte += "Attaque niv. "+i +
  13064. " ("+(pc-lastmax)+"%) : <b>" +
  13065. Math.min(Math.floor(att*1.5), att+3*i)+"</b> D6 ";
  13066. if(modA) {
  13067. texte += "<i>"+aff(modA)+"D6</i> ";
  13068. }
  13069. texte += aff(attbp+attbm)+" => <b>"+jetatt+"</b><br>";
  13070. lastmax = pc;
  13071. if(i<niveau) {
  13072. // Si l'un des % de niveau inf est > % nivmax,
  13073. // on affiche l'espérance à la fin
  13074. notMaxedOut = true;
  13075. }
  13076. }
  13077. if(notMaxedOut) {
  13078. texte += "<i>Attaque moyenne (si réussite) : <b>" +
  13079. Math.floor(10*espatt/lastmax)/10+"</b></i><br>";
  13080. }
  13081. texte += "Dégâts : <b>"+deg+"</b> D3 ";
  13082. if(modD) {
  13083. texte += "<i>"+aff(modD)+"D3</i> ";
  13084. }
  13085. texte += aff(degbp+degbm) +
  13086. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  13087. } else if(comp.indexOf("Balayage")!=-1) {
  13088. texte = "Déstabilisation : <b>"+att+"</b> D6 ";
  13089. if(modA) {
  13090. texte += "<i>"+aff(modA)+"D6</i> ";
  13091. }
  13092. texte += aff(attbp+attbm) +
  13093. " => <b>"+attmoytour+"</b><br>" +
  13094. "Effet : <b>Met à terre l'adversaire</b>";
  13095. } else if(comp.indexOf('Bidouille')!=-1)
  13096. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  13097. +'de votre inventaire avec le texte de votre choix.';
  13098. else if(comp.indexOf('Baroufle')!=-1){
  13099. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  13100. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  13101. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  13102. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  13103. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  13104. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  13105. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  13106. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  13107. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  13108. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  13109. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  13110. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  13111. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  13112. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  13113. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  13114. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  13115. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  13116. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  13117. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  13118. '</tbody></table>';
  13119. } else if(comp.indexOf("Botte Secrete")!=-1) {
  13120. modA = atttour?Math.floor(Math.floor(2*att/3)*atttour/100):0;
  13121. modD = degtour?Math.floor(Math.floor(att/2)*degtour/100):0;
  13122. texte = "Attaque : <b>"+Math.floor(2*att/3)+"</b> D6 ";
  13123. if(modA) {
  13124. texte += "<i>"+aff(modA)+"D6</i> ";
  13125. }
  13126. texte += aff(Math.floor((attbp+attbm)/2)) +
  13127. " => <b>"+Math.round(
  13128. 3.5*(Math.floor(2*att/3)+modA)+Math.floor((attbp+attbm)/2)
  13129. )+"</b><br/>Dégâts : <b>"+Math.floor(att/2)+"</b> D3 ";
  13130. if(modD) {
  13131. texte += "<i>"+aff(modD)+"D3</i> ";
  13132. }
  13133. texte += aff(Math.floor((degbp+degbm)/2))+" => <b>" +
  13134. (2*(Math.floor(att/2)+modD)+Math.floor((degbp+degbm)/2)) +
  13135. "/"+(
  13136. 2*(Math.floor(1.5*Math.floor(att/2))+modD) +
  13137. Math.floor((degbp+degbm)/2)
  13138. )+"</b>";
  13139. } else if(comp.indexOf('Camouflage')!=-1) {
  13140. var camou = getTalent('Camouflage');
  13141. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  13142. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  13143. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  13144. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  13145. } else if(comp.indexOf("Charger")!=-1) {
  13146. if(pvcourant<=0) {
  13147. // N'est plus censé se produire : activation obligatoire si mort
  13148. return "<i>On ne peut charger personne quand on est mort !</i>";
  13149. }
  13150. var portee = Math.min(
  13151. Math.max(
  13152. getPortee(reg+Math.floor(pvcourant/10)) -
  13153. Math.floor((fatigue+bmfatigue)/5),
  13154. 1
  13155. ),
  13156. vuetotale
  13157. );
  13158. if(portee<1) {
  13159. return "<b>Impossible de charger</b>";
  13160. }
  13161. texte = "Attaque : <b>"+att+"</b> D6 ";
  13162. if(modA) {
  13163. texte += "<i>"+aff(modA)+"D6</i> ";
  13164. }
  13165. texte += aff(attbp+attbm) +
  13166. " => <b>"+attmoytour+"</b><br>" +
  13167. "Dégâts : <b>"+deg+"</b> D3 ";
  13168. if(modD) {
  13169. texte += "<i>"+aff(modD)+"D3</i> ";
  13170. }
  13171. texte += aff(degbp+degbm) +
  13172. " => <b>"+degmoytour+"/"+degmoycrittour+"</b><br>" +
  13173. "Portée : <b>"+portee+"</b> case";
  13174. if(portee>1) { texte += "s"; }
  13175. } else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  13176. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  13177. if(vuetotale>1) texte += 's';
  13178. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  13179. if(vuetotale>2) texte += 's';
  13180. }
  13181. else if(comp.indexOf('Piege')!=-1) {
  13182. texte = 'Piège à Glue :<ul><li>Et si vous colliez vos adversaires au sol ?</li></ul>';
  13183. texte += 'Piège à Feu: <ul><li>À moins que vous ne préfériez les envoyer en l\'air !</li>';
  13184. texte += '<li>Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  13185. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b></li></ul>';
  13186. } else if(comp.indexOf("Contre-Attaquer")!=-1) {
  13187. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  13188. texte = "Attaque : <b>"+Math.floor(att/2)+"</b> D6 ";
  13189. if(modA) {
  13190. texte += "<i>"+aff(modA)+"D6</i> ";
  13191. }
  13192. texte += aff(Math.floor((attbp+attbm)/2)) +
  13193. " => <b>"+Math.round(
  13194. 3.5*(Math.floor(att/2)+modA)+Math.floor((attbp+attbm)/2)
  13195. )+"</b><br>" +
  13196. "Dégâts : <b>"+deg+"</b> D3 ";
  13197. if(modD) {
  13198. texte += "<i>"+aff(modD)+"D3</i> ";
  13199. }
  13200. texte += aff(degbp+degbm) +
  13201. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  13202. } else if(comp.indexOf("Coup de Butoir")!=-1) {
  13203. var
  13204. i, pc,
  13205. lastmax=0,
  13206. jetdeg, espdeg=0,
  13207. notMaxedOut = false;
  13208.  
  13209. texte = "Attaque : <b>"+att+"</b> D6 ";
  13210. if(modA) {
  13211. texte += "<i>"+aff(modA)+"D6</i> ";
  13212. }
  13213. texte += aff(attbp+attbm) +
  13214. " => <b>"+attmoytour+"</b>";
  13215. for(i=niveau ; i>0 ; i--) {
  13216. pc = getTalent(comp,i);
  13217. if(lastmax!=0 && pc<=lastmax) {
  13218. // Si %CdB(i)<%CdB(i+1), on passe CdB(i)
  13219. continue;
  13220. }
  13221. jetdeg = 2*(
  13222. Math.min(Math.floor(1.5*deg), deg+3*i) + modD
  13223. ) + degbp+degbm;
  13224. espdeg += (pc-lastmax)*jetdeg;
  13225. texte += "<br>Dégâts niv. "+i+" ("+(pc-lastmax)+"%) : <b>" +
  13226. Math.min(Math.floor(deg*1.5),deg+3*i)+"</b> D3 ";
  13227. if(modD) {
  13228. texte += "<i>"+aff(modD)+"D3</i> ";
  13229. }
  13230. texte += aff(degbp+degbm) +
  13231. " => <b>"+jetdeg +
  13232. "/"+(jetdeg+2*Math.floor(deg/2))+"</b>";
  13233. lastmax = pc;
  13234. if(i<niveau) {
  13235. // Si l'un des % de niveau inf est > % nivmax,
  13236. // on affiche l'espérance à la fin
  13237. notMaxedOut = true;
  13238. }
  13239. }
  13240. if(notMaxedOut) {
  13241. texte += "<br><i>Dégâts moyens (si réussite) : <b>" +
  13242. Math.floor(10*espdeg/lastmax)/10+"/" +
  13243. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2)) +
  13244. "</b></i>";
  13245. }
  13246. } else if(comp.indexOf('Course')!=-1)
  13247. texte = 'Déplacement gratuit : <b>'
  13248. +Math.floor(getTalent('Course')/2)
  13249. +' %</b> de chance';
  13250. else if(comp.indexOf('Deplacement Eclair')!=-1)
  13251. texte = 'Permet d\'économiser <b>1</b> PA '
  13252. +'par rapport au déplacement classique';
  13253. else if(comp.indexOf('Dressage')!=-1)
  13254. texte = 'Le dressage permet d\'apprivoiser un Gowap redevenu sauvage, un Mouch\'oo Sauvage '
  13255. +'ou un Gnu Sauvage. La portée est de une case.';
  13256. else if(comp.indexOf('Ecriture Magique')!=-1)
  13257. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  13258. +'la formule nécessite de réunir les composants de cette formule, '
  13259. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  13260. +'un champignon adéquat pour confectionner l\'encre.';
  13261. else if(comp.indexOf('Frenesie')!=-1) {
  13262. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  13263. +' => <b>'+attmoy+'</b><br/>'
  13264. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  13265. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  13266. }
  13267. else if(comp.indexOf('Golem')!=-1)
  13268. texte = 'Animez votre golem en assemblant divers matériaux '
  13269. +'autour d\'un cerveau minéral.'
  13270. else if(comp.indexOf('Grattage')!=-1) {
  13271. texte = 'Permet de confectionner un Parchemin Vierge '
  13272. +'à partir de composants et de Gigots de Gob\'.';
  13273. }
  13274. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  13275. texte = 'Fait fuir un monstre si tout se passe bien.'
  13276. +'<br/>Lui donne de gros bonus sinon...';
  13277. else if(comp.indexOf('Identification des Champignons')!=-1) {
  13278. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  13279. if(vuetotale>2) texte += 's';
  13280. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  13281. if(vuetotale>4) texte += 's';
  13282. }
  13283. else if(comp.indexOf('Insultes')!=-1)
  13284. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  13285. else if(comp.indexOf('interposer')!=-1)
  13286. texte = 'Jet de réflexe : <b>'
  13287. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  13288. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  13289. else if(comp.indexOf('Lancer de Potions') != -1)
  13290. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  13291. else if(comp.indexOf('Marquage')!=-1)
  13292. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  13293. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  13294. +'se trouver dans la même caverne que le monstre pour le marquer.';
  13295. else if(comp.indexOf('Melange Magique')!=-1)
  13296. texte = 'Cette Compétence permet de combiner deux Potions pour '
  13297. +'en réaliser une nouvelle dont l\'effet est la somme '
  13298. +'des effets des potions initiales.';
  13299. else if(comp.indexOf('Travail de la Pierre')!=-1)
  13300. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  13301. +2*vuetotale+'</b> cases</li>'
  13302. +'<li>Portée verticale (officieuse) : <b>'
  13303. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  13304. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  13305. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  13306. else if(comp.indexOf('Necromancie')!=-1)
  13307. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  13308. +'de faire "revivre" ce monstre.';
  13309. else if(comp.indexOf('Painthure de Guerre')!=-1)
  13310. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  13311. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  13312. +'pour s\'inspirer, et laissez parler votre créativité.'
  13313. else if(comp.indexOf("Parer")!=-1) {
  13314. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  13315. texte = "Jet de parade : <b>"+Math.floor(att/2)+"</b> D6 ";
  13316. if(modA) {
  13317. texte += "<i>"+aff(modA)+"D6</i> ";
  13318. }
  13319. texte += aff(Math.floor((attbp+attbm)/2)) +
  13320. " => <b>"+Math.round(
  13321. 3.5*(Math.floor(att/2)+modA) +
  13322. Math.floor((attbp+attbm)/2)
  13323. )+"</b><hr>Equivalent esquive : <b>" +
  13324. (Math.floor(att/2)+esq)+"</b> D6 ";
  13325. if(modA) {
  13326. texte += "<i>"+aff(modA)+"D6</i> ";
  13327. }
  13328. texte += aff(Math.floor((attbp+attbm)/2)+esqbp+esqbm) +
  13329. " => <b>"+(Math.round(
  13330. 3.5*(Math.floor(att/2)+modA+esq) +
  13331. Math.floor((attbp+attbm)/2)
  13332. )+esqbp+esqbm)+"</b></i>";
  13333. } else if(comp.indexOf('Pistage')!=-1)
  13334. texte = 'Portée horizontale : <b>'
  13335. +2*vuetotale+'</b> cases<br/>'
  13336. +'Portée verticale : <b>'
  13337. +2*Math.ceil(vuetotale/2)+'</b> cases';
  13338. else if(comp.indexOf('Planter un Champignon')!=-1)
  13339. texte = 'Planter un Champignon est une compétence qui vous permet de '
  13340. +'créer des colonies d\'une variété donnée de champignon à partir de '
  13341. +'quelques exemplaires préalablement enterrés.';
  13342. else if(comp.indexOf('Regeneration Accrue')!=-1)
  13343. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  13344. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  13345. else if(comp.indexOf('Reparation')!=-1)
  13346. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  13347. +'et réparez vous-même votre matériel !';
  13348. else if(comp.indexOf('Retraite')!=-1)
  13349. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  13350. +'préférable de préparer un repli stratégique pour déconcerter '
  13351. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  13352. +'Quelle intelligence démoniaque.';
  13353. else if(comp.indexOf("RotoBaffe")!=-1) {
  13354. var
  13355. Datt = att, vattbm = attbp+attbm,
  13356. Ddeg = deg, vdegbm = degbp+degbm;
  13357. for(var i=1 ; i<niveau+2 ; i++) {
  13358. texte += "<b>Attaque n°"+i+" :</b><br>" +
  13359. "Attaque : <b>"+Datt+"</b> D6 ";
  13360. if(modA) {
  13361. texte += "<i>"+aff(modA)+"D6</i> ";
  13362. }
  13363. texte += aff(vattbm) +
  13364. " => <b>"+(Math.round(3.5*(Datt+modA))+vattbm)+"</b><br>" +
  13365. "Dégâts : <b>"+Ddeg+"</b> D3 ";
  13366. if(modD) {
  13367. texte += "<i>"+aff(modD)+"D3</i> ";
  13368. }
  13369. texte += aff(vdegbm) +
  13370. " => <b>"+(2*(Ddeg+modD)+vdegbm) +
  13371. "/"+(2*(Math.floor(1.5*Ddeg)+modD)+vdegbm)+"</b>";
  13372. Datt = Math.floor(0.75*Datt);
  13373. modA = atttour?Math.floor((Datt+atttourD)*atttour/100):0;
  13374. vattbm = Math.floor(0.75*vattbm);
  13375. Ddeg = Math.floor(0.75*Ddeg);
  13376. modD = degtour?Math.floor(Ddeg*degtour/100):0;
  13377. vdegbm = Math.floor(0.75*vdegbm);
  13378. if(i<niveau+1) { texte += "<hr>"; }
  13379. }
  13380. } else if(comp.indexOf('Shamaner')!=-1)
  13381. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  13382. +'des monstres en utilisant des champignons (de 1 à 3).';
  13383. return texte;
  13384. }
  13385.  
  13386. function sortileges(sort) {
  13387. sort = sort.toLowerCase();
  13388. var
  13389. // Fonctions utiles uniquement à "sortileges"
  13390. decumul_buff = function(nom,str,buff) {
  13391. // Décumul des sorts de buff (old school)
  13392. var
  13393. txt = "1<sup>ere</sup>"+nom+" : <b>"+str+" +"+buff+"</b>",
  13394. dec = buff,
  13395. total = buff,
  13396. i=1;
  13397. while(i<6) {
  13398. i++;
  13399. dec = Math.floor(coefDecumul(i)*buff);
  13400. if(dec<=1 || i==6) break;
  13401. total += dec;
  13402. txt += "<br/><i>"+i+"<sup>e</sup> "+nom+" : "+
  13403. str+" +"+dec+" (+"+total+")</i>";
  13404. }
  13405. txt += "<br/><i>"+i+"<sup>e</sup> et + : "+str+" +"+dec+"</i>";
  13406. return txt;
  13407. },
  13408. nbrAdX = function(pc) {
  13409. // Détermine le nombre d'AdX actifs à partir du % de D
  13410. switch(Number(pc)) {
  13411. case 0 : return 0;
  13412. case 20: return 1;
  13413. case 33: return 2;
  13414. case 41: return 3;
  13415. case 46: return 4;
  13416. default: return Math.floor((Number(pc)-39)/2);
  13417. }
  13418. },
  13419. decumulPc = function(n) {
  13420. // Détermine le % de D décumulé du n-ième AdX
  13421. switch(Number(n)) {
  13422. case 0: return 0;
  13423. case 1: return 20;
  13424. case 2: return 13;
  13425. case 3: return 8;
  13426. case 4: return 5;
  13427. case 5: return 3;
  13428. default: return 2;
  13429. }
  13430. },
  13431. decumulFixe = function(bm, n) {
  13432. // Détermine le bonus fixe décumulé du n-ième AdX
  13433. switch(Number(n)) {
  13434. case 0: return 0;
  13435. case 1: return Math.max(1,bm);
  13436. case 2: return Math.max(1,Math.round(bm*6.7)/10);
  13437. case 3: return Math.max(1,Math.round(bm*4)/10);
  13438. default: return 1; // Sous les 1 de moyenne même en D6
  13439. }
  13440. },
  13441. texte = "";
  13442.  
  13443. if (sort.indexOf('analyse anatomique') != -1) {
  13444. texte = 'Portée horizontale : <b>'
  13445. + Math.floor(vuetotale / 2) + '</b> case';
  13446. if (vuetotale > 3){ texte += 's'; }
  13447. texte += '<br/>Portée verticale : <b>'
  13448. + Math.floor((vuetotale+1)/4)+'</b> case';
  13449. if (vuetotale > 7){ texte += 's'; }
  13450. } else if (sort.indexOf('armure etheree') != -1) {
  13451. texte = decumul_buff('AE', 'Armure magique', reg);
  13452. } else if (sort.indexOf("augmentation")!=-1 && sort.indexOf("attaque")!=-1) {
  13453. var
  13454. categoriesAdA = {
  13455. "attx1": {
  13456. // Affichage: code MZ (cf arrayTalents)
  13457. "AN": true,
  13458. "AP": "AP1",
  13459. "Balayage": "Balayage",
  13460. "Charge": "Charger",
  13461. "CdB": "CdB1",
  13462. "Frénésie": "Frenesie",
  13463. "RB": "RB1",
  13464. "GdS": "GdS",
  13465. "Siphon": "Siphon"
  13466. },
  13467. "attx2/3": {
  13468. "Botte Secrète": "BS"
  13469. },
  13470. "attx1/2": {
  13471. "CA": "CA",
  13472. "Parer": "Parer1"
  13473. },
  13474. "degx2/3": {
  13475. "Vampirisme": "Vampi"
  13476. },
  13477. "vuex1": {
  13478. "Projectile Magique": "Projo"
  13479. }
  13480. },
  13481. baseAdA = {
  13482. "attx1" : att,
  13483. "attx2/3": Math.floor(2*att/3),
  13484. "attx1/2": Math.floor(att/2),
  13485. "degx2/3": Math.floor(2*deg/3),
  13486. "vuex1" : vue
  13487. },
  13488. pc = atttour,
  13489. pcInit = pc,
  13490. nbrAdA = nbrAdX(pc),
  13491. categorie, talent, newTalent,
  13492. i, DSup, fixe=0;
  13493.  
  13494. i=nbrAdA;
  13495. while(i++<nbrAdA+3) {
  13496. pc += decumulPc(i);
  13497. fixe += decumulFixe(3.5,i);
  13498. if(texte) { texte += "<hr>"; }
  13499. texte += "<b>"+i+"<sup>e</sup> AdA : " +
  13500. aff(pc)+"% de Dés d'attaque :</b><br>";
  13501. for(categorie in categoriesAdA) {
  13502. // On génére la liste: "talent1, talent2"
  13503. DSup = Math.floor(baseAdA[categorie]*pc/100) -
  13504. Math.floor(baseAdA[categorie]*pcInit/100);
  13505. newTalent = false;
  13506. for(var talent in categoriesAdA[categorie]) {
  13507. if(getTalent(categoriesAdA[categorie][talent])) {
  13508. if(newTalent) { texte += ", "; }
  13509. texte += talent;
  13510. newTalent = true;
  13511. }
  13512. }
  13513. if(newTalent) {
  13514. // Si le trõll a au moins un talent dans la catégorie :
  13515. texte += ": <b>+"+DSup+"D6 +"+Math.floor(fixe)+"</b> <i>(+" +
  13516. Math.floor(3.5*DSup+fixe) +")</i><br>";
  13517. }
  13518. }
  13519. }
  13520. } else if (sort.indexOf('augmentation') != -1 && sort.indexOf('esquive') != -1) {
  13521. texte = decumul_buff('AdE', 'Esquive', Math.floor((esq-1)/2));
  13522. } else if (sort.indexOf("augmentation des degats")!=-1) {
  13523. var
  13524. categoriesAdD = {
  13525. "attx1/2": {
  13526. "Botte Secrète": "BS"
  13527. },
  13528. "degx1": {
  13529. "AN": true,
  13530. "AP": "AP1",
  13531. "Charge": "Charger",
  13532. "CA": "CA",
  13533. "CdB": "CdB1",
  13534. "Frénésie": "Frenesie",
  13535. "RB": "RB1",
  13536. "Rafale": "Rafale",
  13537. "Vampi": "Vampi"
  13538. },
  13539. "degx1/2": {
  13540. "Griffe du Sorcier": "GdS"
  13541. },
  13542. "vuex1/2": {
  13543. "Projectile Magique": "Projo"
  13544. },
  13545. "regx1": {
  13546. "Siphon des Âmes": "Siphon"
  13547. }
  13548. },
  13549. baseAdD = {
  13550. "attx1/2": Math.floor(att/2),
  13551. "degx1" : deg,
  13552. "degx1/2": Math.floor(deg/2),
  13553. "vuex1/2": Math.floor(vue/2),
  13554. "regx1" : reg
  13555. },
  13556. pc = degtour,
  13557. pcInit = pc,
  13558. nbrAdD = nbrAdX(pc),
  13559. categorie, talent, newTalent,
  13560. i, DSup, fixe=0;
  13561.  
  13562. i=nbrAdD;
  13563. while(i++<nbrAdD+3) {
  13564. pc += decumulPc(i);
  13565. fixe += decumulFixe(2,i);
  13566. if(texte) { texte += "<hr>"; }
  13567. texte += "<b>"+i+"<sup>e</sup> AdD : " +
  13568. aff(pc)+"% de Dés de dégâts :</b><br>";
  13569. for(categorie in categoriesAdD) {
  13570. // On génére la liste: "talent1, talent2"
  13571. DSup = Math.floor(baseAdD[categorie]*pc/100) -
  13572. Math.floor(baseAdD[categorie]*pcInit/100);
  13573. newTalent = false;
  13574. for(var talent in categoriesAdD[categorie]) {
  13575. if(getTalent(categoriesAdD[categorie][talent])) {
  13576. if(newTalent) { texte += ", "; }
  13577. texte += talent;
  13578. newTalent = true;
  13579. }
  13580. }
  13581. if(newTalent) {
  13582. // Si le trõll a au moins un talent dans la catégorie :
  13583. texte += ": <b>+"+DSup+"D3 +"+Math.floor(fixe) +
  13584. "</b> <i>(+"+Math.floor(2*DSup+fixe) +
  13585. ")</i><br>";
  13586. }
  13587. }
  13588. }
  13589. } else if(sort.indexOf('bulle anti-magie')!=-1) {
  13590. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  13591. }
  13592. else if(sort.indexOf('bulle magique')!=-1){
  13593. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  13594. }
  13595. else if(sort.indexOf('explosion')!=-1){
  13596. texte = 'Dégâts : <b>'
  13597. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  13598. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  13599. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  13600. }
  13601. else if(sort.indexOf('faiblesse passagere')!=-1){
  13602. if(pvcourant<=0)
  13603. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  13604. texte = 'Portée horizontale : <b>'
  13605. +Math.min(1,vuetotale)+'</b> case<br/>'
  13606. +'Dégâts physiques : <b>-'
  13607. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  13608. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  13609. +'Dégâts magiques : <b>-'
  13610. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  13611. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  13612. }
  13613. else if(sort.indexOf('flash aveuglant')!=-1){
  13614. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  13615. }
  13616. else if(sort.indexOf('glue')!=-1) {
  13617. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  13618. if(vuetotale>2) texte += 's';
  13619. } else if(sort.indexOf("griffe du sorcier")!=-1) {
  13620. var
  13621. modD =0,
  13622. addVenin = function(type, effet, duree) {
  13623. var
  13624. ret = "<b>Venin "+type+" : </b><br/><b>" +
  13625. effet+"</b> D3" +
  13626. " pendant <b>"+duree+"</b> tour",
  13627. dureeReduite = Math.max(Math.floor(duree/2),1);
  13628. if(duree>1) {
  13629. ret += "s";
  13630. }
  13631. return ret +
  13632. " => <b>"+2*effet+" x "+duree+" = "+2*effet*duree +
  13633. "</b> ("+2*effet+" x "+dureeReduite+" = " +
  13634. 2*effet*dureeReduite+")";
  13635. },
  13636. effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  13637. // Frappe
  13638. texte = "Attaque : <b>"+att+"</b> D6 ";
  13639. if(atttour!=0) {
  13640. modD = Math.floor(att*atttour/100);
  13641. texte += "<i>"+aff(modD)+"D6</i> ";
  13642. }
  13643. texte += aff(attbm)
  13644. +" => <b>"+(Math.round(3.5*(att+modD))+attbm)+"</b><br/>"
  13645. +"Dégâts : <b>"+Math.floor(deg/2)+"</b> D3 ";
  13646. if(degtour!=0) {
  13647. modD = Math.floor(Math.floor(deg/2)*degtour/100);
  13648. texte += "<i>"+aff(modD)+"D3</i> ";
  13649. } else {
  13650. modD = 0;
  13651. }
  13652. texte += aff(degbm) +
  13653. " => <b>"+(2*(Math.floor(deg/2)+modD)+degbm) +
  13654. "/"+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm) +
  13655. " ("+resiste(Math.floor(deg/2)+modD,degbm) +
  13656. "/"+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm) +
  13657. ")</b>";
  13658. // Venins
  13659. texte += "<hr>"+addVenin("insidieux",effet,2+Math.floor(vue/5));
  13660. effet = Math.floor(1.5*effet);
  13661. texte += "<hr>"+addVenin("virulent",effet,1+Math.floor(vue/10));
  13662. } else if(sort.indexOf('hypnotisme')!=-1)
  13663. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  13664. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  13665. else if(sort.indexOf('identification des tresors')!=-1)
  13666. texte = 'Permet de connaitre les caractéristiques et effets précis '
  13667. +'d\'un trésor.';
  13668. else if(sort.indexOf('invisibilite')!=-1)
  13669. texte = 'Un troll invisible est indétectable même quand on se trouve '
  13670. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  13671. +'fait disparaître l\'invisibilité.';
  13672. else if(sort.indexOf('levitation')!=-1)
  13673. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  13674. +'Comme les pièges ou les trous par exemple...';
  13675. else if(sort.indexOf("projectile magique")!=-1) {
  13676. var
  13677. modD = 0,
  13678. portee = getPortee(vuetotale);
  13679. // Att
  13680. texte = "Attaque : <b>"+vue+"</b> D6 ";
  13681. if(atttour!=0) {
  13682. modD = Math.floor(vue*atttour/100);
  13683. texte += "<i>"+aff(modD)+"D6</i> ";
  13684. }
  13685. texte += aff(attbm) +
  13686. " => <b>"+(Math.round(3.5*(vue+modD))+attbm)+"</b><br>" +
  13687. "Dégâts : <b>"+Math.floor(vue/2)+"</b> D3 ";
  13688. // Deg
  13689. if(degtour!=0) {
  13690. modD = Math.floor(Math.floor(vue/2)*degtour/100);
  13691. texte += "<i>"+aff(modD)+"D3</i> ";
  13692. } else {
  13693. modD = 0;
  13694. }
  13695. texte += aff(degbm) +
  13696. " => <b>"+(2*(Math.floor(vue/2)+modD)+degbm) +
  13697. "/"+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm) +
  13698. " ("+resiste(Math.floor(vue/2)+modD,degbm) +
  13699. "/"+resiste(1.5*Math.floor(vue/2)+modD,degbm) +
  13700. ") (+ 1D3 par bonus de portée)</b>";
  13701. // Portée
  13702. texte += "<br/>Portée : <b>"+portee+"</b> case";
  13703. if(portee>1) texte += "s";
  13704. } else if(sort.indexOf('projection')!=-1) {
  13705. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  13706. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  13707. +'Si le jet de résistance de la victime est réussi:<br/>'
  13708. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  13709. } else if(sort.indexOf("rafale psychique")!=-1) {
  13710. var modD = 0;
  13711. texte = "Dégâts : <b>"+deg+"</b> D3 ";
  13712. if(degtour!=0) {
  13713. modD = Math.floor(deg*degtour/100);
  13714. texte += "<i>"+aff(modD)+"D3</i> ";
  13715. }
  13716. texte += aff(degbm) +
  13717. " => <b>"+(2*(deg+modD)+degbm) +
  13718. " ("+resiste(deg+modD,degbm)+")</b><br>" +
  13719. "Malus : régénération <b>-"+(deg+modD)+"</b>";
  13720. } else if(sort.indexOf("sacrifice")!=-1) {
  13721. if(pvcourant<=0) {
  13722. // N'est plus censé se produire : activation obligatoire si mort
  13723. return "<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>";
  13724. }
  13725. var
  13726. perteSacro = function(sac) {
  13727. return " (-"+(sac+2*(1+Math.floor(sac/5)))+" PV)";
  13728. },
  13729. sac = Math.floor((pvcourant-1)/2),
  13730. pvdispoSansMalusTemps =
  13731. pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  13732.  
  13733. texte = "Portée horizontale : <b>" +
  13734. Math.min(1,vuetotale)+"</b> case<br>" +
  13735. "Soin maximal : <b>"+sac+"</b> PV"+perteSacro(sac);
  13736. // Sacros max et optimal sans malus (propale R')
  13737. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  13738. if(sac>0) {
  13739. texte += "<hr>Soin maximum limitant les risques de malus " +
  13740. "de temps : <b>" +sac+"</b> PV"+perteSacro(sac);
  13741. } else {
  13742. texte += "<hr>Vous ne pouvez pas compenser de blessures " +
  13743. "dues à un sacrifice";
  13744. }
  13745. } else if(sort.indexOf("siphon")!=-1) {
  13746. var modD = 0;
  13747. texte = "Attaque : <b>"+att+"</b> D6 ";
  13748. if(atttour!=0) {
  13749. modD = Math.floor(att*atttour/100);
  13750. texte += "<i>"+aff(modD)+"D6</i> ";
  13751. }
  13752. texte += aff(attbm) +
  13753. " => <b>"+Math.round(3.5*(att+modD)+attbm)+"</b><br>" +
  13754. "Dégâts : <b>"+reg+"</b> D3 ";
  13755. if(degtour!=0) {
  13756. modD = Math.floor(reg*degtour/100);
  13757. texte += "<i>"+aff(modD)+"D3</i> ";
  13758. } else {
  13759. modD = 0;
  13760. }
  13761. texte += aff(degbm) +
  13762. " => <b>"+(2*(reg+modD)+degbm) +
  13763. "/" + (2*(Math.floor(1.5*reg)+modD)+degbm) +
  13764. " ("+resiste(reg+modD,degbm) +
  13765. "/"+resiste(1.5*reg+modD,degbm)+")</b>";
  13766. texte += "<br>Nécrose : attaque magique <b>-"+(reg+modD)+"</b>";
  13767. } else if(sort.indexOf('telekinesie')!=-1) {
  13768. texte = 'Portée horizontale :';
  13769. var vt = Math.floor(vuetotale/2)+2;
  13770. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  13771. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  13772. for(var i=0 ; i<5 ; i++) {
  13773. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  13774. if(vt>1) texte += 's';
  13775. vt=Math.max(0,vt-1);
  13776. }
  13777. }
  13778. else if(sort.indexOf('teleportation')!=-1) {
  13779. var portee = getPortee(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  13780. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  13781. var pmh = (20+vue+portee);
  13782. var pmv = 3+Math.floor(portee/3);
  13783. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  13784. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  13785. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  13786. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  13787. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  13788. } else if(sort.indexOf('vampirisme')!=-1) {
  13789. var modD = 0;
  13790. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  13791. if(atttour!=0) {
  13792. modD = Math.floor(Math.floor(2*deg/3)*atttour/100);
  13793. texte += '<i>'+aff(modD)+'D6</i> ';
  13794. }
  13795. texte += aff(attbm) +
  13796. ' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm) +
  13797. '</b><br/>Dégâts : <b>'+deg+'</b> D3 ';
  13798. if(degtour!=0) {
  13799. modD = Math.floor(deg*degtour/100);
  13800. texte += '<i>'+aff(modD)+'D3</i> ';
  13801. } else {
  13802. modD = 0;
  13803. }
  13804. texte += aff(degbm) +
  13805. ' => <b>'+(2*(deg+modD)+degbm) +
  13806. '/'+(2*(Math.floor(1.5*deg)+modD)+degbm) +
  13807. ' ('+resiste(deg+modD,degbm) +
  13808. '/'+resiste(1.5*deg+modD,degbm)+')</b>';
  13809. } else if(sort.indexOf('vision accrue')!=-1)
  13810. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  13811. else if(sort.indexOf('vision lointaine')!=-1)
  13812. texte = 'En ciblant une zone située n\'importe où dans le '
  13813. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  13814. else if(sort.indexOf('voir le cache')!=-1)
  13815. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  13816. +Math.min(5,getPortee(vue))+'</b> cases<hr>'
  13817. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  13818. +getPortee(vuetotale)+'</b> cases';
  13819. else if(sort.indexOf('vue troublee')!=-1)
  13820. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  13821. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  13822. return texte;
  13823. }
  13824.  
  13825.  
  13826. /*---------------------------------- Main ------------------------------------*/
  13827.  
  13828. function do_profil2()
  13829. {
  13830. try {
  13831. start_script(31);
  13832.  
  13833. extractionDonnees();
  13834. setInfosCaracteristiques();
  13835. setInfoDescription();
  13836. setInfosEtatLieux();
  13837. setInfosEtatPV();
  13838. setInfosExp();
  13839.  
  13840. creerBulleVide();
  13841. traitementTalents();
  13842. setLienAnatrolliseur();
  13843.  
  13844. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  13845. if(race=='Kastar' || MY_DEBUG){ setAccel(); }
  13846. saveProfil();
  13847. displayScriptTime();
  13848. } catch(e) {
  13849. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.<br>" + traceStack(e, 'profil2').replace("\n", "<br>"), 1000000, true);
  13850. window.console.error(traceStack(e, 'profil2'));
  13851. }
  13852. }
  13853.  
  13854. /*******************************************************************************
  13855. * This file is part of Mountyzilla. *
  13856. * *
  13857. * Mountyzilla is free software; you can redistribute it and/or modify *
  13858. * it under the terms of the GNU General Public License as published by *
  13859. * the Free Software Foundation; either version 2 of the License, or *
  13860. * (at your option) any later version. *
  13861. * *
  13862. * Mountyzilla is distributed in the hope that it will be useful, *
  13863. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13864. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13865. * GNU General Public License for more details. *
  13866. * *
  13867. * You should have received a copy of the GNU General Public License *
  13868. * along with Mountyzilla; if not, write to the Free Software *
  13869. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  13870. *******************************************************************************/
  13871.  
  13872. // x~x script_principal
  13873.  
  13874. // x~x md5.js
  13875. /*
  13876. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  13877. * Digest Algorithm, as defined in RFC 1321.
  13878. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  13879. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  13880. * Distributed under the BSD License
  13881. * See http://pajhome.org.uk/crypt/md5 for more info.
  13882. */
  13883.  
  13884. /*
  13885. * Configurable variables. You may need to tweak these to be compatible with
  13886. * the server-side, but the defaults work in most cases.
  13887. */
  13888. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  13889. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  13890. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  13891.  
  13892. /*
  13893. * These are the functions you'll usually want to call
  13894. * They take string arguments and return either hex or base-64 encoded strings
  13895. */
  13896. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  13897. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  13898. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  13899. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  13900. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  13901. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  13902.  
  13903. /*
  13904. * Perform a simple self-test to see if the VM is working
  13905. */
  13906. function md5_vm_test()
  13907. {
  13908. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  13909. }
  13910.  
  13911. /*
  13912. * Calculate the MD5 of an array of little-endian words, and a bit length
  13913. */
  13914. function core_md5(x, len)
  13915. {
  13916. /* append padding */
  13917. x[len >> 5] |= 0x80 << ((len) % 32);
  13918. x[(((len + 64) >>> 9) << 4) + 14] = len;
  13919.  
  13920. var a = 1732584193;
  13921. var b = -271733879;
  13922. var c = -1732584194;
  13923. var d = 271733878;
  13924.  
  13925. for(var i = 0; i < x.length; i += 16)
  13926. {
  13927. var olda = a;
  13928. var oldb = b;
  13929. var oldc = c;
  13930. var oldd = d;
  13931.  
  13932. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  13933. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  13934. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  13935. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  13936. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  13937. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  13938. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  13939. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  13940. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  13941. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  13942. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  13943. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  13944. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  13945. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  13946. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  13947. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  13948.  
  13949. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  13950. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  13951. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  13952. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  13953. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  13954. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  13955. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  13956. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  13957. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  13958. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  13959. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  13960. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  13961. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  13962. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  13963. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  13964. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  13965.  
  13966. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  13967. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  13968. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  13969. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  13970. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  13971. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  13972. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  13973. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  13974. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  13975. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  13976. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  13977. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  13978. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  13979. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  13980. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  13981. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  13982.  
  13983. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  13984. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  13985. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  13986. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  13987. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  13988. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  13989. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  13990. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  13991. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  13992. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  13993. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  13994. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  13995. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  13996. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  13997. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  13998. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  13999.  
  14000. a = safe_add(a, olda);
  14001. b = safe_add(b, oldb);
  14002. c = safe_add(c, oldc);
  14003. d = safe_add(d, oldd);
  14004. }
  14005. return Array(a, b, c, d);
  14006.  
  14007. }
  14008.  
  14009. /*
  14010. * These functions implement the four basic operations the algorithm uses.
  14011. */
  14012. function md5_cmn(q, a, b, x, s, t)
  14013. {
  14014. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  14015. }
  14016. function md5_ff(a, b, c, d, x, s, t)
  14017. {
  14018. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  14019. }
  14020. function md5_gg(a, b, c, d, x, s, t)
  14021. {
  14022. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  14023. }
  14024. function md5_hh(a, b, c, d, x, s, t)
  14025. {
  14026. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  14027. }
  14028. function md5_ii(a, b, c, d, x, s, t)
  14029. {
  14030. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  14031. }
  14032.  
  14033. /*
  14034. * Calculate the HMAC-MD5, of a key and some data
  14035. */
  14036. function core_hmac_md5(key, data)
  14037. {
  14038. var bkey = str2binl(key);
  14039. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  14040.  
  14041. var ipad = Array(16), opad = Array(16);
  14042. for(var i = 0; i < 16; i++)
  14043. {
  14044. ipad[i] = bkey[i] ^ 0x36363636;
  14045. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  14046. }
  14047.  
  14048. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  14049. return core_md5(opad.concat(hash), 512 + 128);
  14050. }
  14051.  
  14052. /*
  14053. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  14054. * to work around bugs in some JS interpreters.
  14055. */
  14056. function safe_add(x, y)
  14057. {
  14058. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  14059. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  14060. return (msw << 16) | (lsw & 0xFFFF);
  14061. }
  14062.  
  14063. /*
  14064. * Bitwise rotate a 32-bit number to the left.
  14065. */
  14066. function bit_rol(num, cnt)
  14067. {
  14068. return (num << cnt) | (num >>> (32 - cnt));
  14069. }
  14070.  
  14071. /*
  14072. * Convert a string to an array of little-endian words
  14073. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  14074. */
  14075. function str2binl(str)
  14076. {
  14077. var bin = Array();
  14078. var mask = (1 << chrsz) - 1;
  14079. for(var i = 0; i < str.length * chrsz; i += chrsz)
  14080. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  14081. return bin;
  14082. }
  14083.  
  14084. /*
  14085. * Convert an array of little-endian words to a string
  14086. */
  14087. function binl2str(bin)
  14088. {
  14089. var str = "";
  14090. var mask = (1 << chrsz) - 1;
  14091. for(var i = 0; i < bin.length * 32; i += chrsz)
  14092. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  14093. return str;
  14094. }
  14095.  
  14096. /*
  14097. * Convert an array of little-endian words to a hex string.
  14098. */
  14099. function binl2hex(binarray)
  14100. {
  14101. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  14102. var str = "";
  14103. for(var i = 0; i < binarray.length * 4; i++)
  14104. {
  14105. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  14106. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  14107. }
  14108. return str;
  14109. }
  14110.  
  14111. /*
  14112. * Convert an array of little-endian words to a base-64 string
  14113. */
  14114. function binl2b64(binarray)
  14115. {
  14116. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  14117. var str = "";
  14118. for(var i = 0; i < binarray.length * 4; i += 3)
  14119. {
  14120. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  14121. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  14122. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  14123. for(var j = 0; j < 4; j++)
  14124. {
  14125. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  14126. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  14127. }
  14128. }
  14129. return str;
  14130. }
  14131.  
  14132. ///////////////////////////////////////////
  14133. // debug cartes capitan Roule 07/12/2016
  14134. ///////////////////////////////////
  14135. // essais : objet
  14136. // .mode : description
  14137. // .essais : tableau d'objets essai
  14138. // .mode : description
  14139. // .essais : tableau de cartes
  14140. // .noCarte : id de la carte
  14141. // .essais : tableau d'essais, [x, y, n, nb]
  14142. function AfficheEssais(essais, sMode) {
  14143. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  14144. if (!eBigDiv) {
  14145. var insertPoint = document.getElementById('footer1');
  14146. eBigDiv = document.createElement('table');
  14147. eBigDiv.id = 'ListeEssaiCapitan';
  14148. insertBefore(insertPoint, document.createElement('p'));
  14149. insertTitle(insertPoint,'Capitan : Liste des essais');
  14150. insertBefore(insertPoint, eBigDiv);
  14151. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  14152. }
  14153. if (!essais) {
  14154. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  14155. return;
  14156. }
  14157. var carte;
  14158. for (carte in essais) {
  14159. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  14160. }
  14161. if (carte === undefined) {
  14162. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  14163. }
  14164. }
  14165.  
  14166. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  14167. var tr = appendTr(eTable);
  14168. var td = appendTd(tr);
  14169. appendText(td, sMode, bBold);
  14170. td = appendTd(tr);
  14171. appendText(td, sCarte, bBold);
  14172. td = appendTd(tr);
  14173. appendText(td, sText, bBold);
  14174. }
  14175.  
  14176. function getEssaiV1_0() {
  14177. try {
  14178. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  14179. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  14180. var tabK, nK;
  14181. prefs.getChildList('', nK, tabK);
  14182. window.console.log('getEssaiV1_0, nb key : ' + nK);
  14183. //window.console.log('getEssaiV1_0, ' + nK);
  14184. return;
  14185. //return r;
  14186. } catch (e) {
  14187. window.console.log(traceStack(e, 'getEssaiV1_0'));
  14188. }
  14189. }
  14190.  
  14191. function getEssaiV1_1() {
  14192. var locSto = window.localStorage;
  14193. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  14194. var r = [];
  14195. for (var i = 0; i < locSto.length; i++) {
  14196. var k = locSto.key(i);
  14197. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  14198. var t = k.split(/\./);
  14199. if (t[0] !== 'capitan') continue;
  14200. if (t[2] !== 'essai') continue;
  14201. var carte = 'carte n°' + t[1];
  14202. if (r[carte]) r[carte]++;
  14203. else r[carte] = 1;
  14204. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  14205. }
  14206. return r;
  14207. }
  14208.  
  14209. function showEssaiCartes() {
  14210. window.console.log('début showEssai Tout_MZ');
  14211. var essais = getEssaiV1_0();
  14212. AfficheEssais(essais, 'V1.0');
  14213. essais = getEssaiV1_1();
  14214. AfficheEssais(essais, 'V1.1');
  14215. window.console.log('fin showEssai Tout_MZ');
  14216. }
  14217.  
  14218. function testBoolLocalStorage() {
  14219. var b = true;
  14220. var key = 'MZ_essai_bool';
  14221. GM_setValue(key, b);
  14222. window.localStorage[key] = b;
  14223. var v = GM_getValue(key);
  14224. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  14225. var v = window.localStorage.getItem(key);
  14226. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  14227.  
  14228. var b = false;
  14229. GM_setValue(key, b);
  14230. window.localStorage[key] = b;
  14231. var v = GM_getValue(key);
  14232. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  14233. var v = window.localStorage.getItem(key);
  14234. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  14235.  
  14236. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  14237. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  14238. var y = GM_getValue('654654897894654654');
  14239. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  14240. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  14241. }
  14242.  
  14243. /*--------------------------------- Création liste trolligion ---------------------------------*/
  14244. function export_trolligion() {
  14245. try {
  14246. var tabDl = document.getElementsByTagName('dl');
  14247. if ((!tabDl) || !tabDl[0]) {
  14248. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  14249. return;
  14250. }
  14251. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  14252. // nom : string
  14253. // rayonnement : entier
  14254. // grades : table d'objets (une occurence par grade)
  14255. // nom : string
  14256. // trolls : table d'objets (un par Trõll)
  14257. // id
  14258. // nom
  14259. // idguilde
  14260. // guilde
  14261. // race
  14262. // niveau
  14263. // ferveur
  14264. var currentDieu;
  14265. var currentGrade;
  14266. for (var iChild1 in tabDl[0].children) {
  14267. var eChild1 = tabDl[0].children[iChild1];
  14268. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  14269. case 'dd': // Trõll
  14270. var oTroll = {};
  14271. export_trolligion_analyse(oTroll, eChild1);
  14272. currentGrade.trolls.push(oTroll);
  14273. break;
  14274. case 'dt':
  14275. var tabH3 = eChild1.getElementsByTagName('h3');
  14276. if (tabH3 && tabH3[0]) { // changement de dieu
  14277. currentDieu = {
  14278. nom: tabH3[0].innerText || tabH3[0].textContent
  14279. , grades: []};
  14280. var txt = eChild1.innerText || eChild1.textContent;
  14281. var m = txt.match(/yon*ement *:* *(\d+)/);
  14282. if (m) currentDieu.rayonnement = parseInt(m[1]);
  14283. currentGrade = undefined;
  14284. tabDieux.push(currentDieu);
  14285. break;
  14286. }
  14287. var tabH4 = eChild1.getElementsByTagName('h4');
  14288. if (tabH4 && tabH4[0]) { // changement de grade
  14289. var grade;
  14290. var txt = tabH4[0].innerText || tabH4[0].textContent;
  14291. tabI = tabH4[0].getElementsByTagName('i');
  14292. if (tabI && tabI[0]) {
  14293. grade = tabI[0].innerText || tabI[0].textContent;
  14294. grade = grade.replace(/"/g, '');
  14295. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  14296. if (m) grade += ' (' + m[1] + ')';
  14297. } else {
  14298. grade = txt.replace(/"/g, '');
  14299. }
  14300. currentGrade = {nom: grade, trolls: []};
  14301. currentDieu.grades.push(currentGrade);
  14302. break;
  14303. }
  14304. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  14305. break;
  14306. default:
  14307. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  14308. }
  14309. }
  14310.  
  14311. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  14312. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  14313. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  14314. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  14315. for (var iDieu in tabDieux) {
  14316. var oDieu = tabDieux[iDieu];
  14317. for (var iGrade in oDieu.grades) {
  14318. var oGrade = oDieu.grades[iGrade];
  14319. for (var iTroll in oGrade.trolls) {
  14320. var oTroll = oGrade.trolls[iTroll];
  14321. var t = [oDieu.nom, oDieu.rayonnement
  14322. , oGrade.nom
  14323. , oTroll.id, oTroll.nom
  14324. , oTroll.idguilde, oTroll.guilde
  14325. , oTroll.race, oTroll.niveau
  14326. , oTroll.ferveur];
  14327. for (var iParam in t) {
  14328. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14329. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14330. }
  14331. txt += t.join("\t") + "\n";
  14332. }
  14333. }
  14334. var t = [oDieu.nom, oDieu.rayonnement];
  14335. for (var iParam in t) {
  14336. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14337. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14338. }
  14339. txt2 += t.join("\t") + "\n";
  14340. }
  14341. txt += "\n" + txt2;
  14342. } catch (e) {
  14343. window.alert("Échec à l'extraction\n" + e);
  14344. }
  14345. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  14346. try {
  14347. if (copyTextToClipboard(txt)) {
  14348. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  14349. + "Collez dans Calc\n"
  14350. + "ou, au pire, dans EXCEL®");
  14351. } else {
  14352. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  14353. }
  14354. } catch(e) {
  14355. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  14356. }
  14357. }
  14358.  
  14359. function export_trolligion_analyse(oTroll, eChild1) {
  14360. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  14361. var eChild2 = eChild1.childNodes[iChild2];
  14362. if (eChild2.nodeType === undefined) continue; // properties
  14363. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  14364. switch (eChild2.nodeType) {
  14365. case 1: //ELEMENT_NODE:
  14366. switch (eChild2.nodeName.toLowerCase()) {
  14367. case 'a':
  14368. var m;
  14369. if (!eChild2.href) {
  14370. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  14371. break;
  14372. }
  14373. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  14374. if (m) {
  14375. oTroll.id = parseInt(m[1]);
  14376. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  14377. break;
  14378. }
  14379. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  14380. if (m) {
  14381. var idGuilde = parseInt(m[1]);
  14382. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  14383. oTroll.idguilde = parseInt(m[1]);
  14384. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  14385. }
  14386. break;
  14387. }
  14388. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  14389. break;
  14390. case 'br': // ignore
  14391. case 'style': // ignore
  14392. case 'img': // ignore
  14393. break;
  14394. case 'div': // barre de vie
  14395. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  14396. eChild3 = eChild2.children[0];
  14397. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  14398. var eChild4 = eChild3.children[0];
  14399. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  14400. break;
  14401. }
  14402. }
  14403. //window.console.log(eChild2.innerHTML);
  14404. export_trolligion_analyse(oTroll, eChild2);
  14405. break;
  14406. default:
  14407. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  14408. break;
  14409. }
  14410. break;
  14411. case 3: //TEXT_NODE:
  14412. var txt = eChild2.nodeValue.trim();
  14413. if (txt === '') break;
  14414. var m = txt.match(/(.*) *\((\d+)\)/);
  14415. if (m) {
  14416. oTroll.race = m[1].trim();
  14417. oTroll.niveau = parseInt(m[2]);
  14418. } else {
  14419. oTroll.race = txt;
  14420. }
  14421. break;
  14422. default: // ne devrait pas arriver
  14423. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  14424. break;
  14425. }
  14426. }
  14427. }
  14428.  
  14429. function do_trolligion() {
  14430. var divpopup = document.createElement('div');
  14431. divpopup.id = 'MZ_divCopier';
  14432. divpopup.style.position = 'fixed';
  14433. divpopup.style.top = '2px';
  14434. divpopup.style.left = '2px;';
  14435. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  14436. divpopup.style.cursor = 'pointer';
  14437. divpopup.style.zIndex = 200;
  14438. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  14439. divpopup.onclick = export_trolligion;
  14440. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  14441. divpopup.appendChild(img);
  14442. document.body.appendChild(divpopup);
  14443. }
  14444.  
  14445. /*--------------------------------- Dispatch ---------------------------------*/
  14446.  
  14447. //chargerScriptDev("libs");
  14448. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  14449. //if (isDEV) testBoolLocalStorage();
  14450. /* Roule, test getPVsRestants
  14451. var pv = 'Inimaginables (supérieurs à 200)';
  14452. var pvminmax = pv.match(/\d+/g);
  14453. var oMinMaxPV = {min: pvminmax[0], max: pvminmax[1]};
  14454. window.console.log('minmax=' + JSON.stringify(pvminmax) + ', oMinMaxPV=' + JSON.stringify(oMinMaxPV));
  14455. window.console.log('ret getPVsRestants=' + JSON.stringify(getPVsRestants(pv, '±70%')));
  14456. window.console.log('ret getPVsRestants=' + JSON.stringify(getPVsRestants(pv, '±70%', true)));
  14457. */
  14458.  
  14459. // Détection de la page à traiter
  14460. if(isPage("Messagerie/ViewMessageBot")) {
  14461. do_cdmbot();
  14462. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  14463. do_cdmcomp();
  14464. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  14465. do_cdmcomp();
  14466. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  14467. do_cdmcomp();
  14468. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  14469. do_diplo();
  14470. } else if(isPage("MH_Play/Play_equipement")) {
  14471. do_equip();
  14472. } else if(isPage("MH_Play/Play_menu")) {
  14473. do_menu();
  14474. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  14475. do_option();
  14476. //showEssaiCartes();
  14477. } else if(isPage("View/PJView_Events")) {
  14478. /* SCIZ */
  14479. do_scizOverwriteEvents();
  14480. } else if(isPage("View/PJView")) {
  14481. do_pjview();
  14482. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  14483. do_tancompo();
  14484. } else if(isPage("MH_Play/Play_vue")) {
  14485. do_vue();
  14486. /* SCIZ */
  14487. do_scizEnhanceView();
  14488. } else if(isPage("MH_Play/Play_news")) {
  14489. do_news();
  14490. } else if(isPage("MH_Play/Play_evenement")) {
  14491. /* SCIZ */
  14492. do_scizOverwriteEvents();
  14493. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  14494. do_move();
  14495. } else if(isPage("MH_Missions/Mission_Etape")) {
  14496. do_mission();
  14497. } else if(isPage("View/MonsterView")) {
  14498. do_infomonstre();
  14499. /* SCIZ */
  14500. do_scizOverwriteEvents();
  14501. } else if(isPage("MH_Play/Play_e_follo.php")) {
  14502. do_listegowap();
  14503. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  14504. do_lieuDescription();
  14505. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  14506. do_lieuTeleport();
  14507. } else if(isPage("MH_Follower/FO_Ordres")) {
  14508. do_ordresgowap();
  14509. } else if(isPage("MH_Follower/FO_Equipement")) {
  14510. do_equipgowap();
  14511. } else if(isPage("MH_Play/Play_mouche")) {
  14512. do_mouches();
  14513. } else if(isPage("MH_Play/Play_BM")) {
  14514. do_malus();
  14515. } else if(isPage("MH_Play/Play_evenement")) {
  14516. do_myevent();
  14517. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  14518. do_enchant();
  14519. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  14520. do_pre_enchant();
  14521. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  14522. do_actions();
  14523. } 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')) {
  14524. do_mission_liste();
  14525. } else if(isPage('MH_Play/Play_action')) {
  14526. do_actions();
  14527. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  14528. do_profil2();
  14529. } else if(isPage('MH_Play/Play_profil2')) {
  14530. do_profil2();
  14531. } else if(isPage('View/TrolligionView.php')) {
  14532. do_trolligion();
  14533. }
  14534. if (document.body.dataset.MZ_Etat === undefined) { // si l'état a été positionné par quelqu'un d'autre, laisser tel quel
  14535. document.body.dataset.MZ_Etat = 1; // indiquer aux scripts tiers qu'on a fini la première initialisation
  14536. }
  14537. if (document.body.MZ_Callback_init !== undefined) {
  14538. for (var iCallback = 0; iCallback < document.body.MZ_Callback_init.length; iCallback++) {
  14539. document.body.MZ_Callback_init[iCallback]();
  14540. }
  14541. }
  14542. } catch(e) {
  14543. try {
  14544. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  14545. } catch(e2) {
  14546. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  14547. }
  14548. }