-
Notifications
You must be signed in to change notification settings - Fork 0
/
Games.cs
44 lines (37 loc) · 1.37 KB
/
Games.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
namespace HOI4Announcer;
public class Games
{
public static bool HasActiveGame()
{
string path = Path.Combine(Directory.GetCurrentDirectory(), "games");
string filepath = Path.Combine(path,"currentGame.json");
if (File.Exists(filepath))
{
return true;
}
return false;
}
public static void LoadPreviousGame()
{
}
public void NewGame()
{
if (!HasActiveGame())
{
// Define paths for the game folder and the current game
string path = Path.Combine(Directory.GetCurrentDirectory(), "games");
string filepath = Path.Combine(path,"currentGame.json");
// Convert default_nations.yml to json
FileStream stream = File.OpenRead("nations.yml");
// Converts the FileStream into a YAML object (Young Adult Male Losers)
IDeserializer deserializer = new DeserializerBuilder().WithNamingConvention(HyphenatedNamingConvention.Instance).Build();
config = deserializer.Deserialize<Config>(new StreamReader(stream));
// Create new json file
File.WriteAllText(filepath, "{}");
}
else
{
// tell user old game is still active.
}
}
}