Weapons and Armor are now stored like any other item on the PC. Added equip/unequip logic.

This commit is contained in:
WBHarry 2025-05-25 20:56:11 +02:00
parent 71319f2b74
commit 8e92b5f6d9
13 changed files with 121 additions and 70 deletions

View file

@ -242,15 +242,15 @@ export default class DhpPC extends foundry.abstract.TypeDataModel {
}
get armor() {
return this.parent.items.find(x => x.type === 'armor');
return this.parent.items.find(x => x.type === 'armor' && x.system.equipped);
}
get activeWeapons() {
get equippedWeapons() {
const primaryWeapon = this.parent.items.find(
x => x.type === 'weapon' && x.system.active && !x.system.secondary
x => x.type === 'weapon' && x.system.equipped && !x.system.secondary
);
const secondaryWeapon = this.parent.items.find(
x => x.type === 'weapon' && x.system.active && x.system.secondary
x => x.type === 'weapon' && x.system.equipped && x.system.secondary
);
return {
primary: this.#weaponData(primaryWeapon),
@ -325,16 +325,19 @@ export default class DhpPC extends foundry.abstract.TypeDataModel {
);
}
//Should not be done in data?
#weaponData(weapon) {
return weapon
? {
id: weapon.id,
name: weapon.name,
trait: CONFIG.daggerheart.ACTOR.abilities[weapon.system.trait].name, //Should not be done in data?
trait: game.i18n.localize(CONFIG.daggerheart.ACTOR.abilities[weapon.system.trait].label),
range: CONFIG.daggerheart.GENERAL.range[weapon.system.range],
damage: {
value: weapon.system.damage.value,
type: CONFIG.daggerheart.GENERAL.damageTypes[weapon.system.damage.type]
},
burden: weapon.system.burden,
feature: CONFIG.daggerheart.ITEM.weaponFeatures[weapon.system.feature],
img: weapon.img,
uuid: weapon.uuid