mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Added code to add hideout customisation unlocks to profile when quest completion rewards an achievement
Fixed inaccurate `rewards` type for achievement object
This commit is contained in:
parent
b0d3d68d01
commit
3e760e88e4
@ -235,7 +235,7 @@ export class CustomizationController {
|
|||||||
return customisationResultsClone;
|
return customisationResultsClone;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append on customisations unlocked by player to results
|
// Append customisations unlocked by player to results
|
||||||
customisationResultsClone.push(...(profile.customisationUnlocks ?? []));
|
customisationResultsClone.push(...(profile.customisationUnlocks ?? []));
|
||||||
|
|
||||||
return customisationResultsClone;
|
return customisationResultsClone;
|
||||||
|
@ -544,12 +544,47 @@ export class ProfileHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an achievement to player profile
|
* Add an achievement to player profile + check for and add any hideout customisation unlocks to profile
|
||||||
* @param pmcProfile Profile to add achievement to
|
* @param fullProfile Profile to add achievement to
|
||||||
* @param achievementId Id of achievement to add
|
* @param achievementId Id of achievement to add
|
||||||
*/
|
*/
|
||||||
public addAchievementToProfile(pmcProfile: IPmcData, achievementId: string): void {
|
public addAchievementToProfile(fullProfile: ISptProfile, achievementId: string): void {
|
||||||
pmcProfile.Achievements[achievementId] = this.timeUtil.getTimestamp();
|
// Add achievement id to profile with timestamp it was unlocked
|
||||||
|
fullProfile.characters.pmc.Achievements[achievementId] = this.timeUtil.getTimestamp();
|
||||||
|
|
||||||
|
// Check for any customisation unlocks
|
||||||
|
const achievementDataDb = this.databaseService
|
||||||
|
.getTemplates()
|
||||||
|
.achievements.find((achievement) => achievement.id === achievementId);
|
||||||
|
if (!achievementDataDb) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get customisation reward object from achievement db
|
||||||
|
const customizationDirectReward = achievementDataDb.rewards.find(
|
||||||
|
(reward) => reward.type === "CustomizationDirect",
|
||||||
|
);
|
||||||
|
if (!customizationDirectReward) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const customisationDataDb = this.databaseService
|
||||||
|
.getHideout()
|
||||||
|
.customisation.globals.find((customisation) => customisation.itemId === customizationDirectReward.target);
|
||||||
|
if (!customisationDataDb) {
|
||||||
|
this.logger.error(
|
||||||
|
`Unable to find customisation data for ${customizationDirectReward.target} in profile ${fullProfile.info.id}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reward found, add to profile
|
||||||
|
fullProfile.customisationUnlocks.push({
|
||||||
|
id: customizationDirectReward.target,
|
||||||
|
source: "achievement",
|
||||||
|
type: customisationDataDb.type,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public hasAccessToRepeatableFreeRefreshSystem(pmcProfile: IPmcData): boolean {
|
public hasAccessToRepeatableFreeRefreshSystem(pmcProfile: IPmcData): boolean {
|
||||||
|
@ -979,7 +979,7 @@ export class QuestHelper {
|
|||||||
// Handled by getAssort(), locked assorts are stripped out by `assortHelper.stripLockedLoyaltyAssort()` before being sent to player
|
// Handled by getAssort(), locked assorts are stripped out by `assortHelper.stripLockedLoyaltyAssort()` before being sent to player
|
||||||
break;
|
break;
|
||||||
case QuestRewardType.ACHIEVEMENT:
|
case QuestRewardType.ACHIEVEMENT:
|
||||||
this.profileHelper.addAchievementToProfile(pmcProfile, reward.target);
|
this.profileHelper.addAchievementToProfile(fullProfile, reward.target);
|
||||||
break;
|
break;
|
||||||
case QuestRewardType.STASH_ROWS:
|
case QuestRewardType.STASH_ROWS:
|
||||||
this.profileHelper.addStashRowsBonusToProfile(sessionId, Number.parseInt(<string>reward.value)); // Add specified stash rows from quest reward - requires client restart
|
this.profileHelper.addStashRowsBonusToProfile(sessionId, Number.parseInt(<string>reward.value)); // Add specified stash rows from quest reward - requires client restart
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { IQuestConditionTypes, IQuestRewards } from "@spt/models/eft/common/tables/IQuest";
|
import { IQuestConditionTypes, IQuestReward } from "@spt/models/eft/common/tables/IQuest";
|
||||||
|
|
||||||
export interface IAchievement {
|
export interface IAchievement {
|
||||||
id: string;
|
id: string;
|
||||||
imageUrl: string;
|
imageUrl: string;
|
||||||
assetPath: string;
|
assetPath: string;
|
||||||
rewards: IQuestRewards;
|
rewards: IQuestReward[];
|
||||||
conditions: IQuestConditionTypes;
|
conditions: IQuestConditionTypes;
|
||||||
instantComplete: boolean;
|
instantComplete: boolean;
|
||||||
showNotificationsInGame: boolean;
|
showNotificationsInGame: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user