public static LobbyPlayerInfo CreateBotCharacterFromFreelancerSet(FreelancerSet fset) { CharacterType characterType = CharacterType.PunchingDummy; return(new LobbyPlayerInfo { AccountId = 0, BannerID = 0, BotCanTaunt = true, BotsMasqueradeAsHumans = false, CharacterInfo = new LobbyCharacterInfo { CharacterAbilityVfxSwaps = new CharacterAbilityVfxSwapInfo(), CharacterCards = new CharacterCardInfo(), CharacterLevel = 1, CharacterLoadouts = null, CharacterMatches = 0, CharacterMods = new CharacterModInfo(), CharacterSkin = new CharacterVisualInfo(), CharacterTaunts = null, CharacterType = characterType }, EffectiveClientAccessLevel = ClientAccessLevel.Unknown, EmblemID = 0, Handle = "Bot", IsGameOwner = false, IsLoadTestBot = false, IsNPCBot = true, ReadyState = Framework.Constants.Enums.ReadyState.Ready, // Robots are always ready to fight. RibbonID = 0, TitleID = 0, TitleLevel = 0 }); }
public static bool MatchesCharacter(CharacterType character, FreelancerSet freelancerSet) { if (freelancerSet.Types != null && !freelancerSet.Types.Contains(character)) { return(false); } if (freelancerSet.Roles != null) { bool matchesAny = false; foreach (CharacterRole role in freelancerSet.Roles) { if (IsFromRole(character, role)) { return(true); } } } return(false); }
private bool FillTeam(Team team, TeamCompositionRules compositionRules, int maxPlayers, int maxBots, ref List <LobbyServerConnection> availablePlayers, ref LobbyTeamInfo teamInfo) { Log.Print(LogType.Debug, $"Filling Team {team.ToString()}"); int usedPlayers = 0; int usedBots = 0; List <LobbyPlayerInfo> playerInfo = new List <LobbyPlayerInfo>(); for (int slot = 1; slot <= 5; slot++) { //Log.Print(LogType.Debug, "fillteam:: slot "+slot); FreelancerSet botSet = new FreelancerSet() { Roles = new List <CharacterRole>(), Types = new List <CharacterType>() }; bool filled = false; if (usedPlayers != maxPlayers) { foreach (LobbyServerConnection player in availablePlayers) { bool matchedAny = false; bool matched = true; //Log.Print(LogType.Debug, "matching rules with " + player.UserName); foreach (TeamCompositionRules.SlotTypes slotType in compositionRules.Rules.Keys) { if (compositionRules.MatchesSlotType(slotType, team, slot)) { matchedAny = true; //Log.Print(LogType.Debug, "Matched slotType " + slotType.ToString()); /*if (!CharacterUtils.MatchesCharacter(player.PlayerInfo.GetCharacterType(), compositionRules.Rules[slotType])) * { * //Log.Print(LogType.Debug, "not matched rule"); * matched = false; * * if (usedBots == maxBots) * { * break; * } * else * { * FreelancerSet tempSet = compositionRules.Rules[slotType]; * if (tempSet.Roles != null) * botSet.Roles.AddRange(tempSet.Roles); * if (tempSet.Types != null) * botSet.Types.AddRange(tempSet.Types); * } * }*/ } } if (matchedAny && matched) { //Log.Print(LogType.Debug, "Adding player"); LobbyPlayerInfo info = player.GetLobbyPlayerInfo().Clone(); info.TeamId = team; playerInfo.Add(info); filled = true; usedPlayers++; availablePlayers.Remove(player); break; } } } if (!filled) { // try fill with bots if (usedBots != maxBots) // Bots remaining to fill { // create bot //Log.Print(LogType.Debug, "creating bot"); LobbyPlayerInfo botInfo = CharacterUtils.CreateBotCharacterFromFreelancerSet(botSet); botInfo.TeamId = team; playerInfo.Add(botInfo); usedBots++; } } } //Log.Print(LogType.Debug, "For finished"); if (usedPlayers != maxPlayers) { //Log.Print(LogType.Debug, "Bot overflow"); QueueInfo.QueueStatus = QueueStatus.QueueDoesntHaveEnoughHumans; return(false); } //Log.Print(LogType.Debug, "Filling team info"); foreach (LobbyPlayerInfo playerinfo in playerInfo) { teamInfo.TeamPlayerInfo.Add(playerinfo); } //Log.Print(LogType.Debug, "TeamFilled!"); return(true); }