Merge branch 'master' into master
This commit is contained in:
+46
-15
@@ -79,12 +79,14 @@ export class DeltaGreenActorSheet extends ActorSheet {
|
||||
// Can add extra buttons to form header here if necessary
|
||||
_getHeaderButtons(){
|
||||
let buttons = super._getHeaderButtons();
|
||||
let label = "";
|
||||
let label = "Roll Luck";
|
||||
let label2 = "Luck";
|
||||
try{
|
||||
label = game.i18n.translations.DG.RollLuck;
|
||||
label2 = game.i18n.translations.DG.Luck;
|
||||
}
|
||||
catch{
|
||||
label = "Roll Luck"
|
||||
ui.notifications.warn('Missing translation key for either DG.RollLuck or DG.Luck key.')
|
||||
}
|
||||
|
||||
buttons = [
|
||||
@@ -92,7 +94,7 @@ export class DeltaGreenActorSheet extends ActorSheet {
|
||||
label: label,
|
||||
class: "test-extra-icon",
|
||||
icon: "fas fa-dice",
|
||||
onclick: (ev) => sendPercentileTestToChat(this.actor, "Luck", 50)
|
||||
onclick: (ev) => sendPercentileTestToChat(this.actor, label2, 50)
|
||||
}].concat(buttons);
|
||||
|
||||
//buttons = [
|
||||
@@ -161,7 +163,7 @@ export class DeltaGreenActorSheet extends ActorSheet {
|
||||
|
||||
// Drag events for macros.
|
||||
if (this.actor.owner) {
|
||||
let handler = ev => this._onDragItemStart(ev);
|
||||
let handler = ev => this._onDragStart(ev);
|
||||
html.find('li.item').each((i, li) => {
|
||||
if (li.classList.contains("inventory-header")) return;
|
||||
li.setAttribute("draggable", true);
|
||||
@@ -203,29 +205,29 @@ export class DeltaGreenActorSheet extends ActorSheet {
|
||||
let htmlContent = "";
|
||||
|
||||
htmlContent += `<div>`;
|
||||
htmlContent += ` <label>${game.i18n.translations.DG.Skills.SkillGroup}:</label>`;
|
||||
htmlContent += ` <label>${game.i18n.translations.DG?.Skills?.SkillGroup ?? "Skill Group"}:</label>`;
|
||||
htmlContent += ` <select name="new-type-skill-group" />`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG.TypeSkills.Art}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG.TypeSkills.Craft}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG.TypeSkills.ForeignLanguage}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG.TypeSkills.MilitaryScience}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG.TypeSkills.Pilot}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG.TypeSkills.Science}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG.TypeSkills.Other}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG?.TypeSkills?.Craft ?? "Craft"}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG?.TypeSkills?.ForeignLanguage ?? "Foreign Language"}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG?.TypeSkills?.MilitaryScience ?? "Military Science"}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG?.TypeSkills?.Pilot ?? "Pilot"}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG?.TypeSkills?.Science ?? "Science"}</option>`;
|
||||
htmlContent += ` <option>${game.i18n.translations.DG?.TypeSkills?.Other ?? "Other"}</option>`;
|
||||
htmlContent += ` </select>`;
|
||||
htmlContent += `</div>`;
|
||||
|
||||
htmlContent += `<div>`;
|
||||
htmlContent += ` <label>${game.i18n.translations.DG.Skills.SkillName}</label>`;
|
||||
htmlContent += ` <label>${game.i18n.translations.DG?.Skills.SkillName ?? "Skill Name"}</label>`;
|
||||
htmlContent += ` <input type="text" name="new-type-skill-label" />`;
|
||||
htmlContent += `</div>`;
|
||||
|
||||
new Dialog({
|
||||
content: htmlContent,
|
||||
title: game.i18n.translations.DG.Skills.AddTypedOrCustomSkill,
|
||||
title: game.i18n.translations.DG?.Skills?.AddTypedOrCustomSkill ?? "Add Typed or Custom Skill",
|
||||
buttons: {
|
||||
add:{
|
||||
label: game.i18n.translations.DG.Skills.AddSkill,
|
||||
label: game.i18n.translations.DG?.Skills?.AddSkill ?? "Add Skill",
|
||||
callback: btn =>{
|
||||
let newTypeSkillLabel = btn.find("[name='new-type-skill-label']").val();
|
||||
let newTypeSkillGroup = btn.find("[name='new-type-skill-group']").val();
|
||||
@@ -405,4 +407,33 @@ export class DeltaGreenActorSheet extends ActorSheet {
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
_onDragStart(event) {
|
||||
const li = event.currentTarget;
|
||||
if ( event.target.classList.contains("entity-link") ) return;
|
||||
|
||||
// Create drag data
|
||||
const dragData = {
|
||||
actorId: this.actor.id,
|
||||
sceneId: this.actor.isToken ? canvas.scene?.id : null,
|
||||
tokenId: this.actor.isToken ? this.actor.token.id : null
|
||||
};
|
||||
|
||||
// Owned Items
|
||||
if ( li.dataset.itemId ) {
|
||||
const item = this.actor.items.get(li.dataset.itemId);
|
||||
dragData.type = "Item";
|
||||
dragData.data = item.data;
|
||||
}
|
||||
|
||||
// Active Effect
|
||||
if ( li.dataset.effectId ) {
|
||||
const effect = this.actor.effects.get(li.dataset.effectId);
|
||||
dragData.type = "ActiveEffect";
|
||||
dragData.data = effect.data;
|
||||
}
|
||||
|
||||
// Set data transfer
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
|
||||
}
|
||||
}
|
||||
|
||||
+57
-1
@@ -3,6 +3,7 @@ import { DeltaGreenActor } from "./actor/actor.js";
|
||||
import { DeltaGreenActorSheet } from "./actor/actor-sheet.js";
|
||||
import { DeltaGreenItem } from "./item/item.js";
|
||||
import { DeltaGreenItemSheet } from "./item/item-sheet.js";
|
||||
import { sendPercentileTestToChat, sendLethalityTestToChat, sendDamageRollToChat } from "./roll/roll.js";
|
||||
|
||||
import { preloadHandlebarsTemplates } from "./templates.js";
|
||||
|
||||
@@ -11,7 +12,9 @@ Hooks.once('init', async function() {
|
||||
game.deltagreen = {
|
||||
DeltaGreenActor,
|
||||
DeltaGreenItem,
|
||||
rollItemMacro
|
||||
rollItemMacro,
|
||||
rollItemSkillCheckMacro,
|
||||
rollSkillMacro
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -153,9 +156,62 @@ function rollItemMacro(itemName) {
|
||||
let actor;
|
||||
if (speaker.token) actor = game.actors.tokens[speaker.token];
|
||||
if (!actor) actor = game.actors.get(speaker.actor);
|
||||
|
||||
if(!actor) return ui.notifications.warn('Must have an Actor selected first.');
|
||||
|
||||
const item = actor ? actor.items.find(i => i.name === itemName) : null;
|
||||
if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item named ${itemName}`);
|
||||
|
||||
// Trigger the item roll
|
||||
return item.roll();
|
||||
}
|
||||
|
||||
function rollItemSkillCheckMacro(itemName) {
|
||||
const speaker = ChatMessage.getSpeaker();
|
||||
let actor;
|
||||
if (speaker.token) actor = game.actors.tokens[speaker.token];
|
||||
if (!actor) actor = game.actors.get(speaker.actor);
|
||||
|
||||
if(!actor) return ui.notifications.warn('Must have an Actor selected first.');
|
||||
|
||||
const item = actor ? actor.items.find(i => i.name === itemName) : null;
|
||||
if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item named ${itemName}`);
|
||||
|
||||
let skillName = item.data.data.skill.toString();
|
||||
|
||||
let skill = actor.data.data.skills[skillName];
|
||||
let translatedSkillLabel = "";
|
||||
|
||||
try{
|
||||
translatedSkillLabel = game.i18n.localize("DG.Skills." + skillName)
|
||||
}
|
||||
catch{
|
||||
translatedSkillLabel = skillName;
|
||||
}
|
||||
|
||||
sendPercentileTestToChat(actor, translatedSkillLabel, skill.proficiency);
|
||||
}
|
||||
|
||||
function rollSkillMacro(skillName) {
|
||||
const speaker = ChatMessage.getSpeaker();
|
||||
let actor;
|
||||
if (speaker.token) actor = game.actors.tokens[speaker.token];
|
||||
if (!actor) actor = game.actors.get(speaker.actor);
|
||||
|
||||
if(!actor) return ui.notifications.warn('Must have an Actor selected first.');
|
||||
|
||||
let skill = actor.data.data.skills[skillName];
|
||||
|
||||
if(!skill) return ui.notifications.warn('Bad skill name passed to macro.');
|
||||
|
||||
let translatedSkillLabel = "";
|
||||
|
||||
try{
|
||||
translatedSkillLabel = game.i18n.localize("DG.Skills." + skillName)
|
||||
}
|
||||
catch{
|
||||
translatedSkillLabel = skillName;
|
||||
}
|
||||
|
||||
sendPercentileTestToChat(actor, translatedSkillLabel, skill.proficiency);
|
||||
}
|
||||
+247
-220
@@ -27,174 +27,155 @@ export function sendPercentileTestToChat(actor, skill, target, inhuman_flag=fals
|
||||
}
|
||||
}
|
||||
|
||||
if(isCritical){
|
||||
resultString = `${game.i18n.localize("DG.Roll.Critical")} `;
|
||||
}
|
||||
|
||||
if(isSuccess){
|
||||
resultString += `${game.i18n.localize("DG.Roll.Success")}`;
|
||||
|
||||
if(isCritical){
|
||||
resultString = `${game.i18n.localize("DG.Roll.Critical")} `;
|
||||
resultString = resultString.toUpperCase() + '!';
|
||||
styleOverride="color: green";
|
||||
}
|
||||
|
||||
if(isSuccess){
|
||||
resultString += `${game.i18n.localize("DG.Roll.Success")}`;
|
||||
|
||||
if(isCritical){
|
||||
resultString = resultString.toUpperCase() + '!';
|
||||
styleOverride="color: green";
|
||||
}
|
||||
}
|
||||
else{
|
||||
resultString += `${game.i18n.localize("DG.Roll.Failure")}`;
|
||||
|
||||
if(isCritical){
|
||||
resultString = resultString.toUpperCase() + '!';
|
||||
styleOverride="color: red";
|
||||
}
|
||||
}
|
||||
|
||||
html = `<div class="dice-roll">`
|
||||
html += ` <div class="dice-result">`
|
||||
html += ` <div style="${styleOverride}" class="dice-formula">${resultString}</div>`
|
||||
html += ` <div class="dice-tooltip">`
|
||||
html += ` <section class="tooltip-part">`
|
||||
html += ` <div class="dice">`
|
||||
html += ` <p class="part-formula">`
|
||||
html += ` ${roll.formula}`
|
||||
html += ` <span class="part-total">${roll.total}</span>`
|
||||
html += ` </p>`
|
||||
html += ` <ol class="dice-rolls">`
|
||||
html += ` <li class="roll die ${roll.formula}">${roll.total}</li>`
|
||||
html += ` </ol>`
|
||||
html += ` </div>`
|
||||
html += ` </section>`
|
||||
html += ` </div>`
|
||||
html += ` <h4 class="dice-total">${roll.total}</h4>`
|
||||
html += `</div>`
|
||||
|
||||
let chatData = {
|
||||
speaker: ChatMessage.getSpeaker({actor: actor}),
|
||||
content: html,
|
||||
flavor: label,
|
||||
type: CHAT_MESSAGE_TYPES.ROLL,
|
||||
roll: roll,
|
||||
rollMode: game.settings.get("core", "rollMode")
|
||||
};
|
||||
|
||||
// play the dice rolling sound, like a regular in-chat roll
|
||||
AudioHelper.play({src: "sounds/dice.wav", volume: 0.8, autoplay: true, loop: false}, true);
|
||||
|
||||
ChatMessage.create(chatData, {});
|
||||
}
|
||||
else{
|
||||
resultString += `${game.i18n.localize("DG.Roll.Failure")}`;
|
||||
|
||||
export function skillCheckResultIsCritical(rollResult){
|
||||
let isCritical = false;
|
||||
|
||||
if(rollResult === 1 || rollResult === 100){
|
||||
// really good, or reeaaaally bad
|
||||
isCritical = true;
|
||||
}
|
||||
else if(rollResult % 11 === 0){
|
||||
// any matching dice are a crit, i.e. 11, 22, 33...99.
|
||||
isCritical = true;
|
||||
}
|
||||
|
||||
return isCritical;
|
||||
}
|
||||
|
||||
export function sendLethalityTestToChat(actor, weaponName, target){
|
||||
let roll = new Roll('1D100', actor.data.data).roll();
|
||||
let isCritical = false;
|
||||
let skillCheckTotal = roll.total;
|
||||
|
||||
|
||||
// page 57 of agent's handbook
|
||||
// For a failed lethality check, the damage on the tens die is a 10 for a roll of '0'. E.g. '30' + '0' = 13 damage.
|
||||
// Lethality rolls do not fumble or critically succeed, but the attack roll can.
|
||||
// In this situation, the lethality threshold doubles (e.g. 20% would become 40%),
|
||||
// and if the lethality roll fails, the damage is doubled per normal. However right now
|
||||
// the attack roll and damage roll are completely separate... Perhaps in the future, use a
|
||||
// button in the skill check roll to allow doubling this logic?
|
||||
|
||||
// try to determine what the d100 result would be as if it was two d10's being rolled
|
||||
let damageDie1 = Math.floor(skillCheckTotal / 10);
|
||||
let damageDie2 = skillCheckTotal - (damageDie1 * 10);
|
||||
if(damageDie2 === 0){
|
||||
// if the result is evenly divisible by 10 (e.g. 30, 40, 50...)
|
||||
// then the percentile die result was actually one lower than the calculation above would show.
|
||||
// For example, a '70' is actually a 60 + 10, so the damage die should be 6 + 10 = 16, not 7 + 0 = 7.
|
||||
damageDie1 -= 1;
|
||||
damageDie2 = 10;
|
||||
}
|
||||
|
||||
let damageDie1Label = damageDie1.toString();
|
||||
let damageDie2Label = damageDie2.toString();
|
||||
|
||||
if(damageDie1 === 0){
|
||||
// a roll of 00 on the tens part of the d100 counts as a ten if it becomes a damage die
|
||||
// Will leave the labeling as a '0' though, to be consistent with a regular d10 roll
|
||||
damageDie1 = 10;
|
||||
}
|
||||
|
||||
if(damageDie2 === 10){
|
||||
// keep the labelling consistent, show a '0' for a ten
|
||||
damageDie2Label = '0';
|
||||
}
|
||||
|
||||
let nonlethalDamage = damageDie1 + damageDie2;
|
||||
|
||||
let isLethal = false;
|
||||
let html = '';
|
||||
let label = `${game.i18n.localize("DG.Roll.Rolling")} ${game.i18n.localize("DG.Roll.Lethality").toUpperCase()} ${game.i18n.localize("DG.Roll.For")} ${weaponName.toUpperCase()} ${game.i18n.localize("DG.Roll.Target")} ${target}`;
|
||||
let resultString = '';
|
||||
let styleOverride = '';
|
||||
|
||||
if(skillCheckTotal <= target){
|
||||
isLethal = true;
|
||||
resultString = `${game.i18n.localize("DG.Roll.Lethal").toUpperCase()}`;
|
||||
if(isCritical){
|
||||
resultString = resultString.toUpperCase() + '!';
|
||||
styleOverride="color: red";
|
||||
}
|
||||
else{
|
||||
resultString = `${game.i18n.localize("DG.Roll.Failure")}`;
|
||||
}
|
||||
|
||||
html = `<div class="dice-roll">`;
|
||||
html += ` <div class="dice-result">`;
|
||||
html += ` <div style="${styleOverride}" class="dice-formula">${resultString}</div>`;
|
||||
html += ` <div class="dice-tooltip">`;
|
||||
html += ` <section class="tooltip-part">`;
|
||||
html += ` <div class="dice">`;
|
||||
html += ` <p class="part-formula">`;
|
||||
html += ` d100 ${game.i18n.localize("DG.Roll.Or").toUpperCase()} d10 + d10`;
|
||||
html += ` <span class="part-total">${roll.total}</span>`;
|
||||
html += ` </p>`;
|
||||
html += ` <ol class="dice-rolls">`;
|
||||
html += ` <li class="roll die d10">${damageDie1Label}</li>`;
|
||||
html += ` <li class="roll die d10">${damageDie2Label}</li>`;
|
||||
html += ` </ol>`;
|
||||
html += ` </div>`;
|
||||
html += ` </section>`;
|
||||
html += ` </div>`;
|
||||
html += ` <h4 class="dice-total">${roll.total} (${nonlethalDamage} ${game.i18n.localize("DG.Roll.Damage")})</h4>`;
|
||||
html += `</div>`;
|
||||
|
||||
let chatData = {
|
||||
speaker: ChatMessage.getSpeaker({actor: actor}),
|
||||
content: html,
|
||||
flavor: label,
|
||||
type: CHAT_MESSAGE_TYPES.ROLL,
|
||||
roll: roll,
|
||||
rollMode: game.settings.get("core", "rollMode")
|
||||
};
|
||||
|
||||
// play the dice rolling sound, like a regular in-chat roll
|
||||
AudioHelper.play({src: "sounds/dice.wav", volume: 0.8, autoplay: true, loop: false}, true);
|
||||
|
||||
ChatMessage.create(chatData, {});
|
||||
}
|
||||
|
||||
export function sendDamageRollToChat(actor, label, diceFormula){
|
||||
let roll = new Roll(diceFormula, actor.data.data);
|
||||
html = `<div class="dice-roll">`
|
||||
html += ` <div class="dice-result">`
|
||||
html += ` <div style="${styleOverride}" class="dice-formula">${resultString}</div>`
|
||||
html += ` <div class="dice-tooltip">`
|
||||
html += ` <section class="tooltip-part">`
|
||||
html += ` <div class="dice">`
|
||||
html += ` <p class="part-formula">`
|
||||
html += ` ${roll.formula}`
|
||||
html += ` <span class="part-total">${roll.total}</span>`
|
||||
html += ` </p>`
|
||||
html += ` <ol class="dice-rolls">`
|
||||
html += ` <li class="roll die ${roll.formula}">${roll.total}</li>`
|
||||
html += ` </ol>`
|
||||
html += ` </div>`
|
||||
html += ` </section>`
|
||||
html += ` </div>`
|
||||
html += ` <h4 class="dice-total">${roll.total}</h4>`
|
||||
html += `</div>`
|
||||
|
||||
label = `${game.i18n.localize("DG.Roll.RollingDamageFor")} ${label.toUpperCase()}`;
|
||||
let chatData = {
|
||||
speaker: ChatMessage.getSpeaker({actor: actor}),
|
||||
content: html,
|
||||
flavor: label,
|
||||
type: CHAT_MESSAGE_TYPES.ROLL,
|
||||
roll: roll,
|
||||
rollMode: game.settings.get("core", "rollMode")
|
||||
};
|
||||
|
||||
roll.roll().toMessage({
|
||||
speaker: ChatMessage.getSpeaker({ actor: actor }),
|
||||
// play the dice rolling sound, like a regular in-chat roll
|
||||
AudioHelper.play({src: "sounds/dice.wav", volume: 0.8, autoplay: true, loop: false}, true);
|
||||
|
||||
ChatMessage.create(chatData, {});
|
||||
}
|
||||
|
||||
export function skillCheckResultIsCritical(rollResult){
|
||||
let isCritical = false;
|
||||
|
||||
if(rollResult === 1 || rollResult === 100){
|
||||
// really good, or reeaaaally bad
|
||||
isCritical = true;
|
||||
}
|
||||
else if(rollResult % 11 === 0){
|
||||
// any matching dice are a crit, i.e. 11, 22, 33...99.
|
||||
isCritical = true;
|
||||
}
|
||||
|
||||
return isCritical;
|
||||
}
|
||||
|
||||
export function sendLethalityTestToChat(actor, weaponName, target){
|
||||
let roll = new Roll('1D100', actor.data.data).roll();
|
||||
let isCritical = false;
|
||||
let skillCheckTotal = roll.total;
|
||||
|
||||
|
||||
// page 57 of agent's handbook
|
||||
// For a failed lethality check, the damage on the tens die is a 10 for a roll of '0'. E.g. '30' + '0' = 13 damage.
|
||||
// Lethality rolls do not fumble or critically succeed, but the attack roll can.
|
||||
// In this situation, the lethality threshold doubles (e.g. 20% would become 40%),
|
||||
// and if the lethality roll fails, the damage is doubled per normal. However right now
|
||||
// the attack roll and damage roll are completely separate... Perhaps in the future, use a
|
||||
// button in the skill check roll to allow doubling this logic?
|
||||
|
||||
// try to determine what the d100 result would be as if it was two d10's being rolled
|
||||
let damageDie1 = Math.floor(skillCheckTotal / 10);
|
||||
let damageDie2 = skillCheckTotal - (damageDie1 * 10);
|
||||
if(damageDie2 === 0){
|
||||
// if the result is evenly divisible by 10 (e.g. 30, 40, 50...)
|
||||
// then the percentile die result was actually one lower than the calculation above would show.
|
||||
// For example, a '70' is actually a 60 + 10, so the damage die should be 6 + 10 = 16, not 7 + 0 = 7.
|
||||
damageDie1 -= 1;
|
||||
damageDie2 = 10;
|
||||
}
|
||||
|
||||
let damageDie1Label = damageDie1.toString();
|
||||
let damageDie2Label = damageDie2.toString();
|
||||
|
||||
if(damageDie1 === 0){
|
||||
// a roll of 00 on the tens part of the d100 counts as a ten if it becomes a damage die
|
||||
// Will leave the labeling as a '0' though, to be consistent with a regular d10 roll
|
||||
damageDie1 = 10;
|
||||
}
|
||||
|
||||
if(damageDie2 === 10){
|
||||
// keep the labelling consistent, show a '0' for a ten
|
||||
damageDie2Label = '0';
|
||||
}
|
||||
|
||||
let nonlethalDamage = damageDie1 + damageDie2;
|
||||
|
||||
let isLethal = false;
|
||||
let html = '';
|
||||
let label = `${game.i18n.localize("DG.Roll.Rolling")} <b>${game.i18n.localize("DG.Roll.Lethality").toUpperCase()}</b> ${game.i18n.localize("DG.Roll.For")} <b>${weaponName.toUpperCase()}</b> ${game.i18n.localize("DG.Roll.Target")} ${target}`;
|
||||
let resultString = '';
|
||||
let styleOverride = '';
|
||||
|
||||
if(skillCheckTotal <= target){
|
||||
isLethal = true;
|
||||
resultString = `${game.i18n.localize("DG.Roll.Lethal").toUpperCase()}`;
|
||||
styleOverride="color: red";
|
||||
}
|
||||
else{
|
||||
resultString = `${game.i18n.localize("DG.Roll.Failure")}`;
|
||||
}
|
||||
|
||||
html = `<div class="dice-roll">`;
|
||||
html += ` <div class="dice-result">`;
|
||||
html += ` <div style="${styleOverride}" class="dice-formula">${resultString}</div>`;
|
||||
html += ` <div class="dice-tooltip">`;
|
||||
html += ` <section class="tooltip-part">`;
|
||||
html += ` <div class="dice">`;
|
||||
html += ` <p class="part-formula">`;
|
||||
html += ` d100 ${game.i18n.localize("DG.Roll.Or").toUpperCase()} d10 + d10`;
|
||||
html += ` <span class="part-total">${roll.total}</span>`;
|
||||
html += ` </p>`;
|
||||
html += ` <ol class="dice-rolls">`;
|
||||
html += ` <li class="roll die d10">${damageDie1Label}</li>`;
|
||||
html += ` <li class="roll die d10">${damageDie2Label}</li>`;
|
||||
html += ` </ol>`;
|
||||
html += ` </div>`;
|
||||
html += ` </section>`;
|
||||
html += ` </div>`;
|
||||
html += ` <h4 class="dice-total">${roll.total} (${nonlethalDamage} ${game.i18n.localize("DG.Roll.Damage")})</h4>`;
|
||||
html += `</div>`;
|
||||
|
||||
let chatData = {
|
||||
speaker: ChatMessage.getSpeaker({actor: actor}),
|
||||
content: html,
|
||||
flavor: label,
|
||||
type: CHAT_MESSAGE_TYPES.ROLL,
|
||||
roll: roll,
|
||||
@@ -212,21 +193,61 @@ export function sendPercentileTestToChat(actor, skill, target, inhuman_flag=fals
|
||||
targetModifier: 20
|
||||
},
|
||||
};
|
||||
|
||||
let html = await renderTemplate(template, backingData);
|
||||
|
||||
new Dialog({
|
||||
content: html,
|
||||
title: game.i18n.localize("DG.ModifySkillRollDialogue.Title"),
|
||||
default: "roll",
|
||||
buttons: {
|
||||
roll:{
|
||||
label: game.i18n.translations.DG.Roll.Roll,
|
||||
// play the dice rolling sound, like a regular in-chat roll
|
||||
AudioHelper.play({src: "sounds/dice.wav", volume: 0.8, autoplay: true, loop: false}, true);
|
||||
|
||||
callback: html => {
|
||||
try{
|
||||
let targetModifier = html.find("[name='targetModifier']").val(); // this is text as a heads up
|
||||
|
||||
ChatMessage.create(chatData, {});
|
||||
}
|
||||
|
||||
export function sendDamageRollToChat(actor, label, diceFormula){
|
||||
let roll = new Roll(diceFormula, actor.data.data);
|
||||
|
||||
try{
|
||||
label = `${game.i18n.localize("DG.Roll.Rolling")} <b>${game.i18n.localize("DG.Roll.Damage").toUpperCase()}</b> ${game.i18n.localize("DG.Roll.For")} <b>${label.toUpperCase()}</b>`;
|
||||
}
|
||||
catch{
|
||||
label = `Rolling <b>DAMAGE</b> for <b>${label.toUpperCase()}</b>`
|
||||
}
|
||||
|
||||
roll.roll().toMessage({
|
||||
speaker: ChatMessage.getSpeaker({ actor: actor }),
|
||||
flavor: label,
|
||||
type: CHAT_MESSAGE_TYPES.ROLL,
|
||||
roll: roll,
|
||||
rollMode: game.settings.get("core", "rollMode")
|
||||
});
|
||||
}
|
||||
|
||||
export async function showModifyPercentileTestDialogue(actor, label, originalTarget, isLethalityTest){
|
||||
|
||||
let template = "systems/deltagreen/templates/dialog/modify-percentile-roll.html";
|
||||
let backingData = {
|
||||
data:{
|
||||
label: label,
|
||||
originalTarget: originalTarget,
|
||||
targetModifier: 20
|
||||
},
|
||||
};
|
||||
|
||||
let html = await renderTemplate(template, backingData);
|
||||
|
||||
new Dialog({
|
||||
content: html,
|
||||
title: game.i18n.localize("DG.ModifySkillRollDialogue.Title"),
|
||||
default: "roll",
|
||||
buttons: {
|
||||
roll:{
|
||||
label: game.i18n.translations.DG.Roll.Roll,
|
||||
|
||||
callback: html => {
|
||||
try{
|
||||
let targetModifier = html.find("[name='targetModifier']").val(); // this is text as a heads up
|
||||
|
||||
let newTarget = parseInt(originalTarget); // this should be an int, but technically the incoming value is text, so parse it just to be safe
|
||||
if(targetModifier.trim() != "" && !isNaN(targetModifier)){
|
||||
newTarget += parseInt(targetModifier);
|
||||
}
|
||||
let newTarget = parseInt(originalTarget); // this should be an int, but technically the incoming value is text, so parse it just to be safe
|
||||
if(targetModifier.trim() != "" && !isNaN(targetModifier)){
|
||||
newTarget += parseInt(targetModifier);
|
||||
@@ -238,65 +259,71 @@ export function sendPercentileTestToChat(actor, skill, target, inhuman_flag=fals
|
||||
else{
|
||||
sendPercentileTestToChat(actor, label, newTarget,inhuman_flag); //take care of inhuman stat, by default the value is false
|
||||
}
|
||||
if(isLethalityTest){
|
||||
sendLethalityTestToChat(actor, label, newTarget);
|
||||
}
|
||||
catch(ex){
|
||||
console.log(ex);
|
||||
else{
|
||||
sendPercentileTestToChat(actor, label, newTarget);
|
||||
}
|
||||
}
|
||||
catch(ex){
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
).render(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
).render(true);
|
||||
}
|
||||
|
||||
export async function showModifyDamageRollDialogue(actor, label, originalFormula){
|
||||
|
||||
let template = "systems/deltagreen/templates/dialog/modify-damage-roll.html";
|
||||
let backingData = {
|
||||
data:{
|
||||
label: label,
|
||||
originalFormula: originalFormula,
|
||||
outerModifier: "2 * ",
|
||||
innerModifier: "+ 0"
|
||||
},
|
||||
};
|
||||
|
||||
let html = await renderTemplate(template, backingData);
|
||||
export async function showModifyDamageRollDialogue(actor, label, originalFormula){
|
||||
|
||||
let template = "systems/deltagreen/templates/dialog/modify-damage-roll.html";
|
||||
let backingData = {
|
||||
data:{
|
||||
label: label,
|
||||
originalFormula: originalFormula,
|
||||
outerModifier: "2 * ",
|
||||
innerModifier: "+ 0"
|
||||
},
|
||||
};
|
||||
|
||||
let html = await renderTemplate(template, backingData);
|
||||
|
||||
new Dialog({
|
||||
content: html,
|
||||
title: game.i18n.localize("DG.ModifySkillRollDialogue.Title"),
|
||||
default: "roll",
|
||||
buttons: {
|
||||
roll:{
|
||||
label: game.i18n.translations.DG.Roll.Roll,
|
||||
new Dialog({
|
||||
content: html,
|
||||
title: game.i18n.localize("DG.ModifySkillRollDialogue.Title"),
|
||||
default: "roll",
|
||||
buttons: {
|
||||
roll:{
|
||||
label: game.i18n.translations.DG.Roll.Roll,
|
||||
|
||||
callback: html => {
|
||||
try{
|
||||
let outerModifier = html.find("[name='outerModifier']").val(); // this is text as a heads up
|
||||
let innerModifier = html.find("[name='innerModifier']").val(); // this is text as a heads up
|
||||
let modifiedBaseRoll = html.find("[name='originalFormula']").val(); // this is text as a heads up
|
||||
|
||||
if(innerModifier.replace(" ", "") === "+0"){
|
||||
innerModifier = "";
|
||||
}
|
||||
|
||||
let newRoll = "";
|
||||
if(outerModifier.trim() != ""){
|
||||
newRoll += outerModifier + "(" + modifiedBaseRoll + innerModifier.trim() + ")";
|
||||
}
|
||||
else{
|
||||
newRoll += modifiedBaseRoll + innerModifier.trim();
|
||||
}
|
||||
|
||||
sendDamageRollToChat(actor, label, newRoll);
|
||||
callback: html => {
|
||||
try{
|
||||
let outerModifier = html.find("[name='outerModifier']").val(); // this is text as a heads up
|
||||
let innerModifier = html.find("[name='innerModifier']").val(); // this is text as a heads up
|
||||
let modifiedBaseRoll = html.find("[name='originalFormula']").val(); // this is text as a heads up
|
||||
|
||||
if(innerModifier.replace(" ", "") === "+0"){
|
||||
innerModifier = "";
|
||||
}
|
||||
catch(ex){
|
||||
console.log(ex);
|
||||
|
||||
let newRoll = "";
|
||||
if(outerModifier.trim() != ""){
|
||||
newRoll += outerModifier + "(" + modifiedBaseRoll + innerModifier.trim() + ")";
|
||||
}
|
||||
else{
|
||||
newRoll += modifiedBaseRoll + innerModifier.trim();
|
||||
}
|
||||
|
||||
sendDamageRollToChat(actor, label, newRoll);
|
||||
}
|
||||
catch(ex){
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
).render(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
).render(true);
|
||||
}
|
||||
Reference in New Issue
Block a user