Tags for smithing recipes

This commit is contained in:
2026-11-13 20:19:37 -03:00
parent 51b5d148bd
commit d48fa8cca5
7 changed files with 130 additions and 47 deletions
+9 -3
View File
@@ -46,7 +46,8 @@ export function fluid_inputs(recipe: Recipe): FluidAmount[] {
return recipe.fluid_ingredients ?? [];
}
// what a recipe takes. shaped keys, smelting inputs and fuels can be an item or #tag, or a list any of which fits
// what a recipe takes. shaped keys, smelting inputs, fuels and smithing inputs can be an item or #tag, or a list any of
// which fits
export function inputs(recipe: Recipe, tags: TagApi): Ingredient[] {
switch (recipe.type) {
case "shaped":
@@ -59,8 +60,8 @@ export function inputs(recipe: Recipe, tags: TagApi): Ingredient[] {
case "bworld:fuel":
return [{ ids: tags.expand(recipe.item), count: 1 }];
case "bworld:smithing":
return [{ ids: [recipe.tool], count: 1 }, stack(recipe.material)].concat(
recipe.addition ? [stack(recipe.addition)] : [],
return [{ ids: tags.expand(recipe.tool), count: 1 }, choice_stack(recipe.material, tags)].concat(
recipe.addition ? [choice_stack(recipe.addition, tags)] : [],
);
default: {
const { grid, extras } = mod_recipe_inputs(recipe, tags);
@@ -97,6 +98,11 @@ export function stack(value: { id: string; count: number }): Ingredient {
return { ids: [value.id], count: value.count };
}
// { id, count } where id is an item, a #tag or a list of them, like smithing's material
export function choice_stack(value: { id: string | string[]; count: number }, tags: TagApi): Ingredient {
return { ids: tags.expand(value.id), count: value.count };
}
export function seconds(ticks: number): string {
const s = ticks / 20;
return `${Number.isInteger(s) ? s : s.toFixed(1)} s`;