- Adding throw ball and reset battle command.

- Adding throw ball and reset battle command.
This commit is contained in:
Burai Mu 2025-09-10 15:25:32 +08:00
parent 405dc89399
commit 7f02a04f0b
4 changed files with 57 additions and 0 deletions

View File

@ -271,6 +271,7 @@ export class BattleScene extends SceneBase {
public lastEnemyTrainer: Trainer | null; public lastEnemyTrainer: Trainer | null;
public currentBattle: Battle; public currentBattle: Battle;
public pokeballCounts: PokeballCounts; public pokeballCounts: PokeballCounts;
public lastPokeballType: PokeballType = PokeballType.POKEBALL;
public money: number; public money: number;
public pokemonInfoContainer: PokemonInfoContainer; public pokemonInfoContainer: PokemonInfoContainer;
private party: PlayerPokemon[]; private party: PlayerPokemon[];

View File

@ -56,6 +56,7 @@ export class AttemptCapturePhase extends PokemonPhase {
} }
globalScene.pokeballCounts[this.pokeballType]--; globalScene.pokeballCounts[this.pokeballType]--;
globalScene.lastUsedPokeball = this.pokeballType;
this.originalY = pokemon.y; this.originalY = pokemon.y;

View File

@ -13,6 +13,7 @@ import { SettingsDisplayUiHandler } from "#ui/settings-display-ui-handler";
import { SettingsGamepadUiHandler } from "#ui/settings-gamepad-ui-handler"; import { SettingsGamepadUiHandler } from "#ui/settings-gamepad-ui-handler";
import { SettingsKeyboardUiHandler } from "#ui/settings-keyboard-ui-handler"; import { SettingsKeyboardUiHandler } from "#ui/settings-keyboard-ui-handler";
import { SettingsUiHandler } from "#ui/settings-ui-handler"; import { SettingsUiHandler } from "#ui/settings-ui-handler";
import { CommandUiHandler } from "#ui/handlers/command-ui-handler";
import Phaser from "phaser"; import Phaser from "phaser";
type ActionKeys = Record<Button, () => void>; type ActionKeys = Record<Button, () => void>;
@ -213,6 +214,7 @@ export class UiInputs {
SettingsAudioUiHandler, SettingsAudioUiHandler,
SettingsGamepadUiHandler, SettingsGamepadUiHandler,
SettingsKeyboardUiHandler, SettingsKeyboardUiHandler,
CommandUiHandler
]; ];
const uiHandler = globalScene.ui?.getHandler(); const uiHandler = globalScene.ui?.getHandler();
if (whitelist.some(handler => uiHandler instanceof handler)) { if (whitelist.some(handler => uiHandler instanceof handler)) {

View File

@ -13,6 +13,7 @@ import { PartyUiHandler, PartyUiMode } from "#ui/handlers/party-ui-handler";
import { UiHandler } from "#ui/handlers/ui-handler"; import { UiHandler } from "#ui/handlers/ui-handler";
import { addTextObject } from "#ui/text"; import { addTextObject } from "#ui/text";
import i18next from "i18next"; import i18next from "i18next";
import { BattleType } from "../../enums/battle-type";
export class CommandUiHandler extends UiHandler { export class CommandUiHandler extends UiHandler {
private commandsContainer: Phaser.GameObjects.Container; private commandsContainer: Phaser.GameObjects.Container;
@ -187,6 +188,58 @@ export class CommandUiHandler extends UiHandler {
this.toggleTeraButton(); this.toggleTeraButton();
} }
break; break;
case Button.CYCLE_SHINY:
const commandPhase = globalScene.phaseManager.getCurrentPhase() as CommandPhase;
if (globalScene.pokeballCounts[globalScene.lastPokeballType]) {
if (commandPhase.handleCommand(Command.BALL, globalScene.lastPokeballType)) {
globalScene.ui.setMode(UiMode.COMMAND, commandPhase.getFieldIndex());
globalScene.ui.setMode(UiMode.MESSAGE);
success = true;
}
} else {
ui.playError();
}
break;
case Button.CYCLE_ABILITY:
globalScene.ui.setMode(UiMode.MESSAGE)
globalScene.ui.showText(i18next.t("battle:retryBattle"), null, () => {
globalScene.ui.setMode(
UiMode.CONFIRM,
() => {
globalScene.ui.fadeOut(1250).then(() => {
globalScene.reset();
globalScene.phaseManager.clearPhaseQueue();
globalScene.gameData.loadSession(globalScene.sessionSlotId).then(() => {
globalScene.phaseManager.pushNew("EncounterPhase", true);
const availablePartyMembers = globalScene.getPokemonAllowedInBattle().length;
globalScene.phaseManager.pushNew("SummonPhase", 0);
if (globalScene.currentBattle.double && availablePartyMembers > 1) {
globalScene.phaseManager.pushNew("SummonPhase", 1);
}
if (
globalScene.currentBattle.waveIndex > 1 &&
globalScene.currentBattle.battleType !== BattleType.TRAINER
) {
globalScene.phaseManager.pushNew("CheckSwitchPhase", 0, globalScene.currentBattle.double);
if (globalScene.currentBattle.double && availablePartyMembers > 1) {
globalScene.phaseManager.pushNew("CheckSwitchPhase", 1, globalScene.currentBattle.double);
}
}
globalScene.ui.fadeIn(1250);
globalScene.phaseManager.shiftPhase();
});
});
},
() => { globalScene.ui.setMode(UiMode.COMMAND)},
false,
0,
0,
1000,
);
});
break;
} }
} }