mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-29 10:16:14 +00:00
Not sure if I'm happy, but it's over...
This commit is contained in:
parent
618dfbd324
commit
8e6688daef
@ -2632,10 +2632,9 @@ export default class BattleScene extends SceneBase {
|
||||
});
|
||||
}
|
||||
|
||||
removePartyMemberModifiers(partyMemberIndex: integer): Promise<void> {
|
||||
removePartyMemberModifiers(partyMemberId: integer): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
const pokemonId = this.getPlayerParty()[partyMemberIndex].id;
|
||||
const modifiersToRemove = this.modifiers.filter(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === pokemonId);
|
||||
const modifiersToRemove = this.modifiers.filter(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === partyMemberId);
|
||||
for (const m of modifiersToRemove) {
|
||||
this.modifiers.splice(this.modifiers.indexOf(m), 1);
|
||||
}
|
||||
|
@ -5110,7 +5110,7 @@ export class EnemyPokemon extends Pokemon {
|
||||
* @param slotIndex an optional index to place the pokemon in the party
|
||||
* @returns the pokemon that was added or null if the pokemon could not be added
|
||||
*/
|
||||
addToParty(pokeballType: PokeballType, slotIndex: number = -1) {
|
||||
addToParty(pokeballType: PokeballType, slotIndex: number = -1, pokemonReplaced?: number | null) {
|
||||
const party = this.scene.getPlayerParty();
|
||||
let ret: PlayerPokemon | null = null;
|
||||
|
||||
@ -5126,6 +5126,15 @@ export class EnemyPokemon extends Pokemon {
|
||||
if (slotIndex === 0) {
|
||||
newPokemon.setVisible(false); // Hide if replaced with first pokemon
|
||||
}
|
||||
|
||||
if (pokemonReplaced && newPokemon.isAllowedInBattle()) {
|
||||
const modifiersToTransfer = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemonReplaced, true) as PokemonHeldItemModifier[];
|
||||
const transferResults: Promise<boolean>[] = [];
|
||||
for (const modifier of modifiersToTransfer) {
|
||||
transferResults.push(this.scene.tryTransferHeldItemModifier(modifier, newPokemon, false, modifier.getStackCount(), true, true));
|
||||
}
|
||||
Promise.allSettled(transferResults).then(() => newPokemon.scene.removePartyMemberModifiers(pokemonReplaced));
|
||||
}
|
||||
party.splice(slotIndex, 0, newPokemon);
|
||||
} else {
|
||||
party.push(newPokemon);
|
||||
|
@ -233,8 +233,8 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
this.scene.clearEnemyHeldItemModifiers();
|
||||
this.scene.field.remove(pokemon, true);
|
||||
};
|
||||
const addToParty = (slotIndex?: number) => {
|
||||
const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex);
|
||||
const addToParty = (slotIndex?: number, releasedPokemon?: number) => {
|
||||
const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex, releasedPokemon);
|
||||
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false);
|
||||
if (this.scene.getPlayerParty().filter(p => p.isShiny()).length === PLAYER_PARTY_MAX_SIZE) {
|
||||
this.scene.validateAchv(achvs.SHINY_PARTY);
|
||||
@ -262,15 +262,15 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
});
|
||||
}, false);
|
||||
}, () => {
|
||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => {
|
||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: number, _option: PartyOption, releasedPokemon: number) => {
|
||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
||||
if (slotIndex < 6) {
|
||||
addToParty(slotIndex);
|
||||
addToParty(slotIndex, releasedPokemon);
|
||||
} else {
|
||||
promptRelease();
|
||||
}
|
||||
});
|
||||
});
|
||||
}, );
|
||||
}, () => {
|
||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
||||
removePokemon();
|
||||
|
@ -51,8 +51,6 @@ describe("Moves - Dragon Rage", () => {
|
||||
partyPokemon = game.scene.getPlayerParty()[0];
|
||||
enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
// remove berries
|
||||
game.scene.removePartyMemberModifiers(0);
|
||||
game.scene.clearEnemyHeldItemModifiers();
|
||||
});
|
||||
|
||||
|
@ -46,8 +46,6 @@ describe("Moves - Fissure", () => {
|
||||
partyPokemon = game.scene.getPlayerParty()[0];
|
||||
enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
// remove berries
|
||||
game.scene.removePartyMemberModifiers(0);
|
||||
game.scene.clearEnemyHeldItemModifiers();
|
||||
});
|
||||
|
||||
|
@ -123,7 +123,7 @@ export enum PartyOption {
|
||||
ALL = 4000,
|
||||
}
|
||||
|
||||
export type PartySelectCallback = (cursor: integer, option: PartyOption) => void;
|
||||
export type PartySelectCallback = (cursor: integer, option: PartyOption, args?: any | undefined) => void;
|
||||
export type PartyModifierTransferSelectCallback = (fromCursor: integer, index: integer, itemQuantity?: integer, toCursor?: integer) => void;
|
||||
export type PartyModifierSpliceSelectCallback = (fromCursor: integer, toCursor?: integer) => void;
|
||||
export type PokemonSelectFilter = (pokemon: PlayerPokemon) => string | null;
|
||||
@ -1061,9 +1061,11 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
doRelease(slotIndex: integer): void {
|
||||
this.showText(this.getReleaseMessage(getPokemonNameWithAffix(this.scene.getPlayerParty()[slotIndex])), null, () => {
|
||||
this.clearPartySlots();
|
||||
this.scene.removePartyMemberModifiers(slotIndex);
|
||||
const releasedPokemon = this.scene.getPlayerParty().splice(slotIndex, 1)[0];
|
||||
releasedPokemon.destroy();
|
||||
let releasedId: number = 0;
|
||||
if (releasedPokemon.isAllowedInBattle()) {
|
||||
releasedId = releasedPokemon.id;
|
||||
}
|
||||
this.populatePartySlots();
|
||||
if (this.cursor >= this.scene.getPlayerParty().length) {
|
||||
this.setCursor(this.cursor - 1);
|
||||
@ -1071,8 +1073,9 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
if (this.partyUiMode === PartyUiMode.RELEASE) {
|
||||
const selectCallback = this.selectCallback;
|
||||
this.selectCallback = null;
|
||||
selectCallback && selectCallback(this.cursor, PartyOption.RELEASE);
|
||||
selectCallback && selectCallback(this.cursor, PartyOption.RELEASE, releasedId);
|
||||
}
|
||||
releasedPokemon.destroy();
|
||||
this.showText("", 0);
|
||||
}, null, true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user