Modificateur: select difficulté nommée (Évident→Malaisé→Très difficile…)

- Remplace le select -4..+4 par les niveaux Évident/Malaisé/Difficile/etc.
- 'Évident' = réussite automatique (valeur 'auto', pas de dé, force succès)
- Aspect garde son select numérique -4..+4
- Chat message affiche 'Réussite automatique' si autoSuccess
- Ajout CONTEXT_MODIFIER_CHOICES dans config + clés i18n Modifier.*

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-03-29 22:19:34 +02:00
parent 149bc4eb8b
commit 51206acac3
5 changed files with 49 additions and 8 deletions

View File

@@ -43,7 +43,12 @@ export class CelestopolRoll extends Roll {
? game.i18n.localize(SYSTEM.WOUND_LEVELS[woundLevelId]?.label ?? "")
: null
const modifierChoices = [-4, -3, -2, -1, 0, 1, 2, 3, 4].map(v => ({
const modifierChoices = SYSTEM.CONTEXT_MODIFIER_CHOICES.map(c => ({
id: c.id,
value: c.value,
label: game.i18n.localize(c.label),
}))
const aspectChoices = [-4, -3, -2, -1, 0, 1, 2, 3, 4].map(v => ({
value: v,
label: v > 0 ? `+${v}` : `${v}`,
}))
@@ -60,6 +65,7 @@ export class CelestopolRoll extends Roll {
destGaugeFull,
defaultRollMoonDie: options.rollMoonDie ?? false,
modifierChoices,
aspectChoices,
fortuneValue,
}
@@ -85,7 +91,9 @@ export class CelestopolRoll extends Roll {
}
function update() {
const modifier = parseInt(wrap.querySelector('#modifier')?.value ?? 0) || 0
const rawMod = wrap.querySelector('#modifier')?.value
const autoSucc = rawMod === "auto"
const modifier = autoSucc ? 0 : (parseInt(rawMod ?? 0) || 0)
const aspectMod = parseInt(wrap.querySelector('#aspectModifier')?.value ?? 0) || 0
const useDestin = wrap.querySelector('#useDestin')?.checked
const useFort = wrap.querySelector('#useFortune')?.checked
@@ -110,7 +118,9 @@ export class CelestopolRoll extends Roll {
const totalMod = skillValue + effWound + effMod + effAspect
let formula
if (useFort) {
if (autoSucc) {
formula = game.i18n.localize("CELESTOPOL.Roll.autoSuccess")
} else if (useFort) {
const fm = totalMod + 8
formula = `1d8` + (fm > 0 ? ` + ${fm}` : fm < 0 ? ` ${Math.abs(fm)}` : ``)
} else {
@@ -151,7 +161,8 @@ export class CelestopolRoll extends Roll {
const difficulty = rollContext.difficulty ?? "normal"
const diffConfig = SYSTEM.DIFFICULTY_CHOICES[difficulty] ?? SYSTEM.DIFFICULTY_CHOICES.normal
const modifier = parseInt(rollContext.modifier ?? 0) || 0
const autoSuccess = rollContext.modifier === "auto"
const modifier = autoSuccess ? 0 : (parseInt(rollContext.modifier ?? 0) || 0)
const aspectMod = parseInt(rollContext.aspectModifier ?? 0) || 0
const useDestin = destGaugeFull && (rollContext.useDestin === true || rollContext.useDestin === "true")
const useFortune = fortuneValue > 0 && (rollContext.useFortune === true || rollContext.useFortune === "true")
@@ -188,6 +199,7 @@ export class CelestopolRoll extends Roll {
modifier: effectiveModifier,
aspectMod: effectiveAspectMod,
woundMalus: effectiveWoundMalus,
autoSuccess,
useDestin,
useFortune,
puiserRessources,
@@ -259,6 +271,11 @@ export class CelestopolRoll extends Roll {
* - Marge < 0 → échec
*/
computeResult() {
if (this.options.autoSuccess) {
this.options.resultType = "success"
this.options.margin = null
return
}
const threshold = SYSTEM.DIFFICULTY_CHOICES[this.options.difficulty]?.value ?? 0
if (threshold === 0) {
this.options.resultType = "unknown"
@@ -331,6 +348,7 @@ export class CelestopolRoll extends Roll {
marginAbs: margin !== null ? Math.abs(margin) : null,
marginAbove: margin !== null && margin >= 0,
modifier: this.options.modifier ?? 0,
autoSuccess: this.options.autoSuccess ?? false,
aspectMod: this.options.aspectMod ?? 0,
skillValue,
useDestin: this.options.useDestin ?? false,