Skip to content

Commit

Permalink
show level in small sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Oct 12, 2024
1 parent 1dac106 commit 9426748
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<app-sprite class="absolute -top-5 -left-5" [scale]="0.5" [type]="type()" [sprite]="sprite()"></app-sprite>
}

<span class="ml-7">{{ name() }}</span>
<span class="ml-7">{{ name() }} {{ level() }}</span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ export class SpriteWithInlineNameComponent {
public name = input.required<string>();
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();
Expand Down

0 comments on commit 9426748

Please sign in to comment.