Skip to content

Commit

Permalink
fix(checklist): fixed biweekly reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Supamiu committed Sep 20, 2023
1 parent 9c6c03e commit 8a7d4e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions apps/client/src/app/core/is-task-done.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getCompletionEntry } from "./get-completion-entry-key";
import { TaskFrequency } from "../model/task-frequency";
import { TaskScope } from "../model/task-scope";

export function isTaskDone(task: LostarkTask, character: Character, completion: Completion, dailyReset: number, weeklyReset: number, lazyTracking: Record<string, boolean>): number {
export function isTaskDone(task: LostarkTask, character: Character, completion: Completion, dailyReset: number, weeklyReset: number, biWeeklyReset: number, lazyTracking: Record<string, boolean>): number {
if (character.lazy && task.scope !== TaskScope.ROSTER) {
const lazyTrackingFlag = lazyTracking && lazyTracking[`${character.name}:${task.$key}`];
if (lazyTrackingFlag === undefined || lazyTrackingFlag) {
Expand All @@ -15,7 +15,11 @@ export function isTaskDone(task: LostarkTask, character: Character, completion:
}

const completionFlag = getCompletionEntry(completion.data, character, task);
const reset = task.frequency === TaskFrequency.DAILY ? dailyReset : weeklyReset;
const reset = {
[TaskFrequency.DAILY]: dailyReset,
[TaskFrequency.WEEKLY]: weeklyReset,
[TaskFrequency.BIWEEKLY]: biWeeklyReset
}[task.frequency];

if (!completionFlag) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class ChecklistComponent {
completion,
dailyReset,
weeklyReset,
biWeeklyReset,
lazyTracking
), task.amount),
tracked: getCompletionEntry(roster.trackedTasks, character, task, true) !== false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ export class PartyPlannerComponent {
this.completionService.completion$,
this.timeService.lastDailyReset$,
this.timeService.lastWeeklyReset$,
this.timeService.lastBiWeeklyReset$,
this.settings.settings$.pipe(pluck("lazytracking"))
]).pipe(
switchMap(([tasks, roster, completion, dailyReset, weeklyReset, lazyTracking]) => {
switchMap(([tasks, roster, completion, dailyReset, weeklyReset, biWeeklyReset, lazyTracking]) => {
return this.friendIdsToConsider$.pipe(
switchMap(friendIds => {
if (friendIds.length === 0) {
Expand Down Expand Up @@ -145,7 +146,7 @@ export class PartyPlannerComponent {
task,
data: roster.characters
.map(character => {
const done = isTaskDone(task, character, completion, dailyReset, weeklyReset, lazyTracking);
const done = isTaskDone(task, character, completion, dailyReset, weeklyReset, biWeeklyReset, lazyTracking);
const canDo = character.ilvl >= (task.minIlvl || 0) && character.ilvl < (task.maxIlvl || Infinity);
if (done === -1 || done >= task.amount || !canDo) {
return {
Expand All @@ -170,7 +171,7 @@ export class PartyPlannerComponent {
characters: (friendRoster.characters || [])
.filter(c => !c.isPrivate)
.filter(fChar => {
const fDone = isTaskDone(friendTask, fChar, friendCompletion, dailyReset, weeklyReset, {});
const fDone = isTaskDone(friendTask, fChar, friendCompletion, dailyReset, weeklyReset, biWeeklyReset, {});
return fDone >= 0
&& fDone < task.amount
&& fChar.ilvl >= (task.minIlvl || 0)
Expand All @@ -179,7 +180,7 @@ export class PartyPlannerComponent {
.map(c => {
return {
doable: Math.min(
task.amount - isTaskDone(friendTask, c, friendCompletion, dailyReset, weeklyReset, {}),
task.amount - isTaskDone(friendTask, c, friendCompletion, dailyReset, weeklyReset, biWeeklyReset, {}),
task.amount - done
),
c
Expand Down

0 comments on commit 8a7d4e7

Please sign in to comment.