コード例 #1
0
        public async Task BetAsync(int betAmount)
        {
            var user = await GameService.GetUserByID(Context.User.Id);

            if (betAmount <= 0)
            {
                await ReplyAsync("Bet must be greater than 0");

                return;
            }
            if (user is null)
            {
                await ReplyAsync("Unable to find User");

                return;
            }
            if (!await GameService.AddRonPoints(Context.User, -1 * betAmount))
            {
                await ReplyAsync("Not Enough Points");

                return;
            }


            int  winnings;
            Slot slot;

            (winnings, slot) = SlotService.Play(betAmount);
            await GameService.AddRonPoints(Context.User, winnings);

            await ReplyAsync($"```{slot.ToString()}```\n{Context.User.Username} received {winnings} RonPoints");
        }
コード例 #2
0
        public async Task OwOAsync([Remainder] string text)
        {
            if (!await GameService.AddRonPoints(Context.User, -2))
            {
                await ReplyAsync("Not Enough Points! Costs 2 RonPoints.".owo());

                return;
            }
            await ReplyAsync(text.owo());
        }
コード例 #3
0
        public async Task purgeAsync()
        {
            if (!await GameService.AddRonPoints(Context.User, -100))
            {
                await ReplyAsync("Not Enough Points! Costs 100 RonPoints.");

                return;
            }

            MarkovService.Purge();
            await ReplyAsync("Markov Brain Purged, Ronners!");
        }
コード例 #4
0
        public async Task BuyAsync(string ticker, int quantity)
        {
            if (quantity < 1)
            {
                await ReplyAsync("Invalid quantity. Must be greater than 0");

                return;
            }
            var upperTicker = ticker.ToUpperInvariant();

            RonStock stock = RonStockMarketService.GetStock(upperTicker);

            if (stock == null)
            {
                await ReplyAsync($"Stock {upperTicker} doesn't exist.");

                return;
            }

            int cost = stock.Price * quantity * -1;


            UserRonStock usr = await GameService.GetUserRonStockAsync(Context.User, upperTicker);


            if (!await GameService.AddRonPoints(Context.User, cost))
            {
                await ReplyAsync($"Can't Afford to buy {quantity} shares of {upperTicker} for {cost} rp.");

                return;
            }

            if (usr == null)
            {
                usr = new UserRonStock()
                {
                    UserID = Context.User.Id, Symbol = upperTicker, Quantity = quantity
                };
                await GameService.AddUserRonStock(usr);
            }
            else
            {
                usr.Quantity += quantity;
                await GameService.UpdateUserRonStock(usr);
            }

            await ReplyAsync($"Bought {quantity} shares of {upperTicker} for {cost} rp.");
        }
コード例 #5
0
        public async Task BetAsync(int betAmount, string typeString, params string [] bets)
        {
            var user = await GameService.GetUserByID(Context.User.Id);

            var bet = RouletteService.GetBet(typeString, bets);

            if (betAmount <= 0)
            {
                await ReplyAsync("Bet must be greater than 0");

                return;
            }
            if (bet.Type == BetType.Unknown)
            {
                await ReplyAsync("Unknown Bet Type");

                return;
            }
            if (!RouletteService.IsValid(bet))
            {
                await ReplyAsync("Invalid Bet");

                return;
            }
            if (user is null)
            {
                await ReplyAsync("Unable to find User");

                return;
            }
            if (!await GameService.AddRonPoints(Context.User, -1 * betAmount))
            {
                await ReplyAsync("Not Enough Points");

                return;
            }


            int    winnings;
            string result;

            (winnings, result) = RouletteService.GetResult(bet, betAmount);
            await GameService.AddRonPoints(Context.User, winnings);

            await ReplyAsync($"Roulette Rolled a {result}, resulting in {user.Username} winning {winnings} RonPoints");
        }
コード例 #6
0
        public async Task BetAsync(int betAmount, string bet)
        {
            var user = await GameService.GetUserByID(Context.User.Id);

            var betType = BaccaratService.GetBetType(bet);

            if (betAmount <= 0)
            {
                await ReplyAsync("Bet must be greater than 0");

                return;
            }
            if (betType == BaccaratBetType.Unknown)
            {
                await ReplyAsync("Unknown Bet Type");

                return;
            }
            if (user is null)
            {
                await ReplyAsync("Unable to find User");

                return;
            }
            if (!await GameService.AddRonPoints(Context.User, -1 * betAmount))
            {
                await ReplyAsync("Not Enough Points");

                return;
            }

            int    winnings;
            string result;

            (winnings, result) = BaccaratService.Play(betType, betAmount);
            await GameService.AddRonPoints(Context.User, winnings);

            if (winnings > 0)
            {
                await ReplyAsync($"{result}{user.Username} won {winnings} RonPoints!");
            }
            else
            {
                await ReplyAsync($"{result}{user.Username} lost {betAmount} RonPoints!");
            }
        }
コード例 #7
0
        public async Task SellAsync(string ticker, int quantity)
        {
            var upperTicker = ticker.ToUpperInvariant();

            if (quantity < 1)
            {
                await ReplyAsync($"Invalid quantity. Must be greater than 0");

                return;
            }

            RonStock stock = RonStockMarketService.GetStock(upperTicker);

            if (stock == null)
            {
                await ReplyAsync($"Stock {upperTicker} doesn't exist.");

                return;
            }
            UserRonStock usr = await GameService.GetUserRonStockAsync(Context.User, upperTicker);

            if (usr == null || usr.Quantity < quantity)
            {
                await ReplyAsync($"You don't own enough {upperTicker} to sell {quantity} shares.");

                return;
            }

            int cost = quantity * stock.Price;

            usr.Quantity -= quantity;
            if (usr.Quantity == 0)
            {
                await GameService.DeleteUserRonStock(usr);
            }
            else
            {
                await GameService.UpdateUserRonStock(usr);
            }

            await GameService.AddRonPoints(Context.User, cost);

            await ReplyAsync($"Sold {quantity} shares of {upperTicker} for {cost}.");
        }