-
Notifications
You must be signed in to change notification settings - Fork 3
/
Config.cs
71 lines (64 loc) · 1.4 KB
/
Config.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
using Newtonsoft.Json;
using System.IO;
using System.Linq;
using System.Security.Permissions;
namespace POBC.TaskSystem
{
public class TaskConfig
{
public _TaskList[] TaskList = new _TaskList[0];
public TaskConfig Write(string file)
{
File.WriteAllText(file, JsonConvert.SerializeObject(this, Formatting.Indented));
return this;
}
public static TaskConfig Read(string file)
{
if (!File.Exists(file))
{
WriteExample(file);
}
return JsonConvert.DeserializeObject<TaskConfig>(File.ReadAllText(file));
}
public static void WriteExample(string file)
{
var Ex = new _TaskList()
{
ID = 1,
Name = "任务名称",
Type = "主线",
Info = "任务信息",
DetailedInfo = "任务详细信息",
Conditions = new _Conditions[]
{
new _Conditions(){ TaskType ="0",Condition="-15,1"}
},
Reward = new string[]
{
"/BC 这是服务器公告",
"/BC 这是服务器公告"
}
};
var Conf = new TaskConfig()
{
TaskList = new _TaskList[] { Ex }
};
Conf.Write(file);
}
}
public class _TaskList
{
public int ID = 0;
public string Type;
public string Name;
public string Info;
public string DetailedInfo;
public _Conditions[] Conditions;
public string[] Reward;
}
public class _Conditions
{
public string TaskType;
public string Condition;
}
}