//this stuff below should be done in a new MultiRuleset for TeamVs.

        internal override void HandlePlayerFailed(int i)
        {
            //mark slot [i] as failed.
            base.HandlePlayerFailed(i);

            SlotTeams failTeam = player.ScoreEntries[i].Team;
            //check each slot for the team [i] to see if all failed
            bool teamFailed = true;

            foreach (ScoreboardEntry s in player.ScoreEntries)
            {
                if (s != null && s.Team == failTeam && s.Passing == true)
                {
                    teamFailed = false;
                    break;
                }
            }

            if (teamFailed)
            {
                if (player.scoreEntry.Team == failTeam)
                {
                    player.Ruleset.HpBar.SetCurrentHp(0);
                    player.OnFailableHp();
                    ourTeamFailed = true;
                }
                else
                {
                    BanchoClient.SendRequest(RequestType.Osu_MatchComplete, null);
                    player.InitializeScoreGraphs();
                    GameBase.ChangeMode(OsuModes.RankingTeam);
                    NotificationManager.ClearMessageMassive();
                }
            }
        }
Esempio n. 2
0
        public bool Join(bool allowQuickRejoin = false)
        {
            allowQuickRejoin |= Name == "#lobby";

            if (Joined)
            {
                return(true);
            }

            if (Joining)
            {
                return(false);
            }

            if (!allowQuickRejoin && JoinTime > 0 && GameBase.Time - JoinTime < 10000)
            {
                return(false);
            }

            JoinTime = GameBase.Time;

            BanchoClient.SendRequest(RequestType.Osu_ChannelJoin, new bString(Name));
            messageBuffer.Add(new Message("Attempting to join channel...", "", Color.LightCoral));
            Joining = true;
            return(true);
        }
Esempio n. 3
0
        private void OnCreateGame(object sender, EventArgs e)
        {
            if (!BanchoClient.Connected)
            {
                GameBase.ShowMessage("You must be connected to bancho before creating a game.");
                return;
            }

            if (Status == LobbyStatus.PendingCreate)
            {
                return;
            }


            if (BeatmapManager.BeatmapAvailable.Count == 0)
            {
                GameBase.ShowMessage("No beatmaps available!");
                return;
            }
            if (BeatmapManager.Current == null)
            {
                BeatmapManager.Current = BeatmapManager.BeatmapAvailable[0];
            }

            Status = LobbyStatus.PendingCreate;
            BanchoClient.SendRequest(RequestType.Osu_MatchCreate,
                                     new bMatch(MatchType.RankedVs, ConfigManager.sUsername + "'s game", BeatmapManager.Current.DisplayTitle, BeatmapManager.Current.BeatmapChecksum,
                                                BeatmapManager.Current.BeatmapId, Mods.None));
        }
Esempio n. 4
0
        private void onClick(object sender, EventArgs e)
        {
            if (Lobby.Status == LobbyStatus.PendingCreate)
            {
                return;
            }

            if (usePassword.Checked && gamePassword.Box.Text.Length == 0)
            {
                NotificationManager.ShowMessage("Enter a password before attempting to start the game...");
                return;
            }

            NotificationManager.ShowMessageMassive("Creating game...", 1600);
            Lobby.Status = LobbyStatus.PendingCreate;

            ClientSideMatch match = new ClientSideMatch(MatchTypes.Standard,
                                                        MatchScoringTypes.Score,
                                                        MatchTeamTypes.HeadToHead,
                                                        PlayModes.Osu,
                                                        gameName.Box.Text,
                                                        usePassword.Checked ? gamePassword.Box.Text : null,
                                                        (int)playerCount.SelectedObject,
                                                        BeatmapManager.Current.DisplayTitle,
                                                        BeatmapManager.Current.BeatmapChecksum,
                                                        BeatmapManager.Current.BeatmapId,
                                                        Mods.None,
                                                        GameBase.User.Id,
                                                        MultiSpecialModes.None,
                                                        Player.Seed);

            MatchSetup.Match = match;
            BanchoClient.SendRequest(RequestType.Osu_MatchCreate, match);
        }
Esempio n. 5
0
        internal static void LeaveLobby(bool changeMode)
        {
            if (!Joined)
            {
                return;
            }
            Joined = false;

            Matches.Clear();
            BanchoClient.SendRequest(RequestType.Osu_LobbyPart, null);

            if (Status == LobbyStatus.Idle)
            {
                if (!chatOpenOnStart && ChatEngine.IsVisible)
                {
                    ChatEngine.Toggle(true);
                }
                Status = LobbyStatus.NotJoined;
            }

            if (changeMode)
            {
                AudioEngine.PlaySample(AudioEngine.s_MenuBack);
                GameBase.ChangeMode(Modes.Menu);
            }
        }
Esempio n. 6
0
        internal override bool DoSkip()
        {
            if (OutroSkippable)
            {
                base.DoSkip();
                return(true);
            }

            if (queueSkipCount > 0)
            {
                NotificationManager.ClearMessageMassive();
                MultiSkipRequested = false;

                clearSkippedStatus();

                base.DoSkip();
                return(true);
            }

            if (!MultiSkipRequested && (AudioEngine.Time < SkipBoundary) && Status == PlayerStatus.Intro)
            {
                MultiSkipRequested = true;
                NotificationManager.ShowMessageMassive(LocalisationManager.GetString(OsuString.PlayerVs_SkipRequest), 2000);
                BanchoClient.SendRequest(RequestType.Osu_MatchSkipRequest, null);
            }

            return(false);
        }
Esempio n. 7
0
        internal static void GetOnlineBeatmapInfo()
        {
            lock (BeatmapRequestLock)
            {
                if (BeatmapInfoRequestList != null)
                {
                    return;
                }

                bBeatmapInfoRequest req = new bBeatmapInfoRequest();

                BeatmapInfoRequestList = new List <Beatmap>();
                BeatmapInfoRequestList.AddRange(BeatmapAvailable);
                BeatmapInfoRequestList.RemoveAll(b => b.BeatmapChecksum == null);

                int count = BeatmapInfoRequestList.Count;
                for (int i = 0; i < count; i++)
                {
                    req.filenames.Add(Path.GetFileName(BeatmapInfoRequestList[i].Filename));
                }

                Console.WriteLine("Requested details for " + req.filenames.Count + " beatmaps");
                BanchoClient.SendRequest(RequestType.Osu_BeatmapInfoRequest, req);
            }
        }
Esempio n. 8
0
        internal static void LeaveLobby(bool changeMode)
        {
            if (!Joined)
            {
                return;
            }
            Joined = false;

            Matches.Clear();
            BanchoClient.SendRequest(RequestType.Osu_LobbyPart, null);

            if (Status == LobbyStatus.Idle)
            {
                ChatEngine.RemoveChannel(@"#lobby");

                if (!chatOpenOnStart)
                {
                    ChatEngine.HideChat();
                }

                Status = LobbyStatus.NotJoined;
            }

            if (changeMode)
            {
                AudioEngine.PlaySamplePositional(@"menuback");
                Status = LobbyStatus.NotJoined;
                GameBase.ChangeMode(OsuModes.Menu);
            }
        }
Esempio n. 9
0
 private void changeSlot(int id)
 {
     if (id == Match.findPlayerFromId(GameBase.User.Id))
     {
         return;
     }
     BanchoClient.SendRequest(RequestType.Osu_MatchChangeSlot, new bInt(id));
 }
Esempio n. 10
0
        private void requestMatchInfo()
        {
            if (SpectatingMatch != null)
            {
                BanchoClient.SendRequest(RequestType.Osu_SpecialMatchInfoRequest, new bInt(SpectatingMatch.matchId));
            }

            GameBase.Scheduler.AddDelayed(requestMatchInfo, 1000);
        }
Esempio n. 11
0
 internal override void OnFail()
 {
     //After the fail animation, the failing team members will reach here.
     //change mode to ranking screen.
     BanchoClient.SendRequest(RequestType.Osu_MatchComplete, null);
     GameBase.ChangeMode(OsuModes.RankingTeam);
     player.InitializeScoreGraphs();
     NotificationManager.ClearMessageMassive();
 }
        private static void getOnlineBeatmapInfoForQueued()
        {
            if (BeatmapInfoSendListAll == null)
            {
                return;
            }

            if (GameBase.Mode == OsuModes.Play)
            {
                //delay if playing
                GameBase.Scheduler.AddDelayed(getOnlineBeatmapInfoForQueued, 4000);
                return;
            }

            // i351: Allocate maps_per_request of each to eat slightly more memory to avoid
            // having to grow the list possibly many times as it iterates.
            bBeatmapInfoRequest req = new bBeatmapInfoRequest(maps_per_request, maps_per_request);

            int count = BeatmapInfoSendListAll.Count;

            if (count < maps_per_request)
            {
                BeatmapInfoSendListPartial = new List <Beatmap>(BeatmapInfoSendListAll);
                BeatmapInfoSendListAll     = null;
            }
            else
            {
                // i351: Pull entries from the end of the list to avoid a linear-time shift every pull.
                BeatmapInfoSendListPartial = new List <Beatmap>(BeatmapInfoSendListAll.GetRange(count - maps_per_request, maps_per_request));
                BeatmapInfoSendListAll.RemoveRange(count - maps_per_request, maps_per_request);
            }


            // BeatmapIds from the .osu files are often _wrong_. Until this is somehow fixed don't use them for info retrieval.
            foreach (Beatmap b in BeatmapInfoSendListPartial)
            {
                /*if (b.BeatmapId > 0)
                 * {
                 *  req.ids.Add(b.BeatmapId);
                 * }
                 * else*/
                {
                    string filename = Path.GetFileName(b.Filename);
                    if (!string.IsNullOrEmpty(filename))
                    {
                        req.filenames.Add(filename);
                    }
                }
            }

            //BeatmapInfoSendListPartial.RemoveAll(b => b.BeatmapId > 0); //don't use these when receiving data back.

            Debug.Print("Requested details for " + req.filenames.Count + " (filename) plus " + req.ids.Count + " (beatmap_id) beatmaps...");

            BanchoClient.SendRequest(RequestType.Osu_BeatmapInfoRequest, req);
        }
Esempio n. 13
0
        private void OnDisbandGame(object sender, EventArgs e)
        {
            if (!JoinedGame)
            {
                return;
            }
            JoinedGame = false;

            BanchoClient.SendRequest(RequestType.Osu_MatchPart, null);
        }
Esempio n. 14
0
        private void OnCreateGame(object sender, EventArgs e)
        {
            if (JoinedGame)
            {
                return;
            }
            JoinedGame = true;

            BanchoClient.SendRequest(RequestType.Osu_MatchCreate, new bMatch(MatchType.SimpleVs, ConfigManager.sUsername + "'s test game", 1));
        }
Esempio n. 15
0
 public void Leave()
 {
     if (Joined)
     {
         BanchoClient.SendRequest(RequestType.Osu_ChannelLeave, new bString(Name));
         Joined        = false;
         Joining       = false;
         messageToSend = "";
     }
 }
Esempio n. 16
0
 private static void JoinLobby()
 {
     if (Joined)
     {
         return;
     }
     Joined = true;
     Matches.Clear();
     Status = LobbyStatus.Idle;
     BanchoClient.SendRequest(RequestType.Osu_LobbyJoin, null);
 }
Esempio n. 17
0
 private void changeBeatmap()
 {
     if (BeatmapManager.Current != null && Match.beatmapChecksum != BeatmapManager.Current.BeatmapChecksum)
     {
         SongChangePending     = true;
         Match.beatmapName     = BeatmapManager.Current.DisplayTitle;
         Match.beatmapChecksum = BeatmapManager.Current.BeatmapChecksum;
         Match.beatmapId       = BeatmapManager.Current.BeatmapId;
         BanchoClient.SendRequest(RequestType.Osu_MatchChangeSettings, Match);
     }
 }
Esempio n. 18
0
        internal void SendMapComplete()
        {
            //ensure we purge all remaining score frames before sending the complete packet.
            SendScoreChange(true);

            if (!MapCompletePacketSent)
            {
                BanchoClient.SendRequest(RequestType.Osu_MatchComplete, null);
                MapCompletePacketSent = true;
            }
        }
Esempio n. 19
0
        public static void JoinMatch(int matchId, string password = null)
        {
            if (Status == LobbyStatus.PendingJoin)
            {
                return;
            }

            NotificationManager.ShowMessageMassive(LocalisationManager.GetString(OsuString.Lobby_Join), 1500);
            BanchoClient.SendRequest(RequestType.Osu_MatchJoin, new bMatchJoin(matchId, password ?? MatchSetup.Match.gamePassword));
            Status = LobbyStatus.PendingJoin;
        }
Esempio n. 20
0
 public bMatch GetMatchData(int matchId = 0)
 {
     if (!GameBase.Tournament)
     {
         return(null);
     }
     if (matchId > 0)
     {
         BanchoClient.SendRequest(RequestType.Osu_SpecialMatchInfoRequest, new bInt(matchId));
     }
     return(IPC.MatchInfo);
 }
Esempio n. 21
0
        private void SendScoreChange(bool force = false)
        {
            if (!pendingScoreChange || (GameBase.Time - lastScoreChangeSend < 400 && !force))
            {
                return;
            }

            pendingScoreChange  = false;
            lastScoreChangeSend = GameBase.Time;

            BanchoClient.SendRequest(RequestType.Osu_MatchScoreUpdate, lastValidScoreFrame);
        }
Esempio n. 22
0
        internal bool PullStats(bool force)
        {
            if (StatsLoaded && !force)
            {
                return(true);
            }

            if (StatsLoading)
            {
                return(false);
            }

            if (Name.Length > 0)
            {
                StatsLoading = true;

                if (Sprites != null)
                {
                    spriteBackground.FlashColour(Color.Crimson, 3000);
                    spriteName.Text = Name;

                    if (firstReceived)
                    {
                        spriteInfo.Text = string.Empty;
                    }
                }

                if (Name == ConfigManager.sUsername)
                {
                    BanchoClient.SendRequest(RequestType.Osu_RequestStatusUpdate, null);
                }
            }
            else
            {
                Name       = @"Guest";
                Level      = 0;
                Id         = -1;
                Permission = Permissions.Normal;
                InfoText   = LocalisationManager.GetString(OsuString.Options_Online_ClickToLogin);

                spriteName.Text    = Name;
                spriteInfo.Text    = InfoText;
                spriteRank.Text    = string.Empty;
                modeStatus.Texture = null;

                LoadAvatarInto(spriteAvatar, spriteAvatar.MaxDimension);

                updateLevelBar();
            }

            return(true);
        }
Esempio n. 23
0
        private void m_Closed(object sender, EventArgs e)
        {
            if (IsHost && (ModManager.ModStatus & ~Mods.NoVideo) != (oldMods & ~Mods.NoVideo))
            {
                BanchoClient.SendRequest(RequestType.Osu_MatchChangeMods,
                                         new bInt((int)(ModManager.ModStatus & ~Mods.NoVideo)));
            }

            if (!IsHost || (ModManager.ModStatus & Mods.NoVideo) != (oldMods & Mods.NoVideo))
            {
                ModChangePending = true;
            }
        }
Esempio n. 24
0
        internal static void JoinLobby()
        {
            if (Joined)
            {
                return;
            }
            Joined = true;
            Matches.Clear();
            Status = LobbyStatus.Idle;
            BanchoClient.SendRequest(RequestType.Osu_LobbyJoin, null);

            ChatEngine.SwapChannel(ChatEngine.AddChannel(@"#lobby"));
        }
Esempio n. 25
0
        internal static void LeaveGame()
        {
            if (Lobby.Status == LobbyStatus.Idle)
            {
                return;
            }

            Lobby.Status = LobbyStatus.Idle;
            BanchoClient.SendRequest(RequestType.Osu_MatchPart, null);
            Match = null;

            AudioEngine.PlaySample(AudioEngine.s_MenuBack);

            GameBase.ChangeMode(Modes.Lobby);
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        public static void JoinMatch(bMatch info)
        {
            if (Status == LobbyStatus.PendingJoin)
            {
                return;
            }

            if (info.slotOpenCount > info.slotUsedCount && Status == LobbyStatus.Idle)
            {
                BanchoClient.SendRequest(RequestType.Osu_MatchJoin, new bInt(info.matchId));
                Status = LobbyStatus.PendingJoin;
            }
            else
            {
                GameBase.ShowMessage("This match is full!");
                AudioEngine.PlaySample("match-leave");
            }
        }
Esempio n. 28
0
        internal bool PullStats(bool force)
        {
            if (StatsLoaded && !force)
            {
                return(true);
            }

            if (StatsLoading)
            {
                return(false);
            }

            if (Name.Length > 0)
            {
                StatsLoading = true;

                if (Sprites != null)
                {
                    spriteBackground.FlashColour(Color.Crimson, 3000);
                    spriteName.Text = Name;

                    AvatarLoaded = false;

                    if (firstReceived)
                    {
                        spriteInfo.Text = "Loading stats...";
                    }
                }

                if (Name == ConfigManager.sUsername)
                {
                    BanchoClient.SendRequest(RequestType.Osu_RequestStatusUpdate, null);
                }
            }
            else
            {
                spriteName.Text = "Guest";
                spriteInfo.Text = "Please click here to login.";
            }

            return(true);
        }
Esempio n. 29
0
        private void OnReady(object sender, EventArgs e)
        {
            if (GameBase.FadeState != FadeStates.Idle)
            {
                return;
            }

            if (Match.slotStatus[Match.findPlayerFromId(GameBase.User.Id)] == SlotStatus.NotReady)
            {
                BanchoClient.SendRequest(RequestType.Osu_MatchReady, null);
            }
            else if (IsHost && Match.slotReadyCount == Match.slotUsedCount && Match.slotReadyCount > 1)
            {
                BanchoClient.SendRequest(RequestType.Osu_MatchStart, null);
            }
            else if (Match.slotStatus[Match.findPlayerFromId(GameBase.User.Id)] == SlotStatus.Ready)
            {
                BanchoClient.SendRequest(RequestType.Osu_MatchNotReady, null);
            }
        }
Esempio n. 30
0
        internal override void OnFailableHp()
        {
            if (ModManager.CheckActive(Mods.NoFail))
            {
                return;
            }

            if (MultiRuleset.ContinuousPlay)
            {
                if (!Ruleset.Fail(true))
                {
                    return;
                }

                if (MultiFailed)
                {
                    return;
                }

                MultiFailed = true;
                NotificationManager.ShowMessageMassive(LocalisationManager.GetString(OsuString.PlayerVs_FailedButKeepGoing), 3000);
                BanchoClient.SendRequest(RequestType.Osu_MatchFailed, null);
                currentScore.InvalidateSubmission();
                return;
            }

            if (!Failed)
            {
                BanchoClient.SendRequest(RequestType.Osu_MatchFailed, null);
                //We failed...

                SendMapComplete();
                //And won't be playing anymore.

                Ruleset.Fail(false);
            }
        }