Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Mega update round system + fix nukeops (cringe code, warning!!!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemirda committed Apr 12, 2024
1 parent db20192 commit 2bc9593
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
45 changes: 34 additions & 11 deletions Content.Server/GameTicking/GameTicker.RoundFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using System.Linq;
using Content.Shared.Database;
using Robust.Shared.Asynchronous;
using Content.Server.Voting.Managers;
using Content.Shared.Voting;
using Content.Shared.CCVar;
using System.Text.RegularExpressions; //A-13 AnnonceRoundUpdate

namespace Content.Server.GameTicking
{
Expand Down Expand Up @@ -310,7 +308,6 @@ public void EndRound(string text = "")
RunLevel = GameRunLevel.PostRound;

ShowRoundEndScoreboard(text);
SendRoundEndDiscordMessage();
}

public void ShowRoundEndScoreboard(string text = "")
Expand Down Expand Up @@ -411,23 +408,49 @@ public void ShowRoundEndScoreboard(string text = "")

_replayRoundPlayerInfo = listOfPlayerInfoFinal;
_replayRoundText = roundEndText;
var roundEndSummary = GenerateRoundEndSummary(gamemodeTitle, roundEndText, listOfPlayerInfoFinal); //A-13 AnnonceRoundUpdate
SendRoundEndDiscordMessage(roundEndSummary); //A-13 AnnonceRoundUpdate
}

//A-13 AnnonceRoundUpdate start
private string ConvertBBCodeToMarkdown(string text)
{
text = Regex.Replace(text, @"\[.*?\]", "**");

return text;
}

private async void SendRoundEndDiscordMessage()
private string GenerateRoundEndSummary(string gamemodeTitle, string roundEndText, RoundEndMessageEvent.RoundEndPlayerInfo[] playerInfoArray)
{
var roundEndTextMarkdown = ConvertBBCodeToMarkdown(roundEndText);
var stringBuilder = new System.Text.StringBuilder();
stringBuilder.AppendLine($"**Режим**: {gamemodeTitle}\n");
stringBuilder.AppendLine($"**Информация**: {roundEndTextMarkdown}\n");
stringBuilder.AppendLine($"**Игроки**:\n");

foreach (var playerInfo in playerInfoArray)
{
stringBuilder.AppendLine($"*{playerInfo.PlayerOOCName}* '**{playerInfo.PlayerICName}**' в роли: {playerInfo.Role}");
}

return stringBuilder.ToString();
}
//A-13 AnnonceRoundUpdate end

private async void SendRoundEndDiscordMessage(string roundEndSummary) //A-13 AnnonceRoundUpdate
{
try
{
if (_webhookIdentifier == null)
return;

var duration = RoundDuration();
var content = Loc.GetString("discord-round-notifications-end",
("id", RoundId),
("hours", Math.Truncate(duration.TotalHours)),
("minutes", duration.Minutes),
("seconds", duration.Seconds));
//A-13 AnnonceRoundUpdate start
var content = $"**Раунд завершен!**\n" +
$"**Продолжительность**: {Math.Truncate(duration.TotalHours)} часов {duration.Minutes} минут {duration.Seconds} секунд\n" +
$"{roundEndSummary}";
var payload = new WebhookPayload { Content = content };

//A-13 AnnonceRoundUpdate end
await _discord.CreateMessage(_webhookIdentifier.Value, payload);

if (DiscordRoundEndRole == null)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private void OnRoundEndText(RoundEndTextAppendEvent ev)
}
}

ev.AddLine(Loc.GetString("nukeops-list-start"));
//ev.AddLine(Loc.GetString("nukeops-list-start"));

var nukiesQuery = EntityQueryEnumerator<NukeopsRoleComponent, MindContainerComponent>();
while (nukiesQuery.MoveNext(out var nukeopsUid, out _, out var mindContainer))
Expand Down

0 comments on commit 2bc9593

Please sign in to comment.