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
+4
View File
@@ -1,5 +1,9 @@
# 13.0 # 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 ## 13.0.30 - Le pansement d'Illysis
- les soins d'un joueur à l'autre fonctionne de nouveau - les soins d'un joueur à l'autre fonctionne de nouveau
+5 -3
View File
@@ -3,7 +3,7 @@ import { Misc } from "../misc.js"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_DIFF } from "./roll-part-diff.mjs" import { PART_DIFF } from "./roll-part-diff.mjs"
import { RollPartSelect } from "./roll-part-select.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" export const PART_COMP = "comp"
@@ -45,8 +45,10 @@ export class RollPartComp extends RollPartSelect {
this.$selectComp(rollData) this.$selectComp(rollData)
if (rollData.type.current == PART_COMP && selectedComp) { if (rollData.type.current == PART_COMP && selectedComp) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
this.rollPartCarac.selectByKey(rollData, current.comp.system.defaut_carac) const selectedCarac = RollPart.getSelectedPart(rollData, PART_CARAC)
this.rollPartDiff.setDiff(rollData, current.comp.system.default_diffLibre) 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)
} }
} }
+17 -10
View File
@@ -5,11 +5,11 @@ export const ROLLDIALOG_SECTION = {
CHOIX: 'choix', CHOIX: 'choix',
CONDITIONS: 'conditions', CONDITIONS: 'conditions',
AJUSTEMENTS: 'ajustements', AJUSTEMENTS: 'ajustements',
} }
export class RollPart { export class RollPart {
static settingKey(rollPart, key) { return `roll-part-${rollPart.code}.${key}` } static settingKey(rollPart, key) { return `roll-part-${rollPart.code}.${key}` }
get code() { throw new Error(`Pas dse code définie pour ${this}`) } get code() { throw new Error(`Pas dse code définie pour ${this}`) }
get name() { return this.code } get name() { return this.code }
/** la section de la fenêtre ou le paramêtre apparaît */ /** la section de la fenêtre ou le paramêtre apparaît */
@@ -17,30 +17,37 @@ export class RollPart {
get priority() { return 0 /* TODO */ } get priority() { return 0 /* TODO */ }
/** le template handlebars pour affichage */ /** le template handlebars pour affichage */
get template() { return `systems/foundryvtt-reve-de-dragon/templates/roll/roll-part-${this.code}.hbs` } 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 */ /** l'acteur actif du jet */
getActor(rollData) { return rollData.active.actor } getActor(rollData) { return rollData.active.actor }
/** le conteneur de données du RollPart */ /** le conteneur de données du RollPart */
getRefs(rollData) { getRefs(rollData) {
return rollData.refs[this.code] return rollData.refs[this.code]
} }
/** les informations de sélection du paramètre */ /** les informations de sélection du paramètre */
getCurrent(rollData) { getCurrent(rollData) {
return rollData.current[this.code] return rollData.current[this.code]
} }
setCurrent(rollData, current) { setCurrent(rollData, current) {
rollData.current[this.code] = current rollData.current[this.code] = current
} }
/** les informations minimales représentant la sélection dans le rollData permettant de restaurer la fenêtre */ /** les informations minimales représentant la sélection dans le rollData permettant de restaurer la fenêtre */
getSelected(rollData) { return this.getSaved(rollData) } getSelected(rollData) { return this.getSaved(rollData) }
getSaved(rollData) { getSaved(rollData) {
return rollData.selected[this.code] ?? {} return RollPart.getSelectedPart(rollData, this.code)
} }
setSaved(rollData, saved) { setSaved(rollData, saved) {
rollData.selected[this.code] = saved RollPart.setSelectedPart(rollData, this.code, saved)
} }
restore(rollData) { } restore(rollData) { }