Skip to content

Commit cef6e35

Browse files
authored
New string format
1 parent 92759c9 commit cef6e35

1 file changed

Lines changed: 53 additions & 10 deletions

File tree

Werewolf for Telegram/Database/AchievementsReworked.cs

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,64 @@
1-
using System;
1+
//Rextester.Program.Main is the entry point for your code. Don't change it.
2+
//Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354)
3+
4+
using System;
25
using System.Collections;
36
using System.Collections.Generic;
47
using System.ComponentModel;
58
using System.ComponentModel.DataAnnotations;
69
using System.Linq;
710
using System.Reflection;
811
using System.Text;
12+
using System.Text.RegularExpressions;
913
using System.Threading.Tasks;
1014

11-
namespace Database
15+
namespace Rextester
1216
{
17+
public class Program
18+
{
19+
public static void Main(string[] args)
20+
{
21+
//Your code goes here
22+
var useXml = false;
23+
var achvs = Enum.GetValues(typeof(AchievementsReworked)).Cast<AchievementsReworked>().ToList();
24+
var text = "Result:";
25+
foreach (var achv in achvs)
26+
{
27+
text += Environment.NewLine;
28+
if (!useXml)
29+
{
30+
text += Environment.NewLine;
31+
}
32+
text += GetResult(achv, useXml);
33+
}
34+
Console.WriteLine(text);
35+
}
36+
public static string GetResult(AchievementsReworked a, bool useXml)
37+
{
38+
string name = a.GetName();
39+
string name_string = a.GetName(false);
40+
string descr = a.GetDescription();
41+
string descr_string = a.GetDescription(false);
42+
if (useXml)
43+
{
44+
// Lines
45+
var string_key_name = $" <string key=\"{name_string}\">";
46+
var string_key_descr = $" <string key=\"{descr_string}\">";
47+
var string_closure = $" </string>";
48+
var string_value_name = $" <value>{name}</value>";
49+
var string_value_descr = $" <value>{descr}</value>";
50+
var n = Environment.NewLine;
51+
// Strings
52+
var rTxt = string_key_name + n + string_value_name + n + string_closure + n;
53+
rTxt += string_key_descr + n + string_value_descr + n + string_closure;
54+
return rTxt;
55+
}
56+
else
57+
{
58+
return $"{name_string}: {name}{Environment.NewLine}{descr_string}: {descr}";
59+
}
60+
}
61+
}
1362
public enum AchievementsReworked
1463
{
1564
[Display(Name = "None"), Description("You haven't played a game yet!")]
@@ -223,10 +272,7 @@ public static string GetDescription(this AchievementsReworked value, bool text =
223272
return value.ToString();
224273
}
225274
else
226-
{
227-
var achvId = (int)value;
228-
return $"Achievement{achvId.ToString()}Descr";
229-
}
275+
return $"Achievement{value.ToString()}Descr";
230276
}
231277
public static string GetName(this AchievementsReworked value, bool text = true)
232278
{
@@ -241,10 +287,7 @@ public static string GetName(this AchievementsReworked value, bool text = true)
241287
return (descriptionAttributes.Length > 0) ? descriptionAttributes[0].Name : value.ToString();
242288
}
243289
else
244-
{
245-
var achvId = (int)value;
246-
return $"Achievement{achvId.ToString()}Name";
247-
}
290+
return $"Achievement{value.ToString()}Name";
248291
}
249292

250293
public static byte[] ToByteArray(this BitArray bits)

0 commit comments

Comments
 (0)