Fix: valeurs par défaut après la sélection

This commit is contained in:
2026-03-03 17:58:52 +01:00
parent 4fc06a449c
commit 490de5882b
3 changed files with 26 additions and 13 deletions

View File

@@ -1,5 +1,9 @@
# 13.0
## 13.0.31 - Les choix multiples d'Illysis
- les défauts de caractéristique/difficulté des compétences ne sont pris que si aucun autre choix n'est fait
## 13.0.30 - Le pansement d'Illysis
- les soins d'un joueur à l'autre fonctionne de nouveau

View File

@@ -3,7 +3,7 @@ import { Misc } from "../misc.js"
import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_DIFF } from "./roll-part-diff.mjs"
import { RollPartSelect } from "./roll-part-select.mjs"
import { ROLLDIALOG_SECTION } from "./roll-part.mjs"
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"
export const PART_COMP = "comp"
@@ -45,8 +45,10 @@ export class RollPartComp extends RollPartSelect {
this.$selectComp(rollData)
if (rollData.type.current == PART_COMP && selectedComp) {
const current = this.getCurrent(rollData)
this.rollPartCarac.selectByKey(rollData, current.comp.system.defaut_carac)
this.rollPartDiff.setDiff(rollData, current.comp.system.default_diffLibre)
const selectedCarac = RollPart.getSelectedPart(rollData, PART_CARAC)
const selectedDiff = RollPart.getSelectedPart(rollData, PART_DIFF)
this.rollPartCarac.selectByKey(rollData, selectedCarac?.key ?? current.comp.system.defaut_carac)
this.rollPartDiff.setDiff(rollData, selectedDiff?.value ?? current.comp.system.default_diffLibre)
}
}

View File

@@ -5,11 +5,11 @@ export const ROLLDIALOG_SECTION = {
CHOIX: 'choix',
CONDITIONS: 'conditions',
AJUSTEMENTS: 'ajustements',
}
}
export class RollPart {
static settingKey(rollPart, key) { return `roll-part-${rollPart.code}.${key}` }
get code() { throw new Error(`Pas dse code définie pour ${this}`) }
get name() { return this.code }
/** la section de la fenêtre ou le paramêtre apparaît */
@@ -17,30 +17,37 @@ export class RollPart {
get priority() { return 0 /* TODO */ }
/** le template handlebars pour affichage */
get template() { return `systems/foundryvtt-reve-de-dragon/templates/roll/roll-part-${this.code}.hbs` }
static getSelectedPart(rollData, code) {
return rollData.selected[code] ?? {}
}
static setSelectedPart(rollData, code, saved) {
rollData.selected[code] = saved
}
/** l'acteur actif du jet */
getActor(rollData) { return rollData.active.actor }
/** le conteneur de données du RollPart */
getRefs(rollData) {
return rollData.refs[this.code]
}
}
/** les informations de sélection du paramètre */
getCurrent(rollData) {
return rollData.current[this.code]
}
}
setCurrent(rollData, current) {
rollData.current[this.code] = current
}
}
/** les informations minimales représentant la sélection dans le rollData permettant de restaurer la fenêtre */
getSelected(rollData) { return this.getSaved(rollData) }
getSaved(rollData) {
return rollData.selected[this.code] ?? {}
}
return RollPart.getSelectedPart(rollData, this.code)
}
setSaved(rollData, saved) {
rollData.selected[this.code] = saved
}
RollPart.setSelectedPart(rollData, this.code, saved)
}
restore(rollData) { }