1
mirror of https://github.com/thepeacockproject/Peacock synced 2024-11-22 22:12:45 +01:00

Add recommended mission stories (#138)

This commit is contained in:
moonysolari 2023-03-06 12:12:52 -05:00 committed by GitHub
parent db4fa8d7b7
commit e5417e10d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 1 deletions

View File

@ -66,6 +66,7 @@ import { contractsModeHome } from "./contracts/contractsModeRouting"
import random from "random" import random from "random"
import { getUserData } from "./databaseHandler" import { getUserData } from "./databaseHandler"
import { import {
createMainOpportunityTile,
createPlayNextTile, createPlayNextTile,
getSeasonId, getSeasonId,
orderedMissions, orderedMissions,
@ -1274,6 +1275,8 @@ menuDataRouter.get(
), ),
) )
} }
cats.push(createMainOpportunityTile(req.query.contractId))
} }
//#endregion //#endregion

View File

@ -16,9 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { getConfig } from "../configSwizzleManager"
import { generateUserCentric } from "../contracts/dataGen" import { generateUserCentric } from "../contracts/dataGen"
import { controller } from "../controller" import { controller } from "../controller"
import type { GameVersion, PlayNextCampaignDetails } from "../types/types" import type {
GameVersion,
MissionStory,
PlayNextCampaignDetails,
} from "../types/types"
export const orderedMissions: string[] = [ export const orderedMissions: string[] = [
"00000000-0000-0000-0000-000000000200", "00000000-0000-0000-0000-000000000200",
@ -105,3 +110,34 @@ export function createPlayNextTile(
], ],
} }
} }
/**
* Generates tiles for recommended mission stories given a contract ID.
*
* @param contractId The contract ID.
* @returns The tile object.
*/
export function createMainOpportunityTile(contractId: string) {
const contractData = controller.resolveContract(contractId)
const missionStories = getConfig<Record<string, MissionStory>>(
"MissionStories",
false,
)
return {
CategoryType: "MainOpportunity",
CategoryName: "UI_PLAYNEXT_MAINOPPORTUNITY_CATEGORY_NAME",
Items: (contractData.Metadata.Opportunities || [])
.filter((value) => missionStories[value].IsMainOpportunity)
.map((value) => ({
ItemType: null,
ContentType: "Opportunity",
Content: {
RepositoryId: value,
ContractId: contractId,
},
CategoryType: "MainOpportunity",
})),
}
}