diff --git a/lang/en.json b/lang/en.json index 632846c0..a6bc1f3f 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1885,6 +1885,7 @@ "tier4": "tier 4", "domains": "Domains", "downtime": "Downtime", + "roll": "Roll", "rules": "Rules" }, "Tiers": { @@ -1934,6 +1935,7 @@ "fear": "Fear", "features": "Features", "formula": "Formula", + "gm": "GM", "healing": "Healing", "healingRoll": "Healing Roll", "hit": { @@ -1968,6 +1970,10 @@ "none": "None", "noTarget": "No current target", "partner": "Partner", + "player": { + "single": "Player", + "plurial": "Players" + }, "proficiency": "Proficiency", "quantity": "Quantity", "range": "Range", @@ -2162,10 +2168,35 @@ "playerCanEditSheet": { "label": "Players Can Manually Edit Character Settings", "hint": "Players are allowed to access the manual Character Settings and change their statistics beyond the rules." + }, + "roll": { + "roll": { + "label": "Roll", + "hint": "Roll Hint" + }, + "damage": { + "label": "Damage/Healing Roll", + "hint": "Damage/Healing Roll Hint" + }, + "save": { + "label": "Reaction Roll", + "hint": "Reaction Roll Hint" + }, + "damageApply": { + "label": "Apply Damage/Healing", + "hint": "Apply Damage/Healing Hint" + }, + "effect": { + "label": "Apply Effects", + "hint": "Apply Effects Hint" + } } }, "defeated": { "title": "Defeated Handling" + }, + "roll": { + "title": "Roll" } }, "Homebrew": { diff --git a/module/applications/settings/automationSettings.mjs b/module/applications/settings/automationSettings.mjs index 0157e016..1a9b6c36 100644 --- a/module/applications/settings/automationSettings.mjs +++ b/module/applications/settings/automationSettings.mjs @@ -35,13 +35,14 @@ export default class DhAutomationSettings extends HandlebarsApplicationMixin(App header: { template: 'systems/daggerheart/templates/settings/automation-settings/header.hbs' }, general: { template: 'systems/daggerheart/templates/settings/automation-settings/general.hbs' }, rules: { template: 'systems/daggerheart/templates/settings/automation-settings/rules.hbs' }, + roll: { template: 'systems/daggerheart/templates/settings/automation-settings/roll.hbs' }, footer: { template: 'systems/daggerheart/templates/settings/automation-settings/footer.hbs' } }; /** @inheritdoc */ static TABS = { main: { - tabs: [{ id: 'general' }, { id: 'rules' }], + tabs: [{ id: 'general' }, { id: 'rules' }, { id: 'roll', cssClass: "with-hint" }], initial: 'general', labelPrefix: 'DAGGERHEART.GENERAL.Tabs' } diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index bec00581..b9c2fde5 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -176,7 +176,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel // } // Consume resources - // await this.consume(config); + await this.consume(config); if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return; @@ -229,9 +229,9 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel // return roll; // } - doFollowUp(config) { - return !config.hasRoll; - } + // doFollowUp(config) { + // return !config.hasRoll; + // } async consume(config, successCost = false) { const actor= this.actor.system.partner ?? this.actor, @@ -301,13 +301,6 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel get hasDamagePart() { return this.damage?.parts?.length; } - - get modifiers() { - if (!this.actor) return []; - const modifiers = []; - /** Placeholder for specific bonuses **/ - return modifiers; - } /* ROLL */ /* SAVE */ diff --git a/module/data/fields/action/damageField.mjs b/module/data/fields/action/damageField.mjs index b6092c8e..11975e7b 100644 --- a/module/data/fields/action/damageField.mjs +++ b/module/data/fields/action/damageField.mjs @@ -3,7 +3,7 @@ import FormulaField from '../formulaField.mjs'; const fields = foundry.data.fields; export default class DamageField extends fields.SchemaField { - static order = 50; + static order = 20; constructor(options, context = {}) { const damageFields = { diff --git a/module/data/fields/action/effectsField.mjs b/module/data/fields/action/effectsField.mjs index f6b736b5..1014c26d 100644 --- a/module/data/fields/action/effectsField.mjs +++ b/module/data/fields/action/effectsField.mjs @@ -1,7 +1,7 @@ const fields = foundry.data.fields; export default class EffectsField extends fields.ArrayField { - static order = 100; + static order = 60; constructor(options = {}, context = {}) { const element = new fields.SchemaField({ @@ -20,4 +20,45 @@ export default class EffectsField extends fields.ArrayField { return; } } + + async applyEffects(data, targets) { + targets ??= data.system.targets; + const force = true; /* Where should this come from? */ + if (!this.effects?.length || !targets.length) return; + let effects = this.effects; + targets.forEach(async token => { + if (!token.hit && !force) return; + if (this.hasSave && token.saved.success === true) { + effects = this.effects.filter(e => e.onSave === true); + } + if (!effects.length) return; + effects.forEach(async e => { + const actor = canvas.tokens.get(token.id)?.actor, + effect = this.item.effects.get(e._id); + if (!actor || !effect) return; + await this.applyEffect(effect, actor); + }); + }); + } + + async applyEffect(effect, actor) { + const existingEffect = actor.effects.find(e => e.origin === effect.uuid); + if (existingEffect) { + return effect.update( + foundry.utils.mergeObject({ + ...effect.constructor.getInitialDuration(), + disabled: false + }) + ); + } + + // Otherwise, create a new effect on the target + const effectData = foundry.utils.mergeObject({ + ...effect.toObject(), + disabled: false, + transfer: false, + origin: effect.uuid + }); + await ActiveEffect.implementation.create(effectData, { parent: actor }); + } } diff --git a/module/data/fields/action/macroField.mjs b/module/data/fields/action/macroField.mjs index 6556a404..e957262d 100644 --- a/module/data/fields/action/macroField.mjs +++ b/module/data/fields/action/macroField.mjs @@ -1,7 +1,7 @@ const fields = foundry.data.fields; export default class MacroField extends fields.DocumentUUIDField { - static order = 200; + static order = 70; constructor(context = {}) { super({ type: "Macro" }, context); diff --git a/module/data/fields/action/saveField.mjs b/module/data/fields/action/saveField.mjs index 12bf51f9..ca0eb220 100644 --- a/module/data/fields/action/saveField.mjs +++ b/module/data/fields/action/saveField.mjs @@ -1,7 +1,7 @@ const fields = foundry.data.fields; export default class SaveField extends fields.SchemaField { - static order = 75; + static order = 50; constructor(options = {}, context = {}) { const saveFields = { diff --git a/module/data/settings/Automation.mjs b/module/data/settings/Automation.mjs index e1d63669..94e492ea 100644 --- a/module/data/settings/Automation.mjs +++ b/module/data/settings/Automation.mjs @@ -80,6 +80,78 @@ export default class DhAutomation extends foundry.abstract.DataModel { initial: CONFIG.DH.GENERAL.defeatedConditions.defeated.id, label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.defeated.companionDefault.label' }) + }), + 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({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.gm' + }), + players: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.player.plurial' + }) + }), + damage: new fields.SchemaField({ + // label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damage.label', + // hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damage.hint', + gm: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.gm' + }), + players: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.player.plurial' + }) + }), + save: new fields.SchemaField({ + // label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.save.label', + // hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.save.hint', + gm: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.gm' + }), + players: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.player.plurial' + }) + }), + damageApply: new fields.SchemaField({ + // label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damageApply.label', + // hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.damageApply.hint', + gm: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.gm' + }), + players: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.player.plurial' + }) + }), + effect: new fields.SchemaField({ + // label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.effect.label', + // hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.roll.effect.hint', + gm: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.gm' + }), + players: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.GENERAL.player.plurial' + }) + }) }) }; } diff --git a/styles/less/global/elements.less b/styles/less/global/elements.less index 6b5d64c9..bf30172b 100755 --- a/styles/less/global/elements.less +++ b/styles/less/global/elements.less @@ -603,8 +603,9 @@ align-items: center; label { - font-size: 16px; + font-size: var(--font-size-14); font-family: @font-body; + font-weight: normal; } .form-fields { diff --git a/styles/less/ui/settings/settings.less b/styles/less/ui/settings/settings.less index 8062ff73..79c31a4e 100644 --- a/styles/less/ui/settings/settings.less +++ b/styles/less/ui/settings/settings.less @@ -139,4 +139,45 @@ text-align: center; } } + + .tab.with-hint { + fieldset { + gap: .5rem; + + .form-group { + flex-wrap: wrap; + gap: .25rem; + + label { + flex: 1; + } + + .hint { + flex: 0 0 100%; + margin: 0; + font-size: var(--font-size-14); + color: var(--color-form-hint); + } + + &:hover { + .hint { + color: var(--color-form-hint-hover); + } + } + } + + .form-group.setting-two-values { + display: grid; + grid-template-columns: repeat(3, 1fr); + + .form-group label { + text-align: right; + } + + .hint { + grid-column: 1 / -1; + } + } + } + } } diff --git a/templates/settings/automation-settings/roll.hbs b/templates/settings/automation-settings/roll.hbs new file mode 100644 index 00000000..41927a5d --- /dev/null +++ b/templates/settings/automation-settings/roll.hbs @@ -0,0 +1,23 @@ +
+
+ + {{localize "DAGGERHEART.SETTINGS.Automation.roll.title"}} + + {{log @root}} + {{#each settingFields.schema.fields.roll.fields as | field |}} + {{!-- {{formGroup field value=(lookup @root.settingFields.roll field.name) localize=true rootId="automation-roll"}} --}} +
+ + {{#with (lookup @root.settingFields.roll field.name) as | values |}} + {{formGroup field.fields.gm value=values.gm rootId=(concat "automation-roll-" field.name "-gm") localize=true}} + {{formGroup field.fields.players value=values.players rootId=(concat "automation-roll-" field.name "-players") localize=true}} + {{/with}} +

{{localize (concat "DAGGERHEART.SETTINGS.Automation.FIELDS.roll." field.name ".hint")}}

+
+ {{/each}} +
+
\ No newline at end of file