From 9426748ffe4de6e3634d8b3e7286048654cb0189 Mon Sep 17 00:00:00 2001 From: "Kyle J. Kemp" Date: Sat, 12 Oct 2024 08:32:55 -0500 Subject: [PATCH] show level in small sprites --- .../sprite-with-inline-name.component.html | 2 +- .../sprite-with-inline-name.component.ts | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/app/shared/components/sprite-with-inline-name/sprite-with-inline-name.component.html b/src/app/shared/components/sprite-with-inline-name/sprite-with-inline-name.component.html index 2ef7b74..2963e63 100644 --- a/src/app/shared/components/sprite-with-inline-name/sprite-with-inline-name.component.html +++ b/src/app/shared/components/sprite-with-inline-name/sprite-with-inline-name.component.html @@ -3,5 +3,5 @@ } - {{ name() }} + {{ name() }} {{ level() }} \ No newline at end of file diff --git a/src/app/shared/components/sprite-with-inline-name/sprite-with-inline-name.component.ts b/src/app/shared/components/sprite-with-inline-name/sprite-with-inline-name.component.ts index c2b2b6d..923dc75 100644 --- a/src/app/shared/components/sprite-with-inline-name/sprite-with-inline-name.component.ts +++ b/src/app/shared/components/sprite-with-inline-name/sprite-with-inline-name.component.ts @@ -12,6 +12,26 @@ export class SpriteWithInlineNameComponent { public name = input.required(); public type = input.required<'items' | 'creatures'>(); + public level = computed(() => { + const mod = this.modService.mod(); + const name = this.name(); + const type = this.type(); + + let levelReq = 0; + + if (type === 'items') { + const foundItem = mod.items.find((i) => i.name === name); + levelReq = foundItem?.requirements?.level ?? 0; + } + + if (type === 'creatures') { + const foundNpc = mod.npcs.find((i) => i.npcId === name); + levelReq = foundNpc?.level ?? 0; + } + + return levelReq ? `(Level ${levelReq})` : ''; + }); + public sprite = computed(() => { const mod = this.modService.mod(); const name = this.name();