mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-17 22:02:18 +02:00
Item transfer on release to newly acquired Pokemon
This commit is contained in:
parent
fe873c64ec
commit
f647b3c415
@ -4304,7 +4304,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
this.scene.clearEnemyHeldItemModifiers();
|
||||
this.scene.field.remove(pokemon, true);
|
||||
};
|
||||
const addToParty = () => {
|
||||
const addToParty = (modifiersFromReleasedPokemon?: PokemonHeldItemModifier[]) => {
|
||||
const newPokemon = pokemon.addToParty(this.pokeballType);
|
||||
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false);
|
||||
if (this.scene.getParty().filter(p => p.isShiny()).length === 6)
|
||||
@ -4312,8 +4312,10 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
Promise.all(modifiers.map(m => this.scene.addModifier(m, true))).then(() => {
|
||||
this.scene.updateModifiers(true);
|
||||
removePokemon();
|
||||
if (newPokemon)
|
||||
if (newPokemon) {
|
||||
modifiersFromReleasedPokemon?.forEach(m => this.scene.tryTransferHeldItemModifier(m, newPokemon, true, false));
|
||||
newPokemon.loadAssets().then(end);
|
||||
}
|
||||
else
|
||||
end();
|
||||
});
|
||||
@ -4323,10 +4325,11 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
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, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => {
|
||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (releasedPokemonSlotIndex: integer, _option: PartyOption) => {
|
||||
const releasedItems = this.scene.getParty()[releasedPokemonSlotIndex].getTransferrableHeldItems();
|
||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
||||
if (slotIndex < 6)
|
||||
addToParty();
|
||||
if (releasedPokemonSlotIndex < 6)
|
||||
addToParty(releasedItems);
|
||||
else
|
||||
promptRelease();
|
||||
});
|
||||
|
@ -727,28 +727,25 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
|
||||
doRelease(slotIndex: integer): void {
|
||||
this.showText(this.getReleaseMessage(this.scene.getParty()[slotIndex].name), null, () => {
|
||||
|
||||
if (this.partyUiMode === PartyUiMode.RELEASE) {
|
||||
const selectCallback = this.selectCallback;
|
||||
this.selectCallback = null;
|
||||
selectCallback(this.cursor, PartyOption.RELEASE);
|
||||
}
|
||||
|
||||
this.clearPartySlots();
|
||||
this.scene.removePartyMemberModifiers(slotIndex);
|
||||
const releasedPokemon = this.scene.getParty().splice(slotIndex, 1)[0];
|
||||
const releasedItems = releasedPokemon.getTransferrableHeldItems();
|
||||
|
||||
releasedPokemon.destroy();
|
||||
this.populatePartySlots();
|
||||
|
||||
if (this.cursor >= this.scene.getParty().length)
|
||||
this.setCursor(this.cursor - 1);
|
||||
if (this.partyUiMode === PartyUiMode.RELEASE) {
|
||||
const selectCallback = this.selectCallback;
|
||||
this.selectCallback = null;
|
||||
selectCallback(this.cursor, PartyOption.RELEASE);
|
||||
if (releasedItems && releasedItems.length > 0) {
|
||||
const newPokemon = this.scene.getParty()[this.scene.getParty().length - 1];
|
||||
releasedItems.forEach(i => this.scene.tryTransferHeldItemModifier(i, newPokemon, true, false));
|
||||
this.showText("Items were transferred beep boop");
|
||||
}
|
||||
}
|
||||
|
||||
this.showText(null, 0);
|
||||
|
||||
}, null, true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user