mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
h
This commit is contained in:
parent
57aa2afbbe
commit
1b511a587e
17 changed files with 161 additions and 112 deletions
|
|
@ -20,7 +20,7 @@ export default class CostField extends fields.ArrayField {
|
|||
super(element, options, context);
|
||||
}
|
||||
|
||||
static prepareConfig(config) {
|
||||
prepareConfig(config) {
|
||||
const costs = this.cost?.length ? foundry.utils.deepClone(this.cost) : [];
|
||||
config.costs = CostField.calcCosts.call(this, costs);
|
||||
const hasCost = CostField.hasCost.call(this, config.costs);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import FormulaField from '../formulaField.mjs';
|
|||
const fields = foundry.data.fields;
|
||||
|
||||
export default class DamageField extends fields.SchemaField {
|
||||
static order = 20;
|
||||
order = 20;
|
||||
|
||||
constructor(options, context = {}) {
|
||||
const damageFields = {
|
||||
|
|
@ -17,8 +17,8 @@ export default class DamageField extends fields.SchemaField {
|
|||
super(damageFields, options, context);
|
||||
}
|
||||
|
||||
static async execute(data, force = false) {
|
||||
if(this.hasRoll && !force) return;
|
||||
async execute(data, force = false) {
|
||||
if((this.hasRoll && DamageField.getAutomation() === CONFIG.DH.SETTINGS.actionAutomationChoices.never.id) && !force) return false;
|
||||
|
||||
const systemData = data.system ?? data;
|
||||
|
||||
|
|
@ -39,14 +39,19 @@ export default class DamageField extends fields.SchemaField {
|
|||
dialog: {},
|
||||
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 (data.system) {
|
||||
config.source.message = data._id;
|
||||
|
||||
if (data.message || data.system) {
|
||||
config.source.message = data.message?._id ?? data._id;
|
||||
config.directDamage = false;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +82,10 @@ export default class DamageField extends fields.SchemaField {
|
|||
});
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const fields = foundry.data.fields;
|
||||
|
||||
export default class EffectsField extends fields.ArrayField {
|
||||
static order = 60;
|
||||
order = 60;
|
||||
|
||||
constructor(options = {}, context = {}) {
|
||||
const element = new fields.SchemaField({
|
||||
|
|
@ -11,7 +11,7 @@ export default class EffectsField extends fields.ArrayField {
|
|||
super(element, options, context);
|
||||
}
|
||||
|
||||
static async execute(config) {
|
||||
async execute(config) {
|
||||
if(!this.hasRoll) {
|
||||
const roll = new CONFIG.Dice.daggerheart.DHRoll('');
|
||||
roll._evaluated = true;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
const fields = foundry.data.fields;
|
||||
|
||||
export default class MacroField extends fields.DocumentUUIDField {
|
||||
static order = 70;
|
||||
order = 70;
|
||||
|
||||
constructor(context = {}) {
|
||||
super({ type: "Macro" }, context);
|
||||
}
|
||||
|
||||
static async execute(config) {
|
||||
async execute(config) {
|
||||
const fixUUID = !this.macro.includes('Macro.') ? `Macro.${this.macro}` : this.macro,
|
||||
macro = await fromUuid(fixUUID);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default class RangeField extends fields.StringField {
|
|||
super(options, context);
|
||||
}
|
||||
|
||||
static prepareConfig(config) {
|
||||
prepareConfig(config) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,20 +110,22 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
|||
}
|
||||
|
||||
export default class RollField extends fields.EmbeddedDataField {
|
||||
static order = 10;
|
||||
order = 10;
|
||||
|
||||
constructor(options, context = {}) {
|
||||
super(DHActionRollData, options, context);
|
||||
}
|
||||
|
||||
static async execute(config) {
|
||||
async execute(config) {
|
||||
if(!config.hasRoll) return;
|
||||
config = await this.actor.diceRoll(config);
|
||||
if(!config) return false;
|
||||
}
|
||||
|
||||
static prepareConfig(config) {
|
||||
prepareConfig(config) {
|
||||
if(!config.hasRoll) return true;
|
||||
|
||||
config.dialog.configure = !RollField.getAutomation();
|
||||
|
||||
const roll = {
|
||||
baseModifiers: this.roll.getModifier(),
|
||||
|
|
@ -138,4 +140,8 @@ export default class RollField extends fields.EmbeddedDataField {
|
|||
config.roll = roll;
|
||||
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;
|
||||
|
||||
export default class SaveField extends fields.SchemaField {
|
||||
static order = 50;
|
||||
order = 50;
|
||||
|
||||
constructor(options = {}, context = {}) {
|
||||
const saveFields = {
|
||||
|
|
@ -19,13 +19,45 @@ export default class SaveField extends fields.SchemaField {
|
|||
super(saveFields, options, context);
|
||||
}
|
||||
|
||||
static async execute(config) {
|
||||
async execute(config) {
|
||||
if(!this.hasRoll) {
|
||||
const roll = new CONFIG.Dice.daggerheart.DHRoll('');
|
||||
roll._evaluated = true;
|
||||
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);
|
||||
}
|
||||
|
||||
static prepareConfig(config) {
|
||||
if (!this.target?.type) return [];
|
||||
prepareConfig(config) {
|
||||
if (!this.target?.type) return config.targets = [];
|
||||
config.hasTarget = true;
|
||||
let targets;
|
||||
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);
|
||||
}
|
||||
|
||||
static prepareConfig(config) {
|
||||
prepareConfig(config) {
|
||||
const uses = this.uses?.max ? foundry.utils.deepClone(this.uses) : null;
|
||||
if (uses && !uses.value) uses.value = 0;
|
||||
config.uses = uses;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue