mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 21:21:08 +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 {
|
export default class DhCountdowns extends foundry.abstract.DataModel {
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
@ -165,11 +167,11 @@ export class DhCountdown extends foundry.abstract.DataModel {
|
||||||
initial: 1,
|
initial: 1,
|
||||||
label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.current.label'
|
label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.current.label'
|
||||||
}),
|
}),
|
||||||
max: new fields.NumberField({
|
max: new FormulaField({
|
||||||
required: true,
|
required: true,
|
||||||
integer: true,
|
|
||||||
initial: 1,
|
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({
|
looping: new fields.StringField({
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,15 @@ export default class CountdownField extends fields.ArrayField {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = config.countdowns.reduce(
|
const data = await config.countdowns.reduce(
|
||||||
(acc, curr) => {
|
async (acc, curr) => {
|
||||||
|
const { total: max } = await new Roll(curr.progress.max).evaluate();
|
||||||
acc.countdowns[foundry.utils.randomID()] = {
|
acc.countdowns[foundry.utils.randomID()] = {
|
||||||
...curr,
|
...curr,
|
||||||
progress: {
|
progress: {
|
||||||
...curr.progress,
|
...curr.progress,
|
||||||
current: curr.progress.max
|
current: max,
|
||||||
|
max: max
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return acc;
|
return acc;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue