mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 05:31:07 +01:00
Create new actions classes
This commit is contained in:
parent
53be047e12
commit
4c7f3a02c4
6 changed files with 105 additions and 16 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs';
|
import DaggerheartSheet from '../sheets/daggerheart-sheet.mjs';
|
||||||
|
|
||||||
const { ApplicationV2 } = foundry.applications.api;
|
const { ApplicationV2 } = foundry.applications.api;
|
||||||
export default class DaggerheartActionConfig extends DaggerheartSheet(ApplicationV2) {
|
export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
constructor(action) {
|
constructor(action) {
|
||||||
super({});
|
super({});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import DaggerheartAction from '../../../data/action.mjs';
|
import DHAction from '../../../data/action.mjs';
|
||||||
import DaggerheartActionConfig from '../../config/Action.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;
|
||||||
|
|
@ -76,7 +76,7 @@ export default class DomainCardSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
|
|
||||||
static async addAction() {
|
static async addAction() {
|
||||||
const actionIndexes = this.document.system.actions.map(x => x.id.split('-')[2]).sort((a, b) => a - b);
|
const actionIndexes = this.document.system.actions.map(x => x.id.split('-')[2]).sort((a, b) => a - b);
|
||||||
const action = await new DaggerheartAction(
|
const action = await new DHAction(
|
||||||
{
|
{
|
||||||
id: `${this.document.id}-Action-${actionIndexes.length > 0 ? actionIndexes[0] + 1 : 1}`
|
id: `${this.document.id}-Action-${actionIndexes.length > 0 ? actionIndexes[0] + 1 : 1}`
|
||||||
},
|
},
|
||||||
|
|
@ -85,14 +85,14 @@ export default class DomainCardSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
||||||
await new DaggerheartActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render(
|
await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render(
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async editAction(_, button) {
|
static async editAction(_, button) {
|
||||||
const action = this.document.system.actions[button.dataset.index];
|
const action = this.document.system.actions[button.dataset.index];
|
||||||
await new DaggerheartActionConfig(action).render(true);
|
await new DHActionConfig(action).render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async removeAction(event, button) {
|
static async removeAction(event, button) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import DaggerheartAction from '../../../data/action.mjs';
|
import DHAction from '../../../data/action.mjs';
|
||||||
import DaggerheartActionConfig from '../../config/Action.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;
|
||||||
|
|
@ -132,16 +132,16 @@ export default class FeatureSheet extends DaggerheartSheet(ItemSheetV2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async addAction() {
|
static async addAction() {
|
||||||
const action = await new DaggerheartAction({ img: this.document.img }, { parent: this.document });
|
const action = await new DHAction({ img: this.document.img }, { parent: this.document });
|
||||||
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
||||||
await new DaggerheartActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render(
|
await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render(
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async editAction(_, button) {
|
static async editAction(_, button) {
|
||||||
const action = this.document.system.actions[button.dataset.index];
|
const action = this.document.system.actions[button.dataset.index];
|
||||||
await new DaggerheartActionConfig(action).render(true);
|
await new DHActionConfig(action).render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async removeAction(event, button) {
|
static async removeAction(event, button) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export default class DaggerheartAction extends foundry.abstract.DataModel {
|
export default class DHAction extends foundry.abstract.DataModel {
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
|
|
@ -32,3 +32,92 @@ export default class DaggerheartAction extends foundry.abstract.DataModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
|
export class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
|
static defineSchema() {
|
||||||
|
return {
|
||||||
|
_id: new fields.DocumentIdField(),
|
||||||
|
type: new fields.StringField({ blank: false, required: true, readOnly: true, initial: () => '' }),
|
||||||
|
name: new fields.StringField({ initial: 'New Action' }),
|
||||||
|
// description: new fields.StringField({}),
|
||||||
|
// shortDescription: new fields.StringField({}),
|
||||||
|
cost: new fields.SchemaField({
|
||||||
|
type: new fields.StringField({ choices: SYSTEM.GENERAL.abilityCosts, nullable: true, initial: null }),
|
||||||
|
value: new fields.NumberField({ nullable: true, initial: null })
|
||||||
|
}),
|
||||||
|
uses: new fields.SchemaField({
|
||||||
|
value: new fields.NumberField({ nullable: true, initial: null }),
|
||||||
|
max: new fields.NumberField({ nullable: true, initial: null }),
|
||||||
|
recovery: new fields.StringField({
|
||||||
|
// choices: SYSTEM.ACTIONS.targetTypes,
|
||||||
|
// initial: SYSTEM.ACTIONS.targetTypes.other.id
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
duration: new fields.SchemaField({
|
||||||
|
value: new fields.NumberField({ nullable: true, initial: null }),
|
||||||
|
units: new fields.StringField({required: true, blank: false, initial: "instant"})
|
||||||
|
}),
|
||||||
|
target: new fields.SchemaField({
|
||||||
|
type: new fields.StringField({
|
||||||
|
choices: SYSTEM.ACTIONS.targetTypes,
|
||||||
|
initial: SYSTEM.ACTIONS.targetTypes.other.id
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DHAttackAction extends DHBaseAction {
|
||||||
|
static defineSchema() {
|
||||||
|
return {
|
||||||
|
...super.defineSchema(),
|
||||||
|
attack: new fields.SchemaField({}),
|
||||||
|
damage: new fields.SchemaField({})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DHDamageAction extends DHBaseAction {
|
||||||
|
static defineSchema() {
|
||||||
|
return {
|
||||||
|
...super.defineSchema(),
|
||||||
|
damage: new fields.SchemaField({})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DHHealingAction extends DHBaseAction {
|
||||||
|
static defineSchema() {
|
||||||
|
return {
|
||||||
|
...super.defineSchema(),
|
||||||
|
healing: new fields.SchemaField({})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DHSummonAction extends DHBaseAction {
|
||||||
|
static defineSchema() {
|
||||||
|
return {
|
||||||
|
...super.defineSchema(),
|
||||||
|
healing: new fields.SchemaField({})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DHEffectAction extends DHBaseAction {
|
||||||
|
static defineSchema() {
|
||||||
|
return {
|
||||||
|
...super.defineSchema()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DHMacroAction extends DHBaseAction {
|
||||||
|
static defineSchema() {
|
||||||
|
return {
|
||||||
|
...super.defineSchema()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import DaggerheartAction from "../action.mjs";
|
import DHAction from "../action.mjs";
|
||||||
import BaseDataItem from "./base.mjs";
|
import BaseDataItem from "./base.mjs";
|
||||||
|
|
||||||
export default class DHDomainCard extends BaseDataItem {
|
export default class DHDomainCard extends BaseDataItem {
|
||||||
|
|
@ -22,7 +22,7 @@ export default class DHDomainCard extends BaseDataItem {
|
||||||
type: new fields.StringField({ choices: SYSTEM.DOMAIN.cardTypes, required: true, blank: true}),
|
type: new fields.StringField({ choices: SYSTEM.DOMAIN.cardTypes, required: true, blank: true}),
|
||||||
foundation: new fields.BooleanField({ initial: false }),
|
foundation: new fields.BooleanField({ initial: false }),
|
||||||
inVault: new fields.BooleanField({ initial: false }),
|
inVault: new fields.BooleanField({ initial: false }),
|
||||||
actions: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartAction))
|
actions: new fields.ArrayField(new fields.EmbeddedDataField(DHAction))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { getTier } from '../../helpers/utils.mjs';
|
import { getTier } from '../../helpers/utils.mjs';
|
||||||
import DaggerheartAction from '../action.mjs';
|
import DHAction from '../action.mjs';
|
||||||
import BaseDataItem from './base.mjs';
|
import BaseDataItem from './base.mjs';
|
||||||
|
|
||||||
export default class DHFeature extends BaseDataItem {
|
export default class DHFeature extends BaseDataItem {
|
||||||
|
|
@ -92,7 +92,7 @@ export default class DHFeature extends BaseDataItem {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
actions: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartAction))
|
actions: new fields.ArrayField(new fields.EmbeddedDataField(DHAction))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue