mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 04:35:46 +01:00
Handle Steam achievement status check failure by logging them
This commit is contained in:
parent
521889b027
commit
c7c303c551
@ -10,7 +10,7 @@ async function enableAchievementsInterval(window) {
|
||||
// here. Hey if it works it works.
|
||||
const steamAchievements = greenworks.getAchievementNames();
|
||||
log.info(`All Steam achievements ${JSON.stringify(steamAchievements)}`);
|
||||
const playerAchieved = (await Promise.all(steamAchievements.map(name => new Promise((resolve, reject) => { greenworks.getAchievement(name, (playerHas) => resolve(playerHas ? name : ""), reject); })))).filter(name => !!name);
|
||||
const playerAchieved = (await Promise.all(steamAchievements.map(checkSteamAchievement))).filter(name => !!name);
|
||||
log.info(`Player has Steam achievements ${JSON.stringify(playerAchieved)}`);
|
||||
const intervalID = setInterval(async () => {
|
||||
try {
|
||||
@ -34,6 +34,15 @@ async function enableAchievementsInterval(window) {
|
||||
window.achievementsIntervalID = intervalID;
|
||||
}
|
||||
|
||||
function checkSteamAchievement(name) {
|
||||
return new Promise((resolve) => {
|
||||
greenworks.getAchievement(name, playerHas => resolve(playerHas ? name : ""), err => {
|
||||
log.warn(`Failed to get Steam achievement ${name} status: ${err}`);
|
||||
resolve("");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function disableAchievementsInterval(window) {
|
||||
if (window.achievementsIntervalID) {
|
||||
clearInterval(window.achievementsIntervalID);
|
||||
|
Loading…
Reference in New Issue
Block a user