This commit is contained in:
Dapoolp 2025-08-17 11:52:12 +02:00
parent 1228eb0105
commit 810d74baa5
11 changed files with 220 additions and 17 deletions

View file

@ -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": {

View file

@ -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'
}

View file

@ -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 */

View file

@ -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 = {

View file

@ -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 });
}
}

View file

@ -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);

View file

@ -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 = {

View file

@ -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'
})
})
})
};
}

View file

@ -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 {

View file

@ -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;
}
}
}
}
}

View file

@ -0,0 +1,23 @@
<section
class="tab {{tabs.roll.cssClass}} {{tabs.roll.id}}"
data-tab="{{tabs.roll.id}}"
data-group="{{tabs.roll.group}}"
>
<fieldset>
<legend>
{{localize "DAGGERHEART.SETTINGS.Automation.roll.title"}}
</legend>
{{log @root}}
{{#each settingFields.schema.fields.roll.fields as | field |}}
{{!-- {{formGroup field value=(lookup @root.settingFields.roll field.name) localize=true rootId="automation-roll"}} --}}
<div class="form-group setting-two-values">
<label>{{localize (concat "DAGGERHEART.SETTINGS.Automation.FIELDS.roll." field.name ".label")}}</label>
{{#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}}
<p class="hint">{{localize (concat "DAGGERHEART.SETTINGS.Automation.FIELDS.roll." field.name ".hint")}}</p>
</div>
{{/each}}
</fieldset>
</section>