-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerDataSave.cs
65 lines (58 loc) · 1.95 KB
/
PlayerDataSave.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
using System;
using System.Collections.Generic;
using System.Text;
namespace RKstat
{
class PlayerDataSave
{
string pathToSave;
FileOperation file;
List<Player> playerList;
public PlayerDataSave(List<Player> playerList)
{
this.playerList = playerList;
file = new FileOperation();
pathToSave = Config.Instance.PathSave;
}
public void SaveArmyGeneral()
{
file.SetPath(pathToSave + "generalArmy-" + GetDate() + ".txt");
file.Open();
file.Save(CreatGeneralArmyStringData());
}
public void SaveAllDataPlayer()
{
file.SetPath(pathToSave + "allInfo-" + GetDate() + ".txt");
file.Open();
file.Save(CreateAllDataPlayer());
}
private List<string> CreateAllDataPlayer()
{
List<string> tmp = new List<string>();
tmp.Add("Name;Level;Money;Province;City;Condition;FaithPoints;General;ArmyName;WayScience;Workshop");
foreach (var item in playerList)
{
if (item != null)
tmp.Add(item.Name + ";" + item.Level + ";" + item.Money + ";" + item.Province + ";" + item.City
+ ";" + item.Condition + ";" + item.FaithPoints + ";" + item.General + ";" + item.ArmyName + ";" + item.WayScience + ";" + item.Workshop);
}
return tmp;
}
private List<string> CreatGeneralArmyStringData()
{
List<string> tmp = new List<string>();
tmp.Add("Nick;ArmyName");
foreach(var item in playerList)
{
if(item.General == "true")
tmp.Add(item.Name+";"+item.ArmyName);
}
return tmp;
}
private string GetDate()
{
string date = DateTime.Now.ToString("dd-MM-yyyy");
return date;
}
}
}