mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 16:09:03 +01:00
Merged with main
This commit is contained in:
commit
130b2bf100
65 changed files with 1085 additions and 860 deletions
|
|
@ -115,7 +115,6 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
if (!this.actor) throw new Error("An Action can't be used outside of an Actor context.");
|
||||
|
||||
if (this.chatDisplay) await this.toChat();
|
||||
|
||||
let { byPassRoll } = options,
|
||||
config = this.prepareConfig(event, byPassRoll);
|
||||
for (let i = 0; i < this.constructor.extraSchemas.length; i++) {
|
||||
|
|
@ -145,9 +144,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
if (this.rollDamage && this.damage.parts.length) await this.rollDamage(event, config);
|
||||
else if (this.trigger) await this.trigger(event, config);
|
||||
else if (this.hasSave || this.hasEffect) {
|
||||
const roll = new Roll('');
|
||||
const roll = new CONFIG.Dice.daggerheart.DHRoll('');
|
||||
roll._evaluated = true;
|
||||
if (this.hasTarget) config.targetSelection = config.targets.length > 0;
|
||||
await CONFIG.Dice.daggerheart.DHRoll.toMessage(roll, config);
|
||||
}
|
||||
}
|
||||
|
|
@ -180,7 +178,6 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
hasHealing: this.damage?.parts?.length && this.type === 'healing',
|
||||
hasEffect: !!this.effects?.length,
|
||||
hasSave: this.hasSave,
|
||||
hasTarget: true,
|
||||
selectedRollMode: game.settings.get('core', 'rollMode'),
|
||||
isFastForward: event.shiftKey,
|
||||
data: this.getRollData(),
|
||||
|
|
@ -223,24 +220,26 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
}
|
||||
}
|
||||
|
||||
const resources = config.costs
|
||||
const resources = game.system.api.fields.ActionFields.CostField.getRealCosts(config.costs)
|
||||
.filter(
|
||||
c =>
|
||||
c.enabled !== false &&
|
||||
((!successCost && (!c.consumeOnSuccess || config.roll?.success)) ||
|
||||
(successCost && c.consumeOnSuccess))
|
||||
(!successCost && (!c.consumeOnSuccess || config.roll?.success)) ||
|
||||
(successCost && c.consumeOnSuccess)
|
||||
)
|
||||
.map(c => {
|
||||
.reduce((a, c) => {
|
||||
const resource = usefulResources[c.key];
|
||||
return {
|
||||
key: c.key,
|
||||
value: (c.total ?? c.value) * (resource.isReversed ? 1 : -1),
|
||||
target: resource.target,
|
||||
keyIsID: resource.keyIsID
|
||||
};
|
||||
});
|
||||
if (resource) {
|
||||
a.push({
|
||||
key: c.key,
|
||||
value: (c.total ?? c.value) * (resource.isReversed ? 1 : -1),
|
||||
target: resource.target,
|
||||
keyIsID: resource.keyIsID
|
||||
});
|
||||
return a;
|
||||
}
|
||||
}, []);
|
||||
|
||||
await this.actor.modifyResource(resources);
|
||||
await (this.actor.system.partner ?? this.actor).modifyResource(resources);
|
||||
if (
|
||||
config.uses?.enabled &&
|
||||
((!successCost && (!config.uses?.consumeOnSuccess || config.roll?.success)) ||
|
||||
|
|
@ -248,8 +247,11 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
)
|
||||
this.update({ 'uses.value': this.uses.value + 1 });
|
||||
|
||||
if (config.roll?.success || successCost)
|
||||
(config.message ?? config.parent).update({ 'system.successConsumed': true });
|
||||
if (config.roll?.success || successCost) {
|
||||
setTimeout(() => {
|
||||
(config.message ?? config.parent).update({ 'system.successConsumed': true });
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
/* */
|
||||
|
||||
|
|
@ -368,15 +370,15 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
|
||||
async updateChatMessage(message, targetId, changes, chain = true) {
|
||||
setTimeout(async () => {
|
||||
const chatMessage = ui.chat.collection.get(message._id),
|
||||
msgTarget =
|
||||
chatMessage.system.targets.find(mt => mt.id === targetId) ??
|
||||
chatMessage.system.oldTargets.find(mt => mt.id === targetId);
|
||||
msgTarget.saved = changes;
|
||||
const chatMessage = ui.chat.collection.get(message._id);
|
||||
|
||||
await chatMessage.update({
|
||||
system: {
|
||||
targets: chatMessage.system.targets,
|
||||
oldTargets: chatMessage.system.oldTargets
|
||||
flags: {
|
||||
[game.system.id]: {
|
||||
reactionRolls: {
|
||||
[targetId]: changes
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue