[Refactor] Clean up various methods in battle-scene.ts and pokemon.ts (#4412)

* Update `battle-scene.ts` and `data/field/pokemon.ts`

`battle-scene.ts` changes:
- `getParty()` renamed to `getPlayerParty()` for clarity
- `getNonSwitchedXPokemon()` consolidated into `getXPokemon()`
- Some tsdocs were added/updated for
`getXParty()`, `getXField()` and `getXPokemon()`;
and those functions were explicitly marked as `public`
- Helper function `getPokemonAllowedInBattle()` added

`pokemon.ts` changes:
- `isAllowed()` renamed to `isAllowedInChallenge()` for clarity
- A redundant check for an active scene is removed in `isActive()`
- Some tsdocs were added/updated for `isFainted()`,
`isAllowedInChallenge()`, `isAllowedInBattle()` and `isActive()`;
and those functions were explicitly marked as `public`
- `isFainted()` now checks for `hp <= 0` instead of `!hp`

Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>

* Backport eslint change to reduce merge conflicts

* Fix merge issues

---------

Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com>
This commit is contained in:
NightKev 2024-11-03 18:53:52 -08:00 committed by GitHub
parent 87b7122b60
commit af473ba4ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
127 changed files with 833 additions and 882 deletions

View File

@ -764,57 +764,65 @@ export default class BattleScene extends SceneBase {
return true; return true;
} }
getParty(): PlayerPokemon[] { public getPlayerParty(): PlayerPokemon[] {
return this.party; return this.party;
} }
getPlayerPokemon(): PlayerPokemon | undefined {
return this.getPlayerField().find(p => p.isActive());
}
/** /**
* Finds the first {@linkcode Pokemon.isActive() | active PlayerPokemon} that isn't also currently switching out * @returns An array of {@linkcode PlayerPokemon} filtered from the player's party
* @returns Either the first {@linkcode PlayerPokemon} satisfying, or undefined if no player pokemon on the field satisfy * that are {@linkcode PlayerPokemon.isAllowedInBattle | allowed in battle}.
*/ */
getNonSwitchedPlayerPokemon(): PlayerPokemon | undefined { public getPokemonAllowedInBattle(): PlayerPokemon[] {
return this.getPlayerField().find(p => p.isActive() && p.switchOutStatus === false); return this.getPlayerParty().filter(p => p.isAllowedInBattle());
} }
/** /**
* Returns an array of PlayerPokemon of length 1 or 2 depending on if double battles or not * @returns The first {@linkcode PlayerPokemon} that is {@linkcode getPlayerField on the field}
* and {@linkcode PlayerPokemon.isActive is active}
* (aka {@linkcode PlayerPokemon.isAllowedInBattle is allowed in battle}),
* or `undefined` if there are no valid pokemon
* @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true`
*/
public getPlayerPokemon(includeSwitching: boolean = true): PlayerPokemon | undefined {
return this.getPlayerField().find(p => p.isActive() && (includeSwitching || p.switchOutStatus === false));
}
/**
* Returns an array of PlayerPokemon of length 1 or 2 depending on if in a double battle or not.
* Does not actually check if the pokemon are on the field or not.
* @returns array of {@linkcode PlayerPokemon} * @returns array of {@linkcode PlayerPokemon}
*/ */
getPlayerField(): PlayerPokemon[] { public getPlayerField(): PlayerPokemon[] {
const party = this.getParty(); const party = this.getPlayerParty();
return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1)); return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1));
} }
getEnemyParty(): EnemyPokemon[] { public getEnemyParty(): EnemyPokemon[] {
return this.currentBattle?.enemyParty ?? []; return this.currentBattle?.enemyParty ?? [];
} }
getEnemyPokemon(): EnemyPokemon | undefined {
return this.getEnemyField().find(p => p.isActive());
}
/** /**
* Finds the first {@linkcode Pokemon.isActive() | active EnemyPokemon} pokemon from the enemy that isn't also currently switching out * @returns The first {@linkcode EnemyPokemon} that is {@linkcode getEnemyField on the field}
* @returns Either the first {@linkcode EnemyPokemon} satisfying, or undefined if no player pokemon on the field satisfy * and {@linkcode EnemyPokemon.isActive is active}
* (aka {@linkcode EnemyPokemon.isAllowedInBattle is allowed in battle}),
* or `undefined` if there are no valid pokemon
* @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true`
*/ */
getNonSwitchedEnemyPokemon(): EnemyPokemon | undefined { public getEnemyPokemon(includeSwitching: boolean = true): EnemyPokemon | undefined {
return this.getEnemyField().find(p => p.isActive() && p.switchOutStatus === false); return this.getEnemyField().find(p => p.isActive() && (includeSwitching || p.switchOutStatus === false));
} }
/** /**
* Returns an array of EnemyPokemon of length 1 or 2 depending on if double battles or not * Returns an array of EnemyPokemon of length 1 or 2 depending on if in a double battle or not.
* Does not actually check if the pokemon are on the field or not.
* @returns array of {@linkcode EnemyPokemon} * @returns array of {@linkcode EnemyPokemon}
*/ */
getEnemyField(): EnemyPokemon[] { public getEnemyField(): EnemyPokemon[] {
const party = this.getEnemyParty(); const party = this.getEnemyParty();
return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1)); return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1));
} }
getField(activeOnly: boolean = false): Pokemon[] { public getField(activeOnly: boolean = false): Pokemon[] {
const ret = new Array(4).fill(null); const ret = new Array(4).fill(null);
const playerField = this.getPlayerField(); const playerField = this.getPlayerField();
const enemyField = this.getEnemyField(); const enemyField = this.getEnemyField();
@ -867,7 +875,7 @@ export default class BattleScene extends SceneBase {
getPokemonById(pokemonId: integer): Pokemon | null { getPokemonById(pokemonId: integer): Pokemon | null {
const findInParty = (party: Pokemon[]) => party.find(p => p.id === pokemonId); const findInParty = (party: Pokemon[]) => party.find(p => p.id === pokemonId);
return (findInParty(this.getParty()) || findInParty(this.getEnemyParty())) ?? null; return (findInParty(this.getPlayerParty()) || findInParty(this.getEnemyParty())) ?? null;
} }
addPlayerPokemon(species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData, postProcess?: (playerPokemon: PlayerPokemon) => void): PlayerPokemon { addPlayerPokemon(species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData, postProcess?: (playerPokemon: PlayerPokemon) => void): PlayerPokemon {
@ -1062,7 +1070,7 @@ export default class BattleScene extends SceneBase {
this.modifierBar.removeAll(true); this.modifierBar.removeAll(true);
this.enemyModifierBar.removeAll(true); this.enemyModifierBar.removeAll(true);
for (const p of this.getParty()) { for (const p of this.getPlayerParty()) {
p.destroy(); p.destroy();
} }
this.party = []; this.party = [];
@ -1275,7 +1283,7 @@ export default class BattleScene extends SceneBase {
} }
}); });
for (const pokemon of this.getParty()) { for (const pokemon of this.getPlayerParty()) {
pokemon.resetBattleData(); pokemon.resetBattleData();
applyPostBattleInitAbAttrs(PostBattleInitAbAttr, pokemon); applyPostBattleInitAbAttrs(PostBattleInitAbAttr, pokemon);
} }
@ -1285,7 +1293,7 @@ export default class BattleScene extends SceneBase {
} }
} }
for (const pokemon of this.getParty()) { for (const pokemon of this.getPlayerParty()) {
this.triggerPokemonFormChange(pokemon, SpeciesFormChangeTimeOfDayTrigger); this.triggerPokemonFormChange(pokemon, SpeciesFormChangeTimeOfDayTrigger);
} }
@ -1480,7 +1488,7 @@ export default class BattleScene extends SceneBase {
} }
trySpreadPokerus(): void { trySpreadPokerus(): void {
const party = this.getParty(); const party = this.getPlayerParty();
const infectedIndexes: integer[] = []; const infectedIndexes: integer[] = [];
const spread = (index: number, spreadTo: number) => { const spread = (index: number, spreadTo: number) => {
const partyMember = party[index + spreadTo]; const partyMember = party[index + spreadTo];
@ -1677,7 +1685,7 @@ export default class BattleScene extends SceneBase {
updateAndShowText(duration: number): void { updateAndShowText(duration: number): void {
const labels = [ this.luckLabelText, this.luckText ]; const labels = [ this.luckLabelText, this.luckText ];
labels.forEach(t => t.setAlpha(0)); labels.forEach(t => t.setAlpha(0));
const luckValue = getPartyLuckValue(this.getParty()); const luckValue = getPartyLuckValue(this.getPlayerParty());
this.luckText.setText(getLuckString(luckValue)); this.luckText.setText(getLuckString(luckValue));
if (luckValue < 14) { if (luckValue < 14) {
this.luckText.setTint(getLuckTextTint(luckValue)); this.luckText.setTint(getLuckTextTint(luckValue));
@ -2615,7 +2623,7 @@ export default class BattleScene extends SceneBase {
removePartyMemberModifiers(partyMemberIndex: integer): Promise<void> { removePartyMemberModifiers(partyMemberIndex: integer): Promise<void> {
return new Promise(resolve => { return new Promise(resolve => {
const pokemonId = this.getParty()[partyMemberIndex].id; 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 === pokemonId);
for (const m of modifiersToRemove) { for (const m of modifiersToRemove) {
this.modifiers.splice(this.modifiers.indexOf(m), 1); this.modifiers.splice(this.modifiers.indexOf(m), 1);
@ -2742,7 +2750,7 @@ export default class BattleScene extends SceneBase {
} }
} }
this.updatePartyForModifiers(player ? this.getParty() : this.getEnemyParty(), instant).then(() => { this.updatePartyForModifiers(player ? this.getPlayerParty() : this.getEnemyParty(), instant).then(() => {
(player ? this.modifierBar : this.enemyModifierBar).updateModifiers(modifiers); (player ? this.modifierBar : this.enemyModifierBar).updateModifiers(modifiers);
if (!player) { if (!player) {
this.updateUIPositions(); this.updateUIPositions();
@ -2980,7 +2988,7 @@ export default class BattleScene extends SceneBase {
*/ */
getActiveKeys(): string[] { getActiveKeys(): string[] {
const keys: string[] = []; const keys: string[] = [];
const playerParty = this.getParty(); const playerParty = this.getPlayerParty();
playerParty.forEach(p => { playerParty.forEach(p => {
keys.push(p.getSpriteKey(true)); keys.push(p.getSpriteKey(true));
keys.push(p.getBattleSpriteKey(true, true)); keys.push(p.getBattleSpriteKey(true, true));
@ -3016,7 +3024,7 @@ export default class BattleScene extends SceneBase {
this.setFieldScale(0.75); this.setFieldScale(0.75);
this.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); this.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false);
this.currentBattle.double = true; this.currentBattle.double = true;
const availablePartyMembers = this.getParty().filter((p) => p.isAllowedInBattle()); const availablePartyMembers = this.getPlayerParty().filter((p) => p.isAllowedInBattle());
if (availablePartyMembers.length > 1) { if (availablePartyMembers.length > 1) {
this.pushPhase(new ToggleDoublePositionPhase(this, true)); this.pushPhase(new ToggleDoublePositionPhase(this, true));
if (!availablePartyMembers[1].isOnField()) { if (!availablePartyMembers[1].isOnField()) {
@ -3041,7 +3049,7 @@ export default class BattleScene extends SceneBase {
*/ */
applyPartyExp(expValue: number, pokemonDefeated: boolean, useWaveIndexMultiplier?: boolean, pokemonParticipantIds?: Set<number>): void { applyPartyExp(expValue: number, pokemonDefeated: boolean, useWaveIndexMultiplier?: boolean, pokemonParticipantIds?: Set<number>): void {
const participantIds = pokemonParticipantIds ?? this.currentBattle.playerParticipantIds; const participantIds = pokemonParticipantIds ?? this.currentBattle.playerParticipantIds;
const party = this.getParty(); const party = this.getPlayerParty();
const expShareModifier = this.findModifier(m => m instanceof ExpShareModifier) as ExpShareModifier; const expShareModifier = this.findModifier(m => m instanceof ExpShareModifier) as ExpShareModifier;
const expBalanceModifier = this.findModifier(m => m instanceof ExpBalanceModifier) as ExpBalanceModifier; const expBalanceModifier = this.findModifier(m => m instanceof ExpBalanceModifier) as ExpBalanceModifier;
const multipleParticipantExpBonusModifier = this.findModifier(m => m instanceof MultipleParticipantExpBonusModifier) as MultipleParticipantExpBonusModifier; const multipleParticipantExpBonusModifier = this.findModifier(m => m instanceof MultipleParticipantExpBonusModifier) as MultipleParticipantExpBonusModifier;

View File

@ -4869,7 +4869,7 @@ class ForceSwitchOutHelper {
* - If the Pokémon is still alive (hp > 0), and if so, it leaves the field and a new SwitchPhase is initiated. * - If the Pokémon is still alive (hp > 0), and if so, it leaves the field and a new SwitchPhase is initiated.
*/ */
if (switchOutTarget instanceof PlayerPokemon) { if (switchOutTarget instanceof PlayerPokemon) {
if (switchOutTarget.scene.getParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) { if (switchOutTarget.scene.getPlayerParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) {
return false; return false;
} }
@ -4950,7 +4950,7 @@ class ForceSwitchOutHelper {
return false; return false;
} }
const party = player ? pokemon.scene.getParty() : pokemon.scene.getEnemyParty(); const party = player ? pokemon.scene.getPlayerParty() : pokemon.scene.getEnemyParty();
return (!player && pokemon.scene.currentBattle.battleType === BattleType.WILD) return (!player && pokemon.scene.currentBattle.battleType === BattleType.WILD)
|| party.filter(p => p.isAllowedInBattle() || party.filter(p => p.isAllowedInBattle()
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > pokemon.scene.currentBattle.getBattlerCount(); && (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > pokemon.scene.currentBattle.getBattlerCount();

View File

@ -478,7 +478,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
], ],
[Species.NINCADA]: [ [Species.NINCADA]: [
new SpeciesEvolution(Species.NINJASK, 20, null, null), new SpeciesEvolution(Species.NINJASK, 20, null, null),
new SpeciesEvolution(Species.SHEDINJA, 20, null, new SpeciesEvolutionCondition(p => p.scene.getParty().length < 6 && p.scene.pokeballCounts[PokeballType.POKEBALL] > 0)) new SpeciesEvolution(Species.SHEDINJA, 20, null, new SpeciesEvolutionCondition(p => p.scene.getPlayerParty().length < 6 && p.scene.pokeballCounts[PokeballType.POKEBALL] > 0))
], ],
[Species.WHISMUR]: [ [Species.WHISMUR]: [
new SpeciesEvolution(Species.LOUDRED, 20, null, null) new SpeciesEvolution(Species.LOUDRED, 20, null, null)
@ -890,7 +890,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
new SpeciesEvolution(Species.GOGOAT, 32, null, null) new SpeciesEvolution(Species.GOGOAT, 32, null, null)
], ],
[Species.PANCHAM]: [ [Species.PANCHAM]: [
new SpeciesEvolution(Species.PANGORO, 32, null, new SpeciesEvolutionCondition(p => !!p.scene.getParty().find(p => p.getTypes(false, false, true).indexOf(Type.DARK) > -1)), SpeciesWildEvolutionDelay.MEDIUM) new SpeciesEvolution(Species.PANGORO, 32, null, new SpeciesEvolutionCondition(p => !!p.scene.getPlayerParty().find(p => p.getTypes(false, false, true).indexOf(Type.DARK) > -1)), SpeciesWildEvolutionDelay.MEDIUM)
], ],
[Species.ESPURR]: [ [Species.ESPURR]: [
new SpeciesFormEvolution(Species.MEOWSTIC, "", "female", 25, null, new SpeciesEvolutionCondition(p => p.gender === Gender.FEMALE, p => p.gender = Gender.FEMALE)), new SpeciesFormEvolution(Species.MEOWSTIC, "", "female", 25, null, new SpeciesEvolutionCondition(p => p.gender === Gender.FEMALE, p => p.gender = Gender.FEMALE)),

View File

@ -428,7 +428,7 @@ class AnimTimedAddBgEvent extends AnimTimedBgEvent {
moveAnim.bgSprite.setScale(1.25); moveAnim.bgSprite.setScale(1.25);
moveAnim.bgSprite.setAlpha(this.opacity / 255); moveAnim.bgSprite.setAlpha(this.opacity / 255);
scene.field.add(moveAnim.bgSprite); scene.field.add(moveAnim.bgSprite);
const fieldPokemon = scene.getNonSwitchedEnemyPokemon() || scene.getNonSwitchedPlayerPokemon(); const fieldPokemon = scene.getEnemyPokemon(false) ?? scene.getPlayerPokemon(false);
if (!isNullOrUndefined(priority)) { if (!isNullOrUndefined(priority)) {
scene.field.moveTo(moveAnim.bgSprite as Phaser.GameObjects.GameObject, priority); scene.field.moveTo(moveAnim.bgSprite as Phaser.GameObjects.GameObject, priority);
} else if (fieldPokemon?.isOnField()) { } else if (fieldPokemon?.isOnField()) {
@ -999,7 +999,7 @@ export abstract class BattleAnim {
const setSpritePriority = (priority: integer) => { const setSpritePriority = (priority: integer) => {
switch (priority) { switch (priority) {
case 0: case 0:
scene.field.moveBelow(moveSprite as Phaser.GameObjects.GameObject, scene.getNonSwitchedEnemyPokemon() || scene.getNonSwitchedPlayerPokemon()!); // This bang assumes that if (the EnemyPokemon is undefined, then the PlayerPokemon function must return an object), correct assumption? scene.field.moveBelow(moveSprite as Phaser.GameObjects.GameObject, scene.getEnemyPokemon(false) ?? scene.getPlayerPokemon(false)!); // TODO: is this bang correct?
break; break;
case 1: case 1:
scene.field.moveTo(moveSprite, scene.field.getAll().length - 1); scene.field.moveTo(moveSprite, scene.field.getAll().length - 1);

View File

@ -1743,7 +1743,7 @@ export class PartyStatusCureAttr extends MoveEffectAttr {
if (!this.canApply(user, target, move, args)) { if (!this.canApply(user, target, move, args)) {
return false; return false;
} }
const partyPokemon = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty(); const partyPokemon = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
partyPokemon.forEach(p => this.cureStatus(p, user.id)); partyPokemon.forEach(p => this.cureStatus(p, user.id));
if (this.message) { if (this.message) {
@ -1815,7 +1815,7 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
} }
// We don't know which party member will be chosen, so pick the highest max HP in the party // We don't know which party member will be chosen, so pick the highest max HP in the party
const maxPartyMemberHp = user.scene.getParty().map(p => p.getMaxHp()).reduce((maxHp: integer, hp: integer) => Math.max(hp, maxHp), 0); const maxPartyMemberHp = user.scene.getPlayerParty().map(p => p.getMaxHp()).reduce((maxHp: integer, hp: integer) => Math.max(hp, maxHp), 0);
user.scene.pushPhase(new PokemonHealPhase(user.scene, user.getBattlerIndex(), user.scene.pushPhase(new PokemonHealPhase(user.scene, user.getBattlerIndex(),
maxPartyMemberHp, i18next.t("moveTriggers:sacrificialFullRestore", { pokemonName: getPokemonNameWithAffix(user) }), true, false, false, true), true); maxPartyMemberHp, i18next.t("moveTriggers:sacrificialFullRestore", { pokemonName: getPokemonNameWithAffix(user) }), true, false, false, true), true);
@ -1828,7 +1828,7 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
} }
getCondition(): MoveConditionFunc { getCondition(): MoveConditionFunc {
return (user, target, move) => user.scene.getParty().filter(p => p.isActive()).length > user.scene.currentBattle.getBattlerCount(); return (user, _target, _move) => user.scene.getPlayerParty().filter(p => p.isActive()).length > user.scene.currentBattle.getBattlerCount();
} }
} }
@ -2158,7 +2158,7 @@ export class MultiHitAttr extends MoveAttr {
case MultiHitType._10: case MultiHitType._10:
return 10; return 10;
case MultiHitType.BEAT_UP: case MultiHitType.BEAT_UP:
const party = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty(); const party = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
// No status means the ally pokemon can contribute to Beat Up // No status means the ally pokemon can contribute to Beat Up
return party.reduce((total, pokemon) => { return party.reduce((total, pokemon) => {
return total + (pokemon.id === user.id ? 1 : pokemon?.status && pokemon.status.effect !== StatusEffect.NONE ? 0 : 1); return total + (pokemon.id === user.id ? 1 : pokemon?.status && pokemon.status.effect !== StatusEffect.NONE ? 0 : 1);
@ -3467,7 +3467,7 @@ export class MovePowerMultiplierAttr extends VariablePowerAttr {
* @returns The base power of the Beat Up hit. * @returns The base power of the Beat Up hit.
*/ */
const beatUpFunc = (user: Pokemon, allyIndex: number): number => { const beatUpFunc = (user: Pokemon, allyIndex: number): number => {
const party = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty(); const party = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
for (let i = allyIndex; i < party.length; i++) { for (let i = allyIndex; i < party.length; i++) {
const pokemon = party[i]; const pokemon = party[i];
@ -3495,7 +3495,7 @@ export class BeatUpAttr extends VariablePowerAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const power = args[0] as Utils.NumberHolder; const power = args[0] as Utils.NumberHolder;
const party = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty(); const party = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
const allyCount = party.filter(pokemon => { const allyCount = party.filter(pokemon => {
return pokemon.id === user.id || !pokemon.status?.effect; return pokemon.id === user.id || !pokemon.status?.effect;
}).length; }).length;
@ -5720,7 +5720,7 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
return new Promise(resolve => { return new Promise(resolve => {
// If user is player, checks if the user has fainted pokemon // If user is player, checks if the user has fainted pokemon
if (user instanceof PlayerPokemon if (user instanceof PlayerPokemon
&& user.scene.getParty().findIndex(p => p.isFainted()) > -1) { && user.scene.getPlayerParty().findIndex(p => p.isFainted()) > -1) {
(user as PlayerPokemon).revivalBlessing().then(() => { (user as PlayerPokemon).revivalBlessing().then(() => {
resolve(true); resolve(true);
}); });
@ -5794,7 +5794,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
} }
} }
// Switch out logic for the player's Pokemon // Switch out logic for the player's Pokemon
if (switchOutTarget.scene.getParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) { if (switchOutTarget.scene.getPlayerParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) {
return false; return false;
} }
@ -5903,7 +5903,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
} }
} }
const party = player ? user.scene.getParty() : user.scene.getEnemyParty(); const party = player ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
return (!player && !user.scene.currentBattle.battleType) return (!player && !user.scene.currentBattle.battleType)
|| party.filter(p => p.isAllowedInBattle() || party.filter(p => p.isAllowedInBattle()
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > user.scene.currentBattle.getBattlerCount(); && (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > user.scene.currentBattle.getBattlerCount();
@ -7254,7 +7254,7 @@ const targetSleptOrComatoseCondition: MoveConditionFunc = (user: Pokemon, target
const failIfLastCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => user.scene.phaseQueue.find(phase => phase instanceof MovePhase) !== undefined; const failIfLastCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => user.scene.phaseQueue.find(phase => phase instanceof MovePhase) !== undefined;
const failIfLastInPartyCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => { const failIfLastInPartyCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => {
const party: Pokemon[] = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty(); const party: Pokemon[] = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
return party.some(pokemon => pokemon.isActive() && !pokemon.isOnField()); return party.some(pokemon => pokemon.isActive() && !pokemon.isOnField());
}; };
@ -9184,7 +9184,7 @@ export function initMoves() {
.target(MoveTarget.ALL) .target(MoveTarget.ALL)
.condition((user, target, move) => { .condition((user, target, move) => {
// If any fielded pokémon is grass-type and grounded. // If any fielded pokémon is grass-type and grounded.
return [ ...user.scene.getEnemyParty(), ...user.scene.getParty() ].some((poke) => poke.isOfType(Type.GRASS) && poke.isGrounded()); return [ ...user.scene.getEnemyParty(), ...user.scene.getPlayerParty() ].some((poke) => poke.isOfType(Type.GRASS) && poke.isGrounded());
}) })
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => target.isOfType(Type.GRASS) && target.isGrounded() }), .attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => target.isOfType(Type.GRASS) && target.isGrounded() }),
new StatusMove(Moves.STICKY_WEB, Type.BUG, -1, 20, -1, 0, 6) new StatusMove(Moves.STICKY_WEB, Type.BUG, -1, 20, -1, 0, 6)

View File

@ -181,7 +181,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
// Sort berries by party member ID to more easily re-add later if necessary // Sort berries by party member ID to more easily re-add later if necessary
const berryItemsMap = new Map<number, BerryModifier[]>(); const berryItemsMap = new Map<number, BerryModifier[]>();
scene.getParty().forEach(pokemon => { scene.getPlayerParty().forEach(pokemon => {
const pokemonBerries = berryItems.filter(b => b.pokemonId === pokemon.id); const pokemonBerries = berryItems.filter(b => b.pokemonId === pokemon.id);
if (pokemonBerries?.length > 0) { if (pokemonBerries?.length > 0) {
berryItemsMap.set(pokemon.id, pokemonBerries); berryItemsMap.set(pokemon.id, pokemonBerries);
@ -267,7 +267,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
const revSeed = generateModifierType(scene, modifierTypes.REVIVER_SEED); const revSeed = generateModifierType(scene, modifierTypes.REVIVER_SEED);
encounter.setDialogueToken("foodReward", revSeed?.name ?? i18next.t("modifierType:ModifierType.REVIVER_SEED.name")); encounter.setDialogueToken("foodReward", revSeed?.name ?? i18next.t("modifierType:ModifierType.REVIVER_SEED.name"));
const givePartyPokemonReviverSeeds = () => { const givePartyPokemonReviverSeeds = () => {
const party = scene.getParty(); const party = scene.getPlayerParty();
party.forEach(p => { party.forEach(p => {
const heldItems = p.getHeldItems(); const heldItems = p.getHeldItems();
if (revSeed && !heldItems.some(item => item instanceof PokemonInstantReviveModifier)) { if (revSeed && !heldItems.some(item => item instanceof PokemonInstantReviveModifier)) {
@ -308,7 +308,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
const berryMap = encounter.misc.berryItemsMap; const berryMap = encounter.misc.berryItemsMap;
// Returns 2/5 of the berries stolen to each Pokemon // Returns 2/5 of the berries stolen to each Pokemon
const party = scene.getParty(); const party = scene.getPlayerParty();
party.forEach(pokemon => { party.forEach(pokemon => {
const stolenBerries: BerryModifier[] = berryMap.get(pokemon.id); const stolenBerries: BerryModifier[] = berryMap.get(pokemon.id);
const berryTypesAsArray: BerryType[] = []; const berryTypesAsArray: BerryType[] = [];

View File

@ -58,7 +58,7 @@ export const BerriesAboundEncounter: MysteryEncounter =
// Calculate boss mon // Calculate boss mon
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true); const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true); const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon));
const config: EnemyPartyConfig = { const config: EnemyPartyConfig = {
@ -77,7 +77,7 @@ export const BerriesAboundEncounter: MysteryEncounter =
scene.currentBattle.waveIndex > 160 ? 7 scene.currentBattle.waveIndex > 160 ? 7
: scene.currentBattle.waveIndex > 120 ? 5 : scene.currentBattle.waveIndex > 120 ? 5
: scene.currentBattle.waveIndex > 40 ? 4 : 2; : scene.currentBattle.waveIndex > 40 ? 4 : 2;
regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0); regenerateModifierPoolThresholds(scene.getPlayerParty(), ModifierPoolType.PLAYER, 0);
encounter.misc = { numBerries }; encounter.misc = { numBerries };
const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(bossPokemon); const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(bossPokemon);
@ -253,7 +253,7 @@ function tryGiveBerry(scene: BattleScene, prioritizedPokemon?: PlayerPokemon) {
const berryType = randSeedInt(Object.keys(BerryType).filter(s => !isNaN(Number(s))).length) as BerryType; const berryType = randSeedInt(Object.keys(BerryType).filter(s => !isNaN(Number(s))).length) as BerryType;
const berry = generateModifierType(scene, modifierTypes.BERRY, [ berryType ]) as BerryModifierType; const berry = generateModifierType(scene, modifierTypes.BERRY, [ berryType ]) as BerryModifierType;
const party = scene.getParty(); const party = scene.getPlayerParty();
// Will try to apply to prioritized pokemon first, then do normal application method if it fails // Will try to apply to prioritized pokemon first, then do normal application method if it fails
if (prioritizedPokemon) { if (prioritizedPokemon) {

View File

@ -331,7 +331,7 @@ export const BugTypeSuperfanEncounter: MysteryEncounter =
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
// Player gets different rewards depending on the number of bug types they have // Player gets different rewards depending on the number of bug types they have
const numBugTypes = scene.getParty().filter(p => p.isOfType(Type.BUG, true)).length; const numBugTypes = scene.getPlayerParty().filter(p => p.isOfType(Type.BUG, true)).length;
const numBugTypesText = i18next.t(`${namespace}:numBugTypes`, { count: numBugTypes }); const numBugTypesText = i18next.t(`${namespace}:numBugTypes`, { count: numBugTypes });
encounter.setDialogueToken("numBugTypes", numBugTypesText); encounter.setDialogueToken("numBugTypes", numBugTypesText);

View File

@ -245,7 +245,7 @@ export const ClowningAroundEncounter: MysteryEncounter =
// So Vitamins, form change items, etc. are not included // So Vitamins, form change items, etc. are not included
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
const party = scene.getParty(); const party = scene.getPlayerParty();
let mostHeldItemsPokemon = party[0]; let mostHeldItemsPokemon = party[0];
let count = mostHeldItemsPokemon.getHeldItems() let count = mostHeldItemsPokemon.getHeldItems()
.filter(m => m.isTransferable && !(m instanceof BerryModifier)) .filter(m => m.isTransferable && !(m instanceof BerryModifier))
@ -328,7 +328,7 @@ export const ClowningAroundEncounter: MysteryEncounter =
.withPreOptionPhase(async (scene: BattleScene) => { .withPreOptionPhase(async (scene: BattleScene) => {
// Randomize the second type of all player's pokemon // Randomize the second type of all player's pokemon
// If the pokemon does not normally have a second type, it will gain 1 // If the pokemon does not normally have a second type, it will gain 1
for (const pokemon of scene.getParty()) { for (const pokemon of scene.getPlayerParty()) {
const originalTypes = pokemon.getTypes(false, false, true); const originalTypes = pokemon.getTypes(false, false, true);
// If the Pokemon has non-status moves that don't match the Pokemon's type, prioritizes those as the new type // If the Pokemon has non-status moves that don't match the Pokemon's type, prioritizes those as the new type

View File

@ -1,32 +1,32 @@
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { BattlerIndex } from "#app/battle";
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import { EncounterBattleAnim } from "#app/data/battle-anims";
import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import { getPokemonSpecies } from "#app/data/pokemon-species";
import { Moves } from "#enums/moves";
import { TrainerSlot } from "#app/data/trainer-config";
import PokemonData from "#app/system/pokemon-data";
import { Biome } from "#enums/biome";
import { EncounterBattleAnim } from "#app/data/battle-anims";
import { BattlerTagType } from "#enums/battler-tag-type";
import { getEncounterText, queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { MoveRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { MoveRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements";
import { DANCING_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups"; import { DANCING_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { getEncounterText, queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { BattlerIndex } from "#app/battle"; import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { catchPokemon, getEncounterPokemonLevelForWave, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { catchPokemon, getEncounterPokemonLevelForWave, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { PokeballType } from "#enums/pokeball"; import { getPokemonSpecies } from "#app/data/pokemon-species";
import { TrainerSlot } from "#app/data/trainer-config";
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { LearnMovePhase } from "#app/phases/learn-move-phase";
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
import { Stat } from "#enums/stat"; import PokemonData from "#app/system/pokemon-data";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { BattlerTagType } from "#enums/battler-tag-type";
import { Biome } from "#enums/biome";
import { EncounterAnim } from "#enums/encounter-anims"; import { EncounterAnim } from "#enums/encounter-anims";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import { Moves } from "#enums/moves";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { PokeballType } from "#enums/pokeball";
import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import i18next from "i18next"; import i18next from "i18next";
/** the i18n namespace for this encounter */ /** the i18n namespace for this encounter */
@ -92,7 +92,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
.withCatchAllowed(true) .withCatchAllowed(true)
.withFleeAllowed(false) .withFleeAllowed(false)
.withOnVisualsStart((scene: BattleScene) => { .withOnVisualsStart((scene: BattleScene) => {
const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, scene.getEnemyPokemon()!, scene.getParty()[0]); const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, scene.getEnemyPokemon()!, scene.getPlayerPokemon()!);
danceAnim.play(scene); danceAnim.play(scene);
return true; return true;
@ -217,7 +217,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
const onPokemonSelected = (pokemon: PlayerPokemon) => { const onPokemonSelected = (pokemon: PlayerPokemon) => {
encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender()); encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender());
scene.unshiftPhase(new LearnMovePhase(scene, scene.getParty().indexOf(pokemon), Moves.REVELATION_DANCE)); scene.unshiftPhase(new LearnMovePhase(scene, scene.getPlayerParty().indexOf(pokemon), Moves.REVELATION_DANCE));
// Play animation again to "learn" the dance // Play animation again to "learn" the dance
const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, scene.getEnemyPokemon()!, scene.getPlayerPokemon()); const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, scene.getEnemyPokemon()!, scene.getPlayerPokemon());

View File

@ -1,22 +1,22 @@
import { generateModifierType, leaveEncounterWithoutBattle, selectPokemonForOption, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import { CombinationPokemonRequirement, HeldItemRequirement, MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { CombinationPokemonRequirement, HeldItemRequirement, MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements";
import { getEncounterText, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import { getEncounterText, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { generateModifierType, leaveEncounterWithoutBattle, selectPokemonForOption, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PreserveBerryModifier } from "#app/modifier/modifier";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import i18next from "#app/plugins/i18n";
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
import { getPokemonSpecies } from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species";
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PreserveBerryModifier } from "#app/modifier/modifier";
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
import i18next from "#app/plugins/i18n";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
/** the i18n namespace for this encounter */ /** the i18n namespace for this encounter */
const namespace = "mysteryEncounters/delibirdy"; const namespace = "mysteryEncounters/delibirdy";
@ -133,7 +133,7 @@ export const DelibirdyEncounter: MysteryEncounter =
if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) { if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) {
// At max stacks, give the first party pokemon a Shell Bell instead // At max stacks, give the first party pokemon a Shell Bell instead
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
await applyModifierTypeToPlayerPokemon(scene, scene.getParty()[0], shellBell); await applyModifierTypeToPlayerPokemon(scene, scene.getPlayerPokemon()!, shellBell);
scene.playSound("item_fanfare"); scene.playSound("item_fanfare");
await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true); await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true);
} else { } else {
@ -207,7 +207,7 @@ export const DelibirdyEncounter: MysteryEncounter =
if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) { if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) {
// At max stacks, give the first party pokemon a Shell Bell instead // At max stacks, give the first party pokemon a Shell Bell instead
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
await applyModifierTypeToPlayerPokemon(scene, scene.getParty()[0], shellBell); await applyModifierTypeToPlayerPokemon(scene, scene.getPlayerPokemon()!, shellBell);
scene.playSound("item_fanfare"); scene.playSound("item_fanfare");
await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true); await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true);
} else { } else {
@ -220,7 +220,7 @@ export const DelibirdyEncounter: MysteryEncounter =
if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) { if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) {
// At max stacks, give the first party pokemon a Shell Bell instead // At max stacks, give the first party pokemon a Shell Bell instead
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
await applyModifierTypeToPlayerPokemon(scene, scene.getParty()[0], shellBell); await applyModifierTypeToPlayerPokemon(scene, scene.getPlayerPokemon()!, shellBell);
scene.playSound("item_fanfare"); scene.playSound("item_fanfare");
await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true); await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true);
} else { } else {
@ -299,7 +299,7 @@ export const DelibirdyEncounter: MysteryEncounter =
if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) { if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) {
// At max stacks, give the first party pokemon a Shell Bell instead // At max stacks, give the first party pokemon a Shell Bell instead
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
await applyModifierTypeToPlayerPokemon(scene, scene.getParty()[0], shellBell); await applyModifierTypeToPlayerPokemon(scene, scene.getPlayerParty()[0], shellBell);
scene.playSound("item_fanfare"); scene.playSound("item_fanfare");
await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true); await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true);
} else { } else {

View File

@ -214,7 +214,7 @@ function pokemonAndMoveChosen(scene: BattleScene, pokemon: PlayerPokemon, move:
text: `${namespace}:incorrect_exp`, text: `${namespace}:incorrect_exp`,
}, },
]; ];
setEncounterExp(scene, scene.getParty().map((p) => p.id), 50); setEncounterExp(scene, scene.getPlayerParty().map((p) => p.id), 50);
} else { } else {
encounter.selectedOption!.dialogue!.selected = [ encounter.selectedOption!.dialogue!.selected = [
{ {

View File

@ -184,7 +184,7 @@ export const FieryFalloutEncounter: MysteryEncounter =
async (scene: BattleScene) => { async (scene: BattleScene) => {
// Damage non-fire types and burn 1 random non-fire type member + give it Heatproof // Damage non-fire types and burn 1 random non-fire type member + give it Heatproof
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
const nonFireTypes = scene.getParty().filter((p) => p.isAllowedInBattle() && !p.getTypes().includes(Type.FIRE)); const nonFireTypes = scene.getPlayerParty().filter((p) => p.isAllowedInBattle() && !p.getTypes().includes(Type.FIRE));
for (const pkm of nonFireTypes) { for (const pkm of nonFireTypes) {
const percentage = DAMAGE_PERCENTAGE / 100; const percentage = DAMAGE_PERCENTAGE / 100;
@ -257,7 +257,7 @@ export const FieryFalloutEncounter: MysteryEncounter =
function giveLeadPokemonAttackTypeBoostItem(scene: BattleScene) { function giveLeadPokemonAttackTypeBoostItem(scene: BattleScene) {
// Give first party pokemon attack type boost item for free at end of battle // Give first party pokemon attack type boost item for free at end of battle
const leadPokemon = scene.getParty()?.[0]; const leadPokemon = scene.getPlayerParty()?.[0];
if (leadPokemon) { if (leadPokemon) {
// Generate type booster held item, default to Charcoal if item fails to generate // Generate type booster held item, default to Charcoal if item fails to generate
let boosterModifierType = generateModifierType(scene, modifierTypes.ATTACK_TYPE_BOOSTER) as AttackTypeBoosterModifierType; let boosterModifierType = generateModifierType(scene, modifierTypes.ATTACK_TYPE_BOOSTER) as AttackTypeBoosterModifierType;

View File

@ -56,7 +56,7 @@ export const FightOrFlightEncounter: MysteryEncounter =
// Calculate boss mon // Calculate boss mon
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true); const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true); const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
encounter.setDialogueToken("enemyPokemon", bossPokemon.getNameToRender()); encounter.setDialogueToken("enemyPokemon", bossPokemon.getNameToRender());
const config: EnemyPartyConfig = { const config: EnemyPartyConfig = {
@ -86,11 +86,11 @@ export const FightOrFlightEncounter: MysteryEncounter =
: scene.currentBattle.waveIndex > 40 : scene.currentBattle.waveIndex > 40
? ModifierTier.ULTRA ? ModifierTier.ULTRA
: ModifierTier.GREAT; : ModifierTier.GREAT;
regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0); regenerateModifierPoolThresholds(scene.getPlayerParty(), ModifierPoolType.PLAYER, 0);
let item: ModifierTypeOption | null = null; let item: ModifierTypeOption | null = null;
// TMs and Candy Jar excluded from possible rewards as they're too swingy in value for a singular item reward // TMs and Candy Jar excluded from possible rewards as they're too swingy in value for a singular item reward
while (!item || item.type.id.includes("TM_") || item.type.id === "CANDY_JAR") { while (!item || item.type.id.includes("TM_") || item.type.id === "CANDY_JAR") {
item = getPlayerModifierTypeOptions(1, scene.getParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0]; item = getPlayerModifierTypeOptions(1, scene.getPlayerParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0];
} }
encounter.setDialogueToken("itemName", item.type.name); encounter.setDialogueToken("itemName", item.type.name);
encounter.misc = item; encounter.misc = item;

View File

@ -165,7 +165,7 @@ async function summonPlayerPokemon(scene: BattleScene) {
const playerPokemon = encounter.misc.playerPokemon; const playerPokemon = encounter.misc.playerPokemon;
// Swaps the chosen Pokemon and the first player's lead Pokemon in the party // Swaps the chosen Pokemon and the first player's lead Pokemon in the party
const party = scene.getParty(); const party = scene.getPlayerParty();
const chosenIndex = party.indexOf(playerPokemon); const chosenIndex = party.indexOf(playerPokemon);
if (chosenIndex !== 0) { if (chosenIndex !== 0) {
const leadPokemon = party[0]; const leadPokemon = party[0];

View File

@ -191,7 +191,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
receivedPokemonData.pokeball = randInt(4) as PokeballType; receivedPokemonData.pokeball = randInt(4) as PokeballType;
const dataSource = new PokemonData(receivedPokemonData); const dataSource = new PokemonData(receivedPokemonData);
const newPlayerPokemon = scene.addPlayerPokemon(receivedPokemonData.species, receivedPokemonData.level, dataSource.abilityIndex, dataSource.formIndex, dataSource.gender, dataSource.shiny, dataSource.variant, dataSource.ivs, dataSource.nature, dataSource); const newPlayerPokemon = scene.addPlayerPokemon(receivedPokemonData.species, receivedPokemonData.level, dataSource.abilityIndex, dataSource.formIndex, dataSource.gender, dataSource.shiny, dataSource.variant, dataSource.ivs, dataSource.nature, dataSource);
scene.getParty().push(newPlayerPokemon); scene.getPlayerParty().push(newPlayerPokemon);
await newPlayerPokemon.loadAssets(); await newPlayerPokemon.loadAssets();
for (const mod of modifiers) { for (const mod of modifiers) {
@ -224,7 +224,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
const onPokemonSelected = (pokemon: PlayerPokemon) => { const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Randomly generate a Wonder Trade pokemon // Randomly generate a Wonder Trade pokemon
const randomTradeOption = generateTradeOption(scene.getParty().map(p => p.species)); const randomTradeOption = generateTradeOption(scene.getPlayerParty().map(p => p.species));
const tradePokemon = new EnemyPokemon(scene, randomTradeOption, pokemon.level, TrainerSlot.NONE, false); const tradePokemon = new EnemyPokemon(scene, randomTradeOption, pokemon.level, TrainerSlot.NONE, false);
// Extra shiny roll at 1/128 odds (boosted by events and charms) // Extra shiny roll at 1/128 odds (boosted by events and charms)
if (!tradePokemon.shiny) { if (!tradePokemon.shiny) {
@ -299,7 +299,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
receivedPokemonData.pokeball = randInt(4) as PokeballType; receivedPokemonData.pokeball = randInt(4) as PokeballType;
const dataSource = new PokemonData(receivedPokemonData); const dataSource = new PokemonData(receivedPokemonData);
const newPlayerPokemon = scene.addPlayerPokemon(receivedPokemonData.species, receivedPokemonData.level, dataSource.abilityIndex, dataSource.formIndex, dataSource.gender, dataSource.shiny, dataSource.variant, dataSource.ivs, dataSource.nature, dataSource); const newPlayerPokemon = scene.addPlayerPokemon(receivedPokemonData.species, receivedPokemonData.level, dataSource.abilityIndex, dataSource.formIndex, dataSource.gender, dataSource.shiny, dataSource.variant, dataSource.ivs, dataSource.nature, dataSource);
scene.getParty().push(newPlayerPokemon); scene.getPlayerParty().push(newPlayerPokemon);
await newPlayerPokemon.loadAssets(); await newPlayerPokemon.loadAssets();
for (const mod of modifiers) { for (const mod of modifiers) {
@ -384,11 +384,11 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
tier++; tier++;
} }
regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0); regenerateModifierPoolThresholds(scene.getPlayerParty(), ModifierPoolType.PLAYER, 0);
let item: ModifierTypeOption | null = null; let item: ModifierTypeOption | null = null;
// TMs excluded from possible rewards // TMs excluded from possible rewards
while (!item || item.type.id.includes("TM_")) { while (!item || item.type.id.includes("TM_")) {
item = getPlayerModifierTypeOptions(1, scene.getParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0]; item = getPlayerModifierTypeOptions(1, scene.getPlayerParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0];
} }
encounter.setDialogueToken("itemName", item.type.name); encounter.setDialogueToken("itemName", item.type.name);
@ -430,9 +430,9 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
function getPokemonTradeOptions(scene: BattleScene): Map<number, EnemyPokemon[]> { function getPokemonTradeOptions(scene: BattleScene): Map<number, EnemyPokemon[]> {
const tradeOptionsMap: Map<number, EnemyPokemon[]> = new Map<number, EnemyPokemon[]>(); const tradeOptionsMap: Map<number, EnemyPokemon[]> = new Map<number, EnemyPokemon[]>();
// Starts by filtering out any current party members as valid resulting species // Starts by filtering out any current party members as valid resulting species
const alreadyUsedSpecies: PokemonSpecies[] = scene.getParty().map(p => p.species); const alreadyUsedSpecies: PokemonSpecies[] = scene.getPlayerParty().map(p => p.species);
scene.getParty().forEach(pokemon => { scene.getPlayerParty().forEach(pokemon => {
// If the party member is legendary/mythical, the only trade options available are always pulled from generation-specific legendary trade pools // If the party member is legendary/mythical, the only trade options available are always pulled from generation-specific legendary trade pools
if (pokemon.species.legendary || pokemon.species.subLegendary || pokemon.species.mythical) { if (pokemon.species.legendary || pokemon.species.subLegendary || pokemon.species.mythical) {
const generation = pokemon.species.generation; const generation = pokemon.species.generation;

View File

@ -104,7 +104,7 @@ export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.with
], ],
}, },
async (scene: BattleScene) => { async (scene: BattleScene) => {
const allowedPokemon = scene.getParty().filter((p) => p.isAllowedInBattle()); const allowedPokemon = scene.getPlayerParty().filter((p) => p.isAllowedInBattle());
for (const pkm of allowedPokemon) { for (const pkm of allowedPokemon) {
const percentage = DAMAGE_PERCENTAGE / 100; const percentage = DAMAGE_PERCENTAGE / 100;

View File

@ -1,19 +1,19 @@
import { queueEncounterMessage, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { getHighestLevelPlayerPokemon, koPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { ModifierTier } from "#app/modifier/modifier-tier";
import { randSeedInt } from "#app/utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { queueEncounterMessage, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { getHighestLevelPlayerPokemon, koPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { getPokemonSpecies } from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species";
import { Species } from "#enums/species";
import { Moves } from "#enums/moves";
import { GameOverPhase } from "#app/phases/game-over-phase";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
import { ModifierTier } from "#app/modifier/modifier-tier";
import { GameOverPhase } from "#app/phases/game-over-phase";
import { randSeedInt } from "#app/utils";
import { Moves } from "#enums/moves";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
/** i18n namespace for encounter */ /** i18n namespace for encounter */
const namespace = "mysteryEncounters/mysteriousChest"; const namespace = "mysteryEncounters/mysteriousChest";
@ -177,7 +177,7 @@ export const MysteriousChestEncounter: MysteryEncounter =
await showEncounterText(scene, `${namespace}:option.1.bad`); await showEncounterText(scene, `${namespace}:option.1.bad`);
// Handle game over edge case // Handle game over edge case
const allowedPokemon = scene.getParty().filter(p => p.isAllowedInBattle()); const allowedPokemon = scene.getPokemonAllowedInBattle();
if (allowedPokemon.length === 0) { if (allowedPokemon.length === 0) {
// If there are no longer any legal pokemon in the party, game over. // If there are no longer any legal pokemon in the party, game over.
scene.clearPhaseQueue(); scene.clearPhaseQueue();

View File

@ -100,7 +100,7 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter =
// Only Pokemon that can gain benefits are above half HP with no status // Only Pokemon that can gain benefits are above half HP with no status
const selectableFilter = (pokemon: Pokemon) => { const selectableFilter = (pokemon: Pokemon) => {
// If pokemon meets primary pokemon reqs, it can be selected // If pokemon meets primary pokemon reqs, it can be selected
if (!pokemon.isAllowed()) { if (!pokemon.isAllowedInChallenge()) {
return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null; return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null;
} }
if (!encounter.pokemonMeetsPrimaryRequirements(scene, pokemon)) { if (!encounter.pokemonMeetsPrimaryRequirements(scene, pokemon)) {

View File

@ -134,7 +134,7 @@ export const TeleportingHijinksEncounter: MysteryEncounter =
// Init enemy // Init enemy
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true); const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true); const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon));
const config: EnemyPartyConfig = { const config: EnemyPartyConfig = {
@ -170,7 +170,7 @@ async function doBiomeTransitionDialogueAndBattleInit(scene: BattleScene) {
// Init enemy // Init enemy
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true); const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true); const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon));

View File

@ -126,7 +126,7 @@ export const TheExpertPokemonBreederEncounter: MysteryEncounter =
]; ];
// Determine the 3 pokemon the player can battle with // Determine the 3 pokemon the player can battle with
let partyCopy = scene.getParty().slice(0); let partyCopy = scene.getPlayerParty().slice(0);
partyCopy = partyCopy partyCopy = partyCopy
.filter(p => p.isAllowedInBattle()) .filter(p => p.isAllowedInBattle())
.sort((a, b) => a.friendship - b.friendship); .sort((a, b) => a.friendship - b.friendship);
@ -508,11 +508,11 @@ function getEggOptions(scene: BattleScene, commonEggs: number, rareEggs: number)
} }
function removePokemonFromPartyAndStoreHeldItems(scene: BattleScene, encounter: MysteryEncounter, chosenPokemon: PlayerPokemon) { function removePokemonFromPartyAndStoreHeldItems(scene: BattleScene, encounter: MysteryEncounter, chosenPokemon: PlayerPokemon) {
const party = scene.getParty(); const party = scene.getPlayerParty();
const chosenIndex = party.indexOf(chosenPokemon); const chosenIndex = party.indexOf(chosenPokemon);
party[chosenIndex] = party[0]; party[chosenIndex] = party[0];
party[0] = chosenPokemon; party[0] = chosenPokemon;
encounter.misc.originalParty = scene.getParty().slice(1); encounter.misc.originalParty = scene.getPlayerParty().slice(1);
encounter.misc.originalPartyHeldItems = encounter.misc.originalParty encounter.misc.originalPartyHeldItems = encounter.misc.originalParty
.map(p => p.getHeldItems()); .map(p => p.getHeldItems());
scene["party"] = [ scene["party"] = [
@ -529,7 +529,7 @@ function checkAchievement(scene: BattleScene) {
function restorePartyAndHeldItems(scene: BattleScene) { function restorePartyAndHeldItems(scene: BattleScene) {
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
// Restore original party // Restore original party
scene.getParty().push(...encounter.misc.originalParty); scene.getPlayerParty().push(...encounter.misc.originalParty);
// Restore held items // Restore held items
const originalHeldItems = encounter.misc.originalPartyHeldItems; const originalHeldItems = encounter.misc.originalPartyHeldItems;

View File

@ -140,7 +140,7 @@ export const TheStrongStuffEncounter: MysteryEncounter =
// -15 to all base stats of highest BST (halved for HP), +10 to all base stats of rest of party (halved for HP) // -15 to all base stats of highest BST (halved for HP), +10 to all base stats of rest of party (halved for HP)
// Sort party by bst // Sort party by bst
const sortedParty = scene.getParty().slice(0) const sortedParty = scene.getPlayerParty().slice(0)
.sort((pokemon1, pokemon2) => { .sort((pokemon1, pokemon2) => {
const pokemon1Bst = pokemon1.calculateBaseStats().reduce((a, b) => a + b, 0); const pokemon1Bst = pokemon1.calculateBaseStats().reduce((a, b) => a + b, 0);
const pokemon2Bst = pokemon2.calculateBaseStats().reduce((a, b) => a + b, 0); const pokemon2Bst = pokemon2.calculateBaseStats().reduce((a, b) => a + b, 0);

View File

@ -189,7 +189,7 @@ function endTrainerBattleAndShowDialogue(scene: BattleScene): Promise<void> {
const playerField = scene.getPlayerField(); const playerField = scene.getPlayerField();
playerField.forEach((_, p) => scene.unshiftPhase(new ReturnPhase(scene, p))); playerField.forEach((_, p) => scene.unshiftPhase(new ReturnPhase(scene, p)));
for (const pokemon of scene.getParty()) { for (const pokemon of scene.getPlayerParty()) {
// Only trigger form change when Eiscue is in Noice form // Only trigger form change when Eiscue is in Noice form
// Hardcoded Eiscue for now in case it is fused with another pokemon // Hardcoded Eiscue for now in case it is fused with another pokemon
if (pokemon.species.speciesId === Species.EISCUE && pokemon.hasAbility(Abilities.ICE_FACE) && pokemon.formIndex === 1) { if (pokemon.species.speciesId === Species.EISCUE && pokemon.hasAbility(Abilities.ICE_FACE) && pokemon.formIndex === 1) {

View File

@ -152,7 +152,7 @@ export const TrainingSessionEncounter: MysteryEncounter =
} }
// Add pokemon and mods back // Add pokemon and mods back
scene.getParty().push(playerPokemon); scene.getPlayerParty().push(playerPokemon);
for (const mod of modifiers.value) { for (const mod of modifiers.value) {
mod.pokemonId = playerPokemon.id; mod.pokemonId = playerPokemon.id;
scene.addModifier(mod, true, false, false, true); scene.addModifier(mod, true, false, false, true);
@ -229,7 +229,7 @@ export const TrainingSessionEncounter: MysteryEncounter =
scene.gameData.setPokemonCaught(playerPokemon, false); scene.gameData.setPokemonCaught(playerPokemon, false);
// Add pokemon and modifiers back // Add pokemon and modifiers back
scene.getParty().push(playerPokemon); scene.getPlayerParty().push(playerPokemon);
for (const mod of modifiers.value) { for (const mod of modifiers.value) {
mod.pokemonId = playerPokemon.id; mod.pokemonId = playerPokemon.id;
scene.addModifier(mod, true, false, false, true); scene.addModifier(mod, true, false, false, true);
@ -342,7 +342,7 @@ export const TrainingSessionEncounter: MysteryEncounter =
scene.gameData.setPokemonCaught(playerPokemon, false); scene.gameData.setPokemonCaught(playerPokemon, false);
// Add pokemon and mods back // Add pokemon and mods back
scene.getParty().push(playerPokemon); scene.getPlayerParty().push(playerPokemon);
for (const mod of modifiers.value) { for (const mod of modifiers.value) {
mod.pokemonId = playerPokemon.id; mod.pokemonId = playerPokemon.id;
scene.addModifier(mod, true, false, false, true); scene.addModifier(mod, true, false, false, true);

View File

@ -164,7 +164,7 @@ async function tryApplyDigRewardItems(scene: BattleScene) {
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
const leftovers = generateModifierType(scene, modifierTypes.LEFTOVERS) as PokemonHeldItemModifierType; const leftovers = generateModifierType(scene, modifierTypes.LEFTOVERS) as PokemonHeldItemModifierType;
const party = scene.getParty(); const party = scene.getPlayerParty();
// Iterate over the party until an item was successfully given // Iterate over the party until an item was successfully given
// First leftovers // First leftovers

View File

@ -51,7 +51,7 @@ export const UncommonBreedEncounter: MysteryEncounter =
// Calculate boss mon // Calculate boss mon
// Level equal to 2 below highest party member // Level equal to 2 below highest party member
const level = getHighestLevelPlayerPokemon(scene, false, true).level - 2; const level = getHighestLevelPlayerPokemon(scene, false, true).level - 2;
const species = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true); const species = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
const pokemon = new EnemyPokemon(scene, species, level, TrainerSlot.NONE, true); const pokemon = new EnemyPokemon(scene, species, level, TrainerSlot.NONE, true);
// Pokemon will always have one of its egg moves in its moveset // Pokemon will always have one of its egg moves in its moveset

View File

@ -176,7 +176,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
for (const transformation of scene.currentBattle.mysteryEncounter!.misc.teamTransformations) { for (const transformation of scene.currentBattle.mysteryEncounter!.misc.teamTransformations) {
scene.removePokemonFromPlayerParty(transformation.previousPokemon, false); scene.removePokemonFromPlayerParty(transformation.previousPokemon, false);
scene.getParty().push(transformation.newPokemon); scene.getPlayerParty().push(transformation.newPokemon);
} }
}) })
.withOptionPhase(async (scene: BattleScene) => { .withOptionPhase(async (scene: BattleScene) => {
@ -280,7 +280,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
const onBeforeRewards = () => { const onBeforeRewards = () => {
// Before battle rewards, unlock the passive on a pokemon in the player's team for the rest of the run (not permanently) // Before battle rewards, unlock the passive on a pokemon in the player's team for the rest of the run (not permanently)
// One random pokemon will get its passive unlocked // One random pokemon will get its passive unlocked
const passiveDisabledPokemon = scene.getParty().filter(p => !p.passive); const passiveDisabledPokemon = scene.getPlayerParty().filter(p => !p.passive);
if (passiveDisabledPokemon?.length > 0) { if (passiveDisabledPokemon?.length > 0) {
const enablePassiveMon = passiveDisabledPokemon[randSeedInt(passiveDisabledPokemon.length)]; const enablePassiveMon = passiveDisabledPokemon[randSeedInt(passiveDisabledPokemon.length)];
enablePassiveMon.passive = true; enablePassiveMon.passive = true;
@ -306,7 +306,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
}, },
async (scene: BattleScene) => { async (scene: BattleScene) => {
// Leave, reduce party levels by 10% // Leave, reduce party levels by 10%
for (const pokemon of scene.getParty()) { for (const pokemon of scene.getPlayerParty()) {
pokemon.level = Math.max(Math.ceil((100 - PERCENT_LEVEL_LOSS_ON_REFUSE) / 100 * pokemon.level), 1); pokemon.level = Math.max(Math.ceil((100 - PERCENT_LEVEL_LOSS_ON_REFUSE) / 100 * pokemon.level), 1);
pokemon.exp = getLevelTotalExp(pokemon.level, pokemon.species.growthRate); pokemon.exp = getLevelTotalExp(pokemon.level, pokemon.species.growthRate);
pokemon.levelExp = 0; pokemon.levelExp = 0;
@ -329,7 +329,7 @@ interface PokemonTransformation {
} }
function getTeamTransformations(scene: BattleScene): PokemonTransformation[] { function getTeamTransformations(scene: BattleScene): PokemonTransformation[] {
const party = scene.getParty(); const party = scene.getPlayerParty();
// Removes all pokemon from the party // Removes all pokemon from the party
const alreadyUsedSpecies: PokemonSpecies[] = party.map(p => p.species); const alreadyUsedSpecies: PokemonSpecies[] = party.map(p => p.species);
const pokemonTransformations: PokemonTransformation[] = party.map(p => { const pokemonTransformations: PokemonTransformation[] = party.map(p => {
@ -404,7 +404,7 @@ async function doNewTeamPostProcess(scene: BattleScene, transformations: Pokemon
if (shouldGetOldGateau(newPokemon)) { if (shouldGetOldGateau(newPokemon)) {
const stats = getOldGateauBoostedStats(newPokemon); const stats = getOldGateauBoostedStats(newPokemon);
const modType = modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU() const modType = modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU()
.generateType(scene.getParty(), [ OLD_GATEAU_STATS_UP, stats ]) .generateType(scene.getPlayerParty(), [ OLD_GATEAU_STATS_UP, stats ])
?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU); ?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU);
const modifier = modType?.newModifier(newPokemon); const modifier = modType?.newModifier(newPokemon);
if (modifier) { if (modifier) {
@ -417,7 +417,7 @@ async function doNewTeamPostProcess(scene: BattleScene, transformations: Pokemon
} }
// One random pokemon will get its passive unlocked // One random pokemon will get its passive unlocked
const passiveDisabledPokemon = scene.getParty().filter(p => !p.passive); const passiveDisabledPokemon = scene.getPlayerParty().filter(p => !p.passive);
if (passiveDisabledPokemon?.length > 0) { if (passiveDisabledPokemon?.length > 0) {
const enablePassiveMon = passiveDisabledPokemon[randSeedInt(passiveDisabledPokemon.length)]; const enablePassiveMon = passiveDisabledPokemon[randSeedInt(passiveDisabledPokemon.length)];
enablePassiveMon.passive = true; enablePassiveMon.passive = true;

View File

@ -88,7 +88,7 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption {
* @param pokemon * @param pokemon
*/ */
pokemonMeetsPrimaryRequirements(scene: BattleScene, pokemon: Pokemon): boolean { pokemonMeetsPrimaryRequirements(scene: BattleScene, pokemon: Pokemon): boolean {
return !this.primaryPokemonRequirements.some(req => !req.queryParty(scene.getParty()).map(p => p.id).includes(pokemon.id)); return !this.primaryPokemonRequirements.some(req => !req.queryParty(scene.getPlayerParty()).map(p => p.id).includes(pokemon.id));
} }
/** /**
@ -102,10 +102,10 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption {
if (!this.primaryPokemonRequirements || this.primaryPokemonRequirements.length === 0) { if (!this.primaryPokemonRequirements || this.primaryPokemonRequirements.length === 0) {
return true; return true;
} }
let qualified: PlayerPokemon[] = scene.getParty(); let qualified: PlayerPokemon[] = scene.getPlayerParty();
for (const req of this.primaryPokemonRequirements) { for (const req of this.primaryPokemonRequirements) {
if (req.meetsRequirement(scene)) { if (req.meetsRequirement(scene)) {
const queryParty = req.queryParty(scene.getParty()); const queryParty = req.queryParty(scene.getPlayerParty());
qualified = qualified.filter(pkmn => queryParty.includes(pkmn)); qualified = qualified.filter(pkmn => queryParty.includes(pkmn));
} else { } else {
this.primaryPokemon = undefined; this.primaryPokemon = undefined;
@ -162,10 +162,10 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption {
return true; return true;
} }
let qualified: PlayerPokemon[] = scene.getParty(); let qualified: PlayerPokemon[] = scene.getPlayerParty();
for (const req of this.secondaryPokemonRequirements) { for (const req of this.secondaryPokemonRequirements) {
if (req.meetsRequirement(scene)) { if (req.meetsRequirement(scene)) {
const queryParty = req.queryParty(scene.getParty()); const queryParty = req.queryParty(scene.getPlayerParty());
qualified = qualified.filter(pkmn => queryParty.includes(pkmn)); qualified = qualified.filter(pkmn => queryParty.includes(pkmn));
} else { } else {
this.secondaryPokemon = []; this.secondaryPokemon = [];

View File

@ -1,21 +1,21 @@
import { PlayerPokemon } from "#app/field/pokemon";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import { isNullOrUndefined } from "#app/utils"; import { allAbilities } from "#app/data/ability";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { TimeOfDay } from "#enums/time-of-day";
import { Nature } from "#app/data/nature";
import { EvolutionItem, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions"; import { EvolutionItem, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
import { Nature } from "#app/data/nature";
import { FormChangeItem, pokemonFormChanges, SpeciesFormChangeItemTrigger } from "#app/data/pokemon-forms"; import { FormChangeItem, pokemonFormChanges, SpeciesFormChangeItemTrigger } from "#app/data/pokemon-forms";
import { StatusEffect } from "#app/data/status-effect"; import { StatusEffect } from "#app/data/status-effect";
import { Type } from "#app/data/type"; import { Type } from "#app/data/type";
import { WeatherType } from "#app/data/weather"; import { WeatherType } from "#app/data/weather";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { PlayerPokemon } from "#app/field/pokemon";
import { AttackTypeBoosterModifier } from "#app/modifier/modifier"; import { AttackTypeBoosterModifier } from "#app/modifier/modifier";
import { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type"; import { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type";
import { isNullOrUndefined } from "#app/utils";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import { SpeciesFormKey } from "#enums/species-form-key"; import { SpeciesFormKey } from "#enums/species-form-key";
import { allAbilities } from "#app/data/ability"; import { TimeOfDay } from "#enums/time-of-day";
export interface EncounterRequirement { export interface EncounterRequirement {
meetsRequirement(scene: BattleScene): boolean; // Boolean to see if a requirement is met meetsRequirement(scene: BattleScene): boolean; // Boolean to see if a requirement is met
@ -333,7 +333,7 @@ export class PartySizeRequirement extends EncounterSceneRequirement {
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
if (!isNullOrUndefined(this.partySizeRange) && this.partySizeRange[0] <= this.partySizeRange[1]) { if (!isNullOrUndefined(this.partySizeRange) && this.partySizeRange[0] <= this.partySizeRange[1]) {
const partySize = this.excludeDisallowedPokemon ? scene.getParty().filter(p => p.isAllowedInBattle()).length : scene.getParty().length; const partySize = this.excludeDisallowedPokemon ? scene.getPokemonAllowedInBattle().length : scene.getPlayerParty().length;
if (partySize >= 0 && (this.partySizeRange[0] >= 0 && this.partySizeRange[0] > partySize) || (this.partySizeRange[1] >= 0 && this.partySizeRange[1] < partySize)) { if (partySize >= 0 && (this.partySizeRange[0] >= 0 && this.partySizeRange[0] > partySize) || (this.partySizeRange[1] >= 0 && this.partySizeRange[1] < partySize)) {
return false; return false;
} }
@ -343,7 +343,7 @@ export class PartySizeRequirement extends EncounterSceneRequirement {
} }
override getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] { override getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
return [ "partySize", scene.getParty().length.toString() ]; return [ "partySize", scene.getPlayerParty().length.toString() ];
} }
} }
@ -358,7 +358,7 @@ export class PersistentModifierRequirement extends EncounterSceneRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredHeldItemModifiers?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredHeldItemModifiers?.length < 0) {
return false; return false;
} }
@ -421,7 +421,7 @@ export class SpeciesRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredSpecies?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredSpecies?.length < 0) {
return false; return false;
} }
@ -459,7 +459,7 @@ export class NatureRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredNature?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredNature?.length < 0) {
return false; return false;
} }
@ -498,7 +498,7 @@ export class TypeRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
let partyPokemon = scene.getParty(); let partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon)) { if (isNullOrUndefined(partyPokemon)) {
return false; return false;
@ -545,7 +545,7 @@ export class MoveRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) {
return false; return false;
} }
@ -594,7 +594,7 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) {
return false; return false;
} }
@ -635,7 +635,7 @@ export class AbilityRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredAbilities?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredAbilities?.length < 0) {
return false; return false;
} }
@ -677,7 +677,7 @@ export class StatusEffectRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredStatusEffect?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredStatusEffect?.length < 0) {
return false; return false;
} }
@ -746,7 +746,7 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredFormChangeItem?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredFormChangeItem?.length < 0) {
return false; return false;
} }
@ -798,7 +798,7 @@ export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon) || this.requiredEvolutionItem?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredEvolutionItem?.length < 0) {
return false; return false;
} }
@ -849,7 +849,7 @@ export class HeldItemRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon)) { if (isNullOrUndefined(partyPokemon)) {
return false; return false;
} }
@ -900,7 +900,7 @@ export class AttackTypeBoosterHeldItemTypeRequirement extends EncounterPokemonRe
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
if (isNullOrUndefined(partyPokemon)) { if (isNullOrUndefined(partyPokemon)) {
return false; return false;
} }
@ -957,7 +957,7 @@ export class LevelRequirement extends EncounterPokemonRequirement {
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
// Party Pokemon inside required level range // Party Pokemon inside required level range
if (!isNullOrUndefined(this.requiredLevelRange) && this.requiredLevelRange[0] <= this.requiredLevelRange[1]) { if (!isNullOrUndefined(this.requiredLevelRange) && this.requiredLevelRange[0] <= this.requiredLevelRange[1]) {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
const pokemonInRange = this.queryParty(partyPokemon); const pokemonInRange = this.queryParty(partyPokemon);
if (pokemonInRange.length < this.minNumberOfPokemon) { if (pokemonInRange.length < this.minNumberOfPokemon) {
return false; return false;
@ -995,7 +995,7 @@ export class FriendshipRequirement extends EncounterPokemonRequirement {
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
// Party Pokemon inside required friendship range // Party Pokemon inside required friendship range
if (!isNullOrUndefined(this.requiredFriendshipRange) && this.requiredFriendshipRange[0] <= this.requiredFriendshipRange[1]) { if (!isNullOrUndefined(this.requiredFriendshipRange) && this.requiredFriendshipRange[0] <= this.requiredFriendshipRange[1]) {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
const pokemonInRange = this.queryParty(partyPokemon); const pokemonInRange = this.queryParty(partyPokemon);
if (pokemonInRange.length < this.minNumberOfPokemon) { if (pokemonInRange.length < this.minNumberOfPokemon) {
return false; return false;
@ -1038,7 +1038,7 @@ export class HealthRatioRequirement extends EncounterPokemonRequirement {
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
// Party Pokemon's health inside required health range // Party Pokemon's health inside required health range
if (!isNullOrUndefined(this.requiredHealthRange) && this.requiredHealthRange[0] <= this.requiredHealthRange[1]) { if (!isNullOrUndefined(this.requiredHealthRange) && this.requiredHealthRange[0] <= this.requiredHealthRange[1]) {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
const pokemonInRange = this.queryParty(partyPokemon); const pokemonInRange = this.queryParty(partyPokemon);
if (pokemonInRange.length < this.minNumberOfPokemon) { if (pokemonInRange.length < this.minNumberOfPokemon) {
return false; return false;
@ -1082,7 +1082,7 @@ export class WeightRequirement extends EncounterPokemonRequirement {
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
// Party Pokemon's weight inside required weight range // Party Pokemon's weight inside required weight range
if (!isNullOrUndefined(this.requiredWeightRange) && this.requiredWeightRange[0] <= this.requiredWeightRange[1]) { if (!isNullOrUndefined(this.requiredWeightRange) && this.requiredWeightRange[0] <= this.requiredWeightRange[1]) {
const partyPokemon = scene.getParty(); const partyPokemon = scene.getPlayerParty();
const pokemonInRange = this.queryParty(partyPokemon); const pokemonInRange = this.queryParty(partyPokemon);
if (pokemonInRange.length < this.minNumberOfPokemon) { if (pokemonInRange.length < this.minNumberOfPokemon) {
return false; return false;

View File

@ -314,7 +314,7 @@ export default class MysteryEncounter implements IMysteryEncounter {
* @param pokemon * @param pokemon
*/ */
pokemonMeetsPrimaryRequirements(scene: BattleScene, pokemon: Pokemon): boolean { pokemonMeetsPrimaryRequirements(scene: BattleScene, pokemon: Pokemon): boolean {
return !this.primaryPokemonRequirements.some(req => !req.queryParty(scene.getParty()).map(p => p.id).includes(pokemon.id)); return !this.primaryPokemonRequirements.some(req => !req.queryParty(scene.getPlayerParty()).map(p => p.id).includes(pokemon.id));
} }
/** /**
@ -326,18 +326,18 @@ export default class MysteryEncounter implements IMysteryEncounter {
*/ */
private meetsPrimaryRequirementAndPrimaryPokemonSelected(scene: BattleScene): boolean { private meetsPrimaryRequirementAndPrimaryPokemonSelected(scene: BattleScene): boolean {
if (!this.primaryPokemonRequirements || this.primaryPokemonRequirements.length === 0) { if (!this.primaryPokemonRequirements || this.primaryPokemonRequirements.length === 0) {
const activeMon = scene.getParty().filter(p => p.isActive(true)); const activeMon = scene.getPlayerParty().filter(p => p.isActive(true));
if (activeMon.length > 0) { if (activeMon.length > 0) {
this.primaryPokemon = activeMon[0]; this.primaryPokemon = activeMon[0];
} else { } else {
this.primaryPokemon = scene.getParty().filter(p => p.isAllowedInBattle())[0]; this.primaryPokemon = scene.getPlayerParty().filter(p => p.isAllowedInBattle())[0];
} }
return true; return true;
} }
let qualified: PlayerPokemon[] = scene.getParty(); let qualified: PlayerPokemon[] = scene.getPlayerParty();
for (const req of this.primaryPokemonRequirements) { for (const req of this.primaryPokemonRequirements) {
if (req.meetsRequirement(scene)) { if (req.meetsRequirement(scene)) {
qualified = qualified.filter(pkmn => req.queryParty(scene.getParty()).includes(pkmn)); qualified = qualified.filter(pkmn => req.queryParty(scene.getPlayerParty()).includes(pkmn));
} else { } else {
this.primaryPokemon = undefined; this.primaryPokemon = undefined;
return false; return false;
@ -394,10 +394,10 @@ export default class MysteryEncounter implements IMysteryEncounter {
return true; return true;
} }
let qualified: PlayerPokemon[] = scene.getParty(); let qualified: PlayerPokemon[] = scene.getPlayerParty();
for (const req of this.secondaryPokemonRequirements) { for (const req of this.secondaryPokemonRequirements) {
if (req.meetsRequirement(scene)) { if (req.meetsRequirement(scene)) {
qualified = qualified.filter(pkmn => req.queryParty(scene.getParty()).includes(pkmn)); qualified = qualified.filter(pkmn => req.queryParty(scene.getPlayerParty()).includes(pkmn));
} else { } else {
this.secondaryPokemon = []; this.secondaryPokemon = [];
return false; return false;

View File

@ -39,7 +39,7 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement {
} }
override meetsRequirement(scene: BattleScene): boolean { override meetsRequirement(scene: BattleScene): boolean {
const partyPokemon = scene.getParty().filter((pkm) => (this.includeFainted ? pkm.isAllowed() : pkm.isAllowedInBattle())); const partyPokemon = scene.getPlayerParty().filter((pkm) => (this.includeFainted ? pkm.isAllowedInChallenge() : pkm.isAllowedInBattle()));
if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) { if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) {
return false; return false;

View File

@ -418,9 +418,9 @@ export function generateModifierType(scene: BattleScene, modifier: () => Modifie
// Populates item id and tier (order matters) // Populates item id and tier (order matters)
result = result result = result
.withIdFromFunc(modifierTypes[modifierId]) .withIdFromFunc(modifierTypes[modifierId])
.withTierFromPool(ModifierPoolType.PLAYER, scene.getParty()); .withTierFromPool(ModifierPoolType.PLAYER, scene.getPlayerParty());
return result instanceof ModifierTypeGenerator ? result.generateType(scene.getParty(), pregenArgs) : result; return result instanceof ModifierTypeGenerator ? result.generateType(scene.getPlayerParty(), pregenArgs) : result;
} }
/** /**
@ -451,9 +451,9 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p
// Open party screen to choose pokemon // Open party screen to choose pokemon
scene.ui.setMode(Mode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, option: PartyOption) => { scene.ui.setMode(Mode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, option: PartyOption) => {
if (slotIndex < scene.getParty().length) { if (slotIndex < scene.getPlayerParty().length) {
scene.ui.setMode(modeToSetOnExit).then(() => { scene.ui.setMode(modeToSetOnExit).then(() => {
const pokemon = scene.getParty()[slotIndex]; const pokemon = scene.getPlayerParty()[slotIndex];
const secondaryOptions = onPokemonSelected(pokemon); const secondaryOptions = onPokemonSelected(pokemon);
if (!secondaryOptions) { if (!secondaryOptions) {
scene.currentBattle.mysteryEncounter!.setDialogueToken("selectedPokemon", pokemon.getNameToRender()); scene.currentBattle.mysteryEncounter!.setDialogueToken("selectedPokemon", pokemon.getNameToRender());
@ -563,7 +563,7 @@ export function selectOptionThenPokemon(scene: BattleScene, options: OptionSelec
const selectPokemonAfterOption = (selectedOptionIndex: number) => { const selectPokemonAfterOption = (selectedOptionIndex: number) => {
// Open party screen to choose a Pokemon // Open party screen to choose a Pokemon
scene.ui.setMode(Mode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, option: PartyOption) => { scene.ui.setMode(Mode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, option: PartyOption) => {
if (slotIndex < scene.getParty().length) { if (slotIndex < scene.getPlayerParty().length) {
// Pokemon and option selected // Pokemon and option selected
scene.ui.setMode(modeToSetOnExit).then(() => { scene.ui.setMode(modeToSetOnExit).then(() => {
const result: PokemonAndOptionSelected = { selectedPokemonIndex: slotIndex, selectedOptionIndex: selectedOptionIndex }; const result: PokemonAndOptionSelected = { selectedPokemonIndex: slotIndex, selectedOptionIndex: selectedOptionIndex };
@ -713,7 +713,7 @@ export function leaveEncounterWithoutBattle(scene: BattleScene, addHealPhase: bo
* @param doNotContinue - default `false`. If set to true, will not end the battle and continue to next wave * @param doNotContinue - default `false`. If set to true, will not end the battle and continue to next wave
*/ */
export function handleMysteryEncounterVictory(scene: BattleScene, addHealPhase: boolean = false, doNotContinue: boolean = false) { export function handleMysteryEncounterVictory(scene: BattleScene, addHealPhase: boolean = false, doNotContinue: boolean = false) {
const allowedPkm = scene.getParty().filter((pkm) => pkm.isAllowedInBattle()); const allowedPkm = scene.getPlayerParty().filter((pkm) => pkm.isAllowedInBattle());
if (allowedPkm.length === 0) { if (allowedPkm.length === 0) {
scene.clearPhaseQueue(); scene.clearPhaseQueue();
@ -750,7 +750,7 @@ export function handleMysteryEncounterVictory(scene: BattleScene, addHealPhase:
* @param addHealPhase * @param addHealPhase
*/ */
export function handleMysteryEncounterBattleFailed(scene: BattleScene, addHealPhase: boolean = false, doNotContinue: boolean = false) { export function handleMysteryEncounterBattleFailed(scene: BattleScene, addHealPhase: boolean = false, doNotContinue: boolean = false) {
const allowedPkm = scene.getParty().filter((pkm) => pkm.isAllowedInBattle()); const allowedPkm = scene.getPlayerParty().filter((pkm) => pkm.isAllowedInBattle());
if (allowedPkm.length === 0) { if (allowedPkm.length === 0) {
scene.clearPhaseQueue(); scene.clearPhaseQueue();

View File

@ -53,24 +53,24 @@ export function getSpriteKeysFromPokemon(pokemon: Pokemon): { spriteKey: string,
} }
/** /**
* Will never remove the player's last non-fainted Pokemon (if they only have 1) * Will never remove the player's last non-fainted Pokemon (if they only have 1).
* Otherwise, picks a Pokemon completely at random and removes from the party * Otherwise, picks a Pokemon completely at random and removes from the party
* @param scene * @param scene
* @param isAllowed Default false. If true, only picks from legal mons. If no legal mons are found (or there is 1, with `doNotReturnLastAllowedMon = true), will return a mon that is not allowed. * @param isAllowed Default `false`. If `true`, only picks from legal mons. If no legal mons are found (or there is 1, with `doNotReturnLastAllowedMon = true`), will return a mon that is not allowed.
* @param isFainted Default false. If true, includes fainted mons. * @param isFainted Default `false`. If `true`, includes fainted mons.
* @param doNotReturnLastAllowedMon Default false. If true, will never return the last unfainted pokemon in the party. Useful when this function is being used to determine what Pokemon to remove from the party (Don't want to remove last unfainted) * @param doNotReturnLastAllowedMon Default `false`. If `true`, will never return the last unfainted pokemon in the party. Useful when this function is being used to determine what Pokemon to remove from the party (Don't want to remove last unfainted)
* @returns * @returns
*/ */
export function getRandomPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false, doNotReturnLastAllowedMon: boolean = false): PlayerPokemon { export function getRandomPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false, doNotReturnLastAllowedMon: boolean = false): PlayerPokemon {
const party = scene.getParty(); const party = scene.getPlayerParty();
let chosenIndex: number; let chosenIndex: number;
let chosenPokemon: PlayerPokemon | null = null; let chosenPokemon: PlayerPokemon | null = null;
const fullyLegalMons = party.filter(p => (!isAllowed || p.isAllowed()) && (isFainted || !p.isFainted())); const fullyLegalMons = party.filter(p => (!isAllowed || p.isAllowedInChallenge()) && (isFainted || !p.isFainted()));
const allowedOnlyMons = party.filter(p => p.isAllowed()); const allowedOnlyMons = party.filter(p => p.isAllowedInChallenge());
if (doNotReturnLastAllowedMon && fullyLegalMons.length === 1) { if (doNotReturnLastAllowedMon && fullyLegalMons.length === 1) {
// If there is only 1 legal/unfainted mon left, select from fainted legal mons // If there is only 1 legal/unfainted mon left, select from fainted legal mons
const faintedLegalMons = party.filter(p => (!isAllowed || p.isAllowed()) && p.isFainted()); const faintedLegalMons = party.filter(p => (!isAllowed || p.isAllowedInChallenge()) && p.isFainted());
if (faintedLegalMons.length > 0) { if (faintedLegalMons.length > 0) {
chosenIndex = randSeedInt(faintedLegalMons.length); chosenIndex = randSeedInt(faintedLegalMons.length);
chosenPokemon = faintedLegalMons[chosenIndex]; chosenPokemon = faintedLegalMons[chosenIndex];
@ -101,11 +101,11 @@ export function getRandomPlayerPokemon(scene: BattleScene, isAllowed: boolean =
* @returns * @returns
*/ */
export function getHighestLevelPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon { export function getHighestLevelPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon {
const party = scene.getParty(); const party = scene.getPlayerParty();
let pokemon: PlayerPokemon | null = null; let pokemon: PlayerPokemon | null = null;
for (const p of party) { for (const p of party) {
if (isAllowed && !p.isAllowed()) { if (isAllowed && !p.isAllowedInChallenge()) {
continue; continue;
} }
if (!isFainted && p.isFainted()) { if (!isFainted && p.isFainted()) {
@ -127,11 +127,11 @@ export function getHighestLevelPlayerPokemon(scene: BattleScene, isAllowed: bool
* @returns * @returns
*/ */
export function getHighestStatPlayerPokemon(scene: BattleScene, stat: PermanentStat, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon { export function getHighestStatPlayerPokemon(scene: BattleScene, stat: PermanentStat, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon {
const party = scene.getParty(); const party = scene.getPlayerParty();
let pokemon: PlayerPokemon | null = null; let pokemon: PlayerPokemon | null = null;
for (const p of party) { for (const p of party) {
if (isAllowed && !p.isAllowed()) { if (isAllowed && !p.isAllowedInChallenge()) {
continue; continue;
} }
if (!isFainted && p.isFainted()) { if (!isFainted && p.isFainted()) {
@ -152,11 +152,11 @@ export function getHighestStatPlayerPokemon(scene: BattleScene, stat: PermanentS
* @returns * @returns
*/ */
export function getLowestLevelPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon { export function getLowestLevelPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon {
const party = scene.getParty(); const party = scene.getPlayerParty();
let pokemon: PlayerPokemon | null = null; let pokemon: PlayerPokemon | null = null;
for (const p of party) { for (const p of party) {
if (isAllowed && !p.isAllowed()) { if (isAllowed && !p.isAllowedInChallenge()) {
continue; continue;
} }
if (!isFainted && p.isFainted()) { if (!isFainted && p.isFainted()) {
@ -177,11 +177,11 @@ export function getLowestLevelPlayerPokemon(scene: BattleScene, isAllowed: boole
* @returns * @returns
*/ */
export function getHighestStatTotalPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon { export function getHighestStatTotalPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon {
const party = scene.getParty(); const party = scene.getPlayerParty();
let pokemon: PlayerPokemon | null = null; let pokemon: PlayerPokemon | null = null;
for (const p of party) { for (const p of party) {
if (isAllowed && !p.isAllowed()) { if (isAllowed && !p.isAllowedInChallenge()) {
continue; continue;
} }
if (!isFainted && p.isFainted()) { if (!isFainted && p.isFainted()) {
@ -315,7 +315,7 @@ export function applyHealToPokemon(scene: BattleScene, pokemon: PlayerPokemon, h
*/ */
export async function modifyPlayerPokemonBST(pokemon: PlayerPokemon, value: number) { export async function modifyPlayerPokemonBST(pokemon: PlayerPokemon, value: number) {
const modType = modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE() const modType = modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE()
.generateType(pokemon.scene.getParty(), [ value ]) .generateType(pokemon.scene.getPlayerParty(), [ value ])
?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE); ?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE);
const modifier = modType?.newModifier(pokemon); const modifier = modType?.newModifier(pokemon);
if (modifier) { if (modifier) {
@ -591,7 +591,7 @@ export async function catchPokemon(scene: BattleScene, pokemon: EnemyPokemon, po
const addToParty = (slotIndex?: number) => { const addToParty = (slotIndex?: number) => {
const newPokemon = pokemon.addToParty(pokeballType, slotIndex); const newPokemon = pokemon.addToParty(pokeballType, slotIndex);
const modifiers = scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false); const modifiers = scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false);
if (scene.getParty().filter(p => p.isShiny()).length === 6) { if (scene.getPlayerParty().filter(p => p.isShiny()).length === 6) {
scene.validateAchv(achvs.SHINY_PARTY); scene.validateAchv(achvs.SHINY_PARTY);
} }
Promise.all(modifiers.map(m => scene.addModifier(m, true))).then(() => { Promise.all(modifiers.map(m => scene.addModifier(m, true))).then(() => {
@ -605,7 +605,7 @@ export async function catchPokemon(scene: BattleScene, pokemon: EnemyPokemon, po
}); });
}; };
Promise.all([ pokemon.hideInfo(), scene.gameData.setPokemonCaught(pokemon) ]).then(() => { Promise.all([ pokemon.hideInfo(), scene.gameData.setPokemonCaught(pokemon) ]).then(() => {
if (scene.getParty().length === 6) { if (scene.getPlayerParty().length === 6) {
const promptRelease = () => { const promptRelease = () => {
scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => { scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => {
scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true);
@ -826,7 +826,7 @@ export async function addPokemonDataToDexAndValidateAchievements(scene: BattleSc
* @param invalidSelectionKey * @param invalidSelectionKey
*/ */
export function isPokemonValidForEncounterOptionSelection(pokemon: Pokemon, scene: BattleScene, invalidSelectionKey: string): string | null { export function isPokemonValidForEncounterOptionSelection(pokemon: Pokemon, scene: BattleScene, invalidSelectionKey: string): string | null {
if (!pokemon.isAllowed()) { if (!pokemon.isAllowedInChallenge()) {
return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null; return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null;
} }
if (!pokemon.isAllowedInBattle()) { if (!pokemon.isAllowedInBattle()) {

View File

@ -325,35 +325,45 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return this.scene.field.getIndex(this) > -1; return this.scene.field.getIndex(this) > -1;
} }
isFainted(checkStatus?: boolean): boolean { /**
return !this.hp && (!checkStatus || this.status?.effect === StatusEffect.FAINT); * Checks if a pokemon is fainted (ie: its `hp <= 0`).
* It's usually better to call {@linkcode isAllowedInBattle()}
* @param checkStatus `true` to also check that the pokemon's status is {@linkcode StatusEffect.FAINT}
* @returns `true` if the pokemon is fainted
*/
public isFainted(checkStatus: boolean = false): boolean {
return this.hp <= 0 && (!checkStatus || this.status?.effect === StatusEffect.FAINT);
} }
/** /**
* Check if this pokemon is both not fainted (or a fled wild pokemon) and allowed to be in battle. * Check if this pokemon is both not fainted and allowed to be in battle based on currently active challenges.
* This is frequently a better alternative to {@link isFainted} * @returns {boolean} `true` if pokemon is allowed in battle
* @returns {boolean} True if pokemon is allowed in battle
*/ */
isAllowedInBattle(): boolean { public isAllowedInBattle(): boolean {
return !this.isFainted() && this.isAllowed(); return !this.isFainted() && this.isAllowedInChallenge();
} }
/** /**
* Check if this pokemon is allowed (no challenge exclusion) * Check if this pokemon is allowed based on any active challenges.
* This is frequently a better alternative to {@link isFainted} * It's usually better to call {@linkcode isAllowedInBattle()}
* @returns {boolean} True if pokemon is allowed in battle * @returns {boolean} `true` if pokemon is allowed in battle
*/ */
isAllowed(): boolean { public isAllowedInChallenge(): boolean {
const challengeAllowed = new Utils.BooleanHolder(true); const challengeAllowed = new Utils.BooleanHolder(true);
applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed); applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed);
return challengeAllowed.value; return challengeAllowed.value;
} }
isActive(onField?: boolean): boolean { /**
* Checks if the pokemon is allowed in battle (ie: not fainted, and allowed under any active challenges).
* @param onField `true` to also check if the pokemon is currently on the field, defaults to `false`
* @returns `true` if the pokemon is "active". Returns `false` if there is no active {@linkcode BattleScene}
*/
public isActive(onField: boolean = false): boolean {
if (!this.scene) { if (!this.scene) {
return false; return false;
} }
return this.isAllowedInBattle() && !!this.scene && (!onField || this.isOnField()); return this.isAllowedInBattle() && (!onField || this.isOnField());
} }
getDexAttr(): bigint { getDexAttr(): bigint {
@ -4198,7 +4208,7 @@ export class PlayerPokemon extends Pokemon {
return new Promise(resolve => { return new Promise(resolve => {
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.getFieldIndex(), (slotIndex:integer, option: PartyOption) => { this.scene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.getFieldIndex(), (slotIndex:integer, option: PartyOption) => {
if (slotIndex >= 0 && slotIndex < 6) { if (slotIndex >= 0 && slotIndex < 6) {
const pokemon = this.scene.getParty()[slotIndex]; const pokemon = this.scene.getPlayerParty()[slotIndex];
if (!pokemon || !pokemon.isFainted()) { if (!pokemon || !pokemon.isFainted()) {
resolve(); resolve();
} }
@ -4208,7 +4218,7 @@ export class PlayerPokemon extends Pokemon {
pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp())); pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp()));
this.scene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: pokemon.name }), 0, true); this.scene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: pokemon.name }), 0, true);
if (this.scene.currentBattle.double && this.scene.getParty().length > 1) { if (this.scene.currentBattle.double && this.scene.getPlayerParty().length > 1) {
const allyPokemon = this.getAlly(); const allyPokemon = this.getAlly();
if (slotIndex <= 1) { if (slotIndex <= 1) {
// Revived ally pokemon // Revived ally pokemon
@ -4350,7 +4360,7 @@ export class PlayerPokemon extends Pokemon {
newPokemon.fusionLuck = this.fusionLuck; newPokemon.fusionLuck = this.fusionLuck;
newPokemon.usedTMs = this.usedTMs; newPokemon.usedTMs = this.usedTMs;
this.scene.getParty().push(newPokemon); this.scene.getPlayerParty().push(newPokemon);
newPokemon.evolve((!isFusion ? newEvolution : new FusionSpeciesFormEvolution(this.id, newEvolution)), evoSpecies); newPokemon.evolve((!isFusion ? newEvolution : new FusionSpeciesFormEvolution(this.id, newEvolution)), evoSpecies);
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& m.pokemonId === this.id, true) as PokemonHeldItemModifier[]; && m.pokemonId === this.id, true) as PokemonHeldItemModifier[];
@ -4466,8 +4476,8 @@ export class PlayerPokemon extends Pokemon {
this.generateCompatibleTms(); this.generateCompatibleTms();
this.updateInfo(true); this.updateInfo(true);
const fusedPartyMemberIndex = this.scene.getParty().indexOf(pokemon); const fusedPartyMemberIndex = this.scene.getPlayerParty().indexOf(pokemon);
let partyMemberIndex = this.scene.getParty().indexOf(this); let partyMemberIndex = this.scene.getPlayerParty().indexOf(this);
if (partyMemberIndex > fusedPartyMemberIndex) { if (partyMemberIndex > fusedPartyMemberIndex) {
partyMemberIndex--; partyMemberIndex--;
} }
@ -4480,8 +4490,8 @@ export class PlayerPokemon extends Pokemon {
Promise.allSettled(transferModifiers).then(() => { Promise.allSettled(transferModifiers).then(() => {
this.scene.updateModifiers(true, true).then(() => { this.scene.updateModifiers(true, true).then(() => {
this.scene.removePartyMemberModifiers(fusedPartyMemberIndex); this.scene.removePartyMemberModifiers(fusedPartyMemberIndex);
this.scene.getParty().splice(fusedPartyMemberIndex, 1)[0]; this.scene.getPlayerParty().splice(fusedPartyMemberIndex, 1)[0];
const newPartyMemberIndex = this.scene.getParty().indexOf(this); const newPartyMemberIndex = this.scene.getPlayerParty().indexOf(this);
pokemon.getMoveset(true).map((m: PokemonMove) => this.scene.unshiftPhase(new LearnMovePhase(this.scene, newPartyMemberIndex, m.getMove().id))); pokemon.getMoveset(true).map((m: PokemonMove) => this.scene.unshiftPhase(new LearnMovePhase(this.scene, newPartyMemberIndex, m.getMove().id)));
pokemon.destroy(); pokemon.destroy();
this.updateFusionPalette(); this.updateFusionPalette();
@ -5072,7 +5082,7 @@ export class EnemyPokemon extends Pokemon {
* @returns the pokemon that was added or null if the pokemon could not be added * @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) {
const party = this.scene.getParty(); const party = this.scene.getPlayerParty();
let ret: PlayerPokemon | null = null; let ret: PlayerPokemon | null = null;
if (party.length < PLAYER_PARTY_MAX_SIZE) { if (party.length < PLAYER_PARTY_MAX_SIZE) {

View File

@ -746,7 +746,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
return 0; return 0;
} }
if (pokemon.isPlayer() && forThreshold) { if (pokemon.isPlayer() && forThreshold) {
return scene.getParty().map(p => this.getMaxHeldItemCount(p)).reduce((stackCount: number, maxStackCount: number) => Math.max(stackCount, maxStackCount), 0); return scene.getPlayerParty().map(p => this.getMaxHeldItemCount(p)).reduce((stackCount: number, maxStackCount: number) => Math.max(stackCount, maxStackCount), 0);
} }
return this.getMaxHeldItemCount(pokemon); return this.getMaxHeldItemCount(pokemon);
} }
@ -2022,7 +2022,7 @@ export abstract class ConsumablePokemonModifier extends ConsumableModifier {
abstract override apply(playerPokemon: PlayerPokemon, ...args: unknown[]): boolean | Promise<boolean>; abstract override apply(playerPokemon: PlayerPokemon, ...args: unknown[]): boolean | Promise<boolean>;
getPokemon(scene: BattleScene) { getPokemon(scene: BattleScene) {
return scene.getParty().find(p => p.id === this.pokemonId); return scene.getPlayerParty().find(p => p.id === this.pokemonId);
} }
} }
@ -2224,7 +2224,7 @@ export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier {
playerPokemon.addFriendship(FRIENDSHIP_GAIN_FROM_RARE_CANDY); playerPokemon.addFriendship(FRIENDSHIP_GAIN_FROM_RARE_CANDY);
playerPokemon.scene.unshiftPhase(new LevelUpPhase(playerPokemon.scene, playerPokemon.scene.getParty().indexOf(playerPokemon), playerPokemon.level - levelCount.value, playerPokemon.level)); playerPokemon.scene.unshiftPhase(new LevelUpPhase(playerPokemon.scene, playerPokemon.scene.getPlayerParty().indexOf(playerPokemon), playerPokemon.level - levelCount.value, playerPokemon.level));
return true; return true;
} }
@ -2244,7 +2244,7 @@ export class TmModifier extends ConsumablePokemonModifier {
*/ */
override apply(playerPokemon: PlayerPokemon): boolean { override apply(playerPokemon: PlayerPokemon): boolean {
playerPokemon.scene.unshiftPhase(new LearnMovePhase(playerPokemon.scene, playerPokemon.scene.getParty().indexOf(playerPokemon), this.type.moveId, LearnMoveType.TM)); playerPokemon.scene.unshiftPhase(new LearnMovePhase(playerPokemon.scene, playerPokemon.scene.getPlayerParty().indexOf(playerPokemon), this.type.moveId, LearnMoveType.TM));
return true; return true;
} }
@ -2266,7 +2266,7 @@ export class RememberMoveModifier extends ConsumablePokemonModifier {
*/ */
override apply(playerPokemon: PlayerPokemon, cost?: number): boolean { override apply(playerPokemon: PlayerPokemon, cost?: number): boolean {
playerPokemon.scene.unshiftPhase(new LearnMovePhase(playerPokemon.scene, playerPokemon.scene.getParty().indexOf(playerPokemon), playerPokemon.getLearnableLevelMoves()[this.levelMoveIndex], LearnMoveType.MEMORY, cost)); playerPokemon.scene.unshiftPhase(new LearnMovePhase(playerPokemon.scene, playerPokemon.scene.getPlayerParty().indexOf(playerPokemon), playerPokemon.getLearnableLevelMoves()[this.levelMoveIndex], LearnMoveType.MEMORY, cost));
return true; return true;
} }
@ -2783,7 +2783,7 @@ export class MoneyRewardModifier extends ConsumableModifier {
battleScene.addMoney(moneyAmount.value); battleScene.addMoney(moneyAmount.value);
battleScene.getParty().map(p => { battleScene.getPlayerParty().map(p => {
if (p.species?.speciesId === Species.GIMMIGHOUL || p.fusionSpecies?.speciesId === Species.GIMMIGHOUL) { if (p.species?.speciesId === Species.GIMMIGHOUL || p.fusionSpecies?.speciesId === Species.GIMMIGHOUL) {
p.evoCounter ? p.evoCounter++ : p.evoCounter = 1; p.evoCounter ? p.evoCounter++ : p.evoCounter = 1;
const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(p) as EvoTrackerModifier; const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(p) as EvoTrackerModifier;

View File

@ -1,21 +1,22 @@
import BattleScene from "#app/battle-scene";
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { getPokeballCatchMultiplier, getPokeballAtlasKey, getPokeballTintColor, doPokeballBounceAnim } from "#app/data/pokeball"; import BattleScene from "#app/battle-scene";
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
import { SubstituteTag } from "#app/data/battler-tags";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor } from "#app/data/pokeball";
import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect"; import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect";
import { PokeballType } from "#app/enums/pokeball"; import { addPokeballCaptureStars, addPokeballOpenParticles } from "#app/field/anims";
import { StatusEffect } from "#app/enums/status-effect";
import { addPokeballOpenParticles, addPokeballCaptureStars } from "#app/field/anims";
import { EnemyPokemon } from "#app/field/pokemon"; import { EnemyPokemon } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import { PokemonHeldItemModifier } from "#app/modifier/modifier"; import { PokemonHeldItemModifier } from "#app/modifier/modifier";
import { PokemonPhase } from "#app/phases/pokemon-phase";
import { VictoryPhase } from "#app/phases/victory-phase";
import { achvs } from "#app/system/achv"; import { achvs } from "#app/system/achv";
import { PartyUiMode, PartyOption } from "#app/ui/party-ui-handler"; import { PartyOption, PartyUiMode } from "#app/ui/party-ui-handler";
import { SummaryUiMode } from "#app/ui/summary-ui-handler"; import { SummaryUiMode } from "#app/ui/summary-ui-handler";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { PokeballType } from "#enums/pokeball";
import { StatusEffect } from "#enums/status-effect";
import i18next from "i18next"; import i18next from "i18next";
import { PokemonPhase } from "./pokemon-phase";
import { VictoryPhase } from "./victory-phase";
import { SubstituteTag } from "#app/data/battler-tags";
export class AttemptCapturePhase extends PokemonPhase { export class AttemptCapturePhase extends PokemonPhase {
private pokeballType: PokeballType; private pokeballType: PokeballType;
@ -235,7 +236,7 @@ export class AttemptCapturePhase extends PokemonPhase {
const addToParty = (slotIndex?: number) => { const addToParty = (slotIndex?: number) => {
const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex); const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex);
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false); const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false);
if (this.scene.getParty().filter(p => p.isShiny()).length === 6) { if (this.scene.getPlayerParty().filter(p => p.isShiny()).length === PLAYER_PARTY_MAX_SIZE) {
this.scene.validateAchv(achvs.SHINY_PARTY); this.scene.validateAchv(achvs.SHINY_PARTY);
} }
Promise.all(modifiers.map(m => this.scene.addModifier(m, true))).then(() => { Promise.all(modifiers.map(m => this.scene.addModifier(m, true))).then(() => {
@ -249,7 +250,7 @@ export class AttemptCapturePhase extends PokemonPhase {
}); });
}; };
Promise.all([ pokemon.hideInfo(), this.scene.gameData.setPokemonCaught(pokemon) ]).then(() => { Promise.all([ pokemon.hideInfo(), this.scene.gameData.setPokemonCaught(pokemon) ]).then(() => {
if (this.scene.getParty().length === 6) { if (this.scene.getPlayerParty().length === PLAYER_PARTY_MAX_SIZE) {
const promptRelease = () => { const promptRelease = () => {
this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => { this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => {
this.scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); this.scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true);

View File

@ -1,8 +1,8 @@
import BattleScene from "#app/battle-scene";
import { applyPostBattleAbAttrs, PostBattleAbAttr } from "#app/data/ability"; import { applyPostBattleAbAttrs, PostBattleAbAttr } from "#app/data/ability";
import { LapsingPersistentModifier, LapsingPokemonHeldItemModifier } from "#app/modifier/modifier"; import { LapsingPersistentModifier, LapsingPokemonHeldItemModifier } from "#app/modifier/modifier";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
import { GameOverPhase } from "./game-over-phase"; import { GameOverPhase } from "./game-over-phase";
import BattleScene from "#app/battle-scene";
export class BattleEndPhase extends BattlePhase { export class BattleEndPhase extends BattlePhase {
/** If true, will increment battles won */ /** If true, will increment battles won */
@ -41,7 +41,7 @@ export class BattleEndPhase extends BattlePhase {
} }
} }
for (const pokemon of this.scene.getParty().filter(p => p.isAllowedInBattle())) { for (const pokemon of this.scene.getPokemonAllowedInBattle()) {
applyPostBattleAbAttrs(PostBattleAbAttr, pokemon); applyPostBattleAbAttrs(PostBattleAbAttr, pokemon);
} }

View File

@ -37,7 +37,7 @@ export class CheckSwitchPhase extends BattlePhase {
return; return;
} }
if (!this.scene.getParty().slice(1).filter(p => p.isActive()).length) { if (!this.scene.getPlayerParty().slice(1).filter(p => p.isActive()).length) {
super.end(); super.end();
return; return;
} }

View File

@ -1,40 +1,40 @@
import BattleScene from "#app/battle-scene";
import { BattlerIndex, BattleType } from "#app/battle"; import { BattlerIndex, BattleType } from "#app/battle";
import BattleScene from "#app/battle-scene";
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
import { applyAbAttrs, SyncEncounterNatureAbAttr } from "#app/data/ability"; import { applyAbAttrs, SyncEncounterNatureAbAttr } from "#app/data/ability";
import { initEncounterAnims, loadEncounterAnimAssets } from "#app/data/battle-anims";
import { getCharVariantFromDialogue } from "#app/data/dialogue"; import { getCharVariantFromDialogue } from "#app/data/dialogue";
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { doTrainerExclamation } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { getGoldenBugNetSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { TrainerSlot } from "#app/data/trainer-config"; import { TrainerSlot } from "#app/data/trainer-config";
import { getRandomWeatherType } from "#app/data/weather"; import { getRandomWeatherType } from "#app/data/weather";
import { BattleSpec } from "#app/enums/battle-spec";
import { PlayerGender } from "#app/enums/player-gender";
import { Species } from "#app/enums/species";
import { EncounterPhaseEvent } from "#app/events/battle-scene"; import { EncounterPhaseEvent } from "#app/events/battle-scene";
import Pokemon, { FieldPosition } from "#app/field/pokemon"; import Pokemon, { FieldPosition } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import { ModifierPoolType, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
import { BoostBugSpawnModifier, IvScannerModifier, TurnHeldItemTransferModifier } from "#app/modifier/modifier"; import { BoostBugSpawnModifier, IvScannerModifier, TurnHeldItemTransferModifier } from "#app/modifier/modifier";
import { ModifierPoolType, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
import Overrides from "#app/overrides";
import { BattlePhase } from "#app/phases/battle-phase";
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
import { GameOverPhase } from "#app/phases/game-over-phase";
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
import { PostSummonPhase } from "#app/phases/post-summon-phase";
import { ReturnPhase } from "#app/phases/return-phase";
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
import { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase";
import { SummonPhase } from "#app/phases/summon-phase";
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
import { achvs } from "#app/system/achv"; import { achvs } from "#app/system/achv";
import { handleTutorial, Tutorial } from "#app/tutorial"; import { handleTutorial, Tutorial } from "#app/tutorial";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import i18next from "i18next"; import { randSeedInt, randSeedItem } from "#app/utils";
import { BattlePhase } from "./battle-phase"; import { BattleSpec } from "#enums/battle-spec";
import * as Utils from "#app/utils";
import { randSeedInt } from "#app/utils";
import { CheckSwitchPhase } from "./check-switch-phase";
import { GameOverPhase } from "./game-over-phase";
import { PostSummonPhase } from "./post-summon-phase";
import { ReturnPhase } from "./return-phase";
import { ScanIvsPhase } from "./scan-ivs-phase";
import { ShinySparklePhase } from "./shiny-sparkle-phase";
import { SummonPhase } from "./summon-phase";
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
import Overrides from "#app/overrides";
import { initEncounterAnims, loadEncounterAnimAssets } from "#app/data/battle-anims";
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { doTrainerExclamation } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
import { getGoldenBugNetSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { Biome } from "#enums/biome"; import { Biome } from "#enums/biome";
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { PlayerGender } from "#enums/player-gender";
import { Species } from "#enums/species";
import i18next from "i18next";
import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters"; import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters";
export class EncounterPhase extends BattlePhase { export class EncounterPhase extends BattlePhase {
@ -116,7 +116,7 @@ export class EncounterPhase extends BattlePhase {
if (this.scene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) { if (this.scene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
battle.enemyParty[e].ivs = new Array(6).fill(31); battle.enemyParty[e].ivs = new Array(6).fill(31);
} }
this.scene.getParty().slice(0, !battle.double ? 1 : 2).reverse().forEach(playerPokemon => { this.scene.getPlayerParty().slice(0, !battle.double ? 1 : 2).reverse().forEach(playerPokemon => {
applyAbAttrs(SyncEncounterNatureAbAttr, playerPokemon, null, false, battle.enemyParty[e]); applyAbAttrs(SyncEncounterNatureAbAttr, playerPokemon, null, false, battle.enemyParty[e]);
}); });
} }
@ -156,7 +156,7 @@ export class EncounterPhase extends BattlePhase {
return true; return true;
}); });
if (this.scene.getParty().filter(p => p.isShiny()).length === 6) { if (this.scene.getPlayerParty().filter(p => p.isShiny()).length === PLAYER_PARTY_MAX_SIZE) {
this.scene.validateAchv(achvs.SHINY_PARTY); this.scene.validateAchv(achvs.SHINY_PARTY);
} }
@ -248,7 +248,7 @@ export class EncounterPhase extends BattlePhase {
/*if (startingWave > 10) { /*if (startingWave > 10) {
for (let m = 0; m < Math.min(Math.floor(startingWave / 10), 99); m++) for (let m = 0; m < Math.min(Math.floor(startingWave / 10), 99); m++)
this.scene.addModifier(getPlayerModifierTypeOptionsForWave((m + 1) * 10, 1, this.scene.getParty())[0].type.newModifier(), true); this.scene.addModifier(getPlayerModifierTypeOptionsForWave((m + 1) * 10, 1, this.scene.getPlayerParty())[0].type.newModifier(), true);
this.scene.updateModifiers(true); this.scene.updateModifiers(true);
}*/ }*/
@ -259,7 +259,7 @@ export class EncounterPhase extends BattlePhase {
this.scene.mysteryEncounterSaveData.encounterSpawnChance += WEIGHT_INCREMENT_ON_SPAWN_MISS; this.scene.mysteryEncounterSaveData.encounterSpawnChance += WEIGHT_INCREMENT_ON_SPAWN_MISS;
} }
for (const pokemon of this.scene.getParty()) { for (const pokemon of this.scene.getPlayerParty()) {
if (pokemon) { if (pokemon) {
pokemon.resetBattleData(); pokemon.resetBattleData();
} }
@ -338,7 +338,7 @@ export class EncounterPhase extends BattlePhase {
const doSummon = () => { const doSummon = () => {
this.scene.currentBattle.started = true; this.scene.currentBattle.started = true;
this.scene.playBgm(undefined); this.scene.playBgm(undefined);
this.scene.pbTray.showPbTray(this.scene.getParty()); this.scene.pbTray.showPbTray(this.scene.getPlayerParty());
this.scene.pbTrayEnemy.showPbTray(this.scene.getEnemyParty()); this.scene.pbTrayEnemy.showPbTray(this.scene.getEnemyParty());
const doTrainerSummon = () => { const doTrainerSummon = () => {
this.hideEnemyTrainer(); this.hideEnemyTrainer();
@ -362,7 +362,7 @@ export class EncounterPhase extends BattlePhase {
doSummon(); doSummon();
} else { } else {
let message: string; let message: string;
this.scene.executeWithSeedOffset(() => message = Utils.randSeedItem(encounterMessages), this.scene.currentBattle.waveIndex); this.scene.executeWithSeedOffset(() => message = randSeedItem(encounterMessages), this.scene.currentBattle.waveIndex);
message = message!; // tell TS compiler it's defined now message = message!; // tell TS compiler it's defined now
const showDialogueAndSummon = () => { const showDialogueAndSummon = () => {
this.scene.ui.showDialogue(message, trainer?.getName(TrainerSlot.NONE, true), null, () => { this.scene.ui.showDialogue(message, trainer?.getName(TrainerSlot.NONE, true), null, () => {
@ -447,13 +447,13 @@ export class EncounterPhase extends BattlePhase {
if (![ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes(this.scene.currentBattle.battleType)) { if (![ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes(this.scene.currentBattle.battleType)) {
enemyField.map(p => this.scene.pushConditionalPhase(new PostSummonPhase(this.scene, p.getBattlerIndex()), () => { enemyField.map(p => this.scene.pushConditionalPhase(new PostSummonPhase(this.scene, p.getBattlerIndex()), () => {
// if there is not a player party, we can't continue // if there is not a player party, we can't continue
if (!this.scene.getParty()?.length) { if (!this.scene.getPlayerParty().length) {
return false; return false;
} }
// how many player pokemon are on the field ? // how many player pokemon are on the field ?
const pokemonsOnFieldCount = this.scene.getParty().filter(p => p.isOnField()).length; const pokemonsOnFieldCount = this.scene.getPlayerParty().filter(p => p.isOnField()).length;
// if it's a 2vs1, there will never be a 2nd pokemon on our field even // if it's a 2vs1, there will never be a 2nd pokemon on our field even
const requiredPokemonsOnField = Math.min(this.scene.getParty().filter((p) => !p.isFainted()).length, 2); const requiredPokemonsOnField = Math.min(this.scene.getPlayerParty().filter((p) => !p.isFainted()).length, 2);
// if it's a double, there should be 2, otherwise 1 // if it's a double, there should be 2, otherwise 1
if (this.scene.currentBattle.double) { if (this.scene.currentBattle.double) {
return pokemonsOnFieldCount === requiredPokemonsOnField; return pokemonsOnFieldCount === requiredPokemonsOnField;
@ -467,7 +467,7 @@ export class EncounterPhase extends BattlePhase {
} }
if (!this.loaded) { if (!this.loaded) {
const availablePartyMembers = this.scene.getParty().filter(p => p.isAllowedInBattle()); const availablePartyMembers = this.scene.getPokemonAllowedInBattle();
if (!availablePartyMembers[0].isOnField()) { if (!availablePartyMembers[0].isOnField()) {
this.scene.pushPhase(new SummonPhase(this.scene, 0)); this.scene.pushPhase(new SummonPhase(this.scene, 0));

View File

@ -223,7 +223,7 @@ export class EvolutionPhase extends Phase {
this.pokemon.evolve(this.evolution, this.pokemon.species).then(() => { this.pokemon.evolve(this.evolution, this.pokemon.species).then(() => {
const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true); const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true);
for (const lm of levelMoves) { for (const lm of levelMoves) {
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.scene.getParty().indexOf(this.pokemon), lm[1])); this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.scene.getPlayerParty().indexOf(this.pokemon), lm[1]));
} }
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene)); this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));

View File

@ -1,24 +1,24 @@
import BattleScene from "#app/battle-scene";
import { BattlerIndex, BattleType } from "#app/battle"; import { BattlerIndex, BattleType } from "#app/battle";
import { applyPostFaintAbAttrs, PostFaintAbAttr, applyPostKnockOutAbAttrs, PostKnockOutAbAttr, applyPostVictoryAbAttrs, PostVictoryAbAttr } from "#app/data/ability"; import BattleScene from "#app/battle-scene";
import { applyPostFaintAbAttrs, applyPostKnockOutAbAttrs, applyPostVictoryAbAttrs, PostFaintAbAttr, PostKnockOutAbAttr, PostVictoryAbAttr } from "#app/data/ability";
import { BattlerTagLapseType, DestinyBondTag } from "#app/data/battler-tags"; import { BattlerTagLapseType, DestinyBondTag } from "#app/data/battler-tags";
import { battleSpecDialogue } from "#app/data/dialogue"; import { battleSpecDialogue } from "#app/data/dialogue";
import { allMoves, PostVictoryStatStageChangeAttr } from "#app/data/move"; import { allMoves, PostVictoryStatStageChangeAttr } from "#app/data/move";
import { SpeciesFormChangeActiveTrigger } from "#app/data/pokemon-forms";
import { BattleSpec } from "#app/enums/battle-spec"; import { BattleSpec } from "#app/enums/battle-spec";
import { StatusEffect } from "#app/enums/status-effect"; import { StatusEffect } from "#app/enums/status-effect";
import Pokemon, { PokemonMove, EnemyPokemon, PlayerPokemon, HitResult } from "#app/field/pokemon"; import Pokemon, { EnemyPokemon, HitResult, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import { PokemonInstantReviveModifier } from "#app/modifier/modifier"; import { PokemonInstantReviveModifier } from "#app/modifier/modifier";
import { SwitchType } from "#enums/switch-type";
import i18next from "i18next"; import i18next from "i18next";
import { DamagePhase } from "./damage-phase"; import { DamagePhase } from "./damage-phase";
import { GameOverPhase } from "./game-over-phase";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "./pokemon-phase";
import { SwitchPhase } from "./switch-phase";
import { SwitchSummonPhase } from "./switch-summon-phase"; import { SwitchSummonPhase } from "./switch-summon-phase";
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase"; import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
import { GameOverPhase } from "./game-over-phase";
import { SwitchPhase } from "./switch-phase";
import { VictoryPhase } from "./victory-phase"; import { VictoryPhase } from "./victory-phase";
import { SpeciesFormChangeActiveTrigger } from "#app/data/pokemon-forms";
import { SwitchType } from "#enums/switch-type";
import { isNullOrUndefined } from "#app/utils"; import { isNullOrUndefined } from "#app/utils";
import { FRIENDSHIP_LOSS_FROM_FAINT } from "#app/data/balance/starters"; import { FRIENDSHIP_LOSS_FROM_FAINT } from "#app/data/balance/starters";
@ -120,7 +120,7 @@ export class FaintPhase extends PokemonPhase {
if (this.player) { if (this.player) {
/** The total number of Pokemon in the player's party that can legally fight */ /** The total number of Pokemon in the player's party that can legally fight */
const legalPlayerPokemon = this.scene.getParty().filter(p => p.isAllowedInBattle()); const legalPlayerPokemon = this.scene.getPokemonAllowedInBattle();
/** The total number of legal player Pokemon that aren't currently on the field */ /** The total number of legal player Pokemon that aren't currently on the field */
const legalPlayerPartyPokemon = legalPlayerPokemon.filter(p => !p.isActive(true)); const legalPlayerPartyPokemon = legalPlayerPokemon.filter(p => !p.isActive(true));
if (!legalPlayerPokemon.length) { if (!legalPlayerPokemon.length) {

View File

@ -1,8 +1,8 @@
import { clientSessionId } from "#app/account"; import { clientSessionId } from "#app/account";
import { BattleType } from "#app/battle"; import { BattleType } from "#app/battle";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import { getCharVariantFromDialogue } from "#app/data/dialogue";
import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions"; import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
import { getCharVariantFromDialogue } from "#app/data/dialogue";
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species"; import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species";
import { trainerConfigs } from "#app/data/trainer-config"; import { trainerConfigs } from "#app/data/trainer-config";
import Pokemon from "#app/field/pokemon"; import Pokemon from "#app/field/pokemon";
@ -65,7 +65,7 @@ export class GameOverPhase extends BattlePhase {
this.scene.gameData.loadSession(this.scene, this.scene.sessionSlotId).then(() => { this.scene.gameData.loadSession(this.scene, this.scene.sessionSlotId).then(() => {
this.scene.pushPhase(new EncounterPhase(this.scene, true)); this.scene.pushPhase(new EncounterPhase(this.scene, true));
const availablePartyMembers = this.scene.getParty().filter(p => p.isAllowedInBattle()).length; const availablePartyMembers = this.scene.getPokemonAllowedInBattle().length;
this.scene.pushPhase(new SummonPhase(this.scene, 0)); this.scene.pushPhase(new SummonPhase(this.scene, 0));
if (this.scene.currentBattle.double && availablePartyMembers > 1) { if (this.scene.currentBattle.double && availablePartyMembers > 1) {
@ -97,7 +97,7 @@ export class GameOverPhase extends BattlePhase {
firstClear = this.scene.validateAchv(achvs.CLASSIC_VICTORY); firstClear = this.scene.validateAchv(achvs.CLASSIC_VICTORY);
this.scene.validateAchv(achvs.UNEVOLVED_CLASSIC_VICTORY); this.scene.validateAchv(achvs.UNEVOLVED_CLASSIC_VICTORY);
this.scene.gameData.gameStats.sessionsWon++; this.scene.gameData.gameStats.sessionsWon++;
for (const pokemon of this.scene.getParty()) { for (const pokemon of this.scene.getPlayerParty()) {
this.awardRibbon(pokemon); this.awardRibbon(pokemon);
if (pokemon.species.getRootSpeciesId() !== pokemon.species.getRootSpeciesId(true)) { if (pokemon.species.getRootSpeciesId() !== pokemon.species.getRootSpeciesId(true)) {
@ -195,13 +195,13 @@ export class GameOverPhase extends BattlePhase {
if (!this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) { if (!this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.ENDLESS_MODE)); this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.ENDLESS_MODE));
} }
if (this.scene.getParty().filter(p => p.fusionSpecies).length && !this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) { if (this.scene.getPlayerParty().filter(p => p.fusionSpecies).length && !this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) {
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.SPLICED_ENDLESS_MODE)); this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.SPLICED_ENDLESS_MODE));
} }
if (!this.scene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE]) { if (!this.scene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE]) {
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.MINI_BLACK_HOLE)); this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.MINI_BLACK_HOLE));
} }
if (!this.scene.gameData.unlocks[Unlockables.EVIOLITE] && this.scene.getParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)) { if (!this.scene.gameData.unlocks[Unlockables.EVIOLITE] && this.scene.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)) {
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.EVIOLITE)); this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.EVIOLITE));
} }
} }

View File

@ -1,31 +1,31 @@
import { BattlerTagLapseType } from "#app/data/battler-tags";
import MysteryEncounterOption, { OptionPhaseCallback } from "#app/data/mystery-encounters/mystery-encounter-option";
import { SeenEncounterData } from "#app/data/mystery-encounters/mystery-encounter-save-data";
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
import { GameOverPhase } from "#app/phases/game-over-phase";
import { NewBattlePhase } from "#app/phases/new-battle-phase";
import { PostTurnStatusEffectPhase } from "#app/phases/post-turn-status-effect-phase";
import { ReturnPhase } from "#app/phases/return-phase";
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import { SummonPhase } from "#app/phases/summon-phase";
import { SwitchPhase } from "#app/phases/switch-phase";
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
import { BattleSpec } from "#enums/battle-spec";
import { BattlerTagType } from "#enums/battler-tag-type";
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { SwitchType } from "#enums/switch-type";
import i18next from "i18next"; import i18next from "i18next";
import BattleScene from "../battle-scene"; import BattleScene from "../battle-scene";
import { getCharVariantFromDialogue } from "../data/dialogue";
import { OptionSelectSettings, transitionMysteryEncounterIntroVisuals } from "../data/mystery-encounters/utils/encounter-phase-utils";
import { TrainerSlot } from "../data/trainer-config";
import { IvScannerModifier } from "../modifier/modifier";
import { Phase } from "../phase"; import { Phase } from "../phase";
import { Mode } from "../ui/ui"; import { Mode } from "../ui/ui";
import { transitionMysteryEncounterIntroVisuals, OptionSelectSettings } from "../data/mystery-encounters/utils/encounter-phase-utils";
import MysteryEncounterOption, { OptionPhaseCallback } from "#app/data/mystery-encounters/mystery-encounter-option";
import { getCharVariantFromDialogue } from "../data/dialogue";
import { TrainerSlot } from "../data/trainer-config";
import { BattleSpec } from "#enums/battle-spec";
import { IvScannerModifier } from "../modifier/modifier";
import * as Utils from "../utils"; import * as Utils from "../utils";
import { isNullOrUndefined } from "../utils"; import { isNullOrUndefined } from "../utils";
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { BattlerTagLapseType } from "#app/data/battler-tags";
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { PostTurnStatusEffectPhase } from "#app/phases/post-turn-status-effect-phase";
import { SummonPhase } from "#app/phases/summon-phase";
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
import { ReturnPhase } from "#app/phases/return-phase";
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import { NewBattlePhase } from "#app/phases/new-battle-phase";
import { GameOverPhase } from "#app/phases/game-over-phase";
import { SwitchPhase } from "#app/phases/switch-phase";
import { SeenEncounterData } from "#app/data/mystery-encounters/mystery-encounter-save-data";
import { SwitchType } from "#enums/switch-type";
import { BattlerTagType } from "#enums/battler-tag-type";
/** /**
* Will handle (in order): * Will handle (in order):
@ -238,7 +238,7 @@ export class MysteryEncounterBattleStartCleanupPhase extends Phase {
} }
// The total number of Pokemon in the player's party that can legally fight // The total number of Pokemon in the player's party that can legally fight
const legalPlayerPokemon = this.scene.getParty().filter(p => p.isAllowedInBattle()); const legalPlayerPokemon = this.scene.getPokemonAllowedInBattle();
// The total number of legal player Pokemon that aren't currently on the field // The total number of legal player Pokemon that aren't currently on the field
const legalPlayerPartyPokemon = legalPlayerPokemon.filter(p => !p.isActive(true)); const legalPlayerPartyPokemon = legalPlayerPokemon.filter(p => !p.isActive(true));
if (!legalPlayerPokemon.length) { if (!legalPlayerPokemon.length) {
@ -343,7 +343,7 @@ export class MysteryEncounterBattlePhase extends Phase {
const doSummon = () => { const doSummon = () => {
scene.currentBattle.started = true; scene.currentBattle.started = true;
scene.playBgm(undefined); scene.playBgm(undefined);
scene.pbTray.showPbTray(scene.getParty()); scene.pbTray.showPbTray(scene.getPlayerParty());
scene.pbTrayEnemy.showPbTray(scene.getEnemyParty()); scene.pbTrayEnemy.showPbTray(scene.getEnemyParty());
const doTrainerSummon = () => { const doTrainerSummon = () => {
this.hideEnemyTrainer(); this.hideEnemyTrainer();
@ -402,7 +402,7 @@ export class MysteryEncounterBattlePhase extends Phase {
} }
} }
const availablePartyMembers = scene.getParty().filter(p => p.isAllowedInBattle()); const availablePartyMembers = scene.getPlayerParty().filter(p => p.isAllowedInBattle());
if (!availablePartyMembers[0].isOnField()) { if (!availablePartyMembers[0].isOnField()) {
scene.pushPhase(new SummonPhase(scene, 0)); scene.pushPhase(new SummonPhase(scene, 0));

View File

@ -11,13 +11,13 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase {
doEncounter(): void { doEncounter(): void {
this.scene.playBgm(undefined, true); this.scene.playBgm(undefined, true);
for (const pokemon of this.scene.getParty()) { for (const pokemon of this.scene.getPlayerParty()) {
if (pokemon) { if (pokemon) {
pokemon.resetBattleData(); pokemon.resetBattleData();
} }
} }
for (const pokemon of this.scene.getParty().filter(p => p.isOnField())) { for (const pokemon of this.scene.getPlayerParty().filter(p => p.isOnField())) {
applyAbAttrs(PostBiomeChangeAbAttr, pokemon, null); applyAbAttrs(PostBiomeChangeAbAttr, pokemon, null);
} }

View File

@ -13,7 +13,7 @@ export class NextEncounterPhase extends EncounterPhase {
doEncounter(): void { doEncounter(): void {
this.scene.playBgm(undefined, true); this.scene.playBgm(undefined, true);
for (const pokemon of this.scene.getParty()) { for (const pokemon of this.scene.getPlayerParty()) {
if (pokemon) { if (pokemon) {
pokemon.resetBattleData(); pokemon.resetBattleData();
} }

View File

@ -19,7 +19,7 @@ export class PartyHealPhase extends BattlePhase {
this.scene.fadeOutBgm(1000, false); this.scene.fadeOutBgm(1000, false);
} }
this.scene.ui.fadeOut(1000).then(() => { this.scene.ui.fadeOut(1000).then(() => {
for (const pokemon of this.scene.getParty()) { for (const pokemon of this.scene.getPlayerParty()) {
pokemon.hp = pokemon.getMaxHp(); pokemon.hp = pokemon.getMaxHp();
pokemon.resetStatus(); pokemon.resetStatus();
for (const move of pokemon.moveset) { for (const move of pokemon.moveset) {

View File

@ -18,7 +18,7 @@ export abstract class PartyMemberPokemonPhase extends FieldPhase {
} }
getParty(): Pokemon[] { getParty(): Pokemon[] {
return this.player ? this.scene.getParty() : this.scene.getEnemyParty(); return this.player ? this.scene.getPlayerParty() : this.scene.getEnemyParty();
} }
getPokemon(): Pokemon { getPokemon(): Pokemon {

View File

@ -38,7 +38,7 @@ export class SelectModifierPhase extends BattlePhase {
this.scene.reroll = false; this.scene.reroll = false;
} }
const party = this.scene.getParty(); const party = this.scene.getPlayerParty();
if (!this.isCopy) { if (!this.isCopy) {
regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount); regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount);
} }
@ -289,7 +289,7 @@ export class SelectModifierPhase extends BattlePhase {
} }
getModifierTypeOptions(modifierCount: integer): ModifierTypeOption[] { getModifierTypeOptions(modifierCount: integer): ModifierTypeOption[] {
return getPlayerModifierTypeOptions(modifierCount, this.scene.getParty(), this.scene.lockModifierTiers ? this.modifierTiers : undefined, this.customModifierSettings); return getPlayerModifierTypeOptions(modifierCount, this.scene.getPlayerParty(), this.scene.lockModifierTiers ? this.modifierTiers : undefined, this.customModifierSettings);
} }
copy(): SelectModifierPhase { copy(): SelectModifierPhase {

View File

@ -3,16 +3,15 @@ import { applyChallenges, ChallengeType } from "#app/data/challenge";
import { Gender } from "#app/data/gender"; import { Gender } from "#app/data/gender";
import { SpeciesFormChangeMoveLearnedTrigger } from "#app/data/pokemon-forms"; import { SpeciesFormChangeMoveLearnedTrigger } from "#app/data/pokemon-forms";
import { getPokemonSpecies } from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species";
import { Species } from "#app/enums/species"; import { overrideHeldItems, overrideModifiers } from "#app/modifier/modifier";
import { PlayerPokemon } from "#app/field/pokemon"; import Overrides from "#app/overrides";
import { overrideModifiers, overrideHeldItems } from "#app/modifier/modifier";
import { Phase } from "#app/phase"; import { Phase } from "#app/phase";
import { TitlePhase } from "#app/phases/title-phase";
import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler"; import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler";
import { Starter } from "#app/ui/starter-select-ui-handler"; import { Starter } from "#app/ui/starter-select-ui-handler";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { Species } from "#enums/species";
import SoundFade from "phaser3-rex-plugins/plugins/soundfade"; import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { TitlePhase } from "./title-phase";
import Overrides from "#app/overrides";
export class SelectStarterPhase extends Phase { export class SelectStarterPhase extends Phase {
@ -44,7 +43,7 @@ export class SelectStarterPhase extends Phase {
* @param starters {@linkcode Pokemon} with which to start the first battle * @param starters {@linkcode Pokemon} with which to start the first battle
*/ */
initBattle(starters: Starter[]) { initBattle(starters: Starter[]) {
const party = this.scene.getParty(); const party = this.scene.getPlayerParty();
const loadPokemonAssets: Promise<void>[] = []; const loadPokemonAssets: Promise<void>[] = [];
starters.forEach((starter: Starter, i: integer) => { starters.forEach((starter: Starter, i: integer) => {
if (!i && Overrides.STARTER_SPECIES_OVERRIDE) { if (!i && Overrides.STARTER_SPECIES_OVERRIDE) {
@ -103,7 +102,7 @@ export class SelectStarterPhase extends Phase {
this.scene.sessionPlayTime = 0; this.scene.sessionPlayTime = 0;
this.scene.lastSavePlayTime = 0; this.scene.lastSavePlayTime = 0;
// Ensures Keldeo (or any future Pokemon that have this type of form change) starts in the correct form // Ensures Keldeo (or any future Pokemon that have this type of form change) starts in the correct form
this.scene.getParty().forEach((p: PlayerPokemon) => { this.scene.getPlayerParty().forEach((p) => {
this.scene.triggerPokemonFormChange(p, SpeciesFormChangeMoveLearnedTrigger); this.scene.triggerPokemonFormChange(p, SpeciesFormChangeMoveLearnedTrigger);
}); });
this.end(); this.end();

View File

@ -1,7 +1,7 @@
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import { SwitchType } from "#enums/switch-type"; import PartyUiHandler, { PartyOption, PartyUiMode } from "#app/ui/party-ui-handler";
import PartyUiHandler, { PartyUiMode, PartyOption } from "#app/ui/party-ui-handler";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { SwitchType } from "#enums/switch-type";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
import { SwitchSummonPhase } from "./switch-summon-phase"; import { SwitchSummonPhase } from "./switch-summon-phase";
@ -38,7 +38,7 @@ export class SwitchPhase extends BattlePhase {
super.start(); super.start();
// Skip modal switch if impossible (no remaining party members that aren't in battle) // Skip modal switch if impossible (no remaining party members that aren't in battle)
if (this.isModal && !this.scene.getParty().filter(p => p.isAllowedInBattle() && !p.isActive(true)).length) { if (this.isModal && !this.scene.getPlayerParty().filter(p => p.isAllowedInBattle() && !p.isActive(true)).length) {
return super.end(); return super.end();
} }
@ -49,7 +49,7 @@ export class SwitchPhase extends BattlePhase {
* if the mon should have already been returned but is still alive and well * if the mon should have already been returned but is still alive and well
* on the field. see also; battle.test.ts * on the field. see also; battle.test.ts
*/ */
if (this.isModal && !this.doReturn && !this.scene.getParty()[this.fieldIndex].isFainted()) { if (this.isModal && !this.doReturn && !this.scene.getPlayerParty()[this.fieldIndex].isFainted()) {
return super.end(); return super.end();
} }
@ -59,7 +59,7 @@ export class SwitchPhase extends BattlePhase {
} }
// Override field index to 0 in case of double battle where 2/3 remaining legal party members fainted at once // Override field index to 0 in case of double battle where 2/3 remaining legal party members fainted at once
const fieldIndex = this.scene.currentBattle.getBattlerCount() === 1 || this.scene.getParty().filter(p => p.isAllowedInBattle()).length > 1 ? this.fieldIndex : 0; const fieldIndex = this.scene.currentBattle.getBattlerCount() === 1 || this.scene.getPokemonAllowedInBattle().length > 1 ? this.fieldIndex : 0;
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => { this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => {
if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) { if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) {

View File

@ -54,7 +54,7 @@ export class SwitchSummonPhase extends SummonPhase {
} }
} }
if (!this.doReturn || (this.slotIndex !== -1 && !(this.player ? this.scene.getParty() : this.scene.getEnemyParty())[this.slotIndex])) { if (!this.doReturn || (this.slotIndex !== -1 && !(this.player ? this.scene.getPlayerParty() : this.scene.getEnemyParty())[this.slotIndex])) {
if (this.player) { if (this.player) {
return this.switchAndSummon(); return this.switchAndSummon();
} else { } else {

View File

@ -1,21 +1,21 @@
import { loggedInUser } from "#app/account"; import { loggedInUser } from "#app/account";
import BattleScene from "#app/battle-scene";
import { BattleType } from "#app/battle"; import { BattleType } from "#app/battle";
import { getDailyRunStarters, fetchDailyRunSeed } from "#app/data/daily-run"; import BattleScene from "#app/battle-scene";
import { fetchDailyRunSeed, getDailyRunStarters } from "#app/data/daily-run";
import { Gender } from "#app/data/gender"; import { Gender } from "#app/data/gender";
import { getBiomeKey } from "#app/field/arena"; import { getBiomeKey } from "#app/field/arena";
import { GameModes, GameMode, getGameMode } from "#app/game-mode"; import { GameMode, GameModes, getGameMode } from "#app/game-mode";
import { regenerateModifierPoolThresholds, ModifierPoolType, modifierTypes, getDailyRunStarterModifiers } from "#app/modifier/modifier-type"; import { Modifier } from "#app/modifier/modifier";
import { getDailyRunStarterModifiers, ModifierPoolType, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
import { Phase } from "#app/phase"; import { Phase } from "#app/phase";
import { SessionSaveData } from "#app/system/game-data"; import { SessionSaveData } from "#app/system/game-data";
import { Unlockables } from "#app/system/unlockables"; import { Unlockables } from "#app/system/unlockables";
import { vouchers } from "#app/system/voucher"; import { vouchers } from "#app/system/voucher";
import { OptionSelectItem, OptionSelectConfig } from "#app/ui/abstact-option-select-ui-handler"; import { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler"; import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import i18next from "i18next";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Modifier } from "#app/modifier/modifier"; import i18next from "i18next";
import { CheckSwitchPhase } from "./check-switch-phase"; import { CheckSwitchPhase } from "./check-switch-phase";
import { EncounterPhase } from "./encounter-phase"; import { EncounterPhase } from "./encounter-phase";
import { SelectChallengePhase } from "./select-challenge-phase"; import { SelectChallengePhase } from "./select-challenge-phase";
@ -203,7 +203,7 @@ export class TitlePhase extends Phase {
const starters = getDailyRunStarters(this.scene, seed); const starters = getDailyRunStarters(this.scene, seed);
const startingLevel = this.scene.gameMode.getStartingLevel(); const startingLevel = this.scene.gameMode.getStartingLevel();
const party = this.scene.getParty(); const party = this.scene.getPlayerParty();
const loadPokemonAssets: Promise<void>[] = []; const loadPokemonAssets: Promise<void>[] = [];
for (const starter of starters) { for (const starter of starters) {
const starterProps = this.scene.gameData.getSpeciesDexAttrProps(starter.species, starter.dexAttr); const starterProps = this.scene.gameData.getSpeciesDexAttrProps(starter.species, starter.dexAttr);
@ -276,7 +276,7 @@ export class TitlePhase extends Phase {
this.scene.pushPhase(new EncounterPhase(this.scene, this.loaded)); this.scene.pushPhase(new EncounterPhase(this.scene, this.loaded));
if (this.loaded) { if (this.loaded) {
const availablePartyMembers = this.scene.getParty().filter(p => p.isAllowedInBattle()).length; const availablePartyMembers = this.scene.getPokemonAllowedInBattle().length;
this.scene.pushPhase(new SummonPhase(this.scene, 0, true, true)); this.scene.pushPhase(new SummonPhase(this.scene, 0, true, true));
if (this.scene.currentBattle.double && availablePartyMembers > 1) { if (this.scene.currentBattle.double && availablePartyMembers > 1) {

View File

@ -16,9 +16,9 @@ export class ToggleDoublePositionPhase extends BattlePhase {
const playerPokemon = this.scene.getPlayerField().find(p => p.isActive(true)); const playerPokemon = this.scene.getPlayerField().find(p => p.isActive(true));
if (playerPokemon) { if (playerPokemon) {
playerPokemon.setFieldPosition(this.double && this.scene.getParty().filter(p => p.isAllowedInBattle()).length > 1 ? FieldPosition.LEFT : FieldPosition.CENTER, 500).then(() => { playerPokemon.setFieldPosition(this.double && this.scene.getPokemonAllowedInBattle().length > 1 ? FieldPosition.LEFT : FieldPosition.CENTER, 500).then(() => {
if (playerPokemon.getFieldIndex() === 1) { if (playerPokemon.getFieldIndex() === 1) {
const party = this.scene.getParty(); const party = this.scene.getPlayerParty();
party[1] = party[0]; party[1] = party[0];
party[0] = playerPokemon; party[0] = playerPokemon;
} }

View File

@ -1,15 +1,15 @@
import BattleScene from "#app/battle-scene";
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import BattleScene from "#app/battle-scene";
import { handleMysteryEncounterBattleStartEffects, handleMysteryEncounterTurnStartEffects } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { TurnInitEvent } from "#app/events/battle-scene"; import { TurnInitEvent } from "#app/events/battle-scene";
import { PlayerPokemon } from "#app/field/pokemon"; import { PlayerPokemon } from "#app/field/pokemon";
import i18next from "i18next"; import i18next from "i18next";
import { FieldPhase } from "./field-phase";
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
import { CommandPhase } from "./command-phase"; import { CommandPhase } from "./command-phase";
import { EnemyCommandPhase } from "./enemy-command-phase"; import { EnemyCommandPhase } from "./enemy-command-phase";
import { FieldPhase } from "./field-phase";
import { GameOverPhase } from "./game-over-phase"; import { GameOverPhase } from "./game-over-phase";
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
import { TurnStartPhase } from "./turn-start-phase"; import { TurnStartPhase } from "./turn-start-phase";
import { handleMysteryEncounterBattleStartEffects, handleMysteryEncounterTurnStartEffects } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
export class TurnInitPhase extends FieldPhase { export class TurnInitPhase extends FieldPhase {
constructor(scene: BattleScene) { constructor(scene: BattleScene) {
@ -24,7 +24,7 @@ export class TurnInitPhase extends FieldPhase {
if (p.isOnField() && !p.isAllowedInBattle()) { if (p.isOnField() && !p.isAllowedInBattle()) {
this.scene.queueMessage(i18next.t("challenges:illegalEvolution", { "pokemon": p.name }), null, true); this.scene.queueMessage(i18next.t("challenges:illegalEvolution", { "pokemon": p.name }), null, true);
const allowedPokemon = this.scene.getParty().filter(p => p.isAllowedInBattle()); const allowedPokemon = this.scene.getPokemonAllowedInBattle();
if (!allowedPokemon.length) { if (!allowedPokemon.length) {
// If there are no longer any legal pokemon in the party, game over. // If there are no longer any legal pokemon in the party, game over.

View File

@ -328,7 +328,7 @@ export const achvs = {
HIDDEN_ABILITY: new Achv("HIDDEN_ABILITY", "", "HIDDEN_ABILITY.description", "ability_charm", 75), HIDDEN_ABILITY: new Achv("HIDDEN_ABILITY", "", "HIDDEN_ABILITY.description", "ability_charm", 75),
PERFECT_IVS: new Achv("PERFECT_IVS", "", "PERFECT_IVS.description", "blunder_policy", 100), PERFECT_IVS: new Achv("PERFECT_IVS", "", "PERFECT_IVS.description", "blunder_policy", 100),
CLASSIC_VICTORY: new Achv("CLASSIC_VICTORY", "", "CLASSIC_VICTORY.description", "relic_crown", 150, c => c.gameData.gameStats.sessionsWon === 0), CLASSIC_VICTORY: new Achv("CLASSIC_VICTORY", "", "CLASSIC_VICTORY.description", "relic_crown", 150, c => c.gameData.gameStats.sessionsWon === 0),
UNEVOLVED_CLASSIC_VICTORY: new Achv("UNEVOLVED_CLASSIC_VICTORY", "", "UNEVOLVED_CLASSIC_VICTORY.description", "eviolite", 175, c => c.getParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)), UNEVOLVED_CLASSIC_VICTORY: new Achv("UNEVOLVED_CLASSIC_VICTORY", "", "UNEVOLVED_CLASSIC_VICTORY.description", "eviolite", 175, c => c.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)),
MONO_GEN_ONE_VICTORY: new ChallengeAchv("MONO_GEN_ONE", "", "MONO_GEN_ONE.description", "ribbon_gen1", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 1 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), MONO_GEN_ONE_VICTORY: new ChallengeAchv("MONO_GEN_ONE", "", "MONO_GEN_ONE.description", "ribbon_gen1", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 1 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)),
MONO_GEN_TWO_VICTORY: new ChallengeAchv("MONO_GEN_TWO", "", "MONO_GEN_TWO.description", "ribbon_gen2", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 2 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), MONO_GEN_TWO_VICTORY: new ChallengeAchv("MONO_GEN_TWO", "", "MONO_GEN_TWO.description", "ribbon_gen2", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 2 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)),
MONO_GEN_THREE_VICTORY: new ChallengeAchv("MONO_GEN_THREE", "", "MONO_GEN_THREE.description", "ribbon_gen3", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 3 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), MONO_GEN_THREE_VICTORY: new ChallengeAchv("MONO_GEN_THREE", "", "MONO_GEN_THREE.description", "ribbon_gen3", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 3 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)),

View File

@ -949,7 +949,7 @@ export class GameData {
seed: scene.seed, seed: scene.seed,
playTime: scene.sessionPlayTime, playTime: scene.sessionPlayTime,
gameMode: scene.gameMode.modeId, gameMode: scene.gameMode.modeId,
party: scene.getParty().map(p => new PokemonData(p)), party: scene.getPlayerParty().map(p => new PokemonData(p)),
enemyParty: scene.getEnemyParty().map(p => new PokemonData(p)), enemyParty: scene.getEnemyParty().map(p => new PokemonData(p)),
modifiers: scene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)), modifiers: scene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)),
enemyModifiers: scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)), enemyModifiers: scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),
@ -1028,7 +1028,7 @@ export class GameData {
const loadPokemonAssets: Promise<void>[] = []; const loadPokemonAssets: Promise<void>[] = [];
const party = scene.getParty(); const party = scene.getPlayerParty();
party.splice(0, party.length); party.splice(0, party.length);
for (const p of sessionData.party) { for (const p of sessionData.party) {

View File

@ -38,7 +38,7 @@ export default class ModifierData {
type.id = this.typeId; type.id = this.typeId;
if (type instanceof ModifierTypeGenerator) { if (type instanceof ModifierTypeGenerator) {
type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getParty() : scene.getEnemyField(), this.typePregenArgs); type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getPlayerParty() : scene.getEnemyField(), this.typePregenArgs);
} }
const ret = Reflect.construct(constructor, ([ type ] as any[]).concat(this.args).concat(this.stackCount)) as PersistentModifier; const ret = Reflect.construct(constructor, ([ type ] as any[]).concat(this.args).concat(this.stackCount)) as PersistentModifier;

View File

@ -36,7 +36,7 @@ describe("Moves - Aroma Veil", () => {
it("Aroma Veil protects the Pokemon's side against most Move Restriction Battler Tags", async () => { it("Aroma Veil protects the Pokemon's side against most Move Restriction Battler Tags", async () => {
await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]); await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]);
const party = game.scene.getParty()! as PlayerPokemon[]; const party = game.scene.getPlayerParty()! as PlayerPokemon[];
game.move.select(Moves.GROWL); game.move.select(Moves.GROWL);
game.move.select(Moves.GROWL); game.move.select(Moves.GROWL);
@ -50,7 +50,7 @@ describe("Moves - Aroma Veil", () => {
it("Aroma Veil does not protect against Imprison", async () => { it("Aroma Veil does not protect against Imprison", async () => {
await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]); await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]);
const party = game.scene.getParty()! as PlayerPokemon[]; const party = game.scene.getPlayerParty()! as PlayerPokemon[];
game.move.select(Moves.GROWL); game.move.select(Moves.GROWL);
game.move.select(Moves.GROWL, 1); game.move.select(Moves.GROWL, 1);

View File

@ -40,7 +40,7 @@ describe("Abilities - BATTLE BOND", () => {
it("check if fainted pokemon switches to base form on arena reset", async () => { it("check if fainted pokemon switches to base form on arena reset", async () => {
await game.classicMode.startBattle([ Species.MAGIKARP, Species.GRENINJA ]); await game.classicMode.startBattle([ Species.MAGIKARP, Species.GRENINJA ]);
const greninja = game.scene.getParty()[1]; const greninja = game.scene.getPlayerParty()[1];
expect(greninja.formIndex).toBe(ashForm); expect(greninja.formIndex).toBe(ashForm);
greninja.hp = 0; greninja.hp = 0;

View File

@ -138,7 +138,7 @@ describe("Abilities - Disguise", () => {
}); });
await game.classicMode.startBattle([ Species.FURRET, Species.MIMIKYU ]); await game.classicMode.startBattle([ Species.FURRET, Species.MIMIKYU ]);
const mimikyu = game.scene.getParty()[1]!; const mimikyu = game.scene.getPlayerParty()[1]!;
expect(mimikyu.formIndex).toBe(bustedForm); expect(mimikyu.formIndex).toBe(bustedForm);
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);

View File

@ -81,7 +81,7 @@ describe("Abilities - Forecast", () => {
}); });
await game.startBattle([ Species.CASTFORM, Species.FEEBAS, Species.KYOGRE, Species.GROUDON, Species.RAYQUAZA, Species.ALTARIA ]); await game.startBattle([ Species.CASTFORM, Species.FEEBAS, Species.KYOGRE, Species.GROUDON, Species.RAYQUAZA, Species.ALTARIA ]);
vi.spyOn(game.scene.getParty()[5], "getAbility").mockReturnValue(allAbilities[Abilities.CLOUD_NINE]); vi.spyOn(game.scene.getPlayerParty()[5], "getAbility").mockReturnValue(allAbilities[Abilities.CLOUD_NINE]);
const castform = game.scene.getPlayerField()[0]; const castform = game.scene.getPlayerField()[0];
expect(castform.formIndex).toBe(NORMAL_FORM); expect(castform.formIndex).toBe(NORMAL_FORM);

View File

@ -192,7 +192,7 @@ describe("Abilities - Ice Face", () => {
game.doSwitchPokemon(1); game.doSwitchPokemon(1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
eiscue = game.scene.getParty()[1]; eiscue = game.scene.getPlayerParty()[1];
expect(eiscue.formIndex).toBe(noiceForm); expect(eiscue.formIndex).toBe(noiceForm);
expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined();

View File

@ -35,7 +35,7 @@ describe("Abilities - Mimicry", () => {
game.override.enemyAbility(Abilities.MISTY_SURGE); game.override.enemyAbility(Abilities.MISTY_SURGE);
await game.classicMode.startBattle([ Species.FEEBAS, Species.ABRA ]); await game.classicMode.startBattle([ Species.FEEBAS, Species.ABRA ]);
const [ playerPokemon1, playerPokemon2 ] = game.scene.getParty(); const [ playerPokemon1, playerPokemon2 ] = game.scene.getPlayerParty();
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.toNextTurn(); await game.toNextTurn();
expect(playerPokemon1.getTypes().includes(Type.FAIRY)).toBe(true); expect(playerPokemon1.getTypes().includes(Type.FAIRY)).toBe(true);

View File

@ -51,7 +51,7 @@ describe("Abilities - Pastel Veil", () => {
it("it heals the poisoned status condition of allies if user is sent out into battle", async () => { it("it heals the poisoned status condition of allies if user is sent out into battle", async () => {
await game.startBattle([ Species.MAGIKARP, Species.FEEBAS, Species.GALAR_PONYTA ]); await game.startBattle([ Species.MAGIKARP, Species.FEEBAS, Species.GALAR_PONYTA ]);
const ponyta = game.scene.getParty()[2]; const ponyta = game.scene.getPlayerParty()[2];
const magikarp = game.scene.getPlayerField()[0]; const magikarp = game.scene.getPlayerField()[0];
ponyta.abilityIndex = 1; ponyta.abilityIndex = 1;

View File

@ -43,7 +43,7 @@ describe("Abilities - POWER CONSTRUCT", () => {
await game.classicMode.startBattle([ Species.MAGIKARP, Species.ZYGARDE ]); await game.classicMode.startBattle([ Species.MAGIKARP, Species.ZYGARDE ]);
const zygarde = game.scene.getParty().find((p) => p.species.speciesId === Species.ZYGARDE); const zygarde = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.ZYGARDE);
expect(zygarde).not.toBe(undefined); expect(zygarde).not.toBe(undefined);
expect(zygarde!.formIndex).toBe(completeForm); expect(zygarde!.formIndex).toBe(completeForm);
@ -73,7 +73,7 @@ describe("Abilities - POWER CONSTRUCT", () => {
await game.classicMode.startBattle([ Species.MAGIKARP, Species.ZYGARDE ]); await game.classicMode.startBattle([ Species.MAGIKARP, Species.ZYGARDE ]);
const zygarde = game.scene.getParty().find((p) => p.species.speciesId === Species.ZYGARDE); const zygarde = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.ZYGARDE);
expect(zygarde).not.toBe(undefined); expect(zygarde).not.toBe(undefined);
expect(zygarde!.formIndex).toBe(completeForm); expect(zygarde!.formIndex).toBe(completeForm);

View File

@ -43,7 +43,7 @@ describe("Abilities - SCHOOLING", () => {
await game.startBattle([ Species.MAGIKARP, Species.WISHIWASHI ]); await game.startBattle([ Species.MAGIKARP, Species.WISHIWASHI ]);
const wishiwashi = game.scene.getParty().find((p) => p.species.speciesId === Species.WISHIWASHI)!; const wishiwashi = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.WISHIWASHI)!;
expect(wishiwashi).not.toBe(undefined); expect(wishiwashi).not.toBe(undefined);
expect(wishiwashi.formIndex).toBe(schoolForm); expect(wishiwashi.formIndex).toBe(schoolForm);

View File

@ -43,7 +43,7 @@ describe("Abilities - Serene Grace", () => {
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getPlayerParty()[0].formIndex).toBe(0);
game.move.select(moveToUse); game.move.select(moveToUse);
@ -70,7 +70,7 @@ describe("Abilities - Serene Grace", () => {
]); ]);
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getPlayerParty()[0].formIndex).toBe(0);
game.move.select(moveToUse); game.move.select(moveToUse);

View File

@ -1,17 +1,16 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { applyAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, MoveEffectChanceMultiplierAbAttr, MovePowerBoostAbAttr, PostDefendTypeChangeAbAttr } from "#app/data/ability"; import { applyAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, MoveEffectChanceMultiplierAbAttr, MovePowerBoostAbAttr, PostDefendTypeChangeAbAttr } from "#app/data/ability";
import { Stat } from "#enums/stat";
import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import * as Utils from "#app/utils"; import { NumberHolder } from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
describe("Abilities - Sheer Force", () => { describe("Abilities - Sheer Force", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
@ -39,13 +38,10 @@ describe("Abilities - Sheer Force", () => {
it("Sheer Force", async () => { it("Sheer Force", async () => {
const moveToUse = Moves.AIR_SLASH; const moveToUse = Moves.AIR_SLASH;
game.override.ability(Abilities.SHEER_FORCE); game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ await game.classicMode.startBattle([ Species.PIDGEOT ]);
Species.PIDGEOT
]);
game.scene.getEnemyPokemon()!.stats[Stat.SPDEF] = 10000;
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.move.select(moveToUse); game.move.select(moveToUse);
@ -57,8 +53,8 @@ describe("Abilities - Sheer Force", () => {
expect(move.id).toBe(Moves.AIR_SLASH); expect(move.id).toBe(Moves.AIR_SLASH);
//Verify the move is boosted and has no chance of secondary effects //Verify the move is boosted and has no chance of secondary effects
const power = new Utils.IntegerHolder(move.power); const power = new NumberHolder(move.power);
const chance = new Utils.IntegerHolder(move.chance); const chance = new NumberHolder(move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false); applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power); applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
@ -72,13 +68,11 @@ describe("Abilities - Sheer Force", () => {
it("Sheer Force with exceptions including binding moves", async () => { it("Sheer Force with exceptions including binding moves", async () => {
const moveToUse = Moves.BIND; const moveToUse = Moves.BIND;
game.override.ability(Abilities.SHEER_FORCE); game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ await game.classicMode.startBattle([ Species.PIDGEOT ]);
Species.PIDGEOT
]);
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
game.move.select(moveToUse); game.move.select(moveToUse);
@ -90,8 +84,8 @@ describe("Abilities - Sheer Force", () => {
expect(move.id).toBe(Moves.BIND); expect(move.id).toBe(Moves.BIND);
//Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1 //Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1
const power = new Utils.IntegerHolder(move.power); const power = new NumberHolder(move.power);
const chance = new Utils.IntegerHolder(move.chance); const chance = new NumberHolder(move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false); applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power); applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
@ -105,13 +99,11 @@ describe("Abilities - Sheer Force", () => {
it("Sheer Force with moves with no secondary effect", async () => { it("Sheer Force with moves with no secondary effect", async () => {
const moveToUse = Moves.TACKLE; const moveToUse = Moves.TACKLE;
game.override.ability(Abilities.SHEER_FORCE); game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ await game.classicMode.startBattle([ Species.PIDGEOT ]);
Species.PIDGEOT
]);
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
game.move.select(moveToUse); game.move.select(moveToUse);
@ -123,8 +115,8 @@ describe("Abilities - Sheer Force", () => {
expect(move.id).toBe(Moves.TACKLE); expect(move.id).toBe(Moves.TACKLE);
//Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1 //Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1
const power = new Utils.IntegerHolder(move.power); const power = new NumberHolder(move.power);
const chance = new Utils.IntegerHolder(move.chance); const chance = new NumberHolder(move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false); applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power); applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
@ -140,13 +132,11 @@ describe("Abilities - Sheer Force", () => {
game.override.enemyAbility(Abilities.COLOR_CHANGE); game.override.enemyAbility(Abilities.COLOR_CHANGE);
game.override.startingHeldItems([{ name: "KINGS_ROCK", count: 1 }]); game.override.startingHeldItems([{ name: "KINGS_ROCK", count: 1 }]);
game.override.ability(Abilities.SHEER_FORCE); game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ await game.startBattle([ Species.PIDGEOT ]);
Species.PIDGEOT
]);
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
game.move.select(moveToUse); game.move.select(moveToUse);
@ -158,8 +148,8 @@ describe("Abilities - Sheer Force", () => {
expect(move.id).toBe(Moves.CRUSH_CLAW); expect(move.id).toBe(Moves.CRUSH_CLAW);
//Disable color change due to being hit by Sheer Force //Disable color change due to being hit by Sheer Force
const power = new Utils.IntegerHolder(move.power); const power = new NumberHolder(move.power);
const chance = new Utils.IntegerHolder(move.chance); const chance = new NumberHolder(move.chance);
const user = phase.getUserPokemon()!; const user = phase.getUserPokemon()!;
const target = phase.getFirstTarget()!; const target = phase.getFirstTarget()!;
const opponentType = target.getTypes()[0]; const opponentType = target.getTypes()[0];
@ -186,7 +176,7 @@ describe("Abilities - Sheer Force", () => {
Species.PIDGEOT Species.PIDGEOT
]); ]);
const pidgeot = game.scene.getParty()[0]; const pidgeot = game.scene.getPlayerParty()[0];
const onix = game.scene.getEnemyParty()[0]; const onix = game.scene.getEnemyParty()[0];
pidgeot.stats[Stat.DEF] = 10000; pidgeot.stats[Stat.DEF] = 10000;

View File

@ -1,11 +1,11 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { applyAbAttrs, applyPreDefendAbAttrs, IgnoreMoveEffectsAbAttr, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability"; import { applyAbAttrs, applyPreDefendAbAttrs, IgnoreMoveEffectsAbAttr, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability";
import { Stat } from "#enums/stat";
import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import * as Utils from "#app/utils"; import { NumberHolder } from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -27,26 +27,22 @@ describe("Abilities - Shield Dust", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
const movesToUse = [ Moves.AIR_SLASH ];
game.override.battleType("single"); game.override.battleType("single");
game.override.enemySpecies(Species.ONIX); game.override.enemySpecies(Species.ONIX);
game.override.enemyAbility(Abilities.SHIELD_DUST); game.override.enemyAbility(Abilities.SHIELD_DUST);
game.override.startingLevel(100); game.override.startingLevel(100);
game.override.moveset(movesToUse); game.override.moveset(Moves.AIR_SLASH);
game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); game.override.enemyMoveset(Moves.TACKLE);
}); });
it("Shield Dust", async () => { it("Shield Dust", async () => {
const moveToUse = Moves.AIR_SLASH; await game.classicMode.startBattle([ Species.PIDGEOT ]);
await game.startBattle([
Species.PIDGEOT
]);
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; game.scene.getEnemyPokemon()!.stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
game.move.select(moveToUse); game.move.select(Moves.AIR_SLASH);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -56,7 +52,7 @@ describe("Abilities - Shield Dust", () => {
const move = phase.move.getMove(); const move = phase.move.getMove();
expect(move.id).toBe(Moves.AIR_SLASH); expect(move.id).toBe(Moves.AIR_SLASH);
const chance = new Utils.IntegerHolder(move.chance); const chance = new NumberHolder(move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false); applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getFirstTarget()!, phase.getUserPokemon()!, null, null, false, chance); applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getFirstTarget()!, phase.getUserPokemon()!, null, null, false, chance);
expect(chance.value).toBe(0); expect(chance.value).toBe(0);

View File

@ -43,7 +43,7 @@ describe("Abilities - SHIELDS DOWN", () => {
await game.startBattle([ Species.MAGIKARP, Species.MINIOR ]); await game.startBattle([ Species.MAGIKARP, Species.MINIOR ]);
const minior = game.scene.getParty().find((p) => p.species.speciesId === Species.MINIOR)!; const minior = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.MINIOR)!;
expect(minior).not.toBe(undefined); expect(minior).not.toBe(undefined);
expect(minior.formIndex).toBe(coreForm); expect(minior.formIndex).toBe(coreForm);

View File

@ -1,8 +1,8 @@
import { StatusEffect } from "#app/data/status-effect"; import { StatusEffect } from "#app/data/status-effect";
import GameManager from "#app/test/utils/gameManager";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -30,7 +30,7 @@ describe("Abilities - Synchronize", () => {
.enemyAbility(Abilities.SYNCHRONIZE) .enemyAbility(Abilities.SYNCHRONIZE)
.moveset([ Moves.SPLASH, Moves.THUNDER_WAVE, Moves.SPORE, Moves.PSYCHO_SHIFT ]) .moveset([ Moves.SPLASH, Moves.THUNDER_WAVE, Moves.SPORE, Moves.PSYCHO_SHIFT ])
.ability(Abilities.NO_GUARD); .ability(Abilities.NO_GUARD);
}, 20000); });
it("does not trigger when no status is applied by opponent Pokemon", async () => { it("does not trigger when no status is applied by opponent Pokemon", async () => {
await game.classicMode.startBattle([ Species.FEEBAS ]); await game.classicMode.startBattle([ Species.FEEBAS ]);
@ -38,9 +38,9 @@ describe("Abilities - Synchronize", () => {
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("BerryPhase"); await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getParty()[0].status).toBeUndefined(); expect(game.scene.getPlayerPokemon()!.status).toBeUndefined();
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase"); expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
}, 20000); });
it("sets the status of the source pokemon to Paralysis when paralyzed by it", async () => { it("sets the status of the source pokemon to Paralysis when paralyzed by it", async () => {
await game.classicMode.startBattle([ Species.FEEBAS ]); await game.classicMode.startBattle([ Species.FEEBAS ]);
@ -48,10 +48,10 @@ describe("Abilities - Synchronize", () => {
game.move.select(Moves.THUNDER_WAVE); game.move.select(Moves.THUNDER_WAVE);
await game.phaseInterceptor.to("BerryPhase"); await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS); expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS); expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase"); expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
}, 20000); });
it("does not trigger on Sleep", async () => { it("does not trigger on Sleep", async () => {
await game.classicMode.startBattle(); await game.classicMode.startBattle();
@ -60,10 +60,10 @@ describe("Abilities - Synchronize", () => {
await game.phaseInterceptor.to("BerryPhase"); await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getParty()[0].status?.effect).toBeUndefined(); expect(game.scene.getPlayerPokemon()!.status?.effect).toBeUndefined();
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.SLEEP); expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.SLEEP);
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase"); expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
}, 20000); });
it("does not trigger when Pokemon is statused by Toxic Spikes", async () => { it("does not trigger when Pokemon is statused by Toxic Spikes", async () => {
game.override game.override
@ -79,10 +79,10 @@ describe("Abilities - Synchronize", () => {
game.doSwitchPokemon(1); game.doSwitchPokemon(1);
await game.phaseInterceptor.to("BerryPhase"); await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getParty()[0].status?.effect).toBe(StatusEffect.POISON); expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.POISON);
expect(game.scene.getEnemyParty()[0].status?.effect).toBeUndefined(); expect(game.scene.getEnemyPokemon()!.status?.effect).toBeUndefined();
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase"); expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
}, 20000); });
it("shows ability even if it fails to set the status of the opponent Pokemon", async () => { it("shows ability even if it fails to set the status of the opponent Pokemon", async () => {
await game.classicMode.startBattle([ Species.PIKACHU ]); await game.classicMode.startBattle([ Species.PIKACHU ]);
@ -90,10 +90,10 @@ describe("Abilities - Synchronize", () => {
game.move.select(Moves.THUNDER_WAVE); game.move.select(Moves.THUNDER_WAVE);
await game.phaseInterceptor.to("BerryPhase"); await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getParty()[0].status?.effect).toBeUndefined(); expect(game.scene.getPlayerPokemon()!.status?.effect).toBeUndefined();
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS); expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase"); expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
}, 20000); });
it("should activate with Psycho Shift after the move clears the status", async () => { it("should activate with Psycho Shift after the move clears the status", async () => {
game.override.statusEffect(StatusEffect.PARALYSIS); game.override.statusEffect(StatusEffect.PARALYSIS);
@ -102,8 +102,8 @@ describe("Abilities - Synchronize", () => {
game.move.select(Moves.PSYCHO_SHIFT); game.move.select(Moves.PSYCHO_SHIFT);
await game.phaseInterceptor.to("BerryPhase"); await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS); // keeping old gen < V impl for now since it's buggy otherwise expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS); // keeping old gen < V impl for now since it's buggy otherwise
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS); expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase"); expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
}, 20000); });
}); });

View File

@ -42,7 +42,7 @@ describe("Abilities - Wimp Out", () => {
}); });
function confirmSwitch(): void { function confirmSwitch(): void {
const [ pokemon1, pokemon2 ] = game.scene.getParty(); const [ pokemon1, pokemon2 ] = game.scene.getPlayerParty();
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase"); expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
@ -54,7 +54,7 @@ describe("Abilities - Wimp Out", () => {
} }
function confirmNoSwitch(): void { function confirmNoSwitch(): void {
const [ pokemon1, pokemon2 ] = game.scene.getParty(); const [ pokemon1, pokemon2 ] = game.scene.getPlayerParty();
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase"); expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
@ -135,7 +135,7 @@ describe("Abilities - Wimp Out", () => {
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase"); expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
expect(game.scene.getPlayerPokemon()!.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(game.scene.getPlayerPokemon()!.getTag(BattlerTagType.TRAPPED)).toBeUndefined();
expect(game.scene.getParty()[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(game.scene.getPlayerParty()[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined();
confirmSwitch(); confirmSwitch();
}); });
@ -263,7 +263,7 @@ describe("Abilities - Wimp Out", () => {
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(game.scene.getParty()[1].getHpRatio()).toBeGreaterThan(0.5); expect(game.scene.getPlayerParty()[1].getHpRatio()).toBeGreaterThan(0.5);
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase"); expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.TYRUNT); expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.TYRUNT);
}); });
@ -424,7 +424,7 @@ describe("Abilities - Wimp Out", () => {
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(game.scene.getParty()[0].getHpRatio()).toEqual(0.51); expect(game.scene.getPlayerParty()[0].getHpRatio()).toEqual(0.51);
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase"); expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.WIMPOD); expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.WIMPOD);
}); });
@ -522,7 +522,7 @@ describe("Abilities - Wimp Out", () => {
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(game.scene.getParty()[1].status?.effect).toEqual(StatusEffect.POISON); expect(game.scene.getPlayerParty()[1].status?.effect).toEqual(StatusEffect.POISON);
confirmSwitch(); confirmSwitch();
}); });

View File

@ -1,29 +1,23 @@
import { Stat } from "#enums/stat";
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { Status, StatusEffect } from "#app/data/status-effect";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamagePhase } from "#app/phases/damage-phase";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { MessagePhase } from "#app/phases/message-phase";
import { PostSummonPhase } from "#app/phases/post-summon-phase";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { SwitchPhase } from "#app/phases/switch-phase";
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { TurnStartPhase } from "#app/phases/turn-start-phase";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import { SwitchType } from "#enums/switch-type";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { Status, StatusEffect } from "#app/data/status-effect";
import { SwitchType } from "#enums/switch-type";
describe("Abilities - ZEN MODE", () => { describe("Abilities - ZEN MODE", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
const baseForm = 0;
const zenForm = 1;
beforeAll(() => { beforeAll(() => {
phaserGame = new Phaser.Game({ phaserGame = new Phaser.Game({
@ -37,81 +31,71 @@ describe("Abilities - ZEN MODE", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
const moveToUse = Moves.SPLASH; game.override
game.override.battleType("single"); .battleType("single")
game.override.enemySpecies(Species.RATTATA); .enemySpecies(Species.RATTATA)
game.override.enemyAbility(Abilities.HYDRATION); .enemyAbility(Abilities.HYDRATION)
game.override.ability(Abilities.ZEN_MODE); .ability(Abilities.ZEN_MODE)
game.override.startingLevel(100); .startingLevel(100)
game.override.moveset([ moveToUse ]); .moveset(Moves.SPLASH)
game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); .enemyMoveset(Moves.TACKLE);
}); });
test( it("shouldn't change form when taking damage if not dropping below 50% HP", async () => {
"not enough damage to change form", await game.classicMode.startBattle([ Species.DARMANITAN ]);
async () => { const player = game.scene.getPlayerPokemon()!;
const moveToUse = Moves.SPLASH; player.stats[Stat.HP] = 100;
await game.startBattle([ Species.DARMANITAN ]); player.hp = 100;
game.scene.getParty()[0].stats[Stat.HP] = 100; expect(player.formIndex).toBe(baseForm);
game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.move.select(moveToUse); game.move.select(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("BerryPhase");
expect(player.hp).toBeLessThan(100);
expect(player.formIndex).toBe(baseForm);
});
it("should change form when falling below 50% HP", async () => {
await game.classicMode.startBattle([ Species.DARMANITAN ]);
const player = game.scene.getPlayerPokemon()!;
player.stats[Stat.HP] = 1000;
player.hp = 100;
expect(player.formIndex).toBe(baseForm);
game.move.select(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("QuietFormChangePhase");
await game.phaseInterceptor.to("TurnInitPhase", false);
expect(player.hp).not.toBe(100);
expect(player.formIndex).toBe(zenForm);
});
it("should stay zen mode when fainted", async () => {
await game.classicMode.startBattle([ Species.DARMANITAN, Species.CHARIZARD ]);
const player = game.scene.getPlayerPokemon()!;
player.stats[Stat.HP] = 1000;
player.hp = 100;
expect(player.formIndex).toBe(baseForm);
game.move.select(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);
// await game.phaseInterceptor.runFrom(DamagePhase).to(DamagePhase, false);
const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
damagePhase.updateAmount(40);
await game.phaseInterceptor.runFrom(DamagePhase).to(TurnEndPhase, false);
expect(game.scene.getParty()[0].hp).toBeLessThan(100);
expect(game.scene.getParty()[0].formIndex).toBe(0);
},
);
test(
"enough damage to change form",
async () => {
const moveToUse = Moves.SPLASH;
await game.startBattle([ Species.DARMANITAN ]);
game.scene.getParty()[0].stats[Stat.HP] = 1000;
game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.move.select(moveToUse);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to(QuietFormChangePhase);
await game.phaseInterceptor.to(TurnInitPhase, false);
expect(game.scene.getParty()[0].hp).not.toBe(100);
expect(game.scene.getParty()[0].formIndex).not.toBe(0);
},
);
test(
"kill pokemon while on zen mode",
async () => {
const moveToUse = Moves.SPLASH;
await game.startBattle([ Species.DARMANITAN, Species.CHARIZARD ]);
game.scene.getParty()[0].stats[Stat.HP] = 1000;
game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.move.select(moveToUse);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to(DamagePhase, false);
// await game.phaseInterceptor.runFrom(DamagePhase).to(DamagePhase, false);
const damagePhase = game.scene.getCurrentPhase() as DamagePhase; const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
damagePhase.updateAmount(80); damagePhase.updateAmount(80);
await game.phaseInterceptor.runFrom(DamagePhase).to(QuietFormChangePhase); await game.phaseInterceptor.to("QuietFormChangePhase");
expect(game.scene.getParty()[0].hp).not.toBe(100);
expect(game.scene.getParty()[0].formIndex).not.toBe(0); expect(player.hp).not.toBe(100);
await game.killPokemon(game.scene.getParty()[0]); expect(player.formIndex).toBe(zenForm);
expect(game.scene.getParty()[0].isFainted()).toBe(true);
await game.phaseInterceptor.run(MessagePhase); await game.killPokemon(player);
await game.phaseInterceptor.run(EnemyCommandPhase); expect(player.isFainted()).toBe(true);
await game.phaseInterceptor.run(TurnStartPhase);
await game.phaseInterceptor.to("TurnStartPhase");
game.onNextPrompt("SwitchPhase", Mode.PARTY, () => { game.onNextPrompt("SwitchPhase", Mode.PARTY, () => {
game.scene.unshiftPhase(new SwitchSummonPhase(game.scene, SwitchType.SWITCH, 0, 1, false)); game.scene.unshiftPhase(new SwitchSummonPhase(game.scene, SwitchType.SWITCH, 0, 1, false));
game.scene.ui.setMode(Mode.MESSAGE); game.scene.ui.setMode(Mode.MESSAGE);
@ -119,26 +103,20 @@ describe("Abilities - ZEN MODE", () => {
game.onNextPrompt("SwitchPhase", Mode.MESSAGE, () => { game.onNextPrompt("SwitchPhase", Mode.MESSAGE, () => {
game.endPhase(); game.endPhase();
}); });
await game.phaseInterceptor.run(SwitchPhase); await game.phaseInterceptor.to("PostSummonPhase");
await game.phaseInterceptor.to(PostSummonPhase);
expect(game.scene.getParty()[1].formIndex).toBe(1);
},
);
test( expect(game.scene.getPlayerParty()[1].formIndex).toBe(zenForm);
"check if fainted pokemon switches to base form on arena reset", });
async () => {
const baseForm = 0, it("should switch to base form on arena reset", async () => {
zenForm = 1;
game.override.startingWave(4); game.override.startingWave(4);
game.override.starterForms({ game.override.starterForms({
[Species.DARMANITAN]: zenForm, [Species.DARMANITAN]: zenForm,
}); });
await game.startBattle([ Species.MAGIKARP, Species.DARMANITAN ]); await game.classicMode.startBattle([ Species.MAGIKARP, Species.DARMANITAN ]);
const darmanitan = game.scene.getParty().find((p) => p.species.speciesId === Species.DARMANITAN)!; const darmanitan = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.DARMANITAN)!;
expect(darmanitan).not.toBe(undefined);
expect(darmanitan.formIndex).toBe(zenForm); expect(darmanitan.formIndex).toBe(zenForm);
darmanitan.hp = 0; darmanitan.hp = 0;
@ -147,11 +125,10 @@ describe("Abilities - ZEN MODE", () => {
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to("TurnEndPhase");
game.doSelectModifier(); game.doSelectModifier();
await game.phaseInterceptor.to(QuietFormChangePhase); await game.phaseInterceptor.to("QuietFormChangePhase");
expect(darmanitan.formIndex).toBe(baseForm); expect(darmanitan.formIndex).toBe(baseForm);
}, });
);
}); });

View File

@ -41,8 +41,8 @@ describe("Abilities - ZERO TO HERO", () => {
await game.startBattle([ Species.FEEBAS, Species.PALAFIN, Species.PALAFIN ]); await game.startBattle([ Species.FEEBAS, Species.PALAFIN, Species.PALAFIN ]);
const palafin1 = game.scene.getParty()[1]; const palafin1 = game.scene.getPlayerParty()[1];
const palafin2 = game.scene.getParty()[2]; const palafin2 = game.scene.getPlayerParty()[2];
expect(palafin1.formIndex).toBe(heroForm); expect(palafin1.formIndex).toBe(heroForm);
expect(palafin2.formIndex).toBe(heroForm); expect(palafin2.formIndex).toBe(heroForm);
palafin2.hp = 0; palafin2.hp = 0;

View File

@ -136,9 +136,9 @@ describe("Test Battle Phase", () => {
Species.CHANSEY, Species.CHANSEY,
Species.MEW Species.MEW
]); ]);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.CHARIZARD); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(Species.CHARIZARD);
expect(game.scene.getParty()[1].species.speciesId).toBe(Species.CHANSEY); expect(game.scene.getPlayerParty()[1].species.speciesId).toBe(Species.CHANSEY);
expect(game.scene.getParty()[2].species.speciesId).toBe(Species.MEW); expect(game.scene.getPlayerParty()[2].species.speciesId).toBe(Species.MEW);
}, 20000); }, 20000);
it("test remove random battle seed int", async () => { it("test remove random battle seed int", async () => {

View File

@ -49,7 +49,7 @@ describe("Double Battles", () => {
await game.phaseInterceptor.to(BattleEndPhase); await game.phaseInterceptor.to(BattleEndPhase);
game.doSelectModifier(); game.doSelectModifier();
const charizard = game.scene.getParty().findIndex(p => p.species.speciesId === Species.CHARIZARD); const charizard = game.scene.getPlayerParty().findIndex(p => p.species.speciesId === Species.CHARIZARD);
game.doRevivePokemon(charizard); game.doRevivePokemon(charizard);
await game.phaseInterceptor.to(TurnInitPhase); await game.phaseInterceptor.to(TurnInitPhase);

View File

@ -30,7 +30,7 @@ describe("Daily Mode", () => {
it("should initialize properly", async () => { it("should initialize properly", async () => {
await game.dailyMode.runToSummon(); await game.dailyMode.runToSummon();
const party = game.scene.getParty(); const party = game.scene.getPlayerParty();
expect(party).toHaveLength(3); expect(party).toHaveLength(3);
party.forEach(pkm => { party.forEach(pkm => {
expect(pkm.level).toBe(20); expect(pkm.level).toBe(20);

View File

@ -35,8 +35,8 @@ describe("Evolution", () => {
it("should keep hidden ability after evolving", async () => { it("should keep hidden ability after evolving", async () => {
await game.classicMode.runToSummon([ Species.EEVEE, Species.TRAPINCH ]); await game.classicMode.runToSummon([ Species.EEVEE, Species.TRAPINCH ]);
const eevee = game.scene.getParty()[0]; const eevee = game.scene.getPlayerParty()[0];
const trapinch = game.scene.getParty()[1]; const trapinch = game.scene.getPlayerParty()[1];
eevee.abilityIndex = 2; eevee.abilityIndex = 2;
trapinch.abilityIndex = 2; trapinch.abilityIndex = 2;
@ -50,8 +50,8 @@ describe("Evolution", () => {
it("should keep same ability slot after evolving", async () => { it("should keep same ability slot after evolving", async () => {
await game.classicMode.runToSummon([ Species.BULBASAUR, Species.CHARMANDER ]); await game.classicMode.runToSummon([ Species.BULBASAUR, Species.CHARMANDER ]);
const bulbasaur = game.scene.getParty()[0]; const bulbasaur = game.scene.getPlayerParty()[0];
const charmander = game.scene.getParty()[1]; const charmander = game.scene.getPlayerParty()[1];
bulbasaur.abilityIndex = 0; bulbasaur.abilityIndex = 0;
charmander.abilityIndex = 1; charmander.abilityIndex = 1;
@ -80,8 +80,8 @@ describe("Evolution", () => {
nincada.metBiome = -1; nincada.metBiome = -1;
nincada.evolve(pokemonEvolutions[Species.NINCADA][0], nincada.getSpeciesForm()); nincada.evolve(pokemonEvolutions[Species.NINCADA][0], nincada.getSpeciesForm());
const ninjask = game.scene.getParty()[0]; const ninjask = game.scene.getPlayerParty()[0];
const shedinja = game.scene.getParty()[1]; const shedinja = game.scene.getPlayerParty()[1];
expect(ninjask.abilityIndex).toBe(2); expect(ninjask.abilityIndex).toBe(2);
expect(shedinja.abilityIndex).toBe(1); expect(shedinja.abilityIndex).toBe(1);
// Regression test for https://github.com/pagefaultgames/pokerogue/issues/3842 // Regression test for https://github.com/pagefaultgames/pokerogue/issues/3842

View File

@ -45,7 +45,7 @@ describe("Spec - Pokemon", () => {
const zubat = scene.getEnemyPokemon()!; const zubat = scene.getEnemyPokemon()!;
zubat.addToParty(PokeballType.LUXURY_BALL); zubat.addToParty(PokeballType.LUXURY_BALL);
const party = scene.getParty(); const party = scene.getPlayerParty();
expect(party).toHaveLength(6); expect(party).toHaveLength(6);
party.forEach((pkm, index) =>{ party.forEach((pkm, index) =>{
expect(pkm.species.speciesId).toBe(index === 5 ? Species.ZUBAT : Species.ABRA); expect(pkm.species.speciesId).toBe(index === 5 ? Species.ZUBAT : Species.ABRA);
@ -57,7 +57,7 @@ describe("Spec - Pokemon", () => {
const zubat = scene.getEnemyPokemon()!; const zubat = scene.getEnemyPokemon()!;
zubat.addToParty(PokeballType.LUXURY_BALL, slotIndex); zubat.addToParty(PokeballType.LUXURY_BALL, slotIndex);
const party = scene.getParty(); const party = scene.getPlayerParty();
expect(party).toHaveLength(6); expect(party).toHaveLength(6);
party.forEach((pkm, index) =>{ party.forEach((pkm, index) =>{
expect(pkm.species.speciesId).toBe(index === slotIndex ? Species.ZUBAT : Species.ABRA); expect(pkm.species.speciesId).toBe(index === slotIndex ? Species.ZUBAT : Species.ABRA);

View File

@ -1,10 +1,10 @@
import { Stat } from "#enums/stat"; import { StatBoosterModifier } from "#app/modifier/modifier";
import { NumberHolder, randItem } from "#app/utils";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import * as Utils from "#app/utils";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { StatBoosterModifier } from "#app/modifier/modifier";
describe("Items - Eviolite", () => { describe("Items - Eviolite", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -28,14 +28,12 @@ describe("Items - Eviolite", () => {
}); });
it("should provide 50% boost to DEF and SPDEF for unevolved, unfused pokemon", async() => { it("should provide 50% boost to DEF and SPDEF for unevolved, unfused pokemon", async() => {
await game.classicMode.startBattle([ await game.classicMode.startBattle([ Species.PICHU ]);
Species.PICHU
]);
const partyMember = game.scene.getPlayerPokemon()!; const partyMember = game.scene.getPlayerPokemon()!;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const statValue = new NumberHolder(partyMember.getStat(stat, false));
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue); game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Ignore other calculations for simplicity
@ -51,14 +49,12 @@ describe("Items - Eviolite", () => {
}); });
it("should not provide a boost for fully evolved, unfused pokemon", async() => { it("should not provide a boost for fully evolved, unfused pokemon", async() => {
await game.classicMode.startBattle([ await game.classicMode.startBattle([ Species.RAICHU ]);
Species.RAICHU,
]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerPokemon()!;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const statValue = new NumberHolder(partyMember.getStat(stat, false));
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue); game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Ignore other calculations for simplicity
@ -75,12 +71,9 @@ describe("Items - Eviolite", () => {
}); });
it("should provide 50% boost to DEF and SPDEF for completely unevolved, fused pokemon", async() => { it("should provide 50% boost to DEF and SPDEF for completely unevolved, fused pokemon", async() => {
await game.classicMode.startBattle([ await game.classicMode.startBattle([ Species.PICHU, Species.CLEFFA ]);
Species.PICHU,
Species.CLEFFA
]);
const [ partyMember, ally ] = game.scene.getParty(); const [ partyMember, ally ] = game.scene.getPlayerParty();
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -92,7 +85,7 @@ describe("Items - Eviolite", () => {
partyMember.fusionLuck = ally.luck; partyMember.fusionLuck = ally.luck;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const statValue = new NumberHolder(partyMember.getStat(stat, false));
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue); game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Ignore other calculations for simplicity
@ -108,12 +101,9 @@ describe("Items - Eviolite", () => {
}); });
it("should provide 25% boost to DEF and SPDEF for partially unevolved (base), fused pokemon", async() => { it("should provide 25% boost to DEF and SPDEF for partially unevolved (base), fused pokemon", async() => {
await game.classicMode.startBattle([ await game.classicMode.startBattle([ Species.PICHU, Species.CLEFABLE ]);
Species.PICHU,
Species.CLEFABLE
]);
const [ partyMember, ally ] = game.scene.getParty(); const [ partyMember, ally ] = game.scene.getPlayerParty();
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -125,7 +115,7 @@ describe("Items - Eviolite", () => {
partyMember.fusionLuck = ally.luck; partyMember.fusionLuck = ally.luck;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const statValue = new NumberHolder(partyMember.getStat(stat, false));
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue); game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Ignore other calculations for simplicity
@ -141,12 +131,9 @@ describe("Items - Eviolite", () => {
}); });
it("should provide 25% boost to DEF and SPDEF for partially unevolved (fusion), fused pokemon", async() => { it("should provide 25% boost to DEF and SPDEF for partially unevolved (fusion), fused pokemon", async() => {
await game.classicMode.startBattle([ await game.classicMode.startBattle([ Species.RAICHU, Species.CLEFFA ]);
Species.RAICHU,
Species.CLEFFA
]);
const [ partyMember, ally ] = game.scene.getParty(); const [ partyMember, ally ] = game.scene.getPlayerParty();
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -158,7 +145,7 @@ describe("Items - Eviolite", () => {
partyMember.fusionLuck = ally.luck; partyMember.fusionLuck = ally.luck;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const statValue = new NumberHolder(partyMember.getStat(stat, false));
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue); game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Ignore other calculations for simplicity
@ -174,12 +161,9 @@ describe("Items - Eviolite", () => {
}); });
it("should not provide a boost for fully evolved, fused pokemon", async() => { it("should not provide a boost for fully evolved, fused pokemon", async() => {
await game.classicMode.startBattle([ await game.classicMode.startBattle([ Species.RAICHU, Species.CLEFABLE ]);
Species.RAICHU,
Species.CLEFABLE
]);
const [ partyMember, ally ] = game.scene.getParty(); const [ partyMember, ally ] = game.scene.getPlayerParty();
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -191,7 +175,7 @@ describe("Items - Eviolite", () => {
partyMember.fusionLuck = ally.luck; partyMember.fusionLuck = ally.luck;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const statValue = new NumberHolder(partyMember.getStat(stat, false));
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue); game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Ignore other calculations for simplicity
@ -216,14 +200,12 @@ describe("Items - Eviolite", () => {
const gMaxablePokemon = [ Species.PIKACHU, Species.EEVEE, Species.DURALUDON, Species.MEOWTH ]; const gMaxablePokemon = [ Species.PIKACHU, Species.EEVEE, Species.DURALUDON, Species.MEOWTH ];
await game.classicMode.startBattle([ await game.classicMode.startBattle([ randItem(gMaxablePokemon) ]);
Utils.randItem(gMaxablePokemon)
]);
const partyMember = game.scene.getPlayerPokemon()!; const partyMember = game.scene.getPlayerPokemon()!;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const statValue = new NumberHolder(partyMember.getStat(stat, false));
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue); game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Ignore other calculations for simplicity

View File

@ -89,7 +89,7 @@ describe("Items - Leek", () => {
Species.PIKACHU, Species.PIKACHU,
]); ]);
const [ partyMember, ally ] = game.scene.getParty(); const [ partyMember, ally ] = game.scene.getPlayerParty();
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -120,7 +120,7 @@ describe("Items - Leek", () => {
species[Utils.randInt(species.length)] species[Utils.randInt(species.length)]
]); ]);
const [ partyMember, ally ] = game.scene.getParty(); const [ partyMember, ally ] = game.scene.getPlayerParty();
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;

View File

@ -35,7 +35,7 @@ describe("Items - Light Ball", () => {
Species.PIKACHU Species.PIKACHU
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
// Checking console log to make sure Light Ball is applied when getEffectiveStat (with the appropriate stat) is called // Checking console log to make sure Light Ball is applied when getEffectiveStat (with the appropriate stat) is called
partyMember.getEffectiveStat(Stat.DEF); partyMember.getEffectiveStat(Stat.DEF);
@ -68,7 +68,7 @@ describe("Items - Light Ball", () => {
Species.PIKACHU Species.PIKACHU
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
const spAtkStat = partyMember.getStat(Stat.SPATK); const spAtkStat = partyMember.getStat(Stat.SPATK);
@ -97,8 +97,8 @@ describe("Items - Light Ball", () => {
Species.MAROWAK Species.MAROWAK
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const ally = game.scene.getParty()[1]; const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -136,8 +136,8 @@ describe("Items - Light Ball", () => {
Species.PIKACHU Species.PIKACHU
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const ally = game.scene.getParty()[1]; const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -174,7 +174,7 @@ describe("Items - Light Ball", () => {
Species.MAROWAK Species.MAROWAK
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
const spAtkStat = partyMember.getStat(Stat.SPATK); const spAtkStat = partyMember.getStat(Stat.SPATK);

View File

@ -35,7 +35,7 @@ describe("Items - Metal Powder", () => {
Species.DITTO Species.DITTO
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
// Checking console log to make sure Metal Powder is applied when getEffectiveStat (with the appropriate stat) is called // Checking console log to make sure Metal Powder is applied when getEffectiveStat (with the appropriate stat) is called
partyMember.getEffectiveStat(Stat.DEF); partyMember.getEffectiveStat(Stat.DEF);
@ -68,7 +68,7 @@ describe("Items - Metal Powder", () => {
Species.DITTO Species.DITTO
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const defStat = partyMember.getStat(Stat.DEF); const defStat = partyMember.getStat(Stat.DEF);
@ -91,8 +91,8 @@ describe("Items - Metal Powder", () => {
Species.MAROWAK Species.MAROWAK
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const ally = game.scene.getParty()[1]; const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -124,8 +124,8 @@ describe("Items - Metal Powder", () => {
Species.DITTO Species.DITTO
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const ally = game.scene.getParty()[1]; const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -156,7 +156,7 @@ describe("Items - Metal Powder", () => {
Species.MAROWAK Species.MAROWAK
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const defStat = partyMember.getStat(Stat.DEF); const defStat = partyMember.getStat(Stat.DEF);

View File

@ -35,7 +35,7 @@ describe("Items - Quick Powder", () => {
Species.DITTO Species.DITTO
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
// Checking console log to make sure Quick Powder is applied when getEffectiveStat (with the appropriate stat) is called // Checking console log to make sure Quick Powder is applied when getEffectiveStat (with the appropriate stat) is called
partyMember.getEffectiveStat(Stat.DEF); partyMember.getEffectiveStat(Stat.DEF);
@ -68,7 +68,7 @@ describe("Items - Quick Powder", () => {
Species.DITTO Species.DITTO
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const spdStat = partyMember.getStat(Stat.SPD); const spdStat = partyMember.getStat(Stat.SPD);
@ -91,8 +91,8 @@ describe("Items - Quick Powder", () => {
Species.MAROWAK Species.MAROWAK
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const ally = game.scene.getParty()[1]; const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -124,8 +124,8 @@ describe("Items - Quick Powder", () => {
Species.DITTO Species.DITTO
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const ally = game.scene.getParty()[1]; const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -156,7 +156,7 @@ describe("Items - Quick Powder", () => {
Species.MAROWAK Species.MAROWAK
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const spdStat = partyMember.getStat(Stat.SPD); const spdStat = partyMember.getStat(Stat.SPD);

View File

@ -35,7 +35,7 @@ describe("Items - Thick Club", () => {
Species.CUBONE Species.CUBONE
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
// Checking console log to make sure Thick Club is applied when getEffectiveStat (with the appropriate stat) is called // Checking console log to make sure Thick Club is applied when getEffectiveStat (with the appropriate stat) is called
partyMember.getEffectiveStat(Stat.DEF); partyMember.getEffectiveStat(Stat.DEF);
@ -68,7 +68,7 @@ describe("Items - Thick Club", () => {
Species.CUBONE Species.CUBONE
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
@ -90,7 +90,7 @@ describe("Items - Thick Club", () => {
Species.MAROWAK Species.MAROWAK
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
@ -112,7 +112,7 @@ describe("Items - Thick Club", () => {
Species.ALOLA_MAROWAK Species.ALOLA_MAROWAK
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
@ -139,8 +139,8 @@ describe("Items - Thick Club", () => {
Species.PIKACHU Species.PIKACHU
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const ally = game.scene.getParty()[1]; const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -176,8 +176,8 @@ describe("Items - Thick Club", () => {
species[randSpecies] species[randSpecies]
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const ally = game.scene.getParty()[1]; const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -208,7 +208,7 @@ describe("Items - Thick Club", () => {
Species.PIKACHU Species.PIKACHU
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getPlayerParty()[0];
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);

View File

@ -33,7 +33,7 @@ describe("Moves - Aromatherapy", () => {
it("should cure status effect of the user, its ally, and all party pokemon", async () => { it("should cure status effect of the user, its ally, and all party pokemon", async () => {
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getParty(); const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(leftPlayer, "resetStatus");
vi.spyOn(rightPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus");
@ -79,7 +79,7 @@ describe("Moves - Aromatherapy", () => {
it("should not cure status effect of allies ON FIELD with Sap Sipper, should still cure allies in party", async () => { it("should not cure status effect of allies ON FIELD with Sap Sipper, should still cure allies in party", async () => {
game.override.ability(Abilities.SAP_SIPPER); game.override.ability(Abilities.SAP_SIPPER);
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getParty(); const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(leftPlayer, "resetStatus");
vi.spyOn(rightPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus");

View File

@ -95,7 +95,7 @@ describe("Moves - Baton Pass", () => {
game.override.enemyMoveset([ Moves.SALT_CURE ]); game.override.enemyMoveset([ Moves.SALT_CURE ]);
await game.classicMode.startBattle([ Species.PIKACHU, Species.FEEBAS ]); await game.classicMode.startBattle([ Species.PIKACHU, Species.FEEBAS ]);
const [ player1, player2 ] = game.scene.getParty(); const [ player1, player2 ] = game.scene.getPlayerParty();
game.move.select(Moves.BATON_PASS); game.move.select(Moves.BATON_PASS);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);

View File

@ -65,7 +65,7 @@ describe("Moves - Beat Up", () => {
const playerPokemon = game.scene.getPlayerPokemon()!; const playerPokemon = game.scene.getPlayerPokemon()!;
game.scene.getParty()[1].trySetStatus(StatusEffect.BURN); game.scene.getPlayerParty()[1].trySetStatus(StatusEffect.BURN);
game.move.select(Moves.BEAT_UP); game.move.select(Moves.BEAT_UP);

View File

@ -48,7 +48,7 @@ describe("Moves - Dragon Rage", () => {
await game.startBattle(); await game.startBattle();
partyPokemon = game.scene.getParty()[0]; partyPokemon = game.scene.getPlayerParty()[0];
enemyPokemon = game.scene.getEnemyPokemon()!; enemyPokemon = game.scene.getEnemyPokemon()!;
// remove berries // remove berries

View File

@ -73,7 +73,7 @@ describe("Moves - Dragon Tail", () => {
.enemyAbility(Abilities.ROUGH_SKIN); .enemyAbility(Abilities.ROUGH_SKIN);
await game.classicMode.startBattle([ Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD ]); await game.classicMode.startBattle([ Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD ]);
const leadPokemon = game.scene.getParty()[0]!; const leadPokemon = game.scene.getPlayerParty()[0]!;
const enemyLeadPokemon = game.scene.getEnemyParty()[0]!; const enemyLeadPokemon = game.scene.getEnemyParty()[0]!;
const enemySecPokemon = game.scene.getEnemyParty()[1]!; const enemySecPokemon = game.scene.getEnemyParty()[1]!;
@ -105,8 +105,8 @@ describe("Moves - Dragon Tail", () => {
.enemyAbility(Abilities.ROUGH_SKIN); .enemyAbility(Abilities.ROUGH_SKIN);
await game.classicMode.startBattle([ Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD ]); await game.classicMode.startBattle([ Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD ]);
const leadPokemon = game.scene.getParty()[0]!; const leadPokemon = game.scene.getPlayerParty()[0]!;
const secPokemon = game.scene.getParty()[1]!; const secPokemon = game.scene.getPlayerParty()[1]!;
const enemyLeadPokemon = game.scene.getEnemyParty()[0]!; const enemyLeadPokemon = game.scene.getEnemyParty()[0]!;
const enemySecPokemon = game.scene.getEnemyParty()[1]!; const enemySecPokemon = game.scene.getEnemyParty()[1]!;

View File

@ -43,7 +43,7 @@ describe("Moves - Fissure", () => {
await game.startBattle(); await game.startBattle();
partyPokemon = game.scene.getParty()[0]; partyPokemon = game.scene.getPlayerParty()[0];
enemyPokemon = game.scene.getEnemyPokemon()!; enemyPokemon = game.scene.getEnemyPokemon()!;
// remove berries // remove berries

View File

@ -176,7 +176,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
Species.ZEKROM Species.ZEKROM
]); ]);
const party = game.scene.getParty(); const party = game.scene.getPlayerParty();
const enemyParty = game.scene.getEnemyParty(); const enemyParty = game.scene.getEnemyParty();
// Get rid of any modifiers that may alter power // Get rid of any modifiers that may alter power
@ -235,7 +235,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
Species.ZEKROM Species.ZEKROM
]); ]);
const party = game.scene.getParty(); const party = game.scene.getPlayerParty();
const enemyParty = game.scene.getEnemyParty(); const enemyParty = game.scene.getEnemyParty();
// Get rid of any modifiers that may alter power // Get rid of any modifiers that may alter power

View File

@ -33,7 +33,7 @@ describe("Moves - Heal Bell", () => {
it("should cure status effect of the user, its ally, and all party pokemon", async () => { it("should cure status effect of the user, its ally, and all party pokemon", async () => {
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getParty(); const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(leftPlayer, "resetStatus");
vi.spyOn(rightPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus");
@ -79,7 +79,7 @@ describe("Moves - Heal Bell", () => {
it("should not cure status effect of allies ON FIELD with Soundproof, should still cure allies in party", async () => { it("should not cure status effect of allies ON FIELD with Soundproof, should still cure allies in party", async () => {
game.override.ability(Abilities.SOUNDPROOF); game.override.ability(Abilities.SOUNDPROOF);
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getParty(); const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(leftPlayer, "resetStatus");
vi.spyOn(rightPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus");

View File

@ -35,10 +35,10 @@ describe("Moves - Magnet Rise", () => {
it("MAGNET RISE", async () => { it("MAGNET RISE", async () => {
await game.startBattle(); await game.startBattle();
const startingHp = game.scene.getParty()[0].hp; const startingHp = game.scene.getPlayerParty()[0].hp;
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const finalHp = game.scene.getParty()[0].hp; const finalHp = game.scene.getPlayerParty()[0].hp;
const hpLost = finalHp - startingHp; const hpLost = finalHp - startingHp;
expect(hpLost).toBe(0); expect(hpLost).toBe(0);
}, 20000); }, 20000);
@ -46,15 +46,15 @@ describe("Moves - Magnet Rise", () => {
it("MAGNET RISE - Gravity", async () => { it("MAGNET RISE - Gravity", async () => {
await game.startBattle(); await game.startBattle();
const startingHp = game.scene.getParty()[0].hp; const startingHp = game.scene.getPlayerParty()[0].hp;
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
let finalHp = game.scene.getParty()[0].hp; let finalHp = game.scene.getPlayerParty()[0].hp;
let hpLost = finalHp - startingHp; let hpLost = finalHp - startingHp;
expect(hpLost).toBe(0); expect(hpLost).toBe(0);
game.move.select(Moves.GRAVITY); game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
finalHp = game.scene.getParty()[0].hp; finalHp = game.scene.getPlayerParty()[0].hp;
hpLost = finalHp - startingHp; hpLost = finalHp - startingHp;
expect(hpLost).not.toBe(0); expect(hpLost).not.toBe(0);
}, 20000); }, 20000);

View File

@ -79,7 +79,7 @@ describe("Multi-target damage reduction", () => {
it("should reduce earthquake when more than one pokemon other than user is not fainted", async () => { it("should reduce earthquake when more than one pokemon other than user is not fainted", async () => {
await game.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); await game.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
const player2 = game.scene.getParty()[1]; const player2 = game.scene.getPlayerParty()[1];
const [ enemy1, enemy2 ] = game.scene.getEnemyField(); const [ enemy1, enemy2 ] = game.scene.getEnemyField();
game.move.select(Moves.EARTHQUAKE); game.move.select(Moves.EARTHQUAKE);

View File

@ -84,19 +84,19 @@ describe("Moves - Parting Shot", () => {
// use Memento 3 times to debuff enemy // use Memento 3 times to debuff enemy
game.move.select(Moves.MEMENTO); game.move.select(Moves.MEMENTO);
await game.phaseInterceptor.to(FaintPhase); await game.phaseInterceptor.to(FaintPhase);
expect(game.scene.getParty()[0].isFainted()).toBe(true); expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true);
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
await game.phaseInterceptor.to(TurnInitPhase, false); await game.phaseInterceptor.to(TurnInitPhase, false);
game.move.select(Moves.MEMENTO); game.move.select(Moves.MEMENTO);
await game.phaseInterceptor.to(FaintPhase); await game.phaseInterceptor.to(FaintPhase);
expect(game.scene.getParty()[0].isFainted()).toBe(true); expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true);
game.doSelectPartyPokemon(2); game.doSelectPartyPokemon(2);
await game.phaseInterceptor.to(TurnInitPhase, false); await game.phaseInterceptor.to(TurnInitPhase, false);
game.move.select(Moves.MEMENTO); game.move.select(Moves.MEMENTO);
await game.phaseInterceptor.to(FaintPhase); await game.phaseInterceptor.to(FaintPhase);
expect(game.scene.getParty()[0].isFainted()).toBe(true); expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true);
game.doSelectPartyPokemon(3); game.doSelectPartyPokemon(3);
// set up done // set up done
@ -182,8 +182,8 @@ describe("Moves - Parting Shot", () => {
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
// intentionally kill party pokemon, switch to second slot (now 1 party mon is fainted) // intentionally kill party pokemon, switch to second slot (now 1 party mon is fainted)
await game.killPokemon(game.scene.getParty()[0]); await game.killPokemon(game.scene.getPlayerParty()[0]);
expect(game.scene.getParty()[0].isFainted()).toBe(true); expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true);
await game.phaseInterceptor.run(MessagePhase); await game.phaseInterceptor.run(MessagePhase);
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);

View File

@ -44,7 +44,7 @@ describe("Moves - Rollout", () => {
await game.startBattle(); await game.startBattle();
const playerPkm = game.scene.getParty()[0]; const playerPkm = game.scene.getPlayerParty()[0];
vi.spyOn(playerPkm, "stats", "get").mockReturnValue([ 500000, 1, 1, 1, 1, 1 ]); // HP, ATK, DEF, SPATK, SPDEF, SPD vi.spyOn(playerPkm, "stats", "get").mockReturnValue([ 500000, 1, 1, 1, 1, 1 ]); // HP, ATK, DEF, SPATK, SPDEF, SPD
const enemyPkm = game.scene.getEnemyParty()[0]; const enemyPkm = game.scene.getEnemyParty()[0];

View File

@ -59,7 +59,7 @@ describe("Moves - Shed Tail", () => {
await game.classicMode.startBattle([ Species.MAGIKARP ]); await game.classicMode.startBattle([ Species.MAGIKARP ]);
const magikarp = game.scene.getPlayerPokemon()!; const magikarp = game.scene.getPlayerPokemon()!;
expect(game.scene.getParty().length).toBe(1); expect(game.scene.getPlayerParty().length).toBe(1);
game.move.select(Moves.SHED_TAIL); game.move.select(Moves.SHED_TAIL);

View File

@ -38,7 +38,7 @@ describe("Moves - Sparkly Swirl", () => {
.battleType("double") .battleType("double")
.statusEffect(StatusEffect.BURN); .statusEffect(StatusEffect.BURN);
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getParty(); const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
const leftOpp = game.scene.getEnemyPokemon()!; const leftOpp = game.scene.getEnemyPokemon()!;
vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(leftPlayer, "resetStatus");

View File

@ -46,7 +46,7 @@ describe("Moves - Spikes", () => {
game.doSwitchPokemon(1); game.doSwitchPokemon(1);
await game.toNextTurn(); await game.toNextTurn();
const player = game.scene.getParty()[0]; const player = game.scene.getPlayerParty()[0];
expect(player.hp).toBe(player.getMaxHp()); expect(player.hp).toBe(player.getMaxHp());
}, 20000); }, 20000);

Some files were not shown because too many files have changed in this diff Show More