wip set isTrapped to true and removed timedtrap

This commit is contained in:
muscode13 2024-10-26 18:18:34 -06:00
parent 18450a744d
commit dce3e1a7d2
6 changed files with 14 additions and 60 deletions

View File

@ -1203,35 +1203,14 @@ class GrassWaterPledgeTag extends ArenaTag {
} }
export class FairyLockTag extends ArenaTag { export class FairyLockTag extends ArenaTag {
constructor(sourceId: number) { constructor(turnCount: number, sourceId: number) {
super(ArenaTagType.FAIRY_LOCK, 1, Moves.FAIRY_LOCK, sourceId); super(ArenaTagType.FAIRY_LOCK, turnCount, Moves.FAIRY_LOCK, sourceId);
} }
onAdd(arena: Arena): void { onAdd(arena: Arena): void {
arena.scene.queueMessage(i18next.t("arenaTag:fairyLockOnAdd")); arena.scene.queueMessage(i18next.t("arenaTag:fairyLockOnAdd"));
} }
onRemove(arena: Arena): void { }
lapse(arena: Arena): boolean {
// const lockedIn = [...arena.scene.getEnemyField(), ...arena.scene.getPlayerField()];
// lockedIn?.forEach((p: Pokemon) => {
// p.addTag(BattlerTagType.TIMED_TRAP, 1, Moves.FAIRY_LOCK, this.sourceId)
// });
// return super.lapse(arena);
const ret = super.lapse(arena);
if (!ret) {
const lockedIn = [ ...arena.scene.getEnemyField(), ...arena.scene.getPlayerField() ];
console.log(lockedIn);
lockedIn?.forEach((p: Pokemon) => {
p.addTag(BattlerTagType.TIMED_TRAP, 1, Moves.FAIRY_LOCK, this.sourceId);
});
}
return ret;
}
} }
// TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter // TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter
@ -1293,7 +1272,7 @@ export function getArenaTag(tagType: ArenaTagType, turnCount: number, sourceMove
case ArenaTagType.GRASS_WATER_PLEDGE: case ArenaTagType.GRASS_WATER_PLEDGE:
return new GrassWaterPledgeTag(sourceId, side); return new GrassWaterPledgeTag(sourceId, side);
case ArenaTagType.FAIRY_LOCK: case ArenaTagType.FAIRY_LOCK:
return new FairyLockTag(sourceId); return new FairyLockTag(turnCount, sourceId);
default: default:
return null; return null;
} }

View File

@ -2776,25 +2776,6 @@ export class PowerTrickTag extends BattlerTag {
pokemon.setStat(Stat.DEF, temp, false); pokemon.setStat(Stat.DEF, temp, false);
} }
} }
export class TimedTrap extends TrappedTag {
constructor(turnCount: number, sourceMove: Moves, sourceId: number) {
super(BattlerTagType.TRAPPED, BattlerTagLapseType.TURN_END, turnCount, sourceMove, sourceId);
}
onAdd(pokemon: Pokemon): void {}
onRemove(pokemon: Pokemon): void {}
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
const ret = super.lapse(pokemon, lapseType);
if (!ret) {
pokemon.removeTag(BattlerTagType.TRAPPED);
}
return ret;
}
}
/** /**
* Retrieves a {@linkcode BattlerTag} based on the provided tag type, turn count, source move, and source ID. * Retrieves a {@linkcode BattlerTag} based on the provided tag type, turn count, source move, and source ID.
* @param sourceId - The ID of the pokemon adding the tag * @param sourceId - The ID of the pokemon adding the tag
@ -2972,8 +2953,6 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
return new TelekinesisTag(sourceMove); return new TelekinesisTag(sourceMove);
case BattlerTagType.POWER_TRICK: case BattlerTagType.POWER_TRICK:
return new PowerTrickTag(sourceMove, sourceId); return new PowerTrickTag(sourceMove, sourceId);
case BattlerTagType.TIMED_TRAP:
return new TimedTrap(turnCount, sourceMove, sourceId);
case BattlerTagType.NONE: case BattlerTagType.NONE:
default: default:
return new BattlerTag(tagType, BattlerTagLapseType.CUSTOM, turnCount, sourceMove, sourceId); return new BattlerTag(tagType, BattlerTagLapseType.CUSTOM, turnCount, sourceMove, sourceId);

View File

@ -9044,7 +9044,7 @@ export function initMoves() {
.ignoresSubstitute() .ignoresSubstitute()
.ignoresProtect() .ignoresProtect()
.target(MoveTarget.BOTH_SIDES) .target(MoveTarget.BOTH_SIDES)
.attr(AddArenaTagAttr, ArenaTagType.FAIRY_LOCK, 1, true) .attr(AddArenaTagAttr, ArenaTagType.FAIRY_LOCK, 2, true)
.condition((user, target, move) => { .condition((user, target, move) => {
const turnMove = user.getLastXMoves(1); const turnMove = user.getLastXMoves(1);
return !turnMove.length || turnMove[0].move !== move.id || turnMove[0].result !== MoveResult.SUCCESS; return !turnMove.length || turnMove[0].move !== move.id || turnMove[0].result !== MoveResult.SUCCESS;

View File

@ -16,7 +16,6 @@ export enum BattlerTagType {
AQUA_RING = "AQUA_RING", AQUA_RING = "AQUA_RING",
DROWSY = "DROWSY", DROWSY = "DROWSY",
TRAPPED = "TRAPPED", TRAPPED = "TRAPPED",
TIMED_TRAP = "TIMED_TRAP",
BIND = "BIND", BIND = "BIND",
WRAP = "WRAP", WRAP = "WRAP",
FIRE_SPIN = "FIRE_SPIN", FIRE_SPIN = "FIRE_SPIN",

View File

@ -1523,7 +1523,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated) applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated)
); );
return (trappedByAbility.value || !!this.getTag(TrappedTag)); const side = this.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY;
return (trappedByAbility.value || !!this.getTag(TrappedTag) || !!this.scene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, side));
} }
/** /**

View File

@ -1,6 +1,5 @@
import { ArenaTagSide } from "#app/data/arena-tag"; import { ArenaTagSide } from "#app/data/arena-tag";
import { ArenaTagType } from "#app/enums/arena-tag-type"; import { ArenaTagType } from "#app/enums/arena-tag-type";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
@ -54,18 +53,15 @@ describe("Moves - Fairy Lock", () => {
await game.forceEnemyMove(Moves.SPLASH, 1); await game.forceEnemyMove(Moves.SPLASH, 1);
await game.forceEnemyMove(Moves.SPLASH, 1); await game.forceEnemyMove(Moves.SPLASH, 1);
await game.phaseInterceptor.to("BerryPhase"); await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, ArenaTagSide.PLAYER)).not.toBeDefined(); expect(playerPokemon[0].isTrapped()).toEqual(true);
expect(game.scene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, ArenaTagSide.ENEMY)).not.toBeDefined(); expect(playerPokemon[1].isTrapped()).toEqual(true);
expect(enemyField[0].isTrapped()).toEqual(true);
expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); expect(enemyField[1].isTrapped()).toEqual(true);
expect(playerPokemon[1].getTag(BattlerTagType.TRAPPED)).toBeDefined();
expect(enemyField[0].getTag(BattlerTagType.TRAPPED)).toBeDefined();
expect(enemyField[1].getTag(BattlerTagType.TRAPPED)).toBeDefined();
await game.toNextTurn(); await game.toNextTurn();
expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).not.toBeDefined(); expect(playerPokemon[0].isTrapped()).toEqual(false);
expect(playerPokemon[1].getTag(BattlerTagType.TRAPPED)).not.toBeDefined(); expect(playerPokemon[1].isTrapped()).toEqual(false);
expect(enemyField[0].getTag(BattlerTagType.TRAPPED)).not.toBeDefined(); expect(enemyField[0].isTrapped()).toEqual(false);
expect(enemyField[1].getTag(BattlerTagType.TRAPPED)).not.toBeDefined(); expect(enemyField[1].isTrapped()).toEqual(false);
}); });
}); });