1
mirror of https://github.com/thepeacockproject/Peacock synced 2025-03-27 11:12:44 +01:00

Tick all unticked challenge in parent location on the mission end page ()

* Tick all unticked challenge in parent location

* Update default profile with actually used strings

* Add PreviouslySeenXp

* Fix evergreen xp display

* count global xp towards location mastery

* fix type

* run prettier

* Update legacy default user

---------

Co-authored-by: Anthony Fuller <24512050+AnthonyFuller@users.noreply.github.com>
Co-authored-by: Reece Dunham <me@rdil.rocks>
This commit is contained in:
moonysolari 2023-04-22 13:59:47 -04:00 committed by GitHub
parent b3d0353df1
commit d2b10e4425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 40 deletions

@ -130,6 +130,7 @@ export class MasteryService {
userProfile.Extensions.progression.Locations[completionId] ??= {
Xp: 0,
Level: 1,
PreviouslySeenXp: 0,
}
const completionData =
@ -149,6 +150,7 @@ export class MasteryService {
Level: completionData.Level,
MaxLevel: maxLevel,
XP: completionData.Xp,
PreviouslySeenXp: completionData.PreviouslySeenXp,
Completion:
(completionData.Xp - thisLevelXp) / (nextLevelXp - thisLevelXp),
XpLeft: nextLevelXp - completionData.Xp,
@ -269,6 +271,7 @@ export class MasteryService {
locationParentId,
gameVersion,
userId,
locationParentId.includes("SNUG") ? "evergreen" : "mission",
)
const drops: MasteryDrop[] = masteryData.Drops.filter((drop) => {

@ -76,6 +76,7 @@ export class ProgressionService {
] ??= {
Xp: 0,
Level: 1,
PreviouslySeenXp: 0,
})
}

@ -137,6 +137,7 @@ export function generateCompletionData(
Level: 1,
MaxLevel: 1,
XP: 0,
PreviouslySeenXp: 0,
Completion: 1.0,
XpLeft: 0,
Id: locationId,

@ -243,6 +243,7 @@ menuDataRouter.get("/Hub", (req: RequestWithJwt, res) => {
parent,
req.gameVersion,
req.jwt.unique_name,
parent.includes("SNUG") ? "evergreen" : "mission",
)
masteryData.push({

@ -206,7 +206,7 @@ export function calculatePlaystyle(
return playstylesCopy
}
export function calculateXp(
export function calculateGlobalXp(
contractSession: ContractSession,
gameVersion: GameVersion,
): CalculateXpResult {
@ -670,15 +670,16 @@ export async function missionEnd(
const playerProgressionData =
userData.Extensions.progression.PlayerProfileXP
//Calculate XP based on all challenges, including the global ones.
const calculateXpResult: CalculateXpResult = calculateXp(
// Calculate XP based on global challenges.
const calculateXpResult: CalculateXpResult = calculateGlobalXp(
sessionDetails,
req.gameVersion,
)
let justTickedChallenges = 0
let masteryXpGain = 0
let totalXpGain = calculateXpResult.xp
Object.values(contractChallenges)
// Calculate XP based on non-global challenges.
Object.values(locationChallenges)
.flat()
.filter((challengeData) => {
return (
@ -699,7 +700,7 @@ export async function missionEnd(
justTickedChallenges++
masteryXpGain += challengeData.Rewards.MasteryXP
totalXpGain += challengeData.Rewards.MasteryXP
calculateXpResult.completedChallenges.push({
ChallengeId: challengeData.Id,
@ -714,9 +715,6 @@ export async function missionEnd(
})
})
//NOTE: Official doesn't seem to make up it's mind whether or not XPGain is the same for both Mastery and Profile...
const totalXpGain = calculateXpResult.xp + masteryXpGain
const completionData = generateCompletionData(
levelData.Metadata.Location,
req.jwt.unique_name,
@ -725,10 +723,17 @@ export async function missionEnd(
)
//Calculate the old location progression based on the current one and process it
const oldLocationXp = completionData.XP - masteryXpGain
const oldLocationXp = completionData.PreviouslySeenXp
? completionData.PreviouslySeenXp
: completionData.XP - totalXpGain
let oldLocationLevel = levelForXp(oldLocationXp)
const newLocationXp = completionData.XP
let newLocationLevel = levelForXp(newLocationXp)
userData.Extensions.progression.Locations[
locationParentId.toLowerCase()
].PreviouslySeenXp = newLocationXp
writeUserData(req.jwt.unique_name, req.gameVersion)
const masteryData =
controller.masteryService.getMasteryPackage(locationParentId)
@ -850,7 +855,7 @@ export async function missionEnd(
locationLevelInfo = EVERGREEN_LEVEL_INFO
//Override the location levels to trigger potential drops
oldLocationLevel = evergreenLevelForXp(completionData.XP - totalXpGain)
oldLocationLevel = evergreenLevelForXp(oldLocationXp)
newLocationLevel = completionData.Level
//Override the silent assassin rank

@ -481,6 +481,7 @@ export interface UserProfile {
[location: string]: {
Xp: number
Level: number
PreviouslySeenXp: number
}
}
}
@ -661,6 +662,7 @@ export interface CompletionData {
Level: number
MaxLevel: number
XP: number
PreviouslySeenXp: number
Completion: number
XpLeft: number
Id: string

@ -22,7 +22,7 @@
"LastScore": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"Locations": {
"location_ica_facility": {
"location_parent_ica_facility": {
"Xp": 0,
"PreviousXp": 0,
"NextLevelXP": 0,
@ -31,7 +31,7 @@
"LevelCompletion": 0,
"Level": 1
},
"location_paris": {
"location_parent_paris": {
"Xp": 0,
"PreviousXp": 0,
"NextLevelXP": 0,
@ -49,7 +49,7 @@
"LevelCompletion": 0,
"Level": 1
},
"location_marrakech": {
"location_parent_marrakech": {
"Xp": 0,
"PreviousXp": 0,
"NextLevelXP": 0,
@ -57,7 +57,7 @@
"PreviouslySeenStaging": null,
"LevelCompletion": 0
},
"location_bangkok": {
"location_parent_bangkok": {
"Xp": 0,
"PreviousXp": 0,
"NextLevelXP": 0,
@ -66,7 +66,7 @@
"LevelCompletion": 0,
"Level": 1
},
"location_colorado": {
"location_parent_colorado": {
"Xp": 0,
"PreviousXp": 0,
"NextLevelXP": 0,
@ -75,7 +75,7 @@
"LevelCompletion": 0,
"Level": 1
},
"location_hokkaido": {
"location_parent_hokkaido": {
"Xp": 0,
"PreviousXp": 0,
"NextLevelXP": 0,

@ -15,14 +15,14 @@
"LastScore": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"Locations": {
"location_ica_facility": {
"location_parent_ica_facility": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_paris": {
"location_parent_paris": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
@ -36,147 +36,161 @@
"PreviouslySeenStaging": null,
"Level": 1
},
"location_marrakech": {
"location_parent_marrakech": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_bangkok": {
"location_parent_bangkok": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_colorado": {
"location_parent_colorado": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_hokkaido": {
"location_parent_hokkaido": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_newzealand": {
"location_parent_newzealand": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_miami": {
"location_parent_miami": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_colombia": {
"location_parent_colombia": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_mumbai": {
"location_parent_mumbai": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_northamerica": {
"location_parent_northamerica": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_northsea": {
"location_parent_northsea": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_greedy": {
"location_parent_greedy": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_opulent": {
"location_parent_opulent": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_austria": {
"location_parent_austria": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_salty": {
"location_parent_salty": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_caged": {
"location_parent_caged": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_golden": {
"location_parent_golden": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_ancestral": {
"location_parent_ancestral": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_edgy": {
"location_parent_edgy": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_wet": {
"location_parent_wet": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_elegant": {
"location_parent_elegant": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_trapped": {
"location_parent_trapped": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_parent_rocky": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",
"PreviouslySeenStaging": null,
"Level": 1
},
"location_parent_snug": {
"Xp": 0,
"PreviouslySeenXp": 0,
"LastCompletedChallenge": "00000000-0000-0000-0000-000000000000",