예제 #1
0
        public async Task EnableBonusesAsync()
        {
            if (!this.Manager.TryGet(this.Context.Channel.Id, out GameState game))
            {
                // This command only works during a game
                return;
            }
            else if (game.Format.HighestPhaseIndexWithBonus >= 0)
            {
                await this.Context.Channel.SendMessageAsync("Bonuses are already tracked.");

                return;
            }

            bool disableBuzzQueue;

            using (DatabaseAction action = this.DatabaseActionFactory.Create())
            {
                disableBuzzQueue = await action.GetDisabledBuzzQueueAsync(this.Context.Guild.Id);
            }

            // TODO: We should look into cloning the format and changing the HighestPhaseIndexWithBonus field. This
            // would require an argument for how many bonuses to read
            game.Format = Format.CreateTossupBonusesShootout(disableBuzzQueue);
            await this.Context.Channel.SendMessageAsync(
                "Bonuses are now being tracked. Scores for the current question have been cleared.");
        }
        public async Task GetDefaultFormatAsync()
        {
            Task <bool>   useBonuses;
            Task <bool>   disableBuzzQueue;
            Task <string> readerRolePrefix;
            Task <string> teamRolePrefix;

            using (DatabaseAction action = this.DatabaseActionFactory.Create())
            {
                // TODO: Should we make this one call so we don't need to await on all of them (and we could do it
                // with one SELECT instead of 3)?
                useBonuses       = action.GetUseBonusesAsync(this.Context.Guild.Id);
                disableBuzzQueue = action.GetDisabledBuzzQueueAsync(this.Context.Guild.Id);
                readerRolePrefix = action.GetReaderRolePrefixAsync(this.Context.Guild.Id);
                teamRolePrefix   = action.GetTeamRolePrefixAsync(this.Context.Guild.Id);
                await Task.WhenAll(useBonuses, disableBuzzQueue, readerRolePrefix, teamRolePrefix);
            }

            Logger.Information($"getDefaultFormat called in guild {this.Context.Guild.Id} by user {this.Context.User.Id}");
            EmbedBuilder builder = new EmbedBuilder()
            {
                Title       = "Default Format",
                Description = "The default settings for games in this server"
            };

            builder.AddField("Require scoring bonuses?", useBonuses.Result ? "Yes" : "No");
            builder.AddField("Queue buzzes?", disableBuzzQueue.Result ? "No" : "Yes");
            builder.AddField(
                "Reader role prefix?", readerRolePrefix.Result == null ? "None set" : @$ "Yes: " "{readerRolePrefix.Result}" "");
            builder.AddField(
                "Team role prefix?", teamRolePrefix.Result == null ? "None set" : @$ "Yes: " "{teamRolePrefix.Result}" "");

            await this.Context.Channel.SendMessageAsync(embed : builder.Build());
        }
예제 #3
0
        public async Task DisableBonusesAsync()
        {
            if (!this.Manager.TryGet(this.Context.Channel.Id, out GameState game))
            {
                // This command only works during a game
                return;
            }
            else if (game.Format.HighestPhaseIndexWithBonus < 0)
            {
                await this.Context.Channel.SendMessageAsync("Bonuses are already untracked.");

                return;
            }

            bool alwaysUseBonuses;
            bool disableBuzzQueue;

            using (DatabaseAction action = this.DatabaseActionFactory.Create())
            {
                bool[] getTasks = await Task.WhenAll(
                    action.GetUseBonusesAsync(this.Context.Guild.Id),
                    action.GetDisabledBuzzQueueAsync(this.Context.Guild.Id));

                alwaysUseBonuses = getTasks[0];
                disableBuzzQueue = getTasks[1];
            }

            // TODO: We should look into cloning the format and changing the HighestPhaseIndexWithBonus field. This
            // would require another argument for the enable command, though, since it requires a number
            game.Format = Format.CreateTossupShootout(disableBuzzQueue);

            if (alwaysUseBonuses)
            {
                await this.Context.Channel.SendMessageAsync(
                    "Bonuses are no longer being tracked for this game only. Run !disableBonusesByDefault to stop " +
                    "tracking bonuses on this server by default.\nScores for the current question have been cleared.");

                return;
            }

            await this.Context.Channel.SendMessageAsync(
                "Bonuses are no longer being tracked. Scores for the current question have been cleared.");
        }