Ejemplo n.º 1
0
            }                                      // For a friend that inspired pets to begin with <3


            public void DoChecks(PetGame pet)
            {
                if (lastNeglected == default)
                {
                    lastNeglected = pet.bornDate;
                }
                else if (pet.TotalStats == 0)
                {
                    lastNeglected = DateTime.Now;
                }
                double days = (DateTime.Now - lastNeglected).TotalDays;

                if (!string.IsNullOrWhiteSpace(pet.petName) && !string.IsNullOrWhiteSpace(pet.petImageUrl))
                {
                    Custom = true;
                }

                if (days >= 180 && Attention < 4)
                {
                    Attention = 4;
                }
                else if (days >= 30 && Attention < 3)
                {
                    Attention = 3;
                }
                else if (days >= 14 && Attention < 2)
                {
                    Attention = 2;
                }
                else if (days >= 7 && Attention < 1)
                {
                    Attention = 1;
                }
            }
Ejemplo n.º 2
0
        public async Task PetImage(PetGame pet, string args)
        {
            string url = args ?? Context.Message.Attachments.FirstOrDefault()?.Url;

            if (url == null && pet.PetImageUrl == null)
            {
                await ReplyAsync($"{CustomEmoji.Cross} Please specify an image! You can use a link or upload your own.");
            }
            else
            {
                try
                {
                    pet.PetImageUrl = url;
                }
                catch (FormatException)
                {
                    await ReplyAsync($"{CustomEmoji.Cross} Invalid image link!\nYou can try uploading the image yourself.");

                    return;
                }

                if (url == null)
                {
                    await ReplyAsync($"{CustomEmoji.Check} Pet image reset!");
                }
                else
                {
                    await AutoReactAsync();
                }
            }
        }
Ejemplo n.º 3
0
        public async Task PetMaster(string commandName = "", [Remainder] string args = null)
        {
            var command = typeof(MoreGamesModule).GetMethods()
                          .FirstOrDefault(x => x.GetCustomAttribute <PetCommandAttribute>()?.Names.Contains(commandName.ToLower()) ?? false);

            if (command == null)
            {
                await ReplyAsync($"Unknown pet command! Do `{Prefix}pet help` for help");
            }
            else
            {
                var pet = Storage.GetUserGame <PetGame>(Context.User.Id);
                if (pet == null)
                {
                    if (commandName == "")
                    {
                        pet = new PetGame("", Context.User.Id, Services);
                        Storage.AddGame(pet);
                    }
                    else
                    {
                        await ReplyAsync($"You don't have a pet yet! Simply do `{Prefix}pet` to adopt one.");

                        return;
                    }
                }

                await(Task) command.Invoke(this, new object[] { pet, args });
            }
        }
Ejemplo n.º 4
0
        public async Task PetUser(PetGame pet, string args)
        {
            if (string.IsNullOrWhiteSpace(args))
            {
                await ReplyAsync("You must specify a user!");

                return;
            }

            var user = await Context.ParseUserAsync(args);

            if (user == null)
            {
                await ReplyAsync("Can't find the specified user!");

                return;
            }

            pet = Storage.GetUserGame <PetGame>(user.Id);

            if (pet == null)
            {
                await ReplyAsync("This person doesn't have a pet :(");
            }
            else
            {
                await ReplyAsync(pet.GetContent(), pet.GetEmbed(user));
            }
        }
Ejemplo n.º 5
0
        public async Task PetWake(PetGame pet, string args)
        {
            pet.UpdateStats(false);
            await ReplyAsync(pet.asleep? "🌅 You wake up your pet." : "🌅 Your pet is already awake.");

            if (pet.asleep)
            {
                pet.ToggleSleep();
            }
        }
Ejemplo n.º 6
0
 public async Task PetClean(PetGame pet, string args)
 {
     if (pet.Clean())
     {
         await Context.Message.AddReactionAsync(Bot.Random.Choose(PetGame.CleanEmotes).ToEmoji());
     }
     else
     {
         await ReplyAsync($"{CustomEmoji.Cross} Your pet is already clean! (-1 happiness)");
     }
 }
Ejemplo n.º 7
0
 public async Task PetRelease(PetGame pet, string args)
 {
     if (string.IsNullOrWhiteSpace(pet.PetName) || args?.SanitizeMarkdown().SanitizeMentions() == pet.PetName)
     {
         Storage.DeleteGame(pet);
         await ReplyAsync($"Goodbye {(string.IsNullOrWhiteSpace(pet.PetName) ? pet.Name : pet.PetName)}!");
     }
     else
     {
         await ReplyAsync($"❗ Are you sure you want to delete {pet.PetName}? It will be gone forever, along with your stats and achievements, " +
                          $"and you can't get it back. Do **{Prefix}pet release {pet.PetName}** to release.");
     }
 }
Ejemplo n.º 8
0
 public async Task PetPlay(PetGame pet, string args)
 {
     if (pet.Play())
     {
         await Context.Message.AddReactionAsync(Bot.Random.Choose(PetGame.PlayEmotes).ToEmoji());
     }
     else
     {
         string message = pet.energy.Ceiling() >= 5 ? "Your pet doesn't want to play anymore! (-1 happiness)"
                                                    : "Your pet is too tired to play! It needs 5 energy or more.";
         await ReplyAsync($"{CustomEmoji.Cross} {message}");
     }
 }
Ejemplo n.º 9
0
 public async Task PetName(PetGame pet, string args)
 {
     if (string.IsNullOrWhiteSpace(args))
     {
         await ReplyAsync($"{CustomEmoji.Cross} Please specify a name!");
     }
     else if (args.Length > 32)
     {
         await ReplyAsync($"{CustomEmoji.Cross} Pet name can't go above 32 characters!");
     }
     else
     {
         pet.PetName = args;
         await AutoReactAsync();
     }
 }
Ejemplo n.º 10
0
        public async Task PetSleep(PetGame pet, string args)
        {
            pet.UpdateStats(store: false);
            if (pet.energy.Ceiling() == PetGame.MaxStat && !pet.asleep)
            {
                pet.happiness = Math.Max(0, pet.happiness - 1);
                Games.Save(pet);
                await ReplyAsync($"{CustomEmoji.Cross} Your pet is not tired! (-1 happiness)");
            }
            else
            {
                string message = pet.asleep ? "Your pet is already sleeping." : "Your pet is now asleep.";
                await ReplyAsync($"{Bot.Random.Choose(PetGame.SleepEmotes)} {message}");

                if (!pet.asleep)
                {
                    pet.ToggleSleep();
                }
            }
        }
Ejemplo n.º 11
0
        public async Task PetExact(PetGame pet, string args)
        {
            var user = Context.User as SocketGuildUser;

            if (!string.IsNullOrWhiteSpace(args))
            {
                var other = await Context.ParseUserAsync(args);

                if (other != null)
                {
                    user = other;
                    pet  = Storage.GetUserGame <PetGame>(user.Id);
                    if (pet == null)
                    {
                        await ReplyAsync("This person doesn't have a pet :(");

                        return;
                    }
                }
            }

            await ReplyAsync(pet.GetContent(), pet.GetEmbed(user, decimals: true));
        }
Ejemplo n.º 12
0
        public async Task PetPet(PetGame pet, string args)
        {
            var now = DateTime.Now;

            if (now - pet.petTimerStart > TimeSpan.FromMinutes(1))
            {
                pet.petTimerStart           = now;
                pet.timesPetSinceTimerStart = 0;
            }

            int limit = Context.Guild == null ? 15 : 5;

            if (pet.timesPetSinceTimerStart >= limit)
            {
                await ReplyAsync($"{CustomEmoji.Cross} That's enough petting! Try again in a minute"
                                 + (Context.Guild == null ? "." : ", or pet in a DM with the bot."));
            }
            else
            {
                pet.timesPetSinceTimerStart += 1;
                await ReplyAsync(pet.DoPet());
            }
        }
Ejemplo n.º 13
0
        public async Task PetStats(PetGame pet, string args)
        {
            var user = Context.User as SocketGuildUser;

            if (!string.IsNullOrWhiteSpace(args))
            {
                var other = await Context.ParseUserAsync(args);

                if (other != null)
                {
                    user = other;
                    pet  = Games.GetForUser <PetGame>(user.Id);
                    if (pet == null)
                    {
                        await ReplyAsync("This person doesn't have a pet :(");

                        return;
                    }
                }
            }

            await ReplyAsync(pet.GetEmbedAchievements(user));
        }
Ejemplo n.º 14
0
 public async Task Pet(PetGame pet, string args)
 {
     await ReplyAsync(pet.GetContent(), pet.GetEmbed(Context.User as IGuildUser));
 }
Ejemplo n.º 15
0
        public async Task PetHelp(PetGame pet, string args)
        {
            var summary = typeof(MoreGamesModule).GetMethod(nameof(PetMaster)).GetCustomAttribute <SummaryAttribute>();

            await ReplyAsync(summary?.Text.Replace("{prefix}", Prefix) ?? "Couldn't get help");
        }
Ejemplo n.º 16
0
 public async Task PetHelp(PetGame pet, string args)
 {
     await GetModule <GeneralModule>().SendCommandHelp("pet");
 }