mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
h
This commit is contained in:
parent
57aa2afbbe
commit
1b511a587e
17 changed files with 161 additions and 112 deletions
|
|
@ -112,7 +112,8 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
if (message.system.source.item && message.system.source.action) {
|
if (message.system.source.item && message.system.source.action) {
|
||||||
const action = this.getAction(actor, message.system.source.item, message.system.source.action);
|
const action = this.getAction(actor, message.system.source.item, message.system.source.action);
|
||||||
if (!action || !action?.hasDamagePart) return;
|
if (!action || !action?.hasDamagePart) return;
|
||||||
await game.system.api.fields.ActionFields.DamageField.execute.call(action, message, true);
|
// await game.system.api.fields.ActionFields.DamageField.execute.call(action, message, true);
|
||||||
|
action.schema.fields.damage.execute.call(action, message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,22 @@ export const gameSettings = {
|
||||||
LevelTiers: 'LevelTiers',
|
LevelTiers: 'LevelTiers',
|
||||||
Countdowns: 'Countdowns'
|
Countdowns: 'Countdowns'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const actionAutomationChoices = {
|
||||||
|
never: {
|
||||||
|
id: "never",
|
||||||
|
label: "Never"
|
||||||
|
},
|
||||||
|
showDialog: {
|
||||||
|
id: "showDialog",
|
||||||
|
label: "Show Dialog only"
|
||||||
|
},
|
||||||
|
// npcOnly: {
|
||||||
|
// id: "npcOnly",
|
||||||
|
// label: "Always for non-characters"
|
||||||
|
// },
|
||||||
|
always: {
|
||||||
|
id: "always",
|
||||||
|
label: "Always"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,6 @@ const fields = foundry.data.fields;
|
||||||
|
|
||||||
export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel) {
|
export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel) {
|
||||||
static extraSchemas = ['cost', 'uses', 'range'];
|
static extraSchemas = ['cost', 'uses', 'range'];
|
||||||
// static schemaFields = new Map();
|
|
||||||
static schemaFields = [];
|
|
||||||
// static workflow = [];
|
|
||||||
|
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const schemaFields = {
|
const schemaFields = {
|
||||||
|
|
@ -41,26 +38,38 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
|
|
||||||
this.extraSchemas.forEach(s => {
|
this.extraSchemas.forEach(s => {
|
||||||
let clsField;
|
let clsField;
|
||||||
if ((clsField = this.getActionField(s))) {
|
if ((clsField = this.getActionField(s)))
|
||||||
// this.schemaFields.set(s, clsField);
|
|
||||||
this.schemaFields.push(clsField);
|
|
||||||
schemaFields[s] = new clsField();
|
schemaFields[s] = new clsField();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.schemaFields.sort((a, b) => a.order - b.order);
|
|
||||||
|
|
||||||
// this.prepareWorkflow();
|
|
||||||
console.log(this.schemaFields);
|
|
||||||
|
|
||||||
return schemaFields;
|
return schemaFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static defineWorkflow() {
|
||||||
|
const workflow = [];
|
||||||
|
Object.values(this.schema.fields).forEach(s => {
|
||||||
|
if(s.execute) workflow.push( { order: s.order, execute: s.execute } );
|
||||||
|
});
|
||||||
|
workflow.sort((a, b) => a.order - b.order);
|
||||||
|
return workflow.map(s => s.execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
static get workflow() {
|
||||||
|
if ( this.hasOwnProperty("_workflow") ) return this._workflow;
|
||||||
|
const workflow = Object.freeze(this.defineWorkflow());
|
||||||
|
Object.defineProperty(this, "_workflow", {value: workflow, writable: false});
|
||||||
|
return workflow;
|
||||||
|
}
|
||||||
|
|
||||||
static getActionField(name) {
|
static getActionField(name) {
|
||||||
const field = game.system.api.fields.ActionFields[`${name.capitalize()}Field`];
|
const field = game.system.api.fields.ActionFields[`${name.capitalize()}Field`];
|
||||||
return fields.DataField.isPrototypeOf(field) && field;
|
return fields.DataField.isPrototypeOf(field) && field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get workflow() {
|
||||||
|
return this.constructor.workflow;
|
||||||
|
}
|
||||||
|
|
||||||
prepareData() {
|
prepareData() {
|
||||||
this.name = this.name || game.i18n.localize(CONFIG.DH.ACTIONS.actionTypes[this.type].name);
|
this.name = this.name || game.i18n.localize(CONFIG.DH.ACTIONS.actionTypes[this.type].name);
|
||||||
this.img = this.img ?? this.parent?.parent?.img;
|
this.img = this.img ?? this.parent?.parent?.img;
|
||||||
|
|
@ -123,28 +132,9 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
return actorData;
|
return actorData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static prepareWorkflow() {
|
|
||||||
// this.schemaFields.forEach( clsField => {
|
|
||||||
// if (clsField?.execute)
|
|
||||||
// this.workflow.push({ order: clsField.order, exec: clsField.execute});
|
|
||||||
// })
|
|
||||||
/* for (let i = 0; i < this.constructor.extraSchemas.length; i++) {
|
|
||||||
// let clsField = this.constructor.getActionField(this.constructor.extraSchemas[i]);
|
|
||||||
let clsField = this.constructor.schemaFields.get(this.constructor.extraSchemas[i]);
|
|
||||||
if (clsField?.execute) {
|
|
||||||
workflow.push({ order: clsField.order, exec: clsField.execute});
|
|
||||||
// const keep = clsField.prepareConfig.call(this, config);
|
|
||||||
// if (config.isFastForward && !keep) return;
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
// this.workflow.sort((a, b) => a.order - b.order);
|
|
||||||
// }
|
|
||||||
|
|
||||||
async executeWorkflow(config) {
|
async executeWorkflow(config) {
|
||||||
console.log(this.constructor.workflow)
|
for(const part of this.workflow) {
|
||||||
for(const part of this.constructor.workflow) {
|
if(await part.call(this, config) === false) return;
|
||||||
console.log(part)
|
|
||||||
if(await part.exec.call(this, config) === false) return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,12 +142,11 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
if (!this.actor) throw new Error("An Action can't be used outside of an Actor context.");
|
if (!this.actor) throw new Error("An Action can't be used outside of an Actor context.");
|
||||||
|
|
||||||
if (this.chatDisplay) await this.toChat();
|
if (this.chatDisplay) await this.toChat();
|
||||||
|
|
||||||
let { byPassRoll } = options,
|
let { byPassRoll } = options,
|
||||||
config = this.prepareConfig(event, byPassRoll);
|
config = this.prepareConfig(event, byPassRoll);
|
||||||
// for (let i = 0; i < this.constructor.extraSchemas.length; i++) {
|
|
||||||
// let clsField = this.constructor.getActionField(this.constructor.extraSchemas[i]);
|
Object.values(this.schema.fields).forEach( clsField => {
|
||||||
// let clsField = this.constructor.schemaFields.get(this.constructor.extraSchemas[i]);
|
|
||||||
this.constructor.schemaFields.forEach( clsField => {
|
|
||||||
if (clsField?.prepareConfig) {
|
if (clsField?.prepareConfig) {
|
||||||
const keep = clsField.prepareConfig.call(this, config);
|
const keep = clsField.prepareConfig.call(this, config);
|
||||||
if (config.isFastForward && !keep) return;
|
if (config.isFastForward && !keep) return;
|
||||||
|
|
@ -172,9 +161,6 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
if (!config) return;
|
if (!config) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const workflow = [];
|
|
||||||
|
|
||||||
// this.prepareWorkflow(workflow);
|
|
||||||
await this.executeWorkflow(config);
|
await this.executeWorkflow(config);
|
||||||
|
|
||||||
// if (config.hasRoll) {
|
// if (config.hasRoll) {
|
||||||
|
|
@ -376,26 +362,26 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
/* EFFECTS */
|
/* EFFECTS */
|
||||||
|
|
||||||
/* SAVE */
|
/* SAVE */
|
||||||
async rollSave(actor, event, message) {
|
// async rollSave(actor, event, message) {
|
||||||
if (!actor) return;
|
// if (!actor) return;
|
||||||
const title = actor.isNPC
|
// const title = actor.isNPC
|
||||||
? game.i18n.localize('DAGGERHEART.GENERAL.reactionRoll')
|
// ? game.i18n.localize('DAGGERHEART.GENERAL.reactionRoll')
|
||||||
: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
// : game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
||||||
ability: game.i18n.localize(abilities[this.save.trait]?.label)
|
// ability: game.i18n.localize(abilities[this.save.trait]?.label)
|
||||||
});
|
// });
|
||||||
return actor.diceRoll({
|
// return actor.diceRoll({
|
||||||
event,
|
// event,
|
||||||
title,
|
// title,
|
||||||
roll: {
|
// roll: {
|
||||||
trait: this.save.trait,
|
// trait: this.save.trait,
|
||||||
difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty,
|
// difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty,
|
||||||
type: 'reaction'
|
// type: 'reaction'
|
||||||
},
|
// },
|
||||||
type: 'trait',
|
// type: 'trait',
|
||||||
hasRoll: true,
|
// hasRoll: true,
|
||||||
data: actor.getRollData()
|
// data: actor.getRollData()
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
updateSaveMessage(result, message, targetId) {
|
updateSaveMessage(result, message, targetId) {
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
|
|
@ -408,14 +394,14 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
else updateMsg();
|
else updateMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
static rollSaveQuery({ actionId, actorId, event, message }) {
|
// static rollSaveQuery({ actionId, actorId, event, message }) {
|
||||||
return new Promise(async (resolve, reject) => {
|
// return new Promise(async (resolve, reject) => {
|
||||||
const actor = await fromUuid(actorId),
|
// const actor = await fromUuid(actorId),
|
||||||
action = await fromUuid(actionId);
|
// action = await fromUuid(actionId);
|
||||||
if (!actor || !actor?.isOwner) reject();
|
// if (!actor || !actor?.isOwner) reject();
|
||||||
action.rollSave(actor, event, message).then(result => resolve(result));
|
// action.rollSave(actor, event, message).then(result => resolve(result));
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
/* SAVE */
|
/* SAVE */
|
||||||
|
|
||||||
async updateChatMessage(message, targetId, changes, chain = true) {
|
async updateChatMessage(message, targetId, changes, chain = true) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export default class CostField extends fields.ArrayField {
|
||||||
super(element, options, context);
|
super(element, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareConfig(config) {
|
prepareConfig(config) {
|
||||||
const costs = this.cost?.length ? foundry.utils.deepClone(this.cost) : [];
|
const costs = this.cost?.length ? foundry.utils.deepClone(this.cost) : [];
|
||||||
config.costs = CostField.calcCosts.call(this, costs);
|
config.costs = CostField.calcCosts.call(this, costs);
|
||||||
const hasCost = CostField.hasCost.call(this, config.costs);
|
const hasCost = CostField.hasCost.call(this, config.costs);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import FormulaField from '../formulaField.mjs';
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
export default class DamageField extends fields.SchemaField {
|
export default class DamageField extends fields.SchemaField {
|
||||||
static order = 20;
|
order = 20;
|
||||||
|
|
||||||
constructor(options, context = {}) {
|
constructor(options, context = {}) {
|
||||||
const damageFields = {
|
const damageFields = {
|
||||||
|
|
@ -17,8 +17,8 @@ export default class DamageField extends fields.SchemaField {
|
||||||
super(damageFields, options, context);
|
super(damageFields, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async execute(data, force = false) {
|
async execute(data, force = false) {
|
||||||
if(this.hasRoll && !force) return;
|
if((this.hasRoll && DamageField.getAutomation() === CONFIG.DH.SETTINGS.actionAutomationChoices.never.id) && !force) return false;
|
||||||
|
|
||||||
const systemData = data.system ?? data;
|
const systemData = data.system ?? data;
|
||||||
|
|
||||||
|
|
@ -39,14 +39,19 @@ export default class DamageField extends fields.SchemaField {
|
||||||
dialog: {},
|
dialog: {},
|
||||||
data: this.getRollData()
|
data: this.getRollData()
|
||||||
};
|
};
|
||||||
|
if(DamageField.getAutomation() === CONFIG.DH.SETTINGS.actionAutomationChoices.always.id) config.dialog.configure = false;
|
||||||
if (this.hasSave) config.onSave = this.save.damageMod;
|
if (this.hasSave) config.onSave = this.save.damageMod;
|
||||||
if (data.system) {
|
|
||||||
config.source.message = data._id;
|
if (data.message || data.system) {
|
||||||
|
config.source.message = data.message?._id ?? data._id;
|
||||||
config.directDamage = false;
|
config.directDamage = false;
|
||||||
} else {
|
} else {
|
||||||
config.directDamage = true;
|
config.directDamage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(config.source?.message && game.modules.get('dice-so-nice')?.active)
|
||||||
|
await game.dice3d.waitFor3DAnimationByMessageID(config.source.message);
|
||||||
|
|
||||||
if(!CONFIG.Dice.daggerheart.DamageRoll.build(config)) return false;
|
if(!CONFIG.Dice.daggerheart.DamageRoll.build(config)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,6 +82,10 @@ export default class DamageField extends fields.SchemaField {
|
||||||
});
|
});
|
||||||
return formattedFormulas;
|
return formattedFormulas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getAutomation() {
|
||||||
|
return (game.user.isGM && game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).roll.damage.gm) || (!game.user.isGM && game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).roll.damage.players)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DHActionDiceData extends foundry.abstract.DataModel {
|
export class DHActionDiceData extends foundry.abstract.DataModel {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
export default class EffectsField extends fields.ArrayField {
|
export default class EffectsField extends fields.ArrayField {
|
||||||
static order = 60;
|
order = 60;
|
||||||
|
|
||||||
constructor(options = {}, context = {}) {
|
constructor(options = {}, context = {}) {
|
||||||
const element = new fields.SchemaField({
|
const element = new fields.SchemaField({
|
||||||
|
|
@ -11,7 +11,7 @@ export default class EffectsField extends fields.ArrayField {
|
||||||
super(element, options, context);
|
super(element, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async execute(config) {
|
async execute(config) {
|
||||||
if(!this.hasRoll) {
|
if(!this.hasRoll) {
|
||||||
const roll = new CONFIG.Dice.daggerheart.DHRoll('');
|
const roll = new CONFIG.Dice.daggerheart.DHRoll('');
|
||||||
roll._evaluated = true;
|
roll._evaluated = true;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
export default class MacroField extends fields.DocumentUUIDField {
|
export default class MacroField extends fields.DocumentUUIDField {
|
||||||
static order = 70;
|
order = 70;
|
||||||
|
|
||||||
constructor(context = {}) {
|
constructor(context = {}) {
|
||||||
super({ type: "Macro" }, context);
|
super({ type: "Macro" }, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async execute(config) {
|
async execute(config) {
|
||||||
const fixUUID = !this.macro.includes('Macro.') ? `Macro.${this.macro}` : this.macro,
|
const fixUUID = !this.macro.includes('Macro.') ? `Macro.${this.macro}` : this.macro,
|
||||||
macro = await fromUuid(fixUUID);
|
macro = await fromUuid(fixUUID);
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default class RangeField extends fields.StringField {
|
||||||
super(options, context);
|
super(options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareConfig(config) {
|
prepareConfig(config) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,21 +110,23 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class RollField extends fields.EmbeddedDataField {
|
export default class RollField extends fields.EmbeddedDataField {
|
||||||
static order = 10;
|
order = 10;
|
||||||
|
|
||||||
constructor(options, context = {}) {
|
constructor(options, context = {}) {
|
||||||
super(DHActionRollData, options, context);
|
super(DHActionRollData, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async execute(config) {
|
async execute(config) {
|
||||||
if(!config.hasRoll) return;
|
if(!config.hasRoll) return;
|
||||||
config = await this.actor.diceRoll(config);
|
config = await this.actor.diceRoll(config);
|
||||||
if(!config) return false;
|
if(!config) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareConfig(config) {
|
prepareConfig(config) {
|
||||||
if(!config.hasRoll) return true;
|
if(!config.hasRoll) return true;
|
||||||
|
|
||||||
|
config.dialog.configure = !RollField.getAutomation();
|
||||||
|
|
||||||
const roll = {
|
const roll = {
|
||||||
baseModifiers: this.roll.getModifier(),
|
baseModifiers: this.roll.getModifier(),
|
||||||
label: 'Attack',
|
label: 'Attack',
|
||||||
|
|
@ -138,4 +140,8 @@ export default class RollField extends fields.EmbeddedDataField {
|
||||||
config.roll = roll;
|
config.roll = roll;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getAutomation() {
|
||||||
|
return (game.user.isGM && game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).roll.roll.gm) || (!game.user.isGM && game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).roll.roll.players)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
export default class SaveField extends fields.SchemaField {
|
export default class SaveField extends fields.SchemaField {
|
||||||
static order = 50;
|
order = 50;
|
||||||
|
|
||||||
constructor(options = {}, context = {}) {
|
constructor(options = {}, context = {}) {
|
||||||
const saveFields = {
|
const saveFields = {
|
||||||
|
|
@ -19,13 +19,45 @@ export default class SaveField extends fields.SchemaField {
|
||||||
super(saveFields, options, context);
|
super(saveFields, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async execute(config) {
|
async execute(config) {
|
||||||
if(!this.hasRoll) {
|
if(!this.hasRoll) {
|
||||||
const roll = new CONFIG.Dice.daggerheart.DHRoll('');
|
const roll = new CONFIG.Dice.daggerheart.DHRoll('');
|
||||||
roll._evaluated = true;
|
roll._evaluated = true;
|
||||||
await CONFIG.Dice.daggerheart.DHRoll.toMessage(roll, config);
|
await CONFIG.Dice.daggerheart.DHRoll.toMessage(roll, config);
|
||||||
} else {
|
}
|
||||||
return;
|
if(true) {
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async rollSave(actor, event, message) {
|
||||||
|
if (!actor) return;
|
||||||
|
const title = actor.isNPC
|
||||||
|
? game.i18n.localize('DAGGERHEART.GENERAL.reactionRoll')
|
||||||
|
: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
||||||
|
ability: game.i18n.localize(abilities[this.save.trait]?.label)
|
||||||
|
});
|
||||||
|
return actor.diceRoll({
|
||||||
|
event,
|
||||||
|
title,
|
||||||
|
roll: {
|
||||||
|
trait: this.save.trait,
|
||||||
|
difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty,
|
||||||
|
type: 'reaction'
|
||||||
|
},
|
||||||
|
type: 'trait',
|
||||||
|
hasRoll: true,
|
||||||
|
data: actor.getRollData()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static rollSaveQuery({ actionId, actorId, event, message }) {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
const actor = await fromUuid(actorId),
|
||||||
|
action = await fromUuid(actionId);
|
||||||
|
if (!actor || !actor?.isOwner) reject();
|
||||||
|
action.rollSave(actor, event, message).then(result => resolve(result));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ export default class TargetField extends fields.SchemaField {
|
||||||
super(targetFields, options, context);
|
super(targetFields, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareConfig(config) {
|
prepareConfig(config) {
|
||||||
if (!this.target?.type) return [];
|
if (!this.target?.type) return config.targets = [];
|
||||||
config.hasTarget = true;
|
config.hasTarget = true;
|
||||||
let targets;
|
let targets;
|
||||||
if (this.target?.type === CONFIG.DH.GENERAL.targetTypes.self.id)
|
if (this.target?.type === CONFIG.DH.GENERAL.targetTypes.self.id)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export default class UsesField extends fields.SchemaField {
|
||||||
super(usesFields, options, context);
|
super(usesFields, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareConfig(config) {
|
prepareConfig(config) {
|
||||||
const uses = this.uses?.max ? foundry.utils.deepClone(this.uses) : null;
|
const uses = this.uses?.max ? foundry.utils.deepClone(this.uses) : null;
|
||||||
if (uses && !uses.value) uses.value = 0;
|
if (uses && !uses.value) uses.value = 0;
|
||||||
config.uses = uses;
|
config.uses = uses;
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,6 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
||||||
}),
|
}),
|
||||||
roll: new fields.SchemaField({
|
roll: new fields.SchemaField({
|
||||||
roll: new fields.SchemaField({
|
roll: new fields.SchemaField({
|
||||||
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.roll.label',
|
|
||||||
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.roll.hint',
|
|
||||||
gm: new fields.BooleanField({
|
gm: new fields.BooleanField({
|
||||||
required: true,
|
required: true,
|
||||||
initial: false,
|
initial: false,
|
||||||
|
|
@ -97,36 +95,34 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
damage: new fields.SchemaField({
|
damage: new fields.SchemaField({
|
||||||
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damage.label',
|
gm: new fields.StringField({
|
||||||
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damage.hint',
|
|
||||||
gm: new fields.BooleanField({
|
|
||||||
required: true,
|
required: true,
|
||||||
initial: false,
|
initial: "never",
|
||||||
|
choices: CONFIG.DH.SETTINGS.actionAutomationChoices,
|
||||||
label: 'DAGGERHEART.GENERAL.gm'
|
label: 'DAGGERHEART.GENERAL.gm'
|
||||||
}),
|
}),
|
||||||
players: new fields.BooleanField({
|
players: new fields.StringField({
|
||||||
required: true,
|
required: true,
|
||||||
initial: false,
|
initial: "never",
|
||||||
|
choices: CONFIG.DH.SETTINGS.actionAutomationChoices,
|
||||||
label: 'DAGGERHEART.GENERAL.player.plurial'
|
label: 'DAGGERHEART.GENERAL.player.plurial'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
save: new fields.SchemaField({
|
save: new fields.SchemaField({
|
||||||
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.save.label',
|
gm: new fields.StringField({
|
||||||
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.save.hint',
|
|
||||||
gm: new fields.BooleanField({
|
|
||||||
required: true,
|
required: true,
|
||||||
initial: false,
|
initial: "never",
|
||||||
|
choices: CONFIG.DH.SETTINGS.actionAutomationChoices,
|
||||||
label: 'DAGGERHEART.GENERAL.gm'
|
label: 'DAGGERHEART.GENERAL.gm'
|
||||||
}),
|
}),
|
||||||
players: new fields.BooleanField({
|
players: new fields.StringField({
|
||||||
required: true,
|
required: true,
|
||||||
initial: false,
|
initial: "never",
|
||||||
|
choices: CONFIG.DH.SETTINGS.actionAutomationChoices,
|
||||||
label: 'DAGGERHEART.GENERAL.player.plurial'
|
label: 'DAGGERHEART.GENERAL.player.plurial'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
damageApply: new fields.SchemaField({
|
damageApply: new fields.SchemaField({
|
||||||
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damageApply.label',
|
|
||||||
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damageApply.hint',
|
|
||||||
gm: new fields.BooleanField({
|
gm: new fields.BooleanField({
|
||||||
required: true,
|
required: true,
|
||||||
initial: false,
|
initial: false,
|
||||||
|
|
@ -139,8 +135,6 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
effect: new fields.SchemaField({
|
effect: new fields.SchemaField({
|
||||||
// label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.effect.label',
|
|
||||||
// hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.effect.hint',
|
|
||||||
gm: new fields.BooleanField({
|
gm: new fields.BooleanField({
|
||||||
required: true,
|
required: true,
|
||||||
initial: false,
|
initial: false,
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import DHRoll from './dhRoll.mjs';
|
||||||
export default class DamageRoll extends DHRoll {
|
export default class DamageRoll extends DHRoll {
|
||||||
constructor(formula, data = {}, options = {}) {
|
constructor(formula, data = {}, options = {}) {
|
||||||
super(formula, data, options);
|
super(formula, data, options);
|
||||||
|
if(options.dialog.configure === false) this.constructFormula(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DefaultDialog = DamageDialog;
|
static DefaultDialog = DamageDialog;
|
||||||
|
|
@ -40,6 +41,7 @@ export default class DamageRoll extends DHRoll {
|
||||||
await game.dice3d.showForRoll(diceRoll, game.user, true, chatMessage.whisper, chatMessage.blind);
|
await game.dice3d.showForRoll(diceRoll, game.user, true, chatMessage.whisper, chatMessage.blind);
|
||||||
}
|
}
|
||||||
await super.buildPost(roll, config, message);
|
await super.buildPost(roll, config, message);
|
||||||
|
// console.log(config, config.source?.message)
|
||||||
if (config.source?.message) {
|
if (config.source?.message) {
|
||||||
chatMessage.update({ 'system.damage': config.damage });
|
chatMessage.update({ 'system.damage': config.damage });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import DamageReductionDialog from '../applications/dialogs/damageReductionDialog.mjs';
|
import DamageReductionDialog from '../applications/dialogs/damageReductionDialog.mjs';
|
||||||
|
import SaveField from '../data/fields/action/saveField.mjs';
|
||||||
|
|
||||||
export function handleSocketEvent({ action = null, data = {} } = {}) {
|
export function handleSocketEvent({ action = null, data = {} } = {}) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
@ -78,7 +79,7 @@ export const registerSocketHooks = () => {
|
||||||
|
|
||||||
export const registerUserQueries = () => {
|
export const registerUserQueries = () => {
|
||||||
CONFIG.queries.armorSlot = DamageReductionDialog.armorSlotQuery;
|
CONFIG.queries.armorSlot = DamageReductionDialog.armorSlotQuery;
|
||||||
CONFIG.queries.reactionRoll = game.system.api.models.actions.actionsTypes.base.rollSaveQuery;
|
CONFIG.queries.reactionRoll = SaveField.rollSaveQuery;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const emitAsGM = async (eventName, callback, update, uuid = null) => {
|
export const emitAsGM = async (eventName, callback, update, uuid = null) => {
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@
|
||||||
gap: .5rem;
|
gap: .5rem;
|
||||||
|
|
||||||
.form-group {
|
.form-group {
|
||||||
flex-wrap: wrap;
|
// flex-wrap: wrap;
|
||||||
gap: .25rem;
|
gap: .25rem;
|
||||||
|
|
||||||
label {
|
label {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.SETTINGS.Automation.roll.title"}}
|
{{localize "DAGGERHEART.SETTINGS.Automation.roll.title"}}
|
||||||
</legend>
|
</legend>
|
||||||
{{log @root}}
|
|
||||||
{{#each settingFields.schema.fields.roll.fields as | field |}}
|
{{#each settingFields.schema.fields.roll.fields as | field |}}
|
||||||
{{!-- {{formGroup field value=(lookup @root.settingFields.roll field.name) localize=true rootId="automation-roll"}} --}}
|
{{!-- {{formGroup field value=(lookup @root.settingFields.roll field.name) localize=true rootId="automation-roll"}} --}}
|
||||||
<div class="form-group setting-two-values">
|
<div class="form-group setting-two-values">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue