mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 20:21:06 +01:00
Sync countdown current with max when equal (#1221)
This commit is contained in:
parent
5fc04909de
commit
ffac498609
3 changed files with 17 additions and 2 deletions
|
|
@ -110,6 +110,18 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
|
||||
static async updateData(_event, _, formData) {
|
||||
const { hideNewCountdowns, ...settingsData } = foundry.utils.expandObject(formData.object);
|
||||
|
||||
// Sync current and max if max is changing and they were equal before
|
||||
for (const [id, countdown] of Object.entries(settingsData.countdowns ?? {})) {
|
||||
const existing = this.data.countdowns[id];
|
||||
const wasEqual = existing && existing.progress.current === existing.progress.max;
|
||||
if (wasEqual && countdown.progress.max !== existing.progress.max) {
|
||||
countdown.progress.current = countdown.progress.max;
|
||||
} else {
|
||||
countdown.progress.current = Math.min(countdown.progress.current, countdown.progress.max);
|
||||
}
|
||||
}
|
||||
|
||||
this.hideNewCountdowns = hideNewCountdowns;
|
||||
this.updateSetting(settingsData);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue