feat: rerolling rivens #806
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "riven"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Walkthrough
This pull request introduces changes across multiple files to enhance the functionality of a mod reroll system in an application. The modifications involve updating the
warframe-public-export-plusdependency to version0.5.24in thepackage.jsonfile.The primary focus is on the
rerollRandomModControllerin the API controllers, which now implements an asynchronous approach to handling mod rerolls. The changes include the introduction of several new types and interfaces to support the reroll process, the addition of arandomiseStatsfunction, and the implementation of detailed logic for managing inventory upgrades.Complementary updates were made to the inventory model, specifically changing the
upgradesSchematype and adding aPendingRerollFingerprintfield. Additionally, modifications to theIInventoryDatabaseinterface were made to update property types and enhance type safety, aligning with MongoDB object representations. ThegetInventoryfunction in the inventory service was also updated to allow for an optional projection parameter, enhancing data retrieval flexibility. These modifications reflect a comprehensive refinement of the mod reroll mechanism and its underlying data structures.Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
❤️ Share
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.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)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.Other keywords and placeholders
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed.@coderabbitai summaryto generate the high-level summary at a specific location in the PR description.@coderabbitaianywhere in the PR title to generate the title automatically.Documentation and Community
Actionable comments posted: 5
🧹 Nitpick comments (2)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
f1c3dcbefcand29a9fe5716.⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json📒 Files selected for processing (4)
package.json(1 hunks)src/controllers/api/rerollRandomModController.ts(1 hunks)src/models/inventoryModels/inventoryModel.ts(1 hunks)src/types/inventoryTypes/inventoryTypes.ts(1 hunks)✅ Files skipped from review due to trivial changes (1)
🔇 Additional comments (2)
⚠️ Potential issue
Handle potential null references when accessing inventory upgrades.
Similar to the previous case, the code uses the null assertion operator
!without checking if the upgrade exists. This may lead to runtime errors if the upgrade is not found.Apply this diff to add null checks:
📝 Committable suggestion
⚠️ Potential issue
Prevent potential infinite loops when selecting curses.
Similarly, if none of the
meta.upgradeEntrieshavecanBeCurseset totrue, thewhileloop will result in an infinite loop. Ensure that there is at least one entry that can be a curse before entering the loop.Apply this diff to check for curseable entries:
📝 Committable suggestion
⚠️ Potential issue
Prevent potential infinite loops when selecting buffs.
If none of the
meta.upgradeEntrieshavecanBeBuffset totrue, thewhileloop will result in an infinite loop. To prevent this, ensure that there is at least one entry that can be a buff before entering the loop.Apply this diff to check for buffable entries:
📝 Committable suggestion
⚠️ Potential issue
Handle potential null references when accessing inventory upgrades.
Currently, the code uses the null assertion operator
!when accessing the upgrade in the inventory without checking if it exists. If the upgrade is not found, this will cause a runtime error. It's important to add a null check to handle cases where the upgrade may not exist.Apply this diff to add null checks:
@ -7,0 +49,4 @@upgrade.PendingRerollFingerprint = undefined;await inventory.save();res.send(upgrade.UpgradeFingerprint);}⚠️ Potential issue
Check for undefined
PendingRerollFingerprintbefore committing reroll.When
CommitRerollistrue, the code assignsupgrade.PendingRerollFingerprinttoupgrade.UpgradeFingerprintwithout verifying ifPendingRerollFingerprintexists. This could result inupgrade.UpgradeFingerprintbeing set toundefined.Apply this diff to ensure
PendingRerollFingerprintis defined:📝 Committable suggestion
Actionable comments posted: 1
♻️ Duplicate comments (4)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
29a9fe5716andb6cb000078.📒 Files selected for processing (1)
src/controllers/api/rerollRandomModController.ts(1 hunks)🔇 Additional comments (1)
@ -10,0 +58,4 @@fingerprint.buffs = [];const numBuffs = 2 + Math.trunc(Math.random() * 2); // 2 or 3const buffEntries = meta.upgradeEntries!.filter(x => x.canBeBuff);for (let i = 0; i != numBuffs; ++i) {⚠️ Potential issue
Check for undefined
metawhen accessingExportUpgrades[randomModType].It's possible that
randomModTypeis not a key inExportUpgrades, resulting inmetabeingundefined. Accessingmeta.upgradeEntrieswould then cause a runtime error. It's important to check ifmetaexists before proceeding.Apply this diff to add a null check:
📝 Committable suggestion
What's the error message?
Actionable comments posted: 5
🧹 Nitpick comments (1)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
b6cb000078and65f1fe28c1.📒 Files selected for processing (1)
src/controllers/api/rerollRandomModController.ts(1 hunks)@ -7,0 +18,4 @@addMiscItems(inventory, [{ItemType: "/Lotus/Types/Items/MiscItems/Kuva",ItemCount: kuvaCost * -1⚠️ Potential issue
Add validation for rerolls count and kuva cost calculation.
The current implementation could lead to NaN values if
fingerprint.rerollsis undefined, causing inventory validation errors. This matches the reported error in the PR comments.Apply this diff to add proper validation:
📝 Committable suggestion
@ -7,0 +24,4 @@fingerprint.rerolls++;upgrade.UpgradeFingerprint = JSON.stringify(fingerprint);⚠️ Potential issue
Add kuva balance validation before deducting cost.
The code attempts to deduct kuva without checking if the player has enough, which could lead to negative balances or validation errors.
Apply this diff to add balance validation:
📝 Committable suggestion
@ -7,0 +30,4 @@await inventory.save();res.json({⚠️ Potential issue
Validate upgrade.ItemType before randomizing stats.
The code passes
upgrade.ItemTypetorandomiseStatswithout validation, which could cause runtime errors if the item type is invalid or not found inExportUpgrades.Apply this diff to add validation:
📝 Committable suggestion
@ -10,0 +66,4 @@}fingerprint.curses = [];if (Math.random() < 0.5) {⚠️ Potential issue
Prevent duplicate buff stats and add value range validation.
The current implementation could potentially select the same buff multiple times and generates arbitrary stat values without proper bounds checking.
Apply this diff to improve stat generation:
@ -10,0 +73,4 @@};type RerollRandomModRequest = LetsGoGamblingRequest | AwDangitRequest;⚠️ Potential issue
Apply the same value range validation to curse stats.
Similar to buffs, curse stats should also have proper value range validation.
Apply this diff to improve curse stat generation:
📝 Committable suggestion
Actionable comments posted: 1
♻️ Duplicate comments (5)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
65f1fe28c1and8dedba522f.📒 Files selected for processing (2)
src/controllers/api/rerollRandomModController.ts(1 hunks)src/services/inventoryService.ts(1 hunks)🔇 Additional comments (3)
@ -7,0 +11,4 @@if ("ItemIds" in request) {const inventory = await getInventory(accountId, "Upgrades MiscItems");const upgrade = inventory.Upgrades.id(request.ItemIds[0])!;const fingerprint = JSON.parse(upgrade.UpgradeFingerprint!) as IUnveiledRivenFingerprint;⚠️ Potential issue
Add error handling for JSON parsing.
The
getJSONfromStringcall could throw if the request body is invalid JSON.@ -7,0 +11,4 @@if ("ItemIds" in request) {const inventory = await getInventory(accountId, "Upgrades MiscItems");const upgrade = inventory.Upgrades.id(request.ItemIds[0])!;const fingerprint = JSON.parse(upgrade.UpgradeFingerprint!) as IUnveiledRivenFingerprint;CAN YOU SHUT THE FUCK UP ALREADY
@ -7,0 +11,4 @@if ("ItemIds" in request) {const inventory = await getInventory(accountId, "Upgrades MiscItems");const upgrade = inventory.Upgrades.id(request.ItemIds[0])!;const fingerprint = JSON.parse(upgrade.UpgradeFingerprint!) as IUnveiledRivenFingerprint;@Sainan I apologize for any frustration caused. I'll be more selective with my review comments going forward. Would you like me to adjust my review settings or focus on specific types of issues only?
✏️ Learnings added