feat(armorItem): add base thresholds to armor (#21)

Co-authored-by: JimCanE <6275508-jimcane@users.noreply.gitlab.com>
This commit is contained in:
Emilio Jimenez 2025-05-23 17:56:55 +02:00 committed by GitHub
parent 30a3b5fa55
commit 820c2df1f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 55 additions and 36 deletions

View file

@ -910,7 +910,12 @@
"Armor": {
"BaseScore": "Base Score",
"Feature": "Feature",
"Description": "Description"
"Description": "Description",
"BaseThresholds": {
"Base": "Base Thresholds",
"Major": "Major Threshold",
"Severe": "Severe Threshold"
}
},
"Class": {
"Tabs": {

View file

@ -3,27 +3,37 @@ export default class DhpArmor extends foundry.abstract.TypeDataModel {
const fields = foundry.data.fields;
return {
baseScore: new fields.NumberField({ initial: 1, integer: true }),
feature: new fields.StringField({ choices: SYSTEM.ITEM.armorFeatures, integer: false, blank:true}),
feature: new fields.StringField({
choices: SYSTEM.ITEM.armorFeatures,
integer: false,
blank: true,
}),
marks: new fields.SchemaField({
max: new fields.NumberField({ initial: 6, integer: true }),
value: new fields.NumberField({ initial: 0, integer: true }),
}),
baseThresholds: new fields.SchemaField({
major: new fields.NumberField({ initial: 0, integer: true }),
severe: new fields.NumberField({ initial: 0, integer: true }),
}),
description: new fields.HTMLField({}),
}
};
}
get featureInfo() {
return this.feature ? CONFIG.daggerheart.ITEM.armorFeatures[this.feature] : null;
return this.feature
? CONFIG.daggerheart.ITEM.armorFeatures[this.feature]
: null;
}
prepareDerivedData(){
if(this.parent.parent){
prepareDerivedData() {
if (this.parent.parent) {
this.applyLevels();
}
}
// Currently bugged as it double triggers. Should get fixed in an updated foundry version.
applyLevels(){
applyLevels() {
// let armorBonus = 0;
// for(var level in this.parent.parent.system.levelData.levelups){
// var levelData = this.parent.parent.system.levelData.levelups[level];
@ -34,7 +44,6 @@ export default class DhpArmor extends foundry.abstract.TypeDataModel {
// }
// }
// }
// this.marks.max += armorBonus;
}
}

View file

@ -11,6 +11,11 @@
<section class="sheet-body">
{{formField systemFields.baseScore value=source.system.baseScore label=(localize "DAGGERHEART.Sheets.Armor.BaseScore") }}
{{formField systemFields.feature value=source.system.feature label=(localize "DAGGERHEART.Sheets.Armor.Feature") localize=true blank=""}}
<div class="armor-thresholds">
<h2>{{localize "DAGGERHEART.Sheets.Armor.BaseThresholds.Base"}}</h2>
{{ formField systemFields.baseThresholds.fields.major value=source.system.baseThresholds.major label=(localize "DAGGERHEART.Sheets.Armor.BaseThresholds.Major") }}/
{{ formField systemFields.baseThresholds.fields.severe value=source.system.baseThresholds.severe label=(localize "DAGGERHEART.Sheets.Armor.BaseThresholds.Severe") }}
</div>
<div class="feature-description">
<h2>{{localize "DAGGERHEART.Sheets.Armor.Description"}}</h2>
{{formInput systemFields.description value=source.system.description enriched=source.system.description localize=true toggled=true}}