Squashed commit of the following:

commit bde71cc45d
Author: Kalista Payne <sabrecat@gmail.com>
Date:   Thu Mar 20 15:25:11 2025 -0500

    fix(potions): add missing Cryptid release date

commit 1a50413402
Author: Kalista Payne <sabrecat@gmail.com>
Date:   Tue Mar 18 16:52:19 2025 -0500

    fix(wacky): revise text, address linting

commit 2d49a16f55
Author: Phillip Thelen <phillip@habitica.com>
Date:   Tue Mar 18 16:05:17 2025 +0100

    Fix displaying countdown for recurring event items

commit cf20b30975
Author: Kalista Payne <sabrecat@gmail.com>
Date:   Fri Mar 14 18:01:37 2025 -0500

    fix(lint): line length

commit e39e490e41
Author: Kalista Payne <sabrecat@gmail.com>
Date:   Fri Mar 14 17:55:12 2025 -0500

    fix(foolin): correct animation and end date of potions

commit 164e2eefdd
Author: Kalista Payne <sabrecat@gmail.com>
Date:   Thu Mar 13 17:25:14 2025 -0500

    fix(event): Panda Cub typo, shift start date

commit 394c922287
Author: Kalista Payne <sabrecat@gmail.com>
Date:   Thu Mar 13 17:02:12 2025 -0500

    fix(test): account for addition of Cryptid

commit bea9e40338
Author: Kalista Payne <sabrecat@gmail.com>
Date:   Thu Mar 13 16:52:37 2025 -0500

    feat(event): April Fools 2025
This commit is contained in:
Kalista Payne
2025-03-21 15:02:31 -05:00
parent 01881b2fd8
commit f3029953dc
15 changed files with 194 additions and 107 deletions

View File

@@ -841,6 +841,30 @@ function getGalaIndex (date) {
return parseInt((galaCount / 12) * galaMonth, 10);
}
function makeEndDate (checkedDate, matcher) {
let end = moment.utc(checkedDate);
end.hour(SWITCHOVER_TIME);
end.minute(0);
end.second(0);
if (matcher.end !== undefined) {
end.date(matcher.end.getDate());
end.month(matcher.end.getMonth());
} else {
end.date(TYPE_SCHEDULE[matcher.type]);
if (matcher.endMonth !== undefined) {
if (matcher.startMonth
&& matcher.startMonth > matcher.endMonth
&& checkedDate.getMonth() > matcher.endMonth) {
end.year(checkedDate.getFullYear() + 1);
}
end.month(matcher.endMonth);
} else if (end.valueOf() <= checkedDate.getTime()) {
end = moment(end).add(1, 'months');
}
}
return end.toDate();
}
export function assembleScheduledMatchers (date) {
const items = [];
const month = getMonth(date);
@@ -865,7 +889,14 @@ export function assembleScheduledMatchers (date) {
items.push(...galaMatchers);
getRepeatingEvents(date).forEach(event => {
if (event.content) {
items.push(...event.content);
const { content } = event;
const end = makeEndDate(date, event);
const m = content.map(matcher => {
const newMatcher = { ...matcher };
newMatcher.end = end;
return newMatcher;
});
items.push(...m);
}
});
return items;
@@ -878,8 +909,15 @@ function makeMatcherClass (date) {
return {
matchers: [],
end: new Date(),
specialEnds: {},
items: [],
matchingDate: date,
getEnd (key) {
if (this.specialEnds[key]) {
return this.specialEnds[key];
}
return this.end;
},
match (key) {
if (this.matchers.length === 0) {
if (this.items.length > 0) {
@@ -896,25 +934,6 @@ function makeMatcherClass (date) {
};
}
function makeEndDate (checkedDate, matcher) {
let end = moment.utc(checkedDate);
end.date(TYPE_SCHEDULE[matcher.type]);
end.hour(SWITCHOVER_TIME);
end.minute(0);
end.second(0);
if (matcher.endMonth !== undefined) {
if (matcher.startMonth
&& matcher.startMonth > matcher.endMonth
&& checkedDate.getMonth() > matcher.endMonth) {
end.year(checkedDate.getFullYear() + 1);
}
end.month(matcher.endMonth);
} else if (end.valueOf() <= checkedDate.getTime()) {
end = moment(end).add(1, 'months');
}
return end.toDate();
}
export function clearCachedMatchers () {
cacheDate = null;
cachedScheduleMatchers = null;
@@ -939,11 +958,19 @@ export function getAllScheduleMatchingGroups (date) {
if (!cachedScheduleMatchers[matcher.type]) {
cachedScheduleMatchers[matcher.type] = makeMatcherClass(adjustedDate);
}
cachedScheduleMatchers[matcher.type].end = makeEndDate(checkedDate, matcher);
if (matcher.end === undefined) {
// we want the default end date to be for matcher type
cachedScheduleMatchers[matcher.type].end = makeEndDate(checkedDate, matcher);
}
if (matcher.matcher instanceof Function) {
cachedScheduleMatchers[matcher.type].matchers.push(matcher.matcher);
} else if (matcher.items instanceof Array) {
cachedScheduleMatchers[matcher.type].items.push(...matcher.items);
if (matcher.end !== undefined) {
matcher.items.forEach(item => {
cachedScheduleMatchers[matcher.type].specialEnds[item] = matcher.end;
});
}
}
});
}