private void ApplyResultChanges(DsTimeResultValue resultvalue, DsTimeResult result) { result.Count++; if (resultvalue.Win) { result.Wins++; } if (resultvalue.MVP) { result.MVP++; } result.Duration += resultvalue.Duration; result.Kills += resultvalue.Kills; result.Army += resultvalue.Army; foreach (var teammate in resultvalue.Teammates) { var rteammate = result.Teammates.FirstOrDefault(f => f.Cmdr == teammate.Cmdr); if (rteammate == null) { rteammate = new DsParticipant() { Cmdr = teammate.Cmdr }; result.Teammates.Add(rteammate); } rteammate.Count++; if (teammate.Win) { rteammate.Wins++; } } foreach (var opponent in resultvalue.Opponents) { var ropponent = result.Opponents.FirstOrDefault(f => f.Cmdr == opponent.Cmdr); if (ropponent == null) { ropponent = new DsParticipant() { Cmdr = opponent.Cmdr }; result.Opponents.Add(ropponent); } ropponent.Count++; if (opponent.Win) { ropponent.Wins++; } } }
private static void ApplyChanges(DsTimeResult result, List <DsTimeResultValue> values) { if (!values.Any()) { return; } result.Count += values.Count; result.Wins += values.Where(x => x.Win == true).Count(); result.MVP += values.Where(x => x.MVP == true).Count(); result.Duration += values.Sum(s => s.Duration); result.Kills += values.Sum(s => s.Kills); result.Army += values.Sum(s => s.Army); foreach (var cmdr in DSData.cmdrs) { var teammates = values.SelectMany(s => s.Teammates).Where(x => x.Cmdr == cmdr).ToList(); var opponents = values.SelectMany(s => s.Opponents).Where(x => x.Cmdr == cmdr).ToList(); var teammateParticipant = result.Teammates.SingleOrDefault(f => f.Cmdr == cmdr); if (teammateParticipant == null) { teammateParticipant = new DsParticipant() { Cmdr = cmdr }; result.Teammates.Add(teammateParticipant); } if (teammates.Any()) { teammateParticipant.Count += teammates.Count; teammateParticipant.Wins += teammates.Where(x => x.Win == true).Count(); } var opponentParticipant = result.Opponents.SingleOrDefault(s => s.Cmdr == cmdr); if (opponentParticipant == null) { opponentParticipant = new DsParticipant() { Cmdr = cmdr }; result.Opponents.Add(opponentParticipant); } if (opponents.Any()) { opponentParticipant.Count += opponents.Count; opponentParticipant.Wins += opponents.Where(x => x.Win == true).Count(); } } foreach (var teammate in values.SelectMany(s => s.Teammates)) { var rteammate = result.Teammates.FirstOrDefault(f => f.Cmdr == teammate.Cmdr); if (rteammate == null) { rteammate = new DsParticipant() { Cmdr = teammate.Cmdr }; result.Teammates.Add(rteammate); } rteammate.Count++; if (teammate.Win) { rteammate.Wins++; } } foreach (var opponent in values.SelectMany(s => s.Opponents)) { var ropponent = result.Opponents.FirstOrDefault(f => f.Cmdr == opponent.Cmdr); if (ropponent == null) { ropponent = new DsParticipant() { Cmdr = opponent.Cmdr }; result.Opponents.Add(ropponent); } ropponent.Count++; if (opponent.Win) { ropponent.Wins++; } } }