Fix some bugs related to double battles
parent
105b5cd510
commit
3fc830f401
|
@ -545,18 +545,16 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
end() {
|
end() {
|
||||||
const playerField = this.scene.getPlayerField();
|
const pokemon = this.getPokemon();
|
||||||
|
|
||||||
playerField.forEach((pokemon, p) => {
|
if (pokemon.shiny)
|
||||||
if (pokemon.shiny)
|
this.scene.unshiftPhase(new ShinySparklePhase(this.scene, pokemon.getBattlerIndex()));
|
||||||
this.scene.unshiftPhase(new ShinySparklePhase(this.scene, p));
|
|
||||||
});
|
|
||||||
|
|
||||||
playerField.forEach(pokemon => pokemon.resetTurnData());
|
pokemon.resetTurnData();
|
||||||
|
|
||||||
playerField.forEach(pokemon => this.scene.arena.applyTags(ArenaTrapTag, pokemon));
|
this.scene.arena.applyTags(ArenaTrapTag, pokemon);
|
||||||
|
|
||||||
playerField.forEach(pokemon => applyPostSummonAbAttrs(PostSummonAbAttr, pokemon));
|
applyPostSummonAbAttrs(PostSummonAbAttr, pokemon);
|
||||||
|
|
||||||
super.end();
|
super.end();
|
||||||
}
|
}
|
||||||
|
@ -830,7 +828,7 @@ export class CommandPhase extends FieldPhase {
|
||||||
this.scene.ui.setMode(Mode.COMMAND);
|
this.scene.ui.setMode(Mode.COMMAND);
|
||||||
}, null, true);
|
}, null, true);
|
||||||
} else if (cursor < 4) {
|
} else if (cursor < 4) {
|
||||||
const targets = this.scene.getEnemyField().filter(p => p.isActive()).map(p => p.getBattlerIndex());
|
const targets = this.scene.getEnemyField().filter(p => p.isActive(true)).map(p => p.getBattlerIndex());
|
||||||
this.scene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.BALL, cursor: cursor };
|
this.scene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.BALL, cursor: cursor };
|
||||||
this.scene.currentBattle.turnPokeballCounts[cursor as PokeballType]--;
|
this.scene.currentBattle.turnPokeballCounts[cursor as PokeballType]--;
|
||||||
if (targets.length > 1)
|
if (targets.length > 1)
|
||||||
|
@ -1119,7 +1117,7 @@ export class MovePhase extends BattlePhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
canMove(): boolean {
|
canMove(): boolean {
|
||||||
return !!this.pokemon.hp && this.move.isUsable(this.ignorePp) && !!this.targets.length;
|
return this.pokemon.isActive(true) && this.move.isUsable(this.ignorePp) && !!this.targets.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel(): void {
|
cancel(): void {
|
||||||
|
@ -1141,7 +1139,7 @@ export class MovePhase extends BattlePhase {
|
||||||
console.log(this.targets);
|
console.log(this.targets);
|
||||||
|
|
||||||
const targets = this.scene.getField().filter(p => {
|
const targets = this.scene.getField().filter(p => {
|
||||||
if (p?.isActive() && this.targets.indexOf(p.getBattlerIndex()) > -1) {
|
if (p?.isActive(true) && this.targets.indexOf(p.getBattlerIndex()) > -1) {
|
||||||
const hiddenTag = p.getTag(HiddenTag);
|
const hiddenTag = p.getTag(HiddenTag);
|
||||||
if (hiddenTag && !this.move.getMove().getAttrs(HitsTagAttr).filter(hta => (hta as HitsTagAttr).tagType === hiddenTag.tagType).length)
|
if (hiddenTag && !this.move.getMove().getAttrs(HitsTagAttr).filter(hta => (hta as HitsTagAttr).tagType === hiddenTag.tagType).length)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1384,7 +1382,7 @@ class MoveEffectPhase extends PokemonPhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
getTargets(): Pokemon[] {
|
getTargets(): Pokemon[] {
|
||||||
return this.scene.getField().filter(p => p?.isActive() && this.targets.indexOf(p.getBattlerIndex()) > -1);
|
return this.scene.getField().filter(p => p?.isActive(true) && this.targets.indexOf(p.getBattlerIndex()) > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTarget(): Pokemon {
|
getTarget(): Pokemon {
|
||||||
|
@ -1634,7 +1632,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
const pokemon = this.getPokemon();
|
const pokemon = this.getPokemon();
|
||||||
if (pokemon?.isActive() && pokemon.status && pokemon.status.isPostTurn()) {
|
if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn()) {
|
||||||
pokemon.status.incrementTurn();
|
pokemon.status.incrementTurn();
|
||||||
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, () => {
|
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, () => {
|
||||||
this.scene.queueMessage(getPokemonMessage(pokemon, getStatusEffectActivationText(pokemon.status.effect)));
|
this.scene.queueMessage(getPokemonMessage(pokemon, getStatusEffectActivationText(pokemon.status.effect)));
|
||||||
|
@ -2138,7 +2136,7 @@ export class PokemonHealPhase extends CommonAnimPhase {
|
||||||
end() {
|
end() {
|
||||||
const pokemon = this.getPokemon();
|
const pokemon = this.getPokemon();
|
||||||
|
|
||||||
if (!this.getPokemon().isActive()) {
|
if (!this.getPokemon().isActive(true)) {
|
||||||
super.end();
|
super.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,8 +192,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
return !this.hp && (!checkStatus || this.status?.effect === StatusEffect.FAINT);
|
return !this.hp && (!checkStatus || this.status?.effect === StatusEffect.FAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive(): boolean {
|
isActive(onField?: boolean): boolean {
|
||||||
return !this.isFainted() && !!this.scene;
|
return !this.isFainted() && !!this.scene && (!onField || this.scene.field.getIndex(this) > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract isPlayer(): boolean;
|
abstract isPlayer(): boolean;
|
||||||
|
@ -1196,7 +1196,7 @@ export class EnemyPokemon extends Pokemon {
|
||||||
|
|
||||||
getNextTargets(moveId: Moves): BattlerIndex[] {
|
getNextTargets(moveId: Moves): BattlerIndex[] {
|
||||||
const moveTargets = getMoveTargets(this, moveId);
|
const moveTargets = getMoveTargets(this, moveId);
|
||||||
const targets = this.scene.getField().filter(p => p?.isActive() && moveTargets.targets.indexOf(p.getBattlerIndex()) > -1);
|
const targets = this.scene.getField().filter(p => p?.isActive(true) && moveTargets.targets.indexOf(p.getBattlerIndex()) > -1);
|
||||||
if (moveTargets.multiple)
|
if (moveTargets.multiple)
|
||||||
return targets.map(p => p.getBattlerIndex());
|
return targets.map(p => p.getBattlerIndex());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue