From 9fe318ff0e8a7e3aeac07e5633e8ca1de0f86278 Mon Sep 17 00:00:00 2001 From: Ecmelt Date: Wed, 13 Nov 2024 19:11:41 +0000 Subject: [PATCH 1/2] Fix for Condensed Ley-Line Essence recipes --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 7f9e44c..85d63a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -105,6 +105,7 @@ function nestRecipe( const isGuildUpgrade = component.type === 'GuildUpgrade' const id = isGuildUpgrade ? recipeUpgradesMap[component.id] || component.id : component.id const componentRecipe = recipesMap[id] + const condensedLeyLineEssenceIds = [91224, 91137, 91222, 91171] // Just give back the component for currencies if (component.type === 'Currency') { @@ -132,6 +133,11 @@ function nestRecipe( : component } + // These items should not have components if they are components of each other + if (condensedLeyLineEssenceIds.includes(recipe.id) && condensedLeyLineEssenceIds.includes(id)) { + return component + } + // The component recipe is not nested yet, so we nest it now! if (!componentRecipe.nested) { recipesMap[id] = nestRecipe(componentRecipe, recipesMap, recipeUpgradesMap, decorationsMap) From a5fe1837c660609a8affd02a0d23ef754d600540 Mon Sep 17 00:00:00 2001 From: Ecmelt Date: Fri, 15 Nov 2024 12:10:53 +0000 Subject: [PATCH 2/2] Add test --- tests/__snapshots__/index.spec.ts.snap | 177 +++++++++++++++++++++++++ tests/index.spec.ts | 140 +++++++++++++++++++ 2 files changed, 317 insertions(+) diff --git a/tests/__snapshots__/index.spec.ts.snap b/tests/__snapshots__/index.spec.ts.snap index 1cd4b1e..6644b2a 100644 --- a/tests/__snapshots__/index.spec.ts.snap +++ b/tests/__snapshots__/index.spec.ts.snap @@ -719,6 +719,183 @@ Object { } `; +exports[`recipe-nesting excludes components for Condensed Ley-Line Essence items if they are components of each other 1`] = ` +Array [ + Object { + "achievement_id": undefined, + "components": Array [ + Object { + "id": 24272, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 24464, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 24326, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 91224, + "quantity": 2, + "type": "Item", + }, + ], + "disciplines": Array [ + "Mystic Forge", + ], + "id": 91137, + "merchant": undefined, + "min_rating": 400, + "multipleRecipeCount": 3, + "output": 1, + "output_range": undefined, + "prerequisites": Array [ + Object { + "id": 1, + "type": "Recipe", + }, + ], + "quantity": 1, + "type": "Recipe", + "upgrade_id": undefined, + }, + Object { + "achievement_id": undefined, + "components": Array [ + Object { + "id": 24272, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 24534, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 24326, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 91224, + "quantity": 2, + "type": "Item", + }, + ], + "disciplines": Array [ + "Mystic Forge", + ], + "id": 91171, + "merchant": undefined, + "min_rating": 400, + "multipleRecipeCount": 3, + "output": 1, + "output_range": undefined, + "prerequisites": Array [ + Object { + "id": 2, + "type": "Recipe", + }, + ], + "quantity": 1, + "type": "Recipe", + "upgrade_id": undefined, + }, + Object { + "achievement_id": undefined, + "components": Array [ + Object { + "id": 24272, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 24464, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 24326, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 91224, + "quantity": 2, + "type": "Item", + }, + ], + "disciplines": Array [ + "Mystic Forge", + ], + "id": 91222, + "merchant": undefined, + "min_rating": 400, + "multipleRecipeCount": 3, + "output": 1, + "output_range": undefined, + "prerequisites": Array [ + Object { + "id": 3, + "type": "Recipe", + }, + ], + "quantity": 1, + "type": "Recipe", + "upgrade_id": undefined, + }, + Object { + "achievement_id": undefined, + "components": Array [ + Object { + "id": 24272, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 24465, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 91137, + "quantity": 1, + "type": "Item", + }, + Object { + "id": 91224, + "quantity": 2, + "type": "Item", + }, + ], + "disciplines": Array [ + "Mystic Forge", + ], + "id": 91224, + "merchant": undefined, + "min_rating": 400, + "multipleRecipeCount": 3, + "output": 1, + "output_range": undefined, + "prerequisites": Array [ + Object { + "id": 4, + "type": "Recipe", + }, + ], + "quantity": 1, + "type": "Recipe", + "upgrade_id": undefined, + }, +] +`; + exports[`recipe-nesting orders the components correctly 1`] = ` Object { "achievement_id": undefined, diff --git a/tests/index.spec.ts b/tests/index.spec.ts index 143ee43..2499f4d 100644 --- a/tests/index.spec.ts +++ b/tests/index.spec.ts @@ -401,4 +401,144 @@ describe('recipe-nesting', () => { it('ignores recipes with only guild upgrades', () => { expect(output.find((x) => x.id === 4567)).toEqual(undefined) }) + + it('excludes components for Condensed Ley-Line Essence items if they are components of each other', () => { + const input: Array = [ + { + type: 'Recipe', + output_item_id: 91137, + output_item_count: 1, + min_rating: 400, + disciplines: ['Mystic Forge'], + flags: [], + ingredients: [ + { + id: 24272, + type: 'Item', + count: 1, + }, + { + id: 24464, + type: 'Item', + count: 1, + }, + { + id: 24326, + type: 'Item', + count: 1, + }, + { + id: 91224, + type: 'Item', + count: 2, + }, + ], + id: 1, + chat_link: '[&CQIAAAA=]', + multipleRecipeCount: 3, + }, + { + type: 'Recipe', + output_item_id: 91171, + output_item_count: 1, + min_rating: 400, + disciplines: ['Mystic Forge'], + flags: [], + ingredients: [ + { + id: 24272, + type: 'Item', + count: 1, + }, + { + id: 24534, + type: 'Item', + count: 1, + }, + { + id: 24326, + type: 'Item', + count: 1, + }, + { + id: 91224, + type: 'Item', + count: 2, + }, + ], + id: 2, + chat_link: '[&CQIAAAA=]', + multipleRecipeCount: 3, + }, + { + type: 'Recipe', + output_item_id: 91222, + output_item_count: 1, + min_rating: 400, + disciplines: ['Mystic Forge'], + flags: [], + ingredients: [ + { + id: 24272, + type: 'Item', + count: 1, + }, + { + id: 24464, + type: 'Item', + count: 1, + }, + { + id: 24326, + type: 'Item', + count: 1, + }, + { + id: 91224, + type: 'Item', + count: 2, + }, + ], + id: 3, + chat_link: '[&CQIAAAA=]', + multipleRecipeCount: 3, + }, + { + type: 'Recipe', + output_item_id: 91224, + output_item_count: 1, + min_rating: 400, + disciplines: ['Mystic Forge'], + flags: [], + ingredients: [ + { + id: 24272, + type: 'Item', + count: 1, + }, + { + id: 24465, + type: 'Item', + count: 1, + }, + { + id: 91137, + type: 'Item', + count: 1, + }, + { + id: 91224, + type: 'Item', + count: 2, + }, + ], + id: 4, + chat_link: '[&CQIAAAA=]', + multipleRecipeCount: 3, + }, + ] + + const output = nestRecipes(input) + expect(output).toMatchSnapshot() + }) })