Add OrderIndex to challenge groups and removeChallenge function
This commit is contained in:
parent
02e2f9e9ad
commit
9600085087
|
@ -192,6 +192,10 @@ export abstract class ChallengeRegistry {
|
|||
return this.challenges[gameVersion].get(challengeId)
|
||||
}
|
||||
|
||||
removeChallenge(challengeId: string, gameVersion: GameVersion): boolean {
|
||||
return this.challenges[gameVersion].delete(challengeId)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves all the unlockables associated with the challenges for a given game version.
|
||||
* It iterates over all the challenges for the specified game version and for each challenge, it checks if there are any unlockables (Drops).
|
||||
|
@ -1170,7 +1174,7 @@ export class ChallengeService extends ChallengeRegistry {
|
|||
gameVersion,
|
||||
)
|
||||
|
||||
return entries
|
||||
const groups = entries
|
||||
.map(([groupId, challenges], index) => {
|
||||
const groupData = this.getGroupByIdLoc(
|
||||
groupId,
|
||||
|
@ -1217,6 +1221,7 @@ export class ChallengeService extends ChallengeRegistry {
|
|||
IsLocked: location.Properties.IsLocked || false,
|
||||
ImageLocked: location.Properties.LockedIcon || "",
|
||||
RequiredResources: location.Properties.RequiredResources!,
|
||||
OrderIndex: groupData.OrderIndex ?? 10000,
|
||||
SwitchData: {
|
||||
Data: {
|
||||
Challenges: this.mapSwitchChallenges(
|
||||
|
@ -1253,6 +1258,10 @@ export class ChallengeService extends ChallengeRegistry {
|
|||
}
|
||||
})
|
||||
.filter(Boolean) as CompiledChallengeTreeCategory[]
|
||||
|
||||
return groups.sort((a, b) => {
|
||||
return a.OrderIndex - b.OrderIndex
|
||||
})
|
||||
}
|
||||
|
||||
compileRegistryChallengeTreeData(
|
||||
|
|
|
@ -68,6 +68,7 @@ export interface SavedChallengeGroup {
|
|||
Icon: string
|
||||
CategoryId: string
|
||||
Description: string
|
||||
OrderIndex?: number
|
||||
Challenges: SavedChallenge[]
|
||||
}
|
||||
|
||||
|
|
|
@ -1182,6 +1182,7 @@ export interface CompiledChallengeTreeCategory {
|
|||
Location: Unlockable
|
||||
Name: string
|
||||
RequiredResources: string[]
|
||||
OrderIndex: number
|
||||
SwitchData: {
|
||||
Data: {
|
||||
CategoryData: CompiledChallengeTreeCategoryInfo
|
||||
|
|
|
@ -58,6 +58,41 @@ async function fetchDestination(axiosClient, locationId) {
|
|||
return resp.data
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} categoryId
|
||||
* @returns {number}
|
||||
*/
|
||||
function getOrderIndex(categoryId) {
|
||||
switch (categoryId) {
|
||||
case "assassination":
|
||||
return 0
|
||||
case "discovery":
|
||||
return 1
|
||||
case "feats":
|
||||
return 2
|
||||
case "targets":
|
||||
return 3
|
||||
case "classic":
|
||||
return 4
|
||||
case "elusive":
|
||||
return 5
|
||||
case "arcade":
|
||||
return 6
|
||||
case "escalation_hm1":
|
||||
return 7
|
||||
case "escalation_hm2":
|
||||
return 8
|
||||
case "featured_hm1_hm2":
|
||||
return 9
|
||||
case "featured_hm3":
|
||||
return 10
|
||||
case "featured":
|
||||
return 11
|
||||
default:
|
||||
return 100000
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} locationParent
|
||||
* @param {string} jwt
|
||||
|
@ -146,6 +181,7 @@ async function extract(locationParent, jwt, gameVersion) {
|
|||
Icon: group.Icon,
|
||||
CategoryId: group.CategoryId,
|
||||
Description: group.Description,
|
||||
OrderIndex: getOrderIndex(group.CategoryId),
|
||||
Challenges: challengeObjects,
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue