Skip to content

feat: set up pre-craft conditions properly#1353

Open
avilene wants to merge 30 commits into
refactor/EventBasedModulesfrom
feat/precraftconditions
Open

feat: set up pre-craft conditions properly#1353
avilene wants to merge 30 commits into
refactor/EventBasedModulesfrom
feat/precraftconditions

Conversation

@avilene

@avilene avilene commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces a significant refactor of the craft queue "pre-craft" condition system, making the logic more modular, testable, and extensible. The old approach, which used direct boolean fields on CraftQueueItem, has been replaced with a new PrecraftCondition and PrecraftConditionSet system. This enables more granular tracking of why a craft cannot proceed, supports prioritization of blocking conditions, and improves maintainability. Additionally, the sorting and filtering logic for the craft queue has been updated to use the new condition system, and a new method for detecting disabled recipes in the profession UI has been added.

Core system refactor:

  • Introduced PrecraftCondition and PrecraftConditionSet classes to encapsulate individual pre-craft checks and their evaluation state, replacing legacy boolean fields on CraftQueueItem. This enables detailed tracking, prioritization, and extensibility of craft-blocking conditions. (Classes/PrecraftCondition.lua [1] Classes/PrecraftConditionSet.lua [2]
  • Refactored CraftQueueItem to use precraftConditionData for all craftability logic, removing direct boolean fields and legacy calculation methods. Added methods for querying and managing conditions, such as AddCondition, GetFailedConditions, and CalculateCanCraft. (Classes/CraftQueueItem.lua [1] [2] [3]

Craft queue filtering and sorting:

  • Updated CraftQueue:FilterSortByPriority() to use the new precraftConditionData methods (IsCrafter, IsCorrectProfessionOpen, IsAllowedToCraft) for filtering and sorting, and to break ties by comparing the priority of top failed conditions. (Classes/CraftQueue.lua [1] [2] [3]

Recipe disabled state detection:

  • Added RecipeData:GetTradeSkillDisabledRecipeState() to detect if a recipe is currently disabled in the profession UI, including parsing unmet requirements and disabled reasons from Blizzard's API. This is now used as part of the pre-craft evaluation. (Classes/RecipeData.lua Classes/RecipeData.luaR2387-R2426)

Other improvements and cleanup:

  • Removed unused debug logs and legacy fields, and updated references to use the new condition system throughout the affected files. (Classes/CooldownData.lua [1] Classes/ReagentData.lua [2] Classes/CraftQueueItem.lua [3]

These changes lay the groundwork for more sophisticated craftability checks and clearer UI feedback on why a craft cannot proceed.

avilene added 2 commits April 29, 2026 12:06
- Added a new PreCraftConditions module to manage pre-crafting conditions for items in the CraftQueue.
- Enhanced CraftQueueItem to support condition evaluation, including methods for adding, resetting, and checking conditions.
- Updated CraftQueue to incorporate condition checks in the crafting process, improving decision-making for item crafting.
- Introduced new events for handling changes in crafting order tab availability and crafting details updates.
- Refactored UI to support batch processing of crafting conditions, optimizing performance during item evaluations.
- Introduced new classes for managing precraft conditions, including PrecraftCondition, PrecraftConditionSet, PrecraftUserConditions, and PrecraftUserContext.
- Updated CraftQueue and CraftQueueItem to integrate condition evaluation, allowing for dynamic checks during crafting processes.
- Enhanced the PreCraftConditions module to support user context invalidation and evaluation marking for improved crafting logic.
- Refactored UI components to accommodate new condition evaluation mechanisms, optimizing performance during item evaluations.
@avilene avilene marked this pull request as ready for review May 7, 2026 07:03
Comment thread Classes/CraftQueueItem.lua Outdated
Comment thread Classes/CraftQueueItem.lua Outdated
Comment thread Classes/CraftQueueItem.lua
Comment thread Classes/PrecraftConditionSet.lua
Comment thread Classes/PrecraftUserContext.lua Outdated
Comment thread Modules/CraftQueue/PreCraftConditions.lua Outdated
Comment thread Modules/CraftQueue/PreCraftConditions.lua Outdated
Comment thread Modules/CraftQueue/PreCraftConditions.lua Outdated
Comment thread Modules/CraftQueue/UI.lua Outdated
Comment thread Modules/CraftQueue/UI.lua Outdated
avilene added 5 commits May 7, 2026 09:59
…ement

- Introduced the PrecraftConditionSet class to encapsulate condition handling within CraftQueueItem.
- Replaced direct condition management in CraftQueueItem with methods from PrecraftConditionSet.
- Updated related methods to utilize the new structure, enhancing clarity and maintainability.
- Simplified event handling for crafting orders and conditions, ensuring better responsiveness in the UI.
…asses

- Removed the deprecated PrecraftUserConditions and PrecraftUserContext classes to simplify the codebase.
- Updated CraftQueueItem to utilize the new PrecraftConditionSet for condition evaluations.
- Adjusted related methods to enhance clarity and maintainability in condition management.
- Cleaned up the CraftSim.toc file by removing references to the deleted classes.
- Removed the EvaluateQueueItemsInBatches function to streamline the evaluation of craft queue items.
- Consolidated the logic for determining whether to batch process items directly within the UpdateFrameListByCraftQueue method.
- Enhanced the handling of item evaluations using GUTIL.FrameDistributor for improved performance and responsiveness.
- Maintained the same functionality while simplifying the code structure for better maintainability.
- Implemented normalization of crafterUID keys in crafterDB, craftListsDB, itemCountDB, itemOptimizedCostsDB, lastCraftingCostDB, and optionsDB to ensure consistent formatting.
- Added utility functions for realm key normalization and crafterUID key normalization to streamline data handling.
- Enhanced data integrity by merging existing data with normalized keys, improving compatibility for future migrations.
avilene and others added 3 commits May 10, 2026 10:06
- Implemented checks to ensure the profession parameter is provided before proceeding with data operations in the Save and Get methods of the MULTICRAFT_PRELOAD module.
- Initialized the multicraftPreloadDB data structure if it does not already exist, enhancing data integrity.
Comment thread Classes/PrecraftConditionSet.lua Outdated
Comment thread Classes/PrecraftConditionSet.lua Outdated
Comment thread Classes/PrecraftConditionSet.lua Outdated
Comment thread Classes/PrecraftConditionSet.lua Outdated
Comment thread Classes/RecipeData.lua Outdated
Comment thread Modules/CraftQueue/CraftQueue.lua Outdated
Comment thread Modules/CraftQueue/UI.lua Outdated
Comment thread Modules/CraftQueue/UI.lua Outdated
Comment thread Modules/CraftQueue/UI.lua Outdated
Comment thread Modules/CraftQueue/UI.lua Outdated
derfloh205 and others added 6 commits May 11, 2026 15:05
- Eliminated the shapeshift condition from the PrecraftConditionSet and related modules to streamline crafting checks.
- Updated event registration in CraftQueue to remove dependency on shapeshift form updates.
- Replaced direct boolean flags with a structured `precraftConditionData` in `CraftQueueItem` to streamline craftability evaluations.
- Updated various modules to utilize the new methods for checking crafting conditions, improving code clarity and maintainability.
- Ensured consistent usage of `IsCrafter()` and related checks across the codebase.
- Updated `GetLiveDisabledState` to `GetTradeSkillDisabledRecipeState` for clarity on its purpose regarding trade skill data.
- Adjusted related calls in `PrecraftConditionSet` to reflect the new method name, ensuring consistent terminology across the codebase.
@avilene avilene requested a review from derfloh205 May 13, 2026 04:19
@avilene

avilene commented May 13, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

Co-authored-by: avilene <5927637+avilene@users.noreply.github.com>
Co-authored-by: avilene <5927637+avilene@users.noreply.github.com>

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merged latest refactor/EventBasedModules into this branch and resolved the conflicts in CraftSim.toc and Init/Init.lua in 146b230.

avilene added 3 commits May 13, 2026 16:27
…cker

- Enhanced the CURRENCY_DISPLAY_UPDATE function to better manage updates for moxie and concentration currencies.
- Introduced checks to ensure updates only occur when necessary, improving performance.
- Updated GetCurrentConcentrationData to utilize the trade skill API for concentration currency, removing reliance on specialization checks.
- Added UpdateCraftNextButtonFromQueueList function to ensure the Craft Next button reflects the status of the first item in the queue after updates.
- Enhanced UpdateQueueDisplay to call UpdateCraftNextButtonFromQueueList only when batch evaluation is not running, improving performance and responsiveness.
@avilene

avilene commented May 19, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

Co-authored-by: avilene <5927637+avilene@users.noreply.github.com>

Copilot AI commented May 19, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved by merging latest refactor/EventBasedModules into this branch and fixing the conflict in Modules/ConcentrationTracker/ConcentrationTracker.lua in commit f042a1a.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an extensible “pre-craft condition” evaluation system for Craft Queue items, improves recipe disabled-state detection, and normalizes crafter UID keys across multiple DB tables to reduce duplicate/fragmented character data.

Changes:

  • Added PrecraftCondition / PrecraftConditionSet to centralize craftability gating (replacing scattered booleans on CraftQueueItem).
  • Updated Craft Queue UI to batch can-craft evaluation per frame and surface condition failure reasons in tooltips and ordering.
  • Added multiple DB migrations + UID helpers to normalize realm/UID keys and merge legacy duplicates.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Util/Util.lua Adds table merge helpers and introduces realm/crafter UID normalization utilities.
Modules/CraftQueue/UI.lua Refactors queue rendering to batch can-craft evaluation and consume precraft condition data.
Modules/CraftQueue/PreCraftConditions.lua Defines shared precraft condition IDs and priority constants.
Modules/CraftQueue/PreCraftBuffGate.lua Aligns buff gate checks with new crafter/profession-open logic.
Modules/CraftQueue/EditRecipe.lua Updates concentration refresh logic to use CraftQueueItem:IsCrafter().
Modules/CraftQueue/CraftQueue.lua Adds events and deferred refreshes to keep precraft states in sync with UI context changes.
Modules/CraftLog/UI.lua Removes commented debug prints.
Modules/ConcentrationTracker/ConcentrationTracker.lua Hooks currency updates, snapshots moxie, and improves concentration cache invalidation.
Init/Init.lua Emits orders tab availability changes and defers add-work-orders button refresh after tab/profession changes.
DB/recipeSubCrafterDB.lua Migration to normalize stored crafter UID keys.
DB/optionsDB.lua Migration to normalize crafter UID keys in cooldown blacklist option storage.
DB/multicraftPreloadDB.lua Guards against nil profession and ensures DB table initialization.
DB/lastCraftingCostDB.lua Migration to normalize crafter UID keys and resolve duplicates via timestamps.
DB/itemRecipeDB.lua Migration to de-duplicate/normalize “registered crafters” UID list entries.
DB/itemOptimizedCostsDB.lua Migration to normalize crafter UID keys for optimized-cost rows.
DB/ItemCountDB.lua Migration to normalize crafter UID keys and merge item counts.
DB/craftListsDB.lua Migration to normalize crafter UID keys in craft list storage/selection maps.
DB/crafterDB.lua Migration to normalize crafter UID keys and merge legacy duplicate crafter records.
CraftSim.toc Registers new precraft condition class files and condition constants module.
Classes/RecipeData.lua Adds live disabled-state detection and adjusts CanCraft()/crafter UID handling.
Classes/ReagentData.lua Removes commented debug prints.
Classes/PrecraftConditionSet.lua Implements per-item condition evaluation, caching, and query helpers.
Classes/PrecraftCondition.lua Implements a single evaluated condition abstraction.
Classes/CraftQueueItem.lua Replaces per-item craftability booleans with PrecraftConditionSet.
Classes/CraftQueue.lua Updates sorting logic to use precraft condition state and top failed condition priority.
Classes/CooldownData.lua Removes a debug log line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Modules/CraftQueue/UI.lua
craftList:Remove()

CraftSim.DEBUG:StartProfiling("- CraftQueue.FrameListUpdate Add Rows")
for _, craftQueueItem in pairs(craftQueue.craftQueueItems) do
Comment thread Modules/CraftQueue/UI.lua
local rawItems = craftQueue.craftQueueItems or {}
--- Dense array — queue mutations may leave craftQueueItems sparse; FrameDistributor uses `next`.
local items = {}
for _, craftQueueItem in ipairs(rawItems) do
Comment thread Classes/RecipeData.lua
Comment on lines +2618 to 2620
local crafterName = self.crafterData.name or UnitNameUnmodified("player") or ""
local crafterUID = crafterName .. "-" .. CraftSim.UTIL:ResolveCrafterRealm(self.crafterData.realm) --[[@as CrafterUID]]
return crafterUID
Comment thread Util/Util.lua
---@param realm string?
---@return string
function CraftSim.UTIL:ResolveCrafterRealm(realm)
return realm or GetNormalizedRealmName() or GetRealmName() or ""
Comment thread DB/crafterDB.lua
Comment on lines +825 to +830
for crafterUID, crafterData in pairs(CraftSimDB.crafterDB.data or {}) do
local normalizedCrafterUID = CraftSim.UTIL:NormalizeCrafterUIDKey(crafterUID)
if normalizedCrafterUID then
normalizedData[normalizedCrafterUID] = normalizedData[normalizedCrafterUID] or {}
CraftSim.UTIL:MergePreserveData(normalizedData[normalizedCrafterUID], crafterData)
end
Comment thread DB/craftListsDB.lua
Comment on lines +418 to +421
for listID, craftList in pairs(listMap or {}) do
normalizedCharacterLists[normalizedCrafterUID][listID] = normalizedCharacterLists[normalizedCrafterUID]
[listID] or craftList
end
avilene added 2 commits May 28, 2026 09:32
… system

- Introduced a queue action rank system in CraftQueueItem to prioritize crafting actions.
- Updated FilterSortByPriority in CraftQueue to utilize the new ranking for sorting.
- Added GetQueueActionRank method in both CraftQueueItem and PrecrafConditionSet to determine crafting eligibility based on conditions.
- Modified UI logic to reflect changes in crafting order submission based on new conditions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants