mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-07 07:59:26 +02:00
Merge 1b2cb1de00
into 5bfcb1d379
This commit is contained in:
commit
2578fbca44
@ -1,3 +1,4 @@
|
|||||||
|
import type { BattlerTag } from "#data/battler-tags";
|
||||||
import { AbAttrParamsWithCancel, PreAttackModifyPowerAbAttrParams } from "#abilities/ability";
|
import { AbAttrParamsWithCancel, PreAttackModifyPowerAbAttrParams } from "#abilities/ability";
|
||||||
import {
|
import {
|
||||||
applyAbAttrs
|
applyAbAttrs
|
||||||
@ -1306,10 +1307,8 @@ export class MoveEffectAttr extends MoveAttr {
|
|||||||
* @param args Set of unique arguments needed by this attribute
|
* @param args Set of unique arguments needed by this attribute
|
||||||
* @returns true if basic application of the ability attribute should be possible
|
* @returns true if basic application of the ability attribute should be possible
|
||||||
*/
|
*/
|
||||||
canApply(user: Pokemon, target: Pokemon, move: Move, args?: any[]) {
|
canApply(user: Pokemon, target: Pokemon, move: Move, _args?: any[]) {
|
||||||
return !! (this.selfTarget ? user.hp && !user.getTag(BattlerTagType.FRENZY) : target.hp)
|
return !(this.selfTarget ? user : target).isFainted();
|
||||||
&& (this.selfTarget || !target.getTag(BattlerTagType.PROTECTED) ||
|
|
||||||
move.doesFlagEffectApply({ flag: MoveFlags.IGNORE_PROTECT, user, target }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Applies move effects so long as they are able based on {@linkcode canApply} */
|
/** Applies move effects so long as they are able based on {@linkcode canApply} */
|
||||||
@ -5598,16 +5597,15 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
|
|||||||
public tagType: BattlerTagType;
|
public tagType: BattlerTagType;
|
||||||
public turnCountMin: number;
|
public turnCountMin: number;
|
||||||
public turnCountMax: number;
|
public turnCountMax: number;
|
||||||
protected cancelOnFail: boolean;
|
|
||||||
private failOnOverlap: boolean;
|
private failOnOverlap: boolean;
|
||||||
|
|
||||||
constructor(tagType: BattlerTagType, selfTarget: boolean = false, failOnOverlap: boolean = false, turnCountMin: number = 0, turnCountMax?: number, lastHitOnly: boolean = false) {
|
constructor(tagType: BattlerTagType, selfTarget: boolean = false, failOnOverlap = false, turnCountMin = 0, turnCountMax = turnCountMin, lastHitOnly = false) {
|
||||||
super(selfTarget, { lastHitOnly: lastHitOnly });
|
super(selfTarget, { lastHitOnly });
|
||||||
|
|
||||||
this.tagType = tagType;
|
this.tagType = tagType;
|
||||||
this.turnCountMin = turnCountMin;
|
this.turnCountMin = turnCountMin;
|
||||||
this.turnCountMax = turnCountMax !== undefined ? turnCountMax : turnCountMin;
|
this.turnCountMax = turnCountMax;
|
||||||
this.failOnOverlap = !!failOnOverlap;
|
this.failOnOverlap = failOnOverlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
@ -5615,9 +5613,10 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Do any moves actually use chance-based battler tag adding?
|
||||||
const moveChance = this.getMoveChance(user, target, move, this.selfTarget, true);
|
const moveChance = this.getMoveChance(user, target, move, this.selfTarget, true);
|
||||||
if (moveChance < 0 || moveChance === 100 || user.randBattleSeedInt(100) < moveChance) {
|
if (moveChance < 0 || moveChance === 100 || user.randBattleSeedInt(100) < moveChance) {
|
||||||
return (this.selfTarget ? user : target).addTag(this.tagType, user.randBattleSeedIntRange(this.turnCountMin, this.turnCountMax), move.id, user.id);
|
return (this.selfTarget ? user : target).addTag(this.tagType, user.randBattleSeedIntRange(this.turnCountMin, this.turnCountMax), move.id, user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -5825,45 +5824,25 @@ export class CurseAttr extends MoveEffectAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LapseBattlerTagAttr extends MoveEffectAttr {
|
/**
|
||||||
public tagTypes: BattlerTagType[];
|
* Attribute to remove all {@linkcode BattlerTag}s matching one or more tag types.
|
||||||
|
*/
|
||||||
constructor(tagTypes: BattlerTagType[], selfTarget: boolean = false) {
|
|
||||||
super(selfTarget);
|
|
||||||
|
|
||||||
this.tagTypes = tagTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
|
||||||
if (!super.apply(user, target, move, args)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const tagType of this.tagTypes) {
|
|
||||||
(this.selfTarget ? user : target).lapseTag(tagType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class RemoveBattlerTagAttr extends MoveEffectAttr {
|
export class RemoveBattlerTagAttr extends MoveEffectAttr {
|
||||||
public tagTypes: BattlerTagType[];
|
/** An array of {@linkcode BattlerTagType}s to clear. */
|
||||||
|
public tagTypes: [BattlerTagType, ...BattlerTagType[]];
|
||||||
|
|
||||||
constructor(tagTypes: BattlerTagType[], selfTarget: boolean = false) {
|
constructor(tagTypes: [BattlerTagType, ...BattlerTagType[]], selfTarget = false) {
|
||||||
super(selfTarget);
|
super(selfTarget);
|
||||||
|
|
||||||
this.tagTypes = tagTypes;
|
this.tagTypes = tagTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean {
|
||||||
if (!super.apply(user, target, move, args)) {
|
if (!super.apply(user, target, move, _args)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const tagType of this.tagTypes) {
|
(this.selfTarget ? user : target).findAndRemoveTags(t => this.tagTypes.includes(t.tagType));
|
||||||
(this.selfTarget ? user : target).removeTag(tagType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -5930,6 +5909,8 @@ export class ProtectAttr extends AddBattlerTagAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Attributes should not exist solely to display a message
|
||||||
|
|
||||||
export class IgnoreAccuracyAttr extends AddBattlerTagAttr {
|
export class IgnoreAccuracyAttr extends AddBattlerTagAttr {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(BattlerTagType.IGNORE_ACCURACY, true, false, 2);
|
super(BattlerTagType.IGNORE_ACCURACY, true, false, 2);
|
||||||
@ -6001,14 +5982,13 @@ export class RemoveAllSubstitutesAttr extends MoveEffectAttr {
|
|||||||
export class HitsTagAttr extends MoveAttr {
|
export class HitsTagAttr extends MoveAttr {
|
||||||
/** The {@linkcode BattlerTagType} this move hits */
|
/** The {@linkcode BattlerTagType} this move hits */
|
||||||
public tagType: BattlerTagType;
|
public tagType: BattlerTagType;
|
||||||
/** Should this move deal double damage against {@linkcode HitsTagAttr.tagType}? */
|
/** Should this move deal double damage against {@linkcode this.tagType}? */
|
||||||
public doubleDamage: boolean;
|
public doubleDamage: boolean;
|
||||||
|
|
||||||
constructor(tagType: BattlerTagType, doubleDamage: boolean = false) {
|
constructor(tagType: BattlerTagType) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.tagType = tagType;
|
this.tagType = tagType;
|
||||||
this.doubleDamage = !!doubleDamage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
|
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
|
||||||
@ -6023,7 +6003,8 @@ export class HitsTagAttr extends MoveAttr {
|
|||||||
*/
|
*/
|
||||||
export class HitsTagForDoubleDamageAttr extends HitsTagAttr {
|
export class HitsTagForDoubleDamageAttr extends HitsTagAttr {
|
||||||
constructor(tagType: BattlerTagType) {
|
constructor(tagType: BattlerTagType) {
|
||||||
super(tagType, true);
|
super(tagType);
|
||||||
|
this.doubleDamage = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6033,11 +6014,11 @@ export class AddArenaTagAttr extends MoveEffectAttr {
|
|||||||
private failOnOverlap: boolean;
|
private failOnOverlap: boolean;
|
||||||
public selfSideTarget: boolean;
|
public selfSideTarget: boolean;
|
||||||
|
|
||||||
constructor(tagType: ArenaTagType, turnCount?: number | null, failOnOverlap: boolean = false, selfSideTarget: boolean = false) {
|
constructor(tagType: ArenaTagType, turnCount = 0, failOnOverlap = false, selfSideTarget: boolean = false) {
|
||||||
super(true);
|
super(true);
|
||||||
|
|
||||||
this.tagType = tagType;
|
this.tagType = tagType;
|
||||||
this.turnCount = turnCount!; // TODO: is the bang correct?
|
this.turnCount = turnCount;
|
||||||
this.failOnOverlap = failOnOverlap;
|
this.failOnOverlap = failOnOverlap;
|
||||||
this.selfSideTarget = selfSideTarget;
|
this.selfSideTarget = selfSideTarget;
|
||||||
}
|
}
|
||||||
@ -6047,6 +6028,7 @@ export class AddArenaTagAttr extends MoveEffectAttr {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Why does this check effect chance if nothing uses it?
|
||||||
if ((move.chance < 0 || move.chance === 100 || user.randBattleSeedInt(100) < move.chance) && user.getLastXMoves(1)[0]?.result === MoveResult.SUCCESS) {
|
if ((move.chance < 0 || move.chance === 100 || user.randBattleSeedInt(100) < move.chance) && user.getLastXMoves(1)[0]?.result === MoveResult.SUCCESS) {
|
||||||
const side = ((this.selfSideTarget ? user : target).isPlayer() !== (move.hasAttr("AddArenaTrapTagAttr") && target === user)) ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY;
|
const side = ((this.selfSideTarget ? user : target).isPlayer() !== (move.hasAttr("AddArenaTrapTagAttr") && target === user)) ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY;
|
||||||
globalScene.arena.addTag(this.tagType, this.turnCount, move.id, user.id, side);
|
globalScene.arena.addTag(this.tagType, this.turnCount, move.id, user.id, side);
|
||||||
@ -6058,25 +6040,28 @@ export class AddArenaTagAttr extends MoveEffectAttr {
|
|||||||
|
|
||||||
getCondition(): MoveConditionFunc | null {
|
getCondition(): MoveConditionFunc | null {
|
||||||
return this.failOnOverlap
|
return this.failOnOverlap
|
||||||
? (user, target, move) => !globalScene.arena.getTagOnSide(this.tagType, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY)
|
? (_user, target, _move) => !globalScene.arena.getTagOnSide(this.tagType, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic class for removing arena tags
|
* Attribute to remove one or more arena tags from the field.
|
||||||
* @param tagTypes: The types of tags that can be removed
|
|
||||||
* @param selfSideTarget: Is the user removing tags from its own side?
|
|
||||||
*/
|
*/
|
||||||
export class RemoveArenaTagsAttr extends MoveEffectAttr {
|
export class RemoveArenaTagsAttr extends MoveEffectAttr {
|
||||||
public tagTypes: ArenaTagType[];
|
/** An array containing the tags to be removed. */
|
||||||
public selfSideTarget: boolean;
|
private readonly tagTypes: readonly [ArenaTagType, ...ArenaTagType[]];
|
||||||
|
/**
|
||||||
|
* Whether to remove tags from both sides of the field (`true`) or
|
||||||
|
* the target's side of the field (`false`); default `false`
|
||||||
|
*/
|
||||||
|
private removeAllTags: boolean
|
||||||
|
|
||||||
constructor(tagTypes: ArenaTagType[], selfSideTarget: boolean) {
|
constructor(tagTypes: readonly [ArenaTagType, ...ArenaTagType[]], removeAllTags = false, options?: MoveEffectAttrOptions) {
|
||||||
super(true);
|
super(true, options);
|
||||||
|
|
||||||
this.tagTypes = tagTypes;
|
this.tagTypes = tagTypes;
|
||||||
this.selfSideTarget = selfSideTarget;
|
this.removeAllTags = removeAllTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
@ -6084,11 +6069,9 @@ export class RemoveArenaTagsAttr extends MoveEffectAttr {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const side = (this.selfSideTarget ? user : target).isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY;
|
const side = this.removeAllTags ? ArenaTagSide.BOTH : target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY;
|
||||||
|
|
||||||
for (const tagType of this.tagTypes) {
|
globalScene.arena.removeTagsOnSide(this.tagTypes, side);
|
||||||
globalScene.arena.removeTagOnSide(tagType, side);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -6113,6 +6096,7 @@ export class AddArenaTrapTagAttr extends AddArenaTagAttr {
|
|||||||
* @extends AddArenaTagAttr
|
* @extends AddArenaTagAttr
|
||||||
* @see {@linkcode apply}
|
* @see {@linkcode apply}
|
||||||
*/
|
*/
|
||||||
|
// TODO: This has exactly 1 line of code difference from the base attribute wrt. effect chances...
|
||||||
export class AddArenaTrapTagHitAttr extends AddArenaTagAttr {
|
export class AddArenaTrapTagHitAttr extends AddArenaTagAttr {
|
||||||
/**
|
/**
|
||||||
* @param user {@linkcode Pokemon} using this move
|
* @param user {@linkcode Pokemon} using this move
|
||||||
@ -6134,80 +6118,37 @@ export class AddArenaTrapTagHitAttr extends AddArenaTagAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RemoveArenaTrapAttr extends MoveEffectAttr {
|
// TODO: Review if we can remove these attributes
|
||||||
|
const arenaTrapTags = [
|
||||||
|
ArenaTagType.SPIKES,
|
||||||
|
ArenaTagType.TOXIC_SPIKES,
|
||||||
|
ArenaTagType.STEALTH_ROCK,
|
||||||
|
ArenaTagType.STICKY_WEB,
|
||||||
|
] as const;
|
||||||
|
|
||||||
private targetBothSides: boolean;
|
export class RemoveArenaTrapAttr extends RemoveArenaTagsAttr {
|
||||||
|
constructor(targetBothSides = false) {
|
||||||
constructor(targetBothSides: boolean = false) {
|
// TODO: This triggers at a different time than {@linkcode RemoveArenaTagsAbAttr}...
|
||||||
super(true, { trigger: MoveEffectTrigger.PRE_APPLY });
|
super(arenaTrapTags, targetBothSides, { trigger: MoveEffectTrigger.PRE_APPLY });
|
||||||
this.targetBothSides = targetBothSides;
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
|
||||||
|
|
||||||
if (!super.apply(user, target, move, args)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.targetBothSides) {
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.PLAYER);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.PLAYER);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.PLAYER);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.STICKY_WEB, ArenaTagSide.PLAYER);
|
|
||||||
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.ENEMY);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.ENEMY);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.STICKY_WEB, ArenaTagSide.ENEMY);
|
|
||||||
} else {
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.SPIKES, target.isPlayer() ? ArenaTagSide.ENEMY : ArenaTagSide.PLAYER);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.TOXIC_SPIKES, target.isPlayer() ? ArenaTagSide.ENEMY : ArenaTagSide.PLAYER);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.STEALTH_ROCK, target.isPlayer() ? ArenaTagSide.ENEMY : ArenaTagSide.PLAYER);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.STICKY_WEB, target.isPlayer() ? ArenaTagSide.ENEMY : ArenaTagSide.PLAYER);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RemoveScreensAttr extends MoveEffectAttr {
|
const screenTags = [
|
||||||
|
ArenaTagType.REFLECT,
|
||||||
private targetBothSides: boolean;
|
ArenaTagType.LIGHT_SCREEN,
|
||||||
|
ArenaTagType.AURORA_VEIL
|
||||||
constructor(targetBothSides: boolean = false) {
|
] as const;
|
||||||
super(true, { trigger: MoveEffectTrigger.PRE_APPLY });
|
|
||||||
this.targetBothSides = targetBothSides;
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
|
||||||
|
|
||||||
if (!super.apply(user, target, move, args)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.targetBothSides) {
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.REFLECT, ArenaTagSide.PLAYER);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.PLAYER);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, ArenaTagSide.PLAYER);
|
|
||||||
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.REFLECT, ArenaTagSide.ENEMY);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.ENEMY);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, ArenaTagSide.ENEMY);
|
|
||||||
} else {
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.REFLECT, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.LIGHT_SCREEN, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY);
|
|
||||||
globalScene.arena.removeTagOnSide(ArenaTagType.AURORA_VEIL, target.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
|
export class RemoveScreensAttr extends RemoveArenaTagsAttr {
|
||||||
|
constructor(targetBothSides = false) {
|
||||||
|
// TODO: This triggers at a different time than {@linkcode RemoveArenaTagsAbAttr}...
|
||||||
|
super(arenaTrapTags, targetBothSides, { trigger: MoveEffectTrigger.PRE_APPLY });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Swaps arena effects between the player and enemy side
|
/**
|
||||||
* @extends MoveEffectAttr
|
* Swaps arena effects between the player and enemy side
|
||||||
* @see {@linkcode apply}
|
*/
|
||||||
*/
|
|
||||||
export class SwapArenaTagsAttr extends MoveEffectAttr {
|
export class SwapArenaTagsAttr extends MoveEffectAttr {
|
||||||
public SwapTags: ArenaTagType[];
|
public SwapTags: ArenaTagType[];
|
||||||
|
|
||||||
@ -6602,6 +6543,7 @@ export class ChillyReceptionAttr extends ForceSwitchOutAttr {
|
|||||||
return (user, target, move) => globalScene.arena.weather?.weatherType !== WeatherType.SNOW || super.getSwitchOutCondition()(user, target, move);
|
return (user, target, move) => globalScene.arena.weather?.weatherType !== WeatherType.SNOW || super.getSwitchOutCondition()(user, target, move);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RemoveTypeAttr extends MoveEffectAttr {
|
export class RemoveTypeAttr extends MoveEffectAttr {
|
||||||
|
|
||||||
private removedType: PokemonType;
|
private removedType: PokemonType;
|
||||||
@ -8429,7 +8371,6 @@ const MoveAttrs = Object.freeze({
|
|||||||
GulpMissileTagAttr,
|
GulpMissileTagAttr,
|
||||||
JawLockAttr,
|
JawLockAttr,
|
||||||
CurseAttr,
|
CurseAttr,
|
||||||
LapseBattlerTagAttr,
|
|
||||||
RemoveBattlerTagAttr,
|
RemoveBattlerTagAttr,
|
||||||
FlinchAttr,
|
FlinchAttr,
|
||||||
ConfuseAttr,
|
ConfuseAttr,
|
||||||
@ -8993,7 +8934,7 @@ export function initMoves() {
|
|||||||
.attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1)
|
.attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1)
|
||||||
.reflectable(),
|
.reflectable(),
|
||||||
new StatusMove(MoveId.MIND_READER, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
new StatusMove(MoveId.MIND_READER, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
||||||
.attr(IgnoreAccuracyAttr),
|
.attr(AddBattlerTagAttr, BattlerTagType.IGNORE_ACCURACY, true, false, 2),
|
||||||
new StatusMove(MoveId.NIGHTMARE, PokemonType.GHOST, 100, 15, -1, 0, 2)
|
new StatusMove(MoveId.NIGHTMARE, PokemonType.GHOST, 100, 15, -1, 0, 2)
|
||||||
.attr(AddBattlerTagAttr, BattlerTagType.NIGHTMARE)
|
.attr(AddBattlerTagAttr, BattlerTagType.NIGHTMARE)
|
||||||
.condition(targetSleptOrComatoseCondition),
|
.condition(targetSleptOrComatoseCondition),
|
||||||
@ -9097,7 +9038,7 @@ export function initMoves() {
|
|||||||
.attr(MultiHitAttr)
|
.attr(MultiHitAttr)
|
||||||
.makesContact(false),
|
.makesContact(false),
|
||||||
new StatusMove(MoveId.LOCK_ON, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
new StatusMove(MoveId.LOCK_ON, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
||||||
.attr(IgnoreAccuracyAttr),
|
.attr(AddBattlerTagAttr, BattlerTagType.IGNORE_ACCURACY, true, false, 2),
|
||||||
new AttackMove(MoveId.OUTRAGE, PokemonType.DRAGON, MoveCategory.PHYSICAL, 120, 100, 10, -1, 0, 2)
|
new AttackMove(MoveId.OUTRAGE, PokemonType.DRAGON, MoveCategory.PHYSICAL, 120, 100, 10, -1, 0, 2)
|
||||||
.attr(FrenzyAttr)
|
.attr(FrenzyAttr)
|
||||||
.attr(MissEffectAttr, frenzyMissFunc)
|
.attr(MissEffectAttr, frenzyMissFunc)
|
||||||
@ -10418,7 +10359,7 @@ export function initMoves() {
|
|||||||
.target(MoveTarget.USER_AND_ALLIES)
|
.target(MoveTarget.USER_AND_ALLIES)
|
||||||
.condition((user, target, move) => !![ user, user.getAlly() ].filter(p => p?.isActive()).find(p => !![ AbilityId.PLUS, AbilityId.MINUS ].find(a => p?.hasAbility(a, false)))),
|
.condition((user, target, move) => !![ user, user.getAlly() ].filter(p => p?.isActive()).find(p => !![ AbilityId.PLUS, AbilityId.MINUS ].find(a => p?.hasAbility(a, false)))),
|
||||||
new StatusMove(MoveId.HAPPY_HOUR, PokemonType.NORMAL, -1, 30, -1, 0, 6) // No animation
|
new StatusMove(MoveId.HAPPY_HOUR, PokemonType.NORMAL, -1, 30, -1, 0, 6) // No animation
|
||||||
.attr(AddArenaTagAttr, ArenaTagType.HAPPY_HOUR, null, true)
|
.attr(AddArenaTagAttr, ArenaTagType.HAPPY_HOUR, 0, true)
|
||||||
.target(MoveTarget.USER_SIDE),
|
.target(MoveTarget.USER_SIDE),
|
||||||
new StatusMove(MoveId.ELECTRIC_TERRAIN, PokemonType.ELECTRIC, -1, 10, -1, 0, 6)
|
new StatusMove(MoveId.ELECTRIC_TERRAIN, PokemonType.ELECTRIC, -1, 10, -1, 0, 6)
|
||||||
.attr(TerrainChangeAttr, TerrainType.ELECTRIC)
|
.attr(TerrainChangeAttr, TerrainType.ELECTRIC)
|
||||||
@ -10601,7 +10542,7 @@ export function initMoves() {
|
|||||||
.attr(StatStageChangeAttr, [ Stat.SPD ], -1)
|
.attr(StatStageChangeAttr, [ Stat.SPD ], -1)
|
||||||
.reflectable(),
|
.reflectable(),
|
||||||
new SelfStatusMove(MoveId.LASER_FOCUS, PokemonType.NORMAL, -1, 30, -1, 0, 7)
|
new SelfStatusMove(MoveId.LASER_FOCUS, PokemonType.NORMAL, -1, 30, -1, 0, 7)
|
||||||
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false),
|
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false, 2),
|
||||||
new StatusMove(MoveId.GEAR_UP, PokemonType.STEEL, -1, 20, -1, 0, 7)
|
new StatusMove(MoveId.GEAR_UP, PokemonType.STEEL, -1, 20, -1, 0, 7)
|
||||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => !![ AbilityId.PLUS, AbilityId.MINUS ].find(a => target.hasAbility(a, false)) })
|
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => !![ AbilityId.PLUS, AbilityId.MINUS ].find(a => target.hasAbility(a, false)) })
|
||||||
.ignoresSubstitute()
|
.ignoresSubstitute()
|
||||||
@ -10690,7 +10631,7 @@ export function initMoves() {
|
|||||||
new AttackMove(MoveId.MALICIOUS_MOONSAULT, PokemonType.DARK, MoveCategory.PHYSICAL, 180, -1, 1, -1, 0, 7)
|
new AttackMove(MoveId.MALICIOUS_MOONSAULT, PokemonType.DARK, MoveCategory.PHYSICAL, 180, -1, 1, -1, 0, 7)
|
||||||
.unimplemented()
|
.unimplemented()
|
||||||
.attr(AlwaysHitMinimizeAttr)
|
.attr(AlwaysHitMinimizeAttr)
|
||||||
.attr(HitsTagAttr, BattlerTagType.MINIMIZED, true)
|
.attr(HitsTagForDoubleDamageAttr, BattlerTagType.MINIMIZED)
|
||||||
.edgeCase(), // I assume it's because it needs darkest lariat and incineroar
|
.edgeCase(), // I assume it's because it needs darkest lariat and incineroar
|
||||||
new AttackMove(MoveId.OCEANIC_OPERETTA, PokemonType.WATER, MoveCategory.SPECIAL, 195, -1, 1, -1, 0, 7)
|
new AttackMove(MoveId.OCEANIC_OPERETTA, PokemonType.WATER, MoveCategory.SPECIAL, 195, -1, 1, -1, 0, 7)
|
||||||
.unimplemented()
|
.unimplemented()
|
||||||
@ -11318,6 +11259,7 @@ export function initMoves() {
|
|||||||
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_GET_HIT, true, false, 0, 0, true)
|
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_GET_HIT, true, false, 0, 0, true)
|
||||||
.attr(AddBattlerTagAttr, BattlerTagType.RECEIVE_DOUBLE_DAMAGE, true, false, 0, 0, true)
|
.attr(AddBattlerTagAttr, BattlerTagType.RECEIVE_DOUBLE_DAMAGE, true, false, 0, 0, true)
|
||||||
.condition((user, target, move) => {
|
.condition((user, target, move) => {
|
||||||
|
// TODO: This is really really really janky
|
||||||
return !(target.getTag(BattlerTagType.PROTECTED)?.tagType === "PROTECTED" || globalScene.arena.getTag(ArenaTagType.MAT_BLOCK)?.tagType === "MAT_BLOCK");
|
return !(target.getTag(BattlerTagType.PROTECTED)?.tagType === "PROTECTED" || globalScene.arena.getTag(ArenaTagType.MAT_BLOCK)?.tagType === "MAT_BLOCK");
|
||||||
}),
|
}),
|
||||||
new StatusMove(MoveId.REVIVAL_BLESSING, PokemonType.NORMAL, -1, 1, -1, 0, 9)
|
new StatusMove(MoveId.REVIVAL_BLESSING, PokemonType.NORMAL, -1, 1, -1, 0, 9)
|
||||||
@ -11330,7 +11272,7 @@ export function initMoves() {
|
|||||||
new AttackMove(MoveId.TRIPLE_DIVE, PokemonType.WATER, MoveCategory.PHYSICAL, 30, 95, 10, -1, 0, 9)
|
new AttackMove(MoveId.TRIPLE_DIVE, PokemonType.WATER, MoveCategory.PHYSICAL, 30, 95, 10, -1, 0, 9)
|
||||||
.attr(MultiHitAttr, MultiHitType._3),
|
.attr(MultiHitAttr, MultiHitType._3),
|
||||||
new AttackMove(MoveId.MORTAL_SPIN, PokemonType.POISON, MoveCategory.PHYSICAL, 30, 100, 15, 100, 0, 9)
|
new AttackMove(MoveId.MORTAL_SPIN, PokemonType.POISON, MoveCategory.PHYSICAL, 30, 100, 15, 100, 0, 9)
|
||||||
.attr(LapseBattlerTagAttr, [
|
.attr(RemoveBattlerTagAttr, [
|
||||||
BattlerTagType.BIND,
|
BattlerTagType.BIND,
|
||||||
BattlerTagType.WRAP,
|
BattlerTagType.WRAP,
|
||||||
BattlerTagType.FIRE_SPIN,
|
BattlerTagType.FIRE_SPIN,
|
||||||
|
@ -718,7 +718,7 @@ export class Arena {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// creates a new tag object
|
// creates a new tag object
|
||||||
const newTag = getArenaTag(tagType, turnCount || 0, sourceMove, sourceId, side);
|
const newTag = getArenaTag(tagType, turnCount, sourceMove, sourceId, side);
|
||||||
if (newTag) {
|
if (newTag) {
|
||||||
newTag.onAdd(this, quiet);
|
newTag.onAdd(this, quiet);
|
||||||
this.tags.push(newTag);
|
this.tags.push(newTag);
|
||||||
@ -834,6 +834,36 @@ export class Arena {
|
|||||||
return !!tag;
|
return !!tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find and remove all {@linkcode ArenaTag}s with the given tag types on the given side of the field.
|
||||||
|
* @param tagTypes - The {@linkcode ArenaTagType}s to remove
|
||||||
|
* @param side - The {@linkcode ArenaTagSide} to remove the tags from (for side-based tags), or {@linkcode ArenaTagSide.BOTH}
|
||||||
|
* to clear all tags on either side of the field
|
||||||
|
* @param quiet - Whether to suppress removal messages from currently-present tags; default `false`
|
||||||
|
* @todo Review the other tag manipulation functions to see if they can be migrated towards using this (more efficient)
|
||||||
|
*/
|
||||||
|
public removeTagsOnSide(
|
||||||
|
tagTypes: ArenaTagType[] | ReadonlyArray<ArenaTagType>,
|
||||||
|
side: ArenaTagSide,
|
||||||
|
quiet = false,
|
||||||
|
): void {
|
||||||
|
const leftoverTags: ArenaTag[] = [];
|
||||||
|
for (const tag of this.tags) {
|
||||||
|
// Skip tags of different types or on the wrong side of the field
|
||||||
|
if (
|
||||||
|
!tagTypes.includes(tag.tagType) ||
|
||||||
|
!(side === ArenaTagSide.BOTH || tag.side === ArenaTagSide.BOTH || tag.side === side)
|
||||||
|
) {
|
||||||
|
leftoverTags.push(tag);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tag.onRemove(this, quiet);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tags = leftoverTags;
|
||||||
|
}
|
||||||
|
|
||||||
removeAllTags(): void {
|
removeAllTags(): void {
|
||||||
while (this.tags.length) {
|
while (this.tags.length) {
|
||||||
this.tags[0].onRemove(this);
|
this.tags[0].onRemove(this);
|
||||||
|
@ -745,7 +745,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
/**
|
/**
|
||||||
* Applies all move effects that trigger in the event of a successful hit:
|
* Applies all move effects that trigger in the event of a successful hit:
|
||||||
*
|
*
|
||||||
* - {@linkcode MoveEffectTrigger.PRE_APPLY | PRE_APPLY} effects`
|
* - {@linkcode MoveEffectTrigger.PRE_APPLY | PRE_APPLY} effects
|
||||||
* - Applying damage to the target
|
* - Applying damage to the target
|
||||||
* - {@linkcode MoveEffectTrigger.POST_APPLY | POST_APPLY} effects
|
* - {@linkcode MoveEffectTrigger.POST_APPLY | POST_APPLY} effects
|
||||||
* - Invoking {@linkcode applyOnTargetEffects} if the move does not hit a substitute
|
* - Invoking {@linkcode applyOnTargetEffects} if the move does not hit a substitute
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { SubstituteTag } from "#data/battler-tags";
|
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
|
import { ArenaTagSide } from "#enums/arena-tag-side";
|
||||||
import { ArenaTagType } from "#enums/arena-tag-type";
|
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||||
|
import { BattlerIndex } from "#enums/battler-index";
|
||||||
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import { MoveEndPhase } from "#phases/move-end-phase";
|
|
||||||
import { TurnEndPhase } from "#phases/turn-end-phase";
|
|
||||||
import { GameManager } from "#test/test-utils/game-manager";
|
import { GameManager } from "#test/test-utils/game-manager";
|
||||||
|
import type { ArenaTrapTagType } from "#types/arena-tags";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
@ -31,86 +32,65 @@ describe("Moves - Tidy Up", () => {
|
|||||||
.enemySpecies(SpeciesId.MAGIKARP)
|
.enemySpecies(SpeciesId.MAGIKARP)
|
||||||
.enemyAbility(AbilityId.BALL_FETCH)
|
.enemyAbility(AbilityId.BALL_FETCH)
|
||||||
.enemyMoveset(MoveId.SPLASH)
|
.enemyMoveset(MoveId.SPLASH)
|
||||||
.starterSpecies(SpeciesId.FEEBAS)
|
.ability(AbilityId.BALL_FETCH);
|
||||||
.ability(AbilityId.BALL_FETCH)
|
|
||||||
.moveset([MoveId.TIDY_UP])
|
|
||||||
.startingLevel(50);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("spikes are cleared", async () => {
|
it.each<{ name: string; tagType: ArenaTrapTagType }>([
|
||||||
game.override.moveset([MoveId.SPIKES, MoveId.TIDY_UP]).enemyMoveset(MoveId.SPIKES);
|
{ name: "Spikes", tagType: ArenaTagType.SPIKES },
|
||||||
await game.classicMode.startBattle();
|
{ name: "Toxic Spikes", tagType: ArenaTagType.TOXIC_SPIKES },
|
||||||
|
{ name: "Stealth Rock", tagType: ArenaTagType.STEALTH_ROCK },
|
||||||
|
{ name: "Sticky Web", tagType: ArenaTagType.STICKY_WEB },
|
||||||
|
])("should remove $name from both sides of the field", async ({ tagType }) => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
game.move.select(MoveId.SPIKES);
|
// Add tag to both sides of the field
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
game.scene.arena.addTag(tagType, 1, undefined, game.field.getPlayerPokemon().id, ArenaTagSide.PLAYER);
|
||||||
game.move.select(MoveId.TIDY_UP);
|
game.scene.arena.addTag(tagType, 1, undefined, game.field.getPlayerPokemon().id, ArenaTagSide.ENEMY);
|
||||||
await game.phaseInterceptor.to(MoveEndPhase);
|
|
||||||
expect(game.scene.arena.getTag(ArenaTagType.SPIKES)).toBeUndefined();
|
expect(game.scene.arena.getTag(tagType)).toBeDefined();
|
||||||
|
|
||||||
|
game.move.use(MoveId.TIDY_UP);
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
|
expect(game.scene.arena.getTag(tagType)).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("stealth rocks are cleared", async () => {
|
it("should clear substitutes from all pokemon", async () => {
|
||||||
game.override.moveset([MoveId.STEALTH_ROCK, MoveId.TIDY_UP]).enemyMoveset(MoveId.STEALTH_ROCK);
|
game.override.battleStyle("double");
|
||||||
await game.classicMode.startBattle();
|
await game.classicMode.startBattle([SpeciesId.CINCCINO, SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
game.move.select(MoveId.STEALTH_ROCK);
|
game.move.use(MoveId.SUBSTITUTE, BattlerIndex.PLAYER);
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
game.move.use(MoveId.SUBSTITUTE, BattlerIndex.PLAYER_2);
|
||||||
game.move.select(MoveId.TIDY_UP);
|
await game.move.forceEnemyMove(MoveId.SUBSTITUTE);
|
||||||
await game.phaseInterceptor.to(MoveEndPhase);
|
await game.move.forceEnemyMove(MoveId.SUBSTITUTE);
|
||||||
expect(game.scene.arena.getTag(ArenaTagType.STEALTH_ROCK)).toBeUndefined();
|
await game.toNextTurn();
|
||||||
});
|
|
||||||
|
|
||||||
it("toxic spikes are cleared", async () => {
|
game.scene.getField(true).forEach(p => {
|
||||||
game.override.moveset([MoveId.TOXIC_SPIKES, MoveId.TIDY_UP]).enemyMoveset(MoveId.TOXIC_SPIKES);
|
expect(p).toHaveBattlerTag(BattlerTagType.SUBSTITUTE);
|
||||||
await game.classicMode.startBattle();
|
});
|
||||||
|
|
||||||
game.move.select(MoveId.TOXIC_SPIKES);
|
game.move.use(MoveId.TIDY_UP, BattlerIndex.PLAYER);
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
game.move.select(MoveId.TIDY_UP);
|
await game.move.forceEnemyMove(MoveId.SPLASH);
|
||||||
await game.phaseInterceptor.to(MoveEndPhase);
|
await game.move.forceEnemyMove(MoveId.SPLASH);
|
||||||
expect(game.scene.arena.getTag(ArenaTagType.TOXIC_SPIKES)).toBeUndefined();
|
await game.toEndOfTurn();
|
||||||
});
|
|
||||||
|
|
||||||
it("sticky webs are cleared", async () => {
|
game.scene.getField(true).forEach(p => {
|
||||||
game.override.moveset([MoveId.STICKY_WEB, MoveId.TIDY_UP]).enemyMoveset(MoveId.STICKY_WEB);
|
expect(p).not.toHaveBattlerTag(BattlerTagType.SUBSTITUTE);
|
||||||
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
game.move.select(MoveId.STICKY_WEB);
|
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
|
||||||
game.move.select(MoveId.TIDY_UP);
|
|
||||||
await game.phaseInterceptor.to(MoveEndPhase);
|
|
||||||
expect(game.scene.arena.getTag(ArenaTagType.STICKY_WEB)).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("substitutes are cleared", async () => {
|
|
||||||
game.override.moveset([MoveId.SUBSTITUTE, MoveId.TIDY_UP]).enemyMoveset(MoveId.SUBSTITUTE);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
game.move.select(MoveId.SUBSTITUTE);
|
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
|
||||||
game.move.select(MoveId.TIDY_UP);
|
|
||||||
await game.phaseInterceptor.to(MoveEndPhase);
|
|
||||||
|
|
||||||
const pokemon = [game.scene.getPlayerPokemon()!, game.scene.getEnemyPokemon()!];
|
|
||||||
pokemon.forEach(p => {
|
|
||||||
expect(p).toBeDefined();
|
|
||||||
expect(p!.getTag(SubstituteTag)).toBeUndefined();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("user's stats are raised with no traps set", async () => {
|
it("should raise the user's stats even if a tag cannot be removed", async () => {
|
||||||
await game.classicMode.startBattle();
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
const feebas = game.field.getPlayerPokemon();
|
||||||
|
expect(feebas).toHaveStatStage(Stat.ATK, 0);
|
||||||
|
expect(feebas).toHaveStatStage(Stat.SPD, 0);
|
||||||
|
|
||||||
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0);
|
game.move.use(MoveId.TIDY_UP);
|
||||||
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0);
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
game.move.select(MoveId.TIDY_UP);
|
expect(feebas).toHaveStatStage(Stat.ATK, 1);
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
expect(feebas).toHaveStatStage(Stat.SPD, 1);
|
||||||
|
|
||||||
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(1);
|
|
||||||
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user