mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
.
This commit is contained in:
parent
36eac51041
commit
8881f14153
8 changed files with 84 additions and 13 deletions
|
|
@ -401,8 +401,18 @@ class RegisteredTriggers extends Map {
|
||||||
if (currentActor?.uuid !== actor) continue;
|
if (currentActor?.uuid !== actor) continue;
|
||||||
|
|
||||||
for (let command of commands) {
|
for (let command of commands) {
|
||||||
const commandUpdates = await command(...args);
|
try {
|
||||||
if (commandUpdates?.length) updates.push(...commandUpdates);
|
const commandUpdates = await command(...args);
|
||||||
|
if (commandUpdates?.length) updates.push(...commandUpdates);
|
||||||
|
} catch (_) {
|
||||||
|
const triggerName = game.i18n.localize(CONFIG.DH.TRIGGER.triggers[trigger].label);
|
||||||
|
ui.notifications.error(
|
||||||
|
game.i18n.format('DAGGERHEART.CONFIG.Triggers.triggerError', {
|
||||||
|
trigger: triggerName,
|
||||||
|
actor: currentActor?.name
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
lang/en.json
15
lang/en.json
|
|
@ -90,7 +90,9 @@
|
||||||
"customFormula": "Custom Formula",
|
"customFormula": "Custom Formula",
|
||||||
"formula": "Formula"
|
"formula": "Formula"
|
||||||
},
|
},
|
||||||
"displayInChat": "Display in chat"
|
"displayInChat": "Display in chat",
|
||||||
|
"deleteTriggerTitle": "Delete Trigger",
|
||||||
|
"deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?"
|
||||||
},
|
},
|
||||||
"RollField": {
|
"RollField": {
|
||||||
"diceRolling": {
|
"diceRolling": {
|
||||||
|
|
@ -1218,8 +1220,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Triggers": {
|
"Triggers": {
|
||||||
"dualityRoll": "Duality Roll",
|
"dualityRoll": {
|
||||||
"fearRoll": "Fear Roll"
|
"label": "Duality Roll",
|
||||||
|
"hint": "this: Action, roll: DhRoll, actor: DhActor"
|
||||||
|
},
|
||||||
|
"fearRoll": {
|
||||||
|
"label": "Fear Roll",
|
||||||
|
"hint": "this: Action\nroll: DhRoll\nactor: DhActor"
|
||||||
|
},
|
||||||
|
"triggerError": "{trigger} trigger failed for {actor}. It's probably configured wrong."
|
||||||
},
|
},
|
||||||
"WeaponFeature": {
|
"WeaponFeature": {
|
||||||
"barrier": {
|
"barrier": {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
||||||
|
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
tag: 'form',
|
tag: 'form',
|
||||||
classes: ['daggerheart', 'dh-style', 'dialog', 'max-800'],
|
classes: ['daggerheart', 'dh-style', 'action-config', 'dialog', 'max-800'],
|
||||||
window: {
|
window: {
|
||||||
icon: 'fa-solid fa-wrench',
|
icon: 'fa-solid fa-wrench',
|
||||||
resizable: false
|
resizable: false
|
||||||
|
|
@ -126,6 +126,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
||||||
context.baseAttackBonus = this.action.actor?.system.attack?.roll.bonus;
|
context.baseAttackBonus = this.action.actor?.system.attack?.roll.bonus;
|
||||||
context.hasRoll = this.action.hasRoll;
|
context.hasRoll = this.action.hasRoll;
|
||||||
context.triggerOptions = CONFIG.DH.TRIGGER.triggers;
|
context.triggerOptions = CONFIG.DH.TRIGGER.triggers;
|
||||||
|
context.triggers = context.source.triggers.map(trigger => ({
|
||||||
|
...trigger,
|
||||||
|
hint: CONFIG.DH.TRIGGER.triggers[trigger.trigger].hint
|
||||||
|
}));
|
||||||
|
|
||||||
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;
|
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;
|
||||||
context.tierOptions = [
|
context.tierOptions = [
|
||||||
|
|
@ -245,7 +249,19 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
||||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||||
}
|
}
|
||||||
|
|
||||||
static removeTrigger(_event, button) {
|
static async removeTrigger(_event, button) {
|
||||||
|
const trigger = CONFIG.DH.TRIGGER.triggers[this.action.triggers[button.dataset.index].trigger];
|
||||||
|
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||||
|
window: {
|
||||||
|
title: game.i18n.localize('DAGGERHEART.ACTIONS.Config.deleteTriggerTitle')
|
||||||
|
},
|
||||||
|
content: game.i18n.format('DAGGERHEART.ACTIONS.Config.deleteTriggerContent', {
|
||||||
|
trigger: game.i18n.localize(trigger.label)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) return;
|
||||||
|
|
||||||
const data = this.action.toObject();
|
const data = this.action.toObject();
|
||||||
data.triggers = data.triggers.filter((_, index) => index !== Number.parseInt(button.dataset.index));
|
data.triggers = data.triggers.filter((_, index) => index !== Number.parseInt(button.dataset.index));
|
||||||
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
export const triggers = {
|
export const triggers = {
|
||||||
dualityRoll: {
|
dualityRoll: {
|
||||||
id: 'dualityRoll',
|
id: 'dualityRoll',
|
||||||
label: 'DAGGERHEART.CONFIG.Triggers.dualityRoll'
|
label: 'DAGGERHEART.CONFIG.Triggers.dualityRoll.label',
|
||||||
|
hint: 'DAGGERHEART.CONFIG.Triggers.dualityRoll.hint'
|
||||||
},
|
},
|
||||||
fearRoll: {
|
fearRoll: {
|
||||||
id: 'fearRoll',
|
id: 'fearRoll',
|
||||||
label: 'DAGGERHEART.CONFIG.Triggers.fearRoll'
|
label: 'DAGGERHEART.CONFIG.Triggers.fearRoll.label',
|
||||||
|
hint: 'DAGGERHEART.CONFIG.Triggers.fearRoll.hint'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -548,6 +548,7 @@
|
||||||
|
|
||||||
code-mirror {
|
code-mirror {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
height: 500px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
24
styles/less/sheets/actions/actions.less
Normal file
24
styles/less/sheets/actions/actions.less
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
.application.daggerheart.dh-style.action-config {
|
||||||
|
.trigger-data {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
select {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hint-section {
|
||||||
|
flex: 3;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
|
.hint {
|
||||||
|
flex: 1;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import './actions/actions.less';
|
||||||
|
|
||||||
@import './actors/actor-sheet-shared.less';
|
@import './actors/actor-sheet-shared.less';
|
||||||
|
|
||||||
@import './actors/adversary/actions.less';
|
@import './actors/adversary/actions.less';
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,20 @@
|
||||||
>
|
>
|
||||||
<button data-action="addTrigger">{{localize "Add Trigger"}} <i class="fa-solid fa-plus icon-button"></i></button>
|
<button data-action="addTrigger">{{localize "Add Trigger"}} <i class="fa-solid fa-plus icon-button"></i></button>
|
||||||
|
|
||||||
{{#each @root.source.triggers as |trigger index|}}
|
{{#each @root.triggers as |trigger index|}}
|
||||||
<fieldset class="one-column">
|
<fieldset class="one-column">
|
||||||
<legend><a data-action="removeTrigger" data-index="{{index}}"><i class="fa-solid fa-trash"></i></a></legend>
|
<legend><a data-action="removeTrigger" data-index="{{index}}"><i class="fa-solid fa-trash"></i></a></legend>
|
||||||
|
|
||||||
<select id="triggerOptionSelect">
|
<div class="trigger-data">
|
||||||
{{selectOptions @root.triggerOptions seleced=trigger.trigger localize=true}}
|
<select name="{{concat "triggers." index ".trigger"}}">
|
||||||
</select>
|
{{selectOptions @root.triggerOptions seleced=trigger.trigger localize=true}}
|
||||||
|
</select>
|
||||||
|
<div class="hint-section">
|
||||||
|
<strong>{{localize "Context: "}}</strong>
|
||||||
|
<span class="hint">{{localize trigger.hint}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{formInput @root.fields.triggers.element.fields.command value=trigger.command elementType="code-mirror" name=(concat "triggers." index ".command") aria=(object label=(localize "Test"))}}
|
{{formInput @root.fields.triggers.element.fields.command value=trigger.command elementType="code-mirror" name=(concat "triggers." index ".command") aria=(object label=(localize "Test"))}}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue