Skip to content

Commit

Permalink
Fix items not valued beyond max
Browse files Browse the repository at this point in the history
  • Loading branch information
libraryaddict committed Oct 17, 2024
1 parent 3e05fdf commit dd0b037
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/AccountVal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AccountVal {

// Mall extinct items should be at max natural price
const worthEach = Math.min(
this.settings.maxNaturalPrice,
this.settings.maxNaturalPrice + 1,
price.price <= 0 && item.worthMultiplier == 1
? -1
: price.price * (1 / item.worthMultiplier)
Expand Down Expand Up @@ -144,6 +144,10 @@ class AccountVal {
);
}

if (count > 1 && this.settings.showSingleItemWorth) {
title.push(`Worth a total of ${AccountValUtils.getNumber(totalWorth)}`);
}

if (price.accuracy != PriceType.AUTOSELL) {
title.push("");
title.push(
Expand Down Expand Up @@ -216,9 +220,17 @@ class AccountVal {

onShelfName(item.category, totalWorth);

const text = `${AccountValUtils.getNumber(
count
)} ${name} worth a total of ${AccountValUtils.getNumber(totalWorth)}`;
let text = `${AccountValUtils.getNumber(count)} ${name}`;

if (this.settings.showSingleItemWorth) {
if (count > 1) {
text += ` each worth ${AccountValUtils.getNumber(worthEach)}`;
}

text += ` for total ${AccountValUtils.getNumber(totalWorth)}`;
} else {
text += ` worth a total of ${AccountValUtils.getNumber(totalWorth)}`;
}

lines.push(
"<font title='" +
Expand Down
8 changes: 8 additions & 0 deletions src/AccountValSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const sortByAliases: Map<string, SortBy> = new Map([
["count", SortBy.QUANTITY],
["amount", SortBy.QUANTITY],
["meat", SortBy.PRICE],
["price", SortBy.PRICE],
["totalmeat", SortBy.TOTAL_PRICE],
["totalprice", SortBy.TOTAL_PRICE],
["id", SortBy.ITEM_ID],
Expand Down Expand Up @@ -85,6 +86,7 @@ export class AccountValSettings {
presets: PresetSetting[] = [];
doCategories: boolean = false;
maxNaturalPrice = 999_999_999;
showSingleItemWorth: boolean = false;

static getSettings(): ValSetting[] {
const settings: ValSetting[] = [];
Expand Down Expand Up @@ -323,6 +325,12 @@ export class AccountValSettings {
["category", "categories", "shelf", "shelves"],
"Used only for Display Cases at this point, seperates the items into categories"
);
makeSetting(
FieldType.BOOLEAN,
"showSingleItemWorth",
["each"],
"Displays the individual price of each item instead of the total, works best with `sort=meat`"
);

for (const preset of getPresets()) {
makeSetting(
Expand Down

0 comments on commit dd0b037

Please sign in to comment.