-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogSavedData.js
50 lines (40 loc) · 1.31 KB
/
logSavedData.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Debugging utility that dumps all player saved data to a json file.
let unlockablesTable;
let unlockables;
let playerStats;
let savedPaintingIDs;
function preload() {
unlockablesTable = loadTable('./assets/unlockables.csv', 'csv', 'header');
}
function setup() {
noCanvas();
console.log('Retrieving player stats...');
playerStats = getItem('stats');
console.log('Complete...\n');
console.log('Retrieving player paintings...');
savedPaintingIDs = getItem('savedPaintings');
let savedPaintings = [];
if (savedPaintingIDs != null) {
console.log('\tSuccessfully retrieved painting ids...');
JSON.parse(savedPaintingIDs).forEach((paintingID, index) => {
console.log('\t\tRetrieving painting: ' + paintingID + '...');
let paintingJSON = getItem(paintingID);
savedPaintings.push(paintingJSON);
console.log('\t\tComplete...\n');
});
console.log('\tComplete...\n');
}
console.log('Saving Player Data...');
let data = {
'stats': playerStats,
'paintingIDs': savedPaintingIDs,
'paintings': savedPaintings,
};
let w = createWriter('playerData.txt');
w.print(JSON.stringify(data));
w.close();
console.log('Complete...\n');
console.log('Saving Unlockables Table...');
saveTable(unlockablesTable, 'unlockables.csv');
console.log('Complete...\n');
}