mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 08:22:16 +02:00
Splitting up processing of transfer and move recall mode; ensuring that the cancel option works properly
This commit is contained in:
parent
f876dcf76d
commit
85b92bffed
@ -532,15 +532,16 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This will be largely changed with the modifier rework
|
// TODO: This will be largely changed with the modifier rework
|
||||||
processModifierTransferModeInput(button: Button) {
|
processModifierTransferModeInput(pokemon: PlayerPokemon) {
|
||||||
let success = false;
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
const option = this.options[this.optionsCursor];
|
const option = this.options[this.optionsCursor];
|
||||||
|
|
||||||
if (button === Button.ACTION) {
|
if (option === PartyOption.TRANSFER) {
|
||||||
const pokemon = globalScene.getPlayerParty()[this.cursor];
|
return this.processTransferOption();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Revise this condition
|
// TODO: Revise this condition
|
||||||
if (!this.transferMode && option !== PartyOption.CANCEL) {
|
if (!this.transferMode) {
|
||||||
this.startTransfer();
|
this.startTransfer();
|
||||||
|
|
||||||
let ableToTransferText: string;
|
let ableToTransferText: string;
|
||||||
@ -584,8 +585,13 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Might need a check here actually for when this.transferMode is active...
|
||||||
|
processModifierTransferModeLeftRightInput(button: Button) {
|
||||||
|
let success = false;
|
||||||
|
const option = this.options[this.optionsCursor];
|
||||||
if (button === Button.LEFT) {
|
if (button === Button.LEFT) {
|
||||||
/** Decrease quantity for the current item and update UI */
|
/** Decrease quantity for the current item and update UI */
|
||||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
@ -613,8 +619,14 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
); /** Place again the cursor at the same position. Necessary, otherwise the cursor disappears */
|
); /** Place again the cursor at the same position. Necessary, otherwise the cursor disappears */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Might need a check here actually for when this.transferMode is active...
|
||||||
|
processModifierTransferModeUpDownInput(button: Button.UP | Button.DOWN) {
|
||||||
|
let success = false;
|
||||||
|
const option = this.options[this.optionsCursor];
|
||||||
|
|
||||||
if (button === Button.UP || button === Button.DOWN) {
|
|
||||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
if (option !== PartyOption.ALL) {
|
if (option !== PartyOption.ALL) {
|
||||||
this.transferQuantities[option] = this.transferQuantitiesMax[option];
|
this.transferQuantities[option] = this.transferQuantitiesMax[option];
|
||||||
@ -622,7 +634,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
this.updateOptions();
|
this.updateOptions();
|
||||||
}
|
}
|
||||||
success = this.moveOptionCursor(button);
|
success = this.moveOptionCursor(button);
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -634,14 +645,10 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
return this.setCursor(this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0);
|
return this.setCursor(this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
processRememberMoveModeInput(button: Button) {
|
processRememberMoveModeInput(pokemon: PlayerPokemon) {
|
||||||
let success = false;
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
const option = this.options[this.optionsCursor];
|
const option = this.options[this.optionsCursor];
|
||||||
|
|
||||||
if (button === Button.ACTION) {
|
|
||||||
const pokemon = globalScene.getPlayerParty()[this.cursor];
|
|
||||||
if (option !== PartyOption.CANCEL) {
|
|
||||||
// clear overlay on cancel
|
// clear overlay on cancel
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
const filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon);
|
const filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon);
|
||||||
@ -655,9 +662,10 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (button === Button.UP || button === Button.DOWN) {
|
processRememberMoveModeUpDownInput(button: Button.UP | Button.DOWN) {
|
||||||
|
let success = false;
|
||||||
|
|
||||||
success = this.moveOptionCursor(button);
|
success = this.moveOptionCursor(button);
|
||||||
|
|
||||||
// show move description
|
// show move description
|
||||||
@ -670,7 +678,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
// or hide the overlay, in case it's the cancel button
|
// or hide the overlay, in case it's the cancel button
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -703,39 +710,35 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processOptionMenuInput(button: Button) {
|
processOptionMenuInput(button: Button) {
|
||||||
let success = false;
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
const option = this.options[this.optionsCursor];
|
const option = this.options[this.optionsCursor];
|
||||||
|
|
||||||
// Button.CANCEL has no special behavior for any option
|
// Button.CANCEL has no special behavior for any option
|
||||||
if (button === Button.CANCEL || option === PartyOption.CANCEL) {
|
if (button === Button.CANCEL) {
|
||||||
this.clearOptions();
|
this.clearOptions();
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(PartyUiMode[this.partyUiMode]);
|
if (button === Button.ACTION) {
|
||||||
console.log(PartyOption[option]);
|
if (option === PartyOption.CANCEL) {
|
||||||
console.log(this.selectCallback);
|
return this.processOptionMenuInput(Button.CANCEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the input has been already processed we are done, otherwise move on until the correct option is found
|
||||||
|
const pokemon = globalScene.getPlayerParty()[this.cursor];
|
||||||
|
|
||||||
// TODO: Careful about using success for the return values here. Find a better way
|
// TODO: Careful about using success for the return values here. Find a better way
|
||||||
// PartyOption.ALL, and options specific to the mode (held items)
|
// PartyOption.ALL, and options specific to the mode (held items)
|
||||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
success = this.processModifierTransferModeInput(button);
|
return this.processModifierTransferModeInput(pokemon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// options specific to the mode (moves)
|
// options specific to the mode (moves)
|
||||||
if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) {
|
if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) {
|
||||||
success = this.processRememberMoveModeInput(button);
|
return this.processRememberMoveModeInput(pokemon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the input has been already processed we are done, otherwise move on until the correct option is found
|
|
||||||
if (success) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (button === Button.ACTION) {
|
|
||||||
const pokemon = globalScene.getPlayerParty()[this.cursor];
|
|
||||||
|
|
||||||
// These are the options that do not involve a callback
|
// These are the options that do not involve a callback
|
||||||
if (option === PartyOption.SUMMARY) {
|
if (option === PartyOption.SUMMARY) {
|
||||||
return this.processSummaryOption(pokemon);
|
return this.processSummaryOption(pokemon);
|
||||||
@ -786,10 +789,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
// PartyUiMode.POST_BATTLE_SWITCH (SEND_OUT)
|
// PartyUiMode.POST_BATTLE_SWITCH (SEND_OUT)
|
||||||
|
|
||||||
// These are the options that need a callback
|
// These are the options that need a callback
|
||||||
if (option === PartyOption.TRANSFER) {
|
|
||||||
return this.processTransferOption();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (option === PartyOption.RELEASE) {
|
if (option === PartyOption.RELEASE) {
|
||||||
return this.processReleaseOption(pokemon);
|
return this.processReleaseOption(pokemon);
|
||||||
}
|
}
|
||||||
@ -857,10 +856,24 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (button === Button.UP || button === Button.DOWN) {
|
if (button === Button.UP || button === Button.DOWN) {
|
||||||
success = this.moveOptionCursor(button);
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
|
return this.processModifierTransferModeUpDownInput(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) {
|
||||||
|
return this.processRememberMoveModeUpDownInput(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.moveOptionCursor(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button === Button.LEFT || button === Button.RIGHT) {
|
||||||
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
|
return this.processModifierTransferModeLeftRightInput(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
processInput(button: Button): boolean {
|
processInput(button: Button): boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user