some unit test cleanup and general tidying

This commit is contained in:
ImperialSympathizer 2024-10-17 14:22:01 -04:00
parent dcc99ebea0
commit ecf9103350
5 changed files with 10 additions and 26 deletions

View File

@ -19,6 +19,7 @@ import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { CustomModifierSettings } from "#app/modifier/modifier-type"; import { CustomModifierSettings } from "#app/modifier/modifier-type";
import { ModifierTier } from "#app/modifier/modifier-tier"; import { ModifierTier } from "#app/modifier/modifier-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { isNullOrUndefined } from "./utils";
export enum ClassicFixedBossWaves { export enum ClassicFixedBossWaves {
// TODO: other fixed wave battles should be added here // TODO: other fixed wave battles should be added here
@ -414,7 +415,7 @@ export default class Battle {
* Returns if the battle is of type {@linkcode BattleType.MYSTERY_ENCOUNTER} * Returns if the battle is of type {@linkcode BattleType.MYSTERY_ENCOUNTER}
*/ */
isBattleMysteryEncounter(): boolean { isBattleMysteryEncounter(): boolean {
return this.battleType === BattleType.MYSTERY_ENCOUNTER; return !isNullOrUndefined(this.battleType) && this.battleType === BattleType.MYSTERY_ENCOUNTER;
} }
} }

View File

@ -7,7 +7,7 @@ import {
} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import Pokemon, { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import Pokemon, { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import { import {
BerryModifierType, BerryModifierType, getPartyLuckValue,
ModifierPoolType, ModifierPoolType,
ModifierTypeOption, modifierTypes, ModifierTypeOption, modifierTypes,
regenerateModifierPoolThresholds, regenerateModifierPoolThresholds,
@ -30,8 +30,6 @@ import { BerryType } from "#enums/berry-type";
import { PERMANENT_STATS, Stat } from "#enums/stat"; import { PERMANENT_STATS, Stat } from "#enums/stat";
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
import { getPokemonSpecies } from "#app/data/pokemon-species";
import { Species } from "#enums/species";
/** the i18n namespace for the encounter */ /** the i18n namespace for the encounter */
const namespace = "mysteryEncounters/berriesAbound"; const namespace = "mysteryEncounters/berriesAbound";
@ -59,8 +57,7 @@ export const BerriesAboundEncounter: MysteryEncounter =
// Calculate boss mon // Calculate boss mon
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
// const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true); const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true);
const bossSpecies = getPokemonSpecies(Species.KELDEO);
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true); const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon));
const config: EnemyPartyConfig = { const config: EnemyPartyConfig = {

View File

@ -361,10 +361,10 @@ export const BugTypeSuperfanEncounter: MysteryEncounter =
const specialOptions: ModifierTypeOption[] = []; const specialOptions: ModifierTypeOption[] = [];
if (!scene.findModifier(m => m instanceof MegaEvolutionAccessModifier)) { if (!scene.findModifier(m => m instanceof MegaEvolutionAccessModifier)) {
specialOptions.push(generateModifierTypeOption(scene, modifierTypes.MEGA_BRACELET)!); modifierOptions.push(generateModifierTypeOption(scene, modifierTypes.MEGA_BRACELET)!);
} }
if (!scene.findModifier(m => m instanceof GigantamaxAccessModifier)) { if (!scene.findModifier(m => m instanceof GigantamaxAccessModifier)) {
specialOptions.push(generateModifierTypeOption(scene, modifierTypes.DYNAMAX_BAND)!); modifierOptions.push(generateModifierTypeOption(scene, modifierTypes.DYNAMAX_BAND)!);
} }
const nonRareEvolutionModifier = generateModifierTypeOption(scene, modifierTypes.EVOLUTION_ITEM); const nonRareEvolutionModifier = generateModifierTypeOption(scene, modifierTypes.EVOLUTION_ITEM);
if (nonRareEvolutionModifier) { if (nonRareEvolutionModifier) {

View File

@ -1,7 +1,6 @@
import { SettingKeys } from "../../settings/settings"; import { SettingKeys } from "../../settings/settings";
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "../../game-data"; import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "../../game-data";
import { allSpecies } from "../../../data/pokemon-species"; import { allSpecies } from "../../../data/pokemon-species";
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
export const systemMigrators = [ export const systemMigrators = [
/** /**
@ -132,19 +131,5 @@ export const sessionMigrators = [
m.className = "ResetNegativeStatStageModifier"; m.className = "ResetNegativeStatStageModifier";
} }
}); });
// Fix Pokemon nature overrides and custom data migration
data.party.forEach(pokemon => {
if (pokemon["mysteryEncounterData"]) {
pokemon.customPokemonData = new CustomPokemonData(pokemon["mysteryEncounterData"]);
}
if (pokemon["fusionMysteryEncounterData"]) {
pokemon.fusionCustomPokemonData = new CustomPokemonData(pokemon["fusionMysteryEncounterData"]);
}
pokemon.customPokemonData = pokemon.customPokemonData ?? new CustomPokemonData();
if (pokemon["natureOverride"]) {
pokemon.customPokemonData.nature = pokemon["natureOverride"];
}
});
} }
] as const; ] as const;

View File

@ -476,10 +476,11 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler;
expect(modifierSelectHandler.options.length).toEqual(3); expect(modifierSelectHandler.options.length).toEqual(4);
expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("MASTER_BALL"); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("MASTER_BALL");
expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toBe("MAX_LURE"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toBe("MEGA_BRACELET");
expect(modifierSelectHandler.options[2].modifierTypeOption.type.id).toBe("FORM_CHANGE_ITEM"); expect(modifierSelectHandler.options[2].modifierTypeOption.type.id).toBe("DYNAMAX_BAND");
expect(modifierSelectHandler.options[3].modifierTypeOption.type.id).toBe("FORM_CHANGE_ITEM");
}); });
it("should leave encounter without battle", async () => { it("should leave encounter without battle", async () => {