public MatchPreviewForDisplay ToMatchPreviewForDisplay() { MatchPreviewForDisplay mpfd = new MatchPreviewForDisplay(); mpfd.Type = this.Type; if (this.DisplayName.StartsWith("Q") || this.DisplayName.StartsWith("S") || this.DisplayName.StartsWith("F")) { mpfd.DisplayName = this.DisplayName; } else { mpfd.DisplayName = "Q" + this.DisplayName; } mpfd.Status = this.Status; mpfd.Red1 = this.Red1; mpfd.Red2 = this.Red2; mpfd.Red3 = this.Red3; mpfd.Blue1 = this.Blue1; mpfd.Blue2 = this.Blue2; mpfd.Blue3 = this.Blue3; List <Ranking> ranks = getRankings(); try { double rawRedQA = (ranks.Find(i => i.TeamId == Red1).QualificationAverage + ranks.Find(i => i.TeamId == Red2).QualificationAverage + ranks.Find(i => i.TeamId == Red3).QualificationAverage) / 3; double rawRedCanAvg = (ranks.Find(i => i.TeamId == Red1).ContainerPoints + ranks.Find(i => i.TeamId == Red2).ContainerPoints + ranks.Find(i => i.TeamId == Red3).ContainerPoints) / 3; double rawRedCoopAvg = (ranks.Find(i => i.TeamId == Red1).CoopertitionPoints + ranks.Find(i => i.TeamId == Red2).CoopertitionPoints + ranks.Find(i => i.TeamId == Red3).CoopertitionPoints) / 3; double rawBlueQA = (ranks.Find(i => i.TeamId == Blue1).QualificationAverage + ranks.Find(i => i.TeamId == Blue2).QualificationAverage + ranks.Find(i => i.TeamId == Blue3).QualificationAverage) / 3; double rawBlueCanAvg = (ranks.Find(i => i.TeamId == Blue1).ContainerPoints + ranks.Find(i => i.TeamId == Blue2).ContainerPoints + ranks.Find(i => i.TeamId == Blue3).ContainerPoints) / 3; double rawBlueCoopAvg = (ranks.Find(i => i.TeamId == Blue1).CoopertitionPoints + ranks.Find(i => i.TeamId == Blue2).CoopertitionPoints + ranks.Find(i => i.TeamId == Blue3).CoopertitionPoints) / 3; mpfd.RedQA = Math.Round(rawRedQA, 2); mpfd.RedCanAvg = Math.Round(rawRedCanAvg, 2); mpfd.RedCoopAvg = Math.Round(rawRedCoopAvg, 2); mpfd.BlueQA = Math.Round(rawBlueQA, 2); mpfd.BlueCanAvg = Math.Round(rawBlueCanAvg, 2); mpfd.BlueCoopAvg = Math.Round(rawBlueCoopAvg, 2); } catch (NullReferenceException) { mpfd.RedQA = 0; mpfd.BlueQA = 0; } mpfd.Winner = this.Winner; return(mpfd); }
public MatchPreviewForDisplay ToMatchPreviewForDisplay() { MatchPreviewForDisplay mpfd = new MatchPreviewForDisplay(); mpfd.Type = this.Type; if (this.DisplayName.StartsWith("Q") || this.DisplayName.StartsWith("S") || this.DisplayName.StartsWith("F")) { mpfd.DisplayName = this.DisplayName; } else { mpfd.DisplayName = "Q" + this.DisplayName; } mpfd.Status = this.Status; mpfd.Red1 = this.Red1; mpfd.Red2 = this.Red2; mpfd.Red3 = this.Red3; mpfd.Blue1 = this.Blue1; mpfd.Blue2 = this.Blue2; mpfd.Blue3 = this.Blue3; List<Ranking> ranks = getRankings(); try { double rawRedQA = (ranks.Find(i => i.TeamId == Red1).QualificationAverage + ranks.Find(i => i.TeamId == Red2).QualificationAverage + ranks.Find(i => i.TeamId == Red3).QualificationAverage) / 3; double rawRedCanAvg = (ranks.Find(i => i.TeamId == Red1).ContainerPoints + ranks.Find(i => i.TeamId == Red2).ContainerPoints + ranks.Find(i => i.TeamId == Red3).ContainerPoints) / 3; double rawRedCoopAvg = (ranks.Find(i => i.TeamId == Red1).CoopertitionPoints + ranks.Find(i => i.TeamId == Red2).CoopertitionPoints + ranks.Find(i => i.TeamId == Red3).CoopertitionPoints) / 3; double rawBlueQA = (ranks.Find(i => i.TeamId == Blue1).QualificationAverage + ranks.Find(i => i.TeamId == Blue2).QualificationAverage + ranks.Find(i => i.TeamId == Blue3).QualificationAverage) / 3; double rawBlueCanAvg = (ranks.Find(i => i.TeamId == Blue1).ContainerPoints + ranks.Find(i => i.TeamId == Blue2).ContainerPoints + ranks.Find(i => i.TeamId == Blue3).ContainerPoints) / 3; double rawBlueCoopAvg = (ranks.Find(i => i.TeamId == Blue1).CoopertitionPoints + ranks.Find(i => i.TeamId == Blue2).CoopertitionPoints + ranks.Find(i => i.TeamId == Blue3).CoopertitionPoints) / 3; mpfd.RedQA = Math.Round(rawRedQA, 2); mpfd.RedCanAvg = Math.Round(rawRedCanAvg, 2); mpfd.RedCoopAvg = Math.Round(rawRedCoopAvg, 2); mpfd.BlueQA = Math.Round(rawBlueQA, 2); mpfd.BlueCanAvg = Math.Round(rawBlueCanAvg, 2); mpfd.BlueCoopAvg = Math.Round(rawBlueCoopAvg, 2); } catch (NullReferenceException) { mpfd.RedQA = 0; mpfd.BlueQA = 0; } mpfd.Winner = this.Winner; return mpfd; }