-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBannerCreator.cs
77 lines (68 loc) · 2.27 KB
/
BannerCreator.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DiscordBannerBot
{
public class BannerCreator
{
#region Private Properties
private Dictionary<string, List<string>> characterDictionary;
#endregion
#region Public Properties
#endregion
#region Constructors
public BannerCreator()
{
characterDictionary = new Dictionary<string, List<string>>();
FillCharacterDictionary();
}
#endregion
#region Private Methods
/// <summary>
/// Fetches the hardcoded letters from the Characters class and fills up the characterDicionary with
/// usable string lists
/// </summary>
private void FillCharacterDictionary()
{
Type type = typeof(Characters);
foreach (var c in type.GetFields())
{
List<string> charStrings = c.GetValue(null).ToString().Split(Environment.NewLine).ToList();
characterDictionary.Add(c.Name, charStrings);
}
//special case for space (need to find a nicer solution for this^^)
characterDictionary[" "] = characterDictionary["space"];
characterDictionary.Remove("space");
}
#endregion
#region Public Methods
public string CreateBannerMessage(string message)
{
string banner = "";
if (message.Length > 10)
{
banner = "It is too long for me to take in! (That's what she said, hahahah!)";
return banner;
}
for (int i = 0; i < 7; i++)
{
foreach (var character in message)
{
if (characterDictionary.ContainsKey(character.ToString()))
{
banner += characterDictionary[character.ToString()][i] + " ";
}
else
{
banner = "Could not create banner from given input!";
return banner;
}
}
banner += "\n";
}
return banner;
}
#endregion
}
}