diff --git a/components/contracts/contractRouting.ts b/components/contracts/contractRouting.ts index 4509ee0e..47bf02cc 100644 --- a/components/contracts/contractRouting.ts +++ b/components/contracts/contractRouting.ts @@ -357,6 +357,9 @@ function getContractOpportunityData( if (contract.Metadata.Opportunities) { for (const ms of contract.Metadata.Opportunities) { + if (!Object.keys(missionStories).includes(ms)) { + continue + } missionStories[ms].PreviouslyCompleted = ms in userData.Extensions.opportunityprogression const current = fastClone(missionStories[ms]) diff --git a/components/contracts/contractsModeRouting.ts b/components/contracts/contractsModeRouting.ts index addcfcdf..bb20eaff 100644 --- a/components/contracts/contractsModeRouting.ts +++ b/components/contracts/contractsModeRouting.ts @@ -23,6 +23,7 @@ import { getUserData } from "../databaseHandler" import { generateUserCentric } from "./dataGen" import { controller } from "../controller" import { createLocationsData } from "../menus/destinations" +import { contractCreationTutorialId } from "../utils" export function contractsModeHome(req: RequestWithJwt, res: Response): void { const contractsHomeTemplate = getConfig("ContractsTemplate", false) @@ -30,7 +31,7 @@ export function contractsModeHome(req: RequestWithJwt, res: Response): void { const userData = getUserData(req.jwt.unique_name, req.gameVersion) const contractCreationTutorial = controller.resolveContract( - "d7e2607c-6916-48e2-9588-976c7d8998bb", + contractCreationTutorialId, ) res.json({ diff --git a/components/menuData.ts b/components/menuData.ts index 22849f1c..3a163edb 100644 --- a/components/menuData.ts +++ b/components/menuData.ts @@ -18,6 +18,7 @@ import { Response, Router } from "express" import { + contractCreationTutorialId, gameDifficulty, PEACOCKVERSTRING, unlockOrderComparer, @@ -187,7 +188,7 @@ menuDataRouter.get("/Hub", (req: RequestWithJwt, res) => { } const contractCreationTutorial = controller.resolveContract( - "d7e2607c-6916-48e2-9588-976c7d8998bb", + contractCreationTutorialId, )! const locations = getVersionedConfig( @@ -1477,7 +1478,7 @@ preMenuDataRouter.get( menuDataRouter.get("/contractsearchpage", (req: RequestWithJwt, res) => { const createContractTutorial = controller.resolveContract( - "d7e2607c-6916-48e2-9588-976c7d8998bb", + contractCreationTutorialId, ) res.json({ @@ -1641,7 +1642,8 @@ menuDataRouter.get("/contractcreation/create", (req: RequestWithJwt, res) => { } }), ContractConditions: complications(timeLimitStr), - PublishingDisabled: false, + PublishingDisabled: + sesh.contractId === contractCreationTutorialId, Creator: req.jwt.unique_name, ContractId: cUuid, ContractPublicId: joined, diff --git a/components/menus/destinations.ts b/components/menus/destinations.ts index 6c2af854..5903ccba 100644 --- a/components/menus/destinations.ts +++ b/components/menus/destinations.ts @@ -65,7 +65,10 @@ export function getDestinationCompletion( let opportunityCompletedCount = 0 for (const ms in userData.Extensions.opportunityprogression) { - if (missionStories[ms].Location === parent.Id) { + if ( + Object.keys(missionStories).includes(ms) && + missionStories[ms].Location === parent.Id + ) { opportunityCompletedCount++ } } diff --git a/components/menus/planning.ts b/components/menus/planning.ts index c64027d9..e57ed46a 100644 --- a/components/menus/planning.ts +++ b/components/menus/planning.ts @@ -62,7 +62,9 @@ export async function planningView( const isForReset = req.query.resetescalation === "true" for (const ms in userData.Extensions.opportunityprogression) { - missionStories[ms].PreviouslyCompleted = true + if (Object.keys(missionStories).includes(ms)) { + missionStories[ms].PreviouslyCompleted = true + } } if (isForReset) { diff --git a/components/utils.ts b/components/utils.ts index 01342e40..d17edceb 100644 --- a/components/utils.ts +++ b/components/utils.ts @@ -51,6 +51,8 @@ export const uuidRegex = export const contractTypes = ["featured", "usercreated", "creation"] +export const contractCreationTutorialId = "d7e2607c-6916-48e2-9588-976c7d8998bb" + export async function checkForUpdates(): Promise { if (getFlag("updateChecking") === false) { return