mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 22:46:12 +01:00
Corrected back to actions for right items
This commit is contained in:
parent
3d735e6a09
commit
eb96e8b813
17 changed files with 148 additions and 58 deletions
|
|
@ -1478,7 +1478,7 @@
|
||||||
"Features": "Features",
|
"Features": "Features",
|
||||||
"Effects": "Effects",
|
"Effects": "Effects",
|
||||||
"activeEffects": "Active Effects",
|
"activeEffects": "Active Effects",
|
||||||
"inativeEffects": "Inative Effects"
|
"inactiveEffects": "Inactive Effects"
|
||||||
},
|
},
|
||||||
"DomainCard": {
|
"DomainCard": {
|
||||||
"Type": "Type",
|
"Type": "Type",
|
||||||
|
|
|
||||||
|
|
@ -307,9 +307,13 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
getItem(element) {
|
getItem(element) {
|
||||||
const listElement = (element.target ?? element).closest('[data-item-id]');
|
const listElement = (element.target ?? element).closest('[data-item-id]');
|
||||||
const itemId = listElement.dataset.itemId;
|
const itemId = listElement.dataset.itemId;
|
||||||
return listElement.dataset.type === 'effect'
|
|
||||||
? this.document.effects.get(itemId)
|
switch (listElement.dataset.type) {
|
||||||
: this.document.items.get(itemId);
|
case 'effect':
|
||||||
|
return this.document.effects.get(itemId);
|
||||||
|
default:
|
||||||
|
return this.document.items.get(itemId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static triggerContextMenu(event, button) {
|
static triggerContextMenu(event, button) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import DHActionConfig from '../../sheets-configs/action-config.mjs';
|
||||||
import DHApplicationMixin from './application-mixin.mjs';
|
import DHApplicationMixin from './application-mixin.mjs';
|
||||||
|
|
||||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||||
|
|
@ -16,6 +17,9 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
submitOnChange: true
|
submitOnChange: true
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
addAction: DHBaseItemSheet.#addAction,
|
||||||
|
editAction: DHBaseItemSheet.#editAction,
|
||||||
|
removeAction: DHBaseItemSheet.#removeAction,
|
||||||
addFeature: DHBaseItemSheet.#addFeature,
|
addFeature: DHBaseItemSheet.#addFeature,
|
||||||
editFeature: DHBaseItemSheet.#editFeature,
|
editFeature: DHBaseItemSheet.#editFeature,
|
||||||
removeFeature: DHBaseItemSheet.#removeFeature
|
removeFeature: DHBaseItemSheet.#removeFeature
|
||||||
|
|
@ -31,7 +35,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
static TABS = {
|
static TABS = {
|
||||||
primary: {
|
primary: {
|
||||||
tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }],
|
tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'settings' }],
|
||||||
initial: 'description',
|
initial: 'description',
|
||||||
labelPrefix: 'DAGGERHEART.Sheets.TABS'
|
labelPrefix: 'DAGGERHEART.Sheets.TABS'
|
||||||
}
|
}
|
||||||
|
|
@ -64,6 +68,83 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
/* Application Clicks Actions */
|
/* Application Clicks Actions */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render a dialog prompting the user to select an action type.
|
||||||
|
*
|
||||||
|
* @returns {Promise<object>} An object containing the selected action type.
|
||||||
|
*/
|
||||||
|
static async selectActionType() {
|
||||||
|
const content = await foundry.applications.handlebars.renderTemplate(
|
||||||
|
'systems/daggerheart/templates/actionTypes/actionType.hbs',
|
||||||
|
{ types: CONFIG.DH.ACTIONS.actionTypes }
|
||||||
|
),
|
||||||
|
title = 'Select Action Type';
|
||||||
|
|
||||||
|
return foundry.applications.api.DialogV2.prompt({
|
||||||
|
window: { title },
|
||||||
|
content,
|
||||||
|
ok: {
|
||||||
|
label: title,
|
||||||
|
callback: (event, button, dialog) => button.form.elements.type.value
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new action to the item, prompting the user for its type.
|
||||||
|
* @param {PointerEvent} _event - The originating click event
|
||||||
|
* @param {HTMLElement} _button - The capturing HTML element which defines the [data-action="addAction"]
|
||||||
|
*/
|
||||||
|
static async #addAction(_event, _button) {
|
||||||
|
const actionType = await DHBaseItemSheet.selectActionType();
|
||||||
|
if (!actionType) return;
|
||||||
|
try {
|
||||||
|
const cls =
|
||||||
|
game.system.api.models.actions.actionsTypes[actionType] ??
|
||||||
|
game.system.api.models.actions.actionsTypes.attack,
|
||||||
|
action = new cls(
|
||||||
|
{
|
||||||
|
_id: foundry.utils.randomID(),
|
||||||
|
type: actionType,
|
||||||
|
name: game.i18n.localize(CONFIG.DH.ACTIONS.actionTypes[actionType].name),
|
||||||
|
...cls.getSourceConfig(this.document)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
parent: this.document
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
||||||
|
await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render({
|
||||||
|
force: true
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit an existing action on the item
|
||||||
|
* @param {PointerEvent} _event - The originating click event
|
||||||
|
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="editAction"]
|
||||||
|
*/
|
||||||
|
static async #editAction(_event, button) {
|
||||||
|
const action = this.document.system.actions[button.dataset.index];
|
||||||
|
await new DHActionConfig(action).render({ force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove an action from the item.
|
||||||
|
* @param {PointerEvent} event - The originating click event
|
||||||
|
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="removeAction"]
|
||||||
|
*/
|
||||||
|
static async #removeAction(event, button) {
|
||||||
|
event.stopPropagation();
|
||||||
|
const actionIndex = button.closest('[data-index]').dataset.index;
|
||||||
|
await this.document.update({
|
||||||
|
'system.actions': this.document.system.actions.filter((_, index) => index !== Number.parseInt(actionIndex))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new feature to the item, prompting the user for its type.
|
* Add a new feature to the item, prompting the user for its type.
|
||||||
* @param {PointerEvent} _event - The originating click event
|
* @param {PointerEvent} _event - The originating click event
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
{
|
{
|
||||||
selector: '.features-input',
|
selector: '.features-input',
|
||||||
options: () => CONFIG.DH.ITEM.armorFeatures,
|
options: () => CONFIG.DH.ITEM.armorFeatures,
|
||||||
callback: ArmorSheet.#onArmorFeatureSelect
|
callback: ArmorSheet.#onFeatureSelect
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -19,9 +19,9 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
header: { template: 'systems/daggerheart/templates/sheets/items/armor/header.hbs' },
|
header: { template: 'systems/daggerheart/templates/sheets/items/armor/header.hbs' },
|
||||||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||||
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
||||||
features: {
|
actions: {
|
||||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-features.hbs',
|
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
|
||||||
scrollable: ['.features']
|
scrollable: ['.actions']
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
template: 'systems/daggerheart/templates/sheets/items/armor/settings.hbs',
|
template: 'systems/daggerheart/templates/sheets/items/armor/settings.hbs',
|
||||||
|
|
@ -35,7 +35,7 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
|
|
||||||
switch (partId) {
|
switch (partId) {
|
||||||
case 'settings':
|
case 'settings':
|
||||||
context.armorFeatures = this.document.system.armorFeatures.map(x => x.value);
|
context.features = this.document.system.features.map(x => x.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ export default class ArmorSheet extends DHBaseItemSheet {
|
||||||
* Callback function used by `tagifyElement`.
|
* Callback function used by `tagifyElement`.
|
||||||
* @param {Array<Object>} selectedOptions - The currently selected tag objects.
|
* @param {Array<Object>} selectedOptions - The currently selected tag objects.
|
||||||
*/
|
*/
|
||||||
static async #onArmorFeatureSelect(selectedOptions) {
|
static async #onFeatureSelect(selectedOptions) {
|
||||||
await this.document.update({ 'system.armorFeatures': selectedOptions.map(x => ({ value: x.value })) });
|
await this.document.update({ 'system.features': selectedOptions.map(x => ({ value: x.value })) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ export default class ConsumableSheet extends DHBaseItemSheet {
|
||||||
header: { template: 'systems/daggerheart/templates/sheets/items/consumable/header.hbs' },
|
header: { template: 'systems/daggerheart/templates/sheets/items/consumable/header.hbs' },
|
||||||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||||
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
||||||
features: {
|
actions: {
|
||||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-features.hbs',
|
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
|
||||||
scrollable: ['.features']
|
scrollable: ['.actions']
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
template: 'systems/daggerheart/templates/sheets/items/consumable/settings.hbs',
|
template: 'systems/daggerheart/templates/sheets/items/consumable/settings.hbs',
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export default class DomainCardSheet extends DHBaseItemSheet {
|
||||||
/** @override */
|
/** @override */
|
||||||
static TABS = {
|
static TABS = {
|
||||||
primary: {
|
primary: {
|
||||||
tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }, { id: 'effects' }],
|
tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'settings' }, { id: 'effects' }],
|
||||||
initial: 'description',
|
initial: 'description',
|
||||||
labelPrefix: 'DAGGERHEART.Sheets.TABS'
|
labelPrefix: 'DAGGERHEART.Sheets.TABS'
|
||||||
}
|
}
|
||||||
|
|
@ -21,9 +21,9 @@ export default class DomainCardSheet extends DHBaseItemSheet {
|
||||||
header: { template: 'systems/daggerheart/templates/sheets/items/domainCard/header.hbs' },
|
header: { template: 'systems/daggerheart/templates/sheets/items/domainCard/header.hbs' },
|
||||||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||||
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
||||||
features: {
|
actions: {
|
||||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-features.hbs',
|
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
|
||||||
scrollable: ['.features']
|
scrollable: ['.actions']
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
template: 'systems/daggerheart/templates/sheets/items/domainCard/settings.hbs',
|
template: 'systems/daggerheart/templates/sheets/items/domainCard/settings.hbs',
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ export default class MiscellaneousSheet extends DHBaseItemSheet {
|
||||||
header: { template: 'systems/daggerheart/templates/sheets/items/miscellaneous/header.hbs' },
|
header: { template: 'systems/daggerheart/templates/sheets/items/miscellaneous/header.hbs' },
|
||||||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||||
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
||||||
features: {
|
actions: {
|
||||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-features.hbs',
|
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
|
||||||
scrollable: ['.features']
|
scrollable: ['.actions']
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
template: 'systems/daggerheart/templates/sheets/items/miscellaneous/settings.hbs',
|
template: 'systems/daggerheart/templates/sheets/items/miscellaneous/settings.hbs',
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
{
|
{
|
||||||
selector: '.features-input',
|
selector: '.features-input',
|
||||||
options: () => CONFIG.DH.ITEM.weaponFeatures,
|
options: () => CONFIG.DH.ITEM.weaponFeatures,
|
||||||
callback: WeaponSheet.#onWeaponFeatureSelect
|
callback: WeaponSheet.#onFeatureSelect
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -18,9 +18,9 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
header: { template: 'systems/daggerheart/templates/sheets/items/weapon/header.hbs' },
|
header: { template: 'systems/daggerheart/templates/sheets/items/weapon/header.hbs' },
|
||||||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||||
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
||||||
features: {
|
actions: {
|
||||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-features.hbs',
|
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
|
||||||
scrollable: ['.features']
|
scrollable: ['.actions']
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
template: 'systems/daggerheart/templates/sheets/items/weapon/settings.hbs',
|
template: 'systems/daggerheart/templates/sheets/items/weapon/settings.hbs',
|
||||||
|
|
@ -34,7 +34,7 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
|
|
||||||
switch (partId) {
|
switch (partId) {
|
||||||
case 'settings':
|
case 'settings':
|
||||||
context.weaponFeatures = this.document.system.weaponFeatures.map(x => x.value);
|
context.features = this.document.system.features.map(x => x.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
||||||
* Callback function used by `tagifyElement`.
|
* Callback function used by `tagifyElement`.
|
||||||
* @param {Array<Object>} selectedOptions - The currently selected tag objects.
|
* @param {Array<Object>} selectedOptions - The currently selected tag objects.
|
||||||
*/
|
*/
|
||||||
static async #onWeaponFeatureSelect(selectedOptions) {
|
static async #onFeatureSelect(selectedOptions) {
|
||||||
await this.document.update({ 'system.weaponFeatures': selectedOptions.map(x => ({ value: x.value })) });
|
await this.document.update({ 'system.features': selectedOptions.map(x => ({ value: x.value })) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
|
import ActionField from '../fields/actionField.mjs';
|
||||||
import { armorFeatures } from '../../config/itemConfig.mjs';
|
import { armorFeatures } from '../../config/itemConfig.mjs';
|
||||||
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
|
||||||
|
|
||||||
export default class DHArmor extends BaseDataItem {
|
export default class DHArmor extends BaseDataItem {
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|
@ -22,7 +22,7 @@ export default class DHArmor extends BaseDataItem {
|
||||||
tier: new fields.NumberField({ required: true, integer: true, initial: 1, min: 1 }),
|
tier: new fields.NumberField({ required: true, integer: true, initial: 1, min: 1 }),
|
||||||
equipped: new fields.BooleanField({ initial: false }),
|
equipped: new fields.BooleanField({ initial: false }),
|
||||||
baseScore: new fields.NumberField({ integer: true, initial: 0 }),
|
baseScore: new fields.NumberField({ integer: true, initial: 0 }),
|
||||||
armorFeatures: new fields.ArrayField(
|
features: new fields.ArrayField(
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
value: new fields.StringField({
|
value: new fields.StringField({
|
||||||
required: true,
|
required: true,
|
||||||
|
|
@ -40,28 +40,32 @@ export default class DHArmor extends BaseDataItem {
|
||||||
major: new fields.NumberField({ integer: true, initial: 0 }),
|
major: new fields.NumberField({ integer: true, initial: 0 }),
|
||||||
severe: new fields.NumberField({ integer: true, initial: 0 })
|
severe: new fields.NumberField({ integer: true, initial: 0 })
|
||||||
}),
|
}),
|
||||||
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
actions: new fields.ArrayField(new ActionField())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get featureInfo() {
|
||||||
|
return this.feature ? CONFIG.DH.ITEM.armorFeatures[this.feature] : null;
|
||||||
|
}
|
||||||
|
|
||||||
async _preUpdate(changes, options, user) {
|
async _preUpdate(changes, options, user) {
|
||||||
const allowed = await super._preUpdate(changes, options, user);
|
const allowed = await super._preUpdate(changes, options, user);
|
||||||
if (allowed === false) return false;
|
if (allowed === false) return false;
|
||||||
|
|
||||||
if (changes.system?.armorFeatures) {
|
if (changes.system.features) {
|
||||||
const removed = this.armorFeatures.filter(x => !changes.system.armorFeatures.includes(x));
|
const removed = this.features.filter(x => !changes.system.features.includes(x));
|
||||||
const added = changes.system.armorFeatures.filter(x => !this.armorFeatures.includes(x));
|
const added = changes.system.features.filter(x => !this.features.includes(x));
|
||||||
|
|
||||||
for (var armorFeature of removed) {
|
for (var feature of removed) {
|
||||||
for (var effectId of armorFeature.effectIds) {
|
for (var effectId of feature.effectIds) {
|
||||||
await this.parent.effects.get(effectId).delete();
|
await this.parent.effects.get(effectId).delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
changes.system.actions = this.actions.filter(x => !armorFeature.actionIds.includes(x._id));
|
changes.system.actions = this.actions.filter(x => !feature.actionIds.includes(x._id));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var armorFeature of added) {
|
for (var feature of added) {
|
||||||
const featureData = armorFeatures[armorFeature.value];
|
const featureData = armorFeatures[feature.value];
|
||||||
if (featureData.effects?.length > 0) {
|
if (featureData.effects?.length > 0) {
|
||||||
const embeddedItems = await this.parent.createEmbeddedDocuments('ActiveEffect', [
|
const embeddedItems = await this.parent.createEmbeddedDocuments('ActiveEffect', [
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +74,7 @@ export default class DHArmor extends BaseDataItem {
|
||||||
changes: featureData.effects.flatMap(x => x.changes)
|
changes: featureData.effects.flatMap(x => x.changes)
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
armorFeature.effectIds = embeddedItems.map(x => x.id);
|
feature.effectIds = embeddedItems.map(x => x.id);
|
||||||
}
|
}
|
||||||
if (featureData.actions?.length > 0) {
|
if (featureData.actions?.length > 0) {
|
||||||
const newActions = featureData.actions.map(action => {
|
const newActions = featureData.actions.map(action => {
|
||||||
|
|
@ -81,7 +85,7 @@ export default class DHArmor extends BaseDataItem {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
changes.system.actions = [...this.actions, ...newActions];
|
changes.system.actions = [...this.actions, ...newActions];
|
||||||
armorFeature.actionIds = newActions.map(x => x._id);
|
feature.actionIds = newActions.map(x => x._id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
import ActionField from '../fields/actionField.mjs';
|
||||||
|
|
||||||
export default class DHConsumable extends BaseDataItem {
|
export default class DHConsumable extends BaseDataItem {
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|
@ -19,7 +19,7 @@ export default class DHConsumable extends BaseDataItem {
|
||||||
return {
|
return {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
consumeOnUse: new fields.BooleanField({ initial: false }),
|
consumeOnUse: new fields.BooleanField({ initial: false }),
|
||||||
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
actions: new fields.ArrayField(new ActionField())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
import ActionField from '../fields/actionField.mjs';
|
||||||
|
|
||||||
export default class DHDomainCard extends BaseDataItem {
|
export default class DHDomainCard extends BaseDataItem {
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|
@ -30,7 +30,7 @@ export default class DHDomainCard extends BaseDataItem {
|
||||||
}),
|
}),
|
||||||
foundation: new fields.BooleanField({ initial: false }),
|
foundation: new fields.BooleanField({ initial: false }),
|
||||||
inVault: new fields.BooleanField({ initial: false }),
|
inVault: new fields.BooleanField({ initial: false }),
|
||||||
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
actions: new fields.ArrayField(new ActionField())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
import ActionField from '../fields/actionField.mjs';
|
||||||
|
|
||||||
export default class DHMiscellaneous extends BaseDataItem {
|
export default class DHMiscellaneous extends BaseDataItem {
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|
@ -15,9 +15,10 @@ export default class DHMiscellaneous extends BaseDataItem {
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
actions: new fields.ArrayField(new ActionField())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
import { actionsTypes } from '../action/_module.mjs';
|
import { actionsTypes } from '../action/_module.mjs';
|
||||||
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
import ActionField from '../fields/actionField.mjs';
|
||||||
|
|
||||||
export default class DHWeapon extends BaseDataItem {
|
export default class DHWeapon extends BaseDataItem {
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|
@ -38,7 +38,7 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
initial: 'physical'
|
initial: 'physical'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
weaponFeatures: new fields.ArrayField(
|
features: new fields.ArrayField(
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
value: new fields.StringField({
|
value: new fields.StringField({
|
||||||
required: true,
|
required: true,
|
||||||
|
|
@ -49,7 +49,7 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
actionIds: new fields.ArrayField(new fields.StringField({ required: true }))
|
actionIds: new fields.ArrayField(new fields.StringField({ required: true }))
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
actions: new fields.ArrayField(new ActionField())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,9 +57,9 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
const allowed = await super._preUpdate(changes, options, user);
|
const allowed = await super._preUpdate(changes, options, user);
|
||||||
if (allowed === false) return false;
|
if (allowed === false) return false;
|
||||||
|
|
||||||
if (changes.system?.weaponFeatures) {
|
if (changes.system?.features) {
|
||||||
const removed = this.weaponFeatures.filter(x => !changes.system.weaponFeatures.includes(x));
|
const removed = this.features.filter(x => !changes.system.features.includes(x));
|
||||||
const added = changes.system.weaponFeatures.filter(x => !this.weaponFeatures.includes(x));
|
const added = changes.system.features.filter(x => !this.features.includes(x));
|
||||||
|
|
||||||
for (var weaponFeature of removed) {
|
for (var weaponFeature of removed) {
|
||||||
for (var effectId of weaponFeature.effectIds) {
|
for (var effectId of weaponFeature.effectIds) {
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@
|
||||||
data-group='{{tabs.effects.group}}'
|
data-group='{{tabs.effects.group}}'
|
||||||
>
|
>
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.activeEffects') type='effect'}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.activeEffects') type='effect'}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.inativeEffects') type='effect'}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.inactiveEffects') type='effect'}}
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -4,5 +4,5 @@
|
||||||
data-group='{{tabs.effects.group}}'
|
data-group='{{tabs.effects.group}}'
|
||||||
>
|
>
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.activeEffects') type='effect'}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.activeEffects') type='effect'}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.inativeEffects') type='effect'}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.inactiveEffects') type='effect'}}
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -4,5 +4,5 @@
|
||||||
data-group='{{tabs.effects.group}}'
|
data-group='{{tabs.effects.group}}'
|
||||||
>
|
>
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.activeEffects') type='effect'}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.activeEffects') type='effect'}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.inativeEffects') type='effect'}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=(localize 'DAGGERHEART.Sheets.Global.inactiveEffects') type='effect'}}
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<legend>{{title}}</legend>
|
<legend>{{title}}</legend>
|
||||||
<ul class="items-list">
|
<ul class="items-list">
|
||||||
{{#unless (eq cardView 'card') }}
|
{{#unless (eq cardView 'card') }}
|
||||||
{{#if (eq type 'domainCard')}}
|
{{#if (or (eq type 'domainCard') (eq type 'armor') (eq type 'consumable') (eq type 'miscellaneous') (eq type 'weapon'))}}
|
||||||
{{#each document.items as |item|}}
|
{{#each document.items as |item|}}
|
||||||
{{#if (eq item.type ../type)}}
|
{{#if (eq item.type ../type)}}
|
||||||
{{#unless (and (eq ../type 'domainCard') (or (and item.system.inVault (not ../isVault)) (and (not item.system.inVault) ../isVault)))}}
|
{{#unless (and (eq ../type 'domainCard') (or (and item.system.inVault (not ../isVault)) (and (not item.system.inVault) ../isVault)))}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue