Multi-squash power
This commit is contained in:
parent
f6836b26a4
commit
bdbeaac104
|
@ -7670,7 +7670,16 @@ export class ForceLastAttr extends MoveEffectAttr {
|
||||||
override apply(user: Pokemon, target: Pokemon, _move: Move, _args: any[]): boolean {
|
override apply(user: Pokemon, target: Pokemon, _move: Move, _args: any[]): boolean {
|
||||||
const targetMovePhase = target.scene.findPhase<MovePhase>((phase) => phase.pokemon === target);
|
const targetMovePhase = target.scene.findPhase<MovePhase>((phase) => phase.pokemon === target);
|
||||||
if (targetMovePhase && target.scene.tryRemovePhase((phase: MovePhase) => 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ export class MovePhase extends BattlePhase {
|
||||||
protected ignorePp: boolean;
|
protected ignorePp: boolean;
|
||||||
protected failed: boolean = false;
|
protected failed: boolean = false;
|
||||||
protected cancelled: boolean = false;
|
protected cancelled: boolean = false;
|
||||||
|
protected forcedLast: boolean = false;
|
||||||
|
|
||||||
public get pokemon(): Pokemon {
|
public get pokemon(): Pokemon {
|
||||||
return this._pokemon;
|
return this._pokemon;
|
||||||
|
@ -114,6 +115,21 @@ export class MovePhase extends BattlePhase {
|
||||||
this.cancelled = true;
|
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 {
|
public start(): void {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue