Tout_MZ

Client MountyZilla

当前为 2020-06-13 提交的版本,查看 最新版本

  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.44
  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.44 13/06/2020",
  40. " 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
  41. "V1.3.0.43 11/06/2020",
  42. " Affichage callstack en erreur profil",
  43. "V1.3.0.42 18/05/2020",
  44. " Amélioration du support SCIZ (Mise en option des fonctionnalités)",
  45. "V1.3.0.41 15/05/2020",
  46. " Amélioration du support SCIZ (Vie des trolls de la coterie)",
  47. "V1.3.0.40 13/05/2020",
  48. " Correction ARM dans le cas d'un grosse perte pour le tour",
  49. "V1.3.0.39 08/05/2020",
  50. " Correction erreur sur le profil en mode smartphone",
  51. "V1.3.0.38 25/04/2020",
  52. " Amélioration du support SCIZ (Gestion des trésors cachés)",
  53. "V1.3.0.37 19/04/2020",
  54. " Suite travail sur l'envoi de CdM en mode smartphone",
  55. "V1.3.0.36 20/04/2020",
  56. " Amélioration du support SCIZ (Icônes pour les événements !)",
  57. "V1.3.0.35 19/04/2020",
  58. " Ignorer l'absence de date/heure des CdM et gestion smartphone",
  59. "V1.3.0.33 14/04/2020",
  60. " Correction fausse reconnaissance de CdM sur les autres compétences",
  61. "V1.3.0.32 14/04/2020",
  62. " Adaptation page des ordres des suivant + [état et callback] pour les scripts tiers (voir doc sur le mot clef MZ_callback_init)",
  63. "V1.3.0.31 22/03/2020",
  64. " Envoi des CdM à partir du message du Bot",
  65. "V1.3.0.30 22/03/2020",
  66. " Amélioration du support SCIZ (Trésors dans la vue !)",
  67. "V1.3.0.29 14/03/2020",
  68. " Fix calcul PV après blessure en cas de maxPV inconnu",
  69. "V1.3.0.28 13/03/2020",
  70. " Fix la détection incohérence CdM et affichage en rouge",
  71. "V1.3.0.27 20/02/2020",
  72. " Ajout de la probabilité de toucher avec Lancer de Potion dans la Vue",
  73. "V1.3.0.26 08/02/2020",
  74. " Lisibilité CdM en mode smartphone",
  75. "V1.3.0.25 07/02/2020",
  76. " Adaptation basique au profil modifié",
  77. "V1.3.0.23 30/01/2020",
  78. " Correction affichage filtre monstre",
  79. "V1.3.0.22 23/01/2020",
  80. " Re-adaptation re-modif MH (affichage des durées négatives)",
  81. "V1.3.0.21 21/01/2020",
  82. " Adaptation à une modif MH dans la page des suivants",
  83. "V1.3.0.20 21/01/2020",
  84. " Adaptation modif MH (affichage des durées négatives)",
  85. "V1.3.0.19 19/01/2020",
  86. " Centralisation des éléments tactiques",
  87. "V1.3.0.18 19/01/2020",
  88. " Correctif pour les icônes d'action à distance dans la vue",
  89. "V1.3.0.17 16/01/2020",
  90. " Correctif pour le recall du filtre des Monstres",
  91. "V1.3.0.16 10/01/2020",
  92. " Amélioration du support SCIZ (Fix sur le prettyprint)",
  93. "V1.3.0.15 10/01/2020",
  94. " Amélioration du support SCIZ (Fix sur les événements de zone)",
  95. "V1.3.0.14 06/01/2020",
  96. " Correction filtre par famille pour les monstres variables et sans cdm",
  97. "V1.3.0.13 06/01/2020",
  98. " Ajout du filtre sur la famille des monstres",
  99. "V1.3.0.12 28/12/2019",
  100. " Fixed bug fix pour SCIZ (JWT)",
  101. "V1.3.0.11 28/12/2019",
  102. " Bug fix pour SCIZ (JWT)",
  103. "V1.3.0.10 22/12/2019",
  104. " Corrections mineures pour SCIZ",
  105. "V1.3.0.9 19/12/2019",
  106. " Amélioration du support SCIZ (Fixes + AdvancedCSS + SwitchEvent)",
  107. "V1.3.0.8 16/12/2019",
  108. " Amélioration du support SCIZ (Fixes + Play_evenement + PJView_Events)",
  109. "V1.3.0.7 12/12/2019",
  110. " correction cibles des missions 'famille', 'pouvoir' et cas particulier de 'race'",
  111. "V1.3.0.6 11/12/2019",
  112. " 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",
  113. "V1.3.0.5 11/12/2019",
  114. " Première interconnexion avec SCIZ (Options + MonsterView)",
  115. "V1.3.0.4 29/11/2019",
  116. " Ajout des déciles",
  117. "V1.3.0.3 29/11/2019",
  118. " Affichage d'une icône pour les Phœnix dont la génération est connue",
  119. "V1.3.0.2 24/11/2019",
  120. " Réduction taille info CdM",
  121. "V1.3.0.1 22/11/2019",
  122. " Ajustements sur les infos tactiques",
  123. "V1.3.0 15/11/2019",
  124. " Refonte calculs tactiques de la vue - beta",
  125. "V1.2.20.6 09/11/2019",
  126. " Correction de la formule d'AdD dans le profil",
  127. "V1.2.20.5 16/10/2019",
  128. " Mutualisation analyse ordres suivants MZ_analyse_page_ordre_suivant",
  129. "V1.2.20.4 03/10/2019",
  130. " Adaptation modif MH de la page des suivants",
  131. "V1.2.20.3 02/09/2019",
  132. " Compétence golem vers l'anatroliseur",
  133. "V1.2.20.2 25/05/2019",
  134. " Gestion des Parasitus pour les missions",
  135. "V1.2.20.1 25/05/2019",
  136. " Correction de la cible en cas de mission demandant un kill de Crasc + message d'alerte en cas de fumeux",
  137. "V1.2.20.0 25/05/2019",
  138. " Adaptation aux modifications des CdM par MH",
  139. "V1.2.19.2 16/04/2019",
  140. " Correction majuscules dans les talents",
  141. "V1.2.19.1 14/04/2019",
  142. " Prise en compte des nouvelles AdX dans profil2",
  143. "V1.2.18.15 29/03/2019",
  144. " Correction simple quote dans toutes les missions",
  145. "V1.2.18.14 09/03/2019",
  146. " Correction affichage vues 2D externes suite à une modif MH",
  147. "V1.2.18.13 27/02/2019",
  148. " Correction simple quote dans les familles de monstre des missions",
  149. "V1.2.18.12 23/12/2018",
  150. " Message si \"Menu d'actions contextuelles\" est décoché",
  151. "V1.2.18.11 21/11/2018",
  152. " Correction it bricol'troll, login avec accent",
  153. "V1.2.18.10 08/08/2018",
  154. " Correction boulette sDiplo",
  155. "V1.2.18.09 04/08/2018",
  156. " Protection contre diplomatie mal initialisée",
  157. "V1.2.18.08 11/07/2018",
  158. " Correction pour fonctionnement hors GM",
  159. "V1.2.18.07 18/05/2018",
  160. " prise en compte bonus magique d'esquive dans le profil, correction gestion de la souris dans la page d'équipement [Dabihul, welcome back]",
  161. "V1.2.18.06 28/01/2018",
  162. " Protection malus Crasc sans durée",
  163. "V1.2.18.05 18/11/2017",
  164. " Désactivation MZ V2 en mode dev pour les tests d'adaptation violentmonkey",
  165. "V1.2.18.04 04/09/2017",
  166. " retour version 1.2.18.02 avec GM 3.17",
  167. "V1.2.18.03 01/09/2017",
  168. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  169. "V1.2.18.02 26/08/2017",
  170. " correction boulette sur le compos d'enchantement",
  171. "V1.2.18.01 25/08/2017",
  172. " Suppression des messages sur les certificats en https",
  173. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  174. "V1.2.17.19 23/08/2017",
  175. " Possibilité de plusieurs IT Bricol'Troll",
  176. "V1.2.17.18 22/08/2017",
  177. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  178. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  179. "V1.2.17.17 16/07/2017",
  180. " modification du mécanisme de filtrage pour contourner un pb",
  181. "V1.2.17.16 16/07/2017",
  182. " Ajout de messages de debug sur les retours AJAX",
  183. "V1.2.17.15 15/07/2017",
  184. " modification du mécanisme de filtrage pour contourner un pb",
  185. "V1.2.17.14 14/07/2017",
  186. " correction dans la gestion des étapes de mission",
  187. "V1.2.17.13 12/07/2017",
  188. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  189. "V1.2.17.12 16/06/2017",
  190. " Correction mauvais compte de PX quand on change de Trõll",
  191. "V1.2.17.11 01/05/2017",
  192. " Travail sur le fonctionnement hors Greasemonkey",
  193. "V1.2.17.10 30/04/2017",
  194. " Protection dans la récupération d'erreur",
  195. "V1.2.17.9 30/04/2017",
  196. " Correction récupération d'erreur IT Bricol'Troll",
  197. "V1.2.17.8 29/04/2017",
  198. " Correction Bonus/Malus cas +0\+10 (AE)",
  199. " Correction portée IdC",
  200. " Prise en compte du bonus de portée PM dans le calcul tactique",
  201. "V1.2.17.7 26/04/2017",
  202. " Version compatible hors GreaseMonkey",
  203. "V1.2.17.6 23/04/2017",
  204. " Correction gestion des missions en cas de réinstallation",
  205. "V1.2.17.5 20/04/2017",
  206. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  207. "V1.2.17.4 08/04/2017",
  208. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  209. " Adaptation de la diplomatie à une modification de la page MH",
  210. "V1.2.17.3 04/04/2017",
  211. " Messages console en cas de cadre d'erreur",
  212. " Trolls de l'IT mais pas dans le vue en orange",
  213. "V1.2.17.2 20/03/2017",
  214. " Correction des PV restants",
  215. "V1.2.17.1 20/03/2017",
  216. " Blocage des PV restants en attendant résolution de bug",
  217. "V1.2.17 19/03/2017",
  218. " Refonte de l'envoi des CdM",
  219. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  220. "V1.2.16.4 08/03/2017",
  221. " correction ID de troll en envoi de PX/MP",
  222. "V1.2.16.3 27/02/2017",
  223. " correction bonus/malus FP",
  224. "V1.2.16.2 24/02/2017",
  225. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  226. "V1.2.16.1 21/02/2017",
  227. " corrige bug sur Fx 38.8 ESR",
  228. "V1.2.16 21/02/2017",
  229. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  230. " possibilité de masquer les Gowaps Sauvages dans la vue",
  231. " calcul des caractéristiques du siphon des âmes",
  232. "V1.2.15.2 02/02/2017",
  233. " adaptation décumul VlC (page des bonus/malus)",
  234. "V1.2.15.1 29/01/2017",
  235. " carte sur la page de description du lieu TP",
  236. "V1.2.15 25/01/2017",
  237. " mise en place des nouvelles cartes (suivants, TP)",
  238. "V1.2.14.3 25/01/2017",
  239. " résumé dans l'export des données Trõlligion",
  240. "V1.2.14.2 20/01/2017",
  241. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  242. "V1.2.14.1 20/01/2017",
  243. " réécriture filtrage des monstres par niveau dans la vue",
  244. " Changelog dans la page des news MZ",
  245. "V1.2.14 20/01/2017",
  246. " Ajout de l'export des données Trõlligion",
  247. "V1.2.13.7 10/01/2017",
  248. " Exclusion Bricoll'troll dans l'entête GM",
  249. "V1.2.13.6 08/01/2017",
  250. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  251. "V1.2.13.5 07/01/2017",
  252. " Correction bug qui se manisfestait sous LINUX",
  253. "V1.2.13.4 07/01/2017",
  254. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  255. "V1.2.13.3 07/01/2017",
  256. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  257. "V1.2.13.2 07/01/2017",
  258. " Correction missions, recherche troogle (familles et types de monstres)",
  259. "V1.2.13.1 06/01/2017",
  260. " Suppression oldSchoolProfile qui n'existe plus",
  261. " Ajout du 'refresh' du cadre de gauche",
  262. "V1.2.13 01/01/2017",
  263. " homogénéisation des messages d'erreur",
  264. " Ajout du lien Troogle sur les étapes de mission monstre",
  265. "V1.2.12.2 30/12/2016",
  266. " retour en mode normal (http si jeu en http)",
  267. "V1.2.12.1 27/12/2016",
  268. " Correction mode IP",
  269. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  270. "V1.2.12 24/12/2016",
  271. " Nettoyage des URL",
  272. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  273. " Interface bricoll'Troll en https",
  274. " Remise en marche des cartes des trajets des gowaps",
  275. "V1.2.11.5 à 7 20 & 21/12/2016",
  276. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  277. "V1.2.11.4 19/12/2016",
  278. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  279. "V1.2.11.3 19/12/2016",
  280. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  281. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  282. "V1.2.11.2 18/12/2016",
  283. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  284. "V1.2.11.1 17/12/2016",
  285. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  286. "V1.2.11 13/12/2016",
  287. " Passage sur BdD Raistlin \\o/",
  288. "V1.2.10.4 12/12/2016",
  289. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  290. "V1.2.10.3 09/12/2016",
  291. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  292. "V1.2.10.2 09/12/2016",
  293. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  294. "V1.2.10.1 08/12/2016",
  295. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  296. "V1.2.10 07/12/2016",
  297. " correction décumul des bonus/malus",
  298. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  299. "V1.2.9 16/11/2016",
  300. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  301. "V1.2.8 10/11/2016",
  302. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  303. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  304. "V1.2.7 07/11/2016",
  305. " remise en route de l'interface avec l'IT bricol'Troll",
  306. "V1.2.6 19/10/2016",
  307. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  308. " stockage idguilde et nomguilde",
  309. "V1.2.5 17/10/2016",
  310. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  311. " remise en route de la gestion des options avec intégration md5 dans ce script",
  312. "V1.2.4 14/10/2016",
  313. " utilisation du relai raistlin pour l'envoi des CdM",
  314. "V1.2.3 :",
  315. " suppression ancien profil",
  316. " nettoyage doublon sur getPortee",
  317. " adaptation portee TP basée sur les PI",
  318. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  319. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  320. "V1.2.1 :",
  321. " include des URLs MH alternatives",
  322. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  323. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  324. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  325. "V1.1 : regroupement en un gros paquet sale",
  326. ];
  327.  
  328. /**********************************************************
  329. À faire / propositions d'évolutions
  330.  
  331. Bireli-Gravos 08/12/2018
  332. FAIT faire un warning si l'utilisateur a désactivé la case "Menu d'actions contextuelles" dans la fenêtre "limiter la vue"
  333. breizhou13 20/12/2016
  334. envoyer les données à l'IT (Bricol'Trolls) aussi
  335. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  336. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  337. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  338. Akkila le boeuf le 26-03-2017 à 15:56
  339. - bouton pour rafraîchir les infos des trolls de son groupe
  340. Roule'
  341. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  342. Réactiver les jubilaires
  343. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  344. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  345. - voir l'intérêt de refaire fonctionner
  346. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  347. FAIT : ambiguité sur le nom de monstres de mission : Shai, Ombre, Geck'oo et Boujd'la
  348. Sans doute à corriger, la compétence Baroufle pour le lien vers l'anatroliseur
  349. Prévision des DLA de monstre
  350. FAIT Niveau des monstres à la méthode Roule'
  351. Raistlin
  352. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  353. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  354. 80117 - Héra
  355. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  356. 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)
  357. FAIT Possibilité de plusieurs systèmes Bricol'troll
  358. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  359. ?
  360. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  361. Alanae/Gnu
  362. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  363. Kali
  364. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  365. **********************************************************/
  366.  
  367. /**********************************************************
  368. Doc État et Callback pour l'utilisation par les scripts tiers
  369. MZ met à jour la propriété document.body.dataset.MZ_Etat
  370. 1 à la fin de l'initialisation (tout le code MZ s'est déroulé mais il peut y avoir des appels AJAX en cours)
  371. 2 (uniquement sur l'onglet de la vue) quand l'onglet a été mis à jour avec les niveaux, etc.
  372. ATTENTION, l'utilisateur peut demander un complément de CdM s'il voit plus de 500 monstres
  373. MZ appelle les callback définies dans les tableaux suivants, si ces tableaux existent
  374. document.body.MZ_Callback_init: fonctions que MZ appellera quand MZ aura fini sont initialisation
  375. 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é.
  376. document.body.MZ_Callback_fin_vue: fonctions que MZ appellera quand MZ aura fini son premier traitement des CdM dans la vue
  377. ATTENTION document.body.MZ_Callback_init et document.body.MZ_Callback_fin_vue sont des tableaux.
  378. Vous n'êtes pas seuls au monde. Un autre script externe peut s'être déjà enregistré en callback
  379. Voici un exemple de code pour enregistrer une callback
  380. if (document.body.MZ_Callback_init === undefined) {
  381. document.body.MZ_Callback_init = [myCallback];
  382. } else {
  383. document.body.MZ_Callback_init.push(myCallback);
  384. }
  385. **********************************************************/
  386.  
  387. /**********************************************************
  388. **** Début de zone à déplacer dans une bibli commune ******
  389. **********************************************************/
  390.  
  391. // URL de base serveur MZ
  392. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  393. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  394. //var URL_MZ = 'http://192.99.225.92/mz';
  395.  
  396. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  397. // On dirait qu'il n'y en a plus...
  398.  
  399. // URLs externes redirection (pas de souci CORS)
  400. var URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  401. var URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  402. var URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  403. var URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  404. var URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  405. var URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  406. var URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  407. var URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  408. var URL_troogle = 'http://troogle.iktomi.eu/entities/';
  409.  
  410. // URLs de test HTTPS
  411. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  412. var URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  413.  
  414. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  415. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  416. var URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  417.  
  418. // x~x Libs
  419.  
  420. /* ancien TODO
  421. * - revoir la gestion des CdM --> nott armure magique
  422. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  423. * - vérfier la gestion des enchants
  424. */
  425.  
  426. // Roule 04/09/2016 switch extern URLs to https if available
  427. var isHTTPS = false;
  428. if (window.location.protocol.indexOf('https') === 0) {
  429. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  430. URL_bricol = URL_bricol_https;
  431. isHTTPS = true;
  432. }
  433.  
  434. // Roule 23/12/2016 mode dev
  435. var isDEV = false;
  436. if (window.localStorage.getItem('MZ_dev')
  437. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  438. || window.location.href.indexOf('mzdev.mh') >= 0) {
  439. URL_MZ = URL_MZ.replace(/$/, 'dev');
  440. isDEV = true;
  441. }
  442.  
  443. // Images (pas de souci CORS)
  444. var URL_MZimg = URL_MZ + '/img/';
  445. // URLs externes ajax (CORS OK)
  446. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  447. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  448. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  449.  
  450. // liens externes déduits
  451. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  452.  
  453. var MHicons = '/mountyhall/Images/Icones/';
  454. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  455. var MY_DEBUG = false;
  456.  
  457. var horsGM = false;
  458. try { // à partir du 11/07/2018, (GM_getValue === undefined) provoque une exception
  459. horsGM = (GM_getValue === undefined);
  460. } catch (e2) {
  461. horsGM = true;
  462. //window.console.log('test GM_getValue, exception=' + e2);
  463. }
  464. if (horsGM) { // éviter le blocage si pas sous GM
  465. window.console.log('Fonctionnement hors Greasemonkey');
  466. // Roule 18/11/2017 il ne faut pas de "var" dans les ligne précédente. Ça fonctionnait sous Greasemonkey mais plus sous Violentmonkey
  467. GM_getValue = function(key) {};
  468. GM_setValue = function(key, val) {};
  469. GM_deleteValue = function(key) {};
  470. GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  471. }
  472.  
  473. /* Utilisation de la gestion de l'enregistrement des données de
  474. GreaseMonkey, avec partage entre scripts via le localStorage, par
  475. Vapulabehemot (82169) 07/02/2017 */
  476. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  477. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  478. function MY_getValue(key) {
  479. var v = window.localStorage.getItem(key);
  480. vGM = GM_getValue(key);
  481. if ((vGM == null)
  482. || (v != null && v != vGM)){
  483. GM_setValue(key, v);
  484. } else if (v == null && vGM != null) {
  485. v = vGM;
  486. window.localStorage[key] = vGM;
  487. }
  488. return v;
  489. }
  490. function MY_removeValue(key) {
  491. GM_deleteValue(key);
  492. window.localStorage.removeItem(key);
  493. }
  494. function MY_setValue(key, val) {
  495. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  496. val = 1;
  497. else if (val === false)
  498. val = 0;
  499. try {
  500. GM_setValue(key, val);
  501. } catch(e) {
  502. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  503. }
  504. try {
  505. window.localStorage[key] = val;
  506. } catch(e) {
  507. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  508. }
  509. }
  510.  
  511. /*---------------- mise à jour de variables globales utiles ------------------*/
  512. // utilisé pour accès bdd (un peu partout) :
  513. var numTroll = MY_getValue('NUM_TROLL');
  514. // utilisé dans vue pour PX :
  515. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  516. var nivTroll; // = MY_getValue('NIV_TROLL');
  517. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  518. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  519. // utilisés dans actions et vue (calculs SR) :
  520. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  521. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  522. var currentURL = window.location.href;
  523.  
  524. /*-[functions]------------ Fonctions durée de script -------------------------*/
  525. var date_debut = null;
  526.  
  527. function start_script(nbJours_exp) {
  528. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  529. if(date_debut) return;
  530. date_debut = new Date();
  531. // Créé la variable expdate si demandé
  532. if(nbJours_exp) {
  533. expdate = new Date();
  534. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  535. }
  536. }
  537.  
  538. function displayScriptTime(duree, texte) {
  539. var footerNode = document.getElementById('footer2');
  540. if(!footerNode) return;
  541. try{
  542. var node = document.evaluate(
  543. ".//text()[contains(.,'Page générée en')]/../br",
  544. footerNode,null,9,null).singleNodeValue;
  545. }
  546. catch(e){return;}
  547. if (duree) {
  548. insertText(node,
  549. ' - [' + texte + ' en ' + (duree/1000) +' sec.]');
  550. return;
  551. }
  552. insertText(node,
  553. ' - [Script MZ exécuté en '
  554. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  555. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  556. }
  557.  
  558. function traceStack(e, sModule) {
  559. var version = '';
  560. if (GM_info && GM_info.script && GM_info.script.version)
  561. version = ' ' + GM_info.script.version;
  562. sRet = '[MZ' + version + ']'
  563. if (sModule) sRet += ' {' + sModule + '}';
  564. try {
  565. if (e.message) sRet += ' ' + e.message;
  566. } catch (e2) {
  567. sRet += ' <exception acces message>';//+ e2.message;
  568. }
  569. try {
  570. if (e.stack) {
  571. var sStack = e.stack;
  572. // enlever les infos confidentielles
  573. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  574. }
  575. } catch (e2) {
  576. sRet += ' <exception acces stack>'; // + e2.message;
  577. }
  578. return sRet;
  579. }
  580.  
  581. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  582.  
  583. function debugMZ(str){
  584. if(MY_DEBUG){
  585. window.console.debug('[MZ_DEBUG] '+str);
  586. if(typeof str === "object"){
  587. window.console.debug(str);
  588. }
  589. }
  590. }
  591.  
  592. if("function" != typeof isPage) {
  593. function isPage(url) {
  594. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  595. }
  596. }
  597.  
  598. function FF_XMLHttpRequest(MY_XHR_Ob) {
  599. var request = new XMLHttpRequest();
  600. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  601. for(var head in MY_XHR_Ob.headers) {
  602. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  603. }
  604. request.onreadystatechange = function() {
  605. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  606. if(request.readyState!=4) { return; }
  607. if(request.error) {
  608. if(MY_XHR_Ob.onerror) {
  609. MY_XHR_Ob.onerror(request);
  610. }
  611. return;
  612. }
  613. if ((request.status == 0)) {
  614. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  615. if (isDEV) {
  616. var grandCadre = createOrGetGrandCadre();
  617. var sousCadre = document.createElement('div');
  618. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  619. sousCadre.style.width = 'auto';
  620. sousCadre.style.fontSize = 'large';
  621. sousCadre.style.border = 'solid 1px black';
  622. grandCadre.appendChild(sousCadre);
  623. }
  624. if (MY_XHR_Ob.onerror) MY_XHR_Ob.onerror(request);
  625. //showHttpsErrorContenuMixte();
  626. return;
  627. }
  628. if(MY_XHR_Ob.onload) {
  629. var version;
  630. if (MY_XHR_Ob.trace) {
  631. version = '';
  632. if (GM_info && GM_info.script && GM_info.script.version)
  633. version = ' ' + GM_info.script.version;
  634. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  635. }
  636. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  637. MY_XHR_Ob.onload(request);
  638. if (MY_XHR_Ob.trace)
  639. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  640. }
  641. };
  642. request.send(MY_XHR_Ob.data);
  643. }
  644.  
  645. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  646. function MZ_formatDateMS(d, sansMicroSecondes) {
  647. if (d === undefined) d = new Date();
  648. var day = d.getDate();
  649. var month = d.getMonth()+1;
  650. var year = d.getFullYear();
  651. var hours = d.getHours();
  652. var minutes = d.getMinutes();
  653. var seconds = d.getSeconds();
  654. if (day < 10) {day = "0"+day;}
  655. if (month < 10) {month = "0"+month;}
  656. if (hours < 10) {hours = "0"+hours;}
  657. if (minutes < 10) {minutes = "0"+minutes;}
  658. if (seconds < 10) {seconds = "0"+seconds;}
  659. if (sansMicroSecondes) {
  660. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds;
  661. } else {
  662. var ms = d.getMilliseconds();
  663. ms = ('000' + ms).substr(-3, 3);
  664. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  665. }
  666. }
  667.  
  668. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  669.  
  670. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  671. function copyTextToClipboard(text) {
  672. var textArea = document.createElement("textarea");
  673.  
  674. //
  675. // *** This styling is an extra step which is likely not required. ***
  676. //
  677. // Why is it here? To ensure:
  678. // 1. the element is able to have focus and selection.
  679. // 2. if element was to flash render it has minimal visual impact.
  680. // 3. less flakyness with selection and copying which **might** occur if
  681. // the textarea element is not visible.
  682. //
  683. // The likelihood is the element won't even render, not even a flash,
  684. // so some of these are just precautions. However in IE the element
  685. // is visible whilst the popup box asking the user for permission for
  686. // the web page to copy to the clipboard.
  687. //
  688.  
  689. // Place in top-left corner of screen regardless of scroll position.
  690. textArea.style.position = 'fixed';
  691. textArea.style.top = 0;
  692. textArea.style.left = 0;
  693.  
  694. // Ensure it has a small width and height. Setting to 1px / 1em
  695. // doesn't work as this gives a negative w/h on some browsers.
  696. textArea.style.width = '2em';
  697. textArea.style.height = '2em';
  698.  
  699. // We don't need padding, reducing the size if it does flash render.
  700. textArea.style.padding = 0;
  701.  
  702. // Clean up any borders.
  703. textArea.style.border = 'none';
  704. textArea.style.outline = 'none';
  705. textArea.style.boxShadow = 'none';
  706.  
  707. // Avoid flash of white box if rendered for any reason.
  708. textArea.style.background = 'transparent';
  709.  
  710. textArea.value = text;
  711.  
  712. document.body.appendChild(textArea);
  713.  
  714. textArea.select();
  715.  
  716. var successful = document.execCommand('copy');
  717.  
  718. document.body.removeChild(textArea);
  719. return successful;
  720. }
  721.  
  722. function avertissement(txt,duree,bBloque) {
  723. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  724. if(!duree) duree = 15000;
  725. var div = document.createElement('div');
  726. // On numérote les avertissements pour destruction sélective
  727. var num = document.getElementsByName('avertissement').length;
  728. div.num = num;
  729. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  730. div.setAttribute('name','avertissement');
  731. div.className = 'mh_textbox';
  732. div.style.position = 'fixed';
  733. div.style.top = (10+15*num)+'px';
  734. div.style.left = (10+5*num)+'px';
  735. div.style.border = '5px solid red';
  736. div.style.zIndex = 2+num;
  737. div.style.cursor = 'pointer';
  738. div.style.fontSize = 'large';
  739. div.innerHTML = txt;
  740. if (!bBloque) div.onclick=function(){ tueAvertissement(this.num) };
  741.  
  742. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  743. var divcroix = document.createElement('div');
  744. divcroix.style.position = 'absolute';
  745. divcroix.style.top = 0;
  746. divcroix.style.right = 0;
  747. divcroix.style.color = 'black';
  748. divcroix.style.fontSize = 'inherit';
  749. divcroix.style.cursor = 'pointer'
  750. divcroix.style.zIndex = 2+num;
  751. divcroix.innerHTML = "X";
  752. div.appendChild(divcroix);
  753.  
  754. document.body.appendChild(div);
  755. // Destruction automatique de l'avertissement après "un certain temps"
  756. window.setTimeout(function(){ tueAvertissement(num) },duree);
  757. }
  758.  
  759. function tueAvertissement(num) {
  760. var divs = document.getElementsByName('avertissement');
  761. if(divs.length==0) { return; }
  762. for(var i=0 ; i<divs.length ; i++) {
  763. if(divs[i].num==num) {
  764. divs[i].parentNode.removeChild(divs[i]);
  765. return;
  766. }
  767. }
  768. }
  769.  
  770.  
  771. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  772.  
  773. function insertBefore(next,el) {
  774. next.parentNode.insertBefore(el,next);
  775. }
  776.  
  777. function appendTr(tbody,clas) {
  778. var tr = document.createElement('tr');
  779. if(clas) tr.className = clas;
  780. tbody.appendChild(tr);
  781. return tr;
  782. }
  783.  
  784. function insertTr(next,clas) {
  785. var tr = document.createElement('tr');
  786. if(clas) tr.className = clas;
  787. insertBefore(next,tr);
  788. return tr;
  789. }
  790.  
  791. function appendTd(tr) {
  792. var td = document.createElement('td');
  793. if(tr) tr.appendChild(td);
  794. return td;
  795. }
  796.  
  797. function insertTd(next) {
  798. var td = document.createElement('td');
  799. insertBefore(next,td);
  800. return td;
  801. }
  802.  
  803. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  804. function insertAfterTd(eTd) {
  805. var newTd = document.createElement('td');
  806. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  807. return newTd;
  808. }
  809.  
  810. function appendTdCenter(tr,colspan) {
  811. var td = appendTd(tr);
  812. td.align = 'center'; // WARNING - Obsolete
  813. if(colspan) td.colSpan = colspan;
  814. return td;
  815. }
  816.  
  817. function insertTdElement(next,el) {
  818. var td = insertTd(next);
  819. if(el) td.appendChild(el);
  820. return td;
  821. }
  822.  
  823. function appendA(paren,href,cssClass,text) {
  824. var a = document.createElement('a');
  825. if (href) a.href = href;
  826. if (cssClass) a.className = cssClass;
  827. if (text) a.appendChild(document.createTextNode(text));
  828. paren.appendChild(a);
  829. }
  830.  
  831. function appendText(paren,text,bold) {
  832. if(bold) {
  833. var b = document.createElement('b');
  834. b.appendChild(document.createTextNode(text));
  835. paren.appendChild(b);
  836. }
  837. else
  838. paren.appendChild(document.createTextNode(text));
  839. }
  840.  
  841. function insertText(next,text,bold) {
  842. if(bold) {
  843. var b = document.createElement('b');
  844. appendText(b,text);
  845. insertBefore(next,b);
  846. }
  847. else
  848. insertBefore(next,document.createTextNode(text));
  849. }
  850.  
  851. function appendThText(tr,text,bold) {
  852. var th = document.createElement('th');
  853. if(tr) tr.appendChild(th);
  854. th.appendChild(document.createTextNode(text));
  855. if (bold) th.style.fontWeight = 'bold';
  856. return th;
  857. }
  858.  
  859. function appendTdText(tr,text,bold) {
  860. var td = appendTd(tr);
  861. td.appendChild(document.createTextNode(text));
  862. if (bold) td.style.fontWeight = 'bold';
  863. return td;
  864. }
  865.  
  866. function insertTdText(next,text,bold) {
  867. var td = insertTd(next);
  868. appendText(td,text,bold);
  869. return td;
  870. }
  871.  
  872. function appendBr(paren) {
  873. paren.appendChild(document.createElement('br'));
  874. }
  875.  
  876. function insertBr(next) {
  877. insertBefore(next,document.createElement('br'));
  878. }
  879.  
  880. function appendLI(ul,text) {
  881. // uniquement utilisé dans les options (crédits)
  882. var li = document.createElement('li');
  883. appendText(li,text);
  884. ul.appendChild(li);
  885. return li;
  886. }
  887.  
  888. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  889. var input = document.createElement('input');
  890. input.className = 'TextboxV2';
  891. input.type = type;
  892. input.name = nam;
  893. if (sId === undefined) input.id = nam;
  894. else input.id = sId;
  895. input.size = size;
  896. input.maxLength = maxlength;
  897. if(value) input.value = value;
  898. paren.appendChild(input);
  899. return input;
  900. }
  901.  
  902. function appendCheckBox(paren,nam,checked,onClick) {
  903. var input = document.createElement('input');
  904. input.type = 'checkbox';
  905. input.name = nam;
  906. input.id = nam;
  907. if(checked) input.checked = true;
  908. if(onClick) input.onclick = onClick;
  909. paren.appendChild(input);
  910. return input;
  911. }
  912.  
  913. function appendNobr(paren,id,delgg,text) {
  914. var nobr = document.createElement('nobr');
  915. appendCheckBox(nobr,id,null,delgg);
  916. appendText(nobr,text);
  917. paren.appendChild(nobr);
  918. appendText(paren,' ');
  919. return nobr;
  920. }
  921.  
  922. function appendCheckBoxSpan(paren,id,onClick,text) {
  923. var span = document.createElement('span');
  924. span.style.whiteSpace = 'nowrap';
  925. appendCheckBox(span,id,false,onClick);
  926. var label = document.createElement('label');
  927. appendText(label,text);
  928. label.htmlFor = id;
  929. label.style.marginLeft = '-5px';
  930. span.appendChild(label);
  931. span.style.marginRight = '3px';
  932. paren.appendChild(span);
  933. appendText(paren, ' ');
  934. return span;
  935. }
  936.  
  937. function appendOption(select,value,text) {
  938. var option = document.createElement('option');
  939. option.value = value;
  940. appendText(option,text);
  941. select.appendChild(option);
  942. return option;
  943. }
  944.  
  945. function appendHidden(form,nam,value) {
  946. var input = document.createElement('input');
  947. input.type = 'hidden';
  948. input.name = nam;
  949. input.id = nam;
  950. input.value = value;
  951. form.appendChild(input);
  952. }
  953.  
  954. function appendButton(paren,value,onClick) {
  955. var input = document.createElement('input');
  956. input.type = 'button';
  957. input.className = 'mh_form_submit';
  958. input.value = value;
  959. input.onmouseover = function(){this.style.cursor='pointer';};
  960. if(onClick) input.onclick = onClick;
  961. paren.appendChild(input);
  962. return input;
  963. }
  964.  
  965. function insertButton(next,value,onClick) {
  966. var input = document.createElement('input');
  967. input.type = 'button';
  968. input.className = 'mh_form_submit';
  969. input.value = value;
  970. input.onmouseover = function(){this.style.cursor='pointer';};
  971. input.onclick = onClick;
  972. insertBefore(next,input);
  973. return input;
  974. }
  975.  
  976. function appendSubmit(paren,value,onClick) {
  977. var input = document.createElement('input');
  978. input.type = 'submit';
  979. input.className = 'mh_form_submit';
  980. input.value = value;
  981. input.onmouseover = function(){this.style.cursor='pointer';};
  982. if(onClick) input.onclick = onClick;
  983. paren.appendChild(input);
  984. return input;
  985. }
  986.  
  987. function createImage(url,title,style) {
  988. var img = document.createElement('img');
  989. img.src = url;
  990. img.title = title;
  991. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  992. if (style) img.style = style;
  993. return img;
  994. }
  995.  
  996. function createAltImage(url,alt,title) {
  997. var img = document.createElement('img');
  998. img.src = url;
  999. img.alt = alt;
  1000. if (title) img.title = title;
  1001. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  1002. return img;
  1003. }
  1004.  
  1005. function createImageSpan(url,alt,title,text,bold) {
  1006. var span = document.createElement('span');
  1007. span.title = title;
  1008. var img = document.createElement('img');
  1009. img.src = url;
  1010. img.alt = alt;
  1011. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  1012. span.appendChild(img);
  1013. appendText(span,text,bold);
  1014. return span;
  1015. }
  1016.  
  1017. function createCase(titre,table,width) {
  1018. if(!width) width=120;
  1019. var tr = appendTr(table,'mh_tdpage');
  1020.  
  1021. var td = appendTdText(tr,titre,true);
  1022. td.className = 'mh_tdtitre';
  1023. td.width = width;
  1024.  
  1025. td = appendTdText(tr,'');
  1026. td.className = 'mh_tdpage';
  1027. return td;
  1028. }
  1029.  
  1030. function getMyID(e) {
  1031. var parent = e.parentNode;
  1032. for(var i=0 ; i<parent.childNodes.length ; i++) {
  1033. if(e==parent.childNodes[i])
  1034. return i;
  1035. }
  1036. return -1;
  1037. }
  1038.  
  1039. function insertAfter(elt,newElt) {
  1040. var id = getMyID(elt);
  1041. if(id==-1) return;
  1042. if(id<elt.parentNode.childNodes.length-1)
  1043. insertBefore(elt.nextSibling,newElt);
  1044. else
  1045. elt.parentNode.appendChild(newElt);
  1046. }
  1047.  
  1048.  
  1049. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  1050.  
  1051. function aff(nb) {
  1052. return (nb >= 0) ? '+' + nb : nb;
  1053. }
  1054.  
  1055. function getNumber(str) {
  1056. var nbr = str.match(/\d+/);
  1057. return nbr ? Number(nbr[0]) : Number.NaN;
  1058. }
  1059.  
  1060. function getNumbers(str) {
  1061. var nbrs = str.match(/\d+/g);
  1062. if (!nbrs) return [];
  1063. for (var i = 0; i < nbrs.length; i++) {
  1064. nbrs[i] = Number(nbrs[i]);
  1065. }
  1066. return nbrs;
  1067. }
  1068.  
  1069. function getIntegers(str) {
  1070. var nbrs = str.match(/-?\d+/g);
  1071. if (!nbrs) return [];
  1072. for(var i=0 ; i<nbrs.length ; i++) {
  1073. nbrs[i] = Number(nbrs[i]);
  1074. }
  1075. return nbrs;
  1076. }
  1077.  
  1078. function trim(str) {
  1079. return str.replace(/(^\s*)|(\s*$)/g, '');
  1080. }
  1081.  
  1082. if (typeof String.prototype.trim != 'function') {
  1083. // Intégré depuis ES5, pour rétrocompatibilité
  1084. String.prototype.trim = function() {
  1085. return this.replace(/^\s+/, '').replace(/\s+$/, '');
  1086. }
  1087. }
  1088.  
  1089. function epure(texte) {
  1090. return texte
  1091. .replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1092. .replace(/[ç]/g,'c')
  1093. .replace(/[éêèë]/g,'e')
  1094. .replace(/[ïî]/g,'i')
  1095. .replace(/[ôöõ]/g,'o')
  1096. .replace(/[ùûü]/g,'u');
  1097. }
  1098.  
  1099. // WARNING Modifier des constantes, c'est mal
  1100. String.prototype.epure = function() {
  1101. return this
  1102. .replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1103. .replace(/[ç]/g,'c')
  1104. .replace(/[éêèë]/g,'e')
  1105. .replace(/[ïî]/g,'i')
  1106. .replace(/[ôöõ]/g,'o')
  1107. .replace(/[ùûü]/g,'u');
  1108. }
  1109.  
  1110. function bbcode(texte) {
  1111. return texte
  1112. .replace(/&/g, '&amp;')
  1113. .replace(/"/g, '&quot;')
  1114. .replace(/</g, '&lt;')
  1115. .replace(/>/g, '&gt;')
  1116. .replace(/'/g, '&#146;')
  1117. .replace(/\[b\](.*?)\[\/b\]/g, '<b>$1</b>')
  1118. .replace(/\[i\](.*?)\[\/i\]/g, '<i>$1</i>')
  1119. .replace(/\[img\]([^"]*?)\[\/img\]/g, '<img src="$1" />');
  1120. }
  1121.  
  1122. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  1123.  
  1124. function addZero(i) {
  1125. return (i<10) ? '0'+i : i;
  1126. }
  1127.  
  1128. function DateToString(date) {
  1129. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  1130. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  1131. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  1132. }
  1133.  
  1134. function StringToDate(str) {
  1135. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  1136. }
  1137.  
  1138. // fonctionne aussi avec datetime
  1139. function SQLDateToFrench(str) {
  1140. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  1141. }
  1142.  
  1143. // ... et ajoute un "à" du plus bel effet
  1144. function SQLDateToFrenchTime(str) {
  1145. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  1146. }
  1147.  
  1148. // SQLDate vers objet date Javascript
  1149. function SQLDateToObject(str) {
  1150. var t = str.split(/[- :]/);
  1151. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  1152. }
  1153.  
  1154. var mz_ie = (window.attachEvent)? true:false;
  1155. if ("function" !== typeof addEvent) {
  1156. if (mz_ie) {
  1157. function addEvent(obj, typ, fn, sens) {
  1158. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  1159. obj["e"+typ+fn]( window.event );
  1160. }
  1161. obj.attachEvent("on"+typ, obj[typ+fn] );
  1162. }
  1163. }
  1164. else {
  1165. function addEvent(obj, typ, fn, sens) {
  1166. obj.addEventListener(typ, fn, sens);
  1167. }
  1168. }
  1169. }
  1170.  
  1171. /**********************
  1172. * glissière en mode objet
  1173. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  1174. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  1175. *
  1176. * Usage:
  1177. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  1178. * ref : utilisé pour diversifier les IDs HTML
  1179. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  1180. * target : peut être de 3 types
  1181. * - élément HTML : l'élément HTML à zoomer
  1182. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  1183. * - function : callback quand le curseur bouge
  1184. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  1185. * dans le mode dynamique, la callback est appelée sur mouseMove
  1186. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  1187. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  1188. * autres méthodes
  1189. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  1190. **********************/
  1191.  
  1192. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  1193. try {
  1194. var mouseDown = false;
  1195. var div_gliss = document.createElement("div"); // la DIV mère
  1196. div_gliss.id = "MZ_gliss_"+ref;
  1197. var div_label = document.createElement("span"); // le label
  1198. div_label.innerHTML = labelHTML;
  1199. div_gliss.appendChild(div_label);
  1200. div_gliss.className = "choix_zoom";
  1201. var dessin = document.createElement("canvas"); // le dessin lui-même
  1202. dessin.id = "MZ_gliss_dessin_"+ref;
  1203. dessin.style.cursor = "pointer";
  1204. dessin.width = 104;
  1205. dessin.height = 12;
  1206. dessin.style.marginLeft = '2px';
  1207. dessin.style.marginRight = '2px';
  1208. div_gliss.appendChild(dessin);
  1209. var pourcent = document.createElement("span"); // le pourcentage
  1210. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1211. var pourcent_text = document.createTextNode('');
  1212. var previousVal;
  1213. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1214.  
  1215. // alignement vertical
  1216. dessin.style.verticalAlign = 'middle';
  1217. div_label.style.verticalAlign = 'middle';
  1218. pourcent.style.verticalAlign = 'middle';
  1219.  
  1220. pourcent.appendChild(pourcent_text);
  1221. div_gliss.appendChild(pourcent);
  1222.  
  1223. var bulle_pourcent = document.createElement("div"); // la bulle
  1224. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1225. bulle_pourcent.style.display = 'block';
  1226. bulle_pourcent.style.visibility = 'hidden';
  1227. bulle_pourcent.style.position = 'absolute';
  1228. bulle_pourcent.style.zIndex = 3500;
  1229. bulle_pourcent.style.border = '1px solid #a1927f';
  1230. var bulle_pourcent_text = document.createTextNode('');
  1231. bulle_pourcent.appendChild(bulle_pourcent_text);
  1232. document.body.appendChild(bulle_pourcent);
  1233.  
  1234. this.getElt = function() {return div_gliss;};
  1235.  
  1236. ////////////////////////////////////
  1237. // dessine et redessine le curseur
  1238. ////////////////////////////////////
  1239. var dessine_glissiere = function(val) {
  1240. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1241. var ctx = dessin.getContext('2d');
  1242. ctx.clearRect(0, 0,104, 12);
  1243. ctx.fillStyle = "rgb(0,0,0)";
  1244. ctx.fillRect(0,0,2,12);
  1245. ctx.fillRect(102,0,2,12);
  1246. ctx.fillRect(0,5,104,2);
  1247.  
  1248. ctx.fillStyle = "rgb(80,80,80)";
  1249. ctx.fillRect(pos_0_100,0,5,12);
  1250. ctx.fillStyle = "rgb(200,200,200)";
  1251. ctx.fillRect(pos_0_100+1,1,3,10);
  1252. pourcent_text.nodeValue = val+'%';
  1253. previousVal = parseInt(val);
  1254. };
  1255.  
  1256. ////////////////////////////////////
  1257. // action sur mousedown et mousemove
  1258. // stocker la nouvelle valeur
  1259. // redessiner
  1260. // afficher la nouvelle valeur
  1261. // action selon ce qui a été demandé
  1262. ////////////////////////////////////
  1263. var doCallback_glissiere = function (evt) {
  1264. try {
  1265. if (evt.type === 'mousedown') mouseDown = true;
  1266. if (evt.offsetX) {
  1267. var xsouris = evt.offsetX;
  1268. var xpos = evt.clientX;
  1269. var ypos = evt.clientY + document.body.scrollTop;
  1270. }
  1271. else {
  1272. var xsouris = evt.layerX;
  1273. var xpos = evt.pageX;
  1274. var ypos = evt.pageY;
  1275. }
  1276. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1277. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1278. // afficher la nouvelle valeur dans la bulle
  1279. bulle_pourcent_text.nodeValue = val + '%';
  1280. bulle_pourcent.style.top = (ypos+3)+'px';
  1281. bulle_pourcent.style.left = (xpos+16)+'px';
  1282. if (evt.buttons === undefined) {
  1283. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1284. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1285. } else {
  1286. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1287. }
  1288. // stocker la nouvelle valeur
  1289. MY_setValue("MZ_glissiere_" + ref, val);
  1290. // redessiner la glissière avec le curseur où il faut
  1291. dessine_glissiere(val);
  1292. // action selon ce qui a été demandé
  1293. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1294. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1295. if (typeof paramTarget === 'object') {
  1296. var elt = paramTarget;
  1297. } else if (typeof paramTarget === 'string') {
  1298. var elt = document.getElementById(paramTarget);
  1299. } else if (typeof paramTarget === 'function') {
  1300. paramTarget(val);
  1301. return;
  1302. }
  1303. if (elt.setZoom != undefined) elt.setZoom(val);
  1304. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1305. };
  1306.  
  1307. ////////////////////////////////////
  1308. // event mousedown et mousemove : redessiner et callback
  1309. ////////////////////////////////////
  1310. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1311. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1312. ////////////////////////////////////
  1313. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1314. ////////////////////////////////////
  1315. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1316. ////////////////////////////////////
  1317. // event mouseout & mouseover : afficher/cacher la bulle
  1318. ////////////////////////////////////
  1319. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1320. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1321.  
  1322. ////////////////////////////////////
  1323. // dessiner la première fois
  1324. ////////////////////////////////////
  1325. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1326. if (val_init === undefined) val_init = valDef;
  1327. dessine_glissiere(val_init);
  1328. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1329. }
  1330.  
  1331. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1332. // reçoit 2 objets avec des propriétés x et y
  1333. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1334. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1335. var deltaX = locArrivee.x - locDepart.x;
  1336. if (deltaX == 0) return; // pas de point intermédiaire
  1337. var deltaY = locArrivee.y - locDepart.y;
  1338. if (deltaY == 0) return; // pas de point intermédiaire
  1339. var absDeltaX = Math.abs(deltaX);
  1340. var absDeltaY = Math.abs(deltaY);
  1341. if (absDeltaX > absDeltaY) {
  1342. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1343. } else if (absDeltaY > absDeltaX) {
  1344. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1345. } else {
  1346. return; // égalité, pas de point intermédiaire
  1347. }
  1348. }
  1349.  
  1350. /**********************
  1351. * carte en mode objet
  1352. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1353. *
  1354. * Usage:
  1355. * carte = new carte_MZ(ref, tabDepl);
  1356. * ref : utilisé pour diversifier les IDs HTML
  1357. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1358. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1359. * autres méthodes
  1360. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1361. **********************/
  1362.  
  1363. function carte_MZ(ref, tabDepl) {
  1364. try {
  1365. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1366. div1_carte.id = "MZ_carte_"+ref;
  1367. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1368. div1_carte.style.backgroundImage = 'none';
  1369. div1_carte.style.backgroundColor = 'transparent';
  1370. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1371. div2_carte.className = "carte_MZ";
  1372. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1373. var dessin = document.createElement("canvas"); // le dessin lui-même
  1374. dessin.id = "MZ_carte_dessin_"+ref;
  1375. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1376. div1_carte.appendChild(div2_carte);
  1377. div2_carte.appendChild(dessin);
  1378.  
  1379. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1380. , [-66.5, -37.5, 2, 1.5, -69]
  1381. , [-63.5, 8.5, 2, 1.5, -69]
  1382. , [-59.5, -32.5, 2, 1.5, -69]
  1383. , [-52, 57, 0.25, 0.8, -59]
  1384. , [-50.5, -22.5, 2, 1.5, -69]
  1385. , [-35.5, -51.5, 2, 1.5, -69]
  1386. , [-34.5, 14.5, 2, 1.5, -69]
  1387. , [-34.5, 64.5, 2, 1.5, -69]
  1388. , [-11.5, 72.5, 2, 1.5, -69]
  1389. , [5.5, -49.5, 2, 1.5, -69]
  1390. , [5.5, 31.5, 2, 1.5, -69]
  1391. , [10.5, 63.5, 2, 1.5, -69]
  1392. , [12, -15, 0.25, 0.8, -59]
  1393. , [21.5, 35.5, 2, 1.5, -69]
  1394. , [30, -52, 0.25, 0.8, -59]
  1395. , [46.5, 51.5, 2, 1.5, -69]
  1396. , [48, -39, 0.25, 0.8, -59]
  1397. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1398. , [56.5, 23.5, 75, 8.7, -99]
  1399. , [64, 70, 0.25, 0.8, -59]
  1400. , [74.5, 31.5, 2, 1.5, -69]];
  1401.  
  1402. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1403. var couleur_cible = 'rgba(0,0,0,0.5)';
  1404. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1405. var couleur_trou = 'rgb(200,0,0)';
  1406.  
  1407. var coord_x = function(val) {
  1408. return decalh+coeff*(val+100);
  1409. };
  1410. var coord_y = function(val) {
  1411. return decalv+coeff*(100-val);
  1412. };
  1413.  
  1414. var ctx = dessin.getContext('2d');
  1415. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1416. if (coeff) coeff /= 50;
  1417. else coeff = 2;
  1418. var decalv=30, decalh=30;
  1419.  
  1420. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1421. //var res = false
  1422. var x0 = pos0.x;
  1423. var y0 = pos0.x;
  1424. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1425. var px = Math.sign(pos1.x - pos0.x);
  1426. var py = Math.sign(pos1.y - pos0.y);
  1427. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1428. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1429.  
  1430. for(var k in position_trous_MZ) {
  1431. a = parseFloat(px*px+py*py);
  1432. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1433. 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]);
  1434. delta = b*b-a*c
  1435. if(delta >= 0) {
  1436. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1437. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1438. if(t0 <= tmax && t1 >= 0) {
  1439. // 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
  1440. //res = true;
  1441. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1442. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1443. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1444. // Roule : pas utile pour nous
  1445. //res = true;
  1446. //chute.push([x0+l*px, y0+l*py]);
  1447. return true;
  1448. }
  1449. }
  1450. }
  1451. }
  1452. //return res;
  1453. return false;
  1454. };
  1455.  
  1456. var dessine_carte = function () {
  1457. dessin.width = 200*coeff+2*decalh;
  1458. dessin.height = 200*coeff+2*decalv;
  1459.  
  1460. //repere
  1461. ctx.beginPath();
  1462. ctx.moveTo(coord_x(0), coord_y(100));
  1463. ctx.lineTo(coord_x(0), coord_y(-100));
  1464. ctx.moveTo(coord_x(-100), coord_y(0));
  1465. ctx.lineTo(coord_x(100), coord_y(0));
  1466. ctx.stroke();
  1467. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1468.  
  1469. //trous
  1470. ctx.fillStyle = couleur_trou;
  1471. for(var i in position_trous_MZ) {
  1472. ctx.beginPath();
  1473. 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);
  1474. ctx.fill();
  1475. }
  1476. // trajets
  1477. ctx.lineCap = "round";
  1478. ctx.lineJoin = "round";
  1479. for (var iSuivant in tabDepl) {
  1480. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1481. var tabDeplOneSuivant = tabDepl[iSuivant];
  1482. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1483. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1484. // La "cible" au départ
  1485. var typeDepart = tabDeplOneSuivant[0].typ;
  1486. switch (typeDepart) {
  1487. case 'tp':
  1488. ctx.beginPath();
  1489. ctx.lineWidth = 2;
  1490. ctx.strokeStyle = couleur_cible;
  1491. ctx.fillStyle = couleur_cible;
  1492. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1493. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1494. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1495. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1496. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1497. ctx.moveTo(x0 + coeff * 3, y0);
  1498. ctx.lineTo(x0 - coeff * 3, y0);
  1499. ctx.moveTo(x0, y0 + coeff * 3);
  1500. ctx.lineTo(x0, y0 - coeff * 3);
  1501. ctx.stroke();
  1502. break;
  1503. default:
  1504. ctx.beginPath();
  1505. ctx.lineWidth = 1;
  1506. ctx.strokeStyle = couleur_cible;
  1507. ctx.fillStyle = couleur_cible;
  1508. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1509. ctx.moveTo(x0 + coeff * 4, y0);
  1510. ctx.lineTo(x0 - coeff * 4, y0);
  1511. ctx.moveTo(x0, y0 + coeff * 4);
  1512. ctx.lineTo(x0, y0 - coeff * 4);
  1513. ctx.stroke();
  1514. break;
  1515. }
  1516. // les segments
  1517. var nb_pts = tabDeplOneSuivant.length;
  1518. var pointPrecedent = tabDeplOneSuivant[0];
  1519. for (var i=1; i<nb_pts; i++) {
  1520. ctx.beginPath();
  1521. ctx.lineWidth = coeff;
  1522. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1523. ctx.strokeStyle = couleur_depl_normal;
  1524. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1525. if (pointIntermediaire === undefined) {
  1526. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1527. ctx.strokeStyle = couleur_depl_collision_trou;
  1528. else
  1529. ctx.strokeStyle = couleur_depl_normal;
  1530. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1531. } else {
  1532. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1533. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1534. ctx.strokeStyle = couleur_depl_collision_trou;
  1535. else
  1536. ctx.strokeStyle = couleur_depl_normal;
  1537. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1538. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1539. }
  1540. pointPrecedent = tabDeplOneSuivant[i];
  1541. ctx.stroke();
  1542. }
  1543. // Les points à chaque étape
  1544. ctx.fillStyle = couleur_depl_normal;
  1545. for (var i=1; i<nb_pts; i++) {
  1546. ctx.beginPath();
  1547. var x = coord_x(tabDeplOneSuivant[i].x);
  1548. var y = coord_y(tabDeplOneSuivant[i].y);
  1549. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1550. ctx.fill();
  1551. }
  1552. }
  1553. }
  1554.  
  1555. this.setZoom = function (val) {
  1556. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1557. coeff = val / 50;
  1558. dessine_carte();
  1559. }
  1560.  
  1561. // glissiere
  1562. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1563. var eGliss = gliss.getElt();
  1564. eGliss.style.position = 'absolute';
  1565. eGliss.style.top = (coeff * 2) + 'px';
  1566. eGliss.style.left = decalh + 'px';
  1567. dessin.style.position = 'relative';
  1568. div2_carte.style.position = 'relative';
  1569. eGliss.style.zIndex = 9000;
  1570. div2_carte.appendChild(eGliss);
  1571.  
  1572. // affichage au survol de la souris
  1573. var bulle = document.createElement('div');
  1574. bulle.style.visibility = 'hidden';
  1575. bulle.style.position = 'absolute';
  1576. bulle.style.zIndex = 3100;
  1577. bulle.style.border = 'solid 1px #a1927f';
  1578. bulle.className = 'mh_tdpage';
  1579. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1580. var bulleHaut = document.createElement('div');
  1581. bulleHaut.style.display = 'block';
  1582. bulleHaut.style.paddingRight = '3px';
  1583. bulleHaut.className = 'mh_tdtitre';
  1584. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1585. bulle.appendChild(bulleHaut);
  1586. var bulleBas = document.createElement('div');
  1587. bulleBas.style.display = 'block';
  1588. bulleBas.style.whiteSpace = "nowrap";
  1589. bulleBas.style.paddingRight = '3px';
  1590.  
  1591. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1592. bulle.appendChild(bulleBas);
  1593. div2_carte.appendChild(bulle);
  1594. var affichePosition = function(evt) {
  1595. if (evt.offsetX) {
  1596. var xsouris = evt.offsetX;
  1597. var ysouris = evt.offsetY;
  1598. var xpos = evt.clientX;
  1599. var ypos = evt.clientY + document.body.scrollTop;
  1600. }
  1601. else {
  1602. var xsouris = evt.layerX;
  1603. var ysouris = evt.layerY;
  1604. var xpos = evt.pageX;
  1605. var ypos = evt.pageY;
  1606. }
  1607. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1608. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1609. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1610. var tabHTMLbas = [];
  1611. // message pour les trous
  1612. for (var i in position_trous_MZ) {
  1613. var ceTrou = position_trous_MZ[i];
  1614. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1615. if(dist <= 0) {
  1616. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1617. break;
  1618. }
  1619. }
  1620. // messages pour les suivants
  1621. for (var i in tabDepl) {
  1622. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1623. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1624. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1625. }
  1626. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1627. bulle.style.top = (ysouris+8) + 'px';
  1628. bulle.style.left = (xsouris+16) + 'px';
  1629. };
  1630. addEvent(dessin, "mousemove", affichePosition, true);
  1631. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1632. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1633.  
  1634. // dessin initial
  1635. dessine_carte();
  1636.  
  1637. this.getElt = function() {return div1_carte;};
  1638.  
  1639. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1640. }
  1641.  
  1642.  
  1643. /**********************************************************
  1644. **** Fin de zone à déplacer dans une bibli commune ********
  1645. **********************************************************/
  1646.  
  1647. /* DEBUG: NETTOYAGE TAGS */
  1648. if(MY_getValue(numTroll+'.TAGSURL')) {
  1649. MY_removeValue(numTroll+'.TAGSURL');
  1650. }
  1651.  
  1652. // Alerte si mode dev
  1653. if (isDEV) {
  1654. var divpopup = document.createElement('div');
  1655. divpopup.id = 'divDEV';
  1656. divpopup.style =
  1657. 'position: fixed;'+
  1658. 'border: 15px solid red;'+
  1659. 'top: 10px;right: 10px;'+
  1660. 'background-color: white;'+
  1661. 'color: black;'+
  1662. 'font-size: large;'+
  1663. 'padding: 5px'+
  1664. 'z-index: 200;';
  1665. appendText(divpopup, '[MZ] Mode DEV');
  1666. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1667. document.body.appendChild(divpopup);
  1668. }
  1669.  
  1670. /*---------- regroupement des getPortee() ------------------------------------*/
  1671.  
  1672. function getPortee(param) {
  1673. param = Math.max(0,Number(param));
  1674. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1675. // ça devrait être floor, +10.25, -2.5
  1676. }
  1677.  
  1678. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1679.  
  1680. function getPXKill(niv) {
  1681. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1682. return Math.max(0,10+3*niv-2*nivTroll);
  1683. }
  1684.  
  1685. function getPXDeath(niv) {
  1686. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1687. return Math.max(0,10+3*nivTroll-2*niv);
  1688. }
  1689.  
  1690. function analysePX(niv) {
  1691. niv = niv+'';
  1692. var i = niv.indexOf('+');
  1693. if(i!=-1) // si niv = 'XX+' ??
  1694. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1695. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1696. if(i!=-1) {
  1697. var max = getPXKill(niv.slice(i+2));
  1698. if(max==0)
  1699. return ' --> <b>0</b> PX';
  1700. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1701. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1702. }
  1703. i = niv.indexOf('='); // ???
  1704. if(i!=-1) {
  1705. var max = getPXKill(niv.slice(i+1));
  1706. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1707. }
  1708. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1709. }
  1710.  
  1711. function analysePXTroll(niv) {
  1712. var str = analysePX(niv);
  1713. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1714. return str;
  1715. }
  1716.  
  1717.  
  1718. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1719. // Refonte totale du code de Zorya
  1720.  
  1721. // Elements à implémenter en dur dans MZ2.0
  1722. var numQualite = {
  1723. 'Très Mauvaise':1,
  1724. 'Mauvaise':2,
  1725. 'Moyenne':3,
  1726. 'Bonne':4,
  1727. 'Très Bonne':5
  1728. };
  1729.  
  1730. var qualiteNum = [
  1731. '_dummy_',
  1732. 'Très Mauvaise',
  1733. 'Mauvaise',
  1734. 'Moyenne',
  1735. 'Bonne',
  1736. 'Très Bonne'
  1737. ];
  1738.  
  1739. var nival = {
  1740. 'Abishaii Bleu':19,
  1741. 'Abishaii Noir':10,
  1742. 'Abishaii Rouge':23,
  1743. 'Abishaii Vert':15,
  1744. 'Ame-en-peine':8,
  1745. 'Amibe Geante':9,
  1746. 'Anaconda des Catacombes':8,
  1747. 'Ankheg':10,
  1748. 'Anoploure Purpurin':36,
  1749. 'Araignee Geante':2,
  1750. 'Ashashin':35,
  1751. 'Balrog':50,
  1752. 'Banshee':16,
  1753. 'Barghest':36,
  1754. 'Basilisk':11,
  1755. 'Behemoth':34,
  1756. 'Behir':14,
  1757. 'Beholder':50,
  1758. 'Boggart':3,
  1759. 'Bondin':9,
  1760. "Bouj'Dla Placide":37,
  1761. "Bouj'Dla":19,
  1762. 'Bulette':19,
  1763. 'Caillouteux':1,
  1764. 'Capitan':35,
  1765. 'Carnosaure':25,
  1766. 'Champi-Glouton':3,
  1767. 'Chauve-Souris Geante':4,
  1768. 'Cheval a Dents de Sabre':23,
  1769. 'Chevalier du Chaos':20,
  1770. 'Chimere':13,
  1771. 'Chonchon':24,
  1772. 'Coccicruelle':22,
  1773. 'Cockatrice':5,
  1774. 'Crasc Medius':17,
  1775. 'Crasc Maexus':25,
  1776. 'Crasc':10,
  1777. 'Croquemitaine':6,
  1778. 'Cube Gelatineux':32,
  1779. 'Daemonite':27,
  1780. 'Diablotin':5,
  1781. 'Dindon du Chaos':1,
  1782. 'Djinn':29,
  1783. 'Ectoplasme':18,
  1784. 'Effrit':27,
  1785. "Elementaire d'Air":23,
  1786. "Elementaire d'Eau":17,
  1787. 'Elementaire de Feu':21,
  1788. 'Elementaire de Terre':21,
  1789. 'Elementaire du Chaos':26,
  1790. 'Erinyes':7,
  1791. 'Esprit-Follet':16,
  1792. 'Essaim Craterien':30,
  1793. 'Essaim Sanguinaire':25,
  1794. 'Ettin':8,
  1795. 'Familier':1,
  1796. 'Fantome':24,
  1797. 'Feu Follet':20,
  1798. 'Flagelleur Mental':33,
  1799. 'Foudroyeur':38,
  1800. 'Fumeux':22,
  1801. 'Fungus Geant':9,
  1802. 'Fungus Violet':4,
  1803. 'Furgolin':10,
  1804. 'Gargouille':3,
  1805. 'Geant de Pierre':13,
  1806. 'Geant des Gouffres':22,
  1807. "Geck'oo Majestueux":40,
  1808. "Geck'oo":15,
  1809. 'Glouton':20,
  1810. 'Gnoll':5,
  1811. 'Gnu Domestique':1,
  1812. 'Gnu Sauvage':1,
  1813. 'Goblin':4,
  1814. 'Goblours':4,
  1815. "Golem d'Argile":15,
  1816. 'Golem de cuir':1,
  1817. 'Golem de Chair':8,
  1818. 'Golem de Fer':31,
  1819. 'Golem de mithril':1,
  1820. 'Golem de metal':1,
  1821. 'Golem de papier':1,
  1822. 'Golem de Pierre':23,
  1823. 'Gorgone':11,
  1824. 'Goule':4,
  1825. 'Gowap Apprivoise':1,
  1826. 'Gowap Sauvage':1,
  1827. 'Gremlins':3,
  1828. 'Gritche':39,
  1829. 'Grouilleux':4,
  1830. 'Grylle':31,
  1831. 'Harpie':4,
  1832. 'Hellrot':18,
  1833. 'Homme-Lezard':4,
  1834. 'Hurleur':8,
  1835. 'Hydre':50,
  1836. 'Incube':13,
  1837. 'Kobold':2,
  1838. 'Labeilleux':26,
  1839. 'Lezard Geant':5,
  1840. 'Liche':50,
  1841. 'Limace Geante':10,
  1842. 'Loup-Garou':8,
  1843. 'Lutin':4,
  1844. 'Mante Fulcreuse':30,
  1845. 'Manticore':9,
  1846. 'Marilith':33,
  1847. 'Meduse':6,
  1848. 'Megacephale':38,
  1849. 'Mille-Pattes Geant':14,
  1850. 'Mimique':6,
  1851. 'Minotaure':7,
  1852. 'Molosse Satanique':8,
  1853. 'Momie':4,
  1854. 'Monstre Rouilleur':3,
  1855. "Mouch'oo Domestique":14,
  1856. "Mouch'oo Majestueux Sauvage":33,
  1857. "Mouch'oo Sauvage":14,
  1858. 'Na-Haniym-Heee':0,
  1859. 'Necrochore':37,
  1860. 'Necromant':39,
  1861. 'Necrophage':8,
  1862. 'Naga':10,
  1863. 'Nuee de Vermine':13,
  1864. "Nuage d'Insectes":7,
  1865. 'Ogre':7,
  1866. 'Ombre de Roches':13,
  1867. 'Ombre':2,
  1868. 'Orque':3,
  1869. 'Ours-Garou':18,
  1870. 'Palefroi Infernal':29,
  1871. 'Phoenix':32,
  1872. 'Pititabeille':0,
  1873. 'Plante Carnivore':4,
  1874. 'Pseudo-Dragon':5,
  1875. 'Rat Geant':2,
  1876. 'Rat-Garou':3,
  1877. 'Rocketeux':5,
  1878. 'Sagouin':3,
  1879. 'Scarabee Geant':4,
  1880. 'Scorpion Geant':10,
  1881. 'Shai':28,
  1882. 'Sirene':8,
  1883. 'Slaad':5,
  1884. 'Sorciere':17,
  1885. 'Spectre':14,
  1886. 'Sphinx':30,
  1887. 'Squelette':1,
  1888. 'Strige':2,
  1889. 'Succube':13,
  1890. 'Tertre Errant':20,
  1891. 'Thri-kreen':10,
  1892. 'Tigre-Garou':12,
  1893. 'Titan':26,
  1894. 'Trancheur':35,
  1895. 'Tubercule Tueur':14,
  1896. 'Tutoki':4,
  1897. 'Vampire':29,
  1898. 'Ver Carnivore Geant':12,
  1899. 'Ver Carnivore':11,
  1900. 'Veskan Du Chaos':14,
  1901. 'Vouivre':33,
  1902. 'Worg':5,
  1903. 'Xorn':14,
  1904. 'Yeti':8,
  1905. 'Yuan-ti':15,
  1906. 'Zombie':2
  1907. }
  1908.  
  1909. var tabEM = {
  1910. //Monstre: [Compo exact, Sort, Position, Localisation]
  1911. // AA
  1912. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1913. // AE
  1914. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1915. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1916. // AdA
  1917. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1918. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1919. // AdE
  1920. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1921. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1922. // AdD
  1923. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1924. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1925. // BAM
  1926. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1927. // BuM
  1928. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1929. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1930. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1931. // Explo
  1932. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1933. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1934. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1935. // FP
  1936. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1937. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1938. // FA
  1939. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1940. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1941. // Glue
  1942. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1943. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1944. // GdS
  1945. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1946. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1947. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1948. // Invi
  1949. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1950. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1951. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1952. // Lévitation
  1953. // ???
  1954. // PréM :
  1955. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1956. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1957. // Proj
  1958. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1959. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1960. // PuM :
  1961. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1962. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1963. // Sacro
  1964. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1965. // Télék
  1966. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1967. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1968. // TP
  1969. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1970. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1971. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1972. // VA
  1973. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1974. // VL
  1975. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1976. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1977. // VlC
  1978. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1979. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1980. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1981. // VT
  1982. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1983. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1984. // Variables
  1985. 'Rat':["d'un"],
  1986. 'Rat Géant':["d'un"],
  1987. 'Dindon':["d'un"],
  1988. 'Goblin':["d'un"],
  1989. 'Limace':["d'une"],
  1990. 'Limace Géante':["d'une"],
  1991. 'Ver':["d'un"],
  1992. 'Ver Carnivore':["d'un"],
  1993. 'Ver Carnivore Géant':["d'un"],
  1994. 'Fungus':["d'un"],
  1995. 'Vouivre':["d'une"],
  1996. 'Gnu':["d'un"],
  1997. 'Scarabée':["d'un"]
  1998. };
  1999.  
  2000. var mundiChampi = {
  2001. 'Préscientus Reguis':'du Phoenix',
  2002. 'Amanite Trolloïde':'de la Mouche',
  2003. 'Girolle Sanglante':'du Dindon',
  2004. 'Horreur Des Prés':'du Gobelin',
  2005. 'Bolet Péteur':'du Démon',
  2006. 'Pied Jaune':'de la Limace',
  2007. 'Agaric Sous-Terrain':'du Rat',
  2008. 'Suinte Cadavre':"de l'Hydre",
  2009. 'Cèpe Lumineux':'du Ver',
  2010. 'Fungus Rampant':'du Fungus',
  2011. 'Nez Noir':'de la Vouivre',
  2012. 'Pleurote Pleureuse':'du Gnu',
  2013. 'Phytomassus Xilénique':'du Scarabée'
  2014. };
  2015.  
  2016. function addInfoMM(node,mob,niv,qualite,effetQ) {
  2017. appendText(node,' ');
  2018. var urlImg = URL_MZimg
  2019. +'Competences/melangeMagique.png';
  2020. var text = ' [-'+(niv+effetQ)+' %]';
  2021. var str = '';
  2022. switch(mob[0]) {
  2023. case 'A':
  2024. case 'E':
  2025. case 'I':
  2026. case 'O':
  2027. case 'U':
  2028. str = "Compo d'";
  2029. break;
  2030. default:
  2031. str = 'Compo de ';
  2032. }
  2033. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  2034. var span = createImageSpan(urlImg,'MM:',title,text);
  2035. node.appendChild(span);
  2036. }
  2037.  
  2038. function addInfoEM(node,mob,compo,qualite,localisation) {
  2039. if(!tabEM[mob]) return;
  2040. var title = 'Composant variable', texte = 'Variable';
  2041. var bold = false;
  2042. if(tabEM[mob].length>1) {
  2043. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  2044. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  2045. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  2046. if(pc<-20) return;
  2047. if(pc>=0) bold = true;
  2048. texte = aff(pc)+'%';
  2049. title = texte+" pour l'écriture de "+tabEM[mob][1];
  2050. }
  2051. var urlImg = URL_MZimg
  2052. +'Competences/ecritureMagique.png';
  2053. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  2054. node.appendChild(span);
  2055. }
  2056.  
  2057. function insererInfosEM(tbody) {
  2058. // lancé par equip, equipgowap
  2059. var trCompos = document.evaluate(
  2060. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  2061. tbody,null,7,null);
  2062. var strCompos = '';
  2063. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  2064. var node = trCompos.snapshotItem(i).childNodes[7];
  2065. var str = node.firstChild.textContent;
  2066. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  2067. var mob = trim(str.slice(str.indexOf("d'un")+5));
  2068. // Si non-EM on stoppe le traitement
  2069. if(!tabEM[mob]) continue;
  2070. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  2071. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  2072. var localisation = trim(str.slice(0,str.indexOf(' |')));
  2073. addInfoEM(node,mob,compo,qualite,localisation);
  2074. }
  2075. }
  2076.  
  2077. function getQualite(qualite) {
  2078. var nb = numQualite[qualite];
  2079. return nb ? nb-1 : -1;
  2080. }
  2081.  
  2082. function getEM(nom) {
  2083. if(nom.indexOf('[')!=-1)
  2084. nom = trim(nom.substring(0,nom.indexOf('[')));
  2085. if(tabEM[nom]) return nom;
  2086. return '';
  2087. }
  2088.  
  2089. // DEBUG ex-fonction composantEM
  2090. function compoMobEM(mob) {
  2091. if(!tabEM[mob]) return '';
  2092. if(tabEM[mob].length==1)
  2093. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  2094. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  2095. +") pour l'écriture de "+tabEM[mob][1];
  2096. }
  2097.  
  2098. // DEBUG ex-fonction compoEM
  2099. function titreCompoEM(mob,compo,localisation,qualite) {
  2100. if(!tabEM[mob]) return '';
  2101. if(tabEM[mob].length==1) return 'Composant variable';
  2102.  
  2103. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  2104. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  2105. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  2106.  
  2107. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  2108. return '';
  2109. }
  2110.  
  2111. // DEBUG - rétrocompatibilité
  2112. function compoEM(mob) {
  2113. // appelé dans libs, vue
  2114. return compoMobEM(mob);
  2115. }
  2116. function composantEM(mob,compo,localisation,qualite) {
  2117. // appelé dans libs, tancompo
  2118. return titreCompoEM(mob,compo,localisation,qualite);
  2119. }
  2120. //
  2121.  
  2122.  
  2123. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  2124.  
  2125. arrayTalents = {
  2126. /* Compétences */
  2127. 'Acceleration du Metabolisme':'AM',
  2128. 'Attaque Precise':'AP',
  2129. 'Balayage':'Balayage',
  2130. //'Balluchonnage':'Ballu',
  2131. 'Baroufle':'Baroufle',
  2132. 'Bidouille':'Bidouille',
  2133. 'Botte Secrete':'BS',
  2134. 'Camouflage':'Camou',
  2135. 'Charger':'Charger',
  2136. 'Connaissance des Monstres':'CdM',
  2137. 'Construire un Piege':'Piege',
  2138. 'Piege a Feu':'PiegeFeu',
  2139. 'Piege a Glue':'PiegeGlue',
  2140. 'Contre-Attaquer':'CA',
  2141. 'Coup de Butoir':'CdB',
  2142. 'Course':'Course',
  2143. 'Deplacement Eclair':'DE',
  2144. 'Dressage':'Dressage',
  2145. 'Ecriture Magique':'EM',
  2146. 'Frenesie':'Frenesie',
  2147. 'Golemologie':'Golemo',
  2148. 'Golem de cuir':'GolemCuir',
  2149. 'Golem de metal':'GolemMetal',
  2150. 'Golem de mithril':'GolemMithril',
  2151. 'Golem de papier':'GolemPapier',
  2152. 'Grattage':'Grattage',
  2153. 'Hurlement Effrayant':'HE',
  2154. 'Identification des Champignons':'IdC',
  2155. 'Insultes':'Insultes',
  2156. 'Lancer de Potions':'LdP',
  2157. 'Marquage':'Marquage',
  2158. 'Melange Magique':'Melange',
  2159. 'Miner':'Miner',
  2160. 'Travail de la Pierre':'Pierre',
  2161. 'Necromancie':'Necro',
  2162. 'Painthure de Guerre':'PG',
  2163. 'Parer':'Parer',
  2164. 'Pistage':'Pistage',
  2165. 'Planter un Champignon':'PuC',
  2166. 'Regeneration Accrue':'RA',
  2167. 'Reparation':'Reparation',
  2168. 'Retraite':'Retraite',
  2169. 'RotoBaffe':'RB',
  2170. 'Shamaner':'Shamaner',
  2171. "S'interposer":'SInterposer',
  2172. 'Tailler':'Tailler',
  2173. //'Vol':'Vol',
  2174. /* Sortilèges */
  2175. 'Analyse Anatomique':'AA',
  2176. 'Armure Etheree':'AE',
  2177. 'Augmentation de l´Attaque':'AdA', // obsolète?
  2178. "Augmentation de l'Attaque":'AdA',
  2179. 'Augmentation de l´Esquive':'AdE',
  2180. 'Augmentation des Degats':'AdD',
  2181. 'Bulle Anti-Magie':'BAM',
  2182. 'Bulle Magique':'BuM',
  2183. 'Explosion':'Explo',
  2184. 'Faiblesse Passagere':'FP',
  2185. 'Flash Aveuglant':'FA',
  2186. 'Glue':'Glue',
  2187. 'Griffe du Sorcier':'GdS',
  2188. 'Hypnotisme':'Hypno',
  2189. 'Identification des Tresors':'IdT',
  2190. 'Invisibilite':'Invi',
  2191. 'Levitation':'Levitation',
  2192. 'Precision Magique':'PreM',
  2193. 'Projectile Magique':'Projo',
  2194. 'Projection':'Proj',
  2195. 'Puissance Magique':'PuM',
  2196. 'Rafale Psychique':'Rafale',
  2197. 'Sacrifice':'Sacro',
  2198. 'Siphon des ames':'Siphon',
  2199. 'Telekinesie':'Telek',
  2200. 'Teleportation':'TP',
  2201. 'Vampirisme':'Vampi',
  2202. 'Vision Accrue':'VA',
  2203. 'Vision lointaine':'VL',
  2204. 'Voir le Cache':'VlC',
  2205. 'Vue Troublee':'VT'
  2206. //'':''
  2207. }
  2208.  
  2209. // DEBUG - Pour rétrocompatibilité
  2210. function getSortComp(nom,niveau) {
  2211. return getTalent(nom,niveau);
  2212. }
  2213. //
  2214.  
  2215. function getTalent(nom,niveau) {
  2216. if(nom===true) return true;
  2217. var nomEnBase = arrayTalents[epure(nom)];
  2218. if(!nomEnBase) nomEnBase=nom;
  2219. if(!niveau) var niveau = '';
  2220. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2221. return Number(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau));
  2222. return 0;
  2223. }
  2224.  
  2225. function removeAllTalents() {
  2226. for(var talent in arrayTalents) {
  2227. var nomEnBase = arrayTalents[talent];
  2228. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2229. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2230. continue;
  2231. }
  2232. var niveau = 1;
  2233. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2234. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2235. niveau++;
  2236. }
  2237. }
  2238. }
  2239.  
  2240. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2241. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2242. var att = MY_getValue(numTroll+'.caracs.attaque');
  2243. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2244. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2245. var mm = MY_getValue(numTroll+'.caracs.mm');
  2246. var deg = MY_getValue(numTroll+'.caracs.degats');
  2247. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2248. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2249. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2250. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2251. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2252. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2253. return false;
  2254. return true;
  2255. } catch(e) {
  2256. return false;
  2257. }
  2258. }
  2259.  
  2260.  
  2261. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2262.  
  2263. function getPVsRestants(pv,bless,vue) {
  2264. bless = Number(bless.match(/\d+/)[0]);
  2265. if(bless==0) return null;
  2266. var pvminmax = pv.match(/\d+/g);
  2267. var oMinMaxPV = {min: pvminmax[0], max: pvminmax[1]};
  2268. var oMinMaxPVRestant = MZ_getPVsRestants(oMinMaxPV, bless);
  2269. if (vue) {
  2270. if (oMinMaxPVRestant.min) {
  2271. if (oMinMaxPVRestant.max) {
  2272. return ' (' + oMinMaxPVRestant.min + '-' + oMinMaxPVRestant.max + ')';
  2273. } else {
  2274. return " (\u2A7E" + oMinMaxPVRestant.min + ')'; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  2275. }
  2276. } else {
  2277. if (oMinMaxPVRestant.max) {
  2278. return " (\u2A7D" + oMinMaxPVRestant.max + ')'; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  2279. } else {
  2280. return '';
  2281. }
  2282. }
  2283. }
  2284. var oRet = ['Points de Vie restants : '];
  2285. if (oMinMaxPVRestant.min) {
  2286. if (oMinMaxPVRestant.max) {
  2287. oRet[1] = 'Entre '+oMinMaxPVRestant.min+' et '+oMinMaxPVRestant.max;
  2288. } else {
  2289. oRet[1] = "\u2A7E" + oMinMaxPVRestant.min; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  2290. }
  2291. } else {
  2292. if (oMinMaxPVRestant.max) {
  2293. oRet[1] = "\u2A7D" + oMinMaxPVRestant.max; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  2294. } else {
  2295. oRet[1] = 'inconnu';
  2296. }
  2297. }
  2298. return oRet;
  2299. /* à supprimer
  2300. if(bless==95) {
  2301. var pvb = 1;
  2302. var pvh = Math.floor( pvminmax[1]/20 );
  2303. }
  2304. else if(bless==5) {
  2305. var pvb = Math.floor( pvminmax[0]*19/20 );
  2306. var pvh = pvminmax[1];
  2307. }
  2308. else {
  2309. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2310. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2311. }
  2312. return vue ? ' ('+pvb+'-'+pvh+')' :
  2313. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2314. }
  2315. */
  2316. }
  2317.  
  2318. function MZ_getPVsRestants(oMinMaxPV, bless) { // rend un objet minmax
  2319. var oRet = {};
  2320. if(bless==95) {
  2321. oRet.min = 1;
  2322. if (oMinMaxPV.max) oRet.max = Math.floor( oMinMaxPV.max/20);
  2323. } else if(bless==5) {
  2324. if (oMinMaxPV.min) oRet.min = Math.floor( oMinMaxPV.min*19/20);
  2325. if (oMinMaxPV.max) oRet.max = oMinMaxPV.max;
  2326. } else {
  2327. if (oMinMaxPV.min) oRet.min = Math.ceil( oMinMaxPV.min*(95-bless) / 100);
  2328. if (oMinMaxPV.max) oRet.max = Math.floor( oMinMaxPV.max*(105-bless) / 100);
  2329. }
  2330. return oRet;
  2331. }
  2332.  
  2333. /* tentative via jQuery abandonnée
  2334. function insertButtonCdmSmartphone_to_delete(nextName,onClick,texte) {
  2335. if (window.jQuery == undefined) return;
  2336. //window.console.log('jQuery OK');
  2337. var eInput = $('[name="' + nextName + '"]');
  2338. if (!eInput) return;
  2339. //window.console.log('eInput OK');
  2340. var eDiv = eInput.closest("div");
  2341. if (!eDiv) return;
  2342. //window.console.log('eDiv OK');
  2343. var newDiv = eDiv.clone();
  2344. var newSpan = newDiv.children('span');
  2345. newSpan.children(':first-child').text(texte);
  2346. var newInput = newDiv.children('input');
  2347. newInput.removeAttr('onclick');
  2348. newInput.click(onClick);
  2349. newInput.val(texte);
  2350. newInput.removeAttr("type").attr("type", "button");
  2351. var eForm = eDiv.parent();
  2352. window.console.log("insertButtonCdmSmartphone tag newdiv=" + newDiv.prop('tagName') + ', parent tag=' + eForm.prop('tagName'));
  2353. eForm.prepend(newDiv);
  2354. return true;
  2355. }
  2356.  
  2357. function insertButtonCdmSmartphone(nextName,onClick,texte) {
  2358. var tabInput = document.getElementsByName(nextName);
  2359. if (!tabInput) return;
  2360. var eInput = tabInput[0];
  2361. if (!eInput) return;
  2362. //window.console.log('eInput OK');
  2363. var eDiv = eInput.parentNode;
  2364. if (!eDiv) return;
  2365. window.console.log('eDiv.outerHTML=' + eDiv.outerHTML);
  2366. var eNewDiv = eDiv.cloneNode(true);
  2367. window.console.log('eNewDiv.outerHTML=' + eNewDiv.outerHTML);
  2368. var tabNewSpan = eNewDiv.getElementsByTagName('span');
  2369. if (!tabNewSpan) return;
  2370. window.console.log('tabNewSpan lg=' + tabNewSpan.length);
  2371. if (tabNewSpan.length == 0) return;
  2372. tabNewSpan.forEach(function(pSpan) {
  2373. if (pSpan.getElementsByTagName('span').length > 0) return;
  2374. window.console.log('newSpan old text=' + pSpan.innerText);
  2375. while (pSpan.firstChild) pSpan.removeChild(pSpan.firstChild); // vider
  2376. pSpan.appendChild(document.createTextNode(texte));
  2377. });
  2378. var tabNewInput = eNewDiv.getElementsByTagName('input');
  2379. if (!tabNewInput) return;
  2380. var eNewInput = tabNewInput[0];
  2381. if (!eNewInput) return;
  2382. eNewInput.removeAttr('onclick');
  2383. eNewInput.onClick = onClick;
  2384. eNewInput.value = texte;
  2385. eNewInput.type = "button";
  2386. var eForm = eDiv.parentNode;
  2387. window.console.log("insertButtonCdmSmartphone tag eNewDiv=" + eNewDiv.nodeName + ', parent tag=' + eForm.nodeName);
  2388. eForm.insertBefore(eNewDiv, eForm.firstChild);
  2389. return true;
  2390. }
  2391. */
  2392.  
  2393. function insertButtonCdm(nextName,onClick,texte) {
  2394. if (texte==null) texte = 'Participer au bestiaire';
  2395. //if (insertButtonCdmSmartphone(nextName,onClick,texte)) return;
  2396.  
  2397. var nextNode = document.getElementsByName(nextName)[0];
  2398. var espace = document.createTextNode('\t');
  2399. insertBefore(nextNode,espace);
  2400.  
  2401. var button = document.createElement('input');
  2402. button.type = 'button';
  2403. button.className = 'mh_form_submit';
  2404. button.value = texte;
  2405. button.onmouseover = function(){this.style.cursor='pointer';};
  2406. if (onClick) button.onclick = onClick;
  2407. insertBefore(espace,button);
  2408. return button;
  2409. }
  2410.  
  2411. function createCDMTable(id,nom,donneesMonstre, closeFunct) { // rend un Élément Table
  2412. try {
  2413. var table = document.createElement('table');
  2414. var profilActif = isProfilActif();
  2415. table.className = 'mh_tdborder';
  2416. table.border = 0;
  2417. table.cellSpacing = 1;
  2418. table.cellPadding = 4;
  2419.  
  2420. var thead = document.createElement('thead');
  2421. var tr = appendTr(thead,'mh_tdtitre');
  2422. var td = appendTdText(tr, 'CDM de ' + nom + ' (N° '+ id + ')', false);
  2423. td.style.fontWeight = 'bold';
  2424. if (closeFunct) {
  2425. td.colSpan = 2;
  2426. td.style.borderRight = 'none';
  2427. td = appendTdText(tr, 'X', false);
  2428. td.style.cursor = 'pointer';
  2429. td.style.textAlign = 'right';
  2430. td.style.fontWeight = 'bold';
  2431. td.style.width = '1%';
  2432. td.style.borderLeft = 'none';
  2433. td.onclick = closeFunct;
  2434. } else {
  2435. td.colSpan = 3;
  2436. }
  2437. table.appendChild(thead);
  2438. var tbody = document.createElement('tbody');
  2439. table.appendChild(tbody);
  2440.  
  2441. // calcul des PX gagnés
  2442. var ominmaxPX = {};
  2443. if (donneesMonstre.niv) {
  2444. if (donneesMonstre.niv.min) ominmaxPX.min = getPXKill(donneesMonstre.niv.min);
  2445. if (donneesMonstre.niv.max) ominmaxPX.max = getPXKill(donneesMonstre.niv.max);
  2446. }
  2447.  
  2448. MZ_tab_carac_add_tr_minmax2(tbody, 'Niveau', donneesMonstre.niv, 'PX', ominmaxPX);
  2449. MZ_tab_carac_add_tr_texte(tbody, 'Famille', donneesMonstre.fam, '');
  2450. //MZ_tab_carac_add_tr_texte(tbody, 'Génération', donneesMonstre.gen == 23 ? '2 ou 3' : donneesMonstre.gen, ''); // remplacé par une icône
  2451. MZ_tab_carac_add_tr_texte(tbody, 'Blessure', MZ_tab_carac_mkBlessureTexte(donneesMonstre), '');
  2452. MZ_tab_carac_add_tr_minmax(tbody, 'Points de Vie', donneesMonstre.pv, 'PV');
  2453. MZ_tab_carac_add_tr_minmax(tbody, 'Attaque', donneesMonstre.att, 'D6');
  2454. MZ_tab_carac_add_tr_minmax(tbody, 'Esquive', donneesMonstre.esq, 'D6');
  2455. MZ_tab_carac_add_tr_minmax(tbody, 'Dégâts', donneesMonstre.deg, 'D3');
  2456. MZ_tab_carac_add_tr_minmax(tbody, 'Régénération', donneesMonstre.reg, 'D3');
  2457. MZ_tab_carac_add_tr_minmax(tbody, 'Armure physique', donneesMonstre.armP, '');
  2458. MZ_tab_carac_add_tr_minmax(tbody, 'Armure magique', donneesMonstre.armM, '');
  2459. MZ_tab_carac_add_tr_minmax(tbody, 'Armure totale', donneesMonstre.arm, '');
  2460. MZ_tab_carac_add_tr_minmax(tbody, 'Vue', donneesMonstre.vue, 'Case(s)');
  2461. MZ_tab_carac_add_tr_minmax(tbody, 'MM', donneesMonstre.MM, '');
  2462. MZ_tab_carac_add_tr_minmax(tbody, 'RM', donneesMonstre.RM, '');
  2463. MZ_tab_carac_add_tr_minmax(tbody, 'Durée du tour', donneesMonstre.duree, ' heures');
  2464. MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre);
  2465. MZ_tab_carac_add_tr_autres(tbody, donneesMonstre, id, nom);
  2466. /* à supprimer, remplacé par un "title" sur le 3e td de "autres"
  2467. var msgInfo = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2468. if (msgInfo) MZ_tab_carac_add_tr_sansTitre(tbody, msgInfo, 0, true);
  2469. */
  2470. return table;
  2471. }
  2472. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2473. }
  2474.  
  2475. function MZ_tab_carac_mkBlessureTexte(donneesMonstre) {
  2476. if (donneesMonstre.bless === undefined) return;
  2477. var texte = donneesMonstre.bless + '%';
  2478. if (donneesMonstre.bless > 0 && donneesMonstre.pv && donneesMonstre.pv.min && donneesMonstre.pv.max) {
  2479. ominmax = MZ_getPVsRestants(donneesMonstre.pv, donneesMonstre.bless);
  2480. texte += ' (' + ominmax.min + '-' + ominmax.max + ')';
  2481. }
  2482. if (donneesMonstre.timegmt) {
  2483. texte += ' le ' + MZ_formatDateMS(new Date(donneesMonstre.timegmt * 1000), true);
  2484. }
  2485. return texte;
  2486. }
  2487.  
  2488. function MZ_tab_carac_add_tr_sansTitre(table, msg, bItalic) {
  2489. if (!msg) return;
  2490. var tr = appendTr(table,'mh_tdpage');
  2491. td = appendTdText(tr,msg);
  2492. td.colSpan = 3;
  2493. if (bItalic) td.style.fontStyle = 'italic';
  2494. td.className = 'mh_tdpage';
  2495. return td;
  2496. }
  2497.  
  2498. function MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre) {
  2499. if (!donneesMonstre.pouv) return;
  2500. var td = MZ_tab_carac_add_tr_texte(tbody, 'Pouvoir', donneesMonstre.pouv + ' ', '', 0);
  2501. var tabImg = [];
  2502. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.portpouv, {
  2503. 'de zone': ["zone.gif","Pouvoir de zone"],
  2504. 'automatique': ["automatique.gif","Pouvoir automatique"],
  2505. 'au toucher': ["toucher.gif","Pouvoir au toucher"]});
  2506. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2507. var thisImg = tabImg[iImg];
  2508. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2509. }
  2510. }
  2511.  
  2512. function MZ_tab_carac_add_tr_autres(table, donneesMonstre, id, nom) {
  2513. var tabImg = [];
  2514. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attd, {
  2515. '1': ["distance.gif","Attaque à distance"],
  2516. '~': ["cac.gif","Corps à corps"]}); // si absent
  2517. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.nb_att, {
  2518. '1': ["1.gif","1 attaque par tour"],
  2519. '2': ["2.gif","2 attaques par tour"],
  2520. '3': ["3.gif","3 attaques par tour"],
  2521. '4': ["4.gif","4 attaques par tour"],
  2522. '5': ["5.gif","5 attaques par tour"],
  2523. '6': ["6.gif","6 attaques par tour"],
  2524. '999': ["plus.gif","Beaucoup d'attaques par tour"]});
  2525. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attm, {
  2526. '1': ["magic-wand.png","Attaque magique"]});
  2527. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vit, {
  2528. 'lente': ["lent.gif","Lent à se déplacer"],
  2529. 'normale': ["normal.gif","Vitesse normale de déplacement"],
  2530. 'rapide': ["rapide.gif","Déplacement rapide"]});
  2531. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.charg, {
  2532. 'vide': [null,null],
  2533. '~': ["charge2.gif", "Possède de l'équipement (" + donneesMonstre.charg + ")"]});
  2534. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vlc, {
  2535. '1': ["oeil.gif","Voit le caché"]});
  2536. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.gen, {
  2537. '1': ["Phoenix1.png","Phœnix de première génération"],
  2538. '2': ["Phoenix2.png","Phœnix de deuxième génération"],
  2539. '3': ["Phoenix3.png","Phœnix de troisième génération"],
  2540. '23': ["Phoenix23.png","Phœnix de deuxième ou troisième génération"],
  2541. });
  2542.  
  2543. var tr = appendTr(table,'mh_tdpage');
  2544. var td = appendTdText(tr,'Autres',true);
  2545. td.className = 'mh_tdtitre';
  2546. td.width = MZ_EtatCdMs.tdWitdh;
  2547.  
  2548. td = appendTd(tr);
  2549. td.className = 'mh_tdpage';
  2550. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2551. var thisImg = tabImg[iImg];
  2552. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2553. }
  2554. if (donneesMonstre.esq != undefined) {
  2555. td.appendChild(MZ_Tactique.createImage(id, nom));
  2556. }
  2557.  
  2558. var txt = String.fromCharCode(160); // blanc insécable
  2559. if (donneesMonstre.nCdM) txt = donneesMonstre.nCdM;
  2560. var td2 = appendTdText(tr, txt);
  2561. td2.title = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2562. td2.style.width = '1%';
  2563. var myColor = MZ_CdMColorFromMode(donneesMonstre);
  2564. if (myColor) {
  2565. td2.style.backgroundColor = myColor;
  2566. td2.style.color = 'white';
  2567. }
  2568.  
  2569. return td;
  2570. }
  2571.  
  2572. function MZ_tab_carac_add_tr_one_img(tabImg, val, listCas) {
  2573. if (val == undefined) return;
  2574. //console.log('MZ_tab_carac_add_tr_one_img: val=' + val);
  2575. var lVal = (val + '').toLowerCase(); // astuce : transformer le nombre en string (beurk !)
  2576. if (listCas[lVal]) {
  2577. var t = listCas[lVal];
  2578. if (t[0] == null) return;
  2579. tabImg.push(t);
  2580. } else if (listCas['~']) {
  2581. tabImg.push(listCas['~']);
  2582. }
  2583. }
  2584.  
  2585. function MZ_tab_carac_add_tr_texte(table, titre, msg, unit) {
  2586. if (!msg) return;
  2587. var tr = appendTr(table,'mh_tdpage');
  2588.  
  2589. var td = appendTdText(tr,titre,true);
  2590. td.className = 'mh_tdtitre';
  2591. td.width = MZ_EtatCdMs.tdWitdh;
  2592.  
  2593. var texte = msg;
  2594. if (unit) texte += ' ' + unit;
  2595. td = appendTdText(tr,texte);
  2596. td.colSpan = 2;
  2597. td.className = 'mh_tdpage';
  2598. return td;
  2599. }
  2600.  
  2601. function MZ_tab_carac_add_tr_minmax(table, titre, ominmax, unit) {
  2602. if (!ominmax) return;
  2603. if (!(ominmax.min || ominmax.max)) return;
  2604.  
  2605. var tr = appendTr(table,'mh_tdpage');
  2606.  
  2607. var td = appendTdText(tr,titre,true);
  2608. td.className = 'mh_tdtitre';
  2609. td.width = MZ_EtatCdMs.tdWitdh;
  2610.  
  2611. if ((!ominmax.min) || ominmax.min == 0) {
  2612. var texte = '\u2A7D' + ominmax.max + '\u00A0' + unit; // <= (mais plus beau)
  2613. } else if (!ominmax.max) {
  2614. var texte = '\u2A7E' + ominmax.min + '\u00A0' + unit; // >=
  2615. } else {
  2616. var texte = '';
  2617. if (ominmax.min != ominmax.max) {
  2618. var texte = ominmax.min + '-' + ominmax.max + '\u00A0-->\u00A0';
  2619. if (ominmax.min > ominmax.max) {
  2620. td.style.color = 'red';
  2621. unit += ' *** erreur ***';
  2622. }
  2623. }
  2624. texte += ((ominmax.min + ominmax.max)/2) + '\u00A0' + unit;
  2625. }
  2626. td = appendTdText(tr,texte);
  2627. if (ominmax.min2 || ominmax.max2) { // affichage de l'intervalle de confiance à 80%
  2628. if (!ominmax.min2) {
  2629. var txt2 = '\u2A7D' + ominmax.max2; // <= (mais plus beau)
  2630. } else if (!ominmax.max2) {
  2631. var txt2 = '\u2A7E' + ominmax.min2; // >=
  2632. } else {
  2633. var txt2 = ominmax.min2 + '-' + ominmax.max2;
  2634. }
  2635. var span = document.createElement('span');
  2636. span.appendChild(document.createTextNode(txt2));
  2637. span.style.float = 'right';
  2638. span.style.textAlign = 'right';
  2639. span.style.background = 'yellow';
  2640. td.insertBefore(span, td.firstChild);
  2641. table.title = 'En jaune : intervalle de confiance à 80%';
  2642. }
  2643. td.colSpan = 2;
  2644. td.className = 'mh_tdpage';
  2645. return td;
  2646. }
  2647.  
  2648. function MZ_tab_carac_add_tr_minmax2(table, titre, ominmax, unit, ominmaxUnit) {
  2649. if (!ominmax) return;
  2650. if (!(ominmax.min || ominmax.max)) return;
  2651.  
  2652. var tr = appendTr(table,'mh_tdpage');
  2653.  
  2654. var td = appendTdText(tr,titre,true);
  2655. td.className = 'mh_tdtitre';
  2656. td.width = MZ_EtatCdMs.tdWitdh;
  2657.  
  2658. if ((!ominmax.min) || ominmax.min == 0) {
  2659. var texte = '\u2A7D' + ominmax.max;
  2660. } else if (!ominmax.max) {
  2661. var texte = '\u2A7E' + ominmax.min;
  2662. } else {
  2663. var texte = '';
  2664. if (ominmax.min != ominmax.max) {
  2665. var texte = ominmax.min + '-' + ominmax.max;
  2666. if (ominmax.min > ominmax.max) {
  2667. td.style.color = 'red';
  2668. texte += ' *** erreur ***';
  2669. }
  2670. } else {
  2671. var texte = ominmax.min;
  2672. }
  2673. }
  2674.  
  2675. if (ominmaxUnit.min === undefined) {
  2676. if (ominmaxUnit.max === undefined) {
  2677. // ignore (ne devrait pas arriver)
  2678. } else {
  2679. texte += ' --> ' + unit + '\u2A7D' + ominmaxUnit.max;
  2680. }
  2681. } else {
  2682. if (ominmaxUnit.max === undefined) {
  2683. texte += ' --> ' + unit + '\u2A7E' + ominmaxUnit.min;
  2684. } else if (ominmaxUnit.min != ominmaxUnit.max) {
  2685. texte += ' --> ' + ominmaxUnit.min + '\u2A7D' + unit + '\u2A7D' + ominmaxUnit.max;
  2686. if (ominmaxUnit.min > ominmaxUnit.max) {
  2687. td.style.color = 'red';
  2688. texte += ' *** erreur ***';
  2689. }
  2690. } else if (isNaN(ominmaxUnit.min)) {
  2691. texte += ' --> ' + ominmaxUnit.min;
  2692. } else {
  2693. texte += ' --> ' + ominmaxUnit.max + '\u00A0' + unit;
  2694. }
  2695. }
  2696.  
  2697. td = appendTdText(tr,texte);
  2698. td.colSpan = 2;
  2699. td.className = 'mh_tdpage';
  2700. return td;
  2701. }
  2702.  
  2703.  
  2704. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2705.  
  2706. var listeMonstreEnchantement = null,
  2707. listeEquipementEnchantement = null,
  2708. listeInfoEnchantement = null;
  2709.  
  2710. function computeCompoEnchantement()
  2711. {
  2712. listeMonstreEnchantement = new Array();
  2713. listeInfoEnchantement = new Array();
  2714. listeEquipementEnchantement = new Array();
  2715. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2716. for(var i=0;i<liste.length;i++)
  2717. {
  2718. var idEquipement = liste[i]*1;
  2719. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2720. continue;
  2721. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2722. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2723. var texteGlobal='';
  2724. for(var j=0;j<3;j++)
  2725. {
  2726. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2727. var v = MY_getValue(k);
  2728. var infoComposant = MY_getValue().split(';');
  2729. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2730. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2731. continue;
  2732. }
  2733. listeMonstreEnchantement[infoComposant[2]] = 1;
  2734. var array = new Array();
  2735. array[0]=infoComposant[0].replace("Ril","Œil");
  2736. array[1]=infoComposant[1];
  2737. array[2]=infoComposant[2];
  2738. array[3]=getQualite(infoComposant[3]);
  2739. var texte = infoComposant[4].replace("Ril","Œil");
  2740. for(var k=5;k<infoComposant.length;k++)
  2741. {
  2742. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2743. }
  2744. texteGlobal+=texte+'\n';
  2745. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2746. array[4]=texte;
  2747. listeInfoEnchantement.push(array);
  2748. }
  2749. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2750. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2751. }
  2752.  
  2753. }
  2754.  
  2755. function isEnchant(nom) {
  2756. var monstreEnchant = '';
  2757. for(j in listeInfoEnchantement) {
  2758. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2759. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2760. monstreEnchant=monstre;
  2761. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2762. }
  2763. }
  2764. return trim(monstreEnchant);
  2765. }
  2766.  
  2767. function getInfoEnchantementFromMonstre(nom)
  2768. {
  2769. try
  2770. {
  2771. if(!listeMonstreEnchantement)
  2772. {
  2773. computeCompoEnchantement();
  2774. }
  2775. var infosEnchant = '';
  2776. for(j in listeInfoEnchantement) {
  2777. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2778. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2779. if(infosEnchant=='')
  2780. infosEnchant=listeInfoEnchantement[j][4];
  2781. else
  2782. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2783. }
  2784. }
  2785. return trim(infosEnchant);
  2786. }
  2787. catch(e)
  2788. {
  2789. window.alert(e);
  2790. }
  2791. }
  2792.  
  2793. function composantEnchant(Monstre,composant,localisation,qualite) {
  2794. var compo='';
  2795. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2796. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2797. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2798. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2799. listeInfoEnchantement[i][3]<=qualite
  2800. ) {
  2801. return listeInfoEnchantement[i][4];
  2802. }
  2803. }
  2804. return compo;
  2805. }
  2806.  
  2807. function insertEnchantInfos(tbody) {
  2808. try
  2809. {
  2810. if(!listeMonstreEnchantement)
  2811. computeCompoEnchantement();
  2812. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2813. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2814. if(nodes.snapshotLength == 0)
  2815. return false;
  2816. var urlImg = URL_MZimg + 'enchant.png';
  2817. for(var i = 0; i < nodes.snapshotLength; i++) {
  2818. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2819. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2820. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2821. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2822. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2823. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2824. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2825. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2826. if(isEnchant(nomMonstre).length>0)
  2827. {
  2828. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2829. if(infos.length>0)
  2830. {
  2831. if(link.parentNode == link.nextSibling.parentNode)
  2832. {
  2833. var tmp = link.nextSibling;
  2834. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2835. }
  2836. else
  2837. {
  2838. link.parentNode.appendChild(createImage(urlImg,infos));
  2839. }
  2840. }
  2841. }
  2842. }
  2843. }
  2844. catch(e)
  2845. {
  2846. window.alert(e);
  2847. }
  2848. }
  2849.  
  2850. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2851. {
  2852. try
  2853. {
  2854. if(!listeMonstreEnchantement)
  2855. computeCompoEnchantement();
  2856. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2857. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2858. if(nodes.snapshotLength == 0)
  2859. return false;
  2860. var urlImg = URL_MZimg + 'enchant.png';
  2861. for(var i = 0; i < nodes.snapshotLength; i++)
  2862. {
  2863. var link = nodes.snapshotItem(i);
  2864. var idEquipement = link.getAttribute('href');
  2865. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2866. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2867. var nomEquipement = trim(link.firstChild.nodeValue);
  2868. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2869. if(!enchanteur || enchanteur == '')
  2870. continue;
  2871. var infos = listeEquipementEnchantement[idEquipement];
  2872. infos=formateTexte(infos);
  2873. if(infos.length>0)
  2874. {
  2875. if(link.parentNode == link.nextSibling.parentNode)
  2876. {
  2877. var tmp = link.nextSibling;
  2878. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2879. }
  2880. else
  2881. {
  2882. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2883. }
  2884. }
  2885. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2886. }
  2887. }
  2888. catch(e)
  2889. {
  2890. window.alert(e);
  2891. }
  2892. }
  2893.  
  2894. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2895. // Cette section est commune à InfoMonstre et Vue
  2896.  
  2897. var MZ_Tactique = {
  2898. // Variables
  2899. popup: null,
  2900.  
  2901. // Méthodes
  2902. createImage: function(id, nom) {
  2903. // Création de l'image portant le popup tactique
  2904. var img = document.createElement('img');
  2905. img.src = URL_MZimg +
  2906. (isPage('View/MonsterView') ? 'calc.png' : 'calc2.png');
  2907. img.id = id;
  2908. img.nom = nom;
  2909. img.style.verticalAlign = 'middle';
  2910. img.onmouseover = MZ_Tactique.showPopup;
  2911. img.onmouseout = MZ_Tactique.hidePopup;
  2912. return img;
  2913. },
  2914.  
  2915. hidePopup: function() {
  2916. // Masquage du popup tactique
  2917. MZ_Tactique.popup.style.display = 'none';
  2918. },
  2919.  
  2920. initPopup: function() {
  2921. /** @mandatory Initialisation du popup tactique */
  2922. MZ_Tactique.popup = document.createElement('div');
  2923. MZ_Tactique.popup.id = 'MZ_Tactique.popup';
  2924. MZ_Tactique.popup.className = 'mh_textbox';
  2925. MZ_Tactique.popup.style =
  2926. 'position: absolute;' +
  2927. 'border: 1px solid #000000;' +
  2928. 'display: none;' +
  2929. 'z-index: 3;' +
  2930. 'max-width: 400px;';
  2931. document.body.appendChild(MZ_Tactique.popup);
  2932. },
  2933.  
  2934. showPopup: function(evt) {
  2935. // Affichage du popup tactique
  2936. try {
  2937. var id = this.id;
  2938. var nom = this.nom;
  2939. var texte = getAnalyseTactique(id, nom);
  2940. if (texte == undefined || texte == '') return;
  2941. MZ_Tactique.popup.innerHTML = texte;
  2942. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  2943. if (isPage('View/MonsterView')) {
  2944. MZ_Tactique.popup.style.left = Math.min(evt.pageX - 120, window.innerWidth - 300) + 'px';
  2945. } else {
  2946. MZ_Tactique.popup.style.left = Math.min(evt.pageX + 15, window.innerWidth - 400) + 'px';
  2947. }
  2948. MZ_Tactique.popup.style.top = evt.pageY + 15 + 'px';
  2949. MZ_Tactique.popup.style.display = 'block';
  2950. } catch (e) {
  2951. // window.alert(e);
  2952. window.console.error(e);
  2953. }
  2954. }
  2955. };
  2956.  
  2957. // Les % de toucher
  2958. var c = new Array();
  2959.  
  2960. // coefficients binomiaux
  2961. function cnp(n,k)
  2962. {
  2963. if(c[n] != null && c[n][k] != null)
  2964. return c[n][k];
  2965. if(c[n] == null)
  2966. c[n] = new Array();
  2967. if(k==0)
  2968. {
  2969. c[n][k] = 1;
  2970. return 1;
  2971. }
  2972. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2973. c[n][k] = result;
  2974. // Roule debug
  2975. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2976. return result;
  2977. }
  2978.  
  2979. // by Dab, à comparer
  2980. function binom(n,p) {
  2981. if(p<0 || p>n) return 0;
  2982.  
  2983. if(c[n])
  2984. if(c[n][p]) return c[n][p];
  2985. else {
  2986. c[n]=[1];
  2987. c[n][n]=1;
  2988. if(p==0 || p==n) return 1;
  2989. }
  2990.  
  2991. if(2*p>n)
  2992. c[n][p]=binom(n,n-p);
  2993. else
  2994. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2995.  
  2996. return c[n][p];
  2997. }
  2998.  
  2999. var coeff = new Array();
  3000.  
  3001. function coef(n,p)
  3002. {
  3003. if(n==0 && p==0)
  3004. return 1;
  3005. if(p>n*3.5)
  3006. p = 7*n-p
  3007. // roule désactive cache
  3008. if(coeff[n] != null && coeff[n][p] !=null)
  3009. return coeff[n][p];
  3010. if(coeff[n] == null)
  3011. coeff[n] = new Array();
  3012. var kmax = Math.floor((p-n)/6);
  3013. var x=0;
  3014. for(var k=0;k<=kmax;k++)
  3015. {
  3016. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  3017. }
  3018. coeff[n][p] = x;
  3019. // Roule debug
  3020. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  3021. return x;
  3022. }
  3023.  
  3024. function chanceEsquiveParfaite(a,d,ba,bd)
  3025. {
  3026. var win = 0;
  3027. var los = 0;
  3028. if(ba==null)
  3029. ba=0;
  3030. if(bd==null)
  3031. bd=0;
  3032. /* if(6*a+ba<2*(d+bd))
  3033. return 100;
  3034. if(a+ba>2*(6*d+bd))
  3035. return 0;*/
  3036. for(var ds=d;ds<=6*d;ds++)
  3037. {
  3038. var cd = coef(d,ds);
  3039. for(var as=a;as<=6*a;as++)
  3040. {
  3041. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  3042. win += cd * coef(a,as);
  3043. else
  3044. los += cd * coef(a,as);
  3045. }
  3046. }
  3047. // roule debug
  3048. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  3049. return Math.round(100*win/(win+los));
  3050. }
  3051.  
  3052. function chanceTouche(a,d,ba,bd)
  3053. {
  3054. var win = 0;
  3055. var los = 0;
  3056. if(ba==null)
  3057. ba=0;
  3058. if(bd==null)
  3059. bd=0;
  3060. if(a+ba>6*d+bd)
  3061. return 100;
  3062. if(6*a+ba<d+bd)
  3063. return 0;
  3064. for(var ds=d;ds<=6*d;ds++)
  3065. {
  3066. var cd = coef(d,ds);
  3067. for(var as=a;as<=6*a;as++)
  3068. {
  3069. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  3070. win += cd * coef(a,as);
  3071. else
  3072. los += cd * coef(a,as);
  3073. }
  3074. }
  3075. return Math.round(100*win/(win+los));
  3076. }
  3077.  
  3078. function chanceCritique(a,d,ba,bd)
  3079. {
  3080. var win = 0;
  3081. var los = 0;
  3082. if(ba==null)
  3083. ba=0;
  3084. if(bd==null)
  3085. bd=0;
  3086. if(a+ba>2*(6*d+bd))
  3087. return 100;
  3088. if(6*a+ba<2*(d+bd))
  3089. return 0;
  3090. for(var ds=d;ds<=6*d;ds++)
  3091. {
  3092. var cd = coef(d,ds);
  3093. for(var as=a;as<=6*a;as++)
  3094. {
  3095. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  3096. win += cd * coef(a,as);
  3097. else
  3098. los += cd * coef(a,as);
  3099. }
  3100. }
  3101. return Math.round(100*win/(win+los));
  3102. }
  3103.  
  3104. /***********************************************
  3105. Analyse tactique
  3106. ***********************************************/
  3107.  
  3108. function getTexteAnalyse(modificateur,chiffre)
  3109. {
  3110. if(chiffre==0)
  3111. return chiffre;
  3112. return modificateur+ chiffre;
  3113. }
  3114.  
  3115. // rend le HTML pour le tableau de la "calculette"
  3116. function getAnalyseTactique(id,nom) {
  3117. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  3118. var needAutres=false;
  3119. var i;
  3120. if(donneesMonstre == null)
  3121. return;
  3122. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  3123. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  3124. if(array==null)
  3125. return "";
  3126. 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>";
  3127. for(i=0;i<array.length;i++)
  3128. {
  3129. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  3130. {
  3131. needAutres=true;
  3132. break;
  3133. }
  3134. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  3135. 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>";
  3136. else if(i==0) // attaque du monstre sur le Trõll => italique
  3137. 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>";
  3138. else // autre, pas de décoration
  3139. 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>";
  3140. }
  3141. if(needAutres)
  3142. {
  3143. if(i==array.length-1)
  3144. 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>";
  3145. else if(i==1)
  3146. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  3147. else
  3148. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  3149. }
  3150. var txtCdM = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  3151. if (txtCdM) str += '<tr class="mh_tdpage"><td colspan="5" style="font-style: italic;">' + txtCdM + '</td></tr>';
  3152. return str+"</table>";
  3153. }
  3154.  
  3155. function MZ_carac_build_nb_cmd_msg(donneesMonstre) {
  3156. if (!donneesMonstre) return;
  3157. if (!donneesMonstre.Mode) return;
  3158. switch (donneesMonstre.Mode) {
  3159. case 'cdm':
  3160. return 'fondé sur ' + (+donneesMonstre.nCdM) + ' CdM' + (donneesMonstre.nCdM > 1 ? 's' : '') + ' de ce monstre à cet âge';
  3161. case 'stat':
  3162. 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)';
  3163. case 'statV1':
  3164. return 'fondé sur les statistiques anciennes (MZ V1)';
  3165. case 'nom':
  3166. return 'fondé sur le nom du monstre, pas de CdM';
  3167. }
  3168. return 'Mode ' + donneesMonstre.Mode;
  3169. }
  3170.  
  3171. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  3172. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  3173. function analyseTactique(donneesMonstre,nom) {
  3174. try
  3175. {
  3176. var listeAttaques = [];
  3177. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  3178. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  3179. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  3180. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  3181. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  3182. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  3183. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  3184. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  3185. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  3186. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  3187. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  3188. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  3189. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  3190. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  3191. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  3192. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  3193. var modificateurEsquive = '';
  3194. var modificateurArmure = '';
  3195. var modificateurMagie = '';
  3196. var modificateurEsquiveM = '';
  3197. var modificateurArmureM = '';
  3198. var pasDeSR=false;
  3199. var esqM=0,attM=0,armM_mag=0,armM_tot=0,degM=0;
  3200. 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)
  3201. return null;
  3202.  
  3203. if (MY_DEBUG) window.console.log('analyseTactique nom=' + nom + ' ' + JSON.stringify(donneesMonstre));
  3204. if (donneesMonstre.index == undefined) {
  3205. // à supprimer
  3206. var td = document.createElement('td')
  3207. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  3208. var esqM = 0;
  3209. try
  3210. {
  3211. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3212. }
  3213. catch(e)
  3214. {
  3215. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  3216. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3217. modificateurEsquive = '<';
  3218. modificateurArmure = '<';
  3219. modificateurMagie = '<';
  3220. }
  3221.  
  3222. td.innerHTML = bbcode(donneesMonstre[3]);
  3223. var attM = 0;
  3224. try
  3225. {
  3226. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3227. }
  3228. catch(e)
  3229. {
  3230. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  3231. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3232. modificateurEsquiveM = '>';
  3233. modificateurArmureM = '>';
  3234. }
  3235.  
  3236. td.innerHTML = bbcode(donneesMonstre[5]);
  3237. var degM = 0;
  3238. try
  3239. {
  3240. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3241. }
  3242. catch(e)
  3243. {
  3244. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  3245. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3246. modificateurArmureM = '>';
  3247. }
  3248.  
  3249. td.innerHTML = bbcode(donneesMonstre[7]);
  3250. try
  3251. {
  3252. armM_tot=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3253. armM_mag=armM_tot; // compatibilité avec ancien calcul
  3254. }
  3255. catch(e)
  3256. {
  3257. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  3258. armM_tot=Math.ceil(parseInt(td.firstChild.nodeValue));
  3259. armM_mag=armM_tot;
  3260. modificateurArmure = '<';
  3261. }
  3262.  
  3263. var coeffSeuil = 0.95;
  3264. try
  3265. {
  3266. td.innerHTML = bbcode(donneesMonstre[9]);
  3267. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  3268. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3269. var v = (rm / mm);
  3270. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3271. coeffSeuil = (200-seuil)/200;
  3272. }
  3273. catch(e)
  3274. {
  3275. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  3276. modificateurMagie = '<';
  3277. pasDeSR = true;
  3278. }
  3279. } else {
  3280. //calcul de modificateurEsquive, modificateurArmure, modificateurMagie, modificateurEsquiveM, modificateurArmureM, pasDeSR, esqM, attM, armM_mag, armM_tot, degM;
  3281. if (donneesMonstre.esq) {
  3282. if (donneesMonstre.esq.min && donneesMonstre.esq.max) {
  3283. esqM = Math.ceil((donneesMonstre.esq.min + donneesMonstre.esq.max) / 2);
  3284. } else if (donneesMonstre.esq.max) {
  3285. esqM = donneesMonstre.esq.max;
  3286. modificateurEsquive = '<';
  3287. modificateurArmure = '<';
  3288. modificateurMagie = '<';
  3289. }
  3290. }
  3291.  
  3292. if (donneesMonstre.att) {
  3293. if (donneesMonstre.att.min && donneesMonstre.att.max) {
  3294. attM = Math.ceil((donneesMonstre.att.min + donneesMonstre.att.max) / 2);
  3295. } else if (donneesMonstre.att.max) {
  3296. attM = donneesMonstre.att.max;
  3297. modificateurEsquiveM = '>';
  3298. modificateurArmureM = '>';
  3299. }
  3300. }
  3301.  
  3302. if (donneesMonstre.armM) {
  3303. if (donneesMonstre.armM.min && donneesMonstre.armM.max) {
  3304. armM_mag = Math.ceil((donneesMonstre.armM.min + donneesMonstre.armM.max) / 2);
  3305. } else if (donneesMonstre.armM.max) {
  3306. armM_mag = donneesMonstre.armM.max;
  3307. modificateurArmure = '<';
  3308. }
  3309. if (donneesMonstre.armP) {
  3310. if (donneesMonstre.armP.min && donneesMonstre.armP.max) {
  3311. armM_phy = Math.ceil((donneesMonstre.armP.min + donneesMonstre.armP.max) / 2);
  3312. } else if (donneesMonstre.armP.max) {
  3313. armM_phy = donneesMonstre.armP.max;
  3314. modificateurArmure = '<';
  3315. }
  3316. armM_tot = armM_mag + armM_phy;
  3317. } else { // ça ne devrait pas arriver
  3318. armM_tot = armM_mag;
  3319. }
  3320. } else if (donneesMonstre.arm) {
  3321. if (donneesMonstre.arm.min && donneesMonstre.arm.max) {
  3322. armM_tot = Math.ceil((donneesMonstre.arm.min + donneesMonstre.arm.max) / 2);
  3323. armM_mag=armM_tot; // worst case
  3324. } else if (donneesMonstre.arm.max) {
  3325. armM_tot = donneesMonstre.arm.max;
  3326. armM_mag=armM_tot;
  3327. modificateurArmure = '<';
  3328. }
  3329. }
  3330.  
  3331. if (donneesMonstre.deg) {
  3332. if (donneesMonstre.deg.min && donneesMonstre.deg.max) {
  3333. degM = Math.ceil((donneesMonstre.deg.min + donneesMonstre.deg.max) / 2);
  3334. } else if (donneesMonstre.deg.max) {
  3335. degM = donneesMonstre.deg.max;
  3336. modificateurArmureM = '>';
  3337. }
  3338. }
  3339.  
  3340. var coeffSeuil = 0.95;
  3341. if (donneesMonstre.RM) {
  3342. if (donneesMonstre.RM.min && donneesMonstre.RM.max) {
  3343. var rmM = Math.ceil((donneesMonstre.RM.min + donneesMonstre.RM.max) / 2);
  3344. var v = (rmM / mm);
  3345. var seuil = (rmM < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3346. coeffSeuil = (200-seuil)/200;
  3347. } else if (donneesMonstre.deg.max) {
  3348. }
  3349. modificateurMagie = '<';
  3350. pasDeSR = true;
  3351. }
  3352. }
  3353. 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);
  3354.  
  3355. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  3356. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  3357. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  3358. // roule debug
  3359. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  3360. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  3361. 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);
  3362. //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);
  3363. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3364. if(getSortComp("Vampirisme")>0)
  3365. {
  3366. var pour = getSortComp("Vampirisme");
  3367. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3368. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3369. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3370. 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;
  3371. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3372. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3373. }
  3374. if(getSortComp("Siphon des âmes")>0)
  3375. {
  3376. var pour = getSortComp("Siphon des âmes");
  3377. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3378. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3379. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3380. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm-armM_mag,1))/100);
  3381. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3382. }
  3383. if(getSortComp("Botte Secrète")>0)
  3384. {
  3385. var pour = getSortComp("Botte Secrète");
  3386. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3387. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3388. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3389. 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;
  3390. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3391. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3392. }
  3393. if(getSortComp("Rafale Psychique")>0)
  3394. {
  3395. var pour = getSortComp("Rafale Psychique");
  3396. chanceDEsquiveParfaite = 0;
  3397. chanceDeTouche = Math.round(100*pour/100);
  3398. chanceDeCritique = Math.round(0*pour/100);
  3399. 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;
  3400. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3401. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3402. }
  3403. if(getSortComp("Explosion")>0)
  3404. {
  3405. var pour = getSortComp("Explosion");
  3406. chanceDEsquiveParfaite = 0;
  3407. chanceDeTouche = Math.round(100*pour/100);
  3408. chanceDeCritique = Math.round(0*pour/100);
  3409. 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;
  3410. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3411. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3412. }
  3413. if(getSortComp("Projectile Magique")>0)
  3414. {
  3415. var pour = getSortComp("Projectile Magique");
  3416. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  3417. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  3418. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  3419. // distance troll - monstre
  3420. 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;
  3421. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3422. if (donneesMonstre.index !== undefined && MZ_EtatCdMs.tr_monstres !== undefined && MZ_EtatCdMs.tr_monstres[donneesMonstre.index] !== undefined) {
  3423. var dist = getMonstreDistance(donneesMonstre.index);
  3424. //if (isDEV) window.console.log('Dist pour PM=' + dist);
  3425. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  3426. var portee = getPortee(vue+vue_bm);
  3427. if (dist <= portee) {
  3428. degats = Math.round((degats + 2 * (portee-dist)) * 100) / 100;
  3429. } else {
  3430. degats += ' (plus bonus de portée)';
  3431. }
  3432. debugMZ('analyseTactique, iTR= ' + donneesMonstre.index + ', dist=' + dist + ', porteePM=' + portee);
  3433. } else {
  3434. degats += ' (plus bonus de portée)';
  3435. }
  3436. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3437. }
  3438. if(getSortComp("Frénésie")>0)
  3439. {
  3440. var pour = getSortComp("Frénésie");
  3441. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3442. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3443. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3444. 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;
  3445. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3446. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3447. }
  3448. if(getSortComp("Charger")>0)
  3449. {
  3450. var pour = getSortComp("Charger");
  3451. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3452. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3453. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3454. 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;
  3455. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3456. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3457. }
  3458. if(getSortComp("Griffe du Sorcier")>0)
  3459. {
  3460. var pour = getSortComp("Griffe du Sorcier");
  3461. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3462. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3463. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3464. 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;
  3465. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3466. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3467. }
  3468. if(getSortComp("Attaque Précise",1)>0)
  3469. {
  3470. var niveau = 5;
  3471. var oldPour = 0;
  3472. var chanceDEsquiveParfaite = 0;
  3473. var chanceDeTouche = 0;
  3474. var chanceDeCritique = 0;
  3475. degats = 0;
  3476. while(niveau>0)
  3477. {
  3478. var pour = getSortComp("Attaque Précise",niveau);
  3479. if(pour>oldPour)
  3480. {
  3481. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3482. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3483. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3484. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3485. chanceDeTouche += chanceDeToucheNiveau;
  3486. chanceDeCritique += chanceDeCritiqueNiveau;
  3487. 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);
  3488. oldPour = pour;
  3489. }
  3490. niveau--;
  3491. }
  3492. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3493. 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));
  3494. }
  3495. if(getSortComp("Coup de Butoir",1)>0)
  3496. {
  3497. var niveau = 5;
  3498. var oldPour =0;
  3499. var chanceDEsquiveParfaite = 0;
  3500. var chanceDeTouche=0;
  3501. var chanceDeCritique=0;
  3502. degats=0;
  3503. while(niveau>0)
  3504. {
  3505. var pour = getSortComp("Coup de Butoir",niveau);
  3506. if(pour>oldPour)
  3507. {
  3508. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3509. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3510. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3511. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3512. chanceDeTouche += chanceDeToucheNiveau;
  3513. chanceDeCritique += chanceDeCritiqueNiveau;
  3514. 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);
  3515. oldPour = pour;
  3516. }
  3517. niveau--;
  3518. }
  3519. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3520. 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));
  3521. }
  3522. 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;});
  3523. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  3524. {
  3525. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  3526. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  3527. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  3528. }
  3529. else
  3530. {
  3531. chanceDEsquiveParfaite = 0;
  3532. chanceDeTouche = 100;
  3533. chanceDeCritique = 0;
  3534. }
  3535. 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;
  3536.  
  3537. 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));
  3538. return listeAttaques;
  3539. }
  3540. catch(e) {
  3541. window.console.error(traceStack(e, 'analyseTactique'));
  3542. window.alert(e);
  3543. }
  3544. }
  3545.  
  3546. // x~~x marque pour s'y retrouver sous l'éditeur
  3547.  
  3548. /*
  3549. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  3550. * published under GNU License v2.
  3551. *
  3552. * Patch :
  3553. * gestion des missions terminées
  3554. */
  3555.  
  3556. // x~x mission_liste
  3557.  
  3558. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  3559. try {
  3560. var titresMimis = document.evaluate(
  3561. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  3562. document, null, 7, null
  3563. );
  3564. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3565. } catch(e) {
  3566. window.console.error(traceStack(e, 'mission_liste initialisation'));
  3567. return;
  3568. }
  3569.  
  3570. var enCours = {};
  3571. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  3572. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  3573. enCours[num] = true;
  3574. }
  3575.  
  3576. for(var numMimi in obMissions) {
  3577. if(!enCours[numMimi]) {
  3578. delete obMissions[numMimi];
  3579. }
  3580. }
  3581. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3582. }
  3583.  
  3584. function do_mission_liste() {
  3585. checkLesMimis();
  3586. }
  3587.  
  3588. /*******************************************************************************
  3589. * This file is part of Mountyzilla. *
  3590. * *
  3591. * Mountyzilla is free software; you can redistribute it and/or modify *
  3592. * it under the terms of the GNU General Public License as published by *
  3593. * the Free Software Foundation; either version 2 of the License, or *
  3594. * (at your option) any later version. *
  3595. * *
  3596. * Mountyzilla is distributed in the hope that it will be useful, *
  3597. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3598. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3599. * GNU General Public License for more details. *
  3600. * *
  3601. * You should have received a copy of the GNU General Public License *
  3602. * along with Mountyzilla; if not, write to the Free Software *
  3603. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3604. *******************************************************************************/
  3605.  
  3606. // x~x actions
  3607.  
  3608. /* TODO
  3609. * getLvl pour Explo, Rotobaffe et cie
  3610. */
  3611.  
  3612.  
  3613.  
  3614. /* Page de combat */
  3615.  
  3616. function getLevel() {
  3617. var divList = document.getElementsByTagName('div');
  3618. if(divList.length <= 2)
  3619. return;
  3620.  
  3621. // On essaie de voir si cette action était une attaque
  3622. var pList = document.getElementsByTagName('p');
  3623. var nomM = '';
  3624. // Modification pour Frénésie by TetDure
  3625. var numAtt = 0;
  3626. for (var i = 0; i < pList.length; i++) {
  3627. if(pList[i].firstChild) {
  3628. nomM = pList[i].firstChild.nodeValue;
  3629. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3630. numAtt++;
  3631. }
  3632. }
  3633.  
  3634. if(nomM == '')
  3635. return;
  3636.  
  3637. // Si c'est une attaque normale, un seul PX
  3638. var comPX = 1;
  3639. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3640. comPX++;
  3641.  
  3642. // Extraction des infos du monstre attaqué
  3643. var idM;
  3644. var male;
  3645. if(nomM.slice(20, 21) == 'e') {
  3646. male = false;
  3647. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3648. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3649. }
  3650. else {
  3651. male = true;
  3652. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3653. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3654. }
  3655.  
  3656. if(idM == '')
  3657. return;
  3658.  
  3659. var bList = document.getElementsByTagName('b');
  3660. var niveau = '';
  3661. for (var i = 0; i < bList.length; i++) {
  3662. var b = bList[i];
  3663. if(b.childNodes[0].nodeValue != "TUÉ")
  3664. continue;
  3665. var nbPX = "";
  3666. for (i++; i < bList.length; i++) {
  3667. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3668. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3669. return;
  3670. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3671. nbPX = bList[i].childNodes[0].nodeValue;
  3672. break;
  3673. }
  3674. }
  3675. if(nbPX == '')
  3676. return;
  3677. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3678. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3679. if(!nbPX)
  3680. nbPX = 0;
  3681. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3682. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3683. if(comPX > nbPX) {
  3684. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3685. niveau = "";
  3686. } else if(Math.floor(niveau) == niveau) {
  3687. chaine += niveau + ".";
  3688. } else {
  3689. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3690. niveau = "";
  3691. }
  3692. insertBr(b.nextSibling.nextSibling.nextSibling);
  3693. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3694. }
  3695.  
  3696. if(niveau != '') {
  3697. var button = insertButtonCdm('as_Action');
  3698. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3699. + escape(nomM) + "&niveau=" + escape(niveau)
  3700. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3701. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3702. }
  3703. }
  3704.  
  3705.  
  3706. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3707.  
  3708. function insertInfoMagie(node, intitule, magie) {
  3709. if(node.nextSibling) {
  3710. node = node.nextSibling;
  3711. insertBr(node);
  3712. insertText(node, intitule);
  3713. insertText(node, magie, true);
  3714. } else {
  3715. node = node.parentNode;
  3716. appendBr(node);
  3717. appendText(node, intitule);
  3718. appendText(node, magie, true);
  3719. }
  3720. }
  3721.  
  3722. function getMM(sr) {
  3723. if(rmTroll<=0) {
  3724. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3725. }
  3726. sr = Number(sr.match(/\d+/)[0]);
  3727. if(sr==10) {
  3728. return '\u2265 '+5*rmTroll;
  3729. }
  3730. if(sr<=50) {
  3731. return Math.round(50*rmTroll/sr);
  3732. }
  3733. if(sr<90) {
  3734. return Math.round((100-sr)*rmTroll/50);
  3735. }
  3736. return '\u2264 '+Math.round(rmTroll/5);
  3737. }
  3738.  
  3739. function traiteMM() {
  3740. var node = document.evaluate(
  3741. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3742. document, null, 9, null).singleNodeValue;
  3743.  
  3744. if(node) {
  3745. var mm = getMM(node.nodeValue);
  3746. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3747. } else {
  3748. var node = document.evaluate(
  3749. "//p/text()[contains(., 'Seuil de Résistance')]",
  3750. document, null, 9, null).singleNodeValue;
  3751. if(!node) {
  3752. return;
  3753. }
  3754. var mm = getMM(node.nodeValue);
  3755. node = node.nextSibling.nextSibling;
  3756. }
  3757. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3758. }
  3759.  
  3760. function getRM(sr) {
  3761. if(mmTroll<=0) {
  3762. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3763. }
  3764. sr = Number(sr.match(/\d+/)[0]);
  3765. if(sr==10) {
  3766. return '\u2264 '+Math.round(mmTroll/5);
  3767. }
  3768. if(sr<=50) {
  3769. return Math.round(sr*mmTroll/50);
  3770. }
  3771. if(sr<90) {
  3772. return Math.round(50*mmTroll/(100-sr));
  3773. }
  3774. return '\u2265 '+5*mmTroll;
  3775. }
  3776.  
  3777. function traiteRM() {
  3778. var nodes = document.evaluate(
  3779. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3780. document, null, 7, null);
  3781. if(nodes.snapshotLength==0) {
  3782. return;
  3783. }
  3784.  
  3785. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3786. var node = nodes.snapshotItem(i);
  3787. var rm = getRM(node.nodeValue);
  3788. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3789. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3790. }
  3791. }
  3792.  
  3793.  
  3794. /* Fonction stats IdT par Raistlin */
  3795.  
  3796. /*function getIdt() {
  3797. if(MY_getValue("SEND_IDT") == "non")
  3798. return false;
  3799.  
  3800. var regExpBeginning = /^\s+/;
  3801. var regExpEnd = /\s+$/;
  3802.  
  3803. var nomIdt = document.evaluate(
  3804. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3805. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3806. if(!nomIdt)
  3807. return false;
  3808.  
  3809. var caracIdt;
  3810. if(nomIdt.indexOf("Malédiction !") != -1) {
  3811. caracIdt = "";
  3812. nomIdt = "Mission maudite";
  3813. } else {
  3814. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3815. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3816. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3817. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3818. }
  3819. FF_XMLHttpRequest({
  3820. method: 'GET',
  3821. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3822. headers : {
  3823. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3824. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3825. }
  3826. });
  3827. return true;
  3828. }*/
  3829.  
  3830.  
  3831. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3832.  
  3833. function confirmeDecalage() {
  3834. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3835. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3836. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3837.  
  3838. var newDLA = new Date( oldDLA );
  3839. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3840. return window.confirm(
  3841. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3842. +'\nConfirmez-vous ce décalage ?'
  3843. );
  3844. }
  3845.  
  3846. function newsubmitDLA(evt) {
  3847. evt.stopPropagation();
  3848. evt.preventDefault();
  3849. if(confirmeDecalage()) {
  3850. this.submit();
  3851. }
  3852. }
  3853.  
  3854. function changeActionDecalage() {
  3855. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3856. return;
  3857. }
  3858. try {
  3859. // On récupère le contenu du script JS MH de calcul du décalage
  3860. var scriptTxt = document.evaluate(
  3861. ".//script[ not(@src) ]",
  3862. document, null, 9, null
  3863. ).singleNodeValue.textContent;
  3864. // On en extrait la DLA courante
  3865. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3866. scriptTxt = scriptTxt.split('\n')[0];
  3867. var nbs = scriptTxt.match(/\d+/g);
  3868. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3869. } catch(e) {
  3870. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3871. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3872. return;
  3873. }
  3874. var form = document.getElementsByName('ActionForm')[0];
  3875. if(form) {
  3876. form.addEventListener('submit', newsubmitDLA, true);
  3877. } else {
  3878. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3879. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3880. }
  3881. }
  3882.  
  3883. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3884.  
  3885. function prochainMundi() {
  3886. try {
  3887. var node;
  3888. node = document.evaluate(
  3889. "//div[@class='dateAction']/b",
  3890. document, null, 9, null
  3891. ).singleNodeValue;
  3892. if (document.evaluate) {
  3893. } else { // repli en JQuery
  3894. //node = $(
  3895. }
  3896. } catch(e) {
  3897. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3898. return;
  3899. }
  3900. if(!node) { return; }
  3901.  
  3902. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3903. var jour = longueurMois+1-getNumber(node.textContent);
  3904. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3905. var txt = '[Prochain Mundidey ';
  3906. if(jour>1) {
  3907. txt += 'dans '+jour+' jours]';
  3908. } else {
  3909. txt += 'demain]';
  3910. }
  3911. insertText(node.parentNode.nextSibling,txt,true);
  3912. }
  3913.  
  3914.  
  3915. /* Fonction principale */
  3916.  
  3917. function dispatch() {
  3918. if(isPage('MH_Play/Play_action')) {
  3919. prochainMundi();
  3920. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3921. var oldDLA;
  3922. changeActionDecalage();
  3923. } else if(isPage('MH_Play/Actions')) {
  3924. if(document.evaluate(
  3925. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3926. document, null, 2, null
  3927. ).stringValue) {
  3928. traiteMM();
  3929. } else if(document.evaluate(
  3930. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3931. document, null, 2, null
  3932. ).stringValue) {
  3933. //getIdt();
  3934. traiteRM();
  3935. } /*else {
  3936. // Est censé se lancer sur quoi *précisément* ?
  3937. traiteRM();
  3938. getLevel();
  3939. }*/
  3940. } else {
  3941. /* Traitement des messages du bot */
  3942. var messageTitle = document.evaluate(
  3943. "//form/table/tbody/tr[1]/td[1]/"
  3944. +"descendant::text()[contains(.,'[MountyHall]')]",
  3945. document, null, 2, null
  3946. ).stringValue;
  3947. if(messageTitle.indexOf('Attaquant') != -1 &&
  3948. messageTitle.indexOf('sur') != -1) {
  3949. getLevel();
  3950. traiteRM();
  3951. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3952. messageTitle.indexOf('Défenseur') != -1) {
  3953. traiteMM();
  3954. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3955. // à replacer avec Attaque après révision getLvl :
  3956. messageTitle.indexOf('Explosion') != -1 ||
  3957. messageTitle.indexOf('Insulte') != -1) {
  3958. traiteRM();
  3959. }
  3960. }
  3961. }
  3962.  
  3963. function do_actions() {
  3964. start_script(31);
  3965. dispatch();
  3966. displayScriptTime();
  3967. }
  3968.  
  3969. /*********************************************************************************
  3970. * This file is part of Mountyzilla. *
  3971. * *
  3972. * Mountyzilla is free software; you can redistribute it and/or modify *
  3973. * it under the terms of the GNU General Public License as published by *
  3974. * the Free Software Foundation; either version 2 of the License, or *
  3975. * (at your option) any later version. *
  3976. * *
  3977. * Mountyzilla is distributed in the hope that it will be useful, *
  3978. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3979. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3980. * GNU General Public License for more details. *
  3981. * *
  3982. * You should have received a copy of the GNU General Public License *
  3983. * along with Mountyzilla; if not, write to the Free Software *
  3984. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3985. *********************************************************************************/
  3986.  
  3987. // x~x pre-enchant
  3988.  
  3989. /* 2013-08-19 : correction auto syntaxe alert */
  3990.  
  3991. var combobox=null;
  3992.  
  3993. function changeObject()
  3994. {
  3995. if(!combobox)
  3996. return ;
  3997. var id = combobox.options[combobox.selectedIndex].value;
  3998. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3999. if(!id || id=="")
  4000. {
  4001. MY_removeValue(numTroll+".enchantement.lastEquipement");
  4002. return;
  4003. }
  4004. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  4005. }
  4006.  
  4007. function treatePreEnchantement() {
  4008. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4009. if(!input || input.getAttribute("type")=="hidden")
  4010. {
  4011. return false;
  4012. }
  4013. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  4014. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4015. if(!combobox)
  4016. {
  4017. return true;
  4018. }
  4019. combobox.addEventListener('change', changeObject, true);
  4020. return true;
  4021. }
  4022.  
  4023. function treateEnchantement_pre() {
  4024. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4025. if(!input || input.getAttribute("type")!="hidden")
  4026. {
  4027. return false;
  4028. }
  4029. var idEquipement = input.getAttribute("value");
  4030. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  4031. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  4032. if(enchanteur && enchanteur != null)
  4033. return true;
  4034. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4035. if(!input || input.getAttribute("type")!="hidden")
  4036. {
  4037. return false;
  4038. }
  4039. var idEnchanteur = input.getAttribute("value");
  4040.  
  4041. var nodes = document.evaluate(
  4042. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4043. if (nodes.snapshotLength != 3)
  4044. return;
  4045. for(var i=0;i<3;i++)
  4046. {
  4047. var texte = trim(nodes.snapshotItem(i).nodeValue);
  4048. texte = texte.replace(" d'une "," d'un ");
  4049. var compo = texte.substring(0,texte.indexOf(" d'un "));
  4050. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  4051. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  4052. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  4053. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  4054. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  4055. }
  4056. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  4057. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  4058. var liste = MY_getValue(numTroll+".enchantement.liste");
  4059. if(!liste || liste=="")
  4060. {
  4061. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  4062. }
  4063. else
  4064. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  4065. }
  4066.  
  4067. function do_pre_enchant() {
  4068. start_script(60);
  4069. if(!treatePreEnchantement())
  4070. treateEnchantement_pre();
  4071. displayScriptTime();
  4072. }
  4073.  
  4074. /*********************************************************************************
  4075. * This file is part of Mountyzilla. *
  4076. * *
  4077. * Mountyzilla is free software; you can redistribute it and/or modify *
  4078. * it under the terms of the GNU General Public License as published by *
  4079. * the Free Software Foundation; either version 2 of the License, or *
  4080. * (at your option) any later version. *
  4081. * *
  4082. * Mountyzilla is distributed in the hope that it will be useful, *
  4083. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4084. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4085. * GNU General Public License for more details. *
  4086. * *
  4087. * You should have received a copy of the GNU General Public License *
  4088. * along with Mountyzilla; if not, write to the Free Software *
  4089. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4090. *********************************************************************************/
  4091.  
  4092. // x~x enchant
  4093.  
  4094. /* 2013-08-19 : correction auto syntaxe alert */
  4095.  
  4096. function treateEnchantement() {
  4097. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  4098. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  4099. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  4100. return;
  4101. var tab = infoEquipement.split(";");
  4102. if(tab.length<2)
  4103. return;
  4104. var idEquipement = tab[0];
  4105. var nomEquipement = tab[1];
  4106. for(var i=2;i<tab.length;i++)
  4107. nomEquipement += ";"+tab[i];
  4108.  
  4109. var nodes = document.evaluate(
  4110. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4111. if (nodes.snapshotLength != 3)
  4112. return;
  4113. for(var i=0;i<3;i++)
  4114. {
  4115. var texte = trim(nodes.snapshotItem(i).nodeValue);
  4116. texte = texte.replace(" d'une "," d'un ");
  4117. var compo = texte.substring(0,texte.indexOf(" d'un "));
  4118. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  4119. monstre = monstre.replace(/ Géante?/,"");
  4120. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  4121. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  4122. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  4123. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  4124. }
  4125. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  4126. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  4127. var liste = MY_getValue(numTroll+".enchantement.liste");
  4128. if(!liste || liste=="")
  4129. {
  4130. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  4131. }
  4132. else
  4133. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  4134. }
  4135.  
  4136. function do_enchant() {
  4137. start_script(60);
  4138.  
  4139. treateEnchantement();
  4140. MY_removeValue(numTroll+".enchantement.lastEquipement");
  4141. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  4142. displayScriptTime();
  4143. }
  4144.  
  4145. /*********************************************************************************
  4146. * This file is part of Mountyzilla. *
  4147. * *
  4148. * Mountyzilla is free software; you can redistribute it and/or modify *
  4149. * it under the terms of the GNU General Public License as published by *
  4150. * the Free Software Foundation; either version 2 of the License, or *
  4151. * (at your option) any later version. *
  4152. * *
  4153. * Mountyzilla is distributed in the hope that it will be useful, *
  4154. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4155. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4156. * GNU General Public License for more details. *
  4157. * *
  4158. * You should have received a copy of the GNU General Public License *
  4159. * along with Mountyzilla; if not, write to the Free Software *
  4160. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4161. *********************************************************************************/
  4162.  
  4163. // x~x myevent
  4164.  
  4165. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4166. function do_myevent() {
  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 malus
  4188.  
  4189. /* v1.4 - 2014-01-06
  4190. * - Gestion des sorts double composante
  4191. * v1.4.1 - 2014-01-22
  4192. * - Correction décumul
  4193. * TODO
  4194. * - Identifier la position de "PV" dans l'ordre MH
  4195. */
  4196.  
  4197. var listeBM;
  4198.  
  4199.  
  4200. /* [functions] Utilitaires */
  4201.  
  4202. function decumul(bmt,nbr) {
  4203. var bmr;
  4204. if(!nbr || nbr<2) bmr = bmt;
  4205. else if(nbr==2) bmr = parseInt(0.67*bmt);
  4206. else if(nbr==3) bmr = parseInt(0.40*bmt);
  4207. else if(nbr==4) bmr = parseInt(0.25*bmt);
  4208. else if(nbr==5) bmr = parseInt(0.15*bmt);
  4209. else bmr = parseInt(0.1*bmt);
  4210. if(bmt<0) return Math.min(-1,bmr);
  4211. return Math.max(1,bmr);
  4212. }
  4213.  
  4214. function triecaracs(a,b) { // version Yoyor, mod by Dab
  4215. // Roule 23/11/2016 ajout PV
  4216. switch( a ) {
  4217. case 'ATT':
  4218. return -1;
  4219. case 'ESQ':
  4220. if(b=='ATT') return 1;
  4221. return -1;
  4222. case 'DEG':
  4223. switch( b ) {
  4224. case 'ATT':
  4225. case 'ESQ':
  4226. return 1;
  4227. default:
  4228. return -1;
  4229. }
  4230. case 'REG':
  4231. switch( b ) {
  4232. case 'ATT':
  4233. case 'ESQ':
  4234. case 'DEG':
  4235. return 1;
  4236. default:
  4237. return -1;
  4238. }
  4239. case 'Vue':
  4240. switch( b ) {
  4241. case 'ATT':
  4242. case 'ESQ':
  4243. case 'DEG':
  4244. case 'REG':
  4245. return 1;
  4246. default:
  4247. return -1;
  4248. }
  4249. case 'TOUR':
  4250. switch( b ) {
  4251. case 'ATT':
  4252. case 'ESQ':
  4253. case 'DEG':
  4254. case 'REG':
  4255. case 'Vue':
  4256. return 1;
  4257. default:
  4258. return -1;
  4259. }
  4260. case 'PV':
  4261. switch( b ) {
  4262. case 'ATT':
  4263. case 'ESQ':
  4264. case 'DEG':
  4265. case 'REG':
  4266. case 'Vue':
  4267. case 'TOUR':
  4268. return 1;
  4269. default:
  4270. return -1;
  4271. }
  4272. case 'Armure':
  4273. switch( b ) {
  4274. case 'ATT':
  4275. case 'ESQ':
  4276. case 'DEG':
  4277. case 'REG':
  4278. case 'Vue':
  4279. case 'TOUR':
  4280. case 'PV':
  4281. return 1;
  4282. default:
  4283. return -1;
  4284. }
  4285. case 'RM':
  4286. switch( b ) {
  4287. case 'ATT':
  4288. case 'ESQ':
  4289. case 'DEG':
  4290. case 'REG':
  4291. case 'Vue':
  4292. case 'TOUR':
  4293. case 'PV':
  4294. case 'Armure':
  4295. return 1;
  4296. default:
  4297. return -1;
  4298. }
  4299. case 'MM':
  4300. switch( b ) {
  4301. case 'ATT':
  4302. case 'ESQ':
  4303. case 'DEG':
  4304. case 'REG':
  4305. case 'Vue':
  4306. case 'TOUR':
  4307. case 'PV':
  4308. case 'Armure':
  4309. case 'RM':
  4310. return 1;
  4311. default:
  4312. return -1;
  4313. }
  4314. case 'Concentration':
  4315. switch( b ) {
  4316. case 'ATT':
  4317. case 'ESQ':
  4318. case 'DEG':
  4319. case 'REG':
  4320. case 'Vue':
  4321. case 'TOUR':
  4322. case 'PV':
  4323. case 'Armure':
  4324. case 'RM':
  4325. case 'MM':
  4326. return 1;
  4327. default:
  4328. return -1;
  4329. }
  4330. case 'Fatigue':
  4331. switch( b ) {
  4332. case 'ATT':
  4333. case 'ESQ':
  4334. case 'DEG':
  4335. case 'REG':
  4336. case 'Vue':
  4337. case 'TOUR':
  4338. case 'PV':
  4339. case 'Armure':
  4340. case 'RM':
  4341. case 'MM':
  4342. case 'Concentration':
  4343. return 1;
  4344. default:
  4345. return -1;
  4346. }
  4347. case "Dés d'attaque":
  4348. switch( b ) {
  4349. case 'ATT':
  4350. case 'ESQ':
  4351. case 'DEG':
  4352. case 'REG':
  4353. case 'Vue':
  4354. case 'TOUR':
  4355. case 'PV':
  4356. case 'Armure':
  4357. case 'RM':
  4358. case 'MM':
  4359. case 'Concentration':
  4360. case 'Fatigue':
  4361. return 1;
  4362. default:
  4363. return -1;
  4364. }
  4365. case 'Dés de dégâts':
  4366. switch( b ) {
  4367. case 'ATT':
  4368. case 'ESQ':
  4369. case 'DEG':
  4370. case 'REG':
  4371. case 'Vue':
  4372. case 'TOUR':
  4373. case 'PV':
  4374. case 'Armure':
  4375. case 'RM':
  4376. case 'MM':
  4377. case 'Concentration':
  4378. case 'Fatigue':
  4379. case "Dés d'attaque":
  4380. return 1;
  4381. default:
  4382. return -1;
  4383. }
  4384. default :
  4385. switch( b ) {
  4386. case 'ATT':
  4387. case 'ESQ':
  4388. case 'DEG':
  4389. case 'REG':
  4390. case 'Vue':
  4391. case 'TOUR':
  4392. case 'PV':
  4393. case 'Armure':
  4394. case 'RM':
  4395. case 'MM':
  4396. case 'Concentration':
  4397. case 'Fatigue':
  4398. case "Dés d'attaque":
  4399. case 'Dés de dégâts':
  4400. return 1;
  4401. default:
  4402. return -1;
  4403. }
  4404. }
  4405. }
  4406.  
  4407.  
  4408. /* [functions] Fonctions hide / display */
  4409.  
  4410. function toggleDetailsBM() {
  4411. if(MY_getValue('BMDETAIL')!='false') {
  4412. MY_setValue('BMDETAIL','false');
  4413. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4414. for(var i=0 ; i<trlist.length ; i++)
  4415. trlist[i].style.display = 'none';
  4416. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4417. for(var i=0 ; i<trlist.length ; i++)
  4418. trlist[i].style = '';
  4419. }
  4420. else {
  4421. MY_setValue('BMDETAIL','true');
  4422. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4423. for(var i=0 ; i<trlist.length ; i++)
  4424. trlist[i].style.display = 'none';
  4425. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4426. for(var i=0 ; i<trlist.length ; i++)
  4427. trlist[i].style = '';
  4428. }
  4429. }
  4430.  
  4431. function toggleBMList() {
  4432. if(MY_getValue('BMHIDELIST')=='true') {
  4433. MY_setValue('BMHIDELIST','false');
  4434. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4435. listeBM.snapshotItem(i).style = '';
  4436. document.getElementsByTagName('thead')[0].style = '';
  4437. document.getElementById('trhelp').style = '';
  4438. }
  4439. else {
  4440. MY_setValue('BMHIDELIST','true');
  4441. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4442. listeBM.snapshotItem(i).style.display = 'none';
  4443. document.getElementsByTagName('thead')[0].style.display = 'none';
  4444. document.getElementById('trhelp').style.display = 'none';
  4445. }
  4446. }
  4447.  
  4448. function setDisplayBM() {
  4449. if(!listeBM) return;
  4450.  
  4451. var titre = document.getElementById('titre2');
  4452. if(titre) {
  4453. titre.style.cursor = 'pointer';
  4454. titre.onclick = toggleBMList;
  4455. }
  4456.  
  4457. var tfoot = document.getElementsByTagName('tfoot')[0];
  4458. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  4459. tfoot, null, 9, null).singleNodeValue;
  4460. tr.id = 'trhelp';
  4461.  
  4462. if(MY_getValue('BMHIDELIST')=='true') {
  4463. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4464. listeBM.snapshotItem(i).style.display = 'none';
  4465. document.getElementsByTagName('thead')[0].style.display = 'none';
  4466. tr.style.display = 'none';
  4467. }
  4468. }
  4469.  
  4470.  
  4471. /* [functions] Fonction principale */
  4472.  
  4473. function traiteMalus() {
  4474. var mainTab = document.getElementsByTagName('table')[0];
  4475. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4476. if(listeBM.snapshotLength==0) return;
  4477.  
  4478. /* Suppression des BM de fatigue stockés */
  4479. if(MY_getValue(numTroll+'.bm.fatigue'))
  4480. MY_removeValue(numTroll+'.bm.fatigue');
  4481.  
  4482. /* Extraction des données */
  4483. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  4484. var nb = 0;
  4485. while(nb<listeBM.snapshotLength) {
  4486. tr = listeBM.snapshotItem(nb); nb++;
  4487. var effetsT = tr.childNodes[5].textContent.split(' | ');
  4488. var phymag = tr.childNodes[9].textContent;
  4489. var duree = tr.childNodes[11].textContent.match(/\d+/);
  4490. if (duree == null) { // Roule 28/01/2018 protection malus Crasc sans durée
  4491. duree = 1;
  4492. } else {
  4493. duree = Number(duree[0]);
  4494. }
  4495. var type = tr.childNodes[3].textContent, nom;
  4496. // si c'est un type à décumul
  4497. /*
  4498. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  4499. switch(type) {
  4500. case 'Potion':
  4501. case 'Parchemin':
  4502. case 'Sortilège':
  4503. case 'Capacité Spéciale':
  4504. nom = tr.childNodes[1].textContent+phymag;
  4505. break;
  4506. default:
  4507. nom = 'pasdedecumul';
  4508. }
  4509. */
  4510. nom = tr.childNodes[1].textContent+phymag;
  4511. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  4512. nom = 'pasdedecumul';
  4513.  
  4514. uniListe[nb] = {
  4515. 'duree':duree,
  4516. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  4517. 'caracs':{}
  4518. }
  4519. for(var i=0 ; i<effetsT.length ; i++) {
  4520. if(effetsT[i].indexOf(':')==-1) continue;
  4521. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  4522. // nom = 'pasdedecumul' si pas de décumul
  4523. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  4524. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  4525. uniListe[nb]['type'] = phymag;
  4526. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  4527. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  4528. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  4529. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  4530. uniListe[nb]['caracs'][carac] = bm;
  4531. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  4532. listeDurees[duree] = true;
  4533. }
  4534. } // fin boucle sur les lignes de bonus/malus
  4535.  
  4536. /* Gestion des décumuls et cumuls des durées */
  4537. var toursGeres = [];
  4538. for(var d in listeDurees) toursGeres.push(d);
  4539. toursGeres.sort( function (a,b){return b-a;} );
  4540. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  4541. // pour sauvegarder les bm de fatigue
  4542. var strfat = '';
  4543. // Pour affichage & adpatation à footable.js (statique)
  4544. var thead = document.getElementsByTagName('thead')[0];
  4545. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  4546. thead, null, 7, null).snapshotLength;
  4547. var tfoot = document.getElementsByTagName('tfoot')[0];
  4548.  
  4549. for(var i=0 ; i<toursGeres.length ; i++) {
  4550. var tour = toursGeres[i];
  4551. var effetsCeTour = {}; decumulsCeTour = {};
  4552. for(var nb=1 ; nb<uniListe.length ; nb++) {
  4553. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  4554. continue;
  4555. var nom = uniListe[nb]['nom'];
  4556. if(nom!='pasdedecumul') {
  4557. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  4558. decumulsCeTour[nom]++;
  4559. }
  4560. for(var carac in uniListe[nb]['caracs']) {
  4561. var bm = uniListe[nb]['caracs'][carac];
  4562. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  4563. var type = uniListe[nb]['type'];
  4564. if(!effetsCeTour[carac])
  4565. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  4566. var thisBm;
  4567. if(nom=='pasdedecumul')
  4568. thisBm = bm;
  4569. else
  4570. thisBm = decumul(bm,decumulsCeTour[nom]);
  4571. effetsCeTour[carac][type] += thisBm;
  4572. 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]);
  4573. } else {
  4574. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  4575. var thisBm;
  4576. if(nom=='pasdedecumul' || carac=='Fatigue')
  4577. thisBm = bm;
  4578. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  4579. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  4580. else
  4581. thisBm = decumul(bm,decumulsCeTour[nom]);
  4582. effetsCeTour[carac] += thisBm;
  4583. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  4584. }
  4585. } // fin boucle sur les caractéristiques
  4586. } // fin boucle sur les bonus/malus
  4587.  
  4588. /* Création du bilan du tour */
  4589. var texteD = '', texteS = '';
  4590. var caracGerees = [];
  4591. for(var k in effetsCeTour) caracGerees.push(k);
  4592. caracGerees.sort( triecaracs );
  4593.  
  4594. for(var j=0 ; j<caracGerees.length ; j++) {
  4595. var carac = caracGerees[j], str = '';
  4596.  
  4597. switch( carac ) {
  4598. case 'ATT':
  4599. case 'DEG':
  4600. case 'Armure':
  4601. var phy = effetsCeTour[carac]['Physique'];
  4602. var mag = effetsCeTour[carac]['Magie'];
  4603. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  4604. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  4605. break;
  4606. case 'TOUR':
  4607. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  4608. break;
  4609. case 'Fatigue':
  4610. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  4611. case 'PV':
  4612. case 'ESQ':
  4613. case 'REG':
  4614. case 'Vue':
  4615. case 'Voir le Caché':
  4616. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  4617. break;
  4618. default:
  4619. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  4620. }
  4621. if(str) {
  4622. texteD += str;
  4623. texteS += str;
  4624. }
  4625. } // fin boucle sur les caractéristiques
  4626.  
  4627. /* Affichage */
  4628. // Si rien à afficher on passe
  4629. if(!texteD) continue;
  4630. // Si BMM+BMP=0
  4631. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  4632. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  4633. if(MY_getValue('BMDETAIL')=='false')
  4634. tr.style.display = 'none';
  4635. var td = appendTdText(tr,texteD.substring(3));
  4636. td.colSpan = 5-nbHidden;
  4637. var txttour = toursGeres[i]+' Tour';
  4638. if(toursGeres[i]>1) txttour += 's';
  4639. appendTdText(tr,txttour);
  4640.  
  4641. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  4642. if(MY_getValue('BMDETAIL')!='false')
  4643. tr.style.display = 'none';
  4644. td = appendTdText(tr,texteS);
  4645. td.colSpan = 5-nbHidden;
  4646. appendTdText(tr,txttour);
  4647. } // fin boucle sur les tours générés
  4648.  
  4649. /* mise en place toggleDetails */
  4650. tfoot.style.cursor = 'pointer';
  4651. tfoot.onclick = toggleDetailsBM;
  4652.  
  4653. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4654. if(strfat)
  4655. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4656. }
  4657.  
  4658. function do_malus() {
  4659. try {
  4660. start_script();
  4661. traiteMalus();
  4662. setDisplayBM();
  4663. displayScriptTime();
  4664. }
  4665. catch(e) {window.alert(e)};
  4666. }
  4667.  
  4668. /*******************************************************************************
  4669. * This file is part of Mountyzilla. *
  4670. * *
  4671. * Mountyzilla is free software; you can redistribute it and/or modify *
  4672. * it under the terms of the GNU General Public License as published by *
  4673. * the Free Software Foundation; either version 2 of the License, or *
  4674. * (at your option) any later version. *
  4675. * *
  4676. * Mountyzilla is distributed in the hope that it will be useful, *
  4677. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4678. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4679. * GNU General Public License for more details. *
  4680. * *
  4681. * You should have received a copy of the GNU General Public License *
  4682. * along with Mountyzilla; if not, write to the Free Software *
  4683. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4684. *******************************************************************************/
  4685.  
  4686. // x~x mouches
  4687.  
  4688. var mainTab, tr_mouches;
  4689.  
  4690. function initialiseMouches() {
  4691. // Lanceur global
  4692. try {
  4693. mainTab = document.getElementById('mouches');
  4694. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4695. } catch(e) {
  4696. avertissement('Erreur MZ:<br />Consulter la console.');
  4697. window.console.error(traceStack(e, 'mouches'));
  4698. return;
  4699. }
  4700. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4701.  
  4702. setDisplayMouches();
  4703. traiteMouches();
  4704. }
  4705.  
  4706. function setDisplayMouches() {
  4707. // Initialise l'affichage / l'effacement du détail des mouches
  4708. var titre = document.getElementById('titre2');
  4709. if(titre) {
  4710. titre.style.cursor = 'pointer';
  4711. titre.onclick = toggleMouches;
  4712. }
  4713.  
  4714. var tfoot = document.getElementsByTagName('tfoot')[0];
  4715. if(tfoot) {
  4716. tfoot.style.cursor = 'pointer';
  4717. tfoot.onclick = toggleMouches;
  4718. }
  4719.  
  4720. if(MY_getValue('HIDEMOUCHES')=='true') {
  4721. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4722. tr_mouches.snapshotItem(i).style.display = 'none';
  4723. }
  4724. document.getElementsByTagName('thead')[0].style.display = 'none';
  4725. }
  4726. }
  4727.  
  4728. function toggleMouches() {
  4729. // Handler pour afficher / masquer les détasil
  4730. if(MY_getValue('HIDEMOUCHES')=='true') {
  4731. MY_setValue('HIDEMOUCHES','false');
  4732. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4733. tr_mouches.snapshotItem(i).style.display = '';
  4734. }
  4735. document.getElementsByTagName('thead')[0].style.display = '';
  4736. } else {
  4737. MY_setValue('HIDEMOUCHES','true');
  4738. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4739. tr_mouches.snapshotItem(i).style.display = 'none';
  4740. }
  4741. document.getElementsByTagName('thead')[0].style.display = 'none';
  4742. }
  4743. }
  4744.  
  4745. function traiteMouches() {
  4746. // Traitement complet: présence et effets des mouches
  4747. var listeTypes = {}, effetsActifs = {};
  4748.  
  4749. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4750. var tr = tr_mouches.snapshotItem(i);
  4751.  
  4752. // La mouche est-elle présente?
  4753. var etat = document.evaluate(
  4754. './img',
  4755. tr.cells[6], null, 9, null
  4756. ).singleNodeValue.alt;
  4757. if(etat!='La Mouche est là') { continue; }
  4758. // Extraction du type de mouche
  4759. var type = trim(tr.cells[3].textContent);
  4760. if(!listeTypes[type]) {
  4761. listeTypes[type] = 1;
  4762. } else {
  4763. listeTypes[type]++;
  4764. }
  4765.  
  4766. // La mouche a-t-elle un effet?
  4767. var effet = trim(tr.cells[2].textContent);
  4768. if(etat!='La Mouche est là' || !effet) { continue; }
  4769. // Si oui, extraction des effets (multiples pour pogées)
  4770. var caracs = effet.split(' | ');
  4771. for(var j=0 ; j<caracs.length ; j++) {
  4772. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4773. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4774. if(effetsActifs[carac]===void(0)) {
  4775. effetsActifs[carac] = valeur;
  4776. } else {
  4777. effetsActifs[carac] += valeur;
  4778. }
  4779. }
  4780. }
  4781.  
  4782. // Extraction Effet total et affichage des différences à la normale
  4783. var tfoot = document.getElementsByTagName('tfoot')[0];
  4784. if(!tfoot) { return; }
  4785. var nodeTotal = document.evaluate(
  4786. ".//b[contains(./text(),'Effet total')]",
  4787. tfoot, null, 9, null
  4788. ).singleNodeValue.nextSibling;
  4789. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4790. var texte = ' ';
  4791. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4792. if(texte.length>1) { texte += ' | '; }
  4793. var carac = trim(
  4794. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4795. );
  4796. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4797. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4798. texte += effetsTheoriques[i];
  4799. } else {
  4800. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4801. if(carac=='TOUR') { texte += ' min'; }
  4802. texte += '</b>';
  4803. }
  4804. }
  4805. var span = document.createElement('span');
  4806. span.innerHTML = texte;
  4807. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4808.  
  4809. // Affichage des différences du nombre de mouches de chaque type
  4810. var mouchesParType = document.evaluate(
  4811. "./tr/td/ul/li/text()",
  4812. tfoot, null, 7, null
  4813. );
  4814. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4815. var node = mouchesParType.snapshotItem(i);
  4816. var mots = node.nodeValue.split(' ');
  4817. var type = mots.pop();
  4818. if(!listeTypes[type]) {
  4819. node.nodeValue += ' (0 présente)';
  4820. } else if(mots[0]!=listeTypes[type]) {
  4821. if(listeTypes[type]==1) {
  4822. node.nodeValue += ' (1 présente)';
  4823. } else {
  4824. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4825. }
  4826. }
  4827. }
  4828. }
  4829.  
  4830. function do_mouches() {
  4831. start_script();
  4832. initialiseMouches();
  4833. displayScriptTime();
  4834. }
  4835.  
  4836. /*********************************************************************************
  4837. * This file is part of Mountyzilla. *
  4838. * *
  4839. * Mountyzilla is free software; you can redistribute it and/or modify *
  4840. * it under the terms of the GNU General Public License as published by *
  4841. * the Free Software Foundation; either version 2 of the License, or *
  4842. * (at your option) any later version. *
  4843. * *
  4844. * Mountyzilla is distributed in the hope that it will be useful, *
  4845. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4846. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4847. * GNU General Public License for more details. *
  4848. * *
  4849. * You should have received a copy of the GNU General Public License *
  4850. * along with Mountyzilla; if not, write to the Free Software *
  4851. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4852. *********************************************************************************/
  4853.  
  4854. // x~x equipgowap
  4855.  
  4856. var popup;
  4857.  
  4858. function initPopupEquipgowap() {
  4859. popup = document.createElement('div');
  4860. popup.setAttribute('id', 'popup');
  4861. popup.setAttribute('class', 'mh_textbox');
  4862. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4863. 'display: inline; z-index: 3; max-width: 400px;');
  4864. document.body.appendChild(popup);
  4865. }
  4866.  
  4867. function showPopupEquipgowap(evt) {
  4868. var texte = this.getAttribute("texteinfo");
  4869. popup.innerHTML = texte;
  4870. popup.style.left = evt.pageX + 15 + 'px';
  4871. popup.style.top = evt.pageY + 'px';
  4872. popup.style.visibility = "visible";
  4873. }
  4874.  
  4875. function hidePopup() {
  4876. popup.style.visibility = "hidden";
  4877. }
  4878.  
  4879. function createPopupImage(url, text)
  4880. {
  4881. var img = document.createElement('img');
  4882. img.setAttribute('src',url);
  4883. img.setAttribute('align','ABSMIDDLE');
  4884. img.setAttribute("texteinfo",text);
  4885. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4886. img.addEventListener("mouseout", hidePopup,true);
  4887. return img;
  4888. }
  4889.  
  4890. function formateTexte(texte)
  4891. {
  4892. texte = texte.replace(/\n/g,"<br/>");
  4893. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4894. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4895. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4896. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4897. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4898. return texte;
  4899. }
  4900.  
  4901.  
  4902. function treateGowaps() {
  4903. //On récupère les gowaps possédants des composants
  4904. var tbodys = document.evaluate(
  4905. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4906. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4907. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4908. var tbody = tbodys.snapshotItem(j);
  4909. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4910. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4911. if(MY_getValue("NOINFOEM") != "true")
  4912. insertEMInfos(tbody);
  4913. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4914. insertEnchantInfos(tbody);
  4915. }
  4916. }
  4917.  
  4918. function treateChampi() {
  4919. if(MY_getValue("NOINFOEM") == "true")
  4920. return false;
  4921. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4922. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4923. if (nodes.snapshotLength == 0)
  4924. return false;
  4925.  
  4926. for (var i = 0; i < nodes.snapshotLength; i++) {
  4927. var node = nodes.snapshotItem(i);
  4928. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4929. if(texte.indexOf("*")!=-1)
  4930. texte = texte.substring(0,texte.lastIndexOf(" "));
  4931. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4932. if(moisChampi[nomChampi])
  4933. {
  4934. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4935. }
  4936.  
  4937. }
  4938. }
  4939.  
  4940. function do_equipgowap() {
  4941. start_script();
  4942.  
  4943. treateGowaps();
  4944. treateChampi();
  4945. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4946. {
  4947. initPopupEquipgowap();
  4948. computeEnchantementEquipement(createPopupImage,formateTexte);
  4949. }
  4950.  
  4951. displayScriptTime();
  4952. }
  4953.  
  4954. /*********************************************************************************
  4955. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4956. *********************************************************************************/
  4957.  
  4958. // x~x ordresgowap
  4959.  
  4960. var MZ_analyse_page_ordre_suivant;
  4961. if (MZ_analyse_page_ordre_suivant === undefined && isPage("MH_Follower/FO_Ordres")) {
  4962. // Roule 07/10/2019
  4963. // Fonction réutilisée dans MZ, dans Trajet_canvas et dans une extension perso ☺
  4964. // rend un object, par exemple
  4965. var MZ_analyse_page_ordre_suivant = {
  4966. 'result': {ordres: []},
  4967. 'init': function() {
  4968. // façon blindée de tester la variable MY_DEBUG
  4969. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('start MZ_analyse_page_ordre_suivant.init');
  4970. try {
  4971. var eTitle = document.getElementById('titre2');
  4972. // au 07/10/2019, on peut se baser sur les <tr> de l'élément HTML parent 'titre2'
  4973. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('eTitle.nextSibling=' + eTitle.parentNode);
  4974. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4975. for(var i=0 ; i<lignes.length ; i++) {
  4976. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + ' className=' + lignes[i].className);
  4977. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + lignes[i].innerHTML);
  4978. if(lignes[i].className == 'mh_tdtitre_fo') {
  4979. var tds = lignes[i].getElementsByTagName('div');
  4980. for (var j=0; j < tds.length; j++) {
  4981. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant div ' + j + ' ' + tds[j].innerText);
  4982. var tabmatch = tds[j].innerText.match(/(\d+) *\.* *(.*\[.*\].*)$/);
  4983. if (tabmatch) {
  4984. // ID, Nom
  4985. this.result.id = tabmatch[1].trim();
  4986. this.result.nom = tabmatch[2].trim();
  4987. }
  4988. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-?\d+).*Y = (-?\d+).*N = (-?\d+)/i);
  4989. if (tabmatch) {
  4990. // PA, x, y, n
  4991. this.result.PA = parseInt(tabmatch[1]);
  4992. this.result.x = parseInt(tabmatch[2]);
  4993. this.result.y = parseInt(tabmatch[3]);
  4994. this.result.n = parseInt(tabmatch[4]);
  4995. // Trajet_canvas a besoin d'un pointeur vers cette div
  4996. this.result.eltPos = tds[j];
  4997. }
  4998. }
  4999. }
  5000. if(lignes[i].className == 'mh_tdpage_fo') {
  5001. var etd = lignes[i].getElementsByTagName('td')[0];
  5002. if (etd !== undefined) { // undefined dans le cas des Golems
  5003. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant td[0]=' + etd.textContent);
  5004. var tabmatch = etd.textContent.match(/^(.*)X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  5005. if (tabmatch) {
  5006. this.result.ordres.push({ordre: tabmatch[1].trim(), x: parseInt(tabmatch[2]), y: parseInt(tabmatch[3]), n: parseInt(tabmatch[4])});
  5007. } else {
  5008. this.result.ordres.push({ordre: etd.textContent.trim()});
  5009. }
  5010. }
  5011. }
  5012. }
  5013. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('fin MZ_analyse_page_ordre_suivant ' + JSON.stringify(this.result));
  5014. } catch(e) {
  5015. window.console.log('Exception dans MZ_analyse_page_ordre_suivant.init ' + e);
  5016. }
  5017. }
  5018. }
  5019. MZ_analyse_page_ordre_suivant.init();
  5020. }
  5021.  
  5022. // version Roule' janvier 2017
  5023. function MZ_setCarteUnGogoHTML5() {
  5024. // fabriquer la liste des positions successives
  5025. var listeDepl = []; // ce sera un tableau d'objets
  5026. listeDepl = MZ_analyse_page_ordre_suivant.result.ordres.slice(0); // clone array
  5027. 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
  5028.  
  5029. /* à supprimer, remplacé par MZ_analyse_page_ordre_suivant
  5030. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  5031. , y: parseInt(tabPos[3])
  5032. , n: parseInt(tabPos[4])
  5033. , nom: tabNomID[2]
  5034. , id: tabNomID[1]});
  5035.  
  5036. // position courante
  5037. var eTitle = document.getElementById('titre2');
  5038. // déplacements
  5039. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  5040. for(var i=0 ; i<lignes.length ; i++) {
  5041. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + ' className=' + lignes[i].className);
  5042. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + lignes[i].innerHTML);
  5043. if(lignes[i].className == 'mh_tdtitre_fo') {
  5044. var tds = lignes[i].getElementsByTagName('div');
  5045. for (var j=0; j < tds.length; j++) {
  5046. tabmatch = tds[j].innerText.match(/(\d+) *(.*\[.*\].*)$/);
  5047. if (tabmatch) var tabNomID = tabmatch;
  5048. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-.\d+).*Y = (-.\d+).*N = (-.\d+)/i);
  5049. if (tabmatch) var tabPos = tabmatch;
  5050. }
  5051. if (tabPos != undefined && tabNomID != undefined) { // null dans le cas des Golems
  5052. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  5053. , y: parseInt(tabPos[3])
  5054. , n: parseInt(tabPos[4])
  5055. , nom: tabNomID[2]
  5056. , id: tabNomID[1]});
  5057. } else {
  5058. return;
  5059. }
  5060. }
  5061. if(lignes[i].className == 'mh_tdpage_fo') {
  5062. var etd = lignes[i].getElementsByTagName('td')[0];
  5063. if (etd === undefined) return; // cas des Golems
  5064. var point = etd.firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  5065. if (point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  5066. }
  5067. }
  5068. */
  5069. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  5070. }
  5071.  
  5072. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  5073. function MZ_showCarteBottom(listeSuiv) {
  5074. // générer la carte
  5075. var carte = new carte_MZ('cartegogo', listeSuiv);
  5076. // positionner la carte
  5077. var eCarte = carte.getElt();
  5078. eCarte.style.textAlign = 'left';
  5079. eCarte.style.marginTop = '2px';
  5080. var footer = document.getElementById('footer1');
  5081. // Lieu_Teleport.php n'a pas de footer1 :(
  5082. if (!footer) footer = document.getElementById('footer2');
  5083. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  5084. else document.body.appendChild(eCarte);
  5085. }
  5086.  
  5087. function MZ_setCarteTousGogoHTML5() {
  5088. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  5089. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  5090. var suivants = [];
  5091. for (var i=0;i<ligne.length;i++) {
  5092. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  5093. var cas = ligne[i].getElementsByTagName("td")[0];
  5094. //if (cas.className == "mh_tdtitre") {
  5095. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  5096. var oGogo = {};
  5097. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  5098. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  5099. 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 "="
  5100. oGogo.x = parseInt(point[1]);
  5101. oGogo.y = parseInt(point[2]);
  5102. oGogo.n = parseInt(point[3]);
  5103. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  5104. }
  5105. }
  5106. if (suivants.length == 0) return;
  5107. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  5108. }
  5109.  
  5110. function MZ_setCarteTP() {
  5111. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  5112. 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);
  5113. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  5114. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  5115. }
  5116.  
  5117. function testeGlissiere() {
  5118. try {
  5119. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  5120. var footer = document.getElementById('footer1');
  5121. footer.parentNode.insertBefore(gliss.getElt(), footer);
  5122. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  5123. }
  5124.  
  5125. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  5126. if (x0 !== undefined) {
  5127. // ouais, récursif une fois
  5128. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  5129. if (PtInterm === undefined)
  5130. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  5131. else
  5132. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  5133. return;
  5134. }
  5135. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  5136. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  5137. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  5138. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  5139. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  5140. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  5141. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  5142. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  5143. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  5144. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  5145. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  5146. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  5147. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  5148. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  5149. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  5150. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  5151. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  5152. }
  5153.  
  5154. function do_ordresgowap() {
  5155. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  5156. //testeGlissiere();
  5157. //MZ_testsUnitairesCalculIntermediaire();
  5158. }
  5159.  
  5160. function do_listegowap() {
  5161. if (!newCarte) return;
  5162. MZ_setCarteTousGogoHTML5();
  5163. }
  5164.  
  5165. function do_lieuDescription() {
  5166. if (!newCarte) return;
  5167. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  5168. MZ_setCarteTP();
  5169. }
  5170.  
  5171. function do_lieuTeleport() {
  5172. changeButtonValidate();
  5173. if (!newCarte) return;
  5174. MZ_setCarteTP();
  5175. }
  5176.  
  5177. /*******************************************************************************
  5178. * This file is part of Mountyzilla. *
  5179. * *
  5180. * Mountyzilla is free software; you can redistribute it and/or modify *
  5181. * it under the terms of the GNU General Public License as published by *
  5182. * the Free Software Foundation; either version 2 of the License, or *
  5183. * (at your option) any later version. *
  5184. * *
  5185. * Mountyzilla is distributed in the hope that it will be useful, *
  5186. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5187. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5188. * GNU General Public License for more details. *
  5189. * *
  5190. * You should have received a copy of the GNU General Public License *
  5191. * along with Mountyzilla; if not, write to the Free Software *
  5192. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5193. *******************************************************************************/
  5194.  
  5195. // x~x infomonstre
  5196.  
  5197. // DEBUG
  5198. var nomMonstre='';
  5199. var idMonstre=-1;
  5200. //var tbody;
  5201. // var popup; // NOTE Linter : already defined
  5202.  
  5203. function traiteMonstre() {
  5204. try {
  5205. var nodeTitre = document.evaluate(
  5206. "//div[@class='titre2' and contains(text(),'(')]",
  5207. document, null, 9, null
  5208. ).singleNodeValue;
  5209. var texte = nodeTitre.firstChild.nodeValue;
  5210. } catch(e) {
  5211. window.console.log(traceStack(e, 'traiteMonstre'));
  5212. return;
  5213. }
  5214.  
  5215. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  5216. if(nomMonstre.indexOf(']')!=-1) {
  5217. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  5218. }
  5219. idMonstre = texte.match(/\d+/)[0];
  5220. var tReq = [{'index':1, 'id':+idMonstre, 'nom':nomMonstre}]; // "+" pour forcer du numérique
  5221. FF_XMLHttpRequest({
  5222. method: 'POST',
  5223. url: URL_MZgetCaracMonstre,
  5224. headers : {
  5225. 'Content-type':'application/x-www-form-urlencoded'
  5226. },
  5227. data: 'l=' + JSON.stringify(tReq),
  5228. trace: 'demande niveaux monstres V2, MonsterView',
  5229. onload: function(responseDetails) {
  5230. try {
  5231. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  5232. if (responseDetails.status == 0) return;
  5233. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  5234. var texte = responseDetails.responseText;
  5235. var infosRet = JSON.parse(texte);
  5236. if(infosRet.length==0) return;
  5237. var info = infosRet[0];
  5238. // QUESTION Quelle est l'utilité de ceci?
  5239. // 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
  5240. MZ_EtatCdMs.listeCDM[idMonstre] = info;
  5241. try {
  5242. var nodeInsert = document.evaluate(
  5243. "//div[@class = 'titre3']",
  5244. document, null, 9, null
  5245. ).singleNodeValue;
  5246. } catch(e) {
  5247. window.console.log(traceStack(e, 'recherche node pour info CdM'));
  5248. return;
  5249. }
  5250. var table = createCDMTable(idMonstre,nomMonstre,info);
  5251. table.align = 'center';
  5252. var tbody = table.childNodes[1];
  5253. var thead = table.childNodes[0];
  5254. var tdEntete = thead.firstChild.firstChild;
  5255. tdEntete.onclick = toggleTableau;
  5256. tdEntete.style.cursor = 'pointer';
  5257. thead.firstChild.style = 'mh_tdpage';
  5258. tbody.style.display = 'none';
  5259. table.style.width = '350px';
  5260. insertBefore(nodeInsert,table);
  5261. } catch(e) {
  5262. window.console.log(e);
  5263. }
  5264. },
  5265. });
  5266. }
  5267.  
  5268. function toggleTableau() { // click sur un td de thead
  5269. var tbody = this.parentNode.parentNode.parentNode.childNodes[1];
  5270. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  5271. }
  5272.  
  5273. function do_infomonstre() {
  5274. start_script();
  5275. try {
  5276. MZ_Tactique.initPopup();
  5277. traiteMonstre();
  5278. } catch(e) {
  5279. window.console.error(traceStack(e, 'do_infomonstre'));
  5280. window.alert('Erreur infoMonstre:\n'+e);
  5281. }
  5282. displayScriptTime();
  5283. }
  5284.  
  5285. /***
  5286. *** SCIZ
  5287. ***/
  5288.  
  5289. const scizSetup = {
  5290. // Maximum interval (seconds) for matching some events
  5291. eventsMaxMatchingInterval: 5000,
  5292. // Maximum number of treasures to enhanced in the view
  5293. viewMaxEnhancedTreasure: 100
  5294. };
  5295.  
  5296. var scizGlobal = {
  5297. events: [],
  5298. trolls: [],
  5299. treasures: []
  5300. };
  5301.  
  5302. function scizAddCSS() {
  5303. // SCIZ style
  5304. var scizStyle = `
  5305. .sciz-progress-bar-wrapper {
  5306. width: 100px;
  5307. text-align: center;
  5308. display: inline-block;
  5309. }
  5310. .sciz-progress-bar {
  5311. width: 100%;
  5312. background-color: #e0e0e0;
  5313. padding: 1px;
  5314. border-radius: 1px;
  5315. box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2);
  5316. }
  5317. .sciz-progress-bar-fill {
  5318. display: block;
  5319. height: 5px;
  5320. border-radius: 1px;
  5321. transition: width 500ms ease-in-out;
  5322. }
  5323. `;
  5324. // Actually add the SCIZ style
  5325. var scizStyleSheet = document.createElement('style');
  5326. scizStyleSheet.type = 'text/css';
  5327. if (scizStyleSheet.styleSheet) {
  5328. scizStyleSheet.styleSheet.cssText = scizStyle;
  5329. } else {
  5330. scizStyleSheet.appendChild(document.createTextNode(scizStyle));
  5331. }
  5332. document.getElementsByTagName('head')[0].appendChild(scizStyleSheet);
  5333. }
  5334.  
  5335. function scizCreateClickable(height, display, callbackOnClick) {
  5336. var img = document.createElement('img');
  5337. img.src = 'https://www.sciz.fr/static/sciz-logo-quarter.png';
  5338. img.alt = 'SCIZ logo';
  5339. img.style = 'height: ' + height + 'px; cursor: pointer;';
  5340. img.onclick = callbackOnClick;
  5341. var div = document.createElement('div');
  5342. div.style = 'text-align: center;display: ' + display;
  5343. div.appendChild(img);
  5344. return div;
  5345. };
  5346.  
  5347. function scizCreateIcon(height, display, icon) {
  5348. var img = document.createElement('img');
  5349. img.src = 'https://www.sciz.fr/static/' + icon;
  5350. img.alt = 'SCIZ icon';
  5351. img.style = 'height: ' + height + 'px;';
  5352. var div = document.createElement('div');
  5353. div.style = 'text-align: center;display: ' + display;
  5354. div.appendChild(img);
  5355. return div;
  5356. };
  5357.  
  5358. /* SCIZ - View */
  5359.  
  5360. function scizPrettyPrintTroll(t) {
  5361. var res = '';
  5362. // SCIZ progress bar
  5363. var pbPercent = (t.pdv !== null && t.pdv_max !== null) ? t.pdv / t.pdv_max * 100 : -1;
  5364. var pbColor = (pbPercent === -1) ? '#424242' : ((pbPercent < 40) ? '#ff5252' : ((pbPercent < 80) ? '#fb8c00' : '#4caf50'));
  5365. t.pdv_max = (t.pdv_max === null) ? '?' : t.pdv_max;
  5366. 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>';
  5367. // SCIZ other view enhancement...
  5368. return res;
  5369. }
  5370.  
  5371. function scizPrettyPrintTreasure(t) {
  5372. var res = '';
  5373. res += /* t.type + ' - ' + */ t.nom;
  5374. if (t.templates) { res += ' <b>' + t.templates + '</b>' };
  5375. if (t.mithril) { res += ' <b>en Mithril</b>' };
  5376. if (t.effet) { res += ' (' + t.effet + ')' };
  5377. return res;
  5378. }
  5379.  
  5380. function do_scizEnhanceView() {
  5381. scizGlobal.treasures = [];
  5382.  
  5383. // Ensure we have a JWT setup for the current user
  5384. jwt = MY_getValue(numTroll + '.SCIZJWT');
  5385. if (!jwt) { return; }
  5386.  
  5387. scizAddCSS();
  5388.  
  5389. /* SCIZ View - TROLLS */
  5390. cbx = MY_getValue(numTroll + '.SCIZ_CB_VIEW_TROLLS');
  5391. if (cbx !== '0') {
  5392. // Retrieve trolls
  5393. var ids = [];
  5394. const xPathTrollQuery = "//*/table[@id='VueTROLL']/tbody/tr";
  5395. var xPathTrolls = document.evaluate(xPathTrollQuery, document, null, 0, null);
  5396. while (xPathTroll = xPathTrolls.iterateNext()) {
  5397. scizGlobal.trolls.push({
  5398. 'id': parseInt(xPathTroll.children[2].innerHTML),
  5399. 'name': xPathTroll.children[3].innerHTML,
  5400. 'sciz_desc': null,
  5401. 'node': xPathTroll,
  5402. });
  5403. ids.push(xPathTroll.children[2].innerHTML);
  5404. }
  5405.  
  5406. // Add the new column for the SCIZ troll view
  5407. const xPathHeaderTrollQuery = "//*/table[@id='VueTROLL']/thead/tr";
  5408. var xPathHeaderTrolls = document.evaluate(xPathHeaderTrollQuery, document, null, 0, null).iterateNext();
  5409. var th = document.createElement('th');
  5410. th.align = 'center';
  5411. th.appendChild(scizCreateIcon('25', 'block', 'sciz-logo-quarter.png'));
  5412. xPathHeaderTrolls.insertBefore(th, xPathHeaderTrolls.children[4]);
  5413. for (i = 0; i < scizGlobal.trolls.length; i++) {
  5414. var td = document.createElement('td');
  5415. td.align = 'center';
  5416. scizGlobal.trolls[i].node.insertBefore(td, scizGlobal.trolls[i].node.children[4]);
  5417. }
  5418.  
  5419. // Call SCIZ
  5420. var sciz_url = 'https://www.sciz.fr/api/hook/trolls';
  5421. FF_XMLHttpRequest({
  5422. method: 'POST',
  5423. url: sciz_url,
  5424. headers: { 'Authorization': jwt, 'Content-type': 'application/json'},
  5425. data: JSON.stringify({'ids': ids}),
  5426. onload: function(responseDetails) {
  5427. try {
  5428. if (responseDetails.status == 0) {
  5429. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5430. window.console.log(responseDetails);
  5431. return;
  5432. }
  5433. var trolls = JSON.parse(responseDetails.responseText);
  5434. if (trolls.trolls.length < 1) {
  5435. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5436. return;
  5437. }
  5438. // Look for trolls to enhanced
  5439. trolls.trolls.forEach(t => {
  5440. for (i = 0; i < scizGlobal.trolls.length; i++) {
  5441. if (scizGlobal.trolls[i].id === t.id) {
  5442. // PrettyPrint
  5443. t = scizPrettyPrintTroll(t);
  5444. // Store the SCIZ troll desc
  5445. scizGlobal.trolls[i].sciz_desc = t;
  5446. // Add the SCIZ view
  5447. scizGlobal.trolls[i].node.children[4].innerHTML = t;
  5448. }
  5449. }
  5450. });
  5451. } catch(e) {
  5452. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5453. window.console.log(e);
  5454. }
  5455. }
  5456. });
  5457. }
  5458.  
  5459. cbx = MY_getValue(numTroll + '.SCIZ_CB_VIEW_TREASURES');
  5460. if (cbx !== '0') {
  5461. // Retrieve treasures
  5462. var ids = [];
  5463. const xPathQuery = "//*/table[@id='VueTRESOR']/tbody/tr";
  5464. var xPathEvents = document.evaluate(xPathQuery, document, null, 0, null);
  5465. while (xPathEvent = xPathEvents.iterateNext()) {
  5466. scizGlobal.treasures.push({
  5467. 'id': parseInt(xPathEvent.children[2].innerHTML),
  5468. 'type': xPathEvent.children[3].innerHTML,
  5469. 'sciz_desc': null,
  5470. 'buried': xPathEvent.children[3].innerHTML.includes('Enterré'),
  5471. 'node': xPathEvent,
  5472. });
  5473. ids.push(xPathEvent.children[2].innerHTML)
  5474. if (scizGlobal.treasures.length >= scizSetup.viewMaxEnhancedTreasure) { break; }
  5475. }
  5476.  
  5477. // Call SCIZ
  5478. var sciz_url = 'https://www.sciz.fr/api/hook/treasures';
  5479. FF_XMLHttpRequest({
  5480. method: 'POST',
  5481. url: sciz_url,
  5482. headers: { 'Authorization': jwt, 'Content-type': 'application/json'},
  5483. data: JSON.stringify({'ids': ids}),
  5484. onload: function(responseDetails) {
  5485. try {
  5486. if (responseDetails.status == 0) {
  5487. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5488. window.console.log(responseDetails);
  5489. return;
  5490. }
  5491. var treasures = JSON.parse(responseDetails.responseText);
  5492. if (treasures.treasures.length < 1) {
  5493. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5494. return;
  5495. }
  5496. // Look for treasures to enhanced
  5497. treasures.treasures.forEach(t => {
  5498. for (i = 0; i < scizGlobal.treasures.length; i++) {
  5499. if (scizGlobal.treasures[i].id === t.id) {
  5500. // PrettyPrint
  5501. t = scizPrettyPrintTreasure(t);
  5502. // Store the SCIZ treasure desc
  5503. scizGlobal.treasures[i].sciz_desc = t;
  5504. // Adapt the sciz type (delete the buried marker, the do_scizSwitchTreasures will handle it)
  5505. scizGlobal.treasures[i].type = scizGlobal.treasures[i].node.children[3].firstChild.textContent;
  5506. }
  5507. }
  5508. });
  5509. } catch(e) {
  5510. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5511. window.console.log(e);
  5512. }
  5513. // Do the display overwrite and add the switches
  5514. do_scizSwitchTreasures();
  5515. }
  5516. });
  5517. }
  5518. }
  5519.  
  5520. function do_scizSwitchTreasures() {
  5521. scizGlobal.treasures.forEach((t) => {
  5522. if (t.sciz_desc !== null) {
  5523. // Do the switch
  5524. const currentDesc = t.node.children[3].firstChild.textContent;
  5525. t.node.children[3].innerHTML = (currentDesc === t.type) ? ((t.sciz_desc !== null) ? t.sciz_desc : t.type) : t.type;
  5526. if (t.buried) {
  5527. t.node.children[3].innerHTML += '<img src="/mountyhall/Images/hidden.png" alt="[Enterré]" title="Enterré" width="15" height="15">';
  5528. }
  5529. // Add the SCIZ switcher
  5530. t.node.children[3].appendChild(scizCreateClickable('15', 'inline', do_scizSwitchTreasures));
  5531. }
  5532. });
  5533. }
  5534.  
  5535. /* SCIZ - Events */
  5536.  
  5537. function scizPrettyPrintEvent(e) {
  5538. 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
  5539. e.message = e.message.replace(/\n\s*\n*/g, '<br/>');
  5540. 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]];
  5541. beings.forEach(b => {
  5542. if (b[0] && b[1]) {
  5543. b[1] = b[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  5544. if (b[0].toString().length > 6) {
  5545. // Mob
  5546. b[1] = b[1].replace(/^une?\s/g, '');
  5547. 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>');
  5548. } else {
  5549. // Troll
  5550. e.message = e.message.replace(new RegExp('(' + b[1] + ')','gi'), '<b><a href="javascript:EPV(\'' + b[0] + '\')" class="mh_trolls_1">\$1</a></b>');
  5551. }
  5552. }
  5553. });
  5554. return e;
  5555. }
  5556.  
  5557. function do_scizOverwriteEvents() {
  5558. scizGlobal.events = [];
  5559. var eventTableNode = null;
  5560.  
  5561. // Ensure we have a JWT setup for the current user
  5562. jwt = MY_getValue(numTroll + '.SCIZJWT');
  5563. cbx = MY_getValue(numTroll + '.SCIZ_CB_EVENTS');
  5564. if (!jwt || cbx === '0') { return; }
  5565.  
  5566. // Retrieve being ID
  5567. const url = new URL(window.location.href);
  5568. var id = url.searchParams.get('ai_IDPJ');
  5569. id = (!id) ? numTroll : id;
  5570.  
  5571. // Check for advanced profil
  5572. const advanced = document.querySelector("[href*='MH_Style_ProfilAvance.css']") !== null;
  5573. const xPathQuery = (advanced) ? "//*/table[@id='events']/tbody/tr" : "//*/tr[@class='mh_tdpage']";
  5574.  
  5575. // Retrieve local events
  5576. var xPathEvents = document.evaluate(xPathQuery, document, null, 0, null);
  5577. while (xPathEvent = xPathEvents.iterateNext()) {
  5578. scizGlobal.events.push({
  5579. 'time': Date.parse(StringToDate(xPathEvent.children[0].innerHTML)),
  5580. 'type': xPathEvent.children[1].innerHTML,
  5581. 'desc': xPathEvent.children[2].innerHTML,
  5582. 'sciz_type': null,
  5583. 'sciz_desc': null,
  5584. 'node': xPathEvent,
  5585. });
  5586. if (eventTableNode === null) {
  5587. eventTableNode = xPathEvent.parentNode.parentNode;
  5588. }
  5589. }
  5590.  
  5591. const startTime = Math.min.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) - scizSetup.eventsMaxMatchingInterval;
  5592. const endTime = Math.max.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) + scizSetup.eventsMaxMatchingInterval;
  5593.  
  5594. // Check if events have been found in the page
  5595. if (scizGlobal.events.length < 1) {
  5596. window.console.log('ERREUR - MZ/SCIZ - Aucun événement trouvé sur la page...');
  5597. return;
  5598. }
  5599.  
  5600. // Call SCIZ
  5601. var sciz_url = 'https://www.sciz.fr/api/hook/events/' + id + '/' + startTime + '/' + endTime;
  5602. const eventType = url.searchParams.get('as_EventType'); // Retrieve event type filter
  5603. sciz_url += (eventType !== null && eventType !== '') ? '/' + eventType.split(' ')[0] : '' // Only the first word used for filtering ("MORT par monstre" => "MORT");
  5604. FF_XMLHttpRequest({
  5605. method: 'GET',
  5606. url: sciz_url,
  5607. headers: { 'Authorization': jwt },
  5608. // trace: 'Appel à SCIZ pour l'entité ' + id,
  5609. onload: function(responseDetails) {
  5610. try {
  5611. if (responseDetails.status == 0) {
  5612. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5613. window.console.log(responseDetails);
  5614. return;
  5615. }
  5616. var events = JSON.parse(responseDetails.responseText);
  5617. if (events.events.length < 1) {
  5618. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5619. return;
  5620. }
  5621. // Look for events to overwrite (based on timestamps)
  5622. events.events.forEach(e => {
  5623. if (e.message.includes(id)) { // Exclude any event we were not looking for...
  5624. const t = Date.parse(StringToDate(e.time));
  5625. // Look for the best event matching and not already replaced
  5626. var i = -1;
  5627. var lastDelta = Infinity;
  5628. for (j = 0; j < scizGlobal.events.length; j++) {
  5629. if (scizGlobal.events[j].sciz_desc === null) {
  5630. var delta = Math.abs(t - scizGlobal.events[j].time);
  5631. if (delta <= scizSetup.eventsMaxMatchingInterval && delta < lastDelta) {
  5632. lastDelta = delta;
  5633. i = j;
  5634. }
  5635. }
  5636. }
  5637. if (i > -1) {
  5638. // PrettyPrint
  5639. e = scizPrettyPrintEvent(e);
  5640. // Store the SCIZ event and icon
  5641. var div = scizCreateIcon('25', 'block', e.icon);
  5642. scizGlobal.events[i].sciz_type = div.outerHTML;
  5643. scizGlobal.events[i].sciz_desc = e.message;
  5644. // Actual display overwrite
  5645. scizGlobal.events[i].node.children[1].setAttribute("valign", "middle");
  5646. scizGlobal.events[i].node.children[2].setAttribute("valign", "middle");
  5647. scizGlobal.events[i].node.children[1].innerHTML = scizGlobal.events[i].sciz_type;
  5648. scizGlobal.events[i].node.children[2].innerHTML = scizGlobal.events[i].sciz_desc;
  5649. }
  5650. }
  5651. });
  5652. // Add the switch button
  5653. if (eventTableNode !== null) {
  5654. var div = scizCreateClickable('50', 'block', do_scizSwitchEvents);
  5655. eventTableNode.parentNode.insertBefore(div, eventTableNode.nextSibling);
  5656. }
  5657. } catch(e) {
  5658. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5659. window.console.log(e);
  5660. }
  5661. }
  5662. });
  5663. }
  5664.  
  5665. function do_scizSwitchEvents() {
  5666. scizGlobal.events.forEach((e) => {
  5667. const currentType = e.node.children[1].innerHTML;
  5668. e.node.children[1].innerHTML = (currentType === e.type) ? ((e.sciz_type !== null) ? e.sciz_type : e.type) : e.type;
  5669. const currentDesc = e.node.children[2].innerHTML;
  5670. e.node.children[2].innerHTML = (currentDesc === e.desc) ? ((e.sciz_desc !== null) ? e.sciz_desc : e.desc) : e.desc;
  5671. });
  5672. }
  5673.  
  5674. /*******************************************************************************
  5675. * This file is part of Mountyzilla. *
  5676. * *
  5677. * Mountyzilla is free software; you can redistribute it and/or modify *
  5678. * it under the terms of the GNU General Public License as published by *
  5679. * the Free Software Foundation; either version 2 of the License, or *
  5680. * (at your option) any later version. *
  5681. * *
  5682. * Mountyzilla is distributed in the hope that it will be useful, *
  5683. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5684. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5685. * GNU General Public License for more details. *
  5686. * *
  5687. * You should have received a copy of the GNU General Public License *
  5688. * along with Mountyzilla; if not, write to the Free Software *
  5689. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5690. *******************************************************************************/
  5691.  
  5692. // x~x mission
  5693.  
  5694. /* TODO
  5695. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  5696. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  5697. *
  5698. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  5699. */
  5700. function isArray(a) {
  5701. return (!!a) && (a.constructor === Array);
  5702. }
  5703.  
  5704. function saveMission(num,obEtape) {
  5705. var obMissions;
  5706. if(MY_getValue(numTroll+'.MISSIONS')) {
  5707. try {
  5708. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5709. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  5710. } catch(e) {
  5711. window.console.error(traceStack(e, 'Mission parsage'));
  5712. return;
  5713. }
  5714. }
  5715. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  5716. if (obMissions == undefined) obMissions = new Object(); // protection
  5717. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  5718. if(obEtape) {
  5719. obMissions[num] = obEtape;
  5720. } else if(obMissions[num]) {
  5721. delete obMissions[num];
  5722. }
  5723. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  5724. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5725. }
  5726.  
  5727. function addtroogle(tdLibelle, sRestrict) {
  5728. var img = document.createElement('img');
  5729. img.src = URL_MZimg + 'troogle.ico';
  5730. img.alt = 'Troogle logo';
  5731. var a = document.createElement('a');
  5732. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  5733. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  5734. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  5735. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  5736. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  5737. a.href = url;
  5738. a.title = 'Chercher sur Troogle';
  5739. a.target = 'troogle';
  5740. a.appendChild(img);
  5741. tdLibelle.appendChild(a);
  5742. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  5743. }
  5744.  
  5745. function traiteMission() {
  5746. try {
  5747. var titreMission = document.getElementsByClassName('titre2')[0];
  5748. var numMission = titreMission.textContent.match(/\d+/)[0];
  5749. var missionForm = document.getElementsByName('ActionForm')[0];
  5750. var tdLibelle = document.evaluate(
  5751. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  5752. missionForm, null, 9, null).singleNodeValue;
  5753. } catch(e) {
  5754. window.console.error(traceStack(e, 'récupération mission'));
  5755. return;
  5756. }
  5757. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  5758. try {
  5759. if(!tdLibelle) {
  5760. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  5761. debugMZ('traiteMission, la mission semble terminée');
  5762. saveMission(numMission,false);
  5763. return;
  5764. }
  5765.  
  5766. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  5767. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  5768. // debug Roule'
  5769. if (MY_DEBUG) {
  5770. for (var i =0; i < tdLibelle.childNodes.length; i++)
  5771. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  5772. }
  5773. if(libelle.indexOf('niveau égal à')!=-1) {
  5774. var nbKills = 1, niveau, mod;
  5775. // exemples :
  5776. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  5777. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  5778. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  5779. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  5780. if (tdLibelle.childNodes.length == 1) {
  5781. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  5782. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  5783. if (m) {
  5784. niveau = Number(m[1]);
  5785. mod = 'plus'
  5786. } else {
  5787. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  5788. if (m) {
  5789. niveau = Number(m[1]);
  5790. mod = Number(m[2]);
  5791. } else {
  5792. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  5793. return;
  5794. }
  5795. }
  5796. } else {
  5797. // ancienne méthode (multi childnode)
  5798. // à supprimer un jour peut-être
  5799. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  5800. // Étape de kill multiple de niveau donné
  5801. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5802. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  5803. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5804. niveau = Number(mod[0]);
  5805. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5806. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  5807. } else {
  5808. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  5809. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5810. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  5811. mod = mod ? Number(mod[0]) : 'plus';
  5812. }
  5813. } else {
  5814. // Étape de kill unique de niveau donné
  5815. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  5816. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5817. mod = mod ? Number(mod[0]) : 'plus';
  5818. }
  5819. }
  5820. // if (isDEV) {
  5821. // niveau = 35; // pour les tests Roule
  5822. // alert('niveau forcé à 35 pour test');
  5823. // }
  5824. // debug Roule'
  5825. if (MY_DEBUG) {
  5826. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  5827. }
  5828. saveMission(numMission,{
  5829. type: 'Niveau',
  5830. niveau: niveau,
  5831. mod: mod,
  5832. mundidey: siMundidey,
  5833. libelle: libelle
  5834. });
  5835. if (mod == 'plus')
  5836. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  5837. else
  5838. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  5839. } else if(libelle.indexOf('de la race')!=-1) {
  5840. var nbKills = 1, race;
  5841. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  5842. // Étape de kill multiple de race donnée
  5843. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5844. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5845. } else {
  5846. // Étape de kill unique de race donnée
  5847. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5848. }
  5849. race = race.replace(/\"/g,'');
  5850. race = removeEnclosingSimpleCote(race); // Roule 29/03/2019 Maintenant, on a des '
  5851. saveMission(numMission,{
  5852. type: 'Race',
  5853. race: race,
  5854. mundidey: siMundidey,
  5855. libelle: libelle
  5856. });
  5857. addtroogle(tdLibelle, '@monstre ' + race);
  5858. } else if(libelle.indexOf('de la famille')!=-1) {
  5859. var nbKills = 1, famille;
  5860. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  5861. // Étape de kill multiple de famille donnée
  5862. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5863. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5864. } else {
  5865. // Étape de kill unique de famille donnée
  5866. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5867. }
  5868. famille = famille.replace(/\"/g,'');
  5869. famille = removeEnclosingSimpleCote(famille); // Roule 29/03/2019 Maintenant, on a des '
  5870. saveMission(numMission,{
  5871. type: 'Famille',
  5872. famille: famille,
  5873. mundidey: siMundidey,
  5874. libelle: libelle
  5875. });
  5876. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  5877. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  5878. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  5879. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  5880. debugMZ('traiteMission étape capacité spéciale');
  5881. pouvoir = removeEnclosingSimpleCote(pouvoir); // Roule 29/03/2019 Maintenant, on a des '
  5882. saveMission(numMission,{
  5883. type: 'Pouvoir',
  5884. pouvoir: pouvoir,
  5885. libelle: libelle
  5886. });
  5887. } else {
  5888. debugMZ('traiteMission étape pas pour troogle');
  5889. saveMission(numMission,false);
  5890. }
  5891. } catch(e) {
  5892. window.console.error(traceStack(e, 'récupération étape mission'));
  5893. return;
  5894. }
  5895. }
  5896.  
  5897. function removeEnclosingSimpleCote(x) { // Roule 29/03/2019
  5898. return x.replace(/'$/, '').replace(/^'/, '');
  5899. }
  5900.  
  5901. function do_mission() {
  5902. start_script(60);
  5903.  
  5904. traiteMission();
  5905.  
  5906. displayScriptTime();
  5907. }
  5908.  
  5909. /*******************************************************************************
  5910. * This file is part of Mountyzilla. *
  5911. * *
  5912. * Mountyzilla is free software; you can redistribute it and/or modify *
  5913. * it under the terms of the GNU General Public License as published by *
  5914. * the Free Software Foundation; either version 2 of the License, or *
  5915. * (at your option) any later version. *
  5916. * *
  5917. * Mountyzilla is distributed in the hope that it will be useful, *
  5918. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5919. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5920. * GNU General Public License for more details. *
  5921. * *
  5922. * You should have received a copy of the GNU General Public License *
  5923. * along with Mountyzilla; if not, write to the Free Software *
  5924. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5925. *******************************************************************************/
  5926.  
  5927. // x~x move
  5928.  
  5929. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  5930.  
  5931. var petitsTrous = {
  5932. '-52;57': true,
  5933. '55;70': true,
  5934. '64;70': true,
  5935. '12;-15': true,
  5936. '30;-52': true,
  5937. '48;-39': true
  5938. };
  5939.  
  5940. var grosTrous = {
  5941. '-35;65': true,
  5942. '-13;73': true,
  5943. '-64;9': true,
  5944. '-35;15': true,
  5945. '5;32': true,
  5946. '10;64': true,
  5947. '21;36': true,
  5948. '46;52': true,
  5949. '74;32': true,
  5950. '-71;-7': true,
  5951. '-67;-37': true,
  5952. '-60;-32': true,
  5953. '-51;-22': true,
  5954. '-36;-51': true,
  5955. '5;-49': true
  5956. };
  5957.  
  5958. var centreCarmine_X = 56.5;
  5959. var centreCarmine_Y = 23.5;
  5960. var rayonCarmine = 8.7;
  5961.  
  5962. function isTrou(x,y,n) {
  5963. if(petitsTrous[x+';'+y]) {
  5964. return n<0 && n>-60;
  5965. }
  5966. if(grosTrous[x+';'+y]
  5967. || grosTrous[x-1+';'+y]
  5968. || grosTrous[x+';'+y+1]
  5969. || grosTrous[x-1+';'+y+1]) {
  5970. return n<0 && n>-70;
  5971. }
  5972. if(Math.sqrt(
  5973. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  5974. )<=rayonCarmine) {
  5975. return n<0 && n>-100;
  5976. }
  5977. return false;
  5978. }
  5979.  
  5980. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  5981.  
  5982. function validateDestination() {
  5983. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  5984. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  5985. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  5986. var form = document.getElementsByName('ActionForm')[0];
  5987. if(form) {
  5988. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  5989. if(document.getElementsByName('ai_DeplX')[i].checked) {
  5990. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  5991. }
  5992. }
  5993. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  5994. if(document.getElementsByName('ai_DeplY')[i].checked) {
  5995. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  5996. }
  5997. }
  5998. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  5999. if(document.getElementsByName('ai_DeplN')[i].checked) {
  6000. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  6001. }
  6002. }
  6003. if(isTrou(x,y,n)) {
  6004. return window.confirm(
  6005. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  6006. +'Vous allez tomber dans un trou de météorite.\n'
  6007. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  6008. );
  6009. }
  6010. }
  6011. return true;
  6012. }
  6013.  
  6014. function newsubmitDE(event) {
  6015. event.stopPropagation();
  6016. event.preventDefault();
  6017. if(validateDestination()) {
  6018. this.submit();
  6019. }
  6020. }
  6021.  
  6022. function changeValidation() {
  6023. var form = document.getElementsByName('ActionForm')[0];
  6024. if(form) {
  6025. form.addEventListener('submit', newsubmitDE, true);
  6026. }
  6027. }
  6028.  
  6029.  
  6030. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  6031.  
  6032. function validateTPDestination() {
  6033. try {
  6034. var text = document.getElementsByTagName('B')[0];
  6035. var a = text.firstChild.nodeValue.split('|');
  6036. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  6037. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  6038. var pos_n = a[2].substring(5, a[2].length) * 1;
  6039.  
  6040. var nbtrous = 0;
  6041. for(var signX=-1 ; signX<=1 ; signX+=2) {
  6042. for(var x=0 ; x<=2 ; x++) {
  6043. for(var signY=-1 ; signY<=1 ; signY+=2) {
  6044. for(var y=0 ; y<=2 ; y++) {
  6045. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  6046. for(var n = 0 ; n <= 1 ; n++) {
  6047. if(isTrou(
  6048. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  6049. )) {
  6050. nbtrous++;
  6051. }
  6052. }
  6053. }
  6054. }
  6055. }
  6056. }
  6057. }
  6058. if(nbtrous>0 && nbtrous<72) {
  6059. return window.confirm(
  6060. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  6061. +'Vous avez '+Math.floor((100*nbtrous)/144)
  6062. +'% de risque de tomber dans un trou de météorite.\n'
  6063. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  6064. );
  6065. }
  6066. else if(nbtrous>=72) {
  6067. return window.confirm(
  6068. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  6069. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  6070. +'% de risque de tomber dans un trou de météorite !\n'
  6071. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  6072. );
  6073. }
  6074. return true;
  6075. }
  6076. catch(e) {
  6077. window.alert(e)
  6078. }
  6079. }
  6080.  
  6081. function newsubmitTP(event) {
  6082. event.stopPropagation();
  6083. event.preventDefault();
  6084. if(validateTPDestination()) {
  6085. this.submit();
  6086. }
  6087. }
  6088.  
  6089. function changeButtonValidate() {
  6090. var form = document.getElementsByName('Formulaire')[0];
  6091. if(form) {
  6092. if(!form.getAttribute('onsubmit')) {
  6093. form.setAttribute('onsubmit','return true;');
  6094. }
  6095. form.addEventListener('submit', newsubmitTP, true);
  6096. }
  6097. }
  6098.  
  6099.  
  6100. /*-[functions]---------------- Partie Principale -----------------------------*/
  6101.  
  6102. function do_move() {
  6103. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  6104. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  6105. changeValidation();
  6106. //}
  6107. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  6108. // changeButtonValidate();
  6109. //}
  6110. }
  6111.  
  6112. /*******************************************************************************
  6113. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  6114. * Mountyzilla is free software; provided under the GNU General Public License *
  6115. *******************************************************************************/
  6116.  
  6117. // x~x news
  6118.  
  6119. // Nombre de news à afficher & nb max de caractères par news:
  6120. var nbItems = 5;
  6121. var maxCarDescription = 300;
  6122.  
  6123. /*-[functions]------------------- Utilitaires --------------------------------*/
  6124.  
  6125. // Ne semble avoir strictement aucun effet:
  6126. String.prototype.epureDescription = function() {
  6127. return this.replace(/\\(.)/g,"$1");
  6128. }
  6129.  
  6130. function appendTitledTable(node,titre,description) {
  6131. // Crée les tables contenant les infos (avec titre)
  6132. var table = document.createElement('table');
  6133. table.border = 0;
  6134. table.className = 'mh_tdborder';
  6135. table.cellSpacing = 1;
  6136. table.cellPadding = 1;
  6137. table.style.maxWidth = '98%';
  6138. table.style.marginLeft = 'auto';
  6139. table.style.marginRight = 'auto';
  6140. var tbody = document.createElement('tbody');
  6141. table.appendChild(tbody);
  6142. var tr = appendTr(tbody,'mh_tdtitre');
  6143. var td = appendTdCenter(tr,2);
  6144. var span = document.createElement('span');
  6145. appendText(span,titre,true);
  6146. if(description) {
  6147. span.title = description;
  6148. }
  6149. td.appendChild(span);
  6150. node.appendChild(table);
  6151. return tbody;
  6152. }
  6153.  
  6154. function testCertif(paramURL, callbackOnError) {
  6155. try {
  6156. FF_XMLHttpRequest({
  6157. method: 'GET',
  6158. url: paramURL,
  6159. onload: function(responseDetails) {
  6160. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  6161. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  6162. }
  6163. });
  6164. } catch(e) {
  6165. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  6166. callbackOnError();
  6167. }
  6168. }
  6169.  
  6170. function createOrGetGrandCadre() {
  6171. var grandCadre = document.getElementById('grandCadre');
  6172. if (grandCadre) return grandCadre;
  6173. try {
  6174. var rappels = document.evaluate(
  6175. "//p[contains(a/text(),'messagerie')]",
  6176. document, null, 9, null).singleNodeValue;
  6177. }
  6178. catch(e) {
  6179. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  6180. grandCadre = document.createElement('div');
  6181. return grandCadre;
  6182. }
  6183. grandCadre = document.createElement('div');
  6184. grandCadre.id = 'grandCadre';
  6185. var sousCadre = document.createElement('div');
  6186. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  6187. sousCadre.style.textAlign = 'center';
  6188. sousCadre.style.fontSize = 'xx-large';
  6189. grandCadre.appendChild(sousCadre);
  6190.  
  6191. grandCadre.style.border = 'solid 5px red';
  6192. grandCadre.style.width = 'auto';
  6193. insertBefore(rappels,grandCadre);
  6194. return grandCadre;
  6195. }
  6196.  
  6197. function showHttpsErrorCadre1() {
  6198. window.console.log('[MZ] showHttpsErrorCadre1');
  6199. var grandCadre = createOrGetGrandCadre();
  6200. var sousCadre = document.createElement('div');
  6201. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  6202. + '<br />Cela empêchera Moutyzilla de fonctionner'
  6203. + '<br /><a style="color:blue;font-size: inherits;" href="'
  6204. + URL_CertifRaistlin1
  6205. + '" target="raistlin">clique ici</a>'
  6206. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6207. + ' « Confirmer l\'exception de sécurité »'
  6208. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6209. sousCadre.style.width = 'auto';
  6210. sousCadre.style.fontSize = 'large';
  6211. sousCadre.style.border = 'solid 1px black';
  6212. sousCadre.style.backgroundColor = 'red';
  6213. grandCadre.appendChild(sousCadre);
  6214. }
  6215.  
  6216. function showHttpsErrorCadre2() {
  6217. window.console.log('[MZ] showHttpsErrorCadre2');
  6218. var grandCadre = createOrGetGrandCadre();
  6219. var sousCadre = document.createElement('div');
  6220. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  6221. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  6222. + '<a style="color:blue;font-size: inherits;" href="'
  6223. + URL_CertifRaistlin2
  6224. + '" target="raistlin">clique ici</a>'
  6225. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6226. + ' « Confirmer l\'exception de sécurité »'
  6227. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  6228. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6229. sousCadre.style.width = 'auto';
  6230. sousCadre.style.fontSize = 'large';
  6231. sousCadre.style.border = 'solid 1px black';
  6232. sousCadre.style.backgroundColor = 'red';
  6233. grandCadre.appendChild(sousCadre);
  6234. }
  6235.  
  6236. function showHttpsErrorContenuMixte() {
  6237. window.console.log('[MZ] showHttpsErrorContenuMixte');
  6238. var grandCadre = createOrGetGrandCadre();
  6239. var sousCadre = document.createElement('div');
  6240. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  6241. + '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)'
  6242. + '<ul>'
  6243. + '<li>Interface Bricol\'Troll</li>'
  6244. + '<li>Nouveautés de Mountyzilla</li>'
  6245. + '</ul>'
  6246. + '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 />'
  6247. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  6248. sousCadre.style.width = 'auto';
  6249. sousCadre.style.fontSize = 'large';
  6250. sousCadre.style.border = 'solid 1px black';
  6251. grandCadre.appendChild(sousCadre);
  6252. }
  6253.  
  6254. /*-[functions]------------------- Jubilaires ---------------------------------*/
  6255.  
  6256. function traiterJubilaires() {
  6257. // à faire
  6258. }
  6259.  
  6260. function traiterJubilaires_a_supprimer() { // ancienne méthode
  6261. try {
  6262. FF_XMLHttpRequest({
  6263. method: 'GET',
  6264. url: URL_anniv,
  6265. headers: {
  6266. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  6267. 'Accept': 'application/xml,text/xml',
  6268. },
  6269. onload: function(responseDetails) {
  6270. if ((responseDetails.status == 0) && isHTTPS) {
  6271. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  6272. //showHttpsErrorContenuMixte();
  6273. return;
  6274. }
  6275. var listeTrolls = responseDetails.responseText.split('\n');
  6276. if(!listeTrolls || listeTrolls.length==0) {
  6277. return;
  6278. }
  6279. afficherJubilaires(listeTrolls);
  6280. },
  6281. });
  6282. }
  6283. catch(e) {
  6284. if (isHTTPS) {
  6285. window.console.log(traceStack(e, 'appel jubilaires'));
  6286. showHttpsErrorContenuMixte();
  6287. } else {
  6288. window.alert('Erreur Jubilaires:\n'+e);
  6289. }
  6290. }
  6291. }
  6292.  
  6293. function afficherJubilaires(listeTrolls) {
  6294. try {
  6295. var rappels = document.evaluate(
  6296. "//p[contains(a/text(),'messagerie')]",
  6297. document, null, 9, null).singleNodeValue;
  6298. }
  6299. catch(e) {
  6300. return;
  6301. }
  6302. var p = document.createElement('p');
  6303. var tbody = appendTitledTable(p,
  6304. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  6305. 'Envoyez leur un message ou un cadeau !'
  6306. );
  6307. tr = appendTr(tbody,'mh_tdpage');
  6308. td = appendTdCenter(tr);
  6309. var small = document.createElement('small');
  6310. td.appendChild(small);
  6311. var first = true;
  6312. for(var i=0 ; i<listeTrolls.length ; i++) {
  6313. var infos = listeTrolls[i].split(';');
  6314. if(infos.length!=3 || infos[2]==='0') {
  6315. continue;
  6316. }
  6317. if(first) {
  6318. first = false;
  6319. }
  6320. else {
  6321. appendText(small,', ');
  6322. }
  6323. var a = document.createElement('a');
  6324. a.href = 'javascript:EPV('+infos[0]+')';
  6325. appendText(a,infos[1]);
  6326. small.appendChild(a);
  6327. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  6328. }
  6329. insertBefore(rappels,p);
  6330. }
  6331.  
  6332.  
  6333. /*-[functions]--------------------- News MZ ----------------------------------*/
  6334.  
  6335. function traiterNouvelles() {
  6336. var news = new Array;
  6337. news.push(['15/11/2019', 'Refonte des calculs tactiques dans la vue. Affichage du niveau du monstre à tout coup (ou presque).']);
  6338. 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 ;).']);
  6339. afficherNouvelles(news);
  6340. }
  6341.  
  6342. function afficherNouvelles(items) {
  6343. var footer = document.getElementById('footer1');
  6344. if(!footer) {
  6345. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  6346. return;
  6347. }
  6348. var p = document.createElement('p');
  6349. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  6350. var div = document.createElement('div');
  6351. div.style.position = 'absolute';
  6352. div.style.right = 0;
  6353. div.style.top = 0;
  6354. div.style.paddingRight = '3px';
  6355. div.style.whiteSpace = 'nowrap';
  6356. appendText(div, '(version ' + GM_info.script.version + ')');
  6357. tbody.rows[0].cells[0].style.position = 'relative';
  6358. tbody.rows[0].cells[0].appendChild(div);
  6359. for(var i=0 ; i<items.length ; i++) {
  6360. var tr = appendTr(tbody,'mh_tdpage');
  6361. var td = appendTdCenter(tr);
  6362. td.style.verticalAlign = 'top'; // semble sans effet
  6363. appendText(td,items[i][0],true);
  6364. td = appendTd(tr);
  6365. td.innerHTML = items[i][1];
  6366. }
  6367. insertBefore(footer,p);
  6368.  
  6369. // changelog
  6370. var p = document.createElement('p');
  6371. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  6372. tbody.rows[0].cells[0].style.cursor = 'pointer';
  6373. tbody.rows[0].cells[0].onclick = function() {
  6374. try {
  6375. tbody.rows[0].cells[0].onclick = undefined;
  6376. tbody.rows[0].cells[0].style.cursor = '';
  6377. var tr = appendTr(tbody,'mh_tdpage');
  6378. var td = appendTd(tr);
  6379. td.colSpan = 2;
  6380. var pre = document.createElement('pre');
  6381. appendText(pre,MZ_changeLog.join("\n"));
  6382. td.appendChild(pre);
  6383. } catch (e) {
  6384. window.console.log('[MZ] affichage changeLog', e);
  6385. }
  6386. };
  6387. insertBefore(footer,p);
  6388.  
  6389. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  6390. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  6391. if (isHTTPS) {
  6392. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  6393. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6394. } else {
  6395. window.console.log('[MZ test] début switch to https');
  6396. window.sessionStorage.setItem('xxx', "test session trans https");
  6397. window.parent.xxx = "autre test";
  6398. var url = document.location.href;
  6399. window.console.log('[MZ test] url=' + url);
  6400. url = url.replace(/http:\/\//i, 'https://')
  6401. window.console.log('[MZ test] switched url=' + url);
  6402. document.location.href = url;
  6403. }
  6404. }
  6405. if (false) { // version par utilisation d'un IFrame en https
  6406. if (isHTTPS) {
  6407. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  6408. //window.console.log('[MZ test] window.name=' + window.name);
  6409. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  6410. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6411. var txt = window.name;
  6412. var tabtxt = txt.split(/µ/);
  6413. for (var i = 0; i < tabtxt.length; i++) {
  6414. window.console.log('[MZ test]config https ' + tabtxt[i]);
  6415. }
  6416. } else {
  6417. var txt = '';
  6418. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6419. var k = localStorage.key(i);
  6420. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6421. txt += k + "£" + localStorage.getItem(k) + "µ";
  6422. }
  6423. var iframe = document.createElement('iframe');
  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. //iframe.xxx = "truc en plume";
  6429. iframe.name = txt;
  6430. //window.xxx = "machin";
  6431. iframe.src = url;
  6432. //iframe.document.xxx = "truc en plume";
  6433. document.body.appendChild(iframe);
  6434. iframe.style.display = 'none';
  6435. }
  6436. }
  6437. }
  6438. }
  6439.  
  6440.  
  6441. /*---------------------------------- Main ------------------------------------*/
  6442.  
  6443. function do_news() {
  6444. start_script();
  6445.  
  6446. traiterJubilaires();
  6447. traiterNouvelles();
  6448.  
  6449. /* plus besoin, le certificat est "officiel"
  6450. if (isHTTPS) {
  6451. // test si les certificats raistlin ont été acceptés
  6452. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  6453. var infoit = MY_getValue(numTroll+'.INFOSIT');
  6454. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  6455. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  6456. }
  6457. }
  6458. */
  6459.  
  6460. displayScriptTime();
  6461. }
  6462.  
  6463. /*********************************************************************************
  6464. * This file is part of Mountyzilla. *
  6465. * *
  6466. * Mountyzilla is free software; you can redistribute it and/or modify *
  6467. * it under the terms of the GNU General Public License as published by *
  6468. * the Free Software Foundation; either version 2 of the License, or *
  6469. * (at your option) any later version. *
  6470. * *
  6471. * Mountyzilla is distributed in the hope that it will be useful, *
  6472. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6473. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6474. * GNU General Public License for more details. *
  6475. * *
  6476. * You should have received a copy of the GNU General Public License *
  6477. * along with Mountyzilla; if not, write to the Free Software *
  6478. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6479. *********************************************************************************/
  6480.  
  6481. // x~x tabcompo
  6482.  
  6483. var popup;
  6484.  
  6485. function initPopupTabcompo() {
  6486. popup = document.createElement('div');
  6487. popup.setAttribute('id', 'popup');
  6488. popup.setAttribute('class', 'mh_textbox');
  6489. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  6490. + 'display: inline; z-index: 3; max-width: 400px;');
  6491. document.body.appendChild(popup);
  6492. }
  6493.  
  6494. function showPopup(evt) {
  6495. var texte = this.getAttribute("texteinfo");
  6496. popup.innerHTML = texte;
  6497. popup.style.left = evt.pageX + 15 + 'px';
  6498. popup.style.top = evt.pageY + 'px';
  6499. popup.style.visibility = "visible";
  6500. }
  6501.  
  6502. // roule 16/03/2016, existe déjà ailleurs
  6503. // function hidePopup() {
  6504. // popup.style.visibility = 'hidden';
  6505. // }
  6506.  
  6507. function createPopupImage_tabcompo(url, text)
  6508. {
  6509. var img = document.createElement('img');
  6510. img.setAttribute('src',url);
  6511. img.setAttribute('align','ABSMIDDLE');
  6512. img.setAttribute("texteinfo",text);
  6513. img.addEventListener("mouseover", showPopup,true);
  6514. img.addEventListener("mouseout", hidePopup,true);
  6515. return img;
  6516. }
  6517.  
  6518. function formateTexte_tabcompo(texte)
  6519. {
  6520. texte = texte.replace(/\n/g,"<br/>");
  6521. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  6522. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  6523. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  6524. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  6525. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  6526. return texte;
  6527. }
  6528.  
  6529. function arrondi(x) {
  6530. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  6531. }
  6532.  
  6533. function traiteMinerai_tabcompo() {
  6534. if (currentURL.indexOf("as_type=Divers")==-1) return;
  6535. try {
  6536. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  6537. +" and contains(./tr/th/text(),'Minerai')]",
  6538. document, null, 9, null).singleNodeValue;
  6539. node = node.nextSibling.nextSibling;
  6540. }
  6541. catch(e) {return;}
  6542.  
  6543. var trlist = document.evaluate('./tr', node, null, 7, null);
  6544. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  6545. var node = trlist.snapshotItem(i);
  6546. var nature = node.childNodes[5].textContent;
  6547. var caracs = node.childNodes[7].textContent;
  6548. var taille = caracs.match(/\d+/)[0];
  6549. var coef = 1;
  6550. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  6551. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  6552. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  6553. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6554. if (nature.indexOf('Mithril')!=-1) {
  6555. coef = 0.2*coef;
  6556. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  6557. }
  6558. else {
  6559. coef = 0.75*coef+1.25;
  6560. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6561. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  6562. }
  6563. }
  6564. }
  6565.  
  6566. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  6567. function treateComposants() {
  6568. if (currentURL.indexOf("as_type=Compo")==-1) return;
  6569. //On récupère les composants
  6570. var nodes = document.evaluate(
  6571. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6572. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6573. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  6574. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6575. if (nodes.snapshotLength == 0) {
  6576. //window.console.log('[MZ] treateComposants DOWN');
  6577. return;
  6578. }
  6579. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  6580.  
  6581. var texte = "";
  6582. for (var i = 0; i < nodes.snapshotLength; i++) {
  6583. var n1 = nodes.snapshotItem(i).childNodes[1];
  6584. var n3 = nodes.snapshotItem(i).childNodes[3];
  6585. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6586. var prix = n3.childNodes[0].nodeValue;
  6587. if (!prix)
  6588. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6589. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6590. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6591. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6592. + prix.replace(/\n/g, '') + "\n";
  6593. }
  6594.  
  6595. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6596. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6597. var id_taniere = c.snapshotItem(0).nodeValue;
  6598. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  6599.  
  6600. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6601. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  6602. if (form)
  6603. {
  6604. if(document.getElementsByTagName('form').length>0)
  6605. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6606. else
  6607. {
  6608. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6609. insertBefore(thisP, form);
  6610. }
  6611. }
  6612. }
  6613.  
  6614. function treateAllComposants() {
  6615. if(currentURL.indexOf("as_type=Compo")==-1) return;
  6616.  
  6617. //On récupère les composants
  6618. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  6619. document, null, 0, null ).numberValue;
  6620. var c = (categ == 0 ? 3 : 4);
  6621. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  6622. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  6623. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  6624. + "td["+c+"]/text()[1] = '\u0040-\u0040' "
  6625. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  6626. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  6627. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  6628. + "and td[1]/img/@alt = 'Identifié']",
  6629. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6630. if (nodes.snapshotLength == 0) {
  6631. // window.alert('treateAllComposants DOWN');
  6632. return;
  6633. }
  6634.  
  6635. var texte = "";
  6636. for (var i = 0; i < nodes.snapshotLength; i++) {
  6637. var n1 = nodes.snapshotItem(i).childNodes[1];
  6638. var n3 = nodes.snapshotItem(i).childNodes[3];
  6639. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6640. var prix = n3.childNodes[0].nodeValue;
  6641. if (!prix)
  6642. {
  6643. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  6644. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6645. }
  6646. else
  6647. {
  6648. prix= prix.replace(/[\240 ]/g, "");
  6649. if(prix=="-")
  6650. prix=null;
  6651. }
  6652. if(prix)
  6653. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6654. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6655. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6656. + prix.replace(/\n/g, '') + "\n";
  6657. else
  6658. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6659. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6660. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  6661. }
  6662.  
  6663. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6664. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6665. var id_taniere = c.snapshotItem(0).nodeValue;
  6666. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  6667.  
  6668. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6669. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  6670. if (form)
  6671. {
  6672. if(document.getElementsByTagName('form').length>0)
  6673. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6674. else
  6675. {
  6676. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6677. insertBefore(thisP, form);
  6678. }
  6679. }
  6680. }
  6681.  
  6682. function treateEM()
  6683. {
  6684. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  6685. if(currentURL.indexOf("as_type=Compo")==-1)
  6686. return false;
  6687. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  6688. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  6689. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6690. if (nodes.snapshotLength == 0)
  6691. return false;
  6692. for (var i = 0; i < nodes.snapshotLength; i++) {
  6693. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  6694. var link = desc[2].firstChild ;
  6695. var nomCompoTotal = desc[2].textContent ;
  6696. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6697. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6698. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  6699. var locqual = desc[3].textContent ;
  6700. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  6701. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  6702. if(isEM(nomMonstre).length>0)
  6703. {
  6704. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  6705. if(infos.length>0)
  6706. {
  6707. var shortDescr = "Variable";
  6708. var bold = 0;
  6709. if(infos != "Composant variable")
  6710. {
  6711. shortDescr = infos.substring(0,infos.indexOf(" "));
  6712. if(parseInt(shortDescr)>=0)
  6713. bold=1;
  6714. }
  6715. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  6716. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  6717. }
  6718. }
  6719.  
  6720. }
  6721. }
  6722.  
  6723. function treateChampi_tabcompo() {
  6724. if (currentURL.indexOf('as_type=Champi')==-1)
  6725. return false;
  6726. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  6727. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6728. if (nodes.snapshotLength == 0)
  6729. return false;
  6730.  
  6731. for (var i = 0; i < nodes.snapshotLength; i++) {
  6732. var node = nodes.snapshotItem(i);
  6733. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  6734. if (moisChampi[nomChampi])
  6735. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  6736. }
  6737. }
  6738.  
  6739. function treateEnchant()
  6740. {
  6741. if(currentURL.indexOf("as_type=Compo")==-1)
  6742. return false;
  6743. try
  6744. {
  6745. if(!listeMonstreEnchantement)
  6746. computeCompoEnchantement();
  6747. var nodes = document.evaluate(
  6748. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6749. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6750. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6751. if (nodes.snapshotLength == 0)
  6752. return false;
  6753. var urlImg = URL_MZimg + "enchant.png";
  6754. for (var i = 0; i < nodes.snapshotLength; i++) {
  6755. var link = nodes.snapshotItem(i);
  6756. var nomCompoTotal = link.firstChild.nodeValue;
  6757. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6758. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6759. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  6760. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  6761. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  6762. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  6763. if(isEnchant(nomMonstre).length>0)
  6764. {
  6765. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  6766. if(infos.length>0)
  6767. {
  6768. link.parentNode.appendChild(createImage(urlImg,infos));
  6769. }
  6770. }
  6771. }
  6772. }
  6773. catch(e)
  6774. {
  6775. window.alert(e);
  6776. }
  6777. }
  6778.  
  6779. function treateEquipEnchant()
  6780. {
  6781. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  6782. return false;
  6783. initPopupTabcompo();
  6784. computeEnchantementEquipement(createPopupImage_tabcompo,formateTexte_tabcompo);
  6785. }
  6786.  
  6787. function do_tancompo() {
  6788. start_script();
  6789.  
  6790. treateAllComposants();
  6791. treateComposants();
  6792. traiteMinerai_tabcompo();
  6793. if (MY_getValue('NOINFOEM')!='true') {
  6794. treateChampi_tabcompo();
  6795. treateEM();
  6796. }
  6797. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  6798. treateEnchant();
  6799. treateEquipEnchant();
  6800. }
  6801.  
  6802. displayScriptTime();
  6803. }
  6804.  
  6805. /*******************************************************************************
  6806. * This file is part of Mountyzilla. *
  6807. * *
  6808. * Mountyzilla is free software; you can redistribute it and/or modify *
  6809. * it under the terms of the GNU General Public License as published by *
  6810. * the Free Software Foundation; either version 2 of the License, or *
  6811. * (at your option) any later version. *
  6812. * *
  6813. * Mountyzilla is distributed in the hope that it will be useful, *
  6814. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6815. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6816. * GNU General Public License for more details. *
  6817. * *
  6818. * You should have received a copy of the GNU General Public License *
  6819. * along with Mountyzilla; if not, write to the Free Software *
  6820. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6821. *******************************************************************************/
  6822.  
  6823. // x~x pjview
  6824.  
  6825. /* TODO
  6826. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  6827. */
  6828.  
  6829. // Bulle d'infos
  6830. var DivInfo;
  6831. // Booléen stockant l'état de freezing de la bulle
  6832. var freezed = false;
  6833.  
  6834. // liste du matos
  6835. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  6836. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6837. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  6838. var mh_caracs = {
  6839. 'anneau de protection':
  6840. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  6841. "armure d'anneaux":
  6842. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  6843. 'armure de bois':
  6844. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  6845. 'armure de cuir':
  6846. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  6847. 'armure de peaux':
  6848. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  6849. 'armure de pierre':
  6850. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  6851. 'armure de plates':
  6852. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  6853. 'baton lesté':
  6854. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6855. 'bâtons de parade':
  6856. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6857. 'bottes':
  6858. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6859. 'bouclier à pointes':
  6860. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6861. 'boulet et chaîne':
  6862. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6863. 'cagoule':
  6864. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  6865. 'casque à cornes':
  6866. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6867. 'casque à pointes':
  6868. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  6869. 'casque en cuir':
  6870. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  6871. 'casque en métal':
  6872. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6873. 'chaîne cloutée':
  6874. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6875. 'chapeau pointu':
  6876. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  6877. 'collier de dents':
  6878. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  6879. 'collier de pierre':
  6880. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6881. 'collier à pointes':
  6882. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6883. 'cotte de mailles':
  6884. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  6885. 'couronne de cristal':
  6886. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  6887. "couronne d'obsidienne":
  6888. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  6889. "coutelas d'obsidienne":
  6890. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  6891. 'coutelas en os':
  6892. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  6893. 'crochet':
  6894. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6895. 'cuir bouilli':
  6896. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  6897. "cuirasse d'ossements":
  6898. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  6899. "cuirasse d'écailles":
  6900. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  6901. 'culotte en cuir':
  6902. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6903. 'dague':
  6904. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6905. 'epée courte':
  6906. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6907. 'epée longue':
  6908. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6909. 'espadon':
  6910. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6911. 'fouet':
  6912. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6913. 'fourrures':
  6914. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  6915. 'gantelet':
  6916. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6917. 'gorgeron en cuir':
  6918. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6919. 'gorgeron en métal':
  6920. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  6921. 'gourdin':
  6922. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6923. 'gourdin clouté':
  6924. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6925. 'grimoire':
  6926. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  6927. "gros'porte":
  6928. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  6929. 'grosse racine':
  6930. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6931. 'grosse stalagmite':
  6932. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  6933. 'hache de bataille':
  6934. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6935. 'hache de guerre en os':
  6936. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  6937. 'hache de guerre en pierre':
  6938. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  6939. "hache à deux mains d'obsidienne":
  6940. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  6941. 'hallebarde':
  6942. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  6943. "haubert d'écailles":
  6944. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  6945. 'haubert de mailles':
  6946. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  6947. 'heaume':
  6948. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  6949. 'jambières en cuir':
  6950. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6951. 'jambières en fourrure':
  6952. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  6953. 'jambières en maille':
  6954. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6955. 'jambières en métal':
  6956. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  6957. 'jambières en os':
  6958. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6959. "lame d'obsidienne":
  6960. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  6961. 'lame en os':
  6962. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6963. 'lame en pierre':
  6964. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6965. 'lorgnons':
  6966. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  6967. 'machette':
  6968. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6969. "masse d'arme":
  6970. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6971. 'pagne de mailles':
  6972. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6973. 'pagne en cuir':
  6974. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6975. 'robe de mage':
  6976. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  6977. 'rondache en bois':
  6978. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6979. 'rondache en métal':
  6980. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  6981. 'sandales':
  6982. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6983. 'souliers dorés':
  6984. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6985. "talisman d'obsidienne":
  6986. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  6987. 'talisman de pierre':
  6988. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  6989. 'targe':
  6990. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6991. 'torche':
  6992. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  6993. 'torque de pierre':
  6994. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  6995. 'tunique':
  6996. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6997. "tunique d'écailles":
  6998. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  6999. 'turban':
  7000. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  7001. }
  7002.  
  7003. // liste des templates
  7004. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  7005. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  7006. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  7007. var mh_templates = {
  7008. 'de Feu':
  7009. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7010. 'de Résistance':
  7011. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  7012. "de l'Aigle":
  7013. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  7014. 'de la Salamandre':
  7015. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  7016. 'des Cyclopes':
  7017. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  7018. 'des Enragés':
  7019. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  7020. 'des Tortues':
  7021. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  7022. 'des Vampires':
  7023. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  7024. 'du Glacier':
  7025. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  7026. 'du Rat':
  7027. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  7028. 'du Roc':
  7029. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  7030. 'du Temps':
  7031. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  7032. 'du Vent':
  7033. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  7034. 'en Mithril':
  7035. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7036. 'des Anciens':
  7037. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7038. 'des Champions':
  7039. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7040. 'des Duellistes':
  7041. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7042. 'de la Terre':
  7043. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  7044. "de l'Orage":
  7045. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  7046. "de l'Ours":
  7047. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  7048. 'des Béhémoths':
  7049. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  7050. 'des Mages':
  7051. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  7052. 'du Pic':
  7053. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  7054. 'du Sable':
  7055. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  7056. 'acéré':
  7057. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7058. 'acérée':
  7059. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7060. 'équilibré':
  7061. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7062. 'équilibrée':
  7063. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7064. 'léger':
  7065. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7066. 'légère':
  7067. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7068. 'renforcé':
  7069. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7070. 'renforcée':
  7071. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7072. 'robuste':
  7073. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  7074. }
  7075.  
  7076. function clone(arr) {
  7077. // Clonage rapide
  7078. return arr.slice(0);
  7079. }
  7080.  
  7081. function addArray(arr1,arr2) {
  7082. // Somme matricielle
  7083. var res = clone(arr1);
  7084. for(i=res.length-1 ; i>=0 ; i--) {
  7085. res[i] += arr2[i];
  7086. }
  7087. return res;
  7088. }
  7089.  
  7090. function getTemplates(nomItem) {
  7091. // Déstructure le nom de l'item en array [nom, template1, ...]
  7092. var tempFound = true;
  7093. var str = nomItem.trim();
  7094. var arr = [];
  7095. while(tempFound) {
  7096. tempFound = false;
  7097. for(var temp in mh_templates) {
  7098. // on teste la fin du nom contre chaque template
  7099. if(str.slice(-temp.length)!=temp) { continue; }
  7100. tempFound = true;
  7101. str = str.slice(0,-temp.length-1);
  7102. arr.unshift(temp);
  7103. if(str.slice(-3)==' et') {
  7104. str = str.slice(0,-3);
  7105. }
  7106. }
  7107. }
  7108. arr.unshift(str);
  7109. return arr;
  7110. }
  7111.  
  7112. function addMithril(arrayCaracs,typeItem) {
  7113. // Ajoute l'effet du Mithril sur les caracs
  7114. if(typeItem=='arme') {
  7115. if(arrayCaracs[0]<0) {
  7116. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  7117. }
  7118. }
  7119. else {
  7120. if(arrayCaracs[4]<0) {
  7121. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  7122. }
  7123. }
  7124. arrayCaracs[15] /= 2;
  7125. arrayCaracs[16] /= 2;
  7126. return arrayCaracs;
  7127. }
  7128.  
  7129. function addRenfort(arrayCaracs,template) {
  7130. // Ajoute l'effet des pseudo-templates sur les caracs
  7131. // S'applique APRÈS le mithril
  7132. // WARNING - Cette formule n'a rien d'officiel, gare !
  7133. var coef = 0;
  7134. if(/^lég[e,è]re?$/.test(template)) {
  7135. coef = -1;
  7136. }
  7137. else if(/^renforcée?$/.test(template)
  7138. || template==='robuste') {
  7139. coef = 1;
  7140. }
  7141. if(coef) {
  7142. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  7143. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  7144. }
  7145. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  7146. return arrayCaracs;
  7147. }
  7148.  
  7149. function getCaracs(item) {
  7150. // Calcule les caractéristiques de l'item
  7151. var templates = getTemplates(item);
  7152. if(!mh_caracs[templates[0]]) {
  7153. // Si l'item est inconnu
  7154. return [];
  7155. }
  7156. var caracs = clone(mh_caracs[templates[0]]);
  7157. var typeItem = caracs[0];
  7158. caracs.shift();
  7159. templates.shift();
  7160. if(templates[templates.length-1]=='en Mithril') {
  7161. caracs = addMithril(caracs,typeItem);
  7162. templates.pop();
  7163. }
  7164. if(/^acérée?$/.test(templates[0])
  7165. || /^équilibrée?$/.test(templates[0])
  7166. || /^lég[e,è]re?$/.test(templates[0])
  7167. || /^renforcée?$/.test(templates[0])
  7168. || templates[0]=='robuste') {
  7169. caracs = addRenfort(caracs,templates[0]);
  7170. templates.shift();
  7171. }
  7172. for(var i=templates.length-1 ; i>=0 ; i--) {
  7173. caracs = addArray(caracs,mh_templates[templates[i]]);
  7174. }
  7175. return caracs;
  7176. }
  7177.  
  7178. function getLine(tab) {
  7179. // Préparation de la ligne à afficher lors d'un mouseover
  7180. var str = '';
  7181. if(tab[0]!=0 || tab[1]!=0) {
  7182. str += '<b>Att : </b>'+aff(tab[0]);
  7183. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  7184. str += ' | ';
  7185. }
  7186. if(tab[4]!=0) {
  7187. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  7188. }
  7189. if(tab[2]!=0 || tab[3]!=0) {
  7190. str += '<b>Deg : </b>'+aff(tab[2]);
  7191. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  7192. str += ' | ';
  7193. }
  7194. if(tab[8]!=0) {
  7195. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  7196. }
  7197. if(tab[7]!=0) {
  7198. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  7199. }
  7200. if(tab[5]!=0 || tab[6]!=0) {
  7201. str += '<b>Arm : </b>'+aff(tab[5]);
  7202. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  7203. str += ' | ';
  7204. }
  7205. if(tab[9]!=0 || tab[10]!=0) {
  7206. str += '<b>RM : </b>'+aff(tab[9])+'%';
  7207. if(tab[9]!=tab[10]) {
  7208. str += '/'+aff(tab[10])+'%';
  7209. }
  7210. str += ' | ';
  7211. }
  7212. if(tab[11]!=0 || tab[12]!=0) {
  7213. str += '<b>MM : </b>'+aff(tab[11])+'%';
  7214. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  7215. str += ' | ';
  7216. }
  7217. if(tab[13]!=0) {
  7218. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  7219. }
  7220. if(tab[14]!=0) {
  7221. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  7222. }
  7223. str += '<b>Poids : </b>'+tab[15]+' min';
  7224. if(tab[15]!=tab[16]) {
  7225. str += ' / '+tab[16]+' min';
  7226. }
  7227. return str;
  7228. }
  7229.  
  7230. function toolTipInit() {
  7231. DivInfo = document.createElement('div');
  7232. DivInfo.id = 'infosVue';
  7233. DivInfo.className = 'mh_textbox';
  7234. DivInfo.style =
  7235. 'position: absolute;'
  7236. +'border: 1px solid #000000;'
  7237. +'visibility:hidden;'
  7238. +'display:inline;'
  7239. +'z-index:99;';
  7240. document.body.appendChild(DivInfo);
  7241. document.onmousemove = getXY;
  7242. document.onclick = changeFreezeStatus;
  7243. }
  7244.  
  7245. function getXY(evt) {
  7246. if(!freezed && DivInfo.style.visibility=='visible') {
  7247. DivInfo.style.left = evt.pageX+'px';
  7248. DivInfo.style.top = evt.pageY+10+'px';
  7249. }
  7250. }
  7251.  
  7252. function changeFreezeStatus() {
  7253. if(DivInfo.style.visibility=='visible') {
  7254. freezed = !freezed;
  7255. if(!freezed) { hideInfos(); }
  7256. }
  7257. }
  7258.  
  7259. function showInfos() {
  7260. if(freezed) { return; }
  7261. var currentInfos = this.infos;
  7262. DivInfo.innerHTML = currentInfos;
  7263. DivInfo.style.visibility = 'visible';
  7264. }
  7265.  
  7266. function hideInfos() {
  7267. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  7268. }
  7269.  
  7270. function treateEquipement() {
  7271. // Extrait les données du matos et réinjecte les infos déduites
  7272. if(MY_getValue('INFOCARAC')=='false') { return; }
  7273.  
  7274. var faireLigne = false;
  7275. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  7276. var nodes = document.evaluate(
  7277. "//td/b[text()='Equipement Utilisé']/../../"
  7278. +"td[2]/img[contains(@src,bullet)]",
  7279. document, null, 7, null);
  7280. if(nodes.snapshotLength>0) {
  7281. // Si CSS de base
  7282. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7283. var node = nodes.snapshotItem(i);
  7284. var next = node.nextSibling;
  7285. var nnext = next.nextSibling;
  7286. var nom = next.nodeValue.toLowerCase();
  7287. if(nnext.childNodes.length==1) {
  7288. nom += nnext.firstChild.nodeValue;
  7289. }
  7290. nom = nom.trim();
  7291. // gestion winpostrophe
  7292. var c = String.fromCharCode(180);
  7293. while(nom.indexOf(c)!=-1) {
  7294. nom = nom.replace(c,"'");
  7295. }
  7296. var arr = getCaracs(nom);
  7297. if(arr.length>0) {
  7298. faireLigne = true;
  7299. caracs = addArray(caracs,arr);
  7300. var span = document.createElement('span');
  7301. span.appendChild(next);
  7302. span.appendChild(nnext);
  7303. span.infos = getLine(arr);
  7304. span.onmouseover = showInfos;
  7305. span.onmouseout = hideInfos;
  7306. insertBefore(node.nextSibling,span);
  7307. }
  7308. }
  7309.  
  7310. if(faireLigne) {
  7311. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  7312. document, null, 9, null).singleNodeValue;
  7313. node.infos = getLine(caracs);
  7314. node.onmouseover = showInfos;
  7315. node.onmouseout = hideInfos;
  7316. }
  7317. }
  7318. else {
  7319. // Si CSS avancée
  7320. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  7321. document, null, 7, null);
  7322. if(nodes.snapshotLength>0) {
  7323. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7324. var node = nodes.snapshotItem(i);
  7325. var nom = node.firstChild.nodeValue.toLowerCase();
  7326. if(node.childNodes.length>1) {
  7327. nom += node.childNodes[1].firstChild.nodeValue;
  7328. }
  7329. nom = nom.trim();
  7330. // gestion winpostrophe
  7331. var c = String.fromCharCode(180);
  7332. while(nom.indexOf(c)!=-1) {
  7333. nom = nom.replace(c,"'");
  7334. }
  7335. var arr = getCaracs(nom);
  7336. if(arr.length!=0) {
  7337. caracs = addArray(caracs,arr);
  7338. node.infos = getLine(arr);
  7339. node.onmouseover = showInfos;
  7340. node.onmouseout = hideInfos;
  7341. }
  7342. }
  7343. var nodes = document.evaluate("//dt[@class='equipement']",
  7344. document, null, 7, null);
  7345. var node = nodes.snapshotItem(0);
  7346. node.infos = getLine(caracs);
  7347. node.onmouseover = showInfos;
  7348. node.onmouseout = hideInfos;
  7349. }
  7350. }
  7351. }
  7352.  
  7353. function do_pjview() {
  7354. treateEquipement();
  7355. toolTipInit();
  7356. }
  7357.  
  7358. /*******************************************************************************
  7359. * This file is part of Mountyzilla. *
  7360. * *
  7361. * Mountyzilla is free software; you can redistribute it and/or modify *
  7362. * it under the terms of the GNU General Public License as published by *
  7363. * the Free Software Foundation; either version 2 of the License, or *
  7364. * (at your option) any later version. *
  7365. * *
  7366. * Mountyzilla is distributed in the hope that it will be useful, *
  7367. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7368. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7369. * GNU General Public License for more details. *
  7370. * *
  7371. * You should have received a copy of the GNU General Public License *
  7372. * along with Mountyzilla; if not, write to the Free Software *
  7373. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7374. *******************************************************************************/
  7375.  
  7376. // x~x option
  7377.  
  7378. /* TODO
  7379. * Passer le HTML injecté aux conventions HTML5
  7380. */
  7381.  
  7382.  
  7383. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  7384.  
  7385. function saveITData() {
  7386. var IT = document.getElementById('itSelect').value;
  7387. if(IT=='bricol') {
  7388. var nBricol = 1;
  7389. for (var iBricol = 0; ; iBricol++) {
  7390. var extClef = nBricol == 1 ? '' : nBricol;
  7391. var eltSystem = document.getElementById('urlbricol'+iBricol);
  7392. if (eltSystem == undefined) break;
  7393. var system = eltSystem.value;
  7394. window.console.log("[MZ] saveITData system=" + system);
  7395. var login = document.getElementById('loginbricol'+iBricol).value;
  7396. var pass = document.getElementById('passbricol'+iBricol).value;
  7397. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  7398. if(system && login) {
  7399. if (pass) {
  7400. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  7401. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  7402. //window.console.log('v=' + v);
  7403. } else {
  7404. // vérif que rien n'a changé
  7405. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  7406. if(str) {
  7407. var arr = str.split('$');
  7408. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  7409. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  7410. }
  7411. }
  7412. }
  7413. nBricol++;
  7414. }
  7415. }
  7416. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  7417. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  7418. }
  7419. else {
  7420. MY_removeValue(numTroll+'.INFOSIT');
  7421. }
  7422. }
  7423.  
  7424. function saveLinks() {
  7425. var numLinks = document.getElementById('linksBody').childNodes.length;
  7426. var data=[ [] ];
  7427. /* Récupération et tri des liens */
  7428. for(var i=1 ; i<=numLinks ; i++) {
  7429. MY_removeValue('URL'+i);
  7430. MY_removeValue('URL'+i+'.nom');
  7431. MY_removeValue('URL'+i+'.ico');
  7432. var url = document.getElementById('url'+i).value;
  7433. var nom = document.getElementById('nom'+i).value;
  7434. var ico = document.getElementById('ico'+i).value;
  7435. if(url && (nom || ico) ) {
  7436. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  7437. }
  7438. }
  7439. /* Sauvegarde */
  7440. for(var i=1 ; i<data.length ; i++) {
  7441. MY_setValue('URL'+i,data[i][0]);
  7442. MY_setValue('URL'+i+'.nom',data[i][1]);
  7443. MY_setValue('URL'+i+'.ico',data[i][2]);
  7444. }
  7445. }
  7446.  
  7447. function saveAll() {
  7448. try {
  7449. var urlIco = document.getElementById('icoMenuIco').value;
  7450. if(urlIco) {
  7451. MY_setValue(numTroll+'.ICOMENU', urlIco );
  7452. }
  7453. else {
  7454. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  7455. document.getElementById('icoMenuIco').value = '';
  7456. }
  7457. saveLinks();
  7458. refreshLinks();
  7459.  
  7460. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  7461.  
  7462. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  7463. if(maxcdm) {
  7464. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  7465. }
  7466. else {
  7467. MY_removeValue(numTroll+'.MAXCDM');
  7468. document.getElementById('maxcdm').value = '';
  7469. }
  7470.  
  7471. MY_setValue('NOINFOEM',
  7472. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  7473.  
  7474. // Pourquoi Tilk stockait-il tout en str ?
  7475. // -> parce que les booléens c'est foireux (vérifié)
  7476. MY_setValue(numTroll+'.USECSS',
  7477. document.getElementById('usecss').checked ? 'true':'false');
  7478. MY_setValue('INFOCARAC',
  7479. document.getElementById('infocarac').checked ? 'true' : 'false');
  7480. //MY_setValue(numTroll+'.SEND_IDT',
  7481. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  7482. // Fonctionnalité désactivée
  7483.  
  7484. MY_setValue(numTroll+'.AUTOCDM',
  7485. document.getElementById('autoCdM').checked ? 'true' : 'false');
  7486. // MY_setValue('VUECARAC', // Roule 12/12/2019 ça ne fait plus rien
  7487. // document.getElementById('vueCarac').checked ? 'true' : 'false');
  7488. MY_setValue('CONFIRMEDECALAGE',
  7489. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  7490.  
  7491. /* SCIZ */
  7492. var sciz_jwt = document.getElementById('sciz_jwt').value;
  7493. if (sciz_jwt) {
  7494. sciz_jwt = sciz_jwt.replace(new RegExp('[^a-zA-Z0-9\._\-]','g'), '');
  7495. MY_setValue(numTroll + '.SCIZJWT', sciz_jwt);
  7496. }
  7497. var sciz_cb_events = document.getElementById('sciz_cb_events').checked;
  7498. sciz_cb_events = (sciz_cb_events !== null) ? sciz_cb_events : true;
  7499. MY_setValue(numTroll + '.SCIZ_CB_EVENTS', sciz_cb_events);
  7500. var sciz_cb_view_treasures = document.getElementById('sciz_cb_view_treasures').checked;
  7501. sciz_cb_view_treasures = (sciz_cb_view_treasures !== null) ? sciz_cb_view_treasures : true;
  7502. MY_setValue(numTroll + '.SCIZ_CB_VIEW_TREASURES', sciz_cb_view_treasures);
  7503. var sciz_cb_view_trolls = document.getElementById('sciz_cb_view_trolls').checked;
  7504. sciz_cb_view_trolls = (sciz_cb_view_trolls !== null) ? sciz_cb_view_trolls : true;
  7505. MY_setValue(numTroll + '.SCIZ_CB_VIEW_TROLLS', sciz_cb_view_trolls);
  7506.  
  7507. saveITData();
  7508. } catch (e) {
  7509. var bouton = document.getElementById('saveAll');
  7510. window.console.log(e);
  7511. bouton.value = "il y a eu une erreur";
  7512. return;
  7513. }
  7514.  
  7515. var bouton = document.getElementById('saveAll');
  7516. bouton.value = (bouton.value=='Sauvegardé !') ?
  7517. 'Re-sauvegardé !' : 'Sauvegardé !';
  7518. }
  7519.  
  7520.  
  7521. /*-[functions]----------------- EventListeners -------------------------------*/
  7522.  
  7523. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  7524. var itBody = document.getElementById('itBody');
  7525. var nTr = itBody.rows.length;
  7526. // enlever tous les "+" des lignes précédentes
  7527. for (var iTr = 0; iTr < nTr; iTr++) {
  7528. var td = itBody.rows[iTr].cells[0];
  7529. td.innerHTML = '';
  7530. td.title = '';
  7531. td.style.cursor = 'default';
  7532. }
  7533. // ajouter une ligne
  7534. var tr = appendTr(itBody,'mh_tdpage')
  7535. var td = appendTd(tr);
  7536. if (bLast) {
  7537. td.style.whiteSpace = 'nowrap';
  7538. appendText(td, '+');
  7539. td.style.cursor = 'pointer';
  7540. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  7541. td.onclick = function (e) {
  7542. addBricolIT(undefined, undefined, undefined, false, true);
  7543. }
  7544. }
  7545. var td = appendTd(tr);
  7546. td.style.whiteSpace = 'nowrap';
  7547. appendText(td,'Nom du système : ');
  7548. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  7549. td = appendTd(tr);
  7550. td.style.whiteSpace = 'nowrap';
  7551. appendText(td,'Login du compte : ');
  7552. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  7553. td = appendTd(tr);
  7554. td.style.whiteSpace = 'nowrap';
  7555. appendText(td,'Mot de passe du compte : ');
  7556. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  7557. td = appendTd(tr);
  7558. if (bFirst) {
  7559. td.style.whiteSpace = 'nowrap';
  7560. appendText(td,'Affichage des Trõlls hors vue : ');
  7561. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  7562. }
  7563. }
  7564.  
  7565. function onChangeIT() {
  7566. var IT = document.getElementById('itSelect').value;
  7567. var itBody = document.getElementById('itBody');
  7568. itBody.innerHTML = '';
  7569. var tabStr = new Array();
  7570. if(IT=='bricol') {
  7571. for (var iBricol = 1; ; iBricol++) {
  7572. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  7573. //window.console.log('onChangeIT str=' + str);
  7574. if(str) {
  7575. tabStr.push(str);
  7576. } else {
  7577. break;
  7578. }
  7579. }
  7580. if (tabStr.length == 0) {
  7581. addBricolIT('', '', 0, true, true)
  7582. } else {
  7583. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  7584. var arr = tabStr[iBricol].split('$');
  7585. var system = arr[1];
  7586. var login = arr[2];
  7587. var affhv = arr[4];
  7588. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  7589. }
  7590. }
  7591. }
  7592. }
  7593.  
  7594. function refreshLinks() {
  7595. document.getElementById('linksBody').innerHTML = '';
  7596. var anotherURL = MY_getValue('URL1');
  7597. if(!anotherURL) { addLinkField(); }
  7598. var i=1;
  7599. while(anotherURL && i<99) {
  7600. addLinkField(i,anotherURL,
  7601. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  7602. i++;
  7603. anotherURL = MY_getValue('URL'+i);
  7604. }
  7605. }
  7606.  
  7607. function addLinkField(i,url,nom,ico) {
  7608. var linksBody = document.getElementById('linksBody');
  7609. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  7610. var tr = appendTr(linksBody);
  7611. var td = appendTdCenter(tr);
  7612. appendText(td,'Lien '+i+' : ');
  7613. appendTextbox(td,'text','url'+i,40,150,url);
  7614. td = appendTdCenter(tr);
  7615. appendText(td,'Nom : ');
  7616. appendTextbox(td,'text','nom'+i,20,150,nom);
  7617. td = appendTdCenter(tr);
  7618. appendText(td,'Icône : ');
  7619. appendTextbox(td,'text','ico'+i,40,150,ico);
  7620. }
  7621.  
  7622. function removeLinkField() {
  7623. var linksBody = document.getElementById('linksBody');
  7624. var i = linksBody.childNodes.length;
  7625. MY_removeValue('URL'+i);
  7626. MY_removeValue('URL'+i+'.nom');
  7627. MY_removeValue('URL'+i+'.ico');
  7628. linksBody.removeChild(linksBody.lastChild);
  7629. if(linksBody.childNodes.length==0) { addLinkField(); }
  7630. }
  7631.  
  7632. function resetMainIco() {
  7633. document.getElementById('icoMenuIco').value=
  7634. URL_MZimg + 'mz_logo_small.png';
  7635. }
  7636.  
  7637.  
  7638. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  7639.  
  7640. function insertTitle(next,txt) {
  7641. var div = document.createElement('div');
  7642. div.className = 'titre2';
  7643. appendText(div,txt);
  7644. insertBefore(next,div);
  7645. return div;
  7646. }
  7647.  
  7648. function insertMainTable(next) {
  7649. var table = document.createElement('table');
  7650. table.width = '98%';
  7651. table.border = 0;
  7652. table.align = 'center';
  7653. table.cellPadding = 2;
  7654. table.cellSpacing = 1;
  7655. table.className = 'mh_tdborder';
  7656. var tbody = document.createElement('tbody');
  7657. table.appendChild(tbody);
  7658. insertBefore(next,table);
  7659. return tbody;
  7660. }
  7661.  
  7662. function appendSubTable(node) {
  7663. var table = document.createElement('table');
  7664. table.width = '100%';
  7665. var tbody = document.createElement('tbody');
  7666. table.appendChild(tbody);
  7667. node.appendChild(table);
  7668. return tbody;
  7669. }
  7670.  
  7671. function insertOptionTable(insertPt) {
  7672. var mainBody = insertMainTable(insertPt);
  7673.  
  7674. /* Liens dans le Menu */
  7675. var tr = appendTr(mainBody,'mh_tdtitre');
  7676. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  7677. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7678. appendText(td,'Icône du Menu: ');
  7679. var url = MY_getValue(numTroll+'.ICOMENU');
  7680. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  7681. url = URL_MZimg + 'mz_logo_small.png';
  7682. }
  7683. appendTextbox(td,'text','icoMenuIco',50,200,url);
  7684. appendButton(td,'Réinitialiser',resetMainIco);
  7685.  
  7686. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7687. var tbody = appendSubTable(td);
  7688. tbody.id = 'linksBody';
  7689. refreshLinks();
  7690.  
  7691. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  7692. appendButton(td,'Ajouter',addLinkField);
  7693. appendButton(td,'Supprimer',removeLinkField);
  7694.  
  7695. /* Options de la Vue : vue externe, nb de CdM, etc */
  7696. tr = appendTr(mainBody,'mh_tdtitre');
  7697. appendTdText(tr,'Options de la Vue :',true);
  7698. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7699. tbody = appendSubTable(td);
  7700.  
  7701. tr = appendTr(tbody);
  7702. td = appendTdText(tr,'Vue externe : ');
  7703. var select = document.createElement('select');
  7704. select.id = 'vueext';
  7705. td.appendChild(select);
  7706. var listeVues2D = [
  7707. 'Bricol\' Vue',
  7708. 'Vue du CCM',
  7709. 'Vue Gloumfs 2D',
  7710. 'Vue Gloumfs 3D',
  7711. 'Grouky Vue!'
  7712. ];
  7713. for(var i=0 ; i<listeVues2D.length ; i++) {
  7714. appendOption(select,listeVues2D[i],listeVues2D[i]);
  7715. }
  7716. if(MY_getValue('VUEEXT')) {
  7717. select.value = MY_getValue('VUEEXT');
  7718. }
  7719.  
  7720. td = appendTd(tr);
  7721. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  7722. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  7723.  
  7724. tr = appendTr(tbody);
  7725. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  7726. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  7727.  
  7728. td = appendTd(tr);
  7729. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  7730. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  7731.  
  7732. /* Interface Tactique */
  7733. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7734. appendText(td,'Interface Tactique : ',true);
  7735. select = document.createElement('select');
  7736. select.id = 'itSelect';
  7737. appendOption(select,'none','Aucune');
  7738. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  7739. // seule interface supportée !
  7740. td.appendChild(select);
  7741.  
  7742. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7743. tbody = appendSubTable(td);
  7744. tbody.id = 'itBody';
  7745. select.onchange = onChangeIT;
  7746. var str = MY_getValue(numTroll+'.INFOSIT');
  7747. if(str) {
  7748. select.value = str.slice(0,str.indexOf('$'));
  7749. onChangeIT();
  7750. }
  7751.  
  7752. /* SCIZ */
  7753. // JWT
  7754. td = appendTd(appendTr(mainBody, 'mh_tdtitre'));
  7755. appendText(td, 'SCIZ :', true);
  7756. td = appendTd(appendTr(mainBody, 'mh_tdpage'));
  7757. td = appendTdText(td, 'JWT : ');
  7758. appendTextbox(td, 'text', 'sciz_jwt', 150, 500, MY_getValue(numTroll + '.SCIZJWT'));
  7759. // Event checkbox
  7760. td = appendTd(appendTr(mainBody, 'mh_tdpage'));
  7761. tbody = appendSubTable(td);
  7762. tr = appendTr(tbody)
  7763. td = appendTd(tr);
  7764. td.setAttribute('align', 'center');
  7765. appendCheckBox(td, 'sciz_cb_events', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_EVENTS')));
  7766. appendText(td, ' Surcharger les événementsde ma coterie');
  7767. // Treasure checkbox
  7768. td = appendTd(tr);
  7769. td.setAttribute('align', 'center');
  7770. appendCheckBox(td, 'sciz_cb_view_treasures', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_VIEW_TREASURES')));
  7771. appendText(td, ' Afficher les trésors identifiés par ma coterie dans la vue');
  7772. // Trolls data
  7773. td = appendTd(tr);
  7774. td.setAttribute('align', 'center');
  7775. appendCheckBox(td, 'sciz_cb_view_trolls', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_VIEW_TROLLS')));
  7776. appendText(td, ' Afficher les données des trolls de ma coterie dans la vue');
  7777.  
  7778. /* Options diverses */
  7779. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7780. appendText(td,'Options diverses :',true);
  7781. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7782. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  7783. appendText(td,
  7784. ' Afficher les caractéristiques des équipements des autres Trõlls');
  7785.  
  7786. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7787. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  7788. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  7789.  
  7790. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7791. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  7792. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  7793.  
  7794. // td = appendTd(appendTr(mainBody,'mh_tdpage')); // Roule 12/12/2019 ça ne fait plus rien
  7795. // appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  7796. // appendText(td,' Afficher la Vue avec les caractéristiques dans le Profil');
  7797.  
  7798. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7799. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  7800. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  7801.  
  7802. /* Bouton SaveAll */
  7803. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  7804. input = appendButton(td,'Sauvegarder',saveAll);
  7805. input.id = 'saveAll';
  7806. }
  7807.  
  7808. function insertCreditsTable(insertPt) {
  7809. var tbody = insertMainTable(insertPt);
  7810.  
  7811. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  7812. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  7813. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  7814.  
  7815. var ul = document.createElement('ul');
  7816. td.appendChild(ul);
  7817. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  7818. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  7819. appendLI(ul,'Reivax (4234) pour les infos bulles');
  7820. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  7821. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  7822. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  7823. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  7824. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  7825. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  7826. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  7827. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  7828. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  7829. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  7830. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  7831. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  7832. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  7833. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  7834. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  7835. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  7836. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  7837. }
  7838.  
  7839.  
  7840. /* [functions] Obsolètes */
  7841. function deleteEnchantement()
  7842. {
  7843. try
  7844. {
  7845. var idEquipement = this.getAttribute('name');
  7846. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  7847. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  7848. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  7849. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  7850. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  7851. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7852. var string = "";
  7853. for(var i=0;i<listeEquipement.length;i++)
  7854. {
  7855. if(listeEquipement[i]!=idEquipement)
  7856. if(string=="")
  7857. string = listeEquipement[i];
  7858. else
  7859. string += ";"+listeEquipement[i];
  7860. }
  7861. if(string=="")
  7862. {
  7863. MY_removeValue(numTroll+".enchantement.liste");
  7864. var table = this.parentNode.parentNode.parentNode.parentNode;
  7865. var parent = table.parentNode;
  7866. for(var i=0;i<parent.childNodes.length;i++)
  7867. {
  7868. if(parent.childNodes[i]==table)
  7869. {
  7870. parent.removeChild(parent.childNodes[i-1]);
  7871. parent.removeChild(parent.childNodes[i-1]);
  7872. parent.removeChild(parent.childNodes[i-1]);
  7873. break;
  7874. }
  7875. }
  7876. }
  7877. else
  7878. {
  7879. MY_getValue(numTroll+".enchantement.liste",string);
  7880. this.parentNode.parentNode.parentNode
  7881. .removeChild(this.parentNode.parentNode);
  7882. }
  7883. }
  7884. catch(e)
  7885. {
  7886. window.alert(e);
  7887. }
  7888. }
  7889. /* [functions] fin Obsolètes */
  7890.  
  7891. /*-[functions]---------------- Partie principale -----------------------------*/
  7892.  
  7893. function do_option() {
  7894. start_script(712);
  7895. var insertPoint = document.getElementById('footer1');
  7896. insertBefore(insertPoint,document.createElement('p'));
  7897. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  7898. ti.onclick = function (e) {
  7899. var evt = e || window.event;
  7900. if (evt.shiftKey) {
  7901. var txt = '';
  7902. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  7903. var k = localStorage.key(i);
  7904. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  7905. txt += k + "\t" + localStorage.getItem(k) + "\n";
  7906. }
  7907. copyTextToClipboard(txt);
  7908. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  7909. } else if (evt.ctrlKey) {
  7910. var tabK= [];
  7911. var sMatch = numTroll + '.';
  7912. var lMatch = sMatch.length;
  7913. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  7914. var k = localStorage.key(i);
  7915. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  7916. }
  7917. for (var i = 0; i < tabK.length; ++i ) {
  7918. MY_removeValue(tabK[i]);
  7919. }
  7920. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  7921. }
  7922. }
  7923. ti.title = 'Version ' + GM_info.script.version;
  7924. insertOptionTable(insertPoint);
  7925. /* insertion enchantements ici
  7926. if(...)
  7927. insertEnchantementTable();
  7928. */
  7929. insertBefore(insertPoint,document.createElement('p'));
  7930. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  7931. ti.onclick = function (e) {
  7932. var evt = e || window.event;
  7933. if (!evt.shiftKey) return;
  7934. var oldDev = MY_getValue('MZ_dev');
  7935. if (oldDev) {
  7936. MY_removeValue('MZ_dev');
  7937. } else {
  7938. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  7939. MY_setValue('MZ_dev', 1);
  7940. }
  7941. document.location.href = document.location.href;
  7942. }
  7943. insertCreditsTable(insertPoint);
  7944. insertBefore(insertPoint,document.createElement('p'));
  7945.  
  7946. /* [zone] Obsolète ?? */
  7947. if(MY_getValue(numTroll+".enchantement.liste")
  7948. && MY_getValue(numTroll+".enchantement.liste")!="" )
  7949. {
  7950. insertTitle(insertPoint, 'Les Enchantements en cours');
  7951. table = document.createElement('table');
  7952. table.setAttribute('width', '98%');
  7953. table.setAttribute('border', '0');
  7954. table.setAttribute('align', 'center');
  7955. table.setAttribute('cellpadding', '2');
  7956. table.setAttribute('cellspacing', '1');
  7957. table.setAttribute('class', 'mh_tdborder');
  7958.  
  7959. tbody = document.createElement('tbody');
  7960. table.appendChild(tbody);
  7961.  
  7962. tr = appendTr(tbody, 'mh_tdtitre');
  7963. appendTdText(tr, 'Equipement',1);
  7964. appendTdText(tr, 'Composants',1);
  7965. appendTdText(tr, 'Enchanteur',1);
  7966. appendTdText(tr, 'Action',1);
  7967.  
  7968. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7969. for(var i=0;i<listeEquipement.length;i++)
  7970. {
  7971. try
  7972. {
  7973. var idEquipement = listeEquipement[i];
  7974. var nomEquipement = MY_getValue(numTroll+".enchantement."
  7975. +idEquipement+".objet");
  7976. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  7977. +idEquipement+".enchanteur").split(";");
  7978. var ul = document.createElement('UL');
  7979. for(var j=0;j<3;j++)
  7980. {
  7981. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  7982. var v = MY_getValue(k);
  7983. if (v == null) { // protection Roule 26/08/2017
  7984. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  7985. continue;
  7986. }
  7987. var infoComposant = v.split(';');
  7988. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  7989. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  7990. continue;
  7991. }
  7992. var texte = infoComposant[4].replace("Ril ","Œil ");
  7993. for(var k=5;k<infoComposant.length;k++)
  7994. {
  7995. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  7996. }
  7997. li = appendLI(ul,texte);
  7998. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  7999. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  8000. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  8001. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  8002. string+= '<input type="hidden" name="q" value="min" />';
  8003. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  8004. 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>';
  8005.  
  8006. string+= '</form>';
  8007. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  8008. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  8009. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  8010. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  8011. li.innerHTML += string;
  8012. }
  8013. tr = appendTr(tbody, 'mh_tdpage');
  8014.  
  8015. td = appendTdText(tr, nomEquipement);
  8016. td.setAttribute('valign', 'center');
  8017.  
  8018. td = document.createElement('td');
  8019. td.appendChild(ul);
  8020. tr.appendChild(td);
  8021. td.setAttribute('valign', 'center');
  8022.  
  8023. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  8024. td.setAttribute('valign', 'center');
  8025.  
  8026. td = document.createElement('td');
  8027. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  8028. input.setAttribute('name', idEquipement);
  8029. tr.appendChild(td);
  8030. td.setAttribute('valign', 'center');
  8031. }
  8032. catch(e)
  8033. {
  8034. }
  8035. }
  8036. insertBefore(insertPoint, table);
  8037. insertBefore(insertPoint, document.createElement('p'));
  8038. }
  8039. /* [zone] fin Obsolète ?? */
  8040.  
  8041.  
  8042. displayScriptTime();
  8043. }
  8044.  
  8045. /*******************************************************************************
  8046. * This file is part of Mountyzilla. *
  8047. * *
  8048. * Mountyzilla is free software; you can redistribute it and/or modify *
  8049. * it under the terms of the GNU General Public License as published by *
  8050. * the Free Software Foundation; either version 2 of the License, or *
  8051. * (at your option) any later version. *
  8052. * *
  8053. * Mountyzilla is distributed in the hope that it will be useful, *
  8054. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8055. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8056. * GNU General Public License for more details. *
  8057. * *
  8058. * You should have received a copy of the GNU General Public License *
  8059. * along with Mountyzilla; if not, write to the Free Software *
  8060. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8061. *******************************************************************************/
  8062.  
  8063. // x~x equip
  8064.  
  8065. /**
  8066. * 2014-02-08 - v2.0a (from scratch)
  8067. * 2014-02-18 - v2.0a0
  8068. * - ajout calcul Carats / UM des minerais + totaux
  8069. * 2014-03-06 - v2.0a1
  8070. * - retour Infos EM des Champis
  8071. * TODO
  8072. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  8073. */
  8074.  
  8075. function traiteChampis() {
  8076. try{
  8077. var tr = document.getElementById('mh_objet_hidden_Champignon');
  8078. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8079. }
  8080. catch(e){return;}
  8081. if(trlist.length<=0) return;
  8082. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8083. var node = trlist.snapshotItem(i).childNodes[7];
  8084. var str = node.textContent.trim();
  8085. var type = str.slice(0,str.lastIndexOf(' '));
  8086. var mundi = mundiChampi[type];
  8087. if(!mundi) continue;
  8088. var urlImg = URL_MZimg
  8089. +'Competences/ecritureMagique.png';
  8090. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  8091. appendText(node,' ');
  8092. node.appendChild(img);
  8093. }
  8094. }
  8095.  
  8096. function traiteCompos() {
  8097. try {
  8098. var tr = document.getElementById('mh_objet_hidden_Composant');
  8099. var tbody = document.evaluate("./td/table/tbody",
  8100. tr, null, 9, null).singleNodeValue;
  8101. }
  8102. catch(e) {return;}
  8103. insererInfosEM(tbody);
  8104. }
  8105.  
  8106. function traiteMinerai() {
  8107. try{
  8108. var tr = document.getElementById('mh_objet_hidden_Minerai');
  8109. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8110. }
  8111. catch(e){return;}
  8112. if(trlist.length<=0) return;
  8113. var totaux = {};
  8114. var str;
  8115. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8116. var node = trlist.snapshotItem(i);
  8117. var nature = node.childNodes[7].textContent,
  8118. caracs = node.childNodes[9].textContent;
  8119. var taille = Number(caracs.match(/\d+/)[0]);
  8120. var coef = 1;
  8121. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  8122. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  8123. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  8124. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  8125. if(nature.indexOf('Mithril')!=-1) {
  8126. coef = 0.2*coef;
  8127. str = ' | UM: ';
  8128. }
  8129. else {
  8130. coef = 0.75*coef+1.25;
  8131. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  8132. str = ' | Carats: ';
  8133. }
  8134. var carats = Math.round(taille*coef)
  8135. appendText(node.childNodes[9], str+carats );
  8136. if(!totaux[nature]) {
  8137. totaux[nature] = [taille,carats];
  8138. }
  8139. else {
  8140. totaux[nature][0] += taille;
  8141. totaux[nature][1] += carats;
  8142. }
  8143. }
  8144. str = 'Total : ';
  8145. for(var nature in totaux) {
  8146. if(str.length>8) str += ', ';
  8147. if(nature.indexOf('Mithril')!=-1) {
  8148. str += nature+totaux[nature][1]+' UM';
  8149. }
  8150. else {
  8151. str += nature+totaux[nature][0]+'U/'
  8152. +totaux[nature][1]+'c';
  8153. }
  8154. }
  8155. /*var node = document.getElementById('mh_plus_Minerai');
  8156. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  8157. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  8158. if(!titre) return;*/
  8159. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  8160. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  8161. td.colSpan = 7;
  8162. }
  8163.  
  8164. function do_equip() {
  8165. start_script();
  8166.  
  8167. traiteChampis();
  8168. traiteCompos();
  8169. traiteMinerai();
  8170.  
  8171. displayScriptTime();
  8172. }
  8173.  
  8174. /*******************************************************************************
  8175. * This file is part of Mountyzilla. *
  8176. * *
  8177. * Mountyzilla is free software; you can redistribute it and/or modify *
  8178. * it under the terms of the GNU General Public License as published by *
  8179. * the Free Software Foundation; either version 2 of the License, or *
  8180. * (at your option) any later version. *
  8181. * *
  8182. * Mountyzilla is distributed in the hope that it will be useful, *
  8183. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8184. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8185. * GNU General Public License for more details. *
  8186. * *
  8187. * You should have received a copy of the GNU General Public License *
  8188. * along with Mountyzilla; if not, write to the Free Software *
  8189. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8190. *******************************************************************************/
  8191.  
  8192. // x~x diplo
  8193.  
  8194. /*
  8195. TODO:
  8196. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  8197. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  8198. V Étape 3: Ajout de la diplo perso
  8199. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  8200. V Étape 5: Ajout des fioritures (preview de la couleur...)
  8201.  
  8202. Options Globales:
  8203. Actuelles:
  8204. numTroll.USECSS,
  8205. numTroll.NODIPLO
  8206. NOMYTH
  8207. Nouvelles:
  8208. TODO numTroll.USECSS
  8209. numTroll.diplo.off (remplace NODIPLO)
  8210. numTroll.diplo.guilde
  8211. numTroll.diplo.perso
  8212.  
  8213. Structure de diplo.guilde:
  8214. isOn: 'true' ou 'false'
  8215. isDetailOn: 'true' ou 'false'
  8216. guilde
  8217. > id
  8218. > couleur
  8219. AllAmis,AllEnnemis: couleur
  8220. Amis0,...,Ennemis5
  8221. > Troll: idTroll1;...;
  8222. > Guilde: idGuilde1;...;
  8223. > titre
  8224. > couleur
  8225.  
  8226. Structure de diplo.perso:
  8227. isOn: 'true' ou 'false'
  8228. mythiques: couleur
  8229. Troll,Guilde,Monstre:
  8230. > id
  8231. > couleur
  8232. > description
  8233. */
  8234.  
  8235. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8236.  
  8237. function couleurAleatoire() {
  8238. var alph = '0123456789ABCDEF'.split('');
  8239. var clr = '#';
  8240. for (var i=0; i<6; i++) {
  8241. clr+=alph[ Math.floor(16*Math.random()) ];
  8242. }
  8243. return clr;
  8244. }
  8245.  
  8246. function isCouleur(str) {
  8247. return /^#[0-9A-F]{6}$/i.test(str);
  8248. }
  8249.  
  8250. /*-[functions]---------------- Analyse de la page ----------------------------*/
  8251.  
  8252. function appendChoixCouleur(node,id) {
  8253. var span = document.createElement('span');
  8254. span.id = 'span'+id;
  8255. if(isDetailOn) {
  8256. span.style.display = 'none';
  8257. }
  8258. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  8259. if(diploGuilde[id]) {
  8260. couleur = diploGuilde[id];
  8261. }
  8262. appendText(span,' - Couleur HTML: ');
  8263. var input = appendTextbox(span,'text',id,7,7,couleur);
  8264. input.onkeyup = previewCouleur;
  8265. input.onchange = previewCouleur;
  8266. input.onkeyup();
  8267. node.appendChild(span);
  8268. }
  8269.  
  8270. function insertChoixCouleur(node,id) {
  8271. var span = document.createElement('span');
  8272. span.id = 'span'+id;
  8273. // La couleur détaillée passera à une valeur aléatoire
  8274. // si toggle vers isDetailOn
  8275. var couleur = couleurAleatoire();
  8276. if(!isDetailOn) {
  8277. span.style.display = 'none';
  8278. } else if(diploGuilde[id]) {
  8279. couleur = diploGuilde[id].couleur;
  8280. }
  8281. appendText(span,' - Couleur HTML: ');
  8282. var input = appendTextbox(span,'text',id,7,7,couleur);
  8283. input.onkeyup = previewCouleur;
  8284. input.onchange = previewCouleur;
  8285. input.onkeyup();
  8286. insertBefore(node,span);
  8287. }
  8288.  
  8289. function setChoixCouleurs() {
  8290. try {
  8291. //var form = document.getElementsByName('ActionForm')[0];
  8292. var form = document.getElementById('mhPlay');
  8293. var nodesAE = document.evaluate(
  8294. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  8295. "./table/tbody/tr/th[@class='mh_tdtitre']",
  8296. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  8297. form, null, 7, null
  8298. );
  8299. var nodes = document.evaluate(
  8300. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  8301. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  8302. form, null, 7, null
  8303. );
  8304. } catch(e) {
  8305. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  8306. return false;
  8307. };
  8308. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  8309. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  8310. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  8311. for(var i=0 ; i<5 ; i++) {
  8312. nodes.snapshotItem(i).id = 'tdAmis'+i;
  8313. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  8314. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  8315. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  8316. }
  8317. return true;
  8318. }
  8319.  
  8320. function fetchDiploGuilde() {
  8321. try {
  8322. for(var AE in {Amis:0,Ennemis:0}) {
  8323. for(var i=0 ; i<5 ; i++) {
  8324. /* Récup des A/E de rang i */
  8325. var td = document.getElementById('td'+AE+i);
  8326. var ligne = td.getElementsByTagName('table')[0].rows;
  8327. var titre = trim(td.firstChild.textContent);
  8328. // On laisse la gestion des couleurs à setChoixCouleurs:
  8329. var couleur = document.getElementById(AE+i).value;
  8330. diploGuilde[AE+i] = {
  8331. Troll:'',
  8332. Guilde:'',
  8333. titre: titre,
  8334. couleur: couleur
  8335. };
  8336. for(var j=1 ; j<ligne.length ; j++) {
  8337. var str = trim(ligne[j].cells[0].textContent);
  8338. var idx = str.lastIndexOf('(');
  8339. var num = str.slice(idx+1,-1);
  8340. var type = trim(ligne[j].cells[1].textContent);
  8341. diploGuilde[AE+i][type] += num+';';
  8342. }
  8343. }
  8344. }
  8345. } catch(e) {
  8346. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  8347. return false;
  8348. }
  8349. return true;
  8350. }
  8351.  
  8352.  
  8353. /*-[functions]--------------------- Handlers ---------------------------------*/
  8354.  
  8355. function toggleDetails() {
  8356. isDetailOn = !isDetailOn;
  8357. for(var AE in {Amis:0,Ennemis:0}) {
  8358. document.getElementById('spanAll'+AE).style.display =
  8359. (isDetailOn?'none':'');
  8360. for(var i=0 ; i<5 ; i++) {
  8361. document.getElementById('span'+AE+i).style.display =
  8362. (isDetailOn?'':'none');
  8363. }
  8364. }
  8365. }
  8366.  
  8367. function toggleMythiques() {
  8368. isMythiquesOn = !isMythiquesOn;
  8369. document.getElementById('spanMythiques').style.display =
  8370. (isMythiquesOn?'':'none');
  8371. }
  8372.  
  8373. function previewCouleur() {
  8374. var value = this.value;
  8375. if(isCouleur(value)) {
  8376. this.style.backgroundColor = value;
  8377. this.title = '';
  8378. } else {
  8379. this.style.backgroundColor = '';
  8380. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  8381. }
  8382. }
  8383.  
  8384. function appendMenuType(node,duType) {
  8385. var select = document.createElement('select');
  8386. select.className = 'SelectboxV2';
  8387. var type = ['Guilde','Troll','Monstre'];
  8388. for(var i=0 ; i<3 ; i++) {
  8389. appendOption(select,type[i],type[i]);
  8390. if(type[i]==duType) { select.selectedIndex=i; }
  8391. }
  8392. node.appendChild(select);
  8393. }
  8394.  
  8395. function ajouteChamp(type,num,couleur,descr) {
  8396. var champs = document.getElementById('diploPerso');
  8397. var nb = champs.rows.length;
  8398. var tr = champs.insertRow(-1);
  8399. var td = appendTd(tr);
  8400. appendMenuType(td,type);
  8401. td = appendTd(tr);
  8402. appendText(td,' n°');
  8403. appendTextbox(td,'text','num'+nb,6,15,num);
  8404. td = appendTd(tr);
  8405. appendText(td,' couleur HTML:');
  8406. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  8407. input.onkeyup = previewCouleur;
  8408. input.onchange = previewCouleur;
  8409. input.onkeyup();
  8410. td = appendTd(tr);
  8411. appendText(td,' Description:');
  8412. appendTextbox(td,'text','descr'+nb,30,150,descr);
  8413. td = appendTd(tr);
  8414. var span = document.createElement('span');
  8415. appendText(span,'[ok!]',true);
  8416. span.style.visibility = 'hidden';
  8417. td.appendChild(span);
  8418. td = appendTd(tr);
  8419. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  8420. }
  8421.  
  8422. function retireCeChamp() {
  8423. var thisTr = this.parentNode.parentNode;
  8424. thisTr.parentNode.removeChild(thisTr);
  8425. var champs = document.getElementById('diploPerso');
  8426. if(champs.rows.length==0) { ajouteChamp(); }
  8427. }
  8428.  
  8429. function valideChamp(champ) {
  8430. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  8431. isCouleur(champ.cells[2].childNodes[1].value);
  8432. if(isValide) {
  8433. champ.cells[4].firstChild.style.visibility = 'visible';
  8434. } else {
  8435. champ.cells[4].firstChild.style.visibility = 'hidden';
  8436. }
  8437. return isValide;
  8438. }
  8439.  
  8440. function sauvegarderTout() {
  8441. /* Diplo de guilde */
  8442. diploGuilde.isOn =
  8443. document.getElementById('isGuildeOn').checked?'true':'false';
  8444. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  8445. var numGuilde = Number(document.getElementById('numGuilde').value);
  8446. var couleur = document.getElementById('couleurGuilde').value;
  8447. if(numGuilde) {
  8448. diploGuilde.guilde = {
  8449. id: numGuilde,
  8450. couleur: couleur
  8451. };
  8452. } else {
  8453. delete diploGuilde.guilde;
  8454. }
  8455. for(var AE in {Amis:0,Ennemis:0}) {
  8456. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  8457. for(var i=0 ; i<5 ; i++) {
  8458. if(isDetailOn) {
  8459. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  8460. } else {
  8461. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  8462. }
  8463. }
  8464. }
  8465. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  8466.  
  8467. /* Diplo personnelle (ex-fonction saveChamps) */
  8468. var champs = document.getElementById('diploPerso');
  8469. diploPerso = {
  8470. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  8471. Guilde: {},
  8472. Troll: {},
  8473. Monstre: {}
  8474. };
  8475. if(isMythiquesOn &&
  8476. isCouleur(document.getElementById('couleurMythiques').value)) {
  8477. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  8478. }
  8479. for(var i=0 ; i<champs.rows.length ; i++) {
  8480. if(valideChamp(champs.rows[i])) {
  8481. var type = champs.rows[i].cells[0].firstChild.value;
  8482. var num = champs.rows[i].cells[1].childNodes[1].value;
  8483. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  8484. var descr = champs.rows[i].cells[3].childNodes[1].value;
  8485. diploPerso[type][num] = {
  8486. couleur: couleur
  8487. };
  8488. if(descr) {
  8489. diploPerso[type][num].titre = descr;
  8490. }
  8491. }
  8492. }
  8493. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  8494.  
  8495. avertissement('Données sauvegardées');
  8496. }
  8497.  
  8498.  
  8499. /*-[functions]------------- Modifications de la page -------------------------*/
  8500.  
  8501. function creeTablePrincipale() {
  8502. var insertPt = document.getElementById('insertPt');
  8503.  
  8504. /* Titre + bouton de Sauvegarde */
  8505. var tr = insertTr(insertPt,'mh_tdtitre');
  8506. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  8507. appendButton(td,'Sauvegarder',sauvegarderTout);
  8508.  
  8509. /* Options fixes */
  8510. tr = insertTr(insertPt,'mh_tdpage');
  8511. td = appendTdText(tr,'Diplomatie de guilde:',true);
  8512. appendBr(td);
  8513. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  8514. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  8515. appendBr(td);
  8516. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  8517. appendText(td,'Utiliser des couleurs détaillées (10)');
  8518.  
  8519. /* Diplo personnelle */
  8520. tr = insertTr(insertPt,'mh_tdpage');
  8521. td = appendTdText(tr,'Diplomatie personnelle:',true);
  8522. appendBr(td);
  8523. // Diplo Mythiques
  8524. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  8525. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  8526. var span = document.createElement('span');
  8527. span.id = 'spanMythiques';
  8528. if(!isMythiquesOn) {
  8529. span.style.display = 'none';
  8530. }
  8531. var couleur = '#FFAAAA';
  8532. if(diploPerso.mythiques) {
  8533. couleur = diploPerso.mythiques;
  8534. }
  8535. appendText(span,' - couleur HTML:');
  8536. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  8537. input.onkeyup = previewCouleur;
  8538. input.onchange = previewCouleur;
  8539. input.onkeyup();
  8540. td.appendChild(span);
  8541. appendBr(td);
  8542. // Diplo éditable
  8543. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  8544. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  8545. appendBr(td);
  8546. var table = document.createElement('table');
  8547. table.id = 'diploPerso'
  8548. td.appendChild(table);
  8549. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8550. for(var num in diploPerso[type]) {
  8551. ajouteChamp(
  8552. type,
  8553. num,
  8554. diploPerso[type][num].couleur,
  8555. diploPerso[type][num].titre
  8556. );
  8557. }
  8558. }
  8559. if(table.rows.length==0) {
  8560. ajouteChamp();
  8561. }
  8562. appendButton(td,'Ajouter',ajouteChamp)
  8563. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  8564. appendText(td,' ');
  8565. appendButton(td,
  8566. 'Exemples de couleur',
  8567. function() {
  8568. var fenetre = window.open(
  8569. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  8570. 'Divers',
  8571. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  8572. 'status=0,menubar=0,resizable=1,scrollbars=1'
  8573. );
  8574. fenetre.focus();
  8575. }
  8576. );
  8577.  
  8578. /* Couleur de Guilde */
  8579. tr = insertTr(insertPt,'mh_tdtitre');
  8580. td = appendTdText(tr,'GUILDE',true);
  8581. appendText(td,' - n°');
  8582. appendTextbox(td,'text','numGuilde',5,10,
  8583. diploGuilde.guilde && diploGuilde.guilde.id ?
  8584. diploGuilde.guilde.id : ''
  8585. );
  8586. appendText(td,' - Couleur HTML: ');
  8587. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  8588. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  8589. diploGuilde.guilde.couleur : '#BBBBFF'
  8590. );
  8591. input.onkeyup = previewCouleur;
  8592. input.onchange = previewCouleur;
  8593. input.onkeyup();
  8594. }
  8595.  
  8596.  
  8597. /*-[functions]----------------------- Main -----------------------------------*/
  8598.  
  8599. function initDiplo(sType) {
  8600. var sDiplo = MY_getValue(numTroll + '.diplo.' + sType)
  8601. //console.log('sDiplo' + sType + '=' + sDiplo);
  8602. if (sDiplo && (sDiplo != 'null')) { // le stockage JSON nous donne parfois 'null'
  8603. return JSON.parse(sDiplo);
  8604. } else {
  8605. return {};
  8606. }
  8607. }
  8608. var diploGuilde = initDiplo('guilde');
  8609. var diploPerso = initDiplo('perso');
  8610. var isDetailOn = diploGuilde.isDetailOn=='true';
  8611. var isMythiquesOn = diploPerso.mythiques!=undefined;
  8612.  
  8613. function do_diplo() {
  8614. if(setChoixCouleurs() && fetchDiploGuilde()) {
  8615. creeTablePrincipale();
  8616. }
  8617. }
  8618.  
  8619. /*******************************************************************************
  8620. * This file is part of Mountyzilla. *
  8621. * *
  8622. * Mountyzilla is free software; you can redistribute it and/or modify *
  8623. * it under the terms of the GNU General Public License as published by *
  8624. * the Free Software Foundation; either version 2 of the License, or *
  8625. * (at your option) any later version. *
  8626. * *
  8627. * Mountyzilla is distributed in the hope that it will be useful, *
  8628. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8629. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8630. * GNU General Public License for more details. *
  8631. * *
  8632. * You should have received a copy of the GNU General Public License *
  8633. * along with Mountyzilla; if not, write to the Free Software *
  8634. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8635. *******************************************************************************/
  8636.  
  8637. // x~x cdmcomp
  8638.  
  8639. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  8640.  
  8641. function getNonNegInts(str) {
  8642. var nbrs = str.match(/\d+/g);
  8643. for(var i=0 ; i<nbrs.length ; i++) {
  8644. nbrs[i] = Number(nbrs[i]);
  8645. }
  8646. return nbrs;
  8647. }
  8648.  
  8649. function MZ_comp_traiteCdMcomp() {
  8650. // envoi au serveur (PHP) d'un objet avec
  8651. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  8652. // tstamp: l'horodatage
  8653. var oContexteCdM = MZ_analyseCdM('msgEffet', true); // analyse de la CdM, prépare l'envoi, prépare l'ajout de PV min/max selon blessure
  8654. oContexteCdM.nameBut = 'as_Action'; // nom du bouton avant lequel insérer le bouton ou les textes
  8655. if (!oContexteCdM.ok) {
  8656. if (oContexteCdM.error) {
  8657. window.console.log('MZ_comp_traiteCdMcomp, ' + oContexteCdM.error);
  8658. MZ_comp_addMessage(oContexteCdM, 'Erreur MZ, ' + oContexteCdM.error);
  8659. }
  8660. return;
  8661. }
  8662. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify( oContexteCdM.oData));
  8663.  
  8664. MZ_comp_addPvRestant(oContexteCdM);
  8665.  
  8666. var etimestamp = document.getElementById('hserveur');
  8667. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  8668. if (tstamp == undefined) {
  8669. /* dans le cas de la comp, le serveur se repliera sur la date/heure courrante
  8670. window.console.log('MZ_comp_traiteCdMcomp, pas de date/heure');
  8671. MZ_comp_addMessage(oContexteCdM, 'Impossible d\'envoyer la CdM à MZ, pas de date/heure');
  8672. return;
  8673. */
  8674. } else {
  8675. oContexteCdM.oData.tstamp = tstamp.replace(/\]/, '').trim();
  8676. }
  8677.  
  8678. // Envoi auto ou insertion bouton envoi (suivant option)
  8679. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  8680. oContexteCdM.sendInfoCDM();
  8681. MZ_comp_addMessage(oContexteCdM, 'CdM envoyée vers la base MountyZilla !');
  8682. } else {
  8683. insertButtonCdm('as_Action', oContexteCdM.sendInfoCDM);
  8684. }
  8685. }
  8686.  
  8687. function MZ_comp_addMessage(oContexteCdM, msg) {
  8688. var eBefore = document.getElementsByName(oContexteCdM.nameBut)[0].parentNode;
  8689. if (!eBefore) {
  8690. window.console.log('MZ_comp_addMessage, pas de ' + oContexteCdM.nameBut);
  8691. return;
  8692. }
  8693. var p = document.createElement('p');
  8694. p.style.color = 'green';
  8695. appendText(p, msg);
  8696. insertBefore(eBefore, p);
  8697. }
  8698.  
  8699. function MZ_analyseCdM(idHTMLCdM, bIgnoreEltAbsent) { // rend un contexte
  8700. var eltCdM = document.getElementById(idHTMLCdM);
  8701. var oRet = {};
  8702. if (!eltCdM) {
  8703. oRet.ok = false;
  8704. if (!bIgnoreEltAbsent) oRet.error = 'Pas d\'elt ' + idHTMLCdM;
  8705. return oRet;
  8706. }
  8707.  
  8708. // le contexte contiendra
  8709. // txtHeure : le texte de l'heure de la CdM
  8710. // trBlessure : le <tr> de la ligne "blessure"
  8711. // txtBlessure : le texte donnant le % de blessure
  8712. // txtPv : le texte donnant les PV
  8713. // ok : 1 si on a bien reconnu une CdM
  8714. // oData : les data à envoyer en JSON au serveur MZ
  8715. oRet.oData = {}
  8716. oRet.oData.tabCdM = new Array();
  8717. for (var iElt = 0; iElt < eltCdM.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  8718. var eHTML = eltCdM.childNodes[iElt];
  8719. var s = undefined;
  8720. switch (eHTML.nodeName) {
  8721. case '#text':
  8722. s = eHTML.nodeValue;
  8723. // suite : même code que <B> ou <p>
  8724. case 'P':
  8725. case 'B':
  8726. if (s === undefined) s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8727. s = s.trim();
  8728. if (s != '') {
  8729. if (s.match(/aux *alentours* *de/i)) oRet.txtHeure = s;
  8730. if (s.match(/Connaissance *des* *Monstres/i)) oRet.ok = true;
  8731. oRet.oData.tabCdM.push(s);
  8732. }
  8733. break;
  8734. case 'TABLE':
  8735. var s = 'table';
  8736. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  8737. var eTr = eHTML.rows[iTr];
  8738. var tabTd = new Array();
  8739. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  8740. var eTd = eTr.cells[iTd];
  8741. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  8742. s = s.trim();
  8743. tabTd.push(s);
  8744. }
  8745. if (tabTd.length >= 2) {
  8746. if (tabTd[0].match(/Blessure/i)) {
  8747. oRet.trBlessure = eTr;
  8748. oRet.txtBlessure = tabTd[1]
  8749. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  8750. oRet.txtPv = tabTd[1]
  8751. }
  8752. }
  8753. oRet.oData.tabCdM.push(tabTd);
  8754. }
  8755. break;
  8756. case 'BR':
  8757. break; // ignore
  8758. default:
  8759. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8760. if (s != '') oRet.oData.tabCdM.push(s);
  8761. window.console.log('[MZ ' + GM_info.script.version + '] MZ_analyseCdM, type d\'élément non traité : ' + eHTML.nodeName + ' ' + s);
  8762. break;
  8763. }
  8764. }
  8765. oRet.oData.idTroll = numTroll;
  8766.  
  8767. // préparation de l'envoi d'une CdM issue de compte-rendu de compétence
  8768. // fonction définie ici pour avoir vue sur la variable tabCdM
  8769. oRet.sendInfoCDM = function () {
  8770. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  8771. var buttonCDM = this;
  8772. var texte = '';
  8773. FF_XMLHttpRequest({
  8774. method: 'POST',
  8775. url: URL_pageDispatcherV2,
  8776. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oRet.oData)),
  8777. headers : {
  8778. 'Content-type':'application/x-www-form-urlencoded',
  8779. },
  8780. trace: 'envoi CdM',
  8781. onload: function(responseDetails) {
  8782. texte = responseDetails.responseText;
  8783. buttonCDM.value = texte;
  8784. //window.console.log('buttonCDM.parentNode.firstChild.nodeName=' + buttonCDM.parentNode.firstChild.nodeName);
  8785. if (buttonCDM.parentNode.firstChild.nodeName == 'SPAN') { // smartphone
  8786. buttonCDM.parentNode.firstChild.innerHTML = texte;
  8787. }
  8788. if (!isDEV) buttonCDM.disabled = true;
  8789. },
  8790. onerror: function(responseDetails) {
  8791. var msgError = 'inconnue';
  8792. if (responseDetails.status == 0) msgError = ' HTTPS ou CORS'
  8793. if (responseDetails.error) msgError = responseDetails.error;
  8794. msgError = 'Erreur MZ ' + msgError;
  8795. buttonCDM.value = msgError;
  8796. if (buttonCDM.parentNode.firstChild.nodeName == 'SPAN') { // smartphone
  8797. buttonCDM.parentNode.firstChild.innerHTML = msgError;
  8798. }
  8799. },
  8800. });
  8801. }
  8802. return oRet;
  8803. }
  8804.  
  8805. function MZ_comp_addPvRestant(oContexteCdM) {
  8806. // Insertion de l'estimation des PV restants
  8807. if (MY_DEBUG) window.console.log('txtBlessure=' + oContexteCdM.txtBlessure + ', txtPv=' + oContexteCdM.txtPv);
  8808. if (oContexteCdM.txtBlessure === undefined || oContexteCdM.txtPv === undefined) return;
  8809. var pv = getPVsRestants(oContexteCdM.txtPv, oContexteCdM.txtBlessure);
  8810. if (MY_DEBUG) window.console.log('pv=' + pv);
  8811. if (!pv) return; // pv null si le monstre n'est pas blessé
  8812. var tr = document.createElement('tr');
  8813. oContexteCdM.trBlessure.parentNode.insertBefore(tr, oContexteCdM.trBlessure.nextSibling);
  8814. var th = appendThText(tr, pv[0], false);
  8815. th.className = oContexteCdM.trBlessure.cells[0].className;
  8816. var td = appendTdText(tr, pv[1], false);
  8817. var eSpan = document.createElement('span');
  8818. appendText(eSpan, ' (Calculé par Mountyzilla)');
  8819. eSpan.style.fontSize = "small";
  8820. eSpan.style.fontStyle = "italic";
  8821. td.appendChild(eSpan);
  8822. }
  8823.  
  8824. function do_cdmcomp() {
  8825. start_script(31);
  8826. MZ_comp_traiteCdMcomp();
  8827. displayScriptTime();
  8828. }
  8829.  
  8830. /*********************************************************************************
  8831. * This file is part of Mountyzilla. *
  8832. * *
  8833. * Mountyzilla is free software; you can redistribute it and/or modify *
  8834. * it under the terms of the GNU General Public License as published by *
  8835. * the Free Software Foundation; either version 2 of the License, or *
  8836. * (at your option) any later version. *
  8837. * *
  8838. * Mountyzilla is distributed in the hope that it will be useful, *
  8839. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8840. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8841. * GNU General Public License for more details. *
  8842. * *
  8843. * You should have received a copy of the GNU General Public License *
  8844. * along with Mountyzilla; if not, write to the Free Software *
  8845. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8846. *********************************************************************************/
  8847.  
  8848. // x~x cmdbot
  8849.  
  8850. /* v0.2 by Dab - 2013-08-20
  8851. * - patch dégueu pour gérer la décomposition P/M de l'armure
  8852. */
  8853.  
  8854. var buttonCDM;
  8855.  
  8856. /*******************************************************************************************
  8857. CDM :
  8858. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  8859.  
  8860. Il ne vous est pas possible d'améliorer cette compétence.
  8861.  
  8862. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  8863. Niveau : Inimaginable (entre 49 et 51)
  8864. Points de Vie : Surtrollesque (entre 450 et 470)
  8865. Blessure (Approximatif) : 0 %
  8866. Dés d'Attaque : Impressionnant (entre 30 et 32)
  8867. Dés d'Esquive : Impressionnant (entre 28 et 30)
  8868. Dés de Dégat : Très Fort (entre 18 et 20)
  8869. Dés de Régénération : Excellent (égal à 13)
  8870. Armure Physique : Moyen (entre 10 et 12)
  8871. Armure Magique : Faible (inférieur à 6)
  8872. Vue : Moyen (entre 9 et 11)
  8873. Maitrise Magique : Inimaginable (supérieur à 6000)
  8874. Résistance Magique : Inimaginable (supérieur à 6000)
  8875. Nombre d'attaques : 1
  8876. Vitesse de Déplacement : Normale
  8877. Voir le Caché : Oui
  8878. Attaque à distance : Non
  8879. Attaque magique : Oui
  8880. Vole : Non
  8881. Sang froid : Inexistant
  8882. DLA : Milieu
  8883. Durée Tour : Remarquable (entre 9 et 11)
  8884. Chargement : Vide
  8885. Bonus Malus : Aucun
  8886.  
  8887. Vous avez également gagné 1 PX pour la réussite.
  8888. *******************************************************************************************
  8889. BOT :
  8890. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  8891.  
  8892. Le Monstre ciblé fait partie des : Mort-Vivant
  8893.  
  8894. Niveau : Incroyable (entre 36 et 38)
  8895. *******************************************************************************************/
  8896.  
  8897. function getNNInt(str) {
  8898. var nbrs = str.match(/\d+/g);
  8899. for (var i=0 ; i<nbrs.length ; i++)
  8900. nbrs[i] = parseInt(nbrs[i]);
  8901. return nbrs;
  8902. }
  8903.  
  8904. // envoi d'une CdM issue d'un message du BOT
  8905. function sendCDM() {
  8906. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  8907. document, null, 9, null).singleNodeValue;
  8908. /* ancienne version à supprimer
  8909. cdm = td.innerHTML;
  8910. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  8911. "$3$4 ($1 - N°$2)<br>");
  8912. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  8913. 'Blessure : XX % (approximativement)');
  8914. // Supprime la décomposition P/M de l'Armure
  8915. var bgn = cdm.indexOf('Armure Physique');
  8916. if (bgn!=-1) {
  8917. var end = cdm.indexOf('Vue')-2;
  8918. var lines = cdm.substring(bgn,end).split('<br>');
  8919. var armp = getNNInt(lines[0]);
  8920. var armm = getNNInt(lines[1]);
  8921. if (lines[0].indexOf('(inf')!=-1)
  8922. armp = [0,armp[0]];
  8923. if (lines[1].indexOf('(inf')!=-1)
  8924. armm = [0,armm[0]];
  8925. var insrt = 'Armure : ';
  8926. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  8927. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  8928. else
  8929. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  8930. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  8931. }
  8932. cdm = cdm.replace(/<br>/g,'\n');
  8933. */
  8934.  
  8935. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  8936. //window.console.log(tdTxt);
  8937. var oData = {};
  8938. oData.tabCdM = tdTxt.split(/\n/);
  8939. // nettoyage entête : enlève le premier élément tant que
  8940. // - suite de *
  8941. // - "MOUNTYHALL - La Terre des Trõlls"
  8942. // - ligne vide (la première expression régulière matche les lignes vides)
  8943. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  8944. // 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
  8945. var iLigneNonVide;
  8946. for (var i = 0; i < oData.tabCdM.length; i++) {
  8947. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  8948. if (iLigneNonVide === undefined)
  8949. oData.tabCdM.splice(i);
  8950. else
  8951. oData.tabCdM.splice(iLigneNonVide+1);
  8952. break;
  8953. }
  8954. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  8955. }
  8956. //window.console.log(JSON.stringify(oData));
  8957.  
  8958. FF_XMLHttpRequest({
  8959. method: 'POST',
  8960. url: URL_pageDispatcherV2,
  8961. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8962. headers : {
  8963. /* inutile, à supprimer
  8964. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8965. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8966. */
  8967. 'Content-type':'application/x-www-form-urlencoded',
  8968. },
  8969. trace: 'envoi CdM msg du bot',
  8970. onload: function(responseDetails) {
  8971. buttonCDM.value=responseDetails.responseText;
  8972. buttonCDM.disabled = true;
  8973. }
  8974. });
  8975. }
  8976.  
  8977. function MZ_traiteCdMmsg() {
  8978. var oContexteCdM = MZ_analyseCdM('messageContent'); // analyse de la CdM, prépare l'envoi, prépare l'ajout de PV min/max selon blessure
  8979. oContexteCdM.nameBut = 'bForward'; // nom du bouton avant lequel insérer le bouton ou les textes
  8980. if (!oContexteCdM.ok) {
  8981. if (oContexteCdM.error) {
  8982. window.console.log('MZ_traiteCdMmsg, ' + oContexteCdM.error);
  8983. MZ_comp_addMessage(oContexteCdM, 'Erreur MZ, ' + oContexteCdM.error);
  8984. }
  8985. return;
  8986. }
  8987. if (MY_DEBUG) window.console.log('oContexteCdM=' + JSON.stringify( oContexteCdM));
  8988.  
  8989. MZ_comp_addPvRestant(oContexteCdM);
  8990.  
  8991. if (oContexteCdM.txtHeure) {
  8992. var m = oContexteCdM.txtHeure.match(/\d+\/\d+\/\d+ +\d+:\d+:\d+/);
  8993. if (m) var tstamp = m[0];
  8994. }
  8995. if (tstamp == undefined) {
  8996. window.console.log('MZ_traiteCdMmsg, pas de date/heure');
  8997. MZ_comp_addMessage(oContexteCdM, 'Impossible d\'envoyer la CdM à MZ, pas de date/heure');
  8998. return;
  8999. }
  9000. oContexteCdM.oData.tstamp = tstamp.trim();
  9001. oContexteCdM.oData.bMsgBot = 1;
  9002.  
  9003. // Insertion bouton envoi
  9004. insertButtonCdm(oContexteCdM.nameBut, oContexteCdM.sendInfoCDM);
  9005.  
  9006. /* à supprimer
  9007. // Teste si ce message du bot est un message de CdM
  9008. var tdMessageContent = document.getElementById('messageContent');
  9009. if (!tdMessageContent) return;
  9010.  
  9011. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  9012. document, null, 9, null).singleNodeValue;
  9013. if (!td) return false;
  9014.  
  9015. cdm = td.innerHTML;
  9016.  
  9017. // Insertion de l'estimation des PV restants
  9018. var des = cdm.indexOf('Dés');
  9019. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  9020. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  9021. if(pv)
  9022. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  9023.  
  9024. // Insertion bouton envoi + espace
  9025. buttonCDM = insertButtonCdm('bClose',sendCDM);
  9026. */
  9027. }
  9028.  
  9029. /*function traitePouvoir() {
  9030. // Teste si ce message du bot est un message de CdM
  9031. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  9032. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  9033. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  9034. if (!td)
  9035. return false;
  9036.  
  9037. var infos = td.innerHTML;
  9038. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  9039. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  9040. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  9041. var date = /alors : ([^<]+)\./.exec(infos)[1];
  9042. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  9043. var effetPouvoir="";
  9044. var full=false;
  9045. if(infos.indexOf("REDUIT")!=-1) {
  9046. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  9047. }
  9048. else {
  9049. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  9050. full=true;
  9051. }
  9052. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  9053. // On insère le bouton et un espace
  9054. //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));
  9055. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  9056. if(!MY_getValue('AUTOSENDPOUV'))
  9057. {
  9058. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  9059. button.setAttribute("onClick", "window.open('" + url
  9060. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  9061. + "this.value='Merci de votre participation'; this.disabled = true;");
  9062. }
  9063. else
  9064. {
  9065. FF_XMLHttpRequest({
  9066. method: 'GET',
  9067. url: url,
  9068. headers : {
  9069. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9070. 'Accept': 'application/atom+xml,application/xml,text/xml'
  9071. }});
  9072. }
  9073. }*/
  9074.  
  9075. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  9076. MZ_traiteCdMmsg();
  9077. }
  9078. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  9079.  
  9080. /*******************************************************************************
  9081. * This file is part of Mountyzilla. *
  9082. * *
  9083. * Mountyzilla is free software; you can redistribute it and/or modify *
  9084. * it under the terms of the GNU General Public License as published by *
  9085. * the Free Software Foundation; either version 2 of the License, or *
  9086. * (at your option) any later version. *
  9087. * *
  9088. * Mountyzilla is distributed in the hope that it will be useful, *
  9089. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9090. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9091. * GNU General Public License for more details. *
  9092. * *
  9093. * You should have received a copy of the GNU General Public License *
  9094. * along with Mountyzilla; if not, write to the Free Software *
  9095. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9096. *******************************************************************************/
  9097.  
  9098. // x~x menu
  9099. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  9100.  
  9101. var menuRac, mainIco;
  9102.  
  9103. // met à jour les carac sauvegardées (position, DLA, etc.)
  9104. function updateData() {
  9105. var inputs = document.getElementsByTagName('input');
  9106. var divs = document.getElementsByTagName('div');
  9107.  
  9108. //window.console.log('inputs=' + JSON.stringify(inputs));
  9109. if (inputs && inputs.length > 0) {
  9110. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  9111. numTroll = inputs[0].value;
  9112. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  9113. MY_setValue('NUM_TROLL', numTroll);
  9114. MY_setValue('NIV_TROLL',inputs[1].value);
  9115. if(!MY_getValue(numTroll+'.caracs.rm')) {
  9116. MY_setValue(numTroll+'.caracs.rm',0);
  9117. // assure l'init des 4 var de libs
  9118. }
  9119. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  9120. } else {
  9121. // onclick="EnterPJView(91305,750,550)"
  9122. var tabA = document.getElementsByTagName('a');
  9123. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  9124. var s = tabA[0].onclick.toString();;
  9125. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  9126. var m = s.match(/\((\d+) *,/);
  9127. //window.console.log('m=' + JSON.stringify(m));
  9128. numTroll = parseInt(m[1]);
  9129. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  9130. MY_setValue('NUM_TROLL', numTroll);
  9131. } else {
  9132. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  9133. }
  9134. }
  9135.  
  9136. var DLA = new Date(
  9137. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  9138. );
  9139. if(MY_getValue(numTroll+'.DLA.encours')) {
  9140. var DLAstockee = new Date(
  9141. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  9142. );
  9143. if(DLA>DLAstockee) {
  9144. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  9145. // Pose un pb en cas de décalage de DLA
  9146. }
  9147. }
  9148. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  9149.  
  9150. try {
  9151. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  9152. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  9153. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  9154. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  9155. } catch(e) {
  9156. 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, '‹'));
  9157. }
  9158. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  9159. }
  9160.  
  9161. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9162. function initRaccourcis() {
  9163. var anotherURL = MY_getValue('URL1');
  9164. if(!anotherURL) { return; }
  9165.  
  9166. /* Création de l'icône faisant apparaître le menu */
  9167. mainIco = document.createElement('img');
  9168. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  9169. if(!urlIco) {
  9170. urlIco =
  9171. URL_MZimg + 'mz_logo_small.png';
  9172. }
  9173. mainIco.src = urlIco;
  9174. mainIco.alt = 'MZ';
  9175. mainIco.style = 'position:fixed; top:0px; left:0px';
  9176. mainIco.onmouseover = afficheMenu;
  9177. document.body.appendChild(mainIco);
  9178.  
  9179. /* Création du menu des Raccourcis */
  9180. menuRac = document.createElement('div');
  9181. menuRac.className = 'mh_textbox';
  9182. menuRac.style =
  9183. 'position:fixed; top:10px; left:10px;'+
  9184. 'max-width:190px;'+
  9185. 'border-radius: 4px; padding: 4px;'+
  9186. 'z-index: 500;'+
  9187. 'visibility: hidden;';
  9188. document.body.appendChild(menuRac);
  9189. document.addEventListener('mousemove',cacheMenu,false);
  9190. var i=1;
  9191. while(anotherURL) {
  9192. var a = document.createElement('a');
  9193. var url = MY_getValue('URL'+i);
  9194. var nom = MY_getValue('URL'+i+'.nom');
  9195. var ico = MY_getValue('URL'+i+'.ico');
  9196. a.href = url;
  9197. a.target = '_blank';
  9198. if(ico) {
  9199. var txt = nom ? nom : '';
  9200. var img = createImage(ico,txt);
  9201. a.appendChild(img);
  9202. }
  9203. else {
  9204. appendText(a,'['+nom+']');
  9205. }
  9206. menuRac.appendChild(a);
  9207. appendBr(menuRac);
  9208. i++;
  9209. anotherURL = MY_getValue('URL'+i);
  9210. }
  9211. }
  9212.  
  9213. function afficheMenu() {
  9214. menuRac.style.visibility = 'visible';
  9215. }
  9216.  
  9217. function cacheMenu(e) {
  9218. if(menuRac.style.visibility=='hidden') { return; }
  9219. // Position souris
  9220. var ptX = e.clientX;
  9221. var ptY = e.clientY;
  9222. // On recalcule en live les BoundingBox pour mainIco et menuRac
  9223. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  9224. var menuRect = menuRac.getBoundingClientRect();
  9225. var icoRect = mainIco.getBoundingClientRect();
  9226. if((ptX>icoRect.width || ptY>icoRect.height) &&
  9227. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  9228. menuRac.style.visibility = 'hidden';
  9229. }
  9230. }
  9231.  
  9232. // ajout de l'icône, branchée sur un refresh
  9233. function initUpdateCoordGauche() {
  9234. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  9235. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  9236. var img = document.createElement('img');
  9237. img.src = URL_MZimg + 'recycl.png'
  9238. img.onclick = function(evt) {
  9239. document.location.href = document.location.href;
  9240. };
  9241. img.title = 'Mise à jour de la localisation';
  9242. img.style.cursor = 'pointer';
  9243. img.style.position = 'absolute';
  9244. img.style.bottom = 0;
  9245. img.style.left = 0;
  9246. div.appendChild(img);
  9247. }
  9248.  
  9249. function do_menu() {
  9250. // met à jour les carac sauvegardées (position, DLA, etc.)
  9251. updateData();
  9252. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9253. initRaccourcis();
  9254. // Ajout bouton de mise à jour coordonnées
  9255. initUpdateCoordGauche();
  9256. }
  9257.  
  9258. /*******************************************************************************
  9259. * This file is part of Mountyzilla. *
  9260. * *
  9261. * Mountyzilla is free software; you can redistribute it and/or modify *
  9262. * it under the terms of the GNU General Public License as published by *
  9263. * the Free Software Foundation; either version 2 of the License, or *
  9264. * (at your option) any later version. *
  9265. * *
  9266. * Mountyzilla is distributed in the hope that it will be useful, *
  9267. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9268. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9269. * GNU General Public License for more details. *
  9270. * *
  9271. * You should have received a copy of the GNU General Public License *
  9272. * along with Mountyzilla; if not, write to the Free Software *
  9273. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9274. *******************************************************************************/
  9275.  
  9276. // x~x vue
  9277.  
  9278. /* TODO
  9279. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  9280. * prévoir fix ("delete infos")
  9281. */
  9282.  
  9283. /*--------------------------- Variables Globales -----------------------------*/
  9284.  
  9285. // Position actuelle
  9286. var currentPosition=[0,0,0];
  9287.  
  9288. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  9289. var porteeVue=[0,0,0,0];
  9290.  
  9291. // Fenêtres déplaçables
  9292. var winCurr = null;
  9293. var offsetX, offsetY;
  9294.  
  9295. // Diplomatie
  9296. var Diplo = {
  9297. Guilde: {},
  9298. Troll: {},
  9299. Monstre: {}
  9300. // .mythiques: uniquement si option activée
  9301. };
  9302. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  9303.  
  9304. // Infos tactiques
  9305. // => MZ_Tactique.popup
  9306.  
  9307. // Utilisé pour supprimer les monstres "engagés"
  9308. var listeEngages = {};
  9309. var isEngagesComputed = false;
  9310. var cursorOnLink = false; // DEBUG: wtf ?
  9311.  
  9312. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  9313. && MY_getValue(numTroll+'.enchantement.liste')!='';
  9314.  
  9315. // Checkboxes de filtrage
  9316. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  9317. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  9318. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  9319. comboBoxNiveauMin, comboBoxNiveauMax, comboBoxFamille;
  9320.  
  9321. /* Acquisition & Stockage des données de DB */
  9322. var typesAFetcher = {
  9323. 'monstres':1,
  9324. 'trolls':1,
  9325. 'tresors':1,
  9326. 'champignons':1,
  9327. 'lieux':1
  9328. }
  9329.  
  9330. var MZ_EtatCdMs = { // zone où sont stockées les variables "globales" pour la gestion des cdM et infos tactiques
  9331. nbMonstres: 0,
  9332. tr_monstres: [],
  9333. lastIndexDone: 0,
  9334. isCDMsRetrieved: false, // = si les CdM ont déjà été DL
  9335. listeCDM: [],
  9336. // Gère l'affichage en cascade des popups de CdM
  9337. yIndexCDM: 0,
  9338. tdWitdh: 110,
  9339. };
  9340.  
  9341. var VueContext = {};
  9342. var tr_trolls = {}, tr_tresors = {},
  9343. tr_champignons = {}, tr_lieux = {};
  9344. var nbTrolls = 0, nbTresors = 0,
  9345. nbChampignons = 0, nbLieux = 0;
  9346.  
  9347. function fetchData(type) {
  9348. var node;
  9349. try {
  9350. node = document.getElementById('mh_vue_hidden_'+type);
  9351. VueContext['tr_'+type] = node.getElementsByTagName('tr');
  9352. VueContext['nb'+type[0].toUpperCase()+type.slice(1)] = VueContext['tr_'+type].length-1;
  9353. } catch(e) {
  9354. window.console.warn('[MZ Vue] Erreur acquisition type '+type, e);
  9355. }
  9356. }
  9357.  
  9358. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  9359.  
  9360. function positionToString(arr) {
  9361. return arr.join(';');
  9362. }
  9363.  
  9364. function savePosition() {
  9365. // Stocke la position (à jour) de la vue pour les autres scripts
  9366. // DEBUG: Lesquels et pourquoi?
  9367. var pos = getPosition();
  9368. MY_setValue(numTroll+'.position.X',pos[0]);
  9369. MY_setValue(numTroll+'.position.Y',pos[1]);
  9370. MY_setValue(numTroll+'.position.N',pos[2]);
  9371. }
  9372.  
  9373.  
  9374. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  9375. /* INFOS :
  9376. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  9377. * sont identifiables via leur Name
  9378. * les tables-listings sont identifiables via l'ID du tr conteneur
  9379. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  9380. */
  9381.  
  9382. /* [functions] Récup données Utilisateur */
  9383. function getPosition() {
  9384. // Pour rétrocompatibilité
  9385. return currentPosition;
  9386. }
  9387.  
  9388. function getPorteVue() {
  9389. // Pour rétrocompatibilité
  9390. return porteeVue;
  9391. }
  9392.  
  9393. function getVue() {
  9394. // Retourne [vueHpure, vueVpure]
  9395. var vues = getPorteVue();
  9396. return [ vues[0], vues[1] ];
  9397. }
  9398.  
  9399. // Roule 11/03/2016
  9400. /* [functions] Récup données monstres, trolls, etc. */
  9401. function getXxxDistance(xxx, i) {
  9402. return parseInt(VueContext['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  9403. }
  9404. function getXxxPosition(xxx, i) {
  9405. var tds = VueContext['tr_' + xxx.toLowerCase()][i].childNodes;
  9406. var l = tds.length;
  9407. return [
  9408. parseInt(tds[l-3].textContent),
  9409. parseInt(tds[l-2].textContent),
  9410. parseInt(tds[l-1].textContent)
  9411. ];
  9412. }
  9413.  
  9414.  
  9415. /* [functions] Récup données monstres */
  9416. function getMonstreDistance(i) {
  9417. //debugMZ('getMonstreDistance, i=' + i + ', tr=' + MZ_EtatCdMs.tr_monstres[i].innerHTML);
  9418. return parseInt(MZ_EtatCdMs.tr_monstres[i].cells[0].textContent);
  9419. }
  9420.  
  9421. function getMonstreID(i) {
  9422. return Number(MZ_EtatCdMs.tr_monstres[i].cells[2].firstChild.nodeValue);
  9423. }
  9424.  
  9425. function getMonstreIDByTR(tr) {
  9426. return tr.cells[2].firstChild.nodeValue;
  9427. }
  9428.  
  9429. function getMonstreLevelNode(i) {
  9430. return MZ_EtatCdMs.tr_monstres[i].cells[3];
  9431. }
  9432.  
  9433. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  9434. if(!MZ_EtatCdMs.isCDMsRetrieved) return false;
  9435. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  9436. if (!donneesMonstre) return false;
  9437. var niv = donneesMonstre.niv;
  9438. if (niv == undefined) return false;
  9439. if (limitMin > 0 && niv.max && niv.max < limitMin) return true;
  9440. if (limitMax > 0 && niv.min && niv.min > limitMax) return true;
  9441. return false;
  9442. }
  9443.  
  9444. function getMonstreNomNode(i) {
  9445. try {
  9446. var td = document.evaluate(
  9447. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  9448. MZ_EtatCdMs.tr_monstres[i], null, 9, null
  9449. ).singleNodeValue;
  9450. return td;
  9451. } catch(e) {
  9452. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  9453. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  9454. }
  9455. }
  9456.  
  9457. function getMonstreNom(i) {
  9458. return getMonstreNomByTR(MZ_EtatCdMs.tr_monstres[i]);
  9459. }
  9460.  
  9461. function getMonstreNomByTR(tr) {
  9462. try {
  9463. var nom = document.evaluate(
  9464. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  9465. tr, null, 2, null
  9466. ).stringValue;
  9467. return nom;
  9468. } catch(e) {
  9469. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  9470. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  9471. }
  9472. }
  9473.  
  9474. function getMonstrePosition(i) {
  9475. var tds = MZ_EtatCdMs.tr_monstres[i].childNodes;
  9476. var l = tds.length;
  9477. return [
  9478. parseInt(tds[l-3].textContent),
  9479. parseInt(tds[l-2].textContent),
  9480. parseInt(tds[l-1].textContent)
  9481. ];
  9482. }
  9483.  
  9484. function appendMonstres(txt) {
  9485. for(var i=1; i<=MZ_EtatCdMs.nbMonstres ; i++)
  9486. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  9487. return txt;
  9488. }
  9489.  
  9490. function getMonstres() {
  9491. var vue = getVue();
  9492. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9493. }
  9494.  
  9495. function bddMonstres(start,stop) {
  9496. if(!start) { var start = 1; }
  9497. if(!stop) { var stop = MZ_EtatCdMs.nbMonstres; }
  9498. stop = Math.min(MZ_EtatCdMs.nbMonstres,stop);
  9499. var txt='';
  9500. for(var i=start ; i<=stop ; i++) {
  9501. txt += getMonstreID(i)+';'+
  9502. getMonstreNom(i)+';'+
  9503. positionToString(getMonstrePosition(i))+'\n';
  9504. }
  9505. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  9506. }
  9507.  
  9508. /* [functions] Récup données Trolls */
  9509.  
  9510. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  9511. var COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  9512.  
  9513. function getTrollDistance(i) {
  9514. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  9515. }
  9516.  
  9517. var MZ_cache_col_TrollID;
  9518. var MZ_cache_col_TrollNOM;
  9519. var MZ_cache_col_TrollGUILDE;
  9520. var MZ_cache_col_TrollNIV;
  9521.  
  9522. function MZ_find_col_titre(trs, titre) {
  9523. var l = titre.length;
  9524. for (var i=0; i < trs[0].cells.length; i++)
  9525. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  9526. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  9527. return 0;
  9528. }
  9529.  
  9530. function getTrollID(i) {
  9531. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  9532. // Roule 08/03/2017 protection
  9533. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  9534. if (isNaN(iTroll)) return;
  9535. if (iTroll == 0) return;
  9536. return iTroll;
  9537. }
  9538.  
  9539. function getTrollNomNode(i) {
  9540. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  9541. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  9542. }
  9543.  
  9544. function getTrollNivNode(i) {
  9545. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  9546. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  9547. }
  9548.  
  9549. function getTrollGuilde(i) {
  9550. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9551. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  9552. }
  9553.  
  9554. function getTrollGuildeID(i) {
  9555. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9556. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  9557. var href;
  9558. try {
  9559. 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"
  9560. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  9561. } catch(e) { // debug pb remonté par Marsak
  9562. window.console.error(traceStack(e, 'getTrollGuildeID')
  9563. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  9564. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  9565. return -1;
  9566. }
  9567. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  9568. }
  9569. return -1;
  9570. }
  9571.  
  9572. function getTrollPosition(i) {
  9573. var tds = tr_trolls[i].childNodes;
  9574. var l = tds.length;
  9575. return [
  9576. parseInt(tds[l-3].textContent),
  9577. parseInt(tds[l-2].textContent),
  9578. parseInt(tds[l-1].textContent)
  9579. ];
  9580. }
  9581.  
  9582. function bddTrolls() {
  9583. var txt='#DEBUT TROLLS\n'+
  9584. numTroll+';'+positionToString(getPosition())+'\n';
  9585. for(var i=1 ; i<=nbTrolls ; i++) {
  9586. txt += getTrollID(i)+';'+
  9587. positionToString(getTrollPosition(i))+'\n';
  9588. }
  9589. return txt+'#FIN TROLLS';
  9590. }
  9591.  
  9592. /* [functions] Récup données Trésors */
  9593. function getTresorDistance(i) {
  9594. return tr_tresors[i].cells[0].firstChild.nodeValue;
  9595. }
  9596.  
  9597. function getTresorID(i) {
  9598. return trim(tr_tresors[i].cells[2].textContent);
  9599. }
  9600.  
  9601. function getTresorNom(i) {
  9602. // Utilisation de textContent pour régler le "bug de Pollux"
  9603. return trim(tr_tresors[i].cells[3].textContent);
  9604. }
  9605.  
  9606. function getTresorPosition(i) {
  9607. var tds = tr_tresors[i].childNodes;
  9608. var l = tds.length;
  9609. return [
  9610. parseInt(tds[l-3].textContent),
  9611. parseInt(tds[l-2].textContent),
  9612. parseInt(tds[l-1].textContent),
  9613. ];
  9614. }
  9615.  
  9616. function bddTresors(dmin,start,stop) {
  9617. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  9618. if(!dmin) { var dmin = 0; }
  9619. if(!start) { var start = 1; }
  9620. if(!stop) { var stop = nbTresors; }
  9621. stop = Math.min(nbTresors,stop);
  9622. var txt='';
  9623. for(var i=start ; i<=stop ; i++) {
  9624. if(getTresorDistance(i)>=dmin) {
  9625. txt += getTresorID(i)+';'+
  9626. getTresorNom(i)+';'+
  9627. positionToString(getTresorPosition(i))+'\n';
  9628. }
  9629. }
  9630. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  9631. }
  9632.  
  9633. /* [functions] Récup données Champignons */
  9634. // DEBUG: Pas de colonne "Référence" sur serveur de test
  9635. function getChampignonNom(i) {
  9636. return trim(tr_champignons[i].cells[2].textContent);
  9637. }
  9638.  
  9639. function getChampignonPosition(i) {
  9640. var tds = tr_champignons[i].childNodes;
  9641. var l = tds.length;
  9642. return [
  9643. parseInt(tds[l-3].textContent),
  9644. parseInt(tds[l-2].textContent),
  9645. parseInt(tds[l-1].textContent)
  9646. ];
  9647. }
  9648.  
  9649. function bddChampignons() {
  9650. var txt='';
  9651. for(var i=1 ; i<=nbChampignons ; i++) {
  9652. txt += ';'+ // Les champis n'ont pas de Référence
  9653. getChampignonNom(i)+';'+
  9654. positionToString(getChampignonPosition(i))+'\n';
  9655. }
  9656. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  9657. }
  9658.  
  9659. /* [functions] Récup données Lieux */
  9660. function getLieuDistance(i) {
  9661. return parseInt(tr_lieux[i].cells[0].textContent);
  9662. }
  9663.  
  9664. function getLieuID(i) {
  9665. return parseInt(tr_lieux[i].cells[2].textContent);
  9666. }
  9667.  
  9668. function getLieuNom(i) {
  9669. // Conversion ASCII pour éviter les bugs des Vues externes
  9670. return trim(tr_lieux[i].cells[3].textContent);
  9671. }
  9672.  
  9673. function getLieuPosition(i) {
  9674. var tds = tr_lieux[i].childNodes;
  9675. var l = tds.length;
  9676. return [
  9677. parseInt(tds[l-3].textContent),
  9678. parseInt(tds[l-2].textContent),
  9679. parseInt(tds[l-1].textContent)
  9680. ];
  9681. }
  9682.  
  9683. function appendLieux(txt) {
  9684. for(var i = 1; i < nbLieux+1; i++) {
  9685. var tds = x_lieux[i].childNodes;
  9686. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  9687. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  9688. }
  9689. return txt;
  9690. }
  9691.  
  9692. function getLieux() {
  9693. var vue = getVue();
  9694. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9695. }
  9696.  
  9697. function bddLieux(start,stop) {
  9698. if(!start) { var start = 1; }
  9699. if(!stop) { var stop = nbLieux; }
  9700. stop = Math.min(nbLieux,stop);
  9701. var txt='';
  9702. for(var i=start ; i<=stop ; i++) {
  9703. txt += getLieuID(i)+';'+
  9704. epure(getLieuNom(i))+';'+
  9705. positionToString(getLieuPosition(i))+'\n';
  9706. }
  9707. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  9708. }
  9709.  
  9710.  
  9711. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  9712.  
  9713. function saveCheckBox(chkbox, pref) {
  9714. // Enregistre et retourne l'état d'une CheckBox
  9715. var etat = chkbox.checked;
  9716. MY_setValue(pref, etat ? 'true' : 'false' );
  9717. return etat;
  9718. }
  9719.  
  9720. function recallCheckBox(chkbox, pref) {
  9721. // Restitue l'état d'une CheckBox
  9722. chkbox.checked = (MY_getValue(pref)=='true');
  9723. }
  9724.  
  9725. function saveComboBox(cbb, pref) {
  9726. // Enregistre et retourne l'état d'une ComboBox
  9727. var opt = cbb.options[cbb.selectedIndex];
  9728. if (!opt) return;
  9729. var etat = cbb.options[cbb.selectedIndex].value;
  9730. MY_setValue(pref, etat);
  9731. return etat;
  9732. }
  9733.  
  9734. function recallComboBox(cbb, pref) {
  9735. // Restitue l'état d'une ComboBox
  9736. var nb = MY_getValue(pref);
  9737. if(nb) cbb.value = nb;
  9738. return nb;
  9739. }
  9740.  
  9741. function synchroniseFiltres() {
  9742. // Récupération de toutes les options de la vue
  9743. var wasActive =
  9744. Number(recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE')) +
  9745. Number(recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE')) +
  9746. (recallComboBox(comboBoxFamille,'FAMILLEMONSTRE') == 0 ? 0 : 1); // Roule 30/01/2020 on obtient du non numérique si il y a filtre par famille
  9747. if(wasActive>0) {
  9748. debutFiltrage('Monstres');
  9749. }
  9750. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9751. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9752. recallCheckBox(checkBoxMythiques,'NOMYTH');
  9753. recallCheckBox(checkBoxEngages,'NOENGAGE');
  9754. recallCheckBox(checkBoxLevels,'NOLEVEL');
  9755. recallCheckBox(checkBoxIntangibles,'NOINT');
  9756. recallCheckBox(checkBoxGG,'NOGG');
  9757. recallCheckBox(checkBoxCompos,'NOCOMP');
  9758. recallCheckBox(checkBoxBidouilles,'NOBID');
  9759. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  9760. recallCheckBox(checkBoxTrou,'NOTROU');
  9761. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9762. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  9763. if(MY_getValue('NOINFOEM')!='true')
  9764. recallCheckBox(checkBoxEM,'NOEM');
  9765. }
  9766.  
  9767.  
  9768. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  9769.  
  9770. function getVueScript() {
  9771. try {
  9772. var txt = bddTrolls()+
  9773. bddMonstres()+
  9774. bddChampignons()+
  9775. bddTresors()+
  9776. bddLieux()+
  9777. '#DEBUT ORIGINE\n'+
  9778. getPorteVue()[2]+';'+positionToString(getPosition())+
  9779. '\n#FIN ORIGINE\n';
  9780. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  9781. return txt;
  9782. } catch(e) {
  9783. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  9784. window.console.error(traceStack(e, 'getVueScript'))
  9785. }
  9786. }
  9787.  
  9788. /* [functions] Menu Vue 2D */
  9789. var vue2Ddata = {
  9790. 'Bricol\' Vue': {
  9791. url: URL_bricol_mountyhall + 'vue_form.php',
  9792. paramid: 'vue',
  9793. func: getVueScript,
  9794. extra_params: {
  9795. 'mode': 'vue_SP_Vue2',
  9796. 'screen_width': window.screen.width
  9797. }
  9798. },
  9799. 'Vue du CCM': {
  9800. url: URL_vue_CCM,
  9801. paramid: 'vue',
  9802. func: getVueScript,
  9803. extra_params: {
  9804. 'id': numTroll+';'+positionToString(getPosition())
  9805. }
  9806. },
  9807. 'Vue Gloumfs 2D': {
  9808. url: URL_vue_Gloumfs2D,
  9809. paramid: 'vue_mountyzilla',
  9810. func: getVueScript,
  9811. extra_params: {}
  9812. },
  9813. 'Vue Gloumfs 3D': {
  9814. url: URL_vue_Gloumfs3D,
  9815. paramid: 'vue_mountyzilla',
  9816. func: getVueScript,
  9817. extra_params: {}
  9818. },
  9819. 'Grouky Vue!': {
  9820. url: URL_vue_Grouky,
  9821. paramid: 'vue',
  9822. func: getVueScript,
  9823. extra_params: {
  9824. 'type_vue': 'V5b1'
  9825. }
  9826. },
  9827. /*'DEBUG': {
  9828. url: 'http://weblocal/testeur.php',
  9829. paramid: 'vue',
  9830. func: getVueScript,
  9831. extra_params: {}
  9832. }*/
  9833. };
  9834.  
  9835. function refresh2DViewButton() {
  9836. // = EventListener menu+bouton vue 2D
  9837. var vueext = document.getElementById('selectVue2D').value;
  9838. MY_setValue('VUEEXT',vueext);
  9839. var form = document.getElementById('viewForm');
  9840. form.innerHTML = '';
  9841. form.method = 'post';
  9842. form.action = vue2Ddata[vueext].url;
  9843. form.target = '_blank';
  9844. appendHidden(form, vue2Ddata[vueext].paramid, '');
  9845. for(var key in vue2Ddata[vueext].extra_params) {
  9846. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  9847. }
  9848. appendSubmit(form, 'Voir',
  9849. function() {
  9850. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  9851. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  9852. vue2Ddata[vueext].func();
  9853. }
  9854. );
  9855. }
  9856.  
  9857. function set2DViewSystem() {
  9858. // Initialise le système de vue 2D
  9859. // Recherche du point d'insertion
  9860. var center;
  9861. try {
  9862. // Roule 09/03/2019, encore un changement MH, je fais suivre comme je peux
  9863. center = document.getElementById('titre2');
  9864. // version initiale "pré-Roule"
  9865. if (!center) center = document.evaluate(
  9866. "//h2[@id='titre2']/following-sibling::center",
  9867. document, null, 9, null
  9868. ).singleNodeValue;
  9869. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  9870. if (!center) center = document.evaluate(
  9871. "//h2[@id='titre2']/following-sibling::div",
  9872. document, null, 9, null
  9873. ).singleNodeValue;
  9874.  
  9875. } catch(e) {
  9876. avertissement("Erreur d'initialisation du système de vue 2D");
  9877. window.console.error(traceStack(e, 'set2DViewSystem'));
  9878. return;
  9879. }
  9880.  
  9881. // Récupération de la dernière vue utilisée
  9882. var vueext = MY_getValue('VUEEXT');
  9883. if(!vueext || !vue2Ddata[vueext]) {
  9884. // sinon, la vue Bricol'Trolls est employée par défaut
  9885. vueext = 'Bricol\' Vue';
  9886. }
  9887.  
  9888. try {
  9889. // Création du sélecteur de vue externe
  9890. selectVue2D = document.createElement('select');
  9891. selectVue2D.id = 'selectVue2D';
  9892. selectVue2D.className = 'SelectboxV2';
  9893. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  9894. for(var view in vue2Ddata) {
  9895. appendOption(selectVue2D, view, view);
  9896. }
  9897. selectVue2D.value = vueext;
  9898. selectVue2D.onchange = refresh2DViewButton;
  9899.  
  9900. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  9901. var form = document.createElement('form');
  9902. form.id = 'viewForm';
  9903.  
  9904. // Insertion du système de vue
  9905. var table = document.createElement('table');
  9906. var tr = appendTr(table);
  9907. var td = appendTd(tr);
  9908. td.appendChild(selectVue2D);
  9909. td = appendTd(tr);
  9910. td.style.fontSize = '0px'; // gère le bug de l'extra character
  9911. td.appendChild(form);
  9912. if (center.id == 'titre2') { // 09/03/2019 nouvelle méthode
  9913. var eDiv = document.createElement('div');
  9914. eDiv.appendChild(table);
  9915. eDiv.style.witdth = '100%';
  9916. eDiv.style.textAlign = 'center';
  9917. table.style.width = '180px';
  9918. table.style.margin = '0 auto';
  9919. center.parentNode.insertBefore(eDiv,center.nextSibling);
  9920. } else { // ancienne méthode
  9921. center.insertBefore(table,center.firstChild);
  9922. insertBr(center.childNodes[1]);
  9923. }
  9924.  
  9925. // Appelle le handler pour initialiser le bouton de submit
  9926. refresh2DViewButton();
  9927. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  9928. } catch(e) {
  9929. avertissement("Erreur de traitement du système de vue 2D");
  9930. window.console.error(traceStack(e, 'set2DViewSystem'));
  9931. }
  9932. }
  9933.  
  9934. /* [functions] Tableau d'Infos */
  9935. function initialiseInfos() {
  9936. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  9937. var
  9938. infoTab = document.getElementsByName('LimitViewForm')[0].
  9939. getElementsByTagName('table')[0],
  9940. tbody = infoTab.tBodies[0],
  9941. thead = infoTab.createTHead(),
  9942. tr = appendTr(thead,'mh_tdtitre'),
  9943. td = appendTdText(tr,'INFORMATIONS',true),
  9944. span = document.createElement('span');
  9945.  
  9946. // Récupération de la position du joueur
  9947. try {
  9948. var strPos = document.evaluate(
  9949. ".//li/b/text()[contains(.,'X = ')]",
  9950. infoTab, null, 9, null
  9951. ).singleNodeValue.nodeValue;
  9952. // ***INIT GLOBALE*** currentPosition
  9953. currentPosition = getIntegers(strPos);
  9954. debugMZ("retrievePosition(): "+currentPosition);
  9955. } catch(e) {
  9956. // Si on ne trouve pas le "X ="
  9957. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  9958. }
  9959.  
  9960. // Récupération des portées (max et limitée) de la vue
  9961. try {
  9962. var
  9963. nodes = document.evaluate(
  9964. ".//li/b/text()[contains(.,'horizontalement') "+
  9965. "or contains(.,'verticalement')]",
  9966. infoTab, null, 7, null
  9967. ),
  9968. array = [];
  9969. for(var i=0 ; i<4 ; i++) {
  9970. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  9971. }
  9972. // ***INIT GLOBALE*** porteeVue
  9973. porteeVue = array;
  9974. } catch(e) {
  9975. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  9976. }
  9977.  
  9978. infoTab.id = 'infoTab'; // Pour scripts externes
  9979. tbody.id = 'corpsInfoTab';
  9980. tbody.rows[0].cells[0].colSpan = 2;
  9981. td.colSpan = 3;
  9982. td.onmouseover = function() {
  9983. this.style.cursor = 'pointer';
  9984. this.className = 'mh_tdpage';
  9985. };
  9986. td.onmouseout = function() {
  9987. this.className = 'mh_tdtitre';
  9988. };
  9989. td.onclick = function() {
  9990. toggleTableauInfos(false);
  9991. };
  9992.  
  9993. span.id = 'msgInfoTab';
  9994. span.style.display = 'none';
  9995. appendText(
  9996. span,
  9997. ' => Position : X = '+currentPosition[0]+
  9998. ', Y = '+currentPosition[1]+
  9999. ', N = '+currentPosition[2]+
  10000. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  10001. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  10002. true
  10003. );
  10004. td.appendChild(span);
  10005.  
  10006. tr = appendTr(tbody,'mh_tdpage');
  10007. td = appendTdText(tr,'EFFACER : ',true);
  10008. td.align = 'center';
  10009. td.className = 'mh_tdtitre';
  10010. td.width = 100;
  10011. td = appendTdCenter(tr,2);
  10012. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  10013. checkBoxGG = appendCheckBoxSpan(
  10014. td,'delgg',filtreTresors," Les GG'"
  10015. ).firstChild;
  10016. checkBoxCompos = appendCheckBoxSpan(
  10017. td,'delcomp',filtreTresors,' Les Compos'
  10018. ).firstChild;
  10019. checkBoxBidouilles = appendCheckBoxSpan(
  10020. td,'delbid',filtreTresors,' Les Bidouilles'
  10021. ).firstChild;
  10022. checkBoxIntangibles = appendCheckBoxSpan(
  10023. td,'delint',filtreTrolls,' Les Intangibles'
  10024. ).firstChild;
  10025. checkBoxGowapsA = appendCheckBoxSpan(
  10026. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  10027. ).firstChild;
  10028. checkBoxGowapsS = appendCheckBoxSpan(
  10029. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  10030. ).firstChild;
  10031. checkBoxEngages = appendCheckBoxSpan(
  10032. td,'delengage',filtreMonstres,' Les Engagés'
  10033. ).firstChild;
  10034. checkBoxLevels = appendCheckBoxSpan(
  10035. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  10036. ).firstChild;
  10037. checkBoxDiplo = appendCheckBoxSpan(
  10038. td,'delDiplo',refreshDiplo,' La Diplomatie'
  10039. ).firstChild;
  10040. checkBoxTrou = appendCheckBoxSpan(
  10041. td,'deltrou',filtreLieux,' Les Trous'
  10042. ).firstChild;
  10043. checkBoxMythiques = appendCheckBoxSpan(
  10044. td,'delmyth',filtreMonstres,' Les Mythiques'
  10045. ).firstChild;
  10046. if(MY_getValue('NOINFOEM')!='true') {
  10047. checkBoxEM = appendCheckBoxSpan(
  10048. td,'delem',filtreMonstres,' Les Composants EM'
  10049. ).firstChild;
  10050. }
  10051. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  10052. td,'deltres',filtreTresors,' Les Trésors non libres'
  10053. ).firstChild;
  10054. checkBoxTactique = appendCheckBoxSpan(
  10055. td,'deltactique',updateTactique,' Les Infos tactiques'
  10056. ).firstChild;
  10057.  
  10058. if(MY_getValue('INFOPLIE')) {
  10059. toggleTableauInfos(true);
  10060. }
  10061. }
  10062.  
  10063. function toggleTableauInfos(firstRun) {
  10064. var
  10065. msg = document.getElementById('msgInfoTab'),
  10066. corps = document.getElementById('corpsInfoTab'),
  10067. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  10068. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  10069. if(!firstRun) {
  10070. infoplie = !infoplie;
  10071. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  10072. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  10073. }
  10074. if(infoplie) {
  10075. msg.style.display = '';
  10076. corps.style.display = 'none';
  10077. } else {
  10078. msg.style.display = 'none';
  10079. corps.style.display = '';
  10080. }
  10081. }
  10082.  
  10083. /* [functions] Filtres */
  10084. function prepareFiltrage(ref,width) {
  10085. // = Initialise le filtre 'ref'
  10086. try {
  10087. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  10088. } catch(e) {
  10089. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée', e);
  10090. return false;
  10091. }
  10092. if(width) { tdTitre.width = width+'px'; }
  10093. // Ajout du tr de Filtrage (masqué)
  10094. var tbody = tdTitre.parentNode.parentNode;
  10095. var tr = appendTr(tbody,'mh_tdpage');
  10096. tr.style.display = 'none';
  10097. tr.id = 'trFiltre'+ref;
  10098. var td = appendTd(tr);
  10099. td.colSpan = 5;
  10100. // Ajout du bouton de gestion de Filtrage
  10101. var tdBtn = insertAfterTd(tdTitre);
  10102. tdBtn.id = 'tdInsert'+ref;
  10103. var btn = appendButton(tdBtn,'Filtrer');
  10104. btn.id = 'btnFiltre'+ref;
  10105. btn.onclick = function() {
  10106. debutFiltrage(ref);
  10107. };
  10108. return td;
  10109. }
  10110.  
  10111. function debutFiltrage(ref) {
  10112. // = Handler de début de filtrage (filtre 'ref')
  10113. document.getElementById('trFiltre'+ref).style.display = '';
  10114. var btn = document.getElementById('btnFiltre'+ref);
  10115. btn.value = 'Annuler Filtre';
  10116. btn.onclick = function() {
  10117. finFiltrage(ref);
  10118. };
  10119. }
  10120.  
  10121. function finFiltrage(ref) {
  10122. // = Handler de fin de filtrage (filtre 'ref')
  10123. /* On réassigne le bouton 'Filtrer' */
  10124. document.getElementById('trFiltre'+ref).style.display = 'none';
  10125. var btn = document.getElementById('btnFiltre'+ref);
  10126. btn.value = 'Filtrer';
  10127. btn.onclick = function() {
  10128. debutFiltrage(ref);
  10129. };
  10130. /* Réinitialisation filtres */
  10131. document.getElementById('str'+ref).value = '';
  10132. switch(ref) {
  10133. case 'Monstres':
  10134. document.getElementById('nivMinMonstres').value = 0;
  10135. document.getElementById('nivMaxMonstres').value = 0;
  10136. document.getElementById('FamilleMonstres').value = 0;
  10137. break;
  10138. case 'Trolls':
  10139. document.getElementById('strGuildes').value = '';
  10140. }
  10141. /* Nettoyage (=lance le filtre) */
  10142. // Ici this = MZ.global = sandBox de travail de MZ
  10143. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  10144. //this['filtre'+ref]();
  10145. switch (ref) {
  10146. case 'Monstres':
  10147. filtreMonstres();
  10148. break;
  10149. case 'Trolls':
  10150. filtreTrolls();
  10151. break;
  10152. case 'Tresors':
  10153. filtreTresors();
  10154. break;
  10155. case 'Lieux':
  10156. filtreLieux();
  10157. break;
  10158. default:
  10159. window.console.log('cas incongru dans finFiltrage : ' + ref);
  10160. break;
  10161. }
  10162. }
  10163.  
  10164. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  10165. var bouton = appendButton(td,nomBouton,onClick);
  10166. appendText(td,'\u00a0');
  10167. var textbox = appendTextbox(td,'text',id,15,30);
  10168. textbox.onkeypress = function(event) {
  10169. try {
  10170. if(event.keyCode==13) {
  10171. event.preventDefault();
  10172. bouton.click();
  10173. }
  10174. }
  10175. catch(e){
  10176. window.alert(e)
  10177. }
  10178. };
  10179. }
  10180.  
  10181. function ajoutFiltreMenu(tr,id,onChange,liste) {
  10182. var select = document.createElement('select');
  10183. select.id = id;
  10184. select.onchange = onChange;
  10185. appendOption(select,0,'Aucun');
  10186. if (liste == undefined) {
  10187. for(var i=1 ; i<=60 ; i++) {
  10188. appendOption(select,i,i);
  10189. }
  10190. } else {
  10191. liste.forEach(function(f) {appendOption(select,f,f);});
  10192. }
  10193. tr.appendChild(select);
  10194. return select;
  10195. }
  10196.  
  10197. function ajoutDesFiltres() {
  10198. /* Monstres */
  10199. var td = prepareFiltrage('Monstres',130);
  10200. if(td) {
  10201. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  10202. appendText(td,'\u00a0\u00a0\u00a0');
  10203. appendText(td,'Niveau Min: ');
  10204. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  10205. appendText(td,'\u00a0');
  10206. appendText(td,'Niveau Max: ');
  10207. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  10208. appendText(td,'\u00a0');
  10209. appendText(td,'Famille: ');
  10210. comboBoxFamille = ajoutFiltreMenu(td,'FamilleMonstres',filtreMonstres,['Animal', 'Insecte','Démon','Humanoide','Monstre','Mort-Vivant']);
  10211. }
  10212. /* Trõlls */
  10213. td = prepareFiltrage('Trolls',50);
  10214. if(td) {
  10215. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  10216. appendText(td,'\u00a0\u00a0\u00a0');
  10217. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  10218. }
  10219. /* Trésors */
  10220. td = prepareFiltrage('Tresors',55);
  10221. if(td) {
  10222. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  10223. }
  10224. /* Lieux */
  10225. td = prepareFiltrage('Lieux',40);
  10226. if(td) {
  10227. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  10228. }
  10229. }
  10230.  
  10231. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  10232.  
  10233. /* [functions] Affichage de la colonne des niveaux */
  10234. function insertLevelColumn() {
  10235. // Appelé dans le code attaché à la page de vue et au click/unclick de la checkbox
  10236.  
  10237. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  10238. td.width = 25;
  10239. td.id = 'MZ_TITRE_NIVEAU_MONSTRE';
  10240. for(var i=1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10241. //window.console.log('nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', MZ_EtatCdMs.tr_monstres.length=' + MZ_EtatCdMs.tr_monstres.length); // debug Roule
  10242. td = insertTdText(getMonstreLevelNode(i), '-');
  10243. td.style = 'font-weight:bold;text-align:center;';
  10244. }
  10245. }
  10246.  
  10247. function toggleLevelColumn() { // Appelé par le code attaché à la page de vue et au click/unclick de la checkbox NOCDM
  10248. var eltMZ_TITRE_NIVEAU_MONSTRE = document.getElementById('MZ_TITRE_NIVEAU_MONSTRE'); // test si la colonne a déjà été ajoutée
  10249. if(saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  10250. 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é
  10251. // cacher tous les td
  10252. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10253. getMonstreLevelNode(i).style.display = 'none';
  10254. }
  10255. } else {
  10256. if (!eltMZ_TITRE_NIVEAU_MONSTRE) {
  10257. insertLevelColumn();
  10258. retrieveCDMs();
  10259. } else {
  10260. // afficher tous les td
  10261. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10262. getMonstreLevelNode(i).style.display = '';
  10263. }
  10264. }
  10265. }
  10266. }
  10267.  
  10268. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  10269. function basculeCDM(nom,id) {
  10270. // = Bascule l'affichage des popups CdM
  10271. if(MZ_EtatCdMs.listeCDM[id]) {
  10272. if(!document.getElementById('popupCDM'+id)) {
  10273. afficherCDM(nom, id);
  10274. } else {
  10275. cacherPopupCDM('popupCDM'+id);
  10276. }
  10277. } else {
  10278. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  10279. window.console.log("pas de CdM pour id=" + id + ', nom=' + nom);
  10280. }
  10281. }
  10282.  
  10283. function cacherPopupCDM(titre) {
  10284. var popup = document.getElementById(titre);
  10285. popup.parentNode.removeChild(popup);
  10286. }
  10287.  
  10288. function removeTableFromClickEvent() { // "this" est supposé être un <td> ou <th> d'une <table>
  10289. var table = this.parentNode.parentNode.parentNode; // <tr><tbody/thead/tfoot><table>
  10290. table.parentNode.removeChild(table);
  10291. }
  10292.  
  10293. /* DEBUG: Section à mettre à jour */
  10294. var selectionFunction;
  10295.  
  10296. function startDrag(evt) {
  10297. winCurr = this.parentNode;
  10298. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  10299. offsetX = evt.pageX - parseInt( winCurr.style.left );
  10300. offsetY = evt.pageY - parseInt( winCurr.style.top );
  10301. selectionFunction = document.body.style.MozUserSelect;
  10302. document.body.style.MozUserSelect = 'none';
  10303. winCurr.style.MozUserSelect = 'none';
  10304. return false;
  10305. }
  10306.  
  10307. function stopDrag(evt) {
  10308. winCurr.style.MozUserSelect = selectionFunction;
  10309. document.body.style.MozUserSelect = selectionFunction;
  10310. winCurr = null;
  10311. }
  10312.  
  10313. function drag(evt) {
  10314. if(winCurr==null) { return; }
  10315. evt = evt || window.event;
  10316. winCurr.style.left = (evt.pageX - offsetX)+'px';
  10317. winCurr.style.top = (evt.pageY - offsetY)+'px';
  10318. return false;
  10319. }
  10320. /* FIN DEBUG */
  10321. if(!isPage("MH_Play/Play_equipement")) {
  10322. // Conflit overlib/Tout_MZ:
  10323. // Double définition du "onmousemove" sur la page d'équipement
  10324. document.onmousemove = drag;
  10325. }
  10326.  
  10327. function afficherCDM(nom,id) {
  10328. // Crée la table de CdM du mob n° id
  10329. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10330. /* Début création table */
  10331. var table = createCDMTable(id,nom,donneesMonstre, removeTableFromClickEvent);
  10332. /* Ajout du titre avec gestion Drag & Drop */
  10333. var tr = table.firstChild;
  10334. tr.style.cursor = 'move';
  10335. tr.onmousedown = startDrag;
  10336. tr.onmouseup = stopDrag;
  10337. /* à supprimer, remplacé par un "x" sur l'entête
  10338. // Ajout du bouton "Fermer"
  10339. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  10340. tr.style.cursor = 'pointer';
  10341. tr.onmouseover = function() {
  10342. this.className = 'mh_tdpage';
  10343. };
  10344. tr.onmouseout = function() {
  10345. this.className = 'mh_tdtitre';
  10346. };
  10347. tr.idcdm = id;
  10348. tr.onclick = function() {
  10349. cacherPopupCDM('popupCDM'+this.idcdm);
  10350. this.className = 'mh_tdtitre';
  10351. };
  10352. td = appendTdText(tr,'Fermer',true);
  10353. td.colSpan = 2;
  10354. td.style = 'text-align:center;';
  10355. */
  10356. table.id = 'popupCDM'+id;
  10357. table.style.position = 'fixed';
  10358. table.style.backgroundColor = 'rgb(229, 222, 203)';
  10359. table.style.zIndex = 1;
  10360. //var topY = +(300+(30*MZ_EtatCdMs.yIndexCDM))%(30*Math.floor((window.innerHeight-400)/30));
  10361. table.style.left = +(window.innerWidth-365)+'px';
  10362. table.style.width = '300px';
  10363. /* Fin création table & Affichage */
  10364. document.body.appendChild(table);
  10365. var topY = 90 + (30*MZ_EtatCdMs.yIndexCDM);
  10366. //window.console.log('topY=' + topY + ', offsetHeight=' + table.offsetHeight + ', innerHeight=' + window.innerHeight);
  10367. if ((topY + table.offsetHeight) > window.innerHeight) {
  10368. MZ_EtatCdMs.yIndexCDM = 0; // on se repositionne en haut s'il n'y a pas assez de place
  10369. topY = 90;
  10370. } else {
  10371. MZ_EtatCdMs.yIndexCDM++; // décalage pour la fois suivante
  10372. }
  10373. table.style.top = topY + 'px';
  10374. }
  10375.  
  10376. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  10377. function showPopupError(sHTML) {
  10378. window.console.log('[MZ] affichage PopupError ' + sHTML);
  10379. var divpopup = document.createElement('div');
  10380. divpopup.id = 'divpopup';
  10381. divpopup.style =
  10382. 'position: fixed;'+
  10383. 'border: 3px solid #000000;'+
  10384. 'top: 300px;left: 10px;'+
  10385. 'background-color: red;'+
  10386. 'color: white;'+
  10387. 'font-size: xx-large;'+
  10388. 'z-index: 200;';
  10389. divpopup.innerHTML = sHTML;
  10390. var divcroix = document.createElement('div');
  10391. divcroix.style =
  10392. 'position: absolute;'+
  10393. 'top: 0;right: 0;'+
  10394. 'color: inherit;'+
  10395. 'font-size: inherit;'+
  10396. 'cursor: pointer;'+
  10397. 'z-index: 201;';
  10398. divcroix.innerHTML = "X";
  10399. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  10400. document.body.appendChild(divpopup);
  10401. divpopup.appendChild(divcroix);
  10402. }
  10403.  
  10404. function retrieveCDMs() {
  10405. // Récupère les CdM disponibles dans la BDD
  10406. // Lancé uniquement sur toggleLevelColumn
  10407. if(checkBoxLevels.checked) return;
  10408. // Roule, message si l'utilisateur a décoché "Menu d'actions contextuelles"
  10409. if (!MZ_EtatCdMs.tr_monstres[0].cells[2].innerHTML.match(/r[eéè]f/i)) {
  10410. 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);
  10411. return;
  10412. }
  10413. if (MZ_EtatCdMs.nbMonstres < 1) return;
  10414.  
  10415. var tReq = [];
  10416. var nbReq = 0;
  10417. var prevLastIndexDone = MZ_EtatCdMs.lastIndexDone;
  10418. for (var i=prevLastIndexDone+1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10419. //tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  10420. // ne pas demander pour les Gowaps
  10421. var nom = getMonstreNom(i);
  10422. if (nom.match(/^[^\[]*Gowap/i)) { // le mot Gowap peut être précédé par un template (qui ne contient donc pas [)
  10423. getMonstreLevelNode(i).innerHTML = '';
  10424. continue;
  10425. }
  10426. tReq.push({'index':i, 'id':getMonstreID(i), 'nom':nom});
  10427. nbReq++;
  10428. 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
  10429. }
  10430. MZ_EtatCdMs.lastIndexDone = i;
  10431. var startAjaxCdM = new Date();
  10432. window.console.log('[MZ] ' + MZ_formatDateMS() + ' lancement AJAX ' + nbReq + ' demandes niveaux monstres V2');
  10433.  
  10434. FF_XMLHttpRequest({
  10435. method: 'POST',
  10436. url: URL_MZgetCaracMonstre,
  10437. headers : {
  10438. 'Content-type':'application/x-www-form-urlencoded'
  10439. },
  10440. //data: 'l=' + tReq.join("\n"),
  10441. data: 'l=' + JSON.stringify(tReq),
  10442. trace: 'demande niveaux monstres V2',
  10443. onload: function(responseDetails) {
  10444. try {
  10445. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  10446. if (responseDetails.status == 0) return;
  10447. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  10448. var texte = responseDetails.responseText;
  10449. var infos = JSON.parse(texte);
  10450. displayScriptTime(new Date().getTime()-date_debut.getTime(), 'Analyse des CdM MZ');
  10451. if(infos.length==0) return;
  10452.  
  10453. // ajouter les styles CSS pour les popup
  10454. var mystyle = document.createElement('style');
  10455. mystyle.type = 'text/css';
  10456. var sCSS = '.MZtooltip {position: relative;color:red;text-align:center;}\n';
  10457. sCSS += '.MZtooltip .MZtooltiptext {visibility: hidden;width: 250px;padding: 5px 0;border:solid 1px;position: absolute;z-index: 1;color:black;background-color:white}\n';
  10458. sCSS += '.MZtooltip:hover .MZtooltiptext {visibility: visible;}\n';
  10459. mystyle.innerHTML = sCSS;
  10460. document.getElementsByTagName('head')[0].appendChild(mystyle);
  10461.  
  10462. // if (MY_DEBUG) {
  10463. // for (var i = 0; i < 20; i++) window.console.log('infos[' + i + ']=' + JSON.stringify(infos[i]));
  10464. // }
  10465. var begin2, end2, index;
  10466. for(var j=0 ; j<infos.length ; j++) {
  10467. var info = infos[j];
  10468. if (info.index == undefined) continue;
  10469. var eTdLevel = getMonstreLevelNode(info.index)
  10470. this.className = 'mh_tdpage';
  10471. var myColor = undefined;
  10472. if (info.niv != undefined && info.niv.max == -1 && info.Mode != 'cdm') {
  10473. eTdLevel.className = "MZtooltip";
  10474. eTdLevel.style.color = "black";
  10475. eTdLevel.innerHTML = 'Var.<span class="MZtooltiptext">Ce monstre est variable.<br />On ne peut pas avoir d\'information sans CdM.</span>';
  10476. } else if (!(info && info.esq)) {
  10477. //if (MY_DEBUG) window.console.log("pas d'esquive id=" + info.id + ", index=" + info.index);
  10478. eTdLevel.className = "MZtooltip";
  10479. 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>';
  10480. } else {
  10481. eTdLevel.innerHTML = mkMinMaxHTML(info.niv);
  10482. //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
  10483. myColor = MZ_CdMColorFromMode(info);
  10484. eTdLevel.style.cursor = 'pointer';
  10485. eTdLevel.onclick = function() {
  10486. basculeCDM(
  10487. getMonstreNomByTR(this.parentNode),
  10488. getMonstreIDByTR(this.parentNode)
  10489. );
  10490. };
  10491. }
  10492. MZ_EtatCdMs.listeCDM[info.id] = info;
  10493. if (myColor) eTdLevel.style.color = myColor;
  10494. /* Roule' à étudier plus tard, cette différence de style selon la diplo...
  10495. eTdLevel.onmouseover = function() {
  10496. this.className = 'mh_tdtitre';
  10497. };
  10498. eTdLevel.onmouseout = function() {
  10499. if(this.parentNode.diploActive=='oui') {
  10500. this.className = '';
  10501. } else {
  10502. this.className = 'mh_tdpage';
  10503. }
  10504. };
  10505. */
  10506. }
  10507. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  10508. computeMission(prevLastIndexDone+1, MZ_EtatCdMs.nbMonstres);
  10509. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  10510. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  10511. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  10512. document.body.dataset.MZ_Etat = 2; // indiquer aux scripts tiers qu'on a récupéré les carac
  10513. if (document.body.MZ_Callback_fin_vue !== undefined) {
  10514. for (var iCallback = 0; iCallback < document.body.MZ_Callback_fin_vue.length; iCallback++) {
  10515. document.body.MZ_Callback_fin_vue[iCallback]();
  10516. }
  10517. }
  10518. } catch(e) {
  10519. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZgetCaracMonstre+'\n'+texte);
  10520. }
  10521. //if (MY_DEBUG) window.console.log('id=6376829, info=' + JSON.stringify(MZ_EtatCdMs.listeCDM[6376829]));
  10522. MZ_EtatCdMs.isCDMsRetrieved=true;
  10523. // afficher/supprimer le bouton pour demander la suite
  10524. var eltBoutonSuite = document.getElementById('MZ_boutonSuiteCdM');
  10525. window.console.log('[MZ] lastIndexDone=' + MZ_EtatCdMs.lastIndexDone + ', nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', eltBoutonSuite=' + eltBoutonSuite);
  10526. if (MZ_EtatCdMs.lastIndexDone < MZ_EtatCdMs.nbMonstres) {
  10527. if (eltBoutonSuite) {
  10528. while (eltBoutonSuite.firstChild) eltBoutonSuite.removeChild(eltBoutonSuite.firstChild); // vider
  10529. appendText(eltBoutonSuite, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10530. retrieveCDMs(); // lancer la suite
  10531. } else {
  10532. eltBoutonSuite = document.createElement('div');
  10533. eltBoutonSuite.id = 'MZ_boutonSuiteCdM';
  10534. eltBoutonSuite.style.position = 'fixed';
  10535. eltBoutonSuite.style.border = '1px solid black';
  10536. eltBoutonSuite.style.top = '10px';
  10537. eltBoutonSuite.style.right = '10px';
  10538. //eltBoutonSuite.style.backgroundColor = 'white';
  10539. eltBoutonSuite.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/fond/fond2.jpg")';
  10540. eltBoutonSuite.style.color = 'black';
  10541. eltBoutonSuite.style.fontSize = 'large';
  10542. eltBoutonSuite.style.padding = '5px';
  10543. eltBoutonSuite.style.borderRadius = '10px';
  10544. eltBoutonSuite.style.cursor = 'pointer';
  10545. eltBoutonSuite.style.zIndex = '500';
  10546. appendText(eltBoutonSuite, nbReq + ' CdM(s) récupérées');
  10547. appendBr(eltBoutonSuite); // C'est plus classe que d'utiliser innerHTML ☺
  10548. appendText(eltBoutonSuite, 'Cliquer ici pour demander les CdMs');
  10549. appendBr(eltBoutonSuite);
  10550. appendText(eltBoutonSuite, 'des ' + MZ_EtatCdMs.nbMonstres + ' monstres');
  10551. eltBoutonSuite.title = 'Shift-Click pour faire disparaitre ce bouton sans demander les CdMs';
  10552. eltBoutonSuite.onclick = MZ_SuiteCdMs;
  10553. document.body.appendChild(eltBoutonSuite);
  10554. }
  10555. } else {
  10556. if (eltBoutonSuite) eltBoutonSuite.parentNode.removeChild(eltBoutonSuite);
  10557. }
  10558. },
  10559. });
  10560. //str = '';
  10561. //begin = i+1;
  10562. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  10563. }
  10564.  
  10565. function MZ_CdMColorFromMode(info) {
  10566. switch (info.Mode) {
  10567. case 'cdm':
  10568. return 'blue';
  10569. case 'stat':
  10570. return 'purple';
  10571. case 'statV1':
  10572. return 'orange';
  10573. }
  10574. }
  10575.  
  10576. function MZ_SuiteCdMs(e) { // handler du click sur le bouton pour demander la suite des CdMs
  10577. var evt = e || window.event;
  10578. if (evt.shiftKey) {
  10579. this.parentNode.removeChild(this);
  10580. return;
  10581. }
  10582. while (this.firstChild) this.removeChild(this.firstChild); // vider
  10583. appendText(this, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10584. this.title = 'Shift-Click pour faire disparaitre ce bouton';
  10585. this.style.cursor = ''; // default
  10586. this.onclick = MZ_SupprBoutonCdMs;
  10587. retrieveCDMs();
  10588. }
  10589.  
  10590. function MZ_SupprBoutonCdMs(e) {
  10591. var evt = e || window.event;
  10592. if (evt.shiftKey) {
  10593. this.parentNode.removeChild(this);
  10594. }
  10595. }
  10596.  
  10597. function mkMinMaxHTML(oMM) {
  10598. if (oMM == undefined) return '';
  10599. if (oMM.min == undefined) {
  10600. if (oMM.max == undefined) {
  10601. return;
  10602. } else {
  10603. return "\u2A7D" + oMM.max; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  10604. }
  10605. } else {
  10606. if (oMM.max == undefined) {
  10607. return "\u2A7E" + oMM.min; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  10608. } else if (oMM.min == oMM.max) {
  10609. return oMM.min;
  10610. } else if (oMM.min < oMM.max) {
  10611. return oMM.min + '-' + oMM.max;
  10612. } else {
  10613. return '<span style="color:red">' + oMM.min + '-' + oMM.max + '</span>';
  10614. }
  10615. }
  10616. }
  10617.  
  10618. function computeMission(begin,end) {
  10619. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  10620. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  10621. computeVLC(begin,end);
  10622. //+++window.console.log('computeMission, après computeVLC');
  10623. if(!begin) begin=1;
  10624. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10625. var str = MY_getValue(numTroll+'.MISSIONS');
  10626. if(!str) { return; }
  10627.  
  10628. var urlImg = URL_MZimg+'mission.png';
  10629. var obMissions = JSON.parse(str);
  10630.  
  10631. for(var i=end ; i>=begin ; i--) {
  10632. var mess = '';
  10633. var bPeutEtreIcone = false;
  10634. for(var num in obMissions) {
  10635. var mobMission = false;
  10636. var mobMissionPeutEtre = undefined;
  10637. switch(obMissions[num].type) {
  10638. case 'Race':
  10639. var race = epure(obMissions[num].race.toLowerCase());
  10640. var nom = epure(getMonstreNom(i).toLowerCase());
  10641. if(nom.indexOf(race)!=-1) {
  10642. if (race == 'crasc') {
  10643. if (nom.indexOf('medius')!=-1) {
  10644. // pas éligible
  10645. } else if (nom.indexOf('maexus')!=-1) {
  10646. // pas éligible
  10647. } else if (nom.indexOf('parasitus')!=-1) {
  10648. if (nom.match(/^crasc parasitus \[/ui)) {
  10649. // on ne peut pas savoir
  10650. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10651. + '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"';
  10652. } else {
  10653. // c'est un monstre de la race des Crasc Parasitus
  10654. mobMission = false;
  10655. }
  10656. } else {
  10657. mobMission = true;
  10658. }
  10659. } else if (race == 'crasc parasitus') {
  10660. if (nom.match(/^crasc parasitus \[/ui)) {
  10661. // on ne peut pas savoir
  10662. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10663. + '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"';
  10664. } else {
  10665. // c'est un monstre de la race des Crasc Parasitus
  10666. mobMission = true;
  10667. }
  10668. } else if (race == 'shai') {
  10669. if (nom.match(/abishai/ui)) {
  10670. mobMission = false;
  10671. } else {
  10672. mobMission = true;
  10673. }
  10674. } else if (race == 'ombre') {
  10675. if (nom.match(/roche/ui)) {
  10676. mobMission = false;
  10677. } else {
  10678. mobMission = true;
  10679. }
  10680. } else if (race == 'geck\'oo') {
  10681. if (nom.match(/majestueux/ui)) {
  10682. mobMission = false;
  10683. } else {
  10684. mobMission = true;
  10685. }
  10686. } else if (race == 'bouj\'dla') {
  10687. if (nom.match(/placide/ui)) {
  10688. mobMission = false;
  10689. } else {
  10690. mobMission = true;
  10691. }
  10692. } else {
  10693. mobMission = true;
  10694. }
  10695. }
  10696. break;
  10697. case 'Niveau':
  10698. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10699. if (donneesMonstre) {
  10700. var nivMimi = Number(obMissions[num].niveau);
  10701. var mod = obMissions[num].mod; // mission nivMimi±mod si mod est numérique, sinon, c'est >= nivMimi
  10702. if (isNaN(mod)) {
  10703. var minMimi = nivMimi;
  10704. var maxMimi = nivMimi + 999999;
  10705. } else {
  10706. var minMimi = nivMimi - mod;
  10707. var maxMimi = nivMimi + mod;
  10708. }
  10709. if (donneesMonstre.niv) { // nouveau mode
  10710. if (donneesMonstre.niv.max && donneesMonstre.niv.min) {
  10711. if (donneesMonstre.niv.max <= maxMimi && donneesMonstre.niv.min >= minMimi) {
  10712. mobMission = true;
  10713. } else if (!(donneesMonstre.niv.max < minMimi || donneesMonstre.niv.min > maxMimi)) {
  10714. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10715. if (isDEV) mobMissionPeutEtre += '\nMonstre=(' + donneesMonstre.niv.min + ', ' + donneesMonstre.niv.max + '), mimi=(' + minMimi + ', ' + maxMimi + ')'
  10716. }
  10717. } else if (donneesMonstre.niv.max) {
  10718. if (donneesMonstre.niv.max >= minMimi) {
  10719. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10720. }
  10721. } else if (donneesMonstre.niv.min) {
  10722. if (donneesMonstre.niv.min <= maxMimi) {
  10723. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10724. }
  10725. }
  10726. }
  10727. }
  10728. break;
  10729. case 'Famille':
  10730. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10731. if(donneesMonstre && donneesMonstre.fam) {
  10732. var familleMimi = epure(obMissions[num].famille.toLowerCase()).replace(/[']/g,''); // Roule 27/02/2019 simple quote dans les familles
  10733. var familleMob = epure(donneesMonstre.fam.toLowerCase());
  10734. if(familleMob.indexOf(familleMimi)!=-1) {
  10735. mobMission = true;
  10736. }
  10737. }
  10738. break;
  10739. case 'Pouvoir':
  10740. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10741. if(donneesMonstre && donneesMonstre.pouv) {
  10742. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  10743. var pvrMob = epure(donneesMonstre.pouv.toLowerCase());
  10744. if(pvrMob.indexOf(pvrMimi)!=-1) {
  10745. mobMission = true;
  10746. }
  10747. }
  10748. }
  10749. if(mobMission) {
  10750. mess += mess ? '\n\n' : '';
  10751. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  10752. } else if (mobMissionPeutEtre !== undefined) {
  10753. mess += mess ? '\n\n' : '';
  10754. mess += mobMissionPeutEtre + '\n';
  10755. bPeutEtreIcone = true;
  10756. mess += 'Mission '+ num + ' :\n'+obMissions[num].libelle;
  10757. }
  10758. }
  10759. if(mess) {
  10760. var td = getMonstreNomNode(i);
  10761. appendText(td,' ');
  10762. var myURL;
  10763. if (bPeutEtreIcone) {
  10764. myURL = URL_MZimg+'missionX.png';
  10765. } else {
  10766. myURL = urlImg;
  10767. }
  10768. td.appendChild(createImage(myURL,mess));
  10769. }
  10770. }
  10771. }
  10772.  
  10773. function computeVLC(begin,end) {
  10774. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  10775. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  10776. computeTactique(begin,end);
  10777. //+++window.console.log('computeVLC, après computeTactique');
  10778. if(!begin) begin=1;
  10779. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10780. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  10781. if(!cache)
  10782. return false;
  10783. var urlImg = URL_MZimg + "oeil.png";
  10784. for(var i = end; i >= begin;i--)
  10785. {
  10786. var id = getMonstreID(i);
  10787. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10788. var vlc = false;
  10789. /* ancien mode à supprimer
  10790. if(donneesMonstre && donneesMonstre.length>12)
  10791. {
  10792. if(donneesMonstre[12]==1) vlc = 1;
  10793. }
  10794. // */
  10795. // nouveau mode
  10796. if (donneesMonstre && donneesMonstre.vlc) {
  10797. //if (donneesMonstre) window.console.log('computeVLC i=' + i + ' id=' + id + ' ' + JSON.stringify(donneesMonstre));
  10798. var td = getMonstreNomNode(i);
  10799. td.appendChild(document.createTextNode(" "));
  10800. td.appendChild(createImage(urlImg, "Voit le caché"));
  10801. }
  10802. if (donneesMonstre && donneesMonstre.gen) {
  10803. switch (donneesMonstre.gen) {
  10804. case 1:
  10805. var imgPh = URL_MZimg + "Phoenix1.png";
  10806. var txtPh = 'Phœnix de première génération';
  10807. break;
  10808. case 2:
  10809. var imgPh = URL_MZimg + "Phoenix2.png";
  10810. var txtPh = 'Phœnix de deuxième génération';
  10811. break;
  10812. case 3:
  10813. var imgPh = URL_MZimg + "Phoenix3.png";
  10814. var txtPh = 'Phœnix de troisième génération';
  10815. break;
  10816. case 23:
  10817. var imgPh = URL_MZimg + "Phoenix23.png";
  10818. var txtPh = 'Phœnix de deuxième ou troisième génération';
  10819. break;
  10820. }
  10821. var td = getMonstreNomNode(i);
  10822. td.appendChild(document.createTextNode(" "));
  10823. var img = td.appendChild(createImage(imgPh, txtPh));
  10824. img.style.height = '15px';
  10825. img.style.width = 'auto';
  10826. }
  10827. }
  10828. }
  10829.  
  10830. /* appelé
  10831. par updateTactique
  10832. par initialiseInfos
  10833. par do_vue
  10834. par computeVLC
  10835. par computeMission
  10836. par filtreMonstres
  10837. par retrieveCDMs
  10838. */
  10839. function computeTactique(begin, end) {
  10840. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  10841. try {
  10842. if(!begin) begin = 1;
  10843. if(!end) end = MZ_EtatCdMs.nbMonstres;
  10844. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  10845. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10846. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  10847. if(noTactique || !isProfilActif()) return;
  10848. //+++window.console.log('computeTactique, après isProfilActif');
  10849.  
  10850. for(var j=end ; j>=begin ; j--) {
  10851. var id = getMonstreID(j);
  10852. var nom = getMonstreNom(j);
  10853. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10854. var bShowTactique = false;
  10855. //if (isDEV) {
  10856. if (donneesMonstre && donneesMonstre.esq) bShowTactique = true;
  10857. // } else {
  10858. // if(donneesMonstre && nom.indexOf('Gowap')==-1) bShowTactique = true;
  10859. // }
  10860. if (bShowTactique) {
  10861. var td = getMonstreNomNode(j);
  10862. appendText(td,' ');
  10863. td.appendChild(MZ_Tactique.createImage(id, nom));
  10864. }
  10865. }
  10866. }
  10867. catch(e) {
  10868. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  10869. }
  10870. filtreMonstres();
  10871. }
  10872.  
  10873. function updateTactique() {
  10874. // = Handler checkBox noTactique
  10875. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10876. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  10877. if(!MZ_EtatCdMs.isCDMsRetrieved) return;
  10878. //+++window.console.log('updateTactique, isCDMsRetrieved=' + MZ_EtatCdMs.isCDMsRetrieved);
  10879.  
  10880. if(noTactique) {
  10881. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  10882. var tr = getMonstreNomNode(i);
  10883. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  10884. tr, null, 9, null).singleNodeValue;
  10885. if(img) {
  10886. img.parentNode.removeChild(img.previousSibling);
  10887. img.parentNode.removeChild(img);
  10888. }
  10889. }
  10890. }
  10891. else
  10892. computeTactique();
  10893. }
  10894.  
  10895. function filtreMonstres() {
  10896. // = Handler universel pour les fonctions liées aux monstres
  10897. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  10898. urlEnchantImg = URL_MZimg+'enchant.png';
  10899.  
  10900. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  10901. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  10902. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  10903. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  10904. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  10905. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  10906. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  10907. var famille = saveComboBox(comboBoxFamille,'FAMILLEMONSTRE');
  10908. // old/new : détermine s'il faut ou non nettoyer les tr
  10909. var oldNOEM = true, noEM = true;
  10910. if(MY_getValue('NOINFOEM')!='true') {
  10911. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  10912. }
  10913. // Filtrage par nom
  10914. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  10915. // Génère la liste des mobs engagés (si filtrés)
  10916. if(noEngages && !isEngagesComputed) {
  10917. for(var i=nbTrolls ; i>0 ; i--) {
  10918. var pos = getTrollPosition(i);
  10919. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  10920. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  10921. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  10922. }
  10923. isEngagesComputed = true;
  10924. }
  10925.  
  10926. /*** FILTRAGE ***/
  10927. /* À computer :
  10928. * - EM (nom suffit)
  10929. * - Enchant (nom suffit)
  10930. * - Mission (nécessite CdM)
  10931. * - mob VlC (nécessite CdM)
  10932. * Sans computation :
  10933. * - Gowap ? engagé ?
  10934. */
  10935. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  10936. var pos = getMonstrePosition(i);
  10937. var nom = getMonstreNom(i).toLowerCase();
  10938. if(noEM!=oldNOEM) {
  10939. if(noEM) {
  10940. // Si noEM passe de false à true, on nettoie les td "Nom"
  10941. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  10942. var tr = getMonstreNomNode(i);
  10943. while(tr.childNodes.length>1) {
  10944. tr.removeChild(tr.childNodes[1]);
  10945. }
  10946. } else {
  10947. var tr = getMonstreNomNode(i);
  10948. var TypeMonstre=getEM(nom);
  10949. if(TypeMonstre!='') {
  10950. var infosCompo=compoMobEM(TypeMonstre);
  10951. if(infosCompo.length>0) {
  10952. tr.appendChild(document.createTextNode(' '));
  10953. tr.appendChild(createImage(urlImg, infosCompo));
  10954. }
  10955. }
  10956. }
  10957. }
  10958. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  10959. var texte = getInfoEnchantementFromMonstre(nom);
  10960. if(texte!='') {
  10961. var td = getMonstreNomNode(i);
  10962. td.appendChild(document.createTextNode(' '));
  10963. td.appendChild(createImage(urlEnchantImg, texte));
  10964. }
  10965. }
  10966.  
  10967. var dataV2 = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10968. MZ_EtatCdMs.tr_monstres[i].style.display = (
  10969. noGowapsS &&
  10970. nom.indexOf('gowap sauvage')!=-1 &&
  10971. getMonstreDistance(i)>1
  10972. ) || (
  10973. noGowapsA &&
  10974. nom.indexOf('gowap apprivoisé')!=-1 &&
  10975. getMonstreDistance(i)>1
  10976. ) || (
  10977. noEngages &&
  10978. getMonstreDistance(i)!=0 &&
  10979. listeEngages[pos[0]] &&
  10980. listeEngages[pos[0]][pos[1]] &&
  10981. listeEngages[pos[0]][pos[1]][pos[2]]
  10982. ) || (
  10983. strMonstre!='' &&
  10984. nom.indexOf(strMonstre)==-1
  10985. ) || (
  10986. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  10987. getMonstreDistance(i)>1 &&
  10988. nom.toLowerCase().indexOf("kilamo")==-1
  10989. ) || (
  10990. famille!='0' &&
  10991. dataV2 &&
  10992. dataV2.fam &&
  10993. dataV2.fam != famille
  10994. ) ? 'none' : '';
  10995. }
  10996.  
  10997. if(MY_getValue('NOINFOEM')!='true') {
  10998. if(noEM != oldNOEM) {
  10999. if(noEM && MZ_EtatCdMs.isCDMsRetrieved) computeMission();
  11000. }
  11001. oldNOEM = noEM;
  11002. }
  11003.  
  11004. needComputeEnchantement = false;
  11005. }
  11006.  
  11007.  
  11008. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  11009.  
  11010. function filtreTrolls() {
  11011. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  11012. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  11013. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  11014. for(var i=1 ; i<=nbTrolls ; i++) {
  11015. tr_trolls[i].style.display = (
  11016. noIntangibles &&
  11017. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  11018. ) || (
  11019. strTroll!='' &&
  11020. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  11021. ) || (
  11022. strGuilde!='' &&
  11023. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  11024. ) ? 'none' : '';
  11025. }
  11026. }
  11027.  
  11028. /* [functions] Bulle PX Trolls */
  11029. var bulle;
  11030.  
  11031. function initPXTroll() {
  11032. bulle = document.createElement('div');
  11033. bulle.id = 'bulle';
  11034. bulle.className = 'mh_textbox';
  11035. bulle.style =
  11036. 'position: absolute;'+
  11037. 'border: 1px solid #000000;'+
  11038. 'visibility: hidden;'+
  11039. 'display: inline;'+
  11040. 'z-index: 2;';
  11041. document.body.appendChild(bulle);
  11042.  
  11043. for(var i=nbTrolls ; i>0 ; i--) {
  11044. var td_niv = getTrollNivNode(i);
  11045. td_niv.onmouseover = showPXTroll;
  11046. td_niv.onmouseout = hidePXTroll;
  11047. }
  11048. }
  11049.  
  11050. function showPXTroll(evt) {
  11051. var lvl = this.firstChild.nodeValue;
  11052. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  11053. bulle.style.left = evt.pageX+15+'px';
  11054. bulle.style.top = evt.pageY+'px';
  11055. bulle.style.visibility = 'visible';
  11056. }
  11057.  
  11058. function hidePXTroll() {
  11059. bulle.style.visibility = 'hidden';
  11060. }
  11061.  
  11062. /* [functions] Envoi PX / MP */
  11063. function putBoutonPXMP() {
  11064. // Bouton d'initialisation du mode Envoi
  11065. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  11066. var td = document.getElementById('tdInsertTrolls');
  11067. if(!td) { return; }
  11068. td.width = 100;
  11069. td = insertAfterTd(td);
  11070. td.style.verticalAlign = 'top';
  11071. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  11072. bouton.id = 'btnEnvoi';
  11073. }
  11074.  
  11075. function prepareEnvoi() {
  11076. // = 1er Handler du bouton d'envoi
  11077.  
  11078. /* Ajout de la colonne des CheckBoxes */
  11079. var td = insertTdText(getTrollNomNode(0),'');
  11080. td.width = 5;
  11081. for(var i=nbTrolls ; i>0 ; i--) {
  11082. td = insertTd(getTrollNomNode(i));
  11083. appendCheckBox(td,'envoi'+i);
  11084. }
  11085.  
  11086. /* Ajout du radio de choix PX ou MP */
  11087. var btnEnvoi = document.getElementById('btnEnvoi');
  11088. if(!btnEnvoi) { return; }
  11089. var tdEnvoi = btnEnvoi.parentNode;
  11090. appendText(tdEnvoi,' ');
  11091. var span = document.createElement('span');
  11092. span.style.whiteSpace = 'nowrap';
  11093. var radioElt = document.createElement('input');
  11094. radioElt.type = 'radio';
  11095. radioElt.name = 'envoiPXMP';
  11096. radioElt.id = 'radioPX';
  11097. span.appendChild(radioElt);
  11098. appendText(span,' des PX ');
  11099. radioElt = document.createElement('input');
  11100. radioElt.type = 'radio';
  11101. radioElt.name = 'envoiPXMP';
  11102. radioElt.checked = true;
  11103. span.appendChild(radioElt);
  11104. appendText(span,' un MP');
  11105. tdEnvoi.appendChild(span);
  11106.  
  11107. /* Insertion du bouton Annuler */
  11108. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  11109.  
  11110. /* Modification de l'effet du bouton Envoi */
  11111. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  11112. }
  11113.  
  11114. function annuleEnvoi() {
  11115. // = Handler bouton Annuler
  11116. /* Nettoyage du td du bouton Envoi */
  11117. var btnEnvoi = document.getElementById('btnEnvoi');
  11118. var tdEnvoi = btnEnvoi.parentNode;
  11119. while(tdEnvoi.firstChild) {
  11120. tdEnvoi.removeChild(tdEnvoi.firstChild);
  11121. }
  11122. /* Retour à l'effet de base du bouton Envoi */
  11123. btnEnvoi.onclick = prepareEnvoi;
  11124. tdEnvoi.appendChild(btnEnvoi);
  11125. /* Suppression CheckBoxes */
  11126. for(var i=nbTrolls ; i>=0 ; i--) {
  11127. var td = getTrollNomNode(i);
  11128. td.parentNode.removeChild(td);
  11129. }
  11130. }
  11131.  
  11132. function effectueEnvoi() {
  11133. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  11134. var str='';
  11135. var errID = false;
  11136. for(var i=nbTrolls ; i>0 ; i--) {
  11137. var chb = document.getElementById('envoi'+i);
  11138. if(chb.checked) {
  11139. var idTroll = getTrollID(i);
  11140. if (idTroll == undefined) {
  11141. errID = true;
  11142. } else {
  11143. str += (str ? ',' : '') + idTroll;
  11144. }
  11145. }
  11146. }
  11147. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  11148. var PXchecked = document.getElementById('radioPX').checked;
  11149. if(PXchecked) {
  11150. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  11151. } else {
  11152. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  11153. }
  11154. }
  11155.  
  11156. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  11157.  
  11158. function filtreTresors() {
  11159. // += Handler checkboxes : gg, compos, bidouilles, non libres
  11160. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  11161. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  11162. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  11163. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  11164. if(noEngages && !isEngagesComputed) {
  11165. for(var i=nbTrolls ; i>0 ; i--) {
  11166. var pos = getTrollPosition(i);
  11167. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  11168. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  11169. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  11170. }
  11171. isEngagesComputed = true;
  11172. }
  11173. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  11174. for(var i=nbTresors ; i>0 ; i--) {
  11175. var nom = getTresorNom(i);
  11176. var pos = getTresorPosition(i);
  11177. tr_tresors[i].style.display = (
  11178. noGG &&
  11179. nom.indexOf('Gigots de Gob')!=-1
  11180. ) || (
  11181. noCompos &&
  11182. nom.indexOf('Composant')!=-1
  11183. ) || (
  11184. noEngages &&
  11185. listeEngages[pos[2]] &&
  11186. listeEngages[pos[2]][pos[1]] &&
  11187. listeEngages[pos[2]][pos[1]][pos[0]] &&
  11188. getTresorDistance(i)>0
  11189. ) || (
  11190. strTresor!='' &&
  11191. nom.toLowerCase().indexOf(strTresor)==-1
  11192. ) || (
  11193. noBidouilles &&
  11194. nom.indexOf('Bidouille')!=-1
  11195. ) ? 'none' : '';
  11196. }
  11197. }
  11198.  
  11199.  
  11200. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  11201.  
  11202. function filtreLieux() {
  11203. // += Handler checkbox trous
  11204. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  11205. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  11206. for(var i=nbLieux ; i>0 ; i--) {
  11207. tr_lieux[i].style.display = (
  11208. strLieu &&
  11209. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  11210. ) || (
  11211. noTrou &&
  11212. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  11213. getLieuDistance(i)>1
  11214. ) ? 'none' : '';
  11215. }
  11216. }
  11217.  
  11218.  
  11219. /*-[functions]-------------------- Diplomatie --------------------------------*/
  11220.  
  11221. function refreshDiplo() {
  11222. MY_setValue(numTroll+'.diplo.off',
  11223. checkBoxDiplo.checked?'true':'false'
  11224. );
  11225. if(isDiploRaw) { computeDiplo(); }
  11226. appliqueDiplo();
  11227. }
  11228.  
  11229. function computeDiplo() {
  11230. // On extrait les données de couleur et on les stocke par id
  11231. // Ordre de préséance :
  11232. // source Guilde < source Perso
  11233. // guilde cible < troll cible
  11234.  
  11235. /* Diplo de Guilde */
  11236. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  11237. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  11238. if(diploGuilde && diploGuilde.isOn=='true') {
  11239. // Guilde perso
  11240. if(diploGuilde.guilde) {
  11241. Diplo.Guilde[diploGuilde.guilde.id] = {
  11242. couleur: diploGuilde.guilde.couleur,
  11243. titre: 'Ma Guilde'
  11244. };
  11245. }
  11246. // Guildes/Trolls A/E
  11247. for(var AE in {Amis:0,Ennemis:0}) {
  11248. for(var i=0 ; i<5 ; i++) {
  11249. if(diploGuilde[AE+i]) {
  11250. for(var type in {Guilde:0,Troll:0}) {
  11251. var liste = diploGuilde[AE+i][type].split(';');
  11252. for(var j=liste.length-2 ; j>=0 ; j--) {
  11253. Diplo[type][liste[j]] = {
  11254. couleur: diploGuilde[AE+i].couleur,
  11255. titre: diploGuilde[AE+i].titre
  11256. };
  11257. }
  11258. }
  11259. }
  11260. }
  11261. }
  11262. }
  11263.  
  11264. /* Diplo Perso */
  11265. //var diploPerso = MY_getValue(numTroll+'.diplo.perso') ? JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {}; // déjà chargé
  11266. if(diploPerso && diploPerso.isOn=='true') {
  11267. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  11268. for(var id in diploPerso[type]) {
  11269. Diplo[type][id] = diploPerso[type][id];
  11270. }
  11271. }
  11272. }
  11273. if(diploPerso.mythiques) {
  11274. Diplo.mythiques = diploPerso.mythiques;
  11275. }
  11276.  
  11277. isDiploRaw = false;
  11278. }
  11279.  
  11280. function appliqueDiplo() {
  11281. var aAppliquer = Diplo;
  11282. if(checkBoxDiplo.checked) {
  11283. // Pour retour à l'affichage basique sur désactivation de la diplo
  11284. aAppliquer = {
  11285. Guilde: {},
  11286. Troll: {},
  11287. Monstre: {}
  11288. };
  11289. }
  11290.  
  11291. /* On applique "aAppliquer" */
  11292. // Diplo Trõlls
  11293. for(var i=nbTrolls ; i>0 ; i--) {
  11294. var idG = getTrollGuildeID(i);
  11295. var idT = getTrollID(i);
  11296. var tr = tr_trolls[i];
  11297. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  11298. if(aAppliquer.Troll[idT]) {
  11299. tr.className = '';
  11300. var descr = aAppliquer.Troll[idT].titre;
  11301. if(descr) {
  11302. getTrollNomNode(i).title = descr
  11303. }
  11304. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  11305. } else if(aAppliquer.Guilde[idG]) {
  11306. tr.className = '';
  11307. var descr = aAppliquer.Guilde[idG].titre;
  11308. if(descr) {
  11309. getTrollNomNode(i).title = descr
  11310. }
  11311. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  11312. } else {
  11313. tr.className = 'mh_tdpage';
  11314. getTrollNomNode(i).title = '';
  11315. }
  11316. }
  11317.  
  11318. // Diplo Monstres
  11319. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  11320. var id = getMonstreID(i);
  11321. var nom = getMonstreNom(i).toLowerCase();
  11322. var tr = MZ_EtatCdMs.tr_monstres[i];
  11323. if(aAppliquer.Monstre[id]) {
  11324. tr.className = '';
  11325. tr.style.backgroundColor = aAppliquer.Monstre[id].couleur;
  11326. tr.diploActive = 'oui';
  11327. var descr = aAppliquer.Monstre[id].titre;
  11328. if(descr) {
  11329. getMonstreNomNode(i).title = descr;
  11330. }
  11331. } else if(aAppliquer.mythiques &&
  11332. (nom.indexOf('liche')==0 ||
  11333. nom.indexOf('hydre')==0 ||
  11334. nom.indexOf('balrog')==0 ||
  11335. nom.indexOf('beholder')==0)) {
  11336. tr.className = '';
  11337. tr.style.backgroundColor = aAppliquer.mythiques;
  11338. tr.diploActive = 'oui';
  11339. getMonstreNomNode(i).title = 'Monstre Mythique';
  11340. } else {
  11341. tr.className = 'mh_tdpage';
  11342. tr.diploActive = '';
  11343. }
  11344. }
  11345. }
  11346.  
  11347.  
  11348. /*-[functions]---------------- Actions à distance ----------------------------*/
  11349.  
  11350. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  11351. var
  11352. monN = parseInt(getPosition()[2]),
  11353. isLdP = oussa=='self';
  11354.  
  11355. for(var type in keltypes) {
  11356. if (MY_DEBUG) {
  11357. window.console.log(
  11358. 'MZ computeActionDistante(' + dmin + ', ' + dmax + ', ' +
  11359. oussa + ', ' + urlIcon+ ', ' + message + ') type=' + type
  11360. );
  11361. }
  11362. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  11363. for(var i=VueContext['nb'+type] ; i>0 ; i--) {
  11364. var tr = VueContext['tr_'+type.toLowerCase()][i];
  11365. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  11366. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  11367. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  11368. var sonN = getXxxPosition(type, i)[2];
  11369. var d = getXxxDistance(type, i);
  11370. var thismessage = message;
  11371. if (isLdP) {
  11372. var chanceToucher = getTalent("Lancer de Potions") + Math.min(10,
  11373. 10 - 10 * d +
  11374. parseInt(MY_getValue(numTroll+".caracs.vue")) +
  11375. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11376. );
  11377. thismessage += ' (' + chanceToucher + '%)';
  11378. }
  11379.  
  11380. if(sonN==monN && d>=dmin && d<=dmax) {
  11381. var iconeAction = document.evaluate(
  11382. "./descendant::img[@alt='"+alt+"']",
  11383. tr, null, 9, null
  11384. ).singleNodeValue;
  11385. if(iconeAction) {
  11386. if(iconeAction.title) {
  11387. iconeAction.title += "\n"+thismessage;
  11388. } else {
  11389. iconeAction.title = thismessage;
  11390. }
  11391. iconeAction.src = urlIcon;
  11392. } else {
  11393. var tdAction = tr.getElementsByTagName('td')[1];
  11394. var icon = document.createElement('img');
  11395. icon.src = urlIcon;
  11396. icon.height = 20;
  11397. icon.alt = alt;
  11398. icon.title = thismessage;
  11399. tdAction.appendChild(icon);
  11400. }
  11401. }
  11402. }
  11403. }
  11404. }
  11405.  
  11406. function computeCharge() {
  11407. computeActionDistante(1,
  11408. getPortee(
  11409. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  11410. MY_getValue(numTroll+".caracs.regeneration")
  11411. ),
  11412. {'Monstres':1, 'Trolls':1},
  11413. 'Attaquer',
  11414. MHicons+'E_Metal09.png',
  11415. 'Cible à portée de Charge'
  11416. );
  11417. }
  11418.  
  11419. function computeProjo() {
  11420. computeActionDistante(0,
  11421. getPortee(
  11422. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11423. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11424. ),
  11425. {'Monstres':1, 'Trolls':1},
  11426. 'Attaquer',
  11427. MHicons+'S_Fire05.png',
  11428. 'Cible à portée de Projo'
  11429. );
  11430. }
  11431.  
  11432. function computeTelek() {
  11433. computeActionDistante(0,
  11434. Math.floor((
  11435. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11436. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11437. )/2),
  11438. {'Tresors':1},
  11439. 'Telek',
  11440. MHicons+'S_Magic04.png',
  11441. 'Trésor à portée de Télékinésie'
  11442. );
  11443. }
  11444.  
  11445. function computeLdP() {
  11446. computeActionDistante(0,
  11447. 2+Math.floor((
  11448. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11449. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11450. )/5),
  11451. {'Monstres':1, 'Trolls':1},
  11452. 'self',
  11453. MHicons+'P_Red01.png',
  11454. 'Cible à portée de Lancer de Potions'
  11455. );
  11456. }
  11457.  
  11458.  
  11459. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  11460.  
  11461. function putScriptExterne(sInfo) {
  11462. for (var iBricol = 1; ; iBricol++) {
  11463. var extClef = iBricol == 1 ? '' : iBricol;
  11464. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  11465. if (!sInfo) break;
  11466. putScriptExterneOneIT(sInfo);
  11467. }
  11468. }
  11469.  
  11470. function putScriptExterneOneIT(sInfo) {
  11471. if(!sInfo || sInfo=='') return;
  11472.  
  11473. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  11474. if(nomit=='bricol') {
  11475. var data = sInfo.split('$');
  11476. try {
  11477. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  11478. // appendNewScript(URL_bricol+data[1]
  11479. // +'/mz.php?login='+data[2]
  11480. // +'&password='+data[3]
  11481. // );
  11482. FF_XMLHttpRequest({
  11483. method: 'GET',
  11484. url: URL_bricol+data[1]
  11485. +'/mz_json.php?login='+encodeURIComponent(data[2])
  11486. +'&password='+data[3],
  11487. trace: 'bricolTroll',
  11488. onload: function(responseDetails) {
  11489. try {
  11490. if (responseDetails.status == 0) {
  11491. window.console.log('status=0 à l\'appel bricol\'troll');
  11492. if (isHTTPS) {
  11493. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  11494. } else {
  11495. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  11496. }
  11497. return;
  11498. }
  11499. var ratibusData;
  11500. try {
  11501. ratibusData = JSON.parse(responseDetails.responseText);
  11502. } catch(e) {}
  11503. if (ratibusData === undefined) {
  11504. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  11505. return;
  11506. }
  11507. if (ratibusData.error) {
  11508. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  11509. } else {
  11510. putInfosTrolls(ratibusData.data.trolls, data[1]);
  11511. }
  11512. } catch(e) {
  11513. window.console.log(traceStack(e, 'retour bricol\'troll'));
  11514. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  11515. }
  11516. }
  11517. });
  11518. } catch(e) {
  11519. if (isHTTPS) {
  11520. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  11521. } else {
  11522. window.console.log(traceStack(e, 'appel bricol\'troll'));
  11523. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  11524. }
  11525. }
  11526. }
  11527. }
  11528.  
  11529. /*
  11530. * Roule 07/11/2016, on utilise mz_json qui envoie
  11531. {
  11532. "data": {
  11533. "trolls": {
  11534. "59424": {
  11535. "id": 59424,
  11536. "pv": xx,
  11537. "pv_max": xx,
  11538. "updated_at": "2016-10-31 07:28:40",
  11539. "dla": "2016-10-05 07:28:04",
  11540. "pa": 0
  11541. },
  11542. }
  11543. }
  11544. }
  11545. */
  11546.  
  11547. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  11548. function corrigeBricolTrolls(infosTrolls) {
  11549. for(var i in infosTrolls) {
  11550. var pv = infosTrolls[i][0];
  11551. var pvmax = infosTrolls[i][1];
  11552. var pvmem = MY_getValue(i+'.caracs.pv.max');
  11553. if(pvmem && pvmem>pvmax) {
  11554. infosTrolls[i][1] = pvmem;
  11555. pvmax = pvmem;
  11556. }
  11557. if(pv>pvmax) {
  11558. var newpvmax = 5*Math.ceil(pv/5);
  11559. MY_setValue(i+'.caracs.pv.max',newpvmax);
  11560. infosTrolls[i][1] = newpvmax;
  11561. }
  11562. }
  11563. }
  11564.  
  11565. // insère 2 TD avant nextTD avec les infos venant de l'IT
  11566. function addTdInfosTroll(infos, TR, itName) {
  11567. /* cadre barre PV */
  11568. var tab = document.createElement('div');
  11569. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  11570. /* barre PV */
  11571. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  11572. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  11573. .vieContainer {
  11574. background-color: #CCC;
  11575. width: 50px;
  11576. height: 6px;
  11577. border: 1px solid #000;
  11578. text-align: left;
  11579. }
  11580. */
  11581. tab.style.width = '100px';
  11582. tab.style.height = '10px';
  11583. tab.style.border = '1px solid #000';
  11584. tab.style.textAlign = 'left';
  11585. var div2 = document.createElement('div');
  11586. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  11587. var dateLimite = new Date();
  11588. dateLimite.setDate(dateLimite.getDate() - 7);
  11589. if (infos.oUpdatedAt < dateLimite) {
  11590. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  11591. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  11592. } else if (pourcentVie > 66) {
  11593. div2.style.backgroundColor = '#77EE77';
  11594. } else if (pourcentVie > 33) {
  11595. div2.style.backgroundColor = '#EEEE77';
  11596. } else {
  11597. div2.style.backgroundColor = '#FF0000';
  11598. }
  11599. div2.style.width = pourcentVie + '%';
  11600. div2.style.height = '10px';
  11601. tab.appendChild(div2);
  11602. /* ancienne méthode par img, à supprimer
  11603. var img = document.createElement('img');
  11604. img.src = '../Images/Interface/milieu.gif';
  11605. img.height = 10;
  11606. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  11607. tab.appendChild(img);
  11608. */
  11609.  
  11610. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  11611. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  11612. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  11613. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  11614.  
  11615. /* lien vers l'IT */
  11616. var lien = document.createElement('a');
  11617. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  11618. lien.href = URL_bricol+itName+'/index.php';
  11619. lien.target = '_blank';
  11620. lien.appendChild(tab);
  11621. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11622. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  11623. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  11624. //insertTdElement(tdGuilde,lien);
  11625. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  11626. /* PAs dispos */
  11627. var span = document.createElement('span');
  11628. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  11629. appendText(span, infos.pa +' PA' );
  11630. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  11631. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  11632. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  11633. span.style.backgroundColor = 'B8EEB8';
  11634. }
  11635. //insertTdElement(tdGuilde, span);
  11636. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  11637. }
  11638.  
  11639. var MZ_tabTrTrollById;
  11640. function putInfosTrolls(infosTrolls, itName) {
  11641. try {
  11642. if (MZ_tabTrTrollById === undefined) {
  11643. MZ_tabTrTrollById = new Array;
  11644. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  11645. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11646. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  11647. td.width = 40;
  11648. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  11649. td.width = 105;
  11650. for(i=nbTrolls ; i>0 ; i--) {
  11651. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11652. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11653. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  11654. }
  11655. }
  11656.  
  11657.  
  11658. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  11659. //corrigeBricolTrolls(infosTrolls);
  11660.  
  11661. // supression des infos trop vieilles (un mois)
  11662. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  11663. var dateLimite = new Date();
  11664. dateLimite.setMonth(dateLimite.getMonth() - 1);
  11665.  
  11666. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  11667. var str = MY_getValue(numTroll+'.INFOSIT');
  11668. var bAjoutTrollInvi = false;
  11669. if (str) {
  11670. var arr = str.split('$');
  11671. bAjoutTrollInvi = arr[4]>0;
  11672. }
  11673.  
  11674.  
  11675. var tBody = tr_trolls[0].parentNode;
  11676. if (tr_trolls[1] !== undefined)
  11677. tBody = tr_trolls[1].parentNode;
  11678.  
  11679. //window.console.log('nb Troll IT : ' + IDs.length);
  11680. var pos = getPosition();
  11681.  
  11682. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  11683. for (var idTroll in infosTrolls) {
  11684. var infos = infosTrolls[idTroll];
  11685. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  11686. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  11687. if (idTroll == numTroll) continue; // pas nous-même
  11688. var tr;
  11689. if (idTroll in MZ_tabTrTrollById) {
  11690. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  11691. tr = MZ_tabTrTrollById[idTroll];
  11692. } else {
  11693. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  11694. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  11695. // trouver où insérer ce Troll
  11696. var next = undefined;
  11697. for(var j=0 ; j<tr_trolls.length ; j++) {
  11698. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  11699. if (thisDist > distance) {
  11700. next = tr_trolls[j]
  11701. break;
  11702. }
  11703. }
  11704. if (next !== undefined) {
  11705. tr = insertTr(next,'mh_tdpage')
  11706. } else {
  11707. tr = appendTr(tBody,'mh_tdpage');
  11708. }
  11709. tr.style.color = 'orange';
  11710. var td = appendTd(tr); // distance
  11711. appendText(td, distance);
  11712. td = appendTd(tr); // actions
  11713. td = appendTd(tr); // ID
  11714. appendText(td, idTroll);
  11715. td = appendTd(tr); // Nom
  11716. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  11717. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  11718. td = appendTd(tr); // PV
  11719. td = appendTd(tr); // PA
  11720. td = appendTd(tr); // Guilde
  11721. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  11722. td = appendTd(tr); // Niveau
  11723. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  11724. td.align = 'center';
  11725. td = appendTd(tr); // Race
  11726. if (infos.race) appendText(td, infos.race);
  11727. td = appendTd(tr); // X
  11728. td.align = 'center';
  11729. if (infos.x !== undefined) appendText(td, infos.x);
  11730. td = appendTd(tr); // Y
  11731. td.align = 'center';
  11732. if (infos.y !== undefined) appendText(td, infos.y);
  11733. td = appendTd(tr); // N
  11734. td.align = 'center';
  11735. if (infos.n !== undefined) appendText(td, infos.n);
  11736. MZ_tabTrTrollById[idTroll] = tr;
  11737. }
  11738. if (!tr.done) {
  11739. addTdInfosTroll(infos, tr, itName);
  11740. tr.done = true;
  11741. }
  11742. }
  11743. } catch(e) {
  11744. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  11745. window.console.error(traceStack(e, 'putInfosTrolls'));
  11746. }
  11747. }
  11748.  
  11749.  
  11750. /* Mode Tétalanvert! ---------------------------------------------------------*/
  11751.  
  11752. function calculeDistance(maPos,posArr) {
  11753. return Math.max(
  11754. Math.abs(maPos[0]-posArr[0]),
  11755. Math.abs(maPos[1]-posArr[1]),
  11756. Math.abs(maPos[2]-posArr[2])
  11757. );
  11758. }
  11759.  
  11760. function inversionCoord() {
  11761. var maPos = getPosition();
  11762. var listeOffsets = {
  11763. 'monstres':checkBoxLevels.checked?4:3,
  11764. 'trolls':6,
  11765. };
  11766. for(var type in listeOffsets) {
  11767. var trList = VueContext['tr_'+type];
  11768. var offset = listeOffsets[type];
  11769. for(var i=trList.length-1 ; i>0 ; i--) {
  11770. var oldX = parseInt(trList[i].cells[offset].textContent);
  11771. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  11772. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  11773. trList[i].cells[offset].innerHTML = oldY;
  11774. trList[i].cells[offset+1].innerHTML = oldX;
  11775. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  11776. }
  11777. }
  11778. }
  11779.  
  11780.  
  11781. /* Partie principale */
  11782. function do_vue() {
  11783. for(var type in typesAFetcher) {
  11784. fetchData(type);
  11785. }
  11786.  
  11787. // roule' 11/03/2016
  11788. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  11789. // je fais une recopie :(
  11790. MZ_EtatCdMs.tr_monstres = VueContext.tr_monstres;
  11791. tr_trolls = VueContext.tr_trolls;
  11792. tr_tresors = VueContext.tr_tresors;
  11793. tr_champignons = VueContext.tr_champignons;
  11794. tr_lieux = VueContext.tr_lieux;
  11795.  
  11796. MZ_EtatCdMs.nbMonstres = VueContext.nbMonstres;
  11797. nbTrolls = VueContext.nbTrolls;
  11798. nbTresors = VueContext.nbTresors;
  11799. nbChampignons = VueContext.nbChampignons;
  11800. nbLieux = VueContext.nbLieux;
  11801.  
  11802. try {
  11803. start_script(31);
  11804.  
  11805. initialiseInfos();
  11806. savePosition();
  11807.  
  11808. // Fonctionnalité "Têtalenvert" cachée, en test :
  11809. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  11810. inversionCoord();
  11811. }
  11812.  
  11813. ajoutDesFiltres();
  11814. set2DViewSystem();
  11815. //putBoutonTroogle();
  11816. putBoutonPXMP();
  11817.  
  11818. synchroniseFiltres();
  11819. toggleLevelColumn(); // appel des CdM, ne fait rien si la checkbox NOCDM est cochée
  11820.  
  11821. refreshDiplo();
  11822.  
  11823. //400 ms
  11824. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  11825. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  11826. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  11827. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  11828. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  11829. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  11830. var noTresorsEngages =
  11831. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  11832. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  11833. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  11834. filtreMonstres();
  11835. if(noIntangibles) {
  11836. filtreTrolls();
  11837. }
  11838. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  11839. filtreTresors();
  11840. }
  11841. if(noTrou) {
  11842. filtreLieux();
  11843. }
  11844.  
  11845. MZ_Tactique.initPopup();
  11846. initPXTroll();
  11847.  
  11848. if(getTalent("Projectile Magique")) {
  11849. computeProjo();
  11850. }
  11851. if(getTalent("Charger")) {
  11852. computeCharge();
  11853. }
  11854. if(getTalent("Télékinésie")) {
  11855. computeTelek();
  11856. }
  11857. if(getTalent("Lancer de Potions")) {
  11858. computeLdP();
  11859. }
  11860.  
  11861. putScriptExterne();
  11862.  
  11863. displayScriptTime();
  11864. } catch(e) {
  11865. window.console.error(traceStack(e, 'vue'));
  11866. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite (seriez-vous sous l'effet d'un Fumeux ?).");
  11867. }
  11868. }
  11869.  
  11870.  
  11871.  
  11872. /*******************************************************************************
  11873. * This file is part of Mountyzilla. *
  11874. * *
  11875. * Mountyzilla is free software; you can redistribute it and/or modify *
  11876. * it under the terms of the GNU General Public License as published by *
  11877. * the Free Software Foundation; either version 2 of the License, or *
  11878. * (at your option) any later version. *
  11879. * *
  11880. * Mountyzilla is distributed in the hope that it will be useful, *
  11881. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11882. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11883. * GNU General Public License for more details. *
  11884. * *
  11885. * You should have received a copy of the GNU General Public License *
  11886. * along with Mountyzilla; if not, write to the Free Software *
  11887. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11888. *******************************************************************************/
  11889.  
  11890. // x~x profil2
  11891.  
  11892. /*---------------------------- Variables globales ----------------------------*/
  11893.  
  11894. var
  11895. // Anatrolliseur
  11896. urlAnatrolliseur,
  11897. // Infobulles talents
  11898. hauteur = 50, bulleStyle = null,
  11899. // Caracteristiques
  11900. // Infos troll
  11901. race, niv, idtroll, datecrea,
  11902. idguilde, nomguilde,
  11903. // Etats du troll
  11904. fatigue, bmfatigue,
  11905.  
  11906. // Experience, Pi, ...
  11907. pxdistribuables, pxperso,
  11908. piutilisable, pitotal,
  11909. nbmeurtres, nbmorts,
  11910. // utilisee pour les moyennes MM/jour, kill/jour, etc
  11911. NBjours,
  11912. // calcul des DLA suivantes
  11913. DLA, DLAsuiv, HeureServeur,
  11914. // details duree du tour (calcul pvdispo) :
  11915. dtb, pdm, bmt, adb, dpt,
  11916. //posale
  11917. posX, posY, posN,
  11918. // caracs physiques
  11919. vue, vuebp, vuebm, vuetotale,
  11920. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  11921. reg, regbp, regbm, regmoy,
  11922. att, attbp, attbm, attmoy, atttourD, atttour, attmoytour,
  11923. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  11924. deg, degbp, degbm, degmoy, degmoycrit, degtour, degmoytour, degmoycrittour,
  11925. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  11926. rm, rmbp, rmbm, rmtotale,
  11927. mm, mmbp, mmbm, mmtotale,
  11928.  
  11929. // Variables speciales Kastars
  11930. pvActuelKastar, minParPV, overDLA,
  11931. // id pour edition manuelle de lastDLA :
  11932. inJour, inMois, inAn, inHr, inMin, inSec,
  11933. // id pour auto-refresh lastDLA :
  11934. lastDLAZone, maxAMZone, cumulZone,
  11935. lastDLA, DLAaccel;
  11936.  
  11937.  
  11938. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  11939.  
  11940. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  11941. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  11942. function getUniqueValueBySelector(selector, defaultValue){
  11943. var valNode = document.querySelector(selector);
  11944. if(valNode!=null){
  11945. if(valNode.hasChildNodes()) {
  11946. return valNode.childNodes[0].nodeValue;
  11947. }else{
  11948. return defaultValue;
  11949. }
  11950. } else{
  11951. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  11952. return defaultValue;
  11953. }
  11954. }
  11955. function getUniqueStringValueBySelector(selector){
  11956. return getUniqueValueBySelector(selector,"");
  11957. }
  11958. function getUniqueIntValueBySelector(selector){
  11959. var ret = getUniqueValueBySelector(selector,0);
  11960. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  11961. ret = 0;
  11962. }
  11963. return parseInt(ret);
  11964. }
  11965. function getUniqueFloatValueBySelector(selector){
  11966. var ret = getUniqueValueBySelector(selector,0.0);
  11967. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  11968. ret = 0.0;
  11969. }
  11970. return parseFloat(ret);
  11971. }
  11972.  
  11973.  
  11974. function resiste(Ddeg,bm) {
  11975. // version naive mais compréhensible ^^
  11976. // DEBUG: à revoir
  11977. if(!bm) {
  11978. return 2*Math.floor(Ddeg/2);
  11979. }
  11980. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  11981. }
  11982.  
  11983. function retourAZero(fatig) {
  11984. var fat = fatig, raz = 0;
  11985. while(fat>0) {
  11986. raz++;
  11987. fat = Math.floor(fat/1.25);
  11988. }
  11989. return raz;
  11990. }
  11991.  
  11992. function coefDecumul(i) {
  11993. switch(i) {
  11994. case 2: return 0.67;
  11995. case 3: return 0.4;
  11996. case 4: return 0.25;
  11997. case 5: return 0.15;
  11998. default: return 0.1;
  11999. }
  12000. }
  12001.  
  12002. function dureeHM(dmin) {
  12003. var ret = "";
  12004. dmin = Math.floor(dmin);
  12005. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  12006. var mins = dmin%60;
  12007. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  12008. return (ret) ? ret : "-";
  12009. }
  12010.  
  12011. // extraction d'une durée
  12012. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "- 2 h 30 m"
  12013. // c'est protégé (rend 0 si l'élément est absent)
  12014. // Roule' 24/12/2016
  12015. function extractionDuree(selecteur) {
  12016. var s = getUniqueStringValueBySelector(selecteur);
  12017. if (!s) return 0;
  12018. var tabN = getNumbers(s);
  12019. if (tabN.length < 2) return 0;
  12020. if (s.includes('-')) {
  12021. return - tabN[0] * 60 - tabN[1];
  12022. }
  12023. return tabN[0] * 60 + tabN[1];
  12024. }
  12025.  
  12026. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  12027.  
  12028. function extractionDonnees() {
  12029. // Variables temporaires
  12030. var Nbrs = {};
  12031.  
  12032. // *********************
  12033. // Cadre "Description"
  12034. // *********************
  12035. race = getUniqueStringValueBySelector('#descr #race');
  12036. debugMZ("Race : " + race);
  12037. idtroll = getUniqueStringValueBySelector('#descr #id');
  12038. debugMZ("Id troll : " + idtroll);
  12039. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  12040. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  12041. datecrea = new Date(StringToDate(strDateCrea));
  12042. debugMZ("Date creation : " + datecrea);
  12043. // Guilde
  12044. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  12045. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  12046. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  12047.  
  12048. // *******************
  12049. // Cadre "Experience"
  12050. // *******************
  12051. // Niveau de troll
  12052. niv = getUniqueIntValueBySelector('#exp #niv');
  12053. nivTroll = niv;
  12054. debugMZ("Niveau : " + niv);
  12055. // PX
  12056. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  12057. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  12058. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  12059. // PI
  12060. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  12061. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  12062. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  12063. // Meutres/Morts
  12064. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  12065. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  12066. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  12067.  
  12068. // *********************
  12069. // Cadre "Tour de Jeu"
  12070. // *********************
  12071. // DLA
  12072. Nbrs['dla'] = getUniqueStringValueBySelector('#dla #dla>b');
  12073. DLA = new Date(StringToDate(Nbrs['dla']));
  12074. debugMZ('DLA: ' + DLA);
  12075. // DLA suivante
  12076. Nbrs['dlasuiv'] = getUniqueStringValueBySelector('#dla #dla_next');
  12077. DLAsuiv = new Date(StringToDate(Nbrs['dlasuiv']));
  12078. debugMZ('DLAsuiv: ' + DLAsuiv);
  12079. // Duree normale de mon Tour
  12080. dtb = extractionDuree('#dla #tour');
  12081. debugMZ('Duree normale de mon Tour : ' + dtb);
  12082. // Bonus/Malus sur la duree
  12083. bmt = extractionDuree('#dla #bm'); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  12084. debugMZ('Bonus/Malus sur la duree : ' + bmt);
  12085. // Augmentation due aux blessures
  12086. adb = extractionDuree('#dla #blessure');
  12087. debugMZ('Augmentation due aux blessures : ' + adb);
  12088. // Poids de l'equipement
  12089. pdm = extractionDuree('#dla #poids');
  12090. debugMZ('Poids de l\'equipement : ' + pdm);
  12091. // Duree de mon prochain Tour
  12092. dpt = extractionDuree('#dla #duree>b');
  12093. debugMZ('Duree de mon prochain Tour : ' + dpt);
  12094.  
  12095. // ****************
  12096. // Cadre "Etats"
  12097. // ****************
  12098. // Position du troll :
  12099. posX = getUniqueIntValueBySelector('#pos #x');
  12100. posY = getUniqueIntValueBySelector('#pos #y');
  12101. posN = getUniqueIntValueBySelector('#pos #n');
  12102. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  12103. // PV actuel
  12104. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  12105. pvActuelKastar = pvcourant;
  12106. debugMZ("PV actuel : " + pvcourant)
  12107. // Fatigue
  12108. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  12109. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  12110. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  12111.  
  12112. // **************************
  12113. // Cadre "Caracteristiques"
  12114. // **************************
  12115. // Attaque
  12116. att = getUniqueIntValueBySelector('#carac #att');
  12117. attbp = getUniqueIntValueBySelector('#carac #att_p');
  12118. attbm = getUniqueIntValueBySelector('#carac #att_m');
  12119. atttour = getUniqueIntValueBySelector('#carac #att_tour'); // % bonus AdA
  12120. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d'); // malus Parade
  12121. attmoy = 3.5*att + attbp + attbm;
  12122. var DAttBonus = Math.floor(((att+atttourD)*atttour/100)); // À vérifier
  12123. attmoytour = 3.5*(att+DAttBonus) + attbp + attbm;
  12124. debugMZ(
  12125. "ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+
  12126. "; BM Dé att/tour:("+atttourD+"D;"+atttour+"%) "+(atttourD+DAttBonus)+
  12127. "D ;AttMoyTour:"+attmoytour
  12128. );
  12129. // Esquive
  12130. esq = getUniqueIntValueBySelector('#carac #esq');
  12131. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  12132. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  12133. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  12134. esqmoy = 3.5*esq + esqbp+esqbm;
  12135. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  12136. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  12137. // Degat
  12138. deg = getUniqueIntValueBySelector('#carac #deg');
  12139. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  12140. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  12141. degtour = getUniqueIntValueBySelector('#carac #deg_tour'); // % bonus AdD
  12142. degmoy = 2*deg + degbp + degbm;
  12143. degmoycrit = 2*(deg+Math.floor(deg/2)) + degbp + degbm;
  12144. var DDegBonus = Math.floor(deg*degtour/100);
  12145. degmoytour = 2*(deg + DDegBonus) + degbp + degbm;
  12146. degmoycrittour = degmoytour + 2*Math.floor(deg/2);
  12147. debugMZ(
  12148. "DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+
  12149. " ;deg/tour:("+degtour+"%) "+DDegBonus+
  12150. "D; DegMoyTour:"+degmoytour+"/"+degmoycrittour
  12151. );
  12152. // PV
  12153. pvbase = getUniqueIntValueBySelector('#carac #pv');
  12154. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  12155. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  12156. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  12157. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  12158. // Regeneration
  12159. reg = getUniqueIntValueBySelector('#carac #reg');
  12160. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  12161. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  12162. regmoy = 2 * reg + regbp + regbm; // D3
  12163. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  12164. // Armure
  12165. arm = getUniqueIntValueBySelector('#carac #arm');
  12166. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  12167. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  12168. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  12169. armmoy = 2*arm + armbp+armbm;
  12170. armmoytour = 2*Math.max(arm+armtourD, 0) + armbp+armbm;
  12171. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  12172. // TODO : D d'armure non active
  12173. // Vue
  12174. vue = getUniqueIntValueBySelector('#carac #vue');
  12175. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  12176. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  12177. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  12178. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  12179. // RM
  12180. rm = getUniqueIntValueBySelector('#carac #rm');
  12181. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  12182. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  12183. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  12184. rmTroll = rmtotale;
  12185. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  12186. // MM
  12187. mm = getUniqueIntValueBySelector('#carac #mm');
  12188. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  12189. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  12190. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  12191. mmTroll = mmtotale;
  12192. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  12193.  
  12194. // Heure Serveur
  12195. try {
  12196. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  12197. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  12198. HeureServeur = new Date(StringToDate(heureServeurSTR));
  12199. } catch (e) {
  12200. window.console.warn(
  12201. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  12202. );
  12203. HeureServeur = new Date();
  12204. }
  12205. debugMZ("HeureServeur: " + HeureServeur);
  12206.  
  12207. // ***INIT GLOBALE*** NBjours
  12208. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  12209.  
  12210. // Calcul debut lien anatroliseur avec les caracteristiques connues
  12211. var amelio_dtb = function(dtb) {
  12212. if(dtb>555) {
  12213. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  12214. }
  12215. return 10+Math.ceil((555-dtb)/2.5);
  12216. },
  12217. amelio_pv = Math.floor(pvbase/10)-3,
  12218. amelio_vue = vue-3,
  12219. amelio_att = att-3,
  12220. amelio_esq = esq-3,
  12221. amelio_deg = deg-3,
  12222. amelio_reg = reg-1,
  12223. amelio_arm = arm-1;
  12224. if(race==="Darkling"){amelio_reg--; }
  12225. if(race==="Durakuir"){amelio_pv-- ; }
  12226. if(race==="Kastar") {amelio_deg--; }
  12227. if(race==="Skrim") {amelio_att--; }
  12228. if(race==="Tomawak") {amelio_vue--; }
  12229.  
  12230. urlAnatrolliseur = URL_AnatrolDispas
  12231. +"outils_anatrolliseur.php?anatrolliseur=v8"
  12232. +"|r="+race.toLowerCase()
  12233. +"|dla="+amelio_dtb(dtb)
  12234. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  12235. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  12236. +"|att="+amelio_att+","+attbp+","+attbm
  12237. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  12238. +"|deg="+amelio_deg+","+degbp+","+degbm
  12239. +"|reg="+amelio_reg+","+regbp+","+regbm
  12240. +"|arm="+amelio_arm+","+armbp+","+armbm
  12241. +"|mm="+mmtotale
  12242. +"|rm="+rmtotale+"|";
  12243. }
  12244.  
  12245. function saveProfil() {
  12246. MY_setValue(idtroll+'.caracs.attaque',att);
  12247. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  12248. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  12249. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  12250. if(atttourD||atttour) {
  12251. var DAttBonus = atttourD + Math.floor((att+atttourD)*atttour/100);
  12252. MY_setValue(idtroll+'.bonus.DAttM',DAttBonus);
  12253. } else {
  12254. MY_removeValue(idtroll+'.bonus.DAttM');
  12255. }
  12256. MY_setValue(idtroll+'.caracs.esquive',esq);
  12257. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  12258. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  12259. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  12260. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  12261. MY_setValue(idtroll+'.caracs.degats',deg);
  12262. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  12263. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  12264. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  12265. if(degtour) {
  12266. var DDegBonus = Math.floor(deg*degtour/100);
  12267. MY_setValue(idtroll+'.bonus.DDeg',DDegBonus);
  12268. } else {
  12269. MY_removeValue(idtroll+'.bonus.DDeg');
  12270. }
  12271. MY_setValue(idtroll+'.caracs.regeneration',reg);
  12272. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  12273. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  12274. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  12275. MY_setValue(idtroll+'.caracs.vue',vue);
  12276. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  12277. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  12278. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  12279. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  12280. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  12281. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  12282. MY_setValue(idtroll+'.caracs.rm',rm);
  12283. MY_setValue(idtroll+'.caracs.rm.bm',(rmtotale));
  12284. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  12285. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  12286. MY_setValue(idtroll+'.caracs.mm',mm);
  12287. MY_setValue(idtroll+'.caracs.mm.bm',(mmtotale));
  12288. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  12289. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  12290. MY_setValue(idtroll+'.caracs.armure',arm);
  12291. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  12292. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  12293. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  12294. MY_setValue(idtroll+'.position.X',posX);
  12295. MY_setValue(idtroll+'.position.Y',posY);
  12296. MY_setValue(idtroll+'.position.N',posN);
  12297. MY_setValue(idtroll+'.race',race);
  12298. MY_setValue(idtroll+'.niveau',niv);
  12299. MY_setValue(idtroll+'.idguilde',idguilde);
  12300. MY_setValue(idtroll+'.nomguilde',nomguilde);
  12301. }
  12302.  
  12303.  
  12304. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  12305.  
  12306. function setInfosCaracteristiques() {
  12307. // Modification de l'entete
  12308. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  12309. thTotal.innerHTML+='|<i>Moyenne</i>';
  12310. thTotal.title="Moyenne (Moyenne ce tour)";
  12311.  
  12312. // Ajout des informations calculees
  12313. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  12314. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  12315. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  12316.  
  12317. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  12318. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  12319. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  12320.  
  12321. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  12322. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  12323. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  12324.  
  12325. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  12326. var tdRegTotal = trRegeneration.children[5];
  12327. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  12328. // Temps recupere par reg (propale R')
  12329. var regmoyTemp = Math.max(0, regmoy);
  12330. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  12331. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  12332. if (sec != 0) {
  12333. regTitle += " " + sec + " sec";
  12334. }
  12335. trRegeneration.title = regTitle;
  12336.  
  12337. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  12338. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  12339. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  12340.  
  12341. var trRM=document.querySelector("table#caracs #rm").parentElement;
  12342. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  12343. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  12344.  
  12345.  
  12346. var trMM=document.querySelector("table#caracs #mm").parentElement;
  12347. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  12348. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  12349.  
  12350. var tdRefl=document.querySelector("#refl");
  12351. // TODO : prendre en compte bonus/malus D esq du tour ?
  12352. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + esqbp + esqbm;
  12353. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  12354. }
  12355.  
  12356. function setLienAnatrolliseur(){
  12357. var pTableAmelio = document.querySelector("#carac>div>p");
  12358. if (!pTableAmelio) pTableAmelio = document.querySelector("#carac>div>div>p");
  12359. if (!pTableAmelio) return;
  12360. pTableAmelio.appendChild(document.createTextNode(' - '));
  12361. var aElt = document.createElement("a");
  12362. aElt.setAttribute("href",urlAnatrolliseur);
  12363. aElt.setAttribute("target","_blank");
  12364. aElt.className="AllLinks";
  12365. aElt.innerHTML="Anatrolliser";
  12366. pTableAmelio.appendChild(aElt);
  12367. }
  12368. function setInfoDescription() {
  12369. var txtDateCrea = (NBjours!=1) ?
  12370. " ("+NBjours+" jours dans le hall)" :
  12371. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  12372. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  12373. }
  12374.  
  12375. function setInfosEtatLieux() {
  12376. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  12377. '?search=position&orderBy=distance&posx='+
  12378. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  12379. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  12380. appendBr(tdPosition);
  12381. var aElt = document.createElement("a");
  12382. aElt.setAttribute("href",urlBricol);
  12383. aElt.setAttribute("target","_blank");
  12384. aElt.className="AllLinks";
  12385. aElt.innerHTML="Lieux à proximité";
  12386. tdPosition.appendChild(aElt);
  12387. }
  12388.  
  12389. function setInfosEtatPV() { // pour AM et Sacro
  12390. var
  12391. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  12392. sec = Math.floor(15000/pvtotal)%60,
  12393. lifebar = document.querySelector("#pos .barre-vie");
  12394. if(sec!=0) { txt += " "+sec+" sec"; }
  12395. if(lifebar) { lifebar.title = txt; }
  12396. if(pvcourant<=0) { return; }
  12397.  
  12398. // Difference PV p/r a equilibre de temps (propale R')
  12399. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  12400. // ***INIT GLOBALE*** pvdispo
  12401. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  12402. var span = document.createElement("span");
  12403. span.title = txt;
  12404. span.style.fontStyle = "italic";
  12405. if(bmt+pdm>=0) {
  12406. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  12407. } else if(pvdispo>0) {
  12408. txt = "Vous pouvez encore perdre "+
  12409. Math.min(pvdispo,pvcourant)+
  12410. " PV sans malus de temps.";
  12411. } else if(pvdispo<0) {
  12412. txt = "Il vous manque "
  12413. +(-pvdispo)
  12414. +" PV pour ne plus avoir de malus de temps.";
  12415. } else {
  12416. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  12417. }
  12418. appendText(span,txt);
  12419. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  12420. }
  12421.  
  12422. // Complete le cadre "Experience"
  12423. function setInfosExp() {
  12424. var tdNiv = document.querySelector("#exp #niv");
  12425.  
  12426. // Calcul niveau monstre/troll min pour gain PX
  12427. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  12428. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  12429.  
  12430. // Calcul PX restant
  12431. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  12432. if (pxRestant >= 0) {
  12433. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  12434. if (tdinfoEntrainement) tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  12435. }
  12436.  
  12437. // Calul pi/jour
  12438. var
  12439. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  12440. tdPi = document.querySelector("#exp #pi").parentElement;
  12441. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  12442. tdPi.title = tdPiTotal.title;
  12443.  
  12444. // Rapports meurtres,morts
  12445. var tdKill = document.querySelector("#exp #kill");
  12446. tdKill.setAttribute("colspan", 1);
  12447. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  12448.  
  12449. var tdMort = document.querySelector("#exp #mort");
  12450. tdMort.setAttribute("colspan", 1);
  12451. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  12452.  
  12453. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  12454. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  12455. }
  12456.  
  12457.  
  12458. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  12459.  
  12460. function minParPVsac(fat,bm) {
  12461. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  12462. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  12463. var out = [];
  12464. out[0] = (fat>4) ?
  12465. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  12466. 30;
  12467. if(bm && bm>0) {
  12468. var totalfat=fat+bm;
  12469. out[1] = (totalfat>4) ?
  12470. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  12471. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  12472. }
  12473. return out;
  12474. }
  12475.  
  12476. function toInt(str) {
  12477. str = parseInt(str);
  12478. return (str) ? str : 0;
  12479. }
  12480.  
  12481. function saveLastDLA() {
  12482. // pour les calculs d'AM max
  12483. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  12484. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  12485. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  12486. lastDLA = new Date( StringToDate(str) );
  12487. MY_setValue(numTroll+'.DLA.ancienne',str);
  12488. lastDLAZone.innerHTML = '';
  12489. var b = document.createElement('b');
  12490. b.addEventListener('click',inputMode,false);
  12491. appendText(b,str);
  12492. lastDLAZone.appendChild(b);
  12493. refreshAccel();
  12494. }
  12495.  
  12496. function inputMode() {
  12497. // Edition manuelle lastDLA
  12498. var date;
  12499. if(lastDLA)
  12500. date = new Date( lastDLA );
  12501. else
  12502. date = new Date( DLAaccel );
  12503. lastDLAZone.innerHTML = '';
  12504. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  12505. appendText(lastDLAZone,'/');
  12506. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  12507. appendText(lastDLAZone,'/');
  12508. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  12509. appendText(lastDLAZone,' - ');
  12510. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  12511. appendText(lastDLAZone,':');
  12512. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  12513. appendText(lastDLAZone,':');
  12514. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  12515. appendText(lastDLAZone,' - ');
  12516. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  12517. }
  12518.  
  12519. function setAccel() {
  12520. var
  12521. BMfrais=false,
  12522. fat=fatigue, listeBmFat=[],
  12523. tr, th, insertPt;
  12524.  
  12525. // Creation ligne speciale pour AM dans le cadre "Etat"
  12526. tr = document.createElement('tr');
  12527. th = document.createElement('th');
  12528. appendText(th,'Fatigue et AM',true);
  12529. tr.appendChild(th);
  12530. insertPt = document.createElement('td');
  12531. tr.appendChild(insertPt);
  12532. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  12533.  
  12534. // Est-on en over-DLA ?
  12535. // ***INIT GLOBALE*** overDLA
  12536. overDLA = (HeureServeur>DLA.getTime()+3e5);
  12537. if(overDLA) {
  12538. fat=Math.floor(fatigue/1.25);
  12539. }
  12540.  
  12541. // Gestion des BM de fatigue
  12542. if(bmfatigue>0) {
  12543. // On tente de recuperer les BM de fatigue de la page des BM
  12544. if(MY_getValue(numTroll+'.bm.fatigue')) {
  12545. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  12546. BMmemoire.pop();
  12547. var tour = 0;
  12548. for(var i=0 ; i<BMmemoire.length ; i++) {
  12549. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  12550. while(tour<=parseInt(nbrs[0])) {
  12551. listeBmFat[tour]=parseInt(nbrs[1]);
  12552. tour++;
  12553. }
  12554. }
  12555. }
  12556. if(listeBmFat[0]==bmfatigue) {
  12557. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  12558. BMfrais = true;
  12559. MY_removeValue(numTroll+".bm.fatigue");
  12560. }
  12561. } else {
  12562. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  12563. BMfrais = true;
  12564. }
  12565. if(!BMfrais && bmfatigue>0) {
  12566. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  12567. if(bmfatigue==15) {
  12568. listeBmFat = [15,15,15];
  12569. } else {
  12570. listeBmFat = [30,30,15];
  12571. }
  12572. }
  12573. if(overDLA) {
  12574. // Si on est en over-DLA, on decale les bm d'un tour
  12575. listeBmFat.shift();
  12576. }
  12577.  
  12578. // Tableau des fatigues et accel futures
  12579. var
  12580. minppv = minParPVsac(fat,listeBmFat[0]),
  12581. table, tbody,
  12582. ligneTour, ligneFat, ligneMin,
  12583. col;
  12584. // ***INIT GLOBALE*** minParPV
  12585. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  12586. if(fat>0 || listeBmFat[0]>0) {
  12587. table = document.createElement('table');
  12588. table.className = 'mh_tdborder';
  12589. table.border = 0;
  12590. table.cellSpacing = 1;
  12591. table.cellPadding = 1;
  12592. table.style.textAlign = "center";
  12593. tbody = document.createElement('tbody');
  12594. table.appendChild(tbody);
  12595. insertPt.appendChild(table);
  12596.  
  12597. ligneTour = appendTr(tbody,'mh_tdtitre');
  12598. ligneTour.style.fontWeight = "bold";
  12599. var td = appendTdText(ligneTour,'Tour :',true);
  12600. td.align = 'left';
  12601. ligneFat = appendTr(tbody,'mh_tdpage');
  12602. td = appendTdText(ligneFat,'Fatigue :',true);
  12603. td.className = 'mh_tdtitre';
  12604. td.align = 'left';
  12605. ligneMin = appendTr(tbody,'mh_tdpage');
  12606. td = appendTdText(ligneMin,'1 PV =',true);
  12607. td.className = 'mh_tdtitre';
  12608. td.align = 'left';
  12609. col=0;
  12610. while(col<9 && (fat>0 || listeBmFat[col])) {
  12611. if(col==0) {
  12612. if(overDLA) {
  12613. var i = document.createElement('i');
  12614. appendText(i,'A activer');
  12615. ligneTour.appendChild(i);
  12616. } else {
  12617. appendTdText(ligneTour,'En cours');
  12618. }
  12619. } else {
  12620. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12621. }
  12622. if(listeBmFat[col]) {
  12623. if(BMfrais || (!overDLA && col==0)) {
  12624. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  12625. appendTdText(ligneMin,minppv[1]+'\'');
  12626. } else {
  12627. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  12628. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  12629. }
  12630. } else {
  12631. appendTdText(ligneFat,fat);
  12632. appendTdText(ligneMin,minppv[0]+'\'');
  12633. }
  12634. col++;
  12635. fat = Math.floor(fat / 1.25);
  12636. minppv = minParPVsac(fat,listeBmFat[col]);
  12637. }
  12638. if(fat>1 || (fat==1 && !overDLA)) {
  12639. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  12640. appendTdText(ligneFat,'-');
  12641. appendTdText(ligneMin,'-');
  12642. }
  12643. col = (overDLA) ?
  12644. Math.max(retourAZero(fatigue)-1,col) :
  12645. Math.max(retourAZero(fatigue),col);
  12646. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12647. appendTdText(ligneFat,'0');
  12648. appendTdText(ligneMin,'30\'');
  12649.  
  12650. if(!BMfrais && bmfatigue) {
  12651. // si les BM n'ont pas ete rafraichis, on signale:
  12652. appendText(
  12653. insertPt,
  12654. '/!\\ Visitez la page des Bonus/Malus '+
  12655. 'pour mettre à jour votre fatigue. /!\\',
  12656. true
  12657. );
  12658. appendBr(insertPt);
  12659. }
  12660. appendBr(insertPt);
  12661. }
  12662.  
  12663. if(pvcourant<=0) {
  12664. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  12665. return;
  12666. }
  12667.  
  12668. if(fatigue>30) {
  12669. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  12670. return;
  12671. }
  12672.  
  12673. // Setup lastDLAZone
  12674. if(overDLA) {
  12675. // bypass des infos de "menu_FF.js" en cas d'overDLA
  12676. DLAaccel = new Date( DLAsuiv );
  12677. lastDLA = new Date( DLA );
  12678. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  12679. // ***INIT GLOBALE*** pvActuelKastar
  12680. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  12681. appendText(
  12682. insertPt,
  12683. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  12684. true
  12685. );
  12686. appendBr(insertPt);
  12687. } else {
  12688. DLAaccel = new Date( DLA );
  12689. pvActuelKastar = pvcourant;
  12690. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  12691. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  12692. } else {
  12693. lastDLA = false;
  12694. }
  12695. }
  12696. appendText(insertPt,'Dernière DLA enregistrée : ');
  12697. lastDLAZone = document.createElement('span');
  12698. lastDLAZone.style.cursor = 'pointer';
  12699. var b = document.createElement('b');
  12700. b.onclick = inputMode;
  12701. lastDLAZone.appendChild(b);
  12702. insertPt.appendChild(lastDLAZone);
  12703. if(lastDLA) {
  12704. appendText(b,DateToString(lastDLA));
  12705. } else {
  12706. appendText(b,'aucune');
  12707. }
  12708. appendBr(insertPt);
  12709.  
  12710. // Setup maxAMZone et cumulZone
  12711. appendText(insertPt,'Accélération maximale possible : ');
  12712. maxAMZone = document.createElement('b');
  12713. insertPt.appendChild(maxAMZone);
  12714. appendBr(insertPt);
  12715. cumulZone = document.createElement('span');
  12716. insertPt.appendChild(cumulZone);
  12717.  
  12718. refreshAccel();
  12719. }
  12720.  
  12721. function refreshAccel() {
  12722. var pvs, pvsmax;
  12723.  
  12724. // Acceleration pour cumul instantane
  12725. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  12726. if(lastDLA) {
  12727. pvsmax = Math.min(
  12728. pvActuelKastar-1,
  12729. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  12730. );
  12731. maxAMZone.innerHTML = pvsmax+" PV";
  12732. } else {
  12733. pvsmax = pvActuelKastar-1;
  12734. maxAMZone.innerHTML = "inconnue";
  12735. }
  12736.  
  12737. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  12738. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  12739. cumulZone.innerHTML = '';
  12740. if(pvs<=pvsmax) {
  12741. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  12742. appendText(cumulZone,pvs+' PV', true);
  12743. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  12744. if(pvs!=1) {
  12745. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  12746. -(pvs-1)*60*minParPV;
  12747. appendText(
  12748. cumulZone,
  12749. ' ('+(pvs-1)+' PV dans '+
  12750. Math.floor(gainSec/60)+'min'+
  12751. addZero(gainSec%60)+'s)'
  12752. );
  12753. }
  12754. } else {
  12755. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  12756. appendText(
  12757. cumulZone,
  12758. 'Après votre accélération maximale, il vous faudra encore attendre '+
  12759. dureeHM(avantDLA/6e4)+
  12760. ' avant de réactiver.'
  12761. );
  12762. }
  12763. }
  12764.  
  12765.  
  12766. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  12767.  
  12768. function traitementTalents() {
  12769. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  12770. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  12771. removeAllTalents();
  12772. var totalComp = injecteInfosBulles(trCompetence,'competences');
  12773. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  12774. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  12775. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  12776. }
  12777.  
  12778. function injecteInfosBulles(liste,fonction) {
  12779. var totalpc = 0;
  12780. // on parse la liste des talents du type 'fonction'
  12781. for(var i=0 ; i<liste.length ; i++) {
  12782. var
  12783. trTalent=liste[i],
  12784. node=trTalent.cells[1].querySelector('a'),
  12785. nomTalent=epure(trim(node.textContent)),
  12786. indiceTDniveaux=7,
  12787. indiceTDSousCompetence=2,
  12788. sousCompetences=undefined;
  12789. if(fonction=="competences"){
  12790. // un TD en plus pour des information complementaire liees a la comp
  12791. indiceTDniveaux++;
  12792. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  12793. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  12794. for (var j=0; j < sousCompetences.length; j++) {
  12795. sousCompetences[j] = sousCompetences[j].epure().trim();
  12796. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  12797. }
  12798. }
  12799. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  12800. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  12801. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  12802. totalpc += niveauxMaitrisesTalentArray[1];
  12803.  
  12804. // stockage des niveaux inferieurs du talent si presents
  12805. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  12806. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  12807. totalpc+=niveauxMaitrisesTalentArray[j+1];
  12808. }
  12809. }
  12810. return totalpc;
  12811. }
  12812.  
  12813. function setInfos(node,nom,fonction,niveau) {
  12814. node.nom = nom;
  12815. node.fonction = fonction;
  12816. node.niveau = niveau;
  12817. node.onmouseover = setBulle;
  12818. node.onmouseout = cacherBulle;
  12819. }
  12820.  
  12821. var arrayModifAnatroll = {
  12822. 'Glue':'Glu',
  12823. 'PuM':'PuiM',
  12824. 'HE':'Hurlement',
  12825. //'Insultes':'Insu',
  12826. 'Pistage':'Pist',
  12827. 'PuC':'Planter',
  12828. 'Golemo':'Golem',
  12829. }
  12830.  
  12831. function setTalent(nom,pc,niveau,sousCompetences) {
  12832. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  12833. // (et pas les % dont osf) ne serait pas plus rentable
  12834. var nomEnBase = arrayTalents[epure(nom)];
  12835. if(!nomEnBase) {
  12836. debugMZ("setTalent: le talent "+nom+" n'est pas dans la base MZ");
  12837. return;
  12838. }
  12839. if(!niveau) { niveau = 1; }
  12840.  
  12841. switch(nomEnBase) {
  12842. case 'Insultes':
  12843. urlAnatrolliseur += 'Insu'+niveau+'|';
  12844. case 'IdT':
  12845. nomEnBase += niveau;
  12846. break;
  12847. case 'Piege':
  12848. for (var i=0 ; i < sousCompetences.length ; i++) {
  12849. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  12850. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  12851. }
  12852. break;
  12853. case 'AP':
  12854. case 'Baroufle':
  12855. case 'CdB':
  12856. case 'CdM':
  12857. case 'Parer':
  12858. case 'Retraite':
  12859. case 'RB':
  12860. case 'SInterposer':
  12861. nomEnBase += niveau;
  12862. default:
  12863. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  12864. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  12865. }
  12866. //debugMZ("setTalent: nom=" + nom + ", pc=" + pc + ", niveau=" + niveau + ", sousCompetences=" + JSON.stringify(sousCompetences) + "=>setValue(" + numTroll+'.talent.'+nomEnBase+", " + pc + ")");
  12867. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  12868. }
  12869.  
  12870. function creerBulleVide() {
  12871. var table = document.createElement('table');
  12872. table.id = 'bulle';
  12873. table.className = 'mh_tdborder';
  12874. table.width = 300;
  12875. table.border = 0;
  12876. table.cellPadding = 5;
  12877. table.cellSpacing = 1;
  12878. table.style =
  12879. 'position:absolute;'
  12880. +'visibility:hidden;'
  12881. +'z-index:800;'
  12882. +'height:auto;';
  12883. var tr = appendTr(table,'mh_tdtitre');
  12884. appendTdText(tr,'Titre');
  12885. tr = appendTr(table,'mh_tdpage');
  12886. appendTdText(tr,'Contenu');
  12887. var aList = document.getElementsByTagName('a');
  12888. aList[aList.length-1].parentNode.appendChild(table);
  12889. }
  12890.  
  12891. function cacherBulle() {
  12892. if(bulleStyle)
  12893. bulleStyle.visibility = 'hidden';
  12894. }
  12895.  
  12896. function setBulle(evt) {
  12897. var nom = this.nom;
  12898. var fonction = this.fonction;
  12899. var niveau = parseInt(this.niveau);
  12900. var str='';
  12901. if(fonction=='competences'){
  12902. str=competences(nom,niveau);
  12903. } else if(fonction=='sortileges') {
  12904. str=sortileges(nom);
  12905. }
  12906. if(str=='') return;
  12907. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  12908.  
  12909. var xfenetre, yfenetre, xpage, ypage, element = null;
  12910. var offset = 15;
  12911. var bulleWidth = 300;
  12912. if(!hauteur) hauteur = 50;
  12913. element = document.getElementById('bulle');
  12914. xfenetre = evt.clientX;
  12915. yfenetre = evt.clientY;
  12916. xpage = xfenetre;
  12917. ypage = yfenetre;
  12918. if(evt.pageX) xpage = evt.pageX;
  12919. if(evt.pageY) ypage = evt.pageY;
  12920. if(element) {
  12921. bulleStyle = element.style;
  12922. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  12923. element.childNodes[1].firstChild.innerHTML = str;
  12924. }
  12925. if(bulleStyle) {
  12926. if(xfenetre>bulleWidth+offset)
  12927. xpage -= bulleWidth+offset;
  12928. else
  12929. xpage += offset;
  12930. if(yfenetre>hauteur+offset)
  12931. ypage -= hauteur + offset;
  12932. bulleStyle.width = bulleWidth;
  12933. bulleStyle.left = xpage + 'px';
  12934. bulleStyle.top = ypage + 'px';
  12935. bulleStyle.visibility = 'visible';
  12936. }
  12937. }
  12938.  
  12939.  
  12940. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  12941.  
  12942. function competences(comp,niveau) {
  12943. var
  12944. modA = atttour?Math.floor((att+atttourD)*atttour/100):0,
  12945. modD = degtour?Math.floor(deg*degtour/100):0,
  12946. texte = "";
  12947.  
  12948. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  12949. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  12950. if(minParPV>1) texte += 's';
  12951. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  12952. } else if(comp.indexOf("Attaque Precise")!=-1) {
  12953. var
  12954. i, pc,
  12955. lastmax=0,
  12956. jetatt, espatt=0,
  12957. notMaxedOut = false;
  12958.  
  12959. for(i=niveau ; i>0 ; i--) {
  12960. pc = getTalent(comp,i);
  12961. if(lastmax!=0 && pc<=lastmax) {
  12962. // Si %AP(i)<%AP(i+1), on passe AP(i)
  12963. continue;
  12964. }
  12965. jetatt = Math.round(3.5*(
  12966. Math.min(Math.floor(1.5*att), att+3*i) + modA
  12967. )) + attbp+attbm;
  12968. espatt += (pc-lastmax)*jetatt;
  12969. texte += "Attaque niv. "+i +
  12970. " ("+(pc-lastmax)+"%) : <b>" +
  12971. Math.min(Math.floor(att*1.5), att+3*i)+"</b> D6 ";
  12972. if(modA) {
  12973. texte += "<i>"+aff(modA)+"D6</i> ";
  12974. }
  12975. texte += aff(attbp+attbm)+" => <b>"+jetatt+"</b><br>";
  12976. lastmax = pc;
  12977. if(i<niveau) {
  12978. // Si l'un des % de niveau inf est > % nivmax,
  12979. // on affiche l'espérance à la fin
  12980. notMaxedOut = true;
  12981. }
  12982. }
  12983. if(notMaxedOut) {
  12984. texte += "<i>Attaque moyenne (si réussite) : <b>" +
  12985. Math.floor(10*espatt/lastmax)/10+"</b></i><br>";
  12986. }
  12987. texte += "Dégâts : <b>"+deg+"</b> D3 ";
  12988. if(modD) {
  12989. texte += "<i>"+aff(modD)+"D3</i> ";
  12990. }
  12991. texte += aff(degbp+degbm) +
  12992. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  12993. } else if(comp.indexOf("Balayage")!=-1) {
  12994. texte = "Déstabilisation : <b>"+att+"</b> D6 ";
  12995. if(modA) {
  12996. texte += "<i>"+aff(modA)+"D6</i> ";
  12997. }
  12998. texte += aff(attbp+attbm) +
  12999. " => <b>"+attmoytour+"</b><br>" +
  13000. "Effet : <b>Met à terre l'adversaire</b>";
  13001. } else if(comp.indexOf('Bidouille')!=-1)
  13002. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  13003. +'de votre inventaire avec le texte de votre choix.';
  13004. else if(comp.indexOf('Baroufle')!=-1){
  13005. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  13006. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  13007. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  13008. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  13009. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  13010. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  13011. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  13012. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  13013. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  13014. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  13015. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  13016. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  13017. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  13018. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  13019. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  13020. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  13021. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  13022. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  13023. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  13024. '</tbody></table>';
  13025. } else if(comp.indexOf("Botte Secrete")!=-1) {
  13026. modA = atttour?Math.floor(Math.floor(2*att/3)*atttour/100):0;
  13027. modD = degtour?Math.floor(Math.floor(att/2)*degtour/100):0;
  13028. texte = "Attaque : <b>"+Math.floor(2*att/3)+"</b> D6 ";
  13029. if(modA) {
  13030. texte += "<i>"+aff(modA)+"D6</i> ";
  13031. }
  13032. texte += aff(Math.floor((attbp+attbm)/2)) +
  13033. " => <b>"+Math.round(
  13034. 3.5*(Math.floor(2*att/3)+modA)+Math.floor((attbp+attbm)/2)
  13035. )+"</b><br/>Dégâts : <b>"+Math.floor(att/2)+"</b> D3 ";
  13036. if(modD) {
  13037. texte += "<i>"+aff(modD)+"D3</i> ";
  13038. }
  13039. texte += aff(Math.floor((degbp+degbm)/2))+" => <b>" +
  13040. (2*(Math.floor(att/2)+modD)+Math.floor((degbp+degbm)/2)) +
  13041. "/"+(
  13042. 2*(Math.floor(1.5*Math.floor(att/2))+modD) +
  13043. Math.floor((degbp+degbm)/2)
  13044. )+"</b>";
  13045. } else if(comp.indexOf('Camouflage')!=-1) {
  13046. var camou = getTalent('Camouflage');
  13047. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  13048. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  13049. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  13050. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  13051. } else if(comp.indexOf("Charger")!=-1) {
  13052. if(pvcourant<=0) {
  13053. // N'est plus censé se produire : activation obligatoire si mort
  13054. return "<i>On ne peut charger personne quand on est mort !</i>";
  13055. }
  13056. var portee = Math.min(
  13057. Math.max(
  13058. getPortee(reg+Math.floor(pvcourant/10)) -
  13059. Math.floor((fatigue+bmfatigue)/5),
  13060. 1
  13061. ),
  13062. vuetotale
  13063. );
  13064. if(portee<1) {
  13065. return "<b>Impossible de charger</b>";
  13066. }
  13067. texte = "Attaque : <b>"+att+"</b> D6 ";
  13068. if(modA) {
  13069. texte += "<i>"+aff(modA)+"D6</i> ";
  13070. }
  13071. texte += aff(attbp+attbm) +
  13072. " => <b>"+attmoytour+"</b><br>" +
  13073. "Dégâts : <b>"+deg+"</b> D3 ";
  13074. if(modD) {
  13075. texte += "<i>"+aff(modD)+"D3</i> ";
  13076. }
  13077. texte += aff(degbp+degbm) +
  13078. " => <b>"+degmoytour+"/"+degmoycrittour+"</b><br>" +
  13079. "Portée : <b>"+portee+"</b> case";
  13080. if(portee>1) { texte += "s"; }
  13081. } else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  13082. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  13083. if(vuetotale>1) texte += 's';
  13084. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  13085. if(vuetotale>2) texte += 's';
  13086. }
  13087. else if(comp.indexOf('Piege')!=-1) {
  13088. texte = 'Piège à Glue :<ul><li>Et si vous colliez vos adversaires au sol ?</li></ul>';
  13089. texte += 'Piège à Feu: <ul><li>À moins que vous ne préfériez les envoyer en l\'air !</li>';
  13090. texte += '<li>Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  13091. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b></li></ul>';
  13092. } else if(comp.indexOf("Contre-Attaquer")!=-1) {
  13093. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  13094. texte = "Attaque : <b>"+Math.floor(att/2)+"</b> D6 ";
  13095. if(modA) {
  13096. texte += "<i>"+aff(modA)+"D6</i> ";
  13097. }
  13098. texte += aff(Math.floor((attbp+attbm)/2)) +
  13099. " => <b>"+Math.round(
  13100. 3.5*(Math.floor(att/2)+modA)+Math.floor((attbp+attbm)/2)
  13101. )+"</b><br>" +
  13102. "Dégâts : <b>"+deg+"</b> D3 ";
  13103. if(modD) {
  13104. texte += "<i>"+aff(modD)+"D3</i> ";
  13105. }
  13106. texte += aff(degbp+degbm) +
  13107. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  13108. } else if(comp.indexOf("Coup de Butoir")!=-1) {
  13109. var
  13110. i, pc,
  13111. lastmax=0,
  13112. jetdeg, espdeg=0,
  13113. notMaxedOut = false;
  13114.  
  13115. texte = "Attaque : <b>"+att+"</b> D6 ";
  13116. if(modA) {
  13117. texte += "<i>"+aff(modA)+"D6</i> ";
  13118. }
  13119. texte += aff(attbp+attbm) +
  13120. " => <b>"+attmoytour+"</b>";
  13121. for(i=niveau ; i>0 ; i--) {
  13122. pc = getTalent(comp,i);
  13123. if(lastmax!=0 && pc<=lastmax) {
  13124. // Si %CdB(i)<%CdB(i+1), on passe CdB(i)
  13125. continue;
  13126. }
  13127. jetdeg = 2*(
  13128. Math.min(Math.floor(1.5*deg), deg+3*i) + modD
  13129. ) + degbp+degbm;
  13130. espdeg += (pc-lastmax)*jetdeg;
  13131. texte += "<br>Dégâts niv. "+i+" ("+(pc-lastmax)+"%) : <b>" +
  13132. Math.min(Math.floor(deg*1.5),deg+3*i)+"</b> D3 ";
  13133. if(modD) {
  13134. texte += "<i>"+aff(modD)+"D3</i> ";
  13135. }
  13136. texte += aff(degbp+degbm) +
  13137. " => <b>"+jetdeg +
  13138. "/"+(jetdeg+2*Math.floor(deg/2))+"</b>";
  13139. lastmax = pc;
  13140. if(i<niveau) {
  13141. // Si l'un des % de niveau inf est > % nivmax,
  13142. // on affiche l'espérance à la fin
  13143. notMaxedOut = true;
  13144. }
  13145. }
  13146. if(notMaxedOut) {
  13147. texte += "<br><i>Dégâts moyens (si réussite) : <b>" +
  13148. Math.floor(10*espdeg/lastmax)/10+"/" +
  13149. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2)) +
  13150. "</b></i>";
  13151. }
  13152. } else if(comp.indexOf('Course')!=-1)
  13153. texte = 'Déplacement gratuit : <b>'
  13154. +Math.floor(getTalent('Course')/2)
  13155. +' %</b> de chance';
  13156. else if(comp.indexOf('Deplacement Eclair')!=-1)
  13157. texte = 'Permet d\'économiser <b>1</b> PA '
  13158. +'par rapport au déplacement classique';
  13159. else if(comp.indexOf('Dressage')!=-1)
  13160. texte = 'Le dressage permet d\'apprivoiser un Gowap redevenu sauvage, un Mouch\'oo Sauvage '
  13161. +'ou un Gnu Sauvage. La portée est de une case.';
  13162. else if(comp.indexOf('Ecriture Magique')!=-1)
  13163. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  13164. +'la formule nécessite de réunir les composants de cette formule, '
  13165. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  13166. +'un champignon adéquat pour confectionner l\'encre.';
  13167. else if(comp.indexOf('Frenesie')!=-1) {
  13168. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  13169. +' => <b>'+attmoy+'</b><br/>'
  13170. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  13171. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  13172. }
  13173. else if(comp.indexOf('Golem')!=-1)
  13174. texte = 'Animez votre golem en assemblant divers matériaux '
  13175. +'autour d\'un cerveau minéral.'
  13176. else if(comp.indexOf('Grattage')!=-1) {
  13177. texte = 'Permet de confectionner un Parchemin Vierge '
  13178. +'à partir de composants et de Gigots de Gob\'.';
  13179. }
  13180. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  13181. texte = 'Fait fuir un monstre si tout se passe bien.'
  13182. +'<br/>Lui donne de gros bonus sinon...';
  13183. else if(comp.indexOf('Identification des Champignons')!=-1) {
  13184. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  13185. if(vuetotale>2) texte += 's';
  13186. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  13187. if(vuetotale>4) texte += 's';
  13188. }
  13189. else if(comp.indexOf('Insultes')!=-1)
  13190. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  13191. else if(comp.indexOf('interposer')!=-1)
  13192. texte = 'Jet de réflexe : <b>'
  13193. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  13194. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  13195. else if(comp.indexOf('Lancer de Potions') != -1)
  13196. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  13197. else if(comp.indexOf('Marquage')!=-1)
  13198. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  13199. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  13200. +'se trouver dans la même caverne que le monstre pour le marquer.';
  13201. else if(comp.indexOf('Melange Magique')!=-1)
  13202. texte = 'Cette Compétence permet de combiner deux Potions pour '
  13203. +'en réaliser une nouvelle dont l\'effet est la somme '
  13204. +'des effets des potions initiales.';
  13205. else if(comp.indexOf('Travail de la Pierre')!=-1)
  13206. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  13207. +2*vuetotale+'</b> cases</li>'
  13208. +'<li>Portée verticale (officieuse) : <b>'
  13209. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  13210. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  13211. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  13212. else if(comp.indexOf('Necromancie')!=-1)
  13213. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  13214. +'de faire "revivre" ce monstre.';
  13215. else if(comp.indexOf('Painthure de Guerre')!=-1)
  13216. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  13217. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  13218. +'pour s\'inspirer, et laissez parler votre créativité.'
  13219. else if(comp.indexOf("Parer")!=-1) {
  13220. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  13221. texte = "Jet de parade : <b>"+Math.floor(att/2)+"</b> D6 ";
  13222. if(modA) {
  13223. texte += "<i>"+aff(modA)+"D6</i> ";
  13224. }
  13225. texte += aff(Math.floor((attbp+attbm)/2)) +
  13226. " => <b>"+Math.round(
  13227. 3.5*(Math.floor(att/2)+modA) +
  13228. Math.floor((attbp+attbm)/2)
  13229. )+"</b><hr>Equivalent esquive : <b>" +
  13230. (Math.floor(att/2)+esq)+"</b> D6 ";
  13231. if(modA) {
  13232. texte += "<i>"+aff(modA)+"D6</i> ";
  13233. }
  13234. texte += aff(Math.floor((attbp+attbm)/2)+esqbp+esqbm) +
  13235. " => <b>"+(Math.round(
  13236. 3.5*(Math.floor(att/2)+modA+esq) +
  13237. Math.floor((attbp+attbm)/2)
  13238. )+esqbp+esqbm)+"</b></i>";
  13239. } else if(comp.indexOf('Pistage')!=-1)
  13240. texte = 'Portée horizontale : <b>'
  13241. +2*vuetotale+'</b> cases<br/>'
  13242. +'Portée verticale : <b>'
  13243. +2*Math.ceil(vuetotale/2)+'</b> cases';
  13244. else if(comp.indexOf('Planter un Champignon')!=-1)
  13245. texte = 'Planter un Champignon est une compétence qui vous permet de '
  13246. +'créer des colonies d\'une variété donnée de champignon à partir de '
  13247. +'quelques exemplaires préalablement enterrés.';
  13248. else if(comp.indexOf('Regeneration Accrue')!=-1)
  13249. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  13250. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  13251. else if(comp.indexOf('Reparation')!=-1)
  13252. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  13253. +'et réparez vous-même votre matériel !';
  13254. else if(comp.indexOf('Retraite')!=-1)
  13255. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  13256. +'préférable de préparer un repli stratégique pour déconcerter '
  13257. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  13258. +'Quelle intelligence démoniaque.';
  13259. else if(comp.indexOf("RotoBaffe")!=-1) {
  13260. var
  13261. Datt = att, vattbm = attbp+attbm,
  13262. Ddeg = deg, vdegbm = degbp+degbm;
  13263. for(var i=1 ; i<niveau+2 ; i++) {
  13264. texte += "<b>Attaque n°"+i+" :</b><br>" +
  13265. "Attaque : <b>"+Datt+"</b> D6 ";
  13266. if(modA) {
  13267. texte += "<i>"+aff(modA)+"D6</i> ";
  13268. }
  13269. texte += aff(vattbm) +
  13270. " => <b>"+(Math.round(3.5*(Datt+modA))+vattbm)+"</b><br>" +
  13271. "Dégâts : <b>"+Ddeg+"</b> D3 ";
  13272. if(modD) {
  13273. texte += "<i>"+aff(modD)+"D3</i> ";
  13274. }
  13275. texte += aff(vdegbm) +
  13276. " => <b>"+(2*(Ddeg+modD)+vdegbm) +
  13277. "/"+(2*(Math.floor(1.5*Ddeg)+modD)+vdegbm)+"</b>";
  13278. Datt = Math.floor(0.75*Datt);
  13279. modA = atttour?Math.floor((Datt+atttourD)*atttour/100):0;
  13280. vattbm = Math.floor(0.75*vattbm);
  13281. Ddeg = Math.floor(0.75*Ddeg);
  13282. modD = degtour?Math.floor(Ddeg*degtour/100):0;
  13283. vdegbm = Math.floor(0.75*vdegbm);
  13284. if(i<niveau+1) { texte += "<hr>"; }
  13285. }
  13286. } else if(comp.indexOf('Shamaner')!=-1)
  13287. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  13288. +'des monstres en utilisant des champignons (de 1 à 3).';
  13289. return texte;
  13290. }
  13291.  
  13292. function sortileges(sort) {
  13293. var
  13294. // Fonctions utiles uniquement à "sortileges"
  13295. decumul_buff = function(nom,str,buff) {
  13296. // Décumul des sorts de buff (old school)
  13297. var
  13298. txt = "1<sup>ere</sup>"+nom+" : <b>"+str+" +"+buff+"</b>",
  13299. dec = buff,
  13300. total = buff,
  13301. i=1;
  13302. while(i<6) {
  13303. i++;
  13304. dec = Math.floor(coefDecumul(i)*buff);
  13305. if(dec<=1 || i==6) break;
  13306. total += dec;
  13307. txt += "<br/><i>"+i+"<sup>e</sup> "+nom+" : "+
  13308. str+" +"+dec+" (+"+total+")</i>";
  13309. }
  13310. txt += "<br/><i>"+i+"<sup>e</sup> et + : "+str+" +"+dec+"</i>";
  13311. return txt;
  13312. },
  13313. nbrAdX = function(pc) {
  13314. // Détermine le nombre d'AdX actifs à partir du % de D
  13315. switch(Number(pc)) {
  13316. case 0 : return 0;
  13317. case 20: return 1;
  13318. case 33: return 2;
  13319. case 41: return 3;
  13320. case 46: return 4;
  13321. default: return Math.floor((Number(pc)-39)/2);
  13322. }
  13323. },
  13324. decumulPc = function(n) {
  13325. // Détermine le % de D décumulé du n-ième AdX
  13326. switch(Number(n)) {
  13327. case 0: return 0;
  13328. case 1: return 20;
  13329. case 2: return 13;
  13330. case 3: return 8;
  13331. case 4: return 5;
  13332. case 5: return 3;
  13333. default: return 2;
  13334. }
  13335. },
  13336. decumulFixe = function(bm, n) {
  13337. // Détermine le bonus fixe décumulé du n-ième AdX
  13338. switch(Number(n)) {
  13339. case 0: return 0;
  13340. case 1: return Math.max(1,bm);
  13341. case 2: return Math.max(1,Math.round(bm*6.7)/10);
  13342. case 3: return Math.max(1,Math.round(bm*4)/10);
  13343. default: return 1; // Sous les 1 de moyenne même en D6
  13344. }
  13345. },
  13346. texte = "";
  13347.  
  13348. if (sort.indexOf('Analyse Anatomique') != -1) {
  13349. texte = 'Portée horizontale : <b>'
  13350. + Math.floor(vuetotale / 2) + '</b> case';
  13351. if (vuetotale > 3){ texte += 's'; }
  13352. texte += '<br/>Portée verticale : <b>'
  13353. + Math.floor((vuetotale+1)/4)+'</b> case';
  13354. if (vuetotale > 7){ texte += 's'; }
  13355. } else if (sort.indexOf('Armure Etheree') != -1) {
  13356. texte = decumul_buff('AE', 'Armure magique', reg);
  13357. } else if (sort.indexOf("Augmentation")!=-1 && sort.indexOf("Attaque")!=-1) {
  13358. var
  13359. categoriesAdA = {
  13360. "attx1": {
  13361. // Affichage: code MZ (cf arrayTalents)
  13362. "AN": true,
  13363. "AP": "AP1",
  13364. "Balayage": "Balayage",
  13365. "Charge": "Charger",
  13366. "CdB": "CdB1",
  13367. "Frénésie": "Frenesie",
  13368. "RB": "RB1",
  13369. "GdS": "GdS",
  13370. "Siphon": "Siphon"
  13371. },
  13372. "attx2/3": {
  13373. "Botte Secrète": "BS"
  13374. },
  13375. "attx1/2": {
  13376. "CA": "CA",
  13377. "Parer": "Parer1"
  13378. },
  13379. "degx2/3": {
  13380. "Vampirisme": "Vampi"
  13381. },
  13382. "vuex1": {
  13383. "Projectile Magique": "Projo"
  13384. }
  13385. },
  13386. baseAdA = {
  13387. "attx1" : att,
  13388. "attx2/3": Math.floor(2*att/3),
  13389. "attx1/2": Math.floor(att/2),
  13390. "degx2/3": Math.floor(2*deg/3),
  13391. "vuex1" : vue
  13392. },
  13393. pc = atttour,
  13394. pcInit = pc,
  13395. nbrAdA = nbrAdX(pc),
  13396. categorie, talent, newTalent,
  13397. i, DSup, fixe=0;
  13398.  
  13399. i=nbrAdA;
  13400. while(i++<nbrAdA+3) {
  13401. pc += decumulPc(i);
  13402. fixe += decumulFixe(3.5,i);
  13403. if(texte) { texte += "<hr>"; }
  13404. texte += "<b>"+i+"<sup>e</sup> AdA : " +
  13405. aff(pc)+"% de Dés d'attaque :</b><br>";
  13406. for(categorie in categoriesAdA) {
  13407. // On génére la liste: "talent1, talent2"
  13408. DSup = Math.floor(baseAdA[categorie]*pc/100) -
  13409. Math.floor(baseAdA[categorie]*pcInit/100);
  13410. newTalent = false;
  13411. for(var talent in categoriesAdA[categorie]) {
  13412. if(getTalent(categoriesAdA[categorie][talent])) {
  13413. if(newTalent) { texte += ", "; }
  13414. texte += talent;
  13415. newTalent = true;
  13416. }
  13417. }
  13418. if(newTalent) {
  13419. // Si le trõll a au moins un talent dans la catégorie :
  13420. texte += ": <b>+"+DSup+"D6 +"+Math.floor(fixe)+"</b> <i>(+" +
  13421. Math.floor(3.5*DSup+fixe) +")</i><br>";
  13422. }
  13423. }
  13424. }
  13425. } else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1) {
  13426. texte = decumul_buff('AdE', 'Esquive', Math.floor((esq-1)/2));
  13427. } else if (sort.indexOf("Augmentation des Degats")!=-1) {
  13428. var
  13429. categoriesAdD = {
  13430. "attx1/2": {
  13431. "Botte Secrète": "BS"
  13432. },
  13433. "degx1": {
  13434. "AN": true,
  13435. "AP": "AP1",
  13436. "Charge": "Charger",
  13437. "CA": "CA",
  13438. "CdB": "CdB1",
  13439. "Frénésie": "Frenesie",
  13440. "RB": "RB1",
  13441. "Rafale": "Rafale",
  13442. "Vampi": "Vampi"
  13443. },
  13444. "degx1/2": {
  13445. "Griffe du Sorcier": "GdS"
  13446. },
  13447. "vuex1/2": {
  13448. "Projectile Magique": "Projo"
  13449. },
  13450. "regx1": {
  13451. "Siphon des Âmes": "Siphon"
  13452. }
  13453. },
  13454. baseAdD = {
  13455. "attx1/2": Math.floor(att/2),
  13456. "degx1" : deg,
  13457. "degx1/2": Math.floor(deg/2),
  13458. "vuex1/2": Math.floor(vue/2),
  13459. "regx1" : reg
  13460. },
  13461. pc = degtour,
  13462. pcInit = pc,
  13463. nbrAdD = nbrAdX(pc),
  13464. categorie, talent, newTalent,
  13465. i, DSup, fixe=0;
  13466.  
  13467. i=nbrAdD;
  13468. while(i++<nbrAdD+3) {
  13469. pc += decumulPc(i);
  13470. fixe += decumulFixe(2,i);
  13471. if(texte) { texte += "<hr>"; }
  13472. texte += "<b>"+i+"<sup>e</sup> AdD : " +
  13473. aff(pc)+"% de Dés de dégâts :</b><br>";
  13474. for(categorie in categoriesAdD) {
  13475. // On génére la liste: "talent1, talent2"
  13476. DSup = Math.floor(baseAdD[categorie]*pc/100) -
  13477. Math.floor(baseAdD[categorie]*pcInit/100);
  13478. newTalent = false;
  13479. for(var talent in categoriesAdD[categorie]) {
  13480. if(getTalent(categoriesAdD[categorie][talent])) {
  13481. if(newTalent) { texte += ", "; }
  13482. texte += talent;
  13483. newTalent = true;
  13484. }
  13485. }
  13486. if(newTalent) {
  13487. // Si le trõll a au moins un talent dans la catégorie :
  13488. texte += ": <b>+"+DSup+"D3 +"+Math.floor(fixe) +
  13489. "</b> <i>(+"+Math.floor(2*DSup+fixe) +
  13490. ")</i><br>";
  13491. }
  13492. }
  13493. }
  13494. } else if(sort.indexOf('Bulle Anti-Magie')!=-1) {
  13495. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  13496. }
  13497. else if(sort.indexOf('Bulle Magique')!=-1){
  13498. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  13499. }
  13500. else if(sort.indexOf('Explosion')!=-1){
  13501. texte = 'Dégâts : <b>'
  13502. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  13503. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  13504. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  13505. }
  13506. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  13507. if(pvcourant<=0)
  13508. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  13509. texte = 'Portée horizontale : <b>'
  13510. +Math.min(1,vuetotale)+'</b> case<br/>'
  13511. +'Dégâts physiques : <b>-'
  13512. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  13513. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  13514. +'Dégâts magiques : <b>-'
  13515. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  13516. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  13517. }
  13518. else if(sort.indexOf('Flash Aveuglant')!=-1){
  13519. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  13520. }
  13521. else if(sort.indexOf('Glue')!=-1) {
  13522. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  13523. if(vuetotale>2) texte += 's';
  13524. } else if(sort.indexOf("Griffe du Sorcier")!=-1) {
  13525. var
  13526. modD =0,
  13527. addVenin = function(type, effet, duree) {
  13528. var
  13529. ret = "<b>Venin "+type+" : </b><br/><b>" +
  13530. effet+"</b> D3" +
  13531. " pendant <b>"+duree+"</b> tour",
  13532. dureeReduite = Math.max(Math.floor(duree/2),1);
  13533. if(duree>1) {
  13534. ret += "s";
  13535. }
  13536. return ret +
  13537. " => <b>"+2*effet+" x "+duree+" = "+2*effet*duree +
  13538. "</b> ("+2*effet+" x "+dureeReduite+" = " +
  13539. 2*effet*dureeReduite+")";
  13540. },
  13541. effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  13542. // Frappe
  13543. texte = "Attaque : <b>"+att+"</b> D6 ";
  13544. if(atttour!=0) {
  13545. modD = Math.floor(att*atttour/100);
  13546. texte += "<i>"+aff(modD)+"D6</i> ";
  13547. }
  13548. texte += aff(attbm)
  13549. +" => <b>"+(Math.round(3.5*(att+modD))+attbm)+"</b><br/>"
  13550. +"Dégâts : <b>"+Math.floor(deg/2)+"</b> D3 ";
  13551. if(degtour!=0) {
  13552. modD = Math.floor(Math.floor(deg/2)*degtour/100);
  13553. texte += "<i>"+aff(modD)+"D3</i> ";
  13554. } else {
  13555. modD = 0;
  13556. }
  13557. texte += aff(degbm) +
  13558. " => <b>"+(2*(Math.floor(deg/2)+modD)+degbm) +
  13559. "/"+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm) +
  13560. " ("+resiste(Math.floor(deg/2)+modD,degbm) +
  13561. "/"+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm) +
  13562. ")</b>";
  13563. // Venins
  13564. texte += "<hr>"+addVenin("insidieux",effet,2+Math.floor(vue/5));
  13565. effet = Math.floor(1.5*effet);
  13566. texte += "<hr>"+addVenin("virulent",effet,1+Math.floor(vue/10));
  13567. } else if(sort.indexOf('Hypnotisme')!=-1)
  13568. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  13569. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  13570. else if(sort.indexOf('Identification des Tresors')!=-1)
  13571. texte = 'Permet de connaitre les caractéristiques et effets précis '
  13572. +'d\'un trésor.';
  13573. else if(sort.indexOf('Invisibilite')!=-1)
  13574. texte = 'Un troll invisible est indétectable même quand on se trouve '
  13575. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  13576. +'fait disparaître l\'invisibilité.';
  13577. else if(sort.indexOf('Levitation')!=-1)
  13578. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  13579. +'Comme les pièges ou les trous par exemple...';
  13580. else if(sort.indexOf("Projectile Magique")!=-1) {
  13581. var
  13582. modD = 0,
  13583. portee = getPortee(vuetotale);
  13584. // Att
  13585. texte = "Attaque : <b>"+vue+"</b> D6 ";
  13586. if(atttour!=0) {
  13587. modD = Math.floor(vue*atttour/100);
  13588. texte += "<i>"+aff(modD)+"D6</i> ";
  13589. }
  13590. texte += aff(attbm) +
  13591. " => <b>"+(Math.round(3.5*(vue+modD))+attbm)+"</b><br>" +
  13592. "Dégâts : <b>"+Math.floor(vue/2)+"</b> D3 ";
  13593. // Deg
  13594. if(degtour!=0) {
  13595. modD = Math.floor(Math.floor(vue/2)*degtour/100);
  13596. texte += "<i>"+aff(modD)+"D3</i> ";
  13597. } else {
  13598. modD = 0;
  13599. }
  13600. texte += aff(degbm) +
  13601. " => <b>"+(2*(Math.floor(vue/2)+modD)+degbm) +
  13602. "/"+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm) +
  13603. " ("+resiste(Math.floor(vue/2)+modD,degbm) +
  13604. "/"+resiste(1.5*Math.floor(vue/2)+modD,degbm) +
  13605. ") (+ 1D3 par bonus de portée)</b>";
  13606. // Portée
  13607. texte += "<br/>Portée : <b>"+portee+"</b> case";
  13608. if(portee>1) texte += "s";
  13609. } else if(sort.indexOf('Projection')!=-1) {
  13610. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  13611. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  13612. +'Si le jet de résistance de la victime est réussi:<br/>'
  13613. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  13614. } else if(sort.indexOf("Rafale Psychique")!=-1) {
  13615. var modD = 0;
  13616. texte = "Dégâts : <b>"+deg+"</b> D3 ";
  13617. if(degtour!=0) {
  13618. modD = Math.floor(deg*degtour/100);
  13619. texte += "<i>"+aff(modD)+"D3</i> ";
  13620. }
  13621. texte += aff(degbm) +
  13622. " => <b>"+(2*(deg+modD)+degbm) +
  13623. " ("+resiste(deg+modD,degbm)+")</b><br>" +
  13624. "Malus : régénération <b>-"+(deg+modD)+"</b>";
  13625. } else if(sort.indexOf("Sacrifice")!=-1) {
  13626. if(pvcourant<=0) {
  13627. // N'est plus censé se produire : activation obligatoire si mort
  13628. return "<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>";
  13629. }
  13630. var
  13631. perteSacro = function(sac) {
  13632. return " (-"+(sac+2*(1+Math.floor(sac/5)))+" PV)";
  13633. },
  13634. sac = Math.floor((pvcourant-1)/2),
  13635. pvdispoSansMalusTemps =
  13636. pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  13637.  
  13638. texte = "Portée horizontale : <b>" +
  13639. Math.min(1,vuetotale)+"</b> case<br>" +
  13640. "Soin maximal : <b>"+sac+"</b> PV"+perteSacro(sac);
  13641. // Sacros max et optimal sans malus (propale R')
  13642. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  13643. if(sac>0) {
  13644. texte += "<hr>Soin maximum limitant les risques de malus " +
  13645. "de temps : <b>" +sac+"</b> PV"+perteSacro(sac);
  13646. } else {
  13647. texte += "<hr>Vous ne pouvez pas compenser de blessures " +
  13648. "dues à un sacrifice";
  13649. }
  13650. } else if(sort.indexOf("Siphon")!=-1) {
  13651. var modD = 0;
  13652. texte = "Attaque : <b>"+att+"</b> D6 ";
  13653. if(atttour!=0) {
  13654. modD = Math.floor(att*atttour/100);
  13655. texte += "<i>"+aff(modD)+"D6</i> ";
  13656. }
  13657. texte += aff(attbm) +
  13658. " => <b>"+Math.round(3.5*(att+modD)+attbm)+"</b><br>" +
  13659. "Dégâts : <b>"+reg+"</b> D3 ";
  13660. if(degtour!=0) {
  13661. modD = Math.floor(reg*degtour/100);
  13662. texte += "<i>"+aff(modD)+"D3</i> ";
  13663. } else {
  13664. modD = 0;
  13665. }
  13666. texte += aff(degbm) +
  13667. " => <b>"+(2*(reg+modD)+degbm) +
  13668. "/" + (2*(Math.floor(1.5*reg)+modD)+degbm) +
  13669. " ("+resiste(reg+modD,degbm) +
  13670. "/"+resiste(1.5*reg+modD,degbm)+")</b>";
  13671. texte += "<br>Nécrose : attaque magique <b>-"+(reg+modD)+"</b>";
  13672. } else if(sort.indexOf('Telekinesie')!=-1) {
  13673. texte = 'Portée horizontale :';
  13674. var vt = Math.floor(vuetotale/2)+2;
  13675. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  13676. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  13677. for(var i=0 ; i<5 ; i++) {
  13678. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  13679. if(vt>1) texte += 's';
  13680. vt=Math.max(0,vt-1);
  13681. }
  13682. }
  13683. else if(sort.indexOf('Teleportation')!=-1) {
  13684. var portee = getPortee(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  13685. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  13686. var pmh = (20+vue+portee);
  13687. var pmv = 3+Math.floor(portee/3);
  13688. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  13689. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  13690. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  13691. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  13692. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  13693. } else if(sort.indexOf('Vampirisme')!=-1) {
  13694. var modD = 0;
  13695. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  13696. if(atttour!=0) {
  13697. modD = Math.floor(Math.floor(2*deg/3)*atttour/100);
  13698. texte += '<i>'+aff(modD)+'D6</i> ';
  13699. }
  13700. texte += aff(attbm) +
  13701. ' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm) +
  13702. '</b><br/>Dégâts : <b>'+deg+'</b> D3 ';
  13703. if(degtour!=0) {
  13704. modD = Math.floor(deg*degtour/100);
  13705. texte += '<i>'+aff(modD)+'D3</i> ';
  13706. } else {
  13707. modD = 0;
  13708. }
  13709. texte += aff(degbm) +
  13710. ' => <b>'+(2*(deg+modD)+degbm) +
  13711. '/'+(2*(Math.floor(1.5*deg)+modD)+degbm) +
  13712. ' ('+resiste(deg+modD,degbm) +
  13713. '/'+resiste(1.5*deg+modD,degbm)+')</b>';
  13714. } else if(sort.indexOf('Vision Accrue')!=-1)
  13715. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  13716. else if(sort.indexOf('Vision lointaine')!=-1)
  13717. texte = 'En ciblant une zone située n\'importe où dans le '
  13718. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  13719. else if(sort.indexOf('Voir le Cache')!=-1)
  13720. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  13721. +Math.min(5,getPortee(vue))+'</b> cases<hr>'
  13722. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  13723. +getPortee(vuetotale)+'</b> cases';
  13724. else if(sort.indexOf('Vue Troublee')!=-1)
  13725. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  13726. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  13727. return texte;
  13728. }
  13729.  
  13730.  
  13731. /*---------------------------------- Main ------------------------------------*/
  13732.  
  13733. function do_profil2()
  13734. {
  13735. try {
  13736. start_script(31);
  13737.  
  13738. extractionDonnees();
  13739. setInfosCaracteristiques();
  13740. setInfoDescription();
  13741. setInfosEtatLieux();
  13742. setInfosEtatPV();
  13743. setInfosExp();
  13744.  
  13745. creerBulleVide();
  13746. traitementTalents();
  13747. setLienAnatrolliseur();
  13748.  
  13749. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  13750. if(race=='Kastar'){ setAccel(); }
  13751. saveProfil();
  13752. displayScriptTime();
  13753. } catch(e) {
  13754. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.<br>" + traceStack(e, 'profil2').replace("\n", "<br>"), 1000000, true);
  13755. window.console.error(traceStack(e, 'profil2'));
  13756. }
  13757. }
  13758.  
  13759. /*******************************************************************************
  13760. * This file is part of Mountyzilla. *
  13761. * *
  13762. * Mountyzilla is free software; you can redistribute it and/or modify *
  13763. * it under the terms of the GNU General Public License as published by *
  13764. * the Free Software Foundation; either version 2 of the License, or *
  13765. * (at your option) any later version. *
  13766. * *
  13767. * Mountyzilla is distributed in the hope that it will be useful, *
  13768. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13769. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13770. * GNU General Public License for more details. *
  13771. * *
  13772. * You should have received a copy of the GNU General Public License *
  13773. * along with Mountyzilla; if not, write to the Free Software *
  13774. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  13775. *******************************************************************************/
  13776.  
  13777. // x~x script_principal
  13778.  
  13779. // x~x md5.js
  13780. /*
  13781. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  13782. * Digest Algorithm, as defined in RFC 1321.
  13783. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  13784. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  13785. * Distributed under the BSD License
  13786. * See http://pajhome.org.uk/crypt/md5 for more info.
  13787. */
  13788.  
  13789. /*
  13790. * Configurable variables. You may need to tweak these to be compatible with
  13791. * the server-side, but the defaults work in most cases.
  13792. */
  13793. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  13794. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  13795. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  13796.  
  13797. /*
  13798. * These are the functions you'll usually want to call
  13799. * They take string arguments and return either hex or base-64 encoded strings
  13800. */
  13801. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  13802. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  13803. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  13804. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  13805. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  13806. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  13807.  
  13808. /*
  13809. * Perform a simple self-test to see if the VM is working
  13810. */
  13811. function md5_vm_test()
  13812. {
  13813. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  13814. }
  13815.  
  13816. /*
  13817. * Calculate the MD5 of an array of little-endian words, and a bit length
  13818. */
  13819. function core_md5(x, len)
  13820. {
  13821. /* append padding */
  13822. x[len >> 5] |= 0x80 << ((len) % 32);
  13823. x[(((len + 64) >>> 9) << 4) + 14] = len;
  13824.  
  13825. var a = 1732584193;
  13826. var b = -271733879;
  13827. var c = -1732584194;
  13828. var d = 271733878;
  13829.  
  13830. for(var i = 0; i < x.length; i += 16)
  13831. {
  13832. var olda = a;
  13833. var oldb = b;
  13834. var oldc = c;
  13835. var oldd = d;
  13836.  
  13837. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  13838. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  13839. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  13840. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  13841. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  13842. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  13843. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  13844. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  13845. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  13846. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  13847. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  13848. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  13849. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  13850. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  13851. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  13852. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  13853.  
  13854. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  13855. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  13856. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  13857. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  13858. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  13859. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  13860. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  13861. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  13862. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  13863. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  13864. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  13865. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  13866. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  13867. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  13868. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  13869. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  13870.  
  13871. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  13872. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  13873. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  13874. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  13875. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  13876. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  13877. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  13878. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  13879. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  13880. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  13881. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  13882. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  13883. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  13884. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  13885. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  13886. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  13887.  
  13888. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  13889. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  13890. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  13891. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  13892. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  13893. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  13894. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  13895. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  13896. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  13897. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  13898. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  13899. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  13900. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  13901. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  13902. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  13903. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  13904.  
  13905. a = safe_add(a, olda);
  13906. b = safe_add(b, oldb);
  13907. c = safe_add(c, oldc);
  13908. d = safe_add(d, oldd);
  13909. }
  13910. return Array(a, b, c, d);
  13911.  
  13912. }
  13913.  
  13914. /*
  13915. * These functions implement the four basic operations the algorithm uses.
  13916. */
  13917. function md5_cmn(q, a, b, x, s, t)
  13918. {
  13919. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  13920. }
  13921. function md5_ff(a, b, c, d, x, s, t)
  13922. {
  13923. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  13924. }
  13925. function md5_gg(a, b, c, d, x, s, t)
  13926. {
  13927. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  13928. }
  13929. function md5_hh(a, b, c, d, x, s, t)
  13930. {
  13931. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  13932. }
  13933. function md5_ii(a, b, c, d, x, s, t)
  13934. {
  13935. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  13936. }
  13937.  
  13938. /*
  13939. * Calculate the HMAC-MD5, of a key and some data
  13940. */
  13941. function core_hmac_md5(key, data)
  13942. {
  13943. var bkey = str2binl(key);
  13944. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  13945.  
  13946. var ipad = Array(16), opad = Array(16);
  13947. for(var i = 0; i < 16; i++)
  13948. {
  13949. ipad[i] = bkey[i] ^ 0x36363636;
  13950. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  13951. }
  13952.  
  13953. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  13954. return core_md5(opad.concat(hash), 512 + 128);
  13955. }
  13956.  
  13957. /*
  13958. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  13959. * to work around bugs in some JS interpreters.
  13960. */
  13961. function safe_add(x, y)
  13962. {
  13963. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  13964. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  13965. return (msw << 16) | (lsw & 0xFFFF);
  13966. }
  13967.  
  13968. /*
  13969. * Bitwise rotate a 32-bit number to the left.
  13970. */
  13971. function bit_rol(num, cnt)
  13972. {
  13973. return (num << cnt) | (num >>> (32 - cnt));
  13974. }
  13975.  
  13976. /*
  13977. * Convert a string to an array of little-endian words
  13978. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  13979. */
  13980. function str2binl(str)
  13981. {
  13982. var bin = Array();
  13983. var mask = (1 << chrsz) - 1;
  13984. for(var i = 0; i < str.length * chrsz; i += chrsz)
  13985. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  13986. return bin;
  13987. }
  13988.  
  13989. /*
  13990. * Convert an array of little-endian words to a string
  13991. */
  13992. function binl2str(bin)
  13993. {
  13994. var str = "";
  13995. var mask = (1 << chrsz) - 1;
  13996. for(var i = 0; i < bin.length * 32; i += chrsz)
  13997. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  13998. return str;
  13999. }
  14000.  
  14001. /*
  14002. * Convert an array of little-endian words to a hex string.
  14003. */
  14004. function binl2hex(binarray)
  14005. {
  14006. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  14007. var str = "";
  14008. for(var i = 0; i < binarray.length * 4; i++)
  14009. {
  14010. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  14011. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  14012. }
  14013. return str;
  14014. }
  14015.  
  14016. /*
  14017. * Convert an array of little-endian words to a base-64 string
  14018. */
  14019. function binl2b64(binarray)
  14020. {
  14021. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  14022. var str = "";
  14023. for(var i = 0; i < binarray.length * 4; i += 3)
  14024. {
  14025. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  14026. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  14027. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  14028. for(var j = 0; j < 4; j++)
  14029. {
  14030. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  14031. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  14032. }
  14033. }
  14034. return str;
  14035. }
  14036.  
  14037. ///////////////////////////////////////////
  14038. // debug cartes capitan Roule 07/12/2016
  14039. ///////////////////////////////////
  14040. // essais : objet
  14041. // .mode : description
  14042. // .essais : tableau d'objets essai
  14043. // .mode : description
  14044. // .essais : tableau de cartes
  14045. // .noCarte : id de la carte
  14046. // .essais : tableau d'essais, [x, y, n, nb]
  14047. function AfficheEssais(essais, sMode) {
  14048. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  14049. if (!eBigDiv) {
  14050. var insertPoint = document.getElementById('footer1');
  14051. eBigDiv = document.createElement('table');
  14052. eBigDiv.id = 'ListeEssaiCapitan';
  14053. insertBefore(insertPoint, document.createElement('p'));
  14054. insertTitle(insertPoint,'Capitan : Liste des essais');
  14055. insertBefore(insertPoint, eBigDiv);
  14056. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  14057. }
  14058. if (!essais) {
  14059. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  14060. return;
  14061. }
  14062. var carte;
  14063. for (carte in essais) {
  14064. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  14065. }
  14066. if (carte === undefined) {
  14067. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  14068. }
  14069. }
  14070.  
  14071. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  14072. var tr = appendTr(eTable);
  14073. var td = appendTd(tr);
  14074. appendText(td, sMode, bBold);
  14075. td = appendTd(tr);
  14076. appendText(td, sCarte, bBold);
  14077. td = appendTd(tr);
  14078. appendText(td, sText, bBold);
  14079. }
  14080.  
  14081. function getEssaiV1_0() {
  14082. try {
  14083. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  14084. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  14085. var tabK, nK;
  14086. prefs.getChildList('', nK, tabK);
  14087. window.console.log('getEssaiV1_0, nb key : ' + nK);
  14088. //window.console.log('getEssaiV1_0, ' + nK);
  14089. return;
  14090. //return r;
  14091. } catch (e) {
  14092. window.console.log(traceStack(e, 'getEssaiV1_0'));
  14093. }
  14094. }
  14095.  
  14096. function getEssaiV1_1() {
  14097. var locSto = window.localStorage;
  14098. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  14099. var r = [];
  14100. for (var i = 0; i < locSto.length; i++) {
  14101. var k = locSto.key(i);
  14102. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  14103. var t = k.split(/\./);
  14104. if (t[0] !== 'capitan') continue;
  14105. if (t[2] !== 'essai') continue;
  14106. var carte = 'carte n°' + t[1];
  14107. if (r[carte]) r[carte]++;
  14108. else r[carte] = 1;
  14109. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  14110. }
  14111. return r;
  14112. }
  14113.  
  14114. function showEssaiCartes() {
  14115. window.console.log('début showEssai Tout_MZ');
  14116. var essais = getEssaiV1_0();
  14117. AfficheEssais(essais, 'V1.0');
  14118. essais = getEssaiV1_1();
  14119. AfficheEssais(essais, 'V1.1');
  14120. window.console.log('fin showEssai Tout_MZ');
  14121. }
  14122.  
  14123. function testBoolLocalStorage() {
  14124. var b = true;
  14125. var key = 'MZ_essai_bool';
  14126. GM_setValue(key, b);
  14127. window.localStorage[key] = b;
  14128. var v = GM_getValue(key);
  14129. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  14130. var v = window.localStorage.getItem(key);
  14131. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  14132.  
  14133. var b = false;
  14134. GM_setValue(key, b);
  14135. window.localStorage[key] = b;
  14136. var v = GM_getValue(key);
  14137. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  14138. var v = window.localStorage.getItem(key);
  14139. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  14140.  
  14141. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  14142. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  14143. var y = GM_getValue('654654897894654654');
  14144. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  14145. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  14146. }
  14147.  
  14148. /*--------------------------------- Création liste trolligion ---------------------------------*/
  14149. function export_trolligion() {
  14150. try {
  14151. var tabDl = document.getElementsByTagName('dl');
  14152. if ((!tabDl) || !tabDl[0]) {
  14153. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  14154. return;
  14155. }
  14156. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  14157. // nom : string
  14158. // rayonnement : entier
  14159. // grades : table d'objets (une occurence par grade)
  14160. // nom : string
  14161. // trolls : table d'objets (un par Trõll)
  14162. // id
  14163. // nom
  14164. // idguilde
  14165. // guilde
  14166. // race
  14167. // niveau
  14168. // ferveur
  14169. var currentDieu;
  14170. var currentGrade;
  14171. for (var iChild1 in tabDl[0].children) {
  14172. var eChild1 = tabDl[0].children[iChild1];
  14173. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  14174. case 'dd': // Trõll
  14175. var oTroll = {};
  14176. export_trolligion_analyse(oTroll, eChild1);
  14177. currentGrade.trolls.push(oTroll);
  14178. break;
  14179. case 'dt':
  14180. var tabH3 = eChild1.getElementsByTagName('h3');
  14181. if (tabH3 && tabH3[0]) { // changement de dieu
  14182. currentDieu = {
  14183. nom: tabH3[0].innerText || tabH3[0].textContent
  14184. , grades: []};
  14185. var txt = eChild1.innerText || eChild1.textContent;
  14186. var m = txt.match(/yon*ement *:* *(\d+)/);
  14187. if (m) currentDieu.rayonnement = parseInt(m[1]);
  14188. currentGrade = undefined;
  14189. tabDieux.push(currentDieu);
  14190. break;
  14191. }
  14192. var tabH4 = eChild1.getElementsByTagName('h4');
  14193. if (tabH4 && tabH4[0]) { // changement de grade
  14194. var grade;
  14195. var txt = tabH4[0].innerText || tabH4[0].textContent;
  14196. tabI = tabH4[0].getElementsByTagName('i');
  14197. if (tabI && tabI[0]) {
  14198. grade = tabI[0].innerText || tabI[0].textContent;
  14199. grade = grade.replace(/"/g, '');
  14200. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  14201. if (m) grade += ' (' + m[1] + ')';
  14202. } else {
  14203. grade = txt.replace(/"/g, '');
  14204. }
  14205. currentGrade = {nom: grade, trolls: []};
  14206. currentDieu.grades.push(currentGrade);
  14207. break;
  14208. }
  14209. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  14210. break;
  14211. default:
  14212. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  14213. }
  14214. }
  14215.  
  14216. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  14217. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  14218. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  14219. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  14220. for (var iDieu in tabDieux) {
  14221. var oDieu = tabDieux[iDieu];
  14222. for (var iGrade in oDieu.grades) {
  14223. var oGrade = oDieu.grades[iGrade];
  14224. for (var iTroll in oGrade.trolls) {
  14225. var oTroll = oGrade.trolls[iTroll];
  14226. var t = [oDieu.nom, oDieu.rayonnement
  14227. , oGrade.nom
  14228. , oTroll.id, oTroll.nom
  14229. , oTroll.idguilde, oTroll.guilde
  14230. , oTroll.race, oTroll.niveau
  14231. , oTroll.ferveur];
  14232. for (var iParam in t) {
  14233. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14234. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14235. }
  14236. txt += t.join("\t") + "\n";
  14237. }
  14238. }
  14239. var t = [oDieu.nom, oDieu.rayonnement];
  14240. for (var iParam in t) {
  14241. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14242. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14243. }
  14244. txt2 += t.join("\t") + "\n";
  14245. }
  14246. txt += "\n" + txt2;
  14247. } catch (e) {
  14248. window.alert("Échec à l'extraction\n" + e);
  14249. }
  14250. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  14251. try {
  14252. if (copyTextToClipboard(txt)) {
  14253. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  14254. + "Collez dans Calc\n"
  14255. + "ou, au pire, dans EXCEL®");
  14256. } else {
  14257. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  14258. }
  14259. } catch(e) {
  14260. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  14261. }
  14262. }
  14263.  
  14264. function export_trolligion_analyse(oTroll, eChild1) {
  14265. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  14266. var eChild2 = eChild1.childNodes[iChild2];
  14267. if (eChild2.nodeType === undefined) continue; // properties
  14268. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  14269. switch (eChild2.nodeType) {
  14270. case 1: //ELEMENT_NODE:
  14271. switch (eChild2.nodeName.toLowerCase()) {
  14272. case 'a':
  14273. var m;
  14274. if (!eChild2.href) {
  14275. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  14276. break;
  14277. }
  14278. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  14279. if (m) {
  14280. oTroll.id = parseInt(m[1]);
  14281. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  14282. break;
  14283. }
  14284. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  14285. if (m) {
  14286. var idGuilde = parseInt(m[1]);
  14287. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  14288. oTroll.idguilde = parseInt(m[1]);
  14289. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  14290. }
  14291. break;
  14292. }
  14293. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  14294. break;
  14295. case 'br': // ignore
  14296. case 'style': // ignore
  14297. case 'img': // ignore
  14298. break;
  14299. case 'div': // barre de vie
  14300. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  14301. eChild3 = eChild2.children[0];
  14302. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  14303. var eChild4 = eChild3.children[0];
  14304. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  14305. break;
  14306. }
  14307. }
  14308. //window.console.log(eChild2.innerHTML);
  14309. export_trolligion_analyse(oTroll, eChild2);
  14310. break;
  14311. default:
  14312. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  14313. break;
  14314. }
  14315. break;
  14316. case 3: //TEXT_NODE:
  14317. var txt = eChild2.nodeValue.trim();
  14318. if (txt === '') break;
  14319. var m = txt.match(/(.*) *\((\d+)\)/);
  14320. if (m) {
  14321. oTroll.race = m[1].trim();
  14322. oTroll.niveau = parseInt(m[2]);
  14323. } else {
  14324. oTroll.race = txt;
  14325. }
  14326. break;
  14327. default: // ne devrait pas arriver
  14328. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  14329. break;
  14330. }
  14331. }
  14332. }
  14333.  
  14334. function do_trolligion() {
  14335. var divpopup = document.createElement('div');
  14336. divpopup.id = 'MZ_divCopier';
  14337. divpopup.style.position = 'fixed';
  14338. divpopup.style.top = '2px';
  14339. divpopup.style.left = '2px;';
  14340. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  14341. divpopup.style.cursor = 'pointer';
  14342. divpopup.style.zIndex = 200;
  14343. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  14344. divpopup.onclick = export_trolligion;
  14345. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  14346. divpopup.appendChild(img);
  14347. document.body.appendChild(divpopup);
  14348. }
  14349.  
  14350. /*--------------------------------- Dispatch ---------------------------------*/
  14351.  
  14352. //chargerScriptDev("libs");
  14353. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  14354. //if (isDEV) testBoolLocalStorage();
  14355. /* Roule, test getPVsRestants
  14356. var pv = 'Inimaginables (supérieurs à 200)';
  14357. var pvminmax = pv.match(/\d+/g);
  14358. var oMinMaxPV = {min: pvminmax[0], max: pvminmax[1]};
  14359. window.console.log('minmax=' + JSON.stringify(pvminmax) + ', oMinMaxPV=' + JSON.stringify(oMinMaxPV));
  14360. window.console.log('ret getPVsRestants=' + JSON.stringify(getPVsRestants(pv, '±70%')));
  14361. window.console.log('ret getPVsRestants=' + JSON.stringify(getPVsRestants(pv, '±70%', true)));
  14362. */
  14363.  
  14364. // Détection de la page à traiter
  14365. if(isPage("Messagerie/ViewMessageBot")) {
  14366. do_cdmbot();
  14367. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  14368. do_cdmcomp();
  14369. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  14370. do_cdmcomp();
  14371. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  14372. do_cdmcomp();
  14373. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  14374. do_diplo();
  14375. } else if(isPage("MH_Play/Play_equipement")) {
  14376. do_equip();
  14377. } else if(isPage("MH_Play/Play_menu")) {
  14378. do_menu();
  14379. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  14380. do_option();
  14381. //showEssaiCartes();
  14382. } else if(isPage("View/PJView_Events")) {
  14383. /* SCIZ */
  14384. do_scizOverwriteEvents();
  14385. } else if(isPage("View/PJView")) {
  14386. do_pjview();
  14387. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  14388. do_tancompo();
  14389. } else if(isPage("MH_Play/Play_vue")) {
  14390. do_vue();
  14391. /* SCIZ */
  14392. do_scizEnhanceView();
  14393. } else if(isPage("MH_Play/Play_news")) {
  14394. do_news();
  14395. } else if(isPage("MH_Play/Play_evenement")) {
  14396. /* SCIZ */
  14397. do_scizOverwriteEvents();
  14398. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  14399. do_move();
  14400. } else if(isPage("MH_Missions/Mission_Etape")) {
  14401. do_mission();
  14402. } else if(isPage("View/MonsterView")) {
  14403. do_infomonstre();
  14404. /* SCIZ */
  14405. do_scizOverwriteEvents();
  14406. } else if(isPage("MH_Play/Play_e_follo.php")) {
  14407. do_listegowap();
  14408. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  14409. do_lieuDescription();
  14410. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  14411. do_lieuTeleport();
  14412. } else if(isPage("MH_Follower/FO_Ordres")) {
  14413. do_ordresgowap();
  14414. } else if(isPage("MH_Follower/FO_Equipement")) {
  14415. do_equipgowap();
  14416. } else if(isPage("MH_Play/Play_mouche")) {
  14417. do_mouches();
  14418. } else if(isPage("MH_Play/Play_BM")) {
  14419. do_malus();
  14420. } else if(isPage("MH_Play/Play_evenement")) {
  14421. do_myevent();
  14422. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  14423. do_enchant();
  14424. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  14425. do_pre_enchant();
  14426. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  14427. do_actions();
  14428. } 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')) {
  14429. do_mission_liste();
  14430. } else if(isPage('MH_Play/Play_action')) {
  14431. do_actions();
  14432. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  14433. do_profil2();
  14434. } else if(isPage('MH_Play/Play_profil2')) {
  14435. do_profil2();
  14436. } else if(isPage('View/TrolligionView.php')) {
  14437. do_trolligion();
  14438. }
  14439. if (document.body.dataset.MZ_Etat === undefined) { // si l'état a été positionné par quelqu'un d'autre, laisser tel quel
  14440. document.body.dataset.MZ_Etat = 1; // indiquer aux scripts tiers qu'on a fini la première initialisation
  14441. }
  14442. if (document.body.MZ_Callback_init !== undefined) {
  14443. for (var iCallback = 0; iCallback < document.body.MZ_Callback_init.length; iCallback++) {
  14444. document.body.MZ_Callback_init[iCallback]();
  14445. }
  14446. }
  14447. } catch(e) {
  14448. try {
  14449. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  14450. } catch(e2) {
  14451. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  14452. }
  14453. }