Add release option on full party

This commit is contained in:
Flashfyre 2023-04-11 01:31:18 -04:00
parent 525cf41b5e
commit 53ab693bad
3 changed files with 74 additions and 16 deletions

View File

@ -1047,7 +1047,7 @@ export class AttemptCapturePhase extends BattlePhase {
this.scene.sound.play('pb_move');
else {
shakeCounter.stop();
this.release(shakeCount);
this.failCatch(shakeCount);
}
} else
this.scene.sound.play('pb_lock')
@ -1065,7 +1065,7 @@ export class AttemptCapturePhase extends BattlePhase {
});
}
release(shakeCount: integer) {
failCatch(shakeCount: integer) {
const pokemon = this.scene.getEnemyPokemon();
this.scene.sound.play('pb_rel');
@ -1091,7 +1091,6 @@ export class AttemptCapturePhase extends BattlePhase {
}
catch() {
console.log(this, 'catch')
const pokemon = this.scene.getEnemyPokemon();
this.scene.unshiftPhase(new VictoryPhase(this.scene));
this.scene.ui.showText(`${pokemon.name} was caught!`, null, () => {
@ -1100,12 +1099,37 @@ export class AttemptCapturePhase extends BattlePhase {
this.removePb();
this.end();
};
const newPokemon = pokemon.addToParty();
this.scene.field.remove(pokemon, true);
if (newPokemon)
newPokemon.loadAssets().then(end);
else
end();
const addToParty = () => {
const newPokemon = pokemon.addToParty();
pokemon.hp = 0;
this.scene.field.remove(pokemon, true);
if (newPokemon)
newPokemon.loadAssets().then(end);
else
end();
};
if (this.scene.getParty().length === 6) {
const promptRelease = () => {
this.scene.ui.showText(`Your party is full.\nRelease a POKéMON to make room for ${pokemon.name}?`, null, () => {
this.scene.ui.setMode(Mode.CONFIRM, () => {
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, (slotIndex: integer) => {
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
if (slotIndex < 6) {
this.scene.getParty().splice(slotIndex, 1);
addToParty();
} else
promptRelease();
});
});
}, () => {
pokemon.hp = 0;
end();
});
});
};
promptRelease();
} else
addToParty();
}, 0, true);
}

View File

@ -792,7 +792,6 @@ export class EnemyPokemon extends Pokemon {
party.push(newPokemon);
ret = newPokemon;
}
this.hp = 0;
return ret;
}

View File

@ -5,6 +5,7 @@ import { addTextObject, TextStyle } from "../text";
import { Command } from "./command-ui-handler";
import MessageUiHandler from "./message-ui-handler";
import { Mode } from "./ui";
import * as Utils from "../utils";
const defaultMessage = 'Choose a Pokémon.';
@ -12,7 +13,8 @@ export enum PartyUiMode {
SWITCH,
FAINT_SWITCH,
POST_BATTLE_SWITCH,
MODIFIER
MODIFIER,
RELEASE
}
export enum PartyOption {
@ -20,6 +22,7 @@ export enum PartyOption {
SEND_OUT,
APPLY,
SUMMARY,
RELEASE,
CANCEL
}
@ -147,14 +150,23 @@ export default class PartyUiHandler extends MessageUiHandler {
if (this.optionsMode) {
if (button === Button.ACTION) {
const option = this.options[this.optionsCursor];
if (option === PartyOption.SHIFT || option === PartyOption.SEND_OUT || option === PartyOption.APPLY) {
let filterResult: string = this.selectFilter(this.scene.getParty()[this.cursor]);
const pokemon = this.scene.getParty()[this.cursor];
if (option === PartyOption.SHIFT || option === PartyOption.SEND_OUT || option === PartyOption.APPLY || option === PartyOption.RELEASE) {
let filterResult: string = this.selectFilter(pokemon);
if (filterResult === null) {
this.clearOptions();
if (this.selectCallback) {
const selectCallback = this.selectCallback;
this.selectCallback = null;
selectCallback(this.cursor);
if (option === PartyOption.RELEASE) {
this.partyMessageBox.setTexture('party_message');
this.showText(this.getReleaseMessage(pokemon.name), null, () => {
this.selectCallback = null;
selectCallback(this.cursor);
}, null, true);
} else {
this.selectCallback = null;
selectCallback(this.cursor);
}
} else if (this.cursor)
(this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor);
if (this.partyUiMode !== PartyUiMode.MODIFIER)
@ -172,7 +184,7 @@ export default class PartyUiHandler extends MessageUiHandler {
}
} else if (option === PartyOption.SUMMARY) {
ui.playSelect();
ui.setModeWithoutClear(Mode.SUMMARY, this.scene.getParty()[this.cursor]).then(() => this.clearOptions());
ui.setModeWithoutClear(Mode.SUMMARY, pokemon).then(() => this.clearOptions());
} else if (option === PartyOption.CANCEL)
this.processInput(Button.CANCEL);
} else if (button === Button.CANCEL) {
@ -314,6 +326,9 @@ export default class PartyUiHandler extends MessageUiHandler {
case PartyUiMode.MODIFIER:
this.options.push(PartyOption.APPLY);
break;
case PartyUiMode.RELEASE:
this.options.push(PartyOption.RELEASE);
break;
}
this.options.push(PartyOption.SUMMARY, PartyOption.CANCEL);
@ -337,6 +352,26 @@ export default class PartyUiHandler extends MessageUiHandler {
this.setCursor(0);
}
getReleaseMessage(pokemonName: string): string {
const rand = Utils.randInt(128);
if (rand < 32)
return `Goodbye, ${pokemonName}!`;
else if (rand < 64)
return `Farewell, ${pokemonName}!`;
else if (rand < 96)
return `This is where we part, ${pokemonName}!`;
else if (rand < 108)
return `I'll miss you, ${pokemonName}!`;
else if (rand < 116)
return `I'll never forget you, ${pokemonName}!`;
else if (rand < 124)
return `Until we meet again, ${pokemonName}!`;
else if (rand < 127)
return `Sayonara, ${pokemonName}!`
else
return `Smell ya later, ${pokemonName}!`;
}
clearOptions() {
this.optionsMode = false;
this.options.splice(0, this.options.length);