feat: set up pre-craft conditions properly#1353
Open
avilene wants to merge 30 commits into
Open
Conversation
- 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.
derfloh205
previously requested changes
May 7, 2026
…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.
- 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.
derfloh205
previously requested changes
May 11, 2026
- 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.
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>
Contributor
…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.
Collaborator
Author
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: avilene <5927637+avilene@users.noreply.github.com>
Contributor
Contributor
There was a problem hiding this comment.
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/PrecraftConditionSetto centralize craftability gating (replacing scattered booleans onCraftQueueItem). - 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.
| craftList:Remove() | ||
|
|
||
| CraftSim.DEBUG:StartProfiling("- CraftQueue.FrameListUpdate Add Rows") | ||
| for _, craftQueueItem in pairs(craftQueue.craftQueueItems) do |
| 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 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 |
| ---@param realm string? | ||
| ---@return string | ||
| function CraftSim.UTIL:ResolveCrafterRealm(realm) | ||
| return realm or GetNormalizedRealmName() or GetRealmName() or "" |
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 on lines
+418
to
+421
| for listID, craftList in pairs(listMap or {}) do | ||
| normalizedCharacterLists[normalizedCrafterUID][listID] = normalizedCharacterLists[normalizedCrafterUID] | ||
| [listID] or craftList | ||
| end |
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 newPrecraftConditionandPrecraftConditionSetsystem. 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:
PrecraftConditionandPrecraftConditionSetclasses to encapsulate individual pre-craft checks and their evaluation state, replacing legacy boolean fields onCraftQueueItem. This enables detailed tracking, prioritization, and extensibility of craft-blocking conditions. (Classes/PrecraftCondition.lua[1]Classes/PrecraftConditionSet.lua[2]CraftQueueItemto useprecraftConditionDatafor all craftability logic, removing direct boolean fields and legacy calculation methods. Added methods for querying and managing conditions, such asAddCondition,GetFailedConditions, andCalculateCanCraft. (Classes/CraftQueueItem.lua[1] [2] [3]Craft queue filtering and sorting:
CraftQueue:FilterSortByPriority()to use the newprecraftConditionDatamethods (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:
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.luaClasses/RecipeData.luaR2387-R2426)Other improvements and cleanup:
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.