fix: Apply Look not working with Unlock All Skins turned on #549

Merged
VampireKitten merged 2 commits from fix-skins into main 2024-10-15 07:27:59 -07:00
VampireKitten commented 2024-10-14 05:54:26 -07:00 (Migrated from github.com)

Gives the skins IDs so the game doesn't give empty customization slots. Fixes #548

Gives the skins IDs so the game doesn't give empty customization slots. Fixes #548
coderabbitai[bot] commented 2024-10-14 05:54:32 -07:00 (Migrated from github.com)

Walkthrough

The changes in the pull request focus on the inventoryController function located in the src/controllers/api/inventoryController.ts file. The primary modification involves the handling of weapon skins in the inventory response. A new variable, i, is introduced and initialized to zero. This variable is incremented within a loop that processes ExportCustoms. The $oid field of the ItemId object is updated to utilize the string representation of i, which is padded to 24 characters with leading zeros. This replaces the previous static value of "000000000000000000000000".

As a result, each weapon skin in the inventory response is assigned a unique identifier based on its order of processing. The overall structure and logic of the inventory response generation remain unchanged, with no other significant modifications to the control flow or logic of the function. Additionally, there are no alterations to the declarations of exported or public entities in this diff.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant InventoryController
    participant ExportCustoms

    User->>InventoryController: Request inventory
    InventoryController->>ExportCustoms: Process weapon skins
    loop Process each skin
        InventoryController->>InventoryController: Increment i
        InventoryController->>ItemId: Update $oid with padded i
    end
    InventoryController->>User: Return updated inventory response

Assessment against linked issues

Objective Addressed Explanation
Update handling of weapon skins in inventory response (#548)
Ensure unique identifiers for weapon skins (#548)

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9c621ee532 and df2f210966.

📒 Files selected for processing (1)
  • src/controllers/api/inventoryController.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/controllers/api/inventoryController.ts

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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • 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.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough The changes in the pull request focus on the `inventoryController` function located in the `src/controllers/api/inventoryController.ts` file. The primary modification involves the handling of weapon skins in the inventory response. A new variable, `i`, is introduced and initialized to zero. This variable is incremented within a loop that processes `ExportCustoms`. The `$oid` field of the `ItemId` object is updated to utilize the string representation of `i`, which is padded to 24 characters with leading zeros. This replaces the previous static value of `"000000000000000000000000"`. As a result, each weapon skin in the inventory response is assigned a unique identifier based on its order of processing. The overall structure and logic of the inventory response generation remain unchanged, with no other significant modifications to the control flow or logic of the function. Additionally, there are no alterations to the declarations of exported or public entities in this diff. ## Sequence Diagram(s) ```mermaid sequenceDiagram participant User participant InventoryController participant ExportCustoms User->>InventoryController: Request inventory InventoryController->>ExportCustoms: Process weapon skins loop Process each skin InventoryController->>InventoryController: Increment i InventoryController->>ItemId: Update $oid with padded i end InventoryController->>User: Return updated inventory response ``` ## Assessment against linked issues | Objective | Addressed | Explanation | |------------------------------------------------------------|-----------|----------------------------------------| | Update handling of weapon skins in inventory response (#548)| ✅ | | | Ensure unique identifiers for weapon skins (#548) | ✅ | | <!-- walkthrough_end --><!-- This is an auto-generated comment: raw summary by coderabbit.ai --> <!-- src/controllers/api/inventoryController.ts: """ ## Consolidated summary of changes The diff modifies the `inventoryController` function within the `src/controllers/api/inventoryController.ts` file, enhancing the handling of weapon skins in the inventory response. A new variable `i` is introduced and initialized to zero, which is incremented within the loop that processes `ExportCustoms`. The `$oid` field of the `ItemId` object is updated to utilize the string representation of `i`, padded to 24 characters with leading zeros, replacing the previous static value of `"000000000000000000000000"`. This change ensures that each weapon skin has a unique identifier based on its order of processing. The overall structure and logic of the inventory response generation remain unchanged, with no other significant alterations to the control flow or logic of the function. ## Alterations to the declarations of exported or public entities - No changes to the declarations of exported or public entities were made in this diff. """ --> <!-- end of auto-generated comment: raw summary by coderabbit.ai --><!-- This is an auto-generated comment: pr objectives by coderabbit.ai --> <!-- ## PR Summary The pull request titled "Fix Apply Look not working with Unlock All Skins turned on" was submitted by the user VampireKitten and is identified by the number 549. The purpose of this PR is to address an issue where the "Apply Look" feature does not function correctly when the "Unlock All Skins" option is enabled in the game. The description provided indicates that the solution involves supplying the skin IDs, which ensures that the game does not present empty customization slots. This change aims to enhance the user experience by allowing players to apply their desired looks without encountering issues related to skin availability. For further details, the pull request can be accessed at the following URL: [https://github.com/spaceninjaserver/SpaceNinjaServer/pull/549](https://github.com/spaceninjaserver/SpaceNinjaServer/pull/549). ## Objectives from Linked Issues The linked issue #548, titled "UnlockAllSkins breaks trying to apply Look from Look Links," describes a problem where enabling the "Unlock All Skins" feature disrupts the functionality of applying looks from look links. The proposed solution, as suggested by a user named Lemon in the Space Ninja Server Discord, involves modifying the "UnlockAllSkins" section in the `InventoryController.ts` file. The suggested code change includes setting the `inventoryResponse.WeaponSkins` to an empty array when `config.unlockAllSkins` is true. It then iterates through `ExportCustoms`, pushing new objects into `inventoryResponse.WeaponSkins` with appropriate `ItemId` and `ItemType` values. This adjustment aims to ensure that the application of looks is seamless and that players can utilize the "Unlock All Skins" feature without encountering errors related to skin application. --> <!-- end of auto-generated comment: pr objectives by coderabbit.ai --> --- <details> <summary>📜 Recent review details</summary> **Configuration used: .coderabbit.yaml** **Review profile: CHILL** <details> <summary>📥 Commits</summary> Files that changed from the base of the PR and between 9c621ee53283d9c4b8804e642a5f5b0632bfc794 and df2f210966167b04a8848b80d96ac46d440318f7. </details> <details> <summary>📒 Files selected for processing (1)</summary> * src/controllers/api/inventoryController.ts (1 hunks) </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * src/controllers/api/inventoryController.ts </details> </details><!-- commit_ids_reviewed_start --> <!-- 9c621ee53283d9c4b8804e642a5f5b0632bfc794 --> <!-- df2f210966167b04a8848b80d96ac46d440318f7 --> <!-- commit_ids_reviewed_end --><!-- tips_start --> --- 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? <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <details> <summary>🪧 Tips</summary> ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `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.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in 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 pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. </details> <!-- tips_end -->
coderabbitai[bot] (Migrated from github.com) reviewed 2024-10-14 05:56:45 -07:00
coderabbitai[bot] (Migrated from github.com) left a comment

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
src/controllers/api/inventoryController.ts (1)

108-113: Approve changes with minor suggestions for improvement

The changes successfully address the issue mentioned in the PR objectives by providing unique skin IDs when the "Unlock All Skins" option is enabled. This should fix the "Apply Look" functionality as intended.

A few minor suggestions for improvement:

  1. Remove the unnecessary parentheses around (i) on line 113.
  2. Use double quotes instead of single quotes for consistency with the rest of the file.

Here's the suggested modification:

- $oid: (i).toString().padStart(24, '0')
+ $oid: i.toString().padStart(24, "0")

These changes will make the code slightly cleaner and more consistent with the existing style.

🧰 Tools
🪛 GitHub Check: build (22)

[failure] 113-113:
Replace (i).toString().padStart(24,·'0' with i.toString().padStart(24,·"0"

🪛 GitHub Check: build (20)

[failure] 113-113:
Replace (i).toString().padStart(24,·'0' with i.toString().padStart(24,·"0"

🪛 GitHub Check: build (18)

[failure] 113-113:
Replace (i).toString().padStart(24,·'0' with i.toString().padStart(24,·"0"

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 07c2fbcadf and 9c621ee532.

📒 Files selected for processing (1)
  • src/controllers/api/inventoryController.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: build (22)
src/controllers/api/inventoryController.ts

[failure] 113-113:
Replace (i).toString().padStart(24,·'0' with i.toString().padStart(24,·"0"

🪛 GitHub Check: build (20)
src/controllers/api/inventoryController.ts

[failure] 113-113:
Replace (i).toString().padStart(24,·'0' with i.toString().padStart(24,·"0"

🪛 GitHub Check: build (18)
src/controllers/api/inventoryController.ts

[failure] 113-113:
Replace (i).toString().padStart(24,·'0' with i.toString().padStart(24,·"0"

**Actionable comments posted: 0** <details> <summary>🧹 Outside diff range and nitpick comments (1)</summary><blockquote> <details> <summary>src/controllers/api/inventoryController.ts (1)</summary><blockquote> `108-113`: **Approve changes with minor suggestions for improvement** The changes successfully address the issue mentioned in the PR objectives by providing unique skin IDs when the "Unlock All Skins" option is enabled. This should fix the "Apply Look" functionality as intended. A few minor suggestions for improvement: 1. Remove the unnecessary parentheses around `(i)` on line 113. 2. Use double quotes instead of single quotes for consistency with the rest of the file. Here's the suggested modification: ```diff - $oid: (i).toString().padStart(24, '0') + $oid: i.toString().padStart(24, "0") ``` These changes will make the code slightly cleaner and more consistent with the existing style. <details> <summary>🧰 Tools</summary> <details> <summary>🪛 GitHub Check: build (22)</summary><blockquote> [failure] 113-113: Replace `(i).toString().padStart(24,·'0'` with `i.toString().padStart(24,·"0"` </blockquote></details> <details> <summary>🪛 GitHub Check: build (20)</summary><blockquote> [failure] 113-113: Replace `(i).toString().padStart(24,·'0'` with `i.toString().padStart(24,·"0"` </blockquote></details> <details> <summary>🪛 GitHub Check: build (18)</summary><blockquote> [failure] 113-113: Replace `(i).toString().padStart(24,·'0'` with `i.toString().padStart(24,·"0"` </blockquote></details> </details> </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: .coderabbit.yaml** **Review profile: CHILL** <details> <summary>📥 Commits</summary> Files that changed from the base of the PR and between 07c2fbcadf3777333929fe109b8656740307aab9 and 9c621ee53283d9c4b8804e642a5f5b0632bfc794. </details> <details> <summary>📒 Files selected for processing (1)</summary> * src/controllers/api/inventoryController.ts (1 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 GitHub Check: build (22)</summary><blockquote> <details> <summary>src/controllers/api/inventoryController.ts</summary><blockquote> [failure] 113-113: Replace `(i).toString().padStart(24,·'0'` with `i.toString().padStart(24,·"0"` </blockquote></details> </blockquote></details> <details> <summary>🪛 GitHub Check: build (20)</summary><blockquote> <details> <summary>src/controllers/api/inventoryController.ts</summary><blockquote> [failure] 113-113: Replace `(i).toString().padStart(24,·'0'` with `i.toString().padStart(24,·"0"` </blockquote></details> </blockquote></details> <details> <summary>🪛 GitHub Check: build (18)</summary><blockquote> <details> <summary>src/controllers/api/inventoryController.ts</summary><blockquote> [failure] 113-113: Replace `(i).toString().padStart(24,·'0'` with `i.toString().padStart(24,·"0"` </blockquote></details> </blockquote></details> </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Sainan approved these changes 2024-10-14 06:17:53 -07:00
Sign in to join this conversation.
No description provided.