-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
105 lines (98 loc) · 3 KB
/
Program.cs
File metadata and controls
105 lines (98 loc) · 3 KB
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
103
104
105
using ProjOb;
using ProjOb.DTOs;
using ProjOb.Fields;
using ProjOb.Items;
using ProjOb.Items.Effects;
using ProjOb.Items.Effects.WeaponEffects;
using ProjOb.Items.Other;
using ProjOb.Items.weapons;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
namespace Main
{
public class Program
{
static void Main(string[] args)
{
Console.Clear();
bool runServer = true;
int port = 5555;
string address = "127.0.0.1";
Console.OutputEncoding = System.Text.Encoding.Unicode;
Console.SetBufferSize(1000, 1000);
Console.CursorVisible = false;
Game game = new Game();
//game.Run();
if(args.Length == 0)
{
ShowUsage();
return;
}
var arg = args[0];
if (arg == "--server")
{
runServer = true;
if (1 < args.Length && int.TryParse(args[1], out int p))
{
port = p;
}
Console.WriteLine("Server " + port);
game.ServerRun(port);
}
else if (arg == "--client")
{
runServer = false;
if (1 < args.Length)
{
var parts = args[1].Split(':', 2);
if (parts[0].Length > 0)
{
address = parts[0];
}
if (parts[1].Length > 0) {
int.TryParse(parts[1], out int p);
port = p;
}
}
Console.WriteLine("Client " + address + " " + port);
game.ClientRun(address, port);
}
else
{
ShowUsage();
return;
}
}
static void ShowUsage()
{
Console.WriteLine("Usage:");
Console.WriteLine(" --server [port] Uruchom tryb serwera (domyślnie port 5555)");
Console.WriteLine(" --client [adres:port] Uruchom tryb klienta (domyślnie 127.0.0.1:5555)");
}
}
//[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
//[JsonDerivedType(typeof(DTO), "DTO")]
//public interface IDTO
//{
// public void fun();
//}
//[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
//[JsonDerivedType(typeof(aDTO), "aDTO")]
//[JsonDerivedType(typeof(bDTO), "bDTO")]
//public abstract class DTO : IDTO
//{
// public virtual void fun() => Console.WriteLine("base");
//}
//public class aDTO : DTO
//{
// override public void fun() => Console.WriteLine("a");
//}
//public class bDTO : DTO
//{
// override public void fun() => Console.WriteLine("b");
//}
}