1
mirror of https://github.com/thepeacockproject/Peacock synced 2025-02-23 03:35:25 +01:00

Fix a number of bugs on progression, entitlements, and warning logs ()

* Fix "Contract undefined not found!" warnings

* Implement support for /GetContractOpportunities

* Add OpportunityData to MissionManifestMetadata

* Resolved a ts-expect-error by providing types

* Fix requiem unlockables pistol

* Adjust max player level
This commit is contained in:
moonysolari 2023-01-10 17:29:54 -05:00 committed by GitHub
parent e548325955
commit 3adb4b1f67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 76 additions and 11 deletions

@ -17,7 +17,7 @@
*/
import { Router } from "express"
import { nilUuid, ServerVer, uuidRegex } from "../utils"
import { fastClone, nilUuid, ServerVer, uuidRegex } from "../utils"
import { json as jsonMiddleware } from "body-parser"
import {
enqueueEvent,
@ -32,6 +32,7 @@ import type {
GameChanger,
MissionManifest,
MissionManifestObjective,
MissionStory,
RequestWithJwt,
} from "../types/types"
import {
@ -47,6 +48,7 @@ import {
import { createSniperLoadouts } from "../menus/sniper"
import { GetForPlay2Body } from "../types/gameSchemas"
import assert from "assert"
import { getUserData } from "components/databaseHandler"
const contractRoutingRouter = Router()
@ -77,7 +79,6 @@ contractRoutingRouter.post(
}
// Add escalation data to Contract data HERE
// @ts-expect-error TypeScript going crazy
contractData.Metadata = {
...contractData.Metadata,
...(await getPlayEscalationInfo(
@ -87,6 +88,9 @@ contractRoutingRouter.post(
req.gameVersion,
)),
...loadoutData,
...{
OpportunityData: getContractOpportunityData(req, contractData),
},
}
const contractSesh = {
@ -305,4 +309,35 @@ contractRoutingRouter.post(
},
)
contractRoutingRouter.post(
"/GetContractOpportunities",
jsonMiddleware(),
(req: RequestWithJwt<never, { contractId: string }>, res) => {
const contract = controller.resolveContract(req.body.contractId)
res.json(getContractOpportunityData(req, contract))
},
)
function getContractOpportunityData(
req: RequestWithJwt,
contract: MissionManifest,
): MissionStory[] {
const userData = getUserData(req.jwt.unique_name, req.gameVersion)
const result = []
const missionStories = getConfig<Record<string, MissionStory>>(
"MissionStories",
false,
)
for (const ms of contract.Metadata.Opportunities) {
missionStories[ms].PreviouslyCompleted =
ms in userData.Extensions.opportunityprogression
const current = fastClone(missionStories[ms])
delete current.Location
result.push(current)
}
return result
}
export { contractRoutingRouter }

@ -51,7 +51,7 @@ export function contractsModeHome(req: RequestWithJwt, res: Response): void {
XP: userData.Extensions.progression.PlayerProfileXP.Total,
Level: userData.Extensions.progression.PlayerProfileXP
.ProfileLevel,
MaxLevel: 5000,
MaxLevel: 7500,
},
},
})

@ -17,7 +17,12 @@
*/
import { contractIdToHitObject, controller } from "../../controller"
import type { GameVersion, IHit, UserProfile } from "../../types/types"
import type {
EscalationInfo,
GameVersion,
IHit,
UserProfile,
} from "../../types/types"
import { getUserData } from "../../databaseHandler"
import { log, LogLevel } from "../../loggingInterop"
import type { EscalationGroup } from "../escalationMappings"
@ -152,7 +157,7 @@ export function getPlayEscalationInfo(
userId: string,
eGroupId: string,
gameVersion: GameVersion,
) {
): EscalationInfo {
if (!b) {
return {}
}

@ -619,6 +619,9 @@ export class Controller {
* @returns The mission manifest object, or undefined if it wasn't found.
*/
public resolveContract(id: string): MissionManifest | undefined {
if (!id) {
return undefined
}
const optionalPluginJson = this.hooks.getContractManifest.call(id)
if (optionalPluginJson) {

@ -209,7 +209,7 @@ menuDataRouter.get("/Hub", (req: RequestWithJwt, res) => {
XP: userdata.Extensions.progression.PlayerProfileXP.Total,
Level: userdata.Extensions.progression.PlayerProfileXP
.ProfileLevel,
MaxLevel: 5000,
MaxLevel: 7500,
},
},
})
@ -1634,7 +1634,7 @@ menuDataRouter.get("/GetPlayerProfileXpData", (req: RequestWithJwt, res) => {
XP: userData.Extensions.progression.PlayerProfileXP.Total,
Level: userData.Extensions.progression.PlayerProfileXP
.ProfileLevel,
MaxLevel: 5000,
MaxLevel: 7500,
},
},
})

@ -443,7 +443,7 @@ export async function planningView(
XP: userData.Extensions.progression.PlayerProfileXP.Total,
Level: userData.Extensions.progression.PlayerProfileXP
.ProfileLevel,
MaxLevel: 5000,
MaxLevel: 7500,
},
},
})

@ -31,7 +31,7 @@ export const H1_GOTY_UNLOCKABLES = [
export const H1_REQUIEM_UNLOCKABLES = [
"TOKEN_OUTFIT_LEGACY_HERO_REQUIEMSUIT",
"PROP_DEVICE_SONYPREORDER_WHITE_RUBBERDUCK_REMOTE_EXPLOSIVE",
"FIREARMS_PISTOL_CLASSIC_SILVERBALLER",
"FIREARMS_HERO_PISTOL_TACTICAL_015_SU_SKIN05",
]
export const H2_RACCOON_STINGRAY_UNLOCKABLES = [

@ -589,7 +589,7 @@ profileRouter.post(
PlayerProfile: {
Version: 1,
XpPerLevel: 6000,
MaxLevel: 5000,
MaxLevel: 7500,
},
},
})

@ -714,6 +714,18 @@ export type ContractGroupDefinition = {
Order: string[]
}
export interface EscalationInfo {
Type?: MissionType
InGroup?: string
NextContractId?: string
GroupData?: {
Level: number
TotalLevels: number
Completed: boolean
FirstContractId: string
}
}
export interface MissionManifestMetadata {
Id: string
Location: string
@ -742,6 +754,7 @@ export interface MissionManifestMetadata {
RequiredUnlockable?: string
Drops?: string[]
Opportunities?: string[]
OpportunityData?: MissionStory[]
Entitlements: string[]
LastUpdate?: string
PublicId?: string
@ -767,7 +780,6 @@ export interface MissionManifestMetadata {
EndConditions?: {
PointLimit?: number
}
InGroup?: string
Subtype?: string
GroupTitle?: string
TargetExpiration?: number
@ -776,6 +788,16 @@ export interface MissionManifestMetadata {
NonTargetKillPenaltyEnabled?: boolean
NoticedTargetStreakPenaltyMax?: number
IsFeatured?: boolean
// Begin escalation-exclusive properties
InGroup?: string
NextContractId?: string
GroupData?: {
Level: number
TotalLevels: number
Completed: boolean
FirstContractId: string
}
// End escalation-exclusive properties
/**
* Useless property.
*