import { RdDCarac } from "../rdd-carac.js" import { RollPartCheckbox } from "./roll-part-checkbox.mjs" export const PART_APPELMORAL = "appelmoral" export class RollPartAppelMoral extends RollPartCheckbox { get code() { return PART_APPELMORAL } get useCheckboxTemplate() { return false } get isDefaultChecked() { return false } visible(rollData) { return rollData.active.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.current.carac.key) } restore(rollData) { this.getCurrent(rollData).checked = this.getSaved(rollData).checked ?? false } store(rollData, targetData) { this.setSaved(targetData, { checked: this.getCurrent(rollData).checked }) } loadRefs(rollData) { const refs = this.getRefs(rollData) refs.moral = rollData.active.actor.getMoralTotal() refs.label = refs.moral > 0 ? "Appel au moral" : "Énergie du désespoir" } getCheckboxIcon(rollData) { const refs = this.getRefs(rollData) if (refs.moral > 0) { return '' } if (refs.moral < 0) { return '' } return '' } getCheckboxLabel(rollData) { return "Appel au moral" } getCheckboxValue(rollData) { return 1 } }