forked from Saegusae/drop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setting_migration.js
42 lines (36 loc) · 1.02 KB
/
setting_migration.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
'use strict'
const DefaultSettings = {
"defaultPercent": null,
"dropCooldown": 40,
"afkMin": 1,
"afkMax": 30
}
module.exports = function MigrateSettings(from_ver, to_ver, settings) {
if(from_ver === undefined) {
return Object.assign(Object.assign({}, DefaultSettings), settings);
} else if(from_ver === null) {
return DefaultSettings;
} else {
if (from_ver + 1 < to_ver) {
settings = MigrateSettings(from_ver, from_ver + 1, settings);
return MigrateSettings(from_ver + 1, to_ver, settings);
}
switch(to_ver)
{
case 2:
settings.dropCooldown = 30;
break;
case 3:
delete settings.firstUse;
break;
case 4:
settings.afkMin = 1;
settings.afkMax = 30;
if(settings.dropCooldown < 40) {
settings.dropCooldown = 40;
}
break;
}
return settings;
}
}