Exemplo n.º 1
0
        public static void SetRecipeStatus(ArcadeUser user, Recipe recipe, RecipeStatus status)
        {
            if (GetRecipeStatus(user, recipe) >= status)
            {
                return;
            }

            user.SetVar(GetRecipeId(recipe), (long)status);
        }
Exemplo n.º 2
0
        public static string TossSlot(ArcadeUser user, int index)
        {
            QuestData slot = GetSlot(user, index);

            if (slot == null)
            {
                return($"> {Icons.Warning} There isn't an assigned objective in this slot.");
            }

            if (user.GetVar(Stats.LastSkippedQuest) > 0)
            {
                if (StatHelper.SinceLast(user, Stats.LastSkippedQuest) >= SkipCooldown)
                {
                    return($"> {Icons.Warning} You have skipped an objective too recently. Try again in {Format.Countdown(SkipCooldown - StatHelper.SinceLast(user, Stats.LastSkippedQuest))}.");
                }
            }

            Quest quest = GetQuest(slot.Id);

            if (quest == null)
            {
                throw new Exception("Expected to find a parent quest but returned null");
            }

            user.Quests.RemoveAt(index);
            user.SetVar(Stats.LastSkippedQuest, DateTime.UtcNow.Ticks);

            TimeSpan since = StatHelper.SinceLast(user, Stats.LastAssignedQuest);

            bool canAssign = since >= AssignCooldown;

            if (!canAssign)
            {
                TimeSpan toSkip = (AssignCooldown - since) / 2; // skip 50% of the remaining time
                user.SetVar(Stats.LastAssignedQuest, new DateTime(user.GetVar(Stats.LastAssignedQuest)).Add(toSkip).Ticks);
            }

            return($"> 🗑️ You have declined the **{quest.Name}** objective.");
        }
Exemplo n.º 3
0
        public static Message AssignAndDisplay(ArcadeUser user)
        {
            Var.SetIfEmpty(user, Stats.QuestCapacity, DefaultQuestCapacity);

            if (!CanAssign(user))
            {
                return(new Message($"> 🚫 You have already been assigned your daily objectives.\n> Check back in **{Format.Countdown(StatHelper.GetRemainder(user, Stats.LastAssignedQuest, AssignCooldown))}**."));
            }

            if (!HasAnyAssignable(user))
            {
                return(new Message($"> 🚫 You do not meet the criteria to be assigned an objective."));
            }

            IEnumerable <Quest> assignable = GetAssignable(user);

            long available = GetCurrentCapacity(user);

            if (available == 0)
            {
                return(new Message($"> 🚫 You don't currently have any room to be assigned any new objectives."));
            }

            var info = new StringBuilder();

            info.AppendLine($"> {Icons.Assign} You have been assigned new objectives!");

            // If you want to allow for preservation of existing quests, ignore ones already specified
            for (int i = 0; i < available; i++)
            {
                Quest toAssign = Randomizer.Choose(assignable);
                user.Quests.Add(new QuestData(toAssign));
                info.AppendLine($"**Slot {i + 1}: {toAssign.Name}** ({toAssign.Difficulty.ToString()})");
            }

            TimeSpan amountToSkip = AssignCooldown - ((AssignCooldown / user.GetVar(Stats.QuestCapacity)) * available);

            user.SetVar(Stats.LastAssignedQuest, DateTime.UtcNow.Add(amountToSkip).Ticks);
            user.AddToVar(Stats.TotalAssignedQuests, available);

            return(new Message(info.ToString()));
        }
Exemplo n.º 4
0
        public static void Assign(ArcadeUser user)
        {
            Var.SetIfEmpty(user, Stats.QuestCapacity, DefaultQuestCapacity);

            if (!CanAssign(user))
            {
                return;
            }

            if (!HasAnyAssignable(user))
            {
                throw new ArgumentException("The specified user does not have any assignable quests they can use.");
            }

            IEnumerable <Quest> assignable = GetAssignable(user);

            for (int i = 0; i < GetCurrentCapacity(user); i++)
            {
                user.Quests.Add(new QuestData(Randomizer.Choose(assignable)));
            }

            user.SetVar(Stats.LastAssignedQuest, DateTime.UtcNow.Ticks);
        }