-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsave.js
More file actions
158 lines (123 loc) · 5.13 KB
/
save.js
File metadata and controls
158 lines (123 loc) · 5.13 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
var fs = require('fs');
var path = require('path');
const appDir = path.dirname(require.main.filename) + '/';
exports.getSoul = () => {
if (!fs.existsSync(appDir + 'Save/soul.json')) {
console.log("soul doesnt exist yet. creating from template");
var templSoul = fs.readFileSync(appDir + 'SaveTemplates/soul_start.json');
fs.writeFileSync(appDir + 'Save/soul.json', templSoul);
return JSON.parse(templSoul)["soul"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/soul.json'))["soul"];
}
exports.setSoul = (soul) => {
fs.writeFileSync(appDir + 'Save/soul.json', JSON.stringify({'soul':soul}));
}
exports.getUser = () => {
if (!fs.existsSync(appDir + 'Save/user.json')) {
console.log("user doesnt exist yet. creating from template");
var templUser = fs.readFileSync(appDir + 'SaveTemplates/user_start.json');
templUser = JSON.parse(templUser);
templUser["user"]["soul"] = exports.getSoul();
fs.writeFileSync(appDir + 'Save/user.json', JSON.stringify(templUser));
return templUser["user"];
}
var user = JSON.parse(fs.readFileSync(appDir + 'Save/user.json'))
user["user"]["soul"] = exports.getSoul();
return user["user"];
}
exports.setUser = (user) => {
exports.setSoul(user['soul']);
fs.writeFileSync(appDir + 'Save/user.json', JSON.stringify({'user':user}));
}
exports.getUserConfigMenu = () => {
if (!fs.existsSync(appDir + 'Save/user_config_menu.json')) {
console.log("user_config_menu doesnt exist yet. creating from template");
var templ = fs.readFileSync(appDir + 'SaveTemplates/user_config_menu_start.json');
fs.writeFileSync(appDir + 'Save/user_config_menu.json', templ);
return JSON.parse(templ)["user_config_menu"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/user_config_menu.json'))["user_config_menu"];
}
exports.getUserResearch = () => {
if (!fs.existsSync(appDir + 'Save/user_research.json')) {
console.log("user_research doesnt exist yet. creating from template");
var templ = fs.readFileSync(appDir + 'SaveTemplates/user_research_start.json');
fs.writeFileSync(appDir + 'Save/user_research.json', templ);
return JSON.parse(templ)["user_research"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/user_research.json'))["user_research"];
}
exports.getHitChart = () => {
if (!fs.existsSync(appDir + 'Save/hitchart.json')) {
console.log("hitchart doesnt exist yet. creating from template");
var templ = fs.readFileSync(appDir + 'SaveTemplates/hitchart_start.json');
fs.writeFileSync(appDir + 'Save/hitchart.json', templ);
return JSON.parse(templ)["hitchart"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/hitchart.json'))["hitchart"];
}
exports.getLoadingAnnounces = () => {
if (!fs.existsSync(appDir + 'Save/loading_announces.json')) {
console.log("loading_announces doesnt exist yet. creating from template");
var templ = fs.readFileSync(appDir + 'SaveTemplates/loading_announces_start.json');
fs.writeFileSync(appDir + 'Save/loading_announces.json', templ);
return JSON.parse(templ)["loading_announces"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/loading_announces.json'))["loading_announces"];
}
exports.getCl = () => {
if (!fs.existsSync(appDir + 'Save/cl.json')) {
console.log("cl doesnt exist yet. creating from template");
var templ = fs.readFileSync(appDir + 'SaveTemplates/cl_start.json');
fs.writeFileSync(appDir + 'Save/cl.json', templ);
return JSON.parse(templ)["cl"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/cl.json'))["cl"];
}
exports.getAllQuests = () => {
if (!fs.existsSync(appDir + 'Save/all_quests.json')) {
console.log("all_quests doesnt exist yet. creating from template");
var templ = fs.readFileSync(appDir + 'SaveTemplates/all_quests_start.json');
fs.writeFileSync(appDir + 'Save/all_quests.json', templ);
return JSON.parse(templ)["all_quests"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/all_quests.json'))["all_quests"];
}
exports.getPlaylog = () => {
if (!fs.existsSync(appDir + 'Save/playlog.json')) {
console.log("playlog doesnt exist yet. creating from template");
var templ = fs.readFileSync(appDir + 'SaveTemplates/playlog_start.json');
fs.writeFileSync(appDir + 'Save/playlog.json', templ);
return JSON.parse(templ)["playlog"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/playlog.json'))["playlog"];
}
exports.getAv = () => 3;
exports.getDv = () => 146;
exports.getE = () => "0";
exports.getSt = () => 0;
exports.getEmsg = () => "";
exports.getEparam = () => "";
exports.getEnv = () => "prds";
exports.getAccountId = () => "LET_IT_DIE_OFFLINE";
exports.getJson = () => 1;
exports.getCtime = () => {
return {
"sec":Date.now()/1000,
"msec":77,
"svr":1
}
};
exports.getTutorialState = () => {
if (!fs.existsSync(appDir + 'Save/tutorial.json')) {
console.log("tutorial doesnt exist yet. creating from template");
var templ = fs.readFileSync(appDir + 'SaveTemplates/tutorial_start.json');
fs.writeFileSync(appDir + 'Save/tutorial.json', templ);
return JSON.parse(templ)["tutorial"];
}
return JSON.parse(fs.readFileSync(appDir + 'Save/tutorial.json'))["tutorial"];
}
exports.setTutorialState = (tutorial) => {
fs.writeFileSync(appDir + 'Save/tutorial.json', JSON.stringify({'tutorial':tutorial}));
}