Update release

This commit is contained in:
LeRatierBretonnien 2023-03-28 15:41:15 +02:00
parent 0368be050b
commit b9b8fa7c0d
5 changed files with 56 additions and 42 deletions

View File

@ -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)
}

View File

@ -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"

View File

@ -345,6 +345,7 @@
"endurance": 0,
"hasroll": false,
"roll": 0,
"computebody": false,
"items": {}
}
},

View File

@ -135,7 +135,7 @@
<ul class="stat-list alternate-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-field-label-long-img">
<label class="">{{upperFirst key}} Maneuvers</label>
<label class="">{{upperFirst key}} Standard Maneuver</label>
</span>
<span class="item-field-label-short">
<label class="short-label">PHA</label>

View File

@ -6,4 +6,8 @@
<li class="flexrow"><label class="item-field-label-long">Roll</label>
<input type="text" class="item-field-label-medium" name="system.roll" value="{{system.roll}}" data-dtype="Number"/>
</li>
<li class="flexrow"><label class="item-field-label-long">Computes BODY ?</label>
<label class="item-field-label-medium"><input type="checkbox" name="system.computebody" {{checked system.computebody}}/></label>
</li>
{{/if}}