Skip to content

Commit

Permalink
feat(be): update check condition
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Oct 20, 2023
1 parent 83e4f34 commit 6f5befa
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/quest/quest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,25 @@ export class QuestService {
}

verifyQuestCondition(condition: any, currentLevel?: number) {
const unlock: boolean[] = [];

if (condition.level && currentLevel) {
// check user level
return currentLevel >= condition.level;
unlock.push(currentLevel >= condition.level);
}

if (
condition.duration &&
condition.duration.after &&
condition.duration.before
) {
const now = new Date();
const after = new Date(condition.duration.after);
const before = new Date(condition.duration.before);
if (after <= now && now <= before) {
return true;
}
const now = new Date();
if (condition.after) {
const after = new Date(condition.after);
unlock.push(after < now);
}

return false;
if (condition.after) {
const before = new Date(condition.before);
unlock.push(now < before);
}

return unlock.includes(false) || unlock.length === 0 ? false : true;
}

async getAllCampaignQuest(userId?: string) {
Expand Down

0 comments on commit 6f5befa

Please sign in to comment.