-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8d0dec
commit 5d74f9c
Showing
6 changed files
with
99 additions
and
9 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import RecipeParser, { Recipe, replace } from '..' | ||
import { Ingredient, Predicate, Result } from '../../../common/ingredient' | ||
import { RecipeDefinition } from '../../../schema/recipe' | ||
import { exists } from '@pssbletrngle/pack-resolver' | ||
|
||
export type CookingRecipeDefinition = RecipeDefinition & | ||
Readonly<{ | ||
ingredients: Ingredient[] | ||
container?: Ingredient | ||
result: Result | ||
cookingTime?: number | ||
experience?: number | ||
recipe_book_tab?: string | ||
}> | ||
|
||
export class CookingRecipe extends Recipe<CookingRecipeDefinition> { | ||
getIngredients(): Ingredient[] { | ||
return [this.definition.container, ...this.definition.ingredients].filter(exists) | ||
} | ||
|
||
getResults(): Result[] { | ||
return [this.definition.result] | ||
} | ||
|
||
replaceIngredient(from: Predicate<Ingredient>, to: Ingredient): CookingRecipe { | ||
return new CookingRecipe({ | ||
...this.definition, | ||
container: this.definition.container && replace(from, to)(this.definition.container), | ||
ingredients: this.definition.ingredients.map(replace(from, to)), | ||
}) | ||
} | ||
|
||
replaceResult(from: Predicate<Ingredient>, to: Result): CookingRecipe { | ||
return new CookingRecipe({ | ||
...this.definition, | ||
result: to, | ||
}) | ||
} | ||
} | ||
|
||
export default class CookingRecipeParser extends RecipeParser<CookingRecipeDefinition, CookingRecipe> { | ||
create(definition: CookingRecipeDefinition): CookingRecipe { | ||
return new CookingRecipe(definition) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import RecipeParser, { Recipe, replace } from '..' | ||
import { Ingredient, Predicate, Result } from '../../../common/ingredient' | ||
import { RecipeDefinition } from '../../../schema/recipe' | ||
|
||
export type CuttingRecipeDefinition = RecipeDefinition & | ||
Readonly<{ | ||
ingredients: Ingredient[] | ||
result: Result[] | ||
tool: unknown | ||
}> | ||
|
||
export class CuttingRecipe extends Recipe<CuttingRecipeDefinition> { | ||
getIngredients(): Ingredient[] { | ||
return this.definition.ingredients | ||
} | ||
|
||
getResults(): Result[] { | ||
return this.definition.result | ||
} | ||
|
||
replaceIngredient(from: Predicate<Ingredient>, to: Ingredient): CuttingRecipe { | ||
return new CuttingRecipe({ | ||
...this.definition, | ||
ingredients: this.definition.ingredients.map(replace(from, to)), | ||
}) | ||
} | ||
|
||
replaceResult(from: Predicate<Ingredient>, to: Result): CuttingRecipe { | ||
return new CuttingRecipe({ | ||
...this.definition, | ||
result: this.definition.result.map(replace(from, to)), | ||
}) | ||
} | ||
} | ||
|
||
export default class CuttingRecipeParser extends RecipeParser<CuttingRecipeDefinition, CuttingRecipe> { | ||
create(definition: CuttingRecipeDefinition): CuttingRecipe { | ||
return new CuttingRecipe(definition) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters