fvtt-rolemaster-frp/module/sheets/apps/rmss_dice_roller.js

86 lines
2.5 KiB
JavaScript
Raw Normal View History

2024-07-26 14:15:51 +02:00
import {
roll_one_to_onehundred,
roll_low_open_ended,
roll_high_open_ended,
roll_open_ended
} from "./rmss_dice_roller_rolls.js";
import {
getOpenEndedRollModifier,
processOpenEndedSixtySixRoll,
processOpenEndedRoll,
processHighOpenEndedRoll,
processLowOpenEndedRoll
} from "./rmss_dice_roller_processing.js";
export default class RMSSToolsDiceRoller extends FormApplication {
constructor(itemName, characterBonus) {
super();
this.itemName = itemName;
this.characterBonus = characterBonus;
this.rollType = [
{value: "one_to_onehundred", text: "1-100", selected: false},
{value: "open_ended", text: "Open-Ended", selected: true},
{value: "high_open_ended", text: "High Open-Ended", selected: false},
{value: "low_open_ended", text: "Low Open-Ended", selected: false}
];
}
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["form"],
title: "Rolemaster Dice Roller",
popOut: true,
width: 380,
height: 210,
template: "systems/fvtt-rolemaster-frp/templates/sheets/apps/app_dice_roller.html"
});
}
getData() {
// Send data to the template
return {
itemName: this.itemName,
characterBonus: this.characterBonus,
selectOptions: this.rollType,
};
}
activateListeners(html) {
super.activateListeners(html);
}
async _updateObject(event, formData) {
console.log("Rolling Dice");
console.log(formData);
console.log(event);
switch (formData.rollType) {
case "one_to_onehundred":
this.roll_one_to_onehundred();
break;
case "open_ended":
this.roll_open_ended();
break;
case "high_open_ended":
this.roll_high_open_ended();
break;
case "low_open_ended":
this.roll_low_open_ended();
break;
}
}
}
RMSSToolsDiceRoller.prototype.roll_one_to_onehundred = roll_one_to_onehundred;
RMSSToolsDiceRoller.prototype.roll_low_open_ended = roll_low_open_ended;
RMSSToolsDiceRoller.prototype.roll_high_open_ended = roll_high_open_ended;
RMSSToolsDiceRoller.prototype.roll_open_ended = roll_open_ended;
RMSSToolsDiceRoller.prototype.getOpenEndedRollModifier =
getOpenEndedRollModifier;
RMSSToolsDiceRoller.prototype.processOpenEndedSixtySixRoll =
processOpenEndedSixtySixRoll;
RMSSToolsDiceRoller.prototype.processOpenEndedRoll = processOpenEndedRoll;
RMSSToolsDiceRoller.prototype.processHighOpenEndedRoll =
processHighOpenEndedRoll;
RMSSToolsDiceRoller.prototype.processLowOpenEndedRoll = processLowOpenEndedRoll;