mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-30 02:39:05 +08:00
impr(badge): add all year long badge, awarded on 365 day streak
This commit is contained in:
parent
6c4009d248
commit
2a478a0440
2 changed files with 27 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue