mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-24 16:29:27 +02:00
consolidate learn move type params into an enum
This commit is contained in:
parent
b7516349a0
commit
93a048a863
@ -25,7 +25,7 @@ import { BATTLE_STATS, type PermanentStat, Stat, TEMP_BATTLE_STATS, type TempBat
|
|||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { allMoves } from "#app/data/move";
|
import { allMoves } from "#app/data/move";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
import { LearnMovePhase } from "#app/phases/learn-move-phase";
|
import { LearnMovePhase, LearnMoveType } from "#app/phases/learn-move-phase";
|
||||||
import { LevelUpPhase } from "#app/phases/level-up-phase";
|
import { LevelUpPhase } from "#app/phases/level-up-phase";
|
||||||
import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
|
import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
|
||||||
|
|
||||||
@ -1988,7 +1988,7 @@ export class TmModifier extends ConsumablePokemonModifier {
|
|||||||
apply(args: any[]): boolean {
|
apply(args: any[]): boolean {
|
||||||
const pokemon = args[0] as PlayerPokemon;
|
const pokemon = args[0] as PlayerPokemon;
|
||||||
|
|
||||||
pokemon.scene.unshiftPhase(new LearnMovePhase(pokemon.scene, pokemon.scene.getParty().indexOf(pokemon), (this.type as ModifierTypes.TmModifierType).moveId, true));
|
pokemon.scene.unshiftPhase(new LearnMovePhase(pokemon.scene, pokemon.scene.getParty().indexOf(pokemon), (this.type as ModifierTypes.TmModifierType).moveId, LearnMoveType.TM));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2007,7 +2007,7 @@ export class RememberMoveModifier extends ConsumablePokemonModifier {
|
|||||||
const pokemon = args[0] as PlayerPokemon;
|
const pokemon = args[0] as PlayerPokemon;
|
||||||
const cost = args[1] as number;
|
const cost = args[1] as number;
|
||||||
|
|
||||||
pokemon.scene.unshiftPhase(new LearnMovePhase(pokemon.scene, pokemon.scene.getParty().indexOf(pokemon), pokemon.getLearnableLevelMoves()[this.levelMoveIndex], false, cost));
|
pokemon.scene.unshiftPhase(new LearnMovePhase(pokemon.scene, pokemon.scene.getParty().indexOf(pokemon), pokemon.getLearnableLevelMoves()[this.levelMoveIndex], LearnMoveType.MEMORY, cost));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,25 @@ import { PlayerPartyMemberPokemonPhase } from "#app/phases/player-party-member-p
|
|||||||
import Pokemon from "#app/field/pokemon";
|
import Pokemon from "#app/field/pokemon";
|
||||||
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||||
|
|
||||||
|
export enum LearnMoveType {
|
||||||
|
/** For learning a move via level-up, evolution, or other non-item-based event */
|
||||||
|
LEARN_MOVE,
|
||||||
|
/** For learning a move via Memory Mushroom */
|
||||||
|
MEMORY,
|
||||||
|
/** For learning a move via TM */
|
||||||
|
TM
|
||||||
|
}
|
||||||
|
|
||||||
export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
||||||
private moveId: Moves;
|
private moveId: Moves;
|
||||||
private messageMode: Mode;
|
private messageMode: Mode;
|
||||||
private fromTM: boolean;
|
private learnMoveType;
|
||||||
private cost: number;
|
private cost: number;
|
||||||
|
|
||||||
constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves, fromTM?: boolean, cost: number = -1) {
|
constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) {
|
||||||
super(scene, partyMemberIndex);
|
super(scene, partyMemberIndex);
|
||||||
this.moveId = moveId;
|
this.moveId = moveId;
|
||||||
this.fromTM = fromTM ?? false;
|
this.learnMoveType = learnMoveType;
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,24 +149,25 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
|||||||
* @param Pokemon The Pokemon learning the move
|
* @param Pokemon The Pokemon learning the move
|
||||||
*/
|
*/
|
||||||
async learnMove(index: number, move: Move, pokemon: Pokemon, textMessage?: string) {
|
async learnMove(index: number, move: Move, pokemon: Pokemon, textMessage?: string) {
|
||||||
if (this.fromTM) {
|
if (this.learnMoveType === LearnMoveType.TM) {
|
||||||
if (!pokemon.usedTMs) {
|
if (!pokemon.usedTMs) {
|
||||||
pokemon.usedTMs = [];
|
pokemon.usedTMs = [];
|
||||||
}
|
}
|
||||||
pokemon.usedTMs.push(this.moveId);
|
pokemon.usedTMs.push(this.moveId);
|
||||||
|
this.scene.tryRemovePhase((phase) => phase instanceof SelectModifierPhase);
|
||||||
|
} else if (this.learnMoveType === LearnMoveType.MEMORY) {
|
||||||
|
if (this.cost !== -1) {
|
||||||
|
if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) {
|
||||||
|
this.scene.money -= this.cost;
|
||||||
|
this.scene.updateMoneyText();
|
||||||
|
this.scene.animateMoneyChanged(false);
|
||||||
|
}
|
||||||
|
this.scene.playSound("se/buy");
|
||||||
|
} else {
|
||||||
|
this.scene.tryRemovePhase((phase) => phase instanceof SelectModifierPhase);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pokemon.setMove(index, this.moveId);
|
pokemon.setMove(index, this.moveId);
|
||||||
if (this.cost !== -1) {
|
|
||||||
if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) {
|
|
||||||
this.scene.money -= this.cost;
|
|
||||||
this.scene.updateMoneyText();
|
|
||||||
this.scene.animateMoneyChanged(false);
|
|
||||||
}
|
|
||||||
this.scene.playSound("se/buy");
|
|
||||||
} else if (this.fromTM) {
|
|
||||||
// NOTE: this assumes
|
|
||||||
this.scene.tryRemovePhase((phase) => phase instanceof SelectModifierPhase);
|
|
||||||
}
|
|
||||||
initMoveAnim(this.scene, this.moveId).then(() => {
|
initMoveAnim(this.scene, this.moveId).then(() => {
|
||||||
loadMoveAnimAssets(this.scene, [this.moveId], true);
|
loadMoveAnimAssets(this.scene, [this.moveId], true);
|
||||||
this.scene.playSound("level_up_fanfare"); // Sound loaded into game as is
|
this.scene.playSound("level_up_fanfare"); // Sound loaded into game as is
|
||||||
|
Loading…
Reference in New Issue
Block a user