-
Notifications
You must be signed in to change notification settings - Fork 7
Implement rank catchup system | Improve Help command #35
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
Open
jmarmstrong1207
wants to merge
9
commits into
MaxWasUnavailable:feature/dedicated_rework
Choose a base branch
from
jmarmstrong1207:catchup-rank
base: feature/dedicated_rework
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b44b9a0
Add rank catchup system
jmarmstrong1207 42db5dc
Add check in case they rejoin
jmarmstrong1207 bdc24ad
Improve help command listing
jmarmstrong1207 aeca9c0
Provide cmd descriptions when calling /help
jmarmstrong1207 54d1edb
Fix verification
jmarmstrong1207 8b74699
Make catchup toggleable via config
jmarmstrong1207 1f23df9
Send usage string when doing /help <command>
jmarmstrong1207 64f92e5
Optimize Code
jmarmstrong1207 0c726e2
Merge branch 'feature/dedicated_rework' into catchup-rank
jmarmstrong1207 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using NuclearOption.Networking; | ||
| using Nuclei.Helpers; | ||
| using UnityEngine; | ||
| namespace Nuclei.Features; | ||
|
|
||
| public class RankCatchUpService | ||
| { | ||
| public static void CatchUpPlayer(Player player) | ||
| { | ||
| if (player.GetAuthData().SaveData.Faction != null) | ||
| { | ||
| return; // Means that they already joined the server. No double-dipping! | ||
| } | ||
| var currentMissionTime = Time.timeSinceLevelLoad; | ||
| var maxMissionTime = Globals.DedicatedServerManagerInstance.CurrentMissionOption.MaxTime; | ||
| var percentComplete = (currentMissionTime / maxMissionTime) * 2; | ||
|
|
||
| var rank = 0; | ||
| var allocation = 0f; | ||
|
|
||
| if (percentComplete < .20) return; | ||
| else if (percentComplete >= .80) | ||
| { | ||
| rank = 5; | ||
| allocation = 400f; | ||
| } | ||
| else if (percentComplete >= .60) | ||
| { | ||
| rank = 4; | ||
| allocation = 350f; | ||
| } | ||
| else if (percentComplete >= .40) | ||
| { | ||
| rank = 3; | ||
| allocation = 300f; | ||
| } | ||
| else if (percentComplete >= .40) | ||
| { | ||
| rank = 2; | ||
| allocation = 250f; | ||
| } | ||
| else if (percentComplete >= .20) | ||
| { | ||
| rank = 1; | ||
| allocation = 200f; | ||
| } | ||
| player.SetRank(rank, false); | ||
| player.SetAllocation(player.Allocation + allocation); | ||
| ChatService.SendPrivateChatMessage($"Late join - You have been promoted to Rank {rank} with +${allocation}m", player); | ||
| } | ||
| } |
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.
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.
Should never perform functionality in the events. Should instead subscribe to the event somewhere and trigger through that.
The event invocations should be isolated like that.
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.
Could you edit the file to show me? I'm unfamiliar with doing this myself
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.
You'd subscribe to the PlayerJoined event and run a method on that, see Nuclei.cs for an example of this.