2023-01-29 04:35:07 +00:00
|
|
|
/*
|
|
|
|
* The Peacock Project - a HITMAN server replacement.
|
|
|
|
* Copyright (C) 2021-2023 The Peacock Project Team
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { getUserData, writeUserData } from "./databaseHandler"
|
|
|
|
import { getConfig } from "./configSwizzleManager"
|
|
|
|
import { ContractProgressionData } from "./types/types"
|
2023-03-18 22:53:14 +01:00
|
|
|
import { getFlag } from "./flags"
|
2023-04-22 05:13:26 -04:00
|
|
|
import { EVERGREEN_LEVEL_INFO } from "./utils"
|
2023-01-29 04:35:07 +00:00
|
|
|
|
2023-07-24 23:47:28 +01:00
|
|
|
export function setCpd(
|
2023-01-29 04:35:07 +00:00
|
|
|
data: ContractProgressionData,
|
|
|
|
uID: string,
|
|
|
|
cpdID: string,
|
|
|
|
) {
|
|
|
|
const userData = getUserData(uID, "h3")
|
|
|
|
|
|
|
|
userData.Extensions.CPD[cpdID] = {
|
|
|
|
...userData.Extensions.CPD[cpdID],
|
|
|
|
...data,
|
|
|
|
}
|
|
|
|
|
2023-07-24 23:47:28 +01:00
|
|
|
writeUserData(uID, "h3")
|
2023-01-29 04:35:07 +00:00
|
|
|
}
|
|
|
|
|
2023-07-24 23:47:28 +01:00
|
|
|
export function getCpd(uID: string, cpdID: string): ContractProgressionData {
|
2023-01-29 04:35:07 +00:00
|
|
|
const userData = getUserData(uID, "h3")
|
|
|
|
|
|
|
|
if (!Object.keys(userData.Extensions.CPD).includes(cpdID)) {
|
|
|
|
const defaultCPD = getConfig(
|
|
|
|
"DefaultCpdConfig",
|
|
|
|
false,
|
|
|
|
) as ContractProgressionData
|
|
|
|
|
2023-07-24 23:47:28 +01:00
|
|
|
setCpd(defaultCPD, uID, cpdID)
|
2023-01-29 04:35:07 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 23:39:57 -04:00
|
|
|
// NOTE: Override the EvergreenLevel with the latest Mastery Level
|
2023-03-18 22:53:14 +01:00
|
|
|
if (getFlag("gameplayUnlockAllFreelancerMasteries")) {
|
2023-04-22 05:13:26 -04:00
|
|
|
userData.Extensions.CPD[cpdID]["EvergreenLevel"] =
|
|
|
|
EVERGREEN_LEVEL_INFO.length
|
2023-03-18 22:53:14 +01:00
|
|
|
}
|
2023-03-18 18:35:26 +01:00
|
|
|
|
2023-01-29 04:35:07 +00:00
|
|
|
return userData.Extensions.CPD[cpdID]
|
|
|
|
}
|