mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-20 23:32:19 +02:00
refactor wildFlee for seed sower animation bug
This commit is contained in:
parent
deac3141a1
commit
097f90a298
@ -749,6 +749,14 @@ export default class BattleScene extends SceneBase {
|
|||||||
return this.getPlayerField().find(p => p.isActive());
|
return this.getPlayerField().find(p => p.isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the first {@linkcode Pokemon.isActive()} pokemon from the player that isn't also currently switching out
|
||||||
|
* @returns Either the first {@linkcode PlayerPokemon} satisfying, or undefined if no player pokemon on the field satisfy
|
||||||
|
*/
|
||||||
|
getPlayerPokemonOnScreen(): PlayerPokemon | undefined {
|
||||||
|
return this.getPlayerField().find(p => p.isActive() && p.switchOutStatus === false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of PlayerPokemon of length 1 or 2 depending on if double battles or not
|
* Returns an array of PlayerPokemon of length 1 or 2 depending on if double battles or not
|
||||||
* @returns array of {@linkcode PlayerPokemon}
|
* @returns array of {@linkcode PlayerPokemon}
|
||||||
@ -766,6 +774,14 @@ export default class BattleScene extends SceneBase {
|
|||||||
return this.getEnemyField().find(p => p.isActive());
|
return this.getEnemyField().find(p => p.isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the first {@linkcode Pokemon.isActive()} pokemon from the enemy that isn't also currently switching out
|
||||||
|
* @returns Either the first {@linkcode EnemyPokemon} satisfying, or undefined if no player pokemon on the field satisfy
|
||||||
|
*/
|
||||||
|
getEnemyPokemonOnScreen(): EnemyPokemon | undefined {
|
||||||
|
return this.getEnemyField().find(p => p.isActive() && 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 double battles or not
|
||||||
* @returns array of {@linkcode EnemyPokemon}
|
* @returns array of {@linkcode EnemyPokemon}
|
||||||
|
@ -424,7 +424,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.getEnemyPokemon() || scene.getPlayerPokemon();
|
const fieldPokemon = scene.getEnemyPokemonOnScreen() || scene.getPlayerPokemonOnScreen();
|
||||||
if (fieldPokemon?.isOnField()) {
|
if (fieldPokemon?.isOnField()) {
|
||||||
scene.field.moveBelow(moveAnim.bgSprite as Phaser.GameObjects.GameObject, fieldPokemon);
|
scene.field.moveBelow(moveAnim.bgSprite as Phaser.GameObjects.GameObject, fieldPokemon);
|
||||||
}
|
}
|
||||||
@ -887,7 +887,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.getEnemyPokemon() || scene.getPlayerPokemon()!); // TODO: is this bang correct?
|
scene.field.moveBelow(moveSprite as Phaser.GameObjects.GameObject, scene.getEnemyPokemonOnScreen() || scene.getPlayerPokemonOnScreen()!); // this bang is correct to ensure a GameObject is passed in as a second arg (as opposed to undefined)
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
scene.field.moveTo(moveSprite, scene.field.getAll().length - 1);
|
scene.field.moveTo(moveSprite, scene.field.getAll().length - 1);
|
||||||
|
@ -5052,7 +5052,6 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
switchOutTarget.leaveField(false);
|
switchOutTarget.leaveField(false);
|
||||||
|
|
||||||
if (switchOutTarget.hp) {
|
if (switchOutTarget.hp) {
|
||||||
switchOutTarget.setWildFlee(true);
|
|
||||||
user.scene.queueMessage(i18next.t("moveTriggers:fled", {pokemonName: getPokemonNameWithAffix(switchOutTarget)}), null, true, 500);
|
user.scene.queueMessage(i18next.t("moveTriggers:fled", {pokemonName: getPokemonNameWithAffix(switchOutTarget)}), null, true, 500);
|
||||||
|
|
||||||
// in double battles redirect potential moves off fled pokemon
|
// in double battles redirect potential moves off fled pokemon
|
||||||
|
@ -95,7 +95,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
public luck: integer;
|
public luck: integer;
|
||||||
public pauseEvolutions: boolean;
|
public pauseEvolutions: boolean;
|
||||||
public pokerus: boolean;
|
public pokerus: boolean;
|
||||||
public wildFlee: boolean;
|
public switchOutStatus: boolean;
|
||||||
|
|
||||||
public fusionSpecies: PokemonSpecies | null;
|
public fusionSpecies: PokemonSpecies | null;
|
||||||
public fusionFormIndex: integer;
|
public fusionFormIndex: integer;
|
||||||
@ -136,7 +136,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
this.species = species;
|
this.species = species;
|
||||||
this.pokeball = dataSource?.pokeball || PokeballType.POKEBALL;
|
this.pokeball = dataSource?.pokeball || PokeballType.POKEBALL;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.wildFlee = false;
|
this.switchOutStatus = false;
|
||||||
|
|
||||||
// Determine the ability index
|
// Determine the ability index
|
||||||
if (abilityIndex !== undefined) {
|
if (abilityIndex !== undefined) {
|
||||||
@ -319,7 +319,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
isAllowedInBattle(): boolean {
|
isAllowedInBattle(): 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 !this.isFainted() && !this.wildFlee && challengeAllowed.value;
|
return !this.isFainted() && challengeAllowed.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive(onField?: boolean): boolean {
|
isActive(onField?: boolean): boolean {
|
||||||
@ -1974,11 +1974,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets if the pokemon has fled (implies it's a wild pokemon)
|
* sets if the pokemon is switching out (if it's a enemy wild implies it's going to flee)
|
||||||
* @param status - boolean
|
* @param status - boolean
|
||||||
*/
|
*/
|
||||||
setWildFlee(status: boolean): void {
|
setSwitchOut(status: boolean): void {
|
||||||
this.wildFlee = status;
|
this.switchOutStatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateInfo(instant?: boolean): Promise<void> {
|
updateInfo(instant?: boolean): Promise<void> {
|
||||||
@ -3095,6 +3095,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
this.updateFusionPalette();
|
this.updateFusionPalette();
|
||||||
}
|
}
|
||||||
this.summonData = new PokemonSummonData();
|
this.summonData = new PokemonSummonData();
|
||||||
|
this.setSwitchOut(false);
|
||||||
if (!this.battleData) {
|
if (!this.battleData) {
|
||||||
this.resetBattleData();
|
this.resetBattleData();
|
||||||
}
|
}
|
||||||
@ -3476,6 +3477,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
this.scene.field.remove(this);
|
this.scene.field.remove(this);
|
||||||
|
this.setSwitchOut(true);
|
||||||
this.scene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true);
|
this.scene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ describe("Moves - Dragon Tail", () => {
|
|||||||
await game.phaseInterceptor.to(BerryPhase);
|
await game.phaseInterceptor.to(BerryPhase);
|
||||||
|
|
||||||
const isVisible = enemyPokemon.visible;
|
const isVisible = enemyPokemon.visible;
|
||||||
const hasFled = enemyPokemon.wildFlee;
|
const hasFled = enemyPokemon.switchOutStatus;
|
||||||
expect(!isVisible && hasFled).toBe(true);
|
expect(!isVisible && hasFled).toBe(true);
|
||||||
|
|
||||||
// simply want to test that the game makes it this far without crashing
|
// simply want to test that the game makes it this far without crashing
|
||||||
@ -73,7 +73,7 @@ describe("Moves - Dragon Tail", () => {
|
|||||||
await game.phaseInterceptor.to(BerryPhase);
|
await game.phaseInterceptor.to(BerryPhase);
|
||||||
|
|
||||||
const isVisible = enemyPokemon.visible;
|
const isVisible = enemyPokemon.visible;
|
||||||
const hasFled = enemyPokemon.wildFlee;
|
const hasFled = enemyPokemon.switchOutStatus;
|
||||||
expect(!isVisible && hasFled).toBe(true);
|
expect(!isVisible && hasFled).toBe(true);
|
||||||
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
||||||
}, TIMEOUT
|
}, TIMEOUT
|
||||||
@ -98,9 +98,9 @@ describe("Moves - Dragon Tail", () => {
|
|||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
const isVisibleLead = enemyLeadPokemon.visible;
|
const isVisibleLead = enemyLeadPokemon.visible;
|
||||||
const hasFledLead = enemyLeadPokemon.wildFlee;
|
const hasFledLead = enemyLeadPokemon.switchOutStatus;
|
||||||
const isVisibleSec = enemySecPokemon.visible;
|
const isVisibleSec = enemySecPokemon.visible;
|
||||||
const hasFledSec = enemySecPokemon.wildFlee;
|
const hasFledSec = enemySecPokemon.switchOutStatus;
|
||||||
expect(!isVisibleLead && hasFledLead && isVisibleSec && !hasFledSec).toBe(true);
|
expect(!isVisibleLead && hasFledLead && isVisibleSec && !hasFledSec).toBe(true);
|
||||||
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
||||||
|
|
||||||
@ -134,9 +134,9 @@ describe("Moves - Dragon Tail", () => {
|
|||||||
await game.phaseInterceptor.to(BerryPhase);
|
await game.phaseInterceptor.to(BerryPhase);
|
||||||
|
|
||||||
const isVisibleLead = enemyLeadPokemon.visible;
|
const isVisibleLead = enemyLeadPokemon.visible;
|
||||||
const hasFledLead = enemyLeadPokemon.wildFlee;
|
const hasFledLead = enemyLeadPokemon.switchOutStatus;
|
||||||
const isVisibleSec = enemySecPokemon.visible;
|
const isVisibleSec = enemySecPokemon.visible;
|
||||||
const hasFledSec = enemySecPokemon.wildFlee;
|
const hasFledSec = enemySecPokemon.switchOutStatus;
|
||||||
expect(!isVisibleLead && hasFledLead && !isVisibleSec && hasFledSec).toBe(true);
|
expect(!isVisibleLead && hasFledLead && !isVisibleSec && hasFledSec).toBe(true);
|
||||||
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
||||||
expect(secPokemon.hp).toBeLessThan(secPokemon.getMaxHp());
|
expect(secPokemon.hp).toBeLessThan(secPokemon.getMaxHp());
|
||||||
|
Loading…
Reference in New Issue
Block a user