Skip to content

Commit

Permalink
Merge pull request #971 from the-hideout/feature/fix_faction_quests
Browse files Browse the repository at this point in the history
Saving Faction from TT and using it to filter active quests
  • Loading branch information
Razzmatazzz authored Aug 16, 2024
2 parents 0b96c6b + e741e71 commit c95e602
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/features/quests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const selectQuestsWithActive = createSelector([selectQuests, selectTrader
if (settings[settings.gameMode].playerLevel < quest.minPlayerLevel) {
//return false;
}
if (quest.factionName !== 'Any' && settings[settings.gameMode].pmcFaction !== 'NONE' && settings[settings.gameMode].pmcFaction !== quest.factionName) {
return false;
}
for (const req of quest.taskRequirements) {
let reqSatisfied = false;
for (const status of req.status) {
Expand Down
41 changes: 23 additions & 18 deletions src/features/settings/settingsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export const fetchTarkovTrackerProgress = createAsyncThunk(
}

const returnData = {
flea: true,
level: 72,
hasFlea: true,
playerLevel: 72,
pmcFaction: 'NONE',
hideout: {},
quests: [],
questsFailed: [],
Expand Down Expand Up @@ -46,9 +47,11 @@ export const fetchTarkovTrackerProgress = createAsyncThunk(
}
return completedObjectives;
}, []);
returnData.flea = progressData.playerLevel >= 15 ? true : false;
returnData.hasFlea = progressData.playerLevel >= 15 ? true : false;

returnData.level = progressData.playerLevel;
returnData.playerLevel = progressData.playerLevel;

returnData.pmcFaction = progressData.pmcFaction;

const hideoutData = getState().hideout.data;

Expand All @@ -62,12 +65,12 @@ export const fetchTarkovTrackerProgress = createAsyncThunk(
}

for (const station of hideoutData) {
for (const level of station.levels) {
if (level.id !== module.id) {
for (const stationLevel of station.levels) {
if (stationLevel.id !== module.id) {
continue;
}
if (returnData.hideout[station.normalizedName] < level.level) {
returnData.hideout[station.normalizedName] = level.level;
if (returnData.hideout[station.normalizedName] < stationLevel.level) {
returnData.hideout[station.normalizedName] = stationLevel.level;
continue;
}
}
Expand Down Expand Up @@ -101,7 +104,12 @@ const localStorageWriteJson = (key, value) => {

const defaultSettings = {hasFlea: localStorageReadJson('useFlea', true),
playerLevel: 72,
pmcFaction: localStorageReadJson('pmcFaction', 'NONE'),
useTarkovTracker: localStorageReadJson('useTarkovTracker', false),
tarkovTrackerAPIKey: localStorageReadJson('tarkovTrackerAPIKey', ''),
completedQuests: [],
failedQuests: [],
tarkovTrackerModules: [],
prapor: localStorageReadJson('prapor', 4),
therapist: localStorageReadJson('therapist', 4),
fence: localStorageReadJson('fence', 0),
Expand All @@ -115,18 +123,14 @@ const defaultSettings = {hasFlea: localStorageReadJson('useFlea', true),
'booze-generator': localStorageReadJson('booze-generator', 1),
'christmas-tree': localStorageReadJson('christmas-tree', 1),
'intelligence-center': localStorageReadJson('intelligence-center', 3),
lavatory: localStorageReadJson('lavatory', 3),
medstation: localStorageReadJson('medstation', 3),
'lavatory': localStorageReadJson('lavatory', 3),
'medstation': localStorageReadJson('medstation', 3),
'nutrition-unit': localStorageReadJson('nutrition-unit', 3),
'water-collector': localStorageReadJson('water-collector', 3),
workbench: localStorageReadJson('workbench', 3),
'workbench': localStorageReadJson('workbench', 3),
'solar-power': localStorageReadJson('solar-power', 0),
crafting: localStorageReadJson('crafting', 0),
'crafting': localStorageReadJson('crafting', 0),
'hideout-management': localStorageReadJson('hideout-management', 0),
completedQuests: [],
failedQuests: [],
useTarkovTracker: localStorageReadJson('useTarkovTracker', false),
tarkovTrackerModules: [],
minDogtagLevel: localStorageReadJson('minDogtagLevel', 1),
hideDogtagBarters: localStorageReadJson('hideDogtagBarters', false),
};
Expand Down Expand Up @@ -213,8 +217,9 @@ const settingsSlice = createSlice({
state[state.gameMode].completedQuests = action.payload.quests;
state[state.gameMode].failedQuests = action.payload.questsFailed;
state[state.gameMode].objectivesCompleted = action.payload.objectivesCompleted;
state[state.gameMode].hasFlea = action.payload.flea;
state[state.gameMode].playerLevel = action.payload.level;
state[state.gameMode].hasFlea = action.payload.hasFlea;
state[state.gameMode].playerLevel = action.payload.playerLevel;
state[state.gameMode].pmcFaction = action.payload.pmcFaction;

for (const stationKey in action.payload.hideout) {
settingsSlice.caseReducers.setStationOrTraderLevel(state, {
Expand Down

0 comments on commit c95e602

Please sign in to comment.