mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
Merged with main
This commit is contained in:
commit
58f96a36c9
44 changed files with 564 additions and 165 deletions
|
|
@ -11,7 +11,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
this.actor = actor;
|
||||
this.damage = damage;
|
||||
|
||||
const canApplyArmor = actor.system.armorApplicableDamageTypes[damageType];
|
||||
const canApplyArmor = damageType.every(t => actor.system.armorApplicableDamageTypes[t] === true);
|
||||
const maxArmorMarks = canApplyArmor
|
||||
? Math.min(
|
||||
actor.system.armorScore - actor.system.armor.system.marks.value,
|
||||
|
|
|
|||
|
|
@ -56,10 +56,6 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
id: 'effect',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/action-settings/effect.hbs'
|
||||
}
|
||||
/* form: {
|
||||
id: 'action',
|
||||
template: 'systems/daggerheart/templates/config/action.hbs'
|
||||
} */
|
||||
};
|
||||
|
||||
static TABS = {
|
||||
|
|
@ -183,7 +179,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
container = foundry.utils.getProperty(this.action.parent, this.action.systemPath);
|
||||
let newActions;
|
||||
if (Array.isArray(container)) {
|
||||
newActions = foundry.utils.getProperty(this.action.parent, this.action.systemPath).map(x => x.toObject()); // Find better way
|
||||
newActions = foundry.utils.getProperty(this.action.parent, this.action.systemPath).map(x => x.toObject());
|
||||
if (!newActions.findSplice(x => x._id === data._id, data)) newActions.push(data);
|
||||
} else newActions = data;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,12 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
window: {
|
||||
resizable: true
|
||||
},
|
||||
dragDrop: [],
|
||||
dragDrop: [
|
||||
{
|
||||
dragSelector: '[data-item-id][draggable="true"]',
|
||||
dropSelector: null
|
||||
}
|
||||
],
|
||||
contextMenus: [
|
||||
{
|
||||
handler: CharacterSheet._getContextMenuOptions,
|
||||
|
|
@ -739,11 +744,24 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
}
|
||||
}
|
||||
|
||||
async _onDragStart(_, event) {
|
||||
async _onDragStart(event) {
|
||||
const item = this.getItem(event);
|
||||
|
||||
const dragData = {
|
||||
type: item.documentName,
|
||||
uuid: item.uuid
|
||||
};
|
||||
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||
|
||||
super._onDragStart(event);
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
// Prevent event bubbling to avoid duplicate handling
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
super._onDrop(event);
|
||||
this._onDropItem(event, TextEditor.getDragEventData(event));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
export { default as DHApplicationMixin } from './application-mixin.mjs';
|
||||
export { default as DHBaseItemSheet } from './base-item.mjs';
|
||||
export { default as DHHeritageSheet } from './heritage-sheet.mjs';
|
||||
export { default as DHItemAttachmentSheet } from './item-attachment-sheet.mjs';
|
||||
export { default as DHBaseActorSheet } from './base-actor.mjs';
|
||||
export { default as DHBaseActorSettings } from './actor-setting.mjs';
|
||||
|
|
|
|||
85
module/applications/sheets/api/item-attachment-sheet.mjs
Normal file
85
module/applications/sheets/api/item-attachment-sheet.mjs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
export default function ItemAttachmentSheet(Base) {
|
||||
return class extends Base {
|
||||
static DEFAULT_OPTIONS = {
|
||||
...super.DEFAULT_OPTIONS,
|
||||
dragDrop: [
|
||||
...(super.DEFAULT_OPTIONS.dragDrop || []),
|
||||
{ dragSelector: null, dropSelector: '.attachments-section' }
|
||||
],
|
||||
actions: {
|
||||
...super.DEFAULT_OPTIONS.actions,
|
||||
removeAttachment: this.#removeAttachment
|
||||
}
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
...super.PARTS,
|
||||
attachments: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-attachments.hbs',
|
||||
scrollable: ['.attachments']
|
||||
}
|
||||
};
|
||||
|
||||
static TABS = {
|
||||
...super.TABS,
|
||||
primary: {
|
||||
...super.TABS?.primary,
|
||||
tabs: [...(super.TABS?.primary?.tabs || []), { id: 'attachments' }],
|
||||
initial: super.TABS?.primary?.initial || 'description',
|
||||
labelPrefix: super.TABS?.primary?.labelPrefix || 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
};
|
||||
|
||||
async _preparePartContext(partId, context) {
|
||||
await super._preparePartContext(partId, context);
|
||||
|
||||
if (partId === 'attachments') {
|
||||
context.attachedItems = await prepareAttachmentContext(this.document);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
const data = TextEditor.getDragEventData(event);
|
||||
|
||||
const attachmentsSection = event.target.closest('.attachments-section');
|
||||
if (!attachmentsSection) return super._onDrop(event);
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const item = await Item.implementation.fromDropData(data);
|
||||
if (!item) return;
|
||||
|
||||
// Call the data model's public method
|
||||
await this.document.system.addAttachment(item);
|
||||
}
|
||||
|
||||
static async #removeAttachment(event, target) {
|
||||
// Call the data model's public method
|
||||
await this.document.system.removeAttachment(target.dataset.uuid);
|
||||
}
|
||||
|
||||
async _preparePartContext(partId, context) {
|
||||
await super._preparePartContext(partId, context);
|
||||
|
||||
if (partId === 'attachments') {
|
||||
// Keep this simple UI preparation in the mixin
|
||||
const attachedUUIDs = this.document.system.attached;
|
||||
context.attachedItems = await Promise.all(
|
||||
attachedUUIDs.map(async uuid => {
|
||||
const item = await fromUuid(uuid);
|
||||
return {
|
||||
uuid: uuid,
|
||||
name: item?.name || 'Unknown Item',
|
||||
img: item?.img || 'icons/svg/item-bag.svg'
|
||||
};
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import DHBaseItemSheet from '../api/base-item.mjs';
|
||||
import ItemAttachmentSheet from '../api/item-attachment-sheet.mjs';
|
||||
|
||||
export default class ArmorSheet extends DHBaseItemSheet {
|
||||
export default class ArmorSheet extends ItemAttachmentSheet(DHBaseItemSheet) {
|
||||
/**@inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ['armor'],
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }],
|
||||
tagifyConfigs: [
|
||||
{
|
||||
selector: '.features-input',
|
||||
|
|
@ -26,7 +26,8 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
|||
settings: {
|
||||
template: 'systems/daggerheart/templates/sheets/items/armor/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
}
|
||||
},
|
||||
...super.PARTS
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import DHBaseItemSheet from '../api/base-item.mjs';
|
||||
import ItemAttachmentSheet from '../api/item-attachment-sheet.mjs';
|
||||
|
||||
export default class WeaponSheet extends DHBaseItemSheet {
|
||||
export default class WeaponSheet extends ItemAttachmentSheet(DHBaseItemSheet) {
|
||||
/**@inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ['weapon'],
|
||||
|
|
@ -25,12 +26,13 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
|||
settings: {
|
||||
template: 'systems/daggerheart/templates/sheets/items/weapon/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
}
|
||||
},
|
||||
...super.PARTS
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
async _preparePartContext(partId, context) {
|
||||
super._preparePartContext(partId, context);
|
||||
await super._preparePartContext(partId, context);
|
||||
switch (partId) {
|
||||
case 'settings':
|
||||
context.features = this.document.system.weaponFeatures.map(x => x.value);
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
if (message.system.onSave && message.system.targets.find(t => t.id === target.id)?.saved?.success === true)
|
||||
damage = Math.ceil(damage * (CONFIG.DH.ACTIONS.damageOnSave[message.system.onSave]?.mod ?? 1));
|
||||
|
||||
target.actor.takeDamage(damage, message.system.roll.type);
|
||||
target.actor.takeDamage(damage, message.system.damage.damageType);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue