mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 07:22:19 +02:00
Fix some issues with double battles
This commit is contained in:
parent
6235590b72
commit
ae8aff0822
@ -140,7 +140,7 @@ export abstract class FieldPhase extends BattlePhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
executeForAll(func: PokemonFunc): void {
|
executeForAll(func: PokemonFunc): void {
|
||||||
const field = this.scene.getField().filter(p => p);
|
const field = this.scene.getField().filter(p => p?.hp);
|
||||||
field.forEach(pokemon => func(pokemon));
|
field.forEach(pokemon => func(pokemon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1312,7 +1312,7 @@ class MoveEffectPhase extends PokemonPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTargets(): Pokemon[] {
|
getTargets(): Pokemon[] {
|
||||||
return this.scene.getField().filter(p => this.targets.indexOf(p.getBattleTarget()) > -1);
|
return this.scene.getField().filter(p => p?.hp && this.targets.indexOf(p.getBattleTarget()) > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTarget(): Pokemon {
|
getTarget(): Pokemon {
|
||||||
@ -2099,9 +2099,15 @@ export class AttemptCapturePhase extends PokemonPhase {
|
|||||||
start() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
|
const pokemon = this.getPokemon();
|
||||||
|
|
||||||
|
if (!pokemon?.hp) {
|
||||||
|
this.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.scene.pokeballCounts[this.pokeballType]--;
|
this.scene.pokeballCounts[this.pokeballType]--;
|
||||||
|
|
||||||
const pokemon = this.getPokemon();
|
|
||||||
this.originalY = pokemon.y;
|
this.originalY = pokemon.y;
|
||||||
|
|
||||||
const _3m = 3 * pokemon.getMaxHp();
|
const _3m = 3 * pokemon.getMaxHp();
|
||||||
@ -2111,6 +2117,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
|||||||
const statusMultiplier = pokemon.status ? getStatusEffectCatchRateMultiplier(pokemon.status.effect) : 1;
|
const statusMultiplier = pokemon.status ? getStatusEffectCatchRateMultiplier(pokemon.status.effect) : 1;
|
||||||
const x = Math.round((((_3m - _2h) * catchRate * pokeballMultiplier) / _3m) * statusMultiplier);
|
const x = Math.round((((_3m - _2h) * catchRate * pokeballMultiplier) / _3m) * statusMultiplier);
|
||||||
const y = Math.round(65536 / Math.sqrt(Math.sqrt(255 / x)));
|
const y = Math.round(65536 / Math.sqrt(Math.sqrt(255 / x)));
|
||||||
|
const fpOffset = pokemon.getFieldPositionOffset();
|
||||||
|
|
||||||
const pokeballAtlasKey = getPokeballAtlasKey(this.pokeballType);
|
const pokeballAtlasKey = getPokeballAtlasKey(this.pokeballType);
|
||||||
this.pokeball = this.scene.add.sprite(16, 80, 'pb', pokeballAtlasKey);
|
this.pokeball = this.scene.add.sprite(16, 80, 'pb', pokeballAtlasKey);
|
||||||
@ -2123,8 +2130,8 @@ export class AttemptCapturePhase extends PokemonPhase {
|
|||||||
});
|
});
|
||||||
this.scene.tweens.add({
|
this.scene.tweens.add({
|
||||||
targets: this.pokeball,
|
targets: this.pokeball,
|
||||||
x: { value: 236, ease: 'Linear' },
|
x: { value: 236 + fpOffset[0], ease: 'Linear' },
|
||||||
y: { value: 16, ease: 'Cubic.easeOut' },
|
y: { value: 16 + fpOffset[1], ease: 'Cubic.easeOut' },
|
||||||
duration: 500,
|
duration: 500,
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
this.pokeball.setTexture('pb', `${pokeballAtlasKey}_opening`);
|
this.pokeball.setTexture('pb', `${pokeballAtlasKey}_opening`);
|
||||||
|
@ -449,7 +449,7 @@ export default class BattleScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPlayerPokemon(): PlayerPokemon {
|
getPlayerPokemon(): PlayerPokemon {
|
||||||
return this.getParty()[0];
|
return this.getPlayerField().find(() => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayerField(): PlayerPokemon[] {
|
getPlayerField(): PlayerPokemon[] {
|
||||||
@ -458,7 +458,7 @@ export default class BattleScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getEnemyPokemon(): EnemyPokemon {
|
getEnemyPokemon(): EnemyPokemon {
|
||||||
return this.currentBattle?.enemyField[0];
|
return this.currentBattle?.enemyField.find(() => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
getEnemyField(): EnemyPokemon[] {
|
getEnemyField(): EnemyPokemon[] {
|
||||||
|
@ -421,7 +421,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canApplyAbility(): boolean {
|
canApplyAbility(): boolean {
|
||||||
return !this.getAbility().conditions.find(condition => !condition(this));
|
return this.hp && !this.getAbility().conditions.find(condition => !condition(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
getAttackMoveEffectiveness(moveType: Type): TypeDamageMultiplier {
|
getAttackMoveEffectiveness(moveType: Type): TypeDamageMultiplier {
|
||||||
|
Loading…
Reference in New Issue
Block a user