Added .qn and fixed .hangman bugs
This commit is contained in:
		@@ -62,15 +62,14 @@ namespace NadekoBot.Modules.Games.Common.Connect4
 | 
			
		||||
 | 
			
		||||
        private Timer _playerTimeoutTimer;
 | 
			
		||||
 | 
			
		||||
        /* rows = 4, columns = 3, total = 12
 | 
			
		||||
         * [][][][][][]
 | 
			
		||||
         * [][][][][][]
 | 
			
		||||
         * [][][][][][]
 | 
			
		||||
         * [][][][][][]
 | 
			
		||||
         * [][][][][][]
 | 
			
		||||
         * [][][][][][]
 | 
			
		||||
         * [][][][][][]
 | 
			
		||||
         * */
 | 
			
		||||
        /* [ ][ ][ ][ ][ ][ ]
 | 
			
		||||
         * [ ][ ][ ][ ][ ][ ]
 | 
			
		||||
         * [ ][ ][ ][ ][ ][ ]
 | 
			
		||||
         * [ ][ ][ ][ ][ ][ ]
 | 
			
		||||
         * [ ][ ][ ][ ][ ][ ]
 | 
			
		||||
         * [ ][ ][ ][ ][ ][ ]
 | 
			
		||||
         * [ ][ ][ ][ ][ ][ ]
 | 
			
		||||
         */
 | 
			
		||||
 | 
			
		||||
        public Connect4Game(ulong userId, string userName)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -67,8 +67,8 @@ namespace NadekoBot.Modules.Games.Common.Hangman
 | 
			
		||||
            Errors++;
 | 
			
		||||
            if (Errors > MaxErrors)
 | 
			
		||||
            {
 | 
			
		||||
                CurrentPhase = Phase.Ended;
 | 
			
		||||
                var _ = OnGameEnded(this, null);
 | 
			
		||||
                CurrentPhase = Phase.Ended;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -101,8 +101,8 @@ namespace NadekoBot.Modules.Games.Common.Hangman
 | 
			
		||||
                    if (input != Term.Word) // failed
 | 
			
		||||
                        return;
 | 
			
		||||
 | 
			
		||||
                    CurrentPhase = Phase.Ended;
 | 
			
		||||
                    var _ = OnGameEnded?.Invoke(this, userName);
 | 
			
		||||
                    CurrentPhase = Phase.Ended;
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -128,6 +128,7 @@ namespace NadekoBot.Modules.Games.Common.Hangman
 | 
			
		||||
                                                                            .Where(c => char.IsLetterOrDigit(c)))))
 | 
			
		||||
                {
 | 
			
		||||
                    var _ = OnGameEnded.Invoke(this, userName); //if all letters are guessed
 | 
			
		||||
                    CurrentPhase = Phase.Ended;
 | 
			
		||||
                }
 | 
			
		||||
                else //guessed but not last letter
 | 
			
		||||
                {
 | 
			
		||||
 
 | 
			
		||||
@@ -405,6 +405,16 @@ namespace NadekoBot.Modules.Music.Common
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int EnqueueNext(SongInfo song)
 | 
			
		||||
        {
 | 
			
		||||
            lock (locker)
 | 
			
		||||
            {
 | 
			
		||||
                if (Exited)
 | 
			
		||||
                    return -1;
 | 
			
		||||
                return Queue.AddNext(song);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void SetIndex(int index)
 | 
			
		||||
        {
 | 
			
		||||
            if (index < 0)
 | 
			
		||||
 
 | 
			
		||||
@@ -78,6 +78,27 @@ namespace NadekoBot.Modules.Music.Common
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int AddNext(SongInfo song)
 | 
			
		||||
        {
 | 
			
		||||
            song.ThrowIfNull(nameof(song));
 | 
			
		||||
            lock (locker)
 | 
			
		||||
            {
 | 
			
		||||
                if (MaxQueueSize != 0 && Songs.Count >= MaxQueueSize)
 | 
			
		||||
                    throw new QueueFullException();
 | 
			
		||||
                var curSong = Current.Song;
 | 
			
		||||
                if (curSong == null)
 | 
			
		||||
                {
 | 
			
		||||
                    Songs.AddLast(song);
 | 
			
		||||
                    return Songs.Count;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                var songlist = Songs.ToList();
 | 
			
		||||
                songlist.Insert(CurrentIndex + 1, song);
 | 
			
		||||
                Songs = new LinkedList<SongInfo>(songlist);
 | 
			
		||||
                return CurrentIndex + 1;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Next(int skipCount = 1)
 | 
			
		||||
        {
 | 
			
		||||
            lock(locker)
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,7 @@ namespace NadekoBot.Modules.Music
 | 
			
		||||
        //    return Task.CompletedTask;
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        private async Task InternalQueue(MusicPlayer mp, SongInfo songInfo, bool silent)
 | 
			
		||||
        private async Task InternalQueue(MusicPlayer mp, SongInfo songInfo, bool silent, bool queueFirst = false)
 | 
			
		||||
        {
 | 
			
		||||
            if (songInfo == null)
 | 
			
		||||
            {
 | 
			
		||||
@@ -110,8 +110,9 @@ namespace NadekoBot.Modules.Music
 | 
			
		||||
            int index;
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                _log.Info("Added");
 | 
			
		||||
                index = mp.Enqueue(songInfo);
 | 
			
		||||
                index = queueFirst
 | 
			
		||||
                    ? mp.EnqueueNext(songInfo)
 | 
			
		||||
                    : mp.Enqueue(songInfo);
 | 
			
		||||
            }
 | 
			
		||||
            catch (QueueFullException)
 | 
			
		||||
            {
 | 
			
		||||
@@ -175,13 +176,22 @@ namespace NadekoBot.Modules.Music
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        public async Task Queue([Remainder] string query)
 | 
			
		||||
        {
 | 
			
		||||
            _log.Info("Getting player");
 | 
			
		||||
            var mp = await _service.GetOrCreatePlayer(Context);
 | 
			
		||||
            _log.Info("Resolving song");
 | 
			
		||||
            var songInfo = await _service.ResolveSong(query, Context.User.ToString());
 | 
			
		||||
            _log.Info("Queueing song");
 | 
			
		||||
            try { await InternalQueue(mp, songInfo, false); } catch (QueueFullException) { return; }
 | 
			
		||||
            _log.Info("--------------");
 | 
			
		||||
            if ((await Context.Guild.GetCurrentUserAsync()).GetPermissions((IGuildChannel)Context.Channel).ManageMessages)
 | 
			
		||||
            {
 | 
			
		||||
                Context.Message.DeleteAfter(10);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
        public async Task QueueNext([Remainder] string query)
 | 
			
		||||
        {
 | 
			
		||||
            var mp = await _service.GetOrCreatePlayer(Context);
 | 
			
		||||
            var songInfo = await _service.ResolveSong(query, Context.User.ToString());
 | 
			
		||||
            try { await InternalQueue(mp, songInfo, false, true); } catch (QueueFullException) { return; }
 | 
			
		||||
            if ((await Context.Guild.GetCurrentUserAsync()).GetPermissions((IGuildChannel)Context.Channel).ManageMessages)
 | 
			
		||||
            {
 | 
			
		||||
                Context.Message.DeleteAfter(10);
 | 
			
		||||
 
 | 
			
		||||
@@ -1539,6 +1539,15 @@
 | 
			
		||||
  <data name="queue_usage" xml:space="preserve">
 | 
			
		||||
    <value>`{0}q Dream Of Venice`</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="queuenext_cmd" xml:space="preserve">
 | 
			
		||||
    <value>queuenext qn</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="queuenext_desc" xml:space="preserve">
 | 
			
		||||
    <value>Works the same as `{0}queue` command, except it enqueues the new song after the current one. **You must be in a voice channel**.</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="queuenext_usage" xml:space="preserve">
 | 
			
		||||
    <value>`{0}qn Dream Of Venice`</value>
 | 
			
		||||
  </data>
 | 
			
		||||
  <data name="queuesearch_cmd" xml:space="preserve">
 | 
			
		||||
    <value>queuesearch qs yqs</value>
 | 
			
		||||
  </data>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user