From 886eb7fdb31682b5874f4537d99b8d40df13b8db Mon Sep 17 00:00:00 2001 From: frutescens Date: Sun, 25 Aug 2024 17:02:29 -0700 Subject: [PATCH] Additions to handle learning during evolution + test fixes --- src/overrides.ts | 2 +- src/phases/learn-move-phase.ts | 17 +++++++++-------- src/test/phases/learn-move-phase.test.ts | 11 +++++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/overrides.ts b/src/overrides.ts index 8b3d628e05e..55f84ffd3af 100644 --- a/src/overrides.ts +++ b/src/overrides.ts @@ -50,7 +50,7 @@ class DefaultOverrides { readonly STARTING_BIOME_OVERRIDE: Biome = Biome.TOWN; readonly ARENA_TINT_OVERRIDE: TimeOfDay | null = null; /** Multiplies XP gained by this value including 0. Set to null to ignore the override */ - readonly XP_MULTIPLIER_OVERRIDE: number | null = null; + readonly XP_MULTIPLIER_OVERRIDE: number | null = 50; readonly NEVER_CRIT_OVERRIDE: boolean = false; /** default 1000 */ readonly STARTING_MONEY_OVERRIDE: integer = 0; diff --git a/src/phases/learn-move-phase.ts b/src/phases/learn-move-phase.ts index ae2f7c70440..fdbdbb86c7f 100644 --- a/src/phases/learn-move-phase.ts +++ b/src/phases/learn-move-phase.ts @@ -1,6 +1,6 @@ import BattleScene from "#app/battle-scene"; import { initMoveAnim, loadMoveAnimAssets } from "#app/data/battle-anims"; -import { allMoves } from "#app/data/move"; +import Move, { allMoves } from "#app/data/move"; import { SpeciesFormChangeMoveLearnedTrigger } from "#app/data/pokemon-forms"; import { Moves } from "#app/enums/moves"; import { getPokemonNameWithAffix } from "#app/messages"; @@ -9,6 +9,7 @@ import { SummaryUiMode } from "#app/ui/summary-ui-handler"; import { Mode } from "#app/ui/ui"; import i18next from "i18next"; import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase"; +import Pokemon from "#app/field/pokemon"; export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { private moveId: Moves; @@ -33,7 +34,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { } this.messageMode = this.scene.ui.getHandler() instanceof EvolutionSceneHandler ? Mode.EVOLUTION_SCENE : Mode.MESSAGE; - + this.scene.ui.setMode(this.messageMode); // If the Pokemon has less than 4 moves, the new move is added to the largest empty moveset index // If it has 4 moves, the phase then checks if the player wants to replace the move itself. if (currentMoveset.length < 4) { @@ -68,18 +69,16 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { * If a player does not select a move or chooses the new move (moveIndex === 4), the game goes to this.rejectMoveAndEnd() * If an old move is selected, the function then passes the moveIndex to this.learnMove() */ - forgetMoveProcess(move, pokemon) { + forgetMoveProcess(move: Move, pokemon: Pokemon) { this.scene.ui.setMode(this.messageMode); this.scene.ui.showText(i18next.t("battle:learnMoveForgetQuestion"), null, () => { this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: integer) => { if (moveIndex === 4) { this.rejectMoveAndEnd(move, pokemon); - return; } - this.scene.ui.setMode(this.messageMode); const forgetSuccessText = i18next.t("battle:learnMoveForgetSuccess", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: pokemon.moveset[moveIndex]!.getName() }); const fullText = [i18next.t("battle:countdownPoof"), forgetSuccessText, i18next.t("battle:learnMoveAnd")].join("$"); - this.learnMove(moveIndex, move, pokemon, fullText); + this.scene.ui.setMode(this.messageMode).then(() => this.learnMove(moveIndex, move, pokemon, fullText)); }); }, null, true); } @@ -90,13 +89,15 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { * If the player wishes to not teach the Pokemon the move, it displays a message and ends the phase. * If the player reconsiders, it repeats the process for a Pokemon with a full moveset once again. */ - rejectMoveAndEnd(move, pokemon) { + rejectMoveAndEnd(move: Move, pokemon: Pokemon) { this.scene.ui.setMode(this.messageMode); this.scene.ui.showText(i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), null, () => { this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => { this.scene.ui.setMode(this.messageMode); - this.scene.ui.showText(i18next.t("battle:learnMoveNotLearned", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: move.name }), null, () => this.end(), null, true); + this.scene.ui.showText(i18next.t("battle:learnMoveNotLearned", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: move.name }), null, () => { + this.unshiftPhase(); this.end(); + }, null, true); }, () => { this.scene.ui.setMode(this.messageMode); diff --git a/src/test/phases/learn-move-phase.test.ts b/src/test/phases/learn-move-phase.test.ts index f412c25d066..42ec80edc09 100644 --- a/src/test/phases/learn-move-phase.test.ts +++ b/src/test/phases/learn-move-phase.test.ts @@ -2,12 +2,9 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import Phaser from "phaser"; import GameManager from "#test/utils/gameManager"; import { Species } from "#enums/species"; -//import * as Utils from "#app/utils"; import { Moves } from "#enums/moves"; -// import BattleScene from "#app/battle-scene"; import { LearnMovePhase } from "#app/phases/learn-move-phase"; import Overrides from "#app/overrides"; -//import { allMoves } from "#app/data/move"; describe("Learn Move Phase", () => { let phaserGame: Phaser.Game; @@ -41,6 +38,12 @@ describe("Learn Move Phase", () => { const levelReq = levelMove[0]; const levelMoveId = levelMove[1]; expect(pokemon.level).toBeGreaterThanOrEqual(levelReq); - expect(pokemon.getMoveset()[newMovePos]).toBe(levelMoveId); + expect(pokemon?.getMoveset()[newMovePos]?.moveId).toBe(levelMoveId); }); + + /** + * Future Tests: + * If a Pokemon has four moves, the user can specify an old move to be forgotten and a new move will take its place. + * If a Pokemon has four moves, the user can reject the new move, keeping the moveset the same. + */ });