Skip to content

Commit

Permalink
Merge pull request #309 from Qt-dev/fix-coffins
Browse files Browse the repository at this point in the history
Fix coffins
  • Loading branch information
Qt-dev authored Apr 9, 2024
2 parents e93c7e7 + 56c104e commit d23bce9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/main/modules/ItemPricer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ class PriceMatcher {
return 0;
}

const mod = item.implicitMods[0]; // Implicit mod is the only mod on the item
const ilvl = item.properties.find(({ name }) => name === 'Corpse Level').values[0][0]; // Corpse Level is the only property on the item
const mod = item.parsedItem.implicitMods[0]; // Implicit mod is the only mod on the item
const ilvl = item.parsedItem.properties.find(({ name }) => name === 'Corpse Level').values[0][0]; // Corpse Level is the only property on the item
// Find key by:
// 1. Starting with the mod name
// 2. Read the ilvl range
Expand All @@ -806,7 +806,7 @@ class PriceMatcher {
if (!title.startsWith(mod)) return false;
const match = title.match(matchRegexp);
if (!match) return false;
return ilvl >= parseInt(match[1]) && item.ilvl <= parseInt(match[2]);
return ilvl >= parseInt(match[1]) && ilvl <= parseInt(match[2]);
});
if (coffinKey) {
const value = this.ratesCache[tableId][coffinKey];
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/stores/domain/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type LootTableData = {
icon: string;
quantity: number;
stashTabId: string;
stackSize: number;
item?: Item;
itemData?: string;
};
Expand Down Expand Up @@ -204,6 +205,9 @@ export class Item {
this.styleModifiers = itemdata.styleModifiers || {};

this.name = itemdata.name.replace('<<set:MS>><<set:M>><<set:S>>', '').replace(/<>/g, '');
if(itemdata.typeLine === 'Filled Coffin') {
this.name += `${itemdata.implicitMods[0]} - L${itemdata.properties?.find(({name}) => name === 'Corpse Level').values[0][0]}`;
}
this.itemId = itemdata.id;

this.itemLevel = Math.max(1, itemdata.ilvl);
Expand Down Expand Up @@ -264,7 +268,7 @@ export class Item {
// Get the full name to display for an item
@computed getDisplayName(showQuantityInTitle = true): string[] {
// Any normal Basetype with Quality
if (!this.identified && this.quality > 0) {
if (!this.identified && this.quality > 0 && this.baseType !== 'Filled Coffin') {
return [this.baseType];
}
// No identified property, no name -> This is a Gem
Expand Down Expand Up @@ -326,8 +330,9 @@ export class Item {
toLootTable(jsonMode: boolean = false): LootTableData {
const { itemId, value = 0, originalValue = 0, stashTabId = '', rawData } = this;
const { icon } = rawData;
const name = rawData.name || rawData.secretName;
const name = rawData.name || rawData.secretName || this.name;
const type = rawData.hybrid ? rawData.hybrid.baseTypeName : rawData.typeLine;
const stackSize = rawData.maxStackSize;
const quantity = rawData.maxStackSize ? rawData.pickupStackSize ?? rawData.stackSize : 1;
const fullName = type + (name ? ` (${name})` : '');
const lootTableData: LootTableData = {
Expand All @@ -338,6 +343,7 @@ export class Item {
totalValue: value,
icon,
quantity,
stackSize,
stashTabId,
};
if (jsonMode) {
Expand All @@ -357,6 +363,7 @@ export class Item {
originalValue: 0,
icon: '',
quantity: 0,
stackSize: 0,
stashTabId: '',
itemData: '',
};
Expand Down
48 changes: 33 additions & 15 deletions src/renderer/stores/itemStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,40 @@ export default class ItemStore {
this.items
.map((item) => item.toLootTable())
.forEach((item) => {
const { name, quantity, value, totalValue, originalValue } = item;
let group = grouped.find((item) => name === item.name);
if (!group) {
group = {
...item,
value: value,
originalValue: originalValue,
totalValue: 0,
quantity: 0,
items: [],
};
grouped.push(group);
const { quantity, value, totalValue, originalValue, stackSize } = item;
if(stackSize > 0) {
let group = grouped.find(({ name }) => name === item.name);
if (!group) {
group = {
...item,
value: value,
originalValue: originalValue,
totalValue: 0,
quantity: 0,
items: [],
};
grouped.push(group);
}
group.totalValue += totalValue;
group.quantity += quantity;
group.items.push(item);
} else {
let group = grouped.find(({ id }) => id === item.id);
if (!group) {
group = {
...item,
value: value,
originalValue: originalValue,
totalValue: 0,
quantity: 0,
items: [],
};
grouped.push(group);
}
group.totalValue += totalValue;
group.quantity += quantity;
group.items.push(item);
}
group.totalValue += totalValue;
group.quantity += quantity;
group.items.push(item);
});
return grouped;
}
Expand Down

0 comments on commit d23bce9

Please sign in to comment.