// Creates a match for players in the list starting at the given index LobbyMatch CreateMatchInRange(int start, int length) { LobbyMatch match = new LobbyMatch(); LobbyPlayer player; // TODO: Atm we take the first X players from the queue int end = start + length; for (int i = start; i < end; i++) { // TODO: Optimize algorithm while (true) { player = playerList[Random.Range(start, end)]; if (player.queue != null) { break; } } // Set player queue to null, WE REMOVE THEM LATER, all at once player.queue = null; //player.match = match; player.SendMatchAcceptRequest(match); match.teams[i / _playersPerTeam].Add(player); } // Remove those players from the queue playerList.RemoveRange(start, length); return(match); }
// Updates the cached ranking list public void StartRankingListCacheUpdate(LobbyMatch match = null) { byte subject = (byte)RankingSubject.Player; for (byte page = 0; page < GameDB.numRankingPages; page++) { byte pageSaved = page; StartCoroutine(RankingsDB.GetTopRanks( subject, page, maxPlayerCount, data => { if (match != null) { foreach (var team in match.teams) { foreach (var player in team) { if (player.peer.type != LobbyPeerType.Disconnected) { Lobby.RPC("ReceiveRankingList", player.peer, subject, pageSaved, data, false); } } } } } )); } }
public MatchInfo(LobbyMatch match, EventHandler clickAction) : base(string.Empty, 7, Vector2.Zero, 1, true, Color.White) { Match = match; HandleInput = true; OnClick += clickAction; }
// Create practice match public static LobbyMatch CreatePracticeMatch(LobbyPlayer player) { player.LeaveQueue(); LobbyMatch match = new LobbyMatch(); //player.match = match; match.teams[0].Add(player); player.SendMatchAcceptRequest(match); return(match); }
private void setMatch(object sender, EventArgs e) { LobbyMatch newMatch = (sender as MatchInfo)?.Match; if (newMatch == spectatingMatchContainer) { return; } // This has to be done before we set the new match if (SpectatingMatch != null) { BanchoClient.SendRequest(RequestType.Osu_SpecialLeaveMatchChannel, SpectatingMatch.matchId); } spectatingMatchContainer = newMatch; tournament.ChatManager.ClearChat(); foreach (var match in matches) { match.TextBold = match == sender; match.TextColour = match == sender ? SkinManager.NEW_SKIN_COLOUR_MAIN : Color.White; } string gameName = SpectatingMatch.gameName; int index = gameName.IndexOf(':'); if (index > 0) { gameName = gameName.Substring(index + 1); } var teams = gameName.Split('(', ')', '(', ')'); if (teams.Length >= 4) { tournament.SetMatch(teams[1].Trim(), teams[3].Trim()); } else { tournament.SetMatch(string.Empty, string.Empty); } BanchoClient.SendRequest(RequestType.Osu_SpecialJoinMatchChannel, SpectatingMatch.matchId); }
// Send match accept request public void SendMatchAcceptRequest(LobbyMatch newMatch) { instanceAwaitingAccept = newMatch; Lobby.RPC("MatchFound", this.peer); }
private bool CheckFilter(LobbyMatch match) { bool hasTextSearch = filterTextBox.Box.Text.Length > 0; if (ConfigManager.sLobbyPlayMode.Value >= 0 && match.matchInfo.playMode != (PlayModes)ConfigManager.sLobbyPlayMode.Value) { if (!hasTextSearch) { return(false); } } if (!checkShowFullGames.Checked && match.matchInfo.slotFreeCount == 0) { if (!hasTextSearch) { return(false); } } if (!checkInProgress.Checked && match.matchInfo.inProgress) { return(false); } if (checkFriendsOnly.Checked) { bool found = false; for (int i = 0; i < 16; i++) { if (match.matchInfo.slotId[i] < 0) { continue; } User u = BanchoClient.GetUserById(match.matchInfo.slotId[i]); if (u != null && u.IsFriend) { found = true; break; } } if (!found) { return(false); } } if (!checkShowPasswordedGames.Checked && match.matchInfo.passwordRequired) { if (!hasTextSearch) { return(false); } } if (ConfigManager.sLobbyShowExistingOnly && BeatmapManager.GetBeatmapByChecksum(match.matchInfo.beatmapChecksum) == null) { if (!hasTextSearch) { return(false); } } if (hasTextSearch) { string filter = filterTextBox.Box.Text.ToLower(); bool success = false; if (match.matchInfo.gameName.ToLower().Contains(filter)) { success = true; } else if (match.matchInfo.beatmapName.ToLower().Contains(filter)) { success = true; } else { for (int i = 0; i < 8; i++) { if (match.matchInfo.slotId[i] < 0) { continue; } User u = BanchoClient.GetUserById(match.matchInfo.slotId[i]); if (u != null && u.Name.ToLower().Contains(filter)) { success = true; break; } } } return(success); } return(true); }