Skip to content

Commit

Permalink
Role-ban check for antag roles (#2050)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirus59 authored Oct 11, 2024
1 parent f1b2814 commit 4783886
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,14 @@ public void RefreshAntags()
selector.Select(Profile?.AntagPreferences.Contains(antag.ID) == true ? 0 : 1);

var requirements = _entManager.System<SharedRoleSystem>().GetAntagRequirement(antag);
if (!_requirements.CheckRoleRequirements(requirements, (HumanoidCharacterProfile?)_preferencesManager.Preferences?.SelectedCharacter, out var reason))
// SS220 Add role-ban check begin
if (_requirements.IsRoleBaned(antag.ID, out var banReason))
{
selector.LockRequirements(banReason);
Profile = Profile?.WithAntagPreference(antag.ID, false);
SetDirty();
} // SS220 Add role-ban check end
else if (!_requirements.CheckRoleRequirements(requirements, (HumanoidCharacterProfile?)_preferencesManager.Preferences?.SelectedCharacter, out var reason)) // SS220 change 'if' -> 'else if'
{
selector.LockRequirements(reason);
Profile = Profile?.WithAntagPreference(antag.ID, false);
Expand Down
14 changes: 14 additions & 0 deletions Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,18 @@ public IReadOnlyDictionary<string, TimeSpan> GetPlayTimes(ICommonSession session

return _roles;
}

// SS220 Add role-ban check begin
public bool IsRoleBaned(string role, [NotNullWhen(true)] out FormattedMessage? reason)
{
if (_roleBans.Contains($"Job:{role}"))
{
reason = FormattedMessage.FromUnformatted(Loc.GetString("role-ban"));
return true;
}

reason = null;
return false;
}
// SS220 Add role-ban check end
}

0 comments on commit 4783886

Please sign in to comment.