Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Condensed Ley-Line Essence recipes #7

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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)
Expand Down
177 changes: 177 additions & 0 deletions tests/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
140 changes: 140 additions & 0 deletions tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<API_Recipes_Entry_Next> = [
{
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()
})
})
Loading