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); }
public NewBowlingMatch(BowlingServerGETData data) { this.Token = data.token; this.Frames = new List <NewBowlingFrame>(); foreach (List <int> framepoints in data.points) { Frames.Add(new NewBowlingFrame(framepoints)); } //Mark last frame as bonusFrame if (Frames.Count == 11) { Frames[10].SetBonusFrame(true); } calculateFrameScores(); }
public static async Task <BowlingServerGETData> GetBowlingResults() { Uri endPoint = new Uri("http://13.74.31.101/api/points"); using (var client = new HttpClient()) { string repUrl = endPoint.ToString(); HttpResponseMessage response = await client.GetAsync(repUrl); if (response.IsSuccessStatusCode) { string result = await response.Content.ReadAsStringAsync(); BowlingServerGETData scores = (BowlingServerGETData)Newtonsoft.Json.JsonConvert.DeserializeObject(result, typeof(BowlingServerGETData)); return(scores); } else { return(null); } } }
private void calculateScores(BowlingServerGETData data) { NewBowlingMatch match = new NewBowlingMatch(data); verifyAlgorithm(match, data); }
private async void OnClick(object sender, RoutedEventArgs e) { BowlingServerGETData data = await SkatCommunicator.GetBowlingResults(); calculateScores(data); }