Public Access
Get started links to registration and says an admin approves accounts. Back navigation restores the library scroll; search no longer fills history. Steam and PSN unlink ask first. Any close marks news as seen. Confetti plays only when the level rises on the page. Count-ups respect reduced motion. Html lang follows the UI language. Add a 404 page, translated role and dialog close label.
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
const FINISHED = ['FINISHED', 'COMPLETED'];
|
|
|
|
/**
|
|
* Every achievement unlocked. Only while the stats are visible: Core can still send the old unlock count after they turn private.
|
|
*/
|
|
export const allAchievementsUnlocked = (game) => game.hasAchievements && game.statsVisible
|
|
&& game.achievementsTotal > 0 && game.achievementsUnlocked >= game.achievementsTotal;
|
|
|
|
/**
|
|
* 0: not finished, 1: finished, 2: finished and every achievement unlocked.
|
|
*/
|
|
export const celebrationLevel = (game) => {
|
|
if (!FINISHED.includes(game.status)) return 0;
|
|
return allAchievementsUnlocked(game) ? 2 : 1;
|
|
};
|
|
|
|
/**
|
|
* The confetti to play: only when the level rises while the page shows the game (the user sets Finished or completes
|
|
* it here). Opening a finished game and a reload play nothing.
|
|
*
|
|
* @param before {appid, level} of the game shown before, null on opening the page
|
|
* @returns 'small', 'big' or null
|
|
*/
|
|
export const celebrationFor = (before, game) => {
|
|
if (before?.appid !== game.appid) return null;
|
|
const level = celebrationLevel(game);
|
|
if (level <= before.level) return null;
|
|
return level === 2 ? 'big' : 'small';
|
|
};
|