Skip to content

Commit

Permalink
Merge pull request #109 from Lemirda/master-andromeda
Browse files Browse the repository at this point in the history
Mega update round system + fix nukeops (cringe code, warning!!!)
  • Loading branch information
13lackHawk authored Apr 13, 2024
2 parents df2cfa0 + 7a5de10 commit ce8f600
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 39 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
5 changes: 2 additions & 3 deletions Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
using Content.Shared.Roles;
using Content.Shared.Store;
using Content.Shared.Tag;
using Content.Shared.Zombies;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
Expand Down Expand Up @@ -205,7 +204,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 Expand Up @@ -456,7 +455,7 @@ private void DistributeExtraTc(NukeopsRuleComponent nukieRule)
if (Transform(uid).MapID != Transform(nukieRule.NukieOutpost.Value).MapID) // Will receive bonus TC only on their start outpost
continue;

_store.TryAddCurrency(new () { { TelecrystalCurrencyPrototype, nukieRule.WarTCAmountPerNukie } }, uid, component);
_store.TryAddCurrency(new() { { TelecrystalCurrencyPrototype, nukieRule.WarTCAmountPerNukie } }, uid, component);

var msg = Loc.GetString("store-currency-war-boost-given", ("target", uid));
_popupSystem.PopupEntity(msg, uid);
Expand Down
41 changes: 18 additions & 23 deletions Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public sealed partial class EmergencyShuttleSystem
/// </summary>
private float _authorizeTime;

private float _AndromedaEmergency60 = 60; // Andromeda Emergency
private float _AndromedaEmergency30 = 30; // Andromeda Emergency
private float trashcheck60 = 0; // Andromeda Emergency
private float trashcheck30 = 0; // Andromeda Emergency
private float _andromedaEmergency60 = 60; // Andromeda Emergency
private float _andromedaEmergency30 = 30; // Andromeda Emergency
private float _trashcheck60 = 0; // Andromeda Emergency
private float _trashcheck30 = 0; // Andromeda Emergency

private CancellationTokenSource? _roundEndCancelToken;

Expand Down Expand Up @@ -160,34 +160,29 @@ private void UpdateEmergencyConsole(float frameTime)
if (!EarlyLaunchAuthorized)
AnnounceLaunch();
}

// Andromeda Emergency
if (!_launchedShuttles && _consoleAccumulator <= _AndromedaEmergency60 && trashcheck60 == 0)
// Andromeda Emergency start
if (!_launchedShuttles && !_announced && _consoleAccumulator <= _andromedaEmergency60 && _trashcheck60 == 0)
{
if (_announced == false)
{
_chatSystem.DispatchGlobalAnnouncement(
Loc.GetString("emergency-shuttle-andromeda-60", ("AndromedaEmergency60", $"{_AndromedaEmergency60:0}")),
playSound: false,
colorOverride: DangerColor);
_audio.PlayGlobal("/Audio/Announcements/announce.ogg", Filter.Broadcast(), recordReplay: true);
trashcheck60++;
}
_chatSystem.DispatchGlobalAnnouncement(
Loc.GetString("emergency-shuttle-andromeda-60", ("AndromedaEmergency60", $"{_andromedaEmergency60:0}")),
playSound: false,
colorOverride: DangerColor);
_audio.PlayGlobal("/Audio/Announcements/announce.ogg", Filter.Broadcast(), recordReplay: true);
_trashcheck60++;
}

// Andromeda Emergency
if (!_launchedShuttles && _consoleAccumulator <= _AndromedaEmergency30 && trashcheck30 == 0)
if (!_launchedShuttles && _consoleAccumulator <= _andromedaEmergency30 && _trashcheck30 == 0)
{
if (_announced == false)
{
_chatSystem.DispatchGlobalAnnouncement(
Loc.GetString("emergency-shuttle-andromeda-30", ("AndromedaEmergency30", $"{_AndromedaEmergency30:0}")),
Loc.GetString("emergency-shuttle-andromeda-30", ("AndromedaEmergency30", $"{_andromedaEmergency30:0}")),
playSound: false,
colorOverride: DangerColor);
_audio.PlayGlobal("/Audio/Announcements/announce.ogg", Filter.Broadcast(), recordReplay: true);
trashcheck30++;
_trashcheck30++;
}
}
// Andromeda Emergency end

// Imminent departure
if (!_launchedShuttles && _consoleAccumulator <= ShuttleSystem.DefaultStartupTime)
Expand Down Expand Up @@ -357,8 +352,8 @@ private void CleanupEmergencyConsole()
ShuttlesLeft = false;
_launchedShuttles = false;
_consoleAccumulator = float.MinValue;
trashcheck60 = 0; // Andromeda Emergency
trashcheck30 = 0; // Andromeda Emergency
_trashcheck60 = 0; // Andromeda Emergency
_trashcheck30 = 0; // Andromeda Emergency
EarlyLaunchAuthorized = false;
EmergencyShuttleArrived = false;
TransitTime = MinimumTransitTime + (MaximumTransitTime - MinimumTransitTime) * _random.NextFloat();
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Recipes/Construction/furniture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
- !type:TileNotBlocked

- type: construction
name: красивй красный стол #A-13 Translation
name: красивый красный стол #A-13 Translation
id: TableFancyRed
graph: Table
startNode: start
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Recipes/Construction/machines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
state: 4

- type: construction
name: маркас машины #A-13 Translation
name: каркас машины #A-13 Translation
description: Машина в стадии строительства. Нужно больше запчастей. #A-13 Translation
id: MachineFrame
graph: Machine
Expand Down

0 comments on commit ce8f600

Please sign in to comment.