Skip to content

Commit 579a21e

Browse files
committed
fix: H2016 pro mode using 6000 XP per level
Fixes #686
1 parent 59ca865 commit 579a21e

10 files changed

Lines changed: 40 additions & 13 deletions

File tree

components/candle/masteryService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ export class MasteryService {
299299
? xpRequiredForEvergreenLevel
300300
: xpRequiredForLevel,
301301
subPackageId,
302-
masteryPkg.XpPerLevel,
302+
subPackage?.XpPerLevel ?? masteryPkg.XpPerLevel,
303303
),
304304
Id: isSniper ? subPackageId! : masteryPkg.LocationId,
305305
SubLocationId: isSniper ? "" : subLocationId,

components/candle/progressionService.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,29 @@ export class ProgressionService {
185185
parentLocationId,
186186
contractSession.gameVersion,
187187
)
188+
const subPackageId =
189+
contractSession.gameVersion === "h1"
190+
? (contract.Metadata.Difficulty ?? "normal")
191+
: (sniperUnlockable ?? undefined)
188192
const locationData = this.getMasteryProgressionForLocation(
189193
userProfile,
190194
parentLocationId,
191-
contractSession.gameVersion === "h1"
192-
? (contract.Metadata.Difficulty ?? "normal")
193-
: (sniperUnlockable ?? undefined),
195+
subPackageId,
194196
)
195197

196-
const maxLevel = masteryData?.MaxLevel || DEFAULT_MASTERY_MAXLEVEL
198+
// subpackages (e.g. H2016 professional mode) may override the max
199+
// level and the amount of XP required per level.
200+
const subPackage = subPackageId
201+
? masteryData?.SubPackages?.find(
202+
(pkg) => pkg.Id === subPackageId,
203+
)
204+
: undefined
205+
206+
const maxLevel =
207+
subPackage?.MaxLevel ||
208+
masteryData?.MaxLevel ||
209+
DEFAULT_MASTERY_MAXLEVEL
210+
const xpPerLevel = subPackage?.XpPerLevel ?? masteryData?.XpPerLevel
197211
const isEvergreenContract = contract.Metadata.Type === "evergreen"
198212

199213
if (masteryData) {
@@ -207,18 +221,15 @@ export class ProgressionService {
207221
? xpRequiredForEvergreenLevel(maxLevel)
208222
: sniperUnlockable
209223
? xpRequiredForSniperLevel(maxLevel)
210-
: xpRequiredForLevel(
211-
maxLevel,
212-
masteryData.XpPerLevel,
213-
),
224+
: xpRequiredForLevel(maxLevel, xpPerLevel),
214225
)
215226

216227
locationData.Level = clampValue(
217228
isEvergreenContract
218229
? evergreenLevelForXp(locationData.Xp)
219230
: sniperUnlockable
220231
? sniperLevelForXp(locationData.Xp)
221-
: levelForXp(locationData.Xp, masteryData.XpPerLevel),
232+
: levelForXp(locationData.Xp, xpPerLevel),
222233
1,
223234
maxLevel,
224235
)

components/scoreHandler.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,14 +859,23 @@ export async function getMissionEndData(
859859
gameVersion,
860860
)
861861

862+
// some locations (e.g. H2016 professional mode) use a different amount of
863+
// XP per level per subpackage, so prefer the subpackage value when present.
864+
const masteryXpPerLevel =
865+
(query.masteryUnlockableId
866+
? masteryData?.SubPackages?.find(
867+
(subPkg) => subPkg.Id === query.masteryUnlockableId,
868+
)?.XpPerLevel
869+
: undefined) ?? masteryData?.XpPerLevel
870+
862871
// Calculate the old location progression based on the current one and process it
863872
const oldLocationXp = completionData.PreviouslySeenXp
864873
? completionData.PreviouslySeenXp
865874
: completionData.XP - totalXpGain
866-
let oldLocationLevel = levelForXp(oldLocationXp, masteryData?.XpPerLevel)
875+
let oldLocationLevel = levelForXp(oldLocationXp, masteryXpPerLevel)
867876

868877
const newLocationXp = completionData.XP
869-
let newLocationLevel = levelForXp(newLocationXp, masteryData?.XpPerLevel)
878+
let newLocationLevel = levelForXp(newLocationXp, masteryXpPerLevel)
870879
const userProgressionLocations = userData.Extensions.progression.Locations
871880

872881
if (!query.masteryUnlockableId) {
@@ -893,7 +902,7 @@ export async function getMissionEndData(
893902
: masteryData.MaxLevel) || DEFAULT_MASTERY_MAXLEVEL
894903

895904
locationLevelInfo = Array.from({ length: maxLevel }, (_, i) => {
896-
return xpRequiredForLevel(i + 1, masteryData.XpPerLevel)
905+
return xpRequiredForLevel(i + 1, masteryXpPerLevel)
897906
})
898907
}
899908

components/types/mastery.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type MasteryPackageDrop = {
3131
export type MasterySubPackage = {
3232
Id: string
3333
MaxLevel?: number
34+
XpPerLevel?: number
3435
Drops: MasteryPackageDrop[]
3536
}
3637

contractdata/BANGKOK/_LEGACY_BANGKOK_MASTERY.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
{
9999
"Id": "pro1",
100100
"MaxLevel": 10,
101+
"XpPerLevel": 10000,
101102
"Drops": [
102103
{
103104
"Id": "PRO1_STARTING_LOCATION_BANGKOK_SECURITY_HUT",

contractdata/COLORADO/_LEGACY_COLORADO_MASTERY.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
{
9999
"Id": "pro1",
100100
"MaxLevel": 10,
101+
"XpPerLevel": 10000,
101102
"Drops": [
102103
{
103104
"Id": "PRO1_AGENCYPICKUP_COLORADO_WATERTOWER",

contractdata/HOKKAIDO/_LEGACY_HOKKAIDO_MASTERY.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
{
103103
"Id": "pro1",
104104
"MaxLevel": 10,
105+
"XpPerLevel": 10000,
105106
"Drops": [
106107
{
107108
"Id": "PRO1_AGENCYPICKUP_HOKKAIDO_SNOWCRANE_SLEEPINGQUARTERS",

contractdata/MARRAKESH/_LEGACY_MARRAKESH_MASTERY.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
{
9999
"Id": "pro1",
100100
"MaxLevel": 10,
101+
"XpPerLevel": 10000,
101102
"Drops": [
102103
{
103104
"Id": "PRO1_AGENCYPICKUP_MARRAKESH_SPIDER_CONSULATE_BASEMENT",

contractdata/PARIS/_LEGACY_PARIS_MASTERY.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
{
9595
"Id": "pro1",
9696
"MaxLevel": 10,
97+
"XpPerLevel": 10000,
9798
"Drops": [
9899
{
99100
"Id": "PRO1_STARTING_LOCATION_PARIS_PEACOCK_BASEMENT_KITCHEN",

contractdata/SAPIENZA/_LEGACY_SAPIENZA_MASTERY.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
{
9999
"Id": "pro1",
100100
"MaxLevel": 10,
101+
"XpPerLevel": 10000,
101102
"Drops": [
102103
{
103104
"Id": "PRO1_STARTING_LOCATION_SAPIENZA_APARTMENT",

0 commit comments

Comments
 (0)