Skip to content

Commit

Permalink
fix: Add to Encounter will add players that aren't already in the enc…
Browse files Browse the repository at this point in the history
…ounter (close #160)
  • Loading branch information
valentine195 committed May 2, 2023
1 parent b46545f commit 37a6520
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/encounter/ui/Encounter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@
);
})
.flat();
for (const player of players) {
if (!$tracker.find((creature) => creature.name === player)) {
creatures.push(plugin.getPlayerByName(player));
}
}
tracker.add(plugin, rollHP, ...creatures);
};
Expand Down
4 changes: 4 additions & 0 deletions src/tracker/stores/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ function createTracker() {
updateTarget,
updateCreatures,

players: derived(ordered, (creatures) =>
creatures.filter((c) => c.player)
),

setUpdate: (creature: Creature, evt: MouseEvent) =>
updating.update((creatures) => {
if (creatures.has(creature)) {
Expand Down

0 comments on commit 37a6520

Please sign in to comment.