Fix counter and mirror coat implementation
parent
21c8a67b10
commit
c34eb05083
|
@ -1422,7 +1422,18 @@ export class MovePhase extends BattlePhase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.targets);
|
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;
|
||||||
|
if (attacker?.isActive(true))
|
||||||
|
this.targets[0] = attacker.getBattlerIndex();
|
||||||
|
}
|
||||||
|
if (this.targets[0] === BattlerIndex.ATTACKER) {
|
||||||
|
this.cancel();
|
||||||
|
this.showMoveText();
|
||||||
|
this.showFailedText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const targets = this.scene.getField().filter(p => {
|
const targets = this.scene.getField().filter(p => {
|
||||||
if (p?.isActive(true) && this.targets.indexOf(p.getBattlerIndex()) > -1) {
|
if (p?.isActive(true) && this.targets.indexOf(p.getBattlerIndex()) > -1) {
|
||||||
|
@ -1446,6 +1457,7 @@ export class MovePhase extends BattlePhase {
|
||||||
|
|
||||||
const moveQueue = this.pokemon.getMoveQueue();
|
const moveQueue = this.pokemon.getMoveQueue();
|
||||||
|
|
||||||
|
this.showMoveText();
|
||||||
if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) {
|
if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) {
|
||||||
moveQueue.shift();
|
moveQueue.shift();
|
||||||
this.cancel();
|
this.cancel();
|
||||||
|
@ -1457,7 +1469,6 @@ export class MovePhase extends BattlePhase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500);
|
|
||||||
if (!moveQueue.length || !moveQueue.shift().ignorePP) {
|
if (!moveQueue.length || !moveQueue.shift().ignorePP) {
|
||||||
this.move.ppUsed++;
|
this.move.ppUsed++;
|
||||||
for (let opponent of this.pokemon.getOpponents()) {
|
for (let opponent of this.pokemon.getOpponents()) {
|
||||||
|
@ -1479,7 +1490,7 @@ export class MovePhase extends BattlePhase {
|
||||||
this.scene.unshiftPhase(this.getEffectPhase());
|
this.scene.unshiftPhase(this.getEffectPhase());
|
||||||
else {
|
else {
|
||||||
this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual });
|
this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual });
|
||||||
this.scene.queueMessage('But it failed!');
|
this.showFailedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.end();
|
this.end();
|
||||||
|
@ -1529,6 +1540,14 @@ export class MovePhase extends BattlePhase {
|
||||||
return new MoveEffectPhase(this.scene, this.pokemon.getBattlerIndex(), this.targets, this.move);
|
return new MoveEffectPhase(this.scene, this.pokemon.getBattlerIndex(), this.targets, this.move);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showMoveText(): void {
|
||||||
|
this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
showFailedText(): void {
|
||||||
|
this.scene.queueMessage('But it failed!');
|
||||||
|
}
|
||||||
|
|
||||||
end() {
|
end() {
|
||||||
if (!this.followUp && this.canMove())
|
if (!this.followUp && this.canMove())
|
||||||
this.scene.unshiftPhase(new MoveEndPhase(this.scene, this.pokemon.getBattlerIndex()));
|
this.scene.unshiftPhase(new MoveEndPhase(this.scene, this.pokemon.getBattlerIndex()));
|
||||||
|
|
|
@ -14,6 +14,7 @@ export enum BattleType {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum BattlerIndex {
|
export enum BattlerIndex {
|
||||||
|
ATTACKER = -1,
|
||||||
PLAYER,
|
PLAYER,
|
||||||
PLAYER_2,
|
PLAYER_2,
|
||||||
ENEMY,
|
ENEMY,
|
||||||
|
|
|
@ -2356,10 +2356,7 @@ export function getMoveTargets(user: Pokemon, move: Moves): MoveTargetSet {
|
||||||
set = [ opponents[Utils.randInt(opponents.length)] ];
|
set = [ opponents[Utils.randInt(opponents.length)] ];
|
||||||
break;
|
break;
|
||||||
case MoveTarget.ATTACKER:
|
case MoveTarget.ATTACKER:
|
||||||
set = user.turnData.attacksReceived.length
|
return { targets: [ -1 as BattlerIndex ], multiple: false };
|
||||||
? [ user.scene.getPokemonById(user.turnData.attacksReceived[0].sourceId) ]
|
|
||||||
: [];
|
|
||||||
break;
|
|
||||||
case MoveTarget.NEAR_ALLY:
|
case MoveTarget.NEAR_ALLY:
|
||||||
case MoveTarget.ALLY:
|
case MoveTarget.ALLY:
|
||||||
set = [ user.getAlly() ];
|
set = [ user.getAlly() ];
|
||||||
|
|
Loading…
Reference in New Issue