Skip to content

Commit

Permalink
feat(item): item tooltips now show the item value
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Mar 28, 2023
1 parent 5fa5391 commit 1453dd3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/app/components/item-tooltip/item-tooltip.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<strong [ngClass]="[itemClass]">{{ item.name }} &middot; {{ item.category }}</strong>
</div>

<div>
<div class="value">
<em><small>Worth {{ realSellValue(item) | number }} coins</small></em>
</div>

<div class="description">
{{ item.description }}
</div>

Expand Down
3 changes: 2 additions & 1 deletion src/app/components/item-tooltip/item-tooltip.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

.stats, .effects, .gives {

.stats, .effects, .gives, .value, .description {
margin-top: 5px;
}
11 changes: 9 additions & 2 deletions src/app/components/item-tooltip/item-tooltip.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component, Input, OnInit } from '@angular/core';
import { Store } from '@ngxs/store';
import { IGameItem } from '../../../interfaces';
import { getItemRarityClass } from '../../helpers';
import { shopRegisterMultiplier } from '../../../stores/mercantile/mercantile.functions';
import { getItemRarityClass, itemValue } from '../../helpers';
import { ContentService } from '../../services/content.service';

@Component({
Expand All @@ -21,7 +23,7 @@ export class ItemTooltipComponent implements OnInit {
return getItemRarityClass(this.item);
}

constructor(private contentService: ContentService) { }
constructor(private store: Store, private contentService: ContentService) { }

ngOnInit() {
this.hasStats = Object.keys(this.item.stats || {}).length > 0;
Expand All @@ -42,4 +44,9 @@ export class ItemTooltipComponent implements OnInit {
}
}

realSellValue(item: IGameItem) {
return itemValue(item,
2 + shopRegisterMultiplier(this.store.selectSnapshot(state => state.mercantile.shop.saleBonusLevel ?? 0))) * (item.quantity ?? 1);
}

}

0 comments on commit 1453dd3

Please sign in to comment.