add MysteryEncounterBuilder.withSceneWaveRangeRequirement()

This commit is contained in:
Felix Staud 2024-07-09 22:27:13 -07:00 committed by ImperialSympathizer
parent 5a5806185f
commit 25d0bd39ee
10 changed files with 96 additions and 89 deletions

View File

@ -1,5 +1,15 @@
import { Type } from "#app/data/type";
import { ModifierRewardPhase } from "#app/phases";
import { isNullOrUndefined, randSeedInt } from "#app/utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import BattleScene from "../../../battle-scene";
import { AddPokeballModifierType } from "../../../modifier/modifier-type";
import { PokeballType } from "../../pokeball";
import { getPokemonSpecies } from "../../pokemon-species";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { PartySizeRequirement } from "../mystery-encounter-requirements";
import {
EnemyPartyConfig, EnemyPokemonConfig,
getRandomPlayerPokemon,
@ -7,16 +17,6 @@ import {
initBattleWithEnemyConfig,
leaveEncounterWithoutBattle
} from "../mystery-encounter-utils";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { ModifierRewardPhase } from "#app/phases";
import { getPokemonSpecies } from "../../pokemon-species";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { PokeballType } from "../../pokeball";
import { PartySizeRequirement, WaveCountRequirement } from "../mystery-encounter-requirements";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { Type } from "#app/data/type";
import { Species } from "#enums/species";
import { isNullOrUndefined, randSeedInt } from "#app/utils";
// Exclude Ultra Beasts, Paradox, Necrozma, Eternatus, and egg-locked mythicals
const excludedBosses = [
@ -83,7 +83,7 @@ export const DarkDealEncounter: MysteryEncounter = MysteryEncounterBuilder
repeat: true
}
])
.withSceneRequirement(new WaveCountRequirement([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
.withCatchAllowed(true)
.withOption(new MysteryEncounterOptionBuilder()

View File

@ -1,15 +1,14 @@
import BattleScene from "../../../battle-scene";
import {
leaveEncounterWithoutBattle, setEncounterExp,
setEncounterRewards,
} from "#app/data/mystery-encounters/mystery-encounter-utils";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { WaveCountRequirement } from "../mystery-encounter-requirements";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { modifierTypes } from "#app/modifier/modifier-type";
import { Species } from "#enums/species";
import { randSeedInt } from "#app/utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import BattleScene from "../../../battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
export const DepartmentStoreSaleEncounter: MysteryEncounter = MysteryEncounterBuilder
.withEncounterType(MysteryEncounterType.DEPARTMENT_STORE_SALE)
@ -30,7 +29,7 @@ export const DepartmentStoreSaleEncounter: MysteryEncounter = MysteryEncounterBu
}
])
// .withHideIntroVisuals(false)
.withSceneRequirement(new WaveCountRequirement([10, 100]))
.withSceneWaveRangeRequirement(10, 100)
.withOption(new MysteryEncounterOptionBuilder()
.withOptionPhase(async (scene: BattleScene) => {
// Choose TMs

View File

@ -1,5 +1,4 @@
import BattleScene from "../../../battle-scene";
import { ModifierTier } from "#app/modifier/modifier-tier";
import { BattleStat } from "#app/data/battle-stat";
import {
EnemyPartyConfig,
initBattleWithEnemyConfig,
@ -7,10 +6,8 @@ import {
setEncounterRewards,
showEncounterText
} from "#app/data/mystery-encounters/mystery-encounter-utils";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { MoveRequirement, WaveCountRequirement } from "../mystery-encounter-requirements";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import Pokemon from "#app/field/pokemon";
import { ModifierTier } from "#app/modifier/modifier-tier";
import {
getPartyLuckValue,
getPlayerModifierTypeOptions,
@ -18,13 +15,16 @@ import {
ModifierTypeOption,
regenerateModifierPoolThresholds
} from "#app/modifier/modifier-type";
import { BattlerTagType } from "#enums/battler-tag-type";
import { StatChangePhase } from "#app/phases";
import { BattleStat } from "#app/data/battle-stat";
import Pokemon from "#app/field/pokemon";
import { randSeedInt } from "#app/utils";
import { Moves } from "#enums/moves";
import { TextStyle } from "#app/ui/text";
import { randSeedInt } from "#app/utils";
import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import BattleScene from "../../../battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { MoveRequirement } from "../mystery-encounter-requirements";
const validMovesForSteal = [
Moves.PLUCK,
@ -40,7 +40,7 @@ export const FightOrFlightEncounter: MysteryEncounter = MysteryEncounterBuilder
.withEncounterType(MysteryEncounterType.FIGHT_OR_FLIGHT)
.withEncounterTier(MysteryEncounterTier.COMMON)
.withIntroSpriteConfigs([]) // Set in onInit()
.withSceneRequirement(new WaveCountRequirement([10, 180])) // waves 10 to 180
.withSceneWaveRangeRequirement(10, 180) // waves 10 to 180
.withCatchAllowed(true)
.withHideWildIntroMessage(true)
.withOnInit((scene: BattleScene) => {

View File

@ -1,25 +1,24 @@
import BattleScene from "../../../battle-scene";
import { ModifierTier } from "#app/modifier/modifier-tier";
import { modifierTypes } from "#app/modifier/modifier-type";
import { EnemyPartyConfig, initBattleWithEnemyConfig, setEncounterRewards } from "#app/data/mystery-encounters/mystery-encounter-utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { WaveCountRequirement } from "../mystery-encounter-requirements";
import {
trainerConfigs,
TrainerPartyCompoundTemplate,
TrainerPartyTemplate,
trainerPartyTemplates
} from "#app/data/trainer-config";
import * as Utils from "../../../utils";
import { ModifierTier } from "#app/modifier/modifier-tier";
import { modifierTypes } from "#app/modifier/modifier-type";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { PartyMemberStrength } from "#enums/party-member-strength";
import BattleScene from "../../../battle-scene";
import * as Utils from "../../../utils";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
export const MysteriousChallengersEncounter: MysteryEncounter = MysteryEncounterBuilder
.withEncounterType(MysteryEncounterType.MYSTERIOUS_CHALLENGERS)
.withEncounterTier(MysteryEncounterTier.GREAT)
.withIntroSpriteConfigs([]) // These are set in onInit()
.withSceneRequirement(new WaveCountRequirement([10, 180])) // waves 10 to 180
.withSceneWaveRangeRequirement(10, 180) // waves 10 to 180
.withOnInit((scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter;
// Calculates what trainers are available for battle in the encounter

View File

@ -1,5 +1,3 @@
import BattleScene from "../../../battle-scene";
import { ModifierTier } from "#app/modifier/modifier-tier";
import {
getHighestLevelPlayerPokemon,
koPlayerPokemon,
@ -8,12 +6,13 @@ import {
setEncounterRewards,
showEncounterText
} from "#app/data/mystery-encounters/mystery-encounter-utils";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { WaveCountRequirement } from "../mystery-encounter-requirements";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { ModifierTier } from "#app/modifier/modifier-tier";
import { GameOverPhase } from "#app/phases";
import { randSeedInt } from "#app/utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import BattleScene from "../../../battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
export const MysteriousChestEncounter: MysteryEncounter = MysteryEncounterBuilder
.withEncounterType(MysteryEncounterType.MYSTERIOUS_CHEST)
@ -29,7 +28,7 @@ export const MysteriousChestEncounter: MysteryEncounter = MysteryEncounterBuilde
}
])
.withHideIntroVisuals(false)
.withSceneRequirement(new WaveCountRequirement([10, 180])) // waves 2 to 180
.withSceneWaveRangeRequirement(10, 180) // waves 2 to 180
.withOption(new MysteryEncounterOptionBuilder()
.withPreOptionPhase(async (scene: BattleScene) => {
// Play animation

View File

@ -1,4 +1,3 @@
import BattleScene from "../../../battle-scene";
import {
generateModifierType,
leaveEncounterWithoutBattle,
@ -7,20 +6,20 @@ import {
setEncounterRewards,
updatePlayerMoney,
} from "#app/data/mystery-encounters/mystery-encounter-utils";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { StatusEffect } from "#app/data/status-effect";
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
import { modifierTypes } from "#app/modifier/modifier-type";
import { randSeedInt } from "#app/utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import BattleScene from "../../../battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import {
HealthRatioRequirement,
MoneyRequirement,
StatusEffectRequirement,
WaveCountRequirement
StatusEffectRequirement
} from "../mystery-encounter-requirements";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { modifierTypes } from "#app/modifier/modifier-type";
import { Species } from "#enums/species";
import { randSeedInt } from "#app/utils";
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
import { StatusEffect } from "#app/data/status-effect";
export const ShadyVitaminDealerEncounter: MysteryEncounter = MysteryEncounterBuilder
.withEncounterType(MysteryEncounterType.SHADY_VITAMIN_DEALER)
@ -42,7 +41,7 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter = MysteryEncounterBui
y: 2
}
])
.withSceneRequirement(new WaveCountRequirement([10, 180]))
.withSceneWaveRangeRequirement(10, 180)
.withPrimaryPokemonRequirement(new StatusEffectRequirement([StatusEffect.NONE])) // Pokemon must not have status
.withPrimaryPokemonRequirement(new HealthRatioRequirement([0.34, 1])) // Pokemon must have above 1/3rd HP
.withOption(new MysteryEncounterOptionBuilder()

View File

@ -1,4 +1,18 @@
import {
ModifierTypeOption,
modifierTypes
} from "#app/modifier/modifier-type";
import { BerryType } from "#enums/berry-type";
import { Moves } from "#enums/moves";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import BattleScene from "../../../battle-scene";
import * as Utils from "../../../utils";
import { getPokemonSpecies } from "../../pokemon-species";
import { Status, StatusEffect } from "../../status-effect";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { MoveRequirement } from "../mystery-encounter-requirements";
import {
EnemyPartyConfig,
EnemyPokemonConfig, generateModifierType,
@ -6,20 +20,6 @@ import {
leaveEncounterWithoutBattle, queueEncounterMessage,
setEncounterRewards
} from "../mystery-encounter-utils";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import * as Utils from "../../../utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { MoveRequirement, WaveCountRequirement } from "../mystery-encounter-requirements";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import {
ModifierTypeOption,
modifierTypes
} from "#app/modifier/modifier-type";
import { getPokemonSpecies } from "../../pokemon-species";
import { Species } from "#enums/species";
import { Status, StatusEffect } from "../../status-effect";
import { Moves } from "#enums/moves";
import { BerryType } from "#enums/berry-type";
export const SleepingSnorlaxEncounter: MysteryEncounter = MysteryEncounterBuilder
.withEncounterType(MysteryEncounterType.SLEEPING_SNORLAX)
@ -33,7 +33,7 @@ export const SleepingSnorlaxEncounter: MysteryEncounter = MysteryEncounterBuilde
repeat: true
}
])
.withSceneRequirement(new WaveCountRequirement([10, 180])) // waves 10 to 180
.withSceneWaveRangeRequirement(10, 180) // waves 10 to 180
.withCatchAllowed(true)
.withHideWildIntroMessage(true)
.withOnInit((scene: BattleScene) => {

View File

@ -1,4 +1,4 @@
import BattleScene from "../../../battle-scene";
import { Ability, allAbilities } from "#app/data/ability";
import {
EnemyPartyConfig,
getEncounterText,
@ -6,23 +6,22 @@ import {
selectPokemonForOption,
setEncounterRewards
} from "#app/data/mystery-encounters/mystery-encounter-utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { WaveCountRequirement } from "../mystery-encounter-requirements";
import { PlayerPokemon } from "#app/field/pokemon";
import PokemonData from "#app/system/pokemon-data";
import { randSeedShuffle } from "#app/utils";
import { getNatureName, Nature } from "#app/data/nature";
import { BattlerTagType } from "#enums/battler-tag-type";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { speciesStarters } from "#app/data/pokemon-species";
import { Stat } from "#app/data/pokemon-stat";
import { PlayerPokemon } from "#app/field/pokemon";
import { pokemonInfo } from "#app/locales/en/pokemon-info";
import { PokemonHeldItemModifier } from "#app/modifier/modifier";
import { PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
import { Ability, allAbilities } from "#app/data/ability";
import { speciesStarters } from "#app/data/pokemon-species";
import { AbilityAttr } from "#app/system/game-data";
import { Stat } from "#app/data/pokemon-stat";
import { pokemonInfo } from "#app/locales/en/pokemon-info";
import PokemonData from "#app/system/pokemon-data";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { randSeedShuffle } from "#app/utils";
import { BattlerTagType } from "#enums/battler-tag-type";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import BattleScene from "../../../battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilder
.withEncounterType(MysteryEncounterType.TRAINING_SESSION)
@ -35,7 +34,7 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
y: 3
}
])
.withSceneRequirement(new WaveCountRequirement([10, 180])) // waves 10 to 180
.withSceneWaveRangeRequirement(10, 180) // waves 10 to 180
.withHideWildIntroMessage(true)
.withOption(new MysteryEncounterOptionBuilder()
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {

View File

@ -71,7 +71,7 @@ export class PreviousEncounterRequirement extends EncounterSceneRequirement {
}
}
export class WaveCountRequirement extends EncounterSceneRequirement {
export class WaveRangeRequirement extends EncounterSceneRequirement {
waveRange: [number, number];
/**

View File

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