-
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
85e3f7d
commit 2bcc279
Showing
4 changed files
with
801 additions
and
753 deletions.
There are no files selected for viewing
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
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,43 @@ | ||
import RecipeParser, { Recipe } from '..' | ||
import { Ingredient, Predicate, Result } from '../../../common/ingredient' | ||
import { RecipeDefinition } from '../../../schema/recipe' | ||
|
||
type StonecuttingRecipeDefinition = RecipeDefinition & | ||
Readonly<{ | ||
ingredient: Ingredient | ||
result: string | ||
count?: number | ||
}> | ||
|
||
class StonecuttingRecipe extends Recipe<StonecuttingRecipeDefinition> { | ||
getIngredients(): Ingredient[] { | ||
return [this.definition.ingredient] | ||
} | ||
|
||
getResults(): Result[] { | ||
return [{ item: this.definition.result, count: this.definition.count }] | ||
} | ||
|
||
replaceIngredient(from: Predicate<Ingredient>, to: Ingredient): Recipe { | ||
return new StonecuttingRecipe({ | ||
...this.definition, | ||
ingredient: to, | ||
}) | ||
} | ||
|
||
replaceResult(from: Predicate<Ingredient>, to: Result): Recipe { | ||
if (!('item' in to)) throw new Error('stonecutting does only support item results') | ||
|
||
return new StonecuttingRecipe({ | ||
...this.definition, | ||
result: to.item, | ||
count: to.count ?? 1, | ||
}) | ||
} | ||
} | ||
|
||
export default class StonecuttingParser extends RecipeParser<StonecuttingRecipeDefinition, StonecuttingRecipe> { | ||
create(definition: StonecuttingRecipeDefinition): StonecuttingRecipe { | ||
return new StonecuttingRecipe(definition) | ||
} | ||
} |
Oops, something went wrong.