import { HawkmoonUtility } from "./hawkmoon-utility.js"; export class HawkmoonRollDialog extends Dialog { /* -------------------------------------------- */ static async create(actor, rollData ) { let options = { classes: ["HawkmoonDialog"], width: 320, height: 'fit-content', 'z-index': 99999 }; let html = await renderTemplate('systems/fvtt-hawkmoon-cyd/templates/roll-dialog-generic.html', rollData); return new HawkmoonRollDialog(actor, rollData, html, options ); } /* -------------------------------------------- */ constructor(actor, rollData, html, options, close = undefined) { let conf = { title: "Test de Capacité", content: html, buttons: { rolld10: { icon: '', label: "Lancer 1d10", callback: () => { this.roll("d10") } }, rolld20: { icon: '', label: "Lancer 1d20", callback: () => { this.roll("d20") } }, cancel: { icon: '', label: "Annuler", callback: () => { this.close() } } }, close: close } super(conf, options); this.actor = actor this.rollData = rollData } /* -------------------------------------------- */ roll ( dice) { this.rollData.mainDice = dice HawkmoonUtility.rollHawkmoon( this.rollData ) } /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html); var dialog = this; function onLoad() { } $(function () { onLoad(); }); html.find('#modificateur').change(async (event) => { this.rollData.modificateur = Number(event.currentTarget.value) }) html.find('#difficulte').change(async (event) => { this.rollData.difficulte = Number(event.currentTarget.value) }) html.find('#attrKey').change(async (event) => { this.rollData.attrKey = String(event.currentTarget.value) }) html.find('#select-maitrise').change(async (event) => { this.rollData.maitriseId = String(event.currentTarget.value) }) html.find('#competence-talents').change((event) => { this.rollData.selectedTalents = $('#competence-talents').val() }) html.find('#taille-cible').change((event) => { this.rollData.tailleCible = String(event.currentTarget.value) }) html.find('#tireur-deplacement').change((event) => { this.rollData.tireurDeplacement = String(event.currentTarget.value) }) html.find('#cible-couvert').change((event) => { this.rollData.cibleCouvert = String(event.currentTarget.value) }) html.find('#distance-tir').change((event) => { this.rollData.distanceTir = String(event.currentTarget.value) }) html.find('#bonus-malus-context').change((event) => { this.rollData.bonusMalusContext = Number(event.currentTarget.value) }) html.find('#defenseur-au-sol').change((event) => { this.rollData.defenseurAuSol = event.currentTarget.checked }) html.find('#defenseur-aveugle').change((event) => { this.rollData.defenseurAveugle = event.currentTarget.checked }) html.find('#defenseur-de-dos').change((event) => { this.rollData.defenseurDeDos = event.currentTarget.checked }) html.find('#defenseur-restreint').change((event) => { this.rollData.defenseurRestreint = event.currentTarget.checked }) html.find('#defenseur-immobilise').change((event) => { this.rollData.defenseurImmobilise = event.currentTarget.checked }) html.find('#attaque-charge').change((event) => { this.rollData.attaqueCharge = event.currentTarget.checked }) html.find('#attaque-desarme').change((event) => { this.rollData.attaqueDesarme = event.currentTarget.checked }) } }