mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
159 - Companion (#224)
* Initial datamodel * Fixed attack * Temp * Fixed normal levelup * Fixed showing summary of new experiences * Touchups * level sync fixes * Reworked Action storage * Companions now take stress when damaged * Fixed Feature flow * Removed retroactive companion levelup * Restored delevel on partner removal * PR fixes * Added a check for card duplicates on character
This commit is contained in:
parent
6f1529fefe
commit
b7e4169079
57 changed files with 1682 additions and 1012 deletions
|
|
@ -6,11 +6,7 @@ export default class FeatureSheet extends DHBaseItemSheet {
|
|||
id: 'daggerheart-feature',
|
||||
classes: ['feature'],
|
||||
position: { height: 600 },
|
||||
window: { resizable: true },
|
||||
actions: {
|
||||
addEffect: this.addEffect,
|
||||
removeEffect: this.removeEffect
|
||||
}
|
||||
window: { resizable: true }
|
||||
};
|
||||
|
||||
/**@override */
|
||||
|
|
@ -22,27 +18,16 @@ export default class FeatureSheet extends DHBaseItemSheet {
|
|||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
|
||||
scrollable: ['.actions']
|
||||
},
|
||||
settings: {
|
||||
template: 'systems/daggerheart/templates/sheets/items/feature/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
},
|
||||
effects: {
|
||||
template: 'systems/daggerheart/templates/sheets/items/feature/effects.hbs',
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
||||
scrollable: ['.effects']
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Internally tracks the selected effect type from the select.
|
||||
* @type {String}
|
||||
* @private
|
||||
*/
|
||||
_selectedEffectType;
|
||||
|
||||
/**@override */
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'settings' }, { id: 'effects' }],
|
||||
tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'effects' }],
|
||||
initial: 'description',
|
||||
labelPrefix: 'DAGGERHEART.Sheets.TABS'
|
||||
}
|
||||
|
|
@ -50,68 +35,10 @@ export default class FeatureSheet extends DHBaseItemSheet {
|
|||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**@inheritdoc*/
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
if (partId === 'effects')
|
||||
htmlElement.querySelector('.effect-select')?.addEventListener('change', this._effectSelect.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles selection of a new effect type.
|
||||
* @param {Event} event - Change Event
|
||||
*/
|
||||
_effectSelect(event) {
|
||||
const value = event.currentTarget.value;
|
||||
this._selectedEffectType = value;
|
||||
this.render({ parts: ['effects'] });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**@inheritdoc */
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.properties = CONFIG.daggerheart.ACTOR.featureProperties;
|
||||
context.dice = CONFIG.daggerheart.GENERAL.diceTypes;
|
||||
context.effectConfig = CONFIG.daggerheart.EFFECTS;
|
||||
|
||||
context.selectedEffectType = this._selectedEffectType;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Adds a new effect to the item, based on the selected effect type.
|
||||
* @param {PointerEvent} _event - The originating click event
|
||||
* @param {HTMLElement} _target - The capturing HTML element which defines the [data-action]
|
||||
* @returns
|
||||
*/
|
||||
static async addEffect(_event, _target) {
|
||||
const type = this._selectedEffectType;
|
||||
if (!type) return;
|
||||
const { id, name, ...rest } = CONFIG.daggerheart.EFFECTS.effectTypes[type];
|
||||
await this.item.update({
|
||||
[`system.effects.${foundry.utils.randomID()}`]: {
|
||||
type,
|
||||
value: '',
|
||||
...rest
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an effect from the item.
|
||||
* @param {PointerEvent} _event - The originating click event
|
||||
* @param {HTMLElement} target - The capturing HTML element which defines the [data-action]
|
||||
* @returns
|
||||
*/
|
||||
static async removeEffect(_event, target) {
|
||||
const path = `system.effects.-=${target.dataset.effect}`;
|
||||
await this.item.update({ [path]: null });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue