This commit is contained in:
2025-12-12 14:23:40 +01:00
parent 6a88fe93ab
commit 2cd3bfbb47
58 changed files with 2866 additions and 260 deletions

View File

@@ -20,7 +20,7 @@ export class UserAchievement implements IEntity<string> {
readonly userId: string;
readonly achievementId: string;
readonly earnedAt: Date;
readonly notifiedAt?: Date;
readonly notifiedAt: Date | undefined;
readonly progress: number;
private constructor(props: UserAchievementProps) {
@@ -53,8 +53,12 @@ export class UserAchievement implements IEntity<string> {
*/
markNotified(): UserAchievement {
return new UserAchievement({
...this,
id: this.id,
userId: this.userId,
achievementId: this.achievementId,
earnedAt: this.earnedAt,
notifiedAt: new Date(),
progress: this.progress,
});
}
@@ -64,7 +68,11 @@ export class UserAchievement implements IEntity<string> {
updateProgress(progress: number): UserAchievement {
const clampedProgress = Math.max(0, Math.min(100, progress));
return new UserAchievement({
...this,
id: this.id,
userId: this.userId,
achievementId: this.achievementId,
earnedAt: this.earnedAt,
...(this.notifiedAt ? { notifiedAt: this.notifiedAt } : {}),
progress: clampedProgress,
});
}