Feature/247 auto add yope fear clear stress (#285)

* cleanup

* test

* Step 1

* #2

* Fix Effect Action & Add Hope tumation settings to hook

* remove circular dependency

* Snuck in some localization fixes I noticed

* Remove success condition for duality roll gain

* Changed config.roll.type logic

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
Dapoulp 2025-07-07 01:38:39 +02:00 committed by GitHub
parent ee4a5d17a6
commit 52be430eff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 187 additions and 160 deletions

View file

@ -10,14 +10,10 @@ const fields = foundry.data.fields;
/*
ToDo
- Add setting and/or checkbox for cost and damage like
- Target Check / Target Picker
- Range Check
- Area of effect and measurement placement
- Summon Action create method
Other
- Auto use action <= Into Roll
*/
export default class DHBaseAction extends foundry.abstract.DataModel {
@ -200,28 +196,23 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
const isFastForward = event.shiftKey || (!this.hasRoll && !this.hasSave);
// Prepare base Config
const initConfig = this.initActionConfig(event);
// let config = this.initActionConfig(event);
// Prepare Targets
const targetConfig = this.prepareTarget();
if (isFastForward && !targetConfig) return ui.notifications.warn('Too many targets selected for that actions.');
// config = this.prepareTarget(config);
// Prepare Range
const rangeConfig = this.prepareRange();
// config = this.prepareRange(config);
// Prepare Costs
const costsConfig = this.prepareCost();
if (isFastForward && !this.hasCost(costsConfig))
return ui.notifications.warn("You don't have the resources to use that action.");
// config = this.prepareUseCost(config)
// Prepare Uses
const usesConfig = this.prepareUse();
if (isFastForward && !this.hasUses(usesConfig))
return ui.notifications.warn("That action doesn't have remaining uses.");
// config = this.prepareUseCost(config)
// Prepare Roll Data
const actorData = this.getRollData();
@ -238,8 +229,9 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
// Display configuration window if necessary
if (config.dialog?.configure && this.requireConfigurationDialog(config)) {
config = await D20RollDialog.configure(config);
// if (config.dialog?.configure && this.requireConfigurationDialog(config)) {
if (this.requireConfigurationDialog(config)) {
config = await D20RollDialog.configure(null, config);
if (!config) return;
}
@ -250,37 +242,6 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
if (!config) return;
}
if (this.hasSave) {
/* config.targets.forEach((t) => {
if(t.hit) {
const target = game.canvas.tokens.get(t.id),
actor = target?.actor;
if(!actor) return;
actor.saveRoll({
event,
title: 'Roll Save',
roll: {
trait: this.save.trait,
difficulty: this.save.difficulty
},
dialog: {
configure: false
},
data: actor.getRollData()
}).then(async (result) => {
t.saved = result;
setTimeout(async () => {
const message = ui.chat.collection.get(config.message.id),
msgTargets = message.system.targets,
msgTarget = msgTargets.find(mt => mt.id === t.id);
msgTarget.saved = result;
await message.update({'system.targets': msgTargets});
},100)
})
}
}) */
}
if (this.doFollowUp()) {
if (this.rollDamage) await this.rollDamage(event, config);
if (this.rollHealing) await this.rollHealing(event, config);
@ -329,12 +290,12 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
}
prepareTarget() {
if(!this.target?.type) return [];
let targets;
if (this.target?.type === CONFIG.DH.ACTIONS.targetTypes.self.id)
targets = this.constructor.formatTarget(this.actor.token ?? this.actor.prototypeToken);
targets = Array.from(game.user.targets);
// foundry.CONST.TOKEN_DISPOSITIONS.FRIENDLY
if (this.target?.type && this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
if (this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
targets = targets.filter(t => this.isTargetFriendly(t));
if (this.target.amount && targets.length > this.target.amount) targets = [];
}
@ -540,6 +501,7 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
});
});
}
/* SAVE */
async updateChatMessage(message, targetId, changes, chain = true) {
setTimeout(async () => {
@ -558,7 +520,6 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
});
}
}
/* SAVE */
async toChat(origin) {
const cls = getDocumentClass('ChatMessage');

View file

@ -3,38 +3,16 @@ import DHBaseAction from './baseAction.mjs';
export default class DHEffectAction extends DHBaseAction {
static extraSchemas = ['effects', 'target'];
async use(event, ...args) {
const config = await super.use(event, args);
if (['error', 'warning'].includes(config.type)) return;
return await this.chatApplyEffects(event, config);
}
async trigger(event, data) {
if(this.effects.length) {
const cls = getDocumentClass('ChatMessage'),
msg = {
type: 'applyEffect',
user: game.user.id,
system: data
};
async chatApplyEffects(event, data) {
const cls = getDocumentClass('ChatMessage'),
systemData = {
title: game.i18n.format('DAGGERHEART.UI.Chat.applyEffect.title', { name: this.name }),
origin: this.actor._id,
description: '',
targets: data.targets.map(x => ({ id: x.id, name: x.name, img: x.img, hit: true })),
action: {
itemId: this.item._id,
actionId: this._id
}
},
msg = new cls({
type: 'applyEffect',
user: game.user.id,
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/apply-effects.hbs',
systemData
)
});
cls.create(msg.toObject());
}
get chatTemplate() {
return 'systems/daggerheart/templates/ui/chat/apply-effects.hbs';
return await cls.create(msg);
} else this.toChat(this.id);
}
}