Multi-squash power

This commit is contained in:
Dean 2024-12-27 01:38:04 -08:00
parent f6836b26a4
commit bdbeaac104
2 changed files with 26 additions and 1 deletions

View File

@ -7670,7 +7670,16 @@ export class ForceLastAttr extends MoveEffectAttr {
override apply(user: Pokemon, target: Pokemon, _move: Move, _args: any[]): boolean {
const targetMovePhase = target.scene.findPhase<MovePhase>((phase) => phase.pokemon === target);
if (targetMovePhase && target.scene.tryRemovePhase((phase: MovePhase) => phase.pokemon === target)) {
target.scene.prependToPhase(new MovePhase(target.scene, target, [ ...targetMovePhase.targets ], targetMovePhase.move), WeatherEffectPhase);
const weatherPhase = target.scene.findPhase((phase) => phase instanceof WeatherEffectPhase)!;
let newMovePhaseIndex = target.scene.phaseQueue.indexOf(weatherPhase);
let nextMovePhase = target.scene.phaseQueue[newMovePhaseIndex - 1];
while (nextMovePhase instanceof MovePhase
&& nextMovePhase.isForcedLast()
&& nextMovePhase.pokemon.getEffectiveStat(Stat.SPD) < user.getEffectiveStat(Stat.SPD)) {
newMovePhaseIndex--;
nextMovePhase = target.scene.phaseQueue[newMovePhaseIndex];
}
target.scene.phaseQueue.splice(newMovePhaseIndex, 0, new MovePhase(target.scene, target, [ ...targetMovePhase.targets ], targetMovePhase.move, false, false, true));
}
return true;
}

View File

@ -56,6 +56,7 @@ export class MovePhase extends BattlePhase {
protected ignorePp: boolean;
protected failed: boolean = false;
protected cancelled: boolean = false;
protected forcedLast: boolean = false;
public get pokemon(): Pokemon {
return this._pokemon;
@ -114,6 +115,21 @@ export class MovePhase extends BattlePhase {
this.cancelled = true;
}
/**
* Flags that the current move has been forced to the end of the turn
* Needed for speed order, see {@linkcode Moves.QUASH}
* */
public forceLast(): MovePhase {
this.forcedLast = true;
return this;
}
public isForcedLast(): boolean {
return this.forcedLast;
}
public start(): void {
super.start();