Add command cancelling and 2nd battler move memory

pull/2/head
Flashfyre 2023-10-18 23:16:38 -04:00
parent 83c70889fc
commit eab6d082fd
4 changed files with 51 additions and 16 deletions

View File

@ -973,7 +973,7 @@ export class CommandPhase extends FieldPhase {
this.scene.ui.setMode(Mode.MESSAGE);
this.scene.ui.showText(`${move.getName()} is disabled!`, null, () => {
this.scene.ui.clearText();
this.scene.ui.setMode(Mode.FIGHT);
this.scene.ui.setMode(Mode.FIGHT, this.fieldIndex);
}, null, true);
}
}
@ -1044,6 +1044,21 @@ export class CommandPhase extends FieldPhase {
return success;
}
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();
}
}
getFieldIndex(): integer {
return this.fieldIndex;
}
getPokemon(): PlayerPokemon {
return this.scene.getPlayerField()[this.fieldIndex];
}

View File

@ -124,6 +124,7 @@ export abstract class PokemonSpeciesForm {
case Species.MELOETTA:
ret += this.getFormSpriteKey(formIndex).replace(/-/g, '');
break;
case Species.UNFEZANT:
case Species.FRILLISH:
case Species.JELLICENT:
ret += !female ? 'm' : 'f';

View File

@ -2,7 +2,7 @@ import { CommandPhase } from "../battle-phases";
import BattleScene, { Button } from "../battle-scene";
import { addTextObject, TextStyle } from "./text";
import PartyUiHandler, { PartyUiMode } from "./party-ui-handler";
import UI, { Mode } from "./ui";
import { Mode } from "./ui";
import UiHandler from "./uiHandler";
export enum Command {
@ -56,7 +56,7 @@ export default class CommandUiHandler extends UiHandler {
if (button === Button.ACTION) {
switch (this.cursor) {
case 0:
ui.setMode(Mode.FIGHT);
ui.setMode(Mode.FIGHT, (this.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
success = true;
break;
case 1:
@ -72,7 +72,8 @@ export default class CommandUiHandler extends UiHandler {
success = true;
break;
}
}
} else
(this.scene.getCurrentPhase() as CommandPhase).cancel();
} else {
switch (button) {
case Button.UP:

View File

@ -13,6 +13,9 @@ export default class FightUiHandler extends UiHandler {
private ppText: Phaser.GameObjects.Text;
private cursorObj: Phaser.GameObjects.Image;
protected fieldIndex: integer = 0;
protected cursor2: integer = 0;
constructor(scene: BattleScene) {
super(scene, Mode.FIGHT);
}
@ -36,9 +39,11 @@ export default class FightUiHandler extends UiHandler {
show(args: any[]) {
super.show(args);
this.fieldIndex = args.length ? args[0] as integer : 0;
const messageHandler = this.getUi().getMessageHandler();
messageHandler.bg.setTexture('bg_fight');
this.setCursor(this.cursor);
this.setCursor(this.getCursor());
this.displayMoves();
}
@ -47,9 +52,11 @@ export default class FightUiHandler extends UiHandler {
let success = false;
const cursor = this.getCursor();
if (button === Button.CANCEL || button === Button.ACTION) {
if (button === Button.ACTION) {
if ((this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, this.cursor, false))
if ((this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, cursor, false))
success = true;
else
ui.playError();
@ -60,20 +67,20 @@ export default class FightUiHandler extends UiHandler {
} else {
switch (button) {
case Button.UP:
if (this.cursor >= 2)
success = this.setCursor(this.cursor - 2);
if (cursor >= 2)
success = this.setCursor(cursor - 2);
break;
case Button.DOWN:
if (this.cursor < 2)
success = this.setCursor(this.cursor + 2);
if (cursor < 2)
success = this.setCursor(cursor + 2);
break;
case Button.LEFT:
if (this.cursor % 2 === 1)
success = this.setCursor(this.cursor - 1);
if (cursor % 2 === 1)
success = this.setCursor(cursor - 1);
break;
case Button.RIGHT:
if (this.cursor % 2 === 0)
success = this.setCursor(this.cursor + 1);
if (cursor % 2 === 0)
success = this.setCursor(cursor + 1);
break;
}
}
@ -82,9 +89,20 @@ export default class FightUiHandler extends UiHandler {
ui.playSelect();
}
getCursor(): integer {
return !this.fieldIndex ? this.cursor : this.cursor2;
}
setCursor(cursor: integer): boolean {
const ui = this.getUi();
const ret = super.setCursor(cursor);
const changed = this.getCursor() !== cursor;
if (changed) {
if (!this.fieldIndex)
this.cursor = cursor;
else
this.cursor2 = cursor;
}
if (!this.cursorObj) {
this.cursorObj = this.scene.add.image(0, 0, 'cursor');
@ -110,7 +128,7 @@ export default class FightUiHandler extends UiHandler {
this.cursorObj.setPosition(13 + (cursor % 2 === 1 ? 100 : 0), -31 + (cursor >= 2 ? 15 : 0));
return ret;
return changed;
}
displayMoves() {