Implement CraftingMinigame base class with step sequencing, score tracking, and quality calculation #242

Open
opened 2026-03-16 01:41:41 +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-crafting-minigame-base-class
Commit Message Implement CraftingMinigame base class with step sequencing, score tracking, and quality calculation (#242)

Background and Context

The crafting system in Aethyr uses an interactive minigame to determine the quality of crafted items. Rather than a simple click-and-wait mechanic, players engage with a series of timed challenges that test their skill and attention. The CraftingMinigame base class is the engine that orchestrates this experience.

The base class manages a sequence of 5-15 CraftingChallenge steps. Each step is a mini-challenge (e.g., Strike, Hold, Sequence, Wait) that awards a score based on how well the player performs. The total score is calculated as: sum of step scores / max possible score. This normalized score (0.0 to 1.0) is then mapped to a quality tier percentage (1-100) which determines the final item quality.

This is the foundational class that all challenge types plug into. It must be extensible so new challenge types can be added in the future.

Expected Behavior

The CraftingMinigame class provides:

  1. Initialization: Accepts a list of CraftingChallenge step definitions (5-15 steps). Validates the step count is within range.
  2. Step Sequencing: Advances through challenges one at a time, presenting each to the player and collecting their input/response.
  3. Score Tracking: Each completed step returns a score (0 to step's max score). The minigame accumulates the total score and tracks the maximum possible score.
  4. Quality Calculation: After all steps are completed, calculates total_score / max_possible_score * 100 to produce a quality percentage (1-100).
  5. State Management: Tracks current step index, whether the minigame is in progress, completed, or abandoned.
  6. Timeout Handling: If a player takes too long on a step, that step scores 0 and the minigame advances to the next step.
  7. Extensibility: CraftingChallenge is an abstract base class that specific challenge types inherit from.

Acceptance Criteria

  • CraftingMinigame class exists and can be initialized with a list of 5-15 CraftingChallenge step definitions.
  • Initialization raises an error if the step count is outside the 5-15 range.
  • The minigame advances through steps sequentially, presenting one at a time.
  • Each step's score is accumulated into a running total alongside the maximum possible score.
  • After all steps complete, quality_score returns (total_score / max_possible_score * 100).round clamped to 1-100.
  • The minigame tracks state: :pending, :in_progress, :completed, :abandoned.
  • Steps that time out score 0 and the minigame continues to the next step.
  • CraftingChallenge is an abstract base class with methods present, evaluate, max_score, and timeout.
  • The design supports subclassing CraftingChallenge for new challenge types.

Subtasks

  • Create the CraftingChallenge abstract base class with present, evaluate, max_score, and timeout interface methods.
  • Create the CraftingMinigame class with initialization, step validation, and state management.
  • Implement step sequencing logic that advances through challenges one at a time.
  • Implement score tracking: per-step scores, total score, and max possible score.
  • Implement quality calculation: (total_score / max_possible_score * 100).round clamped to 1-100.
  • Implement timeout handling that scores 0 for timed-out steps and advances.
  • Implement state transitions: :pending -> :in_progress -> :completed or :abandoned.
  • Docs: Update YARD comments on affected classes and methods. Update relevant Docusaurus documentation pages if applicable.
  • Tests (Cucumber): Add tests/unit/crafting_minigame_base.feature covering initialization validation, step sequencing, score accumulation, quality calculation, timeout handling, state transitions.
  • Tests (Cucumber Integration): Add integration feature in tests/integration/ for a complete minigame run with mock challenges.
  • 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-crafting-minigame-base-class` | | **Commit Message** | `Implement CraftingMinigame base class with step sequencing, score tracking, and quality calculation (#242)` | ## Background and Context The crafting system in Aethyr uses an interactive minigame to determine the quality of crafted items. Rather than a simple click-and-wait mechanic, players engage with a series of timed challenges that test their skill and attention. The `CraftingMinigame` base class is the engine that orchestrates this experience. The base class manages a sequence of 5-15 `CraftingChallenge` steps. Each step is a mini-challenge (e.g., Strike, Hold, Sequence, Wait) that awards a score based on how well the player performs. The total score is calculated as: `sum of step scores / max possible score`. This normalized score (0.0 to 1.0) is then mapped to a quality tier percentage (1-100) which determines the final item quality. This is the foundational class that all challenge types plug into. It must be extensible so new challenge types can be added in the future. ## Expected Behavior The `CraftingMinigame` class provides: 1. **Initialization**: Accepts a list of `CraftingChallenge` step definitions (5-15 steps). Validates the step count is within range. 2. **Step Sequencing**: Advances through challenges one at a time, presenting each to the player and collecting their input/response. 3. **Score Tracking**: Each completed step returns a score (0 to step's max score). The minigame accumulates the total score and tracks the maximum possible score. 4. **Quality Calculation**: After all steps are completed, calculates `total_score / max_possible_score * 100` to produce a quality percentage (1-100). 5. **State Management**: Tracks current step index, whether the minigame is in progress, completed, or abandoned. 6. **Timeout Handling**: If a player takes too long on a step, that step scores 0 and the minigame advances to the next step. 7. **Extensibility**: `CraftingChallenge` is an abstract base class that specific challenge types inherit from. ## Acceptance Criteria - [ ] `CraftingMinigame` class exists and can be initialized with a list of 5-15 `CraftingChallenge` step definitions. - [ ] Initialization raises an error if the step count is outside the 5-15 range. - [ ] The minigame advances through steps sequentially, presenting one at a time. - [ ] Each step's score is accumulated into a running total alongside the maximum possible score. - [ ] After all steps complete, `quality_score` returns `(total_score / max_possible_score * 100).round` clamped to 1-100. - [ ] The minigame tracks state: `:pending`, `:in_progress`, `:completed`, `:abandoned`. - [ ] Steps that time out score 0 and the minigame continues to the next step. - [ ] `CraftingChallenge` is an abstract base class with methods `present`, `evaluate`, `max_score`, and `timeout`. - [ ] The design supports subclassing `CraftingChallenge` for new challenge types. ## Subtasks - [ ] Create the `CraftingChallenge` abstract base class with `present`, `evaluate`, `max_score`, and `timeout` interface methods. - [ ] Create the `CraftingMinigame` class with initialization, step validation, and state management. - [ ] Implement step sequencing logic that advances through challenges one at a time. - [ ] Implement score tracking: per-step scores, total score, and max possible score. - [ ] Implement quality calculation: `(total_score / max_possible_score * 100).round` clamped to 1-100. - [ ] Implement timeout handling that scores 0 for timed-out steps and advances. - [ ] Implement state transitions: `:pending` -> `:in_progress` -> `:completed` or `:abandoned`. - [ ] Docs: Update YARD comments on affected classes and methods. Update relevant Docusaurus documentation pages if applicable. - [ ] Tests (Cucumber): Add `tests/unit/crafting_minigame_base.feature` covering initialization validation, step sequencing, score accumulation, quality calculation, timeout handling, state transitions. - [ ] Tests (Cucumber Integration): Add integration feature in `tests/integration/` for a complete minigame run with mock challenges. - [ ] 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:41 +00:00
freemo self-assigned this 2026-03-16 01:41:41 +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#242
No description provided.