Update implementation of Pokeball and run commands
This commit is contained in:
parent
970d014bfd
commit
cc435284ec
|
@ -937,6 +937,15 @@ export class CommandPhase extends FieldPhase {
|
|||
start() {
|
||||
super.start();
|
||||
|
||||
if (this.fieldIndex) {
|
||||
const allyCommand = this.scene.currentBattle.turnCommands[this.fieldIndex - 1];
|
||||
if (allyCommand.command === Command.BALL || allyCommand.command === Command.RUN)
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex] = { command: allyCommand.command, skip: true };
|
||||
}
|
||||
|
||||
if (this.scene.currentBattle.turnCommands[this.fieldIndex]?.skip)
|
||||
return this.end();
|
||||
|
||||
const playerPokemon = this.scene.getPlayerField()[this.fieldIndex];
|
||||
|
||||
const moveQueue = playerPokemon.getMoveQueue();
|
||||
|
@ -1007,16 +1016,27 @@ export class CommandPhase extends FieldPhase {
|
|||
this.scene.ui.showText(null, 0);
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
}, null, true);
|
||||
} else if (cursor < 4) {
|
||||
} else {
|
||||
const targets = this.scene.getEnemyField().filter(p => p.isActive(true)).map(p => p.getBattlerIndex());
|
||||
if (targets.length > 1) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
this.scene.ui.showText(`You can only throw a Poké Ball\nwhen there is one Pokémon remaining!`, null, () => {
|
||||
this.scene.ui.showText(null, 0);
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
}, null, true);
|
||||
} else if (cursor < 4) {
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.BALL, cursor: cursor };
|
||||
this.scene.currentBattle.turnPokeballCounts[cursor as PokeballType]--;
|
||||
if (targets.length > 1)
|
||||
this.scene.unshiftPhase(new SelectTargetPhase(this.scene, this.fieldIndex));
|
||||
else
|
||||
else {
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex].targets = targets;
|
||||
if (this.fieldIndex)
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex - 1].skip = true;
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Command.POKEMON:
|
||||
case Command.RUN:
|
||||
|
@ -1039,6 +1059,8 @@ export class CommandPhase extends FieldPhase {
|
|||
? { command: Command.POKEMON, cursor: cursor, args: args }
|
||||
: { command: Command.RUN };
|
||||
success = true;
|
||||
if (this.fieldIndex)
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex - 1].skip = true;
|
||||
} else if (trapTag) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
|
@ -1059,9 +1081,6 @@ export class CommandPhase extends FieldPhase {
|
|||
|
||||
cancel() {
|
||||
if (this.fieldIndex) {
|
||||
const lastCommand = this.scene.currentBattle.turnCommands[0];
|
||||
if (lastCommand.command === Command.BALL)
|
||||
this.scene.currentBattle.turnPokeballCounts[lastCommand.cursor]++;
|
||||
this.scene.unshiftPhase(new CommandPhase(this.scene, 0));
|
||||
this.scene.unshiftPhase(new CommandPhase(this.scene, 1));
|
||||
this.end();
|
||||
|
@ -1117,12 +1136,12 @@ export class SelectTargetPhase extends PokemonPhase {
|
|||
this.scene.ui.setMode(Mode.TARGET_SELECT, this.fieldIndex, move, (cursor: integer) => {
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
if (cursor === -1) {
|
||||
if (turnCommand.command === Command.BALL)
|
||||
this.scene.currentBattle.turnPokeballCounts[turnCommand.cursor]++;
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex] = null;
|
||||
this.scene.unshiftPhase(new CommandPhase(this.scene, this.fieldIndex));
|
||||
} else
|
||||
turnCommand.targets = [ cursor ];
|
||||
if (this.scene.currentBattle.turnCommands[this.fieldIndex].command === Command.BALL && this.fieldIndex)
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex - 1].skip = true;
|
||||
this.end();
|
||||
});
|
||||
}
|
||||
|
@ -1169,6 +1188,9 @@ export class TurnStartPhase extends FieldPhase {
|
|||
const pokemon = field[o];
|
||||
const turnCommand = this.scene.currentBattle.turnCommands[o];
|
||||
|
||||
if (turnCommand.skip)
|
||||
continue;
|
||||
|
||||
switch (turnCommand.command) {
|
||||
case Command.FIGHT:
|
||||
const queuedMove = turnCommand.move;
|
||||
|
|
|
@ -24,6 +24,7 @@ export interface TurnCommand {
|
|||
cursor?: integer;
|
||||
move?: QueuedMove;
|
||||
targets?: BattlerIndex[];
|
||||
skip?: boolean;
|
||||
args?: any[];
|
||||
};
|
||||
|
||||
|
@ -42,7 +43,6 @@ export default class Battle {
|
|||
public started: boolean;
|
||||
public turn: integer;
|
||||
public turnCommands: TurnCommands;
|
||||
public turnPokeballCounts: PokeballCounts;
|
||||
public playerParticipantIds: Set<integer> = new Set<integer>();
|
||||
public escapeAttempts: integer = 0;
|
||||
public lastMove: Moves;
|
||||
|
@ -94,7 +94,6 @@ export default class Battle {
|
|||
incrementTurn(scene: BattleScene): void {
|
||||
this.turn++;
|
||||
this.turnCommands = Object.fromEntries(Utils.getEnumValues(BattlerIndex).map(bt => [ bt, null ]));
|
||||
this.turnPokeballCounts = Object.assign({}, scene.pokeballCounts);
|
||||
}
|
||||
|
||||
addParticipant(playerPokemon: PlayerPokemon): void {
|
||||
|
|
|
@ -60,13 +60,13 @@ export default class BallUiHandler extends UiHandler {
|
|||
|
||||
let success = false;
|
||||
|
||||
const pokeballTypeCount = Object.keys(this.scene.currentBattle.turnPokeballCounts).length;
|
||||
const pokeballTypeCount = Object.keys(this.scene.pokeballCounts).length;
|
||||
|
||||
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||
const commandPhase = this.scene.getCurrentPhase() as CommandPhase;
|
||||
success = true;
|
||||
if (button === Button.ACTION && this.cursor < pokeballTypeCount) {
|
||||
if (this.scene.currentBattle.turnPokeballCounts[this.cursor]) {
|
||||
if (this.scene.pokeballCounts[this.cursor]) {
|
||||
if (commandPhase.handleCommand(Command.BALL, this.cursor)) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, commandPhase.getFieldIndex());
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
|
@ -94,7 +94,7 @@ export default class BallUiHandler extends UiHandler {
|
|||
}
|
||||
|
||||
updateCounts() {
|
||||
this.countsText.setText(Object.values(this.scene.currentBattle.turnPokeballCounts).map(c => `x${c}`).join('\n'));
|
||||
this.countsText.setText(Object.values(this.scene.pokeballCounts).map(c => `x${c}`).join('\n'));
|
||||
}
|
||||
|
||||
setCursor(cursor: integer): boolean {
|
||||
|
|
Loading…
Reference in New Issue