Skip to content

Commit

Permalink
fix: handling of status amounts and logging of receiving multiple sta…
Browse files Browse the repository at this point in the history
…tuses (#141)
  • Loading branch information
dfaggioli authored Apr 24, 2023
1 parent aecdff3 commit 2821442
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ export type Condition = {
resetOnRound?: boolean;
hasAmount?: boolean;
startingAmount?: number;
amount?:number;
} & (
| {
hasAmount: true;
startingAmount: number;
amount: number;
}
| {}
);
Expand Down
2 changes: 1 addition & 1 deletion src/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default class Logger {
if (message.status.length > 1) {
status = [
message.status
.slice(0, Math.min(message.status.length - 1, 1))
.slice(0, Math.max(message.status.length - 1, 1))
.join(", ")
];
status.push(message.status[message.status.length - 1]);
Expand Down
2 changes: 1 addition & 1 deletion src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ class StatusModal extends Modal {
(t
.setValue(`${this.status.startingAmount}`)
.onChange((v) => {
this.status.startingAmount = Number(v);
this.status.amount = this.status.startingAmount = Number(v);
}).inputEl.type = "number")
);
}
Expand Down
9 changes: 4 additions & 5 deletions src/tracker/ui/creatures/Status.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import type { Condition } from "index";
export let status: Condition;
$: amount = status.startingAmount;
const deleteIcon = (node: HTMLElement) => {
new ExtraButtonComponent(node).setIcon("cross-in-box");
};
Expand All @@ -31,12 +30,12 @@
class="icon"
use:minus
on:click={() => {
amount--;
if (amount <= 0) dispatch("remove");
status.amount--;
if (status.amount <= 0) dispatch("remove");
}}
/>
<span>{amount}</span>
<div class="icon" use:plus on:click={() => amount++} />
<span>{status.amount}</span>
<div class="icon" use:plus on:click={() => status.amount++} />
</div>
{/if}
<div use:deleteIcon on:click={() => dispatch("remove")} />
Expand Down

0 comments on commit 2821442

Please sign in to comment.