Skip to content

Commit

Permalink
refactor: Clean up mapObjectives slightly; remove hacky safehouse fix
Browse files Browse the repository at this point in the history
The old fix is no longer needed as of the previous commit
  • Loading branch information
grappigegovert committed Jan 4, 2025
1 parent 7ddc746 commit fa7641e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
19 changes: 4 additions & 15 deletions components/contracts/dataGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ export function mapObjectives(
objectives: MissionManifestObjective[],
gameChangers: string[],
displayOrder: GroupObjectiveDisplayOrderItem[],
isEvergreenSafehouse = false,
): MissionManifestObjective[] {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result = new Map<string, any>()
Expand All @@ -317,13 +316,11 @@ export function mapObjectives(
}

for (const gamechangerId of gameChangers) {
if (isEvergreenSafehouse) break
const gameChangerProps = gameChangerData[gamechangerId]

if (gameChangerProps && !gameChangerProps.ShowBasedOnObjectives) {
if (gameChangerProps.IsHidden) {
if (gameChangerProps.Objectives?.length === 1) {
// Either 0 or 1 I think.
const objective = gameChangerProps.Objectives[0]!
objective.Id = gamechangerId
gameChangerObjectives.push(objective)
Expand Down Expand Up @@ -363,13 +360,11 @@ export function mapObjectives(
}
}

for (const objective of (objectives || []).concat(gameChangerObjectives)) {
for (const objective of objectives.concat(gameChangerObjectives)) {
if (
objective.Activation ||
(objective.OnActive?.IfInProgress &&
objective.OnActive.IfInProgress.Visible === false) ||
(objective.OnActive?.IfCompleted &&
objective.OnActive.IfCompleted.Visible === false &&
objective.OnActive?.IfInProgress?.Visible === false ||
(objective.OnActive?.IfCompleted?.Visible === false &&
// @ts-expect-error State machines are impossible to type
objective.Definition?.States?.Start?.["-"]?.Transition ===
"Success")
Expand Down Expand Up @@ -485,7 +480,7 @@ export function mapObjectives(
const sortedResult: MissionManifestObjective[] = []
const resultIds: Set<string> = new Set()

for (const { Id, IsNew } of displayOrder || []) {
for (const { Id, IsNew } of displayOrder) {
if (!resultIds.has(Id)) {
// if not yet added
const objective = result.get(Id)
Expand All @@ -501,12 +496,6 @@ export function mapObjectives(
}
}

// This is something to get the main objective to show on the planning menu - AF
if (isEvergreenSafehouse) {
sortedResult.push(result.get("f9cfcf80-9977-4ad1-b3c7-0228a2026b9c"))
resultIds.add("f9cfcf80-9977-4ad1-b3c7-0228a2026b9c")
}

// add each objective or gamechanger that is not already in the result
for (const Id of objectives.map((obj) => obj.Id).concat(gameChangers)) {
if (!resultIds.has(Id)) {
Expand Down
1 change: 0 additions & 1 deletion components/menus/planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ export async function getPlanningData(
contractData.Data.Objectives!,
contractData.Data.GameChangers || [],
contractData.Metadata.GroupObjectiveDisplayOrder || [],
Boolean(contractData.Metadata.IsEvergreenSafehouse),
),
GroupData: groupData,
Entrances:
Expand Down

0 comments on commit fa7641e

Please sign in to comment.