Fixed armor

This commit is contained in:
WBHarry 2025-07-08 01:05:23 +02:00
parent f633c42aa8
commit b3472177da
8 changed files with 86 additions and 46 deletions

View file

@ -152,7 +152,15 @@ export default class DhCharacter extends BaseDataActor {
initial: null
}),
weapon: new fields.SchemaField({
/* Unimplemented
-> Should remove the lowest damage dice from weapon damage
-> Reflect this in the chat message somehow so players get feedback that their choice is helping them.
*/
dropLowestDamageDice: new fields.BooleanField({ initial: false }),
/* Unimplemented
-> Should flip any lowest possible dice rolls for weapon damage to highest
-> Reflect this in the chat message somehow so players get feedback that their choice is helping them.
*/
flipMinDiceValue: new fields.BooleanField({ intial: false })
}),
runeWard: new fields.BooleanField({ initial: false })
@ -302,6 +310,13 @@ export default class DhCharacter extends BaseDataActor {
);
}
get armorApplicableDamageTypes() {
return {
physical: !this.rules.damageReduction.magical,
magical: !this.rules.damageReduction.physical
};
}
static async unequipBeforeEquip(itemToEquip) {
const primary = this.primaryWeapon,
secondary = this.secondaryWeapon;
@ -368,6 +383,7 @@ export default class DhCharacter extends BaseDataActor {
}
const armor = this.armor;
this.armorScore = this.armor ? this.armor.system.baseScore + (this.bonuses.armorScore ?? 0) : 0; // Bonuses to armorScore won't have been applied yet. Need to solve in documentPreparation somehow
this.damageThresholds = {
major: armor
? armor.system.baseThresholds.major + this.levelData.level.current
@ -395,7 +411,6 @@ export default class DhCharacter extends BaseDataActor {
this.rules.damageReduction.maxArmorMarked.total =
this.rules.damageReduction.maxArmorMarked.value + this.rules.damageReduction.maxArmorMarked.bonus;
this.armorScore = this.armor ? this.armor.system.baseScore + (this.bonuses.armorScore ?? 0) : 0;
this.resources.hitPoints.maxTotal = (this.class.value?.system?.hitPoints ?? 0) + this.resources.hitPoints.bonus;
this.resources.stress.maxTotal = this.resources.stress.max + this.resources.stress.bonus;
this.evasion.total = (this.class?.evasion ?? 0) + this.evasion.bonus;

View file

@ -22,7 +22,7 @@ export default class DHArmor extends BaseDataItem {
tier: new fields.NumberField({ required: true, integer: true, initial: 1, min: 1 }),
equipped: new fields.BooleanField({ initial: false }),
baseScore: new fields.NumberField({ integer: true, initial: 0 }),
features: new fields.ArrayField(
armorFeatures: new fields.ArrayField(
new fields.SchemaField({
value: new fields.StringField({
required: true,
@ -44,25 +44,22 @@ export default class DHArmor extends BaseDataItem {
};
}
get featureInfo() {
return this.feature ? CONFIG.DH.ITEM.armorFeatures[this.feature] : null;
}
async _preUpdate(changes, options, user) {
const allowed = await super._preUpdate(changes, options, user);
if (allowed === false) return false;
if (changes.system.features) {
const removed = this.features.filter(x => !changes.system.features.includes(x));
const added = changes.system.features.filter(x => !this.features.includes(x));
if (changes.system.armorFeatures) {
const removed = this.armorFeatures.filter(x => !changes.system.armorFeatures.includes(x));
const added = changes.system.armorFeatures.filter(x => !this.armorFeatures.includes(x));
const effectIds = [];
const actionIds = [];
for (var feature of removed) {
for (var effectId of feature.effectIds) {
await this.parent.effects.get(effectId).delete();
}
changes.system.actions = this.actions.filter(x => !feature.actionIds.includes(x._id));
effectIds.push(...feature.effectIds);
actionIds.push(...feature.actionIds);
}
await this.parent.deleteEmbeddedDocuments('ActiveEffect', effectIds);
changes.system.actions = this.actions.filter(x => !actionIds.includes(x._id));
for (var feature of added) {
const featureData = armorFeatures[feature.value];