Additions to handle learning during evolution + test fixes

This commit is contained in:
frutescens 2024-08-25 17:02:29 -07:00
parent 06d5600ce4
commit 886eb7fdb3
3 changed files with 17 additions and 13 deletions

View File

@ -50,7 +50,7 @@ class DefaultOverrides {
readonly STARTING_BIOME_OVERRIDE: Biome = Biome.TOWN; readonly STARTING_BIOME_OVERRIDE: Biome = Biome.TOWN;
readonly ARENA_TINT_OVERRIDE: TimeOfDay | null = null; readonly ARENA_TINT_OVERRIDE: TimeOfDay | null = null;
/** Multiplies XP gained by this value including 0. Set to null to ignore the override */ /** 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; readonly NEVER_CRIT_OVERRIDE: boolean = false;
/** default 1000 */ /** default 1000 */
readonly STARTING_MONEY_OVERRIDE: integer = 0; readonly STARTING_MONEY_OVERRIDE: integer = 0;

View File

@ -1,6 +1,6 @@
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import { initMoveAnim, loadMoveAnimAssets } from "#app/data/battle-anims"; 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 { SpeciesFormChangeMoveLearnedTrigger } from "#app/data/pokemon-forms";
import { Moves } from "#app/enums/moves"; import { Moves } from "#app/enums/moves";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
@ -9,6 +9,7 @@ import { SummaryUiMode } from "#app/ui/summary-ui-handler";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import i18next from "i18next"; import i18next from "i18next";
import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase"; import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase";
import Pokemon from "#app/field/pokemon";
export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
private moveId: Moves; 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.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 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 it has 4 moves, the phase then checks if the player wants to replace the move itself.
if (currentMoveset.length < 4) { 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 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() * 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.setMode(this.messageMode);
this.scene.ui.showText(i18next.t("battle:learnMoveForgetQuestion"), null, () => { this.scene.ui.showText(i18next.t("battle:learnMoveForgetQuestion"), null, () => {
this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: integer) => { this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: integer) => {
if (moveIndex === 4) { if (moveIndex === 4) {
this.rejectMoveAndEnd(move, pokemon); 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 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("$"); 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); }, 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 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. * 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.setMode(this.messageMode);
this.scene.ui.showText(i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), null, () => { this.scene.ui.showText(i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), null, () => {
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, this.scene.ui.setModeWithoutClear(Mode.CONFIRM,
() => { () => {
this.scene.ui.setMode(this.messageMode); 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); this.scene.ui.setMode(this.messageMode);

View File

@ -2,12 +2,9 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import Phaser from "phaser"; import Phaser from "phaser";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
//import * as Utils from "#app/utils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
// import BattleScene from "#app/battle-scene";
import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { LearnMovePhase } from "#app/phases/learn-move-phase";
import Overrides from "#app/overrides"; import Overrides from "#app/overrides";
//import { allMoves } from "#app/data/move";
describe("Learn Move Phase", () => { describe("Learn Move Phase", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -41,6 +38,12 @@ describe("Learn Move Phase", () => {
const levelReq = levelMove[0]; const levelReq = levelMove[0];
const levelMoveId = levelMove[1]; const levelMoveId = levelMove[1];
expect(pokemon.level).toBeGreaterThanOrEqual(levelReq); 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.
*/
}); });