-
Notifications
You must be signed in to change notification settings - Fork 1
/
RPGconfig.cs
57 lines (50 loc) · 1.05 KB
/
RPGconfig.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
using Newtonsoft.Json;
using System.IO;
namespace POBC.RPG
{
public class RPGConfig
{
public bool Display = true;
public int DisplayInterval = 180; // should larger than max player count
public RPGC[] RPGList = new RPGC[0];
public RPGConfig Write(string file)
{
File.WriteAllText(file, JsonConvert.SerializeObject(this, Formatting.Indented));
return this;
}
public static RPGConfig Read(string file)
{
if (!File.Exists(file))
{
WriteExample(file);
}
return JsonConvert.DeserializeObject<RPGConfig>(File.ReadAllText(file));
}
public static void WriteExample(string file)
{
var Ex = new RPGC()
{
Group = "default",
GoGroup = "LV1",
Co = new string[]
{
"/BC 这是服务器公告",
},
C = 1
};
var Conf = new RPGConfig()
{
Display = true,
RPGList = new RPGC[] { Ex }
};
Conf.Write(file);
}
}
public class RPGC
{
public string Group = string.Empty;
public string GoGroup = string.Empty;
public string[] Co = new string[0];
public int C = 0;
}
}