Tout_MZ

Client MountyZilla

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

  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.54
  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.54 28/08/2020",
  40. " Supprime le déplacement de la page de vue au survol de la souris du titre \"INFORMATIONS\"",
  41. "V1.3.0.53 20/07/2020",
  42. " Correction de la vue smartphone",
  43. "V1.3.0.51 23/06/2020",
  44. " Correction de la vue",
  45. "V1.3.0.47 23/06/2020",
  46. " Correction blessure",
  47. "V1.3.0.46 23/06/2020",
  48. " Adaptation réserve de temps",
  49. "V1.3.0.45 17/06/2020",
  50. " Pas de reset (erroné ?) fatigue en affichage profil",
  51. "V1.3.0.44 13/06/2020",
  52. " 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
  53. "V1.3.0.43 11/06/2020",
  54. " Affichage callstack en erreur profil",
  55. "V1.3.0.42 18/05/2020",
  56. " Amélioration du support SCIZ (Mise en option des fonctionnalités)",
  57. "V1.3.0.41 15/05/2020",
  58. " Amélioration du support SCIZ (Vie des trolls de la coterie)",
  59. "V1.3.0.40 13/05/2020",
  60. " Correction ARM dans le cas d'un grosse perte pour le tour",
  61. "V1.3.0.39 08/05/2020",
  62. " Correction erreur sur le profil en mode smartphone",
  63. "V1.3.0.38 25/04/2020",
  64. " Amélioration du support SCIZ (Gestion des trésors cachés)",
  65. "V1.3.0.37 19/04/2020",
  66. " Suite travail sur l'envoi de CdM en mode smartphone",
  67. "V1.3.0.36 20/04/2020",
  68. " Amélioration du support SCIZ (Icônes pour les événements !)",
  69. "V1.3.0.35 19/04/2020",
  70. " Ignorer l'absence de date/heure des CdM et gestion smartphone",
  71. "V1.3.0.33 14/04/2020",
  72. " Correction fausse reconnaissance de CdM sur les autres compétences",
  73. "V1.3.0.32 14/04/2020",
  74. " Adaptation page des ordres des suivant + [état et callback] pour les scripts tiers (voir doc sur le mot clef MZ_callback_init)",
  75. "V1.3.0.31 22/03/2020",
  76. " Envoi des CdM à partir du message du Bot",
  77. "V1.3.0.30 22/03/2020",
  78. " Amélioration du support SCIZ (Trésors dans la vue !)",
  79. "V1.3.0.29 14/03/2020",
  80. " Fix calcul PV après blessure en cas de maxPV inconnu",
  81. "V1.3.0.28 13/03/2020",
  82. " Fix la détection incohérence CdM et affichage en rouge",
  83. "V1.3.0.27 20/02/2020",
  84. " Ajout de la probabilité de toucher avec Lancer de Potion dans la Vue",
  85. "V1.3.0.26 08/02/2020",
  86. " Lisibilité CdM en mode smartphone",
  87. "V1.3.0.25 07/02/2020",
  88. " Adaptation basique au profil modifié",
  89. "V1.3.0.23 30/01/2020",
  90. " Correction affichage filtre monstre",
  91. "V1.3.0.22 23/01/2020",
  92. " Re-adaptation re-modif MH (affichage des durées négatives)",
  93. "V1.3.0.21 21/01/2020",
  94. " Adaptation à une modif MH dans la page des suivants",
  95. "V1.3.0.20 21/01/2020",
  96. " Adaptation modif MH (affichage des durées négatives)",
  97. "V1.3.0.19 19/01/2020",
  98. " Centralisation des éléments tactiques",
  99. "V1.3.0.18 19/01/2020",
  100. " Correctif pour les icônes d'action à distance dans la vue",
  101. "V1.3.0.17 16/01/2020",
  102. " Correctif pour le recall du filtre des Monstres",
  103. "V1.3.0.16 10/01/2020",
  104. " Amélioration du support SCIZ (Fix sur le prettyprint)",
  105. "V1.3.0.15 10/01/2020",
  106. " Amélioration du support SCIZ (Fix sur les événements de zone)",
  107. "V1.3.0.14 06/01/2020",
  108. " Correction filtre par famille pour les monstres variables et sans cdm",
  109. "V1.3.0.13 06/01/2020",
  110. " Ajout du filtre sur la famille des monstres",
  111. "V1.3.0.12 28/12/2019",
  112. " Fixed bug fix pour SCIZ (JWT)",
  113. "V1.3.0.11 28/12/2019",
  114. " Bug fix pour SCIZ (JWT)",
  115. "V1.3.0.10 22/12/2019",
  116. " Corrections mineures pour SCIZ",
  117. "V1.3.0.9 19/12/2019",
  118. " Amélioration du support SCIZ (Fixes + AdvancedCSS + SwitchEvent)",
  119. "V1.3.0.8 16/12/2019",
  120. " Amélioration du support SCIZ (Fixes + Play_evenement + PJView_Events)",
  121. "V1.3.0.7 12/12/2019",
  122. " correction cibles des missions 'famille', 'pouvoir' et cas particulier de 'race'",
  123. "V1.3.0.6 11/12/2019",
  124. " 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",
  125. "V1.3.0.5 11/12/2019",
  126. " Première interconnexion avec SCIZ (Options + MonsterView)",
  127. "V1.3.0.4 29/11/2019",
  128. " Ajout des déciles",
  129. "V1.3.0.3 29/11/2019",
  130. " Affichage d'une icône pour les Phœnix dont la génération est connue",
  131. "V1.3.0.2 24/11/2019",
  132. " Réduction taille info CdM",
  133. "V1.3.0.1 22/11/2019",
  134. " Ajustements sur les infos tactiques",
  135. "V1.3.0 15/11/2019",
  136. " Refonte calculs tactiques de la vue - beta",
  137. "V1.2.20.6 09/11/2019",
  138. " Correction de la formule d'AdD dans le profil",
  139. "V1.2.20.5 16/10/2019",
  140. " Mutualisation analyse ordres suivants MZ_analyse_page_ordre_suivant",
  141. "V1.2.20.4 03/10/2019",
  142. " Adaptation modif MH de la page des suivants",
  143. "V1.2.20.3 02/09/2019",
  144. " Compétence golem vers l'anatroliseur",
  145. "V1.2.20.2 25/05/2019",
  146. " Gestion des Parasitus pour les missions",
  147. "V1.2.20.1 25/05/2019",
  148. " Correction de la cible en cas de mission demandant un kill de Crasc + message d'alerte en cas de fumeux",
  149. "V1.2.20.0 25/05/2019",
  150. " Adaptation aux modifications des CdM par MH",
  151. "V1.2.19.2 16/04/2019",
  152. " Correction majuscules dans les talents",
  153. "V1.2.19.1 14/04/2019",
  154. " Prise en compte des nouvelles AdX dans profil2",
  155. "V1.2.18.15 29/03/2019",
  156. " Correction simple quote dans toutes les missions",
  157. "V1.2.18.14 09/03/2019",
  158. " Correction affichage vues 2D externes suite à une modif MH",
  159. "V1.2.18.13 27/02/2019",
  160. " Correction simple quote dans les familles de monstre des missions",
  161. "V1.2.18.12 23/12/2018",
  162. " Message si \"Menu d'actions contextuelles\" est décoché",
  163. "V1.2.18.11 21/11/2018",
  164. " Correction it bricol'troll, login avec accent",
  165. "V1.2.18.10 08/08/2018",
  166. " Correction boulette sDiplo",
  167. "V1.2.18.09 04/08/2018",
  168. " Protection contre diplomatie mal initialisée",
  169. "V1.2.18.08 11/07/2018",
  170. " Correction pour fonctionnement hors GM",
  171. "V1.2.18.07 18/05/2018",
  172. " prise en compte bonus magique d'esquive dans le profil, correction gestion de la souris dans la page d'équipement [Dabihul, welcome back]",
  173. "V1.2.18.06 28/01/2018",
  174. " Protection malus Crasc sans durée",
  175. "V1.2.18.05 18/11/2017",
  176. " Désactivation MZ V2 en mode dev pour les tests d'adaptation violentmonkey",
  177. "V1.2.18.04 04/09/2017",
  178. " retour version 1.2.18.02 avec GM 3.17",
  179. "V1.2.18.03 01/09/2017",
  180. " Désactivation de GM_setValue/getValue à cause d'une lenteur sur GM 3.16",
  181. "V1.2.18.02 26/08/2017",
  182. " correction boulette sur le compos d'enchantement",
  183. "V1.2.18.01 25/08/2017",
  184. " Suppression des messages sur les certificats en https",
  185. " Protection contre des erreurs dans le stockage des compos d'enchantement",
  186. "V1.2.17.19 23/08/2017",
  187. " Possibilité de plusieurs IT Bricol'Troll",
  188. "V1.2.17.18 22/08/2017",
  189. " Adaptation compétence 'travail de la pierre' (dont anatrolliseur)",
  190. " Accélération de l'affichage des niveaux si plus de 500 monstres",
  191. "V1.2.17.17 16/07/2017",
  192. " modification du mécanisme de filtrage pour contourner un pb",
  193. "V1.2.17.16 16/07/2017",
  194. " Ajout de messages de debug sur les retours AJAX",
  195. "V1.2.17.15 15/07/2017",
  196. " modification du mécanisme de filtrage pour contourner un pb",
  197. "V1.2.17.14 14/07/2017",
  198. " correction dans la gestion des étapes de mission",
  199. "V1.2.17.13 12/07/2017",
  200. " Adaptation au déplacement des colonnes dans la vue des Trõlls",
  201. "V1.2.17.12 16/06/2017",
  202. " Correction mauvais compte de PX quand on change de Trõll",
  203. "V1.2.17.11 01/05/2017",
  204. " Travail sur le fonctionnement hors Greasemonkey",
  205. "V1.2.17.10 30/04/2017",
  206. " Protection dans la récupération d'erreur",
  207. "V1.2.17.9 30/04/2017",
  208. " Correction récupération d'erreur IT Bricol'Troll",
  209. "V1.2.17.8 29/04/2017",
  210. " Correction Bonus/Malus cas +0\+10 (AE)",
  211. " Correction portée IdC",
  212. " Prise en compte du bonus de portée PM dans le calcul tactique",
  213. "V1.2.17.7 26/04/2017",
  214. " Version compatible hors GreaseMonkey",
  215. "V1.2.17.6 23/04/2017",
  216. " Correction gestion des missions en cas de réinstallation",
  217. "V1.2.17.5 20/04/2017",
  218. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  219. "V1.2.17.4 08/04/2017",
  220. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  221. " Adaptation de la diplomatie à une modification de la page MH",
  222. "V1.2.17.3 04/04/2017",
  223. " Messages console en cas de cadre d'erreur",
  224. " Trolls de l'IT mais pas dans le vue en orange",
  225. "V1.2.17.2 20/03/2017",
  226. " Correction des PV restants",
  227. "V1.2.17.1 20/03/2017",
  228. " Blocage des PV restants en attendant résolution de bug",
  229. "V1.2.17 19/03/2017",
  230. " Refonte de l'envoi des CdM",
  231. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  232. "V1.2.16.4 08/03/2017",
  233. " correction ID de troll en envoi de PX/MP",
  234. "V1.2.16.3 27/02/2017",
  235. " correction bonus/malus FP",
  236. "V1.2.16.2 24/02/2017",
  237. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  238. "V1.2.16.1 21/02/2017",
  239. " corrige bug sur Fx 38.8 ESR",
  240. "V1.2.16 21/02/2017",
  241. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  242. " possibilité de masquer les Gowaps Sauvages dans la vue",
  243. " calcul des caractéristiques du siphon des âmes",
  244. "V1.2.15.2 02/02/2017",
  245. " adaptation décumul VlC (page des bonus/malus)",
  246. "V1.2.15.1 29/01/2017",
  247. " carte sur la page de description du lieu TP",
  248. "V1.2.15 25/01/2017",
  249. " mise en place des nouvelles cartes (suivants, TP)",
  250. "V1.2.14.3 25/01/2017",
  251. " résumé dans l'export des données Trõlligion",
  252. "V1.2.14.2 20/01/2017",
  253. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  254. "V1.2.14.1 20/01/2017",
  255. " réécriture filtrage des monstres par niveau dans la vue",
  256. " Changelog dans la page des news MZ",
  257. "V1.2.14 20/01/2017",
  258. " Ajout de l'export des données Trõlligion",
  259. "V1.2.13.7 10/01/2017",
  260. " Exclusion Bricoll'troll dans l'entête GM",
  261. "V1.2.13.6 08/01/2017",
  262. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  263. "V1.2.13.5 07/01/2017",
  264. " Correction bug qui se manisfestait sous LINUX",
  265. "V1.2.13.4 07/01/2017",
  266. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  267. "V1.2.13.3 07/01/2017",
  268. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  269. "V1.2.13.2 07/01/2017",
  270. " Correction missions, recherche troogle (familles et types de monstres)",
  271. "V1.2.13.1 06/01/2017",
  272. " Suppression oldSchoolProfile qui n'existe plus",
  273. " Ajout du 'refresh' du cadre de gauche",
  274. "V1.2.13 01/01/2017",
  275. " homogénéisation des messages d'erreur",
  276. " Ajout du lien Troogle sur les étapes de mission monstre",
  277. "V1.2.12.2 30/12/2016",
  278. " retour en mode normal (http si jeu en http)",
  279. "V1.2.12.1 27/12/2016",
  280. " Correction mode IP",
  281. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  282. "V1.2.12 24/12/2016",
  283. " Nettoyage des URL",
  284. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  285. " Interface bricoll'Troll en https",
  286. " Remise en marche des cartes des trajets des gowaps",
  287. "V1.2.11.5 à 7 20 & 21/12/2016",
  288. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  289. "V1.2.11.4 19/12/2016",
  290. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  291. "V1.2.11.3 19/12/2016",
  292. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  293. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  294. "V1.2.11.2 18/12/2016",
  295. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  296. "V1.2.11.1 17/12/2016",
  297. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  298. "V1.2.11 13/12/2016",
  299. " Passage sur BdD Raistlin \\o/",
  300. "V1.2.10.4 12/12/2016",
  301. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  302. "V1.2.10.3 09/12/2016",
  303. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  304. "V1.2.10.2 09/12/2016",
  305. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  306. "V1.2.10.1 08/12/2016",
  307. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  308. "V1.2.10 07/12/2016",
  309. " correction décumul des bonus/malus",
  310. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  311. "V1.2.9 16/11/2016",
  312. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  313. "V1.2.8 10/11/2016",
  314. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  315. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  316. "V1.2.7 07/11/2016",
  317. " remise en route de l'interface avec l'IT bricol'Troll",
  318. "V1.2.6 19/10/2016",
  319. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  320. " stockage idguilde et nomguilde",
  321. "V1.2.5 17/10/2016",
  322. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  323. " remise en route de la gestion des options avec intégration md5 dans ce script",
  324. "V1.2.4 14/10/2016",
  325. " utilisation du relai raistlin pour l'envoi des CdM",
  326. "V1.2.3 :",
  327. " suppression ancien profil",
  328. " nettoyage doublon sur getPortee",
  329. " adaptation portee TP basée sur les PI",
  330. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  331. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  332. "V1.2.1 :",
  333. " include des URLs MH alternatives",
  334. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  335. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  336. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  337. "V1.1 : regroupement en un gros paquet sale",
  338. ];
  339.  
  340. /**********************************************************
  341. À faire / propositions d'évolutions
  342.  
  343. H2P 08/07/2020
  344. * dans la vue des minerais, ça devrait a priori afficher, sur base des formules de mountypedia, le nombre de carats de chaque pépite de minerai
  345. Bireli-Gravos 08/12/2018
  346. FAIT faire un warning si l'utilisateur a désactivé la case "Menu d'actions contextuelles" dans la fenêtre "limiter la vue"
  347. breizhou13 20/12/2016
  348. envoyer les données à l'IT (Bricol'Trolls) aussi
  349. (Roule') Ça me semble difficile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  350. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  351. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  352. Akkila le boeuf le 26-03-2017 à 15:56
  353. - bouton pour rafraîchir les infos des trolls de son groupe
  354. Roule'
  355. FAIT corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  356. Réactiver les jubilaires
  357. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  358. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  359. - voir l'intérêt de refaire fonctionner
  360. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  361. FAIT : ambiguité sur le nom de monstres de mission : Shai, Ombre, Geck'oo et Boujd'la
  362. Sans doute à corriger, la compétence Baroufle pour le lien vers l'anatroliseur
  363. Prévision des DLA de monstre
  364. FAIT Niveau des monstres à la méthode Roule'
  365. Raistlin
  366. * et si la popup des compétences s'affichait aussi au survol des raccourcis ?
  367. FAIT? pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  368. FAIT Les cibles de mission ont disparu dans la vue (remonté par Hera)
  369. 80117 - Héra
  370. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  371. 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)
  372. FAIT Possibilité de plusieurs systèmes Bricol'troll
  373. en 1.2.17.18 SyntaxError: expected expression, got end of script[En savoir plus] Tout_MZ.user.js:12731:6
  374. ?
  375. FAIT Tenir compte de la distance pour le PM (calculatrice de combat)
  376. Alanae/Gnu/Pen-Hiss
  377. * popup d'erreur js en mode smartphone sur un TP (pb trajet_canvas)
  378. a de temps en temps un popup "Error: Permission denied to access property Symbol:toPrimitive"
  379. Kali
  380. MASQUÉ "TyperError: InfoComposant[4] is undefined" à l'affichage de la vue
  381. **********************************************************/
  382.  
  383. /**********************************************************
  384. Doc État et Callback pour l'utilisation par les scripts tiers
  385. MZ met à jour la propriété document.body.dataset.MZ_Etat
  386. 1 à la fin de l'initialisation (tout le code MZ s'est déroulé mais il peut y avoir des appels AJAX en cours)
  387. 2 (uniquement sur l'onglet de la vue) quand l'onglet a été mis à jour avec les niveaux, etc.
  388. ATTENTION, l'utilisateur peut demander un complément de CdM s'il voit plus de 500 monstres
  389. MZ appelle les callback définies dans les tableaux suivants, si ces tableaux existent
  390. document.body.MZ_Callback_init: fonctions que MZ appellera quand MZ aura fini sont initialisation
  391. 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é.
  392. document.body.MZ_Callback_fin_vue: fonctions que MZ appellera quand MZ aura fini son premier traitement des CdM dans la vue
  393. ATTENTION document.body.MZ_Callback_init et document.body.MZ_Callback_fin_vue sont des tableaux.
  394. Vous n'êtes pas seuls au monde. Un autre script externe peut s'être déjà enregistré en callback
  395. Voici un exemple de code pour enregistrer une callback
  396. if (document.body.MZ_Callback_init === undefined) {
  397. document.body.MZ_Callback_init = [myCallback];
  398. } else {
  399. document.body.MZ_Callback_init.push(myCallback);
  400. }
  401. **********************************************************/
  402.  
  403. /**********************************************************
  404. **** Début de zone à déplacer dans une bibli commune ******
  405. **********************************************************/
  406.  
  407. // URL de base serveur MZ
  408. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  409. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  410. //var URL_MZ = 'http://192.99.225.92/mz';
  411.  
  412. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  413. // On dirait qu'il n'y en a plus...
  414.  
  415. // URLs externes redirection (pas de souci CORS)
  416. var URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  417. var URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  418. var URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  419. var URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  420. var URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  421. var URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  422. var URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  423. var URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  424. var URL_troogle = 'http://troogle.iktomi.eu/entities/';
  425.  
  426. // URLs de test HTTPS
  427. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  428. var URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  429.  
  430. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  431. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  432. var URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  433.  
  434. // x~x Libs
  435.  
  436. /* ancien TODO
  437. * - revoir la gestion des CdM --> nott armure magique
  438. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  439. * - vérfier la gestion des enchants
  440. */
  441.  
  442. // Roule 04/09/2016 switch extern URLs to https if available
  443. var isHTTPS = false;
  444. if (window.location.protocol.indexOf('https') === 0) {
  445. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  446. URL_bricol = URL_bricol_https;
  447. isHTTPS = true;
  448. }
  449.  
  450. // Roule 23/12/2016 mode dev
  451. var isDEV = false;
  452. if (window.localStorage.getItem('MZ_dev')
  453. || window.location.href.indexOf('rouletabille.mh.free.fr') > 0
  454. || window.location.href.indexOf('mzdev.mh') >= 0) {
  455. URL_MZ = URL_MZ.replace(/$/, 'dev');
  456. isDEV = true;
  457. }
  458.  
  459. // Images (pas de souci CORS)
  460. var URL_MZimg = URL_MZ + '/img/';
  461. // URLs externes ajax (CORS OK)
  462. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  463. var URL_MZgetCaracMonstre = URL_MZ + '/getCaracMonstre.php';
  464. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  465.  
  466. // liens externes déduits
  467. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  468.  
  469. var MHicons = '/mountyhall/Images/Icones/';
  470. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  471. var MY_DEBUG = false;
  472.  
  473. var horsGM = false;
  474. try { // à partir du 11/07/2018, (GM_getValue === undefined) provoque une exception
  475. horsGM = (GM_getValue === undefined);
  476. } catch (e2) {
  477. horsGM = true;
  478. //window.console.log('test GM_getValue, exception=' + e2);
  479. }
  480. if (horsGM) { // éviter le blocage si pas sous GM
  481. window.console.log('Fonctionnement hors Greasemonkey');
  482. // Roule 18/11/2017 il ne faut pas de "var" dans les ligne précédente. Ça fonctionnait sous Greasemonkey mais plus sous Violentmonkey
  483. GM_getValue = function(key) {};
  484. GM_setValue = function(key, val) {};
  485. GM_deleteValue = function(key) {};
  486. GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  487. }
  488.  
  489. /* Utilisation de la gestion de l'enregistrement des données de
  490. GreaseMonkey, avec partage entre scripts via le localStorage, par
  491. Vapulabehemot (82169) 07/02/2017 */
  492. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  493. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  494. function MY_getValue(key) {
  495. var v = window.localStorage.getItem(key);
  496. vGM = GM_getValue(key);
  497. if ((vGM == null)
  498. || (v != null && v != vGM)){
  499. GM_setValue(key, v);
  500. } else if (v == null && vGM != null) {
  501. v = vGM;
  502. window.localStorage[key] = vGM;
  503. }
  504. return v;
  505. }
  506. function MY_removeValue(key) {
  507. GM_deleteValue(key);
  508. window.localStorage.removeItem(key);
  509. }
  510. function MY_setValue(key, val) {
  511. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  512. val = 1;
  513. else if (val === false)
  514. val = 0;
  515. try {
  516. GM_setValue(key, val);
  517. } catch(e) {
  518. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec GM_setValue(' + key + ', ' + val + ')');
  519. }
  520. try {
  521. window.localStorage[key] = val;
  522. } catch(e) {
  523. window.console.log('[MZ ' + GM_info.script.version + '] MY_setValue echec localStorage[' + key + '] = ' + val);
  524. }
  525. }
  526.  
  527. /*---------------- mise à jour de variables globales utiles ------------------*/
  528. // utilisé pour accès bdd (un peu partout) :
  529. var numTroll = MY_getValue('NUM_TROLL');
  530. // utilisé dans vue pour PX :
  531. // Roule 16/06/2017 on ne peut pas prendre le dernier niveau vu ! on a peut-être changé de Troll
  532. var nivTroll; // = MY_getValue('NIV_TROLL');
  533. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  534. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  535. // utilisés dans actions et vue (calculs SR) :
  536. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  537. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  538. var currentURL = window.location.href;
  539.  
  540. /*-[functions]------------ Fonctions durée de script -------------------------*/
  541. var date_debut = null;
  542.  
  543. function start_script(nbJours_exp) {
  544. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  545. if(date_debut) return;
  546. date_debut = new Date();
  547. // Créé la variable expdate si demandé
  548. if(nbJours_exp) {
  549. expdate = new Date();
  550. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  551. }
  552. }
  553.  
  554. function displayScriptTime(duree, texte) {
  555. var footerNode = document.getElementById('footer2');
  556. if(!footerNode) return;
  557. try{
  558. var node = document.evaluate(
  559. ".//text()[contains(.,'Page générée en')]/../br",
  560. footerNode,null,9,null).singleNodeValue;
  561. }
  562. catch(e){return;}
  563. if (duree) {
  564. insertText(node,
  565. ' - [' + texte + ' en ' + (duree/1000) +' sec.]');
  566. return;
  567. }
  568. insertText(node,
  569. ' - [Script MZ exécuté en '
  570. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  571. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  572. }
  573.  
  574. function traceStack(e, sModule) {
  575. var version = '';
  576. if (GM_info && GM_info.script && GM_info.script.version)
  577. version = ' ' + GM_info.script.version;
  578. sRet = '[MZ' + version + ']'
  579. if (sModule) sRet += ' {' + sModule + '}';
  580. try {
  581. if (e.message) sRet += ' ' + e.message;
  582. } catch (e2) {
  583. sRet += ' <exception acces message>';//+ e2.message;
  584. }
  585. try {
  586. if (e.stack) {
  587. var sStack = e.stack;
  588. // enlever les infos confidentielles
  589. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  590. }
  591. } catch (e2) {
  592. sRet += ' <exception acces stack>'; // + e2.message;
  593. }
  594. return sRet;
  595. }
  596.  
  597. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  598.  
  599. function debugMZ(str){
  600. if(MY_DEBUG){
  601. window.console.debug('[MZ_DEBUG] '+str);
  602. if(typeof str === "object"){
  603. window.console.debug(str);
  604. }
  605. }
  606. }
  607.  
  608. if("function" != typeof isPage) {
  609. function isPage(url) {
  610. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  611. }
  612. }
  613.  
  614. function FF_XMLHttpRequest(MY_XHR_Ob) {
  615. var request = new XMLHttpRequest();
  616. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  617. for(var head in MY_XHR_Ob.headers) {
  618. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  619. }
  620. request.onreadystatechange = function() {
  621. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  622. if(request.readyState!=4) { return; }
  623. if(request.error) {
  624. if(MY_XHR_Ob.onerror) {
  625. MY_XHR_Ob.onerror(request);
  626. }
  627. return;
  628. }
  629. if ((request.status == 0)) {
  630. window.console.log('status=0 au retour de ' + MY_XHR_Ob.url + ', réponse=' + request.responseText);
  631. if (isDEV) {
  632. var grandCadre = createOrGetGrandCadre();
  633. var sousCadre = document.createElement('div');
  634. sousCadre.innerHTML = 'AJAX status = 0, voir console';
  635. sousCadre.style.width = 'auto';
  636. sousCadre.style.fontSize = 'large';
  637. sousCadre.style.border = 'solid 1px black';
  638. grandCadre.appendChild(sousCadre);
  639. }
  640. if (MY_XHR_Ob.onerror) MY_XHR_Ob.onerror(request);
  641. //showHttpsErrorContenuMixte();
  642. return;
  643. }
  644. if(MY_XHR_Ob.onload) {
  645. var version;
  646. if (MY_XHR_Ob.trace) {
  647. version = '';
  648. if (GM_info && GM_info.script && GM_info.script.version)
  649. version = ' ' + GM_info.script.version;
  650. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' début traitement retour AJAX ' + MY_XHR_Ob.trace);
  651. }
  652. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  653. MY_XHR_Ob.onload(request);
  654. if (MY_XHR_Ob.trace)
  655. window.console.log('[MZ' + version + '] ' + MZ_formatDateMS() + ' fin traitement retour AJAX ' + MY_XHR_Ob.trace);
  656. }
  657. };
  658. request.send(MY_XHR_Ob.data);
  659. }
  660.  
  661. // rend une chaine affichant date et heure et milliseconds (maintenant si le paramètre est absent)
  662. function MZ_formatDateMS(d, sansMicroSecondes) {
  663. if (d === undefined) d = new Date();
  664. var day = d.getDate();
  665. var month = d.getMonth()+1;
  666. var year = d.getFullYear();
  667. var hours = d.getHours();
  668. var minutes = d.getMinutes();
  669. var seconds = d.getSeconds();
  670. if (day < 10) {day = "0"+day;}
  671. if (month < 10) {month = "0"+month;}
  672. if (hours < 10) {hours = "0"+hours;}
  673. if (minutes < 10) {minutes = "0"+minutes;}
  674. if (seconds < 10) {seconds = "0"+seconds;}
  675. if (sansMicroSecondes) {
  676. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds;
  677. } else {
  678. var ms = d.getMilliseconds();
  679. ms = ('000' + ms).substr(-3, 3);
  680. return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + '.' + ms;
  681. }
  682. }
  683.  
  684. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  685.  
  686. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  687. function copyTextToClipboard(text) {
  688. var textArea = document.createElement("textarea");
  689.  
  690. //
  691. // *** This styling is an extra step which is likely not required. ***
  692. //
  693. // Why is it here? To ensure:
  694. // 1. the element is able to have focus and selection.
  695. // 2. if element was to flash render it has minimal visual impact.
  696. // 3. less flakyness with selection and copying which **might** occur if
  697. // the textarea element is not visible.
  698. //
  699. // The likelihood is the element won't even render, not even a flash,
  700. // so some of these are just precautions. However in IE the element
  701. // is visible whilst the popup box asking the user for permission for
  702. // the web page to copy to the clipboard.
  703. //
  704.  
  705. // Place in top-left corner of screen regardless of scroll position.
  706. textArea.style.position = 'fixed';
  707. textArea.style.top = 0;
  708. textArea.style.left = 0;
  709.  
  710. // Ensure it has a small width and height. Setting to 1px / 1em
  711. // doesn't work as this gives a negative w/h on some browsers.
  712. textArea.style.width = '2em';
  713. textArea.style.height = '2em';
  714.  
  715. // We don't need padding, reducing the size if it does flash render.
  716. textArea.style.padding = 0;
  717.  
  718. // Clean up any borders.
  719. textArea.style.border = 'none';
  720. textArea.style.outline = 'none';
  721. textArea.style.boxShadow = 'none';
  722.  
  723. // Avoid flash of white box if rendered for any reason.
  724. textArea.style.background = 'transparent';
  725.  
  726. textArea.value = text;
  727.  
  728. document.body.appendChild(textArea);
  729.  
  730. textArea.select();
  731.  
  732. var successful = document.execCommand('copy');
  733.  
  734. document.body.removeChild(textArea);
  735. return successful;
  736. }
  737.  
  738. function avertissement(txt,duree,bBloque) {
  739. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  740. if(!duree) duree = 15000;
  741. var div = document.createElement('div');
  742. // On numérote les avertissements pour destruction sélective
  743. var num = document.getElementsByName('avertissement').length;
  744. div.num = num;
  745. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  746. div.setAttribute('name','avertissement');
  747. div.className = 'mh_textbox';
  748. div.style.position = 'fixed';
  749. div.style.top = (10+15*num)+'px';
  750. div.style.left = (10+5*num)+'px';
  751. div.style.border = '5px solid red';
  752. div.style.zIndex = 2+num;
  753. div.style.cursor = 'pointer';
  754. div.style.fontSize = 'large';
  755. div.innerHTML = txt;
  756. if (!bBloque) div.onclick=function(){ tueAvertissement(this.num) };
  757.  
  758. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  759. var divcroix = document.createElement('div');
  760. divcroix.style.position = 'absolute';
  761. divcroix.style.top = 0;
  762. divcroix.style.right = 0;
  763. divcroix.style.color = 'black';
  764. divcroix.style.fontSize = 'inherit';
  765. divcroix.style.cursor = 'pointer'
  766. divcroix.style.zIndex = 2+num;
  767. divcroix.innerHTML = "X";
  768. div.appendChild(divcroix);
  769.  
  770. document.body.appendChild(div);
  771. // Destruction automatique de l'avertissement après "un certain temps"
  772. window.setTimeout(function(){ tueAvertissement(num) },duree);
  773. }
  774.  
  775. function tueAvertissement(num) {
  776. var divs = document.getElementsByName('avertissement');
  777. if(divs.length==0) { return; }
  778. for(var i=0 ; i<divs.length ; i++) {
  779. if(divs[i].num==num) {
  780. divs[i].parentNode.removeChild(divs[i]);
  781. return;
  782. }
  783. }
  784. }
  785.  
  786.  
  787. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  788.  
  789. function insertBefore(next,el) {
  790. next.parentNode.insertBefore(el,next);
  791. }
  792.  
  793. function appendTr(tbody,clas) {
  794. var tr = document.createElement('tr');
  795. if(clas) tr.className = clas;
  796. tbody.appendChild(tr);
  797. return tr;
  798. }
  799.  
  800. function insertTr(next,clas) {
  801. var tr = document.createElement('tr');
  802. if(clas) tr.className = clas;
  803. insertBefore(next,tr);
  804. return tr;
  805. }
  806.  
  807. function appendTd(tr) {
  808. var td = document.createElement('td');
  809. if(tr) tr.appendChild(td);
  810. return td;
  811. }
  812.  
  813. function insertTd(next) {
  814. var td = document.createElement('td');
  815. insertBefore(next,td);
  816. return td;
  817. }
  818.  
  819. function insertTh(next) {
  820. var th = document.createElement('th');
  821. insertBefore(next,th);
  822. return th;
  823. }
  824.  
  825. // handle when eTd is the last (in this case eTd.nextSibling is null, which is fine for insertBefore)
  826. function insertAfterTd(eTd) {
  827. var newTd = document.createElement('td');
  828. eTd.parentNode.insertBefore(newTd, eTd.nextSibling);
  829. return newTd;
  830. }
  831.  
  832. function appendTdCenter(tr,colspan) {
  833. var td = appendTd(tr);
  834. td.align = 'center'; // WARNING - Obsolete
  835. if(colspan) td.colSpan = colspan;
  836. return td;
  837. }
  838.  
  839. function insertTdElement(next,el) {
  840. var td = insertTd(next);
  841. if(el) td.appendChild(el);
  842. return td;
  843. }
  844.  
  845. function appendA(paren,href,cssClass,text) {
  846. var a = document.createElement('a');
  847. if (href) a.href = href;
  848. if (cssClass) a.className = cssClass;
  849. if (text) a.appendChild(document.createTextNode(text));
  850. paren.appendChild(a);
  851. }
  852.  
  853. function appendText(paren,text,bold) {
  854. if(bold) {
  855. var b = document.createElement('b');
  856. b.appendChild(document.createTextNode(text));
  857. paren.appendChild(b);
  858. }
  859. else
  860. paren.appendChild(document.createTextNode(text));
  861. }
  862.  
  863. function insertText(next,text,bold) {
  864. if(bold) {
  865. var b = document.createElement('b');
  866. appendText(b,text);
  867. insertBefore(next,b);
  868. }
  869. else
  870. insertBefore(next,document.createTextNode(text));
  871. }
  872.  
  873. function appendThText(tr,text,bold) {
  874. var th = document.createElement('th');
  875. if(tr) tr.appendChild(th);
  876. th.appendChild(document.createTextNode(text));
  877. if (bold) th.style.fontWeight = 'bold';
  878. return th;
  879. }
  880.  
  881. function appendTdText(tr,text,bold) {
  882. var td = appendTd(tr);
  883. td.appendChild(document.createTextNode(text));
  884. if (bold) td.style.fontWeight = 'bold';
  885. return td;
  886. }
  887.  
  888. function insertThText(next,text,bold) {
  889. var th = insertTh(next);
  890. appendText(th,text,bold);
  891. return th;
  892. }
  893.  
  894. function insertTdText(next,text,bold) {
  895. var td = insertTd(next);
  896. appendText(td,text,bold);
  897. return td;
  898. }
  899.  
  900. function appendBr(paren) {
  901. paren.appendChild(document.createElement('br'));
  902. }
  903.  
  904. function insertBr(next) {
  905. insertBefore(next,document.createElement('br'));
  906. }
  907.  
  908. function appendLI(ul,text) {
  909. // uniquement utilisé dans les options (crédits)
  910. var li = document.createElement('li');
  911. appendText(li,text);
  912. ul.appendChild(li);
  913. return li;
  914. }
  915.  
  916. function appendTextbox(paren,type,nam,size,maxlength,value, sId) {
  917. var input = document.createElement('input');
  918. input.className = 'TextboxV2';
  919. input.type = type;
  920. input.name = nam;
  921. if (sId === undefined) input.id = nam;
  922. else input.id = sId;
  923. input.size = size;
  924. input.maxLength = maxlength;
  925. if(value) input.value = value;
  926. paren.appendChild(input);
  927. return input;
  928. }
  929.  
  930. function appendCheckBox(paren,nam,checked,onClick) {
  931. var input = document.createElement('input');
  932. input.type = 'checkbox';
  933. input.name = nam;
  934. input.id = nam;
  935. if(checked) input.checked = true;
  936. if(onClick) input.onclick = onClick;
  937. paren.appendChild(input);
  938. return input;
  939. }
  940.  
  941. function appendNobr(paren,id,delgg,text) {
  942. var nobr = document.createElement('nobr');
  943. appendCheckBox(nobr,id,null,delgg);
  944. appendText(nobr,text);
  945. paren.appendChild(nobr);
  946. appendText(paren,' ');
  947. return nobr;
  948. }
  949.  
  950. function appendCheckBoxSpan(paren,id,onClick,text) {
  951. var span = document.createElement('span');
  952. span.style.whiteSpace = 'nowrap';
  953. appendCheckBox(span,id,false,onClick);
  954. var label = document.createElement('label');
  955. appendText(label,text);
  956. label.htmlFor = id;
  957. label.style.marginLeft = '-5px';
  958. span.appendChild(label);
  959. span.style.marginRight = '3px';
  960. paren.appendChild(span);
  961. appendText(paren, ' ');
  962. return span;
  963. }
  964.  
  965. function appendOption(select,value,text) {
  966. var option = document.createElement('option');
  967. option.value = value;
  968. appendText(option,text);
  969. select.appendChild(option);
  970. return option;
  971. }
  972.  
  973. function appendHidden(form,nam,value) {
  974. var input = document.createElement('input');
  975. input.type = 'hidden';
  976. input.name = nam;
  977. input.id = nam;
  978. input.value = value;
  979. form.appendChild(input);
  980. }
  981.  
  982. function appendButton(paren,value,onClick) {
  983. var input = document.createElement('input');
  984. input.type = 'button';
  985. input.className = 'mh_form_submit';
  986. input.value = value;
  987. input.onmouseover = function(){this.style.cursor='pointer';};
  988. if(onClick) input.onclick = onClick;
  989. paren.appendChild(input);
  990. return input;
  991. }
  992.  
  993. function insertButton(next,value,onClick) {
  994. var input = document.createElement('input');
  995. input.type = 'button';
  996. input.className = 'mh_form_submit';
  997. input.value = value;
  998. input.onmouseover = function(){this.style.cursor='pointer';};
  999. input.onclick = onClick;
  1000. insertBefore(next,input);
  1001. return input;
  1002. }
  1003.  
  1004. function appendSubmit(paren,value,onClick) {
  1005. var input = document.createElement('input');
  1006. input.type = 'submit';
  1007. input.className = 'mh_form_submit';
  1008. input.value = value;
  1009. input.onmouseover = function(){this.style.cursor='pointer';};
  1010. if(onClick) input.onclick = onClick;
  1011. paren.appendChild(input);
  1012. return input;
  1013. }
  1014.  
  1015. function createImage(url,title,style) {
  1016. var img = document.createElement('img');
  1017. img.src = url;
  1018. img.title = title;
  1019. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  1020. if (style) img.style = style;
  1021. return img;
  1022. }
  1023.  
  1024. function createAltImage(url,alt,title) {
  1025. var img = document.createElement('img');
  1026. img.src = url;
  1027. img.alt = alt;
  1028. if (title) img.title = title;
  1029. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  1030. return img;
  1031. }
  1032.  
  1033. function createImageSpan(url,alt,title,text,bold) {
  1034. var span = document.createElement('span');
  1035. span.title = title;
  1036. var img = document.createElement('img');
  1037. img.src = url;
  1038. img.alt = alt;
  1039. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  1040. span.appendChild(img);
  1041. appendText(span,text,bold);
  1042. return span;
  1043. }
  1044.  
  1045. function createCase(titre,table,width) {
  1046. if(!width) width=120;
  1047. var tr = appendTr(table,'mh_tdpage');
  1048.  
  1049. var td = appendTdText(tr,titre,true);
  1050. td.className = 'mh_tdtitre';
  1051. td.width = width;
  1052.  
  1053. td = appendTdText(tr,'');
  1054. td.className = 'mh_tdpage';
  1055. return td;
  1056. }
  1057.  
  1058. function getMyID(e) {
  1059. var parent = e.parentNode;
  1060. for(var i=0 ; i<parent.childNodes.length ; i++) {
  1061. if(e==parent.childNodes[i])
  1062. return i;
  1063. }
  1064. return -1;
  1065. }
  1066.  
  1067. function insertAfter(elt,newElt) {
  1068. var id = getMyID(elt);
  1069. if(id==-1) return;
  1070. if(id<elt.parentNode.childNodes.length-1)
  1071. insertBefore(elt.nextSibling,newElt);
  1072. else
  1073. elt.parentNode.appendChild(newElt);
  1074. }
  1075.  
  1076.  
  1077. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  1078.  
  1079. function aff(nb) {
  1080. return (nb >= 0) ? '+' + nb : nb;
  1081. }
  1082.  
  1083. function getNumber(str) {
  1084. var nbr = str.match(/\d+/);
  1085. return nbr ? Number(nbr[0]) : Number.NaN;
  1086. }
  1087.  
  1088. function getNumbers(str) {
  1089. var nbrs = str.match(/\d+/g);
  1090. if (!nbrs) return [];
  1091. for (var i = 0; i < nbrs.length; i++) {
  1092. nbrs[i] = Number(nbrs[i]);
  1093. }
  1094. return nbrs;
  1095. }
  1096.  
  1097. function getIntegers(str) {
  1098. var nbrs = str.match(/-?\d+/g);
  1099. if (!nbrs) return [];
  1100. for(var i=0 ; i<nbrs.length ; i++) {
  1101. nbrs[i] = Number(nbrs[i]);
  1102. }
  1103. return nbrs;
  1104. }
  1105.  
  1106. function trim(str) {
  1107. return str.replace(/(^\s*)|(\s*$)/g, '');
  1108. }
  1109.  
  1110. if (typeof String.prototype.trim != 'function') {
  1111. // Intégré depuis ES5, pour rétrocompatibilité
  1112. String.prototype.trim = function() {
  1113. return this.replace(/^\s+/, '').replace(/\s+$/, '');
  1114. }
  1115. }
  1116.  
  1117. function epure(texte) {
  1118. return texte
  1119. .replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1120. .replace(/[ç]/g,'c')
  1121. .replace(/[éêèë]/g,'e')
  1122. .replace(/[ïî]/g,'i')
  1123. .replace(/[ôöõ]/g,'o')
  1124. .replace(/[ùûü]/g,'u');
  1125. }
  1126.  
  1127. // WARNING Modifier des constantes, c'est mal
  1128. String.prototype.epure = function() {
  1129. return this
  1130. .replace(/[àâä]/g,'a').replace(/Â/g,'A')
  1131. .replace(/[ç]/g,'c')
  1132. .replace(/[éêèë]/g,'e')
  1133. .replace(/[ïî]/g,'i')
  1134. .replace(/[ôöõ]/g,'o')
  1135. .replace(/[ùûü]/g,'u');
  1136. }
  1137.  
  1138. function bbcode(texte) {
  1139. return texte
  1140. .replace(/&/g, '&amp;')
  1141. .replace(/"/g, '&quot;')
  1142. .replace(/</g, '&lt;')
  1143. .replace(/>/g, '&gt;')
  1144. .replace(/'/g, '&#146;')
  1145. .replace(/\[b\](.*?)\[\/b\]/g, '<b>$1</b>')
  1146. .replace(/\[i\](.*?)\[\/i\]/g, '<i>$1</i>')
  1147. .replace(/\[img\]([^"]*?)\[\/img\]/g, '<img src="$1" />');
  1148. }
  1149.  
  1150. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  1151.  
  1152. function addZero(i) {
  1153. return (i<10) ? '0'+i : i;
  1154. }
  1155.  
  1156. function DateToString(date) {
  1157. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  1158. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  1159. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  1160. }
  1161.  
  1162. function StringToDate(str) {
  1163. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  1164. }
  1165.  
  1166. // fonctionne aussi avec datetime
  1167. function SQLDateToFrench(str) {
  1168. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  1169. }
  1170.  
  1171. // ... et ajoute un "à" du plus bel effet
  1172. function SQLDateToFrenchTime(str) {
  1173. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  1174. }
  1175.  
  1176. // SQLDate vers objet date Javascript
  1177. function SQLDateToObject(str) {
  1178. var t = str.split(/[- :]/);
  1179. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  1180. }
  1181.  
  1182. var mz_ie = (window.attachEvent)? true:false;
  1183. if ("function" !== typeof addEvent) {
  1184. if (mz_ie) {
  1185. function addEvent(obj, typ, fn, sens) {
  1186. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  1187. obj["e"+typ+fn]( window.event );
  1188. }
  1189. obj.attachEvent("on"+typ, obj[typ+fn] );
  1190. }
  1191. }
  1192. else {
  1193. function addEvent(obj, typ, fn, sens) {
  1194. obj.addEventListener(typ, fn, sens);
  1195. }
  1196. }
  1197. }
  1198.  
  1199. /**********************
  1200. * glissière en mode objet
  1201. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  1202. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  1203. *
  1204. * Usage:
  1205. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  1206. * ref : utilisé pour diversifier les IDs HTML
  1207. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  1208. * target : peut être de 3 types
  1209. * - élément HTML : l'élément HTML à zoomer
  1210. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  1211. * - function : callback quand le curseur bouge
  1212. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  1213. * dans le mode dynamique, la callback est appelée sur mouseMove
  1214. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  1215. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  1216. * autres méthodes
  1217. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  1218. **********************/
  1219.  
  1220. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  1221. try {
  1222. var mouseDown = false;
  1223. var div_gliss = document.createElement("div"); // la DIV mère
  1224. div_gliss.id = "MZ_gliss_"+ref;
  1225. var div_label = document.createElement("span"); // le label
  1226. div_label.innerHTML = labelHTML;
  1227. div_gliss.appendChild(div_label);
  1228. div_gliss.className = "choix_zoom";
  1229. var dessin = document.createElement("canvas"); // le dessin lui-même
  1230. dessin.id = "MZ_gliss_dessin_"+ref;
  1231. dessin.style.cursor = "pointer";
  1232. dessin.width = 104;
  1233. dessin.height = 12;
  1234. dessin.style.marginLeft = '2px';
  1235. dessin.style.marginRight = '2px';
  1236. div_gliss.appendChild(dessin);
  1237. var pourcent = document.createElement("span"); // le pourcentage
  1238. pourcent.id = "MZ_gliss_pourcent_"+ref;
  1239. var pourcent_text = document.createTextNode('');
  1240. var previousVal;
  1241. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  1242.  
  1243. // alignement vertical
  1244. dessin.style.verticalAlign = 'middle';
  1245. div_label.style.verticalAlign = 'middle';
  1246. pourcent.style.verticalAlign = 'middle';
  1247.  
  1248. pourcent.appendChild(pourcent_text);
  1249. div_gliss.appendChild(pourcent);
  1250.  
  1251. var bulle_pourcent = document.createElement("div"); // la bulle
  1252. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  1253. bulle_pourcent.style.display = 'block';
  1254. bulle_pourcent.style.visibility = 'hidden';
  1255. bulle_pourcent.style.position = 'absolute';
  1256. bulle_pourcent.style.zIndex = 3500;
  1257. bulle_pourcent.style.border = '1px solid #a1927f';
  1258. var bulle_pourcent_text = document.createTextNode('');
  1259. bulle_pourcent.appendChild(bulle_pourcent_text);
  1260. document.body.appendChild(bulle_pourcent);
  1261.  
  1262. this.getElt = function() {return div_gliss;};
  1263.  
  1264. ////////////////////////////////////
  1265. // dessine et redessine le curseur
  1266. ////////////////////////////////////
  1267. var dessine_glissiere = function(val) {
  1268. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  1269. var ctx = dessin.getContext('2d');
  1270. ctx.clearRect(0, 0,104, 12);
  1271. ctx.fillStyle = "rgb(0,0,0)";
  1272. ctx.fillRect(0,0,2,12);
  1273. ctx.fillRect(102,0,2,12);
  1274. ctx.fillRect(0,5,104,2);
  1275.  
  1276. ctx.fillStyle = "rgb(80,80,80)";
  1277. ctx.fillRect(pos_0_100,0,5,12);
  1278. ctx.fillStyle = "rgb(200,200,200)";
  1279. ctx.fillRect(pos_0_100+1,1,3,10);
  1280. pourcent_text.nodeValue = val+'%';
  1281. previousVal = parseInt(val);
  1282. };
  1283.  
  1284. ////////////////////////////////////
  1285. // action sur mousedown et mousemove
  1286. // stocker la nouvelle valeur
  1287. // redessiner
  1288. // afficher la nouvelle valeur
  1289. // action selon ce qui a été demandé
  1290. ////////////////////////////////////
  1291. var doCallback_glissiere = function (evt) {
  1292. try {
  1293. if (evt.type === 'mousedown') mouseDown = true;
  1294. if (evt.offsetX) {
  1295. var xsouris = evt.offsetX;
  1296. var xpos = evt.clientX;
  1297. var ypos = evt.clientY + document.body.scrollTop;
  1298. }
  1299. else {
  1300. var xsouris = evt.layerX;
  1301. var xpos = evt.pageX;
  1302. var ypos = evt.pageY;
  1303. }
  1304. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  1305. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  1306. // afficher la nouvelle valeur dans la bulle
  1307. bulle_pourcent_text.nodeValue = val + '%';
  1308. bulle_pourcent.style.top = (ypos+3)+'px';
  1309. bulle_pourcent.style.left = (xpos+16)+'px';
  1310. if (evt.buttons === undefined) {
  1311. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  1312. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  1313. } else {
  1314. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  1315. }
  1316. // stocker la nouvelle valeur
  1317. MY_setValue("MZ_glissiere_" + ref, val);
  1318. // redessiner la glissière avec le curseur où il faut
  1319. dessine_glissiere(val);
  1320. // action selon ce qui a été demandé
  1321. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  1322. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  1323. if (typeof paramTarget === 'object') {
  1324. var elt = paramTarget;
  1325. } else if (typeof paramTarget === 'string') {
  1326. var elt = document.getElementById(paramTarget);
  1327. } else if (typeof paramTarget === 'function') {
  1328. paramTarget(val);
  1329. return;
  1330. }
  1331. if (elt.setZoom != undefined) elt.setZoom(val);
  1332. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  1333. };
  1334.  
  1335. ////////////////////////////////////
  1336. // event mousedown et mousemove : redessiner et callback
  1337. ////////////////////////////////////
  1338. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  1339. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  1340. ////////////////////////////////////
  1341. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  1342. ////////////////////////////////////
  1343. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1344. ////////////////////////////////////
  1345. // event mouseout & mouseover : afficher/cacher la bulle
  1346. ////////////////////////////////////
  1347. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1348. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1349.  
  1350. ////////////////////////////////////
  1351. // dessiner la première fois
  1352. ////////////////////////////////////
  1353. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1354. if (val_init === undefined) val_init = valDef;
  1355. dessine_glissiere(val_init);
  1356. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1357. }
  1358.  
  1359. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1360. // reçoit 2 objets avec des propriétés x et y
  1361. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1362. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1363. var deltaX = locArrivee.x - locDepart.x;
  1364. if (deltaX == 0) return; // pas de point intermédiaire
  1365. var deltaY = locArrivee.y - locDepart.y;
  1366. if (deltaY == 0) return; // pas de point intermédiaire
  1367. var absDeltaX = Math.abs(deltaX);
  1368. var absDeltaY = Math.abs(deltaY);
  1369. if (absDeltaX > absDeltaY) {
  1370. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1371. } else if (absDeltaY > absDeltaX) {
  1372. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1373. } else {
  1374. return; // égalité, pas de point intermédiaire
  1375. }
  1376. }
  1377.  
  1378. /**********************
  1379. * carte en mode objet
  1380. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1381. *
  1382. * Usage:
  1383. * carte = new carte_MZ(ref, tabDepl);
  1384. * ref : utilisé pour diversifier les IDs HTML
  1385. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1386. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1387. * autres méthodes
  1388. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1389. **********************/
  1390.  
  1391. function carte_MZ(ref, tabDepl) {
  1392. try {
  1393. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1394. div1_carte.id = "MZ_carte_"+ref;
  1395. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1396. div1_carte.style.backgroundImage = 'none';
  1397. div1_carte.style.backgroundColor = 'transparent';
  1398. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1399. div2_carte.className = "carte_MZ";
  1400. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1401. var dessin = document.createElement("canvas"); // le dessin lui-même
  1402. dessin.id = "MZ_carte_dessin_"+ref;
  1403. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1404. div1_carte.appendChild(div2_carte);
  1405. div2_carte.appendChild(dessin);
  1406.  
  1407. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1408. , [-66.5, -37.5, 2, 1.5, -69]
  1409. , [-63.5, 8.5, 2, 1.5, -69]
  1410. , [-59.5, -32.5, 2, 1.5, -69]
  1411. , [-52, 57, 0.25, 0.8, -59]
  1412. , [-50.5, -22.5, 2, 1.5, -69]
  1413. , [-35.5, -51.5, 2, 1.5, -69]
  1414. , [-34.5, 14.5, 2, 1.5, -69]
  1415. , [-34.5, 64.5, 2, 1.5, -69]
  1416. , [-11.5, 72.5, 2, 1.5, -69]
  1417. , [5.5, -49.5, 2, 1.5, -69]
  1418. , [5.5, 31.5, 2, 1.5, -69]
  1419. , [10.5, 63.5, 2, 1.5, -69]
  1420. , [12, -15, 0.25, 0.8, -59]
  1421. , [21.5, 35.5, 2, 1.5, -69]
  1422. , [30, -52, 0.25, 0.8, -59]
  1423. , [46.5, 51.5, 2, 1.5, -69]
  1424. , [48, -39, 0.25, 0.8, -59]
  1425. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1426. , [56.5, 23.5, 75, 8.7, -99]
  1427. , [64, 70, 0.25, 0.8, -59]
  1428. , [74.5, 31.5, 2, 1.5, -69]];
  1429.  
  1430. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1431. var couleur_cible = 'rgba(0,0,0,0.5)';
  1432. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1433. var couleur_trou = 'rgb(200,0,0)';
  1434.  
  1435. var coord_x = function(val) {
  1436. return decalh+coeff*(val+100);
  1437. };
  1438. var coord_y = function(val) {
  1439. return decalv+coeff*(100-val);
  1440. };
  1441.  
  1442. var ctx = dessin.getContext('2d');
  1443. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1444. if (coeff) coeff /= 50;
  1445. else coeff = 2;
  1446. var decalv=30, decalh=30;
  1447.  
  1448. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1449. //var res = false
  1450. var x0 = pos0.x;
  1451. var y0 = pos0.x;
  1452. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1453. var px = Math.sign(pos1.x - pos0.x);
  1454. var py = Math.sign(pos1.y - pos0.y);
  1455. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1456. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1457.  
  1458. for(var k in position_trous_MZ) {
  1459. a = parseFloat(px*px+py*py);
  1460. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1461. 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]);
  1462. delta = b*b-a*c
  1463. if(delta >= 0) {
  1464. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1465. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1466. if(t0 <= tmax && t1 >= 0) {
  1467. // 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
  1468. //res = true;
  1469. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1470. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1471. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1472. // Roule : pas utile pour nous
  1473. //res = true;
  1474. //chute.push([x0+l*px, y0+l*py]);
  1475. return true;
  1476. }
  1477. }
  1478. }
  1479. }
  1480. //return res;
  1481. return false;
  1482. };
  1483.  
  1484. var dessine_carte = function () {
  1485. dessin.width = 200*coeff+2*decalh;
  1486. dessin.height = 200*coeff+2*decalv;
  1487.  
  1488. //repere
  1489. ctx.beginPath();
  1490. ctx.moveTo(coord_x(0), coord_y(100));
  1491. ctx.lineTo(coord_x(0), coord_y(-100));
  1492. ctx.moveTo(coord_x(-100), coord_y(0));
  1493. ctx.lineTo(coord_x(100), coord_y(0));
  1494. ctx.stroke();
  1495. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1496.  
  1497. //trous
  1498. ctx.fillStyle = couleur_trou;
  1499. for(var i in position_trous_MZ) {
  1500. ctx.beginPath();
  1501. 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);
  1502. ctx.fill();
  1503. }
  1504. // trajets
  1505. ctx.lineCap = "round";
  1506. ctx.lineJoin = "round";
  1507. for (var iSuivant in tabDepl) {
  1508. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1509. var tabDeplOneSuivant = tabDepl[iSuivant];
  1510. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1511. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1512. // La "cible" au départ
  1513. var typeDepart = tabDeplOneSuivant[0].typ;
  1514. switch (typeDepart) {
  1515. case 'tp':
  1516. ctx.beginPath();
  1517. ctx.lineWidth = 2;
  1518. ctx.strokeStyle = couleur_cible;
  1519. ctx.fillStyle = couleur_cible;
  1520. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1521. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1522. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1523. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1524. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1525. ctx.moveTo(x0 + coeff * 3, y0);
  1526. ctx.lineTo(x0 - coeff * 3, y0);
  1527. ctx.moveTo(x0, y0 + coeff * 3);
  1528. ctx.lineTo(x0, y0 - coeff * 3);
  1529. ctx.stroke();
  1530. break;
  1531. default:
  1532. ctx.beginPath();
  1533. ctx.lineWidth = 1;
  1534. ctx.strokeStyle = couleur_cible;
  1535. ctx.fillStyle = couleur_cible;
  1536. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1537. ctx.moveTo(x0 + coeff * 4, y0);
  1538. ctx.lineTo(x0 - coeff * 4, y0);
  1539. ctx.moveTo(x0, y0 + coeff * 4);
  1540. ctx.lineTo(x0, y0 - coeff * 4);
  1541. ctx.stroke();
  1542. break;
  1543. }
  1544. // les segments
  1545. var nb_pts = tabDeplOneSuivant.length;
  1546. var pointPrecedent = tabDeplOneSuivant[0];
  1547. for (var i=1; i<nb_pts; i++) {
  1548. ctx.beginPath();
  1549. ctx.lineWidth = coeff;
  1550. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1551. ctx.strokeStyle = couleur_depl_normal;
  1552. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1553. if (pointIntermediaire === undefined) {
  1554. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1555. ctx.strokeStyle = couleur_depl_collision_trou;
  1556. else
  1557. ctx.strokeStyle = couleur_depl_normal;
  1558. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1559. } else {
  1560. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1561. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1562. ctx.strokeStyle = couleur_depl_collision_trou;
  1563. else
  1564. ctx.strokeStyle = couleur_depl_normal;
  1565. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1566. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1567. }
  1568. pointPrecedent = tabDeplOneSuivant[i];
  1569. ctx.stroke();
  1570. }
  1571. // Les points à chaque étape
  1572. ctx.fillStyle = couleur_depl_normal;
  1573. for (var i=1; i<nb_pts; i++) {
  1574. ctx.beginPath();
  1575. var x = coord_x(tabDeplOneSuivant[i].x);
  1576. var y = coord_y(tabDeplOneSuivant[i].y);
  1577. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1578. ctx.fill();
  1579. }
  1580. }
  1581. }
  1582.  
  1583. this.setZoom = function (val) {
  1584. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1585. coeff = val / 50;
  1586. dessine_carte();
  1587. }
  1588.  
  1589. // glissiere
  1590. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1591. var eGliss = gliss.getElt();
  1592. eGliss.style.position = 'absolute';
  1593. eGliss.style.top = (coeff * 2) + 'px';
  1594. eGliss.style.left = decalh + 'px';
  1595. dessin.style.position = 'relative';
  1596. div2_carte.style.position = 'relative';
  1597. eGliss.style.zIndex = 9000;
  1598. div2_carte.appendChild(eGliss);
  1599.  
  1600. // affichage au survol de la souris
  1601. var bulle = document.createElement('div');
  1602. bulle.style.visibility = 'hidden';
  1603. bulle.style.position = 'absolute';
  1604. bulle.style.zIndex = 3100;
  1605. bulle.style.border = 'solid 1px #a1927f';
  1606. bulle.className = 'mh_tdpage';
  1607. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1608. var bulleHaut = document.createElement('div');
  1609. bulleHaut.style.display = 'block';
  1610. bulleHaut.style.paddingRight = '3px';
  1611. bulleHaut.className = 'mh_tdtitre';
  1612. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1613. bulle.appendChild(bulleHaut);
  1614. var bulleBas = document.createElement('div');
  1615. bulleBas.style.display = 'block';
  1616. bulleBas.style.whiteSpace = "nowrap";
  1617. bulleBas.style.paddingRight = '3px';
  1618.  
  1619. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1620. bulle.appendChild(bulleBas);
  1621. div2_carte.appendChild(bulle);
  1622. var affichePosition = function(evt) {
  1623. if (evt.offsetX) {
  1624. var xsouris = evt.offsetX;
  1625. var ysouris = evt.offsetY;
  1626. var xpos = evt.clientX;
  1627. var ypos = evt.clientY + document.body.scrollTop;
  1628. }
  1629. else {
  1630. var xsouris = evt.layerX;
  1631. var ysouris = evt.layerY;
  1632. var xpos = evt.pageX;
  1633. var ypos = evt.pageY;
  1634. }
  1635. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1636. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1637. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1638. var tabHTMLbas = [];
  1639. // message pour les trous
  1640. for (var i in position_trous_MZ) {
  1641. var ceTrou = position_trous_MZ[i];
  1642. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1643. if(dist <= 0) {
  1644. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1645. break;
  1646. }
  1647. }
  1648. // messages pour les suivants
  1649. for (var i in tabDepl) {
  1650. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1651. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1652. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1653. }
  1654. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1655. bulle.style.top = (ysouris+8) + 'px';
  1656. bulle.style.left = (xsouris+16) + 'px';
  1657. };
  1658. addEvent(dessin, "mousemove", affichePosition, true);
  1659. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1660. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1661.  
  1662. // dessin initial
  1663. dessine_carte();
  1664.  
  1665. this.getElt = function() {return div1_carte;};
  1666.  
  1667. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1668. }
  1669.  
  1670.  
  1671. /**********************************************************
  1672. **** Fin de zone à déplacer dans une bibli commune ********
  1673. **********************************************************/
  1674.  
  1675. /* DEBUG: NETTOYAGE TAGS */
  1676. if(MY_getValue(numTroll+'.TAGSURL')) {
  1677. MY_removeValue(numTroll+'.TAGSURL');
  1678. }
  1679.  
  1680. // Alerte si mode dev
  1681. if (isDEV) {
  1682. var divpopup = document.createElement('div');
  1683. divpopup.id = 'divDEV';
  1684. divpopup.style =
  1685. 'position: fixed;'+
  1686. 'border: 15px solid red;'+
  1687. 'top: 10px;right: 10px;'+
  1688. 'background-color: white;'+
  1689. 'color: black;'+
  1690. 'font-size: large;'+
  1691. 'padding: 5px'+
  1692. 'z-index: 200;';
  1693. appendText(divpopup, '[MZ] Mode DEV');
  1694. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1695. document.body.appendChild(divpopup);
  1696. }
  1697.  
  1698. /*---------- regroupement des getPortee() ------------------------------------*/
  1699.  
  1700. function getPortee(param) {
  1701. param = Math.max(0,Number(param));
  1702. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1703. // ça devrait être floor, +10.25, -2.5
  1704. }
  1705.  
  1706. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1707.  
  1708. function getPXKill(niv) {
  1709. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1710. return Math.max(0,10+3*niv-2*nivTroll);
  1711. }
  1712.  
  1713. function getPXDeath(niv) {
  1714. if (nivTroll == undefined) return '? (visitez le profil privé)';
  1715. return Math.max(0,10+3*nivTroll-2*niv);
  1716. }
  1717.  
  1718. function analysePX(niv) {
  1719. niv = niv+'';
  1720. var i = niv.indexOf('+');
  1721. if(i!=-1) // si niv = 'XX+' ??
  1722. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1723. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1724. if(i!=-1) {
  1725. var max = getPXKill(niv.slice(i+2));
  1726. if(max==0)
  1727. return ' --> <b>0</b> PX';
  1728. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1729. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1730. }
  1731. i = niv.indexOf('='); // ???
  1732. if(i!=-1) {
  1733. var max = getPXKill(niv.slice(i+1));
  1734. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1735. }
  1736. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1737. }
  1738.  
  1739. function analysePXTroll(niv) {
  1740. var str = analysePX(niv);
  1741. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1742. return str;
  1743. }
  1744.  
  1745.  
  1746. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1747. // Refonte totale du code de Zorya
  1748.  
  1749. // Elements à implémenter en dur dans MZ2.0
  1750. var numQualite = {
  1751. 'Très Mauvaise':1,
  1752. 'Mauvaise':2,
  1753. 'Moyenne':3,
  1754. 'Bonne':4,
  1755. 'Très Bonne':5
  1756. };
  1757.  
  1758. var qualiteNum = [
  1759. '_dummy_',
  1760. 'Très Mauvaise',
  1761. 'Mauvaise',
  1762. 'Moyenne',
  1763. 'Bonne',
  1764. 'Très Bonne'
  1765. ];
  1766.  
  1767. var nival = {
  1768. 'Abishaii Bleu':19,
  1769. 'Abishaii Noir':10,
  1770. 'Abishaii Rouge':23,
  1771. 'Abishaii Vert':15,
  1772. 'Ame-en-peine':8,
  1773. 'Amibe Geante':9,
  1774. 'Anaconda des Catacombes':8,
  1775. 'Ankheg':10,
  1776. 'Anoploure Purpurin':36,
  1777. 'Araignee Geante':2,
  1778. 'Ashashin':35,
  1779. 'Balrog':50,
  1780. 'Banshee':16,
  1781. 'Barghest':36,
  1782. 'Basilisk':11,
  1783. 'Behemoth':34,
  1784. 'Behir':14,
  1785. 'Beholder':50,
  1786. 'Boggart':3,
  1787. 'Bondin':9,
  1788. "Bouj'Dla Placide":37,
  1789. "Bouj'Dla":19,
  1790. 'Bulette':19,
  1791. 'Caillouteux':1,
  1792. 'Capitan':35,
  1793. 'Carnosaure':25,
  1794. 'Champi-Glouton':3,
  1795. 'Chauve-Souris Geante':4,
  1796. 'Cheval a Dents de Sabre':23,
  1797. 'Chevalier du Chaos':20,
  1798. 'Chimere':13,
  1799. 'Chonchon':24,
  1800. 'Coccicruelle':22,
  1801. 'Cockatrice':5,
  1802. 'Crasc Medius':17,
  1803. 'Crasc Maexus':25,
  1804. 'Crasc':10,
  1805. 'Croquemitaine':6,
  1806. 'Cube Gelatineux':32,
  1807. 'Daemonite':27,
  1808. 'Diablotin':5,
  1809. 'Dindon du Chaos':1,
  1810. 'Djinn':29,
  1811. 'Ectoplasme':18,
  1812. 'Effrit':27,
  1813. "Elementaire d'Air":23,
  1814. "Elementaire d'Eau":17,
  1815. 'Elementaire de Feu':21,
  1816. 'Elementaire de Terre':21,
  1817. 'Elementaire du Chaos':26,
  1818. 'Erinyes':7,
  1819. 'Esprit-Follet':16,
  1820. 'Essaim Craterien':30,
  1821. 'Essaim Sanguinaire':25,
  1822. 'Ettin':8,
  1823. 'Familier':1,
  1824. 'Fantome':24,
  1825. 'Feu Follet':20,
  1826. 'Flagelleur Mental':33,
  1827. 'Foudroyeur':38,
  1828. 'Fumeux':22,
  1829. 'Fungus Geant':9,
  1830. 'Fungus Violet':4,
  1831. 'Furgolin':10,
  1832. 'Gargouille':3,
  1833. 'Geant de Pierre':13,
  1834. 'Geant des Gouffres':22,
  1835. "Geck'oo Majestueux":40,
  1836. "Geck'oo":15,
  1837. 'Glouton':20,
  1838. 'Gnoll':5,
  1839. 'Gnu Domestique':1,
  1840. 'Gnu Sauvage':1,
  1841. 'Goblin':4,
  1842. 'Goblours':4,
  1843. "Golem d'Argile":15,
  1844. 'Golem de cuir':1,
  1845. 'Golem de Chair':8,
  1846. 'Golem de Fer':31,
  1847. 'Golem de mithril':1,
  1848. 'Golem de metal':1,
  1849. 'Golem de papier':1,
  1850. 'Golem de Pierre':23,
  1851. 'Gorgone':11,
  1852. 'Goule':4,
  1853. 'Gowap Apprivoise':1,
  1854. 'Gowap Sauvage':1,
  1855. 'Gremlins':3,
  1856. 'Gritche':39,
  1857. 'Grouilleux':4,
  1858. 'Grylle':31,
  1859. 'Harpie':4,
  1860. 'Hellrot':18,
  1861. 'Homme-Lezard':4,
  1862. 'Hurleur':8,
  1863. 'Hydre':50,
  1864. 'Incube':13,
  1865. 'Kobold':2,
  1866. 'Labeilleux':26,
  1867. 'Lezard Geant':5,
  1868. 'Liche':50,
  1869. 'Limace Geante':10,
  1870. 'Loup-Garou':8,
  1871. 'Lutin':4,
  1872. 'Mante Fulcreuse':30,
  1873. 'Manticore':9,
  1874. 'Marilith':33,
  1875. 'Meduse':6,
  1876. 'Megacephale':38,
  1877. 'Mille-Pattes Geant':14,
  1878. 'Mimique':6,
  1879. 'Minotaure':7,
  1880. 'Molosse Satanique':8,
  1881. 'Momie':4,
  1882. 'Monstre Rouilleur':3,
  1883. "Mouch'oo Domestique":14,
  1884. "Mouch'oo Majestueux Sauvage":33,
  1885. "Mouch'oo Sauvage":14,
  1886. 'Na-Haniym-Heee':0,
  1887. 'Necrochore':37,
  1888. 'Necromant':39,
  1889. 'Necrophage':8,
  1890. 'Naga':10,
  1891. 'Nuee de Vermine':13,
  1892. "Nuage d'Insectes":7,
  1893. 'Ogre':7,
  1894. 'Ombre de Roches':13,
  1895. 'Ombre':2,
  1896. 'Orque':3,
  1897. 'Ours-Garou':18,
  1898. 'Palefroi Infernal':29,
  1899. 'Phoenix':32,
  1900. 'Pititabeille':0,
  1901. 'Plante Carnivore':4,
  1902. 'Pseudo-Dragon':5,
  1903. 'Rat Geant':2,
  1904. 'Rat-Garou':3,
  1905. 'Rocketeux':5,
  1906. 'Sagouin':3,
  1907. 'Scarabee Geant':4,
  1908. 'Scorpion Geant':10,
  1909. 'Shai':28,
  1910. 'Sirene':8,
  1911. 'Slaad':5,
  1912. 'Sorciere':17,
  1913. 'Spectre':14,
  1914. 'Sphinx':30,
  1915. 'Squelette':1,
  1916. 'Strige':2,
  1917. 'Succube':13,
  1918. 'Tertre Errant':20,
  1919. 'Thri-kreen':10,
  1920. 'Tigre-Garou':12,
  1921. 'Titan':26,
  1922. 'Trancheur':35,
  1923. 'Tubercule Tueur':14,
  1924. 'Tutoki':4,
  1925. 'Vampire':29,
  1926. 'Ver Carnivore Geant':12,
  1927. 'Ver Carnivore':11,
  1928. 'Veskan Du Chaos':14,
  1929. 'Vouivre':33,
  1930. 'Worg':5,
  1931. 'Xorn':14,
  1932. 'Yeti':8,
  1933. 'Yuan-ti':15,
  1934. 'Zombie':2
  1935. }
  1936.  
  1937. var tabEM = {
  1938. //Monstre: [Compo exact, Sort, Position, Localisation]
  1939. // AA
  1940. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1941. // AE
  1942. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1943. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1944. // AdA
  1945. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1946. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1947. // AdE
  1948. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1949. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1950. // AdD
  1951. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1952. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1953. // BAM
  1954. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1955. // BuM
  1956. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1957. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1958. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1959. // Explo
  1960. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1961. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1962. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1963. // FP
  1964. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1965. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1966. // FA
  1967. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1968. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1969. // Glue
  1970. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1971. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1972. // GdS
  1973. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1974. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1975. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1976. // Invi
  1977. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1978. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1979. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1980. // Lévitation
  1981. // ???
  1982. // PréM :
  1983. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1984. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1985. // Proj
  1986. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1987. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1988. // PuM :
  1989. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1990. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1991. // Sacro
  1992. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1993. // Télék
  1994. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1995. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1996. // TP
  1997. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1998. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1999. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  2000. // VA
  2001. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  2002. // VL
  2003. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  2004. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  2005. // VlC
  2006. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  2007. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  2008. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  2009. // VT
  2010. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  2011. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  2012. // Variables
  2013. 'Rat':["d'un"],
  2014. 'Rat Géant':["d'un"],
  2015. 'Dindon':["d'un"],
  2016. 'Goblin':["d'un"],
  2017. 'Limace':["d'une"],
  2018. 'Limace Géante':["d'une"],
  2019. 'Ver':["d'un"],
  2020. 'Ver Carnivore':["d'un"],
  2021. 'Ver Carnivore Géant':["d'un"],
  2022. 'Fungus':["d'un"],
  2023. 'Vouivre':["d'une"],
  2024. 'Gnu':["d'un"],
  2025. 'Scarabée':["d'un"]
  2026. };
  2027.  
  2028. var mundiChampi = {
  2029. 'Préscientus Reguis':'du Phoenix',
  2030. 'Amanite Trolloïde':'de la Mouche',
  2031. 'Girolle Sanglante':'du Dindon',
  2032. 'Horreur Des Prés':'du Gobelin',
  2033. 'Bolet Péteur':'du Démon',
  2034. 'Pied Jaune':'de la Limace',
  2035. 'Agaric Sous-Terrain':'du Rat',
  2036. 'Suinte Cadavre':"de l'Hydre",
  2037. 'Cèpe Lumineux':'du Ver',
  2038. 'Fungus Rampant':'du Fungus',
  2039. 'Nez Noir':'de la Vouivre',
  2040. 'Pleurote Pleureuse':'du Gnu',
  2041. 'Phytomassus Xilénique':'du Scarabée'
  2042. };
  2043.  
  2044. function addInfoMM(node,mob,niv,qualite,effetQ) {
  2045. appendText(node,' ');
  2046. var urlImg = URL_MZimg
  2047. +'Competences/melangeMagique.png';
  2048. var text = ' [-'+(niv+effetQ)+' %]';
  2049. var str = '';
  2050. switch(mob[0]) {
  2051. case 'A':
  2052. case 'E':
  2053. case 'I':
  2054. case 'O':
  2055. case 'U':
  2056. str = "Compo d'";
  2057. break;
  2058. default:
  2059. str = 'Compo de ';
  2060. }
  2061. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  2062. var span = createImageSpan(urlImg,'MM:',title,text);
  2063. node.appendChild(span);
  2064. }
  2065.  
  2066. function addInfoEM(node,mob,compo,qualite,localisation) {
  2067. if(!tabEM[mob]) return;
  2068. var title = 'Composant variable', texte = 'Variable';
  2069. var bold = false;
  2070. if(tabEM[mob].length>1) {
  2071. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  2072. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  2073. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  2074. if(pc<-20) return;
  2075. if(pc>=0) bold = true;
  2076. texte = aff(pc)+'%';
  2077. title = texte+" pour l'écriture de "+tabEM[mob][1];
  2078. }
  2079. var urlImg = URL_MZimg
  2080. +'Competences/ecritureMagique.png';
  2081. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  2082. node.appendChild(span);
  2083. }
  2084.  
  2085. function insererInfosEM(tbody) {
  2086. // lancé par equip, equipgowap
  2087. var trCompos = document.evaluate(
  2088. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  2089. tbody,null,7,null);
  2090. var strCompos = '';
  2091. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  2092. var node = trCompos.snapshotItem(i).childNodes[7];
  2093. var str = node.firstChild.textContent;
  2094. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  2095. var mob = trim(str.slice(str.indexOf("d'un")+5));
  2096. // Si non-EM on stoppe le traitement
  2097. if(!tabEM[mob]) continue;
  2098. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  2099. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  2100. var localisation = trim(str.slice(0,str.indexOf(' |')));
  2101. addInfoEM(node,mob,compo,qualite,localisation);
  2102. }
  2103. }
  2104.  
  2105. function getQualite(qualite) {
  2106. var nb = numQualite[qualite];
  2107. return nb ? nb-1 : -1;
  2108. }
  2109.  
  2110. function getEM(nom) {
  2111. if(nom.indexOf('[')!=-1)
  2112. nom = trim(nom.substring(0,nom.indexOf('[')));
  2113. if(tabEM[nom]) return nom;
  2114. return '';
  2115. }
  2116.  
  2117. // DEBUG ex-fonction composantEM
  2118. function compoMobEM(mob) {
  2119. if(!tabEM[mob]) return '';
  2120. if(tabEM[mob].length==1)
  2121. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  2122. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  2123. +") pour l'écriture de "+tabEM[mob][1];
  2124. }
  2125.  
  2126. // DEBUG ex-fonction compoEM
  2127. function titreCompoEM(mob,compo,localisation,qualite) {
  2128. if(!tabEM[mob]) return '';
  2129. if(tabEM[mob].length==1) return 'Composant variable';
  2130.  
  2131. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  2132. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  2133. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  2134.  
  2135. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  2136. return '';
  2137. }
  2138.  
  2139. // DEBUG - rétrocompatibilité
  2140. function compoEM(mob) {
  2141. // appelé dans libs, vue
  2142. return compoMobEM(mob);
  2143. }
  2144. function composantEM(mob,compo,localisation,qualite) {
  2145. // appelé dans libs, tancompo
  2146. return titreCompoEM(mob,compo,localisation,qualite);
  2147. }
  2148. //
  2149.  
  2150.  
  2151. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  2152.  
  2153. arrayTalents = {
  2154. /* Compétences */
  2155. 'Acceleration du Metabolisme':'AM',
  2156. 'Attaque Precise':'AP',
  2157. 'Balayage':'Balayage',
  2158. //'Balluchonnage':'Ballu',
  2159. 'Baroufle':'Baroufle',
  2160. 'Bidouille':'Bidouille',
  2161. 'Botte Secrete':'BS',
  2162. 'Camouflage':'Camou',
  2163. 'Charger':'Charger',
  2164. 'Connaissance des Monstres':'CdM',
  2165. 'Construire un Piege':'Piege',
  2166. 'Piege a Feu':'PiegeFeu',
  2167. 'Piege a Glue':'PiegeGlue',
  2168. 'Contre-Attaquer':'CA',
  2169. 'Coup de Butoir':'CdB',
  2170. 'Course':'Course',
  2171. 'Deplacement Eclair':'DE',
  2172. 'Dressage':'Dressage',
  2173. 'Ecriture Magique':'EM',
  2174. 'Frenesie':'Frenesie',
  2175. 'Golemologie':'Golemo',
  2176. 'Golem de cuir':'GolemCuir',
  2177. 'Golem de metal':'GolemMetal',
  2178. 'Golem de mithril':'GolemMithril',
  2179. 'Golem de papier':'GolemPapier',
  2180. 'Grattage':'Grattage',
  2181. 'Hurlement Effrayant':'HE',
  2182. 'Identification des Champignons':'IdC',
  2183. 'Insultes':'Insultes',
  2184. 'Lancer de Potions':'LdP',
  2185. 'Marquage':'Marquage',
  2186. 'Melange Magique':'Melange',
  2187. 'Miner':'Miner',
  2188. 'Travail de la Pierre':'Pierre',
  2189. 'Necromancie':'Necro',
  2190. 'Painthure de Guerre':'PG',
  2191. 'Parer':'Parer',
  2192. 'Pistage':'Pistage',
  2193. 'Planter un Champignon':'PuC',
  2194. 'Regeneration Accrue':'RA',
  2195. 'Reparation':'Reparation',
  2196. 'Retraite':'Retraite',
  2197. 'RotoBaffe':'RB',
  2198. 'Shamaner':'Shamaner',
  2199. "S'interposer":'SInterposer',
  2200. 'Tailler':'Tailler',
  2201. //'Vol':'Vol',
  2202. /* Sortilèges */
  2203. 'Analyse Anatomique':'AA',
  2204. 'Armure Etheree':'AE',
  2205. 'Augmentation de l´Attaque':'AdA', // obsolète?
  2206. "Augmentation de l'Attaque":'AdA',
  2207. 'Augmentation de l´Esquive':'AdE',
  2208. 'Augmentation des Degats':'AdD',
  2209. 'Bulle Anti-Magie':'BAM',
  2210. 'Bulle Magique':'BuM',
  2211. 'Explosion':'Explo',
  2212. 'Faiblesse Passagere':'FP',
  2213. 'Flash Aveuglant':'FA',
  2214. 'Glue':'Glue',
  2215. 'Griffe du Sorcier':'GdS',
  2216. 'Hypnotisme':'Hypno',
  2217. 'Identification des Tresors':'IdT',
  2218. 'Invisibilite':'Invi',
  2219. 'Levitation':'Levitation',
  2220. 'Precision Magique':'PreM',
  2221. 'Projectile Magique':'Projo',
  2222. 'Projection':'Proj',
  2223. 'Puissance Magique':'PuM',
  2224. 'Rafale Psychique':'Rafale',
  2225. 'Sacrifice':'Sacro',
  2226. 'Siphon des ames':'Siphon',
  2227. 'Telekinesie':'Telek',
  2228. 'Teleportation':'TP',
  2229. 'Vampirisme':'Vampi',
  2230. 'Vision Accrue':'VA',
  2231. 'Vision lointaine':'VL',
  2232. 'Voir le Cache':'VlC',
  2233. 'Vue Troublee':'VT'
  2234. //'':''
  2235. }
  2236.  
  2237. // DEBUG - Pour rétrocompatibilité
  2238. function getSortComp(nom,niveau) {
  2239. return getTalent(nom,niveau);
  2240. }
  2241. //
  2242.  
  2243. function getTalent(nom,niveau) {
  2244. if(nom===true) return true;
  2245. var nomEnBase = arrayTalents[epure(nom)];
  2246. if(!nomEnBase) nomEnBase=nom;
  2247. if(!niveau) var niveau = '';
  2248. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  2249. return Number(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau));
  2250. return 0;
  2251. }
  2252.  
  2253. function removeAllTalents() {
  2254. for(var talent in arrayTalents) {
  2255. var nomEnBase = arrayTalents[talent];
  2256. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  2257. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  2258. continue;
  2259. }
  2260. var niveau = 1;
  2261. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  2262. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  2263. niveau++;
  2264. }
  2265. }
  2266. }
  2267.  
  2268. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  2269. try { // Roule 07/06/2017 protection, ça plante si on est dans une callback de XMLHTTPREQUEST
  2270. var att = MY_getValue(numTroll+'.caracs.attaque');
  2271. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  2272. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  2273. var mm = MY_getValue(numTroll+'.caracs.mm');
  2274. var deg = MY_getValue(numTroll+'.caracs.degats');
  2275. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  2276. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  2277. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  2278. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  2279. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  2280. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  2281. return false;
  2282. return true;
  2283. } catch(e) {
  2284. return false;
  2285. }
  2286. }
  2287.  
  2288.  
  2289. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  2290.  
  2291. function getPVsRestants(pv,bless,vue) {
  2292. bless = Number(bless.match(/\d+/)[0]);
  2293. if(bless==0) return null;
  2294. var pvminmax = pv.match(/\d+/g);
  2295. var oMinMaxPV = {min: pvminmax[0], max: pvminmax[1]};
  2296. var oMinMaxPVRestant = MZ_getPVsRestants(oMinMaxPV, bless);
  2297. if (vue) {
  2298. if (oMinMaxPVRestant.min) {
  2299. if (oMinMaxPVRestant.max) {
  2300. return ' (' + oMinMaxPVRestant.min + '-' + oMinMaxPVRestant.max + ')';
  2301. } else {
  2302. return " (\u2A7E" + oMinMaxPVRestant.min + ')'; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  2303. }
  2304. } else {
  2305. if (oMinMaxPVRestant.max) {
  2306. return " (\u2A7D" + oMinMaxPVRestant.max + ')'; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  2307. } else {
  2308. return '';
  2309. }
  2310. }
  2311. }
  2312. var oRet = ['Points de Vie restants : '];
  2313. if (oMinMaxPVRestant.min) {
  2314. if (oMinMaxPVRestant.max) {
  2315. oRet[1] = 'Entre '+oMinMaxPVRestant.min+' et '+oMinMaxPVRestant.max;
  2316. } else {
  2317. oRet[1] = "\u2A7E" + oMinMaxPVRestant.min; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  2318. }
  2319. } else {
  2320. if (oMinMaxPVRestant.max) {
  2321. oRet[1] = "\u2A7D" + oMinMaxPVRestant.max; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  2322. } else {
  2323. oRet[1] = 'inconnu';
  2324. }
  2325. }
  2326. return oRet;
  2327. /* à supprimer
  2328. if(bless==95) {
  2329. var pvb = 1;
  2330. var pvh = Math.floor( pvminmax[1]/20 );
  2331. }
  2332. else if(bless==5) {
  2333. var pvb = Math.floor( pvminmax[0]*19/20 );
  2334. var pvh = pvminmax[1];
  2335. }
  2336. else {
  2337. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  2338. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  2339. }
  2340. return vue ? ' ('+pvb+'-'+pvh+')' :
  2341. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  2342. }
  2343. */
  2344. }
  2345.  
  2346. function MZ_getPVsRestants(oMinMaxPV, bless) { // rend un objet minmax
  2347. var oRet = {};
  2348. if(bless==95) {
  2349. oRet.min = 1;
  2350. if (oMinMaxPV.max) oRet.max = Math.floor( oMinMaxPV.max/20);
  2351. } else if(bless==5) {
  2352. if (oMinMaxPV.min) oRet.min = Math.floor( oMinMaxPV.min*19/20);
  2353. if (oMinMaxPV.max) oRet.max = oMinMaxPV.max;
  2354. } else {
  2355. if (oMinMaxPV.min) oRet.min = Math.ceil( oMinMaxPV.min*(95-bless) / 100);
  2356. if (oMinMaxPV.max) oRet.max = Math.floor( oMinMaxPV.max*(105-bless) / 100);
  2357. }
  2358. return oRet;
  2359. }
  2360.  
  2361. /* tentative via jQuery abandonnée
  2362. function insertButtonCdmSmartphone_to_delete(nextName,onClick,texte) {
  2363. if (window.jQuery == undefined) return;
  2364. //window.console.log('jQuery OK');
  2365. var eInput = $('[name="' + nextName + '"]');
  2366. if (!eInput) return;
  2367. //window.console.log('eInput OK');
  2368. var eDiv = eInput.closest("div");
  2369. if (!eDiv) return;
  2370. //window.console.log('eDiv OK');
  2371. var newDiv = eDiv.clone();
  2372. var newSpan = newDiv.children('span');
  2373. newSpan.children(':first-child').text(texte);
  2374. var newInput = newDiv.children('input');
  2375. newInput.removeAttr('onclick');
  2376. newInput.click(onClick);
  2377. newInput.val(texte);
  2378. newInput.removeAttr("type").attr("type", "button");
  2379. var eForm = eDiv.parent();
  2380. window.console.log("insertButtonCdmSmartphone tag newdiv=" + newDiv.prop('tagName') + ', parent tag=' + eForm.prop('tagName'));
  2381. eForm.prepend(newDiv);
  2382. return true;
  2383. }
  2384.  
  2385. function insertButtonCdmSmartphone(nextName,onClick,texte) {
  2386. var tabInput = document.getElementsByName(nextName);
  2387. if (!tabInput) return;
  2388. var eInput = tabInput[0];
  2389. if (!eInput) return;
  2390. //window.console.log('eInput OK');
  2391. var eDiv = eInput.parentNode;
  2392. if (!eDiv) return;
  2393. window.console.log('eDiv.outerHTML=' + eDiv.outerHTML);
  2394. var eNewDiv = eDiv.cloneNode(true);
  2395. window.console.log('eNewDiv.outerHTML=' + eNewDiv.outerHTML);
  2396. var tabNewSpan = eNewDiv.getElementsByTagName('span');
  2397. if (!tabNewSpan) return;
  2398. window.console.log('tabNewSpan lg=' + tabNewSpan.length);
  2399. if (tabNewSpan.length == 0) return;
  2400. tabNewSpan.forEach(function(pSpan) {
  2401. if (pSpan.getElementsByTagName('span').length > 0) return;
  2402. window.console.log('newSpan old text=' + pSpan.innerText);
  2403. while (pSpan.firstChild) pSpan.removeChild(pSpan.firstChild); // vider
  2404. pSpan.appendChild(document.createTextNode(texte));
  2405. });
  2406. var tabNewInput = eNewDiv.getElementsByTagName('input');
  2407. if (!tabNewInput) return;
  2408. var eNewInput = tabNewInput[0];
  2409. if (!eNewInput) return;
  2410. eNewInput.removeAttr('onclick');
  2411. eNewInput.onClick = onClick;
  2412. eNewInput.value = texte;
  2413. eNewInput.type = "button";
  2414. var eForm = eDiv.parentNode;
  2415. window.console.log("insertButtonCdmSmartphone tag eNewDiv=" + eNewDiv.nodeName + ', parent tag=' + eForm.nodeName);
  2416. eForm.insertBefore(eNewDiv, eForm.firstChild);
  2417. return true;
  2418. }
  2419. */
  2420.  
  2421. function insertButtonCdm(nextName,onClick,texte) {
  2422. if (texte==null) texte = 'Participer au bestiaire';
  2423. //if (insertButtonCdmSmartphone(nextName,onClick,texte)) return;
  2424.  
  2425. var nextNode = document.getElementsByName(nextName)[0];
  2426. var espace = document.createTextNode('\t');
  2427. insertBefore(nextNode,espace);
  2428.  
  2429. var button = document.createElement('input');
  2430. button.type = 'button';
  2431. button.className = 'mh_form_submit';
  2432. button.value = texte;
  2433. button.onmouseover = function(){this.style.cursor='pointer';};
  2434. if (onClick) button.onclick = onClick;
  2435. insertBefore(espace,button);
  2436. return button;
  2437. }
  2438.  
  2439. function createCDMTable(id,nom,donneesMonstre, closeFunct) { // rend un Élément Table
  2440. try {
  2441. var table = document.createElement('table');
  2442. var profilActif = isProfilActif();
  2443. table.className = 'mh_tdborder';
  2444. table.border = 0;
  2445. table.cellSpacing = 1;
  2446. table.cellPadding = 4;
  2447.  
  2448. var thead = document.createElement('thead');
  2449. var tr = appendTr(thead,'mh_tdtitre');
  2450. var td = appendTdText(tr, 'CDM de ' + nom + ' (N° '+ id + ')', false);
  2451. td.style.fontWeight = 'bold';
  2452. if (closeFunct) {
  2453. td.colSpan = 2;
  2454. td.style.borderRight = 'none';
  2455. td = appendTdText(tr, 'X', false);
  2456. td.style.cursor = 'pointer';
  2457. td.style.textAlign = 'right';
  2458. td.style.fontWeight = 'bold';
  2459. td.style.width = '1%';
  2460. td.style.borderLeft = 'none';
  2461. td.onclick = closeFunct;
  2462. } else {
  2463. td.colSpan = 3;
  2464. }
  2465. table.appendChild(thead);
  2466. var tbody = document.createElement('tbody');
  2467. table.appendChild(tbody);
  2468.  
  2469. // calcul des PX gagnés
  2470. var ominmaxPX = {};
  2471. if (donneesMonstre.niv) {
  2472. if (donneesMonstre.niv.min) ominmaxPX.min = getPXKill(donneesMonstre.niv.min);
  2473. if (donneesMonstre.niv.max) ominmaxPX.max = getPXKill(donneesMonstre.niv.max);
  2474. }
  2475.  
  2476. MZ_tab_carac_add_tr_minmax2(tbody, 'Niveau', donneesMonstre.niv, 'PX', ominmaxPX);
  2477. MZ_tab_carac_add_tr_texte(tbody, 'Famille', donneesMonstre.fam, '');
  2478. //MZ_tab_carac_add_tr_texte(tbody, 'Génération', donneesMonstre.gen == 23 ? '2 ou 3' : donneesMonstre.gen, ''); // remplacé par une icône
  2479. MZ_tab_carac_add_tr_texte(tbody, 'Blessure', MZ_tab_carac_mkBlessureTexte(donneesMonstre), '');
  2480. MZ_tab_carac_add_tr_minmax(tbody, 'Points de Vie', donneesMonstre.pv, 'PV');
  2481. MZ_tab_carac_add_tr_minmax(tbody, 'Attaque', donneesMonstre.att, 'D6');
  2482. MZ_tab_carac_add_tr_minmax(tbody, 'Esquive', donneesMonstre.esq, 'D6');
  2483. MZ_tab_carac_add_tr_minmax(tbody, 'Dégâts', donneesMonstre.deg, 'D3');
  2484. MZ_tab_carac_add_tr_minmax(tbody, 'Régénération', donneesMonstre.reg, 'D3');
  2485. MZ_tab_carac_add_tr_minmax(tbody, 'Armure physique', donneesMonstre.armP, '');
  2486. MZ_tab_carac_add_tr_minmax(tbody, 'Armure magique', donneesMonstre.armM, '');
  2487. MZ_tab_carac_add_tr_minmax(tbody, 'Armure totale', donneesMonstre.arm, '');
  2488. MZ_tab_carac_add_tr_minmax(tbody, 'Vue', donneesMonstre.vue, 'Case(s)');
  2489. MZ_tab_carac_add_tr_minmax(tbody, 'MM', donneesMonstre.MM, '');
  2490. MZ_tab_carac_add_tr_minmax(tbody, 'RM', donneesMonstre.RM, '');
  2491. MZ_tab_carac_add_tr_minmax(tbody, 'Durée du tour', donneesMonstre.duree, ' heures');
  2492. MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre);
  2493. MZ_tab_carac_add_tr_autres(tbody, donneesMonstre, id, nom);
  2494. /* à supprimer, remplacé par un "title" sur le 3e td de "autres"
  2495. var msgInfo = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2496. if (msgInfo) MZ_tab_carac_add_tr_sansTitre(tbody, msgInfo, 0, true);
  2497. */
  2498. return table;
  2499. }
  2500. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2501. }
  2502.  
  2503. function MZ_tab_carac_mkBlessureTexte(donneesMonstre) {
  2504. if (donneesMonstre.bless === undefined) return;
  2505. var texte = donneesMonstre.bless + '%';
  2506. if (donneesMonstre.bless > 0 && donneesMonstre.pv && donneesMonstre.pv.min && donneesMonstre.pv.max) {
  2507. ominmax = MZ_getPVsRestants(donneesMonstre.pv, donneesMonstre.bless);
  2508. texte += ' (' + ominmax.min + '-' + ominmax.max + ')';
  2509. }
  2510. if (donneesMonstre.timegmt) {
  2511. texte += ' le ' + MZ_formatDateMS(new Date(donneesMonstre.timegmt * 1000), true);
  2512. }
  2513. return texte;
  2514. }
  2515.  
  2516. function MZ_tab_carac_add_tr_sansTitre(table, msg, bItalic) {
  2517. if (!msg) return;
  2518. var tr = appendTr(table,'mh_tdpage');
  2519. td = appendTdText(tr,msg);
  2520. td.colSpan = 3;
  2521. if (bItalic) td.style.fontStyle = 'italic';
  2522. td.className = 'mh_tdpage';
  2523. return td;
  2524. }
  2525.  
  2526. function MZ_tab_carac_add_tr_pouvoir(tbody, donneesMonstre) {
  2527. if (!donneesMonstre.pouv) return;
  2528. var td = MZ_tab_carac_add_tr_texte(tbody, 'Pouvoir', donneesMonstre.pouv + ' ', '', 0);
  2529. var tabImg = [];
  2530. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.portpouv, {
  2531. 'de zone': ["zone.gif","Pouvoir de zone"],
  2532. 'automatique': ["automatique.gif","Pouvoir automatique"],
  2533. 'au toucher': ["toucher.gif","Pouvoir au toucher"]});
  2534. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2535. var thisImg = tabImg[iImg];
  2536. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2537. }
  2538. }
  2539.  
  2540. function MZ_tab_carac_add_tr_autres(table, donneesMonstre, id, nom) {
  2541. var tabImg = [];
  2542. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attd, {
  2543. '1': ["distance.gif","Attaque à distance"],
  2544. '~': ["cac.gif","Corps à corps"]}); // si absent
  2545. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.nb_att, {
  2546. '1': ["1.gif","1 attaque par tour"],
  2547. '2': ["2.gif","2 attaques par tour"],
  2548. '3': ["3.gif","3 attaques par tour"],
  2549. '4': ["4.gif","4 attaques par tour"],
  2550. '5': ["5.gif","5 attaques par tour"],
  2551. '6': ["6.gif","6 attaques par tour"],
  2552. '999': ["plus.gif","Beaucoup d'attaques par tour"]});
  2553. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.attm, {
  2554. '1': ["magic-wand.png","Attaque magique"]});
  2555. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vit, {
  2556. 'lente': ["lent.gif","Lent à se déplacer"],
  2557. 'normale': ["normal.gif","Vitesse normale de déplacement"],
  2558. 'rapide': ["rapide.gif","Déplacement rapide"]});
  2559. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.charg, {
  2560. 'vide': [null,null],
  2561. '~': ["charge2.gif", "Possède de l'équipement (" + donneesMonstre.charg + ")"]});
  2562. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.vlc, {
  2563. '1': ["oeil.gif","Voit le caché"]});
  2564. MZ_tab_carac_add_tr_one_img(tabImg, donneesMonstre.gen, {
  2565. '1': ["Phoenix1.png","Phœnix de première génération"],
  2566. '2': ["Phoenix2.png","Phœnix de deuxième génération"],
  2567. '3': ["Phoenix3.png","Phœnix de troisième génération"],
  2568. '23': ["Phoenix23.png","Phœnix de deuxième ou troisième génération"],
  2569. });
  2570.  
  2571. var tr = appendTr(table,'mh_tdpage');
  2572. var td = appendTdText(tr,'Autres',true);
  2573. td.className = 'mh_tdtitre';
  2574. td.width = MZ_EtatCdMs.tdWitdh;
  2575.  
  2576. td = appendTd(tr);
  2577. td.className = 'mh_tdpage';
  2578. for (var iImg = 0; iImg < tabImg.length; iImg++) {
  2579. var thisImg = tabImg[iImg];
  2580. td.appendChild(createImage(URL_MZimg + thisImg[0],thisImg[1]));
  2581. }
  2582. if (donneesMonstre.esq != undefined) {
  2583. td.appendChild(MZ_Tactique.createImage(id, nom));
  2584. }
  2585.  
  2586. var txt = String.fromCharCode(160); // blanc insécable
  2587. if (donneesMonstre.nCdM) txt = donneesMonstre.nCdM;
  2588. var td2 = appendTdText(tr, txt);
  2589. td2.title = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  2590. td2.style.width = '1%';
  2591. var myColor = MZ_CdMColorFromMode(donneesMonstre);
  2592. if (myColor) {
  2593. td2.style.backgroundColor = myColor;
  2594. td2.style.color = 'white';
  2595. }
  2596.  
  2597. return td;
  2598. }
  2599.  
  2600. function MZ_tab_carac_add_tr_one_img(tabImg, val, listCas) {
  2601. if (val == undefined) return;
  2602. //console.log('MZ_tab_carac_add_tr_one_img: val=' + val);
  2603. var lVal = (val + '').toLowerCase(); // astuce : transformer le nombre en string (beurk !)
  2604. if (listCas[lVal]) {
  2605. var t = listCas[lVal];
  2606. if (t[0] == null) return;
  2607. tabImg.push(t);
  2608. } else if (listCas['~']) {
  2609. tabImg.push(listCas['~']);
  2610. }
  2611. }
  2612.  
  2613. function MZ_tab_carac_add_tr_texte(table, titre, msg, unit) {
  2614. if (!msg) return;
  2615. var tr = appendTr(table,'mh_tdpage');
  2616.  
  2617. var td = appendTdText(tr,titre,true);
  2618. td.className = 'mh_tdtitre';
  2619. td.width = MZ_EtatCdMs.tdWitdh;
  2620.  
  2621. var texte = msg;
  2622. if (unit) texte += ' ' + unit;
  2623. td = appendTdText(tr,texte);
  2624. td.colSpan = 2;
  2625. td.className = 'mh_tdpage';
  2626. return td;
  2627. }
  2628.  
  2629. function MZ_tab_carac_add_tr_minmax(table, titre, ominmax, unit) {
  2630. if (!ominmax) return;
  2631. if (!(ominmax.min || ominmax.max)) return;
  2632.  
  2633. var tr = appendTr(table,'mh_tdpage');
  2634.  
  2635. var td = appendTdText(tr,titre,true);
  2636. td.className = 'mh_tdtitre';
  2637. td.width = MZ_EtatCdMs.tdWitdh;
  2638.  
  2639. if ((!ominmax.min) || ominmax.min == 0) {
  2640. var texte = '\u2A7D' + ominmax.max + '\u00A0' + unit; // <= (mais plus beau)
  2641. } else if (!ominmax.max) {
  2642. var texte = '\u2A7E' + ominmax.min + '\u00A0' + unit; // >=
  2643. } else {
  2644. var texte = '';
  2645. if (ominmax.min != ominmax.max) {
  2646. var texte = ominmax.min + '-' + ominmax.max + '\u00A0-->\u00A0';
  2647. if (ominmax.min > ominmax.max) {
  2648. td.style.color = 'red';
  2649. unit += ' *** erreur ***';
  2650. }
  2651. }
  2652. texte += ((ominmax.min + ominmax.max)/2) + '\u00A0' + unit;
  2653. }
  2654. td = appendTdText(tr,texte);
  2655. if (ominmax.min2 || ominmax.max2) { // affichage de l'intervalle de confiance à 80%
  2656. if (!ominmax.min2) {
  2657. var txt2 = '\u2A7D' + ominmax.max2; // <= (mais plus beau)
  2658. } else if (!ominmax.max2) {
  2659. var txt2 = '\u2A7E' + ominmax.min2; // >=
  2660. } else {
  2661. var txt2 = ominmax.min2 + '-' + ominmax.max2;
  2662. }
  2663. var span = document.createElement('span');
  2664. span.appendChild(document.createTextNode(txt2));
  2665. span.style.float = 'right';
  2666. span.style.textAlign = 'right';
  2667. span.style.background = 'yellow';
  2668. td.insertBefore(span, td.firstChild);
  2669. table.title = 'En jaune : intervalle de confiance à 80%';
  2670. }
  2671. td.colSpan = 2;
  2672. td.className = 'mh_tdpage';
  2673. return td;
  2674. }
  2675.  
  2676. function MZ_tab_carac_add_tr_minmax2(table, titre, ominmax, unit, ominmaxUnit) {
  2677. if (!ominmax) return;
  2678. if (!(ominmax.min || ominmax.max)) return;
  2679.  
  2680. var tr = appendTr(table,'mh_tdpage');
  2681.  
  2682. var td = appendTdText(tr,titre,true);
  2683. td.className = 'mh_tdtitre';
  2684. td.width = MZ_EtatCdMs.tdWitdh;
  2685.  
  2686. if ((!ominmax.min) || ominmax.min == 0) {
  2687. var texte = '\u2A7D' + ominmax.max;
  2688. } else if (!ominmax.max) {
  2689. var texte = '\u2A7E' + ominmax.min;
  2690. } else {
  2691. var texte = '';
  2692. if (ominmax.min != ominmax.max) {
  2693. var texte = ominmax.min + '-' + ominmax.max;
  2694. if (ominmax.min > ominmax.max) {
  2695. td.style.color = 'red';
  2696. texte += ' *** erreur ***';
  2697. }
  2698. } else {
  2699. var texte = ominmax.min;
  2700. }
  2701. }
  2702.  
  2703. if (ominmaxUnit.min === undefined) {
  2704. if (ominmaxUnit.max === undefined) {
  2705. // ignore (ne devrait pas arriver)
  2706. } else {
  2707. texte += ' --> ' + unit + '\u2A7D' + ominmaxUnit.max;
  2708. }
  2709. } else {
  2710. if (ominmaxUnit.max === undefined) {
  2711. texte += ' --> ' + unit + '\u2A7E' + ominmaxUnit.min;
  2712. } else if (ominmaxUnit.min != ominmaxUnit.max) {
  2713. texte += ' --> ' + ominmaxUnit.min + '\u2A7D' + unit + '\u2A7D' + ominmaxUnit.max;
  2714. if (ominmaxUnit.min > ominmaxUnit.max) {
  2715. td.style.color = 'red';
  2716. texte += ' *** erreur ***';
  2717. }
  2718. } else if (isNaN(ominmaxUnit.min)) {
  2719. texte += ' --> ' + ominmaxUnit.min;
  2720. } else {
  2721. texte += ' --> ' + ominmaxUnit.max + '\u00A0' + unit;
  2722. }
  2723. }
  2724.  
  2725. td = appendTdText(tr,texte);
  2726. td.colSpan = 2;
  2727. td.className = 'mh_tdpage';
  2728. return td;
  2729. }
  2730.  
  2731.  
  2732. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2733.  
  2734. var listeMonstreEnchantement = null,
  2735. listeEquipementEnchantement = null,
  2736. listeInfoEnchantement = null;
  2737.  
  2738. function computeCompoEnchantement()
  2739. {
  2740. listeMonstreEnchantement = new Array();
  2741. listeInfoEnchantement = new Array();
  2742. listeEquipementEnchantement = new Array();
  2743. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2744. for(var i=0;i<liste.length;i++)
  2745. {
  2746. var idEquipement = liste[i]*1;
  2747. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2748. continue;
  2749. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2750. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2751. var texteGlobal='';
  2752. for(var j=0;j<3;j++)
  2753. {
  2754. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  2755. var v = MY_getValue(k);
  2756. var infoComposant = MY_getValue().split(';');
  2757. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  2758. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  2759. continue;
  2760. }
  2761. listeMonstreEnchantement[infoComposant[2]] = 1;
  2762. var array = new Array();
  2763. array[0]=infoComposant[0].replace("Ril","Œil");
  2764. array[1]=infoComposant[1];
  2765. array[2]=infoComposant[2];
  2766. array[3]=getQualite(infoComposant[3]);
  2767. var texte = infoComposant[4].replace("Ril","Œil");
  2768. for(var k=5;k<infoComposant.length;k++)
  2769. {
  2770. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2771. }
  2772. texteGlobal+=texte+'\n';
  2773. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2774. array[4]=texte;
  2775. listeInfoEnchantement.push(array);
  2776. }
  2777. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2778. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2779. }
  2780.  
  2781. }
  2782.  
  2783. function isEnchant(nom) {
  2784. var monstreEnchant = '';
  2785. for(j in listeInfoEnchantement) {
  2786. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2787. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2788. monstreEnchant=monstre;
  2789. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2790. }
  2791. }
  2792. return trim(monstreEnchant);
  2793. }
  2794.  
  2795. function getInfoEnchantementFromMonstre(nom)
  2796. {
  2797. try
  2798. {
  2799. if(!listeMonstreEnchantement)
  2800. {
  2801. computeCompoEnchantement();
  2802. }
  2803. var infosEnchant = '';
  2804. for(j in listeInfoEnchantement) {
  2805. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2806. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2807. if(infosEnchant=='')
  2808. infosEnchant=listeInfoEnchantement[j][4];
  2809. else
  2810. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2811. }
  2812. }
  2813. return trim(infosEnchant);
  2814. }
  2815. catch(e)
  2816. {
  2817. window.alert(e);
  2818. }
  2819. }
  2820.  
  2821. function composantEnchant(Monstre,composant,localisation,qualite) {
  2822. var compo='';
  2823. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2824. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2825. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2826. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2827. listeInfoEnchantement[i][3]<=qualite
  2828. ) {
  2829. return listeInfoEnchantement[i][4];
  2830. }
  2831. }
  2832. return compo;
  2833. }
  2834.  
  2835. function insertEnchantInfos(tbody) {
  2836. try
  2837. {
  2838. if(!listeMonstreEnchantement)
  2839. computeCompoEnchantement();
  2840. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2841. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2842. if(nodes.snapshotLength == 0)
  2843. return false;
  2844. var urlImg = URL_MZimg + 'enchant.png';
  2845. for(var i = 0; i < nodes.snapshotLength; i++) {
  2846. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2847. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2848. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2849. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2850. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2851. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2852. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2853. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2854. if(isEnchant(nomMonstre).length>0)
  2855. {
  2856. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2857. if(infos.length>0)
  2858. {
  2859. if(link.parentNode == link.nextSibling.parentNode)
  2860. {
  2861. var tmp = link.nextSibling;
  2862. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2863. }
  2864. else
  2865. {
  2866. link.parentNode.appendChild(createImage(urlImg,infos));
  2867. }
  2868. }
  2869. }
  2870. }
  2871. }
  2872. catch(e)
  2873. {
  2874. window.alert(e);
  2875. }
  2876. }
  2877.  
  2878. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2879. {
  2880. try
  2881. {
  2882. if(!listeMonstreEnchantement)
  2883. computeCompoEnchantement();
  2884. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2885. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2886. if(nodes.snapshotLength == 0)
  2887. return false;
  2888. var urlImg = URL_MZimg + 'enchant.png';
  2889. for(var i = 0; i < nodes.snapshotLength; i++)
  2890. {
  2891. var link = nodes.snapshotItem(i);
  2892. var idEquipement = link.getAttribute('href');
  2893. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2894. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2895. var nomEquipement = trim(link.firstChild.nodeValue);
  2896. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2897. if(!enchanteur || enchanteur == '')
  2898. continue;
  2899. var infos = listeEquipementEnchantement[idEquipement];
  2900. infos=formateTexte(infos);
  2901. if(infos.length>0)
  2902. {
  2903. if(link.parentNode == link.nextSibling.parentNode)
  2904. {
  2905. var tmp = link.nextSibling;
  2906. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2907. }
  2908. else
  2909. {
  2910. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2911. }
  2912. }
  2913. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2914. }
  2915. }
  2916. catch(e)
  2917. {
  2918. window.alert(e);
  2919. }
  2920. }
  2921.  
  2922. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2923. // Cette section est commune à InfoMonstre et Vue
  2924.  
  2925. var MZ_Tactique = {
  2926. // Variables
  2927. popup: null,
  2928.  
  2929. // Méthodes
  2930. createImage: function(id, nom) {
  2931. // Création de l'image portant le popup tactique
  2932. var img = document.createElement('img');
  2933. img.src = URL_MZimg +
  2934. (isPage('View/MonsterView') ? 'calc.png' : 'calc2.png');
  2935. img.id = id;
  2936. img.nom = nom;
  2937. img.style.verticalAlign = 'middle';
  2938. img.onmouseover = MZ_Tactique.showPopup;
  2939. img.onmouseout = MZ_Tactique.hidePopup;
  2940. return img;
  2941. },
  2942.  
  2943. hidePopup: function() {
  2944. // Masquage du popup tactique
  2945. MZ_Tactique.popup.style.display = 'none';
  2946. },
  2947.  
  2948. initPopup: function() {
  2949. /** @mandatory Initialisation du popup tactique */
  2950. MZ_Tactique.popup = document.createElement('div');
  2951. MZ_Tactique.popup.id = 'MZ_Tactique.popup';
  2952. MZ_Tactique.popup.className = 'mh_textbox';
  2953. MZ_Tactique.popup.style =
  2954. 'position: absolute;' +
  2955. 'border: 1px solid #000000;' +
  2956. 'display: none;' +
  2957. 'z-index: 3;' +
  2958. 'max-width: 400px;';
  2959. document.body.appendChild(MZ_Tactique.popup);
  2960. },
  2961.  
  2962. showPopup: function(evt) {
  2963. // Affichage du popup tactique
  2964. try {
  2965. var id = this.id;
  2966. var nom = this.nom;
  2967. var texte = getAnalyseTactique(id, nom);
  2968. if (texte == undefined || texte == '') return;
  2969. MZ_Tactique.popup.innerHTML = texte;
  2970. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  2971. if (isPage('View/MonsterView')) {
  2972. MZ_Tactique.popup.style.left = Math.min(evt.pageX - 120, window.innerWidth - 300) + 'px';
  2973. } else {
  2974. MZ_Tactique.popup.style.left = Math.min(evt.pageX + 15, window.innerWidth - 400) + 'px';
  2975. }
  2976. MZ_Tactique.popup.style.top = evt.pageY + 15 + 'px';
  2977. MZ_Tactique.popup.style.display = 'block';
  2978. } catch (e) {
  2979. // window.alert(e);
  2980. window.console.error(e);
  2981. }
  2982. }
  2983. };
  2984.  
  2985. // Les % de toucher
  2986. var c = new Array();
  2987.  
  2988. // coefficients binomiaux
  2989. function cnp(n,k)
  2990. {
  2991. if(c[n] != null && c[n][k] != null)
  2992. return c[n][k];
  2993. if(c[n] == null)
  2994. c[n] = new Array();
  2995. if(k==0)
  2996. {
  2997. c[n][k] = 1;
  2998. return 1;
  2999. }
  3000. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  3001. c[n][k] = result;
  3002. // Roule debug
  3003. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  3004. return result;
  3005. }
  3006.  
  3007. // by Dab, à comparer
  3008. function binom(n,p) {
  3009. if(p<0 || p>n) return 0;
  3010.  
  3011. if(c[n])
  3012. if(c[n][p]) return c[n][p];
  3013. else {
  3014. c[n]=[1];
  3015. c[n][n]=1;
  3016. if(p==0 || p==n) return 1;
  3017. }
  3018.  
  3019. if(2*p>n)
  3020. c[n][p]=binom(n,n-p);
  3021. else
  3022. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  3023.  
  3024. return c[n][p];
  3025. }
  3026.  
  3027. var coeff = new Array();
  3028.  
  3029. function coef(n,p)
  3030. {
  3031. if(n==0 && p==0)
  3032. return 1;
  3033. if(p>n*3.5)
  3034. p = 7*n-p
  3035. // roule désactive cache
  3036. if(coeff[n] != null && coeff[n][p] !=null)
  3037. return coeff[n][p];
  3038. if(coeff[n] == null)
  3039. coeff[n] = new Array();
  3040. var kmax = Math.floor((p-n)/6);
  3041. var x=0;
  3042. for(var k=0;k<=kmax;k++)
  3043. {
  3044. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  3045. }
  3046. coeff[n][p] = x;
  3047. // Roule debug
  3048. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  3049. return x;
  3050. }
  3051.  
  3052. function chanceEsquiveParfaite(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(6*a+ba<2*(d+bd))
  3061. return 100;
  3062. if(a+ba>2*(6*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(2*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. // roule debug
  3076. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  3077. return Math.round(100*win/(win+los));
  3078. }
  3079.  
  3080. function chanceTouche(a,d,ba,bd)
  3081. {
  3082. var win = 0;
  3083. var los = 0;
  3084. if(ba==null)
  3085. ba=0;
  3086. if(bd==null)
  3087. bd=0;
  3088. if(a+ba>6*d+bd)
  3089. return 100;
  3090. if(6*a+ba<d+bd)
  3091. return 0;
  3092. for(var ds=d;ds<=6*d;ds++)
  3093. {
  3094. var cd = coef(d,ds);
  3095. for(var as=a;as<=6*a;as++)
  3096. {
  3097. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  3098. win += cd * coef(a,as);
  3099. else
  3100. los += cd * coef(a,as);
  3101. }
  3102. }
  3103. return Math.round(100*win/(win+los));
  3104. }
  3105.  
  3106. function chanceCritique(a,d,ba,bd)
  3107. {
  3108. var win = 0;
  3109. var los = 0;
  3110. if(ba==null)
  3111. ba=0;
  3112. if(bd==null)
  3113. bd=0;
  3114. if(a+ba>2*(6*d+bd))
  3115. return 100;
  3116. if(6*a+ba<2*(d+bd))
  3117. return 0;
  3118. for(var ds=d;ds<=6*d;ds++)
  3119. {
  3120. var cd = coef(d,ds);
  3121. for(var as=a;as<=6*a;as++)
  3122. {
  3123. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  3124. win += cd * coef(a,as);
  3125. else
  3126. los += cd * coef(a,as);
  3127. }
  3128. }
  3129. return Math.round(100*win/(win+los));
  3130. }
  3131.  
  3132. /***********************************************
  3133. Analyse tactique
  3134. ***********************************************/
  3135.  
  3136. function getTexteAnalyse(modificateur,chiffre)
  3137. {
  3138. if(chiffre==0)
  3139. return chiffre;
  3140. return modificateur+ chiffre;
  3141. }
  3142.  
  3143. // rend le HTML pour le tableau de la "calculette"
  3144. function getAnalyseTactique(id,nom) {
  3145. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  3146. var needAutres=false;
  3147. var i;
  3148. if(donneesMonstre == null)
  3149. return;
  3150. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  3151. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  3152. if(array==null)
  3153. return "";
  3154. 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>";
  3155. for(i=0;i<array.length;i++)
  3156. {
  3157. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  3158. {
  3159. needAutres=true;
  3160. break;
  3161. }
  3162. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  3163. 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>";
  3164. else if(i==0) // attaque du monstre sur le Trõll => italique
  3165. 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>";
  3166. else // autre, pas de décoration
  3167. 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>";
  3168. }
  3169. if(needAutres)
  3170. {
  3171. if(i==array.length-1)
  3172. 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>";
  3173. else if(i==1)
  3174. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  3175. else
  3176. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  3177. }
  3178. var txtCdM = MZ_carac_build_nb_cmd_msg(donneesMonstre);
  3179. if (txtCdM) str += '<tr class="mh_tdpage"><td colspan="5" style="font-style: italic;">' + txtCdM + '</td></tr>';
  3180. return str+"</table>";
  3181. }
  3182.  
  3183. function MZ_carac_build_nb_cmd_msg(donneesMonstre) {
  3184. if (!donneesMonstre) return;
  3185. if (!donneesMonstre.Mode) return;
  3186. switch (donneesMonstre.Mode) {
  3187. case 'cdm':
  3188. return 'fondé sur ' + (+donneesMonstre.nCdM) + ' CdM' + (donneesMonstre.nCdM > 1 ? 's' : '') + ' de ce monstre à cet âge';
  3189. case 'stat':
  3190. 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)';
  3191. case 'statV1':
  3192. return 'fondé sur les statistiques anciennes (MZ V1)';
  3193. case 'nom':
  3194. return 'fondé sur le nom du monstre, pas de CdM';
  3195. }
  3196. return 'Mode ' + donneesMonstre.Mode;
  3197. }
  3198.  
  3199. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  3200. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  3201. function analyseTactique(donneesMonstre,nom) {
  3202. try
  3203. {
  3204. var listeAttaques = [];
  3205. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  3206. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  3207. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  3208. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  3209. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  3210. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  3211. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  3212. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  3213. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  3214. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  3215. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  3216. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  3217. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  3218. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  3219. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  3220. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  3221. var modificateurEsquive = '';
  3222. var modificateurArmure = '';
  3223. var modificateurMagie = '';
  3224. var modificateurEsquiveM = '';
  3225. var modificateurArmureM = '';
  3226. var pasDeSR=false;
  3227. var esqM=0,attM=0,armM_mag=0,armM_tot=0,degM=0;
  3228. 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)
  3229. return null;
  3230.  
  3231. if (MY_DEBUG) window.console.log('analyseTactique nom=' + nom + ' ' + JSON.stringify(donneesMonstre));
  3232. if (donneesMonstre.index == undefined) {
  3233. // à supprimer
  3234. var td = document.createElement('td')
  3235. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  3236. var esqM = 0;
  3237. try
  3238. {
  3239. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3240. }
  3241. catch(e)
  3242. {
  3243. debugMZ('analyseTactique, exeception calcul esqM ' + e.message);
  3244. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3245. modificateurEsquive = '<';
  3246. modificateurArmure = '<';
  3247. modificateurMagie = '<';
  3248. }
  3249.  
  3250. td.innerHTML = bbcode(donneesMonstre[3]);
  3251. var attM = 0;
  3252. try
  3253. {
  3254. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3255. }
  3256. catch(e)
  3257. {
  3258. debugMZ('analyseTactique, exeception calcul attM ' + e.message);
  3259. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3260. modificateurEsquiveM = '>';
  3261. modificateurArmureM = '>';
  3262. }
  3263.  
  3264. td.innerHTML = bbcode(donneesMonstre[5]);
  3265. var degM = 0;
  3266. try
  3267. {
  3268. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3269. }
  3270. catch(e)
  3271. {
  3272. debugMZ('analyseTactique, exeception calcul degM ' + e.message);
  3273. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  3274. modificateurArmureM = '>';
  3275. }
  3276.  
  3277. td.innerHTML = bbcode(donneesMonstre[7]);
  3278. try
  3279. {
  3280. armM_tot=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3281. armM_mag=armM_tot; // compatibilité avec ancien calcul
  3282. }
  3283. catch(e)
  3284. {
  3285. debugMZ('analyseTactique, exeception calcul armM ' + e.message);
  3286. armM_tot=Math.ceil(parseInt(td.firstChild.nodeValue));
  3287. armM_mag=armM_tot;
  3288. modificateurArmure = '<';
  3289. }
  3290.  
  3291. var coeffSeuil = 0.95;
  3292. try
  3293. {
  3294. td.innerHTML = bbcode(donneesMonstre[9]);
  3295. //debugMZ('analyseTactique, calcul SR, donnessMonstre=' + donneesMonstre[9] + ', bbcode=' + bbcode(donneesMonstre[9]));
  3296. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  3297. var v = (rm / mm);
  3298. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3299. coeffSeuil = (200-seuil)/200;
  3300. }
  3301. catch(e)
  3302. {
  3303. debugMZ('analyseTactique, exeception calcul SR ' + e.message);
  3304. modificateurMagie = '<';
  3305. pasDeSR = true;
  3306. }
  3307. } else {
  3308. //calcul de modificateurEsquive, modificateurArmure, modificateurMagie, modificateurEsquiveM, modificateurArmureM, pasDeSR, esqM, attM, armM_mag, armM_tot, degM;
  3309. if (donneesMonstre.esq) {
  3310. if (donneesMonstre.esq.min && donneesMonstre.esq.max) {
  3311. esqM = Math.ceil((donneesMonstre.esq.min + donneesMonstre.esq.max) / 2);
  3312. } else if (donneesMonstre.esq.max) {
  3313. esqM = donneesMonstre.esq.max;
  3314. modificateurEsquive = '<';
  3315. modificateurArmure = '<';
  3316. modificateurMagie = '<';
  3317. }
  3318. }
  3319.  
  3320. if (donneesMonstre.att) {
  3321. if (donneesMonstre.att.min && donneesMonstre.att.max) {
  3322. attM = Math.ceil((donneesMonstre.att.min + donneesMonstre.att.max) / 2);
  3323. } else if (donneesMonstre.att.max) {
  3324. attM = donneesMonstre.att.max;
  3325. modificateurEsquiveM = '>';
  3326. modificateurArmureM = '>';
  3327. }
  3328. }
  3329.  
  3330. if (donneesMonstre.armM) {
  3331. if (donneesMonstre.armM.min && donneesMonstre.armM.max) {
  3332. armM_mag = Math.ceil((donneesMonstre.armM.min + donneesMonstre.armM.max) / 2);
  3333. } else if (donneesMonstre.armM.max) {
  3334. armM_mag = donneesMonstre.armM.max;
  3335. modificateurArmure = '<';
  3336. }
  3337. if (donneesMonstre.armP) {
  3338. if (donneesMonstre.armP.min && donneesMonstre.armP.max) {
  3339. armM_phy = Math.ceil((donneesMonstre.armP.min + donneesMonstre.armP.max) / 2);
  3340. } else if (donneesMonstre.armP.max) {
  3341. armM_phy = donneesMonstre.armP.max;
  3342. modificateurArmure = '<';
  3343. }
  3344. armM_tot = armM_mag + armM_phy;
  3345. } else { // ça ne devrait pas arriver
  3346. armM_tot = armM_mag;
  3347. }
  3348. } else if (donneesMonstre.arm) {
  3349. if (donneesMonstre.arm.min && donneesMonstre.arm.max) {
  3350. armM_tot = Math.ceil((donneesMonstre.arm.min + donneesMonstre.arm.max) / 2);
  3351. armM_mag=armM_tot; // worst case
  3352. } else if (donneesMonstre.arm.max) {
  3353. armM_tot = donneesMonstre.arm.max;
  3354. armM_mag=armM_tot;
  3355. modificateurArmure = '<';
  3356. }
  3357. }
  3358.  
  3359. if (donneesMonstre.deg) {
  3360. if (donneesMonstre.deg.min && donneesMonstre.deg.max) {
  3361. degM = Math.ceil((donneesMonstre.deg.min + donneesMonstre.deg.max) / 2);
  3362. } else if (donneesMonstre.deg.max) {
  3363. degM = donneesMonstre.deg.max;
  3364. modificateurArmureM = '>';
  3365. }
  3366. }
  3367.  
  3368. var coeffSeuil = 0.95;
  3369. if (donneesMonstre.RM) {
  3370. if (donneesMonstre.RM.min && donneesMonstre.RM.max) {
  3371. var rmM = Math.ceil((donneesMonstre.RM.min + donneesMonstre.RM.max) / 2);
  3372. var v = (rmM / mm);
  3373. var seuil = (rmM < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  3374. coeffSeuil = (200-seuil)/200;
  3375. } else if (donneesMonstre.deg.max) {
  3376. }
  3377. modificateurMagie = '<';
  3378. pasDeSR = true;
  3379. }
  3380. }
  3381. 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);
  3382.  
  3383. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  3384. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  3385. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  3386. // roule debug
  3387. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  3388. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  3389. 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);
  3390. //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);
  3391. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3392. if(getSortComp("Vampirisme")>0)
  3393. {
  3394. var pour = getSortComp("Vampirisme");
  3395. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3396. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3397. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  3398. 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;
  3399. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3400. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3401. }
  3402. if(getSortComp("Siphon des âmes")>0)
  3403. {
  3404. var pour = getSortComp("Siphon des âmes");
  3405. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3406. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3407. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3408. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm-armM_mag,1))/100);
  3409. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3410. }
  3411. if(getSortComp("Botte Secrète")>0)
  3412. {
  3413. var pour = getSortComp("Botte Secrète");
  3414. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3415. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3416. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  3417. 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;
  3418. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3419. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3420. }
  3421. if(getSortComp("Rafale Psychique")>0)
  3422. {
  3423. var pour = getSortComp("Rafale Psychique");
  3424. chanceDEsquiveParfaite = 0;
  3425. chanceDeTouche = Math.round(100*pour/100);
  3426. chanceDeCritique = Math.round(0*pour/100);
  3427. 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;
  3428. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3429. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3430. }
  3431. if(getSortComp("Explosion")>0)
  3432. {
  3433. var pour = getSortComp("Explosion");
  3434. chanceDEsquiveParfaite = 0;
  3435. chanceDeTouche = Math.round(100*pour/100);
  3436. chanceDeCritique = Math.round(0*pour/100);
  3437. 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;
  3438. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3439. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  3440. }
  3441. if(getSortComp("Projectile Magique")>0)
  3442. {
  3443. var pour = getSortComp("Projectile Magique");
  3444. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  3445. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  3446. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  3447. // distance troll - monstre
  3448. 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;
  3449. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3450. if (donneesMonstre.index !== undefined && MZ_EtatCdMs.tr_monstres !== undefined && MZ_EtatCdMs.tr_monstres[donneesMonstre.index] !== undefined) {
  3451. var dist = getMonstreDistance(donneesMonstre.index);
  3452. //if (isDEV) window.console.log('Dist pour PM=' + dist);
  3453. var vue_bm = parseInt(MY_getValue(numTroll+".caracs.vue.bm"), 10);
  3454. var portee = getPortee(vue+vue_bm);
  3455. if (dist <= portee) {
  3456. degats = Math.round((degats + 2 * (portee-dist)) * 100) / 100;
  3457. } else {
  3458. degats += ' (plus bonus de portée)';
  3459. }
  3460. debugMZ('analyseTactique, iTR= ' + donneesMonstre.index + ', dist=' + dist + ', porteePM=' + portee);
  3461. } else {
  3462. degats += ' (plus bonus de portée)';
  3463. }
  3464. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3465. }
  3466. if(getSortComp("Frénésie")>0)
  3467. {
  3468. var pour = getSortComp("Frénésie");
  3469. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3470. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3471. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3472. 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;
  3473. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3474. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3475. }
  3476. if(getSortComp("Charger")>0)
  3477. {
  3478. var pour = getSortComp("Charger");
  3479. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  3480. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  3481. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  3482. 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;
  3483. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3484. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  3485. }
  3486. if(getSortComp("Griffe du Sorcier")>0)
  3487. {
  3488. var pour = getSortComp("Griffe du Sorcier");
  3489. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  3490. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  3491. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  3492. 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;
  3493. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  3494. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  3495. }
  3496. if(getSortComp("Attaque Précise",1)>0)
  3497. {
  3498. var niveau = 5;
  3499. var oldPour = 0;
  3500. var chanceDEsquiveParfaite = 0;
  3501. var chanceDeTouche = 0;
  3502. var chanceDeCritique = 0;
  3503. degats = 0;
  3504. while(niveau>0)
  3505. {
  3506. var pour = getSortComp("Attaque Précise",niveau);
  3507. if(pour>oldPour)
  3508. {
  3509. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3510. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3511. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3512. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3513. chanceDeTouche += chanceDeToucheNiveau;
  3514. chanceDeCritique += chanceDeCritiqueNiveau;
  3515. 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);
  3516. oldPour = pour;
  3517. }
  3518. niveau--;
  3519. }
  3520. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3521. 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));
  3522. }
  3523. if(getSortComp("Coup de Butoir",1)>0)
  3524. {
  3525. var niveau = 5;
  3526. var oldPour =0;
  3527. var chanceDEsquiveParfaite = 0;
  3528. var chanceDeTouche=0;
  3529. var chanceDeCritique=0;
  3530. degats=0;
  3531. while(niveau>0)
  3532. {
  3533. var pour = getSortComp("Coup de Butoir",niveau);
  3534. if(pour>oldPour)
  3535. {
  3536. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3537. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3538. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  3539. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  3540. chanceDeTouche += chanceDeToucheNiveau;
  3541. chanceDeCritique += chanceDeCritiqueNiveau;
  3542. 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);
  3543. oldPour = pour;
  3544. }
  3545. niveau--;
  3546. }
  3547. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  3548. 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));
  3549. }
  3550. 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;});
  3551. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  3552. {
  3553. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  3554. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  3555. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  3556. }
  3557. else
  3558. {
  3559. chanceDEsquiveParfaite = 0;
  3560. chanceDeTouche = 100;
  3561. chanceDeCritique = 0;
  3562. }
  3563. 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;
  3564.  
  3565. 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));
  3566. return listeAttaques;
  3567. }
  3568. catch(e) {
  3569. window.console.error(traceStack(e, 'analyseTactique'));
  3570. window.alert(e);
  3571. }
  3572. }
  3573.  
  3574. // x~~x marque pour s'y retrouver sous l'éditeur
  3575.  
  3576. /*
  3577. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  3578. * published under GNU License v2.
  3579. *
  3580. * Patch :
  3581. * gestion des missions terminées
  3582. */
  3583.  
  3584. // x~x mission_liste
  3585.  
  3586. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  3587. try {
  3588. var titresMimis = document.evaluate(
  3589. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  3590. document, null, 7, null
  3591. );
  3592. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3593. } catch(e) {
  3594. window.console.error(traceStack(e, 'mission_liste initialisation'));
  3595. return;
  3596. }
  3597.  
  3598. var enCours = {};
  3599. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  3600. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  3601. enCours[num] = true;
  3602. }
  3603.  
  3604. for(var numMimi in obMissions) {
  3605. if(!enCours[numMimi]) {
  3606. delete obMissions[numMimi];
  3607. }
  3608. }
  3609. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3610. }
  3611.  
  3612. function do_mission_liste() {
  3613. checkLesMimis();
  3614. }
  3615.  
  3616. /*******************************************************************************
  3617. * This file is part of Mountyzilla. *
  3618. * *
  3619. * Mountyzilla is free software; you can redistribute it and/or modify *
  3620. * it under the terms of the GNU General Public License as published by *
  3621. * the Free Software Foundation; either version 2 of the License, or *
  3622. * (at your option) any later version. *
  3623. * *
  3624. * Mountyzilla is distributed in the hope that it will be useful, *
  3625. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3626. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3627. * GNU General Public License for more details. *
  3628. * *
  3629. * You should have received a copy of the GNU General Public License *
  3630. * along with Mountyzilla; if not, write to the Free Software *
  3631. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3632. *******************************************************************************/
  3633.  
  3634. // x~x actions
  3635.  
  3636. /* TODO
  3637. * getLvl pour Explo, Rotobaffe et cie
  3638. */
  3639.  
  3640.  
  3641.  
  3642. /* Page de combat */
  3643.  
  3644. function getLevel() {
  3645. var divList = document.getElementsByTagName('div');
  3646. if(divList.length <= 2)
  3647. return;
  3648.  
  3649. // On essaie de voir si cette action était une attaque
  3650. var pList = document.getElementsByTagName('p');
  3651. var nomM = '';
  3652. // Modification pour Frénésie by TetDure
  3653. var numAtt = 0;
  3654. for (var i = 0; i < pList.length; i++) {
  3655. if(pList[i].firstChild) {
  3656. nomM = pList[i].firstChild.nodeValue;
  3657. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  3658. numAtt++;
  3659. }
  3660. }
  3661.  
  3662. if(nomM == '')
  3663. return;
  3664.  
  3665. // Si c'est une attaque normale, un seul PX
  3666. var comPX = 1;
  3667. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  3668. comPX++;
  3669.  
  3670. // Extraction des infos du monstre attaqué
  3671. var idM;
  3672. var male;
  3673. if(nomM.slice(20, 21) == 'e') {
  3674. male = false;
  3675. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3676. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  3677. }
  3678. else {
  3679. male = true;
  3680. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  3681. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  3682. }
  3683.  
  3684. if(idM == '')
  3685. return;
  3686.  
  3687. var bList = document.getElementsByTagName('b');
  3688. var niveau = '';
  3689. for (var i = 0; i < bList.length; i++) {
  3690. var b = bList[i];
  3691. if(b.childNodes[0].nodeValue != "TUÉ")
  3692. continue;
  3693. var nbPX = "";
  3694. for (i++; i < bList.length; i++) {
  3695. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  3696. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  3697. return;
  3698. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  3699. nbPX = bList[i].childNodes[0].nodeValue;
  3700. break;
  3701. }
  3702. }
  3703. if(nbPX == '')
  3704. return;
  3705. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  3706. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  3707. if(!nbPX)
  3708. nbPX = 0;
  3709. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  3710. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  3711. if(comPX > nbPX) {
  3712. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  3713. niveau = "";
  3714. } else if(Math.floor(niveau) == niveau) {
  3715. chaine += niveau + ".";
  3716. } else {
  3717. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  3718. niveau = "";
  3719. }
  3720. insertBr(b.nextSibling.nextSibling.nextSibling);
  3721. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  3722. }
  3723.  
  3724. if(niveau != '') {
  3725. var button = insertButtonCdm('as_Action');
  3726. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  3727. + escape(nomM) + "&niveau=" + escape(niveau)
  3728. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  3729. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  3730. }
  3731. }
  3732.  
  3733.  
  3734. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  3735.  
  3736. function insertInfoMagie(node, intitule, magie) {
  3737. if(node.nextSibling) {
  3738. node = node.nextSibling;
  3739. insertBr(node);
  3740. insertText(node, intitule);
  3741. insertText(node, magie, true);
  3742. } else {
  3743. node = node.parentNode;
  3744. appendBr(node);
  3745. appendText(node, intitule);
  3746. appendText(node, magie, true);
  3747. }
  3748. }
  3749.  
  3750. function getMM(sr) {
  3751. if(rmTroll<=0) {
  3752. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  3753. }
  3754. sr = Number(sr.match(/\d+/)[0]);
  3755. if(sr==10) {
  3756. return '\u2265 '+5*rmTroll;
  3757. }
  3758. if(sr<=50) {
  3759. return Math.round(50*rmTroll/sr);
  3760. }
  3761. if(sr<90) {
  3762. return Math.round((100-sr)*rmTroll/50);
  3763. }
  3764. return '\u2264 '+Math.round(rmTroll/5);
  3765. }
  3766.  
  3767. function traiteMM() {
  3768. var node = document.evaluate(
  3769. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  3770. document, null, 9, null).singleNodeValue;
  3771.  
  3772. if(node) {
  3773. var mm = getMM(node.nodeValue);
  3774. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3775. } else {
  3776. var node = document.evaluate(
  3777. "//p/text()[contains(., 'Seuil de Résistance')]",
  3778. document, null, 9, null).singleNodeValue;
  3779. if(!node) {
  3780. return;
  3781. }
  3782. var mm = getMM(node.nodeValue);
  3783. node = node.nextSibling.nextSibling;
  3784. }
  3785. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  3786. }
  3787.  
  3788. function getRM(sr) {
  3789. if(mmTroll<=0) {
  3790. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  3791. }
  3792. sr = Number(sr.match(/\d+/)[0]);
  3793. if(sr==10) {
  3794. return '\u2264 '+Math.round(mmTroll/5);
  3795. }
  3796. if(sr<=50) {
  3797. return Math.round(sr*mmTroll/50);
  3798. }
  3799. if(sr<90) {
  3800. return Math.round(50*mmTroll/(100-sr));
  3801. }
  3802. return '\u2265 '+5*mmTroll;
  3803. }
  3804.  
  3805. function traiteRM() {
  3806. var nodes = document.evaluate(
  3807. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  3808. document, null, 7, null);
  3809. if(nodes.snapshotLength==0) {
  3810. return;
  3811. }
  3812.  
  3813. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3814. var node = nodes.snapshotItem(i);
  3815. var rm = getRM(node.nodeValue);
  3816. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3817. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3818. }
  3819. }
  3820.  
  3821.  
  3822. /* Fonction stats IdT par Raistlin */
  3823.  
  3824. /*function getIdt() {
  3825. if(MY_getValue("SEND_IDT") == "non")
  3826. return false;
  3827.  
  3828. var regExpBeginning = /^\s+/;
  3829. var regExpEnd = /\s+$/;
  3830.  
  3831. var nomIdt = document.evaluate(
  3832. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3833. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3834. if(!nomIdt)
  3835. return false;
  3836.  
  3837. var caracIdt;
  3838. if(nomIdt.indexOf("Malédiction !") != -1) {
  3839. caracIdt = "";
  3840. nomIdt = "Mission maudite";
  3841. } else {
  3842. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3843. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3844. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3845. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3846. }
  3847. FF_XMLHttpRequest({
  3848. method: 'GET',
  3849. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3850. headers : {
  3851. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3852. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3853. }
  3854. });
  3855. return true;
  3856. }*/
  3857.  
  3858.  
  3859. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3860.  
  3861. function confirmeDecalage() {
  3862. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3863. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3864. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3865.  
  3866. var newDLA = new Date( oldDLA );
  3867. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3868. return window.confirm(
  3869. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3870. +'\nConfirmez-vous ce décalage ?'
  3871. );
  3872. }
  3873.  
  3874. function newsubmitDLA(evt) {
  3875. evt.stopPropagation();
  3876. evt.preventDefault();
  3877. if(confirmeDecalage()) {
  3878. this.submit();
  3879. }
  3880. }
  3881.  
  3882. function changeActionDecalage() {
  3883. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3884. return;
  3885. }
  3886. try {
  3887. // On récupère le contenu du script JS MH de calcul du décalage
  3888. var scriptTxt = document.evaluate(
  3889. ".//script[ not(@src) ]",
  3890. document, null, 9, null
  3891. ).singleNodeValue.textContent;
  3892. // On en extrait la DLA courante
  3893. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3894. scriptTxt = scriptTxt.split('\n')[0];
  3895. var nbs = scriptTxt.match(/\d+/g);
  3896. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3897. } catch(e) {
  3898. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3899. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3900. return;
  3901. }
  3902. var form = document.getElementsByName('ActionForm')[0];
  3903. if(form) {
  3904. form.addEventListener('submit', newsubmitDLA, true);
  3905. } else {
  3906. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3907. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3908. }
  3909. }
  3910.  
  3911. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3912.  
  3913. function prochainMundi() {
  3914. try {
  3915. var node;
  3916. node = document.evaluate(
  3917. "//div[@class='dateAction']/b",
  3918. document, null, 9, null
  3919. ).singleNodeValue;
  3920. if (document.evaluate) {
  3921. } else { // repli en JQuery
  3922. //node = $(
  3923. }
  3924. } catch(e) {
  3925. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3926. return;
  3927. }
  3928. if(!node) { return; }
  3929.  
  3930. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3931. var jour = longueurMois+1-getNumber(node.textContent);
  3932. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3933. var txt = '[Prochain Mundidey ';
  3934. if(jour>1) {
  3935. txt += 'dans '+jour+' jours]';
  3936. } else {
  3937. txt += 'demain]';
  3938. }
  3939. insertText(node.parentNode.nextSibling,txt,true);
  3940. }
  3941.  
  3942.  
  3943. /* Fonction principale */
  3944.  
  3945. function dispatch() {
  3946. if(isPage('MH_Play/Play_action')) {
  3947. prochainMundi();
  3948. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3949. var oldDLA;
  3950. changeActionDecalage();
  3951. } else if(isPage('MH_Play/Actions')) {
  3952. if(document.evaluate(
  3953. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3954. document, null, 2, null
  3955. ).stringValue) {
  3956. traiteMM();
  3957. } else if(document.evaluate(
  3958. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3959. document, null, 2, null
  3960. ).stringValue) {
  3961. //getIdt();
  3962. traiteRM();
  3963. } /*else {
  3964. // Est censé se lancer sur quoi *précisément* ?
  3965. traiteRM();
  3966. getLevel();
  3967. }*/
  3968. } else {
  3969. /* Traitement des messages du bot */
  3970. var messageTitle = document.evaluate(
  3971. "//form/table/tbody/tr[1]/td[1]/"
  3972. +"descendant::text()[contains(.,'[MountyHall]')]",
  3973. document, null, 2, null
  3974. ).stringValue;
  3975. if(messageTitle.indexOf('Attaquant') != -1 &&
  3976. messageTitle.indexOf('sur') != -1) {
  3977. getLevel();
  3978. traiteRM();
  3979. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3980. messageTitle.indexOf('Défenseur') != -1) {
  3981. traiteMM();
  3982. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3983. // à replacer avec Attaque après révision getLvl :
  3984. messageTitle.indexOf('Explosion') != -1 ||
  3985. messageTitle.indexOf('Insulte') != -1) {
  3986. traiteRM();
  3987. }
  3988. }
  3989. }
  3990.  
  3991. function do_actions() {
  3992. start_script(31);
  3993. dispatch();
  3994. displayScriptTime();
  3995. }
  3996.  
  3997. /*********************************************************************************
  3998. * This file is part of Mountyzilla. *
  3999. * *
  4000. * Mountyzilla is free software; you can redistribute it and/or modify *
  4001. * it under the terms of the GNU General Public License as published by *
  4002. * the Free Software Foundation; either version 2 of the License, or *
  4003. * (at your option) any later version. *
  4004. * *
  4005. * Mountyzilla is distributed in the hope that it will be useful, *
  4006. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4007. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4008. * GNU General Public License for more details. *
  4009. * *
  4010. * You should have received a copy of the GNU General Public License *
  4011. * along with Mountyzilla; if not, write to the Free Software *
  4012. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4013. *********************************************************************************/
  4014.  
  4015. // x~x pre-enchant
  4016.  
  4017. /* 2013-08-19 : correction auto syntaxe alert */
  4018.  
  4019. var combobox=null;
  4020.  
  4021. function changeObject()
  4022. {
  4023. if(!combobox)
  4024. return ;
  4025. var id = combobox.options[combobox.selectedIndex].value;
  4026. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  4027. if(!id || id=="")
  4028. {
  4029. MY_removeValue(numTroll+".enchantement.lastEquipement");
  4030. return;
  4031. }
  4032. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  4033. }
  4034.  
  4035. function treatePreEnchantement() {
  4036. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4037. if(!input || input.getAttribute("type")=="hidden")
  4038. {
  4039. return false;
  4040. }
  4041. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  4042. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4043. if(!combobox)
  4044. {
  4045. return true;
  4046. }
  4047. combobox.addEventListener('change', changeObject, true);
  4048. return true;
  4049. }
  4050.  
  4051. function treateEnchantement_pre() {
  4052. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4053. if(!input || input.getAttribute("type")!="hidden")
  4054. {
  4055. return false;
  4056. }
  4057. var idEquipement = input.getAttribute("value");
  4058. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  4059. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  4060. if(enchanteur && enchanteur != null)
  4061. return true;
  4062. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4063. if(!input || input.getAttribute("type")!="hidden")
  4064. {
  4065. return false;
  4066. }
  4067. var idEnchanteur = input.getAttribute("value");
  4068.  
  4069. var nodes = document.evaluate(
  4070. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4071. if (nodes.snapshotLength != 3)
  4072. return;
  4073. for(var i=0;i<3;i++)
  4074. {
  4075. var texte = trim(nodes.snapshotItem(i).nodeValue);
  4076. texte = texte.replace(" d'une "," d'un ");
  4077. var compo = texte.substring(0,texte.indexOf(" d'un "));
  4078. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  4079. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  4080. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  4081. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  4082. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  4083. }
  4084. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  4085. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  4086. var liste = MY_getValue(numTroll+".enchantement.liste");
  4087. if(!liste || liste=="")
  4088. {
  4089. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  4090. }
  4091. else
  4092. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  4093. }
  4094.  
  4095. function do_pre_enchant() {
  4096. start_script(60);
  4097. if(!treatePreEnchantement())
  4098. treateEnchantement_pre();
  4099. displayScriptTime();
  4100. }
  4101.  
  4102. /*********************************************************************************
  4103. * This file is part of Mountyzilla. *
  4104. * *
  4105. * Mountyzilla is free software; you can redistribute it and/or modify *
  4106. * it under the terms of the GNU General Public License as published by *
  4107. * the Free Software Foundation; either version 2 of the License, or *
  4108. * (at your option) any later version. *
  4109. * *
  4110. * Mountyzilla is distributed in the hope that it will be useful, *
  4111. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4112. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4113. * GNU General Public License for more details. *
  4114. * *
  4115. * You should have received a copy of the GNU General Public License *
  4116. * along with Mountyzilla; if not, write to the Free Software *
  4117. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4118. *********************************************************************************/
  4119.  
  4120. // x~x enchant
  4121.  
  4122. /* 2013-08-19 : correction auto syntaxe alert */
  4123.  
  4124. function treateEnchantement() {
  4125. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  4126. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  4127. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  4128. return;
  4129. var tab = infoEquipement.split(";");
  4130. if(tab.length<2)
  4131. return;
  4132. var idEquipement = tab[0];
  4133. var nomEquipement = tab[1];
  4134. for(var i=2;i<tab.length;i++)
  4135. nomEquipement += ";"+tab[i];
  4136.  
  4137. var nodes = document.evaluate(
  4138. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4139. if (nodes.snapshotLength != 3)
  4140. return;
  4141. for(var i=0;i<3;i++)
  4142. {
  4143. var texte = trim(nodes.snapshotItem(i).nodeValue);
  4144. texte = texte.replace(" d'une "," d'un ");
  4145. var compo = texte.substring(0,texte.indexOf(" d'un "));
  4146. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  4147. monstre = monstre.replace(/ Géante?/,"");
  4148. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  4149. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  4150. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  4151. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  4152. }
  4153. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  4154. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  4155. var liste = MY_getValue(numTroll+".enchantement.liste");
  4156. if(!liste || liste=="")
  4157. {
  4158. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  4159. }
  4160. else
  4161. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  4162. }
  4163.  
  4164. function do_enchant() {
  4165. start_script(60);
  4166.  
  4167. treateEnchantement();
  4168. MY_removeValue(numTroll+".enchantement.lastEquipement");
  4169. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  4170. displayScriptTime();
  4171. }
  4172.  
  4173. /*********************************************************************************
  4174. * This file is part of Mountyzilla. *
  4175. * *
  4176. * Mountyzilla is free software; you can redistribute it and/or modify *
  4177. * it under the terms of the GNU General Public License as published by *
  4178. * the Free Software Foundation; either version 2 of the License, or *
  4179. * (at your option) any later version. *
  4180. * *
  4181. * Mountyzilla is distributed in the hope that it will be useful, *
  4182. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4183. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4184. * GNU General Public License for more details. *
  4185. * *
  4186. * You should have received a copy of the GNU General Public License *
  4187. * along with Mountyzilla; if not, write to the Free Software *
  4188. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4189. *********************************************************************************/
  4190.  
  4191. // x~x myevent
  4192.  
  4193. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4194. function do_myevent() {
  4195. }
  4196.  
  4197. /*********************************************************************************
  4198. * This file is part of Mountyzilla. *
  4199. * *
  4200. * Mountyzilla is free software; you can redistribute it and/or modify *
  4201. * it under the terms of the GNU General Public License as published by *
  4202. * the Free Software Foundation; either version 2 of the License, or *
  4203. * (at your option) any later version. *
  4204. * *
  4205. * Mountyzilla is distributed in the hope that it will be useful, *
  4206. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4207. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4208. * GNU General Public License for more details. *
  4209. * *
  4210. * You should have received a copy of the GNU General Public License *
  4211. * along with Mountyzilla; if not, write to the Free Software *
  4212. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4213. *********************************************************************************/
  4214.  
  4215. // x~x malus
  4216.  
  4217. /* v1.4 - 2014-01-06
  4218. * - Gestion des sorts double composante
  4219. * v1.4.1 - 2014-01-22
  4220. * - Correction décumul
  4221. * TODO
  4222. * - Identifier la position de "PV" dans l'ordre MH
  4223. */
  4224.  
  4225. var listeBM;
  4226.  
  4227.  
  4228. /* [functions] Utilitaires */
  4229.  
  4230. function decumul(bmt,nbr) {
  4231. var bmr;
  4232. if(!nbr || nbr<2) bmr = bmt;
  4233. else if(nbr==2) bmr = parseInt(0.67*bmt);
  4234. else if(nbr==3) bmr = parseInt(0.40*bmt);
  4235. else if(nbr==4) bmr = parseInt(0.25*bmt);
  4236. else if(nbr==5) bmr = parseInt(0.15*bmt);
  4237. else bmr = parseInt(0.1*bmt);
  4238. if(bmt<0) return Math.min(-1,bmr);
  4239. return Math.max(1,bmr);
  4240. }
  4241.  
  4242. function triecaracs(a,b) { // version Yoyor, mod by Dab
  4243. // Roule 23/11/2016 ajout PV
  4244. switch( a ) {
  4245. case 'ATT':
  4246. return -1;
  4247. case 'ESQ':
  4248. if(b=='ATT') return 1;
  4249. return -1;
  4250. case 'DEG':
  4251. switch( b ) {
  4252. case 'ATT':
  4253. case 'ESQ':
  4254. return 1;
  4255. default:
  4256. return -1;
  4257. }
  4258. case 'REG':
  4259. switch( b ) {
  4260. case 'ATT':
  4261. case 'ESQ':
  4262. case 'DEG':
  4263. return 1;
  4264. default:
  4265. return -1;
  4266. }
  4267. case 'Vue':
  4268. switch( b ) {
  4269. case 'ATT':
  4270. case 'ESQ':
  4271. case 'DEG':
  4272. case 'REG':
  4273. return 1;
  4274. default:
  4275. return -1;
  4276. }
  4277. case 'TOUR':
  4278. switch( b ) {
  4279. case 'ATT':
  4280. case 'ESQ':
  4281. case 'DEG':
  4282. case 'REG':
  4283. case 'Vue':
  4284. return 1;
  4285. default:
  4286. return -1;
  4287. }
  4288. case 'PV':
  4289. switch( b ) {
  4290. case 'ATT':
  4291. case 'ESQ':
  4292. case 'DEG':
  4293. case 'REG':
  4294. case 'Vue':
  4295. case 'TOUR':
  4296. return 1;
  4297. default:
  4298. return -1;
  4299. }
  4300. case 'Armure':
  4301. switch( b ) {
  4302. case 'ATT':
  4303. case 'ESQ':
  4304. case 'DEG':
  4305. case 'REG':
  4306. case 'Vue':
  4307. case 'TOUR':
  4308. case 'PV':
  4309. return 1;
  4310. default:
  4311. return -1;
  4312. }
  4313. case 'RM':
  4314. switch( b ) {
  4315. case 'ATT':
  4316. case 'ESQ':
  4317. case 'DEG':
  4318. case 'REG':
  4319. case 'Vue':
  4320. case 'TOUR':
  4321. case 'PV':
  4322. case 'Armure':
  4323. return 1;
  4324. default:
  4325. return -1;
  4326. }
  4327. case 'MM':
  4328. switch( b ) {
  4329. case 'ATT':
  4330. case 'ESQ':
  4331. case 'DEG':
  4332. case 'REG':
  4333. case 'Vue':
  4334. case 'TOUR':
  4335. case 'PV':
  4336. case 'Armure':
  4337. case 'RM':
  4338. return 1;
  4339. default:
  4340. return -1;
  4341. }
  4342. case 'Concentration':
  4343. switch( b ) {
  4344. case 'ATT':
  4345. case 'ESQ':
  4346. case 'DEG':
  4347. case 'REG':
  4348. case 'Vue':
  4349. case 'TOUR':
  4350. case 'PV':
  4351. case 'Armure':
  4352. case 'RM':
  4353. case 'MM':
  4354. return 1;
  4355. default:
  4356. return -1;
  4357. }
  4358. case 'Fatigue':
  4359. switch( b ) {
  4360. case 'ATT':
  4361. case 'ESQ':
  4362. case 'DEG':
  4363. case 'REG':
  4364. case 'Vue':
  4365. case 'TOUR':
  4366. case 'PV':
  4367. case 'Armure':
  4368. case 'RM':
  4369. case 'MM':
  4370. case 'Concentration':
  4371. return 1;
  4372. default:
  4373. return -1;
  4374. }
  4375. case "Dés d'attaque":
  4376. switch( b ) {
  4377. case 'ATT':
  4378. case 'ESQ':
  4379. case 'DEG':
  4380. case 'REG':
  4381. case 'Vue':
  4382. case 'TOUR':
  4383. case 'PV':
  4384. case 'Armure':
  4385. case 'RM':
  4386. case 'MM':
  4387. case 'Concentration':
  4388. case 'Fatigue':
  4389. return 1;
  4390. default:
  4391. return -1;
  4392. }
  4393. case 'Dés de dégâts':
  4394. switch( b ) {
  4395. case 'ATT':
  4396. case 'ESQ':
  4397. case 'DEG':
  4398. case 'REG':
  4399. case 'Vue':
  4400. case 'TOUR':
  4401. case 'PV':
  4402. case 'Armure':
  4403. case 'RM':
  4404. case 'MM':
  4405. case 'Concentration':
  4406. case 'Fatigue':
  4407. case "Dés d'attaque":
  4408. return 1;
  4409. default:
  4410. return -1;
  4411. }
  4412. default :
  4413. switch( b ) {
  4414. case 'ATT':
  4415. case 'ESQ':
  4416. case 'DEG':
  4417. case 'REG':
  4418. case 'Vue':
  4419. case 'TOUR':
  4420. case 'PV':
  4421. case 'Armure':
  4422. case 'RM':
  4423. case 'MM':
  4424. case 'Concentration':
  4425. case 'Fatigue':
  4426. case "Dés d'attaque":
  4427. case 'Dés de dégâts':
  4428. return 1;
  4429. default:
  4430. return -1;
  4431. }
  4432. }
  4433. }
  4434.  
  4435.  
  4436. /* [functions] Fonctions hide / display */
  4437.  
  4438. function toggleDetailsBM() {
  4439. if(MY_getValue('BMDETAIL')!='false') {
  4440. MY_setValue('BMDETAIL','false');
  4441. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4442. for(var i=0 ; i<trlist.length ; i++)
  4443. trlist[i].style.display = 'none';
  4444. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4445. for(var i=0 ; i<trlist.length ; i++)
  4446. trlist[i].style = '';
  4447. }
  4448. else {
  4449. MY_setValue('BMDETAIL','true');
  4450. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  4451. for(var i=0 ; i<trlist.length ; i++)
  4452. trlist[i].style.display = 'none';
  4453. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  4454. for(var i=0 ; i<trlist.length ; i++)
  4455. trlist[i].style = '';
  4456. }
  4457. }
  4458.  
  4459. function toggleBMList() {
  4460. if(MY_getValue('BMHIDELIST')=='true') {
  4461. MY_setValue('BMHIDELIST','false');
  4462. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4463. listeBM.snapshotItem(i).style = '';
  4464. document.getElementsByTagName('thead')[0].style = '';
  4465. document.getElementById('trhelp').style = '';
  4466. }
  4467. else {
  4468. MY_setValue('BMHIDELIST','true');
  4469. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4470. listeBM.snapshotItem(i).style.display = 'none';
  4471. document.getElementsByTagName('thead')[0].style.display = 'none';
  4472. document.getElementById('trhelp').style.display = 'none';
  4473. }
  4474. }
  4475.  
  4476. function setDisplayBM() {
  4477. if(!listeBM) return;
  4478.  
  4479. var titre = document.getElementById('titre2');
  4480. if(titre) {
  4481. titre.style.cursor = 'pointer';
  4482. titre.onclick = toggleBMList;
  4483. }
  4484.  
  4485. var tfoot = document.getElementsByTagName('tfoot')[0];
  4486. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  4487. tfoot, null, 9, null).singleNodeValue;
  4488. tr.id = 'trhelp';
  4489.  
  4490. if(MY_getValue('BMHIDELIST')=='true') {
  4491. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  4492. listeBM.snapshotItem(i).style.display = 'none';
  4493. document.getElementsByTagName('thead')[0].style.display = 'none';
  4494. tr.style.display = 'none';
  4495. }
  4496. }
  4497.  
  4498.  
  4499. /* [functions] Fonction principale */
  4500.  
  4501. function traiteMalus() {
  4502. var mainTab = document.getElementsByTagName('table')[0];
  4503. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4504. if(listeBM.snapshotLength==0) return;
  4505.  
  4506. /* Suppression des BM de fatigue stockés */
  4507. if(MY_getValue(numTroll+'.bm.fatigue'))
  4508. MY_removeValue(numTroll+'.bm.fatigue');
  4509.  
  4510. /* Extraction des données */
  4511. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  4512. var nb = 0;
  4513. while(nb<listeBM.snapshotLength) {
  4514. tr = listeBM.snapshotItem(nb); nb++;
  4515. var effetsT = tr.childNodes[5].textContent.split(' | ');
  4516. var phymag = tr.childNodes[9].textContent;
  4517. var duree = tr.childNodes[11].textContent.match(/\d+/);
  4518. if (duree == null) { // Roule 28/01/2018 protection malus Crasc sans durée
  4519. duree = 1;
  4520. } else {
  4521. duree = Number(duree[0]);
  4522. }
  4523. var type = tr.childNodes[3].textContent, nom;
  4524. // si c'est un type à décumul
  4525. /*
  4526. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  4527. switch(type) {
  4528. case 'Potion':
  4529. case 'Parchemin':
  4530. case 'Sortilège':
  4531. case 'Capacité Spéciale':
  4532. nom = tr.childNodes[1].textContent+phymag;
  4533. break;
  4534. default:
  4535. nom = 'pasdedecumul';
  4536. }
  4537. */
  4538. nom = tr.childNodes[1].textContent+phymag;
  4539. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  4540. nom = 'pasdedecumul';
  4541.  
  4542. uniListe[nb] = {
  4543. 'duree':duree,
  4544. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  4545. 'caracs':{}
  4546. }
  4547. for(var i=0 ; i<effetsT.length ; i++) {
  4548. if(effetsT[i].indexOf(':')==-1) continue;
  4549. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  4550. // nom = 'pasdedecumul' si pas de décumul
  4551. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  4552. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  4553. uniListe[nb]['type'] = phymag;
  4554. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  4555. var tmatch = effetsT[i].match(/(-?\d+)(\\([+-]?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  4556. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  4557. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  4558. uniListe[nb]['caracs'][carac] = bm;
  4559. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  4560. listeDurees[duree] = true;
  4561. }
  4562. } // fin boucle sur les lignes de bonus/malus
  4563.  
  4564. /* Gestion des décumuls et cumuls des durées */
  4565. var toursGeres = [];
  4566. for(var d in listeDurees) toursGeres.push(d);
  4567. toursGeres.sort( function (a,b){return b-a;} );
  4568. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  4569. // pour sauvegarder les bm de fatigue
  4570. var strfat = '';
  4571. // Pour affichage & adpatation à footable.js (statique)
  4572. var thead = document.getElementsByTagName('thead')[0];
  4573. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  4574. thead, null, 7, null).snapshotLength;
  4575. var tfoot = document.getElementsByTagName('tfoot')[0];
  4576.  
  4577. for(var i=0 ; i<toursGeres.length ; i++) {
  4578. var tour = toursGeres[i];
  4579. var effetsCeTour = {}; decumulsCeTour = {};
  4580. for(var nb=1 ; nb<uniListe.length ; nb++) {
  4581. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  4582. continue;
  4583. var nom = uniListe[nb]['nom'];
  4584. if(nom!='pasdedecumul') {
  4585. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  4586. decumulsCeTour[nom]++;
  4587. }
  4588. for(var carac in uniListe[nb]['caracs']) {
  4589. var bm = uniListe[nb]['caracs'][carac];
  4590. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  4591. var type = uniListe[nb]['type'];
  4592. if(!effetsCeTour[carac])
  4593. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  4594. var thisBm;
  4595. if(nom=='pasdedecumul')
  4596. thisBm = bm;
  4597. else
  4598. thisBm = decumul(bm,decumulsCeTour[nom]);
  4599. effetsCeTour[carac][type] += thisBm;
  4600. 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]);
  4601. } else {
  4602. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  4603. var thisBm;
  4604. if(nom=='pasdedecumul' || carac=='Fatigue')
  4605. thisBm = bm;
  4606. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  4607. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  4608. else
  4609. thisBm = decumul(bm,decumulsCeTour[nom]);
  4610. effetsCeTour[carac] += thisBm;
  4611. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  4612. }
  4613. } // fin boucle sur les caractéristiques
  4614. } // fin boucle sur les bonus/malus
  4615.  
  4616. /* Création du bilan du tour */
  4617. var texteD = '', texteS = '';
  4618. var caracGerees = [];
  4619. for(var k in effetsCeTour) caracGerees.push(k);
  4620. caracGerees.sort( triecaracs );
  4621.  
  4622. for(var j=0 ; j<caracGerees.length ; j++) {
  4623. var carac = caracGerees[j], str = '';
  4624. if (MY_DEBUG) window.console.log('MZ traiteMalus, j=' + j + ', carac=' + carac + ', effetsCeTour=' + effetsCeTour[carac] + ', toursGeres=' + toursGeres[i]);
  4625.  
  4626. switch( carac ) {
  4627. case 'ATT':
  4628. case 'DEG':
  4629. case 'Armure':
  4630. var phy = effetsCeTour[carac]['Physique'];
  4631. var mag = effetsCeTour[carac]['Magie'];
  4632. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  4633. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  4634. break;
  4635. case 'TOUR':
  4636. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  4637. break;
  4638. case 'Fatigue':
  4639. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  4640. case 'PV':
  4641. case 'ESQ':
  4642. case 'REG':
  4643. case 'Vue':
  4644. case 'Voir le Caché':
  4645. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  4646. break;
  4647. default:
  4648. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  4649. }
  4650. if(str) {
  4651. texteD += str;
  4652. texteS += str;
  4653. }
  4654. if (MY_DEBUG) window.console.log('MZ traiteMalus, j=' + j + ', strfat=' + strfat);
  4655. } // fin boucle sur les caractéristiques
  4656.  
  4657. /* Affichage */
  4658. // Si rien à afficher on passe
  4659. if(!texteD) continue;
  4660. // Si BMM+BMP=0
  4661. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  4662. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  4663. if(MY_getValue('BMDETAIL')=='false')
  4664. tr.style.display = 'none';
  4665. var td = appendTdText(tr,texteD.substring(3));
  4666. td.colSpan = 5-nbHidden;
  4667. var txttour = toursGeres[i]+' Tour';
  4668. if(toursGeres[i]>1) txttour += 's';
  4669. appendTdText(tr,txttour);
  4670.  
  4671. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  4672. if(MY_getValue('BMDETAIL')!='false')
  4673. tr.style.display = 'none';
  4674. td = appendTdText(tr,texteS);
  4675. td.colSpan = 5-nbHidden;
  4676. appendTdText(tr,txttour);
  4677. } // fin boucle sur les tours générés
  4678.  
  4679. /* mise en place toggleDetails */
  4680. tfoot.style.cursor = 'pointer';
  4681. tfoot.onclick = toggleDetailsBM;
  4682.  
  4683. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  4684. if(strfat)
  4685. MY_setValue(numTroll+'.bm.fatigue',strfat);
  4686. }
  4687.  
  4688. function do_malus() {
  4689. try {
  4690. start_script();
  4691. traiteMalus();
  4692. setDisplayBM();
  4693. displayScriptTime();
  4694. }
  4695. catch(e) {window.alert(e)};
  4696. }
  4697.  
  4698. /*******************************************************************************
  4699. * This file is part of Mountyzilla. *
  4700. * *
  4701. * Mountyzilla is free software; you can redistribute it and/or modify *
  4702. * it under the terms of the GNU General Public License as published by *
  4703. * the Free Software Foundation; either version 2 of the License, or *
  4704. * (at your option) any later version. *
  4705. * *
  4706. * Mountyzilla is distributed in the hope that it will be useful, *
  4707. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4708. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4709. * GNU General Public License for more details. *
  4710. * *
  4711. * You should have received a copy of the GNU General Public License *
  4712. * along with Mountyzilla; if not, write to the Free Software *
  4713. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4714. *******************************************************************************/
  4715.  
  4716. // x~x mouches
  4717.  
  4718. var mainTab, tr_mouches;
  4719.  
  4720. function initialiseMouches() {
  4721. // Lanceur global
  4722. try {
  4723. mainTab = document.getElementById('mouches');
  4724. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  4725. } catch(e) {
  4726. avertissement('Erreur MZ:<br />Consulter la console.');
  4727. window.console.error(traceStack(e, 'mouches'));
  4728. return;
  4729. }
  4730. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  4731.  
  4732. setDisplayMouches();
  4733. traiteMouches();
  4734. }
  4735.  
  4736. function setDisplayMouches() {
  4737. // Initialise l'affichage / l'effacement du détail des mouches
  4738. var titre = document.getElementById('titre2');
  4739. if(titre) {
  4740. titre.style.cursor = 'pointer';
  4741. titre.onclick = toggleMouches;
  4742. }
  4743.  
  4744. var tfoot = document.getElementsByTagName('tfoot')[0];
  4745. if(tfoot) {
  4746. tfoot.style.cursor = 'pointer';
  4747. tfoot.onclick = toggleMouches;
  4748. }
  4749.  
  4750. if(MY_getValue('HIDEMOUCHES')=='true') {
  4751. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4752. tr_mouches.snapshotItem(i).style.display = 'none';
  4753. }
  4754. document.getElementsByTagName('thead')[0].style.display = 'none';
  4755. }
  4756. }
  4757.  
  4758. function toggleMouches() {
  4759. // Handler pour afficher / masquer les détasil
  4760. if(MY_getValue('HIDEMOUCHES')=='true') {
  4761. MY_setValue('HIDEMOUCHES','false');
  4762. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4763. tr_mouches.snapshotItem(i).style.display = '';
  4764. }
  4765. document.getElementsByTagName('thead')[0].style.display = '';
  4766. } else {
  4767. MY_setValue('HIDEMOUCHES','true');
  4768. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4769. tr_mouches.snapshotItem(i).style.display = 'none';
  4770. }
  4771. document.getElementsByTagName('thead')[0].style.display = 'none';
  4772. }
  4773. }
  4774.  
  4775. function traiteMouches() {
  4776. // Traitement complet: présence et effets des mouches
  4777. var listeTypes = {}, effetsActifs = {};
  4778.  
  4779. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  4780. var tr = tr_mouches.snapshotItem(i);
  4781.  
  4782. // La mouche est-elle présente?
  4783. var etat = document.evaluate(
  4784. './img',
  4785. tr.cells[6], null, 9, null
  4786. ).singleNodeValue.alt;
  4787. if(etat!='La Mouche est là') { continue; }
  4788. // Extraction du type de mouche
  4789. var type = trim(tr.cells[3].textContent);
  4790. if(!listeTypes[type]) {
  4791. listeTypes[type] = 1;
  4792. } else {
  4793. listeTypes[type]++;
  4794. }
  4795.  
  4796. // La mouche a-t-elle un effet?
  4797. var effet = trim(tr.cells[2].textContent);
  4798. if(etat!='La Mouche est là' || !effet) { continue; }
  4799. // Si oui, extraction des effets (multiples pour pogées)
  4800. var caracs = effet.split(' | ');
  4801. for(var j=0 ; j<caracs.length ; j++) {
  4802. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  4803. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  4804. if(effetsActifs[carac]===void(0)) {
  4805. effetsActifs[carac] = valeur;
  4806. } else {
  4807. effetsActifs[carac] += valeur;
  4808. }
  4809. }
  4810. }
  4811.  
  4812. // Extraction Effet total et affichage des différences à la normale
  4813. var tfoot = document.getElementsByTagName('tfoot')[0];
  4814. if(!tfoot) { return; }
  4815. var nodeTotal = document.evaluate(
  4816. ".//b[contains(./text(),'Effet total')]",
  4817. tfoot, null, 9, null
  4818. ).singleNodeValue.nextSibling;
  4819. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  4820. var texte = ' ';
  4821. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  4822. if(texte.length>1) { texte += ' | '; }
  4823. var carac = trim(
  4824. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  4825. );
  4826. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  4827. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  4828. texte += effetsTheoriques[i];
  4829. } else {
  4830. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  4831. if(carac=='TOUR') { texte += ' min'; }
  4832. texte += '</b>';
  4833. }
  4834. }
  4835. var span = document.createElement('span');
  4836. span.innerHTML = texte;
  4837. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  4838.  
  4839. // Affichage des différences du nombre de mouches de chaque type
  4840. var mouchesParType = document.evaluate(
  4841. "./tr/td/ul/li/text()",
  4842. tfoot, null, 7, null
  4843. );
  4844. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  4845. var node = mouchesParType.snapshotItem(i);
  4846. var mots = node.nodeValue.split(' ');
  4847. var type = mots.pop();
  4848. if(!listeTypes[type]) {
  4849. node.nodeValue += ' (0 présente)';
  4850. } else if(mots[0]!=listeTypes[type]) {
  4851. if(listeTypes[type]==1) {
  4852. node.nodeValue += ' (1 présente)';
  4853. } else {
  4854. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4855. }
  4856. }
  4857. }
  4858. }
  4859.  
  4860. function do_mouches() {
  4861. start_script();
  4862. initialiseMouches();
  4863. displayScriptTime();
  4864. }
  4865.  
  4866. /*********************************************************************************
  4867. * This file is part of Mountyzilla. *
  4868. * *
  4869. * Mountyzilla is free software; you can redistribute it and/or modify *
  4870. * it under the terms of the GNU General Public License as published by *
  4871. * the Free Software Foundation; either version 2 of the License, or *
  4872. * (at your option) any later version. *
  4873. * *
  4874. * Mountyzilla is distributed in the hope that it will be useful, *
  4875. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4876. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4877. * GNU General Public License for more details. *
  4878. * *
  4879. * You should have received a copy of the GNU General Public License *
  4880. * along with Mountyzilla; if not, write to the Free Software *
  4881. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4882. *********************************************************************************/
  4883.  
  4884. // x~x equipgowap
  4885.  
  4886. var popup;
  4887.  
  4888. function initPopupEquipgowap() {
  4889. popup = document.createElement('div');
  4890. popup.setAttribute('id', 'popup');
  4891. popup.setAttribute('class', 'mh_textbox');
  4892. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4893. 'display: inline; z-index: 3; max-width: 400px;');
  4894. document.body.appendChild(popup);
  4895. }
  4896.  
  4897. function showPopupEquipgowap(evt) {
  4898. var texte = this.getAttribute("texteinfo");
  4899. popup.innerHTML = texte;
  4900. popup.style.left = evt.pageX + 15 + 'px';
  4901. popup.style.top = evt.pageY + 'px';
  4902. popup.style.visibility = "visible";
  4903. }
  4904.  
  4905. function hidePopup() {
  4906. popup.style.visibility = "hidden";
  4907. }
  4908.  
  4909. function createPopupImage(url, text)
  4910. {
  4911. var img = document.createElement('img');
  4912. img.setAttribute('src',url);
  4913. img.setAttribute('align','ABSMIDDLE');
  4914. img.setAttribute("texteinfo",text);
  4915. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4916. img.addEventListener("mouseout", hidePopup,true);
  4917. return img;
  4918. }
  4919.  
  4920. function formateTexte(texte)
  4921. {
  4922. texte = texte.replace(/\n/g,"<br/>");
  4923. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4924. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4925. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4926. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4927. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4928. return texte;
  4929. }
  4930.  
  4931.  
  4932. function treateGowaps() {
  4933. //On récupère les gowaps possédants des composants
  4934. var tbodys = document.evaluate(
  4935. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4936. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4937. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4938. var tbody = tbodys.snapshotItem(j);
  4939. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4940. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4941. if(MY_getValue("NOINFOEM") != "true")
  4942. insertEMInfos(tbody);
  4943. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4944. insertEnchantInfos(tbody);
  4945. }
  4946. }
  4947.  
  4948. function treateChampi() {
  4949. if(MY_getValue("NOINFOEM") == "true")
  4950. return false;
  4951. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4952. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4953. if (nodes.snapshotLength == 0)
  4954. return false;
  4955.  
  4956. for (var i = 0; i < nodes.snapshotLength; i++) {
  4957. var node = nodes.snapshotItem(i);
  4958. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4959. if(texte.indexOf("*")!=-1)
  4960. texte = texte.substring(0,texte.lastIndexOf(" "));
  4961. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4962. if(moisChampi[nomChampi])
  4963. {
  4964. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4965. }
  4966.  
  4967. }
  4968. }
  4969.  
  4970. function do_equipgowap() {
  4971. start_script();
  4972.  
  4973. treateGowaps();
  4974. treateChampi();
  4975. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4976. {
  4977. initPopupEquipgowap();
  4978. computeEnchantementEquipement(createPopupImage,formateTexte);
  4979. }
  4980.  
  4981. displayScriptTime();
  4982. }
  4983.  
  4984. /*********************************************************************************
  4985. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4986. *********************************************************************************/
  4987.  
  4988. // x~x ordresgowap
  4989.  
  4990. var MZ_analyse_page_ordre_suivant;
  4991. if (MZ_analyse_page_ordre_suivant === undefined && isPage("MH_Follower/FO_Ordres")) {
  4992. // Roule 07/10/2019
  4993. // Fonction réutilisée dans MZ, dans Trajet_canvas et dans une extension perso ☺
  4994. // rend un object, par exemple
  4995. var MZ_analyse_page_ordre_suivant = {
  4996. 'result': {ordres: []},
  4997. 'init': function() {
  4998. // façon blindée de tester la variable MY_DEBUG
  4999. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('start MZ_analyse_page_ordre_suivant.init');
  5000. try {
  5001. var eTitle = document.getElementById('titre2');
  5002. // au 07/10/2019, on peut se baser sur les <tr> de l'élément HTML parent 'titre2'
  5003. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('eTitle.nextSibling=' + eTitle.parentNode);
  5004. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  5005. for(var i=0 ; i<lignes.length ; i++) {
  5006. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + ' className=' + lignes[i].className);
  5007. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant tr ' + i + lignes[i].innerHTML);
  5008. if(lignes[i].className == 'mh_tdtitre_fo') {
  5009. var tds = lignes[i].getElementsByTagName('div');
  5010. for (var j=0; j < tds.length; j++) {
  5011. //if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant div ' + j + ' ' + tds[j].innerText);
  5012. var tabmatch = tds[j].innerText.match(/(\d+) *\.* *(.*\[.*\].*)$/);
  5013. if (tabmatch) {
  5014. // ID, Nom
  5015. this.result.id = tabmatch[1].trim();
  5016. this.result.nom = tabmatch[2].trim();
  5017. }
  5018. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-?\d+).*Y = (-?\d+).*N = (-?\d+)/i);
  5019. if (tabmatch) {
  5020. // PA, x, y, n
  5021. this.result.PA = parseInt(tabmatch[1]);
  5022. this.result.x = parseInt(tabmatch[2]);
  5023. this.result.y = parseInt(tabmatch[3]);
  5024. this.result.n = parseInt(tabmatch[4]);
  5025. // Trajet_canvas a besoin d'un pointeur vers cette div
  5026. this.result.eltPos = tds[j];
  5027. }
  5028. }
  5029. }
  5030. if(lignes[i].className == 'mh_tdpage_fo') {
  5031. var etd = lignes[i].getElementsByTagName('td')[0];
  5032. if (etd !== undefined) { // undefined dans le cas des Golems
  5033. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('MZ_analyse_page_ordre_suivant td[0]=' + etd.textContent);
  5034. var tabmatch = etd.textContent.match(/^(.*)X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  5035. if (tabmatch) {
  5036. this.result.ordres.push({ordre: tabmatch[1].trim(), x: parseInt(tabmatch[2]), y: parseInt(tabmatch[3]), n: parseInt(tabmatch[4])});
  5037. } else {
  5038. this.result.ordres.push({ordre: etd.textContent.trim()});
  5039. }
  5040. }
  5041. }
  5042. }
  5043. if (typeof MY_DEBUG !== 'undefined' && MY_DEBUG) window.console.log('fin MZ_analyse_page_ordre_suivant ' + JSON.stringify(this.result));
  5044. } catch(e) {
  5045. window.console.log('Exception dans MZ_analyse_page_ordre_suivant.init ' + e);
  5046. }
  5047. }
  5048. }
  5049. MZ_analyse_page_ordre_suivant.init();
  5050. }
  5051.  
  5052. // version Roule' janvier 2017
  5053. function MZ_setCarteUnGogoHTML5() {
  5054. // fabriquer la liste des positions successives
  5055. var listeDepl = []; // ce sera un tableau d'objets
  5056. listeDepl = MZ_analyse_page_ordre_suivant.result.ordres.slice(0); // clone array
  5057. 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
  5058.  
  5059. /* à supprimer, remplacé par MZ_analyse_page_ordre_suivant
  5060. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  5061. , y: parseInt(tabPos[3])
  5062. , n: parseInt(tabPos[4])
  5063. , nom: tabNomID[2]
  5064. , id: tabNomID[1]});
  5065.  
  5066. // position courante
  5067. var eTitle = document.getElementById('titre2');
  5068. // déplacements
  5069. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  5070. for(var i=0 ; i<lignes.length ; i++) {
  5071. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + ' className=' + lignes[i].className);
  5072. //window.console.log('MZ_setCarteUnGogoHTML5 ' + i + lignes[i].innerHTML);
  5073. if(lignes[i].className == 'mh_tdtitre_fo') {
  5074. var tds = lignes[i].getElementsByTagName('div');
  5075. for (var j=0; j < tds.length; j++) {
  5076. tabmatch = tds[j].innerText.match(/(\d+) *(.*\[.*\].*)$/);
  5077. if (tabmatch) var tabNomID = tabmatch;
  5078. tabmatch = tds[j].innerText.match(/(\d+) *PA.*X = (-.\d+).*Y = (-.\d+).*N = (-.\d+)/i);
  5079. if (tabmatch) var tabPos = tabmatch;
  5080. }
  5081. if (tabPos != undefined && tabNomID != undefined) { // null dans le cas des Golems
  5082. listeDepl.push({x: parseInt(tabPos[2]) // ParseInt obligatoire, javascript language de m*rd*
  5083. , y: parseInt(tabPos[3])
  5084. , n: parseInt(tabPos[4])
  5085. , nom: tabNomID[2]
  5086. , id: tabNomID[1]});
  5087. } else {
  5088. return;
  5089. }
  5090. }
  5091. if(lignes[i].className == 'mh_tdpage_fo') {
  5092. var etd = lignes[i].getElementsByTagName('td')[0];
  5093. if (etd === undefined) return; // cas des Golems
  5094. var point = etd.firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  5095. if (point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  5096. }
  5097. }
  5098. */
  5099. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  5100. }
  5101.  
  5102. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  5103. function MZ_showCarteBottom(listeSuiv) {
  5104. // générer la carte
  5105. var carte = new carte_MZ('cartegogo', listeSuiv);
  5106. // positionner la carte
  5107. var eCarte = carte.getElt();
  5108. eCarte.style.textAlign = 'left';
  5109. eCarte.style.marginTop = '2px';
  5110. var footer = document.getElementById('footer1');
  5111. // Lieu_Teleport.php n'a pas de footer1 :(
  5112. if (!footer) footer = document.getElementById('footer2');
  5113. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  5114. else document.body.appendChild(eCarte);
  5115. }
  5116.  
  5117. function MZ_setCarteTousGogoHTML5() {
  5118. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  5119. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  5120. var suivants = [];
  5121. for (var i=0;i<ligne.length;i++) {
  5122. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  5123. var cas = ligne[i].getElementsByTagName("td")[0];
  5124. //if (cas.className == "mh_tdtitre") {
  5125. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  5126. var oGogo = {};
  5127. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  5128. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  5129. 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 "="
  5130. oGogo.x = parseInt(point[1]);
  5131. oGogo.y = parseInt(point[2]);
  5132. oGogo.n = parseInt(point[3]);
  5133. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  5134. }
  5135. }
  5136. if (suivants.length == 0) return;
  5137. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  5138. }
  5139.  
  5140. function MZ_setCarteTP() {
  5141. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  5142. 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);
  5143. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  5144. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  5145. }
  5146.  
  5147. function testeGlissiere() {
  5148. try {
  5149. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  5150. var footer = document.getElementById('footer1');
  5151. footer.parentNode.insertBefore(gliss.getElt(), footer);
  5152. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  5153. }
  5154.  
  5155. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  5156. if (x0 !== undefined) {
  5157. // ouais, récursif une fois
  5158. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  5159. if (PtInterm === undefined)
  5160. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  5161. else
  5162. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  5163. return;
  5164. }
  5165. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  5166. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  5167. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  5168. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  5169. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  5170. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  5171. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  5172. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  5173. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  5174. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  5175. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  5176. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  5177. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  5178. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  5179. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  5180. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  5181. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  5182. }
  5183.  
  5184. function do_ordresgowap() {
  5185. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  5186. //testeGlissiere();
  5187. //MZ_testsUnitairesCalculIntermediaire();
  5188. }
  5189.  
  5190. function do_listegowap() {
  5191. if (!newCarte) return;
  5192. MZ_setCarteTousGogoHTML5();
  5193. }
  5194.  
  5195. function do_lieuDescription() {
  5196. if (!newCarte) return;
  5197. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  5198. MZ_setCarteTP();
  5199. }
  5200.  
  5201. function do_lieuTeleport() {
  5202. changeButtonValidate();
  5203. if (!newCarte) return;
  5204. MZ_setCarteTP();
  5205. }
  5206.  
  5207. /*******************************************************************************
  5208. * This file is part of Mountyzilla. *
  5209. * *
  5210. * Mountyzilla is free software; you can redistribute it and/or modify *
  5211. * it under the terms of the GNU General Public License as published by *
  5212. * the Free Software Foundation; either version 2 of the License, or *
  5213. * (at your option) any later version. *
  5214. * *
  5215. * Mountyzilla is distributed in the hope that it will be useful, *
  5216. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5217. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5218. * GNU General Public License for more details. *
  5219. * *
  5220. * You should have received a copy of the GNU General Public License *
  5221. * along with Mountyzilla; if not, write to the Free Software *
  5222. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5223. *******************************************************************************/
  5224.  
  5225. // x~x infomonstre
  5226.  
  5227. // DEBUG
  5228. var nomMonstre='';
  5229. var idMonstre=-1;
  5230. //var tbody;
  5231. // var popup; // NOTE Linter : already defined
  5232.  
  5233. function traiteMonstre() {
  5234. try {
  5235. var nodeTitre = document.evaluate(
  5236. "//div[@class='titre2' and contains(text(),'(')]",
  5237. document, null, 9, null
  5238. ).singleNodeValue;
  5239. var texte = nodeTitre.firstChild.nodeValue;
  5240. } catch(e) {
  5241. window.console.log(traceStack(e, 'traiteMonstre'));
  5242. return;
  5243. }
  5244.  
  5245. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  5246. if(nomMonstre.indexOf(']')!=-1) {
  5247. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  5248. }
  5249. idMonstre = texte.match(/\d+/)[0];
  5250. var tReq = [{'index':1, 'id':+idMonstre, 'nom':nomMonstre}]; // "+" pour forcer du numérique
  5251. FF_XMLHttpRequest({
  5252. method: 'POST',
  5253. url: URL_MZgetCaracMonstre,
  5254. headers : {
  5255. 'Content-type':'application/x-www-form-urlencoded'
  5256. },
  5257. data: 'l=' + JSON.stringify(tReq),
  5258. trace: 'demande niveaux monstres V2, MonsterView',
  5259. onload: function(responseDetails) {
  5260. try {
  5261. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  5262. if (responseDetails.status == 0) return;
  5263. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  5264. var texte = responseDetails.responseText;
  5265. var infosRet = JSON.parse(texte);
  5266. if(infosRet.length==0) return;
  5267. var info = infosRet[0];
  5268. // QUESTION Quelle est l'utilité de ceci?
  5269. // 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
  5270. MZ_EtatCdMs.listeCDM[idMonstre] = info;
  5271. try {
  5272. var nodeInsert = document.evaluate(
  5273. "//div[@class = 'titre3']",
  5274. document, null, 9, null
  5275. ).singleNodeValue;
  5276. } catch(e) {
  5277. window.console.log(traceStack(e, 'recherche node pour info CdM'));
  5278. return;
  5279. }
  5280. var table = createCDMTable(idMonstre,nomMonstre,info);
  5281. table.align = 'center';
  5282. var tbody = table.childNodes[1];
  5283. var thead = table.childNodes[0];
  5284. var tdEntete = thead.firstChild.firstChild;
  5285. tdEntete.onclick = toggleTableau;
  5286. tdEntete.style.cursor = 'pointer';
  5287. thead.firstChild.style = 'mh_tdpage';
  5288. tbody.style.display = 'none';
  5289. table.style.width = '350px';
  5290. insertBefore(nodeInsert,table);
  5291. } catch(e) {
  5292. window.console.log(e);
  5293. }
  5294. },
  5295. });
  5296. }
  5297.  
  5298. function toggleTableau() { // click sur un td de thead
  5299. var tbody = this.parentNode.parentNode.parentNode.childNodes[1];
  5300. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  5301. }
  5302.  
  5303. function do_infomonstre() {
  5304. start_script();
  5305. try {
  5306. MZ_Tactique.initPopup();
  5307. traiteMonstre();
  5308. } catch(e) {
  5309. window.console.error(traceStack(e, 'do_infomonstre'));
  5310. window.alert('Erreur infoMonstre:\n'+e);
  5311. }
  5312. displayScriptTime();
  5313. }
  5314.  
  5315. /***
  5316. *** SCIZ
  5317. ***/
  5318.  
  5319. const scizSetup = {
  5320. // Maximum interval (seconds) for matching some events
  5321. eventsMaxMatchingInterval: 5000,
  5322. // Maximum number of treasures to enhanced in the view
  5323. viewMaxEnhancedTreasure: 100
  5324. };
  5325.  
  5326. var scizGlobal = {
  5327. events: [],
  5328. trolls: [],
  5329. treasures: []
  5330. };
  5331.  
  5332. function scizAddCSS() {
  5333. // SCIZ style
  5334. var scizStyle = `
  5335. .sciz-progress-bar-wrapper {
  5336. width: 100px;
  5337. text-align: center;
  5338. display: inline-block;
  5339. }
  5340. .sciz-progress-bar {
  5341. width: 100%;
  5342. background-color: #e0e0e0;
  5343. padding: 1px;
  5344. border-radius: 1px;
  5345. box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2);
  5346. }
  5347. .sciz-progress-bar-fill {
  5348. display: block;
  5349. height: 5px;
  5350. border-radius: 1px;
  5351. transition: width 500ms ease-in-out;
  5352. }
  5353. `;
  5354. // Actually add the SCIZ style
  5355. var scizStyleSheet = document.createElement('style');
  5356. scizStyleSheet.type = 'text/css';
  5357. if (scizStyleSheet.styleSheet) {
  5358. scizStyleSheet.styleSheet.cssText = scizStyle;
  5359. } else {
  5360. scizStyleSheet.appendChild(document.createTextNode(scizStyle));
  5361. }
  5362. document.getElementsByTagName('head')[0].appendChild(scizStyleSheet);
  5363. }
  5364.  
  5365. function scizCreateClickable(height, display, callbackOnClick) {
  5366. var img = document.createElement('img');
  5367. img.src = 'https://www.sciz.fr/static/sciz-logo-quarter.png';
  5368. img.alt = 'SCIZ logo';
  5369. img.style = 'height: ' + height + 'px; cursor: pointer;';
  5370. img.onclick = callbackOnClick;
  5371. var div = document.createElement('div');
  5372. div.style = 'text-align: center;display: ' + display;
  5373. div.appendChild(img);
  5374. return div;
  5375. };
  5376.  
  5377. function scizCreateIcon(height, display, icon) {
  5378. var img = document.createElement('img');
  5379. img.src = 'https://www.sciz.fr/static/' + icon;
  5380. img.alt = 'SCIZ icon';
  5381. img.style = 'height: ' + height + 'px;';
  5382. var div = document.createElement('div');
  5383. div.style = 'text-align: center;display: ' + display;
  5384. div.appendChild(img);
  5385. return div;
  5386. };
  5387.  
  5388. /* SCIZ - View */
  5389.  
  5390. function scizPrettyPrintTroll(t) {
  5391. var res = '';
  5392. // SCIZ progress bar
  5393. var pbPercent = (t.pdv !== null && t.pdv_max !== null) ? t.pdv / t.pdv_max * 100 : -1;
  5394. var pbColor = (pbPercent === -1) ? '#424242' : ((pbPercent < 40) ? '#ff5252' : ((pbPercent < 80) ? '#fb8c00' : '#4caf50'));
  5395. t.pdv_max = (t.pdv_max === null) ? '?' : t.pdv_max;
  5396. 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>';
  5397. // SCIZ other view enhancement...
  5398. return res;
  5399. }
  5400.  
  5401. function scizPrettyPrintTreasure(t) {
  5402. var res = '';
  5403. res += /* t.type + ' - ' + */ t.nom;
  5404. if (t.templates) { res += ' <b>' + t.templates + '</b>' };
  5405. if (t.mithril) { res += ' <b>en Mithril</b>' };
  5406. if (t.effet) { res += ' (' + t.effet + ')' };
  5407. return res;
  5408. }
  5409.  
  5410. function do_scizEnhanceView() {
  5411. scizGlobal.treasures = [];
  5412.  
  5413. // Ensure we have a JWT setup for the current user
  5414. jwt = MY_getValue(numTroll + '.SCIZJWT');
  5415. if (!jwt) { return; }
  5416.  
  5417. scizAddCSS();
  5418.  
  5419. /* SCIZ View - TROLLS */
  5420. cbx = MY_getValue(numTroll + '.SCIZ_CB_VIEW_TROLLS');
  5421. if (cbx !== '0') {
  5422. // Retrieve trolls
  5423. var ids = [];
  5424. const xPathTrollQuery = "//*/table[@id='VueTROLL']/tbody/tr";
  5425. var xPathTrolls = document.evaluate(xPathTrollQuery, document, null, 0, null);
  5426. while (xPathTroll = xPathTrolls.iterateNext()) {
  5427. scizGlobal.trolls.push({
  5428. 'id': parseInt(xPathTroll.children[2].innerHTML),
  5429. 'name': xPathTroll.children[3].innerHTML,
  5430. 'sciz_desc': null,
  5431. 'node': xPathTroll,
  5432. });
  5433. ids.push(xPathTroll.children[2].innerHTML);
  5434. }
  5435.  
  5436. // Add the new column for the SCIZ troll view
  5437. const xPathHeaderTrollQuery = "//*/table[@id='VueTROLL']/thead/tr";
  5438. var xPathHeaderTrolls = document.evaluate(xPathHeaderTrollQuery, document, null, 0, null).iterateNext();
  5439. var th = document.createElement('th');
  5440. th.align = 'center';
  5441. th.appendChild(scizCreateIcon('25', 'block', 'sciz-logo-quarter.png'));
  5442. xPathHeaderTrolls.insertBefore(th, xPathHeaderTrolls.children[4]);
  5443. for (i = 0; i < scizGlobal.trolls.length; i++) {
  5444. var td = document.createElement('td');
  5445. td.align = 'center';
  5446. scizGlobal.trolls[i].node.insertBefore(td, scizGlobal.trolls[i].node.children[4]);
  5447. }
  5448.  
  5449. // Call SCIZ
  5450. var sciz_url = 'https://www.sciz.fr/api/hook/trolls';
  5451. FF_XMLHttpRequest({
  5452. method: 'POST',
  5453. url: sciz_url,
  5454. headers: { 'Authorization': jwt, 'Content-type': 'application/json'},
  5455. data: JSON.stringify({'ids': ids}),
  5456. onload: function(responseDetails) {
  5457. try {
  5458. if (responseDetails.status == 0) {
  5459. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5460. window.console.log(responseDetails);
  5461. return;
  5462. }
  5463. var trolls = JSON.parse(responseDetails.responseText);
  5464. if (trolls.trolls.length < 1) {
  5465. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5466. return;
  5467. }
  5468. // Look for trolls to enhanced
  5469. trolls.trolls.forEach(t => {
  5470. for (i = 0; i < scizGlobal.trolls.length; i++) {
  5471. if (scizGlobal.trolls[i].id === t.id) {
  5472. // PrettyPrint
  5473. t = scizPrettyPrintTroll(t);
  5474. // Store the SCIZ troll desc
  5475. scizGlobal.trolls[i].sciz_desc = t;
  5476. // Add the SCIZ view
  5477. scizGlobal.trolls[i].node.children[4].innerHTML = t;
  5478. }
  5479. }
  5480. });
  5481. } catch(e) {
  5482. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5483. window.console.log(e);
  5484. }
  5485. }
  5486. });
  5487. }
  5488.  
  5489. cbx = MY_getValue(numTroll + '.SCIZ_CB_VIEW_TREASURES');
  5490. if (cbx !== '0') {
  5491. // Retrieve treasures
  5492. var ids = [];
  5493. const xPathQuery = "//*/table[@id='VueTRESOR']/tbody/tr";
  5494. var xPathEvents = document.evaluate(xPathQuery, document, null, 0, null);
  5495. while (xPathEvent = xPathEvents.iterateNext()) {
  5496. scizGlobal.treasures.push({
  5497. 'id': parseInt(xPathEvent.children[2].innerHTML),
  5498. 'type': xPathEvent.children[3].innerHTML,
  5499. 'sciz_desc': null,
  5500. 'buried': xPathEvent.children[3].innerHTML.includes('Enterré'),
  5501. 'node': xPathEvent,
  5502. });
  5503. ids.push(xPathEvent.children[2].innerHTML)
  5504. if (scizGlobal.treasures.length >= scizSetup.viewMaxEnhancedTreasure) { break; }
  5505. }
  5506.  
  5507. // Call SCIZ
  5508. var sciz_url = 'https://www.sciz.fr/api/hook/treasures';
  5509. FF_XMLHttpRequest({
  5510. method: 'POST',
  5511. url: sciz_url,
  5512. headers: { 'Authorization': jwt, 'Content-type': 'application/json'},
  5513. data: JSON.stringify({'ids': ids}),
  5514. onload: function(responseDetails) {
  5515. try {
  5516. if (responseDetails.status == 0) {
  5517. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5518. window.console.log(responseDetails);
  5519. return;
  5520. }
  5521. var treasures = JSON.parse(responseDetails.responseText);
  5522. if (treasures.treasures.length < 1) {
  5523. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5524. return;
  5525. }
  5526. // Look for treasures to enhanced
  5527. treasures.treasures.forEach(t => {
  5528. for (i = 0; i < scizGlobal.treasures.length; i++) {
  5529. if (scizGlobal.treasures[i].id === t.id) {
  5530. // PrettyPrint
  5531. t = scizPrettyPrintTreasure(t);
  5532. // Store the SCIZ treasure desc
  5533. scizGlobal.treasures[i].sciz_desc = t;
  5534. // Adapt the sciz type (delete the buried marker, the do_scizSwitchTreasures will handle it)
  5535. scizGlobal.treasures[i].type = scizGlobal.treasures[i].node.children[3].firstChild.textContent;
  5536. }
  5537. }
  5538. });
  5539. } catch(e) {
  5540. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5541. window.console.log(e);
  5542. }
  5543. // Do the display overwrite and add the switches
  5544. do_scizSwitchTreasures();
  5545. }
  5546. });
  5547. }
  5548. }
  5549.  
  5550. function do_scizSwitchTreasures() {
  5551. scizGlobal.treasures.forEach((t) => {
  5552. if (t.sciz_desc !== null) {
  5553. // Do the switch
  5554. const currentDesc = t.node.children[3].firstChild.textContent;
  5555. t.node.children[3].innerHTML = (currentDesc === t.type) ? ((t.sciz_desc !== null) ? t.sciz_desc : t.type) : t.type;
  5556. if (t.buried) {
  5557. t.node.children[3].innerHTML += '<img src="/mountyhall/Images/hidden.png" alt="[Enterré]" title="Enterré" width="15" height="15">';
  5558. }
  5559. // Add the SCIZ switcher
  5560. t.node.children[3].appendChild(scizCreateClickable('15', 'inline', do_scizSwitchTreasures));
  5561. }
  5562. });
  5563. }
  5564.  
  5565. /* SCIZ - Events */
  5566.  
  5567. function scizPrettyPrintEvent(e) {
  5568. 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
  5569. e.message = e.message.replace(/\n\s*\n*/g, '<br/>');
  5570. 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]];
  5571. beings.forEach(b => {
  5572. if (b[0] && b[1]) {
  5573. b[1] = b[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  5574. if (b[0].toString().length > 6) {
  5575. // Mob
  5576. b[1] = b[1].replace(/^une?\s/g, '');
  5577. 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>');
  5578. } else {
  5579. // Troll
  5580. e.message = e.message.replace(new RegExp('(' + b[1] + ')','gi'), '<b><a href="javascript:EPV(\'' + b[0] + '\')" class="mh_trolls_1">\$1</a></b>');
  5581. }
  5582. }
  5583. });
  5584. return e;
  5585. }
  5586.  
  5587. function do_scizOverwriteEvents() {
  5588. scizGlobal.events = [];
  5589. var eventTableNode = null;
  5590.  
  5591. // Ensure we have a JWT setup for the current user
  5592. jwt = MY_getValue(numTroll + '.SCIZJWT');
  5593. cbx = MY_getValue(numTroll + '.SCIZ_CB_EVENTS');
  5594. if (!jwt || cbx === '0') { return; }
  5595.  
  5596. // Retrieve being ID
  5597. const url = new URL(window.location.href);
  5598. var id = url.searchParams.get('ai_IDPJ');
  5599. id = (!id) ? numTroll : id;
  5600.  
  5601. // Check for advanced profil
  5602. const advanced = document.querySelector("[href*='MH_Style_ProfilAvance.css']") !== null;
  5603. const xPathQuery = (advanced) ? "//*/table[@id='events']/tbody/tr" : "//*/tr[@class='mh_tdpage']";
  5604.  
  5605. // Retrieve local events
  5606. var xPathEvents = document.evaluate(xPathQuery, document, null, 0, null);
  5607. while (xPathEvent = xPathEvents.iterateNext()) {
  5608. scizGlobal.events.push({
  5609. 'time': Date.parse(StringToDate(xPathEvent.children[0].innerHTML)),
  5610. 'type': xPathEvent.children[1].innerHTML,
  5611. 'desc': xPathEvent.children[2].innerHTML,
  5612. 'sciz_type': null,
  5613. 'sciz_desc': null,
  5614. 'node': xPathEvent,
  5615. });
  5616. if (eventTableNode === null) {
  5617. eventTableNode = xPathEvent.parentNode.parentNode;
  5618. }
  5619. }
  5620.  
  5621. const startTime = Math.min.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) - scizSetup.eventsMaxMatchingInterval;
  5622. const endTime = Math.max.apply(Math, scizGlobal.events.map(function(e) { return e.time; })) + scizSetup.eventsMaxMatchingInterval;
  5623.  
  5624. // Check if events have been found in the page
  5625. if (scizGlobal.events.length < 1) {
  5626. window.console.log('ERREUR - MZ/SCIZ - Aucun événement trouvé sur la page...');
  5627. return;
  5628. }
  5629.  
  5630. // Call SCIZ
  5631. var sciz_url = 'https://www.sciz.fr/api/hook/events/' + id + '/' + startTime + '/' + endTime;
  5632. const eventType = url.searchParams.get('as_EventType'); // Retrieve event type filter
  5633. sciz_url += (eventType !== null && eventType !== '') ? '/' + eventType.split(' ')[0] : '' // Only the first word used for filtering ("MORT par monstre" => "MORT");
  5634. FF_XMLHttpRequest({
  5635. method: 'GET',
  5636. url: sciz_url,
  5637. headers: { 'Authorization': jwt },
  5638. // trace: 'Appel à SCIZ pour l'entité ' + id,
  5639. onload: function(responseDetails) {
  5640. try {
  5641. if (responseDetails.status == 0) {
  5642. window.console.log('ERREUR - MZ/SCIZ - Appel à SCIZ en échec...');
  5643. window.console.log(responseDetails);
  5644. return;
  5645. }
  5646. var events = JSON.parse(responseDetails.responseText);
  5647. if (events.events.length < 1) {
  5648. // window.console.log('DEBUG - MZ/SCIZ - Aucun événement trouvé dans la base SCIZ...');
  5649. return;
  5650. }
  5651. // Look for events to overwrite (based on timestamps)
  5652. events.events.forEach(e => {
  5653. if (e.message.includes(id)) { // Exclude any event we were not looking for...
  5654. const t = Date.parse(StringToDate(e.time));
  5655. // Look for the best event matching and not already replaced
  5656. var i = -1;
  5657. var lastDelta = Infinity;
  5658. for (j = 0; j < scizGlobal.events.length; j++) {
  5659. if (scizGlobal.events[j].sciz_desc === null) {
  5660. var delta = Math.abs(t - scizGlobal.events[j].time);
  5661. if (delta <= scizSetup.eventsMaxMatchingInterval && delta < lastDelta) {
  5662. lastDelta = delta;
  5663. i = j;
  5664. }
  5665. }
  5666. }
  5667. if (i > -1) {
  5668. // PrettyPrint
  5669. e = scizPrettyPrintEvent(e);
  5670. // Store the SCIZ event and icon
  5671. var div = scizCreateIcon('25', 'block', e.icon);
  5672. scizGlobal.events[i].sciz_type = div.outerHTML;
  5673. scizGlobal.events[i].sciz_desc = e.message;
  5674. // Actual display overwrite
  5675. scizGlobal.events[i].node.children[1].setAttribute("valign", "middle");
  5676. scizGlobal.events[i].node.children[2].setAttribute("valign", "middle");
  5677. scizGlobal.events[i].node.children[1].innerHTML = scizGlobal.events[i].sciz_type;
  5678. scizGlobal.events[i].node.children[2].innerHTML = scizGlobal.events[i].sciz_desc;
  5679. }
  5680. }
  5681. });
  5682. // Add the switch button
  5683. if (eventTableNode !== null) {
  5684. var div = scizCreateClickable('50', 'block', do_scizSwitchEvents);
  5685. eventTableNode.parentNode.insertBefore(div, eventTableNode.nextSibling);
  5686. }
  5687. } catch(e) {
  5688. window.console.log('ERREUR - MZ/SCIZ - Stacktrace');
  5689. window.console.log(e);
  5690. }
  5691. }
  5692. });
  5693. }
  5694.  
  5695. function do_scizSwitchEvents() {
  5696. scizGlobal.events.forEach((e) => {
  5697. const currentType = e.node.children[1].innerHTML;
  5698. e.node.children[1].innerHTML = (currentType === e.type) ? ((e.sciz_type !== null) ? e.sciz_type : e.type) : e.type;
  5699. const currentDesc = e.node.children[2].innerHTML;
  5700. e.node.children[2].innerHTML = (currentDesc === e.desc) ? ((e.sciz_desc !== null) ? e.sciz_desc : e.desc) : e.desc;
  5701. });
  5702. }
  5703.  
  5704. /*******************************************************************************
  5705. * This file is part of Mountyzilla. *
  5706. * *
  5707. * Mountyzilla is free software; you can redistribute it and/or modify *
  5708. * it under the terms of the GNU General Public License as published by *
  5709. * the Free Software Foundation; either version 2 of the License, or *
  5710. * (at your option) any later version. *
  5711. * *
  5712. * Mountyzilla is distributed in the hope that it will be useful, *
  5713. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5714. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5715. * GNU General Public License for more details. *
  5716. * *
  5717. * You should have received a copy of the GNU General Public License *
  5718. * along with Mountyzilla; if not, write to the Free Software *
  5719. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5720. *******************************************************************************/
  5721.  
  5722. // x~x mission
  5723.  
  5724. /* TODO
  5725. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  5726. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  5727. *
  5728. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  5729. */
  5730. function isArray(a) {
  5731. return (!!a) && (a.constructor === Array);
  5732. }
  5733.  
  5734. function saveMission(num,obEtape) {
  5735. var obMissions;
  5736. if(MY_getValue(numTroll+'.MISSIONS')) {
  5737. try {
  5738. //window.console.log('JSON MISSION (before) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5739. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  5740. } catch(e) {
  5741. window.console.error(traceStack(e, 'Mission parsage'));
  5742. return;
  5743. }
  5744. }
  5745. if (isArray(obMissions)) obMissions = new Object(); // corrige certains cas issus d'anciennes versions MZ
  5746. if (obMissions == undefined) obMissions = new Object(); // protection
  5747. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  5748. if(obEtape) {
  5749. obMissions[num] = obEtape;
  5750. } else if(obMissions[num]) {
  5751. delete obMissions[num];
  5752. }
  5753. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  5754. //window.console.log('JSON MISSION (after) = ' + MY_getValue(numTroll+'.MISSIONS'));
  5755. }
  5756.  
  5757. function addtroogle(tdLibelle, sRestrict) {
  5758. var img = document.createElement('img');
  5759. img.src = URL_MZimg + 'troogle.ico';
  5760. img.alt = 'Troogle logo';
  5761. var a = document.createElement('a');
  5762. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  5763. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  5764. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  5765. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  5766. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  5767. a.href = url;
  5768. a.title = 'Chercher sur Troogle';
  5769. a.target = 'troogle';
  5770. a.appendChild(img);
  5771. tdLibelle.appendChild(a);
  5772. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  5773. }
  5774.  
  5775. function traiteMission() {
  5776. try {
  5777. var titreMission = document.getElementsByClassName('titre2')[0];
  5778. var numMission = titreMission.textContent.match(/\d+/)[0];
  5779. var missionForm = document.getElementsByName('ActionForm')[0];
  5780. var tdLibelle = document.evaluate(
  5781. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  5782. missionForm, null, 9, null).singleNodeValue;
  5783. } catch(e) {
  5784. window.console.error(traceStack(e, 'récupération mission'));
  5785. return;
  5786. }
  5787. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  5788. try {
  5789. if(!tdLibelle) {
  5790. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  5791. debugMZ('traiteMission, la mission semble terminée');
  5792. saveMission(numMission,false);
  5793. return;
  5794. }
  5795.  
  5796. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  5797. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  5798. // debug Roule'
  5799. if (MY_DEBUG) {
  5800. for (var i =0; i < tdLibelle.childNodes.length; i++)
  5801. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  5802. }
  5803. if(libelle.indexOf('niveau égal à')!=-1) {
  5804. var nbKills = 1, niveau, mod;
  5805. // exemples :
  5806. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  5807. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  5808. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  5809. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  5810. if (tdLibelle.childNodes.length == 1) {
  5811. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  5812. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  5813. if (m) {
  5814. niveau = Number(m[1]);
  5815. mod = 'plus'
  5816. } else {
  5817. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  5818. if (m) {
  5819. niveau = Number(m[1]);
  5820. mod = Number(m[2]);
  5821. } else {
  5822. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  5823. return;
  5824. }
  5825. }
  5826. } else {
  5827. // ancienne méthode (multi childnode)
  5828. // à supprimer un jour peut-être
  5829. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  5830. // Étape de kill multiple de niveau donné
  5831. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5832. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  5833. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5834. niveau = Number(mod[0]);
  5835. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5836. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  5837. } else {
  5838. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  5839. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  5840. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  5841. mod = mod ? Number(mod[0]) : 'plus';
  5842. }
  5843. } else {
  5844. // Étape de kill unique de niveau donné
  5845. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  5846. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  5847. mod = mod ? Number(mod[0]) : 'plus';
  5848. }
  5849. }
  5850. // if (isDEV) {
  5851. // niveau = 35; // pour les tests Roule
  5852. // alert('niveau forcé à 35 pour test');
  5853. // }
  5854. // debug Roule'
  5855. if (MY_DEBUG) {
  5856. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  5857. }
  5858. saveMission(numMission,{
  5859. type: 'Niveau',
  5860. niveau: niveau,
  5861. mod: mod,
  5862. mundidey: siMundidey,
  5863. libelle: libelle
  5864. });
  5865. if (mod == 'plus')
  5866. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  5867. else
  5868. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  5869. } else if(libelle.indexOf('de la race')!=-1) {
  5870. var nbKills = 1, race;
  5871. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  5872. // Étape de kill multiple de race donnée
  5873. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5874. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5875. } else {
  5876. // Étape de kill unique de race donnée
  5877. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5878. }
  5879. race = race.replace(/\"/g,'');
  5880. race = removeEnclosingSimpleCote(race); // Roule 29/03/2019 Maintenant, on a des '
  5881. saveMission(numMission,{
  5882. type: 'Race',
  5883. race: race,
  5884. mundidey: siMundidey,
  5885. libelle: libelle
  5886. });
  5887. addtroogle(tdLibelle, '@monstre ' + race);
  5888. } else if(libelle.indexOf('de la famille')!=-1) {
  5889. var nbKills = 1, famille;
  5890. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  5891. // Étape de kill multiple de famille donnée
  5892. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5893. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  5894. } else {
  5895. // Étape de kill unique de famille donnée
  5896. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  5897. }
  5898. famille = famille.replace(/\"/g,'');
  5899. famille = removeEnclosingSimpleCote(famille); // Roule 29/03/2019 Maintenant, on a des '
  5900. saveMission(numMission,{
  5901. type: 'Famille',
  5902. famille: famille,
  5903. mundidey: siMundidey,
  5904. libelle: libelle
  5905. });
  5906. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  5907. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  5908. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  5909. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  5910. debugMZ('traiteMission étape capacité spéciale');
  5911. pouvoir = removeEnclosingSimpleCote(pouvoir); // Roule 29/03/2019 Maintenant, on a des '
  5912. saveMission(numMission,{
  5913. type: 'Pouvoir',
  5914. pouvoir: pouvoir,
  5915. libelle: libelle
  5916. });
  5917. } else {
  5918. debugMZ('traiteMission étape pas pour troogle');
  5919. saveMission(numMission,false);
  5920. }
  5921. } catch(e) {
  5922. window.console.error(traceStack(e, 'récupération étape mission'));
  5923. return;
  5924. }
  5925. }
  5926.  
  5927. function removeEnclosingSimpleCote(x) { // Roule 29/03/2019
  5928. return x.replace(/'$/, '').replace(/^'/, '');
  5929. }
  5930.  
  5931. function do_mission() {
  5932. start_script(60);
  5933.  
  5934. traiteMission();
  5935.  
  5936. displayScriptTime();
  5937. }
  5938.  
  5939. /*******************************************************************************
  5940. * This file is part of Mountyzilla. *
  5941. * *
  5942. * Mountyzilla is free software; you can redistribute it and/or modify *
  5943. * it under the terms of the GNU General Public License as published by *
  5944. * the Free Software Foundation; either version 2 of the License, or *
  5945. * (at your option) any later version. *
  5946. * *
  5947. * Mountyzilla is distributed in the hope that it will be useful, *
  5948. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5949. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5950. * GNU General Public License for more details. *
  5951. * *
  5952. * You should have received a copy of the GNU General Public License *
  5953. * along with Mountyzilla; if not, write to the Free Software *
  5954. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5955. *******************************************************************************/
  5956.  
  5957. // x~x move
  5958.  
  5959. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  5960.  
  5961. var petitsTrous = {
  5962. '-52;57': true,
  5963. '55;70': true,
  5964. '64;70': true,
  5965. '12;-15': true,
  5966. '30;-52': true,
  5967. '48;-39': true
  5968. };
  5969.  
  5970. var grosTrous = {
  5971. '-35;65': true,
  5972. '-13;73': true,
  5973. '-64;9': true,
  5974. '-35;15': true,
  5975. '5;32': true,
  5976. '10;64': true,
  5977. '21;36': true,
  5978. '46;52': true,
  5979. '74;32': true,
  5980. '-71;-7': true,
  5981. '-67;-37': true,
  5982. '-60;-32': true,
  5983. '-51;-22': true,
  5984. '-36;-51': true,
  5985. '5;-49': true
  5986. };
  5987.  
  5988. var centreCarmine_X = 56.5;
  5989. var centreCarmine_Y = 23.5;
  5990. var rayonCarmine = 8.7;
  5991.  
  5992. function isTrou(x,y,n) {
  5993. if(petitsTrous[x+';'+y]) {
  5994. return n<0 && n>-60;
  5995. }
  5996. if(grosTrous[x+';'+y]
  5997. || grosTrous[x-1+';'+y]
  5998. || grosTrous[x+';'+y+1]
  5999. || grosTrous[x-1+';'+y+1]) {
  6000. return n<0 && n>-70;
  6001. }
  6002. if(Math.sqrt(
  6003. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  6004. )<=rayonCarmine) {
  6005. return n<0 && n>-100;
  6006. }
  6007. return false;
  6008. }
  6009.  
  6010. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  6011.  
  6012. function validateDestination() {
  6013. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  6014. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  6015. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  6016. var form = document.getElementsByName('ActionForm')[0];
  6017. if(form) {
  6018. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  6019. if(document.getElementsByName('ai_DeplX')[i].checked) {
  6020. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  6021. }
  6022. }
  6023. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  6024. if(document.getElementsByName('ai_DeplY')[i].checked) {
  6025. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  6026. }
  6027. }
  6028. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  6029. if(document.getElementsByName('ai_DeplN')[i].checked) {
  6030. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  6031. }
  6032. }
  6033. if(isTrou(x,y,n)) {
  6034. return window.confirm(
  6035. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  6036. +'Vous allez tomber dans un trou de météorite.\n'
  6037. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  6038. );
  6039. }
  6040. }
  6041. return true;
  6042. }
  6043.  
  6044. function newsubmitDE(event) {
  6045. event.stopPropagation();
  6046. event.preventDefault();
  6047. if(validateDestination()) {
  6048. this.submit();
  6049. }
  6050. }
  6051.  
  6052. function changeValidation() {
  6053. var form = document.getElementsByName('ActionForm')[0];
  6054. if(form) {
  6055. form.addEventListener('submit', newsubmitDE, true);
  6056. }
  6057. }
  6058.  
  6059.  
  6060. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  6061.  
  6062. function validateTPDestination() {
  6063. try {
  6064. var text = document.getElementsByTagName('B')[0];
  6065. var a = text.firstChild.nodeValue.split('|');
  6066. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  6067. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  6068. var pos_n = a[2].substring(5, a[2].length) * 1;
  6069.  
  6070. var nbtrous = 0;
  6071. for(var signX=-1 ; signX<=1 ; signX+=2) {
  6072. for(var x=0 ; x<=2 ; x++) {
  6073. for(var signY=-1 ; signY<=1 ; signY+=2) {
  6074. for(var y=0 ; y<=2 ; y++) {
  6075. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  6076. for(var n = 0 ; n <= 1 ; n++) {
  6077. if(isTrou(
  6078. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  6079. )) {
  6080. nbtrous++;
  6081. }
  6082. }
  6083. }
  6084. }
  6085. }
  6086. }
  6087. }
  6088. if(nbtrous>0 && nbtrous<72) {
  6089. return window.confirm(
  6090. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  6091. +'Vous avez '+Math.floor((100*nbtrous)/144)
  6092. +'% de risque de tomber dans un trou de météorite.\n'
  6093. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  6094. );
  6095. }
  6096. else if(nbtrous>=72) {
  6097. return window.confirm(
  6098. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  6099. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  6100. +'% de risque de tomber dans un trou de météorite !\n'
  6101. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  6102. );
  6103. }
  6104. return true;
  6105. }
  6106. catch(e) {
  6107. window.alert(e)
  6108. }
  6109. }
  6110.  
  6111. function newsubmitTP(event) {
  6112. event.stopPropagation();
  6113. event.preventDefault();
  6114. if(validateTPDestination()) {
  6115. this.submit();
  6116. }
  6117. }
  6118.  
  6119. function changeButtonValidate() {
  6120. var form = document.getElementsByName('Formulaire')[0];
  6121. if(form) {
  6122. if(!form.getAttribute('onsubmit')) {
  6123. form.setAttribute('onsubmit','return true;');
  6124. }
  6125. form.addEventListener('submit', newsubmitTP, true);
  6126. }
  6127. }
  6128.  
  6129.  
  6130. /*-[functions]---------------- Partie Principale -----------------------------*/
  6131.  
  6132. function do_move() {
  6133. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  6134. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  6135. changeValidation();
  6136. //}
  6137. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  6138. // changeButtonValidate();
  6139. //}
  6140. }
  6141.  
  6142. /*******************************************************************************
  6143. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  6144. * Mountyzilla is free software; provided under the GNU General Public License *
  6145. *******************************************************************************/
  6146.  
  6147. // x~x news
  6148.  
  6149. // Nombre de news à afficher & nb max de caractères par news:
  6150. var nbItems = 5;
  6151. var maxCarDescription = 300;
  6152.  
  6153. /*-[functions]------------------- Utilitaires --------------------------------*/
  6154.  
  6155. // Ne semble avoir strictement aucun effet:
  6156. String.prototype.epureDescription = function() {
  6157. return this.replace(/\\(.)/g,"$1");
  6158. }
  6159.  
  6160. function appendTitledTable(node,titre,description) {
  6161. // Crée les tables contenant les infos (avec titre)
  6162. var table = document.createElement('table');
  6163. table.border = 0;
  6164. table.className = 'mh_tdborder';
  6165. table.cellSpacing = 1;
  6166. table.cellPadding = 1;
  6167. table.style.maxWidth = '98%';
  6168. table.style.marginLeft = 'auto';
  6169. table.style.marginRight = 'auto';
  6170. var tbody = document.createElement('tbody');
  6171. table.appendChild(tbody);
  6172. var tr = appendTr(tbody,'mh_tdtitre');
  6173. var td = appendTdCenter(tr,2);
  6174. var span = document.createElement('span');
  6175. appendText(span,titre,true);
  6176. if(description) {
  6177. span.title = description;
  6178. }
  6179. td.appendChild(span);
  6180. node.appendChild(table);
  6181. return tbody;
  6182. }
  6183.  
  6184. function testCertif(paramURL, callbackOnError) {
  6185. try {
  6186. FF_XMLHttpRequest({
  6187. method: 'GET',
  6188. url: paramURL,
  6189. onload: function(responseDetails) {
  6190. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  6191. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  6192. }
  6193. });
  6194. } catch(e) {
  6195. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  6196. callbackOnError();
  6197. }
  6198. }
  6199.  
  6200. function createOrGetGrandCadre() {
  6201. var grandCadre = document.getElementById('grandCadre');
  6202. if (grandCadre) return grandCadre;
  6203. try {
  6204. var rappels = document.evaluate(
  6205. "//p[contains(a/text(),'messagerie')]",
  6206. document, null, 9, null).singleNodeValue;
  6207. }
  6208. catch(e) {
  6209. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  6210. grandCadre = document.createElement('div');
  6211. return grandCadre;
  6212. }
  6213. grandCadre = document.createElement('div');
  6214. grandCadre.id = 'grandCadre';
  6215. var sousCadre = document.createElement('div');
  6216. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  6217. sousCadre.style.textAlign = 'center';
  6218. sousCadre.style.fontSize = 'xx-large';
  6219. grandCadre.appendChild(sousCadre);
  6220.  
  6221. grandCadre.style.border = 'solid 5px red';
  6222. grandCadre.style.width = 'auto';
  6223. insertBefore(rappels,grandCadre);
  6224. return grandCadre;
  6225. }
  6226.  
  6227. function showHttpsErrorCadre1() {
  6228. window.console.log('[MZ] showHttpsErrorCadre1');
  6229. var grandCadre = createOrGetGrandCadre();
  6230. var sousCadre = document.createElement('div');
  6231. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  6232. + '<br />Cela empêchera Moutyzilla de fonctionner'
  6233. + '<br /><a style="color:blue;font-size: inherits;" href="'
  6234. + URL_CertifRaistlin1
  6235. + '" target="raistlin">clique ici</a>'
  6236. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6237. + ' « Confirmer l\'exception de sécurité »'
  6238. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6239. sousCadre.style.width = 'auto';
  6240. sousCadre.style.fontSize = 'large';
  6241. sousCadre.style.border = 'solid 1px black';
  6242. sousCadre.style.backgroundColor = 'red';
  6243. grandCadre.appendChild(sousCadre);
  6244. }
  6245.  
  6246. function showHttpsErrorCadre2() {
  6247. window.console.log('[MZ] showHttpsErrorCadre2');
  6248. var grandCadre = createOrGetGrandCadre();
  6249. var sousCadre = document.createElement('div');
  6250. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  6251. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  6252. + '<a style="color:blue;font-size: inherits;" href="'
  6253. + URL_CertifRaistlin2
  6254. + '" target="raistlin">clique ici</a>'
  6255. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  6256. + ' « Confirmer l\'exception de sécurité »'
  6257. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  6258. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  6259. sousCadre.style.width = 'auto';
  6260. sousCadre.style.fontSize = 'large';
  6261. sousCadre.style.border = 'solid 1px black';
  6262. sousCadre.style.backgroundColor = 'red';
  6263. grandCadre.appendChild(sousCadre);
  6264. }
  6265.  
  6266. function showHttpsErrorContenuMixte() {
  6267. window.console.log('[MZ] showHttpsErrorContenuMixte');
  6268. var grandCadre = createOrGetGrandCadre();
  6269. var sousCadre = document.createElement('div');
  6270. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  6271. + '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)'
  6272. + '<ul>'
  6273. + '<li>Interface Bricol\'Troll</li>'
  6274. + '<li>Nouveautés de Mountyzilla</li>'
  6275. + '</ul>'
  6276. + '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 />'
  6277. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  6278. sousCadre.style.width = 'auto';
  6279. sousCadre.style.fontSize = 'large';
  6280. sousCadre.style.border = 'solid 1px black';
  6281. grandCadre.appendChild(sousCadre);
  6282. }
  6283.  
  6284. /*-[functions]------------------- Jubilaires ---------------------------------*/
  6285.  
  6286. function traiterJubilaires() {
  6287. // à faire
  6288. }
  6289.  
  6290. function traiterJubilaires_a_supprimer() { // ancienne méthode
  6291. try {
  6292. FF_XMLHttpRequest({
  6293. method: 'GET',
  6294. url: URL_anniv,
  6295. headers: {
  6296. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  6297. 'Accept': 'application/xml,text/xml',
  6298. },
  6299. onload: function(responseDetails) {
  6300. if ((responseDetails.status == 0) && isHTTPS) {
  6301. window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  6302. //showHttpsErrorContenuMixte();
  6303. return;
  6304. }
  6305. var listeTrolls = responseDetails.responseText.split('\n');
  6306. if(!listeTrolls || listeTrolls.length==0) {
  6307. return;
  6308. }
  6309. afficherJubilaires(listeTrolls);
  6310. },
  6311. });
  6312. }
  6313. catch(e) {
  6314. if (isHTTPS) {
  6315. window.console.log(traceStack(e, 'appel jubilaires'));
  6316. showHttpsErrorContenuMixte();
  6317. } else {
  6318. window.alert('Erreur Jubilaires:\n'+e);
  6319. }
  6320. }
  6321. }
  6322.  
  6323. function afficherJubilaires(listeTrolls) {
  6324. try {
  6325. var rappels = document.evaluate(
  6326. "//p[contains(a/text(),'messagerie')]",
  6327. document, null, 9, null).singleNodeValue;
  6328. }
  6329. catch(e) {
  6330. return;
  6331. }
  6332. var p = document.createElement('p');
  6333. var tbody = appendTitledTable(p,
  6334. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  6335. 'Envoyez leur un message ou un cadeau !'
  6336. );
  6337. tr = appendTr(tbody,'mh_tdpage');
  6338. td = appendTdCenter(tr);
  6339. var small = document.createElement('small');
  6340. td.appendChild(small);
  6341. var first = true;
  6342. for(var i=0 ; i<listeTrolls.length ; i++) {
  6343. var infos = listeTrolls[i].split(';');
  6344. if(infos.length!=3 || infos[2]==='0') {
  6345. continue;
  6346. }
  6347. if(first) {
  6348. first = false;
  6349. }
  6350. else {
  6351. appendText(small,', ');
  6352. }
  6353. var a = document.createElement('a');
  6354. a.href = 'javascript:EPV('+infos[0]+')';
  6355. appendText(a,infos[1]);
  6356. small.appendChild(a);
  6357. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  6358. }
  6359. insertBefore(rappels,p);
  6360. }
  6361.  
  6362.  
  6363. /*-[functions]--------------------- News MZ ----------------------------------*/
  6364.  
  6365. function traiterNouvelles() {
  6366. var news = new Array;
  6367. news.push(['15/11/2019', 'Refonte des calculs tactiques dans la vue. Affichage du niveau du monstre à tout coup (ou presque).']);
  6368. 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 ;).']);
  6369. afficherNouvelles(news);
  6370. }
  6371.  
  6372. function afficherNouvelles(items) {
  6373. var footer = document.getElementById('footer1');
  6374. if(!footer) {
  6375. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  6376. return;
  6377. }
  6378. var p = document.createElement('p');
  6379. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  6380. var div = document.createElement('div');
  6381. div.style.position = 'absolute';
  6382. div.style.right = 0;
  6383. div.style.top = 0;
  6384. div.style.paddingRight = '3px';
  6385. div.style.whiteSpace = 'nowrap';
  6386. appendText(div, '(version ' + GM_info.script.version + ')');
  6387. tbody.rows[0].cells[0].style.position = 'relative';
  6388. tbody.rows[0].cells[0].appendChild(div);
  6389. for(var i=0 ; i<items.length ; i++) {
  6390. var tr = appendTr(tbody,'mh_tdpage');
  6391. var td = appendTdCenter(tr);
  6392. td.style.verticalAlign = 'top'; // semble sans effet
  6393. appendText(td,items[i][0],true);
  6394. td = appendTd(tr);
  6395. td.innerHTML = items[i][1];
  6396. }
  6397. insertBefore(footer,p);
  6398.  
  6399. // changelog
  6400. var p = document.createElement('p');
  6401. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  6402. tbody.rows[0].cells[0].style.cursor = 'pointer';
  6403. tbody.rows[0].cells[0].onclick = function() {
  6404. try {
  6405. tbody.rows[0].cells[0].onclick = undefined;
  6406. tbody.rows[0].cells[0].style.cursor = '';
  6407. var tr = appendTr(tbody,'mh_tdpage');
  6408. var td = appendTd(tr);
  6409. td.colSpan = 2;
  6410. var pre = document.createElement('pre');
  6411. appendText(pre,MZ_changeLog.join("\n"));
  6412. td.appendChild(pre);
  6413. } catch (e) {
  6414. window.console.log('[MZ] affichage changeLog', e);
  6415. }
  6416. };
  6417. insertBefore(footer,p);
  6418.  
  6419. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  6420. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  6421. if (isHTTPS) {
  6422. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  6423. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6424. } else {
  6425. window.console.log('[MZ test] début switch to https');
  6426. window.sessionStorage.setItem('xxx', "test session trans https");
  6427. window.parent.xxx = "autre test";
  6428. var url = document.location.href;
  6429. window.console.log('[MZ test] url=' + url);
  6430. url = url.replace(/http:\/\//i, 'https://')
  6431. window.console.log('[MZ test] switched url=' + url);
  6432. document.location.href = url;
  6433. }
  6434. }
  6435. if (false) { // version par utilisation d'un IFrame en https
  6436. if (isHTTPS) {
  6437. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  6438. //window.console.log('[MZ test] window.name=' + window.name);
  6439. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  6440. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  6441. var txt = window.name;
  6442. var tabtxt = txt.split(/µ/);
  6443. for (var i = 0; i < tabtxt.length; i++) {
  6444. window.console.log('[MZ test]config https ' + tabtxt[i]);
  6445. }
  6446. } else {
  6447. var txt = '';
  6448. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6449. var k = localStorage.key(i);
  6450. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6451. txt += k + "£" + localStorage.getItem(k) + "µ";
  6452. }
  6453. var iframe = document.createElement('iframe');
  6454. var url = document.location.href;
  6455. //window.console.log('[MZ test] url=' + url);
  6456. url = url.replace(/http:\/\//i, 'https://')
  6457. //window.console.log('[MZ test] switched url=' + url);
  6458. //iframe.xxx = "truc en plume";
  6459. iframe.name = txt;
  6460. //window.xxx = "machin";
  6461. iframe.src = url;
  6462. //iframe.document.xxx = "truc en plume";
  6463. document.body.appendChild(iframe);
  6464. iframe.style.display = 'none';
  6465. }
  6466. }
  6467. }
  6468. }
  6469.  
  6470.  
  6471. /*---------------------------------- Main ------------------------------------*/
  6472.  
  6473. function do_news() {
  6474. start_script();
  6475.  
  6476. traiterJubilaires();
  6477. traiterNouvelles();
  6478.  
  6479. /* plus besoin, le certificat est "officiel"
  6480. if (isHTTPS) {
  6481. // test si les certificats raistlin ont été acceptés
  6482. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  6483. var infoit = MY_getValue(numTroll+'.INFOSIT');
  6484. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  6485. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  6486. }
  6487. }
  6488. */
  6489.  
  6490. displayScriptTime();
  6491. }
  6492.  
  6493. /*********************************************************************************
  6494. * This file is part of Mountyzilla. *
  6495. * *
  6496. * Mountyzilla is free software; you can redistribute it and/or modify *
  6497. * it under the terms of the GNU General Public License as published by *
  6498. * the Free Software Foundation; either version 2 of the License, or *
  6499. * (at your option) any later version. *
  6500. * *
  6501. * Mountyzilla is distributed in the hope that it will be useful, *
  6502. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6503. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6504. * GNU General Public License for more details. *
  6505. * *
  6506. * You should have received a copy of the GNU General Public License *
  6507. * along with Mountyzilla; if not, write to the Free Software *
  6508. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6509. *********************************************************************************/
  6510.  
  6511. // x~x tabcompo
  6512.  
  6513. var popup;
  6514.  
  6515. function initPopupTabcompo() {
  6516. popup = document.createElement('div');
  6517. popup.setAttribute('id', 'popup');
  6518. popup.setAttribute('class', 'mh_textbox');
  6519. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  6520. + 'display: inline; z-index: 3; max-width: 400px;');
  6521. document.body.appendChild(popup);
  6522. }
  6523.  
  6524. function showPopup(evt) {
  6525. var texte = this.getAttribute("texteinfo");
  6526. popup.innerHTML = texte;
  6527. popup.style.left = evt.pageX + 15 + 'px';
  6528. popup.style.top = evt.pageY + 'px';
  6529. popup.style.visibility = "visible";
  6530. }
  6531.  
  6532. // roule 16/03/2016, existe déjà ailleurs
  6533. // function hidePopup() {
  6534. // popup.style.visibility = 'hidden';
  6535. // }
  6536.  
  6537. function createPopupImage_tabcompo(url, text)
  6538. {
  6539. var img = document.createElement('img');
  6540. img.setAttribute('src',url);
  6541. img.setAttribute('align','ABSMIDDLE');
  6542. img.setAttribute("texteinfo",text);
  6543. img.addEventListener("mouseover", showPopup,true);
  6544. img.addEventListener("mouseout", hidePopup,true);
  6545. return img;
  6546. }
  6547.  
  6548. function formateTexte_tabcompo(texte)
  6549. {
  6550. texte = texte.replace(/\n/g,"<br/>");
  6551. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  6552. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  6553. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  6554. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  6555. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  6556. return texte;
  6557. }
  6558.  
  6559. function arrondi(x) {
  6560. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  6561. }
  6562.  
  6563. function traiteMinerai_tabcompo() {
  6564. if (currentURL.indexOf("as_type=Divers")==-1) return;
  6565. try {
  6566. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  6567. +" and contains(./tr/th/text(),'Minerai')]",
  6568. document, null, 9, null).singleNodeValue;
  6569. node = node.nextSibling.nextSibling;
  6570. }
  6571. catch(e) {return;}
  6572.  
  6573. var trlist = document.evaluate('./tr', node, null, 7, null);
  6574. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  6575. var node = trlist.snapshotItem(i);
  6576. var nature = node.childNodes[5].textContent;
  6577. var caracs = node.childNodes[7].textContent;
  6578. var taille = caracs.match(/\d+/)[0];
  6579. var coef = 1;
  6580. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  6581. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  6582. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  6583. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6584. if (nature.indexOf('Mithril')!=-1) {
  6585. coef = 0.2*coef;
  6586. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  6587. }
  6588. else {
  6589. coef = 0.75*coef+1.25;
  6590. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6591. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  6592. }
  6593. }
  6594. }
  6595.  
  6596. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  6597. function treateComposants() {
  6598. if (currentURL.indexOf("as_type=Compo")==-1) return;
  6599. //On récupère les composants
  6600. var nodes = document.evaluate(
  6601. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6602. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6603. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  6604. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6605. if (nodes.snapshotLength == 0) {
  6606. //window.console.log('[MZ] treateComposants DOWN');
  6607. return;
  6608. }
  6609. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  6610.  
  6611. var texte = "";
  6612. for (var i = 0; i < nodes.snapshotLength; i++) {
  6613. var n1 = nodes.snapshotItem(i).childNodes[1];
  6614. var n3 = nodes.snapshotItem(i).childNodes[3];
  6615. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6616. var prix = n3.childNodes[0].nodeValue;
  6617. if (!prix)
  6618. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6619. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6620. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6621. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6622. + prix.replace(/\n/g, '') + "\n";
  6623. }
  6624.  
  6625. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6626. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6627. var id_taniere = c.snapshotItem(0).nodeValue;
  6628. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  6629.  
  6630. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6631. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  6632. if (form)
  6633. {
  6634. if(document.getElementsByTagName('form').length>0)
  6635. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6636. else
  6637. {
  6638. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6639. insertBefore(thisP, form);
  6640. }
  6641. }
  6642. }
  6643.  
  6644. function treateAllComposants() {
  6645. if(currentURL.indexOf("as_type=Compo")==-1) return;
  6646.  
  6647. //On récupère les composants
  6648. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  6649. document, null, 0, null ).numberValue;
  6650. var c = (categ == 0 ? 3 : 4);
  6651. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  6652. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  6653. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  6654. + "td["+c+"]/text()[1] = '\u0040-\u0040' "
  6655. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  6656. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  6657. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  6658. + "and td[1]/img/@alt = 'Identifié']",
  6659. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6660. if (nodes.snapshotLength == 0) {
  6661. // window.alert('treateAllComposants DOWN');
  6662. return;
  6663. }
  6664.  
  6665. var texte = "";
  6666. for (var i = 0; i < nodes.snapshotLength; i++) {
  6667. var n1 = nodes.snapshotItem(i).childNodes[1];
  6668. var n3 = nodes.snapshotItem(i).childNodes[3];
  6669. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  6670. var prix = n3.childNodes[0].nodeValue;
  6671. if (!prix)
  6672. {
  6673. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  6674. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  6675. }
  6676. else
  6677. {
  6678. prix= prix.replace(/[\240 ]/g, "");
  6679. if(prix=="-")
  6680. prix=null;
  6681. }
  6682. if(prix)
  6683. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6684. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6685. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  6686. + prix.replace(/\n/g, '') + "\n";
  6687. else
  6688. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  6689. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  6690. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  6691. }
  6692.  
  6693. var c = document.evaluate("//div[@class = 'titre2']/text()",
  6694. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6695. var id_taniere = c.snapshotItem(0).nodeValue;
  6696. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  6697.  
  6698. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  6699. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  6700. if (form)
  6701. {
  6702. if(document.getElementsByTagName('form').length>0)
  6703. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  6704. else
  6705. {
  6706. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6707. insertBefore(thisP, form);
  6708. }
  6709. }
  6710. }
  6711.  
  6712. function treateEM()
  6713. {
  6714. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  6715. if(currentURL.indexOf("as_type=Compo")==-1)
  6716. return false;
  6717. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  6718. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  6719. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6720. if (nodes.snapshotLength == 0)
  6721. return false;
  6722. for (var i = 0; i < nodes.snapshotLength; i++) {
  6723. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  6724. var link = desc[2].firstChild ;
  6725. var nomCompoTotal = desc[2].textContent ;
  6726. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6727. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6728. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  6729. var locqual = desc[3].textContent ;
  6730. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  6731. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  6732. if(isEM(nomMonstre).length>0)
  6733. {
  6734. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  6735. if(infos.length>0)
  6736. {
  6737. var shortDescr = "Variable";
  6738. var bold = 0;
  6739. if(infos != "Composant variable")
  6740. {
  6741. shortDescr = infos.substring(0,infos.indexOf(" "));
  6742. if(parseInt(shortDescr)>=0)
  6743. bold=1;
  6744. }
  6745. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  6746. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  6747. }
  6748. }
  6749.  
  6750. }
  6751. }
  6752.  
  6753. function treateChampi_tabcompo() {
  6754. if (currentURL.indexOf('as_type=Champi')==-1)
  6755. return false;
  6756. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  6757. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6758. if (nodes.snapshotLength == 0)
  6759. return false;
  6760.  
  6761. for (var i = 0; i < nodes.snapshotLength; i++) {
  6762. var node = nodes.snapshotItem(i);
  6763. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  6764. if (moisChampi[nomChampi])
  6765. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  6766. }
  6767. }
  6768.  
  6769. function treateEnchant()
  6770. {
  6771. if(currentURL.indexOf("as_type=Compo")==-1)
  6772. return false;
  6773. try
  6774. {
  6775. if(!listeMonstreEnchantement)
  6776. computeCompoEnchantement();
  6777. var nodes = document.evaluate(
  6778. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  6779. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  6780. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  6781. if (nodes.snapshotLength == 0)
  6782. return false;
  6783. var urlImg = URL_MZimg + "enchant.png";
  6784. for (var i = 0; i < nodes.snapshotLength; i++) {
  6785. var link = nodes.snapshotItem(i);
  6786. var nomCompoTotal = link.firstChild.nodeValue;
  6787. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  6788. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  6789. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  6790. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  6791. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  6792. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  6793. if(isEnchant(nomMonstre).length>0)
  6794. {
  6795. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  6796. if(infos.length>0)
  6797. {
  6798. link.parentNode.appendChild(createImage(urlImg,infos));
  6799. }
  6800. }
  6801. }
  6802. }
  6803. catch(e)
  6804. {
  6805. window.alert(e);
  6806. }
  6807. }
  6808.  
  6809. function treateEquipEnchant()
  6810. {
  6811. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  6812. return false;
  6813. initPopupTabcompo();
  6814. computeEnchantementEquipement(createPopupImage_tabcompo,formateTexte_tabcompo);
  6815. }
  6816.  
  6817. function do_tancompo() {
  6818. start_script();
  6819.  
  6820. treateAllComposants();
  6821. treateComposants();
  6822. traiteMinerai_tabcompo();
  6823. if (MY_getValue('NOINFOEM')!='true') {
  6824. treateChampi_tabcompo();
  6825. treateEM();
  6826. }
  6827. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  6828. treateEnchant();
  6829. treateEquipEnchant();
  6830. }
  6831.  
  6832. displayScriptTime();
  6833. }
  6834.  
  6835. /*******************************************************************************
  6836. * This file is part of Mountyzilla. *
  6837. * *
  6838. * Mountyzilla is free software; you can redistribute it and/or modify *
  6839. * it under the terms of the GNU General Public License as published by *
  6840. * the Free Software Foundation; either version 2 of the License, or *
  6841. * (at your option) any later version. *
  6842. * *
  6843. * Mountyzilla is distributed in the hope that it will be useful, *
  6844. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6845. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6846. * GNU General Public License for more details. *
  6847. * *
  6848. * You should have received a copy of the GNU General Public License *
  6849. * along with Mountyzilla; if not, write to the Free Software *
  6850. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6851. *******************************************************************************/
  6852.  
  6853. // x~x pjview
  6854.  
  6855. /* TODO
  6856. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  6857. */
  6858.  
  6859. // Bulle d'infos
  6860. var DivInfo;
  6861. // Booléen stockant l'état de freezing de la bulle
  6862. var freezed = false;
  6863.  
  6864. // liste du matos
  6865. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  6866. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  6867. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  6868. var mh_caracs = {
  6869. 'anneau de protection':
  6870. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  6871. "armure d'anneaux":
  6872. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  6873. 'armure de bois':
  6874. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  6875. 'armure de cuir':
  6876. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  6877. 'armure de peaux':
  6878. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  6879. 'armure de pierre':
  6880. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  6881. 'armure de plates':
  6882. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  6883. 'baton lesté':
  6884. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6885. 'bâtons de parade':
  6886. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6887. 'bottes':
  6888. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6889. 'bouclier à pointes':
  6890. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6891. 'boulet et chaîne':
  6892. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6893. 'cagoule':
  6894. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  6895. 'casque à cornes':
  6896. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6897. 'casque à pointes':
  6898. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  6899. 'casque en cuir':
  6900. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  6901. 'casque en métal':
  6902. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  6903. 'chaîne cloutée':
  6904. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  6905. 'chapeau pointu':
  6906. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  6907. 'collier de dents':
  6908. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  6909. 'collier de pierre':
  6910. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  6911. 'collier à pointes':
  6912. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6913. 'cotte de mailles':
  6914. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  6915. 'couronne de cristal':
  6916. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  6917. "couronne d'obsidienne":
  6918. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  6919. "coutelas d'obsidienne":
  6920. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  6921. 'coutelas en os':
  6922. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  6923. 'crochet':
  6924. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6925. 'cuir bouilli':
  6926. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  6927. "cuirasse d'ossements":
  6928. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  6929. "cuirasse d'écailles":
  6930. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  6931. 'culotte en cuir':
  6932. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6933. 'dague':
  6934. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  6935. 'epée courte':
  6936. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  6937. 'epée longue':
  6938. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6939. 'espadon':
  6940. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6941. 'fouet':
  6942. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6943. 'fourrures':
  6944. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  6945. 'gantelet':
  6946. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  6947. 'gorgeron en cuir':
  6948. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  6949. 'gorgeron en métal':
  6950. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  6951. 'gourdin':
  6952. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  6953. 'gourdin clouté':
  6954. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  6955. 'grimoire':
  6956. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  6957. "gros'porte":
  6958. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  6959. 'grosse racine':
  6960. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6961. 'grosse stalagmite':
  6962. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  6963. 'hache de bataille':
  6964. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  6965. 'hache de guerre en os':
  6966. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  6967. 'hache de guerre en pierre':
  6968. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  6969. "hache à deux mains d'obsidienne":
  6970. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  6971. 'hallebarde':
  6972. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  6973. "haubert d'écailles":
  6974. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  6975. 'haubert de mailles':
  6976. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  6977. 'heaume':
  6978. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  6979. 'jambières en cuir':
  6980. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6981. 'jambières en fourrure':
  6982. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  6983. 'jambières en maille':
  6984. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  6985. 'jambières en métal':
  6986. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  6987. 'jambières en os':
  6988. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  6989. "lame d'obsidienne":
  6990. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  6991. 'lame en os':
  6992. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  6993. 'lame en pierre':
  6994. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6995. 'lorgnons':
  6996. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  6997. 'machette':
  6998. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  6999. "masse d'arme":
  7000. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  7001. 'pagne de mailles':
  7002. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  7003. 'pagne en cuir':
  7004. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  7005. 'robe de mage':
  7006. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  7007. 'rondache en bois':
  7008. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  7009. 'rondache en métal':
  7010. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  7011. 'sandales':
  7012. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  7013. 'souliers dorés':
  7014. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  7015. "talisman d'obsidienne":
  7016. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  7017. 'talisman de pierre':
  7018. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  7019. 'targe':
  7020. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  7021. 'torche':
  7022. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  7023. 'torque de pierre':
  7024. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  7025. 'tunique':
  7026. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  7027. "tunique d'écailles":
  7028. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  7029. 'turban':
  7030. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  7031. }
  7032.  
  7033. // liste des templates
  7034. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  7035. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  7036. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  7037. var mh_templates = {
  7038. 'de Feu':
  7039. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7040. 'de Résistance':
  7041. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  7042. "de l'Aigle":
  7043. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  7044. 'de la Salamandre':
  7045. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  7046. 'des Cyclopes':
  7047. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  7048. 'des Enragés':
  7049. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  7050. 'des Tortues':
  7051. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  7052. 'des Vampires':
  7053. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  7054. 'du Glacier':
  7055. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  7056. 'du Rat':
  7057. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  7058. 'du Roc':
  7059. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  7060. 'du Temps':
  7061. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  7062. 'du Vent':
  7063. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  7064. 'en Mithril':
  7065. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7066. 'des Anciens':
  7067. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7068. 'des Champions':
  7069. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7070. 'des Duellistes':
  7071. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7072. 'de la Terre':
  7073. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  7074. "de l'Orage":
  7075. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  7076. "de l'Ours":
  7077. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  7078. 'des Béhémoths':
  7079. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  7080. 'des Mages':
  7081. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  7082. 'du Pic':
  7083. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  7084. 'du Sable':
  7085. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  7086. 'acéré':
  7087. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7088. 'acérée':
  7089. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7090. 'équilibré':
  7091. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7092. 'équilibrée':
  7093. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  7094. 'léger':
  7095. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7096. 'légère':
  7097. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  7098. 'renforcé':
  7099. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7100. 'renforcée':
  7101. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  7102. 'robuste':
  7103. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  7104. }
  7105.  
  7106. function clone(arr) {
  7107. // Clonage rapide
  7108. return arr.slice(0);
  7109. }
  7110.  
  7111. function addArray(arr1,arr2) {
  7112. // Somme matricielle
  7113. var res = clone(arr1);
  7114. for(i=res.length-1 ; i>=0 ; i--) {
  7115. res[i] += arr2[i];
  7116. }
  7117. return res;
  7118. }
  7119.  
  7120. function getTemplates(nomItem) {
  7121. // Déstructure le nom de l'item en array [nom, template1, ...]
  7122. var tempFound = true;
  7123. var str = nomItem.trim();
  7124. var arr = [];
  7125. while(tempFound) {
  7126. tempFound = false;
  7127. for(var temp in mh_templates) {
  7128. // on teste la fin du nom contre chaque template
  7129. if(str.slice(-temp.length)!=temp) { continue; }
  7130. tempFound = true;
  7131. str = str.slice(0,-temp.length-1);
  7132. arr.unshift(temp);
  7133. if(str.slice(-3)==' et') {
  7134. str = str.slice(0,-3);
  7135. }
  7136. }
  7137. }
  7138. arr.unshift(str);
  7139. return arr;
  7140. }
  7141.  
  7142. function addMithril(arrayCaracs,typeItem) {
  7143. // Ajoute l'effet du Mithril sur les caracs
  7144. if(typeItem=='arme') {
  7145. if(arrayCaracs[0]<0) {
  7146. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  7147. }
  7148. }
  7149. else {
  7150. if(arrayCaracs[4]<0) {
  7151. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  7152. }
  7153. }
  7154. arrayCaracs[15] /= 2;
  7155. arrayCaracs[16] /= 2;
  7156. return arrayCaracs;
  7157. }
  7158.  
  7159. function addRenfort(arrayCaracs,template) {
  7160. // Ajoute l'effet des pseudo-templates sur les caracs
  7161. // S'applique APRÈS le mithril
  7162. // WARNING - Cette formule n'a rien d'officiel, gare !
  7163. var coef = 0;
  7164. if(/^lég[e,è]re?$/.test(template)) {
  7165. coef = -1;
  7166. }
  7167. else if(/^renforcée?$/.test(template)
  7168. || template==='robuste') {
  7169. coef = 1;
  7170. }
  7171. if(coef) {
  7172. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  7173. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  7174. }
  7175. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  7176. return arrayCaracs;
  7177. }
  7178.  
  7179. function getCaracs(item) {
  7180. // Calcule les caractéristiques de l'item
  7181. var templates = getTemplates(item);
  7182. if(!mh_caracs[templates[0]]) {
  7183. // Si l'item est inconnu
  7184. return [];
  7185. }
  7186. var caracs = clone(mh_caracs[templates[0]]);
  7187. var typeItem = caracs[0];
  7188. caracs.shift();
  7189. templates.shift();
  7190. if(templates[templates.length-1]=='en Mithril') {
  7191. caracs = addMithril(caracs,typeItem);
  7192. templates.pop();
  7193. }
  7194. if(/^acérée?$/.test(templates[0])
  7195. || /^équilibrée?$/.test(templates[0])
  7196. || /^lég[e,è]re?$/.test(templates[0])
  7197. || /^renforcée?$/.test(templates[0])
  7198. || templates[0]=='robuste') {
  7199. caracs = addRenfort(caracs,templates[0]);
  7200. templates.shift();
  7201. }
  7202. for(var i=templates.length-1 ; i>=0 ; i--) {
  7203. caracs = addArray(caracs,mh_templates[templates[i]]);
  7204. }
  7205. return caracs;
  7206. }
  7207.  
  7208. function getLine(tab) {
  7209. // Préparation de la ligne à afficher lors d'un mouseover
  7210. var str = '';
  7211. if(tab[0]!=0 || tab[1]!=0) {
  7212. str += '<b>Att : </b>'+aff(tab[0]);
  7213. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  7214. str += ' | ';
  7215. }
  7216. if(tab[4]!=0) {
  7217. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  7218. }
  7219. if(tab[2]!=0 || tab[3]!=0) {
  7220. str += '<b>Deg : </b>'+aff(tab[2]);
  7221. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  7222. str += ' | ';
  7223. }
  7224. if(tab[8]!=0) {
  7225. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  7226. }
  7227. if(tab[7]!=0) {
  7228. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  7229. }
  7230. if(tab[5]!=0 || tab[6]!=0) {
  7231. str += '<b>Arm : </b>'+aff(tab[5]);
  7232. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  7233. str += ' | ';
  7234. }
  7235. if(tab[9]!=0 || tab[10]!=0) {
  7236. str += '<b>RM : </b>'+aff(tab[9])+'%';
  7237. if(tab[9]!=tab[10]) {
  7238. str += '/'+aff(tab[10])+'%';
  7239. }
  7240. str += ' | ';
  7241. }
  7242. if(tab[11]!=0 || tab[12]!=0) {
  7243. str += '<b>MM : </b>'+aff(tab[11])+'%';
  7244. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  7245. str += ' | ';
  7246. }
  7247. if(tab[13]!=0) {
  7248. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  7249. }
  7250. if(tab[14]!=0) {
  7251. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  7252. }
  7253. str += '<b>Poids : </b>'+tab[15]+' min';
  7254. if(tab[15]!=tab[16]) {
  7255. str += ' / '+tab[16]+' min';
  7256. }
  7257. return str;
  7258. }
  7259.  
  7260. function toolTipInit() {
  7261. DivInfo = document.createElement('div');
  7262. DivInfo.id = 'infosVue';
  7263. DivInfo.className = 'mh_textbox';
  7264. DivInfo.style =
  7265. 'position: absolute;'
  7266. +'border: 1px solid #000000;'
  7267. +'visibility:hidden;'
  7268. +'display:inline;'
  7269. +'z-index:99;';
  7270. document.body.appendChild(DivInfo);
  7271. document.onmousemove = getXY;
  7272. document.onclick = changeFreezeStatus;
  7273. }
  7274.  
  7275. function getXY(evt) {
  7276. if(!freezed && DivInfo.style.visibility=='visible') {
  7277. DivInfo.style.left = evt.pageX+'px';
  7278. DivInfo.style.top = evt.pageY+10+'px';
  7279. }
  7280. }
  7281.  
  7282. function changeFreezeStatus() {
  7283. if(DivInfo.style.visibility=='visible') {
  7284. freezed = !freezed;
  7285. if(!freezed) { hideInfos(); }
  7286. }
  7287. }
  7288.  
  7289. function showInfos() {
  7290. if(freezed) { return; }
  7291. var currentInfos = this.infos;
  7292. DivInfo.innerHTML = currentInfos;
  7293. DivInfo.style.visibility = 'visible';
  7294. }
  7295.  
  7296. function hideInfos() {
  7297. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  7298. }
  7299.  
  7300. function treateEquipement() {
  7301. // Extrait les données du matos et réinjecte les infos déduites
  7302. if(MY_getValue('INFOCARAC')=='false') { return; }
  7303.  
  7304. var faireLigne = false;
  7305. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  7306. var nodes = document.evaluate(
  7307. "//td/b[text()='Equipement Utilisé']/../../"
  7308. +"td[2]/img[contains(@src,bullet)]",
  7309. document, null, 7, null);
  7310. if(nodes.snapshotLength>0) {
  7311. // Si CSS de base
  7312. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7313. var node = nodes.snapshotItem(i);
  7314. var next = node.nextSibling;
  7315. var nnext = next.nextSibling;
  7316. var nom = next.nodeValue.toLowerCase();
  7317. if(nnext.childNodes.length==1) {
  7318. nom += nnext.firstChild.nodeValue;
  7319. }
  7320. nom = nom.trim();
  7321. // gestion winpostrophe
  7322. var c = String.fromCharCode(180);
  7323. while(nom.indexOf(c)!=-1) {
  7324. nom = nom.replace(c,"'");
  7325. }
  7326. var arr = getCaracs(nom);
  7327. if(arr.length>0) {
  7328. faireLigne = true;
  7329. caracs = addArray(caracs,arr);
  7330. var span = document.createElement('span');
  7331. span.appendChild(next);
  7332. span.appendChild(nnext);
  7333. span.infos = getLine(arr);
  7334. span.onmouseover = showInfos;
  7335. span.onmouseout = hideInfos;
  7336. insertBefore(node.nextSibling,span);
  7337. }
  7338. }
  7339.  
  7340. if(faireLigne) {
  7341. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  7342. document, null, 9, null).singleNodeValue;
  7343. node.infos = getLine(caracs);
  7344. node.onmouseover = showInfos;
  7345. node.onmouseout = hideInfos;
  7346. }
  7347. }
  7348. else {
  7349. // Si CSS avancée
  7350. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  7351. document, null, 7, null);
  7352. if(nodes.snapshotLength>0) {
  7353. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  7354. var node = nodes.snapshotItem(i);
  7355. var nom = node.firstChild.nodeValue.toLowerCase();
  7356. if(node.childNodes.length>1) {
  7357. nom += node.childNodes[1].firstChild.nodeValue;
  7358. }
  7359. nom = nom.trim();
  7360. // gestion winpostrophe
  7361. var c = String.fromCharCode(180);
  7362. while(nom.indexOf(c)!=-1) {
  7363. nom = nom.replace(c,"'");
  7364. }
  7365. var arr = getCaracs(nom);
  7366. if(arr.length!=0) {
  7367. caracs = addArray(caracs,arr);
  7368. node.infos = getLine(arr);
  7369. node.onmouseover = showInfos;
  7370. node.onmouseout = hideInfos;
  7371. }
  7372. }
  7373. var nodes = document.evaluate("//dt[@class='equipement']",
  7374. document, null, 7, null);
  7375. var node = nodes.snapshotItem(0);
  7376. node.infos = getLine(caracs);
  7377. node.onmouseover = showInfos;
  7378. node.onmouseout = hideInfos;
  7379. }
  7380. }
  7381. }
  7382.  
  7383. function do_pjview() {
  7384. treateEquipement();
  7385. toolTipInit();
  7386. }
  7387.  
  7388. /*******************************************************************************
  7389. * This file is part of Mountyzilla. *
  7390. * *
  7391. * Mountyzilla is free software; you can redistribute it and/or modify *
  7392. * it under the terms of the GNU General Public License as published by *
  7393. * the Free Software Foundation; either version 2 of the License, or *
  7394. * (at your option) any later version. *
  7395. * *
  7396. * Mountyzilla is distributed in the hope that it will be useful, *
  7397. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7398. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7399. * GNU General Public License for more details. *
  7400. * *
  7401. * You should have received a copy of the GNU General Public License *
  7402. * along with Mountyzilla; if not, write to the Free Software *
  7403. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7404. *******************************************************************************/
  7405.  
  7406. // x~x option
  7407.  
  7408. /* TODO
  7409. * Passer le HTML injecté aux conventions HTML5
  7410. */
  7411.  
  7412.  
  7413. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  7414.  
  7415. function saveITData() {
  7416. var IT = document.getElementById('itSelect').value;
  7417. if(IT=='bricol') {
  7418. var nBricol = 1;
  7419. for (var iBricol = 0; ; iBricol++) {
  7420. var extClef = nBricol == 1 ? '' : nBricol;
  7421. var eltSystem = document.getElementById('urlbricol'+iBricol);
  7422. if (eltSystem == undefined) break;
  7423. var system = eltSystem.value;
  7424. window.console.log("[MZ] saveITData system=" + system);
  7425. var login = document.getElementById('loginbricol'+iBricol).value;
  7426. var pass = document.getElementById('passbricol'+iBricol).value;
  7427. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  7428. if(system && login) {
  7429. if (pass) {
  7430. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  7431. MY_setValue(numTroll+'.INFOSIT'+extClef, v);
  7432. //window.console.log('v=' + v);
  7433. } else {
  7434. // vérif que rien n'a changé
  7435. var str = MY_getValue(numTroll+'.INFOSIT'+extClef);
  7436. if(str) {
  7437. var arr = str.split('$');
  7438. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  7439. alert('Attention, système tactique Bricol\'Trolls ' + system + ' sans mot de passe => non modifié');
  7440. }
  7441. }
  7442. }
  7443. nBricol++;
  7444. }
  7445. }
  7446. window.console.log("[MZ] saveITData remove " + numTroll+'.INFOSIT'+extClef);
  7447. MY_removeValue(numTroll+'.INFOSIT'+extClef);
  7448. }
  7449. else {
  7450. MY_removeValue(numTroll+'.INFOSIT');
  7451. }
  7452. }
  7453.  
  7454. function saveLinks() {
  7455. var numLinks = document.getElementById('linksBody').childNodes.length;
  7456. var data=[ [] ];
  7457. /* Récupération et tri des liens */
  7458. for(var i=1 ; i<=numLinks ; i++) {
  7459. MY_removeValue('URL'+i);
  7460. MY_removeValue('URL'+i+'.nom');
  7461. MY_removeValue('URL'+i+'.ico');
  7462. var url = document.getElementById('url'+i).value;
  7463. var nom = document.getElementById('nom'+i).value;
  7464. var ico = document.getElementById('ico'+i).value;
  7465. if(url && (nom || ico) ) {
  7466. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  7467. }
  7468. }
  7469. /* Sauvegarde */
  7470. for(var i=1 ; i<data.length ; i++) {
  7471. MY_setValue('URL'+i,data[i][0]);
  7472. MY_setValue('URL'+i+'.nom',data[i][1]);
  7473. MY_setValue('URL'+i+'.ico',data[i][2]);
  7474. }
  7475. }
  7476.  
  7477. function saveAll() {
  7478. try {
  7479. var urlIco = document.getElementById('icoMenuIco').value;
  7480. if(urlIco) {
  7481. MY_setValue(numTroll+'.ICOMENU', urlIco );
  7482. }
  7483. else {
  7484. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  7485. document.getElementById('icoMenuIco').value = '';
  7486. }
  7487. saveLinks();
  7488. refreshLinks();
  7489.  
  7490. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  7491.  
  7492. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  7493. if(maxcdm) {
  7494. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  7495. }
  7496. else {
  7497. MY_removeValue(numTroll+'.MAXCDM');
  7498. document.getElementById('maxcdm').value = '';
  7499. }
  7500.  
  7501. MY_setValue('NOINFOEM',
  7502. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  7503.  
  7504. // Pourquoi Tilk stockait-il tout en str ?
  7505. // -> parce que les booléens c'est foireux (vérifié)
  7506. MY_setValue(numTroll+'.USECSS',
  7507. document.getElementById('usecss').checked ? 'true':'false');
  7508. MY_setValue('INFOCARAC',
  7509. document.getElementById('infocarac').checked ? 'true' : 'false');
  7510. //MY_setValue(numTroll+'.SEND_IDT',
  7511. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  7512. // Fonctionnalité désactivée
  7513.  
  7514. MY_setValue(numTroll+'.AUTOCDM',
  7515. document.getElementById('autoCdM').checked ? 'true' : 'false');
  7516. // MY_setValue('VUECARAC', // Roule 12/12/2019 ça ne fait plus rien
  7517. // document.getElementById('vueCarac').checked ? 'true' : 'false');
  7518. MY_setValue('CONFIRMEDECALAGE',
  7519. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  7520.  
  7521. /* SCIZ */
  7522. var sciz_jwt = document.getElementById('sciz_jwt').value;
  7523. if (sciz_jwt) {
  7524. sciz_jwt = sciz_jwt.replace(new RegExp('[^a-zA-Z0-9\._\-]','g'), '');
  7525. MY_setValue(numTroll + '.SCIZJWT', sciz_jwt);
  7526. }
  7527. var sciz_cb_events = document.getElementById('sciz_cb_events').checked;
  7528. sciz_cb_events = (sciz_cb_events !== null) ? sciz_cb_events : true;
  7529. MY_setValue(numTroll + '.SCIZ_CB_EVENTS', sciz_cb_events);
  7530. var sciz_cb_view_treasures = document.getElementById('sciz_cb_view_treasures').checked;
  7531. sciz_cb_view_treasures = (sciz_cb_view_treasures !== null) ? sciz_cb_view_treasures : true;
  7532. MY_setValue(numTroll + '.SCIZ_CB_VIEW_TREASURES', sciz_cb_view_treasures);
  7533. var sciz_cb_view_trolls = document.getElementById('sciz_cb_view_trolls').checked;
  7534. sciz_cb_view_trolls = (sciz_cb_view_trolls !== null) ? sciz_cb_view_trolls : true;
  7535. MY_setValue(numTroll + '.SCIZ_CB_VIEW_TROLLS', sciz_cb_view_trolls);
  7536.  
  7537. saveITData();
  7538. } catch (e) {
  7539. var bouton = document.getElementById('saveAll');
  7540. window.console.log(e);
  7541. bouton.value = "il y a eu une erreur";
  7542. return;
  7543. }
  7544.  
  7545. var bouton = document.getElementById('saveAll');
  7546. bouton.value = (bouton.value=='Sauvegardé !') ?
  7547. 'Re-sauvegardé !' : 'Sauvegardé !';
  7548. }
  7549.  
  7550.  
  7551. /*-[functions]----------------- EventListeners -------------------------------*/
  7552.  
  7553. function addBricolIT(sSystem, sLogin, nAffhv, bFirst, bLast) {
  7554. var itBody = document.getElementById('itBody');
  7555. var nTr = itBody.rows.length;
  7556. // enlever tous les "+" des lignes précédentes
  7557. for (var iTr = 0; iTr < nTr; iTr++) {
  7558. var td = itBody.rows[iTr].cells[0];
  7559. td.innerHTML = '';
  7560. td.title = '';
  7561. td.style.cursor = 'default';
  7562. }
  7563. // ajouter une ligne
  7564. var tr = appendTr(itBody,'mh_tdpage')
  7565. var td = appendTd(tr);
  7566. if (bLast) {
  7567. td.style.whiteSpace = 'nowrap';
  7568. appendText(td, '+');
  7569. td.style.cursor = 'pointer';
  7570. td.title = 'Cliquer ici pour ajouter un autre système Bricol\'Troll';
  7571. td.onclick = function (e) {
  7572. addBricolIT(undefined, undefined, undefined, false, true);
  7573. }
  7574. }
  7575. var td = appendTd(tr);
  7576. td.style.whiteSpace = 'nowrap';
  7577. appendText(td,'Nom du système : ');
  7578. appendTextbox(td,'text','urlbricol',20,50,sSystem,'urlbricol' + nTr);
  7579. td = appendTd(tr);
  7580. td.style.whiteSpace = 'nowrap';
  7581. appendText(td,'Login du compte : ');
  7582. appendTextbox(td,'text','loginbricol',20,50,sLogin,'loginbricol' + nTr);
  7583. td = appendTd(tr);
  7584. td.style.whiteSpace = 'nowrap';
  7585. appendText(td,'Mot de passe du compte : ');
  7586. appendTextbox(td,'password','passbricol',20,50,undefined,'passbricol' + nTr);
  7587. td = appendTd(tr);
  7588. if (bFirst) {
  7589. td.style.whiteSpace = 'nowrap';
  7590. appendText(td,'Affichage des Trõlls hors vue : ');
  7591. appendCheckBox(td,'affhvbricol', (nAffhv>0));
  7592. }
  7593. }
  7594.  
  7595. function onChangeIT() {
  7596. var IT = document.getElementById('itSelect').value;
  7597. var itBody = document.getElementById('itBody');
  7598. itBody.innerHTML = '';
  7599. var tabStr = new Array();
  7600. if(IT=='bricol') {
  7601. for (var iBricol = 1; ; iBricol++) {
  7602. var str = MY_getValue(numTroll+'.INFOSIT'+(iBricol==1 ? '' : iBricol));
  7603. //window.console.log('onChangeIT str=' + str);
  7604. if(str) {
  7605. tabStr.push(str);
  7606. } else {
  7607. break;
  7608. }
  7609. }
  7610. if (tabStr.length == 0) {
  7611. addBricolIT('', '', 0, true, true)
  7612. } else {
  7613. for (var iBricol = 0; iBricol < tabStr.length; iBricol++) {
  7614. var arr = tabStr[iBricol].split('$');
  7615. var system = arr[1];
  7616. var login = arr[2];
  7617. var affhv = arr[4];
  7618. addBricolIT(system, login, affhv, iBricol == 0, iBricol == (tabStr.length - 1));
  7619. }
  7620. }
  7621. }
  7622. }
  7623.  
  7624. function refreshLinks() {
  7625. document.getElementById('linksBody').innerHTML = '';
  7626. var anotherURL = MY_getValue('URL1');
  7627. if(!anotherURL) { addLinkField(); }
  7628. var i=1;
  7629. while(anotherURL && i<99) {
  7630. addLinkField(i,anotherURL,
  7631. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  7632. i++;
  7633. anotherURL = MY_getValue('URL'+i);
  7634. }
  7635. }
  7636.  
  7637. function addLinkField(i,url,nom,ico) {
  7638. var linksBody = document.getElementById('linksBody');
  7639. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  7640. var tr = appendTr(linksBody);
  7641. var td = appendTdCenter(tr);
  7642. appendText(td,'Lien '+i+' : ');
  7643. appendTextbox(td,'text','url'+i,40,150,url);
  7644. td = appendTdCenter(tr);
  7645. appendText(td,'Nom : ');
  7646. appendTextbox(td,'text','nom'+i,20,150,nom);
  7647. td = appendTdCenter(tr);
  7648. appendText(td,'Icône : ');
  7649. appendTextbox(td,'text','ico'+i,40,150,ico);
  7650. }
  7651.  
  7652. function removeLinkField() {
  7653. var linksBody = document.getElementById('linksBody');
  7654. var i = linksBody.childNodes.length;
  7655. MY_removeValue('URL'+i);
  7656. MY_removeValue('URL'+i+'.nom');
  7657. MY_removeValue('URL'+i+'.ico');
  7658. linksBody.removeChild(linksBody.lastChild);
  7659. if(linksBody.childNodes.length==0) { addLinkField(); }
  7660. }
  7661.  
  7662. function resetMainIco() {
  7663. document.getElementById('icoMenuIco').value=
  7664. URL_MZimg + 'mz_logo_small.png';
  7665. }
  7666.  
  7667.  
  7668. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  7669.  
  7670. function insertTitle(next,txt) {
  7671. var div = document.createElement('div');
  7672. div.className = 'titre2';
  7673. appendText(div,txt);
  7674. insertBefore(next,div);
  7675. return div;
  7676. }
  7677.  
  7678. function insertMainTable(next) {
  7679. var table = document.createElement('table');
  7680. table.width = '98%';
  7681. table.border = 0;
  7682. table.align = 'center';
  7683. table.cellPadding = 2;
  7684. table.cellSpacing = 1;
  7685. table.className = 'mh_tdborder';
  7686. var tbody = document.createElement('tbody');
  7687. table.appendChild(tbody);
  7688. insertBefore(next,table);
  7689. return tbody;
  7690. }
  7691.  
  7692. function appendSubTable(node) {
  7693. var table = document.createElement('table');
  7694. table.width = '100%';
  7695. var tbody = document.createElement('tbody');
  7696. table.appendChild(tbody);
  7697. node.appendChild(table);
  7698. return tbody;
  7699. }
  7700.  
  7701. function insertOptionTable(insertPt) {
  7702. var mainBody = insertMainTable(insertPt);
  7703.  
  7704. /* Liens dans le Menu */
  7705. var tr = appendTr(mainBody,'mh_tdtitre');
  7706. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  7707. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7708. appendText(td,'Icône du Menu: ');
  7709. var url = MY_getValue(numTroll+'.ICOMENU');
  7710. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  7711. url = URL_MZimg + 'mz_logo_small.png';
  7712. }
  7713. appendTextbox(td,'text','icoMenuIco',50,200,url);
  7714. appendButton(td,'Réinitialiser',resetMainIco);
  7715.  
  7716. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7717. var tbody = appendSubTable(td);
  7718. tbody.id = 'linksBody';
  7719. refreshLinks();
  7720.  
  7721. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  7722. appendButton(td,'Ajouter',addLinkField);
  7723. appendButton(td,'Supprimer',removeLinkField);
  7724.  
  7725. /* Options de la Vue : vue externe, nb de CdM, etc */
  7726. tr = appendTr(mainBody,'mh_tdtitre');
  7727. appendTdText(tr,'Options de la Vue :',true);
  7728. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7729. tbody = appendSubTable(td);
  7730.  
  7731. tr = appendTr(tbody);
  7732. td = appendTdText(tr,'Vue externe : ');
  7733. var select = document.createElement('select');
  7734. select.id = 'vueext';
  7735. td.appendChild(select);
  7736. var listeVues2D = [
  7737. 'Bricol\' Vue',
  7738. 'Vue du CCM',
  7739. 'Vue Gloumfs 2D',
  7740. 'Vue Gloumfs 3D',
  7741. 'Grouky Vue!'
  7742. ];
  7743. for(var i=0 ; i<listeVues2D.length ; i++) {
  7744. appendOption(select,listeVues2D[i],listeVues2D[i]);
  7745. }
  7746. if(MY_getValue('VUEEXT')) {
  7747. select.value = MY_getValue('VUEEXT');
  7748. }
  7749.  
  7750. td = appendTd(tr);
  7751. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  7752. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  7753.  
  7754. tr = appendTr(tbody);
  7755. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  7756. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  7757.  
  7758. td = appendTd(tr);
  7759. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  7760. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  7761.  
  7762. /* Interface Tactique */
  7763. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7764. appendText(td,'Interface Tactique : ',true);
  7765. select = document.createElement('select');
  7766. select.id = 'itSelect';
  7767. appendOption(select,'none','Aucune');
  7768. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  7769. // seule interface supportée !
  7770. td.appendChild(select);
  7771.  
  7772. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7773. tbody = appendSubTable(td);
  7774. tbody.id = 'itBody';
  7775. select.onchange = onChangeIT;
  7776. var str = MY_getValue(numTroll+'.INFOSIT');
  7777. if(str) {
  7778. select.value = str.slice(0,str.indexOf('$'));
  7779. onChangeIT();
  7780. }
  7781.  
  7782. /* SCIZ */
  7783. // JWT
  7784. td = appendTd(appendTr(mainBody, 'mh_tdtitre'));
  7785. appendText(td, 'SCIZ :', true);
  7786. td = appendTd(appendTr(mainBody, 'mh_tdpage'));
  7787. td = appendTdText(td, 'JWT : ');
  7788. appendTextbox(td, 'text', 'sciz_jwt', 150, 500, MY_getValue(numTroll + '.SCIZJWT'));
  7789. // Event checkbox
  7790. td = appendTd(appendTr(mainBody, 'mh_tdpage'));
  7791. tbody = appendSubTable(td);
  7792. tr = appendTr(tbody)
  7793. td = appendTd(tr);
  7794. td.setAttribute('align', 'center');
  7795. appendCheckBox(td, 'sciz_cb_events', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_EVENTS')));
  7796. appendText(td, ' Surcharger les événementsde ma coterie');
  7797. // Treasure checkbox
  7798. td = appendTd(tr);
  7799. td.setAttribute('align', 'center');
  7800. appendCheckBox(td, 'sciz_cb_view_treasures', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_VIEW_TREASURES')));
  7801. appendText(td, ' Afficher les trésors identifiés par ma coterie dans la vue');
  7802. // Trolls data
  7803. td = appendTd(tr);
  7804. td.setAttribute('align', 'center');
  7805. appendCheckBox(td, 'sciz_cb_view_trolls', [null, '1'].includes(MY_getValue(numTroll + '.SCIZ_CB_VIEW_TROLLS')));
  7806. appendText(td, ' Afficher les données des trolls de ma coterie dans la vue');
  7807.  
  7808. /* Options diverses */
  7809. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  7810. appendText(td,'Options diverses :',true);
  7811. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7812. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  7813. appendText(td,
  7814. ' Afficher les caractéristiques des équipements des autres Trõlls');
  7815.  
  7816. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7817. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  7818. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  7819.  
  7820. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7821. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  7822. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  7823.  
  7824. // td = appendTd(appendTr(mainBody,'mh_tdpage')); // Roule 12/12/2019 ça ne fait plus rien
  7825. // appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  7826. // appendText(td,' Afficher la Vue avec les caractéristiques dans le Profil');
  7827.  
  7828. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  7829. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  7830. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  7831.  
  7832. /* Bouton SaveAll */
  7833. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  7834. input = appendButton(td,'Sauvegarder',saveAll);
  7835. input.id = 'saveAll';
  7836. }
  7837.  
  7838. function insertCreditsTable(insertPt) {
  7839. var tbody = insertMainTable(insertPt);
  7840.  
  7841. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  7842. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  7843. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  7844.  
  7845. var ul = document.createElement('ul');
  7846. td.appendChild(ul);
  7847. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  7848. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  7849. appendLI(ul,'Reivax (4234) pour les infos bulles');
  7850. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  7851. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  7852. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  7853. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  7854. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  7855. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  7856. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  7857. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  7858. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  7859. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  7860. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  7861. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  7862. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  7863. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  7864. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  7865. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  7866. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  7867. }
  7868.  
  7869.  
  7870. /* [functions] Obsolètes */
  7871. function deleteEnchantement()
  7872. {
  7873. try
  7874. {
  7875. var idEquipement = this.getAttribute('name');
  7876. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  7877. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  7878. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  7879. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  7880. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  7881. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7882. var string = "";
  7883. for(var i=0;i<listeEquipement.length;i++)
  7884. {
  7885. if(listeEquipement[i]!=idEquipement)
  7886. if(string=="")
  7887. string = listeEquipement[i];
  7888. else
  7889. string += ";"+listeEquipement[i];
  7890. }
  7891. if(string=="")
  7892. {
  7893. MY_removeValue(numTroll+".enchantement.liste");
  7894. var table = this.parentNode.parentNode.parentNode.parentNode;
  7895. var parent = table.parentNode;
  7896. for(var i=0;i<parent.childNodes.length;i++)
  7897. {
  7898. if(parent.childNodes[i]==table)
  7899. {
  7900. parent.removeChild(parent.childNodes[i-1]);
  7901. parent.removeChild(parent.childNodes[i-1]);
  7902. parent.removeChild(parent.childNodes[i-1]);
  7903. break;
  7904. }
  7905. }
  7906. }
  7907. else
  7908. {
  7909. MY_getValue(numTroll+".enchantement.liste",string);
  7910. this.parentNode.parentNode.parentNode
  7911. .removeChild(this.parentNode.parentNode);
  7912. }
  7913. }
  7914. catch(e)
  7915. {
  7916. window.alert(e);
  7917. }
  7918. }
  7919. /* [functions] fin Obsolètes */
  7920.  
  7921. /*-[functions]---------------- Partie principale -----------------------------*/
  7922.  
  7923. function do_option() {
  7924. start_script(712);
  7925. var insertPoint = document.getElementById('footer1');
  7926. insertBefore(insertPoint,document.createElement('p'));
  7927. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  7928. ti.onclick = function (e) {
  7929. var evt = e || window.event;
  7930. if (evt.shiftKey) {
  7931. var txt = '';
  7932. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  7933. var k = localStorage.key(i);
  7934. if (k.match(/INFOSIT/i)) continue; // masquer le mdp Bricol'Troll
  7935. txt += k + "\t" + localStorage.getItem(k) + "\n";
  7936. }
  7937. copyTextToClipboard(txt);
  7938. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  7939. } else if (evt.ctrlKey) {
  7940. var tabK= [];
  7941. var sMatch = numTroll + '.';
  7942. var lMatch = sMatch.length;
  7943. for (var i = 0, len = localStorage.length; i < len; ++i ) {
  7944. var k = localStorage.key(i);
  7945. if (k.substring(0, lMatch) == sMatch) tabK.push(k);
  7946. }
  7947. for (var i = 0; i < tabK.length; ++i ) {
  7948. MY_removeValue(tabK[i]);
  7949. }
  7950. window.alert(tabK.length + ' informations locales du Trõll ' + numTroll + ' ont été effacées-' + sMatch + '-' + lMatch);
  7951. }
  7952. }
  7953. ti.title = 'Version ' + GM_info.script.version;
  7954. insertOptionTable(insertPoint);
  7955. /* insertion enchantements ici
  7956. if(...)
  7957. insertEnchantementTable();
  7958. */
  7959. insertBefore(insertPoint,document.createElement('p'));
  7960. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  7961. ti.onclick = function (e) {
  7962. var evt = e || window.event;
  7963. if (!evt.shiftKey) return;
  7964. var oldDev = MY_getValue('MZ_dev');
  7965. if (oldDev) {
  7966. MY_removeValue('MZ_dev');
  7967. } else {
  7968. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  7969. MY_setValue('MZ_dev', 1);
  7970. }
  7971. document.location.href = document.location.href;
  7972. }
  7973. insertCreditsTable(insertPoint);
  7974. insertBefore(insertPoint,document.createElement('p'));
  7975.  
  7976. /* [zone] Obsolète ?? */
  7977. if(MY_getValue(numTroll+".enchantement.liste")
  7978. && MY_getValue(numTroll+".enchantement.liste")!="" )
  7979. {
  7980. insertTitle(insertPoint, 'Les Enchantements en cours');
  7981. table = document.createElement('table');
  7982. table.setAttribute('width', '98%');
  7983. table.setAttribute('border', '0');
  7984. table.setAttribute('align', 'center');
  7985. table.setAttribute('cellpadding', '2');
  7986. table.setAttribute('cellspacing', '1');
  7987. table.setAttribute('class', 'mh_tdborder');
  7988.  
  7989. tbody = document.createElement('tbody');
  7990. table.appendChild(tbody);
  7991.  
  7992. tr = appendTr(tbody, 'mh_tdtitre');
  7993. appendTdText(tr, 'Equipement',1);
  7994. appendTdText(tr, 'Composants',1);
  7995. appendTdText(tr, 'Enchanteur',1);
  7996. appendTdText(tr, 'Action',1);
  7997.  
  7998. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  7999. for(var i=0;i<listeEquipement.length;i++)
  8000. {
  8001. try
  8002. {
  8003. var idEquipement = listeEquipement[i];
  8004. var nomEquipement = MY_getValue(numTroll+".enchantement."
  8005. +idEquipement+".objet");
  8006. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  8007. +idEquipement+".enchanteur").split(";");
  8008. var ul = document.createElement('UL');
  8009. for(var j=0;j<3;j++)
  8010. {
  8011. var k = numTroll+'.enchantement.'+idEquipement+'.composant.'+j;
  8012. var v = MY_getValue(k);
  8013. if (v == null) { // protection Roule 26/08/2017
  8014. window.console.log('[MZ] err infoComposant k=' + k + ', v is null');
  8015. continue;
  8016. }
  8017. var infoComposant = v.split(';');
  8018. if (infoComposant.length < 5) { // protection Roule 25/08/2017
  8019. window.console.log('[MZ] err infoComposant k=' + k + ', v=' + v);
  8020. continue;
  8021. }
  8022. var texte = infoComposant[4].replace("Ril ","Œil ");
  8023. for(var k=5;k<infoComposant.length;k++)
  8024. {
  8025. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  8026. }
  8027. li = appendLI(ul,texte);
  8028. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  8029. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  8030. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  8031. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  8032. string+= '<input type="hidden" name="q" value="min" />';
  8033. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  8034. 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>';
  8035.  
  8036. string+= '</form>';
  8037. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  8038. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  8039. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  8040. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  8041. li.innerHTML += string;
  8042. }
  8043. tr = appendTr(tbody, 'mh_tdpage');
  8044.  
  8045. td = appendTdText(tr, nomEquipement);
  8046. td.setAttribute('valign', 'center');
  8047.  
  8048. td = document.createElement('td');
  8049. td.appendChild(ul);
  8050. tr.appendChild(td);
  8051. td.setAttribute('valign', 'center');
  8052.  
  8053. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  8054. td.setAttribute('valign', 'center');
  8055.  
  8056. td = document.createElement('td');
  8057. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  8058. input.setAttribute('name', idEquipement);
  8059. tr.appendChild(td);
  8060. td.setAttribute('valign', 'center');
  8061. }
  8062. catch(e)
  8063. {
  8064. }
  8065. }
  8066. insertBefore(insertPoint, table);
  8067. insertBefore(insertPoint, document.createElement('p'));
  8068. }
  8069. /* [zone] fin Obsolète ?? */
  8070.  
  8071.  
  8072. displayScriptTime();
  8073. }
  8074.  
  8075. /*******************************************************************************
  8076. * This file is part of Mountyzilla. *
  8077. * *
  8078. * Mountyzilla is free software; you can redistribute it and/or modify *
  8079. * it under the terms of the GNU General Public License as published by *
  8080. * the Free Software Foundation; either version 2 of the License, or *
  8081. * (at your option) any later version. *
  8082. * *
  8083. * Mountyzilla is distributed in the hope that it will be useful, *
  8084. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8085. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8086. * GNU General Public License for more details. *
  8087. * *
  8088. * You should have received a copy of the GNU General Public License *
  8089. * along with Mountyzilla; if not, write to the Free Software *
  8090. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8091. *******************************************************************************/
  8092.  
  8093. // x~x equip
  8094.  
  8095. /**
  8096. * 2014-02-08 - v2.0a (from scratch)
  8097. * 2014-02-18 - v2.0a0
  8098. * - ajout calcul Carats / UM des minerais + totaux
  8099. * 2014-03-06 - v2.0a1
  8100. * - retour Infos EM des Champis
  8101. * TODO
  8102. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  8103. */
  8104.  
  8105. function traiteChampis() {
  8106. try{
  8107. var tr = document.getElementById('mh_objet_hidden_Champignon');
  8108. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8109. }
  8110. catch(e){return;}
  8111. if(trlist.length<=0) return;
  8112. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8113. var node = trlist.snapshotItem(i).childNodes[7];
  8114. var str = node.textContent.trim();
  8115. var type = str.slice(0,str.lastIndexOf(' '));
  8116. var mundi = mundiChampi[type];
  8117. if(!mundi) continue;
  8118. var urlImg = URL_MZimg
  8119. +'Competences/ecritureMagique.png';
  8120. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  8121. appendText(node,' ');
  8122. node.appendChild(img);
  8123. }
  8124. }
  8125.  
  8126. function traiteCompos() {
  8127. try {
  8128. var tr = document.getElementById('mh_objet_hidden_Composant');
  8129. var tbody = document.evaluate("./td/table/tbody",
  8130. tr, null, 9, null).singleNodeValue;
  8131. }
  8132. catch(e) {return;}
  8133. insererInfosEM(tbody);
  8134. }
  8135.  
  8136. function traiteMinerai() {
  8137. try{
  8138. var tr = document.getElementById('mh_objet_hidden_Minerai');
  8139. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  8140. }
  8141. catch(e){return;}
  8142. if(trlist.length<=0) return;
  8143. var totaux = {};
  8144. var str;
  8145. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  8146. var node = trlist.snapshotItem(i);
  8147. var nature = node.childNodes[7].textContent,
  8148. caracs = node.childNodes[9].textContent;
  8149. var taille = Number(caracs.match(/\d+/)[0]);
  8150. var coef = 1;
  8151. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  8152. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  8153. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  8154. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  8155. if(nature.indexOf('Mithril')!=-1) {
  8156. coef = 0.2*coef;
  8157. str = ' | UM: ';
  8158. }
  8159. else {
  8160. coef = 0.75*coef+1.25;
  8161. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  8162. str = ' | Carats: ';
  8163. }
  8164. var carats = Math.round(taille*coef)
  8165. appendText(node.childNodes[9], str+carats );
  8166. if(!totaux[nature]) {
  8167. totaux[nature] = [taille,carats];
  8168. }
  8169. else {
  8170. totaux[nature][0] += taille;
  8171. totaux[nature][1] += carats;
  8172. }
  8173. }
  8174. str = 'Total : ';
  8175. for(var nature in totaux) {
  8176. if(str.length>8) str += ', ';
  8177. if(nature.indexOf('Mithril')!=-1) {
  8178. str += nature+totaux[nature][1]+' UM';
  8179. }
  8180. else {
  8181. str += nature+totaux[nature][0]+'U/'
  8182. +totaux[nature][1]+'c';
  8183. }
  8184. }
  8185. /*var node = document.getElementById('mh_plus_Minerai');
  8186. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  8187. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  8188. if(!titre) return;*/
  8189. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  8190. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  8191. td.colSpan = 7;
  8192. }
  8193.  
  8194. function do_equip() {
  8195. start_script();
  8196.  
  8197. traiteChampis();
  8198. traiteCompos();
  8199. traiteMinerai();
  8200.  
  8201. displayScriptTime();
  8202. }
  8203.  
  8204. /*******************************************************************************
  8205. * This file is part of Mountyzilla. *
  8206. * *
  8207. * Mountyzilla is free software; you can redistribute it and/or modify *
  8208. * it under the terms of the GNU General Public License as published by *
  8209. * the Free Software Foundation; either version 2 of the License, or *
  8210. * (at your option) any later version. *
  8211. * *
  8212. * Mountyzilla is distributed in the hope that it will be useful, *
  8213. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8214. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8215. * GNU General Public License for more details. *
  8216. * *
  8217. * You should have received a copy of the GNU General Public License *
  8218. * along with Mountyzilla; if not, write to the Free Software *
  8219. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8220. *******************************************************************************/
  8221.  
  8222. // x~x diplo
  8223.  
  8224. /*
  8225. TODO:
  8226. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  8227. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  8228. V Étape 3: Ajout de la diplo perso
  8229. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  8230. V Étape 5: Ajout des fioritures (preview de la couleur...)
  8231.  
  8232. Options Globales:
  8233. Actuelles:
  8234. numTroll.USECSS,
  8235. numTroll.NODIPLO
  8236. NOMYTH
  8237. Nouvelles:
  8238. TODO numTroll.USECSS
  8239. numTroll.diplo.off (remplace NODIPLO)
  8240. numTroll.diplo.guilde
  8241. numTroll.diplo.perso
  8242.  
  8243. Structure de diplo.guilde:
  8244. isOn: 'true' ou 'false'
  8245. isDetailOn: 'true' ou 'false'
  8246. guilde
  8247. > id
  8248. > couleur
  8249. AllAmis,AllEnnemis: couleur
  8250. Amis0,...,Ennemis5
  8251. > Troll: idTroll1;...;
  8252. > Guilde: idGuilde1;...;
  8253. > titre
  8254. > couleur
  8255.  
  8256. Structure de diplo.perso:
  8257. isOn: 'true' ou 'false'
  8258. mythiques: couleur
  8259. Troll,Guilde,Monstre:
  8260. > id
  8261. > couleur
  8262. > description
  8263. */
  8264.  
  8265. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  8266.  
  8267. function couleurAleatoire() {
  8268. var alph = '0123456789ABCDEF'.split('');
  8269. var clr = '#';
  8270. for (var i=0; i<6; i++) {
  8271. clr+=alph[ Math.floor(16*Math.random()) ];
  8272. }
  8273. return clr;
  8274. }
  8275.  
  8276. function isCouleur(str) {
  8277. return /^#[0-9A-F]{6}$/i.test(str);
  8278. }
  8279.  
  8280. /*-[functions]---------------- Analyse de la page ----------------------------*/
  8281.  
  8282. function appendChoixCouleur(node,id) {
  8283. var span = document.createElement('span');
  8284. span.id = 'span'+id;
  8285. if(isDetailOn) {
  8286. span.style.display = 'none';
  8287. }
  8288. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  8289. if(diploGuilde[id]) {
  8290. couleur = diploGuilde[id];
  8291. }
  8292. appendText(span,' - Couleur HTML: ');
  8293. var input = appendTextbox(span,'text',id,7,7,couleur);
  8294. input.onkeyup = previewCouleur;
  8295. input.onchange = previewCouleur;
  8296. input.onkeyup();
  8297. node.appendChild(span);
  8298. }
  8299.  
  8300. function insertChoixCouleur(node,id) {
  8301. var span = document.createElement('span');
  8302. span.id = 'span'+id;
  8303. // La couleur détaillée passera à une valeur aléatoire
  8304. // si toggle vers isDetailOn
  8305. var couleur = couleurAleatoire();
  8306. if(!isDetailOn) {
  8307. span.style.display = 'none';
  8308. } else if(diploGuilde[id]) {
  8309. couleur = diploGuilde[id].couleur;
  8310. }
  8311. appendText(span,' - Couleur HTML: ');
  8312. var input = appendTextbox(span,'text',id,7,7,couleur);
  8313. input.onkeyup = previewCouleur;
  8314. input.onchange = previewCouleur;
  8315. input.onkeyup();
  8316. insertBefore(node,span);
  8317. }
  8318.  
  8319. function setChoixCouleurs() {
  8320. try {
  8321. //var form = document.getElementsByName('ActionForm')[0];
  8322. var form = document.getElementById('mhPlay');
  8323. var nodesAE = document.evaluate(
  8324. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  8325. "./table/tbody/tr/th[@class='mh_tdtitre']",
  8326. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  8327. form, null, 7, null
  8328. );
  8329. var nodes = document.evaluate(
  8330. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  8331. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  8332. form, null, 7, null
  8333. );
  8334. } catch(e) {
  8335. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  8336. return false;
  8337. };
  8338. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  8339. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  8340. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  8341. for(var i=0 ; i<5 ; i++) {
  8342. nodes.snapshotItem(i).id = 'tdAmis'+i;
  8343. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  8344. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  8345. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  8346. }
  8347. return true;
  8348. }
  8349.  
  8350. function fetchDiploGuilde() {
  8351. try {
  8352. for(var AE in {Amis:0,Ennemis:0}) {
  8353. for(var i=0 ; i<5 ; i++) {
  8354. /* Récup des A/E de rang i */
  8355. var td = document.getElementById('td'+AE+i);
  8356. var ligne = td.getElementsByTagName('table')[0].rows;
  8357. var titre = trim(td.firstChild.textContent);
  8358. // On laisse la gestion des couleurs à setChoixCouleurs:
  8359. var couleur = document.getElementById(AE+i).value;
  8360. diploGuilde[AE+i] = {
  8361. Troll:'',
  8362. Guilde:'',
  8363. titre: titre,
  8364. couleur: couleur
  8365. };
  8366. for(var j=1 ; j<ligne.length ; j++) {
  8367. var str = trim(ligne[j].cells[0].textContent);
  8368. var idx = str.lastIndexOf('(');
  8369. var num = str.slice(idx+1,-1);
  8370. var type = trim(ligne[j].cells[1].textContent);
  8371. diploGuilde[AE+i][type] += num+';';
  8372. }
  8373. }
  8374. }
  8375. } catch(e) {
  8376. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  8377. return false;
  8378. }
  8379. return true;
  8380. }
  8381.  
  8382.  
  8383. /*-[functions]--------------------- Handlers ---------------------------------*/
  8384.  
  8385. function toggleDetails() {
  8386. isDetailOn = !isDetailOn;
  8387. for(var AE in {Amis:0,Ennemis:0}) {
  8388. document.getElementById('spanAll'+AE).style.display =
  8389. (isDetailOn?'none':'');
  8390. for(var i=0 ; i<5 ; i++) {
  8391. document.getElementById('span'+AE+i).style.display =
  8392. (isDetailOn?'':'none');
  8393. }
  8394. }
  8395. }
  8396.  
  8397. function toggleMythiques() {
  8398. isMythiquesOn = !isMythiquesOn;
  8399. document.getElementById('spanMythiques').style.display =
  8400. (isMythiquesOn?'':'none');
  8401. }
  8402.  
  8403. function previewCouleur() {
  8404. var value = this.value;
  8405. if(isCouleur(value)) {
  8406. this.style.backgroundColor = value;
  8407. this.title = '';
  8408. } else {
  8409. this.style.backgroundColor = '';
  8410. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  8411. }
  8412. }
  8413.  
  8414. function appendMenuType(node,duType) {
  8415. var select = document.createElement('select');
  8416. select.className = 'SelectboxV2';
  8417. var type = ['Guilde','Troll','Monstre'];
  8418. for(var i=0 ; i<3 ; i++) {
  8419. appendOption(select,type[i],type[i]);
  8420. if(type[i]==duType) { select.selectedIndex=i; }
  8421. }
  8422. node.appendChild(select);
  8423. }
  8424.  
  8425. function ajouteChamp(type,num,couleur,descr) {
  8426. var champs = document.getElementById('diploPerso');
  8427. var nb = champs.rows.length;
  8428. var tr = champs.insertRow(-1);
  8429. var td = appendTd(tr);
  8430. appendMenuType(td,type);
  8431. td = appendTd(tr);
  8432. appendText(td,' n°');
  8433. appendTextbox(td,'text','num'+nb,6,15,num);
  8434. td = appendTd(tr);
  8435. appendText(td,' couleur HTML:');
  8436. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  8437. input.onkeyup = previewCouleur;
  8438. input.onchange = previewCouleur;
  8439. input.onkeyup();
  8440. td = appendTd(tr);
  8441. appendText(td,' Description:');
  8442. appendTextbox(td,'text','descr'+nb,30,150,descr);
  8443. td = appendTd(tr);
  8444. var span = document.createElement('span');
  8445. appendText(span,'[ok!]',true);
  8446. span.style.visibility = 'hidden';
  8447. td.appendChild(span);
  8448. td = appendTd(tr);
  8449. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  8450. }
  8451.  
  8452. function retireCeChamp() {
  8453. var thisTr = this.parentNode.parentNode;
  8454. thisTr.parentNode.removeChild(thisTr);
  8455. var champs = document.getElementById('diploPerso');
  8456. if(champs.rows.length==0) { ajouteChamp(); }
  8457. }
  8458.  
  8459. function valideChamp(champ) {
  8460. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  8461. isCouleur(champ.cells[2].childNodes[1].value);
  8462. if(isValide) {
  8463. champ.cells[4].firstChild.style.visibility = 'visible';
  8464. } else {
  8465. champ.cells[4].firstChild.style.visibility = 'hidden';
  8466. }
  8467. return isValide;
  8468. }
  8469.  
  8470. function sauvegarderTout() {
  8471. /* Diplo de guilde */
  8472. diploGuilde.isOn =
  8473. document.getElementById('isGuildeOn').checked?'true':'false';
  8474. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  8475. var numGuilde = Number(document.getElementById('numGuilde').value);
  8476. var couleur = document.getElementById('couleurGuilde').value;
  8477. if(numGuilde) {
  8478. diploGuilde.guilde = {
  8479. id: numGuilde,
  8480. couleur: couleur
  8481. };
  8482. } else {
  8483. delete diploGuilde.guilde;
  8484. }
  8485. for(var AE in {Amis:0,Ennemis:0}) {
  8486. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  8487. for(var i=0 ; i<5 ; i++) {
  8488. if(isDetailOn) {
  8489. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  8490. } else {
  8491. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  8492. }
  8493. }
  8494. }
  8495. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  8496.  
  8497. /* Diplo personnelle (ex-fonction saveChamps) */
  8498. var champs = document.getElementById('diploPerso');
  8499. diploPerso = {
  8500. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  8501. Guilde: {},
  8502. Troll: {},
  8503. Monstre: {}
  8504. };
  8505. if(isMythiquesOn &&
  8506. isCouleur(document.getElementById('couleurMythiques').value)) {
  8507. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  8508. }
  8509. for(var i=0 ; i<champs.rows.length ; i++) {
  8510. if(valideChamp(champs.rows[i])) {
  8511. var type = champs.rows[i].cells[0].firstChild.value;
  8512. var num = champs.rows[i].cells[1].childNodes[1].value;
  8513. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  8514. var descr = champs.rows[i].cells[3].childNodes[1].value;
  8515. diploPerso[type][num] = {
  8516. couleur: couleur
  8517. };
  8518. if(descr) {
  8519. diploPerso[type][num].titre = descr;
  8520. }
  8521. }
  8522. }
  8523. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  8524.  
  8525. avertissement('Données sauvegardées');
  8526. }
  8527.  
  8528.  
  8529. /*-[functions]------------- Modifications de la page -------------------------*/
  8530.  
  8531. function creeTablePrincipale() {
  8532. var insertPt = document.getElementById('insertPt');
  8533.  
  8534. /* Titre + bouton de Sauvegarde */
  8535. var tr = insertTr(insertPt,'mh_tdtitre');
  8536. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  8537. appendButton(td,'Sauvegarder',sauvegarderTout);
  8538.  
  8539. /* Options fixes */
  8540. tr = insertTr(insertPt,'mh_tdpage');
  8541. td = appendTdText(tr,'Diplomatie de guilde:',true);
  8542. appendBr(td);
  8543. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  8544. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  8545. appendBr(td);
  8546. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  8547. appendText(td,'Utiliser des couleurs détaillées (10)');
  8548.  
  8549. /* Diplo personnelle */
  8550. tr = insertTr(insertPt,'mh_tdpage');
  8551. td = appendTdText(tr,'Diplomatie personnelle:',true);
  8552. appendBr(td);
  8553. // Diplo Mythiques
  8554. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  8555. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  8556. var span = document.createElement('span');
  8557. span.id = 'spanMythiques';
  8558. if(!isMythiquesOn) {
  8559. span.style.display = 'none';
  8560. }
  8561. var couleur = '#FFAAAA';
  8562. if(diploPerso.mythiques) {
  8563. couleur = diploPerso.mythiques;
  8564. }
  8565. appendText(span,' - couleur HTML:');
  8566. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  8567. input.onkeyup = previewCouleur;
  8568. input.onchange = previewCouleur;
  8569. input.onkeyup();
  8570. td.appendChild(span);
  8571. appendBr(td);
  8572. // Diplo éditable
  8573. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  8574. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  8575. appendBr(td);
  8576. var table = document.createElement('table');
  8577. table.id = 'diploPerso'
  8578. td.appendChild(table);
  8579. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8580. for(var num in diploPerso[type]) {
  8581. ajouteChamp(
  8582. type,
  8583. num,
  8584. diploPerso[type][num].couleur,
  8585. diploPerso[type][num].titre
  8586. );
  8587. }
  8588. }
  8589. if(table.rows.length==0) {
  8590. ajouteChamp();
  8591. }
  8592. appendButton(td,'Ajouter',ajouteChamp)
  8593. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  8594. appendText(td,' ');
  8595. appendButton(td,
  8596. 'Exemples de couleur',
  8597. function() {
  8598. var fenetre = window.open(
  8599. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  8600. 'Divers',
  8601. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  8602. 'status=0,menubar=0,resizable=1,scrollbars=1'
  8603. );
  8604. fenetre.focus();
  8605. }
  8606. );
  8607.  
  8608. /* Couleur de Guilde */
  8609. tr = insertTr(insertPt,'mh_tdtitre');
  8610. td = appendTdText(tr,'GUILDE',true);
  8611. appendText(td,' - n°');
  8612. appendTextbox(td,'text','numGuilde',5,10,
  8613. diploGuilde.guilde && diploGuilde.guilde.id ?
  8614. diploGuilde.guilde.id : ''
  8615. );
  8616. appendText(td,' - Couleur HTML: ');
  8617. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  8618. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  8619. diploGuilde.guilde.couleur : '#BBBBFF'
  8620. );
  8621. input.onkeyup = previewCouleur;
  8622. input.onchange = previewCouleur;
  8623. input.onkeyup();
  8624. }
  8625.  
  8626.  
  8627. /*-[functions]----------------------- Main -----------------------------------*/
  8628.  
  8629. function initDiplo(sType) {
  8630. var sDiplo = MY_getValue(numTroll + '.diplo.' + sType)
  8631. //console.log('sDiplo' + sType + '=' + sDiplo);
  8632. if (sDiplo && (sDiplo != 'null')) { // le stockage JSON nous donne parfois 'null'
  8633. return JSON.parse(sDiplo);
  8634. } else {
  8635. return {};
  8636. }
  8637. }
  8638. var diploGuilde = initDiplo('guilde');
  8639. var diploPerso = initDiplo('perso');
  8640. var isDetailOn = diploGuilde.isDetailOn=='true';
  8641. var isMythiquesOn = diploPerso.mythiques!=undefined;
  8642.  
  8643. function do_diplo() {
  8644. if(setChoixCouleurs() && fetchDiploGuilde()) {
  8645. creeTablePrincipale();
  8646. }
  8647. }
  8648.  
  8649. /*******************************************************************************
  8650. * This file is part of Mountyzilla. *
  8651. * *
  8652. * Mountyzilla is free software; you can redistribute it and/or modify *
  8653. * it under the terms of the GNU General Public License as published by *
  8654. * the Free Software Foundation; either version 2 of the License, or *
  8655. * (at your option) any later version. *
  8656. * *
  8657. * Mountyzilla is distributed in the hope that it will be useful, *
  8658. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8659. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8660. * GNU General Public License for more details. *
  8661. * *
  8662. * You should have received a copy of the GNU General Public License *
  8663. * along with Mountyzilla; if not, write to the Free Software *
  8664. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8665. *******************************************************************************/
  8666.  
  8667. // x~x cdmcomp
  8668.  
  8669. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  8670.  
  8671. function getNonNegInts(str) {
  8672. var nbrs = str.match(/\d+/g);
  8673. for(var i=0 ; i<nbrs.length ; i++) {
  8674. nbrs[i] = Number(nbrs[i]);
  8675. }
  8676. return nbrs;
  8677. }
  8678.  
  8679. function MZ_comp_traiteCdMcomp() {
  8680. // envoi au serveur (PHP) d'un objet avec
  8681. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  8682. // tstamp: l'horodatage
  8683. var oContexteCdM = MZ_analyseCdM('msgEffet', true); // analyse de la CdM, prépare l'envoi, prépare l'ajout de PV min/max selon blessure
  8684. oContexteCdM.nameBut = 'as_Action'; // nom du bouton avant lequel insérer le bouton ou les textes
  8685. if (!oContexteCdM.ok) {
  8686. if (oContexteCdM.error) {
  8687. window.console.log('MZ_comp_traiteCdMcomp, ' + oContexteCdM.error);
  8688. MZ_comp_addMessage(oContexteCdM, 'Erreur MZ, ' + oContexteCdM.error);
  8689. }
  8690. return;
  8691. }
  8692. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify( oContexteCdM.oData));
  8693.  
  8694. MZ_comp_addPvRestant(oContexteCdM);
  8695.  
  8696. var etimestamp = document.getElementById('hserveur');
  8697. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  8698. if (tstamp == undefined) {
  8699. /* dans le cas de la comp, le serveur se repliera sur la date/heure courrante
  8700. window.console.log('MZ_comp_traiteCdMcomp, pas de date/heure');
  8701. MZ_comp_addMessage(oContexteCdM, 'Impossible d\'envoyer la CdM à MZ, pas de date/heure');
  8702. return;
  8703. */
  8704. } else {
  8705. oContexteCdM.oData.tstamp = tstamp.replace(/\]/, '').trim();
  8706. }
  8707.  
  8708. // Envoi auto ou insertion bouton envoi (suivant option)
  8709. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  8710. oContexteCdM.sendInfoCDM();
  8711. MZ_comp_addMessage(oContexteCdM, 'CdM envoyée vers la base MountyZilla !');
  8712. } else {
  8713. insertButtonCdm('as_Action', oContexteCdM.sendInfoCDM);
  8714. }
  8715. }
  8716.  
  8717. function MZ_comp_addMessage(oContexteCdM, msg) {
  8718. var eBefore = document.getElementsByName(oContexteCdM.nameBut)[0].parentNode;
  8719. if (!eBefore) {
  8720. window.console.log('MZ_comp_addMessage, pas de ' + oContexteCdM.nameBut);
  8721. return;
  8722. }
  8723. var p = document.createElement('p');
  8724. p.style.color = 'green';
  8725. appendText(p, msg);
  8726. insertBefore(eBefore, p);
  8727. }
  8728.  
  8729. function MZ_analyseCdM(idHTMLCdM, bIgnoreEltAbsent) { // rend un contexte
  8730. var eltCdM = document.getElementById(idHTMLCdM);
  8731. var oRet = {};
  8732. if (!eltCdM) {
  8733. oRet.ok = false;
  8734. if (!bIgnoreEltAbsent) oRet.error = 'Pas d\'elt ' + idHTMLCdM;
  8735. return oRet;
  8736. }
  8737.  
  8738. // le contexte contiendra
  8739. // txtHeure : le texte de l'heure de la CdM
  8740. // trBlessure : le <tr> de la ligne "blessure"
  8741. // txtBlessure : le texte donnant le % de blessure
  8742. // txtPv : le texte donnant les PV
  8743. // ok : 1 si on a bien reconnu une CdM
  8744. // oData : les data à envoyer en JSON au serveur MZ
  8745. oRet.oData = {}
  8746. oRet.oData.tabCdM = new Array();
  8747. for (var iElt = 0; iElt < eltCdM.childNodes.length; iElt++) { //eHTML of msgEffet.childNodes) { for...of pas supporté par IE et Edge
  8748. var eHTML = eltCdM.childNodes[iElt];
  8749. var s = undefined;
  8750. switch (eHTML.nodeName) {
  8751. case '#text':
  8752. s = eHTML.nodeValue;
  8753. // suite : même code que <B> ou <p>
  8754. case 'P':
  8755. case 'B':
  8756. if (s === undefined) s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8757. s = s.trim();
  8758. if (s != '') {
  8759. if (s.match(/aux *alentours* *de/i)) oRet.txtHeure = s;
  8760. if (s.match(/Connaissance *des* *Monstres/i)) oRet.ok = true;
  8761. oRet.oData.tabCdM.push(s);
  8762. }
  8763. break;
  8764. case 'TABLE':
  8765. var s = 'table';
  8766. for (var iTr = 0; iTr < eHTML.rows.length; iTr++) { // eTr of eHTML.rows) {
  8767. var eTr = eHTML.rows[iTr];
  8768. var tabTd = new Array();
  8769. for (var iTd = 0; iTd < eTr.cells.length; iTd++) { //eTd of eTr.cells) {
  8770. var eTd = eTr.cells[iTd];
  8771. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  8772. s = s.trim();
  8773. tabTd.push(s);
  8774. }
  8775. if (tabTd.length >= 2) {
  8776. if (tabTd[0].match(/Blessure/i)) {
  8777. oRet.trBlessure = eTr;
  8778. oRet.txtBlessure = tabTd[1]
  8779. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  8780. oRet.txtPv = tabTd[1]
  8781. }
  8782. }
  8783. oRet.oData.tabCdM.push(tabTd);
  8784. }
  8785. break;
  8786. case 'BR':
  8787. break; // ignore
  8788. default:
  8789. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  8790. if (s != '') oRet.oData.tabCdM.push(s);
  8791. window.console.log('[MZ ' + GM_info.script.version + '] MZ_analyseCdM, type d\'élément non traité : ' + eHTML.nodeName + ' ' + s);
  8792. break;
  8793. }
  8794. }
  8795. oRet.oData.idTroll = numTroll;
  8796.  
  8797. // préparation de l'envoi d'une CdM issue de compte-rendu de compétence
  8798. // fonction définie ici pour avoir vue sur la variable tabCdM
  8799. oRet.sendInfoCDM = function () {
  8800. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  8801. var buttonCDM = this;
  8802. var texte = '';
  8803. FF_XMLHttpRequest({
  8804. method: 'POST',
  8805. url: URL_pageDispatcherV2,
  8806. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oRet.oData)),
  8807. headers : {
  8808. 'Content-type':'application/x-www-form-urlencoded',
  8809. },
  8810. trace: 'envoi CdM',
  8811. onload: function(responseDetails) {
  8812. texte = responseDetails.responseText;
  8813. buttonCDM.value = texte;
  8814. //window.console.log('buttonCDM.parentNode.firstChild.nodeName=' + buttonCDM.parentNode.firstChild.nodeName);
  8815. if (buttonCDM.parentNode.firstChild.nodeName == 'SPAN') { // smartphone
  8816. buttonCDM.parentNode.firstChild.innerHTML = texte;
  8817. }
  8818. if (!isDEV) buttonCDM.disabled = true;
  8819. },
  8820. onerror: function(responseDetails) {
  8821. var msgError = 'inconnue';
  8822. if (responseDetails.status == 0) msgError = ' HTTPS ou CORS'
  8823. if (responseDetails.error) msgError = responseDetails.error;
  8824. msgError = 'Erreur MZ ' + msgError;
  8825. buttonCDM.value = msgError;
  8826. if (buttonCDM.parentNode.firstChild.nodeName == 'SPAN') { // smartphone
  8827. buttonCDM.parentNode.firstChild.innerHTML = msgError;
  8828. }
  8829. },
  8830. });
  8831. }
  8832. return oRet;
  8833. }
  8834.  
  8835. function MZ_comp_addPvRestant(oContexteCdM) {
  8836. // Insertion de l'estimation des PV restants
  8837. if (MY_DEBUG) window.console.log('txtBlessure=' + oContexteCdM.txtBlessure + ', txtPv=' + oContexteCdM.txtPv);
  8838. if (oContexteCdM.txtBlessure === undefined || oContexteCdM.txtPv === undefined) return;
  8839. var pv = getPVsRestants(oContexteCdM.txtPv, oContexteCdM.txtBlessure);
  8840. if (MY_DEBUG) window.console.log('pv=' + pv);
  8841. if (!pv) return; // pv null si le monstre n'est pas blessé
  8842. var tr = document.createElement('tr');
  8843. oContexteCdM.trBlessure.parentNode.insertBefore(tr, oContexteCdM.trBlessure.nextSibling);
  8844. var th = appendThText(tr, pv[0], false);
  8845. th.className = oContexteCdM.trBlessure.cells[0].className;
  8846. var td = appendTdText(tr, pv[1], false);
  8847. var eSpan = document.createElement('span');
  8848. appendText(eSpan, ' (Calculé par Mountyzilla)');
  8849. eSpan.style.fontSize = "small";
  8850. eSpan.style.fontStyle = "italic";
  8851. td.appendChild(eSpan);
  8852. }
  8853.  
  8854. function do_cdmcomp() {
  8855. start_script(31);
  8856. MZ_comp_traiteCdMcomp();
  8857. displayScriptTime();
  8858. }
  8859.  
  8860. /*********************************************************************************
  8861. * This file is part of Mountyzilla. *
  8862. * *
  8863. * Mountyzilla is free software; you can redistribute it and/or modify *
  8864. * it under the terms of the GNU General Public License as published by *
  8865. * the Free Software Foundation; either version 2 of the License, or *
  8866. * (at your option) any later version. *
  8867. * *
  8868. * Mountyzilla is distributed in the hope that it will be useful, *
  8869. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8870. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8871. * GNU General Public License for more details. *
  8872. * *
  8873. * You should have received a copy of the GNU General Public License *
  8874. * along with Mountyzilla; if not, write to the Free Software *
  8875. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8876. *********************************************************************************/
  8877.  
  8878. // x~x cmdbot
  8879.  
  8880. /* v0.2 by Dab - 2013-08-20
  8881. * - patch dégueu pour gérer la décomposition P/M de l'armure
  8882. */
  8883.  
  8884. var buttonCDM;
  8885.  
  8886. /*******************************************************************************************
  8887. CDM :
  8888. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  8889.  
  8890. Il ne vous est pas possible d'améliorer cette compétence.
  8891.  
  8892. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  8893. Niveau : Inimaginable (entre 49 et 51)
  8894. Points de Vie : Surtrollesque (entre 450 et 470)
  8895. Blessure (Approximatif) : 0 %
  8896. Dés d'Attaque : Impressionnant (entre 30 et 32)
  8897. Dés d'Esquive : Impressionnant (entre 28 et 30)
  8898. Dés de Dégat : Très Fort (entre 18 et 20)
  8899. Dés de Régénération : Excellent (égal à 13)
  8900. Armure Physique : Moyen (entre 10 et 12)
  8901. Armure Magique : Faible (inférieur à 6)
  8902. Vue : Moyen (entre 9 et 11)
  8903. Maitrise Magique : Inimaginable (supérieur à 6000)
  8904. Résistance Magique : Inimaginable (supérieur à 6000)
  8905. Nombre d'attaques : 1
  8906. Vitesse de Déplacement : Normale
  8907. Voir le Caché : Oui
  8908. Attaque à distance : Non
  8909. Attaque magique : Oui
  8910. Vole : Non
  8911. Sang froid : Inexistant
  8912. DLA : Milieu
  8913. Durée Tour : Remarquable (entre 9 et 11)
  8914. Chargement : Vide
  8915. Bonus Malus : Aucun
  8916.  
  8917. Vous avez également gagné 1 PX pour la réussite.
  8918. *******************************************************************************************
  8919. BOT :
  8920. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  8921.  
  8922. Le Monstre ciblé fait partie des : Mort-Vivant
  8923.  
  8924. Niveau : Incroyable (entre 36 et 38)
  8925. *******************************************************************************************/
  8926.  
  8927. function getNNInt(str) {
  8928. var nbrs = str.match(/\d+/g);
  8929. for (var i=0 ; i<nbrs.length ; i++)
  8930. nbrs[i] = parseInt(nbrs[i]);
  8931. return nbrs;
  8932. }
  8933.  
  8934. // envoi d'une CdM issue d'un message du BOT
  8935. function sendCDM() {
  8936. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  8937. document, null, 9, null).singleNodeValue;
  8938. /* ancienne version à supprimer
  8939. cdm = td.innerHTML;
  8940. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  8941. "$3$4 ($1 - N°$2)<br>");
  8942. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  8943. 'Blessure : XX % (approximativement)');
  8944. // Supprime la décomposition P/M de l'Armure
  8945. var bgn = cdm.indexOf('Armure Physique');
  8946. if (bgn!=-1) {
  8947. var end = cdm.indexOf('Vue')-2;
  8948. var lines = cdm.substring(bgn,end).split('<br>');
  8949. var armp = getNNInt(lines[0]);
  8950. var armm = getNNInt(lines[1]);
  8951. if (lines[0].indexOf('(inf')!=-1)
  8952. armp = [0,armp[0]];
  8953. if (lines[1].indexOf('(inf')!=-1)
  8954. armm = [0,armm[0]];
  8955. var insrt = 'Armure : ';
  8956. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  8957. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  8958. else
  8959. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  8960. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  8961. }
  8962. cdm = cdm.replace(/<br>/g,'\n');
  8963. */
  8964.  
  8965. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  8966. //window.console.log(tdTxt);
  8967. var oData = {};
  8968. oData.tabCdM = tdTxt.split(/\n/);
  8969. // nettoyage entête : enlève le premier élément tant que
  8970. // - suite de *
  8971. // - "MOUNTYHALL - La Terre des Trõlls"
  8972. // - ligne vide (la première expression régulière matche les lignes vides)
  8973. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  8974. // 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
  8975. var iLigneNonVide;
  8976. for (var i = 0; i < oData.tabCdM.length; i++) {
  8977. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  8978. if (iLigneNonVide === undefined)
  8979. oData.tabCdM.splice(i);
  8980. else
  8981. oData.tabCdM.splice(iLigneNonVide+1);
  8982. break;
  8983. }
  8984. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  8985. }
  8986. //window.console.log(JSON.stringify(oData));
  8987.  
  8988. FF_XMLHttpRequest({
  8989. method: 'POST',
  8990. url: URL_pageDispatcherV2,
  8991. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  8992. headers : {
  8993. /* inutile, à supprimer
  8994. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8995. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8996. */
  8997. 'Content-type':'application/x-www-form-urlencoded',
  8998. },
  8999. trace: 'envoi CdM msg du bot',
  9000. onload: function(responseDetails) {
  9001. buttonCDM.value=responseDetails.responseText;
  9002. buttonCDM.disabled = true;
  9003. }
  9004. });
  9005. }
  9006.  
  9007. function MZ_traiteCdMmsg() {
  9008. var oContexteCdM = MZ_analyseCdM('messageContent'); // analyse de la CdM, prépare l'envoi, prépare l'ajout de PV min/max selon blessure
  9009. oContexteCdM.nameBut = 'bForward'; // nom du bouton avant lequel insérer le bouton ou les textes
  9010. if (!oContexteCdM.ok) {
  9011. if (oContexteCdM.error) {
  9012. window.console.log('MZ_traiteCdMmsg, ' + oContexteCdM.error);
  9013. MZ_comp_addMessage(oContexteCdM, 'Erreur MZ, ' + oContexteCdM.error);
  9014. }
  9015. return;
  9016. }
  9017. if (MY_DEBUG) window.console.log('oContexteCdM=' + JSON.stringify( oContexteCdM));
  9018.  
  9019. MZ_comp_addPvRestant(oContexteCdM);
  9020.  
  9021. if (oContexteCdM.txtHeure) {
  9022. var m = oContexteCdM.txtHeure.match(/\d+\/\d+\/\d+ +\d+:\d+:\d+/);
  9023. if (m) var tstamp = m[0];
  9024. }
  9025. if (tstamp == undefined) {
  9026. window.console.log('MZ_traiteCdMmsg, pas de date/heure');
  9027. MZ_comp_addMessage(oContexteCdM, 'Impossible d\'envoyer la CdM à MZ, pas de date/heure');
  9028. return;
  9029. }
  9030. oContexteCdM.oData.tstamp = tstamp.trim();
  9031. oContexteCdM.oData.bMsgBot = 1;
  9032.  
  9033. // Insertion bouton envoi
  9034. insertButtonCdm(oContexteCdM.nameBut, oContexteCdM.sendInfoCDM);
  9035.  
  9036. /* à supprimer
  9037. // Teste si ce message du bot est un message de CdM
  9038. var tdMessageContent = document.getElementById('messageContent');
  9039. if (!tdMessageContent) return;
  9040.  
  9041. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  9042. document, null, 9, null).singleNodeValue;
  9043. if (!td) return false;
  9044.  
  9045. cdm = td.innerHTML;
  9046.  
  9047. // Insertion de l'estimation des PV restants
  9048. var des = cdm.indexOf('Dés');
  9049. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  9050. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  9051. if(pv)
  9052. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  9053.  
  9054. // Insertion bouton envoi + espace
  9055. buttonCDM = insertButtonCdm('bClose',sendCDM);
  9056. */
  9057. }
  9058.  
  9059. /*function traitePouvoir() {
  9060. // Teste si ce message du bot est un message de CdM
  9061. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  9062. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  9063. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  9064. if (!td)
  9065. return false;
  9066.  
  9067. var infos = td.innerHTML;
  9068. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  9069. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  9070. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  9071. var date = /alors : ([^<]+)\./.exec(infos)[1];
  9072. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  9073. var effetPouvoir="";
  9074. var full=false;
  9075. if(infos.indexOf("REDUIT")!=-1) {
  9076. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  9077. }
  9078. else {
  9079. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  9080. full=true;
  9081. }
  9082. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  9083. // On insère le bouton et un espace
  9084. //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));
  9085. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  9086. if(!MY_getValue('AUTOSENDPOUV'))
  9087. {
  9088. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  9089. button.setAttribute("onClick", "window.open('" + url
  9090. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  9091. + "this.value='Merci de votre participation'; this.disabled = true;");
  9092. }
  9093. else
  9094. {
  9095. FF_XMLHttpRequest({
  9096. method: 'GET',
  9097. url: url,
  9098. headers : {
  9099. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9100. 'Accept': 'application/atom+xml,application/xml,text/xml'
  9101. }});
  9102. }
  9103. }*/
  9104.  
  9105. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  9106. MZ_traiteCdMmsg();
  9107. }
  9108. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  9109.  
  9110. /*******************************************************************************
  9111. * This file is part of Mountyzilla. *
  9112. * *
  9113. * Mountyzilla is free software; you can redistribute it and/or modify *
  9114. * it under the terms of the GNU General Public License as published by *
  9115. * the Free Software Foundation; either version 2 of the License, or *
  9116. * (at your option) any later version. *
  9117. * *
  9118. * Mountyzilla is distributed in the hope that it will be useful, *
  9119. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9120. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9121. * GNU General Public License for more details. *
  9122. * *
  9123. * You should have received a copy of the GNU General Public License *
  9124. * along with Mountyzilla; if not, write to the Free Software *
  9125. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9126. *******************************************************************************/
  9127.  
  9128. // x~x menu
  9129. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  9130.  
  9131. var menuRac, mainIco;
  9132.  
  9133. // met à jour les carac sauvegardées (position, DLA, etc.)
  9134. function updateData() {
  9135. var inputs = document.getElementsByTagName('input');
  9136. var divs = document.getElementsByTagName('div');
  9137.  
  9138. //window.console.log('inputs=' + JSON.stringify(inputs));
  9139. if (inputs && inputs.length > 0) {
  9140. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  9141. numTroll = inputs[0].value;
  9142. window.console.log('[MZd ' + GM_info.script.version + '] init1 numTroll ' + numTroll);
  9143. MY_setValue('NUM_TROLL', numTroll);
  9144. MY_setValue('NIV_TROLL',inputs[1].value);
  9145. if(!MY_getValue(numTroll+'.caracs.rm')) {
  9146. MY_setValue(numTroll+'.caracs.rm',0);
  9147. // assure l'init des 4 var de libs
  9148. }
  9149. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  9150. } else {
  9151. // onclick="EnterPJView(91305,750,550)"
  9152. var tabA = document.getElementsByTagName('a');
  9153. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  9154. var s = tabA[0].onclick.toString();;
  9155. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  9156. var m = s.match(/\((\d+) *,/);
  9157. //window.console.log('m=' + JSON.stringify(m));
  9158. numTroll = parseInt(m[1]);
  9159. window.console.log('[MZd ' + GM_info.script.version + '] init2 numTroll ' + numTroll);
  9160. MY_setValue('NUM_TROLL', numTroll);
  9161. } else {
  9162. window.console.log('[MZd ' + GM_info.script.version + '] updateData, impossible de retrouver le numéro de Troll (tabA.length=' + tabA.length + ')');
  9163. }
  9164. }
  9165.  
  9166. var DLA = new Date(
  9167. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  9168. );
  9169. if(MY_getValue(numTroll+'.DLA.encours')) {
  9170. var DLAstockee = new Date(
  9171. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  9172. );
  9173. if(DLA>DLAstockee) {
  9174. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  9175. // Pose un pb en cas de décalage de DLA
  9176. }
  9177. }
  9178. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  9179.  
  9180. try {
  9181. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  9182. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  9183. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  9184. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  9185. } catch(e) {
  9186. 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, '‹'));
  9187. }
  9188. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  9189. }
  9190.  
  9191. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9192. function initRaccourcis() {
  9193. var anotherURL = MY_getValue('URL1');
  9194. if(!anotherURL) { return; }
  9195.  
  9196. /* Création de l'icône faisant apparaître le menu */
  9197. mainIco = document.createElement('img');
  9198. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  9199. if(!urlIco) {
  9200. urlIco =
  9201. URL_MZimg + 'mz_logo_small.png';
  9202. }
  9203. mainIco.src = urlIco;
  9204. mainIco.alt = 'MZ';
  9205. mainIco.style = 'position:fixed; top:0px; left:0px';
  9206. mainIco.onmouseover = afficheMenu;
  9207. document.body.appendChild(mainIco);
  9208.  
  9209. /* Création du menu des Raccourcis */
  9210. menuRac = document.createElement('div');
  9211. menuRac.className = 'mh_textbox';
  9212. menuRac.style =
  9213. 'position:fixed; top:10px; left:10px;'+
  9214. 'max-width:190px;'+
  9215. 'border-radius: 4px; padding: 4px;'+
  9216. 'z-index: 500;'+
  9217. 'visibility: hidden;';
  9218. document.body.appendChild(menuRac);
  9219. document.addEventListener('mousemove',cacheMenu,false);
  9220. var i=1;
  9221. while(anotherURL) {
  9222. var a = document.createElement('a');
  9223. var url = MY_getValue('URL'+i);
  9224. var nom = MY_getValue('URL'+i+'.nom');
  9225. var ico = MY_getValue('URL'+i+'.ico');
  9226. a.href = url;
  9227. a.target = '_blank';
  9228. if(ico) {
  9229. var txt = nom ? nom : '';
  9230. var img = createImage(ico,txt);
  9231. a.appendChild(img);
  9232. }
  9233. else {
  9234. appendText(a,'['+nom+']');
  9235. }
  9236. menuRac.appendChild(a);
  9237. appendBr(menuRac);
  9238. i++;
  9239. anotherURL = MY_getValue('URL'+i);
  9240. }
  9241. }
  9242.  
  9243. function afficheMenu() {
  9244. menuRac.style.visibility = 'visible';
  9245. }
  9246.  
  9247. function cacheMenu(e) {
  9248. if(menuRac.style.visibility=='hidden') { return; }
  9249. // Position souris
  9250. var ptX = e.clientX;
  9251. var ptY = e.clientY;
  9252. // On recalcule en live les BoundingBox pour mainIco et menuRac
  9253. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  9254. var menuRect = menuRac.getBoundingClientRect();
  9255. var icoRect = mainIco.getBoundingClientRect();
  9256. if((ptX>icoRect.width || ptY>icoRect.height) &&
  9257. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  9258. menuRac.style.visibility = 'hidden';
  9259. }
  9260. }
  9261.  
  9262. // ajout de l'icône, branchée sur un refresh
  9263. function initUpdateCoordGauche() {
  9264. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  9265. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  9266. var img = document.createElement('img');
  9267. img.src = URL_MZimg + 'recycl.png'
  9268. img.onclick = function(evt) {
  9269. document.location.href = document.location.href;
  9270. };
  9271. img.title = 'Mise à jour de la localisation';
  9272. img.style.cursor = 'pointer';
  9273. img.style.position = 'absolute';
  9274. img.style.bottom = 0;
  9275. img.style.left = 0;
  9276. div.appendChild(img);
  9277. }
  9278.  
  9279. // ajout sur les raccoucis des mêmes popup que dans le profil
  9280. function MZ_initPopupFrameGauche() {
  9281. var eListeFavoris = document.getElementById('listeFavori');
  9282. if (!eListeFavoris) {
  9283. window.console.log('MZ **erreur** pas de listeFavori dans la frame de gauche');
  9284. return;
  9285. }
  9286. var tabA = eListeFavoris.getElementsByTagName('A');
  9287. for (var i = 0; i < tabA.length; i++) {
  9288. var a = tabA[i];
  9289. setInfos(a,epure(trim(a.textContent)),'*',1);
  9290. }
  9291. }
  9292.  
  9293. function do_menu() {
  9294. // met à jour les carac sauvegardées (position, DLA, etc.)
  9295. updateData();
  9296. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  9297. initRaccourcis();
  9298. // Ajout bouton de mise à jour coordonnées
  9299. initUpdateCoordGauche();
  9300. // Ajout popup sur les raccourcis des actions
  9301. //MZ_initPopupFrameGauche();
  9302. }
  9303.  
  9304. /*******************************************************************************
  9305. * This file is part of Mountyzilla. *
  9306. * *
  9307. * Mountyzilla is free software; you can redistribute it and/or modify *
  9308. * it under the terms of the GNU General Public License as published by *
  9309. * the Free Software Foundation; either version 2 of the License, or *
  9310. * (at your option) any later version. *
  9311. * *
  9312. * Mountyzilla is distributed in the hope that it will be useful, *
  9313. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9314. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9315. * GNU General Public License for more details. *
  9316. * *
  9317. * You should have received a copy of the GNU General Public License *
  9318. * along with Mountyzilla; if not, write to the Free Software *
  9319. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9320. *******************************************************************************/
  9321.  
  9322. // x~x vue
  9323.  
  9324. /* TODO
  9325. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  9326. * prévoir fix ("delete infos")
  9327. */
  9328.  
  9329. /*--------------------------- Variables Globales -----------------------------*/
  9330.  
  9331. // Position actuelle
  9332. var currentPosition=[0,0,0];
  9333.  
  9334. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  9335. var porteeVue=[0,0,0,0];
  9336.  
  9337. // Fenêtres déplaçables
  9338. var winCurr = null;
  9339. var offsetX, offsetY;
  9340.  
  9341. // Diplomatie
  9342. var Diplo = {
  9343. Guilde: {},
  9344. Troll: {},
  9345. Monstre: {}
  9346. // .mythiques: uniquement si option activée
  9347. };
  9348. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  9349.  
  9350. // Infos tactiques
  9351. // => MZ_Tactique.popup
  9352.  
  9353. // Utilisé pour supprimer les monstres "engagés"
  9354. var listeEngages = {};
  9355. var isEngagesComputed = false;
  9356. var cursorOnLink = false; // DEBUG: wtf ?
  9357.  
  9358. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  9359. && MY_getValue(numTroll+'.enchantement.liste')!='';
  9360.  
  9361. // Checkboxes de filtrage
  9362. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  9363. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  9364. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  9365. comboBoxNiveauMin, comboBoxNiveauMax, comboBoxFamille;
  9366.  
  9367. /* Acquisition & Stockage des données de DB */
  9368. var typesAFetcher = {
  9369. 'monstres':1,
  9370. 'trolls':1,
  9371. 'tresors':1,
  9372. 'champignons':1,
  9373. 'lieux':1
  9374. }
  9375.  
  9376. var MZ_EtatCdMs = { // zone où sont stockées les variables "globales" pour la gestion des cdM et infos tactiques
  9377. nbMonstres: 0,
  9378. tr_monstres: [],
  9379. lastIndexDone: 0,
  9380. isCDMsRetrieved: false, // = si les CdM ont déjà été DL
  9381. listeCDM: [],
  9382. indexCellDist: -1,
  9383. indexCellActions: -1,
  9384. indexCellID: -1,
  9385. indexCellNivMZ: -1,
  9386. indexCellX: -1,
  9387. indexCellY: -1,
  9388. indexCellN: -1,
  9389. // Gère l'affichage en cascade des popups de CdM
  9390. yIndexCDM: 0,
  9391. tdWitdh: 110,
  9392. };
  9393.  
  9394. var VueContext = {};
  9395. var tr_trolls = {}, tr_tresors = {},
  9396. tr_champignons = {}, tr_lieux = {};
  9397. var nbTrolls = 0, nbTresors = 0,
  9398. nbChampignons = 0, nbLieux = 0;
  9399.  
  9400. function fetchData(type) {
  9401. var node;
  9402. try {
  9403. node = document.getElementById('mh_vue_hidden_'+type);
  9404. VueContext['tr_'+type] = node.getElementsByTagName('tr');
  9405. VueContext['nb'+type[0].toUpperCase()+type.slice(1)] = VueContext['tr_'+type].length-1;
  9406. } catch(e) {
  9407. window.console.warn('[MZ Vue] Erreur acquisition type '+type, e);
  9408. }
  9409. }
  9410.  
  9411. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  9412.  
  9413. function positionToString(arr) {
  9414. return arr.join(';');
  9415. }
  9416.  
  9417. function savePosition() {
  9418. // Stocke la position (à jour) de la vue pour les autres scripts
  9419. // DEBUG: Lesquels et pourquoi?
  9420. var pos = getPosition();
  9421. MY_setValue(numTroll+'.position.X',pos[0]);
  9422. MY_setValue(numTroll+'.position.Y',pos[1]);
  9423. MY_setValue(numTroll+'.position.N',pos[2]);
  9424. }
  9425.  
  9426.  
  9427. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  9428. /* INFOS :
  9429. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  9430. * sont identifiables via leur Name
  9431. * les tables-listings sont identifiables via l'ID du tr conteneur
  9432. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  9433. */
  9434.  
  9435. /* [functions] Récup données Utilisateur */
  9436. function getPosition() {
  9437. // Pour rétrocompatibilité
  9438. return currentPosition;
  9439. }
  9440.  
  9441. function getPorteVue() {
  9442. // Pour rétrocompatibilité
  9443. return porteeVue;
  9444. }
  9445.  
  9446. function getVue() {
  9447. // Retourne [vueHpure, vueVpure]
  9448. var vues = getPorteVue();
  9449. return [ vues[0], vues[1] ];
  9450. }
  9451.  
  9452. // Roule 11/03/2016
  9453. /* [functions] Récup données monstres, trolls, etc. */
  9454. function getXxxDistance(xxx, i) {
  9455. return parseInt(VueContext['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  9456. }
  9457. function getXxxPosition(xxx, i) {
  9458. var tds = VueContext['tr_' + xxx.toLowerCase()][i].childNodes;
  9459. var l = tds.length;
  9460. return [
  9461. parseInt(tds[l-3].textContent),
  9462. parseInt(tds[l-2].textContent),
  9463. parseInt(tds[l-1].textContent)
  9464. ];
  9465. }
  9466.  
  9467.  
  9468. /* [functions] Récup données monstres */
  9469. function getMonstreDistance(i) {
  9470. //debugMZ('getMonstreDistance, i=' + i + ', tr=' + MZ_EtatCdMs.tr_monstres[i].innerHTML);
  9471. return parseInt(MZ_EtatCdMs.tr_monstres[i].cells[MZ_EtatCdMs.indexCellDist].textContent);
  9472. }
  9473.  
  9474. function getMonstreID(i) {
  9475. return Number(MZ_EtatCdMs.tr_monstres[i].cells[MZ_EtatCdMs.indexCellID].firstChild.nodeValue);
  9476. }
  9477.  
  9478. function getMonstreIDByTR(tr) {
  9479. return tr.cells[MZ_EtatCdMs.indexCellID].firstChild.nodeValue;
  9480. }
  9481.  
  9482. function getMonstreLevelNode(i) {
  9483. return MZ_EtatCdMs.tr_monstres[i].cells[MZ_EtatCdMs.indexCellNivMZ];
  9484. }
  9485.  
  9486. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  9487. if(!MZ_EtatCdMs.isCDMsRetrieved) return false;
  9488. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  9489. if (!donneesMonstre) return false;
  9490. var niv = donneesMonstre.niv;
  9491. if (niv == undefined) return false;
  9492. if (limitMin > 0 && niv.max && niv.max < limitMin) return true;
  9493. if (limitMax > 0 && niv.min && niv.min > limitMax) return true;
  9494. return false;
  9495. }
  9496.  
  9497. function getMonstreNomNode(i) {
  9498. try {
  9499. var td = document.evaluate(
  9500. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  9501. MZ_EtatCdMs.tr_monstres[i], null, 9, null
  9502. ).singleNodeValue;
  9503. return td;
  9504. } catch(e) {
  9505. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  9506. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  9507. }
  9508. }
  9509.  
  9510. function getMonstreNom(i) {
  9511. return getMonstreNomByTR(MZ_EtatCdMs.tr_monstres[i]);
  9512. }
  9513.  
  9514. function getMonstreNomByTR(tr) {
  9515. try {
  9516. var nom = document.evaluate(
  9517. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  9518. tr, null, 2, null
  9519. ).stringValue;
  9520. return nom;
  9521. } catch(e) {
  9522. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  9523. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  9524. }
  9525. }
  9526.  
  9527. function getMonstrePosition(i) {
  9528. var tds = MZ_EtatCdMs.tr_monstres[i].childNodes;
  9529. return [
  9530. parseInt(tds[MZ_EtatCdMs.indexCellX].textContent),
  9531. parseInt(tds[MZ_EtatCdMs.indexCellY].textContent),
  9532. parseInt(tds[MZ_EtatCdMs.indexCellN].textContent)
  9533. ];
  9534. }
  9535.  
  9536. function appendMonstres(txt) {
  9537. for(var i=1; i<=MZ_EtatCdMs.nbMonstres ; i++)
  9538. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  9539. return txt;
  9540. }
  9541.  
  9542. function getMonstres() {
  9543. var vue = getVue();
  9544. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9545. }
  9546.  
  9547. function bddMonstres(start,stop) {
  9548. if(!start) { var start = 1; }
  9549. if(!stop) { var stop = MZ_EtatCdMs.nbMonstres; }
  9550. stop = Math.min(MZ_EtatCdMs.nbMonstres,stop);
  9551. var txt='';
  9552. for(var i=start ; i<=stop ; i++) {
  9553. txt += getMonstreID(i)+';'+
  9554. getMonstreNom(i)+';'+
  9555. positionToString(getMonstrePosition(i))+'\n';
  9556. }
  9557. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  9558. }
  9559.  
  9560. /* [functions] Récup données Trolls */
  9561.  
  9562. // Roule 12/07/2017 détecte les colonnes à partir des titres. Mamoune vient de les faire bouger :(
  9563. var COL_TROLL_DIST = 0; // celui-là, on le garde en dur
  9564.  
  9565. function getTrollDistance(i) {
  9566. return parseInt(tr_trolls[i].cells[COL_TROLL_DIST].textContent);
  9567. }
  9568.  
  9569. var MZ_cache_col_TrollID;
  9570. var MZ_cache_col_TrollNOM;
  9571. var MZ_cache_col_TrollGUILDE;
  9572. var MZ_cache_col_TrollNIV;
  9573.  
  9574. function MZ_find_col_titre(trs, titre) {
  9575. var l = titre.length;
  9576. for (var i=0; i < trs[0].cells.length; i++)
  9577. if (trs[0].cells[i].textContent.toLowerCase().substr(0, l) == titre) return i;
  9578. window.console.log('MZ : impossible de trouver la colonne de titre ' + titre + ' dans ' + trs[0].textContent);
  9579. return 0;
  9580. }
  9581.  
  9582. function getTrollID(i) {
  9583. if (MZ_cache_col_TrollID === undefined) MZ_cache_col_TrollID = MZ_find_col_titre(tr_trolls, 'réf');
  9584. // Roule 08/03/2017 protection
  9585. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  9586. if (isNaN(iTroll)) return;
  9587. if (iTroll == 0) return;
  9588. return iTroll;
  9589. }
  9590.  
  9591. function getTrollNomNode(i) {
  9592. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  9593. return tr_trolls[i].cells[MZ_cache_col_TrollNOM];
  9594. }
  9595.  
  9596. function getTrollNivNode(i) {
  9597. if (MZ_cache_col_TrollNIV === undefined) MZ_cache_col_TrollNIV = MZ_find_col_titre(tr_trolls, 'niv');
  9598. return tr_trolls[i].cells[MZ_cache_col_TrollNIV];
  9599. }
  9600.  
  9601. function getTrollGuilde(i) {
  9602. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9603. return trim(tr_trolls[i].cells[MZ_cache_col_TrollGUILDE].textContent);
  9604. }
  9605.  
  9606. function getTrollGuildeID(i) {
  9607. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  9608. if(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length>0) {
  9609. var href;
  9610. try {
  9611. 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"
  9612. href = tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].firstChild.getAttribute('href');
  9613. } catch(e) { // debug pb remonté par Marsak
  9614. window.console.error(traceStack(e, 'getTrollGuildeID')
  9615. ,'nb child=' + tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE].childNodes.length
  9616. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  9617. return -1;
  9618. }
  9619. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  9620. }
  9621. return -1;
  9622. }
  9623.  
  9624. function getTrollPosition(i) {
  9625. var tds = tr_trolls[i].childNodes;
  9626. var l = tds.length;
  9627. return [
  9628. parseInt(tds[l-3].textContent),
  9629. parseInt(tds[l-2].textContent),
  9630. parseInt(tds[l-1].textContent)
  9631. ];
  9632. }
  9633.  
  9634. function bddTrolls() {
  9635. var txt='#DEBUT TROLLS\n'+
  9636. numTroll+';'+positionToString(getPosition())+'\n';
  9637. for(var i=1 ; i<=nbTrolls ; i++) {
  9638. txt += getTrollID(i)+';'+
  9639. positionToString(getTrollPosition(i))+'\n';
  9640. }
  9641. return txt+'#FIN TROLLS';
  9642. }
  9643.  
  9644. /* [functions] Récup données Trésors */
  9645. function getTresorDistance(i) {
  9646. return tr_tresors[i].cells[0].firstChild.nodeValue;
  9647. }
  9648.  
  9649. function getTresorID(i) {
  9650. return trim(tr_tresors[i].cells[2].textContent);
  9651. }
  9652.  
  9653. function getTresorNom(i) {
  9654. // Utilisation de textContent pour régler le "bug de Pollux"
  9655. return trim(tr_tresors[i].cells[3].textContent);
  9656. }
  9657.  
  9658. function getTresorPosition(i) {
  9659. var tds = tr_tresors[i].childNodes;
  9660. var l = tds.length;
  9661. return [
  9662. parseInt(tds[l-3].textContent),
  9663. parseInt(tds[l-2].textContent),
  9664. parseInt(tds[l-1].textContent),
  9665. ];
  9666. }
  9667.  
  9668. function bddTresors(dmin,start,stop) {
  9669. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  9670. if(!dmin) { var dmin = 0; }
  9671. if(!start) { var start = 1; }
  9672. if(!stop) { var stop = nbTresors; }
  9673. stop = Math.min(nbTresors,stop);
  9674. var txt='';
  9675. for(var i=start ; i<=stop ; i++) {
  9676. if(getTresorDistance(i)>=dmin) {
  9677. txt += getTresorID(i)+';'+
  9678. getTresorNom(i)+';'+
  9679. positionToString(getTresorPosition(i))+'\n';
  9680. }
  9681. }
  9682. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  9683. }
  9684.  
  9685. /* [functions] Récup données Champignons */
  9686. // DEBUG: Pas de colonne "Référence" sur serveur de test
  9687. function getChampignonNom(i) {
  9688. return trim(tr_champignons[i].cells[2].textContent);
  9689. }
  9690.  
  9691. function getChampignonPosition(i) {
  9692. var tds = tr_champignons[i].childNodes;
  9693. var l = tds.length;
  9694. return [
  9695. parseInt(tds[l-3].textContent),
  9696. parseInt(tds[l-2].textContent),
  9697. parseInt(tds[l-1].textContent)
  9698. ];
  9699. }
  9700.  
  9701. function bddChampignons() {
  9702. var txt='';
  9703. for(var i=1 ; i<=nbChampignons ; i++) {
  9704. txt += ';'+ // Les champis n'ont pas de Référence
  9705. getChampignonNom(i)+';'+
  9706. positionToString(getChampignonPosition(i))+'\n';
  9707. }
  9708. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  9709. }
  9710.  
  9711. /* [functions] Récup données Lieux */
  9712. function getLieuDistance(i) {
  9713. return parseInt(tr_lieux[i].cells[0].textContent);
  9714. }
  9715.  
  9716. function getLieuID(i) {
  9717. return parseInt(tr_lieux[i].cells[2].textContent);
  9718. }
  9719.  
  9720. function getLieuNom(i) {
  9721. // Conversion ASCII pour éviter les bugs des Vues externes
  9722. return trim(tr_lieux[i].cells[3].textContent);
  9723. }
  9724.  
  9725. function getLieuPosition(i) {
  9726. var tds = tr_lieux[i].childNodes;
  9727. var l = tds.length;
  9728. return [
  9729. parseInt(tds[l-3].textContent),
  9730. parseInt(tds[l-2].textContent),
  9731. parseInt(tds[l-1].textContent)
  9732. ];
  9733. }
  9734.  
  9735. function appendLieux(txt) {
  9736. for(var i = 1; i < nbLieux+1; i++) {
  9737. var tds = x_lieux[i].childNodes;
  9738. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  9739. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  9740. }
  9741. return txt;
  9742. }
  9743.  
  9744. function getLieux() {
  9745. var vue = getVue();
  9746. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  9747. }
  9748.  
  9749. function bddLieux(start,stop) {
  9750. if(!start) { var start = 1; }
  9751. if(!stop) { var stop = nbLieux; }
  9752. stop = Math.min(nbLieux,stop);
  9753. var txt='';
  9754. for(var i=start ; i<=stop ; i++) {
  9755. txt += getLieuID(i)+';'+
  9756. epure(getLieuNom(i))+';'+
  9757. positionToString(getLieuPosition(i))+'\n';
  9758. }
  9759. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  9760. }
  9761.  
  9762.  
  9763. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  9764.  
  9765. function saveCheckBox(chkbox, pref) {
  9766. // Enregistre et retourne l'état d'une CheckBox
  9767. var etat = chkbox.checked;
  9768. MY_setValue(pref, etat ? 'true' : 'false' );
  9769. return etat;
  9770. }
  9771.  
  9772. function recallCheckBox(chkbox, pref) {
  9773. // Restitue l'état d'une CheckBox
  9774. chkbox.checked = (MY_getValue(pref)=='true');
  9775. }
  9776.  
  9777. function saveComboBox(cbb, pref) {
  9778. if (!cbb) return;
  9779. // Enregistre et retourne l'état d'une ComboBox
  9780. var opt = cbb.options[cbb.selectedIndex];
  9781. if (!opt) return;
  9782. var etat = cbb.options[cbb.selectedIndex].value;
  9783. MY_setValue(pref, etat);
  9784. return etat;
  9785. }
  9786.  
  9787. function recallComboBox(cbb, pref) {
  9788. // Restitue l'état d'une ComboBox
  9789. var nb = MY_getValue(pref);
  9790. if(nb && cbb) cbb.value = nb;
  9791. return nb;
  9792. }
  9793.  
  9794. function synchroniseFiltres() {
  9795. // Récupération de toutes les options de la vue
  9796. var wasActive =
  9797. Number(recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE')) +
  9798. Number(recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE')) +
  9799. (recallComboBox(comboBoxFamille,'FAMILLEMONSTRE') == 0 ? 0 : 1); // Roule 30/01/2020 on obtient du non numérique si il y a filtre par famille
  9800. if(wasActive>0) {
  9801. debutFiltrage('Monstres');
  9802. }
  9803. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9804. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9805. recallCheckBox(checkBoxMythiques,'NOMYTH');
  9806. recallCheckBox(checkBoxEngages,'NOENGAGE');
  9807. recallCheckBox(checkBoxLevels,'NOLEVEL');
  9808. recallCheckBox(checkBoxIntangibles,'NOINT');
  9809. recallCheckBox(checkBoxGG,'NOGG');
  9810. recallCheckBox(checkBoxCompos,'NOCOMP');
  9811. recallCheckBox(checkBoxBidouilles,'NOBID');
  9812. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  9813. recallCheckBox(checkBoxTrou,'NOTROU');
  9814. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9815. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  9816. if(MY_getValue('NOINFOEM')!='true')
  9817. recallCheckBox(checkBoxEM,'NOEM');
  9818. }
  9819.  
  9820.  
  9821. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  9822.  
  9823. function getVueScript() {
  9824. try {
  9825. var txt = bddTrolls()+
  9826. bddMonstres()+
  9827. bddChampignons()+
  9828. bddTresors()+
  9829. bddLieux()+
  9830. '#DEBUT ORIGINE\n'+
  9831. getPorteVue()[2]+';'+positionToString(getPosition())+
  9832. '\n#FIN ORIGINE\n';
  9833. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  9834. return txt;
  9835. } catch(e) {
  9836. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  9837. window.console.error(traceStack(e, 'getVueScript'))
  9838. }
  9839. }
  9840.  
  9841. /* [functions] Menu Vue 2D */
  9842. var vue2Ddata = {
  9843. 'Bricol\' Vue': {
  9844. url: URL_bricol_mountyhall + 'vue_form.php',
  9845. paramid: 'vue',
  9846. func: getVueScript,
  9847. extra_params: {
  9848. 'mode': 'vue_SP_Vue2',
  9849. 'screen_width': window.screen.width
  9850. }
  9851. },
  9852. 'Vue du CCM': {
  9853. url: URL_vue_CCM,
  9854. paramid: 'vue',
  9855. func: getVueScript,
  9856. extra_params: {
  9857. 'id': numTroll+';'+positionToString(getPosition())
  9858. }
  9859. },
  9860. 'Vue Gloumfs 2D': {
  9861. url: URL_vue_Gloumfs2D,
  9862. paramid: 'vue_mountyzilla',
  9863. func: getVueScript,
  9864. extra_params: {}
  9865. },
  9866. 'Vue Gloumfs 3D': {
  9867. url: URL_vue_Gloumfs3D,
  9868. paramid: 'vue_mountyzilla',
  9869. func: getVueScript,
  9870. extra_params: {}
  9871. },
  9872. 'Grouky Vue!': {
  9873. url: URL_vue_Grouky,
  9874. paramid: 'vue',
  9875. func: getVueScript,
  9876. extra_params: {
  9877. 'type_vue': 'V5b1'
  9878. }
  9879. },
  9880. /*'DEBUG': {
  9881. url: 'http://weblocal/testeur.php',
  9882. paramid: 'vue',
  9883. func: getVueScript,
  9884. extra_params: {}
  9885. }*/
  9886. };
  9887.  
  9888. function refresh2DViewButton() {
  9889. // = EventListener menu+bouton vue 2D
  9890. var vueext = document.getElementById('selectVue2D').value;
  9891. MY_setValue('VUEEXT',vueext);
  9892. var form = document.getElementById('viewForm');
  9893. form.innerHTML = '';
  9894. form.method = 'post';
  9895. form.action = vue2Ddata[vueext].url;
  9896. form.target = '_blank';
  9897. appendHidden(form, vue2Ddata[vueext].paramid, '');
  9898. for(var key in vue2Ddata[vueext].extra_params) {
  9899. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  9900. }
  9901. appendSubmit(form, 'Voir',
  9902. function() {
  9903. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  9904. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  9905. vue2Ddata[vueext].func();
  9906. }
  9907. );
  9908. }
  9909.  
  9910. function set2DViewSystem() {
  9911. // Initialise le système de vue 2D
  9912. // Recherche du point d'insertion
  9913. var center;
  9914. try {
  9915. // Roule 09/03/2019, encore un changement MH, je fais suivre comme je peux
  9916. center = document.getElementById('titre2');
  9917. // version initiale "pré-Roule"
  9918. if (!center) center = document.evaluate(
  9919. "//h2[@id='titre2']/following-sibling::center",
  9920. document, null, 9, null
  9921. ).singleNodeValue;
  9922. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  9923. if (!center) center = document.evaluate(
  9924. "//h2[@id='titre2']/following-sibling::div",
  9925. document, null, 9, null
  9926. ).singleNodeValue;
  9927.  
  9928. } catch(e) {
  9929. avertissement("Erreur d'initialisation du système de vue 2D");
  9930. window.console.error(traceStack(e, 'set2DViewSystem'));
  9931. return;
  9932. }
  9933.  
  9934. // Récupération de la dernière vue utilisée
  9935. var vueext = MY_getValue('VUEEXT');
  9936. if(!vueext || !vue2Ddata[vueext]) {
  9937. // sinon, la vue Bricol'Trolls est employée par défaut
  9938. vueext = 'Bricol\' Vue';
  9939. }
  9940.  
  9941. try {
  9942. // Création du sélecteur de vue externe
  9943. selectVue2D = document.createElement('select');
  9944. selectVue2D.id = 'selectVue2D';
  9945. selectVue2D.className = 'SelectboxV2';
  9946. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue, troll n°' + numTroll);
  9947. for(var view in vue2Ddata) {
  9948. appendOption(selectVue2D, view, view);
  9949. }
  9950. selectVue2D.value = vueext;
  9951. selectVue2D.onchange = refresh2DViewButton;
  9952.  
  9953. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  9954. var form = document.createElement('form');
  9955. form.id = 'viewForm';
  9956.  
  9957. // Insertion du système de vue
  9958. var table = document.createElement('table');
  9959. var tr = appendTr(table);
  9960. var td = appendTd(tr);
  9961. td.appendChild(selectVue2D);
  9962. td = appendTd(tr);
  9963. td.style.fontSize = '0px'; // gère le bug de l'extra character
  9964. td.appendChild(form);
  9965. if (center.id == 'titre2') { // 09/03/2019 nouvelle méthode
  9966. var eDiv = document.createElement('div');
  9967. eDiv.appendChild(table);
  9968. eDiv.style.witdth = '100%';
  9969. eDiv.style.textAlign = 'center';
  9970. table.style.width = '180px';
  9971. table.style.margin = '0 auto';
  9972. center.parentNode.insertBefore(eDiv,center.nextSibling);
  9973. } else { // ancienne méthode
  9974. center.insertBefore(table,center.firstChild);
  9975. insertBr(center.childNodes[1]);
  9976. }
  9977.  
  9978. // Appelle le handler pour initialiser le bouton de submit
  9979. refresh2DViewButton();
  9980. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  9981. } catch(e) {
  9982. avertissement("Erreur de traitement du système de vue 2D");
  9983. window.console.error(traceStack(e, 'set2DViewSystem'));
  9984. }
  9985. }
  9986.  
  9987. /* [functions] Tableau d'Infos */
  9988. function initialiseInfos() {
  9989. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  9990. var
  9991. infoTab = document.getElementById('infoTab'),
  9992. tbody = infoTab.tBodies[0],
  9993. thead = infoTab.createTHead(),
  9994. tr = appendTr(thead,'mh_tdtitre'),
  9995. td = appendTdText(tr,'INFORMATIONS',true),
  9996. span = document.createElement('span');
  9997.  
  9998. // Récupération de la position du joueur
  9999. try {
  10000. var strPos = document.evaluate(
  10001. ".//b/text()[contains(.,'X = ') or contains(.,'X\u00A0=\u00A0')]", // &nbsp; en vue smartphone
  10002. infoTab, null, 9, null
  10003. ).singleNodeValue.nodeValue;
  10004. // ***INIT GLOBALE*** currentPosition
  10005. currentPosition = getIntegers(strPos);
  10006. debugMZ("retrievePosition(): "+currentPosition);
  10007. } catch(e) {
  10008. // Si on ne trouve pas le "X ="
  10009. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  10010. }
  10011.  
  10012. // Récupération des portées (max et limitée) de la vue
  10013. try {
  10014. var
  10015. nodes = document.evaluate(
  10016. ".//b/text()[contains(.,'horizontalement') "+
  10017. "or contains(.,'verticalement')]",
  10018. infoTab, null, 7, null
  10019. );
  10020. var array = [];
  10021. for(var i=0 ; i<4 && i<nodes.snapshotLength ; i++) {
  10022. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  10023. }
  10024. // ***INIT GLOBALE*** porteeVue
  10025. porteeVue = array;
  10026. if (porteeVue.length < 4) {
  10027. porteeVue[2] = array[0];
  10028. porteeVue[3] = array[1];
  10029. }
  10030. } catch(e) {
  10031. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  10032. }
  10033.  
  10034. infoTab.id = 'infoTab'; // Pour scripts externes
  10035. tbody.id = 'corpsInfoTab';
  10036. tbody.rows[0].cells[0].colSpan = 2;
  10037. if (tbody.rows.length > 1) tbody.rows[1].cells[0].colSpan = 2;
  10038. td.colSpan = 3;
  10039. td.style.cursor = 'pointer';
  10040. /* quel intérêt de changer de className ? et ça fait bouger toute la frame d'un pixel ou deux, c'est désagréable
  10041. td.onmouseover = function() {
  10042. this.style.cursor = 'pointer';
  10043. this.className = 'mh_tdpage';
  10044. };
  10045. td.onmouseout = function() {
  10046. this.className = 'mh_tdtitre';
  10047. };
  10048. */
  10049. td.onclick = function() {
  10050. toggleTableauInfos(false);
  10051. };
  10052.  
  10053. span.id = 'msgInfoTab';
  10054. span.style.display = 'none';
  10055. appendText(
  10056. span,
  10057. ' => Position : X = '+currentPosition[0]+
  10058. ', Y = '+currentPosition[1]+
  10059. ', N = '+currentPosition[2]+
  10060. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  10061. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  10062. true
  10063. );
  10064. td.appendChild(span);
  10065.  
  10066. tr = appendTr(tbody,'mh_tdpage');
  10067. td = appendTdText(tr,'EFFACER : ',true);
  10068. td.align = 'center';
  10069. td.className = 'mh_tdtitre';
  10070. td.width = 100;
  10071. td = appendTdCenter(tr,2);
  10072. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  10073. checkBoxGG = appendCheckBoxSpan(
  10074. td,'delgg',filtreTresors," Les GG'"
  10075. ).firstChild;
  10076. checkBoxCompos = appendCheckBoxSpan(
  10077. td,'delcomp',filtreTresors,' Les Compos'
  10078. ).firstChild;
  10079. checkBoxBidouilles = appendCheckBoxSpan(
  10080. td,'delbid',filtreTresors,' Les Bidouilles'
  10081. ).firstChild;
  10082. checkBoxIntangibles = appendCheckBoxSpan(
  10083. td,'delint',filtreTrolls,' Les Intangibles'
  10084. ).firstChild;
  10085. checkBoxGowapsA = appendCheckBoxSpan(
  10086. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  10087. ).firstChild;
  10088. checkBoxGowapsS = appendCheckBoxSpan(
  10089. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  10090. ).firstChild;
  10091. checkBoxEngages = appendCheckBoxSpan(
  10092. td,'delengage',filtreMonstres,' Les Engagés'
  10093. ).firstChild;
  10094. checkBoxLevels = appendCheckBoxSpan(
  10095. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  10096. ).firstChild;
  10097. checkBoxDiplo = appendCheckBoxSpan(
  10098. td,'delDiplo',refreshDiplo,' La Diplomatie'
  10099. ).firstChild;
  10100. checkBoxTrou = appendCheckBoxSpan(
  10101. td,'deltrou',filtreLieux,' Les Trous'
  10102. ).firstChild;
  10103. checkBoxMythiques = appendCheckBoxSpan(
  10104. td,'delmyth',filtreMonstres,' Les Mythiques'
  10105. ).firstChild;
  10106. if(MY_getValue('NOINFOEM')!='true') {
  10107. checkBoxEM = appendCheckBoxSpan(
  10108. td,'delem',filtreMonstres,' Les Composants EM'
  10109. ).firstChild;
  10110. }
  10111. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  10112. td,'deltres',filtreTresors,' Les Trésors non libres'
  10113. ).firstChild;
  10114. checkBoxTactique = appendCheckBoxSpan(
  10115. td,'deltactique',updateTactique,' Les Infos tactiques'
  10116. ).firstChild;
  10117.  
  10118. if(MY_getValue('INFOPLIE')) {
  10119. toggleTableauInfos(true);
  10120. }
  10121. }
  10122.  
  10123. function toggleTableauInfos(firstRun) {
  10124. var
  10125. msg = document.getElementById('msgInfoTab'),
  10126. corps = document.getElementById('corpsInfoTab'),
  10127. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  10128. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  10129. if(!firstRun) {
  10130. infoplie = !infoplie;
  10131. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  10132. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  10133. }
  10134. if(infoplie) {
  10135. msg.style.display = '';
  10136. corps.style.display = 'none';
  10137. } else {
  10138. msg.style.display = 'none';
  10139. corps.style.display = '';
  10140. }
  10141. }
  10142.  
  10143. /* [functions] Filtres */
  10144. function prepareFiltrage(ref,width) {
  10145. // = Initialise le filtre 'ref'
  10146. try {
  10147. var tdTitre = document.getElementById(ref.toLowerCase()).closest('td');
  10148. } catch(e) {
  10149. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée', e);
  10150. return false;
  10151. }
  10152. if(width) { tdTitre.width = width+'px'; }
  10153. // Ajout du tr de Filtrage (masqué)
  10154. var tbody = tdTitre.parentNode.parentNode;
  10155. var tr = appendTr(tbody,'mh_tdpage');
  10156. tr.style.display = 'none';
  10157. tr.id = 'trFiltre'+ref;
  10158. var td = appendTd(tr);
  10159. td.colSpan = 5;
  10160. // Ajout du bouton de gestion de Filtrage
  10161. var tdBtn = insertAfterTd(tdTitre);
  10162. tdBtn.id = 'tdInsert'+ref;
  10163. var btn = appendButton(tdBtn,'Filtrer');
  10164. btn.id = 'btnFiltre'+ref;
  10165. btn.onclick = function() {
  10166. debutFiltrage(ref);
  10167. };
  10168. return td;
  10169. }
  10170.  
  10171. function debutFiltrage(ref) {
  10172. // = Handler de début de filtrage (filtre 'ref')
  10173. document.getElementById('trFiltre'+ref).style.display = '';
  10174. var btn = document.getElementById('btnFiltre'+ref);
  10175. btn.value = 'Annuler Filtre';
  10176. btn.onclick = function() {
  10177. finFiltrage(ref);
  10178. };
  10179. }
  10180.  
  10181. function finFiltrage(ref) {
  10182. // = Handler de fin de filtrage (filtre 'ref')
  10183. /* On réassigne le bouton 'Filtrer' */
  10184. document.getElementById('trFiltre'+ref).style.display = 'none';
  10185. var btn = document.getElementById('btnFiltre'+ref);
  10186. btn.value = 'Filtrer';
  10187. btn.onclick = function() {
  10188. debutFiltrage(ref);
  10189. };
  10190. /* Réinitialisation filtres */
  10191. document.getElementById('str'+ref).value = '';
  10192. switch(ref) {
  10193. case 'Monstres':
  10194. document.getElementById('nivMinMonstres').value = 0;
  10195. document.getElementById('nivMaxMonstres').value = 0;
  10196. document.getElementById('FamilleMonstres').value = 0;
  10197. break;
  10198. case 'Trolls':
  10199. document.getElementById('strGuildes').value = '';
  10200. }
  10201. /* Nettoyage (=lance le filtre) */
  10202. // Ici this = MZ.global = sandBox de travail de MZ
  10203. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  10204. //this['filtre'+ref]();
  10205. switch (ref) {
  10206. case 'Monstres':
  10207. filtreMonstres();
  10208. break;
  10209. case 'Trolls':
  10210. filtreTrolls();
  10211. break;
  10212. case 'Tresors':
  10213. filtreTresors();
  10214. break;
  10215. case 'Lieux':
  10216. filtreLieux();
  10217. break;
  10218. default:
  10219. window.console.log('cas incongru dans finFiltrage : ' + ref);
  10220. break;
  10221. }
  10222. }
  10223.  
  10224. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  10225. var bouton = appendButton(td,nomBouton,onClick);
  10226. appendText(td,'\u00a0');
  10227. var textbox = appendTextbox(td,'text',id,15,30);
  10228. textbox.onkeypress = function(event) {
  10229. try {
  10230. if(event.keyCode==13) {
  10231. event.preventDefault();
  10232. bouton.click();
  10233. }
  10234. }
  10235. catch(e){
  10236. window.alert(e)
  10237. }
  10238. };
  10239. }
  10240.  
  10241. function ajoutFiltreMenu(tr,id,onChange,liste) {
  10242. var select = document.createElement('select');
  10243. select.id = id;
  10244. select.onchange = onChange;
  10245. appendOption(select,0,'Aucun');
  10246. if (liste == undefined) {
  10247. for(var i=1 ; i<=60 ; i++) {
  10248. appendOption(select,i,i);
  10249. }
  10250. } else {
  10251. liste.forEach(function(f) {appendOption(select,f,f);});
  10252. }
  10253. tr.appendChild(select);
  10254. return select;
  10255. }
  10256.  
  10257. function ajoutDesFiltres() {
  10258. /* Monstres */
  10259. var td = prepareFiltrage('Monstres',130);
  10260. if(td) {
  10261. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  10262. appendText(td,'\u00a0\u00a0\u00a0');
  10263. appendText(td,'Niveau Min: ');
  10264. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  10265. appendText(td,'\u00a0');
  10266. appendText(td,'Niveau Max: ');
  10267. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  10268. appendText(td,'\u00a0');
  10269. appendText(td,'Famille: ');
  10270. comboBoxFamille = ajoutFiltreMenu(td,'FamilleMonstres',filtreMonstres,['Animal', 'Insecte','Démon','Humanoide','Monstre','Mort-Vivant']);
  10271. }
  10272. /* Trõlls */
  10273. td = prepareFiltrage('Trolls',50);
  10274. if(td) {
  10275. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  10276. appendText(td,'\u00a0\u00a0\u00a0');
  10277. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  10278. }
  10279. /* Trésors */
  10280. td = prepareFiltrage('Tresors',55);
  10281. if(td) {
  10282. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  10283. }
  10284. /* Lieux */
  10285. td = prepareFiltrage('Lieux',40);
  10286. if(td) {
  10287. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  10288. }
  10289. }
  10290.  
  10291. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  10292.  
  10293. /* [functions] Affichage de la colonne des niveaux */
  10294. function insertLevelColumn() {
  10295. // Appelé dans le code attaché à la page de vue et au click/unclick de la checkbox
  10296.  
  10297. MZ_EtatCdMs.indexCellNivMZ = MZ_EtatCdMs.indexCellID + 1; // la colonne des niveaux sera insérée après la colonne des ID
  10298. MZ_EtatCdMs.indexCellX += 1; // et ça décale les colonnes suivantes
  10299. MZ_EtatCdMs.indexCellY += 1;
  10300. MZ_EtatCdMs.indexCellN += 1;
  10301. var td = insertThText(getMonstreLevelNode(0),'Niv.',false);
  10302. //td.width = 25;
  10303.  
  10304. /* plus de colgroup le 08/07/2020. Mais comme ça pourrait revenir, je laisse le bout de code en commentaire (Roule)
  10305. var eColGroup = getMonstreLevelNode(0).closest('table').getElementsByTagName('colgroup')[0];
  10306. var eCol = document.createElement('col');
  10307. eCol.style.width= '35px';
  10308. insertBefore(eColGroup.children[3],eCol);
  10309. */
  10310.  
  10311. var monsterStyle = document.getElementById('mh_vue_hidden_monstres').getElementsByTagName('style')[0];
  10312. var sStyle = '.mh_tdborder.footable#VueMONSTRE th:nth-child(' + (MZ_EtatCdMs.indexCellDist + 1) + '), ';
  10313. sStyle += '.mh_tdborder.footable#VueMONSTRE td:nth-child(' + (MZ_EtatCdMs.indexCellDist + 1) + ') { width: 40px; text-align: right; }';
  10314. if (MZ_EtatCdMs.indexCellActions >= 0) sStyle += '.mh_tdborder.footable#VueMONSTRE th:nth-child(' + (MZ_EtatCdMs.indexCellActions + 1) + ') { width: 33px; }';
  10315. sStyle += '.mh_tdborder.footable#VueMONSTRE th:nth-child(' + (MZ_EtatCdMs.indexCellID + 1) + '), ';
  10316. sStyle += '.mh_tdborder.footable#VueMONSTRE td:nth-child(' + (MZ_EtatCdMs.indexCellID + 1) + ') { width: 50px; text-align: right; }';
  10317. sStyle += '.mh_tdborder.footable#VueMONSTRE th:nth-child(' + (MZ_EtatCdMs.indexCellNivMZ + 1) + ') { width: 35px; text-align: center; }';
  10318. sStyle += '.mh_tdborder.footable#VueMONSTRE th:nth-child(' + (MZ_EtatCdMs.indexCellX + 1) + '), ';
  10319. sStyle += '.mh_tdborder.footable#VueMONSTRE td:nth-child(' + (MZ_EtatCdMs.indexCellX + 1) + '), ';
  10320. sStyle += '.mh_tdborder.footable#VueMONSTRE th:nth-child(' + (MZ_EtatCdMs.indexCellY + 1) + '), ';
  10321. sStyle += '.mh_tdborder.footable#VueMONSTRE td:nth-child(' + (MZ_EtatCdMs.indexCellY + 1) + '), ';
  10322. sStyle += '.mh_tdborder.footable#VueMONSTRE th:nth-child(' + (MZ_EtatCdMs.indexCellN + 1) + '), ';
  10323. sStyle += '.mh_tdborder.footable#VueMONSTRE td:nth-child(' + (MZ_EtatCdMs.indexCellN + 1) + ') { width: 30px; text-align: center; }';
  10324. monsterStyle.innerHTML = sStyle;
  10325. /* version MH hors MZ avec colonne des menus contextuels (non smartphone)
  10326. .mh_tdborder.footable#VueMONSTRE th:nth-child(1),
  10327. .mh_tdborder.footable#VueMONSTRE td:nth-child(1) { width: 40px; text-align: right; }
  10328. .mh_tdborder.footable#VueMONSTRE th:nth-child(2) { width: 33px; }
  10329. .mh_tdborder.footable#VueMONSTRE th:nth-child(3) { width: 50px; }
  10330. .mh_tdborder.footable#VueMONSTRE th:nth-child(5),
  10331. .mh_tdborder.footable#VueMONSTRE td:nth-child(5),
  10332. .mh_tdborder.footable#VueMONSTRE th:nth-child(6),
  10333. .mh_tdborder.footable#VueMONSTRE td:nth-child(6),
  10334. .mh_tdborder.footable#VueMONSTRE th:nth-child(7),
  10335. .mh_tdborder.footable#VueMONSTRE td:nth-child(7) { width: 30px; text-align: center; }
  10336. */
  10337.  
  10338. td.id = 'MZ_TITRE_NIVEAU_MONSTRE';
  10339. for(var i=1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10340. //window.console.log('nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', MZ_EtatCdMs.tr_monstres.length=' + MZ_EtatCdMs.tr_monstres.length); // debug Roule
  10341. td = insertTdText(getMonstreLevelNode(i), '-');
  10342. td.style = 'font-weight:bold;text-align:center;';
  10343. }
  10344. }
  10345.  
  10346. function toggleLevelColumn() { // Appelé par le code attaché à la page de vue et au click/unclick de la checkbox NOCDM
  10347. var eltMZ_TITRE_NIVEAU_MONSTRE = document.getElementById('MZ_TITRE_NIVEAU_MONSTRE'); // test si la colonne a déjà été ajoutée
  10348. if(saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  10349. 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é
  10350. // cacher tous les td
  10351. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10352. getMonstreLevelNode(i).style.display = 'none';
  10353. }
  10354. } else {
  10355. if (!eltMZ_TITRE_NIVEAU_MONSTRE) {
  10356. insertLevelColumn();
  10357. retrieveCDMs();
  10358. } else {
  10359. // afficher tous les td
  10360. for(var i=0 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10361. getMonstreLevelNode(i).style.display = '';
  10362. }
  10363. }
  10364. }
  10365. }
  10366.  
  10367. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  10368. function basculeCDM(nom,id) {
  10369. // = Bascule l'affichage des popups CdM
  10370. if(MZ_EtatCdMs.listeCDM[id]) {
  10371. if(!document.getElementById('popupCDM'+id)) {
  10372. afficherCDM(nom, id);
  10373. } else {
  10374. cacherPopupCDM('popupCDM'+id);
  10375. }
  10376. } else {
  10377. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  10378. window.console.log("pas de CdM pour id=" + id + ', nom=' + nom);
  10379. }
  10380. }
  10381.  
  10382. function cacherPopupCDM(titre) {
  10383. var popup = document.getElementById(titre);
  10384. popup.parentNode.removeChild(popup);
  10385. }
  10386.  
  10387. function removeTableFromClickEvent() { // "this" est supposé être un <td> ou <th> d'une <table>
  10388. var table = this.parentNode.parentNode.parentNode; // <tr><tbody/thead/tfoot><table>
  10389. table.parentNode.removeChild(table);
  10390. }
  10391.  
  10392. /* DEBUG: Section à mettre à jour */
  10393. var selectionFunction;
  10394.  
  10395. function startDrag(evt) {
  10396. winCurr = this.parentNode;
  10397. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  10398. offsetX = evt.pageX - parseInt( winCurr.style.left );
  10399. offsetY = evt.pageY - parseInt( winCurr.style.top );
  10400. selectionFunction = document.body.style.MozUserSelect;
  10401. document.body.style.MozUserSelect = 'none';
  10402. winCurr.style.MozUserSelect = 'none';
  10403. return false;
  10404. }
  10405.  
  10406. function stopDrag(evt) {
  10407. winCurr.style.MozUserSelect = selectionFunction;
  10408. document.body.style.MozUserSelect = selectionFunction;
  10409. winCurr = null;
  10410. }
  10411.  
  10412. function drag(evt) {
  10413. if(winCurr==null) { return; }
  10414. evt = evt || window.event;
  10415. winCurr.style.left = (evt.pageX - offsetX)+'px';
  10416. winCurr.style.top = (evt.pageY - offsetY)+'px';
  10417. return false;
  10418. }
  10419. /* FIN DEBUG */
  10420. if(!isPage("MH_Play/Play_equipement")) {
  10421. // Conflit overlib/Tout_MZ:
  10422. // Double définition du "onmousemove" sur la page d'équipement
  10423. document.onmousemove = drag;
  10424. }
  10425.  
  10426. function afficherCDM(nom,id) {
  10427. // Crée la table de CdM du mob n° id
  10428. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10429. /* Début création table */
  10430. var table = createCDMTable(id,nom,donneesMonstre, removeTableFromClickEvent);
  10431. /* Ajout du titre avec gestion Drag & Drop */
  10432. var tr = table.firstChild;
  10433. tr.style.cursor = 'move';
  10434. tr.onmousedown = startDrag;
  10435. tr.onmouseup = stopDrag;
  10436. /* à supprimer, remplacé par un "x" sur l'entête
  10437. // Ajout du bouton "Fermer"
  10438. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  10439. tr.style.cursor = 'pointer';
  10440. tr.onmouseover = function() {
  10441. this.className = 'mh_tdpage';
  10442. };
  10443. tr.onmouseout = function() {
  10444. this.className = 'mh_tdtitre';
  10445. };
  10446. tr.idcdm = id;
  10447. tr.onclick = function() {
  10448. cacherPopupCDM('popupCDM'+this.idcdm);
  10449. this.className = 'mh_tdtitre';
  10450. };
  10451. td = appendTdText(tr,'Fermer',true);
  10452. td.colSpan = 2;
  10453. td.style = 'text-align:center;';
  10454. */
  10455. table.id = 'popupCDM'+id;
  10456. table.style.position = 'fixed';
  10457. table.style.backgroundColor = 'rgb(229, 222, 203)';
  10458. table.style.zIndex = 1;
  10459. //var topY = +(300+(30*MZ_EtatCdMs.yIndexCDM))%(30*Math.floor((window.innerHeight-400)/30));
  10460. table.style.left = +(window.innerWidth-365)+'px';
  10461. table.style.width = '300px';
  10462. /* Fin création table & Affichage */
  10463. document.body.appendChild(table);
  10464. var topY = 90 + (30*MZ_EtatCdMs.yIndexCDM);
  10465. //window.console.log('topY=' + topY + ', offsetHeight=' + table.offsetHeight + ', innerHeight=' + window.innerHeight);
  10466. if ((topY + table.offsetHeight) > window.innerHeight) {
  10467. MZ_EtatCdMs.yIndexCDM = 0; // on se repositionne en haut s'il n'y a pas assez de place
  10468. topY = 90;
  10469. } else {
  10470. MZ_EtatCdMs.yIndexCDM++; // décalage pour la fois suivante
  10471. }
  10472. table.style.top = topY + 'px';
  10473. }
  10474.  
  10475. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  10476. function showPopupError(sHTML) {
  10477. window.console.log('[MZ] affichage PopupError ' + sHTML);
  10478. var divpopup = document.createElement('div');
  10479. divpopup.id = 'divpopup';
  10480. divpopup.style =
  10481. 'position: fixed;'+
  10482. 'border: 3px solid #000000;'+
  10483. 'top: 300px;left: 10px;'+
  10484. 'background-color: red;'+
  10485. 'color: white;'+
  10486. 'font-size: xx-large;'+
  10487. 'z-index: 200;';
  10488. divpopup.innerHTML = sHTML;
  10489. var divcroix = document.createElement('div');
  10490. divcroix.style =
  10491. 'position: absolute;'+
  10492. 'top: 0;right: 0;'+
  10493. 'color: inherit;'+
  10494. 'font-size: inherit;'+
  10495. 'cursor: pointer;'+
  10496. 'z-index: 201;';
  10497. divcroix.innerHTML = "X";
  10498. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  10499. document.body.appendChild(divpopup);
  10500. divpopup.appendChild(divcroix);
  10501. }
  10502.  
  10503. function retrieveCDMs() {
  10504. // Récupère les CdM disponibles dans la BDD
  10505. // Lancé uniquement sur toggleLevelColumn
  10506. if(checkBoxLevels.checked) return;
  10507. if (MZ_EtatCdMs.nbMonstres < 1) return;
  10508.  
  10509. var tReq = [];
  10510. var nbReq = 0;
  10511. var prevLastIndexDone = MZ_EtatCdMs.lastIndexDone;
  10512. for (var i=prevLastIndexDone+1 ; i<=MZ_EtatCdMs.nbMonstres ; i++) {
  10513. //tReq.push(i + "\t" + getMonstreID(i) + "\t" + getMonstreNom(i));
  10514. // ne pas demander pour les Gowaps
  10515. var nom = getMonstreNom(i);
  10516. if (nom.match(/^[^\[]*Gowap/i)) { // le mot Gowap peut être précédé par un template (qui ne contient donc pas [)
  10517. getMonstreLevelNode(i).innerHTML = '';
  10518. continue;
  10519. }
  10520. tReq.push({'index':i, 'id':getMonstreID(i), 'nom':nom});
  10521. nbReq++;
  10522. 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
  10523. }
  10524. MZ_EtatCdMs.lastIndexDone = i;
  10525. var startAjaxCdM = new Date();
  10526. window.console.log('[MZ] ' + MZ_formatDateMS() + ' lancement AJAX ' + nbReq + ' demandes niveaux monstres V2');
  10527.  
  10528. FF_XMLHttpRequest({
  10529. method: 'POST',
  10530. url: URL_MZgetCaracMonstre,
  10531. headers : {
  10532. 'Content-type':'application/x-www-form-urlencoded'
  10533. },
  10534. //data: 'l=' + tReq.join("\n"),
  10535. data: 'l=' + JSON.stringify(tReq),
  10536. trace: 'demande niveaux monstres V2',
  10537. onload: function(responseDetails) {
  10538. try {
  10539. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  10540. if (responseDetails.status == 0) return;
  10541. //window.console.log('[MZd] ' + (+new Date) + ' ajax niv monstres début');
  10542. var texte = responseDetails.responseText;
  10543. var infos = JSON.parse(texte);
  10544. displayScriptTime(new Date().getTime()-date_debut.getTime(), 'Analyse des CdM MZ');
  10545. if(infos.length==0) return;
  10546.  
  10547. // ajouter les styles CSS pour les popup
  10548. var mystyle = document.createElement('style');
  10549. mystyle.type = 'text/css';
  10550. var sCSS = '.MZtooltip {position: relative;color:red;text-align:center;}\n';
  10551. sCSS += '.MZtooltip .MZtooltiptext {visibility: hidden;width: 250px;padding: 5px 0;border:solid 1px;position: absolute;z-index: 1;color:black;background-color:white}\n';
  10552. sCSS += '.MZtooltip:hover .MZtooltiptext {visibility: visible;}\n';
  10553. mystyle.innerHTML = sCSS;
  10554. document.getElementsByTagName('head')[0].appendChild(mystyle);
  10555.  
  10556. // if (MY_DEBUG) {
  10557. // for (var i = 0; i < 20; i++) window.console.log('infos[' + i + ']=' + JSON.stringify(infos[i]));
  10558. // }
  10559. var begin2, end2, index;
  10560. for(var j=0 ; j<infos.length ; j++) {
  10561. var info = infos[j];
  10562. if (info.index == undefined) continue;
  10563. var eTdLevel = getMonstreLevelNode(info.index)
  10564. this.className = 'mh_tdpage';
  10565. var myColor = undefined;
  10566. if (info.niv != undefined && info.niv.max == -1 && info.Mode != 'cdm') {
  10567. eTdLevel.className = "MZtooltip";
  10568. eTdLevel.style.color = "black";
  10569. eTdLevel.innerHTML = 'Var.<span class="MZtooltiptext">Ce monstre est variable.<br />On ne peut pas avoir d\'information sans CdM.</span>';
  10570. } else if (!(info && info.esq)) {
  10571. //if (MY_DEBUG) window.console.log("pas d'esquive id=" + info.id + ", index=" + info.index);
  10572. eTdLevel.className = "MZtooltip";
  10573. 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>';
  10574. } else {
  10575. eTdLevel.innerHTML = mkMinMaxHTML(info.niv);
  10576. //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
  10577. myColor = MZ_CdMColorFromMode(info);
  10578. eTdLevel.style.cursor = 'pointer';
  10579. eTdLevel.onclick = function() {
  10580. basculeCDM(
  10581. getMonstreNomByTR(this.parentNode),
  10582. getMonstreIDByTR(this.parentNode)
  10583. );
  10584. };
  10585. }
  10586. MZ_EtatCdMs.listeCDM[info.id] = info;
  10587. if (myColor) eTdLevel.style.color = myColor;
  10588. /* Roule' à étudier plus tard, cette différence de style selon la diplo...
  10589. eTdLevel.onmouseover = function() {
  10590. this.className = 'mh_tdtitre';
  10591. };
  10592. eTdLevel.onmouseout = function() {
  10593. if(this.parentNode.diploActive=='oui') {
  10594. this.className = '';
  10595. } else {
  10596. this.className = 'mh_tdpage';
  10597. }
  10598. };
  10599. */
  10600. }
  10601. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant computeMission');
  10602. computeMission(prevLastIndexDone+1, MZ_EtatCdMs.nbMonstres);
  10603. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres avant filtreMonstres');
  10604. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  10605. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' ajax niv monstres fin');
  10606. document.body.dataset.MZ_Etat = 2; // indiquer aux scripts tiers qu'on a récupéré les carac
  10607. if (document.body.MZ_Callback_fin_vue !== undefined) {
  10608. for (var iCallback = 0; iCallback < document.body.MZ_Callback_fin_vue.length; iCallback++) {
  10609. document.body.MZ_Callback_fin_vue[iCallback]();
  10610. }
  10611. }
  10612. } catch(e) {
  10613. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZgetCaracMonstre+'\n'+texte);
  10614. }
  10615. //if (MY_DEBUG) window.console.log('id=6376829, info=' + JSON.stringify(MZ_EtatCdMs.listeCDM[6376829]));
  10616. MZ_EtatCdMs.isCDMsRetrieved=true;
  10617. // afficher/supprimer le bouton pour demander la suite
  10618. var eltBoutonSuite = document.getElementById('MZ_boutonSuiteCdM');
  10619. window.console.log('[MZ] lastIndexDone=' + MZ_EtatCdMs.lastIndexDone + ', nbMonstres=' + MZ_EtatCdMs.nbMonstres + ', eltBoutonSuite=' + eltBoutonSuite);
  10620. if (MZ_EtatCdMs.lastIndexDone < MZ_EtatCdMs.nbMonstres) {
  10621. if (eltBoutonSuite) {
  10622. while (eltBoutonSuite.firstChild) eltBoutonSuite.removeChild(eltBoutonSuite.firstChild); // vider
  10623. appendText(eltBoutonSuite, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10624. retrieveCDMs(); // lancer la suite
  10625. } else {
  10626. eltBoutonSuite = document.createElement('div');
  10627. eltBoutonSuite.id = 'MZ_boutonSuiteCdM';
  10628. eltBoutonSuite.style.position = 'fixed';
  10629. eltBoutonSuite.style.border = '1px solid black';
  10630. eltBoutonSuite.style.top = '10px';
  10631. eltBoutonSuite.style.right = '10px';
  10632. //eltBoutonSuite.style.backgroundColor = 'white';
  10633. eltBoutonSuite.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/fond/fond2.jpg")';
  10634. eltBoutonSuite.style.color = 'black';
  10635. eltBoutonSuite.style.fontSize = 'large';
  10636. eltBoutonSuite.style.padding = '5px';
  10637. eltBoutonSuite.style.borderRadius = '10px';
  10638. eltBoutonSuite.style.cursor = 'pointer';
  10639. eltBoutonSuite.style.zIndex = '500';
  10640. appendText(eltBoutonSuite, nbReq + ' CdM(s) récupérées');
  10641. appendBr(eltBoutonSuite); // C'est plus classe que d'utiliser innerHTML ☺
  10642. appendText(eltBoutonSuite, 'Cliquer ici pour demander les CdMs');
  10643. appendBr(eltBoutonSuite);
  10644. appendText(eltBoutonSuite, 'des ' + MZ_EtatCdMs.nbMonstres + ' monstres');
  10645. eltBoutonSuite.title = 'Shift-Click pour faire disparaitre ce bouton sans demander les CdMs';
  10646. eltBoutonSuite.onclick = MZ_SuiteCdMs;
  10647. document.body.appendChild(eltBoutonSuite);
  10648. }
  10649. } else {
  10650. if (eltBoutonSuite) eltBoutonSuite.parentNode.removeChild(eltBoutonSuite);
  10651. }
  10652. },
  10653. });
  10654. //str = '';
  10655. //begin = i+1;
  10656. if (MY_DEBUG) window.console.log('[MZd] ' + MZ_formatDateMS() + ' requête ajax partie pour ' + tReq.length + ' monstres');
  10657. }
  10658.  
  10659. function MZ_CdMColorFromMode(info) {
  10660. switch (info.Mode) {
  10661. case 'cdm':
  10662. return 'blue';
  10663. case 'stat':
  10664. return 'purple';
  10665. case 'statV1':
  10666. return 'orange';
  10667. }
  10668. }
  10669.  
  10670. function MZ_SuiteCdMs(e) { // handler du click sur le bouton pour demander la suite des CdMs
  10671. var evt = e || window.event;
  10672. if (evt.shiftKey) {
  10673. this.parentNode.removeChild(this);
  10674. return;
  10675. }
  10676. while (this.firstChild) this.removeChild(this.firstChild); // vider
  10677. appendText(this, 'en cours ' + MZ_EtatCdMs.lastIndexDone + "/" + MZ_EtatCdMs.nbMonstres);
  10678. this.title = 'Shift-Click pour faire disparaitre ce bouton';
  10679. this.style.cursor = ''; // default
  10680. this.onclick = MZ_SupprBoutonCdMs;
  10681. retrieveCDMs();
  10682. }
  10683.  
  10684. function MZ_SupprBoutonCdMs(e) {
  10685. var evt = e || window.event;
  10686. if (evt.shiftKey) {
  10687. this.parentNode.removeChild(this);
  10688. }
  10689. }
  10690.  
  10691. function mkMinMaxHTML(oMM) {
  10692. if (oMM == undefined) return '';
  10693. if (oMM.min == undefined) {
  10694. if (oMM.max == undefined) {
  10695. return;
  10696. } else {
  10697. return "\u2A7D" + oMM.max; // U+2A7D "LESS-THAN OR SLANTED EQUAL TO"
  10698. }
  10699. } else {
  10700. if (oMM.max == undefined) {
  10701. return "\u2A7E" + oMM.min; // U+2A7E "GREATER-THAN OR SLANTED EQUAL TO"
  10702. } else if (oMM.min == oMM.max) {
  10703. return oMM.min;
  10704. } else if (oMM.min < oMM.max) {
  10705. return oMM.min + '-' + oMM.max;
  10706. } else {
  10707. return '<span style="color:red">' + oMM.min + '-' + oMM.max + '</span>';
  10708. }
  10709. }
  10710. }
  10711.  
  10712. function computeMission(begin,end) {
  10713. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  10714. //+++window.console.log('computeMission, begin=' + begin + ', end=' + end);
  10715. computeVLC(begin,end);
  10716. //+++window.console.log('computeMission, après computeVLC');
  10717. if(!begin) begin=1;
  10718. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10719. var str = MY_getValue(numTroll+'.MISSIONS');
  10720. if(!str) { return; }
  10721.  
  10722. var urlImg = URL_MZimg+'mission.png';
  10723. var obMissions = JSON.parse(str);
  10724.  
  10725. for(var i=end ; i>=begin ; i--) {
  10726. var mess = '';
  10727. var bPeutEtreIcone = false;
  10728. for(var num in obMissions) {
  10729. var mobMission = false;
  10730. var mobMissionPeutEtre = undefined;
  10731. switch(obMissions[num].type) {
  10732. case 'Race':
  10733. var race = epure(obMissions[num].race.toLowerCase());
  10734. var nom = epure(getMonstreNom(i).toLowerCase());
  10735. if(nom.indexOf(race)!=-1) {
  10736. if (race == 'crasc') {
  10737. if (nom.indexOf('medius')!=-1) {
  10738. // pas éligible
  10739. } else if (nom.indexOf('maexus')!=-1) {
  10740. // pas éligible
  10741. } else if (nom.indexOf('parasitus')!=-1) {
  10742. if (nom.match(/^crasc parasitus \[/ui)) {
  10743. // on ne peut pas savoir
  10744. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10745. + '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"';
  10746. } else {
  10747. // c'est un monstre de la race des Crasc Parasitus
  10748. mobMission = false;
  10749. }
  10750. } else {
  10751. mobMission = true;
  10752. }
  10753. } else if (race == 'crasc parasitus') {
  10754. if (nom.match(/^crasc parasitus \[/ui)) {
  10755. // on ne peut pas savoir
  10756. mobMissionPeutEtre = 'Impossible de savoir si ce monstre a comme race "Crasc" ou "Crasc Parasitus"\n'
  10757. + '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"';
  10758. } else {
  10759. // c'est un monstre de la race des Crasc Parasitus
  10760. mobMission = true;
  10761. }
  10762. } else if (race == 'shai') {
  10763. if (nom.match(/abishai/ui)) {
  10764. mobMission = false;
  10765. } else {
  10766. mobMission = true;
  10767. }
  10768. } else if (race == 'ombre') {
  10769. if (nom.match(/roche/ui)) {
  10770. mobMission = false;
  10771. } else {
  10772. mobMission = true;
  10773. }
  10774. } else if (race == 'geck\'oo') {
  10775. if (nom.match(/majestueux/ui)) {
  10776. mobMission = false;
  10777. } else {
  10778. mobMission = true;
  10779. }
  10780. } else if (race == 'bouj\'dla') {
  10781. if (nom.match(/placide/ui)) {
  10782. mobMission = false;
  10783. } else {
  10784. mobMission = true;
  10785. }
  10786. } else {
  10787. mobMission = true;
  10788. }
  10789. }
  10790. break;
  10791. case 'Niveau':
  10792. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10793. if (donneesMonstre) {
  10794. var nivMimi = Number(obMissions[num].niveau);
  10795. var mod = obMissions[num].mod; // mission nivMimi±mod si mod est numérique, sinon, c'est >= nivMimi
  10796. if (isNaN(mod)) {
  10797. var minMimi = nivMimi;
  10798. var maxMimi = nivMimi + 999999;
  10799. } else {
  10800. var minMimi = nivMimi - mod;
  10801. var maxMimi = nivMimi + mod;
  10802. }
  10803. if (donneesMonstre.niv) { // nouveau mode
  10804. if (donneesMonstre.niv.max && donneesMonstre.niv.min) {
  10805. if (donneesMonstre.niv.max <= maxMimi && donneesMonstre.niv.min >= minMimi) {
  10806. mobMission = true;
  10807. } else if (!(donneesMonstre.niv.max < minMimi || donneesMonstre.niv.min > maxMimi)) {
  10808. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10809. if (isDEV) mobMissionPeutEtre += '\nMonstre=(' + donneesMonstre.niv.min + ', ' + donneesMonstre.niv.max + '), mimi=(' + minMimi + ', ' + maxMimi + ')'
  10810. }
  10811. } else if (donneesMonstre.niv.max) {
  10812. if (donneesMonstre.niv.max >= minMimi) {
  10813. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10814. }
  10815. } else if (donneesMonstre.niv.min) {
  10816. if (donneesMonstre.niv.min <= maxMimi) {
  10817. mobMissionPeutEtre = 'Il reste à déterminer le niveau exact du monstre';
  10818. }
  10819. }
  10820. }
  10821. }
  10822. break;
  10823. case 'Famille':
  10824. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10825. if(donneesMonstre && donneesMonstre.fam) {
  10826. var familleMimi = epure(obMissions[num].famille.toLowerCase()).replace(/[']/g,''); // Roule 27/02/2019 simple quote dans les familles
  10827. var familleMob = epure(donneesMonstre.fam.toLowerCase());
  10828. if(familleMob.indexOf(familleMimi)!=-1) {
  10829. mobMission = true;
  10830. }
  10831. }
  10832. break;
  10833. case 'Pouvoir':
  10834. var donneesMonstre = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  10835. if(donneesMonstre && donneesMonstre.pouv) {
  10836. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  10837. var pvrMob = epure(donneesMonstre.pouv.toLowerCase());
  10838. if(pvrMob.indexOf(pvrMimi)!=-1) {
  10839. mobMission = true;
  10840. }
  10841. }
  10842. }
  10843. if(mobMission) {
  10844. mess += mess ? '\n\n' : '';
  10845. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  10846. } else if (mobMissionPeutEtre !== undefined) {
  10847. mess += mess ? '\n\n' : '';
  10848. mess += mobMissionPeutEtre + '\n';
  10849. bPeutEtreIcone = true;
  10850. mess += 'Mission '+ num + ' :\n'+obMissions[num].libelle;
  10851. }
  10852. }
  10853. if(mess) {
  10854. var td = getMonstreNomNode(i);
  10855. appendText(td,' ');
  10856. var myURL;
  10857. if (bPeutEtreIcone) {
  10858. myURL = URL_MZimg+'missionX.png';
  10859. } else {
  10860. myURL = urlImg;
  10861. }
  10862. td.appendChild(createImage(myURL,mess));
  10863. }
  10864. }
  10865. }
  10866.  
  10867. function computeVLC(begin,end) {
  10868. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  10869. //+++window.console.log('computeVLC, begin=' + begin + ', end=' + end);
  10870. computeTactique(begin,end);
  10871. //+++window.console.log('computeVLC, après computeTactique');
  10872. if(!begin) begin=1;
  10873. if(!end) end=MZ_EtatCdMs.nbMonstres;
  10874. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  10875. if(!cache)
  10876. return false;
  10877. var urlImg = URL_MZimg + "oeil.png";
  10878. for(var i = end; i >= begin;i--)
  10879. {
  10880. var id = getMonstreID(i);
  10881. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10882. var vlc = false;
  10883. /* ancien mode à supprimer
  10884. if(donneesMonstre && donneesMonstre.length>12)
  10885. {
  10886. if(donneesMonstre[12]==1) vlc = 1;
  10887. }
  10888. // */
  10889. // nouveau mode
  10890. if (donneesMonstre && donneesMonstre.vlc) {
  10891. //if (donneesMonstre) window.console.log('computeVLC i=' + i + ' id=' + id + ' ' + JSON.stringify(donneesMonstre));
  10892. var td = getMonstreNomNode(i);
  10893. td.appendChild(document.createTextNode(" "));
  10894. td.appendChild(createImage(urlImg, "Voit le caché"));
  10895. }
  10896. if (donneesMonstre && donneesMonstre.gen) {
  10897. switch (donneesMonstre.gen) {
  10898. case 1:
  10899. var imgPh = URL_MZimg + "Phoenix1.png";
  10900. var txtPh = 'Phœnix de première génération';
  10901. break;
  10902. case 2:
  10903. var imgPh = URL_MZimg + "Phoenix2.png";
  10904. var txtPh = 'Phœnix de deuxième génération';
  10905. break;
  10906. case 3:
  10907. var imgPh = URL_MZimg + "Phoenix3.png";
  10908. var txtPh = 'Phœnix de troisième génération';
  10909. break;
  10910. case 23:
  10911. var imgPh = URL_MZimg + "Phoenix23.png";
  10912. var txtPh = 'Phœnix de deuxième ou troisième génération';
  10913. break;
  10914. }
  10915. var td = getMonstreNomNode(i);
  10916. td.appendChild(document.createTextNode(" "));
  10917. var img = td.appendChild(createImage(imgPh, txtPh));
  10918. img.style.height = '15px';
  10919. img.style.width = 'auto';
  10920. }
  10921. }
  10922. }
  10923.  
  10924. /* appelé
  10925. par updateTactique
  10926. par initialiseInfos
  10927. par do_vue
  10928. par computeVLC
  10929. par computeMission
  10930. par filtreMonstres
  10931. par retrieveCDMs
  10932. */
  10933. function computeTactique(begin, end) {
  10934. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  10935. try {
  10936. if(!begin) begin = 1;
  10937. if(!end) end = MZ_EtatCdMs.nbMonstres;
  10938. //+++window.console.log('computeTactique, begin=' + begin + ', end=' + end + ', checkBoxTactique=' + checkBoxTactique);
  10939. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10940. //+++window.console.log('computeTactique, noTactique=' + noTactique);
  10941. if(noTactique || !isProfilActif()) return;
  10942. //+++window.console.log('computeTactique, après isProfilActif');
  10943.  
  10944. for(var j=end ; j>=begin ; j--) {
  10945. var id = getMonstreID(j);
  10946. var nom = getMonstreNom(j);
  10947. var donneesMonstre = MZ_EtatCdMs.listeCDM[id];
  10948. var bShowTactique = false;
  10949. //if (isDEV) {
  10950. if (donneesMonstre && donneesMonstre.esq) bShowTactique = true;
  10951. // } else {
  10952. // if(donneesMonstre && nom.indexOf('Gowap')==-1) bShowTactique = true;
  10953. // }
  10954. if (bShowTactique) {
  10955. var td = getMonstreNomNode(j);
  10956. appendText(td,' ');
  10957. td.appendChild(MZ_Tactique.createImage(id, nom));
  10958. }
  10959. }
  10960. }
  10961. catch(e) {
  10962. window.console.error(traceStack(e, 'computeTactique')+'\nmob num : ' + j);
  10963. }
  10964. filtreMonstres();
  10965. }
  10966.  
  10967. function updateTactique() {
  10968. // = Handler checkBox noTactique
  10969. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  10970. //+++window.console.log('updateTactique, noTactique=' + noTactique);
  10971. if(!MZ_EtatCdMs.isCDMsRetrieved) return;
  10972. //+++window.console.log('updateTactique, isCDMsRetrieved=' + MZ_EtatCdMs.isCDMsRetrieved);
  10973.  
  10974. if(noTactique) {
  10975. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  10976. var tr = getMonstreNomNode(i);
  10977. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  10978. tr, null, 9, null).singleNodeValue;
  10979. if(img) {
  10980. img.parentNode.removeChild(img.previousSibling);
  10981. img.parentNode.removeChild(img);
  10982. }
  10983. }
  10984. }
  10985. else
  10986. computeTactique();
  10987. }
  10988.  
  10989. function filtreMonstres() {
  10990. // = Handler universel pour les fonctions liées aux monstres
  10991. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  10992. urlEnchantImg = URL_MZimg+'enchant.png';
  10993.  
  10994. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  10995. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  10996. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  10997. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  10998. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  10999. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  11000. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  11001. var famille = saveComboBox(comboBoxFamille,'FAMILLEMONSTRE');
  11002. // old/new : détermine s'il faut ou non nettoyer les tr
  11003. var oldNOEM = true, noEM = true;
  11004. if(MY_getValue('NOINFOEM')!='true') {
  11005. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  11006. }
  11007. // Filtrage par nom
  11008. var eMonstre = document.getElementById('strMonstres');
  11009. if (!eMonstre) return; // cas smartphone
  11010. var strMonstre = eMonstre.value.toLowerCase();
  11011. // Génère la liste des mobs engagés (si filtrés)
  11012. if(noEngages && !isEngagesComputed) {
  11013. for(var i=nbTrolls ; i>0 ; i--) {
  11014. var pos = getTrollPosition(i);
  11015. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  11016. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  11017. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  11018. }
  11019. isEngagesComputed = true;
  11020. }
  11021.  
  11022. /*** FILTRAGE ***/
  11023. /* À computer :
  11024. * - EM (nom suffit)
  11025. * - Enchant (nom suffit)
  11026. * - Mission (nécessite CdM)
  11027. * - mob VlC (nécessite CdM)
  11028. * Sans computation :
  11029. * - Gowap ? engagé ?
  11030. */
  11031. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  11032. var pos = getMonstrePosition(i);
  11033. var nom = getMonstreNom(i).toLowerCase();
  11034. if(noEM!=oldNOEM) {
  11035. if(noEM) {
  11036. // Si noEM passe de false à true, on nettoie les td "Nom"
  11037. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  11038. var tr = getMonstreNomNode(i);
  11039. while(tr.childNodes.length>1) {
  11040. tr.removeChild(tr.childNodes[1]);
  11041. }
  11042. } else {
  11043. var tr = getMonstreNomNode(i);
  11044. var TypeMonstre=getEM(nom);
  11045. if(TypeMonstre!='') {
  11046. var infosCompo=compoMobEM(TypeMonstre);
  11047. if(infosCompo.length>0) {
  11048. tr.appendChild(document.createTextNode(' '));
  11049. tr.appendChild(createImage(urlImg, infosCompo));
  11050. }
  11051. }
  11052. }
  11053. }
  11054. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  11055. var texte = getInfoEnchantementFromMonstre(nom);
  11056. if(texte!='') {
  11057. var td = getMonstreNomNode(i);
  11058. td.appendChild(document.createTextNode(' '));
  11059. td.appendChild(createImage(urlEnchantImg, texte));
  11060. }
  11061. }
  11062.  
  11063. var dataV2 = MZ_EtatCdMs.listeCDM[getMonstreID(i)];
  11064. MZ_EtatCdMs.tr_monstres[i].style.display = (
  11065. noGowapsS &&
  11066. nom.indexOf('gowap sauvage')!=-1 &&
  11067. getMonstreDistance(i)>1
  11068. ) || (
  11069. noGowapsA &&
  11070. nom.indexOf('gowap apprivoisé')!=-1 &&
  11071. getMonstreDistance(i)>1
  11072. ) || (
  11073. noEngages &&
  11074. getMonstreDistance(i)!=0 &&
  11075. listeEngages[pos[0]] &&
  11076. listeEngages[pos[0]][pos[1]] &&
  11077. listeEngages[pos[0]][pos[1]][pos[2]]
  11078. ) || (
  11079. strMonstre!='' &&
  11080. nom.indexOf(strMonstre)==-1
  11081. ) || (
  11082. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  11083. getMonstreDistance(i)>1 &&
  11084. nom.toLowerCase().indexOf("kilamo")==-1
  11085. ) || (
  11086. famille!='0' &&
  11087. dataV2 &&
  11088. dataV2.fam &&
  11089. dataV2.fam != famille
  11090. ) ? 'none' : '';
  11091. }
  11092.  
  11093. if(MY_getValue('NOINFOEM')!='true') {
  11094. if(noEM != oldNOEM) {
  11095. if(noEM && MZ_EtatCdMs.isCDMsRetrieved) computeMission();
  11096. }
  11097. oldNOEM = noEM;
  11098. }
  11099.  
  11100. needComputeEnchantement = false;
  11101. }
  11102.  
  11103.  
  11104. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  11105.  
  11106. function filtreTrolls() {
  11107. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  11108. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  11109. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  11110. for(var i=1 ; i<=nbTrolls ; i++) {
  11111. tr_trolls[i].style.display = (
  11112. noIntangibles &&
  11113. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  11114. ) || (
  11115. strTroll!='' &&
  11116. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  11117. ) || (
  11118. strGuilde!='' &&
  11119. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  11120. ) ? 'none' : '';
  11121. }
  11122. }
  11123.  
  11124. /* [functions] Bulle PX Trolls */
  11125. var bulle;
  11126.  
  11127. function initPXTroll() {
  11128. bulle = document.createElement('div');
  11129. bulle.id = 'bulle';
  11130. bulle.className = 'mh_textbox';
  11131. bulle.style =
  11132. 'position: absolute;'+
  11133. 'border: 1px solid #000000;'+
  11134. 'visibility: hidden;'+
  11135. 'display: inline;'+
  11136. 'z-index: 2;';
  11137. document.body.appendChild(bulle);
  11138.  
  11139. for(var i=nbTrolls ; i>0 ; i--) {
  11140. var td_niv = getTrollNivNode(i);
  11141. td_niv.onmouseover = showPXTroll;
  11142. td_niv.onmouseout = hidePXTroll;
  11143. }
  11144. }
  11145.  
  11146. function showPXTroll(evt) {
  11147. var lvl = this.firstChild.nodeValue;
  11148. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  11149. bulle.style.left = evt.pageX+15+'px';
  11150. bulle.style.top = evt.pageY+'px';
  11151. bulle.style.visibility = 'visible';
  11152. }
  11153.  
  11154. function hidePXTroll() {
  11155. bulle.style.visibility = 'hidden';
  11156. }
  11157.  
  11158. /* [functions] Envoi PX / MP */
  11159. function putBoutonPXMP() {
  11160. // Bouton d'initialisation du mode Envoi
  11161. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  11162. var td = document.getElementById('tdInsertTrolls');
  11163. if(!td) { return; }
  11164. td.width = 100;
  11165. td = insertAfterTd(td);
  11166. td.style.verticalAlign = 'top';
  11167. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  11168. bouton.id = 'btnEnvoi';
  11169. }
  11170.  
  11171. function prepareEnvoi() {
  11172. // = 1er Handler du bouton d'envoi
  11173.  
  11174. /* Ajout de la colonne des CheckBoxes */
  11175. var td = insertTdText(getTrollNomNode(0),'');
  11176. td.width = 5;
  11177. for(var i=nbTrolls ; i>0 ; i--) {
  11178. td = insertTd(getTrollNomNode(i));
  11179. appendCheckBox(td,'envoi'+i);
  11180. }
  11181.  
  11182. /* Ajout du radio de choix PX ou MP */
  11183. var btnEnvoi = document.getElementById('btnEnvoi');
  11184. if(!btnEnvoi) { return; }
  11185. var tdEnvoi = btnEnvoi.parentNode;
  11186. appendText(tdEnvoi,' ');
  11187. var span = document.createElement('span');
  11188. span.style.whiteSpace = 'nowrap';
  11189. var radioElt = document.createElement('input');
  11190. radioElt.type = 'radio';
  11191. radioElt.name = 'envoiPXMP';
  11192. radioElt.id = 'radioPX';
  11193. span.appendChild(radioElt);
  11194. appendText(span,' des PX ');
  11195. radioElt = document.createElement('input');
  11196. radioElt.type = 'radio';
  11197. radioElt.name = 'envoiPXMP';
  11198. radioElt.checked = true;
  11199. span.appendChild(radioElt);
  11200. appendText(span,' un MP');
  11201. tdEnvoi.appendChild(span);
  11202.  
  11203. /* Insertion du bouton Annuler */
  11204. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  11205.  
  11206. /* Modification de l'effet du bouton Envoi */
  11207. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  11208. }
  11209.  
  11210. function annuleEnvoi() {
  11211. // = Handler bouton Annuler
  11212. /* Nettoyage du td du bouton Envoi */
  11213. var btnEnvoi = document.getElementById('btnEnvoi');
  11214. var tdEnvoi = btnEnvoi.parentNode;
  11215. while(tdEnvoi.firstChild) {
  11216. tdEnvoi.removeChild(tdEnvoi.firstChild);
  11217. }
  11218. /* Retour à l'effet de base du bouton Envoi */
  11219. btnEnvoi.onclick = prepareEnvoi;
  11220. tdEnvoi.appendChild(btnEnvoi);
  11221. /* Suppression CheckBoxes */
  11222. for(var i=nbTrolls ; i>=0 ; i--) {
  11223. var td = getTrollNomNode(i);
  11224. td.parentNode.removeChild(td);
  11225. }
  11226. }
  11227.  
  11228. function effectueEnvoi() {
  11229. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  11230. var str='';
  11231. var errID = false;
  11232. for(var i=nbTrolls ; i>0 ; i--) {
  11233. var chb = document.getElementById('envoi'+i);
  11234. if(chb.checked) {
  11235. var idTroll = getTrollID(i);
  11236. if (idTroll == undefined) {
  11237. errID = true;
  11238. } else {
  11239. str += (str ? ',' : '') + idTroll;
  11240. }
  11241. }
  11242. }
  11243. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  11244. var PXchecked = document.getElementById('radioPX').checked;
  11245. if(PXchecked) {
  11246. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  11247. } else {
  11248. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  11249. }
  11250. }
  11251.  
  11252. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  11253.  
  11254. function filtreTresors() {
  11255. // += Handler checkboxes : gg, compos, bidouilles, non libres
  11256. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  11257. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  11258. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  11259. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  11260. if(noEngages && !isEngagesComputed) {
  11261. for(var i=nbTrolls ; i>0 ; i--) {
  11262. var pos = getTrollPosition(i);
  11263. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  11264. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  11265. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  11266. }
  11267. isEngagesComputed = true;
  11268. }
  11269. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  11270. for(var i=nbTresors ; i>0 ; i--) {
  11271. var nom = getTresorNom(i);
  11272. var pos = getTresorPosition(i);
  11273. tr_tresors[i].style.display = (
  11274. noGG &&
  11275. nom.indexOf('Gigots de Gob')!=-1
  11276. ) || (
  11277. noCompos &&
  11278. nom.indexOf('Composant')!=-1
  11279. ) || (
  11280. noEngages &&
  11281. listeEngages[pos[2]] &&
  11282. listeEngages[pos[2]][pos[1]] &&
  11283. listeEngages[pos[2]][pos[1]][pos[0]] &&
  11284. getTresorDistance(i)>0
  11285. ) || (
  11286. strTresor!='' &&
  11287. nom.toLowerCase().indexOf(strTresor)==-1
  11288. ) || (
  11289. noBidouilles &&
  11290. nom.indexOf('Bidouille')!=-1
  11291. ) ? 'none' : '';
  11292. }
  11293. }
  11294.  
  11295.  
  11296. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  11297.  
  11298. function filtreLieux() {
  11299. // += Handler checkbox trous
  11300. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  11301. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  11302. for(var i=nbLieux ; i>0 ; i--) {
  11303. tr_lieux[i].style.display = (
  11304. strLieu &&
  11305. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  11306. ) || (
  11307. noTrou &&
  11308. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  11309. getLieuDistance(i)>1
  11310. ) ? 'none' : '';
  11311. }
  11312. }
  11313.  
  11314.  
  11315. /*-[functions]-------------------- Diplomatie --------------------------------*/
  11316.  
  11317. function refreshDiplo() {
  11318. MY_setValue(numTroll+'.diplo.off',
  11319. checkBoxDiplo.checked?'true':'false'
  11320. );
  11321. if(isDiploRaw) { computeDiplo(); }
  11322. appliqueDiplo();
  11323. }
  11324.  
  11325. function computeDiplo() {
  11326. // On extrait les données de couleur et on les stocke par id
  11327. // Ordre de préséance :
  11328. // source Guilde < source Perso
  11329. // guilde cible < troll cible
  11330.  
  11331. /* Diplo de Guilde */
  11332. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  11333. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  11334. if(diploGuilde && diploGuilde.isOn=='true') {
  11335. // Guilde perso
  11336. if(diploGuilde.guilde) {
  11337. Diplo.Guilde[diploGuilde.guilde.id] = {
  11338. couleur: diploGuilde.guilde.couleur,
  11339. titre: 'Ma Guilde'
  11340. };
  11341. }
  11342. // Guildes/Trolls A/E
  11343. for(var AE in {Amis:0,Ennemis:0}) {
  11344. for(var i=0 ; i<5 ; i++) {
  11345. if(diploGuilde[AE+i]) {
  11346. for(var type in {Guilde:0,Troll:0}) {
  11347. var liste = diploGuilde[AE+i][type].split(';');
  11348. for(var j=liste.length-2 ; j>=0 ; j--) {
  11349. Diplo[type][liste[j]] = {
  11350. couleur: diploGuilde[AE+i].couleur,
  11351. titre: diploGuilde[AE+i].titre
  11352. };
  11353. }
  11354. }
  11355. }
  11356. }
  11357. }
  11358. }
  11359.  
  11360. /* Diplo Perso */
  11361. //var diploPerso = MY_getValue(numTroll+'.diplo.perso') ? JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {}; // déjà chargé
  11362. if(diploPerso && diploPerso.isOn=='true') {
  11363. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  11364. for(var id in diploPerso[type]) {
  11365. Diplo[type][id] = diploPerso[type][id];
  11366. }
  11367. }
  11368. }
  11369. if(diploPerso.mythiques) {
  11370. Diplo.mythiques = diploPerso.mythiques;
  11371. }
  11372.  
  11373. isDiploRaw = false;
  11374. }
  11375.  
  11376. function appliqueDiplo() {
  11377. var aAppliquer = Diplo;
  11378. if(checkBoxDiplo.checked) {
  11379. // Pour retour à l'affichage basique sur désactivation de la diplo
  11380. aAppliquer = {
  11381. Guilde: {},
  11382. Troll: {},
  11383. Monstre: {}
  11384. };
  11385. }
  11386.  
  11387. /* On applique "aAppliquer" */
  11388. // Diplo Trõlls
  11389. for(var i=nbTrolls ; i>0 ; i--) {
  11390. var idG = getTrollGuildeID(i);
  11391. var idT = getTrollID(i);
  11392. var tr = tr_trolls[i];
  11393. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  11394. if(aAppliquer.Troll[idT]) {
  11395. tr.className = '';
  11396. var descr = aAppliquer.Troll[idT].titre;
  11397. if(descr) {
  11398. getTrollNomNode(i).title = descr
  11399. }
  11400. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  11401. } else if(aAppliquer.Guilde[idG]) {
  11402. tr.className = '';
  11403. var descr = aAppliquer.Guilde[idG].titre;
  11404. if(descr) {
  11405. getTrollNomNode(i).title = descr
  11406. }
  11407. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  11408. } else {
  11409. tr.className = 'mh_tdpage';
  11410. getTrollNomNode(i).title = '';
  11411. }
  11412. }
  11413.  
  11414. // Diplo Monstres
  11415. for(var i=MZ_EtatCdMs.nbMonstres ; i>0 ; i--) {
  11416. var id = getMonstreID(i);
  11417. var nom = getMonstreNom(i).toLowerCase();
  11418. var tr = MZ_EtatCdMs.tr_monstres[i];
  11419. if(aAppliquer.Monstre[id]) {
  11420. tr.className = '';
  11421. tr.style.backgroundColor = aAppliquer.Monstre[id].couleur;
  11422. tr.diploActive = 'oui';
  11423. var descr = aAppliquer.Monstre[id].titre;
  11424. if(descr) {
  11425. getMonstreNomNode(i).title = descr;
  11426. }
  11427. } else if(aAppliquer.mythiques &&
  11428. (nom.indexOf('liche')==0 ||
  11429. nom.indexOf('hydre')==0 ||
  11430. nom.indexOf('balrog')==0 ||
  11431. nom.indexOf('beholder')==0)) {
  11432. tr.className = '';
  11433. tr.style.backgroundColor = aAppliquer.mythiques;
  11434. tr.diploActive = 'oui';
  11435. getMonstreNomNode(i).title = 'Monstre Mythique';
  11436. } else {
  11437. tr.className = 'mh_tdpage';
  11438. tr.diploActive = '';
  11439. }
  11440. }
  11441. }
  11442.  
  11443.  
  11444. /*-[functions]---------------- Actions à distance ----------------------------*/
  11445.  
  11446. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  11447. var
  11448. monN = parseInt(getPosition()[2]),
  11449. isLdP = oussa=='self';
  11450.  
  11451. for(var type in keltypes) {
  11452. if (MY_DEBUG) {
  11453. window.console.log(
  11454. 'MZ computeActionDistante(' + dmin + ', ' + dmax + ', ' +
  11455. oussa + ', ' + urlIcon+ ', ' + message + ') type=' + type
  11456. );
  11457. }
  11458. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  11459. for(var i=VueContext['nb'+type] ; i>0 ; i--) {
  11460. var tr = VueContext['tr_'+type.toLowerCase()][i];
  11461. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  11462. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  11463. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  11464. var sonN = getXxxPosition(type, i)[2];
  11465. var d = getXxxDistance(type, i);
  11466. var thismessage = message;
  11467. if (isLdP) {
  11468. var chanceToucher = getTalent("Lancer de Potions") + Math.min(10,
  11469. 10 - 10 * d +
  11470. parseInt(MY_getValue(numTroll+".caracs.vue")) +
  11471. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11472. );
  11473. thismessage += ' (' + chanceToucher + '%)';
  11474. }
  11475.  
  11476. if(sonN==monN && d>=dmin && d<=dmax) {
  11477. var iconeAction = document.evaluate(
  11478. "./descendant::img[@alt='"+alt+"']",
  11479. tr, null, 9, null
  11480. ).singleNodeValue;
  11481. if(iconeAction) {
  11482. if(iconeAction.title) {
  11483. iconeAction.title += "\n"+thismessage;
  11484. } else {
  11485. iconeAction.title = thismessage;
  11486. }
  11487. iconeAction.src = urlIcon;
  11488. } else {
  11489. var tdAction = tr.getElementsByTagName('td')[1];
  11490. var icon = document.createElement('img');
  11491. icon.src = urlIcon;
  11492. icon.height = 20;
  11493. icon.alt = alt;
  11494. icon.title = thismessage;
  11495. tdAction.appendChild(icon);
  11496. }
  11497. }
  11498. }
  11499. }
  11500. }
  11501.  
  11502. function computeCharge() {
  11503. computeActionDistante(1,
  11504. getPortee(
  11505. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  11506. MY_getValue(numTroll+".caracs.regeneration")
  11507. ),
  11508. {'Monstres':1, 'Trolls':1},
  11509. 'Attaquer',
  11510. MHicons+'E_Metal09.png',
  11511. 'Cible à portée de Charge'
  11512. );
  11513. }
  11514.  
  11515. function computeProjo() {
  11516. computeActionDistante(0,
  11517. getPortee(
  11518. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11519. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11520. ),
  11521. {'Monstres':1, 'Trolls':1},
  11522. 'Attaquer',
  11523. MHicons+'S_Fire05.png',
  11524. 'Cible à portée de Projo'
  11525. );
  11526. }
  11527.  
  11528. function computeTelek() {
  11529. computeActionDistante(0,
  11530. Math.floor((
  11531. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11532. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11533. )/2),
  11534. {'Tresors':1},
  11535. 'Telek',
  11536. MHicons+'S_Magic04.png',
  11537. 'Trésor à portée de Télékinésie'
  11538. );
  11539. }
  11540.  
  11541. function computeLdP() {
  11542. computeActionDistante(0,
  11543. 2+Math.floor((
  11544. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  11545. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  11546. )/5),
  11547. {'Monstres':1, 'Trolls':1},
  11548. 'self',
  11549. MHicons+'P_Red01.png',
  11550. 'Cible à portée de Lancer de Potions'
  11551. );
  11552. }
  11553.  
  11554.  
  11555. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  11556.  
  11557. function putScriptExterne(sInfo) {
  11558. for (var iBricol = 1; ; iBricol++) {
  11559. var extClef = iBricol == 1 ? '' : iBricol;
  11560. var sInfo = MY_getValue(numTroll+'.INFOSIT'+extClef);
  11561. if (!sInfo) break;
  11562. putScriptExterneOneIT(sInfo);
  11563. }
  11564. }
  11565.  
  11566. function putScriptExterneOneIT(sInfo) {
  11567. if(!sInfo || sInfo=='') return;
  11568.  
  11569. var nomit = sInfo.slice(0,sInfo.indexOf('$'));
  11570. if(nomit=='bricol') {
  11571. var data = sInfo.split('$');
  11572. try {
  11573. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  11574. // appendNewScript(URL_bricol+data[1]
  11575. // +'/mz.php?login='+data[2]
  11576. // +'&password='+data[3]
  11577. // );
  11578. FF_XMLHttpRequest({
  11579. method: 'GET',
  11580. url: URL_bricol+data[1]
  11581. +'/mz_json.php?login='+encodeURIComponent(data[2])
  11582. +'&password='+data[3],
  11583. trace: 'bricolTroll',
  11584. onload: function(responseDetails) {
  11585. try {
  11586. if (responseDetails.status == 0) {
  11587. window.console.log('status=0 à l\'appel bricol\'troll');
  11588. if (isHTTPS) {
  11589. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  11590. } else {
  11591. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  11592. }
  11593. return;
  11594. }
  11595. var ratibusData;
  11596. try {
  11597. ratibusData = JSON.parse(responseDetails.responseText);
  11598. } catch(e) {}
  11599. if (ratibusData === undefined) {
  11600. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  11601. return;
  11602. }
  11603. if (ratibusData.error) {
  11604. avertissement('<br />Bricol\'Troll (' + data[1] + ') a répondu :<br />' + ratibusData.error);
  11605. } else {
  11606. putInfosTrolls(ratibusData.data.trolls, data[1]);
  11607. }
  11608. } catch(e) {
  11609. window.console.log(traceStack(e, 'retour bricol\'troll'));
  11610. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  11611. }
  11612. }
  11613. });
  11614. } catch(e) {
  11615. if (isHTTPS) {
  11616. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  11617. } else {
  11618. window.console.log(traceStack(e, 'appel bricol\'troll'));
  11619. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  11620. }
  11621. }
  11622. }
  11623. }
  11624.  
  11625. /*
  11626. * Roule 07/11/2016, on utilise mz_json qui envoie
  11627. {
  11628. "data": {
  11629. "trolls": {
  11630. "59424": {
  11631. "id": 59424,
  11632. "pv": xx,
  11633. "pv_max": xx,
  11634. "updated_at": "2016-10-31 07:28:40",
  11635. "dla": "2016-10-05 07:28:04",
  11636. "pa": 0
  11637. },
  11638. }
  11639. }
  11640. }
  11641. */
  11642.  
  11643. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  11644. function corrigeBricolTrolls(infosTrolls) {
  11645. for(var i in infosTrolls) {
  11646. var pv = infosTrolls[i][0];
  11647. var pvmax = infosTrolls[i][1];
  11648. var pvmem = MY_getValue(i+'.caracs.pv.max');
  11649. if(pvmem && pvmem>pvmax) {
  11650. infosTrolls[i][1] = pvmem;
  11651. pvmax = pvmem;
  11652. }
  11653. if(pv>pvmax) {
  11654. var newpvmax = 5*Math.ceil(pv/5);
  11655. MY_setValue(i+'.caracs.pv.max',newpvmax);
  11656. infosTrolls[i][1] = newpvmax;
  11657. }
  11658. }
  11659. }
  11660.  
  11661. // insère 2 TD avant nextTD avec les infos venant de l'IT
  11662. function addTdInfosTroll(infos, TR, itName) {
  11663. /* cadre barre PV */
  11664. var tab = document.createElement('div');
  11665. tab.title = infos.pv+'/'+infos.pv_max+' PV le '+ SQLDateToFrenchTime(infos.updated_at);
  11666. /* barre PV */
  11667. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  11668. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  11669. .vieContainer {
  11670. background-color: #CCC;
  11671. width: 50px;
  11672. height: 6px;
  11673. border: 1px solid #000;
  11674. text-align: left;
  11675. }
  11676. */
  11677. tab.style.width = '100px';
  11678. tab.style.height = '10px';
  11679. tab.style.border = '1px solid #000';
  11680. tab.style.textAlign = 'left';
  11681. var div2 = document.createElement('div');
  11682. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  11683. var dateLimite = new Date();
  11684. dateLimite.setDate(dateLimite.getDate() - 7);
  11685. if (infos.oUpdatedAt < dateLimite) {
  11686. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  11687. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  11688. } else if (pourcentVie > 66) {
  11689. div2.style.backgroundColor = '#77EE77';
  11690. } else if (pourcentVie > 33) {
  11691. div2.style.backgroundColor = '#EEEE77';
  11692. } else {
  11693. div2.style.backgroundColor = '#FF0000';
  11694. }
  11695. div2.style.width = pourcentVie + '%';
  11696. div2.style.height = '10px';
  11697. tab.appendChild(div2);
  11698. /* ancienne méthode par img, à supprimer
  11699. var img = document.createElement('img');
  11700. img.src = '../Images/Interface/milieu.gif';
  11701. img.height = 10;
  11702. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  11703. tab.appendChild(img);
  11704. */
  11705.  
  11706. if (MZ_cache_col_TrollNOM === undefined) MZ_cache_col_TrollNOM = MZ_find_col_titre(tr_trolls, 'nom');
  11707. var tdNom = TR.childNodes[MZ_cache_col_TrollNOM]
  11708. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  11709. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  11710.  
  11711. /* lien vers l'IT */
  11712. var lien = document.createElement('a');
  11713. //var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  11714. lien.href = URL_bricol+itName+'/index.php';
  11715. lien.target = '_blank';
  11716. lien.appendChild(tab);
  11717. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11718. //window.console.log('[MZd] MZ_cache_col_TrollGUILDE=' + MZ_cache_col_TrollGUILDE);
  11719. //var tdGuilde = TR.childNodes[MZ_cache_col_TrollGUILDE];
  11720. //insertTdElement(tdGuilde,lien);
  11721. TR.childNodes[MZ_cache_col_TrollGUILDE].appendChild(lien);
  11722. /* PAs dispos */
  11723. var span = document.createElement('span');
  11724. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  11725. appendText(span, infos.pa +' PA' );
  11726. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  11727. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  11728. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  11729. span.style.backgroundColor = 'B8EEB8';
  11730. }
  11731. //insertTdElement(tdGuilde, span);
  11732. TR.childNodes[MZ_cache_col_TrollGUILDE+1].appendChild(span);
  11733. }
  11734.  
  11735. var MZ_tabTrTrollById;
  11736. function putInfosTrolls(infosTrolls, itName) {
  11737. try {
  11738. if (MZ_tabTrTrollById === undefined) {
  11739. MZ_tabTrTrollById = new Array;
  11740. // ajout des 2 colonnes dans la table HTML des Trõlls + construire le tableau MZ_tabTrTrollById
  11741. if (MZ_cache_col_TrollGUILDE === undefined) MZ_cache_col_TrollGUILDE = MZ_find_col_titre(tr_trolls, 'guild');
  11742. var td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PA',true);
  11743. td.width = 40;
  11744. td = insertTdText(tr_trolls[0].childNodes[MZ_cache_col_TrollGUILDE],'PV',true);
  11745. td.width = 105;
  11746. for(i=nbTrolls ; i>0 ; i--) {
  11747. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11748. insertTd(tr_trolls[i].childNodes[MZ_cache_col_TrollGUILDE]);
  11749. MZ_tabTrTrollById[getTrollID(i)] = tr_trolls[i];
  11750. }
  11751. }
  11752.  
  11753.  
  11754. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  11755. //corrigeBricolTrolls(infosTrolls);
  11756.  
  11757. // supression des infos trop vieilles (un mois)
  11758. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  11759. var dateLimite = new Date();
  11760. dateLimite.setMonth(dateLimite.getMonth() - 1);
  11761.  
  11762. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  11763. var str = MY_getValue(numTroll+'.INFOSIT');
  11764. var bAjoutTrollInvi = false;
  11765. if (str) {
  11766. var arr = str.split('$');
  11767. bAjoutTrollInvi = arr[4]>0;
  11768. }
  11769.  
  11770.  
  11771. var tBody = tr_trolls[0].parentNode;
  11772. if (tr_trolls[1] !== undefined)
  11773. tBody = tr_trolls[1].parentNode;
  11774.  
  11775. //window.console.log('nb Troll IT : ' + IDs.length);
  11776. var pos = getPosition();
  11777.  
  11778. // mise à jour des infos dans le HTML (et ajout de ligne si nécessaire)
  11779. for (var idTroll in infosTrolls) {
  11780. var infos = infosTrolls[idTroll];
  11781. infos.oUpdatedAt = SQLDateToObject(infos.updated_at); // trop vieux
  11782. if (infos.oUpdatedAt < dateLimite) continue; // infos trop vieilles
  11783. if (idTroll == numTroll) continue; // pas nous-même
  11784. var tr;
  11785. if (idTroll in MZ_tabTrTrollById) {
  11786. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' est déjà dans la table HTML');
  11787. tr = MZ_tabTrTrollById[idTroll];
  11788. } else {
  11789. //window.console.log('[MZ] putInfosTrolls, le Troll ' + idTroll + ' doit être ajouté à la table HTML');
  11790. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  11791. // trouver où insérer ce Troll
  11792. var next = undefined;
  11793. for(var j=0 ; j<tr_trolls.length ; j++) {
  11794. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  11795. if (thisDist > distance) {
  11796. next = tr_trolls[j]
  11797. break;
  11798. }
  11799. }
  11800. if (next !== undefined) {
  11801. tr = insertTr(next,'mh_tdpage')
  11802. } else {
  11803. tr = appendTr(tBody,'mh_tdpage');
  11804. }
  11805. tr.style.color = 'orange';
  11806. var td = appendTd(tr); // distance
  11807. appendText(td, distance);
  11808. td = appendTd(tr); // actions
  11809. td = appendTd(tr); // ID
  11810. appendText(td, idTroll);
  11811. td = appendTd(tr); // Nom
  11812. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  11813. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  11814. td = appendTd(tr); // PV
  11815. td = appendTd(tr); // PA
  11816. td = appendTd(tr); // Guilde
  11817. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  11818. td = appendTd(tr); // Niveau
  11819. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  11820. td.align = 'center';
  11821. td = appendTd(tr); // Race
  11822. if (infos.race) appendText(td, infos.race);
  11823. td = appendTd(tr); // X
  11824. td.align = 'center';
  11825. if (infos.x !== undefined) appendText(td, infos.x);
  11826. td = appendTd(tr); // Y
  11827. td.align = 'center';
  11828. if (infos.y !== undefined) appendText(td, infos.y);
  11829. td = appendTd(tr); // N
  11830. td.align = 'center';
  11831. if (infos.n !== undefined) appendText(td, infos.n);
  11832. MZ_tabTrTrollById[idTroll] = tr;
  11833. }
  11834. if (!tr.done) {
  11835. addTdInfosTroll(infos, tr, itName);
  11836. tr.done = true;
  11837. }
  11838. }
  11839. } catch(e) {
  11840. avertissement('Erreur de traitement des informations Bricol\'Troll, le détail est dans la console (F12)');
  11841. window.console.error(traceStack(e, 'putInfosTrolls'));
  11842. }
  11843. }
  11844.  
  11845.  
  11846. /* Mode Tétalanvert! ---------------------------------------------------------*/
  11847.  
  11848. function calculeDistance(maPos,posArr) {
  11849. return Math.max(
  11850. Math.abs(maPos[0]-posArr[0]),
  11851. Math.abs(maPos[1]-posArr[1]),
  11852. Math.abs(maPos[2]-posArr[2])
  11853. );
  11854. }
  11855.  
  11856. function inversionCoord() {
  11857. var maPos = getPosition();
  11858. var listeOffsets = {
  11859. 'monstres':checkBoxLevels.checked?4:3,
  11860. 'trolls':6,
  11861. };
  11862. for(var type in listeOffsets) {
  11863. var trList = VueContext['tr_'+type];
  11864. var offset = listeOffsets[type];
  11865. for(var i=trList.length-1 ; i>0 ; i--) {
  11866. var oldX = parseInt(trList[i].cells[offset].textContent);
  11867. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  11868. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  11869. trList[i].cells[offset].innerHTML = oldY;
  11870. trList[i].cells[offset+1].innerHTML = oldX;
  11871. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  11872. }
  11873. }
  11874. }
  11875.  
  11876.  
  11877. /* Partie principale */
  11878. function do_vue() {
  11879. for(var type in typesAFetcher) {
  11880. fetchData(type);
  11881. }
  11882.  
  11883. // roule' 11/03/2016
  11884. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  11885. // je fais une recopie :(
  11886. MZ_EtatCdMs.tr_monstres = VueContext.tr_monstres;
  11887. for (var i = 0; i < MZ_EtatCdMs.tr_monstres[0].cells.length; i++) {// Roule 22/07/2020
  11888. if (MZ_EtatCdMs.tr_monstres[0].cells[i].innerText.match(/Dist/i)) MZ_EtatCdMs.indexCellDist = i;
  11889. if (MZ_EtatCdMs.tr_monstres[0].cells[i].innerText.match(/Action/i)) MZ_EtatCdMs.indexCellActions = i;
  11890. if (MZ_EtatCdMs.tr_monstres[0].cells[i].innerText.match(/r[eéè]f/i)) MZ_EtatCdMs.indexCellID = i;
  11891. if (MZ_EtatCdMs.tr_monstres[0].cells[i].innerText.match(/^X$/i)) MZ_EtatCdMs.indexCellX = i;
  11892. if (MZ_EtatCdMs.tr_monstres[0].cells[i].innerText.match(/^Y$/i)) MZ_EtatCdMs.indexCellY = i;
  11893. if (MZ_EtatCdMs.tr_monstres[0].cells[i].innerText.match(/^N$/i)) MZ_EtatCdMs.indexCellN = i;
  11894. }
  11895. if (MZ_EtatCdMs.indexCellDist < 0 || MZ_EtatCdMs.indexCellID < 0 || MZ_EtatCdMs.indexCellX < 0 || MZ_EtatCdMs.indexCellY < 0 || MZ_EtatCdMs.indexCellN < 0) {
  11896. avertissement('Impossible de retrouver les colonnes de la vue des monstres, arrêt MZ', 9999999);
  11897. return;
  11898. }
  11899. tr_trolls = VueContext.tr_trolls;
  11900. tr_tresors = VueContext.tr_tresors;
  11901. tr_champignons = VueContext.tr_champignons;
  11902. tr_lieux = VueContext.tr_lieux;
  11903.  
  11904. MZ_EtatCdMs.nbMonstres = VueContext.nbMonstres;
  11905. nbTrolls = VueContext.nbTrolls;
  11906. nbTresors = VueContext.nbTresors;
  11907. nbChampignons = VueContext.nbChampignons;
  11908. nbLieux = VueContext.nbLieux;
  11909.  
  11910. try {
  11911. start_script(31);
  11912.  
  11913. initialiseInfos();
  11914. savePosition();
  11915.  
  11916. // Fonctionnalité "Têtalenvert" cachée, en test :
  11917. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  11918. inversionCoord();
  11919. }
  11920.  
  11921. ajoutDesFiltres();
  11922. set2DViewSystem();
  11923. //putBoutonTroogle();
  11924. putBoutonPXMP();
  11925.  
  11926. synchroniseFiltres();
  11927. toggleLevelColumn(); // appel des CdM, ne fait rien si la checkbox NOCDM est cochée
  11928.  
  11929. refreshDiplo();
  11930.  
  11931. //400 ms
  11932. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  11933. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  11934. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  11935. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  11936. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  11937. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  11938. var noTresorsEngages =
  11939. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  11940. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  11941. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  11942. filtreMonstres();
  11943. if(noIntangibles) {
  11944. filtreTrolls();
  11945. }
  11946. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  11947. filtreTresors();
  11948. }
  11949. if(noTrou) {
  11950. filtreLieux();
  11951. }
  11952.  
  11953. MZ_Tactique.initPopup();
  11954. initPXTroll();
  11955.  
  11956. if(getTalent("Projectile Magique")) {
  11957. computeProjo();
  11958. }
  11959. if(getTalent("Charger")) {
  11960. computeCharge();
  11961. }
  11962. if(getTalent("Télékinésie")) {
  11963. computeTelek();
  11964. }
  11965. if(getTalent("Lancer de Potions")) {
  11966. computeLdP();
  11967. }
  11968.  
  11969. putScriptExterne();
  11970.  
  11971. displayScriptTime();
  11972. } catch(e) {
  11973. window.console.error(traceStack(e, 'vue'));
  11974. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite (seriez-vous sous l'effet d'un Fumeux ?).");
  11975. }
  11976. }
  11977.  
  11978.  
  11979.  
  11980. /*******************************************************************************
  11981. * This file is part of Mountyzilla. *
  11982. * *
  11983. * Mountyzilla is free software; you can redistribute it and/or modify *
  11984. * it under the terms of the GNU General Public License as published by *
  11985. * the Free Software Foundation; either version 2 of the License, or *
  11986. * (at your option) any later version. *
  11987. * *
  11988. * Mountyzilla is distributed in the hope that it will be useful, *
  11989. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11990. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11991. * GNU General Public License for more details. *
  11992. * *
  11993. * You should have received a copy of the GNU General Public License *
  11994. * along with Mountyzilla; if not, write to the Free Software *
  11995. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11996. *******************************************************************************/
  11997.  
  11998. // x~x profil2
  11999.  
  12000. /*---------------------------- Variables globales ----------------------------*/
  12001.  
  12002. var
  12003. // Anatrolliseur
  12004. urlAnatrolliseur,
  12005. // Infobulles talents
  12006. hauteur = 50, bulleStyle = null,
  12007. // Caracteristiques
  12008. // Infos troll
  12009. race, niv, idtroll, datecrea,
  12010. idguilde, nomguilde,
  12011. // Etats du troll
  12012. fatigue, bmfatigue,
  12013.  
  12014. // Experience, Pi, ...
  12015. pxdistribuables, pxperso,
  12016. piutilisable, pitotal,
  12017. nbmeurtres, nbmorts,
  12018. // utilisee pour les moyennes MM/jour, kill/jour, etc
  12019. NBjours,
  12020. // calcul des DLA suivantes
  12021. DLA, DLAsuiv, HeureServeur,
  12022. // details duree du tour (calcul pvdispo) :
  12023. dtb, pdm, bmt, adb, dpt,
  12024. //posale
  12025. posX, posY, posN,
  12026. // caracs physiques
  12027. vue, vuebp, vuebm, vuetotale,
  12028. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  12029. reg, regbp, regbm, regmoy,
  12030. att, attbp, attbm, attmoy, atttourD, atttour, attmoytour,
  12031. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  12032. deg, degbp, degbm, degmoy, degmoycrit, degtour, degmoytour, degmoycrittour,
  12033. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  12034. rm, rmbp, rmbm, rmtotale,
  12035. mm, mmbp, mmbm, mmtotale,
  12036.  
  12037. // Variables speciales Kastars
  12038. pvActuelKastar, minParPV, overDLA,
  12039. // id pour edition manuelle de lastDLA :
  12040. inJour, inMois, inAn, inHr, inMin, inSec,
  12041. // id pour auto-refresh lastDLA :
  12042. lastDLAZone, maxAMZone, cumulZone,
  12043. lastDLA, DLAaccel;
  12044.  
  12045.  
  12046. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  12047.  
  12048. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  12049. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  12050. function getUniqueValueBySelector(selector, defaultValue){
  12051. var valNode = document.querySelector(selector);
  12052. if(valNode!=null){
  12053. if(valNode.hasChildNodes()) {
  12054. return valNode.childNodes[0].nodeValue;
  12055. }else{
  12056. return defaultValue;
  12057. }
  12058. } else{
  12059. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  12060. return defaultValue;
  12061. }
  12062. }
  12063. function getUniqueStringValueBySelector(selector){
  12064. return getUniqueValueBySelector(selector,"");
  12065. }
  12066. function getUniqueIntValueBySelector(selector){
  12067. var ret = getUniqueValueBySelector(selector,0);
  12068. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  12069. ret = 0;
  12070. }
  12071. return parseInt(ret);
  12072. }
  12073. function getUniqueFloatValueBySelector(selector){
  12074. var ret = getUniqueValueBySelector(selector,0.0);
  12075. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  12076. ret = 0.0;
  12077. }
  12078. return parseFloat(ret);
  12079. }
  12080.  
  12081.  
  12082. function resiste(Ddeg,bm) {
  12083. // version naive mais compréhensible ^^
  12084. // DEBUG: à revoir
  12085. if(!bm) {
  12086. return 2*Math.floor(Ddeg/2);
  12087. }
  12088. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  12089. }
  12090.  
  12091. function retourAZero(fatig) {
  12092. var fat = fatig, raz = 0;
  12093. while(fat>0) {
  12094. raz++;
  12095. fat = Math.floor(fat/1.25);
  12096. }
  12097. return raz;
  12098. }
  12099.  
  12100. function coefDecumul(i) {
  12101. switch(i) {
  12102. case 2: return 0.67;
  12103. case 3: return 0.4;
  12104. case 4: return 0.25;
  12105. case 5: return 0.15;
  12106. default: return 0.1;
  12107. }
  12108. }
  12109.  
  12110. function dureeHM(dmin) {
  12111. var ret = "";
  12112. dmin = Math.floor(dmin);
  12113. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  12114. var mins = dmin%60;
  12115. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  12116. return (ret) ? ret : "-";
  12117. }
  12118.  
  12119. // extraction d'une durée
  12120. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "- 2 h 30 m"
  12121. // c'est protégé (rend 0 si l'élément est absent)
  12122. // Roule' 24/12/2016
  12123. function extractionDuree(selecteur) {
  12124. var s = getUniqueStringValueBySelector(selecteur);
  12125. if (!s) return 0;
  12126. var tabN = getNumbers(s);
  12127. if (tabN.length < 2) return 0;
  12128. if (s.includes('-')) {
  12129. return - tabN[0] * 60 - tabN[1];
  12130. }
  12131. return tabN[0] * 60 + tabN[1];
  12132. }
  12133.  
  12134. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  12135.  
  12136. function extractionDonnees() {
  12137. // Variables temporaires
  12138. var Nbrs = {};
  12139.  
  12140. // *********************
  12141. // Cadre "Description"
  12142. // *********************
  12143. race = getUniqueStringValueBySelector('#descr #race');
  12144. debugMZ("Race : " + race);
  12145. idtroll = getUniqueStringValueBySelector('#descr #id');
  12146. debugMZ("Id troll : " + idtroll);
  12147. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  12148. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  12149. datecrea = new Date(StringToDate(strDateCrea));
  12150. debugMZ("Date creation : " + datecrea);
  12151. // Guilde
  12152. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  12153. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  12154. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  12155.  
  12156. // *******************
  12157. // Cadre "Experience"
  12158. // *******************
  12159. // Niveau de troll
  12160. niv = getUniqueIntValueBySelector('#exp #niv');
  12161. nivTroll = niv;
  12162. debugMZ("Niveau : " + niv);
  12163. // PX
  12164. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  12165. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  12166. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  12167. // PI
  12168. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  12169. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  12170. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  12171. // Meutres/Morts
  12172. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  12173. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  12174. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  12175.  
  12176. // *********************
  12177. // Cadre "Tour de Jeu"
  12178. // *********************
  12179. // DLA
  12180. Nbrs['dla'] = getUniqueStringValueBySelector('#dla #dla>b');
  12181. DLA = new Date(StringToDate(Nbrs['dla']));
  12182. debugMZ('DLA: ' + DLA);
  12183. // DLA suivante
  12184. Nbrs['dlasuiv'] = getUniqueStringValueBySelector('#dla #dla_next');
  12185. DLAsuiv = new Date(StringToDate(Nbrs['dlasuiv']));
  12186. debugMZ('DLAsuiv: ' + DLAsuiv);
  12187. // Duree normale de mon Tour
  12188. dtb = extractionDuree('#dla #tour');
  12189. debugMZ('Duree normale de mon Tour : ' + dtb);
  12190. // Réserve
  12191. dtreserve = extractionDuree('#dla #reserve');
  12192. debugMZ('Durée de réserve : ' + dtreserve);
  12193. // Poids de l'equipement
  12194. pdm = extractionDuree('#dla #poids');
  12195. debugMZ('Poids de l\'equipement : ' + pdm);
  12196. // Bonus/Malus equipemente
  12197. bmt = extractionDuree('#dla #bmequipement'); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  12198. debugMZ('Bonus/Malus sur la duree : ' + bmt);
  12199. // Augmentation due aux blessures
  12200. adb = extractionDuree('#dla #blessure');
  12201. debugMZ('Augmentation due aux blessures : ' + adb);
  12202. // Mouches
  12203. bmmouche = extractionDuree('#dla #mouche');
  12204. debugMZ('Bonus des mouches : ' + bmmouche);
  12205. // Duree de mon prochain Tour
  12206. dpt = extractionDuree('#dla #duree>b');
  12207. debugMZ('Duree de mon prochain Tour : ' + dpt);
  12208.  
  12209. // ****************
  12210. // Cadre "Etats"
  12211. // ****************
  12212. // Position du troll :
  12213. posX = getUniqueIntValueBySelector('#pos #x');
  12214. posY = getUniqueIntValueBySelector('#pos #y');
  12215. posN = getUniqueIntValueBySelector('#pos #n');
  12216. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  12217. // PV actuel
  12218. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  12219. pvActuelKastar = pvcourant;
  12220. debugMZ("PV actuel : " + pvcourant)
  12221. // Fatigue
  12222. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  12223. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  12224. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  12225.  
  12226. // **************************
  12227. // Cadre "Caracteristiques"
  12228. // **************************
  12229. // Attaque
  12230. att = getUniqueIntValueBySelector('#carac #att');
  12231. attbp = getUniqueIntValueBySelector('#carac #att_p');
  12232. attbm = getUniqueIntValueBySelector('#carac #att_m');
  12233. atttour = getUniqueIntValueBySelector('#carac #att_tour'); // % bonus AdA
  12234. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d'); // malus Parade
  12235. attmoy = 3.5*att + attbp + attbm;
  12236. var DAttBonus = Math.floor(((att+atttourD)*atttour/100)); // À vérifier
  12237. attmoytour = 3.5*(att+DAttBonus) + attbp + attbm;
  12238. debugMZ(
  12239. "ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+
  12240. "; BM Dé att/tour:("+atttourD+"D;"+atttour+"%) "+(atttourD+DAttBonus)+
  12241. "D ;AttMoyTour:"+attmoytour
  12242. );
  12243. // Esquive
  12244. esq = getUniqueIntValueBySelector('#carac #esq');
  12245. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  12246. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  12247. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  12248. esqmoy = 3.5*esq + esqbp+esqbm;
  12249. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  12250. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  12251. // Degat
  12252. deg = getUniqueIntValueBySelector('#carac #deg');
  12253. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  12254. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  12255. degtour = getUniqueIntValueBySelector('#carac #deg_tour'); // % bonus AdD
  12256. degmoy = 2*deg + degbp + degbm;
  12257. degmoycrit = 2*(deg+Math.floor(deg/2)) + degbp + degbm;
  12258. var DDegBonus = Math.floor(deg*degtour/100);
  12259. degmoytour = 2*(deg + DDegBonus) + degbp + degbm;
  12260. degmoycrittour = degmoytour + 2*Math.floor(deg/2);
  12261. debugMZ(
  12262. "DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+
  12263. " ;deg/tour:("+degtour+"%) "+DDegBonus+
  12264. "D; DegMoyTour:"+degmoytour+"/"+degmoycrittour
  12265. );
  12266. // PV
  12267. pvbase = getUniqueIntValueBySelector('#carac #pv');
  12268. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  12269. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  12270. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  12271. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  12272. // Regeneration
  12273. reg = getUniqueIntValueBySelector('#carac #reg');
  12274. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  12275. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  12276. regmoy = 2 * reg + regbp + regbm; // D3
  12277. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  12278. // Armure
  12279. arm = getUniqueIntValueBySelector('#carac #arm');
  12280. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  12281. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  12282. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  12283. armmoy = 2*arm + armbp+armbm;
  12284. armmoytour = 2*Math.max(arm+armtourD, 0) + armbp+armbm;
  12285. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  12286. // TODO : D d'armure non active
  12287. // Vue
  12288. vue = getUniqueIntValueBySelector('#carac #vue');
  12289. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  12290. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  12291. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  12292. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  12293. // RM
  12294. rm = getUniqueIntValueBySelector('#carac #rm');
  12295. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  12296. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  12297. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  12298. rmTroll = rmtotale;
  12299. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  12300. // MM
  12301. mm = getUniqueIntValueBySelector('#carac #mm');
  12302. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  12303. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  12304. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  12305. mmTroll = mmtotale;
  12306. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  12307.  
  12308. // Heure Serveur
  12309. try {
  12310. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  12311. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  12312. HeureServeur = new Date(StringToDate(heureServeurSTR));
  12313. } catch (e) {
  12314. window.console.warn(
  12315. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  12316. );
  12317. HeureServeur = new Date();
  12318. }
  12319. debugMZ("HeureServeur: " + HeureServeur);
  12320.  
  12321. // ***INIT GLOBALE*** NBjours
  12322. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  12323.  
  12324. // Calcul debut lien anatroliseur avec les caracteristiques connues
  12325. var amelio_dtb = function(dtb) {
  12326. if(dtb>555) {
  12327. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  12328. }
  12329. return 10+Math.ceil((555-dtb)/2.5);
  12330. },
  12331. amelio_pv = Math.floor(pvbase/10)-3,
  12332. amelio_vue = vue-3,
  12333. amelio_att = att-3,
  12334. amelio_esq = esq-3,
  12335. amelio_deg = deg-3,
  12336. amelio_reg = reg-1,
  12337. amelio_arm = arm-1;
  12338. if(race==="Darkling"){amelio_reg--; }
  12339. if(race==="Durakuir"){amelio_pv-- ; }
  12340. if(race==="Kastar") {amelio_deg--; }
  12341. if(race==="Skrim") {amelio_att--; }
  12342. if(race==="Tomawak") {amelio_vue--; }
  12343.  
  12344. urlAnatrolliseur = URL_AnatrolDispas
  12345. +"outils_anatrolliseur.php?anatrolliseur=v8"
  12346. +"|r="+race.toLowerCase()
  12347. +"|dla="+amelio_dtb(dtb)
  12348. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  12349. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  12350. +"|att="+amelio_att+","+attbp+","+attbm
  12351. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  12352. +"|deg="+amelio_deg+","+degbp+","+degbm
  12353. +"|reg="+amelio_reg+","+regbp+","+regbm
  12354. +"|arm="+amelio_arm+","+armbp+","+armbm
  12355. +"|mm="+mmtotale
  12356. +"|rm="+rmtotale+"|";
  12357. }
  12358.  
  12359. function saveProfil() {
  12360. MY_setValue(idtroll+'.caracs.attaque',att);
  12361. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  12362. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  12363. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  12364. if(atttourD||atttour) {
  12365. var DAttBonus = atttourD + Math.floor((att+atttourD)*atttour/100);
  12366. MY_setValue(idtroll+'.bonus.DAttM',DAttBonus);
  12367. } else {
  12368. MY_removeValue(idtroll+'.bonus.DAttM');
  12369. }
  12370. MY_setValue(idtroll+'.caracs.esquive',esq);
  12371. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  12372. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  12373. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  12374. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  12375. MY_setValue(idtroll+'.caracs.degats',deg);
  12376. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  12377. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  12378. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  12379. if(degtour) {
  12380. var DDegBonus = Math.floor(deg*degtour/100);
  12381. MY_setValue(idtroll+'.bonus.DDeg',DDegBonus);
  12382. } else {
  12383. MY_removeValue(idtroll+'.bonus.DDeg');
  12384. }
  12385. MY_setValue(idtroll+'.caracs.regeneration',reg);
  12386. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  12387. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  12388. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  12389. MY_setValue(idtroll+'.caracs.vue',vue);
  12390. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  12391. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  12392. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  12393. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  12394. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  12395. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  12396. MY_setValue(idtroll+'.caracs.rm',rm);
  12397. MY_setValue(idtroll+'.caracs.rm.bm',(rmtotale));
  12398. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  12399. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  12400. MY_setValue(idtroll+'.caracs.mm',mm);
  12401. MY_setValue(idtroll+'.caracs.mm.bm',(mmtotale));
  12402. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  12403. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  12404. MY_setValue(idtroll+'.caracs.armure',arm);
  12405. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  12406. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  12407. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  12408. MY_setValue(idtroll+'.position.X',posX);
  12409. MY_setValue(idtroll+'.position.Y',posY);
  12410. MY_setValue(idtroll+'.position.N',posN);
  12411. MY_setValue(idtroll+'.race',race);
  12412. MY_setValue(idtroll+'.niveau',niv);
  12413. MY_setValue(idtroll+'.idguilde',idguilde);
  12414. MY_setValue(idtroll+'.nomguilde',nomguilde);
  12415. }
  12416.  
  12417.  
  12418. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  12419.  
  12420. function setInfosCaracteristiques() {
  12421. // Modification de l'entete
  12422. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  12423. thTotal.innerHTML+='|<i>Moyenne</i>';
  12424. thTotal.title="Moyenne (Moyenne ce tour)";
  12425.  
  12426. // Ajout des informations calculees
  12427. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  12428. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  12429. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  12430.  
  12431. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  12432. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  12433. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  12434.  
  12435. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  12436. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  12437. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  12438.  
  12439. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  12440. var tdRegTotal = trRegeneration.children[5];
  12441. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  12442. // Temps recupere par reg (propale R')
  12443. var regmoyTemp = Math.max(0, regmoy);
  12444. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  12445. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  12446. if (sec != 0) {
  12447. regTitle += " " + sec + " sec";
  12448. }
  12449. trRegeneration.title = regTitle;
  12450.  
  12451. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  12452. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  12453. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  12454.  
  12455. var trRM=document.querySelector("table#caracs #rm").parentElement;
  12456. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  12457. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  12458.  
  12459.  
  12460. var trMM=document.querySelector("table#caracs #mm").parentElement;
  12461. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  12462. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  12463.  
  12464. var tdRefl=document.querySelector("#refl");
  12465. // TODO : prendre en compte bonus/malus D esq du tour ?
  12466. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + esqbp + esqbm;
  12467. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  12468. }
  12469.  
  12470. function setLienAnatrolliseur(){
  12471. var pTableAmelio = document.querySelector("#carac>div>p");
  12472. if (!pTableAmelio) pTableAmelio = document.querySelector("#carac>div>div>p");
  12473. if (!pTableAmelio) return;
  12474. pTableAmelio.appendChild(document.createTextNode(' - '));
  12475. var aElt = document.createElement("a");
  12476. aElt.setAttribute("href",urlAnatrolliseur);
  12477. aElt.setAttribute("target","_blank");
  12478. aElt.className="AllLinks";
  12479. aElt.innerHTML="Anatrolliser";
  12480. pTableAmelio.appendChild(aElt);
  12481. }
  12482. function setInfoDescription() {
  12483. var txtDateCrea = (NBjours!=1) ?
  12484. " ("+NBjours+" jours dans le hall)" :
  12485. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  12486. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  12487. }
  12488.  
  12489. function setInfosEtatLieux() {
  12490. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  12491. '?search=position&orderBy=distance&posx='+
  12492. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  12493. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  12494. appendBr(tdPosition);
  12495. var aElt = document.createElement("a");
  12496. aElt.setAttribute("href",urlBricol);
  12497. aElt.setAttribute("target","_blank");
  12498. aElt.className="AllLinks";
  12499. aElt.innerHTML="Lieux à proximité";
  12500. tdPosition.appendChild(aElt);
  12501. }
  12502.  
  12503. function setInfosEtatPV() { // pour AM et Sacro
  12504. var
  12505. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  12506. sec = Math.floor(15000/pvtotal)%60,
  12507. lifebar = document.querySelector("#pos .barre-vie");
  12508. if(sec!=0) { txt += " "+sec+" sec"; }
  12509. if(lifebar) { lifebar.title = txt; }
  12510. if(pvcourant<=0) { return; }
  12511.  
  12512. // Difference PV p/r a equilibre de temps (propale R')
  12513. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(dtreserve + pdm + bmt + bmmouche))
  12514. // ***INIT GLOBALE*** pvdispo
  12515. var bmPVHorsBlessure = dtreserve + pdm + bmt + bmmouche;
  12516. var pvdispo = pvcourant-pvtotal-Math.ceil(bmPVHorsBlessure*pvtotal/250);
  12517. var span = document.createElement("span");
  12518. span.title = txt;
  12519. span.style.fontStyle = "italic";
  12520. if(bmPVHorsBlessure>=0) {
  12521. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  12522. } else if(pvdispo>0) {
  12523. txt = "Vous pouvez encore perdre "+
  12524. Math.min(pvdispo,pvcourant)+
  12525. " PV sans malus de temps.";
  12526. } else if(pvdispo<0) {
  12527. txt = "Il vous manque "
  12528. +(-pvdispo)
  12529. +" PV pour ne plus avoir de malus de temps.";
  12530. } else {
  12531. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  12532. }
  12533. appendText(span,txt);
  12534. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  12535. }
  12536.  
  12537. // Complete le cadre "Experience"
  12538. function setInfosExp() {
  12539. var tdNiv = document.querySelector("#exp #niv");
  12540.  
  12541. // Calcul niveau monstre/troll min pour gain PX
  12542. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  12543. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  12544.  
  12545. // Calcul PX restant
  12546. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  12547. if (pxRestant >= 0) {
  12548. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  12549. if (tdinfoEntrainement) tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  12550. }
  12551.  
  12552. // Calul pi/jour
  12553. var
  12554. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  12555. tdPi = document.querySelector("#exp #pi").parentElement;
  12556. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  12557. tdPi.title = tdPiTotal.title;
  12558.  
  12559. // Rapports meurtres,morts
  12560. var tdKill = document.querySelector("#exp #kill");
  12561. tdKill.setAttribute("colspan", 1);
  12562. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  12563.  
  12564. var tdMort = document.querySelector("#exp #mort");
  12565. tdMort.setAttribute("colspan", 1);
  12566. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  12567.  
  12568. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  12569. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  12570. }
  12571.  
  12572.  
  12573. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  12574.  
  12575. function minParPVsac(fat,bm) {
  12576. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  12577. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  12578. var out = [];
  12579. out[0] = (fat>4) ?
  12580. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  12581. 30;
  12582. if(bm && bm>0) {
  12583. var totalfat=fat+bm;
  12584. out[1] = (totalfat>4) ?
  12585. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  12586. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  12587. }
  12588. return out;
  12589. }
  12590.  
  12591. function toInt(str) {
  12592. str = parseInt(str);
  12593. return (str) ? str : 0;
  12594. }
  12595.  
  12596. function saveLastDLA() {
  12597. // pour les calculs d'AM max
  12598. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  12599. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  12600. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  12601. lastDLA = new Date( StringToDate(str) );
  12602. MY_setValue(numTroll+'.DLA.ancienne',str);
  12603. lastDLAZone.innerHTML = '';
  12604. var b = document.createElement('b');
  12605. b.addEventListener('click',inputMode,false);
  12606. appendText(b,str);
  12607. lastDLAZone.appendChild(b);
  12608. refreshAccel();
  12609. }
  12610.  
  12611. function inputMode() {
  12612. // Edition manuelle lastDLA
  12613. var date;
  12614. if(lastDLA)
  12615. date = new Date( lastDLA );
  12616. else
  12617. date = new Date( DLAaccel );
  12618. lastDLAZone.innerHTML = '';
  12619. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  12620. appendText(lastDLAZone,'/');
  12621. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  12622. appendText(lastDLAZone,'/');
  12623. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  12624. appendText(lastDLAZone,' - ');
  12625. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  12626. appendText(lastDLAZone,':');
  12627. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  12628. appendText(lastDLAZone,':');
  12629. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  12630. appendText(lastDLAZone,' - ');
  12631. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  12632. }
  12633.  
  12634. function setAccel() {
  12635. var
  12636. BMfrais=false,
  12637. fat=fatigue, listeBmFat=[],
  12638. tr, th, insertPt;
  12639.  
  12640. // Creation ligne speciale pour AM dans le cadre "Etat"
  12641. tr = document.createElement('tr');
  12642. th = document.createElement('th');
  12643. appendText(th,'Fatigue et AM',true);
  12644. tr.appendChild(th);
  12645. insertPt = document.createElement('td');
  12646. tr.appendChild(insertPt);
  12647. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  12648.  
  12649. // Est-on en over-DLA ?
  12650. // ***INIT GLOBALE*** overDLA
  12651. overDLA = (HeureServeur>DLA.getTime()+3e5);
  12652. if(overDLA) {
  12653. fat=Math.floor(fatigue/1.25);
  12654. }
  12655.  
  12656. // Gestion des BM de fatigue
  12657. if(bmfatigue>0) {
  12658. if (MY_DEBUG) window.console.log('MZE setAccel, bmfatigue=' + bmfatigue + ', ' + numTroll+'.bm.fatigue=' + MY_getValue(numTroll+'.bm.fatigue'));
  12659. // On tente de recuperer les BM de fatigue de la page des BM
  12660. if(MY_getValue(numTroll+'.bm.fatigue')) {
  12661. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  12662. BMmemoire.pop();
  12663. var tour = 0;
  12664. for(var i=0 ; i<BMmemoire.length ; i++) {
  12665. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  12666. while(tour<=parseInt(nbrs[0])) {
  12667. listeBmFat[tour]=parseInt(nbrs[1]);
  12668. tour++;
  12669. }
  12670. }
  12671. }
  12672. if(listeBmFat[0]==bmfatigue) {
  12673. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  12674. BMfrais = true;
  12675. // Roule 17/06/2020 je ne vois pas du tout pourquoi on viderait xxx;bm.fatigue ici. Et ça fait que la fatigue des Kastars affiche une erreur la 2e fois qu'on va sur le profil... J'enlève
  12676. //MY_removeValue(numTroll+".bm.fatigue");
  12677. }
  12678. } else {
  12679. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  12680. BMfrais = true;
  12681. }
  12682. if(!BMfrais && bmfatigue>0) {
  12683. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  12684. if(bmfatigue==15) {
  12685. listeBmFat = [15,15,15];
  12686. } else {
  12687. listeBmFat = [30,30,15];
  12688. }
  12689. }
  12690. if(overDLA) {
  12691. // Si on est en over-DLA, on decale les bm d'un tour
  12692. listeBmFat.shift();
  12693. }
  12694.  
  12695. // Tableau des fatigues et accel futures
  12696. var
  12697. minppv = minParPVsac(fat,listeBmFat[0]),
  12698. table, tbody,
  12699. ligneTour, ligneFat, ligneMin,
  12700. col;
  12701. // ***INIT GLOBALE*** minParPV
  12702. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  12703. if(fat>0 || listeBmFat[0]>0) {
  12704. table = document.createElement('table');
  12705. table.className = 'mh_tdborder';
  12706. table.border = 0;
  12707. table.cellSpacing = 1;
  12708. table.cellPadding = 1;
  12709. table.style.textAlign = "center";
  12710. tbody = document.createElement('tbody');
  12711. table.appendChild(tbody);
  12712. insertPt.appendChild(table);
  12713.  
  12714. ligneTour = appendTr(tbody,'mh_tdtitre');
  12715. ligneTour.style.fontWeight = "bold";
  12716. var td = appendTdText(ligneTour,'Tour :',true);
  12717. td.align = 'left';
  12718. ligneFat = appendTr(tbody,'mh_tdpage');
  12719. td = appendTdText(ligneFat,'Fatigue :',true);
  12720. td.className = 'mh_tdtitre';
  12721. td.align = 'left';
  12722. ligneMin = appendTr(tbody,'mh_tdpage');
  12723. td = appendTdText(ligneMin,'1 PV =',true);
  12724. td.className = 'mh_tdtitre';
  12725. td.align = 'left';
  12726. col=0;
  12727. while(col<9 && (fat>0 || listeBmFat[col])) {
  12728. if(col==0) {
  12729. if(overDLA) {
  12730. var i = document.createElement('i');
  12731. appendText(i,'A activer');
  12732. ligneTour.appendChild(i);
  12733. } else {
  12734. appendTdText(ligneTour,'En cours');
  12735. }
  12736. } else {
  12737. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12738. }
  12739. if(listeBmFat[col]) {
  12740. if(BMfrais || (!overDLA && col==0)) {
  12741. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  12742. appendTdText(ligneMin,minppv[1]+'\'');
  12743. } else {
  12744. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  12745. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  12746. }
  12747. } else {
  12748. appendTdText(ligneFat,fat);
  12749. appendTdText(ligneMin,minppv[0]+'\'');
  12750. }
  12751. col++;
  12752. fat = Math.floor(fat / 1.25);
  12753. minppv = minParPVsac(fat,listeBmFat[col]);
  12754. }
  12755. if(fat>1 || (fat==1 && !overDLA)) {
  12756. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  12757. appendTdText(ligneFat,'-');
  12758. appendTdText(ligneMin,'-');
  12759. }
  12760. col = (overDLA) ?
  12761. Math.max(retourAZero(fatigue)-1,col) :
  12762. Math.max(retourAZero(fatigue),col);
  12763. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  12764. appendTdText(ligneFat,'0');
  12765. appendTdText(ligneMin,'30\'');
  12766.  
  12767. if(!BMfrais && bmfatigue) {
  12768. // si les BM n'ont pas ete rafraichis, on signale:
  12769. appendText(
  12770. insertPt,
  12771. '/!\\ Visitez la page des Bonus/Malus '+
  12772. 'pour mettre à jour votre fatigue. /!\\',
  12773. true
  12774. );
  12775. appendBr(insertPt);
  12776. }
  12777. appendBr(insertPt);
  12778. }
  12779.  
  12780. if(pvcourant<=0) {
  12781. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  12782. return;
  12783. }
  12784.  
  12785. if(fatigue>30) {
  12786. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  12787. return;
  12788. }
  12789.  
  12790. // Setup lastDLAZone
  12791. if(overDLA) {
  12792. // bypass des infos de "menu_FF.js" en cas d'overDLA
  12793. DLAaccel = new Date( DLAsuiv );
  12794. lastDLA = new Date( DLA );
  12795. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  12796. // ***INIT GLOBALE*** pvActuelKastar
  12797. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  12798. appendText(
  12799. insertPt,
  12800. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  12801. true
  12802. );
  12803. appendBr(insertPt);
  12804. } else {
  12805. DLAaccel = new Date( DLA );
  12806. pvActuelKastar = pvcourant;
  12807. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  12808. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  12809. } else {
  12810. lastDLA = false;
  12811. }
  12812. }
  12813. appendText(insertPt,'Dernière DLA enregistrée : ');
  12814. lastDLAZone = document.createElement('span');
  12815. lastDLAZone.style.cursor = 'pointer';
  12816. var b = document.createElement('b');
  12817. b.onclick = inputMode;
  12818. lastDLAZone.appendChild(b);
  12819. insertPt.appendChild(lastDLAZone);
  12820. if(lastDLA) {
  12821. appendText(b,DateToString(lastDLA));
  12822. } else {
  12823. appendText(b,'aucune');
  12824. }
  12825. appendBr(insertPt);
  12826.  
  12827. // Setup maxAMZone et cumulZone
  12828. appendText(insertPt,'Accélération maximale possible : ');
  12829. maxAMZone = document.createElement('b');
  12830. insertPt.appendChild(maxAMZone);
  12831. appendBr(insertPt);
  12832. cumulZone = document.createElement('span');
  12833. insertPt.appendChild(cumulZone);
  12834.  
  12835. refreshAccel();
  12836. }
  12837.  
  12838. function refreshAccel() {
  12839. var pvs, pvsmax;
  12840.  
  12841. // Acceleration pour cumul instantane
  12842. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  12843. if(lastDLA) {
  12844. pvsmax = Math.min(
  12845. pvActuelKastar-1,
  12846. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  12847. );
  12848. maxAMZone.innerHTML = pvsmax+" PV";
  12849. } else {
  12850. pvsmax = pvActuelKastar-1;
  12851. maxAMZone.innerHTML = "inconnue";
  12852. }
  12853.  
  12854. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  12855. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  12856. cumulZone.innerHTML = '';
  12857. if(pvs<=pvsmax) {
  12858. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  12859. appendText(cumulZone,pvs+' PV', true);
  12860. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  12861. if(pvs!=1) {
  12862. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  12863. -(pvs-1)*60*minParPV;
  12864. appendText(
  12865. cumulZone,
  12866. ' ('+(pvs-1)+' PV dans '+
  12867. Math.floor(gainSec/60)+'min'+
  12868. addZero(gainSec%60)+'s)'
  12869. );
  12870. }
  12871. } else {
  12872. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  12873. appendText(
  12874. cumulZone,
  12875. 'Après votre accélération maximale, il vous faudra encore attendre '+
  12876. dureeHM(avantDLA/6e4)+
  12877. ' avant de réactiver.'
  12878. );
  12879. }
  12880. }
  12881.  
  12882.  
  12883. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  12884.  
  12885. function traitementTalents() {
  12886. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  12887. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  12888. removeAllTalents();
  12889. var totalComp = injecteInfosBulles(trCompetence,'competences');
  12890. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  12891. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  12892. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  12893. }
  12894.  
  12895. function injecteInfosBulles(liste,fonction) {
  12896. var totalpc = 0;
  12897. // on parse la liste des talents du type 'fonction'
  12898. for(var i=0 ; i<liste.length ; i++) {
  12899. var
  12900. trTalent=liste[i],
  12901. node=trTalent.cells[1].querySelector('a'),
  12902. nomTalent=epure(trim(node.textContent)),
  12903. indiceTDniveaux=7,
  12904. indiceTDSousCompetence=2,
  12905. sousCompetences=undefined;
  12906. if(fonction=="competences"){
  12907. // un TD en plus pour des information complementaire liees a la comp
  12908. indiceTDniveaux++;
  12909. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  12910. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  12911. for (var j=0; j < sousCompetences.length; j++) {
  12912. sousCompetences[j] = sousCompetences[j].epure().trim();
  12913. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  12914. }
  12915. }
  12916. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  12917. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  12918. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  12919. totalpc += niveauxMaitrisesTalentArray[1];
  12920.  
  12921. // stockage des niveaux inferieurs du talent si presents
  12922. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  12923. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  12924. totalpc+=niveauxMaitrisesTalentArray[j+1];
  12925. }
  12926. }
  12927. return totalpc;
  12928. }
  12929.  
  12930. function setInfos(node,nom,fonction,niveau) {
  12931. node.nom = nom;
  12932. node.fonction = fonction;
  12933. node.niveau = niveau;
  12934. node.onmouseover = setBulle;
  12935. node.onmouseout = cacherBulle;
  12936. }
  12937.  
  12938. var arrayModifAnatroll = {
  12939. 'Glue':'Glu',
  12940. 'PuM':'PuiM',
  12941. 'HE':'Hurlement',
  12942. //'Insultes':'Insu',
  12943. 'Pistage':'Pist',
  12944. 'PuC':'Planter',
  12945. 'Golemo':'Golem',
  12946. }
  12947.  
  12948. function setTalent(nom,pc,niveau,sousCompetences) {
  12949. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  12950. // (et pas les % dont osf) ne serait pas plus rentable
  12951. var nomEnBase = arrayTalents[epure(nom)];
  12952. if(!nomEnBase) {
  12953. debugMZ("setTalent: le talent "+nom+" n'est pas dans la base MZ");
  12954. return;
  12955. }
  12956. if(!niveau) { niveau = 1; }
  12957.  
  12958. switch(nomEnBase) {
  12959. case 'Insultes':
  12960. urlAnatrolliseur += 'Insu'+niveau+'|';
  12961. case 'IdT':
  12962. nomEnBase += niveau;
  12963. break;
  12964. case 'Piege':
  12965. for (var i=0 ; i < sousCompetences.length ; i++) {
  12966. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  12967. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  12968. }
  12969. break;
  12970. case 'AP':
  12971. case 'Baroufle':
  12972. case 'CdB':
  12973. case 'CdM':
  12974. case 'Parer':
  12975. case 'Retraite':
  12976. case 'RB':
  12977. case 'SInterposer':
  12978. nomEnBase += niveau;
  12979. default:
  12980. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  12981. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  12982. }
  12983. //debugMZ("setTalent: nom=" + nom + ", pc=" + pc + ", niveau=" + niveau + ", sousCompetences=" + JSON.stringify(sousCompetences) + "=>setValue(" + numTroll+'.talent.'+nomEnBase+", " + pc + ")");
  12984. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  12985. }
  12986.  
  12987. function creerBulleVide() {
  12988. var table = document.createElement('table');
  12989. table.id = 'bulle';
  12990. table.className = 'mh_tdborder';
  12991. table.width = 300;
  12992. table.border = 0;
  12993. table.cellPadding = 5;
  12994. table.cellSpacing = 1;
  12995. table.style =
  12996. 'position:absolute;'
  12997. +'visibility:hidden;'
  12998. +'z-index:800;'
  12999. +'height:auto;';
  13000. var tr = appendTr(table,'mh_tdtitre');
  13001. appendTdText(tr,'Titre');
  13002. tr = appendTr(table,'mh_tdpage');
  13003. appendTdText(tr,'Contenu');
  13004. var aList = document.getElementsByTagName('a');
  13005. aList[aList.length-1].parentNode.appendChild(table);
  13006. return table;
  13007. }
  13008.  
  13009. function cacherBulle() {
  13010. if(bulleStyle)
  13011. bulleStyle.visibility = 'hidden';
  13012. }
  13013.  
  13014. function setBulle(evt) {
  13015. var nom = this.nom;
  13016. var fonction = this.fonction;
  13017. var niveau = parseInt(this.niveau);
  13018. var str='';
  13019. if(fonction=='competences'){
  13020. str=competences(nom,niveau);
  13021. } else if(fonction=='sortileges') {
  13022. str=sortileges(nom);
  13023. } else if (fonction == '*') { // pour les raccourcis de la frame de gauche : on ne sait pas si c'est compétence ou sort
  13024. str=competences(nom,niveau);
  13025. if (str == '') str=sortileges(nom);
  13026. }
  13027. if(str=='') {
  13028. if (MY_DEBUG) window.console.log('MZ setBulle, pas de description sur ' + nom);
  13029. return;
  13030. }
  13031. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  13032.  
  13033. var xfenetre, yfenetre, xpage, ypage, element = null;
  13034. var offset = 15;
  13035. var bulleWidth = 300;
  13036. if(!hauteur) hauteur = 50;
  13037. element = document.getElementById('bulle');
  13038. if (!element) element = creerBulleVide();
  13039. xfenetre = evt.clientX;
  13040. yfenetre = evt.clientY;
  13041. xpage = xfenetre;
  13042. ypage = yfenetre;
  13043. if(evt.pageX) xpage = evt.pageX;
  13044. if(evt.pageY) ypage = evt.pageY;
  13045. if(element) {
  13046. bulleStyle = element.style;
  13047. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  13048. element.childNodes[1].firstChild.innerHTML = str;
  13049. }
  13050. if(bulleStyle) {
  13051. if(xfenetre>bulleWidth+offset)
  13052. xpage -= bulleWidth+offset;
  13053. else
  13054. xpage += offset;
  13055. if(yfenetre>hauteur+offset)
  13056. ypage -= hauteur + offset;
  13057. bulleStyle.width = bulleWidth;
  13058. bulleStyle.left = xpage + 'px';
  13059. bulleStyle.top = ypage + 'px';
  13060. bulleStyle.visibility = 'visible';
  13061. }
  13062. }
  13063.  
  13064.  
  13065. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  13066.  
  13067. function competences(comp,niveau) {
  13068. var
  13069. modA = atttour?Math.floor((att+atttourD)*atttour/100):0,
  13070. modD = degtour?Math.floor(deg*degtour/100):0,
  13071. texte = "";
  13072.  
  13073. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  13074. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  13075. if(minParPV>1) texte += 's';
  13076. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  13077. } else if(comp.indexOf("Attaque Precise")!=-1) {
  13078. var
  13079. i, pc,
  13080. lastmax=0,
  13081. jetatt, espatt=0,
  13082. notMaxedOut = false;
  13083.  
  13084. for(i=niveau ; i>0 ; i--) {
  13085. pc = getTalent(comp,i);
  13086. if(lastmax!=0 && pc<=lastmax) {
  13087. // Si %AP(i)<%AP(i+1), on passe AP(i)
  13088. continue;
  13089. }
  13090. jetatt = Math.round(3.5*(
  13091. Math.min(Math.floor(1.5*att), att+3*i) + modA
  13092. )) + attbp+attbm;
  13093. espatt += (pc-lastmax)*jetatt;
  13094. texte += "Attaque niv. "+i +
  13095. " ("+(pc-lastmax)+"%) : <b>" +
  13096. Math.min(Math.floor(att*1.5), att+3*i)+"</b> D6 ";
  13097. if(modA) {
  13098. texte += "<i>"+aff(modA)+"D6</i> ";
  13099. }
  13100. texte += aff(attbp+attbm)+" => <b>"+jetatt+"</b><br>";
  13101. lastmax = pc;
  13102. if(i<niveau) {
  13103. // Si l'un des % de niveau inf est > % nivmax,
  13104. // on affiche l'espérance à la fin
  13105. notMaxedOut = true;
  13106. }
  13107. }
  13108. if(notMaxedOut) {
  13109. texte += "<i>Attaque moyenne (si réussite) : <b>" +
  13110. Math.floor(10*espatt/lastmax)/10+"</b></i><br>";
  13111. }
  13112. texte += "Dégâts : <b>"+deg+"</b> D3 ";
  13113. if(modD) {
  13114. texte += "<i>"+aff(modD)+"D3</i> ";
  13115. }
  13116. texte += aff(degbp+degbm) +
  13117. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  13118. } else if(comp.indexOf("Balayage")!=-1) {
  13119. texte = "Déstabilisation : <b>"+att+"</b> D6 ";
  13120. if(modA) {
  13121. texte += "<i>"+aff(modA)+"D6</i> ";
  13122. }
  13123. texte += aff(attbp+attbm) +
  13124. " => <b>"+attmoytour+"</b><br>" +
  13125. "Effet : <b>Met à terre l'adversaire</b>";
  13126. } else if(comp.indexOf('Bidouille')!=-1)
  13127. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  13128. +'de votre inventaire avec le texte de votre choix.';
  13129. else if(comp.indexOf('Baroufle')!=-1){
  13130. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  13131. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  13132. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  13133. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  13134. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  13135. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  13136. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  13137. '<tr class="mh_tdpage"><td>Ghimighimighimi</td><td>Impacte le baroufleur</td></tr>' +
  13138. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  13139. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  13140. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  13141. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  13142. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  13143. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  13144. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  13145. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  13146. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  13147. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  13148. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  13149. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  13150. '</tbody></table>';
  13151. } else if(comp.indexOf("Botte Secrete")!=-1) {
  13152. modA = atttour?Math.floor(Math.floor(2*att/3)*atttour/100):0;
  13153. modD = degtour?Math.floor(Math.floor(att/2)*degtour/100):0;
  13154. texte = "Attaque : <b>"+Math.floor(2*att/3)+"</b> D6 ";
  13155. if(modA) {
  13156. texte += "<i>"+aff(modA)+"D6</i> ";
  13157. }
  13158. texte += aff(Math.floor((attbp+attbm)/2)) +
  13159. " => <b>"+Math.round(
  13160. 3.5*(Math.floor(2*att/3)+modA)+Math.floor((attbp+attbm)/2)
  13161. )+"</b><br/>Dégâts : <b>"+Math.floor(att/2)+"</b> D3 ";
  13162. if(modD) {
  13163. texte += "<i>"+aff(modD)+"D3</i> ";
  13164. }
  13165. texte += aff(Math.floor((degbp+degbm)/2))+" => <b>" +
  13166. (2*(Math.floor(att/2)+modD)+Math.floor((degbp+degbm)/2)) +
  13167. "/"+(
  13168. 2*(Math.floor(1.5*Math.floor(att/2))+modD) +
  13169. Math.floor((degbp+degbm)/2)
  13170. )+"</b>";
  13171. } else if(comp.indexOf('Camouflage')!=-1) {
  13172. var camou = getTalent('Camouflage');
  13173. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  13174. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  13175. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  13176. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  13177. } else if(comp.indexOf("Charger")!=-1) {
  13178. if(pvcourant<=0) {
  13179. // N'est plus censé se produire : activation obligatoire si mort
  13180. return "<i>On ne peut charger personne quand on est mort !</i>";
  13181. }
  13182. var portee = Math.min(
  13183. Math.max(
  13184. getPortee(reg+Math.floor(pvcourant/10)) -
  13185. Math.floor((fatigue+bmfatigue)/5),
  13186. 1
  13187. ),
  13188. vuetotale
  13189. );
  13190. if(portee<1) {
  13191. return "<b>Impossible de charger</b>";
  13192. }
  13193. texte = "Attaque : <b>"+att+"</b> D6 ";
  13194. if(modA) {
  13195. texte += "<i>"+aff(modA)+"D6</i> ";
  13196. }
  13197. texte += aff(attbp+attbm) +
  13198. " => <b>"+attmoytour+"</b><br>" +
  13199. "Dégâts : <b>"+deg+"</b> D3 ";
  13200. if(modD) {
  13201. texte += "<i>"+aff(modD)+"D3</i> ";
  13202. }
  13203. texte += aff(degbp+degbm) +
  13204. " => <b>"+degmoytour+"/"+degmoycrittour+"</b><br>" +
  13205. "Portée : <b>"+portee+"</b> case";
  13206. if(portee>1) { texte += "s"; }
  13207. } else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  13208. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  13209. if(vuetotale>1) texte += 's';
  13210. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  13211. if(vuetotale>2) texte += 's';
  13212. }
  13213. else if(comp.indexOf('Piege')!=-1) {
  13214. texte = 'Piège à Glue :<ul><li>Et si vous colliez vos adversaires au sol ?</li></ul>';
  13215. texte += 'Piège à Feu: <ul><li>À moins que vous ne préfériez les envoyer en l\'air !</li>';
  13216. texte += '<li>Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  13217. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b></li></ul>';
  13218. } else if(comp.indexOf("Contre-Attaquer")!=-1) {
  13219. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  13220. texte = "Attaque : <b>"+Math.floor(att/2)+"</b> D6 ";
  13221. if(modA) {
  13222. texte += "<i>"+aff(modA)+"D6</i> ";
  13223. }
  13224. texte += aff(Math.floor((attbp+attbm)/2)) +
  13225. " => <b>"+Math.round(
  13226. 3.5*(Math.floor(att/2)+modA)+Math.floor((attbp+attbm)/2)
  13227. )+"</b><br>" +
  13228. "Dégâts : <b>"+deg+"</b> D3 ";
  13229. if(modD) {
  13230. texte += "<i>"+aff(modD)+"D3</i> ";
  13231. }
  13232. texte += aff(degbp+degbm) +
  13233. " => <b>"+degmoytour+"/"+degmoycrittour+"</b>";
  13234. } else if(comp.indexOf("Coup de Butoir")!=-1) {
  13235. var
  13236. i, pc,
  13237. lastmax=0,
  13238. jetdeg, espdeg=0,
  13239. notMaxedOut = false;
  13240.  
  13241. texte = "Attaque : <b>"+att+"</b> D6 ";
  13242. if(modA) {
  13243. texte += "<i>"+aff(modA)+"D6</i> ";
  13244. }
  13245. texte += aff(attbp+attbm) +
  13246. " => <b>"+attmoytour+"</b>";
  13247. for(i=niveau ; i>0 ; i--) {
  13248. pc = getTalent(comp,i);
  13249. if(lastmax!=0 && pc<=lastmax) {
  13250. // Si %CdB(i)<%CdB(i+1), on passe CdB(i)
  13251. continue;
  13252. }
  13253. jetdeg = 2*(
  13254. Math.min(Math.floor(1.5*deg), deg+3*i) + modD
  13255. ) + degbp+degbm;
  13256. espdeg += (pc-lastmax)*jetdeg;
  13257. texte += "<br>Dégâts niv. "+i+" ("+(pc-lastmax)+"%) : <b>" +
  13258. Math.min(Math.floor(deg*1.5),deg+3*i)+"</b> D3 ";
  13259. if(modD) {
  13260. texte += "<i>"+aff(modD)+"D3</i> ";
  13261. }
  13262. texte += aff(degbp+degbm) +
  13263. " => <b>"+jetdeg +
  13264. "/"+(jetdeg+2*Math.floor(deg/2))+"</b>";
  13265. lastmax = pc;
  13266. if(i<niveau) {
  13267. // Si l'un des % de niveau inf est > % nivmax,
  13268. // on affiche l'espérance à la fin
  13269. notMaxedOut = true;
  13270. }
  13271. }
  13272. if(notMaxedOut) {
  13273. texte += "<br><i>Dégâts moyens (si réussite) : <b>" +
  13274. Math.floor(10*espdeg/lastmax)/10+"/" +
  13275. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2)) +
  13276. "</b></i>";
  13277. }
  13278. } else if(comp.indexOf('Course')!=-1)
  13279. texte = 'Déplacement gratuit : <b>'
  13280. +Math.floor(getTalent('Course')/2)
  13281. +' %</b> de chance';
  13282. else if(comp.indexOf('Deplacement Eclair')!=-1)
  13283. texte = 'Permet d\'économiser <b>1</b> PA '
  13284. +'par rapport au déplacement classique';
  13285. else if(comp.indexOf('Dressage')!=-1)
  13286. texte = 'Le dressage permet d\'apprivoiser un Gowap redevenu sauvage, un Mouch\'oo Sauvage '
  13287. +'ou un Gnu Sauvage. La portée est de une case.';
  13288. else if(comp.indexOf('Ecriture Magique')!=-1)
  13289. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  13290. +'la formule nécessite de réunir les composants de cette formule, '
  13291. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  13292. +'un champignon adéquat pour confectionner l\'encre.';
  13293. else if(comp.indexOf('Frenesie')!=-1) {
  13294. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  13295. +' => <b>'+attmoy+'</b><br/>'
  13296. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  13297. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  13298. }
  13299. else if(comp.indexOf('Golem')!=-1)
  13300. texte = 'Animez votre golem en assemblant divers matériaux '
  13301. +'autour d\'un cerveau minéral.'
  13302. else if(comp.indexOf('Grattage')!=-1) {
  13303. texte = 'Permet de confectionner un Parchemin Vierge '
  13304. +'à partir de composants et de Gigots de Gob\'.';
  13305. }
  13306. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  13307. texte = 'Fait fuir un monstre si tout se passe bien.'
  13308. +'<br/>Lui donne de gros bonus sinon...';
  13309. else if(comp.indexOf('Identification des Champignons')!=-1) {
  13310. texte = 'Portée horizontale : <b>'+Math.floor(vuetotale/2)+'</b> case';
  13311. if(vuetotale>2) texte += 's';
  13312. texte += '<br/>Portée verticale : <b>'+Math.floor(vuetotale/4)+'</b> case';
  13313. if(vuetotale>4) texte += 's';
  13314. }
  13315. else if(comp.indexOf('Insultes')!=-1)
  13316. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  13317. else if(comp.indexOf('interposer')!=-1)
  13318. texte = 'Jet de réflexe : <b>'
  13319. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  13320. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  13321. else if(comp.indexOf('Lancer de Potions') != -1)
  13322. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  13323. else if(comp.indexOf('Marquage')!=-1)
  13324. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  13325. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  13326. +'se trouver dans la même caverne que le monstre pour le marquer.';
  13327. else if(comp.indexOf('Melange Magique')!=-1)
  13328. texte = 'Cette Compétence permet de combiner deux Potions pour '
  13329. +'en réaliser une nouvelle dont l\'effet est la somme '
  13330. +'des effets des potions initiales.';
  13331. else if(comp.indexOf('Travail de la Pierre')!=-1)
  13332. texte = 'Miner :<ul><li>Portée horizontale (officieuse) : <b>'
  13333. +2*vuetotale+'</b> cases</li>'
  13334. +'<li>Portée verticale (officieuse) : <b>'
  13335. +2*Math.ceil(vuetotale/2)+'</b> cases</li></ul>'
  13336. +'Tailler: <ul><li>Permet d\'augmenter sensiblement la valeur marchande de certains '
  13337. +'minerais. Mais cette opération délicate n\'est pas sans risques...</li></ul>';
  13338. else if(comp.indexOf('Necromancie')!=-1)
  13339. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  13340. +'de faire "revivre" ce monstre.';
  13341. else if(comp.indexOf('Painthure de Guerre')!=-1)
  13342. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  13343. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  13344. +'pour s\'inspirer, et laissez parler votre créativité.'
  13345. else if(comp.indexOf("Parer")!=-1) {
  13346. modA = atttour?Math.floor(Math.floor(att/2)*atttour/100):0;
  13347. texte = "Jet de parade : <b>"+Math.floor(att/2)+"</b> D6 ";
  13348. if(modA) {
  13349. texte += "<i>"+aff(modA)+"D6</i> ";
  13350. }
  13351. texte += aff(Math.floor((attbp+attbm)/2)) +
  13352. " => <b>"+Math.round(
  13353. 3.5*(Math.floor(att/2)+modA) +
  13354. Math.floor((attbp+attbm)/2)
  13355. )+"</b><hr>Equivalent esquive : <b>" +
  13356. (Math.floor(att/2)+esq)+"</b> D6 ";
  13357. if(modA) {
  13358. texte += "<i>"+aff(modA)+"D6</i> ";
  13359. }
  13360. texte += aff(Math.floor((attbp+attbm)/2)+esqbp+esqbm) +
  13361. " => <b>"+(Math.round(
  13362. 3.5*(Math.floor(att/2)+modA+esq) +
  13363. Math.floor((attbp+attbm)/2)
  13364. )+esqbp+esqbm)+"</b></i>";
  13365. } else if(comp.indexOf('Pistage')!=-1)
  13366. texte = 'Portée horizontale : <b>'
  13367. +2*vuetotale+'</b> cases<br/>'
  13368. +'Portée verticale : <b>'
  13369. +2*Math.ceil(vuetotale/2)+'</b> cases';
  13370. else if(comp.indexOf('Planter un Champignon')!=-1)
  13371. texte = 'Planter un Champignon est une compétence qui vous permet de '
  13372. +'créer des colonies d\'une variété donnée de champignon à partir de '
  13373. +'quelques exemplaires préalablement enterrés.';
  13374. else if(comp.indexOf('Regeneration Accrue')!=-1)
  13375. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  13376. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  13377. else if(comp.indexOf('Reparation')!=-1)
  13378. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  13379. +'et réparez vous-même votre matériel !';
  13380. else if(comp.indexOf('Retraite')!=-1)
  13381. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  13382. +'préférable de préparer un repli stratégique pour déconcerter '
  13383. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  13384. +'Quelle intelligence démoniaque.';
  13385. else if(comp.indexOf("RotoBaffe")!=-1) {
  13386. var
  13387. Datt = att, vattbm = attbp+attbm,
  13388. Ddeg = deg, vdegbm = degbp+degbm;
  13389. for(var i=1 ; i<niveau+2 ; i++) {
  13390. texte += "<b>Attaque n°"+i+" :</b><br>" +
  13391. "Attaque : <b>"+Datt+"</b> D6 ";
  13392. if(modA) {
  13393. texte += "<i>"+aff(modA)+"D6</i> ";
  13394. }
  13395. texte += aff(vattbm) +
  13396. " => <b>"+(Math.round(3.5*(Datt+modA))+vattbm)+"</b><br>" +
  13397. "Dégâts : <b>"+Ddeg+"</b> D3 ";
  13398. if(modD) {
  13399. texte += "<i>"+aff(modD)+"D3</i> ";
  13400. }
  13401. texte += aff(vdegbm) +
  13402. " => <b>"+(2*(Ddeg+modD)+vdegbm) +
  13403. "/"+(2*(Math.floor(1.5*Ddeg)+modD)+vdegbm)+"</b>";
  13404. Datt = Math.floor(0.75*Datt);
  13405. modA = atttour?Math.floor((Datt+atttourD)*atttour/100):0;
  13406. vattbm = Math.floor(0.75*vattbm);
  13407. Ddeg = Math.floor(0.75*Ddeg);
  13408. modD = degtour?Math.floor(Ddeg*degtour/100):0;
  13409. vdegbm = Math.floor(0.75*vdegbm);
  13410. if(i<niveau+1) { texte += "<hr>"; }
  13411. }
  13412. } else if(comp.indexOf('Shamaner')!=-1)
  13413. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  13414. +'des monstres en utilisant des champignons (de 1 à 3).';
  13415. return texte;
  13416. }
  13417.  
  13418. function sortileges(sort) {
  13419. sort = sort.toLowerCase();
  13420. var
  13421. // Fonctions utiles uniquement à "sortileges"
  13422. decumul_buff = function(nom,str,buff) {
  13423. // Décumul des sorts de buff (old school)
  13424. var
  13425. txt = "1<sup>ere</sup>"+nom+" : <b>"+str+" +"+buff+"</b>",
  13426. dec = buff,
  13427. total = buff,
  13428. i=1;
  13429. while(i<6) {
  13430. i++;
  13431. dec = Math.floor(coefDecumul(i)*buff);
  13432. if(dec<=1 || i==6) break;
  13433. total += dec;
  13434. txt += "<br/><i>"+i+"<sup>e</sup> "+nom+" : "+
  13435. str+" +"+dec+" (+"+total+")</i>";
  13436. }
  13437. txt += "<br/><i>"+i+"<sup>e</sup> et + : "+str+" +"+dec+"</i>";
  13438. return txt;
  13439. },
  13440. nbrAdX = function(pc) {
  13441. // Détermine le nombre d'AdX actifs à partir du % de D
  13442. switch(Number(pc)) {
  13443. case 0 : return 0;
  13444. case 20: return 1;
  13445. case 33: return 2;
  13446. case 41: return 3;
  13447. case 46: return 4;
  13448. default: return Math.floor((Number(pc)-39)/2);
  13449. }
  13450. },
  13451. decumulPc = function(n) {
  13452. // Détermine le % de D décumulé du n-ième AdX
  13453. switch(Number(n)) {
  13454. case 0: return 0;
  13455. case 1: return 20;
  13456. case 2: return 13;
  13457. case 3: return 8;
  13458. case 4: return 5;
  13459. case 5: return 3;
  13460. default: return 2;
  13461. }
  13462. },
  13463. decumulFixe = function(bm, n) {
  13464. // Détermine le bonus fixe décumulé du n-ième AdX
  13465. switch(Number(n)) {
  13466. case 0: return 0;
  13467. case 1: return Math.max(1,bm);
  13468. case 2: return Math.max(1,Math.round(bm*6.7)/10);
  13469. case 3: return Math.max(1,Math.round(bm*4)/10);
  13470. default: return 1; // Sous les 1 de moyenne même en D6
  13471. }
  13472. },
  13473. texte = "";
  13474.  
  13475. if (sort.indexOf('analyse anatomique') != -1) {
  13476. texte = 'Portée horizontale : <b>'
  13477. + Math.floor(vuetotale / 2) + '</b> case';
  13478. if (vuetotale > 3){ texte += 's'; }
  13479. texte += '<br/>Portée verticale : <b>'
  13480. + Math.floor((vuetotale+1)/4)+'</b> case';
  13481. if (vuetotale > 7){ texte += 's'; }
  13482. } else if (sort.indexOf('armure etheree') != -1) {
  13483. texte = decumul_buff('AE', 'Armure magique', reg);
  13484. } else if (sort.indexOf("augmentation")!=-1 && sort.indexOf("attaque")!=-1) {
  13485. var
  13486. categoriesAdA = {
  13487. "attx1": {
  13488. // Affichage: code MZ (cf arrayTalents)
  13489. "AN": true,
  13490. "AP": "AP1",
  13491. "Balayage": "Balayage",
  13492. "Charge": "Charger",
  13493. "CdB": "CdB1",
  13494. "Frénésie": "Frenesie",
  13495. "RB": "RB1",
  13496. "GdS": "GdS",
  13497. "Siphon": "Siphon"
  13498. },
  13499. "attx2/3": {
  13500. "Botte Secrète": "BS"
  13501. },
  13502. "attx1/2": {
  13503. "CA": "CA",
  13504. "Parer": "Parer1"
  13505. },
  13506. "degx2/3": {
  13507. "Vampirisme": "Vampi"
  13508. },
  13509. "vuex1": {
  13510. "Projectile Magique": "Projo"
  13511. }
  13512. },
  13513. baseAdA = {
  13514. "attx1" : att,
  13515. "attx2/3": Math.floor(2*att/3),
  13516. "attx1/2": Math.floor(att/2),
  13517. "degx2/3": Math.floor(2*deg/3),
  13518. "vuex1" : vue
  13519. },
  13520. pc = atttour,
  13521. pcInit = pc,
  13522. nbrAdA = nbrAdX(pc),
  13523. categorie, talent, newTalent,
  13524. i, DSup, fixe=0;
  13525.  
  13526. i=nbrAdA;
  13527. while(i++<nbrAdA+3) {
  13528. pc += decumulPc(i);
  13529. fixe += decumulFixe(3.5,i);
  13530. if(texte) { texte += "<hr>"; }
  13531. texte += "<b>"+i+"<sup>e</sup> AdA : " +
  13532. aff(pc)+"% de Dés d'attaque :</b><br>";
  13533. for(categorie in categoriesAdA) {
  13534. // On génére la liste: "talent1, talent2"
  13535. DSup = Math.floor(baseAdA[categorie]*pc/100) -
  13536. Math.floor(baseAdA[categorie]*pcInit/100);
  13537. newTalent = false;
  13538. for(var talent in categoriesAdA[categorie]) {
  13539. if(getTalent(categoriesAdA[categorie][talent])) {
  13540. if(newTalent) { texte += ", "; }
  13541. texte += talent;
  13542. newTalent = true;
  13543. }
  13544. }
  13545. if(newTalent) {
  13546. // Si le trõll a au moins un talent dans la catégorie :
  13547. texte += ": <b>+"+DSup+"D6 +"+Math.floor(fixe)+"</b> <i>(+" +
  13548. Math.floor(3.5*DSup+fixe) +")</i><br>";
  13549. }
  13550. }
  13551. }
  13552. } else if (sort.indexOf('augmentation') != -1 && sort.indexOf('esquive') != -1) {
  13553. texte = decumul_buff('AdE', 'Esquive', Math.floor((esq-1)/2));
  13554. } else if (sort.indexOf("augmentation des degats")!=-1) {
  13555. var
  13556. categoriesAdD = {
  13557. "attx1/2": {
  13558. "Botte Secrète": "BS"
  13559. },
  13560. "degx1": {
  13561. "AN": true,
  13562. "AP": "AP1",
  13563. "Charge": "Charger",
  13564. "CA": "CA",
  13565. "CdB": "CdB1",
  13566. "Frénésie": "Frenesie",
  13567. "RB": "RB1",
  13568. "Rafale": "Rafale",
  13569. "Vampi": "Vampi"
  13570. },
  13571. "degx1/2": {
  13572. "Griffe du Sorcier": "GdS"
  13573. },
  13574. "vuex1/2": {
  13575. "Projectile Magique": "Projo"
  13576. },
  13577. "regx1": {
  13578. "Siphon des Âmes": "Siphon"
  13579. }
  13580. },
  13581. baseAdD = {
  13582. "attx1/2": Math.floor(att/2),
  13583. "degx1" : deg,
  13584. "degx1/2": Math.floor(deg/2),
  13585. "vuex1/2": Math.floor(vue/2),
  13586. "regx1" : reg
  13587. },
  13588. pc = degtour,
  13589. pcInit = pc,
  13590. nbrAdD = nbrAdX(pc),
  13591. categorie, talent, newTalent,
  13592. i, DSup, fixe=0;
  13593.  
  13594. i=nbrAdD;
  13595. while(i++<nbrAdD+3) {
  13596. pc += decumulPc(i);
  13597. fixe += decumulFixe(2,i);
  13598. if(texte) { texte += "<hr>"; }
  13599. texte += "<b>"+i+"<sup>e</sup> AdD : " +
  13600. aff(pc)+"% de Dés de dégâts :</b><br>";
  13601. for(categorie in categoriesAdD) {
  13602. // On génére la liste: "talent1, talent2"
  13603. DSup = Math.floor(baseAdD[categorie]*pc/100) -
  13604. Math.floor(baseAdD[categorie]*pcInit/100);
  13605. newTalent = false;
  13606. for(var talent in categoriesAdD[categorie]) {
  13607. if(getTalent(categoriesAdD[categorie][talent])) {
  13608. if(newTalent) { texte += ", "; }
  13609. texte += talent;
  13610. newTalent = true;
  13611. }
  13612. }
  13613. if(newTalent) {
  13614. // Si le trõll a au moins un talent dans la catégorie :
  13615. texte += ": <b>+"+DSup+"D3 +"+Math.floor(fixe) +
  13616. "</b> <i>(+"+Math.floor(2*DSup+fixe) +
  13617. ")</i><br>";
  13618. }
  13619. }
  13620. }
  13621. } else if(sort.indexOf('bulle anti-magie')!=-1) {
  13622. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  13623. }
  13624. else if(sort.indexOf('bulle magique')!=-1){
  13625. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  13626. }
  13627. else if(sort.indexOf('explosion')!=-1){
  13628. texte = 'Dégâts : <b>'
  13629. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  13630. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  13631. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  13632. }
  13633. else if(sort.indexOf('faiblesse passagere')!=-1){
  13634. if(pvcourant<=0)
  13635. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  13636. texte = 'Portée horizontale : <b>'
  13637. +Math.min(1,vuetotale)+'</b> case<br/>'
  13638. +'Dégâts physiques : <b>-'
  13639. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  13640. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  13641. +'Dégâts magiques : <b>-'
  13642. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  13643. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  13644. }
  13645. else if(sort.indexOf('flash aveuglant')!=-1){
  13646. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  13647. }
  13648. else if(sort.indexOf('glue')!=-1) {
  13649. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  13650. if(vuetotale>2) texte += 's';
  13651. } else if(sort.indexOf("griffe du sorcier")!=-1) {
  13652. var
  13653. modD =0,
  13654. addVenin = function(type, effet, duree) {
  13655. var
  13656. ret = "<b>Venin "+type+" : </b><br/><b>" +
  13657. effet+"</b> D3" +
  13658. " pendant <b>"+duree+"</b> tour",
  13659. dureeReduite = Math.max(Math.floor(duree/2),1);
  13660. if(duree>1) {
  13661. ret += "s";
  13662. }
  13663. return ret +
  13664. " => <b>"+2*effet+" x "+duree+" = "+2*effet*duree +
  13665. "</b> ("+2*effet+" x "+dureeReduite+" = " +
  13666. 2*effet*dureeReduite+")";
  13667. },
  13668. effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  13669. // Frappe
  13670. texte = "Attaque : <b>"+att+"</b> D6 ";
  13671. if(atttour!=0) {
  13672. modD = Math.floor(att*atttour/100);
  13673. texte += "<i>"+aff(modD)+"D6</i> ";
  13674. }
  13675. texte += aff(attbm)
  13676. +" => <b>"+(Math.round(3.5*(att+modD))+attbm)+"</b><br/>"
  13677. +"Dégâts : <b>"+Math.floor(deg/2)+"</b> D3 ";
  13678. if(degtour!=0) {
  13679. modD = Math.floor(Math.floor(deg/2)*degtour/100);
  13680. texte += "<i>"+aff(modD)+"D3</i> ";
  13681. } else {
  13682. modD = 0;
  13683. }
  13684. texte += aff(degbm) +
  13685. " => <b>"+(2*(Math.floor(deg/2)+modD)+degbm) +
  13686. "/"+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm) +
  13687. " ("+resiste(Math.floor(deg/2)+modD,degbm) +
  13688. "/"+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm) +
  13689. ")</b>";
  13690. // Venins
  13691. texte += "<hr>"+addVenin("insidieux",effet,2+Math.floor(vue/5));
  13692. effet = Math.floor(1.5*effet);
  13693. texte += "<hr>"+addVenin("virulent",effet,1+Math.floor(vue/10));
  13694. } else if(sort.indexOf('hypnotisme')!=-1)
  13695. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  13696. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  13697. else if(sort.indexOf('identification des tresors')!=-1)
  13698. texte = 'Permet de connaitre les caractéristiques et effets précis '
  13699. +'d\'un trésor.';
  13700. else if(sort.indexOf('invisibilite')!=-1)
  13701. texte = 'Un troll invisible est indétectable même quand on se trouve '
  13702. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  13703. +'fait disparaître l\'invisibilité.';
  13704. else if(sort.indexOf('levitation')!=-1)
  13705. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  13706. +'Comme les pièges ou les trous par exemple...';
  13707. else if(sort.indexOf("projectile magique")!=-1) {
  13708. var
  13709. modD = 0,
  13710. portee = getPortee(vuetotale);
  13711. // Att
  13712. texte = "Attaque : <b>"+vue+"</b> D6 ";
  13713. if(atttour!=0) {
  13714. modD = Math.floor(vue*atttour/100);
  13715. texte += "<i>"+aff(modD)+"D6</i> ";
  13716. }
  13717. texte += aff(attbm) +
  13718. " => <b>"+(Math.round(3.5*(vue+modD))+attbm)+"</b><br>" +
  13719. "Dégâts : <b>"+Math.floor(vue/2)+"</b> D3 ";
  13720. // Deg
  13721. if(degtour!=0) {
  13722. modD = Math.floor(Math.floor(vue/2)*degtour/100);
  13723. texte += "<i>"+aff(modD)+"D3</i> ";
  13724. } else {
  13725. modD = 0;
  13726. }
  13727. texte += aff(degbm) +
  13728. " => <b>"+(2*(Math.floor(vue/2)+modD)+degbm) +
  13729. "/"+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm) +
  13730. " ("+resiste(Math.floor(vue/2)+modD,degbm) +
  13731. "/"+resiste(1.5*Math.floor(vue/2)+modD,degbm) +
  13732. ") (+ 1D3 par bonus de portée)</b>";
  13733. // Portée
  13734. texte += "<br/>Portée : <b>"+portee+"</b> case";
  13735. if(portee>1) texte += "s";
  13736. } else if(sort.indexOf('projection')!=-1) {
  13737. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  13738. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  13739. +'Si le jet de résistance de la victime est réussi:<br/>'
  13740. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  13741. } else if(sort.indexOf("rafale psychique")!=-1) {
  13742. var modD = 0;
  13743. texte = "Dégâts : <b>"+deg+"</b> D3 ";
  13744. if(degtour!=0) {
  13745. modD = Math.floor(deg*degtour/100);
  13746. texte += "<i>"+aff(modD)+"D3</i> ";
  13747. }
  13748. texte += aff(degbm) +
  13749. " => <b>"+(2*(deg+modD)+degbm) +
  13750. " ("+resiste(deg+modD,degbm)+")</b><br>" +
  13751. "Malus : régénération <b>-"+(deg+modD)+"</b>";
  13752. } else if(sort.indexOf("sacrifice")!=-1) {
  13753. if(pvcourant<=0) {
  13754. // N'est plus censé se produire : activation obligatoire si mort
  13755. return "<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>";
  13756. }
  13757. var
  13758. perteSacro = function(sac) {
  13759. return " (-"+(sac+2*(1+Math.floor(sac/5)))+" PV)";
  13760. },
  13761. sac = Math.floor((pvcourant-1)/2),
  13762. pvdispoSansMalusTemps =
  13763. pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  13764.  
  13765. texte = "Portée horizontale : <b>" +
  13766. Math.min(1,vuetotale)+"</b> case<br>" +
  13767. "Soin maximal : <b>"+sac+"</b> PV"+perteSacro(sac);
  13768. // Sacros max et optimal sans malus (propale R')
  13769. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  13770. if(sac>0) {
  13771. texte += "<hr>Soin maximum limitant les risques de malus " +
  13772. "de temps : <b>" +sac+"</b> PV"+perteSacro(sac);
  13773. } else {
  13774. texte += "<hr>Vous ne pouvez pas compenser de blessures " +
  13775. "dues à un sacrifice";
  13776. }
  13777. } else if(sort.indexOf("siphon")!=-1) {
  13778. var modD = 0;
  13779. texte = "Attaque : <b>"+att+"</b> D6 ";
  13780. if(atttour!=0) {
  13781. modD = Math.floor(att*atttour/100);
  13782. texte += "<i>"+aff(modD)+"D6</i> ";
  13783. }
  13784. texte += aff(attbm) +
  13785. " => <b>"+Math.round(3.5*(att+modD)+attbm)+"</b><br>" +
  13786. "Dégâts : <b>"+reg+"</b> D3 ";
  13787. if(degtour!=0) {
  13788. modD = Math.floor(reg*degtour/100);
  13789. texte += "<i>"+aff(modD)+"D3</i> ";
  13790. } else {
  13791. modD = 0;
  13792. }
  13793. texte += aff(degbm) +
  13794. " => <b>"+(2*(reg+modD)+degbm) +
  13795. "/" + (2*(Math.floor(1.5*reg)+modD)+degbm) +
  13796. " ("+resiste(reg+modD,degbm) +
  13797. "/"+resiste(1.5*reg+modD,degbm)+")</b>";
  13798. texte += "<br>Nécrose : attaque magique <b>-"+(reg+modD)+"</b>";
  13799. } else if(sort.indexOf('telekinesie')!=-1) {
  13800. texte = 'Portée horizontale :';
  13801. var vt = Math.floor(vuetotale/2)+2;
  13802. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  13803. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  13804. for(var i=0 ; i<5 ; i++) {
  13805. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  13806. if(vt>1) texte += 's';
  13807. vt=Math.max(0,vt-1);
  13808. }
  13809. }
  13810. else if(sort.indexOf('teleportation')!=-1) {
  13811. var portee = getPortee(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  13812. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  13813. var pmh = (20+vue+portee);
  13814. var pmv = 3+Math.floor(portee/3);
  13815. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  13816. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  13817. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  13818. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  13819. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  13820. } else if(sort.indexOf('vampirisme')!=-1) {
  13821. var modD = 0;
  13822. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  13823. if(atttour!=0) {
  13824. modD = Math.floor(Math.floor(2*deg/3)*atttour/100);
  13825. texte += '<i>'+aff(modD)+'D6</i> ';
  13826. }
  13827. texte += aff(attbm) +
  13828. ' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm) +
  13829. '</b><br/>Dégâts : <b>'+deg+'</b> D3 ';
  13830. if(degtour!=0) {
  13831. modD = Math.floor(deg*degtour/100);
  13832. texte += '<i>'+aff(modD)+'D3</i> ';
  13833. } else {
  13834. modD = 0;
  13835. }
  13836. texte += aff(degbm) +
  13837. ' => <b>'+(2*(deg+modD)+degbm) +
  13838. '/'+(2*(Math.floor(1.5*deg)+modD)+degbm) +
  13839. ' ('+resiste(deg+modD,degbm) +
  13840. '/'+resiste(1.5*deg+modD,degbm)+')</b>';
  13841. } else if(sort.indexOf('vision accrue')!=-1)
  13842. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  13843. else if(sort.indexOf('vision lointaine')!=-1)
  13844. texte = 'En ciblant une zone située n\'importe où dans le '
  13845. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  13846. else if(sort.indexOf('voir le cache')!=-1)
  13847. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  13848. +Math.min(5,getPortee(vue))+'</b> cases<hr>'
  13849. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  13850. +getPortee(vuetotale)+'</b> cases';
  13851. else if(sort.indexOf('vue troublee')!=-1)
  13852. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  13853. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  13854. return texte;
  13855. }
  13856.  
  13857.  
  13858. /*---------------------------------- Main ------------------------------------*/
  13859.  
  13860. function do_profil2()
  13861. {
  13862. try {
  13863. start_script(31);
  13864.  
  13865. extractionDonnees();
  13866. setInfosCaracteristiques();
  13867. setInfoDescription();
  13868. setInfosEtatLieux();
  13869. setInfosEtatPV();
  13870. setInfosExp();
  13871.  
  13872. creerBulleVide();
  13873. traitementTalents();
  13874. setLienAnatrolliseur();
  13875.  
  13876. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  13877. if(race=='Kastar' || MY_DEBUG){ setAccel(); }
  13878. saveProfil();
  13879. displayScriptTime();
  13880. } catch(e) {
  13881. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.<br>" + traceStack(e, 'profil2').replace("\n", "<br>"), 1000000, true);
  13882. window.console.error(traceStack(e, 'profil2'));
  13883. }
  13884. }
  13885.  
  13886. /*******************************************************************************
  13887. * This file is part of Mountyzilla. *
  13888. * *
  13889. * Mountyzilla is free software; you can redistribute it and/or modify *
  13890. * it under the terms of the GNU General Public License as published by *
  13891. * the Free Software Foundation; either version 2 of the License, or *
  13892. * (at your option) any later version. *
  13893. * *
  13894. * Mountyzilla is distributed in the hope that it will be useful, *
  13895. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13896. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13897. * GNU General Public License for more details. *
  13898. * *
  13899. * You should have received a copy of the GNU General Public License *
  13900. * along with Mountyzilla; if not, write to the Free Software *
  13901. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  13902. *******************************************************************************/
  13903.  
  13904. // x~x script_principal
  13905.  
  13906. // x~x md5.js
  13907. /*
  13908. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  13909. * Digest Algorithm, as defined in RFC 1321.
  13910. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  13911. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  13912. * Distributed under the BSD License
  13913. * See http://pajhome.org.uk/crypt/md5 for more info.
  13914. */
  13915.  
  13916. /*
  13917. * Configurable variables. You may need to tweak these to be compatible with
  13918. * the server-side, but the defaults work in most cases.
  13919. */
  13920. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  13921. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  13922. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  13923.  
  13924. /*
  13925. * These are the functions you'll usually want to call
  13926. * They take string arguments and return either hex or base-64 encoded strings
  13927. */
  13928. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  13929. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  13930. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  13931. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  13932. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  13933. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  13934.  
  13935. /*
  13936. * Perform a simple self-test to see if the VM is working
  13937. */
  13938. function md5_vm_test()
  13939. {
  13940. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  13941. }
  13942.  
  13943. /*
  13944. * Calculate the MD5 of an array of little-endian words, and a bit length
  13945. */
  13946. function core_md5(x, len)
  13947. {
  13948. /* append padding */
  13949. x[len >> 5] |= 0x80 << ((len) % 32);
  13950. x[(((len + 64) >>> 9) << 4) + 14] = len;
  13951.  
  13952. var a = 1732584193;
  13953. var b = -271733879;
  13954. var c = -1732584194;
  13955. var d = 271733878;
  13956.  
  13957. for(var i = 0; i < x.length; i += 16)
  13958. {
  13959. var olda = a;
  13960. var oldb = b;
  13961. var oldc = c;
  13962. var oldd = d;
  13963.  
  13964. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  13965. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  13966. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  13967. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  13968. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  13969. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  13970. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  13971. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  13972. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  13973. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  13974. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  13975. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  13976. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  13977. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  13978. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  13979. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  13980.  
  13981. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  13982. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  13983. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  13984. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  13985. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  13986. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  13987. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  13988. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  13989. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  13990. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  13991. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  13992. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  13993. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  13994. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  13995. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  13996. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  13997.  
  13998. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  13999. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  14000. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  14001. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  14002. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  14003. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  14004. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  14005. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  14006. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  14007. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  14008. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  14009. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  14010. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  14011. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  14012. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  14013. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  14014.  
  14015. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  14016. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  14017. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  14018. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  14019. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  14020. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  14021. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  14022. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  14023. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  14024. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  14025. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  14026. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  14027. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  14028. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  14029. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  14030. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  14031.  
  14032. a = safe_add(a, olda);
  14033. b = safe_add(b, oldb);
  14034. c = safe_add(c, oldc);
  14035. d = safe_add(d, oldd);
  14036. }
  14037. return Array(a, b, c, d);
  14038.  
  14039. }
  14040.  
  14041. /*
  14042. * These functions implement the four basic operations the algorithm uses.
  14043. */
  14044. function md5_cmn(q, a, b, x, s, t)
  14045. {
  14046. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  14047. }
  14048. function md5_ff(a, b, c, d, x, s, t)
  14049. {
  14050. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  14051. }
  14052. function md5_gg(a, b, c, d, x, s, t)
  14053. {
  14054. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  14055. }
  14056. function md5_hh(a, b, c, d, x, s, t)
  14057. {
  14058. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  14059. }
  14060. function md5_ii(a, b, c, d, x, s, t)
  14061. {
  14062. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  14063. }
  14064.  
  14065. /*
  14066. * Calculate the HMAC-MD5, of a key and some data
  14067. */
  14068. function core_hmac_md5(key, data)
  14069. {
  14070. var bkey = str2binl(key);
  14071. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  14072.  
  14073. var ipad = Array(16), opad = Array(16);
  14074. for(var i = 0; i < 16; i++)
  14075. {
  14076. ipad[i] = bkey[i] ^ 0x36363636;
  14077. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  14078. }
  14079.  
  14080. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  14081. return core_md5(opad.concat(hash), 512 + 128);
  14082. }
  14083.  
  14084. /*
  14085. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  14086. * to work around bugs in some JS interpreters.
  14087. */
  14088. function safe_add(x, y)
  14089. {
  14090. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  14091. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  14092. return (msw << 16) | (lsw & 0xFFFF);
  14093. }
  14094.  
  14095. /*
  14096. * Bitwise rotate a 32-bit number to the left.
  14097. */
  14098. function bit_rol(num, cnt)
  14099. {
  14100. return (num << cnt) | (num >>> (32 - cnt));
  14101. }
  14102.  
  14103. /*
  14104. * Convert a string to an array of little-endian words
  14105. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  14106. */
  14107. function str2binl(str)
  14108. {
  14109. var bin = Array();
  14110. var mask = (1 << chrsz) - 1;
  14111. for(var i = 0; i < str.length * chrsz; i += chrsz)
  14112. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  14113. return bin;
  14114. }
  14115.  
  14116. /*
  14117. * Convert an array of little-endian words to a string
  14118. */
  14119. function binl2str(bin)
  14120. {
  14121. var str = "";
  14122. var mask = (1 << chrsz) - 1;
  14123. for(var i = 0; i < bin.length * 32; i += chrsz)
  14124. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  14125. return str;
  14126. }
  14127.  
  14128. /*
  14129. * Convert an array of little-endian words to a hex string.
  14130. */
  14131. function binl2hex(binarray)
  14132. {
  14133. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  14134. var str = "";
  14135. for(var i = 0; i < binarray.length * 4; i++)
  14136. {
  14137. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  14138. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  14139. }
  14140. return str;
  14141. }
  14142.  
  14143. /*
  14144. * Convert an array of little-endian words to a base-64 string
  14145. */
  14146. function binl2b64(binarray)
  14147. {
  14148. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  14149. var str = "";
  14150. for(var i = 0; i < binarray.length * 4; i += 3)
  14151. {
  14152. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  14153. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  14154. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  14155. for(var j = 0; j < 4; j++)
  14156. {
  14157. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  14158. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  14159. }
  14160. }
  14161. return str;
  14162. }
  14163.  
  14164. ///////////////////////////////////////////
  14165. // debug cartes capitan Roule 07/12/2016
  14166. ///////////////////////////////////
  14167. // essais : objet
  14168. // .mode : description
  14169. // .essais : tableau d'objets essai
  14170. // .mode : description
  14171. // .essais : tableau de cartes
  14172. // .noCarte : id de la carte
  14173. // .essais : tableau d'essais, [x, y, n, nb]
  14174. function AfficheEssais(essais, sMode) {
  14175. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  14176. if (!eBigDiv) {
  14177. var insertPoint = document.getElementById('footer1');
  14178. eBigDiv = document.createElement('table');
  14179. eBigDiv.id = 'ListeEssaiCapitan';
  14180. insertBefore(insertPoint, document.createElement('p'));
  14181. insertTitle(insertPoint,'Capitan : Liste des essais');
  14182. insertBefore(insertPoint, eBigDiv);
  14183. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  14184. }
  14185. if (!essais) {
  14186. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  14187. return;
  14188. }
  14189. var carte;
  14190. for (carte in essais) {
  14191. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  14192. }
  14193. if (carte === undefined) {
  14194. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  14195. }
  14196. }
  14197.  
  14198. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  14199. var tr = appendTr(eTable);
  14200. var td = appendTd(tr);
  14201. appendText(td, sMode, bBold);
  14202. td = appendTd(tr);
  14203. appendText(td, sCarte, bBold);
  14204. td = appendTd(tr);
  14205. appendText(td, sText, bBold);
  14206. }
  14207.  
  14208. function getEssaiV1_0() {
  14209. try {
  14210. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  14211. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  14212. var tabK, nK;
  14213. prefs.getChildList('', nK, tabK);
  14214. window.console.log('getEssaiV1_0, nb key : ' + nK);
  14215. //window.console.log('getEssaiV1_0, ' + nK);
  14216. return;
  14217. //return r;
  14218. } catch (e) {
  14219. window.console.log(traceStack(e, 'getEssaiV1_0'));
  14220. }
  14221. }
  14222.  
  14223. function getEssaiV1_1() {
  14224. var locSto = window.localStorage;
  14225. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  14226. var r = [];
  14227. for (var i = 0; i < locSto.length; i++) {
  14228. var k = locSto.key(i);
  14229. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  14230. var t = k.split(/\./);
  14231. if (t[0] !== 'capitan') continue;
  14232. if (t[2] !== 'essai') continue;
  14233. var carte = 'carte n°' + t[1];
  14234. if (r[carte]) r[carte]++;
  14235. else r[carte] = 1;
  14236. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  14237. }
  14238. return r;
  14239. }
  14240.  
  14241. function showEssaiCartes() {
  14242. window.console.log('début showEssai Tout_MZ');
  14243. var essais = getEssaiV1_0();
  14244. AfficheEssais(essais, 'V1.0');
  14245. essais = getEssaiV1_1();
  14246. AfficheEssais(essais, 'V1.1');
  14247. window.console.log('fin showEssai Tout_MZ');
  14248. }
  14249.  
  14250. function testBoolLocalStorage() {
  14251. var b = true;
  14252. var key = 'MZ_essai_bool';
  14253. GM_setValue(key, b);
  14254. window.localStorage[key] = b;
  14255. var v = GM_getValue(key);
  14256. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  14257. var v = window.localStorage.getItem(key);
  14258. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  14259.  
  14260. var b = false;
  14261. GM_setValue(key, b);
  14262. window.localStorage[key] = b;
  14263. var v = GM_getValue(key);
  14264. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  14265. var v = window.localStorage.getItem(key);
  14266. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  14267.  
  14268. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  14269. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  14270. var y = GM_getValue('654654897894654654');
  14271. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  14272. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  14273. }
  14274.  
  14275. /*--------------------------------- Création liste trolligion ---------------------------------*/
  14276. function export_trolligion() {
  14277. try {
  14278. var tabDl = document.getElementsByTagName('dl');
  14279. if ((!tabDl) || !tabDl[0]) {
  14280. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  14281. return;
  14282. }
  14283. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  14284. // nom : string
  14285. // rayonnement : entier
  14286. // grades : table d'objets (une occurence par grade)
  14287. // nom : string
  14288. // trolls : table d'objets (un par Trõll)
  14289. // id
  14290. // nom
  14291. // idguilde
  14292. // guilde
  14293. // race
  14294. // niveau
  14295. // ferveur
  14296. var currentDieu;
  14297. var currentGrade;
  14298. for (var iChild1 in tabDl[0].children) {
  14299. var eChild1 = tabDl[0].children[iChild1];
  14300. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  14301. case 'dd': // Trõll
  14302. var oTroll = {};
  14303. export_trolligion_analyse(oTroll, eChild1);
  14304. currentGrade.trolls.push(oTroll);
  14305. break;
  14306. case 'dt':
  14307. var tabH3 = eChild1.getElementsByTagName('h3');
  14308. if (tabH3 && tabH3[0]) { // changement de dieu
  14309. currentDieu = {
  14310. nom: tabH3[0].innerText || tabH3[0].textContent
  14311. , grades: []};
  14312. var txt = eChild1.innerText || eChild1.textContent;
  14313. var m = txt.match(/yon*ement *:* *(\d+)/);
  14314. if (m) currentDieu.rayonnement = parseInt(m[1]);
  14315. currentGrade = undefined;
  14316. tabDieux.push(currentDieu);
  14317. break;
  14318. }
  14319. var tabH4 = eChild1.getElementsByTagName('h4');
  14320. if (tabH4 && tabH4[0]) { // changement de grade
  14321. var grade;
  14322. var txt = tabH4[0].innerText || tabH4[0].textContent;
  14323. tabI = tabH4[0].getElementsByTagName('i');
  14324. if (tabI && tabI[0]) {
  14325. grade = tabI[0].innerText || tabI[0].textContent;
  14326. grade = grade.replace(/"/g, '');
  14327. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  14328. if (m) grade += ' (' + m[1] + ')';
  14329. } else {
  14330. grade = txt.replace(/"/g, '');
  14331. }
  14332. currentGrade = {nom: grade, trolls: []};
  14333. currentDieu.grades.push(currentGrade);
  14334. break;
  14335. }
  14336. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  14337. break;
  14338. default:
  14339. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  14340. }
  14341. }
  14342.  
  14343. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  14344. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  14345. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  14346. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  14347. for (var iDieu in tabDieux) {
  14348. var oDieu = tabDieux[iDieu];
  14349. for (var iGrade in oDieu.grades) {
  14350. var oGrade = oDieu.grades[iGrade];
  14351. for (var iTroll in oGrade.trolls) {
  14352. var oTroll = oGrade.trolls[iTroll];
  14353. var t = [oDieu.nom, oDieu.rayonnement
  14354. , oGrade.nom
  14355. , oTroll.id, oTroll.nom
  14356. , oTroll.idguilde, oTroll.guilde
  14357. , oTroll.race, oTroll.niveau
  14358. , oTroll.ferveur];
  14359. for (var iParam in t) {
  14360. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14361. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14362. }
  14363. txt += t.join("\t") + "\n";
  14364. }
  14365. }
  14366. var t = [oDieu.nom, oDieu.rayonnement];
  14367. for (var iParam in t) {
  14368. if (t[iParam] === undefined) t[iParam] = ''; // protection
  14369. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  14370. }
  14371. txt2 += t.join("\t") + "\n";
  14372. }
  14373. txt += "\n" + txt2;
  14374. } catch (e) {
  14375. window.alert("Échec à l'extraction\n" + e);
  14376. }
  14377. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  14378. try {
  14379. if (copyTextToClipboard(txt)) {
  14380. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  14381. + "Collez dans Calc\n"
  14382. + "ou, au pire, dans EXCEL®");
  14383. } else {
  14384. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  14385. }
  14386. } catch(e) {
  14387. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  14388. }
  14389. }
  14390.  
  14391. function export_trolligion_analyse(oTroll, eChild1) {
  14392. for (var iChild2 in eChild1.childNodes) { // childNodes pour obtenir les éléments texte aussi
  14393. var eChild2 = eChild1.childNodes[iChild2];
  14394. if (eChild2.nodeType === undefined) continue; // properties
  14395. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  14396. switch (eChild2.nodeType) {
  14397. case 1: //ELEMENT_NODE:
  14398. switch (eChild2.nodeName.toLowerCase()) {
  14399. case 'a':
  14400. var m;
  14401. if (!eChild2.href) {
  14402. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  14403. break;
  14404. }
  14405. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  14406. if (m) {
  14407. oTroll.id = parseInt(m[1]);
  14408. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  14409. break;
  14410. }
  14411. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  14412. if (m) {
  14413. var idGuilde = parseInt(m[1]);
  14414. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  14415. oTroll.idguilde = parseInt(m[1]);
  14416. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  14417. }
  14418. break;
  14419. }
  14420. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  14421. break;
  14422. case 'br': // ignore
  14423. case 'style': // ignore
  14424. case 'img': // ignore
  14425. break;
  14426. case 'div': // barre de vie
  14427. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  14428. eChild3 = eChild2.children[0];
  14429. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  14430. var eChild4 = eChild3.children[0];
  14431. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  14432. break;
  14433. }
  14434. }
  14435. //window.console.log(eChild2.innerHTML);
  14436. export_trolligion_analyse(oTroll, eChild2);
  14437. break;
  14438. default:
  14439. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  14440. break;
  14441. }
  14442. break;
  14443. case 3: //TEXT_NODE:
  14444. var txt = eChild2.nodeValue.trim();
  14445. if (txt === '') break;
  14446. var m = txt.match(/(.*) *\((\d+)\)/);
  14447. if (m) {
  14448. oTroll.race = m[1].trim();
  14449. oTroll.niveau = parseInt(m[2]);
  14450. } else {
  14451. oTroll.race = txt;
  14452. }
  14453. break;
  14454. default: // ne devrait pas arriver
  14455. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  14456. break;
  14457. }
  14458. }
  14459. }
  14460.  
  14461. function do_trolligion() {
  14462. var divpopup = document.createElement('div');
  14463. divpopup.id = 'MZ_divCopier';
  14464. divpopup.style.position = 'fixed';
  14465. divpopup.style.top = '2px';
  14466. divpopup.style.left = '2px;';
  14467. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  14468. divpopup.style.cursor = 'pointer';
  14469. divpopup.style.zIndex = 200;
  14470. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  14471. divpopup.onclick = export_trolligion;
  14472. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  14473. divpopup.appendChild(img);
  14474. document.body.appendChild(divpopup);
  14475. }
  14476.  
  14477. /*--------------------------------- Dispatch ---------------------------------*/
  14478.  
  14479. //chargerScriptDev("libs");
  14480. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  14481. //if (isDEV) testBoolLocalStorage();
  14482. /* Roule, test getPVsRestants
  14483. var pv = 'Inimaginables (supérieurs à 200)';
  14484. var pvminmax = pv.match(/\d+/g);
  14485. var oMinMaxPV = {min: pvminmax[0], max: pvminmax[1]};
  14486. window.console.log('minmax=' + JSON.stringify(pvminmax) + ', oMinMaxPV=' + JSON.stringify(oMinMaxPV));
  14487. window.console.log('ret getPVsRestants=' + JSON.stringify(getPVsRestants(pv, '±70%')));
  14488. window.console.log('ret getPVsRestants=' + JSON.stringify(getPVsRestants(pv, '±70%', true)));
  14489. */
  14490.  
  14491. // Détection de la page à traiter
  14492. if(isPage("Messagerie/ViewMessageBot")) {
  14493. do_cdmbot();
  14494. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  14495. do_cdmcomp();
  14496. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  14497. do_cdmcomp();
  14498. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  14499. do_cdmcomp();
  14500. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  14501. do_diplo();
  14502. } else if(isPage("MH_Play/Play_equipement")) {
  14503. do_equip();
  14504. } else if(isPage("MH_Play/Play_menu")) {
  14505. do_menu();
  14506. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  14507. do_option();
  14508. //showEssaiCartes();
  14509. } else if(isPage("View/PJView_Events")) {
  14510. /* SCIZ */
  14511. do_scizOverwriteEvents();
  14512. } else if(isPage("View/PJView")) {
  14513. do_pjview();
  14514. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  14515. do_tancompo();
  14516. } else if(isPage("MH_Play/Play_vue")) {
  14517. do_vue();
  14518. /* SCIZ */
  14519. do_scizEnhanceView();
  14520. } else if(isPage("MH_Play/Play_news")) {
  14521. do_news();
  14522. } else if(isPage("MH_Play/Play_evenement")) {
  14523. /* SCIZ */
  14524. do_scizOverwriteEvents();
  14525. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  14526. do_move();
  14527. } else if(isPage("MH_Missions/Mission_Etape")) {
  14528. do_mission();
  14529. } else if(isPage("View/MonsterView")) {
  14530. do_infomonstre();
  14531. /* SCIZ */
  14532. do_scizOverwriteEvents();
  14533. } else if(isPage("MH_Play/Play_e_follo.php")) {
  14534. do_listegowap();
  14535. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  14536. do_lieuDescription();
  14537. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  14538. do_lieuTeleport();
  14539. } else if(isPage("MH_Follower/FO_Ordres")) {
  14540. do_ordresgowap();
  14541. } else if(isPage("MH_Follower/FO_Equipement")) {
  14542. do_equipgowap();
  14543. } else if(isPage("MH_Play/Play_mouche")) {
  14544. do_mouches();
  14545. } else if(isPage("MH_Play/Play_BM")) {
  14546. do_malus();
  14547. } else if(isPage("MH_Play/Play_evenement")) {
  14548. do_myevent();
  14549. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  14550. do_enchant();
  14551. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  14552. do_pre_enchant();
  14553. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  14554. do_actions();
  14555. } 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')) {
  14556. do_mission_liste();
  14557. } else if(isPage('MH_Play/Play_action')) {
  14558. do_actions();
  14559. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  14560. do_profil2();
  14561. } else if(isPage('MH_Play/Play_profil2')) {
  14562. do_profil2();
  14563. } else if(isPage('View/TrolligionView.php')) {
  14564. do_trolligion();
  14565. }
  14566. if (document.body.dataset.MZ_Etat === undefined) { // si l'état a été positionné par quelqu'un d'autre, laisser tel quel
  14567. document.body.dataset.MZ_Etat = 1; // indiquer aux scripts tiers qu'on a fini la première initialisation
  14568. }
  14569. if (document.body.MZ_Callback_init !== undefined) {
  14570. for (var iCallback = 0; iCallback < document.body.MZ_Callback_init.length; iCallback++) {
  14571. document.body.MZ_Callback_init[iCallback]();
  14572. }
  14573. }
  14574. } catch(e) {
  14575. try {
  14576. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  14577. } catch(e2) {
  14578. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  14579. }
  14580. }