Exemplo n.º 1
0
        public async Task SpinSlot(uint amount)
        {
            if (amount < 1)
            {
                await ReplyAsync("You can' spin for that amount of Miunies.\nAND YOU KNOW IT!");

                return;
            }
            var account = _globalUserAccounts.GetById(Context.User.Id);

            if (account.Miunies < amount)
            {
                await ReplyAsync($"Sorry but it seems like you don't have enough Minuies... You only have {account.Miunies}.");

                return;
            }

            account.Miunies -= amount;
            _globalUserAccounts.SaveAccounts(Context.User.Id);

            var slotEmojis       = Global.Slot.Spin();
            var payoutAndFlavour = Global.Slot.GetPayoutAndFlavourText(amount);

            if (payoutAndFlavour.Item1 > 0)
            {
                account.Miunies += payoutAndFlavour.Item1;
                _globalUserAccounts.SaveAccounts();
            }

            await ReplyAsync(slotEmojis);

            await Task.Delay(1000);

            await ReplyAsync(payoutAndFlavour.Item2);
        }
Exemplo n.º 2
0
        public async Task AddReminder([Remainder] string args)
        {
            string[] splittedArgs = null;
            if (args.Contains(" in "))
            {
                splittedArgs = args.Split(new string[] { " in " }, StringSplitOptions.None);
            }
            if (splittedArgs == null || splittedArgs.Length < 2)
            {
                await ReplyAsync("I think you are confused about how to use this command... aren't you?\n" +
                                 "Let me REMIND you it is: `remind DO THE THING! :rage: in 2d 23h 3m 12s`\n" +
                                 "And the ` in ` before the timeparameters is very important you little dumbo you...");

                return;
            }

            var timeString = splittedArgs[splittedArgs.Length - 1];

            if (timeString == "24h")
            {
                timeString = "1d";
            }

            splittedArgs[splittedArgs.Length - 1] = "";
            var reminderString = string.Join(" in ", splittedArgs, 0, splittedArgs.Length - 1);

            var timeDateTime = DateTime.UtcNow + TimeSpan.ParseExact(timeString, ReminderFormat.Formats, CultureInfo.CurrentCulture);

            var newReminder = new ReminderEntry(timeDateTime, reminderString);

            var account = _globalUserAccounts.GetById(Context.User.Id);

            account.Reminders.Add(newReminder);
            _globalUserAccounts.SaveAccounts(Context.User.Id);


            var          timezone  = account.TimeZone ?? "UTC";
            TimeZoneInfo tz        = TimeZoneInfo.FindSystemTimeZoneById($"{timezone}");
            var          localTime = TimeZoneInfo.ConvertTimeFromUtc(timeDateTime, tz);

            var bigmess2 =
                $"{reminderString}\n\n" +
                $"We will send you a DM in  __**{localTime}**__ `by {timezone}`\n";

            var embed = new EmbedBuilder();

            embed.WithAuthor(Context.User);
            embed.WithCurrentTimestamp();
            embed.WithColor(Color.Blue);
            embed.WithTitle("I will remind you through DM:");
            embed.AddField($"**____**", $"{bigmess2}");

            ReplyAsync("", false, embed.Build());
        }
Exemplo n.º 3
0
        public async Task Gift(uint taiyaki, IGuildUser userB)
        {
            var config = GlobalGuildAccounts.GetGuildAccount(Context.Guild.Id);
            var giver  = GlobalUserAccounts.GetUserAccount(Context.User);

            if (giver.Taiyaki < taiyaki)
            {
                await ReplyAsync(
                    $":angry:  **|** Stop trying to gift an amount of {config.Currency} over your account balance! ");
            }
            else
            {
                if (userB == null)
                {
                    var embed = new EmbedBuilder();
                    embed.WithColor(Global.NayuColor);
                    embed.WithTitle(
                        $"🖐️ **|** Please say who you want to gift {config.Currency} to. Ex: n!gift <amount of {config.Currency}s> @user");
                    await SendMessage(Context, embed.Build());
                }
                else
                {
                    var recipient = GlobalUserAccounts.GetUserAccount((SocketUser)userB);

                    giver.Taiyaki     -= taiyaki;
                    recipient.Taiyaki += taiyaki;
                    GlobalUserAccounts.SaveAccounts(giver.Id, recipient.Id);

                    await SendMessage(Context, null,
                                      $"✅  **|** {Context.User.Mention} has gifted {userB.Mention} {taiyaki} {config.Currency}(s). How generous.");
                }
            }
        }
Exemplo n.º 4
0
        internal static TransferResult UserToUser(IUser from, IUser to, ulong amount)
        {
            if (from.Id == to.Id)
            {
                return(TransferResult.SelfTransfer);
            }

            if (to.Id == Global.Client.CurrentUser.Id)
            {
                return(TransferResult.TransferToBot);
            }

            var transferSource = GlobalUserAccounts.GetUserAccount(from.Id);

            if (transferSource.Miunies < amount)
            {
                return(TransferResult.NotEnoughMiunies);
            }

            var transferTarget = GlobalUserAccounts.GetUserAccount(to.Id);

            transferSource.Miunies -= amount;
            transferTarget.Miunies += amount;

            GlobalUserAccounts.SaveAccounts(transferSource.Id, transferTarget.Id);

            return(TransferResult.Success);
        }
Exemplo n.º 5
0
        public static AttackResult MeditateAttack(ShardedCommandContext context, Core.Entities.Chomusuke chom)
        {
            var    config = GlobalUserAccounts.GetUserAccount(context.User);
            string response;
            bool   success = false;
            var    dmg     = 0;

            if (chom.Effects.Contains(Effect.Meditating))
            {
                response = $"{chom.Name} has already meditated! Try Again!";
            }
            else if (chom.Effects.Contains(Effect.Blocking))
            {
                response = $"{chom.Name} cannot meditate while in blocking formation! Try Again!";
            }
            else if (chom.Effects.Contains(Effect.Deflecting))
            {
                response = $"{chom.Name} cannot meditate while in deflecting formation! Try Again!";
            }
            else
            {
                response =
                    $":shield:  **|** **{config.OpponentName}**, {chom.Name} just meditated! \n\n**{config.OpponentName}**'s next attack will deal 30% more damage";
                chom.Effects.Add(Effect.Meditating);
                GlobalUserAccounts.SaveAccounts(config.Id);
                success = true;
            }

            return(new AttackResult {
                Success = success, Response = response, Damage = dmg
            });
        }
Exemplo n.º 6
0
Arquivo: Duels.cs Projeto: Phytal/Nayu
        public async Task EndFight()
        {
            var config  = GlobalUserAccounts.GetUserAccount(Context.User);
            var configg = GlobalUserAccounts.GetUserAccount(config.OpponentId);

            await ReplyAsync(":flag_white:  **|** " + Context.User.Mention + " ended the fight.");

            var choms = ActiveChomusuke.GetActiveChomusuke(Context.User.Id, config.OpponentId);
            var chom1 = choms.Item1;
            var chom2 = choms.Item2;

            config.Fighting      = false;
            configg.Fighting     = false;
            chom1.Health         = chom1.HealthCapacity;
            chom2.Health         = chom2.HealthCapacity;
            config.OpponentId    = 0;
            configg.OpponentId   = 0;
            config.OpponentName  = null;
            configg.OpponentName = null;
            config.WhosTurn      = null;
            config.WhoWaits      = null;
            config.PlaceHolder   = null;
            configg.WhosTurn     = null;
            configg.WhoWaits     = null;
            chom1.Effects?.Clear();
            chom2.Effects?.Clear();
            chom1.PotionEffects?.Clear();
            chom2.PotionEffects?.Clear();

            GlobalUserAccounts.SaveAccounts(config.Id, configg.Id);
        }
Exemplo n.º 7
0
        public static async Task OpenRareBox(SocketUser user, ITextChannel channel)
        {
            var config = GlobalUserAccounts.GetUserAccount(user);

            var embed = new EmbedBuilder()
                        .WithColor(Global.NayuColor)
                        .WithImageUrl("https://i.imgur.com/0oB1JXq.png");

            embed.Title       = "Rare Lootbox";
            embed.Description = $"**{user.Username}** opened a **RARE** Lootbox!";
            ushort taiyakies = (ushort)Global.Rng.Next(320, 500);

            config.Taiyaki += taiyakies;
            embed.AddField("Taiyakis", taiyakies);

            config.NormalCapsule += 1;
            embed.AddField("Chomusuke Item", "Normal Chomusuke Capsule (Open it with `n!openCapsule`!)");

            string item = ItemProbability.DuelsItemProbabiliy(user, 'r');

            embed.AddField("Duels Item", $"{item} (x1)");


            GlobalUserAccounts.SaveAccounts(config.Id);
            await channel.SendMessageAsync("", embed : embed.Build());
        }
Exemplo n.º 8
0
        public static async Task OpenLegendaryBox(SocketUser user, ITextChannel channel)
        {
            var config  = GlobalUserAccounts.GetUserAccount(user);
            var configg = GlobalUserAccounts.GetUserAccount(user);

            var embed = new EmbedBuilder()
                        .WithColor(Global.NayuColor)
                        .WithImageUrl("https://i.imgur.com/SfibEDJ.png");

            embed.Title       = "Legendary Lootbox";
            embed.Description = $"**{user.Username}** opened a **LEGENDARY** Lootbox!";
            ushort taiyakies = (ushort)Global.Rng.Next(800, 1200);

            config.Taiyaki += taiyakies;
            embed.AddField("Taiyakis", taiyakies);

            int chomusukeBool = Global.Rng.Next(1, 3);

            if (chomusukeBool == 1 || chomusukeBool == 2)
            {
                configg.MythicalCapsule += 1;
                embed.AddField("Chomusuke Item", "Mythical Chomusuke Capsule (Open it with `n!openCapsule`!)");

                GlobalUserAccounts.SaveAccounts(config.Id);

                string item = ItemProbability.DuelsItemProbabiliy(user, 'l');
                embed.AddField("Duels Item", $"{item} (x1)");

                await channel.SendMessageAsync("", embed : embed.Build());
            }
        }
Exemplo n.º 9
0
        public static async Task Reset(ShardedCommandContext context, Core.Entities.Chomusuke chom1,
                                       Core.Entities.Chomusuke chom2)
        {
            var config  = GlobalUserAccounts.GetUserAccount(context.User);
            var player2 = context.Guild.GetUser(config.OpponentId);
            var configg = GlobalUserAccounts.GetUserAccount(player2);

            config.Fighting      = false;
            configg.Fighting     = false;
            chom1.Health         = chom1.HealthCapacity;
            chom2.Health         = chom2.HealthCapacity;
            config.OpponentId    = 0;
            configg.OpponentId   = 0;
            config.OpponentName  = null;
            configg.OpponentName = null;
            config.WhosTurn      = null;
            config.WhoWaits      = null;
            config.PlaceHolder   = null;
            configg.WhosTurn     = null;
            configg.WhoWaits     = null;
            chom1.Effects?.Clear();
            chom2.Effects?.Clear();
            chom1.PotionEffects?.Clear();
            chom2.PotionEffects?.Clear();
            await ActiveChomusuke.ConvertActiveVariable(context.User.Id, config.OpponentId, chom1, chom2);

            GlobalUserAccounts.SaveAccounts(config.Id, configg.Id);
        }
Exemplo n.º 10
0
        public static async Task Burned(ShardedCommandContext context)
        {
            var config = GlobalUserAccounts.GetUserAccount(context.User);
            var chom   = ActiveChomusuke.GetOneActiveChomusuke(config.Id);

            var dmg = (uint)Global.Rng.Next(2, 5);

            if (!chom.Effects.Contains(Effect.Burned))
            {
                return;
            }
            var rng = Global.Rng.Next(1, 5);

            if (rng == 4)
            {
                chom.Effects.Remove(Effect.Burned);
                GlobalUserAccounts.SaveAccounts(config.Id);
                await SendMessage(context, null, $"{chom.Name} stopped burning!");

                return;
            }

            chom.Health -= dmg;
            GlobalUserAccounts.SaveAccounts(config.Id);
            await SendMessage(context, null, $"{chom.Name} took {dmg} from being burned!");
        }
Exemplo n.º 11
0
        internal static async Task MessageRewards(SocketGuildUser user, SocketTextChannel channel, SocketMessage msg)
        {
            if (msg == null)
            {
                return;
            }
            if (msg.Channel == msg.Author.GetOrCreateDMChannelAsync())
            {
                return;
            }
            if (msg.Author.IsBot)
            {
                return;
            }

            var      userAccount = GlobalUserAccounts.GetUserAccount(user);
            DateTime now         = DateTime.UtcNow;

            if (now < userAccount.LastMessage.AddSeconds(Constants.MessageRewardCooldown) || msg.Content.Length < Constants.MessageRewardMinLenght)
            {
                return;
            }

            // Generate a randomized reward in the configured boundries
            userAccount.Money      += (ulong)Global.Rng.Next(Constants.MessagRewardMinMax.Item1, Constants.MessagRewardMinMax.Item2 + 1);
            userAccount.LastMessage = now;

            GlobalUserAccounts.SaveAccounts();

            return;
        }
Exemplo n.º 12
0
        public async Task OpenMessageCommand(ulong id)
        {
            var config = GlobalUserAccounts.GetUserAccount(Context.User);

            if (id < 1 || id > config.InboxIDTracker)
            {
                throw new ArgumentException("Please enter a valid ID");
            }

            if (!config.Inbox.Any())
            {
                throw new ArgumentException("You don't have any messages to open! (Empty Inbox)");
            }

            var validMessages = config.Inbox.Where(i => i.ID == id);

            foreach (var msg in validMessages)
            {
                string readIcon = null;
                if (!msg.Read)
                {
                    readIcon = ":small_blue_diamond: ";
                }
                var embB = new EmbedBuilder()
                           .WithTitle($"{readIcon}{msg.Title}")
                           .WithDescription(msg.Content)
                           .WithFooter($"Accessed {DateTime.Now:f}")
                           .WithColor(Global.NayuColor);
                msg.Read = true;
                GlobalUserAccounts.SaveAccounts(Context.User.Id);
                await ReplyAsync("", false, embB.Build());

                break;
            }
        }
Exemplo n.º 13
0
        public async Task DeleteMessageCommand(ulong id)
        {
            var config = GlobalUserAccounts.GetUserAccount(Context.User);

            if (id < 1 || id > config.InboxIDTracker)
            {
                throw new ArgumentException("Please enter a valid ID");
            }

            if (!config.Inbox.Any())
            {
                throw new ArgumentException("You don't have any messages to delete! (Empty Inbox)");
            }

            var validMessages = config.Inbox.Where(i => i.ID == id);

            foreach (var msg in validMessages)
            {
                config.Inbox.Remove(msg);
                GlobalUserAccounts.SaveAccounts(id);
                await ReplyAsync($"Deleted message **({msg.Title})**.");

                break;
            }
        }
Exemplo n.º 14
0
        public async Task ClearListFromConfig()
        {
            var guildUser = Context.User as SocketGuildUser;

            if (!guildUser.GuildPermissions.Administrator)
            {
                string description =
                    $"{Global.ENo} **|** You Need the **Administrator** Permission to do that {Context.User.Username}";
                var errorEmbed = EmbedHandler.CreateEmbed(Context, "Error", description,
                                                          EmbedHandler.EmbedMessageType.Exception);
                await ReplyAndDeleteAsync("", embed : errorEmbed);

                return;
            }

            var config = GlobalGuildAccounts.GetGuildAccount(Context.Guild.Id);
            var embed  = new EmbedBuilder();

            embed.WithColor(Global.NayuColor);
            if (config == null)
            {
                embed.WithDescription("You don't have a Guild Config created.");
            }
            else
            {
                embed.WithDescription($"Cleared {config.SelfRoles.Count} roles from the self role list.");
                config.SelfRoles.Clear();
                GlobalUserAccounts.SaveAccounts(Context.Guild.Id);
            }

            await SendMessage(Context, embed.Build());
        }
Exemplo n.º 15
0
        public async Task Endfight()
        {
            var config  = GlobalUserAccounts.GetUserAccount(Context.User);
            var configg = GlobalUserAccounts.GetUserAccount(config.OpponentId);

            await ReplyAsync(":flag_white:  | " + Context.User.Mention + " ended the fight.");

            config.Fighting      = false;
            configg.Fighting     = false;
            config.Health        = 100;
            configg.Health       = 100;
            config.OpponentId    = 0;
            configg.OpponentId   = 0;
            config.OpponentName  = null;
            configg.OpponentName = null;
            config.whosTurn      = null;
            config.whoWaits      = null;
            config.placeHolder   = null;
            configg.whosTurn     = null;
            configg.whoWaits     = null;
            configg.placeHolder  = null;
            config.Meds          = 6;
            configg.Meds         = 6;
            config.Blocking      = false;
            configg.Blocking     = false;
            configg.Deflecting   = false;
            config.Deflecting    = false;
            config.Wins         += 1;
            configg.Losses      += 1;
            GlobalUserAccounts.SaveAccounts();
        }
Exemplo n.º 16
0
        private async void CheckReminders(object sender, ElapsedEventArgs e)
        {
            var now = DateTime.UtcNow;
            // Get all accounts that have at least one reminder that needs to be sent out
            var accounts = _globalUserAccounts.GetFilteredAccounts(acc => acc.Reminders.Any(rem => rem.DueDate < now));

            foreach (var account in accounts)
            {
                var guildUser = Global.Client.GetUser(account.Id);
                var dmChannel = await guildUser?.GetOrCreateDMChannelAsync();

                if (dmChannel == null)
                {
                    return;
                }

                var toBeRemoved = new List <ReminderEntry>();

                foreach (var reminder in account.Reminders)
                {
                    if (reminder.DueDate >= now)
                    {
                        continue;
                    }
                    dmChannel.SendMessageAsync(reminder.Description);
                    // Usage of a second list because trying to use
                    // accountReminders.Remove(reminder) would break the foreach loop
                    toBeRemoved.Add(reminder);
                }
                // Remove all elements that needs to be removed
                toBeRemoved.ForEach(remRem => account.Reminders.Remove(remRem));
                _globalUserAccounts.SaveAccounts(account.Id);
            }
        }
Exemplo n.º 17
0
        public static async Task OpenCommonBox(SocketUser user, ITextChannel channel)
        {
            var config = GlobalUserAccounts.GetUserAccount(user);

            var embed = new EmbedBuilder()
                        .WithColor(Global.NayuColor)
                        .WithImageUrl("https://i.imgur.com/3kCtn6V.png");

            embed.Title       = "Common Lootbox";
            embed.Description = $"**{user.Username}** opened a **COMMON** Lootbox!";
            byte taiyakies = (byte)Global.Rng.Next(50, 100);

            config.Taiyaki += taiyakies;
            embed.AddField("Taiyakis", taiyakies);

            config.NormalCapsule += 1;
            embed.AddField("Chomusuke Item", "Normal Chomusuke Capsule (Open it with `n!openCapsule`!)");
            int duelBool = Global.Rng.Next(1, 4); //2/3 chance

            if (duelBool == 1 || duelBool == 2)
            {
                string item = ItemProbability.DuelsItemProbabiliy(user, 'c');
                embed.AddField("Duels Item", $"{item} (x1)");
            }

            GlobalUserAccounts.SaveAccounts(config.Id);
            await channel.SendMessageAsync("", embed : embed.Build());
        }
Exemplo n.º 18
0
        public static Tuple <int, int> GetDMGModifiers(SocketUser attacker, SocketUser defender, int dmg)
        {
            var config   = GlobalUserAccounts.GetUserAccount(attacker);
            var choms    = ActiveChomusuke.GetActiveChomusuke(attacker.Id, defender.Id);
            var chom1    = choms.Item1;
            var chom2    = choms.Item2;
            int modifier = 0;

            if (chom1.PotionEffects.Keys.Contains("Strength"))
            {
                modifier += chom1.PotionEffects["Strength"];
            }
            if (chom2.PotionEffects.Keys.Contains("Debuff"))
            {
                modifier += chom2.PotionEffects["Debuff"];
            }
            if (chom1.Effects.Contains(Effect.Meditating))
            {
                modifier += 30;
                chom1.Effects.Remove(Effect.Meditating);
                GlobalUserAccounts.SaveAccounts(config.Id);
            }

            if (Helpers.GetCritical())
            {
                modifier += 20;
            }
            if (config.Blessing == "Blessing Of Strength")
            {
                modifier += 10;
            }
            int newdmg = (modifier / 100 + 1) * dmg;

            return(new Tuple <int, int>(newdmg, modifier));
        }
Exemplo n.º 19
0
        public static async Task OpenUncommonBox(SocketUser user, ITextChannel channel)
        {
            var config = GlobalUserAccounts.GetUserAccount(user);

            var embed = new EmbedBuilder()
                        .WithColor(Global.NayuColor)
                        .WithImageUrl("https://i.imgur.com/EOEhmXS.png");

            embed.Title       = "Uncommon Lootbox";
            embed.Description = $"**{user.Username}** opened an **UNCOMMON** Lootbox!";
            ushort taiyakies = (ushort)Global.Rng.Next(150, 301);

            config.Taiyaki += taiyakies;
            embed.AddField("Taiyakis", taiyakies);

            byte chomusukeBool = (byte)Global.Rng.Next(1, 4);

            if (chomusukeBool == 1 || chomusukeBool == 2)
            {
                config.NormalCapsule += 1;
                embed.AddField("Chomusuke Item", "Normal Chomusuke Capsule (Open it with `n!openCapsule`!)");
            }


            string item = ItemProbability.DuelsItemProbabiliy(user, 'u');

            embed.AddField("Duels Item", $"{item} (x1)");

            GlobalUserAccounts.SaveAccounts(config.Id);

            await channel.SendMessageAsync("", embed : embed.Build());
        }
Exemplo n.º 20
0
        /// <summary>
        /// Checks if the opponent is blocking.
        /// Returns: Success, Blocked Damage, Taken Damage
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="defender"></param>
        /// <param name="dmg"></param>
        /// <returns> Success, Blocked Damage, Taken Damage</returns>
        public static Tuple <bool, int, int> CheckForBlock(SocketUser attacker, SocketUser defender, int dmg)
        {
            var config = GlobalUserAccounts.GetUserAccount(defender);
            var choms  = ActiveChomusuke.GetActiveChomusuke(attacker.Id, defender.Id);
            var chom1  = choms.Item1;
            var chom2  = choms.Item2;

            int finaldmg2 = 0, finaldmg1 = 0;

            if (chom1.PotionEffects.ContainsKey("Speed"))
            {
                chom2.Effects.Remove(Effect.Blocking);
                ActiveChomusuke.ConvertActiveVariable(attacker.Id, config.OpponentId, chom1, chom2);
                return(new Tuple <bool, int, int>(true, 0, 0));
            }

            if (chom2.Effects.Contains(Effect.Blocking))
            {
                finaldmg1 = dmg * (3 / 4); //blocked dmg
                finaldmg2 = dmg * (1 / 4); //taken dmg
                chom2.Effects.Remove(Effect.Blocking);

                return(new Tuple <bool, int, int>(true, finaldmg1, finaldmg2));
            }

            GlobalUserAccounts.SaveAccounts(config.Id);
            return(new Tuple <bool, int, int>(false, 0, 0)); // use for values
        }
Exemplo n.º 21
0
        public async Task ClearInboxCommand()
        {
            var config = GlobalUserAccounts.GetUserAccount(Context.User);

            if (!config.Inbox.Any())
            {
                throw new ArgumentException("Your inbox is already empty!");
            }

            await ReplyAsync(
                "Are you sure you want to clear your inbox? (This cannot be reversed!)\nType `yes` or `no` to confirm your decision");

            var response = await NextMessageAsync();

            if (response.Content.Equals("yes", StringComparison.CurrentCultureIgnoreCase) &&
                (response.Author.Equals(Context.User)))
            {
                config.Inbox.Clear();
                GlobalUserAccounts.SaveAccounts(Context.User.Id);
                await ReplyAsync($"✅  **|** Cleared your inbox!");
            }

            else if (response.Content.Equals("no", StringComparison.CurrentCultureIgnoreCase) &&
                     (response.Author.Equals(Context.User)))
            {
                await ReplyAsync($"✅ **|** Successfully canceled the action.");
            }
            else
            {
                throw new ArgumentException("Please enter a valid response `(yes/no)`.");
            }
        }
Exemplo n.º 22
0
        public static Tuple <bool, int> CheckForDeflect(SocketUser attacker, SocketUser defender, int dmg)
        {
            var config   = GlobalUserAccounts.GetUserAccount(defender);
            var choms    = ActiveChomusuke.GetActiveChomusuke(attacker.Id, defender.Id);
            var chom1    = choms.Item1;
            var chom2    = choms.Item2;
            int finaldmg = 0;

            if (chom1.PotionEffects.ContainsKey("Speed"))
            {
                chom2.Effects.Remove(Effect.Deflecting);
                ActiveChomusuke.ConvertActiveVariable(attacker.Id, config.OpponentId, chom1, chom2);
                return(new Tuple <bool, int>(true, 0));
            }

            if (chom2.Effects.Contains(Effect.Deflecting))
            {
                finaldmg = dmg / 2; //damage taken and deflected
                chom2.Effects.Remove(Effect.Deflecting);
                return(new Tuple <bool, int>(true, finaldmg));
            }

            GlobalUserAccounts.SaveAccounts(config.Id);
            return(new Tuple <bool, int>(false, 0));
        }
Exemplo n.º 23
0
        public async Task WsashiStats([Remainder] string arg = "")
        {
            SocketUser target        = null;
            var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();

            target = mentionedUser ?? Context.User;

            var  userAccount = GlobalUserAccounts.GetUserAccount(target);
            uint Level       = userAccount.LevelNumber;

            GlobalUserAccounts.SaveAccounts();
            var xp         = userAccount.XP;
            var requiredXp = (Math.Pow(userAccount.LevelNumber + 1, 2) * 50);

            var thumbnailurl = target.GetAvatarUrl();
            var auth         = new EmbedAuthorBuilder()
            {
                Name    = target.Username,
                IconUrl = thumbnailurl,
            };

            var embed = new EmbedBuilder()
            {
                Author = auth
            };

            embed.WithColor(37, 152, 255);
            embed.AddField("Lvl.", Level, true);
            embed.AddField("Exp.", $"{xp}/{requiredXp} (tot. {userAccount.XP})", true);

            await Context.Channel.SendMessageAsync("", embed : embed.Build());
        }
Exemplo n.º 24
0
        public static Tuple <int, int> GetDMGModifiers(SocketUser attacker, SocketUser defender, int dmg)
        {
            var config   = GlobalUserAccounts.GetUserAccount(attacker);
            var configg  = GlobalUserAccounts.GetUserAccount(defender);
            int modifier = 0;

            if (configg.armour == "bronze")
            {
                modifier -= 5;
            }
            if (configg.armour == "steel")
            {
                modifier -= 10;
            }
            if (configg.armour == "gold")
            {
                modifier -= 15;
            }
            if (configg.armour == "platinum")
            {
                modifier -= 20;
            }
            if (config.weapon == "bronze")
            {
                modifier += 5;
            }
            if (config.weapon == "steel")
            {
                modifier += 10;
            }
            if (config.weapon == "gold")
            {
                modifier += 15;
            }
            if (config.HasStrengthPots > 0)
            {
                modifier += config.HasStrengthPots;
            }
            if (configg.HasDebuffPots > 0)
            {
                modifier += config.HasDebuffPots;
            }
            if (config.HasPoisonedWeapon == true)
            {
                modifier += 15;
            }
            if (config.IsMeditate == true)
            {
                modifier         += 30;
                config.IsMeditate = false;
                GlobalUserAccounts.SaveAccounts();
            }
            if (config.ActiveBlessing == "Blessing Of Strength")
            {
                modifier += 10;
            }
            int newdmg = (modifier / 100) * dmg + dmg;

            return(new Tuple <int, int>(newdmg, modifier));
        }
Exemplo n.º 25
0
        public async Task SpinSlot(uint Ilość)
        {
            if (Ilość < 1)
            {
                await ReplyAsync("Rozumiem, że tylko na tyle Cię stać, ale zachowójmy się poważnie!");

                return;
            }
            var account = GlobalUserAccounts.GetUserAccount(Context.User.Id);

            if (account.Miunies < Ilość)
            {
                await ReplyAsync($"Wybacz, wygląda na to, że jesteś za mało szczęśliwy... Masz tylko {account.Miunies} PSZ.");

                return;
            }

            account.Miunies -= Ilość;
            GlobalUserAccounts.SaveAccounts(Context.User.Id);

            var slotEmojis       = Global.Slot.Spin();
            var payoutAndFlavour = Global.Slot.GetPayoutAndFlavourText(Ilość);

            if (payoutAndFlavour.Item1 > 0)
            {
                account.Miunies += payoutAndFlavour.Item1;
                GlobalUserAccounts.SaveAccounts();
            }

            await ReplyAsync(slotEmojis);

            await Task.Delay(1000);

            await ReplyAsync(payoutAndFlavour.Item2);
        }
Exemplo n.º 26
0
        public static Tuple <bool, int, int> CheckForBlock(SocketUser attacker, SocketUser defender, int dmg)
        {
            var config    = GlobalUserAccounts.GetUserAccount(defender);
            var configg   = GlobalUserAccounts.GetUserAccount(attacker);
            int finaldmg1 = 0;
            int finaldmg2 = 0;

            if (config.HasSpeedPots)
            {
                config.Blocking = false;
                GlobalUserAccounts.SaveAccounts();
                return(new Tuple <bool, int, int>(true, 0, 0));
            }
            if (config.Blocking == true)
            {
                finaldmg1       = dmg * (3 / 4); //blocked dmg
                finaldmg2       = dmg * (1 / 4); //taken dmg
                config.Blocking = false;
                GlobalUserAccounts.SaveAccounts();
                return(new Tuple <bool, int, int>(true, finaldmg1, finaldmg2));
            }
            else
            {
                return(new Tuple <bool, int, int>(false, 0, 0)); // use for values
            }
        }
Exemplo n.º 27
0
        public async Task Gift(uint Money, IGuildUser userB)
        {
            var config      = GlobalGuildAccounts.GetGuildAccount(Context.Guild.Id);
            var giveaccount = GlobalUserAccounts.GetUserAccount(Context.User);

            if (giveaccount.Money < Money)
            {
                await ReplyAsync($":angry:  | Stop trying to gift an amount of {config.Currency} over your account balance! ");
            }
            else
            {
                if (userB == null)
                {
                    var embed = new EmbedBuilder();
                    embed.WithColor(37, 152, 255);
                    embed.WithTitle($":hand_splayed:  | Please say who you want to gift {config.Currency} to. Ex: w!gift <amount of Potatoes> @user");
                    await Context.Channel.SendMessageAsync("", embed : embed.Build());
                }
                else
                {
                    SocketUser target        = null;
                    var        mentionedUser = Context.Message.MentionedUsers.FirstOrDefault();
                    target = mentionedUser ?? Context.User;

                    var minusaccount = GlobalUserAccounts.GetUserAccount((SocketUser)userB);

                    giveaccount.Money  -= Money;
                    minusaccount.Money += Money;
                    GlobalUserAccounts.SaveAccounts();

                    await Context.Channel.SendMessageAsync($":white_check_mark:  | {Context.User.Mention} has gifted {userB.Mention} {Money} {config.Currency}(s). How generous.");
                }
            }
        }
Exemplo n.º 28
0
        public async Task ChomusukeTrain()
        {
            var config = GlobalUserAccounts.GetUserAccount(Context.User);

            if (config.ActiveChomusuke == 0) //if they set an active chomusuke
            {
                await SendMessage(Context, null,
                                  $"{Global.ENo}  **|**  **{Context.User.Username}**, you don't have an active {Global.EChomusuke} Chomusuke set!\n\nSet an active Chomusuke with `n!active`!");
            }
            else
            {
                var chom   = ActiveChomusuke.GetOneActiveChomusuke(config.Id);
                int choice = Global.Rng.Next(1, 3);

                if (choice == 1)
                {
                    uint xpGain = (uint)Global.Rng.Next(20, 30);
                    chom.XP += xpGain;
                    await ActiveChomusuke.ConvertOneActiveVariable(config.Id, chom);

                    GlobalUserAccounts.SaveAccounts(config.Id);
                    int    randomIndex  = Global.Rng.Next(yesTrainTexts.Length);
                    string text         = yesTrainTexts[randomIndex];
                    var    thumbnailurl = Context.User.GetAvatarUrl();
                    var    auth         = new EmbedAuthorBuilder()
                    {
                        Name    = "Success!",
                        IconUrl = thumbnailurl,
                    };
                    var embed = new EmbedBuilder()
                    {
                        Author = auth
                    };
                    embed.WithColor(0, 255, 0);
                    embed.WithThumbnailUrl(yesTrainLinks[Global.Rng.Next(yesTrainLinks.Length)]);
                    embed.WithDescription($"{text} \n**(+{xpGain} exp)**");
                    await SendMessage(Context, embed.Build());
                }

                if (choice == 2)
                {
                    int    randomIndex  = Global.Rng.Next(yesTrainTexts.Length);
                    string text         = noTrainTexts[randomIndex];
                    var    thumbnailurl = Context.User.GetAvatarUrl();
                    var    auth         = new EmbedAuthorBuilder()
                    {
                        Name    = "Try again!",
                        IconUrl = thumbnailurl,
                    };
                    var embed = new EmbedBuilder()
                    {
                        Author = auth
                    };
                    embed.WithColor(255, 0, 0);
                    embed.WithThumbnailUrl(noTrainLinks[Global.Rng.Next(noTrainLinks.Length)]);
                    embed.WithDescription($"{text}");
                    await SendMessage(Context, embed.Build());
                }
            }
        }
Exemplo n.º 29
0
        public async static Task HandleMessageRewards(SocketMessage s)
        {
            var msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }
            if (msg.Channel == msg.Author.GetOrCreateDMChannelAsync())
            {
                return;
            }
            if (msg.Author.IsBot)
            {
                return;
            }

            var      userAcc = GlobalUserAccounts.GetUserAccount(msg.Author.Id);
            DateTime now     = DateTime.UtcNow;

            // Check if message is long enough and if the coolown of the reward is up - if not return
            if (now < userAcc.LastMessage.AddSeconds(Constants.MessageRewardCooldown) || msg.Content.Length < Constants.MessageRewardMinLenght)
            {
                return; // This Message is not eligible for a reward
            }

            // Generate a randomized reward in the configured boundries
            userAcc.Miunies    += (ulong)Global.Rng.Next(Constants.MessagRewardMinMax.Item1, Constants.MessagRewardMinMax.Item2 + 1);
            userAcc.LastMessage = now;

            GlobalUserAccounts.SaveAccounts(msg.Author.Id);
        }
Exemplo n.º 30
0
        public static AttackResult DeflectAttack(ShardedCommandContext context)
        {
            var config = GlobalUserAccounts.GetUserAccount(context.User);
            var chom   = ActiveChomusuke.GetOneActiveChomusuke(config.Id);

            string response;
            bool   success = false;
            int    dmg     = 0;

            if (chom.Effects.Contains(Effect.Blocking))
            {
                response = "You cannot block while already in blocking formation! Try again!";
                return(new AttackResult {
                    Success = success, Response = response, Damage = dmg
                });
            }

            if (chom.Effects.Contains(Effect.Deflecting))
            {
                response = "You are already in deflecting formation! Try again!";
                return(new AttackResult {
                    Success = success, Response = response, Damage = dmg
                });
            }

            chom.Effects.Add(Effect.Deflecting);
            GlobalUserAccounts.SaveAccounts(config.Id);
            response =
                $":shield:  **|** **{config.OpponentName}**, You are now in deflecting formation!\n\n**{config.OpponentName}**'s shield will deflect 50% of the damage from the next attack";
            success = true;
            return(new AttackResult {
                Success = success, Response = response, Damage = dmg
            });
        }