-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
102 lines (85 loc) · 3.42 KB
/
Program.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
namespace HearthstoneCLI {
class Program {
protected static Dictionary<string, Action<string, Dictionary<string, string>>> m_CmdLineHandlers = new Dictionary<string, Action<string, Dictionary<string, string>>>();
protected static Dictionary<string, string> m_CmdLineArgs = new Dictionary<string, string>();
protected static void ProcessCmdLineArgs(string[] cmdLineArgs)
{
string cmd;
string args;
m_CmdLineArgs.Clear();
for (int ix = 0; ix < cmdLineArgs.Length; ++ix)
{
try
{
cmd = cmdLineArgs[ix].Replace("\"", "").Replace("'", "");
if (!m_CmdLineHandlers.ContainsKey(cmd))
{
//Log.Instance.WriteLine("Unknown cmd line arg '{0}'", cmd);
System.Diagnostics.Debug.Assert(false);
continue;
}
args = cmdLineArgs[++ix].Replace("\"", "").Replace("'", "");
m_CmdLineHandlers[cmd].Invoke(args, m_CmdLineArgs);
}
catch (Exception ex)
{
System.Diagnostics.Debug.Assert(false);
}
}
}
protected static string FindCmdArg(string cmdName, string defaultVal)
{
return m_CmdLineArgs.ContainsKey(cmdName) ? m_CmdLineArgs[cmdName] : defaultVal;
}
protected static void RegisterCmdLineHandlers()
{
Action<string, Dictionary<string, string>> handler = delegate (string arg, Dictionary<string, string> argMap)
{
argMap.Add("GameConfig", arg);
};
m_CmdLineHandlers.Add("-c", handler);
handler = delegate (string arg, Dictionary<string, string> argMap)
{
argMap.Add("Player1Def", arg);
};
m_CmdLineHandlers.Add("-p1", handler);
handler = delegate (string arg, Dictionary<string, string> argMap)
{
argMap.Add("Player2Def", arg);
};
m_CmdLineHandlers.Add("-p2", handler);
handler = delegate (string arg, Dictionary<string, string> argMap)
{
argMap.Add("GameDef", arg);
};
m_CmdLineHandlers.Add("-g", handler);
}
static void Main(string[] args)
{
try
{
RegisterCmdLineHandlers();
ProcessCmdLineArgs(args);
if(m_CmdLineArgs.ContainsKey("GameDef"))
{
Game.Create(FindCmdArg("GameDef", ""));
} else
{
Game.Create(FindCmdArg("GameConfig", ""), FindCmdArg("Player1Def", ""), FindCmdArg("Player2Def", ""));
}
//Emitter.ProcessEmitters();
//var testEmitter = EmitterLoader.Create( "..\\..\\Data\\Particles\\ParticleSystem.json", new Vector2i() { X = Console.WindowWidth / 2, Y = Console.WindowHeight / 2 } );
//testEmitter.Start();
while (!Game.Instance.IsOver && Game.Instance.Execute())
{
}
}
catch( Exception ex )
{
Console.WriteLine(ex.Message);
}
}
}
}