From 24476721af51b7f954fa805a120b2869b5e72f51 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Mon, 27 Nov 2023 21:43:48 +0000 Subject: [PATCH] rev roundend shows converted count (#21854) * add ConvertedCount field to role * make objectives roundend title logic reusable * change rev system + use GetTitle --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../Rules/RevolutionaryRuleSystem.cs | 32 ++++++------ Content.Server/Objectives/ObjectivesSystem.cs | 50 +++++++++++-------- .../Roles/RevolutionaryRoleComponent.cs | 6 ++- .../game-presets/preset-revolutionary.ftl | 16 +++--- 4 files changed, 59 insertions(+), 45 deletions(-) diff --git a/Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs b/Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs index 13369ff8d0..2759e93118 100644 --- a/Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs @@ -7,6 +7,7 @@ using Content.Server.GameTicking.Rules.Components; using Content.Server.Mind; using Content.Server.NPC.Components; using Content.Server.NPC.Systems; +using Content.Server.Objectives; using Content.Server.Popups; using Content.Server.Revolutionary.Components; using Content.Server.Roles; @@ -42,6 +43,7 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem(player)?.ConvertedCount ?? 0; + ev.AddLine(Loc.GetString("rev-headrev-player", ("title", title), ("count", count))); + + // TODO: someone suggested listing all alive? revs maybe implement at some point } - break; } } @@ -208,6 +205,9 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem(ev.User.Value, out var headrev)) + headrev.ConvertedCount++; } if (mindId == default || !_role.MindHasRole(mindId)) diff --git a/Content.Server/Objectives/ObjectivesSystem.cs b/Content.Server/Objectives/ObjectivesSystem.cs index 511558216d..bf5fe1d4d4 100644 --- a/Content.Server/Objectives/ObjectivesSystem.cs +++ b/Content.Server/Objectives/ObjectivesSystem.cs @@ -110,26 +110,9 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem if (!TryComp(mindId, out MindComponent? mind)) continue; - var name = mind.CharacterName; - _mind.TryGetSession(mindId, out var session); - var username = session?.Name; - - string title; - if (username != null) - { - if (name != null) - title = Loc.GetString("objectives-player-user-named", ("user", username), ("name", name)); - else - title = Loc.GetString("objectives-player-user", ("user", username)); - } - else - { - // nothing to identify the player by, just give up - if (name == null) - continue; - - title = Loc.GetString("objectives-player-named", ("name", name)); - } + var title = GetTitle(mindId, mind); + if (title == null) + continue; result += "\n"; @@ -230,6 +213,33 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem return originalEntityInCustody || (TryComp(mind.OwnedEntity, out var cuffed) && cuffed.CuffedHandCount > 0 && _emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value)); } + + /// + /// Get the title for a player's mind used in round end. + /// + public string? GetTitle(EntityUid mindId, MindComponent? mind = null) + { + if (!Resolve(mindId, ref mind)) + return null; + + var name = mind.CharacterName; + _mind.TryGetSession(mindId, out var session); + var username = session?.Name; + + if (username != null) + { + if (name != null) + return Loc.GetString("objectives-player-user-named", ("user", username), ("name", name)); + + return Loc.GetString("objectives-player-user", ("user", username)); + } + + // nothing to identify the player by, just give up + if (name == null) + return null; + + return Loc.GetString("objectives-player-named", ("name", name)); + } } /// diff --git a/Content.Server/Roles/RevolutionaryRoleComponent.cs b/Content.Server/Roles/RevolutionaryRoleComponent.cs index fa06cc3191..821364c738 100644 --- a/Content.Server/Roles/RevolutionaryRoleComponent.cs +++ b/Content.Server/Roles/RevolutionaryRoleComponent.cs @@ -8,5 +8,9 @@ namespace Content.Server.Roles; [RegisterComponent] public sealed partial class RevolutionaryRoleComponent : AntagonistRoleComponent { - + /// + /// For headrevs, how many people you have converted. + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public uint ConvertedCount = 0; } diff --git a/Resources/Locale/en-US/game-ticking/game-presets/preset-revolutionary.ftl b/Resources/Locale/en-US/game-ticking/game-presets/preset-revolutionary.ftl index c6e925d0c4..ba2e3e554a 100644 --- a/Resources/Locale/en-US/game-ticking/game-presets/preset-revolutionary.ftl +++ b/Resources/Locale/en-US/game-ticking/game-presets/preset-revolutionary.ftl @@ -14,14 +14,6 @@ head-rev-briefing = Use flashes to convert people to your cause. Kill all heads to take over the station. -head-rev-initial-name = [color=#5e9cff]{$name}[/color] was one of the Head Revolutionaries. -head-rev-initial-name-user = [color=#5e9cff]{$name}[/color] ([color=gray]{$username}[/color]) was one of the Head Revolutionaries. - -head-rev-initial-count = {$initialCount -> - [one] There was one Head Revolutionary: - *[other] There were {$initialCount} Head Revolutionaries: -} - head-rev-break-mindshield = The Mindshield was destroyed! ## Rev @@ -58,4 +50,12 @@ rev-stalemate = All of the Head Revs and Command died. It's a draw. rev-reverse-stalemate = Both Command and Head Revs survived. +rev-headrev-count = {$initialCount -> + [one] There was one Head Revolutionary: + *[other] There were {$initialCount} Head Revolutionaries: +} +rev-headrev-player = {$title} converted {$count} {$count -> + [one] person + *[other] people +}. -- 2.51.2