public override bool Call(string[] arguments) { if (arguments.Length != 2) { return(false); } Participant participant = Participant.FindParticipantByString(arguments[0]); if (participant == null) { Console.WriteLine("Participant not found"); return(false); } TeamColor?color = TeamColorExtensions.FromString(arguments[1]); if (!color.HasValue) { Console.WriteLine("Color not found"); return(false); } TryRemoveParticipantFromOtherTeam(participant, color.Value); Teams.ByColor(color.Value).Participants.Add(participant.ParticipantId); return(true); }
public override bool Call(string[] arguments) { if (arguments.Length != 1) { return(false); } TeamColor?color = TeamColorExtensions.FromString(arguments[0]); if (!color.HasValue) { Console.WriteLine("Color not found"); return(false); } IDictionary <Player, Rating> newRating = TrueSkillCalculator.CalculateNewRatings( GameInfo.DefaultGameInfo, Matchmaker.Logic.Teams.ConvertToMoserware(), color.Value is TeamColor.Blue ? 1 : 2, color.Value is TeamColor.Red ? 1 : 2); using (Context context = new Context()) { foreach (KeyValuePair <Player, Rating> player in newRating) { Participant participant = context.Participants.Find(player.Key.Id); if (participant == null) { Console.WriteLine($"Failed to find player {player.Key.Id.ToString()}"); continue; } participant.Mean = player.Value.Mean; participant.StandardDeviation = player.Value.StandardDeviation; participant.Rating = player.Value.ConservativeRating; } context.SaveChanges(); } Console.WriteLine("Updated rating for all players"); return(true); }