Files
foundryvtt-reve-de-dragon/module/roll/roll-part-enctotal.mjs

32 lines
1.1 KiB
JavaScript

import { RdDItemCompetence } from "../item-competence.js"
import { RdDCarac } from "../rdd-carac.js"
import { RollPartCheckbox } from "./roll-part-checkbox.mjs"
const ENCTOTAL = "enctotal"
export class RollPartEncTotal extends RollPartCheckbox {
get code() { return ENCTOTAL }
get useCheckboxTemplate() { return false }
visible(rollData) {
return RdDCarac.isAgiliteOuDerobee(rollData.current.carac.key)
&& RdDItemCompetence.isMalusEncombrementTotal(rollData.current.comp?.key)
}
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)
rollDialog.render()
})
}
getCheckboxIcon(rollData) { return '<i class="fa-solid fa-weight-hanging"></i>' }
getCheckboxLabel(rollData) { return "Enc. total" }
getCheckboxValue(rollData) { return - rollData.active.actor.getEncTotal() }
}