Implement recipe system #245

Open
opened 2026-03-16 01:41:46 +00:00 by freemo · 0 comments
Owner

Metadata

Field Value
Parent Epic Epic: Crafting Minigame Engine (#211)
Legendary Crafting & Resource Economy (#200)
Type Feature
Priority High
MoSCoW Must Have
Points 8
Branch feature/m4-recipe-system
Commit Message Implement recipe system (#245)

Background and Context

Recipes are the blueprints that tie the crafting system together. A recipe defines what ingredients are needed, what skill and level are required, what challenge sequence the player will face in the minigame, and what item is produced on completion. Recipes are stored in conf/recipes.yaml and loaded at server startup.

The Recipe class is responsible for validating that a player has the required ingredients in their inventory, checking skill requirements, generating the CraftingMinigame step sequence from the recipe's challenge definition, and producing the output item with quality determined by the minigame score.

This is the glue between the harvesting/resource system, the minigame engine, and the item/inventory system.

Expected Behavior

The Recipe data model includes:

  1. ingredient_list (Array<Hash>) — A list of required ingredients with item type and quantity (e.g., [{item: "iron_ore", qty: 3}, {item: "coal", qty: 1}]).
  2. required_skill (String) — The crafting skill required (e.g., "smithing").
  3. required_level (Integer) — The minimum skill level required to attempt this recipe.
  4. challenge_sequence (Array<Hash>) — An ordered list of challenge step definitions (e.g., [{type: "strike", difficulty: 3}, {type: "hold", duration: 4}, ...]).
  5. output_item_template (Hash) — The template for the output item, including base stats that are modified by quality (e.g., {type: "iron_sword", base_damage: 10, base_durability: 100}).

Workflow:

  1. Player initiates crafting with craft <recipe_name>.
  2. Recipe validates ingredients are present in the player's inventory.
  3. Recipe checks the player's skill level meets required_level for required_skill.
  4. If validation passes, ingredients are consumed from inventory.
  5. Recipe generates a CraftingMinigame with the defined challenge_sequence.
  6. After the minigame completes, the quality score is applied to the output_item_template to produce the final item.
  7. The crafted item is added to the player's inventory.

Acceptance Criteria

  • Recipe class exists with all 5 fields properly defined.
  • Recipes are loaded from conf/recipes.yaml at server startup.
  • Recipe#validate_ingredients(player) returns true if the player has all required ingredients, false otherwise.
  • Recipe#check_skill(player) returns true if the player meets the skill and level requirements.
  • Recipe#consume_ingredients(player) removes the required ingredients from the player's inventory.
  • Recipe#generate_minigame creates a CraftingMinigame with the recipe's challenge sequence.
  • Recipe#craft_item(quality_score) produces an item from the output template with stats modified by quality.
  • A craft <recipe_name> command initiates the full crafting workflow.
  • Invalid recipes in YAML are logged and skipped without crashing the server.
  • At least 5 example recipes are provided in conf/recipes.yaml.

Subtasks

  • Create the Recipe class with all 5 fields and accessors.
  • Implement YAML loading from conf/recipes.yaml with validation and error handling.
  • Implement validate_ingredients to check player inventory against the ingredient list.
  • Implement check_skill to verify the player's skill level meets requirements.
  • Implement consume_ingredients to remove ingredients from inventory on craft start.
  • Implement generate_minigame to create a CraftingMinigame from the challenge sequence.
  • Implement craft_item to produce a quality-scaled item from the output template.
  • Implement the craft <recipe_name> command handler that orchestrates the full workflow.
  • Create conf/recipes.yaml with at least 5 example recipes spanning different skills.
  • Docs: Update YARD comments on affected classes and methods. Update relevant Docusaurus documentation pages if applicable.
  • Tests (Cucumber): Add tests/unit/recipe_system.feature covering YAML loading, ingredient validation, skill checks, ingredient consumption, minigame generation, item crafting with quality.
  • Tests (Cucumber Integration): Add integration feature in tests/integration/ for end-to-end recipe crafting flow.
  • Tests (Profiling): Run bundle exec rake unit_profile and verify no performance regressions.
  • Quality: Verify coverage >=97% via bundle exec rake unit. If coverage is <97% then review the current unit test coverage report at build/tests/unit/coverage/ and use it to write new Cucumber based unit tests to improve code coverage. Specifically, write Cucumber/Gherkin style unit tests that are descriptively named and specifically improve coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun bundle exec rake unit to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.
  • Quality: Run bundle exec rake (default task: unit tests with coverage) and bundle exec rake integration, fix any errors if needed ensuring both pass across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata | Field | Value | |---|---| | **Parent Epic** | Epic: Crafting Minigame Engine (#211) | | **Legendary** | Crafting & Resource Economy (#200) | | **Type** | Feature | | **Priority** | High | | **MoSCoW** | Must Have | | **Points** | 8 | | **Branch** | `feature/m4-recipe-system` | | **Commit Message** | `Implement recipe system (#245)` | ## Background and Context Recipes are the blueprints that tie the crafting system together. A recipe defines what ingredients are needed, what skill and level are required, what challenge sequence the player will face in the minigame, and what item is produced on completion. Recipes are stored in `conf/recipes.yaml` and loaded at server startup. The `Recipe` class is responsible for validating that a player has the required ingredients in their inventory, checking skill requirements, generating the `CraftingMinigame` step sequence from the recipe's challenge definition, and producing the output item with quality determined by the minigame score. This is the glue between the harvesting/resource system, the minigame engine, and the item/inventory system. ## Expected Behavior The `Recipe` data model includes: 1. **ingredient_list** (`Array<Hash>`) — A list of required ingredients with item type and quantity (e.g., `[{item: "iron_ore", qty: 3}, {item: "coal", qty: 1}]`). 2. **required_skill** (`String`) — The crafting skill required (e.g., `"smithing"`). 3. **required_level** (`Integer`) — The minimum skill level required to attempt this recipe. 4. **challenge_sequence** (`Array<Hash>`) — An ordered list of challenge step definitions (e.g., `[{type: "strike", difficulty: 3}, {type: "hold", duration: 4}, ...]`). 5. **output_item_template** (`Hash`) — The template for the output item, including base stats that are modified by quality (e.g., `{type: "iron_sword", base_damage: 10, base_durability: 100}`). Workflow: 1. Player initiates crafting with `craft <recipe_name>`. 2. `Recipe` validates ingredients are present in the player's inventory. 3. `Recipe` checks the player's skill level meets `required_level` for `required_skill`. 4. If validation passes, ingredients are consumed from inventory. 5. `Recipe` generates a `CraftingMinigame` with the defined `challenge_sequence`. 6. After the minigame completes, the quality score is applied to the `output_item_template` to produce the final item. 7. The crafted item is added to the player's inventory. ## Acceptance Criteria - [ ] `Recipe` class exists with all 5 fields properly defined. - [ ] Recipes are loaded from `conf/recipes.yaml` at server startup. - [ ] `Recipe#validate_ingredients(player)` returns true if the player has all required ingredients, false otherwise. - [ ] `Recipe#check_skill(player)` returns true if the player meets the skill and level requirements. - [ ] `Recipe#consume_ingredients(player)` removes the required ingredients from the player's inventory. - [ ] `Recipe#generate_minigame` creates a `CraftingMinigame` with the recipe's challenge sequence. - [ ] `Recipe#craft_item(quality_score)` produces an item from the output template with stats modified by quality. - [ ] A `craft <recipe_name>` command initiates the full crafting workflow. - [ ] Invalid recipes in YAML are logged and skipped without crashing the server. - [ ] At least 5 example recipes are provided in `conf/recipes.yaml`. ## Subtasks - [ ] Create the `Recipe` class with all 5 fields and accessors. - [ ] Implement YAML loading from `conf/recipes.yaml` with validation and error handling. - [ ] Implement `validate_ingredients` to check player inventory against the ingredient list. - [ ] Implement `check_skill` to verify the player's skill level meets requirements. - [ ] Implement `consume_ingredients` to remove ingredients from inventory on craft start. - [ ] Implement `generate_minigame` to create a `CraftingMinigame` from the challenge sequence. - [ ] Implement `craft_item` to produce a quality-scaled item from the output template. - [ ] Implement the `craft <recipe_name>` command handler that orchestrates the full workflow. - [ ] Create `conf/recipes.yaml` with at least 5 example recipes spanning different skills. - [ ] Docs: Update YARD comments on affected classes and methods. Update relevant Docusaurus documentation pages if applicable. - [ ] Tests (Cucumber): Add `tests/unit/recipe_system.feature` covering YAML loading, ingredient validation, skill checks, ingredient consumption, minigame generation, item crafting with quality. - [ ] Tests (Cucumber Integration): Add integration feature in `tests/integration/` for end-to-end recipe crafting flow. - [ ] Tests (Profiling): Run `bundle exec rake unit_profile` and verify no performance regressions. - [ ] Quality: Verify coverage >=97% via `bundle exec rake unit`. If coverage is <97% then review the current unit test coverage report at `build/tests/unit/coverage/` and use it to write new Cucumber based unit tests to improve code coverage. Specifically, write Cucumber/Gherkin style unit tests that are descriptively named and specifically improve coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `bundle exec rake unit` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%. - [ ] Quality: Run `bundle exec rake` (default task: unit tests with coverage) and `bundle exec rake integration`, fix any errors if needed ensuring both pass across **entire** code base, do not ignore any failure even if it seems unrelated to this commit, fix it. ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo added this to the v1.3.0 milestone 2026-03-16 01:41:46 +00:00
freemo self-assigned this 2026-03-16 01:41:46 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference: aethyr/Aethyr#245
No description provided.