Questify: Minor Bug/Syntax Stuff. (#606)
* Minor bug fix. * Random stuff.
This commit is contained in:
parent
bac33d8c27
commit
140ef17abb
1 changed files with 15 additions and 17 deletions
|
|
@ -576,6 +576,11 @@ async function startVideoProgressTracking(quest: Quest, questTarget: number): Pr
|
|||
activeQuestIntervals.set(quest.id, { progressTimeout: null as any, rerenderTimeout: null as any, progress: initialProgress, type: "watch" });
|
||||
// Max up to ~25 seconds into the future can be reported.
|
||||
const questTargetWithLeeway = questTarget - videoQuestLeeway;
|
||||
let currentProgress = initialProgress;
|
||||
let currentProgressScaled = initialProgress;
|
||||
const timeRemaining = Math.max(0, questTargetWithLeeway - currentProgressScaled);
|
||||
|
||||
QuestifyLogger.info(`[${getFormattedNow()}] Quest ${questName} will be completed in the background in ${timeRemaining} seconds.`);
|
||||
|
||||
if (!questEnrolledAt) {
|
||||
const enrollmentTimeout = 60000;
|
||||
|
|
@ -595,15 +600,12 @@ async function startVideoProgressTracking(quest: Quest, questTarget: number): Pr
|
|||
|
||||
const reportEverySec = 10;
|
||||
let progressIntervalId: NodeJS.Timeout;
|
||||
let currentProgress = initialProgress;
|
||||
let currentProgressScaled = initialProgress;
|
||||
const timeRemaining = Math.max(0, questTargetWithLeeway - currentProgressScaled);
|
||||
|
||||
async function handleSendComplete() {
|
||||
clearInterval(progressIntervalId);
|
||||
clearTimeout(renderIntervalId);
|
||||
activeQuestIntervals.delete(quest.id);
|
||||
const success = await reportVideoQuestProgress(quest, questTarget, QuestifyLogger);
|
||||
activeQuestIntervals.delete(quest.id);
|
||||
|
||||
if (success) {
|
||||
QuestifyLogger.info(`[${getFormattedNow()}] Quest ${questName} completed.`);
|
||||
|
|
@ -675,10 +677,6 @@ async function startVideoProgressTracking(quest: Quest, questTarget: number): Pr
|
|||
intervalData.progressTimeout = progressIntervalId;
|
||||
intervalData.rerenderTimeout = renderIntervalId;
|
||||
}
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
QuestifyLogger.info(`[${getFormattedNow()}] Quest ${questName} will be completed in the background in ${timeRemaining} seconds.`);
|
||||
}
|
||||
}
|
||||
|
||||
async function startPlayGameProgressTracking(quest: Quest, questTarget: number): Promise<void> {
|
||||
|
|
@ -690,6 +688,8 @@ async function startPlayGameProgressTracking(quest: Quest, questTarget: number):
|
|||
const heartbeatInterval = 20; // Heartbeats must be at most 2 minutes apart.
|
||||
activeQuestIntervals.set(quest.id, { progressTimeout: null as any, rerenderTimeout: null as any, progress: initialProgress, type: "play" });
|
||||
|
||||
QuestifyLogger.info(`[${getFormattedNow()}] Quest ${questName} will be completed in the background in ${remaining} seconds.`);
|
||||
|
||||
if (!questEnrolledAt) {
|
||||
const enrollmentTimeout = 60000;
|
||||
const enrolled = await waitUntilEnrolled(quest, enrollmentTimeout, 500, QuestifyLogger);
|
||||
|
|
@ -726,8 +726,8 @@ async function startPlayGameProgressTracking(quest: Quest, questTarget: number):
|
|||
if (isComplete) {
|
||||
clearInterval(progressIntervalId);
|
||||
clearTimeout(renderIntervalId);
|
||||
activeQuestIntervals.delete(quest.id);
|
||||
const success = await reportPlayGameQuestProgress(quest, true, QuestifyLogger, { attempts: 3, delay: 2500 });
|
||||
activeQuestIntervals.delete(quest.id);
|
||||
|
||||
if (success) {
|
||||
QuestifyLogger.info(`[${getFormattedNow()}] Quest ${questName} completed.`);
|
||||
|
|
@ -748,8 +748,8 @@ async function startPlayGameProgressTracking(quest: Quest, questTarget: number):
|
|||
clearTimeout(renderIntervalId);
|
||||
|
||||
setTimeout(async () => {
|
||||
activeQuestIntervals.delete(quest.id);
|
||||
const success = await reportPlayGameQuestProgress(quest, true, QuestifyLogger, { attempts: 3, delay: 2500 });
|
||||
activeQuestIntervals.delete(quest.id);
|
||||
|
||||
if (success) {
|
||||
QuestifyLogger.info(`[${getFormattedNow()}] Quest ${questName} completed.`);
|
||||
|
|
@ -788,10 +788,6 @@ async function startPlayGameProgressTracking(quest: Quest, questTarget: number):
|
|||
intervalData.progressTimeout = progressIntervalId;
|
||||
intervalData.rerenderTimeout = renderIntervalId;
|
||||
}
|
||||
|
||||
if (remaining > 0) {
|
||||
QuestifyLogger.info(`[${getFormattedNow()}] Quest ${questName} will be completed in the background in ${remaining} seconds.`);
|
||||
}
|
||||
}
|
||||
|
||||
async function startAchievementActivityProgressTracking(quest: Quest, questTarget: number): Promise<void> {
|
||||
|
|
@ -800,6 +796,8 @@ async function startAchievementActivityProgressTracking(quest: Quest, questTarge
|
|||
const achievementType = quest.config.taskConfigV2?.tasks.ACHIEVEMENT_IN_ACTIVITY;
|
||||
activeQuestIntervals.set(quest.id, { progressTimeout: null as any, rerenderTimeout: null as any, progress: 0, type: "achievement" });
|
||||
|
||||
QuestifyLogger.info(`[${getFormattedNow()}] Quest ${questName} will be completed in the background.`);
|
||||
|
||||
if (!questEnrolledAt) {
|
||||
const enrollmentTimeout = 60000;
|
||||
const enrolled = await waitUntilEnrolled(quest, enrollmentTimeout, 15, QuestifyLogger);
|
||||
|
|
@ -929,7 +927,7 @@ function getQuestUnacceptedButtonText(quest: Quest): string | null {
|
|||
const targetFormatted = `${String(Math.floor(target / 60)).padStart(2, "0")}:${String(target % 60).padStart(2, "0")}`;
|
||||
|
||||
if (target > 0) {
|
||||
if ((playType && completeGameQuestsInBackground) || (watchType && completeVideoQuestsInBackground)) {
|
||||
if ((playType && completeGameQuestsInBackground && IS_DISCORD_DESKTOP) || (watchType && completeVideoQuestsInBackground)) {
|
||||
return `Complete (${targetFormatted})`;
|
||||
} else if (achievementType && completeAchievementQuestsInBackground) {
|
||||
return "Complete (Immediate)";
|
||||
|
|
@ -948,7 +946,7 @@ function getQuestAcceptedButtonText(quest: Quest): string | null {
|
|||
const intervalData = activeQuestIntervals.get(quest.id);
|
||||
|
||||
if (questEnrolledAt) {
|
||||
if (((playType && completeGameQuestsInBackground) || (watchType && completeVideoQuestsInBackground))) {
|
||||
if (((playType && completeGameQuestsInBackground && IS_DISCORD_DESKTOP) || (watchType && completeVideoQuestsInBackground))) {
|
||||
const taskType = playType || watchType;
|
||||
const duration = taskType?.target || 0;
|
||||
const durationWithLeeway = watchType ? duration - videoQuestLeeway : duration;
|
||||
|
|
@ -959,7 +957,7 @@ function getQuestAcceptedButtonText(quest: Quest): string | null {
|
|||
|
||||
if (!!intervalData) {
|
||||
return !canCompleteImmediately && timeRemaining ? `Completing (${progressFormatted})` : "Completing...";
|
||||
} else if (watchType || (playType && IS_DISCORD_DESKTOP)) {
|
||||
} else if (watchType || playType) {
|
||||
return canCompleteImmediately ? "Complete (Immediate)" : timeRemaining === durationWithLeeway ? `Complete (${progressFormatted})` : `Resume (${progressFormatted})`;
|
||||
}
|
||||
} else if (achievementType && completeAchievementQuestsInBackground) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue