mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-29 18:26:09 +00:00
Add command cancelling and 2nd battler move memory
This commit is contained in:
parent
83c70889fc
commit
eab6d082fd
@ -973,7 +973,7 @@ export class CommandPhase extends FieldPhase {
|
|||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
this.scene.ui.showText(`${move.getName()} is disabled!`, null, () => {
|
this.scene.ui.showText(`${move.getName()} is disabled!`, null, () => {
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
this.scene.ui.setMode(Mode.FIGHT);
|
this.scene.ui.setMode(Mode.FIGHT, this.fieldIndex);
|
||||||
}, null, true);
|
}, null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1044,6 +1044,21 @@ export class CommandPhase extends FieldPhase {
|
|||||||
return success;
|
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 {
|
getPokemon(): PlayerPokemon {
|
||||||
return this.scene.getPlayerField()[this.fieldIndex];
|
return this.scene.getPlayerField()[this.fieldIndex];
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
case Species.MELOETTA:
|
case Species.MELOETTA:
|
||||||
ret += this.getFormSpriteKey(formIndex).replace(/-/g, '');
|
ret += this.getFormSpriteKey(formIndex).replace(/-/g, '');
|
||||||
break;
|
break;
|
||||||
|
case Species.UNFEZANT:
|
||||||
case Species.FRILLISH:
|
case Species.FRILLISH:
|
||||||
case Species.JELLICENT:
|
case Species.JELLICENT:
|
||||||
ret += !female ? 'm' : 'f';
|
ret += !female ? 'm' : 'f';
|
||||||
|
@ -2,7 +2,7 @@ import { CommandPhase } from "../battle-phases";
|
|||||||
import BattleScene, { Button } from "../battle-scene";
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
import { addTextObject, TextStyle } from "./text";
|
import { addTextObject, TextStyle } from "./text";
|
||||||
import PartyUiHandler, { PartyUiMode } from "./party-ui-handler";
|
import PartyUiHandler, { PartyUiMode } from "./party-ui-handler";
|
||||||
import UI, { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
import UiHandler from "./uiHandler";
|
import UiHandler from "./uiHandler";
|
||||||
|
|
||||||
export enum Command {
|
export enum Command {
|
||||||
@ -56,7 +56,7 @@ export default class CommandUiHandler extends UiHandler {
|
|||||||
if (button === Button.ACTION) {
|
if (button === Button.ACTION) {
|
||||||
switch (this.cursor) {
|
switch (this.cursor) {
|
||||||
case 0:
|
case 0:
|
||||||
ui.setMode(Mode.FIGHT);
|
ui.setMode(Mode.FIGHT, (this.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@ -72,7 +72,8 @@ export default class CommandUiHandler extends UiHandler {
|
|||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
(this.scene.getCurrentPhase() as CommandPhase).cancel();
|
||||||
} else {
|
} else {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case Button.UP:
|
case Button.UP:
|
||||||
|
@ -13,6 +13,9 @@ export default class FightUiHandler extends UiHandler {
|
|||||||
private ppText: Phaser.GameObjects.Text;
|
private ppText: Phaser.GameObjects.Text;
|
||||||
private cursorObj: Phaser.GameObjects.Image;
|
private cursorObj: Phaser.GameObjects.Image;
|
||||||
|
|
||||||
|
protected fieldIndex: integer = 0;
|
||||||
|
protected cursor2: integer = 0;
|
||||||
|
|
||||||
constructor(scene: BattleScene) {
|
constructor(scene: BattleScene) {
|
||||||
super(scene, Mode.FIGHT);
|
super(scene, Mode.FIGHT);
|
||||||
}
|
}
|
||||||
@ -36,9 +39,11 @@ export default class FightUiHandler extends UiHandler {
|
|||||||
show(args: any[]) {
|
show(args: any[]) {
|
||||||
super.show(args);
|
super.show(args);
|
||||||
|
|
||||||
|
this.fieldIndex = args.length ? args[0] as integer : 0;
|
||||||
|
|
||||||
const messageHandler = this.getUi().getMessageHandler();
|
const messageHandler = this.getUi().getMessageHandler();
|
||||||
messageHandler.bg.setTexture('bg_fight');
|
messageHandler.bg.setTexture('bg_fight');
|
||||||
this.setCursor(this.cursor);
|
this.setCursor(this.getCursor());
|
||||||
this.displayMoves();
|
this.displayMoves();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,9 +52,11 @@ export default class FightUiHandler extends UiHandler {
|
|||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
|
const cursor = this.getCursor();
|
||||||
|
|
||||||
if (button === Button.CANCEL || button === Button.ACTION) {
|
if (button === Button.CANCEL || button === Button.ACTION) {
|
||||||
if (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;
|
success = true;
|
||||||
else
|
else
|
||||||
ui.playError();
|
ui.playError();
|
||||||
@ -60,20 +67,20 @@ export default class FightUiHandler extends UiHandler {
|
|||||||
} else {
|
} else {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case Button.UP:
|
case Button.UP:
|
||||||
if (this.cursor >= 2)
|
if (cursor >= 2)
|
||||||
success = this.setCursor(this.cursor - 2);
|
success = this.setCursor(cursor - 2);
|
||||||
break;
|
break;
|
||||||
case Button.DOWN:
|
case Button.DOWN:
|
||||||
if (this.cursor < 2)
|
if (cursor < 2)
|
||||||
success = this.setCursor(this.cursor + 2);
|
success = this.setCursor(cursor + 2);
|
||||||
break;
|
break;
|
||||||
case Button.LEFT:
|
case Button.LEFT:
|
||||||
if (this.cursor % 2 === 1)
|
if (cursor % 2 === 1)
|
||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(cursor - 1);
|
||||||
break;
|
break;
|
||||||
case Button.RIGHT:
|
case Button.RIGHT:
|
||||||
if (this.cursor % 2 === 0)
|
if (cursor % 2 === 0)
|
||||||
success = this.setCursor(this.cursor + 1);
|
success = this.setCursor(cursor + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,9 +89,20 @@ export default class FightUiHandler extends UiHandler {
|
|||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCursor(): integer {
|
||||||
|
return !this.fieldIndex ? this.cursor : this.cursor2;
|
||||||
|
}
|
||||||
|
|
||||||
setCursor(cursor: integer): boolean {
|
setCursor(cursor: integer): boolean {
|
||||||
const ui = this.getUi();
|
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) {
|
if (!this.cursorObj) {
|
||||||
this.cursorObj = this.scene.add.image(0, 0, 'cursor');
|
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));
|
this.cursorObj.setPosition(13 + (cursor % 2 === 1 ? 100 : 0), -31 + (cursor >= 2 ? 15 : 0));
|
||||||
|
|
||||||
return ret;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayMoves() {
|
displayMoves() {
|
||||||
|
Loading…
Reference in New Issue
Block a user