Skip to content

Commit

Permalink
fix: Encounters saved from builder now roll initiatives correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed May 9, 2023
1 parent a1079c4 commit 50e9281
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions src/builder/view/encounter/Encounter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,30 @@
new Notice("An encounter by that name already exists.");
return;
}
const creatures = [
...[...$players].map((p) => CreatureCreator.from(p)),
...[...$encounter.entries()]
.map((c) =>
[...Array(c[1]).keys()].map(() =>
CreatureCreator.from(c[0])
try {
const creatures = [
...[...$players].map((p) => CreatureCreator.from(p)),
...[...$encounter.entries()]
.map((c) =>
[...Array(c[1]).keys()].map(() =>
CreatureCreator.from(c[0])
)
)
)
.flat()
];
plugin.data.encounters[encName] = {
creatures: [...creatures.map((c) => c.toJSON())],
state: false,
name: encName,
round: 1,
logFile: null
};
.flat()
];
plugin.data.encounters[encName] = {
creatures: [...creatures.map((c) => c.toJSON())],
state: false,
name: encName,
round: 1,
roll: true,
rollHP: plugin.data.rollHP,
logFile: null
};
new Notice(`Encounter "${encName}" saved.`);
} catch (e) {
new Notice("There was an issue saving the encounter.");
}
modal.close();
})
);
Expand Down

0 comments on commit 50e9281

Please sign in to comment.