mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Improved Schema and now it works
This commit is contained in:
parent
e83202681e
commit
e22928b59e
2 changed files with 36 additions and 63 deletions
|
|
@ -1,20 +1,20 @@
|
||||||
|
import DHSummonField from '../fields/action/summonField.mjs';
|
||||||
import DHBaseAction from './baseAction.mjs';
|
import DHBaseAction from './baseAction.mjs';
|
||||||
|
import DHSummonDialog from '../../applications/dialogs/summonDialog.mjs';
|
||||||
|
|
||||||
export default class DHSummonAction extends DHBaseAction {
|
export default class DHSummonAction extends DHBaseAction {
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
|
||||||
return {
|
return {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
summon: new fields.ArrayField(new fields.SchemaField({
|
summon: new DHSummonField({ required: false, initial: [] })
|
||||||
actorUUID: new fields.DocumentUUIDField({ type: 'Actor', required: true }),
|
|
||||||
count: new fields.NumberField({ required: true, default: 1, min: 1, integer: true })
|
|
||||||
}), { required: false, initial: [] })
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static extraSchemas=[...super.extraSchemas,'summon'];
|
||||||
|
|
||||||
get defaultValues() {
|
get defaultValues() {
|
||||||
return {
|
return {
|
||||||
summon: { actorUUID: "", count: 1 }
|
summon: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,12 +30,6 @@ export default class DHSummonAction extends DHBaseAction {
|
||||||
return game.user.can('TOKEN_CREATE');
|
return game.user.can('TOKEN_CREATE');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Accessor for summon manager for performing the summon action
|
|
||||||
get summonManager() {
|
|
||||||
return game.dh.summon; //incomplete implementation
|
|
||||||
}
|
|
||||||
|
|
||||||
//Logic to perform the summon action - incomplete implementation
|
|
||||||
async _performAction(event, ...args) {
|
async _performAction(event, ...args) {
|
||||||
const validSummons = this.summon.filter(entry => entry.actorUUID);
|
const validSummons = this.summon.filter(entry => entry.actorUUID);
|
||||||
if (validSummons.length === 0) {
|
if (validSummons.length === 0) {
|
||||||
|
|
@ -50,5 +44,7 @@ export default class DHSummonAction extends DHBaseAction {
|
||||||
console.log(`- Ready to summon ${entry.count}x [${actor?.name || "Unknown Actor"}]`);
|
console.log(`- Ready to summon ${entry.count}x [${actor?.name || "Unknown Actor"}]`);
|
||||||
}
|
}
|
||||||
console.groupEnd();
|
console.groupEnd();
|
||||||
|
|
||||||
|
//Todo: Open Summon Dialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,61 +1,38 @@
|
||||||
import DHSummonDialog from '../../../applications/dialogs/summonDialog.mjs';
|
|
||||||
|
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
export default class DHSummonField extends fields.SchemaField {
|
export default class DHSummonField extends fields.ArrayField {
|
||||||
/**
|
/**
|
||||||
* Action Workflow order
|
* Action Workflow order
|
||||||
*/
|
*/
|
||||||
static order = 120;
|
static order = 120;
|
||||||
|
|
||||||
constructor(options = {}, context = {}) {
|
constructor(options = {}, context = {}) {
|
||||||
const summonFields = {
|
const summonFields = new fields.SchemaField({
|
||||||
summon: new fields.ArrayField(new fields.SchemaField({
|
|
||||||
actorUUID: new fields.DocumentUUIDField({
|
actorUUID: new fields.DocumentUUIDField({
|
||||||
type: 'Actor',
|
type: 'Actor',
|
||||||
required: true }),
|
required: true
|
||||||
|
}),
|
||||||
count: new fields.NumberField({
|
count: new fields.NumberField({
|
||||||
required: true,
|
required: true,
|
||||||
default: 1,
|
default: 1,
|
||||||
min: 1,
|
min: 1,
|
||||||
integer: true })
|
integer: true
|
||||||
}), { required: false, initial: [] })
|
})
|
||||||
};
|
})
|
||||||
super(summonFields, options, context);
|
super(summonFields, options, context);
|
||||||
|
|
||||||
|
// summon: new fields.ArrayField(new fields.SchemaField({
|
||||||
|
// actorUUID: new fields.DocumentUUIDField({
|
||||||
|
// type: 'Actor',
|
||||||
|
// required: true }),
|
||||||
|
// count: new fields.NumberField({
|
||||||
|
// required: true,
|
||||||
|
// default: 1,
|
||||||
|
// min: 1,
|
||||||
|
// integer: true })
|
||||||
|
// }), { required: false, initial: [] })
|
||||||
|
// };
|
||||||
|
// super(summonFields, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Summon Action Workflow part.
|
|
||||||
* Must be called within Action context or similar.
|
|
||||||
* @param {object} config Object that contains workflow datas. Usually made from Action Fields prepareConfig methods.
|
|
||||||
*/
|
|
||||||
static async execute(config) {
|
|
||||||
const selected = await DHSummonDialog.configure(config, this.item);
|
|
||||||
if (!selected) return false;
|
|
||||||
return await DHSummonField.summon.call(this, selected);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Update Action Workflow config object.
|
|
||||||
* Must be called within Action context.
|
|
||||||
* @param {object} config Object that contains workflow datas. Usually made from Action Fields prepareConfig methods.
|
|
||||||
*/
|
|
||||||
prepareConfig(config) {
|
|
||||||
if (!canvas.scene){
|
|
||||||
ui.notifications.warn(game.i18n.localize("DAGGERHEART.ACTIONS.TYPES.summon.error"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Logic to perform the summon action - incomplete implementation
|
|
||||||
*/
|
|
||||||
|
|
||||||
get defaultValues() {
|
|
||||||
return {
|
|
||||||
summon: { actorUUID: "", count: 1 }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
get canSummon() {
|
|
||||||
return game.user.can('TOKEN_CREATE');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue