diff --git a/components/Window.jsx b/components/Window.jsx index 773befc..c456aaf 100644 --- a/components/Window.jsx +++ b/components/Window.jsx @@ -31,6 +31,7 @@ export default function Window() { }, achievementUnlocker: { idle: true, + hidden: false, interval: [30, 130], } }; diff --git a/components/automation/AchievementUnlocker.jsx b/components/automation/AchievementUnlocker.jsx index b4fad7e..ff99c18 100644 --- a/components/automation/AchievementUnlocker.jsx +++ b/components/automation/AchievementUnlocker.jsx @@ -18,19 +18,22 @@ export default function AchievementUnlocker({ setActivePage }) { const startAchievementUnlocker = async () => { try { const achievementUnlocker = JSON.parse(localStorage.getItem('achievementUnlocker')) || []; + const settings = JSON.parse(localStorage.getItem('settings')) || {}; if (achievementUnlocker.length < 1) { logEvent('[Achievement Unlocker - Auto] No games left - stopping'); - stopIdler(currentGame.appId); + if (currentGame) { + stopIdler(currentGame.appId); + } setGamesWithAchievements(0); setIsComplete(true); return; } - const { achievements, game } = await fetchAchievements(achievementUnlocker[0]); + const { achievements, game } = await fetchAchievements(achievementUnlocker[0], settings); if (achievements.length > 0) { - await unlockAchievements(achievements, game); + await unlockAchievements(achievements, settings); } removeGameFromUnlockerList(game.game.id); @@ -54,13 +57,13 @@ export default function AchievementUnlocker({ setActivePage }) { }; }, []); - const fetchAchievements = async (gameData) => { + const fetchAchievements = async (gameData, settings) => { const game = JSON.parse(gameData); const userSummary = JSON.parse(localStorage.getItem('userSummary')) || {}; setCurrentGame({ appId: game.game.id, name: game.game.name }); - const [userAchievementsResponse, gameAchievementsResponse] = await Promise.all([ + const [userAchievementsResponse, gameAchievementsResponse, gameSchemaResponse] = await Promise.all([ fetch('https://apibase.vercel.app/api/route', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -70,6 +73,11 @@ export default function AchievementUnlocker({ setActivePage }) { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ route: 'game-achievement-percentage', appId: game.game.id }), + }), + fetch('https://apibase.vercel.app/api/route', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ route: 'game-schema', appId: game.game.id }), }) ]); @@ -80,9 +88,19 @@ export default function AchievementUnlocker({ setActivePage }) { const userAchievements = await userAchievementsResponse.json(); const gameAchievements = await gameAchievementsResponse.json(); + const gameSchema = await gameSchemaResponse.json(); const achievements = userAchievements.achievements - .filter(achievement => !achievement.unlocked) + .filter(achievement => { + const schemaAchievement = gameSchema.availableGameStats.achievements.find( + a => a.name === achievement.name + ); + if (settings.achievementUnlocker.hidden) { + return !achievement.unlocked && schemaAchievement.hidden === 0; + } else { + return !achievement.unlocked; + } + }) .map(achievement => { const percentageData = gameAchievements.find(a => a.name === achievement.name); return { @@ -100,8 +118,7 @@ export default function AchievementUnlocker({ setActivePage }) { return { achievements, game }; }; - const unlockAchievements = async (achievements) => { - const settings = JSON.parse(localStorage.getItem('settings')) || {}; + const unlockAchievements = async (achievements, settings) => { const { interval, idle } = settings.achievementUnlocker; if (idle) { diff --git a/components/gameslist/Automate.jsx b/components/gameslist/Automate.jsx index 360e66d..30d75a1 100644 --- a/components/gameslist/Automate.jsx +++ b/components/gameslist/Automate.jsx @@ -72,6 +72,7 @@ export default function Automate({ setActivePage }) { key='idle' startContent={} onClick={startCardFarming} + textValue='Start achievement unlocker' >

Start card farming

@@ -80,6 +81,7 @@ export default function Automate({ setActivePage }) { key='achiements' startContent={} onClick={startAchievementUnlocker} + textValue='Start achievement unlocker' >

Start achievement unlocker

@@ -88,6 +90,7 @@ export default function Automate({ setActivePage }) { key='settings' startContent={} onClick={() => setActivePage('settings')} + textValue='Change settings' >

Change settings

diff --git a/components/gameslist/CardMenu.jsx b/components/gameslist/CardMenu.jsx index 1bd05ec..aa64459 100644 --- a/components/gameslist/CardMenu.jsx +++ b/components/gameslist/CardMenu.jsx @@ -20,6 +20,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='idle' startContent={} onClick={() => handleIdle(item.game.id, item.game.name)} + textValue='Idle game' >

Idle game

@@ -28,6 +29,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='achievements' startContent={} onClick={() => viewAchievments(item)} + textValue='View achievements' >

View achievements

@@ -37,6 +39,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='fav-rem' startContent={} onClick={(e) => removeFromFavorites(e, item)} + textValue='Remove from favorites' >

Remove from favorites

@@ -46,6 +49,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='fav-add' startContent={} onClick={(e) => addToFavorites(e, item)} + textValue='Add to favorites' >

Add to favorites

@@ -56,6 +60,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='cf-rem' startContent={} onClick={(e) => removeFromCardFarming(e, item)} + textValue='Remove from card farming' >

Remove from card farming

@@ -65,6 +70,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='cf-add' startContent={} onClick={(e) => addToCardFarming(e, item)} + textValue='Add to card farming' >

Add to card farming

@@ -75,6 +81,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='au-rem' startContent={} onClick={(e) => removeFromAchievementUnlocker(e, item)} + textValue='Remove from achievement unlocker' >

Remove from achievement unlocker

@@ -84,6 +91,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='au-add' startContent={} onClick={(e) => addToAchievementUnlocker(e, item)} + textValue='Add to achievement unlocker' >

Add to achievement unlocker

diff --git a/components/gameslist/GameAchievementList.jsx b/components/gameslist/GameAchievementList.jsx index 959461f..7563939 100644 --- a/components/gameslist/GameAchievementList.jsx +++ b/components/gameslist/GameAchievementList.jsx @@ -115,8 +115,8 @@ export default function GameAchievementList({ gameList, favorites, cardFarming, > {`${item.game.name} diff --git a/components/gameslist/GameIdleList.jsx b/components/gameslist/GameIdleList.jsx index 2d53cda..80040d8 100644 --- a/components/gameslist/GameIdleList.jsx +++ b/components/gameslist/GameIdleList.jsx @@ -115,8 +115,8 @@ export default function GameIdleList({ gameList, favorites, cardFarming, achieve > {`${item.game.name} diff --git a/components/settings/AchievementSettings.jsx b/components/settings/AchievementSettings.jsx index 8152961..0fe7973 100644 --- a/components/settings/AchievementSettings.jsx +++ b/components/settings/AchievementSettings.jsx @@ -77,6 +77,18 @@ export default function AchievementSettings({ settings, setSettings }) { + +
+

+ Skip hidden achievements +

+
+
+ diff --git a/components/settings/Settings.jsx b/components/settings/Settings.jsx index 6cd280d..786217a 100644 --- a/components/settings/Settings.jsx +++ b/components/settings/Settings.jsx @@ -28,6 +28,7 @@ export default function Settings() { }, achievementUnlocker: { idle: true, + hidden: false, interval: [30, 130], } }; diff --git a/components/settings/SettingsMenu.jsx b/components/settings/SettingsMenu.jsx index 48df8eb..eabe554 100644 --- a/components/settings/SettingsMenu.jsx +++ b/components/settings/SettingsMenu.jsx @@ -17,22 +17,22 @@ export default function SettingsMenu() { - + Help - + Changelog - + Report an issue - + Buy me a coffee