Skip to content

Commit

Permalink
Merge pull request #66 from Corvax-Frontier/up130824
Browse files Browse the repository at this point in the history
Up130824
  • Loading branch information
Vonsant authored Aug 13, 2024
2 parents 736f1b0 + 115546d commit 00efc57
Show file tree
Hide file tree
Showing 60 changed files with 321,574 additions and 181,598 deletions.
38 changes: 33 additions & 5 deletions Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,55 @@ namespace Content.Server.DeltaV.Speech.EntitySystems;

public sealed class ScottishAccentSystem : EntitySystem
{
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
[Dependency]
private readonly ReplacementAccentSystem _replacement = default!;

private static readonly Regex RegexCh = new(@"ч", RegexOptions.IgnoreCase);
private static readonly Regex RegexShch = new(@"щ", RegexOptions.IgnoreCase);
private static readonly Regex RegexZh = new(@"ж", RegexOptions.IgnoreCase);
private static readonly Regex RegexR = new(@"р", RegexOptions.IgnoreCase);
private static readonly Regex RegexY = new(@"ы", RegexOptions.IgnoreCase);
private static readonly Regex RegexO = new(@"о", RegexOptions.IgnoreCase);

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ScottishAccentComponent, AccentGetEvent>(OnAccentGet);
}

// converts left word when typed into the right word. For example typing you becomes ye.
public string Accentuate(string message, ScottishAccentComponent component)
{
var msg = message;

msg = _replacement.ApplyReplacements(msg, "scottish");

msg = RegexCh.Replace(msg, "тш");
msg = RegexShch.Replace(msg, "ш");
msg = RegexZh.Replace(msg, "дж");
msg = RegexR.Replace(msg, "рр");
msg = RegexY.Replace(msg, "и");
msg = RegexO.Replace(msg, "э");

// Добавление случайных американизмов
var words = msg.Split(' ');
for (int i = 0; i < words.Length; i++)
{
if (Random.Shared.NextDouble() < 0.02)
{
words[i] += " йоу";
}
else if (Random.Shared.NextDouble() < 0.02)
{
words[i] += " мэн";
}
}
msg = string.Join(" ", words);

return msg;
}

private void OnAccentGet(EntityUid uid, ScottishAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message, component);
}
}
}
Loading

0 comments on commit 00efc57

Please sign in to comment.