mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-25 11:59:54 +02:00
[Fix] 2094 - Critical Damage (#2096)
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
This commit is contained in:
parent
66ddb5c032
commit
7fd2a7f17e
12 changed files with 109 additions and 78 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import { triggerChatRollFx } from '../../helpers/utils.mjs';
|
||||
import { MemberData } from '../tagTeamData.mjs';
|
||||
import DHActorRoll from './actorRoll.mjs';
|
||||
|
||||
export class ChatDamageData extends foundry.abstract.DataModel {
|
||||
constructor(data = {}, options = {}) {
|
||||
|
|
@ -7,6 +9,17 @@ export class ChatDamageData extends foundry.abstract.DataModel {
|
|||
this._prepareRolls();
|
||||
}
|
||||
|
||||
get isCritical() {
|
||||
if (this.parent && this.parent instanceof MemberData) {
|
||||
return this.parent.roll.isCritical;
|
||||
}
|
||||
if (this.parent && this.parent instanceof DHActorRoll && this.parent.parent) {
|
||||
return Roll.fromJSON(this.parent.parent._source.rolls[0]).isCritical;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
|
|
@ -28,7 +41,15 @@ export class ChatDamageData extends foundry.abstract.DataModel {
|
|||
}
|
||||
|
||||
_prepareRolls() {
|
||||
this.main &&= Roll.fromData(this.main);
|
||||
this.main &&= Roll.fromData({
|
||||
...this.main,
|
||||
options: {
|
||||
...this.main.options,
|
||||
isCritical:
|
||||
this.main.options.isCritical === false ? false : (this.main.options.isCritical || this.isCritical)
|
||||
}
|
||||
});
|
||||
|
||||
for (const key of Object.keys(this.resources)) {
|
||||
this.resources[key] = Roll.fromData(this.resources[key]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue