Skip to content

Commit

Permalink
Fix challenges for H2 and H2016 (thepeacockproject#152)
Browse files Browse the repository at this point in the history
* Add location templates for older game versions

* Fix challenge data extraction script for h1

* Add challenge location templates

* unfinished game version support

* Fix challenge data extraction script for H2

* Conform function calls to new signature

* Add a game version for all maps

* Improve comments

* Try to add difficulty support

* fix type error

* fix GetActiveChallengesAndProgression difficulty

* Add difficulty for GetChallengeTreeFor

* Fix up difficulty in other places

* Add challenges data jsons for all three games

* Add H2 global TC challenges

* Fix H1 challenge typeheader

* Fix Type fields in SavedChallenge

* Fix imports

* Delete backup file

* Reduce hard-coding of difficulty number

* Support versioned global challenges

* remove H2GlobalChallenges

* Add missing global Challenges

* Make versions a global variable

* run prettier

* Use Drop Ids instead of unlockables

---------

Co-authored-by: Reece Dunham <[email protected]>
  • Loading branch information
moonysolari and RDIL authored Apr 5, 2023
1 parent 235072b commit 5fff1c8
Show file tree
Hide file tree
Showing 70 changed files with 199,666 additions and 3,413 deletions.
21 changes: 21 additions & 0 deletions components/candle/challengeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import assert from "assert"
import { SavedChallengeGroup } from "../types/challenges"
import { controller } from "../controller"
import { gameDifficulty } from "../utils"

export function compileScoringChallenge(
challenge: RegistryChallenge,
Expand Down Expand Up @@ -82,6 +83,7 @@ export type ChallengeFilterOptions =
type: ChallengeFilterType.Contract
contractId: string
locationId: string
difficulty: number
}
| {
type: ChallengeFilterType.Contracts
Expand Down Expand Up @@ -111,18 +113,31 @@ export function inclusionDataCheck(
)
}

export function isChallengeForDifficulty(
difficulty: number,
challenge: RegistryChallenge,
): boolean {
return (
!challenge.DifficultyLevels ||
challenge.DifficultyLevels.length === 0 ||
gameDifficulty[challenge.DifficultyLevels[0]] <= difficulty
)
}

/**
* Judges whether a challenge should be included in the challenges list of a contract.
* @requires The challenge and the contract share the same parent location.
* @param contractId The id of the contract.
* @param locationId The sublocation ID of the challenge.
* @param difficulty The upper bound on the difficulty of the challenges to return.
* @param challenge The challenge in question.
* @param forCareer Whether the result is used to decide what is shown the CAREER -> CHALLENGES page. Defaulted to false.
* @returns A boolean value, denoting the result.
*/
function isChallengeInContract(
contractId: string,
locationId: string,
difficulty: number,
challenge: RegistryChallenge,
forCareer = false,
): boolean {
Expand All @@ -132,6 +147,10 @@ function isChallengeInContract(
return false
}

if (!isChallengeForDifficulty(difficulty, challenge)) {
return false
}

if (
locationId === "LOCATION_HOKKAIDO_SHIM_MAMUSHI" &&
challenge.LocationId === "LOCATION_HOKKAIDO"
Expand Down Expand Up @@ -190,6 +209,7 @@ export function filterChallenge(
return isChallengeInContract(
options.contractId,
options.locationId,
options.difficulty,
challenge,
)
}
Expand All @@ -198,6 +218,7 @@ export function filterChallenge(
isChallengeInContract(
contractId,
options.locationId,
gameDifficulty.master, // Get challenges of all difficulties
challenge,
true,
),
Expand Down
Loading

0 comments on commit 5fff1c8

Please sign in to comment.