mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 08:50:43 -05:00
Fixed prestiges not being persisted to profile
This commit is contained in:
parent
6ae0517ca3
commit
f4180993cb
@ -3,8 +3,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_standard",
|
"descriptionLocaleKey": "launcher-profile_standard",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -2701,8 +2701,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -5595,8 +5595,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_leftbehind",
|
"descriptionLocaleKey": "launcher-profile_leftbehind",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -8852,8 +8852,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -12213,8 +12213,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_preparetoescape",
|
"descriptionLocaleKey": "launcher-profile_preparetoescape",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -15928,8 +15928,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -19846,8 +19846,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile-edgeofdarkness",
|
"descriptionLocaleKey": "launcher-profile-edgeofdarkness",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -23612,8 +23612,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -27509,8 +27509,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile-unheard",
|
"descriptionLocaleKey": "launcher-profile-unheard",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -32014,8 +32014,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -36740,8 +36740,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile-tournament",
|
"descriptionLocaleKey": "launcher-profile-tournament",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -37729,8 +37729,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -38719,8 +38719,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_sptdeveloper",
|
"descriptionLocaleKey": "launcher-profile_sptdeveloper",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -41870,8 +41870,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -45008,8 +45008,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_spteasystart",
|
"descriptionLocaleKey": "launcher-profile_spteasystart",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -48427,8 +48427,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -51849,8 +51849,8 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_sptzerotohero",
|
"descriptionLocaleKey": "launcher-profile_sptzerotohero",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
@ -52828,8 +52828,8 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"Achievements": [],
|
"Achievements": {},
|
||||||
"Prestige": [],
|
"Prestige": {},
|
||||||
"TaskConditionCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
|
@ -22,8 +22,12 @@ export class PrestigeCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Handle client/prestige/obtain */
|
/** Handle client/prestige/obtain */
|
||||||
public obtainPrestige(url: string, info: IObtainPrestigeRequest[], sessionID: string): INullResponseData {
|
public async obtainPrestige(
|
||||||
this.prestigeController.obtainPrestige(sessionID, info);
|
url: string,
|
||||||
|
info: IObtainPrestigeRequest[],
|
||||||
|
sessionID: string,
|
||||||
|
): Promise<INullResponseData> {
|
||||||
|
await this.prestigeController.obtainPrestige(sessionID, info);
|
||||||
|
|
||||||
return this.httpResponse.nullResponse();
|
return this.httpResponse.nullResponse();
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ export class PrestigeController {
|
|||||||
/**
|
/**
|
||||||
* Handle /client/prestige/obtain
|
* Handle /client/prestige/obtain
|
||||||
*/
|
*/
|
||||||
public obtainPrestige(sessionId: string, request: IObtainPrestigeRequest[]): void {
|
public async obtainPrestige(sessionId: string, request: IObtainPrestigeRequest[]): Promise<void> {
|
||||||
const prePrestigeProfileClone = this.cloner.clone(this.profileHelper.getFullProfile(sessionId));
|
const prePrestigeProfileClone = this.cloner.clone(this.profileHelper.getFullProfile(sessionId));
|
||||||
const prePrestigePmc = prePrestigeProfileClone.characters.pmc;
|
const prePrestigePmc = prePrestigeProfileClone.characters.pmc;
|
||||||
const createRequest: IProfileCreateRequestData = {
|
const createRequest: IProfileCreateRequestData = {
|
||||||
@ -73,14 +73,19 @@ export class PrestigeController {
|
|||||||
voiceId: Object.values(this.databaseService.getTemplates().customization).find(
|
voiceId: Object.values(this.databaseService.getTemplates().customization).find(
|
||||||
(customisation) => customisation._name === prePrestigePmc.Info.Voice,
|
(customisation) => customisation._name === prePrestigePmc.Info.Voice,
|
||||||
)._id,
|
)._id,
|
||||||
sptForcePrestigeLevel: prePrestigeProfileClone.characters.pmc.Info.PrestigeLevel + 1, // Current + 1
|
sptForcePrestigeLevel: prePrestigeProfileClone.characters.pmc.Info.PrestigeLevel + 1, // Current + 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reset profile
|
// Reset profile
|
||||||
this.createProfileService.createProfile(sessionId, createRequest);
|
await this.createProfileService.createProfile(sessionId, createRequest);
|
||||||
|
|
||||||
// Get freshly reset profile ready for editing
|
// Get freshly reset profile ready for editing
|
||||||
const newProfile = this.profileHelper.getFullProfile(sessionId);
|
const newProfile = this.profileHelper.getFullProfile(sessionId);
|
||||||
|
if (!newProfile) {
|
||||||
|
this.logger.error(`Unable to create get new profile for: ${sessionId}`);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Skill copy
|
// Skill copy
|
||||||
const commonSKillsToCopy = prePrestigePmc.Skills.Common;
|
const commonSKillsToCopy = prePrestigePmc.Skills.Common;
|
||||||
@ -109,18 +114,29 @@ export class PrestigeController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const indexToGet = Math.min(createRequest.sptForcePrestigeLevel - 1, 1); // Index starts at 0
|
const indexOfPrestigeObtained = Math.min(createRequest.sptForcePrestigeLevel - 1, 1); // Index starts at 0
|
||||||
const rewards = this.databaseService.getTemplates().prestige.elements[indexToGet].rewards;
|
// Assumes Prestige data is in descending order
|
||||||
this.addPrestigeRewardsToProfile(sessionId, newProfile, rewards);
|
const matchingPrestigeData = this.databaseService.getTemplates().prestige.elements[indexOfPrestigeObtained];
|
||||||
|
|
||||||
|
this.addPrestigeRewardsToProfile(sessionId, newProfile, matchingPrestigeData.rewards);
|
||||||
|
|
||||||
|
// Flag profile as having achieved this prestige level
|
||||||
|
newProfile.characters.pmc.Prestige[matchingPrestigeData.id] = this.timeUtil.getTimestamp();
|
||||||
|
|
||||||
// Copy transferred items
|
// Copy transferred items
|
||||||
for (const transferRequest of request) {
|
for (const transferRequest of request) {
|
||||||
const item = prePrestigePmc.Inventory.items.find((item) => item._id === transferRequest.id);
|
const item = prePrestigePmc.Inventory.items.find((item) => item._id === transferRequest.id);
|
||||||
|
if (!item) {
|
||||||
|
this.logger.error(
|
||||||
|
`Unable to find item with id: ${transferRequest.id} in profile: ${sessionId}, skipping`,
|
||||||
|
);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const addItemRequest: IAddItemDirectRequest = {
|
const addItemRequest: IAddItemDirectRequest = {
|
||||||
itemWithModsToAdd: [item],
|
itemWithModsToAdd: [item],
|
||||||
foundInRaid: item.upd?.SpawnedInSession,
|
foundInRaid: item.upd?.SpawnedInSession ?? false,
|
||||||
useSortingTable: false,
|
useSortingTable: false,
|
||||||
callback: null,
|
|
||||||
};
|
};
|
||||||
this.inventoryHelper.addItemToStash(
|
this.inventoryHelper.addItemToStash(
|
||||||
sessionId,
|
sessionId,
|
||||||
@ -134,6 +150,9 @@ export class PrestigeController {
|
|||||||
if (!newProfile.achievements["676091c0f457869a94017a23"]) {
|
if (!newProfile.achievements["676091c0f457869a94017a23"]) {
|
||||||
newProfile.achievements["676091c0f457869a94017a23"] = this.timeUtil.getTimestamp();
|
newProfile.achievements["676091c0f457869a94017a23"] = this.timeUtil.getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force save of above changes to disk
|
||||||
|
await this.saveServer.saveProfile(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected addPrestigeRewardsToProfile(sessionId: string, newProfile: ISptProfile, rewards: IReward[]) {
|
protected addPrestigeRewardsToProfile(sessionId: string, newProfile: ISptProfile, rewards: IReward[]) {
|
||||||
|
@ -161,7 +161,8 @@ export class InventoryHelper {
|
|||||||
pmcData.Inventory.items.push(...itemWithModsToAddClone);
|
pmcData.Inventory.items.push(...itemWithModsToAddClone);
|
||||||
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Added ${itemWithModsToAddClone[0].upd?.StackObjectsCount ?? 1} item: ${itemWithModsToAddClone[0]._tpl
|
`Added ${itemWithModsToAddClone[0].upd?.StackObjectsCount ?? 1} item: ${
|
||||||
|
itemWithModsToAddClone[0]._tpl
|
||||||
} with: ${itemWithModsToAddClone.length - 1} mods to inventory`,
|
} with: ${itemWithModsToAddClone.length - 1} mods to inventory`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ export interface IBotBase {
|
|||||||
RagfairInfo: IRagfairInfo;
|
RagfairInfo: IRagfairInfo;
|
||||||
/** Achievement id and timestamp */
|
/** Achievement id and timestamp */
|
||||||
Achievements: Record<string, number>;
|
Achievements: Record<string, number>;
|
||||||
|
Prestige: Record<string, number>;
|
||||||
RepeatableQuests: IPmcDataRepeatableQuest[];
|
RepeatableQuests: IPmcDataRepeatableQuest[];
|
||||||
Bonuses: IBonus[];
|
Bonuses: IBonus[];
|
||||||
Notes: INotes;
|
Notes: INotes;
|
||||||
|
@ -4,6 +4,6 @@ export interface IAddItemDirectRequest {
|
|||||||
/** Item and child mods to add to player inventory */
|
/** Item and child mods to add to player inventory */
|
||||||
itemWithModsToAdd: IItem[];
|
itemWithModsToAdd: IItem[];
|
||||||
foundInRaid: boolean;
|
foundInRaid: boolean;
|
||||||
callback: (buyCount: number) => void;
|
callback?: (buyCount: number) => void;
|
||||||
useSortingTable: boolean;
|
useSortingTable: boolean;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export class PrestigeStaticRouter extends StaticRouter {
|
|||||||
new RouteAction(
|
new RouteAction(
|
||||||
"/client/prestige/obtain",
|
"/client/prestige/obtain",
|
||||||
async (url: string, info: any, sessionID: string, _output: string): Promise<INullResponseData> => {
|
async (url: string, info: any, sessionID: string, _output: string): Promise<INullResponseData> => {
|
||||||
return this.prestigeCallbacks.obtainPrestige(url, info, sessionID);
|
return await this.prestigeCallbacks.obtainPrestige(url, info, sessionID);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user