Esempio n. 1
0
        private async Task <InhouseQueue> GetQueue(string queueName)
        {
            var queues = Context.Database.GetCollection <InhouseQueue>();
            var queue  = await InhouseQueue.GetQueueAsync(Context.Channel.Id, queueName, Context.Client, queues);

            if (queue == null)
            {
                throw new ArgumentException("Did not find any current inhouse queue for this channel.");
            }
            return(queue);
        }
Esempio n. 2
0
        private async Task DeleteQueue(string queueName)
        {
            var queues = Context.Database.GetCollection <InhouseQueue>();

            var existing = await InhouseQueue.GetQueueAsync(Context.Channel.Id, queueName, Context.Client, queues);

            if (existing != null)
            {
                queues.Delete(existing.Name);
                await Context.Channel.SendMessageAsync($"Queue {queueName} deleted.");
            }
            else
            {
                await Context.Channel.SendMessageAsync($"Queue {queueName} not found in this channel.");
            }
        }
Esempio n. 3
0
        private List <List <Player> > SplitQueue(TeamSize sizeHint, InhouseQueue queue, SplitMode splitMode)
        {
            if (queue == null)
            {
                return(null);
            }

            List <Player> players = queue.Players.Values.ToList <Player>();

            if (splitMode == SplitMode.Random)
            {
                return(SplitQueueRandom(players, sizeHint));
            }
            else if (splitMode == SplitMode.SkillGroup)
            {
                return(SplitQueueSkillGroup(players, sizeHint));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        private async Task <InhouseQueue> CreateQueue(string queueName)
        {
            var newQueue = new InhouseQueue(Context.Channel.Id, queueName);

            var queues = Context.Database.GetCollection <InhouseQueue>();

            // Delete current queue if exists
            try
            {
                var existing = await InhouseQueue.GetQueueAsync(Context.Channel.Id, queueName, Context.Client, queues);

                if (existing != null)
                {
                    queues.Delete(existing.Name);
                }
            }
            catch (Exception) { }

            // Insert into DB
            queues.Insert(newQueue);
            queues.EnsureIndex(x => x.Name);

            return(newQueue);
        }
Esempio n. 5
0
        public static async Task <IUserMessage> PlayersRemoved(IMessageChannel channel, InhouseQueue queue, List <Player> list)
        {
            string players = string.Join("\r\n", queue.Players.Select(p => p.Value.Username));

            return(await channel.SendMessageAsync($"Players were removed succesfully!\r\n\r\n Queue: {players}"));
        }
Esempio n. 6
0
 public static async Task <IUserMessage> QueueStarted(IMessageChannel channel, InhouseQueue queue)
 {
     return(await channel.SendMessageAsync($"New Inhouse Queue created named {queue.Name}!"));
 }