feat(damageThresholds): PCs use armor base + current level

This commit is contained in:
JimCanE 2025-05-23 23:08:42 +02:00
parent 504e2ca0f2
commit 2313c4a18c
3 changed files with 24 additions and 42 deletions

View file

@ -5,6 +5,22 @@ import DhpLevelup from '../levelup.mjs';
import AncestrySelectionDialog from '../ancestrySelectionDialog.mjs';
import DaggerheartSheet from './daggerheart-sheet.mjs';
function computeDamageThresholds(armor, currentLevel) {
if (!armor) {
return {
major: currentLevel,
severe: currentLevel * 2
};
}
const {
baseThresholds: { major = 0, severe = 0 }
} = armor.system;
return {
major: major + currentLevel,
severe: severe + currentLevel
};
}
const { ActorSheetV2 } = foundry.applications.sheets;
export default class PCSheet extends DaggerheartSheet(ActorSheetV2) {
constructor(options = {}) {
@ -286,6 +302,11 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) {
context.inventory = Array(1).fill(Array(5).fill([]));
}
this.document.damageThresholds = computeDamageThresholds(
context.source.items.find(x => x.type === 'armor'),
context.source.system.levelData.currentLevel
);
context.classFeatures = (
this.multiclassFeatureSetSelected
? this.document.system.multiclassFeatures