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 '' } getCheckboxLabel(rollData) { return "Enc. total" } getCheckboxValue(rollData) { return - rollData.active.actor.getEncTotal() } }