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

32 lines
867 B
JavaScript

import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"
const PART_TRICHER = "tricher"
export class RollPartTricher extends RollPart {
get code() { return PART_TRICHER }
get section() { return ROLLDIALOG_SECTION.CONDITIONS }
visible(rollData) { return game.user.isGM }
prepareContext(rollData) {
const current = this.getCurrent(rollData)
if (current.resultat == undefined) {
current.resultat = -1
}
}
getAjustements(rollData) {
rollData.current.resultat = this.getCurrent(rollData).resultat
return []
}
async _onRender(rollDialog, context, options) {
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
input?.addEventListener("change", e => {
this.getCurrent(rollDialog.rollData).resultat = parseInt(e.currentTarget.value)
})
}
}