Skip to content

Commit

Permalink
Merge pull request #22 from gw2efficiency/update-prerequisites
Browse files Browse the repository at this point in the history
Update prerequisites from recipe-nesting
  • Loading branch information
queicherius authored Sep 5, 2024
2 parents 2baf337 + acb06b7 commit 52beccd
Show file tree
Hide file tree
Showing 19 changed files with 581 additions and 168 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@devoxa/eslint-config": "2.0.5",
"@devoxa/flocky": "^1.3.1",
"@devoxa/prettier-config": "1.0.0",
"@gw2efficiency/recipe-nesting": "^3.0.4",
"@gw2efficiency/recipe-nesting": "^3.1.0",
"@types/jest": "27.0.1",
"@types/node": "15.12.5",
"eslint": "7.32.0",
Expand Down
5 changes: 3 additions & 2 deletions src/craftingSteps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Prerequisites } from '@gw2efficiency/recipe-nesting'
import { RecipeTreeWithCraftFlags } from './types'

export function craftingSteps(tree: RecipeTreeWithCraftFlags) {
Expand Down Expand Up @@ -43,7 +44,7 @@ interface CraftingStep {
minRating: number | null
disciplines: Array<string>
merchant?: { name: string; locations: Array<string> }
recipeId?: number
prerequisites: Prerequisites
components: Array<{ id: number; type: 'Item' | 'Recipe' | 'Currency'; quantity: number }>
}

Expand Down Expand Up @@ -85,7 +86,7 @@ function craftingStepsInner(
minRating: tree.min_rating,
disciplines: tree.disciplines,
merchant: tree.merchant,
recipeId: tree.recipe_id,
prerequisites: tree.prerequisites,
components: treeComponents.map((component) => ({
id: component.id,
type: component.type,
Expand Down
6 changes: 1 addition & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import type { NestedRecipe as NestedRecipeTree } from '@gw2efficiency/recipe-nesting'

type ExtendRecipeTree<TBaseTree, TProperties> = Omit<
TBaseTree,
'type' | 'components' | 'recipe_id'
> & {
type ExtendRecipeTree<TBaseTree, TProperties> = Omit<TBaseTree, 'type' | 'components'> & {
type: 'Recipe' | 'Item' | 'Currency'
components?: Array<ExtendRecipeTree<TBaseTree, TProperties>>
recipe_id?: number
} & TProperties

export type RecipeTree = ExtendRecipeTree<NestedRecipeTree, { __never?: never }>
Expand Down
5 changes: 5 additions & 0 deletions tests/__snapshots__/calculateTreeCraftFlags.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Object {
"id": 2,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 1,
"totalQuantity": 1,
"type": "Recipe",
Expand All @@ -34,6 +35,7 @@ Object {
"id": 3,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 2,
"totalQuantity": 2,
"type": "Recipe",
Expand All @@ -51,6 +53,7 @@ Object {
"id": 4,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 2,
"totalQuantity": 2,
"type": "Recipe",
Expand All @@ -68,6 +71,7 @@ Object {
"id": 5,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 2,
"totalQuantity": 2,
"type": "Recipe",
Expand All @@ -82,6 +86,7 @@ Object {
"id": 1,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 1,
"totalQuantity": 1,
"type": "Recipe",
Expand Down
13 changes: 13 additions & 0 deletions tests/__snapshots__/calculateTreePrices.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Object {
"id": 2,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 1,
"totalQuantity": 1,
"type": "Item",
Expand All @@ -30,6 +31,7 @@ Object {
"id": 3,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 2,
"totalQuantity": 2,
"type": "Item",
Expand All @@ -45,6 +47,7 @@ Object {
"id": 1,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 10,
"totalQuantity": 10,
"type": "Currency",
Expand All @@ -60,6 +63,7 @@ Object {
"id": 2,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 10,
"totalQuantity": 10,
"type": "Currency",
Expand All @@ -73,6 +77,7 @@ Object {
"id": 1,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 1,
"totalQuantity": 1,
"type": "Recipe",
Expand All @@ -96,6 +101,7 @@ Object {
"id": 2,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 1,
"totalQuantity": 1,
"type": "Item",
Expand All @@ -112,6 +118,7 @@ Object {
"id": 3,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 2,
"totalQuantity": 2,
"type": "Item",
Expand All @@ -126,6 +133,7 @@ Object {
"id": 1,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 1,
"totalQuantity": 1,
"type": "Recipe",
Expand All @@ -148,6 +156,7 @@ Object {
"id": 2,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 1,
"totalQuantity": 1,
"type": "Item",
Expand All @@ -167,6 +176,7 @@ Object {
"id": 4,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 50,
"totalQuantity": 50,
"type": "Item",
Expand All @@ -182,6 +192,7 @@ Object {
"id": 5,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 2,
"totalQuantity": 2,
"type": "Item",
Expand All @@ -195,6 +206,7 @@ Object {
"id": 3,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 2,
"totalQuantity": 2,
"type": "Recipe",
Expand All @@ -208,6 +220,7 @@ Object {
"id": 1,
"min_rating": null,
"output": 1,
"prerequisites": Array [],
"quantity": 1,
"totalQuantity": 1,
"type": "Recipe",
Expand Down
Loading

0 comments on commit 52beccd

Please sign in to comment.