mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Adding Prettier
* Added prettier with automatic useage on pre-commit to avoid style breakage * Ran Prettier on the project
This commit is contained in:
parent
820c2df1f4
commit
b24cdcc9ed
136 changed files with 13929 additions and 12206 deletions
|
|
@ -1,65 +1,83 @@
|
|||
const fields = foundry.data.fields;
|
||||
const diceField = () => new fields.SchemaField({
|
||||
dice: new fields.StringField({}),
|
||||
value: new fields.NumberField({ integer: true}),
|
||||
});
|
||||
const diceField = () =>
|
||||
new fields.SchemaField({
|
||||
dice: new fields.StringField({}),
|
||||
value: new fields.NumberField({ integer: true })
|
||||
});
|
||||
|
||||
export default class DhpDualityRoll extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
|
||||
return {
|
||||
roll: new fields.StringField({}),
|
||||
modifiers: new fields.ArrayField(new fields.SchemaField({
|
||||
value: new fields.NumberField({ integer: true }),
|
||||
label: new fields.StringField({}),
|
||||
title: new fields.StringField({}),
|
||||
})),
|
||||
hope: diceField(),
|
||||
fear: diceField(),
|
||||
advantage: diceField(),
|
||||
disadvantage: diceField(),
|
||||
advantageSelected: new fields.NumberField({ initial: 0 }),
|
||||
targets: new fields.ArrayField(new fields.SchemaField({
|
||||
id: new fields.StringField({}),
|
||||
name: new fields.StringField({}),
|
||||
img: new fields.StringField({}),
|
||||
difficulty: new fields.NumberField({ integer: true, nullable: true }),
|
||||
evasion: new fields.NumberField({ integer: true }),
|
||||
hit: new fields.BooleanField({ initial: false }),
|
||||
})),
|
||||
damage: new fields.SchemaField({
|
||||
value: new fields.StringField({}),
|
||||
type: new fields.StringField({ choices: Object.keys(SYSTEM.GENERAL.damageTypes), integer: false }),
|
||||
bonusDamage: new fields.ArrayField(new fields.SchemaField({
|
||||
value: new fields.StringField({}),
|
||||
type: new fields.StringField({ choices: Object.keys(SYSTEM.GENERAL.damageTypes), integer: false }),
|
||||
initiallySelected: new fields.BooleanField(),
|
||||
appliesOn: new fields.StringField({ choices: Object.keys(SYSTEM.EFFECTS.applyLocations) }, { nullable: true, initial: null }),
|
||||
description: new fields.StringField({}),
|
||||
hopeIncrease: new fields.StringField({ nullable: true })
|
||||
}), { nullable: true, initial: null })
|
||||
})
|
||||
}
|
||||
return {
|
||||
roll: new fields.StringField({}),
|
||||
modifiers: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
value: new fields.NumberField({ integer: true }),
|
||||
label: new fields.StringField({}),
|
||||
title: new fields.StringField({})
|
||||
})
|
||||
),
|
||||
hope: diceField(),
|
||||
fear: diceField(),
|
||||
advantage: diceField(),
|
||||
disadvantage: diceField(),
|
||||
advantageSelected: new fields.NumberField({ initial: 0 }),
|
||||
targets: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
id: new fields.StringField({}),
|
||||
name: new fields.StringField({}),
|
||||
img: new fields.StringField({}),
|
||||
difficulty: new fields.NumberField({ integer: true, nullable: true }),
|
||||
evasion: new fields.NumberField({ integer: true }),
|
||||
hit: new fields.BooleanField({ initial: false })
|
||||
})
|
||||
),
|
||||
damage: new fields.SchemaField({
|
||||
value: new fields.StringField({}),
|
||||
type: new fields.StringField({ choices: Object.keys(SYSTEM.GENERAL.damageTypes), integer: false }),
|
||||
bonusDamage: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
value: new fields.StringField({}),
|
||||
type: new fields.StringField({
|
||||
choices: Object.keys(SYSTEM.GENERAL.damageTypes),
|
||||
integer: false
|
||||
}),
|
||||
initiallySelected: new fields.BooleanField(),
|
||||
appliesOn: new fields.StringField(
|
||||
{ choices: Object.keys(SYSTEM.EFFECTS.applyLocations) },
|
||||
{ nullable: true, initial: null }
|
||||
),
|
||||
description: new fields.StringField({}),
|
||||
hopeIncrease: new fields.StringField({ nullable: true })
|
||||
}),
|
||||
{ nullable: true, initial: null }
|
||||
)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
get totalLabel() {
|
||||
const label = this.hope.value > this.fear.value ? "DAGGERHEART.General.Hope" : this.fear.value > this.hope.value ? "DAGGERHEART.General.Fear" : "DAGGERHEART.General.CriticalSuccess";
|
||||
get totalLabel() {
|
||||
const label =
|
||||
this.hope.value > this.fear.value
|
||||
? 'DAGGERHEART.General.Hope'
|
||||
: this.fear.value > this.hope.value
|
||||
? 'DAGGERHEART.General.Fear'
|
||||
: 'DAGGERHEART.General.CriticalSuccess';
|
||||
|
||||
return game.i18n.localize(label);
|
||||
return game.i18n.localize(label);
|
||||
}
|
||||
|
||||
prepareDerivedData(){
|
||||
const total = this.total;
|
||||
prepareDerivedData() {
|
||||
const total = this.total;
|
||||
|
||||
this.targets.forEach(target => {
|
||||
target.hit = target.difficulty ? total >= target.difficulty : total >= target.evasion;
|
||||
});
|
||||
this.targets.forEach(target => {
|
||||
target.hit = target.difficulty ? total >= target.difficulty : total >= target.evasion;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +128,7 @@ export default class DhpDualityRoll extends foundry.abstract.TypeDataModel {
|
|||
|
||||
// get total() {
|
||||
// const modifiers = this.modifiers.reduce((acc, x) => acc+x.value, 0);
|
||||
// const regular = {
|
||||
// const regular = {
|
||||
// normal: this.disadvantage.value ? Math.min(this.disadvantage.value, this.hope.value) + this.fear.value + modifiers : this.hope.value + this.fear.value + modifiers,
|
||||
// alternate: this.advantage.value ? this.advantage.value + this.fear.value + modifiers : null,
|
||||
// };
|
||||
|
|
@ -126,7 +144,7 @@ export default class DhpDualityRoll extends foundry.abstract.TypeDataModel {
|
|||
// get totalLabel() {
|
||||
// if(this.advantage.value && this.advantageSelected === 0) return game.i18n.localize("DAGGERHEART.Chat.DualityRoll.AdvantageChooseTitle");
|
||||
|
||||
// const hope = !this.advantage.value || this.advantageSelected === 1 ? this.hope.value : this.advantage.value;
|
||||
// const hope = !this.advantage.value || this.advantageSelected === 1 ? this.hope.value : this.advantage.value;
|
||||
// const label = hope > this.fear.value ? "DAGGERHEART.General.Hope" : this.fear.value > hope ? "DAGGERHEART.General.Fear" : "DAGGERHEART.General.CriticalSuccess";
|
||||
|
||||
// return game.i18n.localize(label);
|
||||
|
|
@ -147,4 +165,4 @@ export default class DhpDualityRoll extends foundry.abstract.TypeDataModel {
|
|||
// target.hit = target.difficulty ? total.normal >= target.difficulty : total.normal >= target.evasion;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue