mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Countdown max as formula to enable random countdowns
This commit is contained in:
parent
cd7c61af42
commit
8b02a4c830
2 changed files with 10 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import FormulaField from './fields/formulaField.mjs';
|
||||
|
||||
export default class DhCountdowns extends foundry.abstract.DataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
|
|
@ -165,11 +167,11 @@ export class DhCountdown extends foundry.abstract.DataModel {
|
|||
initial: 1,
|
||||
label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.current.label'
|
||||
}),
|
||||
max: new fields.NumberField({
|
||||
max: new FormulaField({
|
||||
required: true,
|
||||
integer: true,
|
||||
initial: 1,
|
||||
label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.max.label'
|
||||
label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.max.label',
|
||||
deterministic: false
|
||||
}),
|
||||
looping: new fields.StringField({
|
||||
required: true,
|
||||
|
|
|
|||
|
|
@ -39,13 +39,15 @@ export default class CountdownField extends fields.ArrayField {
|
|||
return;
|
||||
}
|
||||
|
||||
const data = config.countdowns.reduce(
|
||||
(acc, curr) => {
|
||||
const data = await config.countdowns.reduce(
|
||||
async (acc, curr) => {
|
||||
const { total: max } = await new Roll(curr.progress.max).evaluate();
|
||||
acc.countdowns[foundry.utils.randomID()] = {
|
||||
...curr,
|
||||
progress: {
|
||||
...curr.progress,
|
||||
current: curr.progress.max
|
||||
current: max,
|
||||
max: max
|
||||
}
|
||||
};
|
||||
return acc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue