Add some missing code from updates
This commit is contained in:
parent
7fd334b35e
commit
841f032e45
|
@ -29,8 +29,8 @@ export class MovePhase extends BattlePhase {
|
|||
public targets: BattlerIndex[];
|
||||
protected followUp: boolean;
|
||||
protected ignorePp: boolean;
|
||||
protected failed: boolean;
|
||||
protected cancelled: boolean;
|
||||
protected failed: boolean = false;
|
||||
protected cancelled: boolean = false;
|
||||
|
||||
/**
|
||||
* @param followUp Indicates that the move being uses is a "follow-up" - for example, a move being used by Metronome or Dancer.
|
||||
|
@ -44,8 +44,6 @@ export class MovePhase extends BattlePhase {
|
|||
this.move = move;
|
||||
this.followUp = followUp ?? false;
|
||||
this.ignorePp = ignorePp ?? false;
|
||||
this.failed = false;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
canMove(ignoreDisableTags?: boolean): boolean {
|
||||
|
@ -213,7 +211,8 @@ export class MovePhase extends BattlePhase {
|
|||
|
||||
const move = this.move.getMove();
|
||||
|
||||
// Move conditions assume the move has a single target (is this sustainable?)
|
||||
// Move conditions assume the move has a single target
|
||||
// TODO: is this sustainable?
|
||||
const passesConditions = move.applyConditions(this.pokemon, targets[0], move);
|
||||
const failureMessage = move.getFailedText(this.pokemon, targets[0], move, new Utils.BooleanHolder(false));
|
||||
|
||||
|
@ -298,7 +297,7 @@ export class MovePhase extends BattlePhase {
|
|||
resolveRedirectTarget() {
|
||||
if (this.targets.length === 1) {
|
||||
const currentTarget = this.targets[0];
|
||||
const redirectTarget = new Utils.IntegerHolder(currentTarget);
|
||||
const redirectTarget = new Utils.NumberHolder(currentTarget);
|
||||
|
||||
// check move redirection abilities of every pokemon *except* the user.
|
||||
this.scene.getField(true).filter(p => p !== this.pokemon).forEach(p => applyAbAttrs(RedirectMoveAbAttr, p, null, false, this.move.moveId, redirectTarget));
|
||||
|
@ -339,13 +338,20 @@ export class MovePhase extends BattlePhase {
|
|||
resolveCounterAttackTarget() {
|
||||
if (this.targets.length === 1 && this.targets[0] === BattlerIndex.ATTACKER) {
|
||||
if (this.pokemon.turnData.attacksReceived.length) {
|
||||
const attacker = this.pokemon.turnData.attacksReceived.length
|
||||
? this.pokemon.scene.getPokemonById(this.pokemon.turnData.attacksReceived[0].sourceId)
|
||||
: null;
|
||||
const attacker = this.pokemon.scene.getPokemonById(this.pokemon.turnData.attacksReceived[0].sourceId);
|
||||
|
||||
if (attacker?.isActive(true)) {
|
||||
this.targets[0] = attacker.getBattlerIndex();
|
||||
}
|
||||
|
||||
// account for metal burst and comeuppance hitting remaining targets in double battles
|
||||
// counterattack will redirect to remaining ally if original attacker faints
|
||||
if (this.scene.currentBattle.double && this.move.getMove().hasFlag(MoveFlags.REDIRECT_COUNTER)) {
|
||||
if (this.scene.getField()[this.targets[0]].hp === 0) {
|
||||
const opposingField = this.pokemon.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField();
|
||||
this.targets[0] = opposingField.find(p => p.hp > 0)?.getBattlerIndex() ?? BattlerIndex.ATTACKER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.targets[0] === BattlerIndex.ATTACKER) {
|
||||
|
|
Loading…
Reference in New Issue