mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Fixed weapons
This commit is contained in:
parent
286944d2e6
commit
ee89d5cb9e
5 changed files with 115 additions and 56 deletions
|
|
@ -763,32 +763,14 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
static async #toggleEquipItem(_event, button) {
|
||||
const item = await getDocFromElement(button);
|
||||
if (!item) return;
|
||||
if (item.system.equipped) {
|
||||
await item.update({ 'system.equipped': false });
|
||||
return;
|
||||
}
|
||||
|
||||
switch (item.type) {
|
||||
case 'armor':
|
||||
const currentArmor = this.document.system.armor;
|
||||
if (currentArmor) {
|
||||
await currentArmor.update({ 'system.equipped': false });
|
||||
}
|
||||
|
||||
await item.update({ 'system.equipped': true });
|
||||
break;
|
||||
case 'weapon':
|
||||
if (this.document.effects.find(x => !x.disabled && x.type === 'beastform')) {
|
||||
return ui.notifications.warn(
|
||||
game.i18n.localize('DAGGERHEART.UI.Notifications.beastformEquipWeapon')
|
||||
);
|
||||
}
|
||||
|
||||
await this.document.system.constructor.unequipBeforeEquip.bind(this.document.system)(item);
|
||||
|
||||
await item.update({ 'system.equipped': true });
|
||||
break;
|
||||
}
|
||||
const changedData = await this.document.toggleEquipItem(item);
|
||||
const removedData = changedData.filter(x => !x.add);
|
||||
this.document.update({
|
||||
'system.sidebarFavorites': [
|
||||
...this.document.system.sidebarFavorites.filter(x => removedData.every(r => r.item.id !== x.id))
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1042,6 +1024,6 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
|
||||
if (this.document.system.sidebarFavorites.some(x => x.id === item.id)) return;
|
||||
|
||||
this.document.update({ 'system.sidebarFavorites': [...this.document.system.sidebarFavorites, item] });
|
||||
this.document.setFavoriteItem(item, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -547,13 +547,20 @@ export default function DHApplicationMixin(Base) {
|
|||
name: 'Unfavorite',
|
||||
icon: 'fa-regular fa-star',
|
||||
condition: target => {
|
||||
return this.document.type === 'character' && target.closest('.items-sidebar-list');
|
||||
const doc = getDocFromElementSync(target);
|
||||
const isFavorited = this.document.system.sidebarFavorites.some(x => x.id === doc.id);
|
||||
return this.document.type === 'character' && isFavorited;
|
||||
},
|
||||
callback: async (target, _event) => {
|
||||
const doc = await getDocFromElement(target);
|
||||
this.document.update({
|
||||
'system.sidebarFavorites': this.document.system.sidebarFavorites.filter(x => x.id !== doc.id)
|
||||
});
|
||||
if (doc.type === 'domainCard') {
|
||||
} else {
|
||||
this.document.update({
|
||||
'system.sidebarFavorites': this.document.system.sidebarFavorites.filter(
|
||||
x => x.id !== doc.id
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -562,17 +569,16 @@ export default function DHApplicationMixin(Base) {
|
|||
icon: 'fa-solid fa-star',
|
||||
condition: target => {
|
||||
const doc = getDocFromElementSync(target);
|
||||
const isFavorited = this.document.system.sidebarFavorites.some(x => x.id === doc.id);
|
||||
return (
|
||||
!(doc instanceof game.system.api.documents.DhActiveEffect) &&
|
||||
this.document.type === 'character' &&
|
||||
!target.closest('.items-sidebar-list')
|
||||
!isFavorited
|
||||
);
|
||||
},
|
||||
callback: async (target, _event) => {
|
||||
const doc = await getDocFromElement(target);
|
||||
this.document.update({
|
||||
'system.sidebarFavorites': [...this.document.system.sidebarFavorites, doc]
|
||||
});
|
||||
this.document.setFavoriteItem(doc, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue