Feature/167 damage types and resistances (#330)

* Add Resistances

* Relocate Damage Reduction

* Damage Types

* dmg type fallback

* Actor getRollData

* Remove comments
This commit is contained in:
Dapoulp 2025-07-12 20:13:09 +02:00 committed by GitHub
parent 3f4c884974
commit 812a5e8dd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 167 additions and 97 deletions

View file

@ -1,5 +1,12 @@
import DHBaseActorSettings from "../../applications/sheets/api/actor-setting.mjs";
const resistanceField = () =>
new foundry.data.fields.SchemaField({
resistance: new foundry.data.fields.BooleanField({ initial: false }),
immunity: new foundry.data.fields.BooleanField({ initial: false }),
reduction: new foundry.data.fields.NumberField({ integer: true, initial: 0 })
});
/**
* Describes metadata about the actor data model type
* @typedef {Object} ActorDataModelMetadata
@ -16,6 +23,7 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
type: 'base',
isNPC: true,
settingSheet: null,
hasResistances: true
};
}
@ -27,10 +35,16 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
/** @inheritDoc */
static defineSchema() {
const fields = foundry.data.fields;
const schema = {};
return {
description: new fields.HTMLField({ required: true, nullable: true })
};
if(this.metadata.isNPC)
schema.description = new fields.HTMLField({ required: true, nullable: true });
if(this.metadata.hasResistances)
schema.resistance = new fields.SchemaField({
physical: resistanceField(),
magical: resistanceField()
})
return schema;
}
/**