mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 05:01:08 +01:00
Added class hopeFeatures and classFeatures
This commit is contained in:
parent
4a596179d8
commit
bd3e76a20a
5 changed files with 99 additions and 16 deletions
|
|
@ -1137,6 +1137,8 @@
|
||||||
"Appearance": "Appearance",
|
"Appearance": "Appearance",
|
||||||
"settings": "Settings"
|
"settings": "Settings"
|
||||||
},
|
},
|
||||||
|
"HopeFeatures": "Hope Features",
|
||||||
|
"Class Features": "Class Features",
|
||||||
"Domains": "Domains",
|
"Domains": "Domains",
|
||||||
"DamageThresholds": {
|
"DamageThresholds": {
|
||||||
"Title": "Damage Thresholds",
|
"Title": "Damage Thresholds",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
|
import { actionsTypes } from '../../../data/_module.mjs';
|
||||||
import { tagifyElement } from '../../../helpers/utils.mjs';
|
import { tagifyElement } from '../../../helpers/utils.mjs';
|
||||||
|
import DHActionConfig from '../../config/Action.mjs';
|
||||||
import DaggerheartSheet from '../daggerheart-sheet.mjs';
|
import DaggerheartSheet from '../daggerheart-sheet.mjs';
|
||||||
|
|
||||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||||
const { TextEditor } = foundry.applications.ux;
|
const { TextEditor } = foundry.applications.ux;
|
||||||
|
|
||||||
export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
tag: 'form',
|
tag: 'form',
|
||||||
|
|
@ -11,8 +14,9 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
actions: {
|
actions: {
|
||||||
removeSubclass: this.removeSubclass,
|
removeSubclass: this.removeSubclass,
|
||||||
viewSubclass: this.viewSubclass,
|
viewSubclass: this.viewSubclass,
|
||||||
deleteFeature: this.deleteFeature,
|
addFeature: this.addFeature,
|
||||||
editFeature: this.editFeature,
|
editFeature: this.editFeature,
|
||||||
|
deleteFeature: this.deleteFeature,
|
||||||
removeItem: this.removeItem,
|
removeItem: this.removeItem,
|
||||||
viewItem: this.viewItem,
|
viewItem: this.viewItem,
|
||||||
removePrimaryWeapon: this.removePrimaryWeapon,
|
removePrimaryWeapon: this.removePrimaryWeapon,
|
||||||
|
|
@ -151,6 +155,69 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
await this.document.update({ 'system.characterGuide.suggestedArmor': null }, { diff: false });
|
await this.document.update({ 'system.characterGuide.suggestedArmor': null }, { diff: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async selectActionType() {
|
||||||
|
const content = await foundry.applications.handlebars.renderTemplate(
|
||||||
|
'systems/daggerheart/templates/views/actionType.hbs',
|
||||||
|
{ types: SYSTEM.ACTIONS.actionTypes }
|
||||||
|
),
|
||||||
|
title = 'Select Action Type',
|
||||||
|
type = 'form',
|
||||||
|
data = {};
|
||||||
|
return Dialog.prompt({
|
||||||
|
title,
|
||||||
|
label: title,
|
||||||
|
content,
|
||||||
|
type,
|
||||||
|
callback: html => {
|
||||||
|
const form = html[0].querySelector('form'),
|
||||||
|
fd = new foundry.applications.ux.FormDataExtended(form);
|
||||||
|
foundry.utils.mergeObject(data, fd.object, { inplace: true });
|
||||||
|
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
rejectClose: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getActionPath(type) {
|
||||||
|
return type === 'hope' ? 'hopeFeatures' : 'classFeatures';
|
||||||
|
}
|
||||||
|
|
||||||
|
static async addFeature(_, target) {
|
||||||
|
const actionPath = this.getActionPath(target.dataset.type);
|
||||||
|
const actionType = await this.selectActionType();
|
||||||
|
const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack,
|
||||||
|
action = new cls(
|
||||||
|
{
|
||||||
|
_id: foundry.utils.randomID(),
|
||||||
|
systemPath: actionPath,
|
||||||
|
type: actionType.type,
|
||||||
|
name: game.i18n.localize(SYSTEM.ACTIONS.actionTypes[actionType.type].name),
|
||||||
|
...cls.getSourceConfig(this.document)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
parent: this.document
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await this.document.update({ [`system.${actionPath}`]: [...this.document.system[actionPath], action] });
|
||||||
|
}
|
||||||
|
|
||||||
|
static async editFeature(_, target) {
|
||||||
|
const action = this.document.system[this.getActionPath(target.dataset.type)].find(
|
||||||
|
x => x._id === target.dataset.feature
|
||||||
|
);
|
||||||
|
await new DHActionConfig(action).render(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async deleteFeature(_, target) {
|
||||||
|
const actionPath = this.getActionPath(target.dataset.type);
|
||||||
|
await this.document.update({
|
||||||
|
[`system.${actionPath}`]: this.document.system[actionPath].filter(
|
||||||
|
action => action._id !== target.dataset.feature
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async _onDrop(event) {
|
async _onDrop(event) {
|
||||||
const data = TextEditor.getDragEventData(event);
|
const data = TextEditor.getDragEventData(event);
|
||||||
const item = await fromUuid(data.uuid);
|
const item = await fromUuid(data.uuid);
|
||||||
|
|
@ -158,10 +225,6 @@ export default class ClassSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
await this.document.update({
|
await this.document.update({
|
||||||
'system.subclasses': [...this.document.system.subclasses.map(x => x.uuid), item.uuid]
|
'system.subclasses': [...this.document.system.subclasses.map(x => x.uuid), item.uuid]
|
||||||
});
|
});
|
||||||
} else if (item.type === 'feature') {
|
|
||||||
await this.document.update({
|
|
||||||
'system.features': [...this.document.system.features.map(x => x.uuid), item.uuid]
|
|
||||||
});
|
|
||||||
} else if (item.type === 'weapon') {
|
} else if (item.type === 'weapon') {
|
||||||
if (event.currentTarget.classList.contains('primary-weapon-section')) {
|
if (event.currentTarget.classList.contains('primary-weapon-section')) {
|
||||||
if (!this.document.system.characterGuide.suggestedPrimaryWeapon && !item.system.secondary)
|
if (!this.document.system.characterGuide.suggestedPrimaryWeapon && !item.system.secondary)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
||||||
|
import ActionField from '../fields/actionField.mjs';
|
||||||
|
|
||||||
export default class DHClass extends BaseDataItem {
|
export default class DHClass extends BaseDataItem {
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|
@ -19,7 +20,8 @@ export default class DHClass extends BaseDataItem {
|
||||||
domains: new fields.ArrayField(new fields.StringField(), { max: 2 }),
|
domains: new fields.ArrayField(new fields.StringField(), { max: 2 }),
|
||||||
classItems: new fields.ArrayField(new ForeignDocumentUUIDField({ type: 'Item' })),
|
classItems: new fields.ArrayField(new ForeignDocumentUUIDField({ type: 'Item' })),
|
||||||
evasion: new fields.NumberField({ initial: 0, integer: true }),
|
evasion: new fields.NumberField({ initial: 0, integer: true }),
|
||||||
features: new fields.ArrayField(new ForeignDocumentUUIDField({ type: 'Item' })),
|
hopeFeatures: new foundry.data.fields.ArrayField(new ActionField()),
|
||||||
|
classFeatures: new foundry.data.fields.ArrayField(new ActionField()),
|
||||||
subclasses: new fields.ArrayField(
|
subclasses: new fields.ArrayField(
|
||||||
new ForeignDocumentUUIDField({ type: 'Item', required: false, nullable: true, initial: undefined })
|
new ForeignDocumentUUIDField({ type: 'Item', required: false, nullable: true, initial: undefined })
|
||||||
),
|
),
|
||||||
|
|
@ -51,6 +53,10 @@ export default class DHClass extends BaseDataItem {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get hopeFeature() {
|
||||||
|
return this.hopeFeatures.length > 0 ? this.hopeFeatures[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
async _preCreate(data, options, user) {
|
async _preCreate(data, options, user) {
|
||||||
const allowed = await super._preCreate(data, options, user);
|
const allowed = await super._preCreate(data, options, user);
|
||||||
if (allowed === false) return;
|
if (allowed === false) return;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
<a
|
<a
|
||||||
class='effect-control'
|
class='effect-control'
|
||||||
data-action='editFeature'
|
data-action='editFeature'
|
||||||
data-feature='{{feature.uuid}}'
|
data-feature='{{feature._id}}'
|
||||||
|
data-type='{{type}}'
|
||||||
data-tooltip='{{localize "DAGGERHEART.Tooltip.openItemWorld"}}'
|
data-tooltip='{{localize "DAGGERHEART.Tooltip.openItemWorld"}}'
|
||||||
>
|
>
|
||||||
<i class="fa-solid fa-globe"></i>
|
<i class="fa-solid fa-globe"></i>
|
||||||
|
|
@ -17,7 +18,8 @@
|
||||||
<a
|
<a
|
||||||
class='effect-control'
|
class='effect-control'
|
||||||
data-action='deleteFeature'
|
data-action='deleteFeature'
|
||||||
data-feature='{{feature.uuid}}'
|
data-feature='{{feature._id}}'
|
||||||
|
data-type='{{type}}'
|
||||||
data-tooltip='{{localize "DAGGERHEART.Tooltip.delete"}}'
|
data-tooltip='{{localize "DAGGERHEART.Tooltip.delete"}}'
|
||||||
>
|
>
|
||||||
<i class='fas fa-trash'></i>
|
<i class='fas fa-trash'></i>
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,25 @@
|
||||||
data-tab='{{tabs.features.id}}'
|
data-tab='{{tabs.features.id}}'
|
||||||
data-group='{{tabs.features.group}}'
|
data-group='{{tabs.features.group}}'
|
||||||
>
|
>
|
||||||
|
<div class="two-columns even">
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{localize "DAGGERHEART.Sheets.Class.HopeFeatures"}} <a><i class="fa-solid fa-plus icon-button" data-type="hope" data-action="addFeature"></i></a></legend>
|
||||||
|
<div class="feature-list">
|
||||||
|
{{#each source.system.hopeFeatures as |feature index|}}
|
||||||
|
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' type='hope' feature=feature}}
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{{localize "DAGGERHEART.Sheets.Feature.Tabs.Features"}}</legend>
|
<legend>{{localize "DAGGERHEART.Sheets.Class.ClassFeatures"}} <a><i class="fa-solid fa-plus icon-button" data-type="class" data-action="addFeature"></i></a></legend>
|
||||||
<div class="feature-list">
|
<div class="feature-list">
|
||||||
{{#each source.system.features as |feature index|}}
|
{{#each source.system.classFeatures as |feature index|}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' feature=feature}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs' type='class' feature=feature}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{{localize "TYPES.Item.subclass"}}</legend>
|
<legend>{{localize "TYPES.Item.subclass"}}</legend>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue