-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLexiconClass.cs
More file actions
106 lines (100 loc) · 3.74 KB
/
LexiconClass.cs
File metadata and controls
106 lines (100 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.Linq;
namespace Lexicon_Plugin
{
public static class LexiconClass
{
public static Random rand = new Random();
public static string Lexiconify(string msg)
{
char[] array = new char[0];
string[] array2 = msg.Split(new char[]
{
' '
});
string result;
if (LexiconClass.rand.Next(0, 100) <= LexiconPlugin.config.HurrDurrChancePercentage && LexiconPlugin.config.ReplaceWithHurrDurr)
{
result = LexiconClass.ReplaceWithHurrDurr(msg);
}
else if (LexiconClass.rand.Next(0, 100) <= LexiconPlugin.config.RandomPhrasesChancePercentage && LexiconPlugin.config.SayRandomPhrases)
{
result = LexiconClass.SayRandomBullshit();
}
else
{
for (int i = 0; i < array2.Length; i++)
{
string key = array2[i].ToLower();
if (LexiconPlugin.config.LexiconWords.ContainsKey(key))
{
array = LexiconPlugin.config.LexiconWords[key].ToArray<char>();
for (int j = 0; j < array.Length; j++)
{
if (j < array2[i].Length)
{
if (char.IsUpper(array2[i][j]))
{
array[j] = char.ToUpper(array[j]);
}
}
}
array2[i] = new string(array);
}
}
string text = string.Join(" ", array2);
if (LexiconClass.rand.Next(0, 100) <= LexiconPlugin.config.TypoChancePercentage && LexiconPlugin.config.InsertRandomTypos)
{
text = LexiconClass.InsertRandomTypo(string.Join(" ", array2));
}
result = text;
}
return result;
}
public static string SayRandomBullshit()
{
return LexiconPlugin.config.RandomPhrases[LexiconClass.rand.Next(0, LexiconPlugin.config.RandomPhrases.Length)];
}
public static string ReplaceWithHurrDurr(string s)
{
string[] array = s.Split(new char[]
{
' '
});
for (int i = 0; i < array.Length; i++)
{
array[i] = ((LexiconClass.rand.Next(0, 2) == 0) ? "hurr" : "durr");
}
return string.Join(" ", array);
}
public static string InsertRandomTypo(string s)
{
List<char> list = s.ToList<char>();
if (LexiconClass.rand.Next(0, 5) == 0 && list.Count > 0)
{
int index = LexiconClass.rand.Next(0, s.Length);
switch (LexiconClass.rand.Next(0, 3))
{
case 0:
list.RemoveAt(index);
break;
case 1:
list.Insert(index, LexiconClass.RandChar());
s = new string(list.ToArray());
break;
case 2:
list[index] = LexiconClass.RandChar();
s = new string(list.ToArray());
break;
}
}
return new string(list.ToArray());
}
public static char RandChar()
{
string text = "abcdefghijklmnopqrstuvwxyz ',.;123456789";
return text[LexiconClass.rand.Next(0, text.Length)];
}
}
}