From 28214427a6af672a63ae562351dd4761fbb2d53a Mon Sep 17 00:00:00 2001 From: Dario Faggioli Date: Mon, 24 Apr 2023 04:46:49 +0200 Subject: [PATCH] fix: handling of status amounts and logging of receiving multiple statuses (#141) --- index.ts | 2 ++ src/logger/logger.ts | 2 +- src/settings/settings.ts | 2 +- src/tracker/ui/creatures/Status.svelte | 9 ++++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index b59d3365..64d915cb 100644 --- a/index.ts +++ b/index.ts @@ -63,10 +63,12 @@ export type Condition = { resetOnRound?: boolean; hasAmount?: boolean; startingAmount?: number; + amount?:number; } & ( | { hasAmount: true; startingAmount: number; + amount: number; } | {} ); diff --git a/src/logger/logger.ts b/src/logger/logger.ts index 507066b9..d3bbb677 100644 --- a/src/logger/logger.ts +++ b/src/logger/logger.ts @@ -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]); diff --git a/src/settings/settings.ts b/src/settings/settings.ts index ee817ae7..7f2b72e5 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -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") ); } diff --git a/src/tracker/ui/creatures/Status.svelte b/src/tracker/ui/creatures/Status.svelte index 471e64f8..b25aabeb 100644 --- a/src/tracker/ui/creatures/Status.svelte +++ b/src/tracker/ui/creatures/Status.svelte @@ -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"); }; @@ -31,12 +30,12 @@ class="icon" use:minus on:click={() => { - amount--; - if (amount <= 0) dispatch("remove"); + status.amount--; + if (status.amount <= 0) dispatch("remove"); }} /> - {amount} -
amount++} /> + {status.amount} +
status.amount++} />
{/if}
dispatch("remove")} />