This commit is contained in:
2021-02-09 23:32:55 +01:00
parent 92f8fe4ee8
commit 42af291a7c
25 changed files with 587 additions and 62 deletions

View File

@ -2,7 +2,10 @@
import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
/* -------------------------------------------- */
export class SoSUtility {
const severity2malus = { "none": 0, "light": -1, "moderate": -2, "severe": -3, "critical": -4};
/* -------------------------------------------- */
export class SoSUtility {
/* -------------------------------------------- */
static async preloadHandlebarsTemplates() {
@ -16,6 +19,8 @@ import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
'systems/foundryvtt-shadows-over-sol/templates/item-sheet.html',
'systems/foundryvtt-shadows-over-sol/templates/item-geneline-sheet.html',
'systems/foundryvtt-shadows-over-sol/templates/item-subculture-sheet.html',
'systems/foundryvtt-shadows-over-sol/templates/item-weapon-sheet.html',
'systems/foundryvtt-shadows-over-sol/templates/item-commongear-sheet.html',
'systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html'
]
@ -82,6 +87,23 @@ import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
d.render(true);
}
/* -------------------------------------------- */
static getConsequenceMalus(severity) {
return severity2malus[severity] ?? 0;
}
/* -------------------------------------------- */
static computeEncumbrance( items) {
let trappings = items.filter( item => item.type == 'gear' || item.type == 'armor' || item.type == 'weapon' );
let sumEnc = 0;
for (let object of trappings) {
if ( (!object.data.worn) && (!object.data.neg) && (!object.data.containerid || object.data.containerid == "") ) {
sumEnc += (object.big > 0) ? object.big : 1;
}
}
return sumEnc;
}
/* -------------------------------------------- */
static closeAction(event) {
let uniqId = event.currentTarget.attributes['data-uniq-id'].value;