Skip to content

Commit

Permalink
fix: drops in legacy mission rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
RDIL committed Aug 11, 2024
1 parent 64cc438 commit a8da654
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
18 changes: 7 additions & 11 deletions components/candle/progressionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ProgressionService {
userProfile: UserProfile,
location: string,
sniperUnlockable?: string,
) {
): void {
// Total XP for profile XP is the total sum of the action and mastery XP
const xp = actionXp + masteryXp

Expand Down Expand Up @@ -104,7 +104,7 @@ export class ProgressionService {
masteryLocationDrops: MasteryPackageDrop[],
minLevel: number,
maxLevel: number,
) {
): Unlockable[] {
const unlockableIds = masteryLocationDrops
.filter((drop) => drop.Level > minLevel && drop.Level <= maxLevel)
.map((drop) => drop.Id)
Expand Down Expand Up @@ -135,7 +135,7 @@ export class ProgressionService {
}
}

return unlockables
return unlockables.filter((u) => !!u) as Unlockable[]
}

// Grants xp and rewards to mastery progression on contract location
Expand All @@ -146,11 +146,11 @@ export class ProgressionService {
userProfile: UserProfile,
location: string,
sniperUnlockable?: string,
): boolean {
): void {
const contract = controller.resolveContract(contractSession.contractId)

if (!contract) {
return false
return
}

const subLocation = getSubLocationByName(
Expand All @@ -163,7 +163,7 @@ export class ProgressionService {
: location ?? contract.Metadata.Location

if (!parentLocationId) {
return false
return
}

// We can't grant sniper XP here as it's based on final score, so we skip updating mastery
Expand Down Expand Up @@ -248,8 +248,6 @@ export class ProgressionService {
profileData.Sublocations[contract.Metadata.Location].Xp += masteryXp
profileData.Sublocations[contract.Metadata.Location].ActionXp +=
actionXp

return true
}

// Grants xp to user profile
Expand All @@ -258,7 +256,7 @@ export class ProgressionService {
xp: number,
contractSession: ContractSession,
userProfile: UserProfile,
): boolean {
): void {
const profileData = userProfile.Extensions.progression.PlayerProfileXP

profileData.Total += xp
Expand All @@ -267,7 +265,5 @@ export class ProgressionService {
1,
getMaxProfileLevel(contractSession.gameVersion),
)

return true
}
}
25 changes: 16 additions & 9 deletions components/menuData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ menuDataRouter.get(
const contractData = controller.resolveContract(contractId, true)
const userData = getUserData(req.jwt.unique_name, req.gameVersion)

assert.ok(contractData, "contract not found")
assert.ok(userData, "user data not found")

const difficulty =
contractData.Metadata.Difficulty === "pro1" ? "pro1" : "normal"

try {
const missionEndData = await getMissionEndData(
req.query,
Expand All @@ -317,11 +323,9 @@ menuDataRouter.get(
res.json({
template: getConfig("MissionRewardsTemplate", false),
data: {
LevelInfo: [
0, 6000, 12000, 18000, 24000, 30000, 36000, 42000,
48000, 54000, 60000, 66000, 72000, 78000, 84000, 90000,
96000, 102000, 108000, 114000,
],
LevelInfo:
missionEndData.MissionReward.LocationProgression
.LevelInfo,
XP: missionEndData.ScoreOverview.XP,
Level: missionEndData.ScoreOverview.Level,
Completion: missionEndData.ScoreOverview.Completion,
Expand All @@ -331,7 +335,6 @@ menuDataRouter.get(
contractId,
req.gameVersion,
req.jwt.unique_name,
// TODO: Should a difficulty be passed here?
),
)
.flat()
Expand All @@ -348,11 +351,15 @@ menuDataRouter.get(
ChallengeDescription: challengeData.Description,
XPGain: challengeData.Rewards.MasteryXP,
})),
Drops: [],
Drops: missionEndData.MissionReward.Drops.map((drop) => ({
// legacy doesn't have the source challenge
Unlockable: drop.Unlockable,
})),
ContractCompletionBonus: 0,
GroupCompletionBonus: 0,
LocationHideProgression: true,
Difficulty: "normal", // FIXME: is this right?
LocationHideProgression:
missionEndData.ScoreOverview.LocationHideProgression,
Difficulty: difficulty,
CompletionData: generateCompletionData(
contractData?.Metadata.Location || "",
req.jwt.unique_name,
Expand Down
2 changes: 1 addition & 1 deletion components/scoreHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ export async function getMissionEndData(
].PreviouslySeenXp = newLocationXp
}

writeUserData(jwt.unique_name, gameVersion)
if (!isDryRun) writeUserData(jwt.unique_name, gameVersion)

const masteryData = controller.masteryService.getMasteryPackage(
locationParentId,
Expand Down

0 comments on commit a8da654

Please sign in to comment.