Compare commits

...

23 Commits

Author SHA1 Message Date
Bertie690
f86bc385e4
Merge b4d1c39064 into da7903ab92 2025-08-15 12:09:50 -04:00
fabske0
da7903ab92
[i18n] rename cancel to cancelButton (#6267)
rename cancel to cancelButton
2025-08-15 11:34:54 -04:00
Bertie690
70e7f8b4d4
[Misc] Removed populateAnims script (#6229)
Removed `populateAnims`

Co-authored-by: Wlowscha <54003515+Wlowscha@users.noreply.github.com>
2025-08-15 17:11:37 +02:00
Bertie690
b4d1c39064
Merge branch 'beta' into mortal-spin 2025-08-14 16:23:48 -04:00
NightKev
5402722468
Merge branch 'beta' into mortal-spin 2025-08-14 11:38:16 -07:00
Bertie690
2480ee2be8
Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-08-14 14:09:12 -04:00
Bertie690
0b2077d036
Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-08-14 14:09:06 -04:00
Bertie690
9ab3009091
Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-08-14 14:08:56 -04:00
Bertie690
776d69fe58
Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-08-14 14:08:46 -04:00
NightKev
ee59eaba0c
Merge branch 'beta' into mortal-spin 2025-08-14 10:44:01 -07:00
Bertie690
d086c69081
Merge branch 'beta' into mortal-spin 2025-08-14 00:25:00 -04:00
NightKev
113c7bde17 Fix RemoveScreensAttr 2025-08-09 20:45:29 -07:00
Bertie690
1b2cb1de00
Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-08-03 20:35:46 -04:00
Bertie690
6f3d1b9116
Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-08-03 20:35:35 -04:00
Bertie690
65f28b7dc4 Reverted file 2025-08-03 17:54:26 -04:00
Bertie690
4dda982ff6 Finished up fixing up tidy up tests; removed matcher to go to its own PR 2025-08-03 13:25:46 -04:00
Bertie690
caa62987d6 Merge remote-tracking branch 'upstream/beta' into mortal-spin 2025-08-02 18:42:24 -04:00
Bertie690
808e29f55e Added toHaveArenaTagMatcher 2025-08-02 18:40:28 -04:00
Bertie690
1b9e4e05ee Significantly cleaned up RemoveArenaTrapAttr and RemoveScreensAttr 2025-08-02 16:26:17 -04:00
Bertie690
2439754aed De-janked params of addBattlerTagAttr 2025-08-02 16:22:26 -04:00
Bertie690
065659c396 Actually removed mortal spin attribute 2025-08-02 16:15:03 -04:00
Bertie690
3a88045871 Removed unused parameter from addBattlerTagAttr 2025-08-02 15:42:58 -04:00
Bertie690
a6f2e5ba04 Removed Mortal-spin exclusive LapseTagAttr 2025-08-02 15:07:10 -04:00
7 changed files with 167 additions and 499 deletions

View File

@ -27,13 +27,7 @@ import { UiInputs } from "#app/ui-inputs";
import { biomeDepths, getBiomeName } from "#balance/biomes";
import { pokemonPrevolutions } from "#balance/pokemon-evolutions";
import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#balance/starters";
import {
initCommonAnims,
initMoveAnim,
loadCommonAnimAssets,
loadMoveAnimAssets,
populateAnims,
} from "#data/battle-anims";
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets } from "#data/battle-anims";
import { allAbilities, allMoves, allSpecies, modifierTypes } from "#data/data-lists";
import { battleSpecDialogue } from "#data/dialogue";
import type { SpeciesFormChangeTrigger } from "#data/form-change-triggers";
@ -388,7 +382,6 @@ export class BattleScene extends SceneBase {
const defaultMoves = [MoveId.TACKLE, MoveId.TAIL_WHIP, MoveId.FOCUS_ENERGY, MoveId.STRUGGLE];
await Promise.all([
populateAnims(),
this.initVariantData(),
initCommonAnims().then(() => loadCommonAnimAssets(true)),
Promise.all(defaultMoves.map(m => initMoveAnim(m))).then(() => loadMoveAnimAssets(defaultMoves, true)),

View File

@ -404,22 +404,18 @@ export const chargeAnims = new Map<ChargeAnim, AnimConfig | [AnimConfig, AnimCon
export const commonAnims = new Map<CommonAnim, AnimConfig>();
export const encounterAnims = new Map<EncounterAnim, AnimConfig>();
export function initCommonAnims(): Promise<void> {
return new Promise(resolve => {
const commonAnimNames = getEnumKeys(CommonAnim);
const commonAnimIds = getEnumValues(CommonAnim);
export async function initCommonAnims(): Promise<void> {
const commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
for (let ca = 0; ca < commonAnimIds.length; ca++) {
const commonAnimId = commonAnimIds[ca];
for (const commonAnimName of getEnumKeys(CommonAnim)) {
const commonAnimId = CommonAnim[commonAnimName];
commonAnimFetches.push(
globalScene
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimNames[ca])}.json`)
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimName)}.json`)
.then(response => response.json())
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
);
}
Promise.allSettled(commonAnimFetches).then(() => resolve());
});
await Promise.allSettled(commonAnimFetches);
}
export function initMoveAnim(move: MoveId): Promise<void> {
@ -1396,279 +1392,3 @@ export class EncounterBattleAnim extends BattleAnim {
return this.oppAnim;
}
}
export async function populateAnims() {
const commonAnimNames = getEnumKeys(CommonAnim).map(k => k.toLowerCase());
const commonAnimMatchNames = commonAnimNames.map(k => k.replace(/_/g, ""));
const commonAnimIds = getEnumValues(CommonAnim);
const chargeAnimNames = getEnumKeys(ChargeAnim).map(k => k.toLowerCase());
const chargeAnimMatchNames = chargeAnimNames.map(k => k.replace(/_/g, " "));
const chargeAnimIds = getEnumValues(ChargeAnim);
const commonNamePattern = /name: (?:Common:)?(Opp )?(.*)/;
const moveNameToId = {};
// Exclude MoveId.NONE;
for (const move of getEnumValues(MoveId).slice(1)) {
// KARATE_CHOP => KARATECHOP
const moveName = MoveId[move].toUpperCase().replace(/_/g, "");
moveNameToId[moveName] = move;
}
const seNames: string[] = []; //(await fs.readdir('./public/audio/se/battle_anims/')).map(se => se.toString());
const animsData: any[] = []; //battleAnimRawData.split('!ruby/array:PBAnimation').slice(1); // TODO: add a proper type
for (let a = 0; a < animsData.length; a++) {
const fields = animsData[a].split("@").slice(1);
const nameField = fields.find(f => f.startsWith("name: "));
let isOppMove: boolean | undefined;
let commonAnimId: CommonAnim | undefined;
let chargeAnimId: ChargeAnim | undefined;
if (!nameField.startsWith("name: Move:") && !(isOppMove = nameField.startsWith("name: OppMove:"))) {
const nameMatch = commonNamePattern.exec(nameField)!; // TODO: is this bang correct?
const name = nameMatch[2].toLowerCase();
if (commonAnimMatchNames.indexOf(name) > -1) {
commonAnimId = commonAnimIds[commonAnimMatchNames.indexOf(name)];
} else if (chargeAnimMatchNames.indexOf(name) > -1) {
isOppMove = nameField.startsWith("name: Opp ");
chargeAnimId = chargeAnimIds[chargeAnimMatchNames.indexOf(name)];
}
}
const nameIndex = nameField.indexOf(":", 5) + 1;
const animName = nameField.slice(nameIndex, nameField.indexOf("\n", nameIndex));
if (!moveNameToId.hasOwnProperty(animName) && !commonAnimId && !chargeAnimId) {
continue;
}
const anim = commonAnimId || chargeAnimId ? new AnimConfig() : new AnimConfig();
if (anim instanceof AnimConfig) {
(anim as AnimConfig).id = moveNameToId[animName];
}
if (commonAnimId) {
commonAnims.set(commonAnimId, anim);
} else if (chargeAnimId) {
chargeAnims.set(chargeAnimId, !isOppMove ? anim : [chargeAnims.get(chargeAnimId) as AnimConfig, anim]);
} else {
moveAnims.set(
moveNameToId[animName],
!isOppMove ? (anim as AnimConfig) : [moveAnims.get(moveNameToId[animName]) as AnimConfig, anim as AnimConfig],
);
}
for (let f = 0; f < fields.length; f++) {
const field = fields[f];
const fieldName = field.slice(0, field.indexOf(":"));
const fieldData = field.slice(fieldName.length + 1, field.lastIndexOf("\n")).trim();
switch (fieldName) {
case "array": {
const framesData = fieldData.split(" - - - ").slice(1);
for (let fd = 0; fd < framesData.length; fd++) {
anim.frames.push([]);
const frameData = framesData[fd];
const focusFramesData = frameData.split(" - - ");
for (let tf = 0; tf < focusFramesData.length; tf++) {
const values = focusFramesData[tf].replace(/ {6}- /g, "").split("\n");
const targetFrame = new AnimFrame(
Number.parseFloat(values[0]),
Number.parseFloat(values[1]),
Number.parseFloat(values[2]),
Number.parseFloat(values[11]),
Number.parseFloat(values[3]),
Number.parseInt(values[4]) === 1,
Number.parseInt(values[6]) === 1,
Number.parseInt(values[5]),
Number.parseInt(values[7]),
Number.parseInt(values[8]),
Number.parseInt(values[12]),
Number.parseInt(values[13]),
Number.parseInt(values[14]),
Number.parseInt(values[15]),
Number.parseInt(values[16]),
Number.parseInt(values[17]),
Number.parseInt(values[18]),
Number.parseInt(values[19]),
Number.parseInt(values[21]),
Number.parseInt(values[22]),
Number.parseInt(values[23]),
Number.parseInt(values[24]),
Number.parseInt(values[20]) === 1,
Number.parseInt(values[25]),
Number.parseInt(values[26]) as AnimFocus,
);
anim.frames[fd].push(targetFrame);
}
}
break;
}
case "graphic": {
const graphic = fieldData !== "''" ? fieldData : "";
anim.graphic = graphic.indexOf(".") > -1 ? graphic.slice(0, fieldData.indexOf(".")) : graphic;
break;
}
case "timing": {
const timingEntries = fieldData.split("- !ruby/object:PBAnimTiming ").slice(1);
for (let t = 0; t < timingEntries.length; t++) {
const timingData = timingEntries[t]
.replace(/\n/g, " ")
.replace(/[ ]{2,}/g, " ")
.replace(/[a-z]+: ! '', /gi, "")
.replace(/name: (.*?),/, 'name: "$1",')
.replace(
/flashColor: !ruby\/object:Color { alpha: ([\d.]+), blue: ([\d.]+), green: ([\d.]+), red: ([\d.]+)}/,
"flashRed: $4, flashGreen: $3, flashBlue: $2, flashAlpha: $1",
);
const frameIndex = Number.parseInt(/frame: (\d+)/.exec(timingData)![1]); // TODO: is the bang correct?
let resourceName = /name: "(.*?)"/.exec(timingData)![1].replace("''", ""); // TODO: is the bang correct?
const timingType = Number.parseInt(/timingType: (\d)/.exec(timingData)![1]); // TODO: is the bang correct?
let timedEvent: AnimTimedEvent | undefined;
switch (timingType) {
case 0:
if (resourceName && resourceName.indexOf(".") === -1) {
let ext: string | undefined;
["wav", "mp3", "m4a"].every(e => {
if (seNames.indexOf(`${resourceName}.${e}`) > -1) {
ext = e;
return false;
}
return true;
});
if (!ext) {
ext = ".wav";
}
resourceName += `.${ext}`;
}
timedEvent = new AnimTimedSoundEvent(frameIndex, resourceName);
break;
case 1:
timedEvent = new AnimTimedAddBgEvent(frameIndex, resourceName.slice(0, resourceName.indexOf(".")));
break;
case 2:
timedEvent = new AnimTimedUpdateBgEvent(frameIndex, resourceName.slice(0, resourceName.indexOf(".")));
break;
}
if (!timedEvent) {
continue;
}
const propPattern = /([a-z]+): (.*?)(?:,|\})/gi;
let propMatch: RegExpExecArray;
while ((propMatch = propPattern.exec(timingData)!)) {
// TODO: is this bang correct?
const prop = propMatch[1];
let value: any = propMatch[2];
switch (prop) {
case "bgX":
case "bgY":
value = Number.parseFloat(value);
break;
case "volume":
case "pitch":
case "opacity":
case "colorRed":
case "colorGreen":
case "colorBlue":
case "colorAlpha":
case "duration":
case "flashScope":
case "flashRed":
case "flashGreen":
case "flashBlue":
case "flashAlpha":
case "flashDuration":
value = Number.parseInt(value);
break;
}
if (timedEvent.hasOwnProperty(prop)) {
timedEvent[prop] = value;
}
}
if (!anim.frameTimedEvents.has(frameIndex)) {
anim.frameTimedEvents.set(frameIndex, []);
}
anim.frameTimedEvents.get(frameIndex)!.push(timedEvent); // TODO: is this bang correct?
}
break;
}
case "position":
anim.position = Number.parseInt(fieldData);
break;
case "hue":
anim.hue = Number.parseInt(fieldData);
break;
}
}
}
// biome-ignore lint/correctness/noUnusedVariables: used in commented code
const animReplacer = (k, v) => {
if (k === "id" && !v) {
return undefined;
}
if (v instanceof Map) {
return Object.fromEntries(v);
}
if (v instanceof AnimTimedEvent) {
v["eventType"] = v.getEventType();
}
return v;
};
const animConfigProps = ["id", "graphic", "frames", "frameTimedEvents", "position", "hue"];
const animFrameProps = [
"x",
"y",
"zoomX",
"zoomY",
"angle",
"mirror",
"visible",
"blendType",
"target",
"graphicFrame",
"opacity",
"color",
"tone",
"flash",
"locked",
"priority",
"focus",
];
const propSets = [animConfigProps, animFrameProps];
// biome-ignore lint/correctness/noUnusedVariables: used in commented code
const animComparator = (a: Element, b: Element) => {
let props: string[];
for (let p = 0; p < propSets.length; p++) {
props = propSets[p];
// @ts-expect-error TODO
const ai = props.indexOf(a.key);
if (ai === -1) {
continue;
}
// @ts-expect-error TODO
const bi = props.indexOf(b.key);
return ai < bi ? -1 : ai > bi ? 1 : 0;
}
return 0;
};
/*for (let ma of moveAnims.keys()) {
const data = moveAnims.get(ma);
(async () => {
await fs.writeFile(`../public/battle-anims/${Moves[ma].toLowerCase().replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
})();
}
for (let ca of chargeAnims.keys()) {
const data = chargeAnims.get(ca);
(async () => {
await fs.writeFile(`../public/battle-anims/${chargeAnimNames[chargeAnimIds.indexOf(ca)].replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
})();
}
for (let cma of commonAnims.keys()) {
const data = commonAnims.get(cma);
(async () => {
await fs.writeFile(`../public/battle-anims/common-${commonAnimNames[commonAnimIds.indexOf(cma)].replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
})();
}*/
}

View File

@ -1,3 +1,4 @@
import type { BattlerTag } from "#data/battler-tags";
import { AbAttrParamsWithCancel, PreAttackModifyPowerAbAttrParams } from "#abilities/ability";
import {
applyAbAttrs
@ -1312,10 +1313,8 @@ export class MoveEffectAttr extends MoveAttr {
* @param args Set of unique arguments needed by this attribute
* @returns true if basic application of the ability attribute should be possible
*/
canApply(user: Pokemon, target: Pokemon, move: Move, args?: any[]) {
return !! (this.selfTarget ? user.hp && !user.getTag(BattlerTagType.FRENZY) : target.hp)
&& (this.selfTarget || !target.getTag(BattlerTagType.PROTECTED) ||
move.doesFlagEffectApply({ flag: MoveFlags.IGNORE_PROTECT, user, target }));
canApply(user: Pokemon, target: Pokemon, move: Move, _args?: any[]) {
return !(this.selfTarget ? user : target).isFainted();
}
/** Applies move effects so long as they are able based on {@linkcode canApply} */
@ -5614,16 +5613,15 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
public tagType: BattlerTagType;
public turnCountMin: number;
public turnCountMax: number;
protected cancelOnFail: boolean;
private failOnOverlap: boolean;
constructor(tagType: BattlerTagType, selfTarget: boolean = false, failOnOverlap: boolean = false, turnCountMin: number = 0, turnCountMax?: number, lastHitOnly: boolean = false) {
super(selfTarget, { lastHitOnly: lastHitOnly });
constructor(tagType: BattlerTagType, selfTarget: boolean = false, failOnOverlap = false, turnCountMin = 0, turnCountMax = turnCountMin, lastHitOnly = false) {
super(selfTarget, { lastHitOnly });
this.tagType = tagType;
this.turnCountMin = turnCountMin;
this.turnCountMax = turnCountMax !== undefined ? turnCountMax : turnCountMin;
this.failOnOverlap = !!failOnOverlap;
this.turnCountMax = turnCountMax;
this.failOnOverlap = failOnOverlap;
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
@ -5631,6 +5629,7 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
return false;
}
// TODO: Do any moves actually use chance-based battler tag adding?
const moveChance = this.getMoveChance(user, target, move, this.selfTarget, true);
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);
@ -5841,32 +5840,14 @@ export class CurseAttr extends MoveEffectAttr {
}
}
export class LapseBattlerTagAttr extends MoveEffectAttr {
public tagTypes: BattlerTagType[];
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;
}
}
/**
* Attribute to remove all {@linkcode BattlerTag}s matching one or more tag types.
*/
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);
this.tagTypes = tagTypes;
@ -5877,9 +5858,7 @@ export class RemoveBattlerTagAttr extends MoveEffectAttr {
return false;
}
for (const tagType of this.tagTypes) {
(this.selfTarget ? user : target).removeTag(tagType);
}
(this.selfTarget ? user : target).findAndRemoveTags(t => this.tagTypes.includes(t.tagType));
return true;
}
@ -5986,14 +5965,13 @@ export class RemoveAllSubstitutesAttr extends MoveEffectAttr {
export class HitsTagAttr extends MoveAttr {
/** The {@linkcode BattlerTagType} this move hits */
public tagType: BattlerTagType;
/** Should this move deal double damage against {@linkcode HitsTagAttr.tagType}? */
public doubleDamage: boolean;
/** Should this move deal double damage against {@linkcode tagType}? */
public doubleDamage = false;
constructor(tagType: BattlerTagType, doubleDamage: boolean = false) {
constructor(tagType: BattlerTagType) {
super();
this.tagType = tagType;
this.doubleDamage = !!doubleDamage;
}
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
@ -6008,7 +5986,8 @@ export class HitsTagAttr extends MoveAttr {
*/
export class HitsTagForDoubleDamageAttr extends HitsTagAttr {
constructor(tagType: BattlerTagType) {
super(tagType, true);
super(tagType);
this.doubleDamage = true;
}
}
@ -6018,11 +5997,11 @@ export class AddArenaTagAttr extends MoveEffectAttr {
private failOnOverlap: 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);
this.tagType = tagType;
this.turnCount = turnCount!; // TODO: is the bang correct?
this.turnCount = turnCount;
this.failOnOverlap = failOnOverlap;
this.selfSideTarget = selfSideTarget;
}
@ -6032,6 +6011,7 @@ export class AddArenaTagAttr extends MoveEffectAttr {
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) {
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);
@ -6043,25 +6023,29 @@ export class AddArenaTagAttr extends MoveEffectAttr {
getCondition(): MoveConditionFunc | null {
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;
}
}
/**
* Generic class for removing arena tags
* @param tagTypes: The types of tags that can be removed
* @param selfSideTarget: Is the user removing tags from its own side?
* Attribute to remove one or more arena tags from the field.
*/
export class RemoveArenaTagsAttr extends MoveEffectAttr {
public tagTypes: ArenaTagType[];
public selfSideTarget: boolean;
/** An array containing the tags to be removed. */
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`)
* @defaultValue `false`
*/
private removeAllTags: boolean
constructor(tagTypes: ArenaTagType[], selfSideTarget: boolean) {
super(true);
constructor(tagTypes: readonly [ArenaTagType, ...ArenaTagType[]], removeAllTags = false, options?: MoveEffectAttrOptions) {
super(true, options);
this.tagTypes = tagTypes;
this.selfSideTarget = selfSideTarget;
this.removeAllTags = removeAllTags;
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
@ -6069,11 +6053,9 @@ export class RemoveArenaTagsAttr extends MoveEffectAttr {
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.removeTagOnSide(tagType, side);
}
globalScene.arena.removeTagsOnSide(this.tagTypes, side);
return true;
}
@ -6098,6 +6080,7 @@ export class AddArenaTrapTagAttr extends AddArenaTagAttr {
* @extends AddArenaTagAttr
* @see {@linkcode apply}
*/
// TODO: This has exactly 1 line of code difference from the base attribute wrt. effect chances...
export class AddArenaTrapTagHitAttr extends AddArenaTagAttr {
/**
* @param user {@linkcode Pokemon} using this move
@ -6119,80 +6102,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;
constructor(targetBothSides: boolean = false) {
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.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 RemoveArenaTrapAttr extends RemoveArenaTagsAttr {
constructor(targetBothSides = false) {
// TODO: This triggers at a different time than `RemoveArenaTagsAbAttr`...
super(arenaTrapTags, targetBothSides, { trigger: MoveEffectTrigger.PRE_APPLY });
}
}
export class RemoveScreensAttr extends MoveEffectAttr {
private targetBothSides: boolean;
constructor(targetBothSides: boolean = false) {
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;
const screenTags = [
ArenaTagType.REFLECT,
ArenaTagType.LIGHT_SCREEN,
ArenaTagType.AURORA_VEIL
] as const;
export class RemoveScreensAttr extends RemoveArenaTagsAttr {
constructor(targetBothSides = false) {
// TODO: This triggers at a different time than {@linkcode RemoveArenaTagsAbAttr}...
super(screenTags, targetBothSides, { trigger: MoveEffectTrigger.PRE_APPLY });
}
}
/*Swaps arena effects between the player and enemy side
* @extends MoveEffectAttr
* @see {@linkcode apply}
*/
/**
* Swaps arena effects between the player and enemy side
*/
export class SwapArenaTagsAttr extends MoveEffectAttr {
public SwapTags: ArenaTagType[];
@ -8420,7 +8360,6 @@ const MoveAttrs = Object.freeze({
GulpMissileTagAttr,
JawLockAttr,
CurseAttr,
LapseBattlerTagAttr,
RemoveBattlerTagAttr,
FlinchAttr,
ConfuseAttr,
@ -10416,7 +10355,7 @@ export function initMoves() {
.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)))),
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),
new StatusMove(MoveId.ELECTRIC_TERRAIN, PokemonType.ELECTRIC, -1, 10, -1, 0, 6)
.attr(TerrainChangeAttr, TerrainType.ELECTRIC)
@ -10694,7 +10633,7 @@ export function initMoves() {
new AttackMove(MoveId.MALICIOUS_MOONSAULT, PokemonType.DARK, MoveCategory.PHYSICAL, 180, -1, 1, -1, 0, 7)
.unimplemented()
.attr(AlwaysHitMinimizeAttr)
.attr(HitsTagAttr, BattlerTagType.MINIMIZED, true)
.attr(HitsTagForDoubleDamageAttr, BattlerTagType.MINIMIZED)
.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)
.unimplemented()
@ -11322,6 +11261,7 @@ export function initMoves() {
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_GET_HIT, true, false, 0, 0, true)
.attr(AddBattlerTagAttr, BattlerTagType.RECEIVE_DOUBLE_DAMAGE, true, false, 0, 0, true)
.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");
}),
new StatusMove(MoveId.REVIVAL_BLESSING, PokemonType.NORMAL, -1, 1, -1, 0, 9)
@ -11334,7 +11274,7 @@ export function initMoves() {
new AttackMove(MoveId.TRIPLE_DIVE, PokemonType.WATER, MoveCategory.PHYSICAL, 30, 95, 10, -1, 0, 9)
.attr(MultiHitAttr, MultiHitType._3),
new AttackMove(MoveId.MORTAL_SPIN, PokemonType.POISON, MoveCategory.PHYSICAL, 30, 100, 15, 100, 0, 9)
.attr(LapseBattlerTagAttr, [
.attr(RemoveBattlerTagAttr, [
BattlerTagType.BIND,
BattlerTagType.WRAP,
BattlerTagType.FIRE_SPIN,

View File

@ -718,7 +718,7 @@ export class Arena {
}
// creates a new tag object
const newTag = getArenaTag(tagType, turnCount || 0, sourceMove, sourceId, side);
const newTag = getArenaTag(tagType, turnCount, sourceMove, sourceId, side);
if (newTag) {
newTag.onAdd(this, quiet);
this.tags.push(newTag);
@ -834,6 +834,36 @@ export class Arena {
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 {
while (this.tags.length) {
this.tags[0].onRemove(this);

View File

@ -745,7 +745,7 @@ export class MoveEffectPhase extends PokemonPhase {
/**
* 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
* - {@linkcode MoveEffectTrigger.POST_APPLY | POST_APPLY} effects
* - Invoking {@linkcode applyOnTargetEffects} if the move does not hit a substitute

View File

@ -2142,7 +2142,12 @@ class PartyCancelButton extends Phaser.GameObjects.Container {
this.partyCancelPb = partyCancelPb;
const partyCancelText = addTextObject(-10, -7, i18next.t("partyUiHandler:cancel"), TextStyle.PARTY_CANCEL_BUTTON);
const partyCancelText = addTextObject(
-10,
-7,
i18next.t("partyUiHandler:cancelButton"),
TextStyle.PARTY_CANCEL_BUTTON,
);
this.add(partyCancelText);
}

View File

@ -1,12 +1,13 @@
import { SubstituteTag } from "#data/battler-tags";
import { AbilityId } from "#enums/ability-id";
import { ArenaTagSide } from "#enums/arena-tag-side";
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 { SpeciesId } from "#enums/species-id";
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 type { ArenaTrapTagType } from "#types/arena-tags";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -31,86 +32,65 @@ describe("Moves - Tidy Up", () => {
.enemySpecies(SpeciesId.MAGIKARP)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH)
.starterSpecies(SpeciesId.FEEBAS)
.ability(AbilityId.BALL_FETCH)
.moveset([MoveId.TIDY_UP])
.startingLevel(50);
.ability(AbilityId.BALL_FETCH);
});
it("spikes are cleared", async () => {
game.override.moveset([MoveId.SPIKES, MoveId.TIDY_UP]).enemyMoveset(MoveId.SPIKES);
await game.classicMode.startBattle();
it.each<{ name: string; tagType: ArenaTrapTagType }>([
{ name: "Spikes", tagType: ArenaTagType.SPIKES },
{ 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);
await game.phaseInterceptor.to(TurnEndPhase);
game.move.select(MoveId.TIDY_UP);
await game.phaseInterceptor.to(MoveEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.SPIKES)).toBeUndefined();
// Add tag to both sides of the field
game.scene.arena.addTag(tagType, 1, undefined, game.field.getPlayerPokemon().id, ArenaTagSide.PLAYER);
game.scene.arena.addTag(tagType, 1, undefined, game.field.getPlayerPokemon().id, ArenaTagSide.ENEMY);
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 () => {
game.override.moveset([MoveId.STEALTH_ROCK, MoveId.TIDY_UP]).enemyMoveset(MoveId.STEALTH_ROCK);
await game.classicMode.startBattle();
it("should clear substitutes from all pokemon", async () => {
game.override.battleStyle("double");
await game.classicMode.startBattle([SpeciesId.CINCCINO, SpeciesId.FEEBAS]);
game.move.select(MoveId.STEALTH_ROCK);
await game.phaseInterceptor.to(TurnEndPhase);
game.move.select(MoveId.TIDY_UP);
await game.phaseInterceptor.to(MoveEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.STEALTH_ROCK)).toBeUndefined();
game.move.use(MoveId.SUBSTITUTE, BattlerIndex.PLAYER);
game.move.use(MoveId.SUBSTITUTE, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.SUBSTITUTE);
await game.move.forceEnemyMove(MoveId.SUBSTITUTE);
await game.toNextTurn();
game.scene.getField(true).forEach(p => {
expect(p).toHaveBattlerTag(BattlerTagType.SUBSTITUTE);
});
it("toxic spikes are cleared", async () => {
game.override.moveset([MoveId.TOXIC_SPIKES, MoveId.TIDY_UP]).enemyMoveset(MoveId.TOXIC_SPIKES);
await game.classicMode.startBattle();
game.move.use(MoveId.TIDY_UP, BattlerIndex.PLAYER);
game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.SPLASH);
await game.move.forceEnemyMove(MoveId.SPLASH);
await game.toEndOfTurn();
game.move.select(MoveId.TOXIC_SPIKES);
await game.phaseInterceptor.to(TurnEndPhase);
game.move.select(MoveId.TIDY_UP);
await game.phaseInterceptor.to(MoveEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.TOXIC_SPIKES)).toBeUndefined();
});
it("sticky webs are cleared", async () => {
game.override.moveset([MoveId.STICKY_WEB, MoveId.TIDY_UP]).enemyMoveset(MoveId.STICKY_WEB);
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.field.getPlayerPokemon(), game.field.getEnemyPokemon()];
pokemon.forEach(p => {
expect(p).toBeDefined();
expect(p!.getTag(SubstituteTag)).toBeUndefined();
game.scene.getField(true).forEach(p => {
expect(p).not.toHaveBattlerTag(BattlerTagType.SUBSTITUTE);
});
});
it("user's stats are raised with no traps set", async () => {
await game.classicMode.startBattle();
it("should raise the user's stats even if a tag cannot be removed", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const playerPokemon = game.field.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);
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0);
game.move.use(MoveId.TIDY_UP);
await game.toEndOfTurn();
game.move.select(MoveId.TIDY_UP);
await game.phaseInterceptor.to(TurnEndPhase);
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(1);
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1);
expect(feebas).toHaveStatStage(Stat.ATK, 1);
expect(feebas).toHaveStatStage(Stat.SPD, 1);
});
});