예제 #1
0
        //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();
                }
            }
        }
예제 #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);
        }
예제 #3
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);
        }
예제 #4
0
        public void SetSpectate(int userId)
        {
            if (!GameBase.Tournament || GameBase.FadeState != FadeStates.Idle)
            {
                return;
            }

            GameBase.Scheduler.Add(delegate
            {
                User found = BanchoClient.GetUserById(userId);
                if (found != null && found == StreamingManager.CurrentlySpectating)
                {
                    if (GameBase.TourneySpectatorName != null)
                    {
                        GameBase.TourneySpectatorName.Text = found.Name;
                    }
                    return;
                }

                StreamingManager.StopSpectating();
                if (found != null)
                {
                    found.BeatmapId              = 0;
                    found.BeatmapName            = string.Empty;
                    found.CurrentBeatmapChecksum = string.Empty;
                    StreamingManager.StartSpectating(found);
                }
            });
        }
예제 #5
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));
        }
예제 #6
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);
            }
        }
예제 #7
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);
            }
        }
예제 #8
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);
            }
        }
예제 #9
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);
        }
예제 #10
0
 private void changeSlot(int id)
 {
     if (id == Match.findPlayerFromId(GameBase.User.Id))
     {
         return;
     }
     BanchoClient.SendRequest(RequestType.Osu_MatchChangeSlot, new bInt(id));
 }
예제 #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();
 }
예제 #12
0
        private void requestMatchInfo()
        {
            if (SpectatingMatch != null)
            {
                BanchoClient.SendRequest(RequestType.Osu_SpecialMatchInfoRequest, new bInt(SpectatingMatch.matchId));
            }

            GameBase.Scheduler.AddDelayed(requestMatchInfo, 1000);
        }
예제 #13
0
 internal void PerformLogout()
 {
     BanchoClient.DisconnectImmediately();
     ConfigManager.sUsername.Value = string.Empty;
     ConfigManager.sPassword.Value = string.Empty;
     GameBase.User.Name            = string.Empty;
     GameBase.User.Refresh();
     ReloadElements();
 }
예제 #14
0
        public void PopulateTitleStatics()
        {
            try
            {
                string artist = Source.Length > 0 ? Source + " (" + Artist + ")" : Artist;

                if (Artist.Length > 0)
                {
                    SortTitle = artist + " - " + Title;
                }
                else if (Title.Length > 0)
                {
                    SortTitle = Title;
                }
                else
                {
                    SortTitle = Path.GetFileName(Filename);
                }

                string versionString = (Version.Length > 0 ? " [" + Version + "]" : "");

                if (Artist.Length > 0)
                {
                    DisplayTitle = artist + " - " + Title + versionString;
                }
                else if (Title.Length > 0)
                {
                    DisplayTitle = Title + versionString;
                }
                else
                {
                    DisplayTitle = Path.GetFileName(Filename);
                }

                if (Title.Length > 0)
                {
                    DisplayTitleNoArtist = Title + versionString;
                }
                else
                {
                    DisplayTitleNoArtist = Path.GetFileName(Filename);
                }

                if (Creator.Length > 0)
                {
                    GroupTitle = SortTitle + Creator;
                }
                else
                {
                    GroupTitle = SortTitle;
                }
            }
            catch (Exception e)
            {
                BanchoClient.HandleException(e, "Populating title statistics");
            }
        }
        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);
        }
예제 #16
0
        internal static void IncomingBeatmapInfoReply(bBeatmapInfoReply reply)
        {
            try
            {
                lock (BeatmapRequestLock)
                {
                    foreach (Beatmap b in BeatmapInfoRequestList)
                    {
                        b.submissionStatus = SubmissionStatus.NotSubmitted;
                        b.PlayerRank       = Rankings.N;
                    }

                    foreach (bBeatmapInfo bmi in reply.beatmapInfo)
                    {
                        Beatmap b = BeatmapInfoRequestList[bmi.id];

                        if (bmi.checksum != b.BeatmapChecksum)
                        {
                            b.submissionStatus = SubmissionStatus.UpdateAvailable;
                        }
                        else
                        {
                            switch (bmi.ranked)
                            {
                            case 2:
                                b.submissionStatus = SubmissionStatus.Approved;
                                break;

                            case 1:
                                b.submissionStatus = SubmissionStatus.Ranked;
                                break;

                            default:
                                b.submissionStatus = SubmissionStatus.Pending;
                                break;
                            }
                        }

                        b.BeatmapId      = bmi.beatmapId;
                        b.BeatmapSetId   = bmi.beatmapSetId;
                        b.BeatmapTopicId = bmi.threadId;
                        b.PlayerRank     = bmi.playerRank;
                    }

                    BeatmapInfoRequestList = null;
                }
                if (NewBeatmapInfo != null)
                {
                    NewBeatmapInfo(null, null);
                }
            }
            catch (Exception e)
            {
                BanchoClient.HandleException(e, "beatmap info reply");
            }
        }
예제 #17
0
        public string GetUsername(int userId)
        {
            try
            {
                return(BanchoClient.GetUserById(userId).Name);
            }
            catch { }

            return(string.Empty);
        }
예제 #18
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));
        }
예제 #19
0
 public void Leave()
 {
     if (Joined)
     {
         BanchoClient.SendRequest(RequestType.Osu_ChannelLeave, new bString(Name));
         Joined        = false;
         Joining       = false;
         messageToSend = "";
     }
 }
예제 #20
0
        private void OnDisbandGame(object sender, EventArgs e)
        {
            if (!JoinedGame)
            {
                return;
            }
            JoinedGame = false;

            BanchoClient.SendRequest(RequestType.Osu_MatchPart, null);
        }
예제 #21
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);
     }
 }
예제 #22
0
 private static void JoinLobby()
 {
     if (Joined)
     {
         return;
     }
     Joined = true;
     Matches.Clear();
     Status = LobbyStatus.Idle;
     BanchoClient.SendRequest(RequestType.Osu_LobbyJoin, null);
 }
예제 #23
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;
            }
        }
예제 #24
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;
        }
예제 #25
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);
        }
예제 #26
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);
 }
예제 #27
0
        internal static void DoOnClick()
        {
            if (PhysicalClickRegistered)
            {
                SpriteManager.ClickHandledSprite = null;
                BanchoClient.Activity();
            }

            SpriteManager.HandleClick(false);

            InputManager.TriggerEvent(InputEventType.OnClick);
        }
예제 #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;

                    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);
        }
예제 #29
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;
            }
        }
예제 #30
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"));
        }