mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] Countdown Rols And Randomzie (#1329)
* . * . * . * Raised system version
This commit is contained in:
parent
9e0bc3cff1
commit
d137e33c3d
37 changed files with 281 additions and 87 deletions
|
|
@ -40,18 +40,40 @@ export default class CountdownField extends fields.ArrayField {
|
|||
}
|
||||
|
||||
const data = { countdowns: {} };
|
||||
const countdownMessages = [];
|
||||
for (let countdown of config.countdowns) {
|
||||
const { total: max } = await new Roll(countdown.progress.max).evaluate();
|
||||
let startFormula = countdown.progress.startFormula ? countdown.progress.startFormula : null;
|
||||
let countdownStart = startFormula ?? '1';
|
||||
if (startFormula) {
|
||||
const roll = await new Roll(startFormula).roll();
|
||||
if (roll.dice.length > 0) {
|
||||
countdownStart = roll.total;
|
||||
const message = await roll.toMessage();
|
||||
countdownMessages.push(message);
|
||||
} else {
|
||||
startFormula = null;
|
||||
}
|
||||
}
|
||||
|
||||
data.countdowns[foundry.utils.randomID()] = {
|
||||
...countdown,
|
||||
progress: {
|
||||
...countdown.progress,
|
||||
current: max,
|
||||
max: max
|
||||
current: countdownStart,
|
||||
start: countdownStart,
|
||||
startFormula
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (game.modules.get('dice-so-nice')?.active) {
|
||||
await Promise.all(
|
||||
countdownMessages.map(message => {
|
||||
return game.dice3d.waitFor3DAnimationByMessageID(message.id);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
await emitAsGM(
|
||||
GMUpdateEvent.UpdateCountdowns,
|
||||
async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue