Skip to content

Commit

Permalink
Fixed created items missing upgradeLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
colecrouter committed Oct 27, 2024
1 parent 2ca847b commit 68b8e67
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const createItem = (name: string) => {

// Initialize the item
const item: Item = {
name,
name: data.Name,
itemId: data.ItemId,
stack: 1,
quality: 0,
Expand Down Expand Up @@ -108,7 +108,8 @@ export const createItem = (name: string) => {

// Handle tools separately
if (data._type === "Tool") {
itemType = toolTypeMap.get(name);
const nameWithoutPrefix = name.split(" ").slice(1).join(" ");
itemType = toolTypeMap.get(nameWithoutPrefix);

// Special handling for upgrade levels
if (["Pickaxe", "Axe", "Hoe", "WateringCan"].includes(itemType ?? "")) {
Expand All @@ -117,7 +118,7 @@ export const createItem = (name: string) => {
if (name.startsWith(levelName)) {
item.upgradeLevel = levelValue;
// Remove prefix from name
item.name = item.name.replace(`${levelName} `, "");
item.name = nameWithoutPrefix;
break;
}
}
Expand Down

0 comments on commit 68b8e67

Please sign in to comment.