feat: ajoute la règle Fortune dans les jets
Règle : si Fortune > 0, le joueur peut cocher 'Fortune' pour lancer 1d8 + 8 au lieu de 2d8 (contraint les probabilités vers le haut). - character.mjs : passe fortuneValue dans roll.prompt() - roll.mjs : checkbox Fortune, formule 1d8 + 8 + totalModifier si cochée - roll-dialog.hbs : bloc Fortune (visible si fortuneValue > 0), preview mis à jour - chat-message.hbs : affiche '+8' dans la zone dés, ligne formule avec badge Fortune - roll.less : styles .form-fortune-row, .fl-mod.fortune, .fortune-fixed-badge - lang/fr.json : Roll.fortune/fortuneBonus/fortuneFixed/usedFortune Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -144,7 +144,11 @@
|
|||||||
"visibilityPublic": "Public",
|
"visibilityPublic": "Public",
|
||||||
"visibilityGM": "MJ uniquement",
|
"visibilityGM": "MJ uniquement",
|
||||||
"visibilitySelf": "Secret (moi)",
|
"visibilitySelf": "Secret (moi)",
|
||||||
"skillValue": "Valeur de compétence"
|
"skillValue": "Valeur de compétence",
|
||||||
|
"fortune": "Utiliser la Fortune",
|
||||||
|
"fortuneBonus": "1d8 + 8 au lieu de 2d8",
|
||||||
|
"fortuneFixed": "Bonus fixe Fortune",
|
||||||
|
"usedFortune": "Fortune utilisée (1d8+8)"
|
||||||
},
|
},
|
||||||
"Moon": {
|
"Moon": {
|
||||||
"none": "Aucune phase",
|
"none": "Aucune phase",
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export class CelestopolRoll extends Roll {
|
|||||||
const skillValue = options.skillValue ?? 0
|
const skillValue = options.skillValue ?? 0
|
||||||
const woundLevelId = options.woundLevel ?? 0
|
const woundLevelId = options.woundLevel ?? 0
|
||||||
const destGaugeFull = options.destGaugeFull ?? false
|
const destGaugeFull = options.destGaugeFull ?? false
|
||||||
|
const fortuneValue = options.fortuneValue ?? 0
|
||||||
const woundLabel = woundLevelId > 0
|
const woundLabel = woundLevelId > 0
|
||||||
? game.i18n.localize(SYSTEM.WOUND_LEVELS[woundLevelId]?.label ?? "")
|
? game.i18n.localize(SYSTEM.WOUND_LEVELS[woundLevelId]?.label ?? "")
|
||||||
: null
|
: null
|
||||||
@@ -59,6 +60,7 @@ export class CelestopolRoll extends Roll {
|
|||||||
destGaugeFull,
|
destGaugeFull,
|
||||||
defaultRollMoonDie: options.rollMoonDie ?? false,
|
defaultRollMoonDie: options.rollMoonDie ?? false,
|
||||||
modifierChoices,
|
modifierChoices,
|
||||||
|
fortuneValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = await foundry.applications.handlebars.renderTemplate(
|
const content = await foundry.applications.handlebars.renderTemplate(
|
||||||
@@ -98,10 +100,15 @@ export class CelestopolRoll extends Roll {
|
|||||||
const modifier = parseInt(rollContext.modifier ?? 0) || 0
|
const modifier = parseInt(rollContext.modifier ?? 0) || 0
|
||||||
const aspectMod = parseInt(rollContext.aspectModifier ?? 0) || 0
|
const aspectMod = parseInt(rollContext.aspectModifier ?? 0) || 0
|
||||||
const useDestin = destGaugeFull && (rollContext.useDestin === true || rollContext.useDestin === "true")
|
const useDestin = destGaugeFull && (rollContext.useDestin === true || rollContext.useDestin === "true")
|
||||||
|
const useFortune = fortuneValue > 0 && (rollContext.useFortune === true || rollContext.useFortune === "true")
|
||||||
const rollMoonDie = rollContext.rollMoonDie === true || rollContext.rollMoonDie === "true"
|
const rollMoonDie = rollContext.rollMoonDie === true || rollContext.rollMoonDie === "true"
|
||||||
|
|
||||||
|
// Fortune : 1d8 + 8 ; Destin : 3d8 ; sinon : 2d8
|
||||||
const nbDice = useDestin ? 3 : 2
|
const nbDice = useDestin ? 3 : 2
|
||||||
const totalModifier = skillValue + woundMalus + aspectMod + modifier
|
const totalModifier = skillValue + woundMalus + aspectMod + modifier
|
||||||
const formula = buildFormula(nbDice, totalModifier)
|
const formula = useFortune
|
||||||
|
? buildFormula(1, totalModifier + 8)
|
||||||
|
: buildFormula(nbDice, totalModifier)
|
||||||
|
|
||||||
// Jet du dé de lune séparé (narratif)
|
// Jet du dé de lune séparé (narratif)
|
||||||
let moonDieResult = null
|
let moonDieResult = null
|
||||||
@@ -121,7 +128,8 @@ export class CelestopolRoll extends Roll {
|
|||||||
modifier,
|
modifier,
|
||||||
aspectMod,
|
aspectMod,
|
||||||
useDestin,
|
useDestin,
|
||||||
nbDice,
|
useFortune,
|
||||||
|
nbDice: useFortune ? 1 : nbDice,
|
||||||
formula,
|
formula,
|
||||||
rollMode: rollContext.visibility ?? "publicroll",
|
rollMode: rollContext.visibility ?? "publicroll",
|
||||||
rollMoonDie,
|
rollMoonDie,
|
||||||
@@ -245,6 +253,7 @@ export class CelestopolRoll extends Roll {
|
|||||||
aspectMod: this.options.aspectMod ?? 0,
|
aspectMod: this.options.aspectMod ?? 0,
|
||||||
skillValue,
|
skillValue,
|
||||||
useDestin: this.options.useDestin ?? false,
|
useDestin: this.options.useDestin ?? false,
|
||||||
|
useFortune: this.options.useFortune ?? false,
|
||||||
nbDice: this.options.nbDice ?? diceResults.length,
|
nbDice: this.options.nbDice ?? diceResults.length,
|
||||||
woundMalus,
|
woundMalus,
|
||||||
woundLabel,
|
woundLabel,
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ export default class CelestopolCharacter extends foundry.abstract.TypeDataModel
|
|||||||
difficulty: this.prefs.difficulty,
|
difficulty: this.prefs.difficulty,
|
||||||
rollMoonDie: this.prefs.rollMoonDie ?? false,
|
rollMoonDie: this.prefs.rollMoonDie ?? false,
|
||||||
destGaugeFull: this.destin.lvl >= 8,
|
destGaugeFull: this.destin.lvl >= 8,
|
||||||
|
fortuneValue: this.attributs.fortune.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,6 +285,81 @@
|
|||||||
|
|
||||||
.form-visibility label { color: #888; }
|
.form-visibility label { color: #888; }
|
||||||
|
|
||||||
|
// ── Ligne Fortune ──
|
||||||
|
.form-fortune-row {
|
||||||
|
border: 1px solid rgba(12,76,12,0.4);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: rgba(12,76,12,0.06);
|
||||||
|
padding: 7px 10px;
|
||||||
|
|
||||||
|
.fortune-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
input[type="checkbox"] {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
border: 2px solid var(--cel-border, #7a5c20);
|
||||||
|
border-radius: 2px;
|
||||||
|
background: white;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&:checked {
|
||||||
|
background: var(--cel-green, #0c4c0c);
|
||||||
|
border-color: var(--cel-green, #0c4c0c);
|
||||||
|
&::after {
|
||||||
|
content: "⚜";
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 0.6em;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fortune-icon {
|
||||||
|
font-size: 1.1em;
|
||||||
|
color: var(--cel-green, #0c4c0c);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fortune-text {
|
||||||
|
flex: 1;
|
||||||
|
.fortune-main {
|
||||||
|
font-family: var(--cel-font-title, "CopaseticNF", serif);
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: var(--cel-green, #0c4c0c);
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.fortune-bonus {
|
||||||
|
font-size: 0.72em;
|
||||||
|
color: var(--cel-border, #7a5c20);
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fortune-badge {
|
||||||
|
font-size: 0.8em;
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--cel-green, #0c4c0c);
|
||||||
|
background: rgba(12,76,12,0.12);
|
||||||
|
border: 1px solid rgba(12,76,12,0.3);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 1px 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── Prévisualisation ──
|
// ── Prévisualisation ──
|
||||||
.dice-preview {
|
.dice-preview {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -431,6 +506,8 @@
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
.fl-mod { color: #444; font-weight: bold; }
|
.fl-mod { color: #444; font-weight: bold; }
|
||||||
|
.fl-mod.fortune { color: var(--cel-green, #0c4c0c); font-weight: bold; }
|
||||||
|
.fl-mod.wound { color: #922; }
|
||||||
.fl-asp { color: var(--cel-orange, #e07b00); font-weight: bold; }
|
.fl-asp { color: var(--cel-orange, #e07b00); font-weight: bold; }
|
||||||
.fl-sep { font-weight: bold; color: var(--cel-border, #7a5c20); margin: 0 2px; }
|
.fl-sep { font-weight: bold; color: var(--cel-border, #7a5c20); margin: 0 2px; }
|
||||||
.fl-eq { color: #aaa; }
|
.fl-eq { color: #aaa; }
|
||||||
@@ -487,6 +564,22 @@
|
|||||||
border-top: 1px dashed var(--cel-border, #7a5c20);
|
border-top: 1px dashed var(--cel-border, #7a5c20);
|
||||||
|
|
||||||
.used-destin { font-weight: bold; }
|
.used-destin { font-weight: bold; }
|
||||||
|
.used-fortune { font-weight: bold; color: var(--cel-green, #0c4c0c); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Fortune fixe badge dans zone dés ──
|
||||||
|
.fortune-fixed-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 2px solid var(--cel-green, #0c4c0c);
|
||||||
|
background: rgba(12,76,12,0.1);
|
||||||
|
color: var(--cel-green, #0c4c0c);
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.9em;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Résultat dé de lune ──
|
// ── Résultat dé de lune ──
|
||||||
|
|||||||
@@ -20,14 +20,25 @@
|
|||||||
{{#each diceResults as |die|}}
|
{{#each diceResults as |die|}}
|
||||||
<span class="die-face d8 {{#if (eq die 8)}}max{{/if}}{{#if (eq die 1)}}min{{/if}}">{{die}}</span>
|
<span class="die-face d8 {{#if (eq die 8)}}max{{/if}}{{#if (eq die 1)}}min{{/if}}">{{die}}</span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{#if useFortune}}<span class="fortune-fixed-badge">+8</span>{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{!-- Formule détaillée --}}
|
{{!-- Formule détaillée --}}
|
||||||
<div class="formula-line">
|
<div class="formula-line">
|
||||||
<span class="fl-label">{{localize "CELESTOPOL.Roll.formula"}} :</span>
|
<span class="fl-label">{{localize "CELESTOPOL.Roll.formula"}} :</span>
|
||||||
|
{{#if useFortune}}
|
||||||
|
<span class="fl-ndice">1d8</span>
|
||||||
|
<span class="fl-op">+</span>
|
||||||
|
<span class="fl-mod fortune" title="{{localize "CELESTOPOL.Roll.fortuneFixed"}}">8</span>
|
||||||
|
{{else}}
|
||||||
<span class="fl-ndice">{{nbDice}}d8</span>
|
<span class="fl-ndice">{{nbDice}}d8</span>
|
||||||
|
{{/if}}
|
||||||
<span class="fl-eq"> = </span>
|
<span class="fl-eq"> = </span>
|
||||||
<span class="fl-sum">{{diceSum}}</span>
|
<span class="fl-sum">{{diceSum}}</span>
|
||||||
|
{{#if useFortune}}
|
||||||
|
<span class="fl-op">+</span>
|
||||||
|
<span class="fl-mod fortune">8</span>
|
||||||
|
{{/if}}
|
||||||
{{#if skillValue}}
|
{{#if skillValue}}
|
||||||
<span class="fl-op">+</span>
|
<span class="fl-op">+</span>
|
||||||
<span class="fl-mod" title="{{localize "CELESTOPOL.Roll.skillValue"}}">{{skillValue}}</span>
|
<span class="fl-mod" title="{{localize "CELESTOPOL.Roll.skillValue"}}">{{skillValue}}</span>
|
||||||
@@ -62,12 +73,17 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{!-- Infos bonus (Destin, Aspect) --}}
|
{{!-- Infos bonus (Destin, Fortune, Aspect) --}}
|
||||||
{{#if useDestin}}
|
{{#if useDestin}}
|
||||||
<div class="used-info">
|
<div class="used-info">
|
||||||
<span class="used-destin">✦ {{localize "CELESTOPOL.Roll.usedDestin"}}</span>
|
<span class="used-destin">✦ {{localize "CELESTOPOL.Roll.usedDestin"}}</span>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if useFortune}}
|
||||||
|
<div class="used-info">
|
||||||
|
<span class="used-fortune">⚜ {{localize "CELESTOPOL.Roll.usedFortune"}}</span>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{!-- Résultat du Dé de la Lune (narratif) --}}
|
{{!-- Résultat du Dé de la Lune (narratif) --}}
|
||||||
{{#if hasMoonDie}}
|
{{#if hasMoonDie}}
|
||||||
|
|||||||
@@ -82,6 +82,21 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{!-- Fortune (1d8+8) — seulement si Fortune > 0 --}}
|
||||||
|
{{#if fortuneValue}}
|
||||||
|
<div class="form-fortune-row">
|
||||||
|
<label class="fortune-toggle" for="useFortune">
|
||||||
|
<input type="checkbox" id="useFortune" name="useFortune">
|
||||||
|
<span class="fortune-icon">⚜</span>
|
||||||
|
<span class="fortune-text">
|
||||||
|
<span class="fortune-main">{{localize "CELESTOPOL.Roll.fortune"}}</span>
|
||||||
|
<span class="fortune-bonus">{{localize "CELESTOPOL.Roll.fortuneBonus"}}</span>
|
||||||
|
</span>
|
||||||
|
<span class="fortune-badge">{{fortuneValue}}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{!-- Visibilité --}}
|
{{!-- Visibilité --}}
|
||||||
<div class="form-row-line form-visibility">
|
<div class="form-row-line form-visibility">
|
||||||
<label for="visibility">{{localize "CELESTOPOL.Roll.visibility"}}</label>
|
<label for="visibility">{{localize "CELESTOPOL.Roll.visibility"}}</label>
|
||||||
@@ -114,18 +129,25 @@
|
|||||||
const modifier = parseInt(wrap.querySelector('#modifier')?.value ?? 0) || 0;
|
const modifier = parseInt(wrap.querySelector('#modifier')?.value ?? 0) || 0;
|
||||||
const aspectMod = parseInt(wrap.querySelector('#aspectModifier')?.value ?? 0) || 0;
|
const aspectMod = parseInt(wrap.querySelector('#aspectModifier')?.value ?? 0) || 0;
|
||||||
const useDestin = wrap.querySelector('#useDestin')?.checked;
|
const useDestin = wrap.querySelector('#useDestin')?.checked;
|
||||||
|
const useFortune= wrap.querySelector('#useFortune')?.checked;
|
||||||
const ndice = useDestin ? 3 : 2;
|
const ndice = useDestin ? 3 : 2;
|
||||||
const totalMod = skillVal + woundMalus + modifier + aspectMod;
|
const totalMod = skillVal + woundMalus + modifier + aspectMod;
|
||||||
|
|
||||||
let formula = `${ndice}d8`;
|
let formula;
|
||||||
if (totalMod > 0) formula += ` + ${totalMod}`;
|
if (useFortune) {
|
||||||
if (totalMod < 0) formula += ` − ${Math.abs(totalMod)}`;
|
const fm = totalMod + 8;
|
||||||
|
formula = `1d8` + (fm > 0 ? ` + ${fm}` : fm < 0 ? ` − ${Math.abs(fm)}` : ``);
|
||||||
|
} else {
|
||||||
|
formula = `${ndice}d8`;
|
||||||
|
if (totalMod > 0) formula += ` + ${totalMod}`;
|
||||||
|
if (totalMod < 0) formula += ` − ${Math.abs(totalMod)}`;
|
||||||
|
}
|
||||||
|
|
||||||
const previewEl = wrap.querySelector('#preview-formula');
|
const previewEl = wrap.querySelector('#preview-formula');
|
||||||
if (previewEl) previewEl.textContent = formula;
|
if (previewEl) previewEl.textContent = formula;
|
||||||
}
|
}
|
||||||
|
|
||||||
wrap.querySelectorAll('#modifier, #aspectModifier, #useDestin').forEach(el => {
|
wrap.querySelectorAll('#modifier, #aspectModifier, #useDestin, #useFortune').forEach(el => {
|
||||||
el.addEventListener('change', update);
|
el.addEventListener('change', update);
|
||||||
el.addEventListener('input', update);
|
el.addEventListener('input', update);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user