mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 14:59:16 +02:00
Add achievements to base game
- Add a script to generate achievement data from Steamworks API - Add achievements page with a link in sidebar - Calculate achievements (1/min) with an engine counter - Store achievements with a timestamp on unlocked in the PlayerObject - Add a script to generate monochrome icons from Steam icons - Add toast when unlocking an achievement
This commit is contained in:
@@ -10,3 +10,13 @@ It decodes the save and prettifies the output. Canno be used to modify a save ga
|
||||
```sh
|
||||
node ./pretty-save.js 'C:\\Users\\martin\\Desktop\\bitburnerSave_1641395736_BN12x14.json' 'C:\\Users\\martin\\Desktop\\pretty.json'
|
||||
```
|
||||
|
||||
## Fetch Steam Achievements Data
|
||||
|
||||
Used to synchronize the achievements info in steamworks to the game's data.json
|
||||
|
||||
**Usage**
|
||||
```sh
|
||||
# Get your key here: https://steamcommunity.com/dev/apikey
|
||||
node fetch-steam-achievements-data.js DEVKEYDEVKEYDEVKEYDEVKEY
|
||||
```
|
||||
|
||||
69
tools/fetch-steam-achievements-data.js
Normal file
69
tools/fetch-steam-achievements-data.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const https = require('https')
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const key = process.argv[2]
|
||||
|
||||
function getRawJSON() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const options = {
|
||||
hostname: 'api.steampowered.com',
|
||||
port: 443,
|
||||
path: `/ISteamUserStats/GetSchemaForGame/v0002/?appid=1812820&key=${key}`,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
||||
}
|
||||
}
|
||||
|
||||
let data = [];
|
||||
const req = https.request(options, res => {
|
||||
console.log(`statusCode: ${res.statusCode}`)
|
||||
|
||||
res.on('data', chunk => {
|
||||
data.push(chunk)
|
||||
})
|
||||
|
||||
res.on('end', () => {
|
||||
console.log('Response ended: ');
|
||||
resolve(Buffer.concat(data).toString());
|
||||
});
|
||||
})
|
||||
|
||||
req.on('error', error => {
|
||||
console.error(error)
|
||||
req.end();
|
||||
reject(error);
|
||||
});
|
||||
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchAchievementsData() {
|
||||
const raw = await getRawJSON();
|
||||
const o = JSON.parse(raw);
|
||||
const achievements = {};
|
||||
o.game.availableGameStats.achievements.forEach((a) => {
|
||||
achievements[a.name] = {
|
||||
ID: a.name,
|
||||
Name: a.displayName,
|
||||
Description: a.description,
|
||||
};
|
||||
})
|
||||
|
||||
const data = {
|
||||
note: '***** Generated from a script, overwritten by steam achievements data *****',
|
||||
fetchedOn: new Date().getTime(),
|
||||
achievements,
|
||||
}
|
||||
|
||||
const jsonPath = path.resolve(__dirname, '../src/Achievements/AchievementData.json');
|
||||
await fs.writeFile(jsonPath, JSON.stringify(data, null, 2));
|
||||
return data;
|
||||
}
|
||||
|
||||
fetchAchievementsData().
|
||||
then((json) => console.log(JSON.stringify(json, null, 2)));
|
||||
Reference in New Issue
Block a user