impr(badge): add all year long badge, awarded on 365 day streak

This commit is contained in:
Miodec 2023-09-03 12:57:45 +02:00
parent 6c4009d248
commit 2a478a0440
2 changed files with 27 additions and 0 deletions

View file

@ -452,6 +452,25 @@ export async function addResult(
const streak = await UserDAL.updateStreak(uid, result.timestamp);
const shouldGetBadge =
streak >= 365 &&
user.inventory?.badges?.find((b) => b.id === 14) === undefined;
if (shouldGetBadge) {
const mail = buildMonkeyMail({
subject: "Badge",
body: "Congratulations for reaching a 365 day streak! You have been awarded a special badge. Now, go touch some grass.",
rewards: [
{
type: "badge",
item: {
id: 14,
},
},
],
});
UserDAL.addToInbox(uid, [mail], req.ctx.configuration.users.inbox);
}
const xpGained = await calculateXp(
result,
req.ctx.configuration.users.xp,

View file

@ -103,6 +103,14 @@ const badges: Record<number, MonkeyTypes.UserBadge> = {
color: "white",
customStyle: "animation: rgb-bg 10s linear infinite;",
},
14: {
id: 14,
name: "All Year Long",
description: "Reached a streak of 365 days",
icon: "fa-fire",
color: "var(--bg-color)",
background: "var(--main-color)",
},
};
export function getHTMLById(