Ejemplo n.º 1
0
        public async Task TradeGold(int amount)
        {
            if (amount < 50000)
            {
                await Context.Channel.SendErrorAsync("You must enter a value over 50000.");

                return;
            }
            if (amount % 50000 != 0)
            {
                amount = (int)Math.Floor((double)amount / 50000) * 50000;
                await Context.Channel.SendErrorAsync($"The amount must be divisible by 50,000. Your amount has been rounded down accordingly to {amount}.");
            }

            //check they have the amount of gold they're claiming
            Woodcutting wc;

            using (var uow = DBHandler.UnitOfWork())
            {
                wc = uow.Woodcutting.GetOrCreateWoodcutting(Context.User.Id);
            }

            if (wc.Gold < amount)
            {
                await Context.Channel.SendErrorAsync("You do not have enough gold.");

                return;
            }

            //How many bells?
            var bellMulti  = amount / 50000;
            var bellAmount = bellMulti * 500;

            //Ok
            var dbConVal = new ValDBConnection(_config.ValDB, _logger);

            //Okay
            var result = await dbConVal.AddCurrencyForUser(Context.User.Id, bellAmount);

            if (!result)
            {
                await Context.Channel.SendErrorAsync($"Failed while adding your bells. No gold has been taken, no bells have been added. Try again later.");

                return;
            }

            //Now lets remove the golod
            using (var uow = DBHandler.UnitOfWork())
            {
                //remove it
                uow.Woodcutting.AddGold(Context.User.Id, -amount);

                //Get wc
                wc = uow.Woodcutting.GetOrCreateWoodcutting(Context.User.Id);
            }

            //It's all G U C C I now
            await Context.Channel.SendSuccessAsync($"Woodcutting", $"You have converted {amount} gold into {bellAmount}🔔.\nYour new gold count is: {wc.Gold}\nPlease use Valeria to check your bell count. If there's an issue, please report it to Nicole (proof required to rectify any issues).", null, "Gamble it all away...");
        }
Ejemplo n.º 2
0
        private async Task Quote(int id)
        {
            var dbConVal = new ValDBConnection(_config.ValDB, _logger);

            //Got quote
            QuoteModel q = await dbConVal.GetQuoteByID(id);

            if (q != null)
            {
                await Context.Channel.SendMessageAsync($"`\"{q.Keyword.ToLower()}\" #{q.ID}` :mega: {q.Quote}");
            }
        }
Ejemplo n.º 3
0
        public async Task ValAward(int amount, IUser user)
        {
            if (_config.ValDB == "")
            {
                return;
            }

            //Lets GO NIB
            var dbConVal = new ValDBConnection(_config.ValDB, _logger);

            //Okay
            var result = await dbConVal.AddCurrencyForUser(user.Id, amount);

            if (!result)
            {
                await Context.Channel.SendErrorAsync($"Failed during database edit.");

                return;
            }

            await Context.Channel.SendSuccessAsync($"Added {amount} bells to user {user.Username}");
        }
Ejemplo n.º 4
0
        private async Task QuoteGuess(int timeout = 15)
        {
            //Limit
            if (timeout > 30)
            {
                timeout = 30;
            }

            var dbConVal = new ValDBConnection(_config.ValDB, _logger);

            //Got quote
            QuoteModel q = await dbConVal.GetRandomQuote();

            if (q == null)
            {
                return;
            }

            QuoteGame Game = new QuoteGame
            {
                Channel = Context.Channel.Id,
                Answer  = q.Keyword,
                Guesses = new HashSet <QGuess>()
            };

            if (_quoteGuessService.StartQG(Game, (DiscordSocketClient)Context.Client))
            {
                //Start game
                await Context.Channel.SendSuccessAsync("📣 Quote", $"{q.Quote}");

                //Wait timeout
                await Task.Delay(timeout * 1000);

                //End
                await _quoteGuessService.EndGameInChannel(Context.Guild, Context.Channel);
            }
        }