Allow specifying a text to be shown to players in the summary when ending the round. (#1818)
* Allow specifying a text to be shown to players when ending the round. Also sets text * Fix comment
This commit is contained in:
committed by
GitHub
parent
de61a01703
commit
9e7d698145
@@ -113,7 +113,7 @@ namespace Content.Client.GameTicking
|
|||||||
private void RoundEnd(MsgRoundEndMessage message)
|
private void RoundEnd(MsgRoundEndMessage message)
|
||||||
{
|
{
|
||||||
//This is not ideal at all, but I don't see an immediately better fit anywhere else.
|
//This is not ideal at all, but I don't see an immediately better fit anywhere else.
|
||||||
var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundDuration, message.AllPlayersEndInfo);
|
var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.AllPlayersEndInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Content.Client.UserInterface
|
|||||||
private TabContainer RoundEndWindowTabs { get; }
|
private TabContainer RoundEndWindowTabs { get; }
|
||||||
protected override Vector2? CustomSize => (520, 580);
|
protected override Vector2? CustomSize => (520, 580);
|
||||||
|
|
||||||
public RoundEndSummaryWindow(string gm, TimeSpan roundTimeSpan, List<RoundEndPlayerInfo> info)
|
public RoundEndSummaryWindow(string gm, string roundEnd, TimeSpan roundTimeSpan, List<RoundEndPlayerInfo> info)
|
||||||
{
|
{
|
||||||
|
|
||||||
Title = Loc.GetString("Round End Summary");
|
Title = Loc.GetString("Round End Summary");
|
||||||
@@ -50,6 +50,14 @@ namespace Content.Client.UserInterface
|
|||||||
gamemodeLabel.SetMarkup(Loc.GetString("Round of [color=white]{0}[/color] has ended.", gm));
|
gamemodeLabel.SetMarkup(Loc.GetString("Round of [color=white]{0}[/color] has ended.", gm));
|
||||||
RoundEndSummaryTab.AddChild(gamemodeLabel);
|
RoundEndSummaryTab.AddChild(gamemodeLabel);
|
||||||
|
|
||||||
|
//Round end text
|
||||||
|
if (!string.IsNullOrEmpty(roundEnd))
|
||||||
|
{
|
||||||
|
var roundendLabel = new RichTextLabel();
|
||||||
|
roundendLabel.SetMarkup(Loc.GetString(roundEnd));
|
||||||
|
RoundEndSummaryTab.AddChild(roundendLabel);
|
||||||
|
}
|
||||||
|
|
||||||
//Duration
|
//Duration
|
||||||
var roundTimeLabel = new RichTextLabel();
|
var roundTimeLabel = new RichTextLabel();
|
||||||
roundTimeLabel.SetMarkup(Loc.GetString("It lasted for [color=yellow]{0} hours, {1} minutes, and {2} seconds.",
|
roundTimeLabel.SetMarkup(Loc.GetString("It lasted for [color=yellow]{0} hours, {1} minutes, and {2} seconds.",
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Content.IntegrationTests
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndRound()
|
public void EndRound(string roundEnd)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Content.Server.GameObjects.Components.Suspicion;
|
||||||
using Content.Server.Interfaces.Chat;
|
using Content.Server.Interfaces.Chat;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
using Content.Server.Mobs.Roles;
|
using Content.Server.Mobs.Roles;
|
||||||
@@ -50,7 +51,8 @@ namespace Content.Server.GameTicking.GameRules
|
|||||||
foreach (var playerSession in _playerManager.GetAllPlayers())
|
foreach (var playerSession in _playerManager.GetAllPlayers())
|
||||||
{
|
{
|
||||||
if (playerSession.AttachedEntity == null
|
if (playerSession.AttachedEntity == null
|
||||||
|| !playerSession.AttachedEntity.TryGetComponent(out IDamageableComponent damageable))
|
|| !playerSession.AttachedEntity.TryGetComponent(out IDamageableComponent damageable)
|
||||||
|
|| !playerSession.AttachedEntity.TryGetComponent(out SuspicionRoleComponent suspicionRole))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -69,24 +71,46 @@ namespace Content.Server.GameTicking.GameRules
|
|||||||
if ((innocentsAlive + traitorsAlive) == 0)
|
if ((innocentsAlive + traitorsAlive) == 0)
|
||||||
{
|
{
|
||||||
_chatManager.DispatchServerAnnouncement("Everybody is dead, it's a stalemate!");
|
_chatManager.DispatchServerAnnouncement("Everybody is dead, it's a stalemate!");
|
||||||
EndRound();
|
EndRound(Victory.Stalemate);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (traitorsAlive == 0)
|
else if (traitorsAlive == 0)
|
||||||
{
|
{
|
||||||
_chatManager.DispatchServerAnnouncement("The traitors are dead! The innocents win.");
|
_chatManager.DispatchServerAnnouncement("The traitors are dead! The innocents win.");
|
||||||
EndRound();
|
EndRound(Victory.Innocents);
|
||||||
}
|
}
|
||||||
else if (innocentsAlive == 0)
|
else if (innocentsAlive == 0)
|
||||||
{
|
{
|
||||||
_chatManager.DispatchServerAnnouncement("The innocents are dead! The traitors win.");
|
_chatManager.DispatchServerAnnouncement("The innocents are dead! The traitors win.");
|
||||||
EndRound();
|
EndRound(Victory.Traitors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EndRound()
|
private enum Victory
|
||||||
{
|
{
|
||||||
_gameTicker.EndRound();
|
Stalemate,
|
||||||
|
Innocents,
|
||||||
|
Traitors
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EndRound(Victory victory)
|
||||||
|
{
|
||||||
|
string text;
|
||||||
|
|
||||||
|
switch (victory)
|
||||||
|
{
|
||||||
|
case Victory.Innocents:
|
||||||
|
text = "The innocents have won!";
|
||||||
|
break;
|
||||||
|
case Victory.Traitors:
|
||||||
|
text = "The traitors have won!";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
text = "Nobody wins!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gameTicker.EndRound(text);
|
||||||
_chatManager.DispatchServerAnnouncement($"Restarting in 10 seconds.");
|
_chatManager.DispatchServerAnnouncement($"Restarting in 10 seconds.");
|
||||||
_checkTimerCancel.Cancel();
|
_checkTimerCancel.Cancel();
|
||||||
Timer.Spawn(TimeSpan.FromSeconds(10), () => _gameTicker.RestartRound());
|
Timer.Spawn(TimeSpan.FromSeconds(10), () => _gameTicker.RestartRound());
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ namespace Content.Server.GameTicking
|
|||||||
(HumanoidCharacterProfile) (await _prefsManager.GetPreferencesAsync(p.SessionId.Username))
|
(HumanoidCharacterProfile) (await _prefsManager.GetPreferencesAsync(p.SessionId.Username))
|
||||||
.SelectedCharacter;
|
.SelectedCharacter;
|
||||||
|
|
||||||
public void EndRound()
|
public void EndRound(string roundEndText = "")
|
||||||
{
|
{
|
||||||
DebugTools.Assert(RunLevel == GameRunLevel.InRound);
|
DebugTools.Assert(RunLevel == GameRunLevel.InRound);
|
||||||
Logger.InfoS("ticker", "Ending round!");
|
Logger.InfoS("ticker", "Ending round!");
|
||||||
@@ -336,6 +336,7 @@ namespace Content.Server.GameTicking
|
|||||||
//Tell every client the round has ended.
|
//Tell every client the round has ended.
|
||||||
var roundEndMessage = _netManager.CreateNetMessage<MsgRoundEndMessage>();
|
var roundEndMessage = _netManager.CreateNetMessage<MsgRoundEndMessage>();
|
||||||
roundEndMessage.GamemodeTitle = MakeGamePreset(null).ModeTitle;
|
roundEndMessage.GamemodeTitle = MakeGamePreset(null).ModeTitle;
|
||||||
|
roundEndMessage.RoundEndText = roundEndText;
|
||||||
|
|
||||||
//Get the timespan of the round.
|
//Get the timespan of the round.
|
||||||
roundEndMessage.RoundDuration = IoCManager.Resolve<IGameTiming>().RealTime.Subtract(_roundStartTimeSpan);
|
roundEndMessage.RoundDuration = IoCManager.Resolve<IGameTiming>().RealTime.Subtract(_roundStartTimeSpan);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Content.Server.Interfaces.GameTicking
|
|||||||
|
|
||||||
void RestartRound();
|
void RestartRound();
|
||||||
void StartRound(bool force = false);
|
void StartRound(bool force = false);
|
||||||
void EndRound();
|
void EndRound(string roundEndText = "");
|
||||||
|
|
||||||
void Respawn(IPlayerSession targetPlayer);
|
void Respawn(IPlayerSession targetPlayer);
|
||||||
void MakeObserve(IPlayerSession player);
|
void MakeObserve(IPlayerSession player);
|
||||||
|
|||||||
@@ -253,6 +253,7 @@ namespace Content.Shared
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public string GamemodeTitle;
|
public string GamemodeTitle;
|
||||||
|
public string RoundEndText;
|
||||||
public TimeSpan RoundDuration;
|
public TimeSpan RoundDuration;
|
||||||
|
|
||||||
|
|
||||||
@@ -263,6 +264,7 @@ namespace Content.Shared
|
|||||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||||
{
|
{
|
||||||
GamemodeTitle = buffer.ReadString();
|
GamemodeTitle = buffer.ReadString();
|
||||||
|
RoundEndText = buffer.ReadString();
|
||||||
|
|
||||||
var hours = buffer.ReadInt32();
|
var hours = buffer.ReadInt32();
|
||||||
var mins = buffer.ReadInt32();
|
var mins = buffer.ReadInt32();
|
||||||
@@ -289,6 +291,7 @@ namespace Content.Shared
|
|||||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||||
{
|
{
|
||||||
buffer.Write(GamemodeTitle);
|
buffer.Write(GamemodeTitle);
|
||||||
|
buffer.Write(RoundEndText);
|
||||||
buffer.Write(RoundDuration.Hours);
|
buffer.Write(RoundDuration.Hours);
|
||||||
buffer.Write(RoundDuration.Minutes);
|
buffer.Write(RoundDuration.Minutes);
|
||||||
buffer.Write(RoundDuration.Seconds);
|
buffer.Write(RoundDuration.Seconds);
|
||||||
|
|||||||
Reference in New Issue
Block a user