forked from OceanUwU/slaytabase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keywords.js
62 lines (58 loc) · 1.43 KB
/
keywords.js
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
const keywords = [
['[E]', 'Energy'],
['[R]', 'Energy'],
['[G]', 'Energy'],
['[B]', 'Energy'],
['[W]', 'Energy'],
['[fist_icon]', 'finisheremoji'],
['champ:Combo:', 'Combo:'],
['slimeboundmod:Bruiser_Slime', 'Bruiser Slime'],
['slimeboundmod:Bruiser', 'Bruiser'],
];
const directKeywords = [
'Exhaust',
'Ethereal',
'Echo',
'Retain',
'Innate',
'Unplayable',
'Fleeting',
'Weak',
'Frail',
'Vulnerable',
'Strength',
'Dexterity',
'Focus',
'Vigor',
'Artifact',
'Intangible',
'Confused',
'Stance',
'Scry',
'Fetch',
'Block',
'Temporary HP',
'Upgrade',
'Fatal',
'Transform',
'Status',
'Curse',
];
export default function keywordify(text, character) {
for (let i of keywords)
text = text.replaceAll(i[0], `**${i[1]}**`);
for (let i of directKeywords)
text = text.replaceAll(i, `**${i}**`);
let lines = text.split('\n');
for (let i in lines) {
let words = lines[i].split(' ');
for (let j in words) {
let word = words[j];
if (word.includes(':') && word.indexOf(':') != word.length-1 && !word.startsWith('**') && !word.startsWith('<')) //if is modded keyword
words[j] = `**${word.slice(word.indexOf(':')+1).replaceAll('_', ' ')}**`;
}
lines[i] = words.join(' ');
}
text = lines.join('\n');
return text;
}