Fix attacks with charge (solar beam, dig...) allowing to switch target on second turn

pull/414/head
Paul Beslin 2024-05-03 00:18:05 +02:00 committed by Samuel H
parent b84a4b4ee5
commit 24a9dba2c4
4 changed files with 19 additions and 4 deletions

View File

@ -391,6 +391,12 @@ export class FrenzyTag extends BattlerTag {
}
}
export class ChargingTag extends BattlerTag {
constructor(sourceMove: Moves, sourceId: integer) {
super(BattlerTagType.CHARGING, BattlerTagLapseType.CUSTOM, 1, sourceMove, sourceId);
}
}
export class EncoreTag extends BattlerTag {
public moveId: Moves;
@ -1116,6 +1122,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: integer, sourc
return new NightmareTag();
case BattlerTagType.FRENZY:
return new FrenzyTag(sourceMove, sourceId);
case BattlerTagType.CHARGING:
return new ChargingTag(sourceMove, sourceId);
case BattlerTagType.ENCORE:
return new EncoreTag(sourceId);
case BattlerTagType.HELPING_HAND:

View File

@ -9,6 +9,7 @@ export enum BattlerTagType {
SEEDED = "SEEDED",
NIGHTMARE = "NIGHTMARE",
FRENZY = "FRENZY",
CHARGING = "CHARGING",
ENCORE = "ENCORE",
HELPING_HAND = "HELPING_HAND",
INGRAIN = "INGRAIN",

View File

@ -1325,10 +1325,13 @@ export class ChargeAttr extends OverrideMoveEffectAttr {
user.getMoveQueue().push({ move: move.id, targets: [ target.getBattlerIndex() ], ignorePP: true });
if (this.sameTurn)
user.scene.pushMovePhase(new MovePhase(user.scene, user, [ target.getBattlerIndex() ], user.moveset.find(m => m.moveId === move.id), true), this.followUpPriority);
user.addTag(BattlerTagType.CHARGING, 1, move.id, user.id);
resolve(true);
});
} else
} else {
user.lapseTag(BattlerTagType.CHARGING);
resolve(false);
}
});
}

View File

@ -1686,6 +1686,8 @@ export class CommandPhase extends FieldPhase {
console.log(moveTargets, playerPokemon.name);
if (moveTargets.targets.length <= 1 || moveTargets.multiple)
turnCommand.move.targets = moveTargets.targets;
else if(playerPokemon.getTag(BattlerTagType.CHARGING) && playerPokemon.getMoveQueue().length >= 1)
turnCommand.move.targets = playerPokemon.getMoveQueue()[0].targets;
else
this.scene.unshiftPhase(new SelectTargetPhase(this.scene, this.fieldIndex));
this.scene.currentBattle.turnCommands[this.fieldIndex] = turnCommand;
@ -2327,11 +2329,12 @@ export class MovePhase extends BattlePhase {
showMoveText(): void {
if (this.move.getMove().getAttrs(ChargeAttr).length) {
this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500);
const lastMove = this.pokemon.getLastXMoves() as TurnMove[];
if (!lastMove.length || lastMove[0].move !== this.move.getMove().id || lastMove[0].result !== MoveResult.OTHER)
if (!lastMove.length || lastMove[0].move !== this.move.getMove().id || lastMove[0].result !== MoveResult.OTHER){
this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500);
return;
}
}
if (this.pokemon.getTag(BattlerTagType.RECHARGING || BattlerTagType.INTERRUPTED))
return;