mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed Check Rolls, Attack Rolls and Damage Rolls for PCs
This commit is contained in:
parent
707e47bc1b
commit
5a501d6769
16 changed files with 204 additions and 95 deletions
|
|
@ -8,6 +8,8 @@ const diceField = () =>
|
|||
export default class DhpDualityRoll extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
return {
|
||||
title: new fields.StringField(),
|
||||
origin: new fields.StringField({ required: true }),
|
||||
roll: new fields.StringField({}),
|
||||
modifiers: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
|
|
@ -20,7 +22,6 @@ export default class DhpDualityRoll extends foundry.abstract.TypeDataModel {
|
|||
fear: diceField(),
|
||||
advantage: diceField(),
|
||||
disadvantage: diceField(),
|
||||
advantageSelected: new fields.NumberField({ initial: 0 }),
|
||||
targets: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
id: new fields.StringField({}),
|
||||
|
|
@ -57,8 +58,16 @@ export default class DhpDualityRoll extends foundry.abstract.TypeDataModel {
|
|||
|
||||
get total() {
|
||||
const modifiers = this.modifiers.reduce((acc, x) => acc + x.value, 0);
|
||||
const advantage = (this.advantage.value ?? this.disadvantage.value) ? -this.disadvantage.value : 0;
|
||||
return this.hope.value + this.fear.value + advantage + modifiers;
|
||||
const advantage = this.advantage.value
|
||||
? this.advantage.value
|
||||
: this.disadvantage.value
|
||||
? -this.disadvantage.value
|
||||
: 0;
|
||||
return this.highestRoll + advantage + modifiers;
|
||||
}
|
||||
|
||||
get highestRoll() {
|
||||
return Math.max(this.hope.value, this.fear.value);
|
||||
}
|
||||
|
||||
get totalLabel() {
|
||||
|
|
@ -75,6 +84,9 @@ export default class DhpDualityRoll extends foundry.abstract.TypeDataModel {
|
|||
prepareDerivedData() {
|
||||
const total = this.total;
|
||||
|
||||
this.hope.discarded = this.hope.value < this.fear.value;
|
||||
this.fear.discarded = this.fear.value < this.hope.value;
|
||||
|
||||
this.targets.forEach(target => {
|
||||
target.hit = target.difficulty ? total >= target.difficulty : total >= target.evasion;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue