mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 22:46:12 +01:00
Removed action fields on Adversary/Environment in favor of using Feature Items
This commit is contained in:
parent
9d76405221
commit
c3b8def6b1
23 changed files with 274 additions and 433 deletions
|
|
@ -1,7 +1,3 @@
|
|||
import DHActionConfig from './action-config.mjs';
|
||||
import DHBaseItemSheet from '../sheets/api/base-item.mjs';
|
||||
import { actionsTypes } from '../../data/action/_module.mjs';
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DHAdversarySettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
|
|
@ -26,9 +22,9 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl
|
|||
actions: {
|
||||
addExperience: this.#addExperience,
|
||||
removeExperience: this.#removeExperience,
|
||||
addAction: this.#addAction,
|
||||
editAction: this.#editAction,
|
||||
removeAction: this.#removeAction
|
||||
addFeature: this.#addFeature,
|
||||
editFeature: this.#editFeature,
|
||||
removeFeature: this.#removeFeature
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
|
|
@ -55,9 +51,9 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl
|
|||
id: 'experiences',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/adversary-settings/experiences.hbs'
|
||||
},
|
||||
actions: {
|
||||
id: 'actions',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/adversary-settings/actions.hbs'
|
||||
features: {
|
||||
id: 'features',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/adversary-settings/features.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -86,13 +82,13 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl
|
|||
icon: null,
|
||||
label: 'DAGGERHEART.General.tabs.experiences'
|
||||
},
|
||||
actions: {
|
||||
features: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'actions',
|
||||
id: 'features',
|
||||
icon: null,
|
||||
label: 'DAGGERHEART.General.tabs.actions'
|
||||
label: 'DAGGERHEART.General.tabs.features'
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -130,46 +126,25 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl
|
|||
this.render();
|
||||
}
|
||||
|
||||
static async #addAction(_event, _button) {
|
||||
const actionType = await DHBaseItemSheet.selectActionType();
|
||||
if (!actionType) return;
|
||||
try {
|
||||
const cls = actionsTypes[actionType] ?? actionsTypes.attack,
|
||||
action = new cls(
|
||||
{
|
||||
_id: foundry.utils.randomID(),
|
||||
type: actionType,
|
||||
name: game.i18n.localize(CONFIG.DH.ACTIONS.actionTypes[actionType].name),
|
||||
...cls.getSourceConfig(this.actor)
|
||||
},
|
||||
{
|
||||
parent: this.actor
|
||||
}
|
||||
);
|
||||
await this.actor.update({ 'system.actions': [...this.actor.system.actions, action] });
|
||||
await new DHActionConfig(this.actor.system.actions[this.actor.system.actions.length - 1]).render({
|
||||
force: true
|
||||
});
|
||||
this.render();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
static async #addFeature(_, _button) {
|
||||
await this.actor.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
type: 'feature',
|
||||
name: game.i18n.localize('DAGGERHEART.General.newFeature'),
|
||||
img: 'icons/skills/melee/weapons-crossed-swords-black.webp'
|
||||
}
|
||||
]);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async #editAction(event, target) {
|
||||
static async #editFeature(event, target) {
|
||||
event.stopPropagation();
|
||||
const actionIndex = target.dataset.index;
|
||||
await new DHActionConfig(this.actor.system.actions[actionIndex]).render({
|
||||
force: true
|
||||
});
|
||||
this.actor.items.get(target.id).sheet.render(true);
|
||||
}
|
||||
|
||||
static async #removeAction(event, target) {
|
||||
static async #removeFeature(event, target) {
|
||||
event.stopPropagation();
|
||||
const actionIndex = target.dataset.index;
|
||||
await this.actor.update({
|
||||
'system.actions': this.actor.system.actions.filter((_, index) => index !== Number.parseInt(actionIndex))
|
||||
});
|
||||
await this.actor.deleteEmbeddedDocuments('Item', [target.id]);
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import DHActionConfig from './action-config.mjs';
|
||||
import DHBaseItemSheet from '../sheets/api/base-item.mjs';
|
||||
import { actionsTypes } from '../../data/action/_module.mjs';
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
|
|
@ -25,9 +21,9 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap
|
|||
},
|
||||
position: { width: 455, height: 'auto' },
|
||||
actions: {
|
||||
addAction: this.#addAction,
|
||||
editAction: this.#editAction,
|
||||
removeAction: this.#removeAction,
|
||||
addFeature: this.#addFeature,
|
||||
editFeature: this.#editFeature,
|
||||
removeFeature: this.#removeFeature,
|
||||
addCategory: this.#addCategory,
|
||||
deleteProperty: this.#deleteProperty,
|
||||
viewAdversary: this.#viewAdversary,
|
||||
|
|
@ -51,9 +47,9 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap
|
|||
id: 'details',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/environment-settings/details.hbs'
|
||||
},
|
||||
actions: {
|
||||
id: 'actions',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/environment-settings/actions.hbs'
|
||||
features: {
|
||||
id: 'features',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/environment-settings/features.hbs'
|
||||
},
|
||||
adversaries: {
|
||||
id: 'adversaries',
|
||||
|
|
@ -70,13 +66,13 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap
|
|||
icon: null,
|
||||
label: 'DAGGERHEART.General.tabs.details'
|
||||
},
|
||||
actions: {
|
||||
features: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'actions',
|
||||
id: 'features',
|
||||
icon: null,
|
||||
label: 'DAGGERHEART.General.tabs.actions'
|
||||
label: 'DAGGERHEART.General.tabs.features'
|
||||
},
|
||||
adversaries: {
|
||||
active: false,
|
||||
|
|
@ -122,46 +118,23 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap
|
|||
return tabs;
|
||||
}
|
||||
|
||||
static async #addAction(_event, _button) {
|
||||
const actionType = await DHBaseItemSheet.selectActionType();
|
||||
if (!actionType) return;
|
||||
try {
|
||||
const cls = actionsTypes[actionType] ?? actionsTypes.attack,
|
||||
action = new cls(
|
||||
{
|
||||
_id: foundry.utils.randomID(),
|
||||
type: actionType,
|
||||
name: game.i18n.localize(CONFIG.DH.ACTIONS.actionTypes[actionType].name),
|
||||
...cls.getSourceConfig(this.actor)
|
||||
},
|
||||
{
|
||||
parent: this.actor
|
||||
}
|
||||
);
|
||||
await this.actor.update({ 'system.actions': [...this.actor.system.actions, action] });
|
||||
await new DHActionConfig(this.actor.system.actions[this.actor.system.actions.length - 1]).render({
|
||||
force: true
|
||||
});
|
||||
this.render();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
static async #addFeature(_, _button) {
|
||||
await this.actor.createEmbeddedDocuments('Item', [
|
||||
{
|
||||
type: 'feature',
|
||||
name: game.i18n.localize('DAGGERHEART.General.newFeature'),
|
||||
img: 'icons/magic/perception/orb-crystal-ball-scrying-blue.webp'
|
||||
}
|
||||
]);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async #editAction(event, target) {
|
||||
event.stopPropagation();
|
||||
const actionIndex = target.dataset.index;
|
||||
await new DHActionConfig(this.actor.system.actions[actionIndex]).render({
|
||||
force: true
|
||||
});
|
||||
static async #editFeature(_, target) {
|
||||
this.actor.items.get(target.id).sheet.render(true);
|
||||
}
|
||||
|
||||
static async #removeAction(event, target) {
|
||||
event.stopPropagation();
|
||||
const actionIndex = target.dataset.index;
|
||||
await this.actor.update({
|
||||
'system.actions': this.actor.system.actions.filter((_, index) => index !== Number.parseInt(actionIndex))
|
||||
});
|
||||
static async #removeFeature(_, target) {
|
||||
await this.actor.deleteEmbeddedDocuments('Item', [target.id]);
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,19 +29,19 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
static PARTS = {
|
||||
sidebar: { template: 'systems/daggerheart/templates/sheets/actors/adversary/sidebar.hbs' },
|
||||
header: { template: 'systems/daggerheart/templates/sheets/actors/adversary/header.hbs' },
|
||||
actions: { template: 'systems/daggerheart/templates/sheets/actors/adversary/actions.hbs' },
|
||||
features: { template: 'systems/daggerheart/templates/sheets/actors/adversary/features.hbs' },
|
||||
notes: { template: 'systems/daggerheart/templates/sheets/actors/adversary/notes.hbs' },
|
||||
effects: { template: 'systems/daggerheart/templates/sheets/actors/adversary/effects.hbs' }
|
||||
};
|
||||
|
||||
static TABS = {
|
||||
actions: {
|
||||
features: {
|
||||
active: true,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'actions',
|
||||
id: 'features',
|
||||
icon: null,
|
||||
label: 'DAGGERHEART.General.tabs.actions'
|
||||
label: 'DAGGERHEART.General.tabs.features'
|
||||
},
|
||||
notes: {
|
||||
active: false,
|
||||
|
|
@ -71,9 +71,9 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
return context;
|
||||
}
|
||||
|
||||
getAction(element) {
|
||||
getItem(element) {
|
||||
const itemId = (element.target ?? element).closest('[data-item-id]').dataset.itemId,
|
||||
item = this.document.system.actions.find(x => x.id === itemId);
|
||||
item = this.document.items.get(itemId);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
}
|
||||
|
||||
static async useItem(event) {
|
||||
const action = this.getAction(event) ?? this.actor.system.attack;
|
||||
const action = this.getItem(event) ?? this.actor.system.attack;
|
||||
action.use(event);
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
|
||||
cls.create(msg.toObject());
|
||||
} else {
|
||||
const item = this.getAction(event) ?? this.document.system.attack;
|
||||
const item = this.getItem(event) ?? this.document.system.attack;
|
||||
item.toChat(this.document.id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
|
|||
|
||||
static PARTS = {
|
||||
header: { template: 'systems/daggerheart/templates/sheets/actors/environment/header.hbs' },
|
||||
actions: { template: 'systems/daggerheart/templates/sheets/actors/environment/actions.hbs' },
|
||||
features: { template: 'systems/daggerheart/templates/sheets/actors/environment/features.hbs' },
|
||||
potentialAdversaries: {
|
||||
template: 'systems/daggerheart/templates/sheets/actors/environment/potentialAdversaries.hbs'
|
||||
},
|
||||
|
|
@ -34,13 +34,13 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
|
|||
};
|
||||
|
||||
static TABS = {
|
||||
actions: {
|
||||
features: {
|
||||
active: true,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'actions',
|
||||
id: 'features',
|
||||
icon: null,
|
||||
label: 'DAGGERHEART.General.tabs.actions'
|
||||
label: 'DAGGERHEART.General.tabs.features'
|
||||
},
|
||||
potentialAdversaries: {
|
||||
active: false,
|
||||
|
|
@ -69,9 +69,9 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
|
|||
return context;
|
||||
}
|
||||
|
||||
getAction(element) {
|
||||
getItem(element) {
|
||||
const itemId = (element.target ?? element).closest('[data-item-id]').dataset.itemId,
|
||||
item = this.document.system.actions.find(x => x.id === itemId);
|
||||
item = this.document.items.get(itemId);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
|
|||
}
|
||||
|
||||
static async useItem(event, button) {
|
||||
const action = this.getAction(event);
|
||||
const action = this.getItem(event);
|
||||
if (!action) {
|
||||
await this.viewAdversary(event, button);
|
||||
} else {
|
||||
|
|
@ -123,7 +123,7 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
|
|||
}
|
||||
|
||||
static async toChat(event) {
|
||||
const item = this.getAction(event);
|
||||
const item = this.getItem(event);
|
||||
item.toChat(this.document.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ export default class DhpAdversary extends BaseDataActor {
|
|||
hitPoints: resourceField(),
|
||||
stress: resourceField()
|
||||
}),
|
||||
actions: new fields.ArrayField(new ActionField()),
|
||||
attack: new ActionField({
|
||||
initial: {
|
||||
name: 'Attack',
|
||||
|
|
@ -86,4 +85,8 @@ export default class DhpAdversary extends BaseDataActor {
|
|||
get attackBonus() {
|
||||
return this.attack.roll.bonus;
|
||||
}
|
||||
|
||||
get features() {
|
||||
return this.parent.items.filter(x => x.type === 'feature');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ export default class DhCharacter extends BaseDataActor {
|
|||
value: new ForeignDocumentUUIDField({ type: 'Item', nullable: true }),
|
||||
subclass: new ForeignDocumentUUIDField({ type: 'Item', nullable: true })
|
||||
}),
|
||||
actions: new fields.ArrayField(new ActionField()),
|
||||
levelData: new fields.EmbeddedDataField(DhLevelData),
|
||||
bonuses: new fields.SchemaField({
|
||||
armorScore: new fields.NumberField({ integer: true, initial: 0 }),
|
||||
|
|
|
|||
|
|
@ -30,8 +30,11 @@ export default class DhEnvironment extends BaseDataActor {
|
|||
adversaries: new ForeignDocumentUUIDArrayField({ type: 'Actor' })
|
||||
})
|
||||
),
|
||||
actions: new fields.ArrayField(new ActionField()),
|
||||
notes: new fields.HTMLField()
|
||||
};
|
||||
}
|
||||
|
||||
get features() {
|
||||
return this.parent.items.filter(x => x.type === 'feature');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ export default class D20Roll extends DHRoll {
|
|||
: config.roll.advantage == this.ADV_MODE.DISADVANTAGE
|
||||
? false
|
||||
: null;
|
||||
setDiceSoNiceForDualityRoll(roll, advantageState);
|
||||
this.postEvaluate(roll, config);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue