mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-22 07:23:37 +02:00
[Feature] Action Areas (#1815)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
* Functioning setup * . * Fixes * Completed * Apply suggestions from code review Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com> * using function.call instead of function.bind * Run lint fix on action areas PR (#1820) * . * . * Restructured getTemplateShape to be a lot more readable * . * . * Changed from 'area' to 'areas' * . * Moved the areas button to the left * Fix regression with actions list * Updated all SRD adversaries --------- Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com> Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
This commit is contained in:
parent
646e0debbd
commit
3eda3c4c05
89 changed files with 1871 additions and 686 deletions
|
|
@ -72,8 +72,8 @@ export default class ActionSelectionDialog extends HandlebarsApplicationMixin(Ap
|
|||
|
||||
static async #onChooseAction(event, button) {
|
||||
const { actionId } = button.dataset;
|
||||
this.#action = this.#item.system.actionsList.find(a => a._id === actionId);
|
||||
Object.defineProperty(this.#event, 'shiftKey', {
|
||||
this.action = this.item.system.actionsList.find(a => a._id === actionId);
|
||||
Object.defineProperty(this.event, 'shiftKey', {
|
||||
get() {
|
||||
return event.shiftKey;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,7 +264,9 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
key = event.target.closest('[data-key]').dataset.key;
|
||||
if (!this.action[key]) return;
|
||||
|
||||
data[key].push(this.action.defaultValues[key] ?? {});
|
||||
const value = key === 'areas' ? { name: this.action.item.name } : {};
|
||||
|
||||
data[key].push(this.action.defaultValues[key] ?? value);
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ export default class DHActionConfig extends DHActionBaseConfig {
|
|||
return context;
|
||||
}
|
||||
|
||||
static async addEffect(_event) {
|
||||
static async addEffect(event) {
|
||||
const { areaIndex } = event.target.dataset;
|
||||
if (!this.action.effects) return;
|
||||
const data = this.action.toObject();
|
||||
|
||||
const created = await this.action.item.createEmbeddedDocuments('ActiveEffect', [
|
||||
game.system.api.data.activeEffects.BaseEffect.getDefaultObject()
|
||||
game.system.api.data.activeEffects.BaseEffect.getDefaultObject({ transfer: false })
|
||||
]);
|
||||
|
||||
data.effects.push({ _id: created[0]._id });
|
||||
if (areaIndex !== undefined) data.areas[areaIndex].effects.push(created[0]._id);
|
||||
else data.effects.push({ _id: created[0]._id });
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
this.action.item.effects.get(created[0]._id).sheet.render(true);
|
||||
}
|
||||
|
|
@ -52,9 +54,19 @@ export default class DHActionConfig extends DHActionBaseConfig {
|
|||
|
||||
static removeEffect(event, button) {
|
||||
if (!this.action.effects) return;
|
||||
const index = button.dataset.index,
|
||||
|
||||
const { areaIndex, index } = button.dataset;
|
||||
let effectId = null;
|
||||
if (areaIndex !== undefined) {
|
||||
effectId = this.action.areas[areaIndex].effects[index];
|
||||
const data = this.action.toObject();
|
||||
data.areas[areaIndex].effects.splice(index, 1);
|
||||
this.constructor.updateForm.call(this, null, null, { object: foundry.utils.flattenObject(data) });
|
||||
} else {
|
||||
effectId = this.action.effects[index]._id;
|
||||
this.constructor.removeElement.bind(this)(event, button);
|
||||
this.constructor.removeElement.call(this, event, button);
|
||||
}
|
||||
|
||||
this.action.item.deleteEmbeddedDocuments('ActiveEffect', [effectId]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,21 +31,35 @@ export default class DHActionSettingsConfig extends DHActionBaseConfig {
|
|||
}
|
||||
|
||||
static async addEffect(_event) {
|
||||
const { areaIndex } = event.target.dataset;
|
||||
if (!this.action.effects) return;
|
||||
const effectData = game.system.api.data.activeEffects.BaseEffect.getDefaultObject();
|
||||
|
||||
const effectData = game.system.api.data.activeEffects.BaseEffect.getDefaultObject({ transfer: false });
|
||||
const data = this.action.toObject();
|
||||
|
||||
this.sheetUpdate(data, effectData);
|
||||
this.effects = [...this.effects, effectData];
|
||||
data.effects.push({ _id: effectData.id });
|
||||
|
||||
if (areaIndex !== undefined) data.areas[areaIndex].effects.push(effectData.id);
|
||||
else data.effects.push({ _id: effectData.id });
|
||||
|
||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||
}
|
||||
|
||||
static removeEffect(event, button) {
|
||||
if (!this.action.effects) return;
|
||||
const index = button.dataset.index,
|
||||
const { areaIndex, index } = button.dataset;
|
||||
let effectId = null;
|
||||
if (areaIndex !== undefined) {
|
||||
effectId = this.action.areas[areaIndex].effects[index];
|
||||
const data = this.action.toObject();
|
||||
data.areas[areaIndex].effects.splice(index, 1);
|
||||
this.constructor.updateForm.call(this, null, null, { object: foundry.utils.flattenObject(data) });
|
||||
} else {
|
||||
effectId = this.action.effects[index]._id;
|
||||
this.constructor.removeElement.bind(this)(event, button);
|
||||
this.constructor.removeElement.call(this, event, button);
|
||||
}
|
||||
|
||||
this.sheetUpdate(
|
||||
this.action.toObject(),
|
||||
this.effects.find(x => x.id === effectId),
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ export default class DHContextMenu extends foundry.applications.ux.ContextMenu {
|
|||
static triggerContextMenu(event, altSelector) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const { clientX, clientY } = event;
|
||||
|
||||
const selector = altSelector ?? '[data-item-uuid]';
|
||||
if (ui.context?.selector === selector) return;
|
||||
|
||||
const { clientX, clientY } = event;
|
||||
const target = event.target.closest(selector) ?? event.currentTarget.closest(selector);
|
||||
target?.dispatchEvent(
|
||||
new PointerEvent('contextmenu', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue