private static ProposedBattle TryToMakeBattle(PlayerEntry player, IList <PlayerEntry> otherPlayers, bool ignoreSizeLimit) { var allPlayers = new List <PlayerEntry>(); allPlayers.AddRange(otherPlayers); allPlayers.Add(player); var playersByElo = otherPlayers.Where(x => x != player) .OrderBy(x => Math.Abs(x.LobbyUser.EffectiveMmElo - player.LobbyUser.EffectiveMmElo)) .ThenBy(x => x.JoinedTime) .ToList(); var testedBattles = player.GenerateWantedBattles(allPlayers, ignoreSizeLimit); foreach (var other in playersByElo) { foreach (var bat in testedBattles) { if (bat.CanBeAdded(other, allPlayers, ignoreSizeLimit)) { bat.AddPlayer(other, allPlayers); } if (bat.Players.Count == bat.Size && bat.VerifyBalance(DynamicConfig.Instance.MmTeamsMinimumWinChance)) { return(bat); } } } return(null); }
private static ProposedBattle TryToMakeBattle(PlayerEntry player, IList <PlayerEntry> otherPlayers) { var allPlayers = new List <PlayerEntry>(); allPlayers.AddRange(otherPlayers); allPlayers.Add(player); var playersByElo = otherPlayers.Where(x => x != player) .OrderBy(x => Math.Abs(x.LobbyUser.EffectiveMmElo - player.LobbyUser.EffectiveMmElo)) .ThenBy(x => x.JoinedTime) .ToList(); var testedBattles = player.GenerateWantedBattles(allPlayers); foreach (var other in playersByElo) { foreach (var bat in testedBattles) { if (bat.CanBeAdded(other, allPlayers)) { bat.AddPlayer(other, allPlayers); } if (bat.Players.Count == bat.Size) { return(bat); } } } return(null); }
public bool CanBeAdded(PlayerEntry other, List <PlayerEntry> allPlayers, bool ignoreSizeLimit) { //Trace.TraceError("MM: proposed battle {0} checking {1}", string.Join(", ", Players.Select(x => x.Name)), other.Name); if (Players.Contains(other)) { //Trace.TraceError("MM: cannot add {0}, already added", other.Name); return(false); } if (owner.Party != null && other.Party == owner.Party) { return(true); // always accept same party } if (!other.GenerateWantedBattles(allPlayers, ignoreSizeLimit).Any(y => (y.Size == Size) && (y.QueueType == QueueType))) { //Trace.TraceError("MM: cannot add {0}, does not want same game type", other.Name); return(false); } var width = owner.EloWidth * widthMultiplier; if (hasParty) { width = width * DynamicConfig.Instance.MmWidthReductionForParties; } if (other.Party != null) { if (!hasParty) { width = width * DynamicConfig.Instance.MmWidthReductionForParties; } if (!VerifyPartySizeFits(other.Party)) { //Trace.TraceError("MM: cannot add party {0}, party size does not fit", other.Name); return(false); } if ((GetPartyMinElo(other.Party, allPlayers) - MinElo > width) || (MaxElo - GetPartyMaxElo(other.Party, allPlayers) > width)) { //Trace.TraceError("MM: cannot add party {0}, {1} - {2} > {3} || {4} - {5} > {3}", other.Name, GetPartyMinElo(other.Party, allPlayers), MinElo, width, MaxElo, GetPartyMaxElo(other.Party, allPlayers)); return(false); } } else if ((GetPlayerMinElo(other) - MinElo > width) || (MaxElo - GetPlayerMaxElo(other) > width)) { //Trace.TraceError("MM: cannot add {0}, {1} - {2} > {3} || {4} - {5} > {3}", other.Name, GetPlayerMinElo(other), MinElo, width, MaxElo, GetPlayerMaxElo(other)); return(false); } return(true); }
public bool CanBeAdded(PlayerEntry other) { if (!other.GenerateWantedBattles().Any(y => y.Size == Size && y.QueueType == QueueType)) return false; var width = owner.EloWidth * widthMultiplier; if ((GetPlayerMinElo(other) - MinElo > width) || (MaxElo - GetPlayerMaxElo(other) > width)) return false; return true; }
private static ProposedBattle TryToMakeBattle(PlayerEntry player, IList<PlayerEntry> otherPlayers) { var playersByElo = otherPlayers.Where(x => x != player) .OrderBy(x => Math.Abs(x.LobbyUser.EffectiveMmElo - player.LobbyUser.EffectiveMmElo)) .ThenBy(x => x.JoinedTime) .ToList(); var testedBattles = player.GenerateWantedBattles(); foreach (var other in playersByElo) foreach (var bat in testedBattles) if (bat.CanBeAdded(other)) { bat.AddPlayer(other); if (bat.Players.Count == bat.Size) return bat; } return null; }
public bool CanBeAdded(PlayerEntry other) { if (!other.GenerateWantedBattles().Any(y => (y.Size == Size) && (y.Mode == Mode))) return false; var widthMultiplier = Math.Max(1.0, 1.0 + (Size - 4) * 0.1); var width = owner.EloWidth * widthMultiplier; var elo = GetElo(other); if ((elo - MinElo > width) || (MaxElo - elo > width)) return false; return true; }