예제 #1
0
        public BowlingServerPOSTData(NewBowlingMatch match)
        {
            this.token = match.Token;
            points     = new List <int>();

            foreach (NewBowlingFrame frame in match.Frames)
            {
                if (!frame.IsBonusFrame())
                {
                    points.Add(frame.GetAccumulatedScore());
                }
            }
        }
예제 #2
0
        private async void verifyAlgorithm(NewBowlingMatch match, BowlingServerGETData data)
        {
            string verification = await SkatCommunicator.VerifyBowlingResults(match);

            string frameResults = "Frame results: ";

            foreach (NewBowlingFrame frame in match.Frames)
            {
                frameResults += string.Format("[{0},{1}]", frame.GetPinsDownAtThrow(0), frame.GetPinsDownAtThrow(1));
            }

            MessageBox.Show(frameResults + Environment.NewLine + Environment.NewLine + verification);
        }
예제 #3
0
        public static async Task <string> VerifyBowlingResults(NewBowlingMatch match)
        {
            Uri endPoint = new Uri("http://13.74.31.101/api/points");

            using (var client = new HttpClient())
            {
                BowlingServerPOSTData postData = new BowlingServerPOSTData(match);
                string repUrl         = endPoint.ToString();
                var    serializedData = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(postData), Encoding.UTF8, "application/json");

                HttpResponseMessage response = await client.PostAsync(repUrl, serializedData);

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsStringAsync());
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #4
0
        private void calculateScores(BowlingServerGETData data)
        {
            NewBowlingMatch match = new NewBowlingMatch(data);

            verifyAlgorithm(match, data);
        }