Fix: malus encombrement
This commit is contained in:
@@ -41,7 +41,7 @@ export class RollPartCheckbox extends RollPart {
|
||||
}
|
||||
|
||||
getCheckboxLabelAjustement(rollData) {
|
||||
return `${this.getCheckboxIcon(rollData)} ${this.getRefs(rollData).label}`
|
||||
return `${this.getCheckboxIcon(rollData)} ${this.getCheckboxLabel(rollData)}`
|
||||
}
|
||||
|
||||
async _onRender(rollDialog, context, options) {
|
||||
|
||||
@@ -15,18 +15,32 @@ export class RollPartEncTotal extends RollPartCheckbox {
|
||||
&& RdDItemCompetence.isMalusEncombrementTotal(rollData.current.comp?.key)
|
||||
}
|
||||
|
||||
loadRefs(rollData) {
|
||||
const refs = this.getRefs(rollData)
|
||||
refs.malusEnc = - Math.floor(rollData.active.actor.getEncTotal())
|
||||
const current = this.getCurrent(rollData)
|
||||
current.value = refs.malusEnc
|
||||
}
|
||||
|
||||
async _onRender(rollDialog, context, options) {
|
||||
super._onRender(rollDialog, context, options)
|
||||
|
||||
const inputMalusEnc = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="malusenc"]`)
|
||||
|
||||
|
||||
inputMalusEnc?.addEventListener("change", e => {
|
||||
this.getCurrent(rollDialog.rollData).value = parseInt(e.currentTarget.value)
|
||||
const malusEnc = Math.floor(e.currentTarget.value)
|
||||
const rollData = rollDialog.rollData
|
||||
const refs = this.getRefs(rollData)
|
||||
const current = this.getCurrent(rollData)
|
||||
if (refs.malusEnc == current.value) {
|
||||
current.value = malusEnc
|
||||
}
|
||||
refs.malusEnc = malusEnc
|
||||
rollDialog.render()
|
||||
})
|
||||
}
|
||||
|
||||
getCheckboxIcon(rollData) { return `<img src="${RDD_CONFIG.icons.surenc}">` }
|
||||
getCheckboxLabel(rollData) { return "Enc. total" }
|
||||
getCheckboxValue(rollData) { return - rollData.active.actor.getEncTotal() }
|
||||
getCheckboxValue(rollData) { return this.getCurrent(rollData).value }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user