localize skeleton accent (#32166)

* localize skeleton accent

* commit number 2

* remove that from this

* this

* babushka
This commit is contained in:
lzk
2024-09-15 21:49:05 +02:00
committed by GitHub
parent 12e2371c8d
commit 7fed39d511
3 changed files with 54 additions and 24 deletions

View File

@@ -7,29 +7,11 @@ namespace Content.Server.Speech.EntitySystems;
public sealed partial class SkeletonAccentSystem : EntitySystem public sealed partial class SkeletonAccentSystem : EntitySystem
{ {
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
[GeneratedRegex(@"(?<!\w)[^aeiou]one", RegexOptions.IgnoreCase, "en-US")] [GeneratedRegex(@"(?<!\w)[^aeiou]one", RegexOptions.IgnoreCase, "en-US")]
private static partial Regex BoneRegex(); private static partial Regex BoneRegex();
private static readonly Dictionary<string, string> DirectReplacements = new()
{
{ "fuck you", "I've got a BONE to pick with you" },
{ "fucked", "boned"},
{ "fuck", "RATTLE RATTLE" },
{ "fck", "RATTLE RATTLE" },
{ "shit", "RATTLE RATTLE" }, // Capitalize RATTLE RATTLE regardless of original message case.
{ "definitely", "make no bones about it" },
{ "absolutely", "make no bones about it" },
{ "afraid", "rattled"},
{ "scared", "rattled"},
{ "spooked", "rattled"},
{ "shocked", "rattled"},
{ "killed", "skeletonized"},
{ "humorous", "humerus"},
{ "to be a", "tibia"},
{ "under", "ulna"}
};
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -50,11 +32,8 @@ public sealed partial class SkeletonAccentSystem : EntitySystem
// At the start of words, any non-vowel + "one" becomes "bone", e.g. tone -> bone ; lonely -> bonely; clone -> clone (remains unchanged). // At the start of words, any non-vowel + "one" becomes "bone", e.g. tone -> bone ; lonely -> bonely; clone -> clone (remains unchanged).
msg = BoneRegex().Replace(msg, "bone"); msg = BoneRegex().Replace(msg, "bone");
// Direct word/phrase replacements: // apply word replacements
foreach (var (first, replace) in DirectReplacements) msg = _replacement.ApplyReplacements(msg, "skeleton");
{
msg = Regex.Replace(msg, $@"(?<!\w){first}(?!\w)", replace, RegexOptions.IgnoreCase);
}
// Suffix: // Suffix:
if (_random.Prob(component.ackChance)) if (_random.Prob(component.ackChance))

View File

@@ -0,0 +1,32 @@
accent-skeleton-words-1 = fuck you
accent-skeleton-words-replace-1 = I've got a BONE to pick with you
accent-skeleton-words-2 = fucked
accent-skeleton-words-replace-2 = boned
accent-skeleton-words-3 = fuck
accent-skeleton-words-3-2 = fck
accent-skeleton-words-3-3 = shit
accent-skeleton-words-replace-3 = RATTLE RATTLE
accent-skeleton-words-4 = definitely
accent-skeleton-words-4-2 = absolutely
accent-skeleton-words-replace-4 = make no bones about it
accent-skeleton-words-5 = afraid
accent-skeleton-words-5-2 = scared
accent-skeleton-words-5-3 = spooked
accent-skeleton-words-5-4 = shocked
accent-skeleton-words-replace-5 = rattled
accent-skeleton-words-6 = killed
accent-skeleton-words-replace-6 = skeletonized
accent-skeleton-words-7 = humorous
accent-skeleton-words-replace-7 = humerus
accent-skeleton-words-8 = to be a
accent-skeleton-words-replace-8 = tibia
accent-skeleton-words-9 = under
accent-skeleton-words-replace-9 = ulna

View File

@@ -587,3 +587,22 @@
accent-russian-words-4: accent-russian-words-replace-4 accent-russian-words-4: accent-russian-words-replace-4
accent-russian-words-5: accent-russian-words-replace-5 accent-russian-words-5: accent-russian-words-replace-5
accent-russian-words-6: accent-russian-words-replace-6 accent-russian-words-6: accent-russian-words-replace-6
- type: accent
id: skeleton
wordReplacements:
accent-skeleton-words-1: accent-skeleton-words-replace-1
accent-skeleton-words-2: accent-skeleton-words-replace-2
accent-skeleton-words-3: accent-skeleton-words-replace-3
accent-skeleton-words-3-2: accent-skeleton-words-replace-3
accent-skeleton-words-3-3: accent-skeleton-words-replace-3
accent-skeleton-words-4: accent-skeleton-words-replace-4
accent-skeleton-words-4-2: accent-skeleton-words-replace-4
accent-skeleton-words-5: accent-skeleton-words-replace-5
accent-skeleton-words-5-2: accent-skeleton-words-replace-5
accent-skeleton-words-5-3: accent-skeleton-words-replace-5
accent-skeleton-words-5-4: accent-skeleton-words-replace-5
accent-skeleton-words-6: accent-skeleton-words-replace-6
accent-skeleton-words-7: accent-skeleton-words-replace-7
accent-skeleton-words-8: accent-skeleton-words-replace-8
accent-skeleton-words-9: accent-skeleton-words-replace-9