add iron/gold smelting + disambiguate workbench-vs-recipe

Q: iron_smelt (iron_ore + wood → iron_ingot) and gold_smelt
(gold + wood → gold_ingot) recipes added at Smelter, using the
existing ingredient2 buffer mechanism. New TYPE_IRON_INGOT and
TYPE_GOLD_INGOT item types (procedural hue-hash draw for now).

R: new Recipe.target_workbench field (StringName, empty = any matching
skill) round-trips through to_dict/from_dict. Workbench bill picker
filters by both required_skill AND target_workbench vs lower-cased
label_text. plank → carpenter, stone_block/iron_smelt/gold_smelt →
smelter, flour → millstone. Cooking-only recipes (bread, meal) stay
unrestricted since Hearth is the only cooking workbench.

9 recipes total now, 4 distinct workbench routes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-16 18:45:11 +01:00
parent 57e1f0f389
commit 6789ca739f
5 changed files with 77 additions and 5 deletions

View file

@ -415,15 +415,24 @@ func _on_recipe_chosen(id: int) -> void:
_populate_bills()
## Returns all catalog recipes whose required_skill matches the workbench's
## accepted_skill. Returns an empty array when no workbench is set.
## Returns all catalog recipes visible at the current workbench.
## Two-pass filter:
## 1. required_skill must match workbench.accepted_skill.
## 2. If the recipe has a target_workbench set, it must match
## workbench.label_text.to_lower() — e.g. "Carpenter" → "carpenter".
## Recipes with an empty target_workbench pass to any matching-skill bench.
## Returns an empty array when no workbench is set.
func _filtered_recipes() -> Array[Recipe]:
if current_workbench == null:
return []
var workbench_key: StringName = StringName(current_workbench.label_text.to_lower())
var result: Array[Recipe] = []
for r in RecipeCatalog.all():
if r.required_skill == current_workbench.accepted_skill:
result.append(r)
if r.required_skill != current_workbench.accepted_skill:
continue
if r.target_workbench != &"" and r.target_workbench != workbench_key:
continue
result.append(r)
return result