From b9b8fa7c0da4e6367cbab71fa7e13b7827f69598 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Tue, 28 Mar 2023 15:41:15 +0200 Subject: [PATCH] Update release --- modules/hero6-utility.js | 87 ++++++++++++--------- system.json | 4 +- template.json | 1 + templates/actors/actor-sheet.hbs | 2 +- templates/partials/partial-item-hasroll.hbs | 4 + 5 files changed, 56 insertions(+), 42 deletions(-) diff --git a/modules/hero6-utility.js b/modules/hero6-utility.js index bf2b67b..8bcaa2d 100644 --- a/modules/hero6-utility.js +++ b/modules/hero6-utility.js @@ -22,12 +22,12 @@ export class Hero6Utility { }) Handlebars.registerHelper('exists', function (val) { return val != null && val != undefined; - }); + }); Handlebars.registerHelper('includes', function (array, val) { return array.includes(val); }) Handlebars.registerHelper('upper', function (text) { - if (text) { + if (text) { return text.toUpperCase(); } return text @@ -46,14 +46,14 @@ export class Hero6Utility { return parseInt(a) * parseInt(b); }) Handlebars.registerHelper('locationLabel', function (key) { - return __locationNames[key] + return __locationNames[key] }) Handlebars.registerHelper('isSkillCustom', function (key) { - if (key == "custom" ) { + if (key == "custom") { return true; } return false - }) + }) this.gameSettings() @@ -82,15 +82,15 @@ export class Hero6Utility { /*-------------------------------------------- */ static getDerivatedDiceFormulas(value) { - let rollFormula = Math.floor(value/5) +"d6" - let displayFormula = Math.floor(value/5) - if ( value % 5 > 2) { + let rollFormula = Math.floor(value / 5) + "d6" + let displayFormula = Math.floor(value / 5) + if (value % 5 > 2) { rollFormula += "+round(1d6/2)" displayFormula += " 1/2d6" } else { displayFormula += "d6" } - return {rollFormula:rollFormula, displayFormula: displayFormula} + return { rollFormula: rollFormula, displayFormula: displayFormula } } /*-------------------------------------------- */ static upperFirst(text) { @@ -308,13 +308,40 @@ export class Hero6Utility { } } + /* -------------- ----------------------------- */ + static computeBodyValue(roll) { + 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 + } + } + } + return bodyValue + } + + /* -------------------------------------------- */ static async rollHero6(rollData) { let actor = game.actors.get(rollData.actorId) // ability/save/size => 0 - let diceFormula = "3d6" + let diceFormula = "3d6" let target = 10 if (rollData.charac) { target = rollData.charac.roll @@ -323,7 +350,7 @@ export class Hero6Utility { target = rollData.item.roll || rollData.item.system.roll } target += rollData.bonusMalus - + // Performs roll console.log("Roll formula", diceFormula) let myRoll = rollData.roll @@ -331,6 +358,7 @@ export class Hero6Utility { myRoll = new Roll(diceFormula).roll({ async: false }) await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) } + rollData.roll = myRoll rollData.target = target rollData.diceFormula = diceFormula @@ -339,47 +367,28 @@ export class Hero6Utility { if (rollData.result <= target) { rollData.isSuccess = true } - if ( myRoll.terms[0].total == 3) { // Always a success + if (myRoll.terms[0].total == 3) { // Always a success rollData.isSuccess = true } - if ( myRoll.terms[0].total == 18) { // Always a failure + if (myRoll.terms[0].total == 18) { // Always a failure rollData.isSuccess = false } rollData.margin = target - rollData.result + if (rollData.item && rollData.item.system.computebody) { + rollData.bodyValue = this.computeBody(myRoll) + } + this.outputRollMessage(rollData) } /* -------------- ----------------------------- */ - static processDirectRoll(rollData ) { - let roll = new Roll(rollData.rollFormula).roll({async: false}) + 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 + rollData.bodyValue = this.computeBody(rollData.roll) this.outputRollMessage(rollData) } diff --git a/system.json b/system.json index ddde425..0555c58 100644 --- a/system.json +++ b/system.json @@ -91,7 +91,7 @@ "styles": [ "styles/simple.css" ], - "version": "10.0.32", + "version": "10.0.33", "compatibility": { "minimum": "10", "verified": "10", @@ -99,7 +99,7 @@ }, "title": "Hero System v6 for FoundrtVTT (Official)", "manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/raw/branch/main/system.json", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.32.zip", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.33.zip", "url": "https://www.uberwald.me/gitea/uberwald/", "background": "images/ui/hro6_welcome_page.webp", "id": "fvtt-hero-system-6" diff --git a/template.json b/template.json index 6703762..28d5d06 100644 --- a/template.json +++ b/template.json @@ -345,6 +345,7 @@ "endurance": 0, "hasroll": false, "roll": 0, + "computebody": false, "items": {} } }, diff --git a/templates/actors/actor-sheet.hbs b/templates/actors/actor-sheet.hbs index f1c01fa..20561c3 100644 --- a/templates/actors/actor-sheet.hbs +++ b/templates/actors/actor-sheet.hbs @@ -135,7 +135,7 @@