Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable strict types mode #362

Merged
merged 25 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions components/candle/challengeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import {
ChallengeProgressionData,
CompiledChallengeRewardData,
CompiledChallengeRuntimeData,
InclusionData,
MissionManifest,
Expand All @@ -28,19 +27,6 @@ import { SavedChallengeGroup } from "../types/challenges"
import { controller } from "../controller"
import { gameDifficulty, isSniperLocation } from "../utils"

// TODO: unused?
export function compileScoringChallenge(
challenge: RegistryChallenge,
): CompiledChallengeRewardData {
return {
ChallengeId: challenge.Id,
ChallengeName: challenge.Name,
ChallengeDescription: challenge.Description,
ChallengeImageUrl: challenge.ImageName,
XPGain: challenge.Rewards?.MasteryXP || 0,
}
}

export function compileRuntimeChallenge(
challenge: RegistryChallenge,
progression: ChallengeProgressionData,
Expand Down Expand Up @@ -106,8 +92,8 @@ export type ChallengeFilterOptions =
* @returns A boolean as the result.
*/
export function inclusionDataCheck(
incData: InclusionData,
contract: MissionManifest,
incData: InclusionData | undefined,
contract: MissionManifest | undefined,
): boolean {
if (!incData) return true
if (!contract) return false
Expand Down Expand Up @@ -174,24 +160,24 @@ function isChallengeInContract(
: {
...challenge.InclusionData,
ContractTypes:
challenge.InclusionData.ContractTypes.filter(
challenge.InclusionData?.ContractTypes?.filter(
(type) => type !== "tutorial",
),
) || [],
Comment on lines -177 to +165
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible behavior change

},
contract,
)
}

// Is this for the current contract or group contract?
const isForContract = (challenge.InclusionData?.ContractIds || []).includes(
contract.Metadata.Id,
contract?.Metadata.Id || "",
)

// Is this for the current contract type?
// As of v6.1.0, this is only used for ET challenges.
const isForContractType = (
challenge.InclusionData?.ContractTypes || []
).includes(controller.resolveContract(contractId).Metadata.Type)
).includes(controller.resolveContract(contractId)!.Metadata.Type)

// Is this a location-wide challenge?
// "location" is more widely used, but "parentlocation" is used in Ambrose and Berlin, as well as some "Discover XX" challenges.
Expand Down Expand Up @@ -287,7 +273,7 @@ export function filterChallenge(
*/
export function mergeSavedChallengeGroups(
g1: SavedChallengeGroup,
g2: SavedChallengeGroup,
g2?: SavedChallengeGroup,
): SavedChallengeGroup {
return {
...g1,
Expand Down
Loading
Loading