Merge branch 'beta' into instruct

This commit is contained in:
Bertie690 2024-11-12 13:03:58 -05:00 committed by GitHub
commit 1dafc62765
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 26 deletions

View File

@ -668,12 +668,12 @@ export default class Move implements Localizable {
} }
/** /**
* Sees if, given the target pokemon, a move fails on it (by looking at each {@linkcode MoveAttr} of this move * Sees if a move has a custom failure text (by looking at each {@linkcode MoveAttr} of this move)
* @param user {@linkcode Pokemon} using the move * @param user {@linkcode Pokemon} using the move
* @param target {@linkcode Pokemon} receiving the move * @param target {@linkcode Pokemon} receiving the move
* @param move {@linkcode Move} using the move * @param move {@linkcode Move} using the move
* @param cancelled {@linkcode Utils.BooleanHolder} to hold boolean value * @param cancelled {@linkcode Utils.BooleanHolder} to hold boolean value
* @returns string of the failed text, or null * @returns string of the custom failure text, or `null` if it uses the default text ("But it failed!")
*/ */
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null { getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
for (const attr of this.attrs) { for (const attr of this.attrs) {

View File

@ -1,59 +1,66 @@
import BattleScene from "#app/battle-scene"; import type BattleScene from "#app/battle-scene";
import { ExpNotification } from "#app/enums/exp-notification"; import { ExpNotification } from "#app/enums/exp-notification";
import { EvolutionPhase } from "#app/phases/evolution-phase"; import type { PlayerPokemon } from "#app/field/pokemon";
import { PlayerPokemon } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import { EvolutionPhase } from "#app/phases/evolution-phase";
import { LearnMovePhase } from "#app/phases/learn-move-phase";
import { PlayerPartyMemberPokemonPhase } from "#app/phases/player-party-member-pokemon-phase";
import { LevelAchv } from "#app/system/achv"; import { LevelAchv } from "#app/system/achv";
import { NumberHolder } from "#app/utils";
import i18next from "i18next"; import i18next from "i18next";
import * as Utils from "#app/utils";
import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase";
import { LearnMovePhase } from "./learn-move-phase";
export class LevelUpPhase extends PlayerPartyMemberPokemonPhase { export class LevelUpPhase extends PlayerPartyMemberPokemonPhase {
private lastLevel: integer; protected lastLevel: number;
private level: integer; protected level: number;
protected pokemon: PlayerPokemon = this.getPlayerPokemon();
constructor(scene: BattleScene, partyMemberIndex: integer, lastLevel: integer, level: integer) { constructor(scene: BattleScene, partyMemberIndex: number, lastLevel: number, level: number) {
super(scene, partyMemberIndex); super(scene, partyMemberIndex);
this.lastLevel = lastLevel; this.lastLevel = lastLevel;
this.level = level; this.level = level;
this.scene = scene;
} }
start() { public override start() {
super.start(); super.start();
if (this.level > this.scene.gameData.gameStats.highestLevel) { if (this.level > this.scene.gameData.gameStats.highestLevel) {
this.scene.gameData.gameStats.highestLevel = this.level; this.scene.gameData.gameStats.highestLevel = this.level;
} }
this.scene.validateAchvs(LevelAchv, new Utils.NumberHolder(this.level)); this.scene.validateAchvs(LevelAchv, new NumberHolder(this.level));
const pokemon = this.getPokemon(); const prevStats = this.pokemon.stats.slice(0);
const prevStats = pokemon.stats.slice(0); this.pokemon.calculateStats();
pokemon.calculateStats(); this.pokemon.updateInfo();
pokemon.updateInfo();
if (this.scene.expParty === ExpNotification.DEFAULT) { if (this.scene.expParty === ExpNotification.DEFAULT) {
this.scene.playSound("level_up_fanfare"); this.scene.playSound("level_up_fanfare");
this.scene.ui.showText(i18next.t("battle:levelUp", { pokemonName: getPokemonNameWithAffix(this.getPokemon()), level: this.level }), null, () => this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end()), null, true); this.scene.ui.showText(
i18next.t("battle:levelUp", { pokemonName: getPokemonNameWithAffix(this.pokemon), level: this.level }),
null,
() => this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false)
.then(() => this.end()), null, true);
} else if (this.scene.expParty === ExpNotification.SKIP) { } else if (this.scene.expParty === ExpNotification.SKIP) {
this.end(); this.end();
} else { } else {
// we still want to display the stats if activated // we still want to display the stats if activated
this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end()); this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end());
} }
}
public override end() {
if (this.lastLevel < 100) { // this feels like an unnecessary optimization if (this.lastLevel < 100) { // this feels like an unnecessary optimization
const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1); const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1);
for (const lm of levelMoves) { for (const lm of levelMoves) {
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm[1])); this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm[1]));
} }
} }
if (!pokemon.pauseEvolutions) { if (!this.pokemon.pauseEvolutions) {
const evolution = pokemon.getEvolution(); const evolution = this.pokemon.getEvolution();
if (evolution) { if (evolution) {
this.scene.unshiftPhase(new EvolutionPhase(this.scene, pokemon as PlayerPokemon, evolution, this.lastLevel)); this.scene.unshiftPhase(new EvolutionPhase(this.scene, this.pokemon, evolution, this.lastLevel));
} }
} }
return super.end();
} }
} }

View File

@ -378,10 +378,8 @@ export class MovePhase extends BattlePhase {
this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual }); this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual });
const failureMessage = move.getFailedText(this.pokemon, targets[0], move, new BooleanHolder(false)); const failureMessage = move.getFailedText(this.pokemon, targets[0], move, new BooleanHolder(false));
if (failureMessage) { this.showMoveText();
this.showMoveText(); this.showFailedText(failureMessage ?? undefined);
this.showFailedText(failureMessage);
}
// Remove the user from its semi-invulnerable state (if applicable) // Remove the user from its semi-invulnerable state (if applicable)
this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT); this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT);