feat: système de magie complet avec dialogue de lancement

- Modèle sortilege enrichi (type, niveau, portée, durée, conditions, effets)
- Personnage: champ rangMagie (ensorceleur/initié/thaumaturge)
- Constantes: SORTILEGE_MODIFICATEURS (table 3x3), RANG_MAGICIEN
- Dialogue de lancement: tirage MJ, sélection atouts + Coupe, total temps réel
- Calcul difficulté: carte MJ + modificateur selon type × niveau
- Table des échecs magiques (normal/critique selon rang)
- Pioche automatique après succès, défausse après échec
- Template chat avec résultat localisé

Corrections post-review:
- Boucle de défausse sur échec corrigée (itérait toujours sur [0])
- Clé de localisation HAMALRON.Roll.cast -> HAMALRON.Sortilege.cast
- Ajout de la clé manquante noCoupe
- Labels localisés dans le chat (categorieLabel, niveauLabel)
This commit is contained in:
2026-07-10 19:07:05 +02:00
parent 54e769176a
commit 1749210322
12 changed files with 567 additions and 22 deletions
+55
View File
@@ -0,0 +1,55 @@
<div class="{{cssClass}}">
<div class="sortilege-header">
<img src="{{actingCharImg}}" class="actor-avatar" data-tooltip="{{actingCharName}}" />
<div>
<h3>{{spell.name}}</h3>
<span>{{categorieLabel}} · {{niveauLabel}}</span>
</div>
</div>
<div class="sortilege-cards-used">
<h4>{{localize "HAMALRON.Sortilege.atoutsUsed"}}</h4>
<div class="used-cards">
{{#each atoutsUtilises}}
<div class="used-card">
<img src="{{this.img}}" />
<span>{{this.name}}</span>
</div>
{{/each}}
</div>
{{#if cartesCoupeUtilisees.length}}
<h4>{{localize "HAMALRON.Sortilege.coupeUsed"}}</h4>
<div class="used-cards">
{{#each cartesCoupeUtilisees}}
<div class="used-card">
<img src="{{this.img}}" />
<span>{{this.name}}</span>
</div>
{{/each}}
</div>
{{/if}}
</div>
<div class="sortilege-result">
<div class="calc-row">
<span>{{localize "HAMALRON.Sortilege.playerTotal"}}</span>
<span>{{totalJoueur}}</span>
</div>
<div class="calc-row">
<span>{{localize "HAMALRON.Sortilege.totalDifficulty"}}</span>
<span>{{difficulte}} (carte {{carteMJ}} + {{modificateur}})</span>
</div>
<div class="calc-divider"></div>
<div class="calc-row total-row {{#if isSuccess}}result-success{{else}}result-failure{{/if}}">
<span>
{{#if isSuccess}}
<i class="fas fa-check-circle"></i> {{localize "HAMALRON.Label.success"}}
{{else if isCritique}}
<i class="fas fa-bolt"></i> {{localize "HAMALRON.Sortilege.failureCritical"}}
{{else}}
<i class="fas fa-times-circle"></i> {{localize "HAMALRON.Sortilege.failureNormal"}}
{{/if}}
</span>
</div>
</div>
</div>
+84
View File
@@ -0,0 +1,84 @@
<div class="fvtt-hamalron-sortilege-dialog">
<div class="dialog-info">
<img src="{{actorImage}}" alt="{{actorName}}" class="actor-portrait" />
<div class="spell-info">
<h3>{{spell.name}}</h3>
<span class="spell-meta">{{categorieLabel}} · {{niveauLabel}}</span>
<span class="spell-meta">{{localize "HAMALRON.Sortilege.rang"}} : {{rangLabel}}</span>
</div>
</div>
<fieldset>
<legend>{{localize "HAMALRON.Sortilege.difficulty"}}</legend>
<div class="difficulty-row">
<button type="button" id="draw-card-btn" class="draw-btn">
<i class="fas fa-cards"></i> {{localize "HAMALRON.Sortilege.drawCard"}}
</button>
</div>
<div class="difficulty-row">
<label>{{localize "HAMALRON.Sortilege.cardDrawn"}} :</label>
<span id="carte-mj-nom">-</span>
</div>
<div class="difficulty-row">
<label>{{localize "HAMALRON.Sortilege.cardValue"}} :</label>
<input type="number" id="carte-mj" name="carte-mj" value="0" min="0" max="23" />
</div>
<div class="difficulty-row">
<label>{{localize "HAMALRON.Sortilege.modifier"}} :</label>
<span>{{modificateur}}</span>
</div>
<div class="difficulty-row">
<label>{{localize "HAMALRON.Sortilege.totalDifficulty"}} :</label>
<span id="difficulte-totale">0</span>
</div>
</fieldset>
<fieldset>
<legend>{{localize "HAMALRON.Sortilege.selectAtouts"}}</legend>
<p class="hint">{{localize "HAMALRON.Sortilege.atoutHint"}}</p>
<div class="card-select-grid">
{{#each atouts}}
<label class="card-option">
<input type="checkbox" name="atout" value="{{this.id}}" data-value="{{this.valeurNumerique}}" />
<img src="{{this.img}}" alt="{{this.name}}" />
<span>{{this.name}} ({{this.valeurNumerique}})</span>
</label>
{{else}}
<p class="no-cards">{{localize "HAMALRON.Sortilege.noAtout"}}</p>
{{/each}}
</div>
<div class="card-total">
<label>{{localize "HAMALRON.Sortilege.atoutTotal"}} :</label>
<span id="total-atouts">0</span>
</div>
</fieldset>
{{#if peutUtiliserCoupe}}
<fieldset>
<legend>{{localize "HAMALRON.Sortilege.selectCoupe"}}</legend>
<p class="hint">{{localize "HAMALRON.Sortilege.coupeHint"}}</p>
<div class="card-select-grid">
{{#each cartesCoupe}}
<label class="card-option">
<input type="checkbox" name="coupe" value="{{this.id}}" data-value="{{this.valeurNumerique}}" />
<img src="{{this.img}}" alt="{{this.name}}" />
<span>{{this.name}} ({{this.valeurNumerique}})</span>
</label>
{{else}}
<p class="no-cards">{{localize "HAMALRON.Sortilege.noCoupe"}}</p>
{{/each}}
</div>
<div class="card-total">
<label>{{localize "HAMALRON.Sortilege.coupeTotal"}} :</label>
<span id="total-coupe">0</span>
</div>
</fieldset>
{{/if}}
<fieldset class="result-row">
<legend>{{localize "HAMALRON.Sortilege.total"}}</legend>
<div class="total-display">
<span>{{localize "HAMALRON.Sortilege.playerTotal"}} : <strong id="total-joueur">0</strong></span>
</div>
</fieldset>
</div>
+9
View File
@@ -36,8 +36,17 @@
<span class="categorie" data-tooltip="Catégorie">{{upperFirst
item.system.categorie
}}</span>
<span class="niveau" data-tooltip="Niveau requis">{{upperFirst
item.system.niveauRequis
}}</span>
<div class="controls">
<a
data-tooltip="{{localize 'HAMALRON.Roll.cast'}}"
data-action="castSortilege"
data-item-id="{{item.id}}"
data-item-uuid="{{item.uuid}}"
><i class="fas fa-wand-magic-sparkles"></i></a>
<a
data-tooltip="{{localize 'HAMALRON.Edit'}}"
data-action="edit"
+37 -1
View File
@@ -11,7 +11,13 @@
</div>
<fieldset>
<legend>{{localize "HAMALRON.Label.information"}}</legend>
{{formField systemFields.categorie value=system.categorie localize=true}}
{{formField systemFields.niveauRequis value=system.niveauRequis localize=true}}
{{formField systemFields.concentration value=system.concentration localize=true}}
{{formField systemFields.portee value=system.portee localize=true}}
{{formField systemFields.duree value=system.duree localize=true}}
{{formField systemFields.conditions value=system.conditions localize=true}}
</fieldset>
<fieldset>
@@ -25,4 +31,34 @@
}}
</fieldset>
</section>
<fieldset>
<legend>{{localize "HAMALRON.Label.effects"}}</legend>
<label>{{localize "HAMALRON.Label.amateur"}}</label>
{{formInput
systemFields.effetAmateur
enriched=enrichedEffetAmateur
value=system.effetAmateur
name="system.effetAmateur"
toggled=true
}}
<label>{{localize "HAMALRON.Label.competent"}}</label>
{{formInput
systemFields.effetCompetent
enriched=enrichedEffetCompetent
value=system.effetCompetent
name="system.effetCompetent"
toggled=true
}}
<label>{{localize "HAMALRON.Label.expert"}}</label>
{{formInput
systemFields.effetExpert
enriched=enrichedEffetExpert
value=system.effetExpert
name="system.effetExpert"
toggled=true
}}
</fieldset>
</section>