Ejemplo n.º 1
0
        private RotnBotUser AddRotnBotUser(SocketUser user)
        {
            var rotnBotUser = new RotnBotUser(user);

            AddRotnBotUser(rotnBotUser);
            return(rotnBotUser);
        }
Ejemplo n.º 2
0
        public async Task BuyChestAsync()
        {
            RotnBotUser user = _rotnBotUserService.GetUser(Context.Message.Author);
            int         cost = 30;

            if (user.Points < cost)
            {
                await ReplyAsync($"{Context.Message.Author}, you need { (cost - user.Points) } more points to afford a chest");

                return;
            }

            Random rnd       = new Random();
            int    newPoints = PoinstChests[rnd.Next(0, PoinstChests.Length)];

            user.Points -= cost;
            user.Points += newPoints;
            user.ChestsPurchased++;

            _rotnBotUserService.AddOrUpdateUser(user);

            StringBuilder sb = new StringBuilder();


            sb.AppendLine($"{Context.Message.Author} spent {cost} on a points chest");
            if (newPoints == 100)
            {
                sb.AppendLine(":moneybag::moneybag::moneybag: Jackpot! :moneybag::moneybag::moneybag:");
            }
            sb.AppendLine($"The chest contained {newPoints} points");
            sb.AppendLine($"{(newPoints >= cost ? "You gain" : "You lose")} {( newPoints - cost )} points");
            sb.AppendLine($"You have a new total of {user.Points} points");

            await ReplyAsync(sb.ToString());
        }
Ejemplo n.º 3
0
        private void UpdateRotnBotUser(RotnBotUser user)
        {
            RotnBotUser existingUser = RotnBotUserCollection.Where(e => e.DiscordUserId == user.DiscordUserId).FirstOrDefault();

            if (existingUser != null)
            {
                existingUser = user;
            }
            SaveJsonToDisk(Filenames.SteamIds, RotnBotUserCollection);
        }
Ejemplo n.º 4
0
        public void AddOrUpdateUser(RotnBotUser user)
        {
            RotnBotUser existingUser = GetUserByDiscordId(user.DiscordUserId);

            if (existingUser == null)
            {
                AddRotnBotUser(user);
            }
            else
            {
                UpdateRotnBotUser(user);
            }
        }
Ejemplo n.º 5
0
        public async Task MySteamId()
        {
            RotnBotUser user = _rotnBotUserService.GetUserByDiscordId(Context.Message.Author.Id);

            if (user != null)
            {
                await ReplyAsync($"{Context.Message.Author}, your steam ID is {user.SteamUserId}");
            }
            else
            {
                await ReplyAsync($"No Steam ID set for {Context.Message.Author}");
            }
        }
Ejemplo n.º 6
0
        public async Task SetMySteamId([Summary("The user's steam Id")] string steamId)
        {
            if (steamId.Length > 10)
            {
                long steamId64;
                if (long.TryParse(steamId, out steamId64))
                {
                    steamId = Convert64BitSteamID(steamId64);
                }
            }

            RotnBotUser rotnBotUser = _rotnBotUserService.GetUser(Context.Message.Author);

            rotnBotUser.SteamUserId = steamId;
            _rotnBotUserService.AddOrUpdateUser(rotnBotUser);

            await ReplyAsync("Steam ID set. For " + Context.Message.Author.ToString());
        }
Ejemplo n.º 7
0
        public async Task OpenChestAsync()
        {
            RotnBotUser user = _rotnBotUserService.GetUser(Context.Message.Author);

            if (user.LastChestOpened.Date == DateTime.Now.Date)
            {
                await ReplyAsync($"{Context.Message.Author} you have already opened your free points chest today.");

                return;
            }


            Random rnd       = new Random();
            int    newPoints = PoinstChests[rnd.Next(0, PoinstChests.Length)];

            user.LastChestOpened = DateTime.Now;
            user.Points         += newPoints;
            _rotnBotUserService.AddOrUpdateUser(user);

            await ReplyAsync($"{Context.Message.Author}, you have recieved {newPoints} {(newPoints > 1 ? "points" : "point")}\nYou now have {user.Points} {(user.Points > 1 ? "points" : "point")}");
        }
Ejemplo n.º 8
0
        public async Task MyPointsAsync()
        {
            RotnBotUser user = _rotnBotUserService.GetUser(Context.Message.Author);

            await ReplyAsync($"{Context.Message.Author}, you have {user.Points} points");
        }
Ejemplo n.º 9
0
 private void AddRotnBotUser(RotnBotUser user)
 {
     RotnBotUserCollection.Add(user);
     SaveJsonToDisk(Filenames.SteamIds, RotnBotUserCollection);
 }