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={
Start card farming
@@ -80,6 +81,7 @@ export default function Automate({ setActivePage }) { key='achiements' startContent={Start achievement unlocker
@@ -88,6 +90,7 @@ export default function Automate({ setActivePage }) { key='settings' startContent={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={Idle game
@@ -28,6 +29,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='achievements' startContent={View achievements
@@ -37,6 +39,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='fav-rem' startContent={Remove from favorites
@@ -46,6 +49,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='fav-add' startContent={Add to favorites
@@ -56,6 +60,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='cf-rem' startContent={Remove from card farming
@@ -65,6 +70,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='cf-add' startContent={Add to card farming
@@ -75,6 +81,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='au-rem' startContent={Remove from achievement unlocker
@@ -84,6 +91,7 @@ export default function CardMenu({ item, favorites, cardFarming, achievementUnlo key='au-add' startContent={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, >+ Skip hidden achievements +
+