This repository was archived by the owner on Aug 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
[DRAFT] Вайоленс, наконец-то (завтра) #182
Open
RavMorgan
wants to merge
14
commits into
master
Choose a base branch
from
violence
base: master
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
14 commits
Select commit
Hold shift + click to select a range
e35d4be
База, основа, фундамент, генштаб
f6b4a5e
Merge remote-tracking branch 'origin/master' into violence
9f9e25c
unclean gamemode
kurokoTurbo c92c142
simple TODO and cleanup left
kurokoTurbo c56db1b
coding
kurokoTurbo fe70ad9
StartRound, EndRound. Getting there
kurokoTurbo cf6d480
yaica commit
kurokoTurbo 372bf42
small things make the game
kurokoTurbo ce999b8
насилие гейминг
kurokoTurbo 06ac5d0
saving equip between rounds
kurokoTurbo f7696e7
buying equipment
kurokoTurbo 2ff3c87
SwitchTeamCommand done, some cleanup
kurokoTurbo 6db6ed4
fix retardation
kurokoTurbo 0e76d37
debug map + prototypes
kurokoTurbo 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
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
14 changes: 14 additions & 0 deletions
14
Content.Server/_Miracle/Components/ViolenceParticipatorComponent.cs
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,14 @@ | ||
| namespace Content.Server._Miracle.Components; | ||
|
|
||
| /// <summary> | ||
| /// This is used for... | ||
| /// </summary> | ||
| [RegisterComponent] | ||
| public sealed partial class ViolenceParticipatorComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// List of factions in this gamemode. | ||
| /// </summary> | ||
| [DataField] | ||
| public EntityUid? MatchUid { get; private set; } = null; | ||
| } |
46 changes: 46 additions & 0 deletions
46
Content.Server/_Miracle/GameRules/Violence/SwitchTeamCommand.cs
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,46 @@ | ||
| using Content.Server.Administration; | ||
| using Content.Shared.Administration; | ||
| using Robust.Shared.Console; | ||
| using Robust.Shared.Network; | ||
|
|
||
| // TODO: test permissions | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Ensure proper permissions are tested for the Would you like me to help implement the permission checks or create a test case for this command? |
||
| namespace Content.Server._Miracle.GameRules.Violence; | ||
|
|
||
| [AdminCommand(AdminFlags.Admin)] | ||
| internal class SwitchTeamCommand : IConsoleCommand | ||
| { | ||
| [Dependency] private readonly IPlayerLocator _locator = default!; | ||
|
|
||
| public string Command => "switchteam"; | ||
| public string Description => "Switches the player's team."; | ||
| public string Help => "switchteam <playerId> <newTeamId>"; | ||
|
|
||
| public async void Execute(IConsoleShell shell, string argStr, string[] args) | ||
| { | ||
| if (args.Length != 2) | ||
| { | ||
| shell.WriteLine("Expected exactly 2 arguments."); | ||
| return; | ||
| } | ||
|
|
||
| var target = args[0]; | ||
| var located = await _locator.LookupIdByNameOrIdAsync(target); | ||
| var player = shell.Player; | ||
|
|
||
| if (player == null) | ||
| { | ||
| shell.WriteLine("Player not found."); | ||
| return; | ||
| } | ||
|
|
||
| if (!ushort.TryParse(args[1], out var newTeamId)) | ||
| { | ||
| shell.WriteLine($"Invalid team ID: {args[1]}"); | ||
| return; | ||
| } | ||
|
|
||
| var violenceRuleSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ViolenceRuleSystem>(); | ||
| violenceRuleSystem.SwitchTeam(player.UserId, newTeamId); | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Refactor to avoid code duplication in team point management methods.
The methods
AdjustTeamPointValue,SetTeamPointValue, andGetTeamPointValueshare similar logic with their player counterparts. Consider abstracting common functionalities into helper methods to reduce duplication and improve maintainability.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.
Which counterparts?
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.
@rhailrake, the counterparts to the new team point management methods (
AdjustTeamPointValue,SetTeamPointValue,GetTeamPointValue) in thePointSystemclass are the methods that manage individual player points. These include:AdjustPointValue: Adds a specified point value to a player's total points.SetPointValue: Sets the total point value for a player.GetPointValue: Retrieves the total point value for a player.These methods are similar in functionality to the new team methods but operate on individual player points rather than team points. The logic for adjusting, setting, and getting points is quite similar between these sets of methods, which is why refactoring to reduce code duplication was suggested.
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.
Suggest your version then
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.
@rhailrake, here's a suggested refactor for the
PointSystemclass to reduce code duplication between the team and individual player point management methods. I've introduced helper methods to encapsulate common functionalities:This refactoring introduces three helper methods:
TryResolveComponents,UpdatePoints, andRaisePointChangeEvent, which are used in both the team and individual point management methods to handle common operations such as component resolution, point updating, and event raising. This reduces duplication and enhances maintainability.