Skip to content

fix(get_prototype_recipe): return crafting time, category and enabled state - #435

Open
hashbender wants to merge 1 commit into
JackHopkins:mainfrom
hashbender:fix/get-prototype-recipe-fields
Open

hashbender wants to merge 1 commit into
JackHopkins:mainfrom
hashbender:fix/get-prototype-recipe-fields

Conversation

@hashbender

Copy link
Copy Markdown

Problem

storage.utils.serialize_recipe already returns each recipe's energy, category and enabled. The client drops all three:

return Recipe(name=name, ingredients=ingredients, products=products)

So every recipe comes back as energy=0, category=None, enabled=False, which are the model's defaults. The manual promises "Additional metadata like crafting time and category". The category is the only field that says which machine makes a recipe:

  • smelting means a furnace;
  • advanced-crafting (for example engine-unit) can't be hand-crafted;
  • chemistry means a chemical plant.

Without it, an agent can't tell any of this from the tool. enabled is the only way to see whether a recipe is unlocked.

Reported as item 9 of #418.

Fix

Pass energy, category and enabled from the reply into Recipe(...). The Recipe model already has these fields, so nothing else changes.

Testing

  • New tests/unit/test_get_prototype_recipe_fields.py (server-free, 2 tests): stubs execute with the reply shape serialize_recipe produces (numbers as strings) and checks the three fields. Both fail on main and pass here.
  • tests/unit passes (6 tests).
  • New test_get_recipe_time_category_and_enabled in tests/actions/test_get_prototype_recipe.py: iron-gear-wheel is 0.5 s / crafting / enabled, and engine-unit is 10 s / advanced-crafting (from the 2.0.73 recipe.lua). It needs a server; I haven't run it.
  • ruff 0.11.13 format/check clean.

🤖 Generated with Claude Code

… state

serialize_recipe already sends energy, category and enabled, but the client
built Recipe(name, ingredients, products) only, so every recipe came back as
energy=0, category=None, enabled=False. The category is what says which
machine makes a recipe (e.g. engine-unit is advanced-crafting, so it cannot
be hand-crafted), and the manual promises "crafting time and category".

Pass the three fields through.

Tests: server-free unit tests with a stubbed reply, and a server test for
iron-gear-wheel and engine-unit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant