Skip to content

Commit

Permalink
fix: could not find food components
Browse files Browse the repository at this point in the history
  • Loading branch information
Icaruk committed Oct 14, 2024
1 parent 8e3bf8f commit da9ce5f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vite-min-template",
"name": "albion-profit",
"private": true,
"version": "0.0.0",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down Expand Up @@ -35,5 +35,5 @@
"postcss-simple-vars": "^7.0.1",
"vite": "^5.2.11"
},
"packageManager": "pnpm@9.3.0"
"packageManager": "pnpm@9.12.1"
}
22 changes: 18 additions & 4 deletions src/pages/home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ export default observer(function Home() {
const productId = product?.id;

const { id, tier, enchant } = getItemIdComponents(productId);
console.log({ id, tier, enchant });

const url = `https://gameinfo.albiononline.com/api/gameinfo/items/${id}/data`;

Expand All @@ -518,15 +519,28 @@ export default observer(function Home() {
const newItemsToAdd = [];

let craftingRequirements = itemData?.craftingRequirements ?? {};
let enchantZeroNotFound = false;

if (enchant) {
if (Object.keys(craftingRequirements).length === 0) {
const enchantIndex = enchant - 1;
craftingRequirements =
itemData?.enchantments?.enchantments[enchantIndex]?.craftingRequirements ?? {};

let enchantData = itemData?.enchantments?.enchantments[enchantIndex];

if (!enchantData) {
enchantData = itemData?.enchantments?.enchantments[enchantIndex + 1];
enchantZeroNotFound = true;
}

craftingRequirements = enchantData?.craftingRequirements ?? {};
}

/** @type {Array<{uniqueName: string, count: number}>} */
const craftResourceList = craftingRequirements?.craftResourceList ?? [];
let craftResourceList = craftingRequirements?.craftResourceList ?? [];

if (enchantZeroNotFound) {
// Temporary fix when enchant 0 is not found, enchant 1 is used instead and only the first resource is used
craftResourceList = [craftResourceList[0]];
}

/*
ore -> metalbar
Expand Down

0 comments on commit da9ce5f

Please sign in to comment.