Skip to content

Commit

Permalink
fix: Creature hidden state no longer reset with HP / Status
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed May 9, 2023
1 parent 40da2d3 commit e88b468
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions src/tracker/stores/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,16 @@ function createTracker() {
if ("hidden" in change) {
creature.hidden = change.hidden!;
_logger.log(
`${creature.getName()} ${creature.hidden ? "hidden" : "revealed"
`${creature.getName()} ${
creature.hidden ? "hidden" : "revealed"
}`
);
}
if ("enabled" in change) {
creature.enabled = change.enabled!;
_logger.log(
`${creature.getName()} ${creature.enabled ? "enabled" : "disabled"
`${creature.getName()} ${
creature.enabled ? "enabled" : "disabled"
}`
);
}
Expand Down Expand Up @@ -397,9 +399,7 @@ function createTracker() {
Number(ac.charAt(0) == "\\")
);
}
message.ac = ac.slice(
Number(ac.charAt(0) == "\\")
);
message.ac = ac.slice(Number(ac.charAt(0) == "\\"));
}
messages.push(message);
updates.push({ creature, change });
Expand Down Expand Up @@ -539,7 +539,7 @@ function createTracker() {
creature.hp =
creature.max =
creature.current_max =
roller.rollSync();
roller.rollSync();
}
}
creatures.push(...items);
Expand Down Expand Up @@ -608,7 +608,7 @@ function createTracker() {
creature.hp =
creature.max =
creature.current_max =
roller.rollSync();
roller.rollSync();
}
}
}
Expand All @@ -630,9 +630,7 @@ function createTracker() {
creature.current_ac = creature.ac;
creature.hp = creature.current_max = creature.max;
creature.enabled = true;
creature.hidden = false;
creature.status.clear();
creature.active = false;
}
_logger?.log("Encounter HP & Statuses reset");
return creatures;
Expand All @@ -646,15 +644,17 @@ function createTracker() {
if (message.hp) {
if (message.temp) {
perCreature.push(
`${message.name
`${
message.name
} gained ${message.hp.toString()} temporary HP`
);
} else if (message.max) {
if (message.hp < 0) {
perCreature.push(
`${message.name} took ${(
-1 * message.hp
).toString()} max HP damage${message.unc ? " and died" : ""
).toString()} max HP damage${
message.unc ? " and died" : ""
}`
);
} else {
Expand All @@ -668,14 +668,16 @@ function createTracker() {
perCreature.push(
`${message.name} took ${(
-1 * message.hp
).toString()} damage${message.unc
? " and was knocked unconscious"
: ""
).toString()} damage${
message.unc
? " and was knocked unconscious"
: ""
}`
);
} else if (message.hp > 0) {
perCreature.push(
`${message.name
`${
message.name
} was healed for ${message.hp.toString()} HP`
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tracker/ui/Controls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
});
menu.addItem((item) => {
item.setIcon(REDO)
.setTitle("Reset HP & Status")
.setTitle("Reset HP / Status")
.onClick(() => tracker.reset());
});
menu.addItem((item) => {
Expand Down

0 comments on commit e88b468

Please sign in to comment.