Beispiel #1
0
        public void NSCRSG()
        {
            if (CurrentRoom == null) {
                ez.Discard();
                return;
            }

            if (!RequiresAuthentication()) return;

            byte pickResponseStatus = ez.Read1();

            string pickName = ez.ReadNT();
            string pickArtist = ez.ReadNT();
            string pickAlbum = ez.ReadNT();

            switch (pickResponseStatus) {
                case 0: // Player has song
                    ez.Discard();
                    return;

                case 1: // Player does not have song
                    mainClass.SendChatAll(NameFormat() + " does " + Func.ChatColor("aa0000") + "not" + Func.ChatColor("ffffff") + " have that song!", CurrentRoom);
                    ez.Discard();
                    return;
            }

            if (CurrentRoom.Free || CanChangeRoomSettings()) {
                if (CurrentRoom.CurrentSong.Name == pickName &&
                    CurrentRoom.CurrentSong.Artist == pickArtist &&
                    CurrentRoom.CurrentSong.SubTitle == pickAlbum) {
                    User[] pickUsers = GetUsersInRoom();

                    bool canStart = true;
                    string cantStartReason = "";

                    foreach (User user in pickUsers) {
                        if (user.CurrentScreen != NSScreen.Room) {
                            canStart = false;
                            cantStartReason = user.NameFormat() + " is not ready yet!";
                        }
                    }

                    if (canStart) {
                        foreach (User user in pickUsers) {
                            Data.AddSong(true, this);
                            user.SendSong(true);
                            user.SendGameStatus();
                        }
                    } else
                        mainClass.SendChatAll(cantStartReason, CurrentRoom);
                } else {
                    User[] pickUsers = GetUsersInRoom();

                    bool canStart = true;
                    string cantStartReason = "";

                    foreach (User user in pickUsers) {
                        if (user.CurrentScreen != NSScreen.Room) {
                            canStart = false;
                            cantStartReason = user.NameFormat() + " is not ready yet!";
                        }
                    }

                    if (canStart) {
                        Song newSong = new Song();

                        newSong.Name = pickName;
                        newSong.Artist = pickArtist;
                        newSong.SubTitle = pickAlbum;

                        CurrentRoom.CurrentSong = newSong;

                        int pickSongPlayed = 0;
                        Hashtable pickSongRow = Data.AddSong(false, this);
                        if (pickSongRow != null) {
                            pickSongPlayed = (int)pickSongRow["Played"];
                            newSong.Time = (int)pickSongRow["Time"];
                        }

                        mainClass.SendChatAll(NameFormat() + " selected " + Func.ChatColor("00aa00") + pickName + Func.ChatColor("ffffff") + ", which has " + (pickSongPlayed == 0 ? "never been played." : (pickSongPlayed > 1 ? "been played " + pickSongPlayed.ToString() + " times." : "been played only once.")), CurrentRoom);

                        foreach (User user in pickUsers) {
                            user.SendSong(false);
                            user.SongTime.Reset();
                        }
                    } else
                        mainClass.SendChatAll(cantStartReason, CurrentRoom);
                }
            } else {
                ez.Discard();
                SendChatMessage("You are not the room owner. Ask " + CurrentRoom.Owner.NameFormat() + " for /free");
            }
        }
Beispiel #2
0
        public void NSCRSG()
        {
            if (CurrentRoom == null)
            {
            ez.Discard();
            return;
            }

            if (!RequiresAuthentication()) return;

            byte pickResponseStatus = ez.Read1();

            string pickName = ez.ReadNT();
            string pickArtist = ez.ReadNT();
            string pickAlbum = ez.ReadNT();

            int timewaited;
            if ( (SelectTime.ElapsedMilliseconds < 751) && (SelectTime.ElapsedMilliseconds != 0) )
            {
            timewaited = 0;
            }
            else
            {
            timewaited = 1;
            }
            SelectTime.Restart();

            if (mSongScanner != null && mSongScanner.IsScanning())
            {
            string packname = mSongScanner.GetCurrentPackName();
            int packid = mSongScanner.GetCurrentPackID();
            switch (pickResponseStatus)
            {
            case 0: // Player has song
                CanPlay = SyncNeeded = true;
                //Has pack or not debug output in room
                //mainClass.SendChatAll(NameFormat() + " has pack: " + packname + " ID: " + packid, CurrentRoom);
                MySql.Query("INSERT INTO userpacks (userid,packid) VALUES('" + User_ID + "','" + packid + "')");
                ScanResponse = true;
                ez.Discard();
                break;

            case 1: // Player does not have song
                CanPlay = SyncNeeded = false;
                ScanResponse = true;
                ez.Discard();
                break;
            }

            mSongScanner.SendNextSong();
            return;
            }

            switch (pickResponseStatus)
            {
            case 0: // Player has song
            CanPlay = SyncNeeded = true;
            ez.Discard();
            return;

            case 1: // Player does not have song
            CanPlay = SyncNeeded = false;
            mainClass.SendChatAll(NameFormat() + " does " + Func.ChatColor("aa0000") + "not" + Func.ChatColor("ffffff") + " have that song!", CurrentRoom);
            ez.Discard();
            return;
            }

            User[] pickUsers = GetUsersInRoom();

            bool canStart = true;
            string cantStartReason = "";

            Song currentSong = CurrentRoom.CurrentSong;
            bool isNewSong = currentSong.Artist != pickArtist ||
                         currentSong.Name != pickName ||
                         currentSong.SubTitle != pickAlbum;

            foreach (User user in pickUsers)
            {
            if (user.CurrentScreen != NSScreen.Room)
            {
                canStart = false;
                cantStartReason = user.NameFormat() + " is not ready yet!";
                break;
            }
            else if (user.Scanning)
            {
                canStart = false;
                cantStartReason = user.NameFormat() + " is Pack Scanning!";
                break;
            }
            else if (timewaited == 0)
            {
                canStart = false;
                cantStartReason = "Please wait .75 seconds!!!";
                break;
            }
            else if (!user.CanPlay && !isNewSong && !newjoin )
            {
                canStart = false;
                cantStartReason = user.NameFormat() + " Lacks so not starting!";
                break;
            }
            }

            if (CurrentRoom.Free || CanChangeRoomSettings())
            {
            if (CurrentRoom.CurrentSong.Name == pickName &&
                    CurrentRoom.CurrentSong.Artist == pickArtist &&
                    CurrentRoom.CurrentSong.SubTitle == pickAlbum)
            {

                if (canStart)
                {
                    foreach (User user in pickUsers)
                    {
                        Data.AddSong(true, this);
                        user.SendSong(true);
                        user.SendGameStatus();
                    }
                }
                else
                    mainClass.SendChatAll(cantStartReason, CurrentRoom);
            }
            else
            {
                if (canStart)
                {
                    Song newSong = new Song();

                    newSong.Name = pickName;
                    newSong.Artist = pickArtist;
                    newSong.SubTitle = pickAlbum;

                    CurrentRoom.CurrentSong = newSong;

                    CurrentRoom.CurrentSong.PICKName = pickName;
                    CurrentRoom.CurrentSong.PICKArtist = pickArtist;
                    CurrentRoom.CurrentSong.PICKSubTitle = pickAlbum;

                    string htime = "";
                    int pickSongPlayed = 0;
                    int newSongID = 0;
                    Hashtable pickSongRow = Data.AddSong(false, this);
                    if (pickSongRow != null)
                    {
                        newSongID = (int)pickSongRow["ID"];
                        pickSongPlayed = (int)pickSongRow["Played"];
                        newSong.Time = (int)pickSongRow["Time"];
                        htime = Human(newSong.Time);
                    }

                    if (pickSongPlayed != 0 )
                    {
                        Hashtable pickSongPlayedRow = Data.SongPlayed(newSongID);
                        if ( (int)pickSongPlayedRow["Played"] < 1 )
                        {
                            pickSongPlayed = (int)pickSongPlayedRow["Played"];
                        }
                    }
            //	    int asciilength = pickName.Length;

            //	    int utf8length = Utf8Decode(pickName).Length;
            //	    int textdiff = asciilength - utf8length;
            //	    string chatname =  Utf8Decode(pickName);
            //	    for (int i = 0; i < textdiff; i++)
            //	    {
            //			chatname = "\n" + chatname + "\n";
            //	    }
                    if (newSong.Time != 0)
                    {
                        mainClass.SendChatAll(NameFormat() + " selected " + Func.ChatColor("00aa00") + pickName + Func.ChatColor("ffffff") + Func.ChatColor("ffffff") + ", which has " + (pickSongPlayed == 0 ? "never been played." : (pickSongPlayed > 1 ? "been played " + pickSongPlayed.ToString() + " times " : "never been played.") + " and is " + htime + " long." ), CurrentRoom);
                    }
                    else
                    {
                        mainClass.SendChatAll(NameFormat() + " selected " + Func.ChatColor("00aa00") + pickName + Func.ChatColor("ffffff") + Func.ChatColor("ffffff") + ", which has " + (pickSongPlayed == 0 ? "never been played." : (pickSongPlayed > 1 ? "been played " + pickSongPlayed.ToString() + " times." : "never been played.") ), CurrentRoom);
                    }
                    newjoin = false;
                    foreach (User user in pickUsers)
                    {
                        user.SendSong(false);
                        user.SongTime.Reset();
                    }
                }
                else
                    mainClass.SendChatAll(cantStartReason, CurrentRoom);
            }
            }
            else
            {
            ez.Discard();
            SendChatMessage("You are not the room owner. Ask " + CurrentRoom.Owner.NameFormat() + " for /free");
            }
        }