Пример #1
0
    public static void Parse(string[] datarray, List <FinalMatchData> list, TcpClient myclient, List <Conversation> myconversationlist, List <Player> playerlist)
    {
        for (int i = 0; i < datarray.Length - 1;)
        {
            switch (datarray[i])
            {
            case "1":
                Console.WriteLine("parsed a one");
                String[] fullcomment = Parser.ChatSplit(datarray[i + 1]);

                string s = "";
                if ((fullcomment != null) && (fullcomment[1].StartsWith("!")))
                {
                    s = Responder.Respond(myconversationlist, playerlist, fullcomment[0], fullcomment[1]);
                }

                if (s != "")
                {
                    MyStreamHelper.WriteToChat(s + "\n", myclient);
                }
                i = i + 3;
                break;

            case "2":
                Console.WriteLine("parsed a 2");
                list.Add(new MatchOverData(datarray[i + 1]));

                MyStreamHelper.WriteToChat("/info" + "\n", myclient);
                MyStreamHelper.WriteToChat("/scoreboard" + "\n", myclient);
                i = i + 3;
                break;

            case "3":
                Console.WriteLine("parsed a 3");
                list.Add(new ScoreboardData(datarray[i + 2], datarray[i + 3], datarray[i + 5], datarray[i + 6]));
                i = i + 7;
                break;

            case "4":
                Console.WriteLine("parsed a 4");
                list.Add(new InfoData(datarray[i + 5]));
                i = i + 8;
                break;

            case "5":
                Console.WriteLine("parsed a 5");
                i = i + 3;
                break;

            case "6":
                Console.WriteLine("parsed a 6");
                ELOScore.MatchupOccured(datarray[i + 1], datarray[i + 2], playerlist);
                i = i + 4;
                break;

            default:
                throw new System.ArgumentException("Cannot Parse: Not one of the enumerated info types: " + datarray[i]);
            }
        }
    }
Пример #2
0
    public static void Main(string[] args)
    {
        List <Player> players = ELOScore.ReadFromFile(BMConstants.PlayerListName);

        TcpClient myclient = MyStreamHelper.Connect();

        MyStreamHelper.Login(BMConstants.RConPW, myclient);

        List <FinalMatchData> list = new List <FinalMatchData>();
        StreamWriter          sw   = new StreamWriter(BMConstants.DataFileName, true);

        sw.WriteLine("Initialized");
        List <Conversation> conversations = Responder.CreateConversationList(BMConstants.ChatListName);


        while (!Console.KeyAvailable)
        {
            Thread.Sleep(1000);
            Parser.Parse(MyStreamHelper.ReadFromStream(myclient), list, myclient, conversations, players);
            Parser.SaveToFile(sw, list);
            list.Clear();
            ELOScore.WriteToFile(players, BMConstants.PlayerListName);
        }
        Console.WriteLine("You pressed a key: Quitting");
        sw.Flush()
        ;               sw.Close();
        myclient.Close();
        // List<Conversation> conversations = Responder.CreateConversationList("chat_list.txt");
        // Console.WriteLine(Responder.Respond(conversations,"!data pistol\n"));
    }