Smithing table

This commit is contained in:
2026-09-25 23:48:29 -03:00
parent 9237152aa1
commit 8f32a59bd6
15 changed files with 279 additions and 13 deletions
+18 -2
View File
@@ -78,7 +78,15 @@ export type RecipeJson =
result: { id: string; count: number };
}
| { type: "furnace"; input: string; output: { id: string; count: number }; cook_time: number }
| { type: "fuel"; item: string; burn_time: number };
| { type: "fuel"; item: string; burn_time: number }
// upgrades a tool at a smithing table, with some of a material and maybe one more item
| {
type: "smithing";
tool: string;
material: { id: string; count: number };
addition?: string;
result: string;
};
// the crafting grid's format, see server/game/crafting.ts
export interface GridRecipe {
@@ -447,8 +455,16 @@ export function validate_recipe(json: unknown): Problems {
problems.push("burn_time must be a positive number of ticks");
}
break;
case "smithing":
problems.push(
...validate_id(json.tool, "tool"),
...validate_stack(json.material, "material"),
...validate_id(json.result, "result"),
);
if (json.addition !== undefined) problems.push(...validate_id(json.addition, "addition"));
break;
default:
problems.push('type must be "shaped", "furnace" or "fuel"');
problems.push('type must be "shaped", "furnace", "fuel" or "smithing"');
}
return problems;
}