mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-12-01 03:06:19 +00:00
Clean up various phases
Remove redundant code, utilize default parameters, clean up some leftover `strict-null` `TODO`s, replace `integer` with `number`
This commit is contained in:
parent
7a0c88e661
commit
a0f10c1b7d
@ -1261,8 +1261,6 @@ export default class BattleScene extends SceneBase {
|
||||
this.currentBattle.mysteryEncounterType = mysteryEncounterType;
|
||||
}
|
||||
|
||||
//this.pushPhase(new TrainerMessageTestPhase(this, TrainerType.RIVAL, TrainerType.RIVAL_2, TrainerType.RIVAL_3, TrainerType.RIVAL_4, TrainerType.RIVAL_5, TrainerType.RIVAL_6));
|
||||
|
||||
if (!waveIndex && lastBattle) {
|
||||
const isWaveIndexMultipleOfTen = !(lastBattle.waveIndex % 10);
|
||||
const isEndlessOrDaily = this.gameMode.hasShortBiomes || this.gameMode.isDaily;
|
||||
|
@ -23,7 +23,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
private pokeball: Phaser.GameObjects.Sprite;
|
||||
private originalY: number;
|
||||
|
||||
constructor(scene: BattleScene, targetIndex: integer, pokeballType: PokeballType) {
|
||||
constructor(scene: BattleScene, targetIndex: number, pokeballType: PokeballType) {
|
||||
super(scene, BattlerIndex.ENEMY + targetIndex);
|
||||
|
||||
this.pokeballType = pokeballType;
|
||||
@ -160,7 +160,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
});
|
||||
}
|
||||
|
||||
failCatch(shakeCount: integer) {
|
||||
failCatch(shakeCount: number) {
|
||||
const pokemon = this.getPokemon();
|
||||
|
||||
this.scene.playSound("se/pb_rel");
|
||||
@ -262,7 +262,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
});
|
||||
}, false);
|
||||
}, () => {
|
||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => {
|
||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: number, _option: PartyOption) => {
|
||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
||||
if (slotIndex < 6) {
|
||||
addToParty(slotIndex);
|
||||
|
@ -8,8 +8,12 @@ export class BattlePhase extends Phase {
|
||||
}
|
||||
|
||||
showEnemyTrainer(trainerSlot: TrainerSlot = TrainerSlot.NONE): void {
|
||||
const sprites = this.scene.currentBattle.trainer?.getSprites()!; // TODO: is this bang correct?
|
||||
const tintSprites = this.scene.currentBattle.trainer?.getTintSprites()!; // TODO: is this bang correct?
|
||||
if (!this.scene.currentBattle.trainer) {
|
||||
console.warn("Enemy trainer is missing!");
|
||||
return;
|
||||
}
|
||||
const sprites = this.scene.currentBattle.trainer.getSprites();
|
||||
const tintSprites = this.scene.currentBattle.trainer.getTintSprites();
|
||||
for (let i = 0; i < sprites.length; i++) {
|
||||
const visible = !trainerSlot || !i === (trainerSlot === TrainerSlot.TRAINER) || sprites.length < 2;
|
||||
[ sprites[i], tintSprites[i] ].map(sprite => {
|
||||
|
@ -4,10 +4,9 @@ import { BattlerIndex } from "#app/battle";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
|
||||
export class CheckStatusEffectPhase extends Phase {
|
||||
private order : BattlerIndex[];
|
||||
constructor(scene : BattleScene, order : BattlerIndex[]) {
|
||||
private order: BattlerIndex[];
|
||||
constructor(scene: BattleScene, order: BattlerIndex[]) {
|
||||
super(scene);
|
||||
this.scene = scene;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,10 @@ import { SwitchPhase } from "./switch-phase";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
|
||||
export class CheckSwitchPhase extends BattlePhase {
|
||||
protected fieldIndex: integer;
|
||||
protected fieldIndex: number;
|
||||
protected useName: boolean;
|
||||
|
||||
constructor(scene: BattleScene, fieldIndex: integer, useName: boolean) {
|
||||
constructor(scene: BattleScene, fieldIndex: number, useName: boolean) {
|
||||
super(scene);
|
||||
|
||||
this.fieldIndex = fieldIndex;
|
||||
|
@ -21,9 +21,9 @@ import { ArenaTagSide } from "#app/data/arena-tag";
|
||||
import { ArenaTagType } from "#app/enums/arena-tag-type";
|
||||
|
||||
export class CommandPhase extends FieldPhase {
|
||||
protected fieldIndex: integer;
|
||||
protected fieldIndex: number;
|
||||
|
||||
constructor(scene: BattleScene, fieldIndex: integer) {
|
||||
constructor(scene: BattleScene, fieldIndex: number) {
|
||||
super(scene);
|
||||
|
||||
this.fieldIndex = fieldIndex;
|
||||
@ -90,7 +90,7 @@ export class CommandPhase extends FieldPhase {
|
||||
}
|
||||
}
|
||||
|
||||
handleCommand(command: Command, cursor: integer, ...args: any[]): boolean {
|
||||
handleCommand(command: Command, cursor: number, ...args: any[]): boolean {
|
||||
const playerPokemon = this.scene.getPlayerField()[this.fieldIndex];
|
||||
let success: boolean;
|
||||
|
||||
@ -307,7 +307,7 @@ export class CommandPhase extends FieldPhase {
|
||||
return true;
|
||||
}
|
||||
|
||||
getFieldIndex(): integer {
|
||||
getFieldIndex(): number {
|
||||
return this.fieldIndex;
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,13 @@ import { PokemonPhase } from "./pokemon-phase";
|
||||
|
||||
export class CommonAnimPhase extends PokemonPhase {
|
||||
private anim: CommonAnim | null;
|
||||
private targetIndex: integer | undefined;
|
||||
private targetIndex?: BattlerIndex;
|
||||
private playOnEmptyField: boolean;
|
||||
|
||||
constructor(scene: BattleScene, battlerIndex?: BattlerIndex, targetIndex?: BattlerIndex | undefined, anim?: CommonAnim, playOnEmptyField: boolean = false) {
|
||||
constructor(scene: BattleScene, battlerIndex?: BattlerIndex, targetIndex?: BattlerIndex, anim: CommonAnim | null = null, playOnEmptyField: boolean = false) {
|
||||
super(scene, battlerIndex);
|
||||
|
||||
this.anim = anim!; // TODO: is this bang correct?
|
||||
this.anim = anim;
|
||||
this.targetIndex = targetIndex;
|
||||
this.playOnEmptyField = playOnEmptyField;
|
||||
}
|
||||
|
@ -6,15 +6,15 @@ import * as Utils from "#app/utils";
|
||||
import { PokemonPhase } from "./pokemon-phase";
|
||||
|
||||
export class DamagePhase extends PokemonPhase {
|
||||
private amount: integer;
|
||||
private amount: number;
|
||||
private damageResult: DamageResult;
|
||||
private critical: boolean;
|
||||
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex, amount: integer, damageResult?: DamageResult, critical: boolean = false) {
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex, amount: number, damageResult: DamageResult = HitResult.EFFECTIVE, critical: boolean = false) {
|
||||
super(scene, battlerIndex);
|
||||
|
||||
this.amount = amount;
|
||||
this.damageResult = damageResult || HitResult.EFFECTIVE;
|
||||
this.damageResult = damageResult;
|
||||
this.critical = critical;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ export class DamagePhase extends PokemonPhase {
|
||||
this.applyDamage();
|
||||
}
|
||||
|
||||
updateAmount(amount: integer): void {
|
||||
updateAmount(amount: number): void {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ export class EggHatchPhase extends Phase {
|
||||
private eggHatchData: EggHatchData;
|
||||
|
||||
/** The number of eggs that are hatching */
|
||||
private eggsToHatchCount: integer;
|
||||
private eggsToHatchCount: number;
|
||||
/** The container that lists how many eggs are hatching */
|
||||
private eggCounterContainer: EggCounterContainer;
|
||||
|
||||
@ -57,7 +57,7 @@ export class EggHatchPhase extends Phase {
|
||||
/** The newly hatched {@link PlayerPokemon} */
|
||||
private pokemon: PlayerPokemon;
|
||||
/** The index of which egg move is unlocked. 0-2 is common, 3 is rare */
|
||||
private eggMoveIndex: integer;
|
||||
private eggMoveIndex: number;
|
||||
/** Internal booleans representing if the egg is hatched, able to be skipped, or skipped */
|
||||
private hatched: boolean;
|
||||
private canSkip: boolean;
|
||||
@ -66,7 +66,7 @@ export class EggHatchPhase extends Phase {
|
||||
private evolutionBgm: AnySound;
|
||||
private eggLapsePhase: EggLapsePhase;
|
||||
|
||||
constructor(scene: BattleScene, hatchScene: EggLapsePhase, egg: Egg, eggsToHatchCount: integer) {
|
||||
constructor(scene: BattleScene, hatchScene: EggLapsePhase, egg: Egg, eggsToHatchCount: number) {
|
||||
super(scene);
|
||||
this.eggLapsePhase = hatchScene;
|
||||
this.egg = egg;
|
||||
@ -219,7 +219,7 @@ export class EggHatchPhase extends Phase {
|
||||
* @param count the current number of times this function has been called.
|
||||
* @returns nothing since it's a Promise<void>
|
||||
*/
|
||||
doEggShake(intensity: number, repeatCount?: integer, count?: integer): Promise<void> {
|
||||
doEggShake(intensity: number, repeatCount?: number, count?: number): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
if (repeatCount === undefined) {
|
||||
repeatCount = 0;
|
||||
@ -376,7 +376,7 @@ export class EggHatchPhase extends Phase {
|
||||
* @param amplitude Scaling
|
||||
* @returns a number
|
||||
*/
|
||||
sin(index: integer, amplitude: integer): number {
|
||||
sin(index: number, amplitude: number): number {
|
||||
return amplitude * Math.sin(index * (Math.PI / 128));
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ export class EggHatchPhase extends Phase {
|
||||
* @param intensity number of times this is repeated (this is a badly named variable)
|
||||
* @param offsetY how much to offset the Y coordinates
|
||||
*/
|
||||
doSpray(intensity: integer, offsetY?: number) {
|
||||
doSpray(intensity: number, offsetY?: number) {
|
||||
this.scene.tweens.addCounter({
|
||||
repeat: intensity,
|
||||
duration: Utils.getFrameMs(1),
|
||||
@ -400,7 +400,7 @@ export class EggHatchPhase extends Phase {
|
||||
* @param trigIndex Used to modify the particle's vertical speed, is a random number from 0-7
|
||||
* @param offsetY how much to offset the Y coordinate
|
||||
*/
|
||||
doSprayParticle(trigIndex: integer, offsetY: number) {
|
||||
doSprayParticle(trigIndex: number, offsetY: number) {
|
||||
const initialX = this.eggHatchBg.displayWidth / 2;
|
||||
const initialY = this.eggHatchBg.displayHeight / 2 + offsetY;
|
||||
const shardKey = !this.egg.isManaphyEgg() ? this.egg.tier.toString() : "1";
|
||||
|
@ -40,10 +40,10 @@ import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mys
|
||||
export class EncounterPhase extends BattlePhase {
|
||||
private loaded: boolean;
|
||||
|
||||
constructor(scene: BattleScene, loaded?: boolean) {
|
||||
constructor(scene: BattleScene, loaded: boolean = false) {
|
||||
super(scene);
|
||||
|
||||
this.loaded = !!loaded;
|
||||
this.loaded = loaded;
|
||||
}
|
||||
|
||||
start() {
|
||||
@ -268,7 +268,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
const enemyField = this.scene.getEnemyField();
|
||||
this.scene.tweens.add({
|
||||
targets: [ this.scene.arenaEnemy, this.scene.currentBattle.trainer, enemyField, this.scene.arenaPlayer, this.scene.trainer ].flat(),
|
||||
x: (_target, _key, value, fieldIndex: integer) => fieldIndex < 2 + (enemyField.length) ? value + 300 : value - 300,
|
||||
x: (_target, _key, value, fieldIndex: number) => fieldIndex < 2 + (enemyField.length) ? value + 300 : value - 300,
|
||||
duration: 2000,
|
||||
onComplete: () => {
|
||||
if (!this.tryOverrideForBattleSpec()) {
|
||||
|
@ -13,10 +13,10 @@ import { FieldPhase } from "./field-phase";
|
||||
* @see {@linkcode EnemyPokemon.getNextMove}
|
||||
*/
|
||||
export class EnemyCommandPhase extends FieldPhase {
|
||||
protected fieldIndex: integer;
|
||||
protected fieldIndex: number;
|
||||
protected skipTurn: boolean = false;
|
||||
|
||||
constructor(scene: BattleScene, fieldIndex: integer) {
|
||||
constructor(scene: BattleScene, fieldIndex: number) {
|
||||
super(scene);
|
||||
|
||||
this.fieldIndex = fieldIndex;
|
||||
|
@ -3,7 +3,7 @@ import { EnemyPokemon } from "#app/field/pokemon";
|
||||
import { PartyMemberPokemonPhase } from "./party-member-pokemon-phase";
|
||||
|
||||
export abstract class EnemyPartyMemberPokemonPhase extends PartyMemberPokemonPhase {
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer) {
|
||||
constructor(scene: BattleScene, partyMemberIndex: number) {
|
||||
super(scene, partyMemberIndex, false);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import { EndEvolutionPhase } from "#app/phases/end-evolution-phase";
|
||||
|
||||
export class EvolutionPhase extends Phase {
|
||||
protected pokemon: PlayerPokemon;
|
||||
protected lastLevel: integer;
|
||||
protected lastLevel: number;
|
||||
|
||||
private preEvolvedPokemonName: string;
|
||||
|
||||
@ -33,7 +33,7 @@ export class EvolutionPhase extends Phase {
|
||||
protected pokemonEvoSprite: Phaser.GameObjects.Sprite;
|
||||
protected pokemonEvoTintSprite: Phaser.GameObjects.Sprite;
|
||||
|
||||
constructor(scene: BattleScene, pokemon: PlayerPokemon, evolution: SpeciesFormEvolution | null, lastLevel: integer) {
|
||||
constructor(scene: BattleScene, pokemon: PlayerPokemon, evolution: SpeciesFormEvolution | null, lastLevel: number) {
|
||||
super(scene);
|
||||
|
||||
this.pokemon = pokemon;
|
||||
@ -339,7 +339,7 @@ export class EvolutionPhase extends Phase {
|
||||
});
|
||||
}
|
||||
|
||||
doCycle(l: number, lastCycle: integer = 15): Promise<boolean> {
|
||||
doCycle(l: number, lastCycle: number = 15): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
const isLastCycle = l === lastCycle;
|
||||
this.scene.tweens.add({
|
||||
@ -410,7 +410,7 @@ export class EvolutionPhase extends Phase {
|
||||
});
|
||||
}
|
||||
|
||||
doSpiralUpwardParticle(trigIndex: integer) {
|
||||
doSpiralUpwardParticle(trigIndex: number) {
|
||||
const initialX = this.evolutionBaseBg.displayWidth / 2;
|
||||
const particle = this.scene.add.image(initialX, 0, "evo_sparkle");
|
||||
this.evolutionContainer.add(particle);
|
||||
@ -446,7 +446,7 @@ export class EvolutionPhase extends Phase {
|
||||
updateParticle();
|
||||
}
|
||||
|
||||
doArcDownParticle(trigIndex: integer) {
|
||||
doArcDownParticle(trigIndex: number) {
|
||||
const initialX = this.evolutionBaseBg.displayWidth / 2;
|
||||
const particle = this.scene.add.image(initialX, 0, "evo_sparkle");
|
||||
particle.setScale(0.5);
|
||||
@ -479,7 +479,7 @@ export class EvolutionPhase extends Phase {
|
||||
updateParticle();
|
||||
}
|
||||
|
||||
doCircleInwardParticle(trigIndex: integer, speed: integer) {
|
||||
doCircleInwardParticle(trigIndex: number, speed: number) {
|
||||
const initialX = this.evolutionBaseBg.displayWidth / 2;
|
||||
const initialY = this.evolutionBaseBg.displayHeight / 2;
|
||||
const particle = this.scene.add.image(initialX, initialY, "evo_sparkle");
|
||||
@ -511,7 +511,7 @@ export class EvolutionPhase extends Phase {
|
||||
updateParticle();
|
||||
}
|
||||
|
||||
doSprayParticle(trigIndex: integer) {
|
||||
doSprayParticle(trigIndex: number) {
|
||||
const initialX = this.evolutionBaseBg.displayWidth / 2;
|
||||
const initialY = this.evolutionBaseBg.displayHeight / 2;
|
||||
const particle = this.scene.add.image(initialX, initialY, "evo_sparkle");
|
||||
|
@ -9,7 +9,7 @@ import { LevelUpPhase } from "./level-up-phase";
|
||||
export class ExpPhase extends PlayerPartyMemberPokemonPhase {
|
||||
private expValue: number;
|
||||
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer, expValue: number) {
|
||||
constructor(scene: BattleScene, partyMemberIndex: number, expValue: number) {
|
||||
super(scene, partyMemberIndex);
|
||||
|
||||
this.expValue = expValue;
|
||||
|
@ -29,10 +29,10 @@ export class GameOverPhase extends BattlePhase {
|
||||
private victory: boolean;
|
||||
private firstRibbons: PokemonSpecies[] = [];
|
||||
|
||||
constructor(scene: BattleScene, victory?: boolean) {
|
||||
constructor(scene: BattleScene, victory: boolean = false) {
|
||||
super(scene);
|
||||
|
||||
this.victory = !!victory;
|
||||
this.victory = victory;
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -25,10 +25,10 @@ export enum LearnMoveType {
|
||||
export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
||||
private moveId: Moves;
|
||||
private messageMode: Mode;
|
||||
private learnMoveType;
|
||||
private learnMoveType: LearnMoveType;
|
||||
private cost: number;
|
||||
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) {
|
||||
constructor(scene: BattleScene, partyMemberIndex: number, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) {
|
||||
super(scene, partyMemberIndex);
|
||||
this.moveId = moveId;
|
||||
this.learnMoveType = learnMoveType;
|
||||
@ -98,7 +98,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
||||
async forgetMoveProcess(move: Move, pokemon: Pokemon) {
|
||||
this.scene.ui.setMode(this.messageMode);
|
||||
await this.scene.ui.showTextPromise(i18next.t("battle:learnMoveForgetQuestion"), undefined, true);
|
||||
await this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: integer) => {
|
||||
await this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: number) => {
|
||||
if (moveIndex === 4) {
|
||||
this.scene.ui.setMode(this.messageMode).then(() => this.rejectMoveAndEnd(move, pokemon));
|
||||
return;
|
||||
|
@ -10,10 +10,10 @@ import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-pha
|
||||
import { LearnMovePhase } from "./learn-move-phase";
|
||||
|
||||
export class LevelUpPhase extends PlayerPartyMemberPokemonPhase {
|
||||
private lastLevel: integer;
|
||||
private level: integer;
|
||||
private lastLevel: number;
|
||||
private level: number;
|
||||
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer, lastLevel: integer, level: integer) {
|
||||
constructor(scene: BattleScene, partyMemberIndex: number, lastLevel: number, level: number) {
|
||||
super(scene, partyMemberIndex);
|
||||
|
||||
this.lastLevel = lastLevel;
|
||||
|
@ -11,10 +11,10 @@ import { UnavailablePhase } from "./unavailable-phase";
|
||||
export class LoginPhase extends Phase {
|
||||
private showText: boolean;
|
||||
|
||||
constructor(scene: BattleScene, showText?: boolean) {
|
||||
constructor(scene: BattleScene, showText: boolean = true) {
|
||||
super(scene);
|
||||
|
||||
this.showText = showText === undefined || !!showText;
|
||||
this.showText = showText;
|
||||
}
|
||||
|
||||
start(): void {
|
||||
|
@ -3,18 +3,18 @@ import { Phase } from "#app/phase";
|
||||
|
||||
export class MessagePhase extends Phase {
|
||||
private text: string;
|
||||
private callbackDelay: integer | null;
|
||||
private prompt: boolean | null;
|
||||
private promptDelay: integer | null;
|
||||
private callbackDelay?: number | null;
|
||||
private prompt?: boolean | null;
|
||||
private promptDelay?: number | null;
|
||||
private speaker?: string;
|
||||
|
||||
constructor(scene: BattleScene, text: string, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null, speaker?: string) {
|
||||
constructor(scene: BattleScene, text: string, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null, speaker?: string) {
|
||||
super(scene);
|
||||
|
||||
this.text = text;
|
||||
this.callbackDelay = callbackDelay!; // TODO: is this bang correct?
|
||||
this.prompt = prompt!; // TODO: is this bang correct?
|
||||
this.promptDelay = promptDelay!; // TODO: is this bang correct?
|
||||
this.callbackDelay = callbackDelay;
|
||||
this.prompt = prompt;
|
||||
this.promptDelay = promptDelay;
|
||||
this.speaker = speaker;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ export class MoneyRewardPhase extends BattlePhase {
|
||||
}
|
||||
|
||||
start() {
|
||||
const moneyAmount = new Utils.IntegerHolder(this.scene.getWaveMoneyAmount(this.moneyMultiplier));
|
||||
const moneyAmount = new Utils.NumberHolder(this.scene.getWaveMoneyAmount(this.moneyMultiplier));
|
||||
|
||||
this.scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);
|
||||
|
||||
|
@ -1,46 +0,0 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { initMoveAnim, loadMoveAnimAssets, MoveAnim } from "#app/data/battle-anims";
|
||||
import { allMoves, SelfStatusMove } from "#app/data/move";
|
||||
import { Moves } from "#app/enums/moves";
|
||||
import * as Utils from "#app/utils";
|
||||
import { BattlePhase } from "./battle-phase";
|
||||
|
||||
export class MoveAnimTestPhase extends BattlePhase {
|
||||
private moveQueue: Moves[];
|
||||
|
||||
constructor(scene: BattleScene, moveQueue?: Moves[]) {
|
||||
super(scene);
|
||||
|
||||
this.moveQueue = moveQueue || Utils.getEnumValues(Moves).slice(1);
|
||||
}
|
||||
|
||||
start() {
|
||||
const moveQueue = this.moveQueue.slice(0);
|
||||
this.playMoveAnim(moveQueue, true);
|
||||
}
|
||||
|
||||
playMoveAnim(moveQueue: Moves[], player: boolean) {
|
||||
const moveId = player ? moveQueue[0] : moveQueue.shift();
|
||||
if (moveId === undefined) {
|
||||
this.playMoveAnim(this.moveQueue.slice(0), true);
|
||||
return;
|
||||
} else if (player) {
|
||||
console.log(Moves[moveId]);
|
||||
}
|
||||
|
||||
initMoveAnim(this.scene, moveId).then(() => {
|
||||
loadMoveAnimAssets(this.scene, [ moveId ], true)
|
||||
.then(() => {
|
||||
const user = player ? this.scene.getPlayerPokemon()! : this.scene.getEnemyPokemon()!;
|
||||
const target = (player !== (allMoves[moveId] instanceof SelfStatusMove)) ? this.scene.getEnemyPokemon()! : this.scene.getPlayerPokemon()!;
|
||||
new MoveAnim(moveId, user, target.getBattlerIndex()).play(this.scene, allMoves[moveId].hitsSubstitute(user, target), () => { // TODO: are the bangs correct here?
|
||||
if (player) {
|
||||
this.playMoveAnim(moveQueue, false);
|
||||
} else {
|
||||
this.playMoveAnim(moveQueue, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -3,11 +3,11 @@ import Pokemon from "#app/field/pokemon";
|
||||
import { FieldPhase } from "./field-phase";
|
||||
|
||||
export abstract class PartyMemberPokemonPhase extends FieldPhase {
|
||||
protected partyMemberIndex: integer;
|
||||
protected fieldIndex: integer;
|
||||
protected partyMemberIndex: number;
|
||||
protected fieldIndex: number;
|
||||
protected player: boolean;
|
||||
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer, player: boolean) {
|
||||
constructor(scene: BattleScene, partyMemberIndex: number, player: boolean) {
|
||||
super(scene);
|
||||
|
||||
this.partyMemberIndex = partyMemberIndex;
|
||||
|
@ -3,7 +3,7 @@ import { PlayerPokemon } from "#app/field/pokemon";
|
||||
import { PartyMemberPokemonPhase } from "./party-member-pokemon-phase";
|
||||
|
||||
export abstract class PlayerPartyMemberPokemonPhase extends PartyMemberPokemonPhase {
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer) {
|
||||
constructor(scene: BattleScene, partyMemberIndex: number) {
|
||||
super(scene, partyMemberIndex, true);
|
||||
}
|
||||
|
||||
|
@ -7,18 +7,18 @@ import { BattlePhase } from "#app/phases/battle-phase";
|
||||
|
||||
export class PokemonAnimPhase extends BattlePhase {
|
||||
/** The type of animation to play in this phase */
|
||||
private key: PokemonAnimType;
|
||||
protected key: PokemonAnimType;
|
||||
/** The Pokemon to which this animation applies */
|
||||
private pokemon: Pokemon;
|
||||
protected pokemon: Pokemon;
|
||||
/** Any other field sprites affected by this animation */
|
||||
private fieldAssets: Phaser.GameObjects.Sprite[];
|
||||
protected fieldAssets: Phaser.GameObjects.Sprite[];
|
||||
|
||||
constructor(scene: BattleScene, key: PokemonAnimType, pokemon: Pokemon, fieldAssets?: Phaser.GameObjects.Sprite[]) {
|
||||
constructor(scene: BattleScene, key: PokemonAnimType, pokemon: Pokemon, fieldAssets: Phaser.GameObjects.Sprite[] = []) {
|
||||
super(scene);
|
||||
|
||||
this.key = key;
|
||||
this.pokemon = pokemon;
|
||||
this.fieldAssets = fieldAssets ?? [];
|
||||
this.fieldAssets = fieldAssets;
|
||||
}
|
||||
|
||||
start(): void {
|
||||
|
@ -14,7 +14,7 @@ import { BattlerTagType } from "#app/enums/battler-tag-type";
|
||||
import { HealBlockTag } from "#app/data/battler-tags";
|
||||
|
||||
export class PokemonHealPhase extends CommonAnimPhase {
|
||||
private hpHealed: integer;
|
||||
private hpHealed: number;
|
||||
private message: string | null;
|
||||
private showFullHpMessage: boolean;
|
||||
private skipAnim: boolean;
|
||||
@ -22,7 +22,7 @@ export class PokemonHealPhase extends CommonAnimPhase {
|
||||
private healStatus: boolean;
|
||||
private preventFullHeal: boolean;
|
||||
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex, hpHealed: integer, message: string | null, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false, preventFullHeal: boolean = false) {
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex, hpHealed: number, message: string | null, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false, preventFullHeal: boolean = false) {
|
||||
super(scene, battlerIndex, undefined, CommonAnim.HEALTH_UP);
|
||||
|
||||
this.hpHealed = hpHealed;
|
||||
@ -59,7 +59,7 @@ export class PokemonHealPhase extends CommonAnimPhase {
|
||||
this.message = null;
|
||||
return super.end();
|
||||
} else if (healOrDamage) {
|
||||
const hpRestoreMultiplier = new Utils.IntegerHolder(1);
|
||||
const hpRestoreMultiplier = new Utils.NumberHolder(1);
|
||||
if (!this.revive) {
|
||||
this.scene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier);
|
||||
}
|
||||
|
@ -4,15 +4,16 @@ import Pokemon from "#app/field/pokemon";
|
||||
import { FieldPhase } from "./field-phase";
|
||||
|
||||
export abstract class PokemonPhase extends FieldPhase {
|
||||
protected battlerIndex: BattlerIndex | integer;
|
||||
protected battlerIndex: BattlerIndex | number;
|
||||
public player: boolean;
|
||||
public fieldIndex: integer;
|
||||
public fieldIndex: number;
|
||||
|
||||
constructor(scene: BattleScene, battlerIndex?: BattlerIndex | integer) {
|
||||
constructor(scene: BattleScene, battlerIndex?: BattlerIndex | number) {
|
||||
super(scene);
|
||||
|
||||
battlerIndex = battlerIndex ?? scene.getField().find(p => p?.isActive())!.getBattlerIndex(); // TODO: is the bang correct here?
|
||||
if (battlerIndex === undefined) {
|
||||
battlerIndex = scene.getField().find(p => p?.isActive())!.getBattlerIndex(); // TODO: is the bang correct here?
|
||||
console.warn("There are no Pokemon on the field!"); // TODO: figure out a suitable fallback behavior
|
||||
}
|
||||
|
||||
this.battlerIndex = battlerIndex;
|
||||
|
@ -4,12 +4,12 @@ import { EndCardPhase } from "./end-card-phase";
|
||||
import { TitlePhase } from "./title-phase";
|
||||
|
||||
export class PostGameOverPhase extends Phase {
|
||||
private endCardPhase: EndCardPhase | null;
|
||||
private endCardPhase?: EndCardPhase;
|
||||
|
||||
constructor(scene: BattleScene, endCardPhase?: EndCardPhase) {
|
||||
super(scene);
|
||||
|
||||
this.endCardPhase = endCardPhase!; // TODO: is this bang correct?
|
||||
this.endCardPhase = endCardPhase;
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -4,12 +4,12 @@ import { Mode } from "#app/ui/ui";
|
||||
import * as Utils from "#app/utils";
|
||||
|
||||
export class ReloadSessionPhase extends Phase {
|
||||
private systemDataStr: string | null;
|
||||
private systemDataStr?: string;
|
||||
|
||||
constructor(scene: BattleScene, systemDataStr?: string) {
|
||||
super(scene);
|
||||
|
||||
this.systemDataStr = systemDataStr ?? null;
|
||||
this.systemDataStr = systemDataStr;
|
||||
}
|
||||
|
||||
start(): void {
|
||||
|
@ -4,7 +4,7 @@ import { SwitchType } from "#enums/switch-type";
|
||||
import { SwitchSummonPhase } from "./switch-summon-phase";
|
||||
|
||||
export class ReturnPhase extends SwitchSummonPhase {
|
||||
constructor(scene: BattleScene, fieldIndex: integer) {
|
||||
constructor(scene: BattleScene, fieldIndex: number) {
|
||||
super(scene, SwitchType.SWITCH, fieldIndex, -1, true);
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ import i18next from "i18next";
|
||||
import { PokemonPhase } from "./pokemon-phase";
|
||||
|
||||
export class ScanIvsPhase extends PokemonPhase {
|
||||
private shownIvs: integer;
|
||||
private shownIvs: number;
|
||||
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex, shownIvs: integer) {
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex, shownIvs: number) {
|
||||
super(scene, battlerIndex);
|
||||
|
||||
this.shownIvs = shownIvs;
|
||||
|
@ -37,7 +37,7 @@ export class SelectBiomePhase extends BattlePhase {
|
||||
} else if (Array.isArray(biomeLinks[currentBiome])) {
|
||||
let biomes: Biome[] = [];
|
||||
this.scene.executeWithSeedOffset(() => {
|
||||
biomes = (biomeLinks[currentBiome] as (Biome | [Biome, integer])[])
|
||||
biomes = (biomeLinks[currentBiome] as (Biome | [Biome, number])[])
|
||||
.filter(b => !Array.isArray(b) || !Utils.randSeedInt(b[1]))
|
||||
.map(b => !Array.isArray(b) ? b : b[0]);
|
||||
}, this.scene.currentBattle.waveIndex);
|
||||
@ -46,7 +46,7 @@ export class SelectBiomePhase extends BattlePhase {
|
||||
this.scene.executeWithSeedOffset(() => {
|
||||
biomeChoices = (!Array.isArray(biomeLinks[currentBiome])
|
||||
? [ biomeLinks[currentBiome] as Biome ]
|
||||
: biomeLinks[currentBiome] as (Biome | [Biome, integer])[])
|
||||
: biomeLinks[currentBiome] as (Biome | [Biome, number])[])
|
||||
.filter((b, i) => !Array.isArray(b) || !Utils.randSeedInt(b[1]))
|
||||
.map(b => Array.isArray(b) ? b[0] : b);
|
||||
}, this.scene.currentBattle.waveIndex);
|
||||
|
@ -13,14 +13,14 @@ import { CustomModifierSettings } from "#app/modifier/modifier-type";
|
||||
import { isNullOrUndefined, NumberHolder } from "#app/utils";
|
||||
|
||||
export class SelectModifierPhase extends BattlePhase {
|
||||
private rerollCount: integer;
|
||||
private rerollCount: number;
|
||||
private modifierTiers?: ModifierTier[];
|
||||
private customModifierSettings?: CustomModifierSettings;
|
||||
private isCopy: boolean;
|
||||
|
||||
private typeOptions: ModifierTypeOption[];
|
||||
|
||||
constructor(scene: BattleScene, rerollCount: integer = 0, modifierTiers?: ModifierTier[], customModifierSettings?: CustomModifierSettings, isCopy: boolean = false) {
|
||||
constructor(scene: BattleScene, rerollCount: number = 0, modifierTiers?: ModifierTier[], customModifierSettings?: CustomModifierSettings, isCopy: boolean = false) {
|
||||
super(scene);
|
||||
|
||||
this.rerollCount = rerollCount;
|
||||
@ -42,7 +42,7 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
if (!this.isCopy) {
|
||||
regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount);
|
||||
}
|
||||
const modifierCount = new Utils.IntegerHolder(3);
|
||||
const modifierCount = new Utils.NumberHolder(3);
|
||||
if (this.isPlayer()) {
|
||||
this.scene.applyModifiers(ExtraModifierModifier, true, modifierCount);
|
||||
this.scene.applyModifiers(TempExtraModifierModifier, true, modifierCount);
|
||||
@ -63,7 +63,7 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
|
||||
this.typeOptions = this.getModifierTypeOptions(modifierCount.value);
|
||||
|
||||
const modifierSelectCallback = (rowCursor: integer, cursor: integer) => {
|
||||
const modifierSelectCallback = (rowCursor: number, cursor: number) => {
|
||||
if (rowCursor < 0 || cursor < 0) {
|
||||
this.scene.ui.showText(i18next.t("battle:skipItemQuestion"), null, () => {
|
||||
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
|
||||
@ -75,7 +75,7 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
return false;
|
||||
}
|
||||
let modifierType: ModifierType;
|
||||
let cost: integer;
|
||||
let cost: number;
|
||||
const rerollCost = this.getRerollCost(this.scene.lockModifierTiers);
|
||||
switch (rowCursor) {
|
||||
case 0:
|
||||
@ -98,7 +98,7 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: integer, itemIndex: integer, itemQuantity: integer, toSlotIndex: integer) => {
|
||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: number, itemIndex: number, itemQuantity: number, toSlotIndex: number) => {
|
||||
if (toSlotIndex !== undefined && fromSlotIndex < 6 && toSlotIndex < 6 && fromSlotIndex !== toSlotIndex && itemIndex > -1) {
|
||||
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||
&& m.isTransferable && m.pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
|
||||
@ -197,7 +197,7 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
|
||||
if (modifierType! instanceof PokemonModifierType) { //TODO: is the bang correct?
|
||||
if (modifierType instanceof FusePokemonModifierType) {
|
||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.SPLICE, -1, (fromSlotIndex: integer, spliceSlotIndex: integer) => {
|
||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.SPLICE, -1, (fromSlotIndex: number, spliceSlotIndex: number) => {
|
||||
if (spliceSlotIndex !== undefined && fromSlotIndex < 6 && spliceSlotIndex < 6 && fromSlotIndex !== spliceSlotIndex) {
|
||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => {
|
||||
const modifier = modifierType.newModifier(party[fromSlotIndex], party[spliceSlotIndex])!; //TODO: is the bang correct?
|
||||
@ -220,13 +220,13 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
const tmMoveId = isTmModifier
|
||||
? (modifierType as TmModifierType).moveId
|
||||
: undefined;
|
||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, partyUiMode, -1, (slotIndex: integer, option: PartyOption) => {
|
||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, partyUiMode, -1, (slotIndex: number, option: PartyOption) => {
|
||||
if (slotIndex < 6) {
|
||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => {
|
||||
const modifier = !isMoveModifier
|
||||
? !isRememberMoveModifier
|
||||
? modifierType.newModifier(party[slotIndex])
|
||||
: modifierType.newModifier(party[slotIndex], option as integer)
|
||||
: modifierType.newModifier(party[slotIndex], option as number)
|
||||
: modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1);
|
||||
applyModifier(modifier!, true); // TODO: is the bang correct?
|
||||
});
|
||||
@ -288,7 +288,7 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
return ModifierPoolType.PLAYER;
|
||||
}
|
||||
|
||||
getModifierTypeOptions(modifierCount: integer): ModifierTypeOption[] {
|
||||
getModifierTypeOptions(modifierCount: number): ModifierTypeOption[] {
|
||||
return getPlayerModifierTypeOptions(modifierCount, this.scene.getPlayerParty(), this.scene.lockModifierTiers ? this.modifierTiers : undefined, this.customModifierSettings);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ export class SelectStarterPhase extends Phase {
|
||||
|
||||
this.scene.ui.setMode(Mode.STARTER_SELECT, (starters: Starter[]) => {
|
||||
this.scene.ui.clearText();
|
||||
this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: integer) => {
|
||||
this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => {
|
||||
if (slotId === -1) {
|
||||
this.scene.clearPhaseQueue();
|
||||
this.scene.pushPhase(new TitlePhase(this.scene));
|
||||
@ -45,7 +45,7 @@ export class SelectStarterPhase extends Phase {
|
||||
initBattle(starters: Starter[]) {
|
||||
const party = this.scene.getPlayerParty();
|
||||
const loadPokemonAssets: Promise<void>[] = [];
|
||||
starters.forEach((starter: Starter, i: integer) => {
|
||||
starters.forEach((starter: Starter, i: number) => {
|
||||
if (!i && Overrides.STARTER_SPECIES_OVERRIDE) {
|
||||
starter.species = getPokemonSpecies(Overrides.STARTER_SPECIES_OVERRIDE as Species);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import i18next from "#app/plugins/i18n";
|
||||
import { allMoves } from "#app/data/move";
|
||||
|
||||
export class SelectTargetPhase extends PokemonPhase {
|
||||
constructor(scene: BattleScene, fieldIndex: integer) {
|
||||
constructor(scene: BattleScene, fieldIndex: number) {
|
||||
super(scene, fieldIndex);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-pha
|
||||
export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase {
|
||||
private expValue: number;
|
||||
|
||||
constructor(scene: BattleScene, partyMemberIndex: integer, expValue: number) {
|
||||
constructor(scene: BattleScene, partyMemberIndex: number, expValue: number) {
|
||||
super(scene, partyMemberIndex);
|
||||
|
||||
this.expValue = expValue;
|
||||
|
@ -16,14 +16,14 @@ export type StatStageChangeCallback = (target: Pokemon | null, changed: BattleSt
|
||||
export class StatStageChangePhase extends PokemonPhase {
|
||||
private stats: BattleStat[];
|
||||
private selfTarget: boolean;
|
||||
private stages: integer;
|
||||
private stages: number;
|
||||
private showMessage: boolean;
|
||||
private ignoreAbilities: boolean;
|
||||
private canBeCopied: boolean;
|
||||
private onChange: StatStageChangeCallback | null;
|
||||
|
||||
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex, selfTarget: boolean, stats: BattleStat[], stages: integer, showMessage: boolean = true, ignoreAbilities: boolean = false, canBeCopied: boolean = true, onChange: StatStageChangeCallback | null = null) {
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex, selfTarget: boolean, stats: BattleStat[], stages: number, showMessage: boolean = true, ignoreAbilities: boolean = false, canBeCopied: boolean = true, onChange: StatStageChangeCallback | null = null) {
|
||||
super(scene, battlerIndex);
|
||||
|
||||
this.selfTarget = selfTarget;
|
||||
@ -214,7 +214,7 @@ export class StatStageChangePhase extends PokemonPhase {
|
||||
}
|
||||
}
|
||||
|
||||
getStatStageChangeMessages(stats: BattleStat[], stages: integer, relStages: integer[]): string[] {
|
||||
getStatStageChangeMessages(stats: BattleStat[], stages: number, relStages: number[]): string[] {
|
||||
const messages: string[] = [];
|
||||
|
||||
const relStageStatIndexes = {};
|
||||
|
@ -4,7 +4,7 @@ import i18next from "i18next";
|
||||
import { SummonPhase } from "./summon-phase";
|
||||
|
||||
export class SummonMissingPhase extends SummonPhase {
|
||||
constructor(scene: BattleScene, fieldIndex: integer) {
|
||||
constructor(scene: BattleScene, fieldIndex: number) {
|
||||
super(scene, fieldIndex);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
|
||||
export class SummonPhase extends PartyMemberPokemonPhase {
|
||||
private loaded: boolean;
|
||||
|
||||
constructor(scene: BattleScene, fieldIndex: integer, player: boolean = true, loaded: boolean = false) {
|
||||
constructor(scene: BattleScene, fieldIndex: number, player: boolean = true, loaded: boolean = false) {
|
||||
super(scene, fieldIndex, player);
|
||||
|
||||
this.loaded = loaded;
|
||||
|
@ -10,7 +10,7 @@ import { SwitchSummonPhase } from "./switch-summon-phase";
|
||||
* for the player (if a switch would be valid for the current battle state).
|
||||
*/
|
||||
export class SwitchPhase extends BattlePhase {
|
||||
protected readonly fieldIndex: integer;
|
||||
protected readonly fieldIndex: number;
|
||||
private readonly switchType: SwitchType;
|
||||
private readonly isModal: boolean;
|
||||
private readonly doReturn: boolean;
|
||||
@ -25,7 +25,7 @@ export class SwitchPhase extends BattlePhase {
|
||||
* @param doReturn Indicates if the party member on the field should be
|
||||
* recalled to ball or has already left the field. Passed to {@linkcode SwitchSummonPhase}.
|
||||
*/
|
||||
constructor(scene: BattleScene, switchType: SwitchType, fieldIndex: integer, isModal: boolean, doReturn: boolean) {
|
||||
constructor(scene: BattleScene, switchType: SwitchType, fieldIndex: number, isModal: boolean, doReturn: boolean) {
|
||||
super(scene);
|
||||
|
||||
this.switchType = switchType;
|
||||
@ -61,7 +61,7 @@ export class SwitchPhase extends BattlePhase {
|
||||
// Override field index to 0 in case of double battle where 2/3 remaining legal party members fainted at once
|
||||
const fieldIndex = this.scene.currentBattle.getBattlerCount() === 1 || this.scene.getPokemonAllowedInBattle().length > 1 ? this.fieldIndex : 0;
|
||||
|
||||
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => {
|
||||
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: number, option: PartyOption) => {
|
||||
if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) {
|
||||
const switchType = (option === PartyOption.PASS_BATON) ? SwitchType.BATON_PASS : this.switchType;
|
||||
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, switchType, fieldIndex, slotIndex, this.doReturn));
|
||||
|
@ -16,7 +16,7 @@ import { SwitchType } from "#enums/switch-type";
|
||||
|
||||
export class SwitchSummonPhase extends SummonPhase {
|
||||
private readonly switchType: SwitchType;
|
||||
private readonly slotIndex: integer;
|
||||
private readonly slotIndex: number;
|
||||
private readonly doReturn: boolean;
|
||||
|
||||
private lastPokemon: Pokemon;
|
||||
@ -25,12 +25,12 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||
* Constructor for creating a new SwitchSummonPhase
|
||||
* @param scene {@linkcode BattleScene} the scene the phase is associated with
|
||||
* @param switchType the type of switch behavior
|
||||
* @param fieldIndex integer representing position on the battle field
|
||||
* @param slotIndex integer for the index of pokemon (in party of 6) to switch into
|
||||
* @param fieldIndex number representing position on the battle field
|
||||
* @param slotIndex number for the index of pokemon (in party of 6) to switch into
|
||||
* @param doReturn boolean whether to render "comeback" dialogue
|
||||
* @param player boolean if the switch is from the player
|
||||
*/
|
||||
constructor(scene: BattleScene, switchType: SwitchType, fieldIndex: integer, slotIndex: integer, doReturn: boolean, player?: boolean) {
|
||||
constructor(scene: BattleScene, switchType: SwitchType, fieldIndex: number, slotIndex: number, doReturn: boolean, player?: boolean) {
|
||||
super(scene, fieldIndex, player !== undefined ? player : true);
|
||||
|
||||
this.switchType = switchType;
|
||||
|
@ -1,8 +0,0 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { MessagePhase } from "./message-phase";
|
||||
|
||||
export class TestMessagePhase extends MessagePhase {
|
||||
constructor(scene: BattleScene, message: string) {
|
||||
super(scene, message, null, true);
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
import { loggedInUser } from "#app/account";
|
||||
import { BattleType } from "#app/battle";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { fetchDailyRunSeed, getDailyRunStarters } from "#app/data/daily-run";
|
||||
import { Gender } from "#app/data/gender";
|
||||
import { getBiomeKey } from "#app/field/arena";
|
||||
@ -24,16 +23,10 @@ import { SummonPhase } from "./summon-phase";
|
||||
|
||||
|
||||
export class TitlePhase extends Phase {
|
||||
private loaded: boolean;
|
||||
private loaded: boolean = false;
|
||||
private lastSessionData: SessionSaveData;
|
||||
public gameMode: GameModes;
|
||||
|
||||
constructor(scene: BattleScene) {
|
||||
super(scene);
|
||||
|
||||
this.loaded = false;
|
||||
}
|
||||
|
||||
start(): void {
|
||||
super.start();
|
||||
|
||||
@ -133,7 +126,7 @@ export class TitlePhase extends Phase {
|
||||
label: i18next.t("menu:loadGame"),
|
||||
handler: () => {
|
||||
this.scene.ui.setOverlayMode(Mode.SAVE_SLOT, SaveSlotUiMode.LOAD,
|
||||
(slotId: integer) => {
|
||||
(slotId: number) => {
|
||||
if (slotId === -1) {
|
||||
return this.showOptions();
|
||||
}
|
||||
@ -166,7 +159,7 @@ export class TitlePhase extends Phase {
|
||||
this.scene.ui.setMode(Mode.TITLE, config);
|
||||
}
|
||||
|
||||
loadSaveSlot(slotId: integer): void {
|
||||
loadSaveSlot(slotId: number): void {
|
||||
this.scene.sessionSlotId = slotId > -1 || !loggedInUser ? slotId : loggedInUser.lastSessionSlot;
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
this.scene.ui.resetModeChain();
|
||||
@ -184,7 +177,7 @@ export class TitlePhase extends Phase {
|
||||
}
|
||||
|
||||
initDailyRun(): void {
|
||||
this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: integer) => {
|
||||
this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => {
|
||||
this.scene.clearPhaseQueue();
|
||||
if (slotId === -1) {
|
||||
this.scene.pushPhase(new TitlePhase(this.scene));
|
||||
|
@ -1,41 +0,0 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { trainerConfigs } from "#app/data/trainer-config";
|
||||
import { TrainerType } from "#app/enums/trainer-type";
|
||||
import { BattlePhase } from "./battle-phase";
|
||||
import { TestMessagePhase } from "./test-message-phase";
|
||||
|
||||
export class TrainerMessageTestPhase extends BattlePhase {
|
||||
private trainerTypes: TrainerType[];
|
||||
|
||||
constructor(scene: BattleScene, ...trainerTypes: TrainerType[]) {
|
||||
super(scene);
|
||||
|
||||
this.trainerTypes = trainerTypes;
|
||||
}
|
||||
|
||||
start() {
|
||||
super.start();
|
||||
|
||||
const testMessages: string[] = [];
|
||||
|
||||
for (const t of Object.keys(trainerConfigs)) {
|
||||
const type = parseInt(t);
|
||||
if (this.trainerTypes.length && !this.trainerTypes.find(tt => tt === type as TrainerType)) {
|
||||
continue;
|
||||
}
|
||||
const config = trainerConfigs[type];
|
||||
[ config.encounterMessages, config.femaleEncounterMessages, config.victoryMessages, config.femaleVictoryMessages, config.defeatMessages, config.femaleDefeatMessages ]
|
||||
.map(messages => {
|
||||
if (messages?.length) {
|
||||
testMessages.push(...messages);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (const message of testMessages) {
|
||||
this.scene.pushPhase(new TestMessagePhase(this.scene, message));
|
||||
}
|
||||
|
||||
this.end();
|
||||
}
|
||||
}
|
@ -44,7 +44,6 @@ export class TurnInitPhase extends FieldPhase {
|
||||
}
|
||||
});
|
||||
|
||||
//this.scene.pushPhase(new MoveAnimTestPhase(this.scene));
|
||||
this.scene.eventTarget.dispatchEvent(new TurnInitEvent());
|
||||
|
||||
handleMysteryEncounterBattleStartEffects(this.scene);
|
||||
|
@ -99,8 +99,8 @@ export class TurnStartPhase extends FieldPhase {
|
||||
const bMove = allMoves[bCommand!.move!.move];
|
||||
|
||||
// The game now considers priority and applies the relevant move and ability attributes
|
||||
const aPriority = new Utils.IntegerHolder(aMove.priority);
|
||||
const bPriority = new Utils.IntegerHolder(bMove.priority);
|
||||
const aPriority = new Utils.NumberHolder(aMove.priority);
|
||||
const bPriority = new Utils.NumberHolder(bMove.priority);
|
||||
|
||||
applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, aMove, aPriority);
|
||||
applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, bMove, bPriority);
|
||||
|
@ -16,7 +16,7 @@ export class VictoryPhase extends PokemonPhase {
|
||||
/** If true, indicates that the phase is intended for EXP purposes only, and not to continue a battle to next phase */
|
||||
isExpOnly: boolean;
|
||||
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex | integer, isExpOnly: boolean = false) {
|
||||
constructor(scene: BattleScene, battlerIndex: BattlerIndex | number, isExpOnly: boolean = false) {
|
||||
super(scene, battlerIndex);
|
||||
|
||||
this.isExpOnly = isExpOnly;
|
||||
|
@ -21,8 +21,7 @@ export class WeatherEffectPhase extends CommonAnimPhase {
|
||||
this.weather = this.scene?.arena?.weather;
|
||||
|
||||
if (!this.weather) {
|
||||
this.end();
|
||||
return;
|
||||
return this.end();
|
||||
}
|
||||
|
||||
this.setAnimation(CommonAnim.SUNNY + (this.weather.weatherType - 1));
|
||||
@ -46,7 +45,7 @@ export class WeatherEffectPhase extends CommonAnimPhase {
|
||||
|
||||
const damage = Utils.toDmgValue(pokemon.getMaxHp() / 16);
|
||||
|
||||
this.scene.queueMessage(getWeatherDamageMessage(this.weather?.weatherType!, pokemon)!); // TODO: are those bangs correct?
|
||||
this.scene.queueMessage(getWeatherDamageMessage(this.weather!.weatherType, pokemon) ?? "");
|
||||
pokemon.damageAndUpdate(damage, HitResult.EFFECTIVE, false, false, true);
|
||||
};
|
||||
|
||||
@ -59,7 +58,7 @@ export class WeatherEffectPhase extends CommonAnimPhase {
|
||||
}
|
||||
}
|
||||
|
||||
this.scene.ui.showText(getWeatherLapseMessage(this.weather.weatherType)!, null, () => { // TODO: is this bang correct?
|
||||
this.scene.ui.showText(getWeatherLapseMessage(this.weather.weatherType) ?? "", null, () => {
|
||||
this.executeForAll((pokemon: Pokemon) => applyPostWeatherLapseAbAttrs(PostWeatherLapseAbAttr, pokemon, this.weather));
|
||||
|
||||
super.start();
|
||||
|
Loading…
Reference in New Issue
Block a user