add MysteryEncounterBuilder.withScenePartySizeRequirement

This commit is contained in:
Felix Staud 2024-07-09 22:28:36 -07:00 committed by ImperialSympathizer
parent 25d0bd39ee
commit adf52bf604
2 changed files with 13 additions and 2 deletions

View File

@ -9,7 +9,6 @@ import { PokeballType } from "../../pokeball";
import { getPokemonSpecies } from "../../pokemon-species"; import { getPokemonSpecies } from "../../pokemon-species";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter"; import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option"; import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { PartySizeRequirement } from "../mystery-encounter-requirements";
import { import {
EnemyPartyConfig, EnemyPokemonConfig, EnemyPartyConfig, EnemyPokemonConfig,
getRandomPlayerPokemon, getRandomPlayerPokemon,
@ -84,7 +83,7 @@ export const DarkDealEncounter: MysteryEncounter = MysteryEncounterBuilder
} }
]) ])
.withSceneWaveRangeRequirement(30, 180) // waves 30 to 180 .withSceneWaveRangeRequirement(30, 180) // waves 30 to 180
.withSceneRequirement(new PartySizeRequirement([2, 6])) // Must have at least 2 pokemon in party .withScenePartySizeRequirement(2, 6) // Must have at least 2 pokemon in party
.withCatchAllowed(true) .withCatchAllowed(true)
.withOption(new MysteryEncounterOptionBuilder() .withOption(new MysteryEncounterOptionBuilder()
.withPreOptionPhase(async (scene: BattleScene) => { .withPreOptionPhase(async (scene: BattleScene) => {

View File

@ -8,6 +8,7 @@ import MysteryEncounterOption from "./mystery-encounter-option";
import { import {
EncounterPokemonRequirement, EncounterPokemonRequirement,
EncounterSceneRequirement, EncounterSceneRequirement,
PartySizeRequirement,
WaveRangeRequirement WaveRangeRequirement
} from "./mystery-encounter-requirements"; } from "./mystery-encounter-requirements";
import * as Utils from "../../utils"; import * as Utils from "../../utils";
@ -442,6 +443,17 @@ export class MysteryEncounterBuilder implements Partial<MysteryEncounter> {
return this.withSceneRequirement(new WaveRangeRequirement([min, max ?? min])); return this.withSceneRequirement(new WaveRangeRequirement([min, max ?? min]));
} }
/**
* Specifies a party size requirement for an encounter.
*
* @param min min wave (or exact size if only min is given)
* @param max optional max size. If not given, defaults to min => exact wave
* @returns
*/
withScenePartySizeRequirement(min: number, max?: number) {
return this.withSceneRequirement(new PartySizeRequirement([min, max ?? min]));
}
withPrimaryPokemonRequirement(requirement: EncounterPokemonRequirement): this & Required<Pick<MysteryEncounter, "primaryPokemonRequirements">> { withPrimaryPokemonRequirement(requirement: EncounterPokemonRequirement): this & Required<Pick<MysteryEncounter, "primaryPokemonRequirements">> {
this.primaryPokemonRequirements.push(requirement); this.primaryPokemonRequirements.push(requirement);
return Object.assign(this, { primaryPokemonRequirements: this.primaryPokemonRequirements }); return Object.assign(this, { primaryPokemonRequirements: this.primaryPokemonRequirements });