CatStation/Content.Shared/Speech/EntitySystems/MothAccentSystem.cs

43 lines
2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Text.RegularExpressions;
using Content.Shared.Speech.Components;
using Content.Shared.Speech.EntitySystems;
using Robust.Shared.Random;
namespace Content.Shared.Speech.EntitySystems;
public sealed partial class MothAccentSystem : RelayAccentSystem<MothAccentComponent>
{
[Dependency] private IRobustRandom _random = default!; // Corvax-Localization
private static readonly Regex RegexLowerBuzz = new("z{1,3}");
private static readonly Regex RegexUpperBuzz = new("Z{1,3}");
// Corvax-Localization-Start
private static readonly Regex _regexLowerZh = new Regex("ж+");
private static readonly Regex _regexUpperZh = new Regex("Ж+");
private static readonly Regex _regexLowerZ = new Regex("з+");
private static readonly Regex _regexUpperZ = new Regex("З+");
private static readonly List<string> _replacementsZh = new List<string> { "жж", "жжж" };
private static readonly List<string> _replacementsZhUpper = new List<string> { "ЖЖ", "ЖЖЖ" };
private static readonly List<string> _replacementsZ = new List<string> { "зз", "ззз" };
private static readonly List<string> _replacementsZUpper = new List<string> { "ЗЗ", "ЗЗЗ" };
// Corvax-Localization-End
public override string Accentuate(string message, Entity<MothAccentComponent>? ent = null)
{
// buzzz
message = RegexLowerBuzz.Replace(message, "zzz");
// buZZZ
message = RegexUpperBuzz.Replace(message, "ZZZ");
// Corvax-Localization-Start
message = _regexLowerZh.Replace(message, _random.Pick(_replacementsZh));
message = _regexUpperZh.Replace(message, _random.Pick(_replacementsZhUpper));
message = _regexLowerZ.Replace(message, _random.Pick(_replacementsZ)); // используем существующий regexLowerZ
message = _regexUpperZ.Replace(message, _random.Pick(_replacementsZUpper)); // используем существующий regexUpperZ
// Corvax-Localization-End
return message;
}
}