예제 #1
0
        public string Interpreter(Guid guid)
        {
            string finalResponse = "";

            string[] arrayResp = RespToServer.Split(";");

            if (arrayResp[0].Contains("Player"))
            {
                finalResponse = CreatePlayer(arrayResp);
            }
            else if (RespToServer.Contains("RoomRequest"))
            {
                finalResponse = RoomRequest(guid);
            }
            else if (RespToServer.Contains("GameStart"))
            {
                finalResponse = RoomRequest(guid);
            }
            else if (RespToServer.Contains("Color"))
            {
                AssignColor(guid);
                finalResponse = AssignPlayer(guid);
            }
            else if (RespToServer.Contains("move"))
            {
                finalResponse = ResponseAssigment(guid, ParseMovement());
            }
            else if (RespToServer.Contains("refresh"))
            {
                finalResponse = MoveNotification(guid);;
            }

            return(finalResponse);
        }
예제 #2
0
        public string ParseMovement()
        {
            string[] toParse  = RespToServer.Split(" ");
            string   response = "";
            int      count    = 0;

            foreach (string item in toParse)
            {
                if (count < 4)
                {
                    count++; continue;
                }
                response = response + item + " ";
            }
            StringBuilder builder = new StringBuilder();

            foreach (char specialchar in RespToServer)
            {
                char toadd = specialchar;
                if (specialchar == '<' | specialchar == '>' | specialchar == '=' | specialchar == '"' | specialchar == '/')
                {
                    toadd = '|';
                }
                builder.Append(toadd);
            }
            response = builder.ToString();
            return(response);
        }
예제 #3
0
        public string CreatePlayer(string[] arrayResp)
        {
            arrayResp = RespToServer.Split(" ");
            User user = new User();

            user.Name     = arrayResp[3];
            user.Password = arrayResp[6];
            WhaitingList.Add(user);
            if (user.Name != null && user.Password != null)
            {
                return(user.Token.ToString());
            }

            return("errore nella creazione utente");
        }