예제 #1
0
        private static GeneralistProto Chat(string Order)
        {
            GeneralistProto proto = new GeneralistProto {
                Type = CmdTarget.Chat,
                Chat = new Chat {
                    Msg = Order
                }
            };

            return(proto);
        }
예제 #2
0
        private static GeneralistProto List(string Order)
        {
            GeneralistProto proto = new GeneralistProto {
                Type      = CmdTarget.Servercmd,
                Servercmd = new CServer {
                    Cmd = CServer.Types.Cmd.Listing
                }
            };

            return(proto);
        }
예제 #3
0
        private static GeneralistProto Hand(string Order)
        {
            GeneralistProto proto = new GeneralistProto {
                Type    = CmdTarget.Gamecmd,
                Gamecmd = new CGame {
                    Cmd = CGame.Types.Cmd.Hand
                }
            };

            return(proto);
        }
예제 #4
0
 public void Send(ref GeneralistProto proto)
 {
     try
     {
         var data = proto.ToByteArray();
         State.Socket.Send(data);
     }
     catch (Exception e)
     {
         Console.Error.WriteLine(e.ToString());
         Environment.Exit(84);
     }
 }
예제 #5
0
        public static GeneralistProto Generate(string Order)
        {
            GeneralistProto Proto = null;

            string keyResult = keys.FirstOrDefault <string>(s => Order.Contains(s));

            switch (keyResult)
            {
            case "#CREATE":
                Proto = Create(Order);
                break;

            case "#JOIN":
                Proto = Join(Order);
                break;

            case "#LIST":
                Proto = List(Order);
                break;

            case "#USERNAME":
                Proto = Username(Order);
                break;

            case "#TEAM":
                Proto = Team(Order);
                break;

            case "#CARD":
                Proto = Card(Order);
                break;

            case "#CONTRACT":
                Proto = Contract(Order);
                break;

            case "#HAND":
                Proto = Hand(Order);
                break;

            case "#EXIT":
                Environment.Exit(0);
                break;

            default:
                Proto = Chat(Order);
                break;
            }
            return(Proto);
        }
예제 #6
0
        private static GeneralistProto Team(string Order)
        {
            if (Order.Length < 6)
            {
                return(null);
            }
            GeneralistProto proto = new GeneralistProto {
                Type     = CmdTarget.Lobbycmd,
                Lobbycmd = new CLobby {
                    Cmd  = CLobby.Types.Cmd.Team,
                    Team = (Order.Substring(6).Equals("BLUE")) ? CoincheClient.Team.Blue : CoincheClient.Team.Red
                }
            };

            return(proto);
        }
예제 #7
0
        private static GeneralistProto Username(string Order)
        {
            if (Order.Length < 10)
            {
                return(null);
            }
            GeneralistProto proto = new GeneralistProto {
                Type     = CmdTarget.Lobbycmd,
                Lobbycmd = new CLobby {
                    Cmd   = CLobby.Types.Cmd.Username,
                    Value = Order.Substring(10)
                }
            };

            return(proto);
        }
예제 #8
0
        private static GeneralistProto Join(string Order)
        {
            if (Order.Length < 6)
            {
                return(null);
            }
            GeneralistProto proto = new GeneralistProto {
                Type      = CmdTarget.Servercmd,
                Servercmd = new CServer {
                    Cmd   = CServer.Types.Cmd.Join,
                    Value = Order.Substring(6)
                }
            };

            return(proto);
        }
예제 #9
0
        private static GeneralistProto Contract(string Order)
        {
            if (Order.Length < 10)
            {
                return(null);
            }
            GeneralistProto proto = new GeneralistProto {
                Type    = CmdTarget.Gamecmd,
                Gamecmd = new CGame {
                    Cmd   = CGame.Types.Cmd.Contract,
                    Value = Order.Substring(10)
                }
            };

            return(proto);
        }
예제 #10
0
        private static void ConnectAndStart()
        {
            Console.Out.WriteLine("Please insert your name, you little peace of shit:");
            var         name   = Console.In.ReadLine();
            AsyncClient client = new AsyncClient("localhost", 42000);

            client.Start();
            GeneralistProto proto = new GeneralistProto {
                Type = CmdTarget.Authentification,
                Auth = new Authentification {
                    Name = name
                },
                //optional timestamp
            };

            client.Send(ref proto);
            StartInteraction(ref client);
        }