Update combat tab
This commit is contained in:
@@ -20,6 +20,9 @@ export class Hero6Utility {
|
||||
Handlebars.registerHelper('count', function (list) {
|
||||
return list.length;
|
||||
})
|
||||
Handlebars.registerHelper('exists', function (val) {
|
||||
return val != null && val != undefined;
|
||||
});
|
||||
Handlebars.registerHelper('includes', function (array, val) {
|
||||
return array.includes(val);
|
||||
})
|
||||
@@ -78,12 +81,16 @@ export class Hero6Utility {
|
||||
|
||||
|
||||
/*-------------------------------------------- */
|
||||
static getDerivatedDiceValue(value) {
|
||||
let dices = Math.floor(value/5) +"d6"
|
||||
static getDerivatedDiceFormulas(value) {
|
||||
let rollFormula = Math.floor(value/5) +"d6"
|
||||
let displayFormula = Math.floor(value/5)
|
||||
if ( value % 5 > 2) {
|
||||
dices += "+1d3"
|
||||
rollFormula += "+round(1d6/2)"
|
||||
displayFormula += " 1/2d6"
|
||||
} else {
|
||||
displayFormula += "d6"
|
||||
}
|
||||
return dices
|
||||
return {rollFormula:rollFormula, displayFormula: displayFormula}
|
||||
}
|
||||
/*-------------------------------------------- */
|
||||
static upperFirst(text) {
|
||||
@@ -340,15 +347,53 @@ export class Hero6Utility {
|
||||
}
|
||||
rollData.margin = target - rollData.result
|
||||
|
||||
this.outputRollMessage(rollData)
|
||||
}
|
||||
|
||||
/* -------------- ----------------------------- */
|
||||
static processDirectRoll(rollData ) {
|
||||
let roll = new Roll(rollData.rollFormula).roll({async: false})
|
||||
rollData.roll = roll
|
||||
|
||||
// Compute BODY
|
||||
let bodyValue = 0
|
||||
for (let term of roll.terms) {
|
||||
if ( term.constructor.name == "Die") {
|
||||
for (let value of term.values) {
|
||||
if (value > 1) {
|
||||
bodyValue +=1
|
||||
}
|
||||
if (value == 6) {
|
||||
bodyValue +=1
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( term.constructor.name == "NumericTerm") {
|
||||
if (term.total > 1) {
|
||||
bodyValue +=1
|
||||
}
|
||||
if (term.total == 6) {
|
||||
bodyValue +=1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rollData.result = roll.total
|
||||
rollData.bodyValue = bodyValue
|
||||
|
||||
this.outputRollMessage(rollData)
|
||||
}
|
||||
|
||||
/* -------------- ----------------------------- */
|
||||
static async outputRollMessage(rollData) {
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-hero-system-6/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "rolldata", rollData)
|
||||
console.log("Rolldata result", rollData)
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* -------------- ----------------------------- */
|
||||
static sortArrayObjectsByName(myArray) {
|
||||
myArray.sort((a, b) => {
|
||||
let fa = a.name.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user