Skip to content
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

[Port] Respawn Button / Кнопка Респавна #56

Merged
merged 8 commits into from
Sep 21, 2024
Merged

Conversation

Spatison
Copy link
Member

Описание PR

Порт кнопки респавна в меню призрака.


Изменения

🆑 Spatison

  • add: Added respawn button / Добавлена кнопка респавна

Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Warning

Rate limit exceeded

@Spatison has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 14 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 1f84c4b and 980e442.

Walkthrough

The pull request introduces new localization files for the ghost respawn feature in both English and Russian, including strings that inform players about respawn mechanics, such as time remaining, maximum player limits, and rules regarding knowledge transfer from previous characters. Additionally, it removes certain localization strings in the Russian GUI file, indicating a potential simplification of the user interface related to ghost respawning. A new dependency is added to the game logic to enhance tracking of ghost return attempts.

Changes

File Path Change Summary
Resources/Locale/en-US/_white/ghost/ghost-respawn.ftl Added localization strings for ghost respawn mechanics in English.
Resources/Locale/ru-RU/_white/ghost/ghost-respawn.ftl Added localization strings for ghost respawn mechanics in Russian.
Resources/Locale/ru-RU/ghost/ghost-gui.ftl Removed localization strings related to ghost respawn functionality in Russian.
Content.Server/GameTicking/GameTicker.GamePreset.cs Added logic to track death time for users attempting to return as ghosts, including a new dependency on GhostReturnToRoundSystem.

Assessment against linked issues

Objective Addressed Explanation
None identified No linked issues provided for assessment.

Possibly related PRs

  • [Port] Custom Ghost's #21: The changes in this PR introduce custom ghost entities, which may interact with the ghost respawn feature by providing visual representations and behaviors for ghosts, enhancing the overall ghost mechanics in the game.
  • [Fix] Ru Loc / Локализация #51: This PR focuses on localization improvements, including the addition of new translations that could potentially include terms related to ghost respawning, thereby enhancing the user experience for players interacting with the ghost respawn feature.

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 generate interesting stats about this repository and render them as a table.
    -- @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (1)
Content.Server/GameTicking/GameTicker.GamePreset.cs (1)

25-25: Dependency injection looks good, but improve the comment.

The dependency injection for GhostReturnToRoundSystem is properly set up. However, the "WD EDIT" comment is unclear. Consider using a more descriptive comment to convey the purpose of this change.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f2424be and ec107d5.

Files selected for processing (13)
  • Content.Client/Ghost/GhostSystem.cs (1 hunks)
  • Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs (3 hunks)
  • Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml (1 hunks)
  • Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs (2 hunks)
  • Content.Server/GameTicking/GameTicker.GamePreset.cs (3 hunks)
  • Content.Server/GameTicking/GameTicker.Spawning.cs (3 hunks)
  • Content.Server/_White/Ghost/GhostReturnToRoundSystem.cs (1 hunks)
  • Content.Shared/Ghost/SharedGhostSystem.cs (1 hunks)
  • Content.Shared/_White/CVars.cs (2 hunks)
  • Resources/Locale/en-US/_white/ghost/ghost-gui.ftl (1 hunks)
  • Resources/Locale/en-US/_white/ghost/ghost-respawn.ftl (1 hunks)
  • Resources/Locale/ru-RU/_white/ghost/ghost-gui.ftl (1 hunks)
  • Resources/Locale/ru-RU/_white/ghost/ghost-respawn.ftl (1 hunks)
Files skipped from review due to trivial changes (2)
  • Resources/Locale/en-US/_white/ghost/ghost-gui.ftl
  • Resources/Locale/ru-RU/_white/ghost/ghost-gui.ftl
Additional comments not posted (29)
Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml (1)

8-8: LGTM!

The addition of the "ReturnToRound" button aligns with the PR objectives to enhance the user experience by providing players with a straightforward option to respawn after their character has died. The button is correctly placed within the BoxContainer alongside other navigation buttons, and the localization syntax is used appropriately to ensure the button text can be translated.

Resources/Locale/ru-RU/_white/ghost/ghost-respawn.ftl (7)

1-4: LGTM!

The code segment correctly handles the pluralization of the word "minute" based on the value of $time for the Russian language.


5-5: LGTM!

The code segment clearly conveys the message that the respawn function is not available when the number of players on the server exceeds a certain limit.


6-7: LGTM!

The code segment effectively communicates the respawn rules, emphasizing the obligation not to transfer knowledge from the previous character to the new one and mentioning the penalty for violating this rule.


8-8: LGTM!

The code segment handles the scenario when the time of death is missing and sets a default value.


9-9: LGTM!

The code segment provides clear instructions to the player to change the character in the character settings when trying to respawn as the same character.


11-14: LGTM!

The code segment correctly handles the different verb forms for logging when a player enters or attempts to enter the round after returning to the lobby with a similar name.


15-15: LGTM!

The code segment clearly logs when a player returns to the lobby.

Resources/Locale/en-US/_white/ghost/ghost-respawn.ftl (8)

1-3: LGTM!

The localization string correctly uses a selector to display the appropriate plural form of "minute" based on the value of $time. The Fluent syntax is followed accurately.


4-4: LGTM!

The localization string correctly conveys the message that the respawn function is not available when the number of players on the server exceeds a certain limit. The $players variable is used appropriately to display the number of players.


5-5: LGTM!

The localization string correctly defines the title for the window displaying the rules for returning to the round.


6-6: LGTM!

The localization string effectively communicates the rules and consequences of using the respawn feature. The use of color tags helps highlight important parts of the message, such as the agreement not to transfer knowledge and the potential ban for violating the rules. The Fluent syntax is followed correctly.


7-7: LGTM!

The localization string correctly informs the user that when there is no time of death available, a standard value is set. The message is clear and concise.


8-8: LGTM!

The localization string correctly informs the user that they cannot enter the round for the same character after respawning and suggests changing the character in the settings. The message is clear and provides a helpful suggestion to the user.


10-13: LGTM!

The localization string correctly logs a message when a player joins or tries to join the round after respawning with a similar name. It uses a selector to display the appropriate verb form based on the value of $try. The placeholders for the player's name, old name, and new name are used correctly. The Fluent syntax is followed accurately.


14-14: LGTM!

The localization string correctly logs a message when a user returns to the lobby. The placeholder for the user's name ($userName) is used appropriately. The message is clear and concise.

Content.Shared/_White/CVars.cs (1)

35-41: LGTM!

The new configuration variables for ghost respawn functionality are implemented correctly:

  • Variable names are clear and descriptive.
  • Default values are reasonable.
  • Server-only access is appropriate.
  • Code follows the existing style and structure of the class.

The changes align with the PR objective of adding a respawn button in the ghost menu.

Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs (2)

17-17: LGTM!

The new event ReturnToRoundPressed is declared correctly in the GhostGui class. The event is public, allowing it to be subscribed from outside the class.


30-30: LGTM!

The ReturnToRound button is correctly subscribed to the ReturnToRoundPressed event in the constructor of the GhostGui class. The event subscription is consistent with the other button event subscriptions in the constructor.

Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs (3)

123-123: LGTM!

The code change correctly subscribes the ReturnToRound method to handle the new ReturnToRoundPressed event of the Gui object. This is consistent with the event subscription pattern followed in the LoadGui method.


137-137: LGTM!

The code change correctly unsubscribes the ReturnToRound method from the ReturnToRoundPressed event of the Gui object. This is consistent with the event unsubscription pattern followed in the UnloadGui method and ensures proper cleanup when the GUI is unloaded.


147-150: Verify the ReturnToRound method implementation.

The ReturnToRound method is correctly implemented in the GhostUIController class. It follows the pattern of other similar methods and safely calls the ReturnToRound method on the _system object using the null-conditional operator.

Please ensure that the ReturnToRound method is properly implemented in the GhostSystem class to handle the respawn logic as per the PR objectives.

Run the following script to verify the ReturnToRound method implementation:

Verification successful

The ReturnToRound method is correctly implemented in the GhostSystem class.

The method raises a network event GhostReturnToRoundRequest, which aligns with the expected behavior for handling respawn logic. The implementation is consistent with the design pattern used for similar methods. No issues were found with the current implementation.

  • GhostSystem.cs: The ReturnToRound method raises the GhostReturnToRoundRequest network event.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `ReturnToRound` method in the `GhostSystem` class.

# Test: Search for the method declaration. Expect: The method should exist and contain the respawn logic.
rg --type cs -A 10 $'void ReturnToRound\(\)'

Length of output: 1418

Content.Server/_White/Ghost/GhostReturnToRoundSystem.cs (3)

24-28: LGTM!

The Initialize method correctly subscribes to the required events.


30-102: LGTM!

The OnGhostReturnToRoundRequest method correctly handles the ghost respawn request based on the provided conditions. It uses the required dependencies to get the configuration values, send chat messages, log events, and respawn the player. The method also correctly updates the DeathTime dictionary.


104-107: LGTM!

The ResetDeathTimes method correctly clears the DeathTime dictionary when the round restarts.

Content.Shared/Ghost/SharedGhostSystem.cs (1)

153-154: Clarify the purpose and usage of the GhostReturnToRoundRequest class.

The addition of the GhostReturnToRoundRequest class looks good. It appears to represent a network request for a ghost entity to return to the game round, based on the class name and the Serializable and NetSerializable attributes.

However, please provide more information about the specific purpose and usage of this class. Consider adding XML documentation comments to describe the class and its intended behavior.

Also, the WD EDIT comments suggest that this change is specific to a particular project or fork. Is this change intended to be included in the main codebase? If so, please remove the WD EDIT comments to avoid confusion.

Content.Client/Ghost/GhostSystem.cs (1)

185-189: LGTM!

The ReturnToRound method is implemented correctly and follows the existing pattern of raising network events in this class. The method name clearly conveys its purpose, and the public access modifier seems appropriate if it needs to be called from outside this class.

Content.Server/GameTicking/GameTicker.Spawning.cs (2)

161-216: Respawn character name check added. LGTM!

The added code block enhances the respawn system by checking if the player is attempting to respawn with the same or a similar character name. This helps prevent metagaming and confusion.

The check works as follows:

  1. Query all mind components with the same user ID.
  2. If an exact match is found, prevent the respawn and send a message to the player.
  3. If a high similarity (>= 85%) is found, send an admin alert and prevent the respawn.
  4. If a moderate similarity (>= 50%) is found, send an admin alert.

The code changes are well-structured and follow the existing coding style.


412-427: String similarity calculation function added. Looks good!

The CalculateStringSimilarity function calculates the similarity between two strings by comparing each character at the same position and counting the number of matching characters. The similarity percentage is then calculated as (matchingCharacters / maxLength) * 100.

This simple character-by-character comparison serves the purpose of detecting most similar names. However, if more advanced similarity detection is needed in the future, consider using more sophisticated algorithms like Levenshtein distance or Jaro-Winkler distance.

Content.Server/GameTicking/GameTicker.GamePreset.cs Outdated Show resolved Hide resolved
@Remuchi
Copy link
Collaborator

Remuchi commented Sep 13, 2024

ошибки линтера актуальные

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Collaborator

@Remuchi Remuchi left a comment

Choose a reason for hiding this comment

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

А еще merge conflict.
Переводы я не трогала, но там тоже ужас.

Content.Server/_White/Ghost/GhostReturnToRoundSystem.cs Outdated Show resolved Hide resolved
Content.Server/_White/Ghost/GhostReturnToRoundSystem.cs Outdated Show resolved Hide resolved
Content.Server/_White/Ghost/GhostReturnToRoundSystem.cs Outdated Show resolved Hide resolved
Content.Server/_White/Ghost/GhostReturnToRoundSystem.cs Outdated Show resolved Hide resolved
Content.Server/_White/Ghost/GhostReturnToRoundSystem.cs Outdated Show resolved Hide resolved
Content.Server/GameTicking/GameTicker.Spawning.cs Outdated Show resolved Hide resolved
@Remuchi Remuchi merged commit 4e0cb0b into master Sep 21, 2024
11 checks passed
@Remuchi Remuchi deleted the ghost-respawn branch September 21, 2024 10:20
riddleridou added a commit that referenced this pull request Sep 21, 2024
VMSolidus added a commit to Simple-Station/Einstein-Engines that referenced this pull request Oct 4, 2024
# Description

This ports WWhiteDreamProject/wwdpublic#56
The new Respawn System is one that allows players to return themselves
to the lobby after a configurable delay, while also requiring that they
respawn as a different character upon returning.

# TODO

- [x] Finish the usual cleanup

# Changelog

:cl:
- add: Ported a Respawn System. This system allows players to return
themselves to the lobby, while also requiring that if they re-enter the
round, that they must do so on a different character.

---------

Co-authored-by: Spatison <[email protected]>
Remuchi added a commit that referenced this pull request Oct 19, 2024
Remuchi pushed a commit that referenced this pull request Oct 19, 2024
# Description

This ports #56
The new Respawn System is one that allows players to return themselves
to the lobby after a configurable delay, while also requiring that they
respawn as a different character upon returning.

# TODO

- [x] Finish the usual cleanup

# Changelog

:cl:
- add: Ported a Respawn System. This system allows players to return
themselves to the lobby, while also requiring that if they re-enter the
round, that they must do so on a different character.

---------

Co-authored-by: Spatison <[email protected]>
# Conflicts:
#	Resources/Locale/ru-RU/ghost/ghost-gui.ftl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants