-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add support for mod sets #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces changes to mod generation and image rendering. It modifies function calls to pass parameters as an object instead of individual arguments, affecting the README, generator, and tests. New types and constants are added for mapping rarity data, while drawing functions are enhanced with new header-processing capabilities and parameter reordering. Utility functions are also refactored, and minor naming corrections are made. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Generator
participant Utils
participant Drawers
Client->>Generator: Call generate({ mod, rank, ... })
alt mod contains modSet
Generator->>Utils: setHeader(uniqueName)
Utils-->>Generator: headerImage
Generator->>Drawers: drawHeader(headerImage, tier)
Drawers-->>Generator: processed header image
end
Generator-->>Client: Return generated mod image
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
README.md (1)
31-31: Updated function call structureUpdating the function call to use an object parameter structure improves code clarity by making parameter names explicit at the call site.
However, there's a typo in the comment: "defualt" should be "default".
-const image = generateBasicMod({mod, rank: 3}); // You can set rank to whatever rank you want by defualt it's 0 +const image = generateBasicMod({mod, rank: 3}); // You can set rank to whatever rank you want by default it's 0src/utils.ts (2)
111-115: Consider adding JSDoc to document parameter reorderingThe
modDescriptionfunction parameters have been reordered and defaults added, which is a breaking change to the function signature.Consider adding JSDoc to clearly document the new parameter order:
+/** + * Generates a formatted description for a mod based on rank, description, and level stats + * @param rank The rank of the mod (defaults to 0) + * @param description Optional description text + * @param levelStats Optional level statistics + * @returns Formatted description string or undefined + */ export const modDescription = ( rank: number = 0, description?: string | undefined, levelStats?: LevelStat[] | undefined ): string | undefined => {
194-198: Add error handling for malformed uniqueNamesThe
setHeaderfunction assumes a specific format for uniqueNames, but doesn't handle potential errors.Consider adding error handling for uniqueNames that don't follow the expected format:
export const setHeader = async (uniqueName: string) => { const parts = uniqueName.split('/'); + if (parts.length < 2) { + throw new Error(`Invalid uniqueName format: ${uniqueName}`); + } const name = parts.reverse()[1]; return fetchModPiece(`${name}Header.png`); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
assets/readme/Augur Message.pngis excluded by!**/*.png
📒 Files selected for processing (6)
README.md(2 hunks)src/data.ts(1 hunks)src/drawers.ts(6 hunks)src/generator.ts(4 hunks)src/utils.ts(3 hunks)tests/generator.spec.ts(1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
src/generator.ts (2)
src/utils.ts (3)
CanvasOutput(166-170)setHeader(194-198)exportCanvas(172-192)src/drawers.ts (2)
horizontalPad(8-8)drawHeader(27-54)
tests/generator.spec.ts (1)
src/utils.ts (1)
Format(164-164)
🔇 Additional comments (21)
src/data.ts (2)
1-3: Type definition looks goodThe
UniquenameTypetype definition provides a clear structure for the mapping objects that follow. Using a custom type enhances code readability and maintainability.
5-11: Properly structured mapping for mod raritiesGood organization of mod rarity mapping with clear key-value pairs. This modular approach of moving constants to a dedicated data file improves code organization.
README.md (1)
7-7: Good example additionAdding the Augur Message example image enriches the documentation by showing a mod set example, which aligns with the new feature being implemented.
tests/generator.spec.ts (2)
24-24: Good test coverage for mod setsAdding a mod set example (
WarframeAugurMessageMod) to the test suite ensures the new feature is properly tested.
39-39: Updated function call aligns with new interfaceThe function call has been properly updated to use the new object parameter structure, which aligns with the changes in the generator interface.
src/generator.ts (6)
4-6: Improved imports organizationThe imports have been reorganized to better group related functionality. Good practice to include
horizontalPadfrom 'drawers.js' and add the import formodRarityMapfrom the new data file.
8-14: Well-structured interface for propsThe new
GenerateModPropsinterface provides a clear structure for the parameters, making the function more maintainable and the API more consistent. The optional parameters are appropriately marked.
24-24: Documentation and function signature updatedThe function documentation and signature have been updated to reflect the new interface. The destructuring of props makes the code cleaner.
Also applies to: 30-30, 33-33, 37-38
65-72: Improved code organization with variable extractionExtracting
topFrameHeightinto a variable improves readability. The consistent use ofhorizontalPadalso fixes a naming inconsistency.
74-84: New support for mod setsThe implementation for mod sets looks good. It checks if
mod.modSetexists and renders the appropriate header with the correct tint based on the tier.
107-107: Improved default handling for output parameterUsing the nullish coalescing operator
??to provide a default value for the output parameter is a good practice. This ensures a consistent default without overriding explicitundefinedvalues.src/drawers.ts (7)
8-8: Fixed variable name typoThe variable name has been correctly changed from "horizantalPad" to "horizontalPad" for consistency and accuracy.
27-54: Good implementation of the new drawHeader functionThe new
drawHeaderfunction properly implements image tinting based on tier color. The brightness calculation and weighting approach provides a good balance between the original image and the tint color.
155-155: Interface update supports mod setsThe addition of the optional
setBonusproperty to theBackgroundPropsinterface properly supports the new mod set functionality.
201-201: Added strokeStyle for visual consistencySetting the stroke style to match the text color ensures visual consistency when drawing set bonus rectangles.
210-210: Updated modDescription function callThe function call has been updated to match the new parameter order in utils.ts.
227-257: Good implementation of mod set visualizationThe code properly implements the visualization of mod sets with:
- Rectangle indicators for each set piece
- Filled rectangles based on the setBonus value
- Display of the active set bonus stat
This provides clear visual feedback about set completion status and benefits.
174-178: Fixed thumbnail positioning with new variable nameThe thumbnail positioning and dimensions have been updated to use the corrected
horizontalPadvariable, maintaining consistent padding.src/utils.ts (3)
8-8: Good refactoring of constantsMoving
modRarityMapandtierColorto a dedicated data file improves code organization by centralizing game-specific data.
200-205: Good implementation of hexToRgb utilityThe
hexToRgbfunction properly handles hex color conversion with a fallback for invalid formats.
183-187: Improved default handling in exportCanvasThe changes ensure that default values are used when quality or config parameters are not provided, preventing potential errors.
What did you fix?
Add support for creating set mods
Reproduction steps
Evidence/screenshot/link to line
Considerations
Summary by CodeRabbit
Documentation
New Features
Bug Fixes
Refactor