Exemplo n.º 1
0
        public BestScores()
        {
            InitializeComponent();
            string answer = Communicator.Send("", (byte)ReqCode.GETSTATISTICS);

            answer = answer.Substring(5, answer.IndexOf('}') - 4);
            GetUserScoreResponse response = JsonConvert.DeserializeObject <GetUserScoreResponse>(answer);

            string[] arr = response.statistics.Split(',');
            if (arr.Length > 1 && int.Parse(arr[1]) >= 0)
            {
                user_1.Text = arr[0] + "'s score is " + arr[1];
            }
            else
            {
                user_1.FontSize = 18;
                user_1.Text     = "No best scores! you should start playing!";
            }
            if (arr.Length > 3 && int.Parse(arr[3]) >= 0)
            {
                user_2.Text = arr[2] + "'s score is " + arr[3];
            }
            if (arr.Length > 5 && int.Parse(arr[5]) >= 0)
            {
                user_3.Text = arr[4] + "'s score is " + arr[5];
            }
            if (arr.Length > 7 && int.Parse(arr[7]) >= 0)
            {
                user_4.Text = arr[6] + "'s score is " + arr[7];
            }
            if (arr.Length > 9 && int.Parse(arr[9]) >= 0)
            {
                user_5.Text = arr[8] + "'s score is " + arr[9];
            }
        }
Exemplo n.º 2
0
        public MyScore()
        {
            InitializeComponent();
            string answer = Communicator.Send(MainWindow.username, (byte)ReqCode.GETUSERSCORE);

            answer = answer.Substring(5, answer.IndexOf('}') - 4);
            GetUserScoreResponse response = JsonConvert.DeserializeObject <GetUserScoreResponse>(answer);

            string[] arr = response.statistics.Split(',');
            avg_time.Text      = float.Parse(arr[0]) == -1.0 ? "0" : arr[0].Substring(0, 3);
            right_answers.Text = int.Parse(arr[1]) == -1 ? "0" : arr[1];
            wrong_answers.Text = int.Parse(arr[2]) == -1 ? "0" : arr[2];
            games_num.Text     = int.Parse(arr[3]) == -1 ? "0" : arr[3];
        }