mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/517 action cost on success (#546)
* Add checkboxes * Consume post roll logic
This commit is contained in:
parent
90a97c7105
commit
c46d676cc3
11 changed files with 93 additions and 18 deletions
|
|
@ -42,10 +42,28 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
damage: new fields.ObjectField(),
|
||||
costs: new fields.ArrayField(
|
||||
new fields.ObjectField()
|
||||
)
|
||||
),
|
||||
successConsumed: new fields.BooleanField({ initial: false })
|
||||
};
|
||||
}
|
||||
|
||||
get actionActor() {
|
||||
if(!this.source.actor) return null;
|
||||
return fromUuidSync(this.source.actor);
|
||||
}
|
||||
|
||||
get actionItem() {
|
||||
const actionActor = this.actionActor;
|
||||
if(!actionActor || !this.source.item) return null;
|
||||
return actionActor.items.get(this.source.item);
|
||||
}
|
||||
|
||||
get action() {
|
||||
const actionItem = this.actionItem;
|
||||
if(!actionItem || !this.source.action) return null;
|
||||
return actionItem.system.actionsList?.find(a => a.id === this.source.action);
|
||||
}
|
||||
|
||||
get messageTemplate() {
|
||||
return 'systems/daggerheart/templates/ui/chat/roll.hbs';
|
||||
}
|
||||
|
|
@ -74,14 +92,14 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
|
||||
async updateTargets() {
|
||||
this.currentTargets = this.getTargetList();
|
||||
if(!this.targetSelection && this.hasSave) {
|
||||
if(!this.targetSelection) {
|
||||
this.currentTargets.forEach(ct => {
|
||||
if(this.targets.find(t => t.actorId === ct.actorId)) return;
|
||||
const indexTarget = this.oldTargets.findIndex(ot => ot.actorId === ct.actorId);
|
||||
if(indexTarget === -1)
|
||||
this.oldTargets.push(ct);
|
||||
});
|
||||
this.setPendingSaves();
|
||||
if(this.hasSave) this.setPendingSaves();
|
||||
if(this.currentTargets.length) {
|
||||
if(!this.parent._id) return;
|
||||
const updates = await this.parent.update(
|
||||
|
|
@ -91,7 +109,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
}
|
||||
}
|
||||
);
|
||||
if(!updates)
|
||||
if(!updates && ui.chat.collection.get(this.parent.id))
|
||||
ui.chat.updateMessage(this.parent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue