From 8e7a3f4eca38189f89457036979cfed8b5ec7300 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Fri, 10 Jul 2026 21:30:09 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20initiative=20-=20auto-init=20deck,=20CSS?= =?UTF-8?q?=20stylis=C3=A9,=20plus=20d'erreurs=20de=20formule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Auto-initialisation du deck s'il est vide ou non initialisé - Fallback silencieux sur 1d6 si vraiment aucune carte dispo - _formula changé en '1d1' pour éviter les erreurs de parsing - Ajout du CSS complet pour le message d'initiative (chat.less) - Fond dégradé sombre, bordure rouge, badge arrondi - Avatar, nom, carte, valeur, score d'initiative - Pied de page stylisé --- css/fvtt-hamalron.css | 81 +++++++++++++++++++++++++++++++++++++ fvtt-hamalron.mjs | 16 ++++++-- styles/chat.less | 93 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 3 deletions(-) diff --git a/css/fvtt-hamalron.css b/css/fvtt-hamalron.css index e511305..6c2bfa1 100644 --- a/css/fvtt-hamalron.css +++ b/css/fvtt-hamalron.css @@ -2997,6 +2997,87 @@ i.fvtt-hamalron { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); } } +.initiative-roll { + background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); + border: 1px solid #e94560; + border-radius: 8px; + overflow: hidden; + font-family: var(--font-secondary, sans-serif); +} +.initiative-roll .initiative-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 8px 12px; + background: rgba(233, 69, 96, 0.15); + border-bottom: 1px solid rgba(233, 69, 96, 0.3); +} +.initiative-roll .initiative-header .initiative-actor { + display: flex; + align-items: center; + gap: 8px; +} +.initiative-roll .initiative-header .initiative-actor .initiative-avatar { + width: 32px; + height: 32px; + border-radius: 50%; + border: 2px solid #e94560; + object-fit: cover; +} +.initiative-roll .initiative-header .initiative-actor .initiative-name { + color: #e0e0e0; + font-size: 14px; + font-weight: 600; +} +.initiative-roll .initiative-header .initiative-badge { + display: flex; + align-items: center; + gap: 6px; + background: #e94560; + color: #fff; + font-size: 20px; + font-weight: 700; + padding: 4px 14px; + border-radius: 20px; + box-shadow: 0 0 10px rgba(233, 69, 96, 0.5); +} +.initiative-roll .initiative-card { + display: flex; + align-items: center; + gap: 12px; + padding: 12px; +} +.initiative-roll .initiative-card .initiative-card-img { + width: 48px; + height: 48px; + object-fit: contain; + border-radius: 4px; + background: rgba(255, 255, 255, 0.05); + padding: 4px; +} +.initiative-roll .initiative-card .initiative-card-info { + display: flex; + flex-direction: column; + gap: 2px; +} +.initiative-roll .initiative-card .initiative-card-info .card-name { + color: #f0e6d3; + font-size: 13px; + font-weight: 500; +} +.initiative-roll .initiative-card .initiative-card-info .card-value { + color: #aaa; + font-size: 12px; +} +.initiative-roll .initiative-footer { + text-align: center; + padding: 4px; + background: rgba(233, 69, 96, 0.08); + font-size: 11px; + color: #e94560; + text-transform: uppercase; + letter-spacing: 2px; +} .application.dialog.fvtt-hamalron { color: var(--color-dark-1); background-color: var(--color-light-1); diff --git a/fvtt-hamalron.mjs b/fvtt-hamalron.mjs index 908047e..3ea1b3e 100644 --- a/fvtt-hamalron.mjs +++ b/fvtt-hamalron.mjs @@ -47,15 +47,25 @@ Hooks.once("init", function () { const combatantName = this.name const origEvaluate = roll.evaluate.bind(roll) roll.evaluate = async function (options = {}) { - const deckManager = globalThis.HamalronTarotDeckManager?._instance - if (deckManager?.deck?.length > 0) { + let deckManager = globalThis.HamalronTarotDeckManager?._instance + if (!deckManager) { + deckManager = new (globalThis.HamalronTarotDeckManager)() + globalThis.HamalronTarotDeckManager._instance = deckManager + } + if (deckManager.deck.length === 0) { + const tarotItems = game.items.filter(i => i.type === "tarot") + if (tarotItems.length > 0) deckManager.resetDeck() + } + if (deckManager.deck.length > 0) { const drawn = deckManager.drawCards(1) if (drawn.length > 0) { const card = drawn[0] const val = SYSTEM.TAROT_VALEURS[card.valeur]?.value ?? 0 this._total = val this._evaluated = true - this._formula = `${card.name} (${val})` + this._formula = "1d1" + this._dice = [] + this._terms = [] this.options.cardDraw = { name: card.name, img: card.img, diff --git a/styles/chat.less b/styles/chat.less index d330749..01f9a75 100644 --- a/styles/chat.less +++ b/styles/chat.less @@ -787,3 +787,96 @@ box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); } } + +.initiative-roll { + background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); + border: 1px solid #e94560; + border-radius: 8px; + overflow: hidden; + font-family: var(--font-secondary, sans-serif); + + .initiative-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 8px 12px; + background: rgba(233, 69, 96, 0.15); + border-bottom: 1px solid rgba(233, 69, 96, 0.3); + + .initiative-actor { + display: flex; + align-items: center; + gap: 8px; + + .initiative-avatar { + width: 32px; + height: 32px; + border-radius: 50%; + border: 2px solid #e94560; + object-fit: cover; + } + + .initiative-name { + color: #e0e0e0; + font-size: 14px; + font-weight: 600; + } + } + + .initiative-badge { + display: flex; + align-items: center; + gap: 6px; + background: #e94560; + color: #fff; + font-size: 20px; + font-weight: 700; + padding: 4px 14px; + border-radius: 20px; + box-shadow: 0 0 10px rgba(233, 69, 96, 0.5); + } + } + + .initiative-card { + display: flex; + align-items: center; + gap: 12px; + padding: 12px; + + .initiative-card-img { + width: 48px; + height: 48px; + object-fit: contain; + border-radius: 4px; + background: rgba(255, 255, 255, 0.05); + padding: 4px; + } + + .initiative-card-info { + display: flex; + flex-direction: column; + gap: 2px; + + .card-name { + color: #f0e6d3; + font-size: 13px; + font-weight: 500; + } + + .card-value { + color: #aaa; + font-size: 12px; + } + } + } + + .initiative-footer { + text-align: center; + padding: 4px; + background: rgba(233, 69, 96, 0.08); + font-size: 11px; + color: #e94560; + text-transform: uppercase; + letter-spacing: 2px; + } +}