Skip to content

Commit b24dd48

Browse files
committed
improve data requests
1 parent 8230d87 commit b24dd48

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/tarkov-data-manager/modules/game-modes.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@ const gameModes = [
22
{
33
name: 'regular',
44
value: 0,
5+
skipData: [],
56
},
67
{
78
name: 'pve',
89
value: 1,
10+
skipData: [
11+
'achievements',
12+
'achievementStats',
13+
'customization',
14+
'prestige',
15+
],
916
},
1017
];
1118

19+
export const getGameMode = (gameModeName) => {
20+
return gameModes.find(gm => gm.name === gameModeName);
21+
};
22+
1223
export default gameModes;

src/tarkov-data-manager/modules/tarkov-changes.mjs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import path from 'node:path';
44
import got from 'got';
55

66
import dataOptions from './data-options.mjs';
7+
import gameModes, { getGameMode } from './game-modes.mjs';
78

89
const defaultOptions = dataOptions.default;
910
const merge = dataOptions.merge;
@@ -153,18 +154,11 @@ const tarkovChanges = {
153154
},
154155
downloadAll: async (options = defaultOptions) => {
155156
options = {...merge(options), download: true};
156-
const skip = {
157-
pve: [
158-
'achievements',
159-
'achievementStats',
160-
'customization',
161-
'prestige',
162-
],
163-
};
157+
const gameMode = getGameMode(options.gameMode);
164158
const promises = [];
165159
for (const file in availableFiles) {
166160
if (availableFiles[file].skip) continue;
167-
if (skip[options.gameMode]?.includes(file)) continue;
161+
if (gameMode.skipData?.includes(file)) continue;
168162
promises.push(tarkovChanges[file](options)
169163
.then(data => {return {name: file, data}})
170164
.catch(error => {return {name: file, error}})

src/tarkov-data-manager/modules/tarkov-dev-data.mjs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,10 @@ const tarkovDevData = {
170170
},
171171
downloadAll: async(options = defaultOptions) => {
172172
options = {...merge(options), download: true};
173-
const skip = {
174-
pve: [
175-
'achievements',
176-
'achievementStats',
177-
'customization',
178-
'prestige',
179-
],
180-
};
173+
const gameMode = getGameMode(options.gameMode);
181174
const promises = [];
182175
for (const file in availableFiles) {
183-
if (skip[options.gameMode]?.includes(file)) continue;
176+
if (gameMode.skipData?.includes(file)) continue;
184177
promises.push(tarkovDevData[file](options)
185178
.then(data => { return {name: file, data}; })
186179
.catch(error => { return {name: file, error}; })

0 commit comments

Comments
 (0)