Skip to content

Commit

Permalink
Consider inserted characters for additional insertions in drunk text …
Browse files Browse the repository at this point in the history
…algorithm
  • Loading branch information
ethanmoffat committed May 5, 2023
1 parent ebcb528 commit 06f1b48
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions EOLib/Domain/Chat/ChatProcessor.cs
Expand Up @@ -53,36 +53,35 @@ public string RemoveFirstCharacterIfNeeded(string chat, ChatType chatType, strin
public string MakeDrunk(string input)
{
// algorithm from: https://discord.com/channels/723989119503696013/787685796055482368/945700924536553544
var ret = new StringBuilder();
var ret = new StringBuilder(input);

//Pass 1:
//If E or A: 70 % chance to insert a j
//if U or O: 70 % chance to insert a w
//if i(lowercase only): 40 % chance to insert a u
//if not a space: 40 % chance to double the letter
foreach (var c in input)
for (int i = 0; i < ret.Length; i++)
{
ret.Append(c);
var c = ret[i];

if (char.ToLower(c) == 'e' || char.ToLower(c) == 'a')
{
if (_random.Next(100) < 70)
ret.Append('j');
ret.Insert(i+1, 'j');
}
else if (char.ToLower(c) == 'u' || char.ToLower(c) == 'o')
{
if (_random.Next(100) < 70)
ret.Append('w');
ret.Insert(i+1, 'w');
}
else if (c == 'i')
{
if (_random.Next(100) < 40)
ret.Append('u');
ret.Insert(i+1, 'u');
}

if (c != ' ' && _random.Next(100) < 40)
else if (c != ' ' && _random.Next(100) < 40)
{
ret.Append(c);
ret.Insert(i+1, c);
}
}

Expand All @@ -106,7 +105,8 @@ public string MakeDrunk(string input)
{
if (ret[i] == ' ' && _random.Next(100) < 30)
{
ret.Insert(i, "*hic*");
ret.Insert(i+1, "*hic* ");
i += 6;
}
}

Expand Down

0 comments on commit 06f1b48

Please sign in to comment.