mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
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:
parent
ee4a5d17a6
commit
52be430eff
21 changed files with 187 additions and 160 deletions
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import DHBaseAction from "../action/baseAction.mjs";
|
||||
|
||||
export default class DHApplyEffect extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
return {
|
||||
title: new fields.StringField(),
|
||||
origin: new fields.StringField({}),
|
||||
description: new fields.StringField({}),
|
||||
targets: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
id: new fields.StringField({ required: true }),
|
||||
|
|
@ -14,10 +14,24 @@ export default class DHApplyEffect extends foundry.abstract.TypeDataModel {
|
|||
hit: new fields.BooleanField({ initial: false })
|
||||
})
|
||||
),
|
||||
action: new fields.SchemaField({
|
||||
itemId: new fields.StringField(),
|
||||
actionId: new fields.StringField()
|
||||
targetSelection: new fields.BooleanField({ initial: true }),
|
||||
source: new fields.SchemaField({
|
||||
actor: new fields.StringField(),
|
||||
item: new fields.StringField(),
|
||||
action: new fields.StringField()
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
this.hasHitTarget = this.targets.filter(t => t.hit === true).length > 0;
|
||||
this.currentTargets =
|
||||
this.targetSelection !== true
|
||||
? Array.from(game.user.targets).map(t => DHBaseAction.formatTarget(t))
|
||||
: this.targets;
|
||||
}
|
||||
|
||||
get messageTemplate() {
|
||||
return 'systems/daggerheart/templates/ui/chat/apply-effects.hbs';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
import { actionsTypes } from '../action/_module.mjs';
|
||||
|
||||
// Temporary Solution
|
||||
export default class ActionField extends foundry.data.fields.ObjectField {
|
||||
getModel(value) {
|
||||
return actionsTypes[value.type] ?? actionsTypes.attack;
|
||||
return game.system.api.models.actions.actionsTypes[value.type] ?? game.system.api.models.actions.actionsTypes.attack;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -4,9 +4,21 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
|||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
hope: new fields.BooleanField({ required: true, initial: false }),
|
||||
actionPoints: new fields.BooleanField({ required: true, initial: false }),
|
||||
countdowns: new fields.BooleanField({ requireD: true, initial: false })
|
||||
hope: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hope.label'
|
||||
}), // Label need to be updated into something like "Duality Roll Auto Gain" + a hint
|
||||
actionPoints: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.actionPoints.label'
|
||||
}),
|
||||
countdowns: new fields.BooleanField({
|
||||
requireD: true,
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.countdowns.label'
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue