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>
This commit is contained in:
@@ -7,6 +7,7 @@ using Content.Server.GameTicking.Rules.Components;
|
|||||||
using Content.Server.Mind;
|
using Content.Server.Mind;
|
||||||
using Content.Server.NPC.Components;
|
using Content.Server.NPC.Components;
|
||||||
using Content.Server.NPC.Systems;
|
using Content.Server.NPC.Systems;
|
||||||
|
using Content.Server.Objectives;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Revolutionary.Components;
|
using Content.Server.Revolutionary.Components;
|
||||||
using Content.Server.Roles;
|
using Content.Server.Roles;
|
||||||
@@ -42,6 +43,7 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
|
|||||||
[Dependency] private readonly MindSystem _mind = default!;
|
[Dependency] private readonly MindSystem _mind = default!;
|
||||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||||
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
||||||
|
[Dependency] private readonly ObjectivesSystem _objectives = default!;
|
||||||
[Dependency] private readonly PopupSystem _popup = default!;
|
[Dependency] private readonly PopupSystem _popup = default!;
|
||||||
[Dependency] private readonly RoleSystem _role = default!;
|
[Dependency] private readonly RoleSystem _role = default!;
|
||||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||||
@@ -101,24 +103,19 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
|
|||||||
var index = (commandLost ? 1 : 0) | (revsLost ? 2 : 0);
|
var index = (commandLost ? 1 : 0) | (revsLost ? 2 : 0);
|
||||||
ev.AddLine(Loc.GetString(Outcomes[index]));
|
ev.AddLine(Loc.GetString(Outcomes[index]));
|
||||||
|
|
||||||
ev.AddLine(Loc.GetString("head-rev-initial-count", ("initialCount", headrev.HeadRevs.Count)));
|
ev.AddLine(Loc.GetString("rev-headrev-count", ("initialCount", headrev.HeadRevs.Count)));
|
||||||
foreach (var player in headrev.HeadRevs)
|
foreach (var player in headrev.HeadRevs.Values)
|
||||||
{
|
{
|
||||||
_mind.TryGetSession(player.Value, out var session);
|
var title = _objectives.GetTitle(player);
|
||||||
var username = session?.Name;
|
if (title == null)
|
||||||
if (username != null)
|
continue;
|
||||||
{
|
|
||||||
ev.AddLine(Loc.GetString("head-rev-initial-name-user",
|
// TODO: when role entities are a thing this has to change
|
||||||
("name", player.Key),
|
var count = CompOrNull<RevolutionaryRoleComponent>(player)?.ConvertedCount ?? 0;
|
||||||
("username", username)));
|
ev.AddLine(Loc.GetString("rev-headrev-player", ("title", title), ("count", count)));
|
||||||
}
|
|
||||||
else
|
// TODO: someone suggested listing all alive? revs maybe implement at some point
|
||||||
{
|
|
||||||
ev.AddLine(Loc.GetString("head-rev-initial-name",
|
|
||||||
("name", player.Key)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,6 +205,9 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
|
|||||||
if (ev.User != null)
|
if (ev.User != null)
|
||||||
{
|
{
|
||||||
_adminLogManager.Add(LogType.Mind, LogImpact.Medium, $"{ToPrettyString(ev.User.Value)} converted {ToPrettyString(ev.Target)} into a Revolutionary");
|
_adminLogManager.Add(LogType.Mind, LogImpact.Medium, $"{ToPrettyString(ev.User.Value)} converted {ToPrettyString(ev.Target)} into a Revolutionary");
|
||||||
|
|
||||||
|
if (_mind.TryGetRole<RevolutionaryRoleComponent>(ev.User.Value, out var headrev))
|
||||||
|
headrev.ConvertedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mindId == default || !_role.MindHasRole<RevolutionaryRoleComponent>(mindId))
|
if (mindId == default || !_role.MindHasRole<RevolutionaryRoleComponent>(mindId))
|
||||||
|
|||||||
@@ -110,26 +110,9 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
|
|||||||
if (!TryComp(mindId, out MindComponent? mind))
|
if (!TryComp(mindId, out MindComponent? mind))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var name = mind.CharacterName;
|
var title = GetTitle(mindId, mind);
|
||||||
_mind.TryGetSession(mindId, out var session);
|
if (title == null)
|
||||||
var username = session?.Name;
|
continue;
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
result += "\n";
|
result += "\n";
|
||||||
|
|
||||||
@@ -230,6 +213,33 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
|
|||||||
return originalEntityInCustody || (TryComp<CuffableComponent>(mind.OwnedEntity, out var cuffed) && cuffed.CuffedHandCount > 0
|
return originalEntityInCustody || (TryComp<CuffableComponent>(mind.OwnedEntity, out var cuffed) && cuffed.CuffedHandCount > 0
|
||||||
&& _emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value));
|
&& _emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the title for a player's mind used in round end.
|
||||||
|
/// </summary>
|
||||||
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -8,5 +8,9 @@ namespace Content.Server.Roles;
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed partial class RevolutionaryRoleComponent : AntagonistRoleComponent
|
public sealed partial class RevolutionaryRoleComponent : AntagonistRoleComponent
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// For headrevs, how many people you have converted.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public uint ConvertedCount = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,14 +14,6 @@ head-rev-briefing =
|
|||||||
Use flashes to convert people to your cause.
|
Use flashes to convert people to your cause.
|
||||||
Kill all heads to take over the station.
|
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!
|
head-rev-break-mindshield = The Mindshield was destroyed!
|
||||||
|
|
||||||
## Rev
|
## 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-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
|
||||||
|
}.
|
||||||
|
|||||||
Reference in New Issue
Block a user