Remove single-use function

This commit is contained in:
NightKev 2024-10-21 02:45:09 -07:00
parent e04c246ab9
commit e68a9d4689

View File

@ -437,7 +437,7 @@ export class BeakBlastChargingTag extends BattlerTag {
* to be removed after the source makes a move (or the turn ends, whichever comes first) * to be removed after the source makes a move (or the turn ends, whichever comes first)
* @param pokemon {@linkcode Pokemon} the owner of this tag * @param pokemon {@linkcode Pokemon} the owner of this tag
* @param lapseType {@linkcode BattlerTagLapseType} the type of functionality invoked in battle * @param lapseType {@linkcode BattlerTagLapseType} the type of functionality invoked in battle
* @returns `true` if invoked with the `AFTER_HIT` lapse type; `false` otherwise * @returns `true` if invoked with the `AFTER_HIT` lapse type
*/ */
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
if (lapseType === BattlerTagLapseType.AFTER_HIT) { if (lapseType === BattlerTagLapseType.AFTER_HIT) {
@ -457,11 +457,10 @@ export class BeakBlastChargingTag extends BattlerTag {
* @see {@link https://bulbapedia.bulbagarden.net/wiki/Shell_Trap_(move) | Shell Trap} * @see {@link https://bulbapedia.bulbagarden.net/wiki/Shell_Trap_(move) | Shell Trap}
*/ */
export class ShellTrapTag extends BattlerTag { export class ShellTrapTag extends BattlerTag {
public activated: boolean; public activated: boolean = false;
constructor() { constructor() {
super(BattlerTagType.SHELL_TRAP, [ BattlerTagLapseType.TURN_END, BattlerTagLapseType.AFTER_HIT ], 1); super(BattlerTagType.SHELL_TRAP, [ BattlerTagLapseType.TURN_END, BattlerTagLapseType.AFTER_HIT ], 1);
this.activated = false;
} }
onAdd(pokemon: Pokemon): void { onAdd(pokemon: Pokemon): void {
@ -472,23 +471,14 @@ export class ShellTrapTag extends BattlerTag {
* "Activates" the shell trap, causing the tag owner to move next. * "Activates" the shell trap, causing the tag owner to move next.
* @param pokemon {@linkcode Pokemon} the owner of this tag * @param pokemon {@linkcode Pokemon} the owner of this tag
* @param lapseType {@linkcode BattlerTagLapseType} the type of functionality invoked in battle * @param lapseType {@linkcode BattlerTagLapseType} the type of functionality invoked in battle
* @returns `true` if invoked with the `CUSTOM` lapse type; `false` otherwise * @returns `true` if invoked with the `AFTER_HIT` lapse type
*/ */
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
if (lapseType === BattlerTagLapseType.AFTER_HIT) { if (lapseType === BattlerTagLapseType.AFTER_HIT) {
const phaseData = getMoveEffectPhaseData(pokemon); const phaseData = getMoveEffectPhaseData(pokemon);
/* Trap should only be triggered by opponent's Physical moves */ // Trap should only be triggered by opponent's Physical moves
if (phaseData?.move.category === MoveCategory.PHYSICAL && pokemon.isOpponent(phaseData.attacker)) { if (phaseData?.move.category === MoveCategory.PHYSICAL && pokemon.isOpponent(phaseData.attacker)) {
this.triggerTrap(pokemon);
}
return true;
}
return super.lapse(pokemon, lapseType);
}
private triggerTrap(pokemon: Pokemon) {
const shellTrapPhaseIndex = pokemon.scene.phaseQueue.findIndex( const shellTrapPhaseIndex = pokemon.scene.phaseQueue.findIndex(
phase => phase instanceof MovePhase && phase.pokemon === pokemon phase => phase instanceof MovePhase && phase.pokemon === pokemon
); );
@ -496,6 +486,7 @@ export class ShellTrapTag extends BattlerTag {
phase => phase instanceof MovePhase phase => phase instanceof MovePhase
); );
// Only shift MovePhase timing if it's not already next up
if (shellTrapPhaseIndex !== -1 && shellTrapPhaseIndex !== firstMovePhaseIndex) { if (shellTrapPhaseIndex !== -1 && shellTrapPhaseIndex !== firstMovePhaseIndex) {
const shellTrapMovePhase = pokemon.scene.phaseQueue.splice(shellTrapPhaseIndex, 1)[0]; const shellTrapMovePhase = pokemon.scene.phaseQueue.splice(shellTrapPhaseIndex, 1)[0];
pokemon.scene.prependToPhase(shellTrapMovePhase, MovePhase); pokemon.scene.prependToPhase(shellTrapMovePhase, MovePhase);
@ -503,6 +494,12 @@ export class ShellTrapTag extends BattlerTag {
this.activated = true; this.activated = true;
} }
return true;
}
return super.lapse(pokemon, lapseType);
}
} }
export class TrappedTag extends BattlerTag { export class TrappedTag extends BattlerTag {