Compare commits

..

No commits in common. "cfcfa84e7280e29eefa9db0121102e5abfc25b41" and "9f30a2af199fe15b75aa94381199ef8731a40f55" have entirely different histories.

21 changed files with 401 additions and 665 deletions

View File

@ -1,7 +1,7 @@
name: Bug Report name: Bug Report
description: Create a report to help us improve description: Create a report to help us improve
title: "[Bug] " title: "[Bug] "
labels: ["Bug", "Triage"] labels: ["Bug"]
body: body:
- type: markdown - type: markdown
attributes: attributes:
@ -19,12 +19,21 @@ body:
value: | value: |
--- ---
- type: textarea - type: textarea
id: repro id: session-file
attributes: attributes:
label: Reproduction label: Session export file
description: Describe the steps to reproduce this bug. If applicable attach user/session data at the bottom description: Open Menu → ManageData → Export Session → Select slot. The file should now be in your `/Downloads` directory. Change the file extension type from `.prsv` to `.txt` (How to [Windows](https://www.guidingtech.com/how-to-change-file-type-on-windows/) | [Mac](https://support.apple.com/guide/mac-help/show-or-hide-filename-extensions-on-mac-mchlp2304/mac) | [iOS](https://www.guidingtech.com/change-file-type-extension-on-iphone/)).
placeholder: Focus me and then drop your file here (or use the upload button at the bottom)
validations: validations:
required: true required: false
- type: textarea
id: data-file
attributes:
label: User data export file
description: Open Menu → ManageData → Export Data. The file should now be in your `/Downloads` directory. Change the file extension type from `.prsv` to `.txt` (How to [Windows](https://www.guidingtech.com/how-to-change-file-type-on-windows/) | [Mac](https://support.apple.com/guide/mac-help/show-or-hide-filename-extensions-on-mac-mchlp2304/mac) | [iOS](https://www.guidingtech.com/change-file-type-extension-on-iphone/)).
placeholder: Focus me and then drop your file here (or use the upload button at the bottom)
validations:
required: false
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
@ -51,20 +60,48 @@ body:
attributes: attributes:
value: | value: |
--- ---
- type: textarea - type: dropdown
id: session-file id: os
attributes: attributes:
label: Session export file label: What OS did you observe the bug on?
description: Open Menu → ManageData → Export Session → Select slot. The file should now be in your `/Downloads` directory. Change the file extension type from `.prsv` to `.txt` (How to [Windows](https://www.guidingtech.com/how-to-change-file-type-on-windows/) | [Mac](https://support.apple.com/guide/mac-help/show-or-hide-filename-extensions-on-mac-mchlp2304/mac) | [iOS](https://www.guidingtech.com/change-file-type-extension-on-iphone/)). multiple: true
placeholder: Focus me and then drop your file here (or use the upload button at the bottom) options:
- PC/Windows
- Mac/OSX
- Linux
- iOS
- Android
- Other
validations:
required: true
- type: input
id: os-other
attributes:
label: If other please specify
validations: validations:
required: false required: false
- type: textarea - type: markdown
id: data-file
attributes: attributes:
label: User data export file value: |
description: Open Menu → ManageData → Export Data. The file should now be in your `/Downloads` directory. Change the file extension type from `.prsv` to `.txt` (How to [Windows](https://www.guidingtech.com/how-to-change-file-type-on-windows/) | [Mac](https://support.apple.com/guide/mac-help/show-or-hide-filename-extensions-on-mac-mchlp2304/mac) | [iOS](https://www.guidingtech.com/change-file-type-extension-on-iphone/)). ---
placeholder: Focus me and then drop your file here (or use the upload button at the bottom) - type: dropdown
id: browser
attributes:
label: Which browser do you use?
multiple: true
options:
- Chrome
- Firefox
- Safari
- Edge
- Opera
- Other
validations:
required: true
- type: input
id: browser-other
attributes:
label: If other please specify
validations: validations:
required: false required: false
- type: markdown - type: markdown

View File

@ -1,7 +1,7 @@
name: Feature Request name: Feature Request
description: Suggest an idea for this project description: Suggest an idea for this project
title: "[Feature] " title: "[Feature] "
labels: ["Enhancement", "Triage"] labels: ["Enhancement"]
body: body:
- type: markdown - type: markdown
attributes: attributes:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -3,36 +3,44 @@
"bcb9be": "ae4c95", "bcb9be": "ae4c95",
"f9f2fc": "ffc0e5", "f9f2fc": "ffc0e5",
"7b787c": "793d6d", "7b787c": "793d6d",
"dcd9dd": "e88cc5", "e1dfe2": "e88cc5",
"c9c0ce": "ce6bac", "d0cfd0": "ce6bac",
"cbc2d1": "d7d2f6", "b8b4ba": "d7d2f6",
"938f94": "b465b9", "938f94": "b465b9",
"fbf2ff": "d3ffff", "6c7275": "d3ffff",
"e66294": "80a4ff", "9362e6": "80a4ff",
"c6bbcb": "a7e6e5", "fcfcfc": "fcfcfc",
"ffa4c5": "bed5ff", "4a494e": "a7e6e5",
"7f806a": "4d8894", "c6a4ff": "bed5ff",
"a8a0ac": "e88cc5", "101010": "101010",
"7c7a78": "793d6d", "3b3a3f": "4d8894",
"bbb4bc": "ce6bac", "aeadae": "e88cc5",
"686568": "686568",
"6f6d71": "793d6d",
"b5b4b6": "ce6bac",
"706e6d": "7d7c75",
"af9e9e": "42a2b1" "af9e9e": "42a2b1"
}, },
"2": { "2": {
"bcb9be": "055946", "bcb9be": "055946",
"f9f2fc": "21be70", "f9f2fc": "21be70",
"7b787c": "004140", "7b787c": "004140",
"dcd9dd": "12a169", "e1dfe2": "12a169",
"c9c0ce": "0a7a57", "d0cfd0": "0a7a57",
"cbc2d1": "567f83", "b8b4ba": "567f83",
"938f94": "2b5458", "938f94": "2b5458",
"fbf2ff": "874059", "6c7275": "874059",
"e66294": "15c05f", "9362e6": "15c05f",
"c6bbcb": "773050", "fcfcfc": "fcfcfc",
"ffa4c5": "8ff3a3", "4a494e": "773050",
"7f806a": "4b1f28", "c6a4ff": "8ff3a3",
"a8a0ac": "12a169", "101010": "101010",
"7c7a78": "004140", "3b3a3f": "4b1f28",
"bbb4bc": "0a7a57", "aeadae": "12a169",
"686568": "686568",
"6f6d71": "004140",
"b5b4b6": "0a7a57",
"706e6d": "7d7c75",
"af9e9e": "48c492" "af9e9e": "48c492"
} }
} }

View File

@ -1,4 +1,5 @@
import BattleScene from "./battle-scene"; import BattleScene from "./battle-scene";
import { EnemyPokemon, PlayerPokemon, QueuedMove } from "./field/pokemon";
import { Command } from "./ui/command-ui-handler"; import { Command } from "./ui/command-ui-handler";
import * as Utils from "./utils"; import * as Utils from "./utils";
import Trainer, { TrainerVariant } from "./field/trainer"; import Trainer, { TrainerVariant } from "./field/trainer";
@ -6,7 +7,6 @@ import { GameMode } from "./game-mode";
import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier"; import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier";
import { PokeballType } from "./data/pokeball"; import { PokeballType } from "./data/pokeball";
import { trainerConfigs } from "#app/data/trainer-config"; import { trainerConfigs } from "#app/data/trainer-config";
import Pokemon, { EnemyPokemon, PlayerPokemon, QueuedMove } from "#app/field/pokemon";
import { ArenaTagType } from "#enums/arena-tag-type"; import { ArenaTagType } from "#enums/arena-tag-type";
import { BattleSpec } from "#enums/battle-spec"; import { BattleSpec } from "#enums/battle-spec";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -41,11 +41,6 @@ export interface TurnCommand {
args?: any[]; args?: any[];
} }
export interface FaintLogEntry {
pokemon: Pokemon,
turn: number
}
interface TurnCommands { interface TurnCommands {
[key: number]: TurnCommand | null [key: number]: TurnCommand | null
} }
@ -77,9 +72,6 @@ export default class Battle {
public playerFaints: number = 0; public playerFaints: number = 0;
/** The number of times a Pokemon on the enemy's side has fainted this battle */ /** The number of times a Pokemon on the enemy's side has fainted this battle */
public enemyFaints: number = 0; public enemyFaints: number = 0;
public playerFaintsHistory: FaintLogEntry[] = [];
public enemyFaintsHistory: FaintLogEntry[] = [];
public mysteryEncounter?: MysteryEncounter; public mysteryEncounter?: MysteryEncounter;
private rngCounter: number = 0; private rngCounter: number = 0;

View File

@ -1298,13 +1298,6 @@ export class ProtectedTag extends BattlerTag {
} }
} }
/** Base class for `BattlerTag`s that block damaging moves but not status moves */
export class DamageProtectedTag extends ProtectedTag {}
/**
* `BattlerTag` class for moves that block damaging moves damage the enemy if the enemy's move makes contact
* Used by {@linkcode Moves.SPIKY_SHIELD}
*/
export class ContactDamageProtectedTag extends ProtectedTag { export class ContactDamageProtectedTag extends ProtectedTag {
private damageRatio: number; private damageRatio: number;
@ -1340,11 +1333,7 @@ export class ContactDamageProtectedTag extends ProtectedTag {
} }
} }
/** export class ContactStatStageChangeProtectedTag extends ProtectedTag {
* `BattlerTag` class for moves that block damaging moves and lower enemy stats if the enemy's move makes contact
* Used by {@linkcode Moves.KINGS_SHIELD}, {@linkcode Moves.OBSTRUCT}, {@linkcode Moves.SILK_TRAP}
*/
export class ContactStatStageChangeProtectedTag extends DamageProtectedTag {
private stat: BattleStat; private stat: BattleStat;
private levels: number; private levels: number;
@ -1400,11 +1389,7 @@ export class ContactPoisonProtectedTag extends ProtectedTag {
} }
} }
/** export class ContactBurnProtectedTag extends ProtectedTag {
* `BattlerTag` class for moves that block damaging moves and burn the enemy if the enemy's move makes contact
* Used by {@linkcode Moves.BURNING_BULWARK}
*/
export class ContactBurnProtectedTag extends DamageProtectedTag {
constructor(sourceMove: Moves) { constructor(sourceMove: Moves) {
super(sourceMove, BattlerTagType.BURNING_BULWARK); super(sourceMove, BattlerTagType.BURNING_BULWARK);
} }

View File

@ -81,16 +81,6 @@ export enum MoveFlags {
MAKES_CONTACT = 1 << 0, MAKES_CONTACT = 1 << 0,
IGNORE_PROTECT = 1 << 1, IGNORE_PROTECT = 1 << 1,
IGNORE_VIRTUAL = 1 << 2, IGNORE_VIRTUAL = 1 << 2,
/**
* Sound-based moves have the following effects:
* - Pokemon with the {@linkcode Abilities.SOUNDPROOF Soundproof Ability} are unaffected by other Pokemon's sound-based moves.
* - Pokemon affected by {@linkcode Moves.THROAT_CHOP Throat Chop} cannot use sound-based moves for two turns.
* - Sound-based moves used by a Pokemon with {@linkcode Abilities.LIQUID_VOICE Liquid Voice} become Water-type moves.
* - Sound-based moves used by a Pokemon with {@linkcode Abilities.PUNK_ROCK Punk Rock} are boosted by 30%. Pokemon with Punk Rock also take half damage from sound-based moves.
* - All sound-based moves (except Howl) can hit Pokemon behind an active {@linkcode Moves.SUBSTITUTE Substitute}.
*
* cf https://bulbapedia.bulbagarden.net/wiki/Sound-based_move
*/
SOUND_BASED = 1 << 3, SOUND_BASED = 1 << 3,
HIDE_USER = 1 << 4, HIDE_USER = 1 << 4,
HIDE_TARGET = 1 << 5, HIDE_TARGET = 1 << 5,
@ -103,20 +93,19 @@ export enum MoveFlags {
* @see {@linkcode Move.recklessMove()} * @see {@linkcode Move.recklessMove()}
*/ */
RECKLESS_MOVE = 1 << 10, RECKLESS_MOVE = 1 << 10,
/** Indicates a move should be affected by {@linkcode Abilities.BULLETPROOF} */
BALLBOMB_MOVE = 1 << 11, BALLBOMB_MOVE = 1 << 11,
/** Grass types and pokemon with {@linkcode Abilities.OVERCOAT} are immune to powder moves */
POWDER_MOVE = 1 << 12, POWDER_MOVE = 1 << 12,
/** Indicates a move should trigger {@linkcode Abilities.DANCER} */
DANCE_MOVE = 1 << 13, DANCE_MOVE = 1 << 13,
/** Indicates a move should trigger {@linkcode Abilities.WIND_RIDER} */
WIND_MOVE = 1 << 14, WIND_MOVE = 1 << 14,
/** Indicates a move should trigger {@linkcode Abilities.TRIAGE} */
TRIAGE_MOVE = 1 << 15, TRIAGE_MOVE = 1 << 15,
IGNORE_ABILITIES = 1 << 16, IGNORE_ABILITIES = 1 << 16,
/** Enables all hits of a multi-hit move to be accuracy checked individually */ /**
* Enables all hits of a multi-hit move to be accuracy checked individually
*/
CHECK_ALL_HITS = 1 << 17, CHECK_ALL_HITS = 1 << 17,
/** Indicates a move is able to be redirected to allies in a double battle if the attacker faints */ /**
* Indicates a move is able to be redirected to allies in a double battle if the attacker faints
*/
REDIRECT_COUNTER = 1 << 18, REDIRECT_COUNTER = 1 << 18,
} }
@ -129,22 +118,22 @@ export default class Move implements Localizable {
private _type: Type; private _type: Type;
private _category: MoveCategory; private _category: MoveCategory;
public moveTarget: MoveTarget; public moveTarget: MoveTarget;
public power: number; public power: integer;
public accuracy: number; public accuracy: integer;
public pp: number; public pp: integer;
public effect: string; public effect: string;
/** The chance of a move's secondary effects activating */ public chance: integer;
public chance: number; public priority: integer;
public priority: number; public generation: integer;
public generation: number; public attrs: MoveAttr[];
public attrs: MoveAttr[] = []; private conditions: MoveCondition[];
private conditions: MoveCondition[] = []; private flags: integer;
/** The move's {@linkcode MoveFlags} */ private nameAppend: string;
private flags: number = 0;
private nameAppend: string = "";
constructor(id: Moves, type: Type, category: MoveCategory, defaultMoveTarget: MoveTarget, power: number, accuracy: number, pp: number, chance: number, priority: number, generation: number) { constructor(id: Moves, type: Type, category: MoveCategory, defaultMoveTarget: MoveTarget, power: integer, accuracy: integer, pp: integer, chance: integer, priority: integer, generation: integer) {
this.id = id; this.id = id;
this.nameAppend = "";
this._type = type; this._type = type;
this._category = category; this._category = category;
this.moveTarget = defaultMoveTarget; this.moveTarget = defaultMoveTarget;
@ -155,6 +144,10 @@ export default class Move implements Localizable {
this.priority = priority; this.priority = priority;
this.generation = generation; this.generation = generation;
this.attrs = [];
this.conditions = [];
this.flags = 0;
if (defaultMoveTarget === MoveTarget.USER) { if (defaultMoveTarget === MoveTarget.USER) {
this.setFlag(MoveFlags.IGNORE_PROTECT, true); this.setFlag(MoveFlags.IGNORE_PROTECT, true);
} }
@ -384,7 +377,7 @@ export default class Move implements Localizable {
* @param makesContact The value (boolean) to set the flag to * @param makesContact The value (boolean) to set the flag to
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
makesContact(makesContact: boolean = true): this { makesContact(makesContact: boolean = true): this { // TODO: is true the correct default?
this.setFlag(MoveFlags.MAKES_CONTACT, makesContact); this.setFlag(MoveFlags.MAKES_CONTACT, makesContact);
return this; return this;
} }
@ -395,7 +388,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.CURSE} * example: @see {@linkcode Moves.CURSE}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
ignoresProtect(ignoresProtect: boolean = true): this { ignoresProtect(ignoresProtect: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.IGNORE_PROTECT, ignoresProtect); this.setFlag(MoveFlags.IGNORE_PROTECT, ignoresProtect);
return this; return this;
} }
@ -406,7 +399,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.NATURE_POWER} * example: @see {@linkcode Moves.NATURE_POWER}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
ignoresVirtual(ignoresVirtual: boolean = true): this { ignoresVirtual(ignoresVirtual: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.IGNORE_VIRTUAL, ignoresVirtual); this.setFlag(MoveFlags.IGNORE_VIRTUAL, ignoresVirtual);
return this; return this;
} }
@ -417,7 +410,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.UPROAR} * example: @see {@linkcode Moves.UPROAR}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
soundBased(soundBased: boolean = true): this { soundBased(soundBased: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.SOUND_BASED, soundBased); this.setFlag(MoveFlags.SOUND_BASED, soundBased);
return this; return this;
} }
@ -428,7 +421,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.TELEPORT} * example: @see {@linkcode Moves.TELEPORT}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
hidesUser(hidesUser: boolean = true): this { hidesUser(hidesUser: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.HIDE_USER, hidesUser); this.setFlag(MoveFlags.HIDE_USER, hidesUser);
return this; return this;
} }
@ -439,7 +432,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.WHIRLWIND} * example: @see {@linkcode Moves.WHIRLWIND}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
hidesTarget(hidesTarget: boolean = true): this { hidesTarget(hidesTarget: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.HIDE_TARGET, hidesTarget); this.setFlag(MoveFlags.HIDE_TARGET, hidesTarget);
return this; return this;
} }
@ -450,7 +443,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.BITE} * example: @see {@linkcode Moves.BITE}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
bitingMove(bitingMove: boolean = true): this { bitingMove(bitingMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.BITING_MOVE, bitingMove); this.setFlag(MoveFlags.BITING_MOVE, bitingMove);
return this; return this;
} }
@ -461,7 +454,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.WATER_PULSE} * example: @see {@linkcode Moves.WATER_PULSE}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
pulseMove(pulseMove: boolean = true): this { pulseMove(pulseMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.PULSE_MOVE, pulseMove); this.setFlag(MoveFlags.PULSE_MOVE, pulseMove);
return this; return this;
} }
@ -472,7 +465,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.DRAIN_PUNCH} * example: @see {@linkcode Moves.DRAIN_PUNCH}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
punchingMove(punchingMove: boolean = true): this { punchingMove(punchingMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.PUNCHING_MOVE, punchingMove); this.setFlag(MoveFlags.PUNCHING_MOVE, punchingMove);
return this; return this;
} }
@ -483,7 +476,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.X_SCISSOR} * example: @see {@linkcode Moves.X_SCISSOR}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
slicingMove(slicingMove: boolean = true): this { slicingMove(slicingMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.SLICING_MOVE, slicingMove); this.setFlag(MoveFlags.SLICING_MOVE, slicingMove);
return this; return this;
} }
@ -494,7 +487,7 @@ export default class Move implements Localizable {
* @param recklessMove The value to set the flag to * @param recklessMove The value to set the flag to
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
recklessMove(recklessMove: boolean = true): this { recklessMove(recklessMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.RECKLESS_MOVE, recklessMove); this.setFlag(MoveFlags.RECKLESS_MOVE, recklessMove);
return this; return this;
} }
@ -505,7 +498,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.ELECTRO_BALL} * example: @see {@linkcode Moves.ELECTRO_BALL}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
ballBombMove(ballBombMove: boolean = true): this { ballBombMove(ballBombMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.BALLBOMB_MOVE, ballBombMove); this.setFlag(MoveFlags.BALLBOMB_MOVE, ballBombMove);
return this; return this;
} }
@ -516,7 +509,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.STUN_SPORE} * example: @see {@linkcode Moves.STUN_SPORE}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
powderMove(powderMove: boolean = true): this { powderMove(powderMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.POWDER_MOVE, powderMove); this.setFlag(MoveFlags.POWDER_MOVE, powderMove);
return this; return this;
} }
@ -527,7 +520,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.PETAL_DANCE} * example: @see {@linkcode Moves.PETAL_DANCE}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
danceMove(danceMove: boolean = true): this { danceMove(danceMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.DANCE_MOVE, danceMove); this.setFlag(MoveFlags.DANCE_MOVE, danceMove);
return this; return this;
} }
@ -538,7 +531,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.HURRICANE} * example: @see {@linkcode Moves.HURRICANE}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
windMove(windMove: boolean = true): this { windMove(windMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.WIND_MOVE, windMove); this.setFlag(MoveFlags.WIND_MOVE, windMove);
return this; return this;
} }
@ -549,7 +542,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.ABSORB} * example: @see {@linkcode Moves.ABSORB}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
triageMove(triageMove: boolean = true): this { triageMove(triageMove: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.TRIAGE_MOVE, triageMove); this.setFlag(MoveFlags.TRIAGE_MOVE, triageMove);
return this; return this;
} }
@ -560,7 +553,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.SUNSTEEL_STRIKE} * example: @see {@linkcode Moves.SUNSTEEL_STRIKE}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
ignoresAbilities(ignoresAbilities: boolean = true): this { ignoresAbilities(ignoresAbilities: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.IGNORE_ABILITIES, ignoresAbilities); this.setFlag(MoveFlags.IGNORE_ABILITIES, ignoresAbilities);
return this; return this;
} }
@ -571,7 +564,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.TRIPLE_AXEL} * example: @see {@linkcode Moves.TRIPLE_AXEL}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
checkAllHits(checkAllHits: boolean = true): this { checkAllHits(checkAllHits: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.CHECK_ALL_HITS, checkAllHits); this.setFlag(MoveFlags.CHECK_ALL_HITS, checkAllHits);
return this; return this;
} }
@ -582,7 +575,7 @@ export default class Move implements Localizable {
* example: @see {@linkcode Moves.METAL_BURST} * example: @see {@linkcode Moves.METAL_BURST}
* @returns The {@linkcode Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
redirectCounter(redirectCounter: boolean = true): this { redirectCounter(redirectCounter: boolean = true): this { // TODO: is `true` the correct default?
this.setFlag(MoveFlags.REDIRECT_COUNTER, redirectCounter); this.setFlag(MoveFlags.REDIRECT_COUNTER, redirectCounter);
return this; return this;
} }
@ -2786,26 +2779,28 @@ export class ResetStatsAttr extends MoveEffectAttr {
super(); super();
this.targetAllPokemon = targetAllPokemon; this.targetAllPokemon = targetAllPokemon;
} }
async apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const promises: Promise<void>[] = []; if (!super.apply(user, target, move, args)) {
return false;
}
if (this.targetAllPokemon) { // Target all pokemon on the field when Freezy Frost or Haze are used if (this.targetAllPokemon) { // Target all pokemon on the field when Freezy Frost or Haze are used
const activePokemon = user.scene.getField(true); const activePokemon = user.scene.getField(true);
activePokemon.forEach(p => promises.push(this.resetStats(p))); activePokemon.forEach(p => this.resetStats(p));
target.scene.queueMessage(i18next.t("moveTriggers:statEliminated")); target.scene.queueMessage(i18next.t("moveTriggers:statEliminated"));
} else { // Affects only the single target when Clear Smog is used } else { // Affects only the single target when Clear Smog is used
promises.push(this.resetStats(target)); this.resetStats(target);
target.scene.queueMessage(i18next.t("moveTriggers:resetStats", {pokemonName: getPokemonNameWithAffix(target)})); target.scene.queueMessage(i18next.t("moveTriggers:resetStats", {pokemonName: getPokemonNameWithAffix(target)}));
} }
await Promise.all(promises);
return true; return true;
} }
async resetStats(pokemon: Pokemon): Promise<void> { resetStats(pokemon: Pokemon) {
for (const s of BATTLE_STATS) { for (const s of BATTLE_STATS) {
pokemon.setStatStage(s, 0); pokemon.setStatStage(s, 0);
} }
return pokemon.updateInfo(); pokemon.updateInfo();
} }
} }
@ -4752,7 +4747,7 @@ export class AddArenaTagAttr extends MoveEffectAttr {
return false; return false;
} }
if ((move.chance < 0 || move.chance === 100 || user.randSeedInt(100) < move.chance) && user.getLastXMoves(1)[0].result === MoveResult.SUCCESS) { if (move.chance < 0 || move.chance === 100 || user.randSeedInt(100) < move.chance) {
user.scene.arena.addTag(this.tagType, this.turnCount, move.id, user.id, (this.selfSideTarget ? user : target).isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY); user.scene.arena.addTag(this.tagType, this.turnCount, move.id, user.id, (this.selfSideTarget ? user : target).isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY);
return true; return true;
} }
@ -7143,7 +7138,6 @@ export function initMoves() {
new StatusMove(Moves.CHARM, Type.FAIRY, 100, 20, -1, 0, 2) new StatusMove(Moves.CHARM, Type.FAIRY, 100, 20, -1, 0, 2)
.attr(StatStageChangeAttr, [ Stat.ATK ], -2), .attr(StatStageChangeAttr, [ Stat.ATK ], -2),
new AttackMove(Moves.ROLLOUT, Type.ROCK, MoveCategory.PHYSICAL, 30, 90, 20, -1, 0, 2) new AttackMove(Moves.ROLLOUT, Type.ROCK, MoveCategory.PHYSICAL, 30, 90, 20, -1, 0, 2)
.partial()
.attr(ConsecutiveUseDoublePowerAttr, 5, true, true, Moves.DEFENSE_CURL), .attr(ConsecutiveUseDoublePowerAttr, 5, true, true, Moves.DEFENSE_CURL),
new AttackMove(Moves.FALSE_SWIPE, Type.NORMAL, MoveCategory.PHYSICAL, 40, 100, 40, -1, 0, 2) new AttackMove(Moves.FALSE_SWIPE, Type.NORMAL, MoveCategory.PHYSICAL, 40, 100, 40, -1, 0, 2)
.attr(SurviveDamageAttr), .attr(SurviveDamageAttr),
@ -7423,11 +7417,9 @@ export function initMoves() {
.attr(HighCritAttr) .attr(HighCritAttr)
.attr(StatusEffectAttr, StatusEffect.BURN), .attr(StatusEffectAttr, StatusEffect.BURN),
new StatusMove(Moves.MUD_SPORT, Type.GROUND, -1, 15, -1, 0, 3) new StatusMove(Moves.MUD_SPORT, Type.GROUND, -1, 15, -1, 0, 3)
.ignoresProtect()
.attr(AddArenaTagAttr, ArenaTagType.MUD_SPORT, 5) .attr(AddArenaTagAttr, ArenaTagType.MUD_SPORT, 5)
.target(MoveTarget.BOTH_SIDES), .target(MoveTarget.BOTH_SIDES),
new AttackMove(Moves.ICE_BALL, Type.ICE, MoveCategory.PHYSICAL, 30, 90, 20, -1, 0, 3) new AttackMove(Moves.ICE_BALL, Type.ICE, MoveCategory.PHYSICAL, 30, 90, 20, -1, 0, 3)
.partial()
.attr(ConsecutiveUseDoublePowerAttr, 5, true, true, Moves.DEFENSE_CURL) .attr(ConsecutiveUseDoublePowerAttr, 5, true, true, Moves.DEFENSE_CURL)
.ballBombMove(), .ballBombMove(),
new AttackMove(Moves.NEEDLE_ARM, Type.GRASS, MoveCategory.PHYSICAL, 60, 100, 15, 30, 0, 3) new AttackMove(Moves.NEEDLE_ARM, Type.GRASS, MoveCategory.PHYSICAL, 60, 100, 15, 30, 0, 3)
@ -7549,7 +7541,6 @@ export function initMoves() {
.recklessMove(), .recklessMove(),
new AttackMove(Moves.MAGICAL_LEAF, Type.GRASS, MoveCategory.SPECIAL, 60, -1, 20, -1, 0, 3), new AttackMove(Moves.MAGICAL_LEAF, Type.GRASS, MoveCategory.SPECIAL, 60, -1, 20, -1, 0, 3),
new StatusMove(Moves.WATER_SPORT, Type.WATER, -1, 15, -1, 0, 3) new StatusMove(Moves.WATER_SPORT, Type.WATER, -1, 15, -1, 0, 3)
.ignoresProtect()
.attr(AddArenaTagAttr, ArenaTagType.WATER_SPORT, 5) .attr(AddArenaTagAttr, ArenaTagType.WATER_SPORT, 5)
.target(MoveTarget.BOTH_SIDES), .target(MoveTarget.BOTH_SIDES),
new SelfStatusMove(Moves.CALM_MIND, Type.PSYCHIC, -1, 20, -1, 0, 3) new SelfStatusMove(Moves.CALM_MIND, Type.PSYCHIC, -1, 20, -1, 0, 3)
@ -7578,7 +7569,6 @@ export function initMoves() {
.attr(AddBattlerTagAttr, BattlerTagType.ROOSTED, true, false) .attr(AddBattlerTagAttr, BattlerTagType.ROOSTED, true, false)
.triageMove(), .triageMove(),
new StatusMove(Moves.GRAVITY, Type.PSYCHIC, -1, 5, -1, 0, 4) new StatusMove(Moves.GRAVITY, Type.PSYCHIC, -1, 5, -1, 0, 4)
.ignoresProtect()
.attr(AddArenaTagAttr, ArenaTagType.GRAVITY, 5) .attr(AddArenaTagAttr, ArenaTagType.GRAVITY, 5)
.target(MoveTarget.BOTH_SIDES), .target(MoveTarget.BOTH_SIDES),
new StatusMove(Moves.MIRACLE_EYE, Type.PSYCHIC, -1, 40, -1, 0, 4) new StatusMove(Moves.MIRACLE_EYE, Type.PSYCHIC, -1, 40, -1, 0, 4)
@ -8022,15 +8012,7 @@ export function initMoves() {
new StatusMove(Moves.REFLECT_TYPE, Type.NORMAL, -1, 15, -1, 0, 5) new StatusMove(Moves.REFLECT_TYPE, Type.NORMAL, -1, 15, -1, 0, 5)
.attr(CopyTypeAttr), .attr(CopyTypeAttr),
new AttackMove(Moves.RETALIATE, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 5, -1, 0, 5) new AttackMove(Moves.RETALIATE, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 5, -1, 0, 5)
.attr(MovePowerMultiplierAttr, (user, target, move) => { .partial(),
const turn = user.scene.currentBattle.turn;
const lastPlayerFaint = user.scene.currentBattle.playerFaintsHistory[user.scene.currentBattle.playerFaintsHistory.length - 1];
const lastEnemyFaint = user.scene.currentBattle.enemyFaintsHistory[user.scene.currentBattle.enemyFaintsHistory.length - 1];
return (
(lastPlayerFaint !== undefined && turn - lastPlayerFaint.turn === 1 && user.isPlayer()) ||
(lastEnemyFaint !== undefined && turn - lastEnemyFaint.turn === 1 && !user.isPlayer())
) ? 2 : 1;
}),
new AttackMove(Moves.FINAL_GAMBIT, Type.FIGHTING, MoveCategory.SPECIAL, -1, 100, 5, -1, 0, 5) new AttackMove(Moves.FINAL_GAMBIT, Type.FIGHTING, MoveCategory.SPECIAL, -1, 100, 5, -1, 0, 5)
.attr(UserHpDamageAttr) .attr(UserHpDamageAttr)
.attr(SacrificialAttrOnHit), .attr(SacrificialAttrOnHit),

View File

@ -1,9 +1,8 @@
import { PokemonFormChangeItemModifier, TerastallizeModifier } from "../modifier/modifier"; import { PokemonFormChangeItemModifier } from "../modifier/modifier";
import Pokemon from "../field/pokemon"; import Pokemon from "../field/pokemon";
import { SpeciesFormKey } from "./pokemon-species"; import { SpeciesFormKey } from "./pokemon-species";
import { StatusEffect } from "./status-effect"; import { StatusEffect } from "./status-effect";
import { MoveCategory, allMoves } from "./move"; import { MoveCategory, allMoves } from "./move";
import { Type } from "./type";
import { Constructor } from "#app/utils"; import { Constructor } from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -358,41 +357,6 @@ export class SpeciesDefaultFormMatchTrigger extends SpeciesFormChangeTrigger {
} }
} }
/**
* Class used for triggering form changes based on the user's Tera type.
* Used by Ogerpon and Terapagos.
* @extends SpeciesFormChangeTrigger
*/
export class SpeciesFormChangeTeraTrigger extends SpeciesFormChangeTrigger {
/** The Tera type that triggers the form change */
private teraType: Type;
constructor(teraType: Type) {
super();
this.teraType = teraType;
}
/**
* Checks if the associated Pokémon has the required Tera Shard that matches with the associated Tera type.
* @param {Pokemon} pokemon the Pokémon that is trying to do the form change
* @returns `true` if the Pokémon can change forms, `false` otherwise
*/
canChange(pokemon: Pokemon): boolean {
return !!pokemon.scene.findModifier(m => m instanceof TerastallizeModifier && m.pokemonId === pokemon.id && m.teraType === this.teraType);
}
}
/**
* Class used for triggering form changes based on the user's lapsed Tera type.
* Used by Ogerpon and Terapagos.
* @extends SpeciesFormChangeTrigger
*/
export class SpeciesFormChangeLapseTeraTrigger extends SpeciesFormChangeTrigger {
canChange(pokemon: Pokemon): boolean {
return !!pokemon.scene.findModifier(m => m instanceof TerastallizeModifier && m.pokemonId === pokemon.id);
}
}
/** /**
* Class used for triggering form changes based on weather. * Class used for triggering form changes based on weather.
* Used by Castform and Cherrim. * Used by Castform and Cherrim.
@ -628,23 +592,6 @@ export const pokemonFormChanges: PokemonFormChanges = {
[Species.ALTARIA]: [ [Species.ALTARIA]: [
new SpeciesFormChange(Species.ALTARIA, "", SpeciesFormKey.MEGA, new SpeciesFormChangeItemTrigger(FormChangeItem.ALTARIANITE)) new SpeciesFormChange(Species.ALTARIA, "", SpeciesFormKey.MEGA, new SpeciesFormChangeItemTrigger(FormChangeItem.ALTARIANITE))
], ],
[Species.CASTFORM]: [
new SpeciesFormChange(Species.CASTFORM, "", "sunny", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.SUNNY, WeatherType.HARSH_SUN]), true),
new SpeciesFormChange(Species.CASTFORM, "rainy", "sunny", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.SUNNY, WeatherType.HARSH_SUN]), true),
new SpeciesFormChange(Species.CASTFORM, "snowy", "sunny", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.SUNNY, WeatherType.HARSH_SUN]), true),
new SpeciesFormChange(Species.CASTFORM, "", "rainy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.RAIN, WeatherType.HEAVY_RAIN]), true),
new SpeciesFormChange(Species.CASTFORM, "sunny", "rainy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.RAIN, WeatherType.HEAVY_RAIN]), true),
new SpeciesFormChange(Species.CASTFORM, "snowy", "rainy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.RAIN, WeatherType.HEAVY_RAIN]), true),
new SpeciesFormChange(Species.CASTFORM, "", "snowy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.HAIL, WeatherType.SNOW]), true),
new SpeciesFormChange(Species.CASTFORM, "sunny", "snowy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.HAIL, WeatherType.SNOW]), true),
new SpeciesFormChange(Species.CASTFORM, "rainy", "snowy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.HAIL, WeatherType.SNOW]), true),
new SpeciesFormChange(Species.CASTFORM, "sunny", "", new SpeciesFormChangeRevertWeatherFormTrigger(Abilities.FORECAST, [WeatherType.NONE, WeatherType.SANDSTORM, WeatherType.STRONG_WINDS, WeatherType.FOG]), true),
new SpeciesFormChange(Species.CASTFORM, "rainy", "", new SpeciesFormChangeRevertWeatherFormTrigger(Abilities.FORECAST, [WeatherType.NONE, WeatherType.SANDSTORM, WeatherType.STRONG_WINDS, WeatherType.FOG]), true),
new SpeciesFormChange(Species.CASTFORM, "snowy", "", new SpeciesFormChangeRevertWeatherFormTrigger(Abilities.FORECAST, [WeatherType.NONE, WeatherType.SANDSTORM, WeatherType.STRONG_WINDS, WeatherType.FOG]), true),
new SpeciesFormChange(Species.CASTFORM, "sunny", "", new SpeciesFormChangeActiveTrigger(), true),
new SpeciesFormChange(Species.CASTFORM, "rainy", "", new SpeciesFormChangeActiveTrigger(), true),
new SpeciesFormChange(Species.CASTFORM, "snowy", "", new SpeciesFormChangeActiveTrigger(), true)
],
[Species.BANETTE]: [ [Species.BANETTE]: [
new SpeciesFormChange(Species.BANETTE, "", SpeciesFormKey.MEGA, new SpeciesFormChangeItemTrigger(FormChangeItem.BANETTITE)) new SpeciesFormChange(Species.BANETTE, "", SpeciesFormKey.MEGA, new SpeciesFormChangeItemTrigger(FormChangeItem.BANETTITE))
], ],
@ -680,11 +627,6 @@ export const pokemonFormChanges: PokemonFormChanges = {
new SpeciesFormChange(Species.DEOXYS, "normal", "defense", new SpeciesFormChangeItemTrigger(FormChangeItem.HARD_METEORITE)), new SpeciesFormChange(Species.DEOXYS, "normal", "defense", new SpeciesFormChangeItemTrigger(FormChangeItem.HARD_METEORITE)),
new SpeciesFormChange(Species.DEOXYS, "normal", "speed", new SpeciesFormChangeItemTrigger(FormChangeItem.SMOOTH_METEORITE)) new SpeciesFormChange(Species.DEOXYS, "normal", "speed", new SpeciesFormChangeItemTrigger(FormChangeItem.SMOOTH_METEORITE))
], ],
[Species.CHERRIM]: [
new SpeciesFormChange(Species.CHERRIM, "overcast", "sunshine", new SpeciesFormChangeWeatherTrigger(Abilities.FLOWER_GIFT, [ WeatherType.SUNNY, WeatherType.HARSH_SUN ]), true),
new SpeciesFormChange(Species.CHERRIM, "sunshine", "overcast", new SpeciesFormChangeRevertWeatherFormTrigger(Abilities.FLOWER_GIFT, [ WeatherType.NONE, WeatherType.SANDSTORM, WeatherType.STRONG_WINDS, WeatherType.FOG, WeatherType.HAIL, WeatherType.HEAVY_RAIN, WeatherType.SNOW, WeatherType.RAIN ]), true),
new SpeciesFormChange(Species.CHERRIM, "sunshine", "overcast", new SpeciesFormChangeActiveTrigger(), true)
],
[Species.LOPUNNY]: [ [Species.LOPUNNY]: [
new SpeciesFormChange(Species.LOPUNNY, "", SpeciesFormKey.MEGA, new SpeciesFormChangeItemTrigger(FormChangeItem.LOPUNNITE)) new SpeciesFormChange(Species.LOPUNNY, "", SpeciesFormKey.MEGA, new SpeciesFormChangeItemTrigger(FormChangeItem.LOPUNNITE))
], ],
@ -880,14 +822,6 @@ export const pokemonFormChanges: PokemonFormChanges = {
[Species.SANDACONDA]: [ [Species.SANDACONDA]: [
new SpeciesFormChange(Species.SANDACONDA, "", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS)) new SpeciesFormChange(Species.SANDACONDA, "", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS))
], ],
[Species.CRAMORANT]: [
new SpeciesFormChange(Species.CRAMORANT, "", "gulping", new SpeciesFormChangeManualTrigger, true, new SpeciesFormChangeCondition(p => p.getHpRatio() >= .5)),
new SpeciesFormChange(Species.CRAMORANT, "", "gorging", new SpeciesFormChangeManualTrigger, true, new SpeciesFormChangeCondition(p => p.getHpRatio() < .5)),
new SpeciesFormChange(Species.CRAMORANT, "gulping", "", new SpeciesFormChangeManualTrigger, true),
new SpeciesFormChange(Species.CRAMORANT, "gorging", "", new SpeciesFormChangeManualTrigger, true),
new SpeciesFormChange(Species.CRAMORANT, "gulping", "", new SpeciesFormChangeActiveTrigger(false), true),
new SpeciesFormChange(Species.CRAMORANT, "gorging", "", new SpeciesFormChangeActiveTrigger(false), true)
],
[Species.TOXTRICITY]: [ [Species.TOXTRICITY]: [
new SpeciesFormChange(Species.TOXTRICITY, "amped", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS)), new SpeciesFormChange(Species.TOXTRICITY, "amped", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS)),
new SpeciesFormChange(Species.TOXTRICITY, "lowkey", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS)), new SpeciesFormChange(Species.TOXTRICITY, "lowkey", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS)),
@ -914,10 +848,6 @@ export const pokemonFormChanges: PokemonFormChanges = {
new SpeciesFormChange(Species.ALCREMIE, "caramel-swirl", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS)), new SpeciesFormChange(Species.ALCREMIE, "caramel-swirl", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS)),
new SpeciesFormChange(Species.ALCREMIE, "rainbow-swirl", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS)) new SpeciesFormChange(Species.ALCREMIE, "rainbow-swirl", SpeciesFormKey.GIGANTAMAX, new SpeciesFormChangeItemTrigger(FormChangeItem.MAX_MUSHROOMS))
], ],
[Species.EISCUE]: [
new SpeciesFormChange(Species.EISCUE, "", "no-ice", new SpeciesFormChangeManualTrigger(), true),
new SpeciesFormChange(Species.EISCUE, "no-ice", "", new SpeciesFormChangeManualTrigger(), true)
],
[Species.MORPEKO]: [ [Species.MORPEKO]: [
new SpeciesFormChange(Species.MORPEKO, "full-belly", "hangry", new SpeciesFormChangeManualTrigger(), true), new SpeciesFormChange(Species.MORPEKO, "full-belly", "hangry", new SpeciesFormChangeManualTrigger(), true),
new SpeciesFormChange(Species.MORPEKO, "hangry", "full-belly", new SpeciesFormChangeManualTrigger(), true) new SpeciesFormChange(Species.MORPEKO, "hangry", "full-belly", new SpeciesFormChangeManualTrigger(), true)
@ -953,24 +883,58 @@ export const pokemonFormChanges: PokemonFormChanges = {
new SpeciesFormChange(Species.OGERPON, "teal-mask", "wellspring-mask", new SpeciesFormChangeItemTrigger(FormChangeItem.WELLSPRING_MASK)), new SpeciesFormChange(Species.OGERPON, "teal-mask", "wellspring-mask", new SpeciesFormChangeItemTrigger(FormChangeItem.WELLSPRING_MASK)),
new SpeciesFormChange(Species.OGERPON, "teal-mask", "hearthflame-mask", new SpeciesFormChangeItemTrigger(FormChangeItem.HEARTHFLAME_MASK)), new SpeciesFormChange(Species.OGERPON, "teal-mask", "hearthflame-mask", new SpeciesFormChangeItemTrigger(FormChangeItem.HEARTHFLAME_MASK)),
new SpeciesFormChange(Species.OGERPON, "teal-mask", "cornerstone-mask", new SpeciesFormChangeItemTrigger(FormChangeItem.CORNERSTONE_MASK)), new SpeciesFormChange(Species.OGERPON, "teal-mask", "cornerstone-mask", new SpeciesFormChangeItemTrigger(FormChangeItem.CORNERSTONE_MASK)),
new SpeciesFormChange(Species.OGERPON, "teal-mask", "teal-mask-tera", new SpeciesFormChangeTeraTrigger(Type.GRASS)), new SpeciesFormChange(Species.OGERPON, "teal-mask", "teal-mask-tera", new SpeciesFormChangeManualTrigger(), true), //When holding a Grass Tera Shard
new SpeciesFormChange(Species.OGERPON, "teal-mask-tera", "teal-mask", new SpeciesFormChangeLapseTeraTrigger(), true, new SpeciesFormChangeCondition(p => p.getTeraType() !== Type.GRASS)), new SpeciesFormChange(Species.OGERPON, "teal-mask-tera", "teal-mask", new SpeciesFormChangeManualTrigger(), true), //When no longer holding a Grass Tera Shard
new SpeciesFormChange(Species.OGERPON, "wellspring-mask", "wellspring-mask-tera", new SpeciesFormChangeTeraTrigger(Type.WATER)), new SpeciesFormChange(Species.OGERPON, "wellspring-mask", "wellspring-mask-tera", new SpeciesFormChangeManualTrigger(), true), //When holding a Water Tera Shard
new SpeciesFormChange(Species.OGERPON, "wellspring-mask-tera", "wellspring-mask", new SpeciesFormChangeLapseTeraTrigger(), true, new SpeciesFormChangeCondition(p => p.getTeraType() !== Type.WATER)), new SpeciesFormChange(Species.OGERPON, "wellspring-mask-tera", "wellspring-mask", new SpeciesFormChangeManualTrigger(), true), //When no longer holding a Water Tera Shard
new SpeciesFormChange(Species.OGERPON, "hearthflame-mask", "hearthflame-mask-tera", new SpeciesFormChangeTeraTrigger(Type.FIRE)), new SpeciesFormChange(Species.OGERPON, "hearthflame-mask", "hearthflame-mask-tera", new SpeciesFormChangeManualTrigger(), true), //When holding a Fire Tera Shard
new SpeciesFormChange(Species.OGERPON, "hearthflame-mask-tera", "hearthflame-mask", new SpeciesFormChangeLapseTeraTrigger(), true, new SpeciesFormChangeCondition(p => p.getTeraType() !== Type.FIRE)), new SpeciesFormChange(Species.OGERPON, "hearthflame-mask-tera", "hearthflame-mask", new SpeciesFormChangeManualTrigger(), true), //When no longer holding a Fire Tera Shard
new SpeciesFormChange(Species.OGERPON, "cornerstone-mask", "cornerstone-mask-tera", new SpeciesFormChangeTeraTrigger(Type.ROCK)), new SpeciesFormChange(Species.OGERPON, "cornerstone-mask", "cornerstone-mask-tera", new SpeciesFormChangeManualTrigger(), true), //When holding a Rock Tera Shard
new SpeciesFormChange(Species.OGERPON, "cornerstone-mask-tera", "cornerstone-mask", new SpeciesFormChangeLapseTeraTrigger(), true, new SpeciesFormChangeCondition(p => p.getTeraType() !== Type.ROCK)) new SpeciesFormChange(Species.OGERPON, "cornerstone-mask-tera", "cornerstone-mask", new SpeciesFormChangeManualTrigger(), true) //When no longer holding a Rock Tera Shard
], ],
[Species.TERAPAGOS]: [ [Species.TERAPAGOS]: [
new SpeciesFormChange(Species.TERAPAGOS, "", "terastal", new SpeciesFormChangeManualTrigger(), true), new SpeciesFormChange(Species.TERAPAGOS, "", "terastal", new SpeciesFormChangeManualTrigger(), true),
new SpeciesFormChange(Species.TERAPAGOS, "terastal", "stellar", new SpeciesFormChangeTeraTrigger(Type.STELLAR)), new SpeciesFormChange(Species.TERAPAGOS, "terastal", "stellar", new SpeciesFormChangeManualTrigger(), true), //When holding a Stellar Tera Shard
new SpeciesFormChange(Species.TERAPAGOS, "stellar", "terastal", new SpeciesFormChangeLapseTeraTrigger(), true, new SpeciesFormChangeCondition(p => p.getTeraType() !== Type.STELLAR)) new SpeciesFormChange(Species.TERAPAGOS, "stellar", "terastal", new SpeciesFormChangeManualTrigger(), true) //When no longer holding a Stellar Tera Shard
], ],
[Species.GALAR_DARMANITAN]: [ [Species.GALAR_DARMANITAN]: [
new SpeciesFormChange(Species.GALAR_DARMANITAN, "", "zen", new SpeciesFormChangeManualTrigger(), true), new SpeciesFormChange(Species.GALAR_DARMANITAN, "", "zen", new SpeciesFormChangeManualTrigger(), true),
new SpeciesFormChange(Species.GALAR_DARMANITAN, "zen", "", new SpeciesFormChangeManualTrigger(), true) new SpeciesFormChange(Species.GALAR_DARMANITAN, "zen", "", new SpeciesFormChangeManualTrigger(), true)
], ],
[Species.EISCUE]: [
new SpeciesFormChange(Species.EISCUE, "", "no-ice", new SpeciesFormChangeManualTrigger(), true),
new SpeciesFormChange(Species.EISCUE, "no-ice", "", new SpeciesFormChangeManualTrigger(), true),
],
[Species.CRAMORANT]: [
new SpeciesFormChange(Species.CRAMORANT, "", "gulping", new SpeciesFormChangeManualTrigger, true, new SpeciesFormChangeCondition(p => p.getHpRatio() >= .5)),
new SpeciesFormChange(Species.CRAMORANT, "", "gorging", new SpeciesFormChangeManualTrigger, true, new SpeciesFormChangeCondition(p => p.getHpRatio() < .5)),
new SpeciesFormChange(Species.CRAMORANT, "gulping", "", new SpeciesFormChangeManualTrigger, true),
new SpeciesFormChange(Species.CRAMORANT, "gorging", "", new SpeciesFormChangeManualTrigger, true),
new SpeciesFormChange(Species.CRAMORANT, "gulping", "", new SpeciesFormChangeActiveTrigger(false), true),
new SpeciesFormChange(Species.CRAMORANT, "gorging", "", new SpeciesFormChangeActiveTrigger(false), true),
],
[Species.CASTFORM]: [
new SpeciesFormChange(Species.CASTFORM, "", "sunny", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.SUNNY, WeatherType.HARSH_SUN]), true),
new SpeciesFormChange(Species.CASTFORM, "rainy", "sunny", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.SUNNY, WeatherType.HARSH_SUN]), true),
new SpeciesFormChange(Species.CASTFORM, "snowy", "sunny", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.SUNNY, WeatherType.HARSH_SUN]), true),
new SpeciesFormChange(Species.CASTFORM, "", "rainy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.RAIN, WeatherType.HEAVY_RAIN]), true),
new SpeciesFormChange(Species.CASTFORM, "sunny", "rainy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.RAIN, WeatherType.HEAVY_RAIN]), true),
new SpeciesFormChange(Species.CASTFORM, "snowy", "rainy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.RAIN, WeatherType.HEAVY_RAIN]), true),
new SpeciesFormChange(Species.CASTFORM, "", "snowy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.HAIL, WeatherType.SNOW]), true),
new SpeciesFormChange(Species.CASTFORM, "sunny", "snowy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.HAIL, WeatherType.SNOW]), true),
new SpeciesFormChange(Species.CASTFORM, "rainy", "snowy", new SpeciesFormChangeWeatherTrigger(Abilities.FORECAST, [WeatherType.HAIL, WeatherType.SNOW]), true),
new SpeciesFormChange(Species.CASTFORM, "sunny", "", new SpeciesFormChangeRevertWeatherFormTrigger(Abilities.FORECAST, [WeatherType.NONE, WeatherType.SANDSTORM, WeatherType.STRONG_WINDS, WeatherType.FOG]), true),
new SpeciesFormChange(Species.CASTFORM, "rainy", "", new SpeciesFormChangeRevertWeatherFormTrigger(Abilities.FORECAST, [WeatherType.NONE, WeatherType.SANDSTORM, WeatherType.STRONG_WINDS, WeatherType.FOG]), true),
new SpeciesFormChange(Species.CASTFORM, "snowy", "", new SpeciesFormChangeRevertWeatherFormTrigger(Abilities.FORECAST, [WeatherType.NONE, WeatherType.SANDSTORM, WeatherType.STRONG_WINDS, WeatherType.FOG]), true),
new SpeciesFormChange(Species.CASTFORM, "sunny", "", new SpeciesFormChangeActiveTrigger(), true),
new SpeciesFormChange(Species.CASTFORM, "rainy", "", new SpeciesFormChangeActiveTrigger(), true),
new SpeciesFormChange(Species.CASTFORM, "snowy", "", new SpeciesFormChangeActiveTrigger(), true),
],
[Species.CHERRIM]: [
new SpeciesFormChange(Species.CHERRIM, "overcast", "sunshine", new SpeciesFormChangeWeatherTrigger(Abilities.FLOWER_GIFT, [ WeatherType.SUNNY, WeatherType.HARSH_SUN ]), true),
new SpeciesFormChange(Species.CHERRIM, "sunshine", "overcast", new SpeciesFormChangeRevertWeatherFormTrigger(Abilities.FLOWER_GIFT, [ WeatherType.NONE, WeatherType.SANDSTORM, WeatherType.STRONG_WINDS, WeatherType.FOG, WeatherType.HAIL, WeatherType.HEAVY_RAIN, WeatherType.SNOW, WeatherType.RAIN ]), true),
new SpeciesFormChange(Species.CHERRIM, "sunshine", "overcast", new SpeciesFormChangeActiveTrigger(), true),
],
}; };
export function initPokemonForms() { export function initPokemonForms() {

View File

@ -15,7 +15,7 @@ import { BerryType } from "#enums/berry-type";
import { StatusEffect, getStatusEffectHealText } from "../data/status-effect"; import { StatusEffect, getStatusEffectHealText } from "../data/status-effect";
import { achvs } from "../system/achv"; import { achvs } from "../system/achv";
import { VoucherType } from "../system/voucher"; import { VoucherType } from "../system/voucher";
import { FormChangeItem, SpeciesFormChangeItemTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeTeraTrigger } from "../data/pokemon-forms"; import { FormChangeItem, SpeciesFormChangeItemTrigger } from "../data/pokemon-forms";
import { Nature } from "#app/data/nature"; import { Nature } from "#app/data/nature";
import Overrides from "#app/overrides"; import Overrides from "#app/overrides";
import { ModifierType, modifierTypes } from "./modifier-type"; import { ModifierType, modifierTypes } from "./modifier-type";
@ -29,7 +29,6 @@ import { Abilities } from "#app/enums/abilities";
import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { LearnMovePhase } from "#app/phases/learn-move-phase";
import { LevelUpPhase } from "#app/phases/level-up-phase"; import { LevelUpPhase } from "#app/phases/level-up-phase";
import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
import { SpeciesFormKey } from "#app/data/pokemon-species";
export type ModifierPredicate = (modifier: Modifier) => boolean; export type ModifierPredicate = (modifier: Modifier) => boolean;
@ -763,7 +762,6 @@ export class TerastallizeModifier extends LapsingPokemonHeldItemModifier {
apply(args: any[]): boolean { apply(args: any[]): boolean {
const pokemon = args[0] as Pokemon; const pokemon = args[0] as Pokemon;
if (pokemon.isPlayer()) { if (pokemon.isPlayer()) {
pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeTeraTrigger);
pokemon.scene.validateAchv(achvs.TERASTALLIZE); pokemon.scene.validateAchv(achvs.TERASTALLIZE);
if (this.teraType === Type.STELLAR) { if (this.teraType === Type.STELLAR) {
pokemon.scene.validateAchv(achvs.STELLAR_TERASTALLIZE); pokemon.scene.validateAchv(achvs.STELLAR_TERASTALLIZE);
@ -777,7 +775,6 @@ export class TerastallizeModifier extends LapsingPokemonHeldItemModifier {
const ret = super.lapse(args); const ret = super.lapse(args);
if (!ret) { if (!ret) {
const pokemon = args[0] as Pokemon; const pokemon = args[0] as Pokemon;
pokemon.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeLapseTeraTrigger);
pokemon.updateSpritePipelineData(); pokemon.updateSpritePipelineData();
} }
return ret; return ret;
@ -1077,18 +1074,6 @@ export class EvolutionStatBoosterModifier extends StatBoosterModifier {
return modifier instanceof EvolutionStatBoosterModifier; return modifier instanceof EvolutionStatBoosterModifier;
} }
/**
* Checks if the stat boosts can apply and if the holder is not currently
* Gigantamax'd.
* @param args [0] {@linkcode Pokemon} that holds the held item
* [1] {@linkcode Stat} N/A
* [2] {@linkcode Utils.NumberHolder} N/A
* @returns true if the stat boosts can be applied, false otherwise
*/
shouldApply(args: any[]): boolean {
return super.shouldApply(args) && ((args[0] as Pokemon).getFormKey() !== SpeciesFormKey.GIGANTAMAX);
}
/** /**
* Boosts the incoming stat value by a {@linkcode multiplier} if the holder * Boosts the incoming stat value by a {@linkcode multiplier} if the holder
* can evolve. Note that, if the holder is a fusion, they will receive * can evolve. Note that, if the holder is a fusion, they will receive

View File

@ -55,10 +55,8 @@ export class FaintPhase extends PokemonPhase {
// Track total times pokemon have been KO'd for supreme overlord/last respects // Track total times pokemon have been KO'd for supreme overlord/last respects
if (pokemon.isPlayer()) { if (pokemon.isPlayer()) {
this.scene.currentBattle.playerFaints += 1; this.scene.currentBattle.playerFaints += 1;
this.scene.currentBattle.playerFaintsHistory.push({ pokemon: pokemon, turn: this.scene.currentBattle.turn });
} else { } else {
this.scene.currentBattle.enemyFaints += 1; this.scene.currentBattle.enemyFaints += 1;
this.scene.currentBattle.enemyFaintsHistory.push({ pokemon: pokemon, turn: this.scene.currentBattle.turn });
} }
this.scene.queueMessage(i18next.t("battle:fainted", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), null, true); this.scene.queueMessage(i18next.t("battle:fainted", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), null, true);

View File

@ -3,7 +3,7 @@ import { BattlerIndex } from "#app/battle";
import { applyPreAttackAbAttrs, AddSecondStrikeAbAttr, IgnoreMoveEffectsAbAttr, applyPostDefendAbAttrs, PostDefendAbAttr, applyPostAttackAbAttrs, PostAttackAbAttr, MaxMultiHitAbAttr, AlwaysHitAbAttr } from "#app/data/ability"; import { applyPreAttackAbAttrs, AddSecondStrikeAbAttr, IgnoreMoveEffectsAbAttr, applyPostDefendAbAttrs, PostDefendAbAttr, applyPostAttackAbAttrs, PostAttackAbAttr, MaxMultiHitAbAttr, AlwaysHitAbAttr } from "#app/data/ability";
import { ArenaTagSide, ConditionalProtectTag } from "#app/data/arena-tag"; import { ArenaTagSide, ConditionalProtectTag } from "#app/data/arena-tag";
import { MoveAnim } from "#app/data/battle-anims"; import { MoveAnim } from "#app/data/battle-anims";
import { BattlerTagLapseType, DamageProtectedTag, ProtectedTag, SemiInvulnerableTag } from "#app/data/battler-tags"; import { BattlerTagLapseType, ProtectedTag, SemiInvulnerableTag } from "#app/data/battler-tags";
import { MoveTarget, applyMoveAttrs, OverrideMoveEffectAttr, MultiHitAttr, AttackMove, FixedDamageAttr, VariableTargetAttr, MissEffectAttr, MoveFlags, applyFilteredMoveAttrs, MoveAttr, MoveEffectAttr, MoveEffectTrigger, ChargeAttr, MoveCategory, NoEffectAttr, HitsTagAttr } from "#app/data/move"; import { MoveTarget, applyMoveAttrs, OverrideMoveEffectAttr, MultiHitAttr, AttackMove, FixedDamageAttr, VariableTargetAttr, MissEffectAttr, MoveFlags, applyFilteredMoveAttrs, MoveAttr, MoveEffectAttr, MoveEffectTrigger, ChargeAttr, MoveCategory, NoEffectAttr, HitsTagAttr } from "#app/data/move";
import { SpeciesFormChangePostMoveTrigger } from "#app/data/pokemon-forms"; import { SpeciesFormChangePostMoveTrigger } from "#app/data/pokemon-forms";
import { BattlerTagType } from "#app/enums/battler-tag-type"; import { BattlerTagType } from "#app/enums/battler-tag-type";
@ -153,8 +153,7 @@ export class MoveEffectPhase extends PokemonPhase {
/** Is the target protected by Protect, etc. or a relevant conditional protection effect? */ /** Is the target protected by Protect, etc. or a relevant conditional protection effect? */
const isProtected = (bypassIgnoreProtect.value || !this.move.getMove().checkFlag(MoveFlags.IGNORE_PROTECT, user, target)) const isProtected = (bypassIgnoreProtect.value || !this.move.getMove().checkFlag(MoveFlags.IGNORE_PROTECT, user, target))
&& (hasConditionalProtectApplied.value || (!target.findTags(t => t instanceof DamageProtectedTag).length && target.findTags(t => t instanceof ProtectedTag).find(t => target.lapseTag(t.tagType))) && (hasConditionalProtectApplied.value || target.findTags(t => t instanceof ProtectedTag).find(t => target.lapseTag(t.tagType)));
|| (this.move.getMove().category !== MoveCategory.STATUS && target.findTags(t => t instanceof DamageProtectedTag).find(t => target.lapseTag(t.tagType))));
/** Does this phase represent the invoked move's first strike? */ /** Does this phase represent the invoked move's first strike? */
const firstHit = (user.turnData.hitsLeft === user.turnData.hitCount); const firstHit = (user.turnData.hitsLeft === user.turnData.hitCount);

View File

@ -1,15 +1,16 @@
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { EvolutionStatBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n";
import * as Utils from "#app/utils";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import * as Utils from "#app/utils";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { StatBoosterModifier } from "#app/modifier/modifier";
describe("Items - Eviolite", () => { describe("Items - Eviolite", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
const TIMEOUT = 20 * 1000;
beforeAll(() => { beforeAll(() => {
phaserGame = new Phase.Game({ phaserGame = new Phase.Game({
@ -24,65 +25,108 @@ describe("Items - Eviolite", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override.battleType("single");
.battleType("single")
.startingHeldItems([{ name: "EVIOLITE" }]);
}); });
it("should provide 50% boost to DEF and SPDEF for unevolved, unfused pokemon", async() => { it("EVIOLITE activates in battle correctly", async() => {
await game.classicMode.startBattle([ game.override.startingHeldItems([{ name: "EVIOLITE" }]);
const consoleSpy = vi.spyOn(console, "log");
await game.startBattle([
Species.PICHU Species.PICHU
]); ]);
const partyMember = game.scene.getPlayerPokemon()!; const partyMember = game.scene.getParty()[0];
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { // Checking console log to make sure Eviolite is applied when getEffectiveStat (with the appropriate stat) is called
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); partyMember.getEffectiveStat(Stat.DEF);
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue); expect(consoleSpy).toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:ModifierType.EVIOLITE.name"), "");
// Ignore other calculations for simplicity // Printing dummy console messages along the way so subsequent checks don't pass because of the first
console.log("");
return Math.floor(statValue.value); partyMember.getEffectiveStat(Stat.SPDEF);
}); expect(consoleSpy).toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:ModifierType.EVIOLITE.name"), "");
const defStat = partyMember.getStat(Stat.DEF, false); console.log("");
const spDefStat = partyMember.getStat(Stat.SPDEF, false);
expect(partyMember.getEffectiveStat(Stat.DEF)).toBe(Math.floor(defStat * 1.5)); partyMember.getEffectiveStat(Stat.ATK);
expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(spDefStat * 1.5)); expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:ModifierType.EVIOLITE.name"), "");
}, TIMEOUT);
it("should not provide a boost for fully evolved, unfused pokemon", async() => { console.log("");
await game.classicMode.startBattle([
partyMember.getEffectiveStat(Stat.SPATK);
expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:ModifierType.EVIOLITE.name"), "");
console.log("");
partyMember.getEffectiveStat(Stat.SPD);
expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:ModifierType.EVIOLITE.name"), "");
});
it("EVIOLITE held by unevolved, unfused pokemon", async() => {
await game.startBattle([
Species.PICHU
]);
const partyMember = game.scene.getParty()[0];
const defStat = partyMember.getStat(Stat.DEF);
const spDefStat = partyMember.getStat(Stat.SPDEF);
// Making sure modifier is not applied without holding item
const defValue = new Utils.NumberHolder(defStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
const spDefValue = new Utils.NumberHolder(spDefStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
expect(defValue.value / defStat).toBe(1);
expect(spDefValue.value / spDefStat).toBe(1);
// Giving Eviolite to party member and testing if it applies
partyMember.scene.addModifier(modifierTypes.EVIOLITE().newModifier(partyMember), true);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
expect(defValue.value / defStat).toBe(1.5);
expect(spDefValue.value / spDefStat).toBe(1.5);
}, 20000);
it("EVIOLITE held by fully evolved, unfused pokemon", async() => {
await game.startBattle([
Species.RAICHU, Species.RAICHU,
]); ]);
const partyMember = game.scene.getParty()[0]; const partyMember = game.scene.getParty()[0];
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { const defStat = partyMember.getStat(Stat.DEF);
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const spDefStat = partyMember.getStat(Stat.SPDEF);
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Making sure modifier is not applied without holding item
const defValue = new Utils.NumberHolder(defStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
const spDefValue = new Utils.NumberHolder(spDefStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
return Math.floor(statValue.value); expect(defValue.value / defStat).toBe(1);
}); expect(spDefValue.value / spDefStat).toBe(1);
const defStat = partyMember.getStat(Stat.DEF, false); // Giving Eviolite to party member and testing if it applies
const spDefStat = partyMember.getStat(Stat.SPDEF, false); partyMember.scene.addModifier(modifierTypes.EVIOLITE().newModifier(partyMember), true);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
expect(partyMember.getEffectiveStat(Stat.DEF)).toBe(defStat); expect(defValue.value / defStat).toBe(1);
expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(spDefStat); expect(spDefValue.value / spDefStat).toBe(1);
}, 20000);
}, TIMEOUT); it("EVIOLITE held by completely unevolved, fused pokemon", async() => {
await game.startBattle([
it("should provide 50% boost to DEF and SPDEF for completely unevolved, fused pokemon", async() => {
await game.classicMode.startBattle([
Species.PICHU, Species.PICHU,
Species.CLEFFA Species.CLEFFA
]); ]);
const [ partyMember, ally ] = game.scene.getParty(); const partyMember = game.scene.getParty()[0];
const ally = game.scene.getParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -93,29 +137,35 @@ describe("Items - Eviolite", () => {
partyMember.fusionGender = ally.gender; partyMember.fusionGender = ally.gender;
partyMember.fusionLuck = ally.luck; partyMember.fusionLuck = ally.luck;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { const defStat = partyMember.getStat(Stat.DEF);
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const spDefStat = partyMember.getStat(Stat.SPDEF);
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Making sure modifier is not applied without holding item
const defValue = new Utils.NumberHolder(defStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
const spDefValue = new Utils.NumberHolder(spDefStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
return Math.floor(statValue.value); expect(defValue.value / defStat).toBe(1);
}); expect(spDefValue.value / spDefStat).toBe(1);
const defStat = partyMember.getStat(Stat.DEF, false); // Giving Eviolite to party member and testing if it applies
const spDefStat = partyMember.getStat(Stat.SPDEF, false); partyMember.scene.addModifier(modifierTypes.EVIOLITE().newModifier(partyMember), true);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
expect(partyMember.getEffectiveStat(Stat.DEF)).toBe(Math.floor(defStat * 1.5)); expect(defValue.value / defStat).toBe(1.5);
expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(spDefStat * 1.5)); expect(spDefValue.value / spDefStat).toBe(1.5);
}, TIMEOUT); }, 20000);
it("should provide 25% boost to DEF and SPDEF for partially unevolved (base), fused pokemon", async() => { it("EVIOLITE held by partially unevolved (base), fused pokemon", async() => {
await game.classicMode.startBattle([ await game.startBattle([
Species.PICHU, Species.PICHU,
Species.CLEFABLE Species.CLEFABLE
]); ]);
const [ partyMember, ally ] = game.scene.getParty(); const partyMember = game.scene.getParty()[0];
const ally = game.scene.getParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -126,29 +176,35 @@ describe("Items - Eviolite", () => {
partyMember.fusionGender = ally.gender; partyMember.fusionGender = ally.gender;
partyMember.fusionLuck = ally.luck; partyMember.fusionLuck = ally.luck;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { const defStat = partyMember.getStat(Stat.DEF);
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const spDefStat = partyMember.getStat(Stat.SPDEF);
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Making sure modifier is not applied without holding item
const defValue = new Utils.NumberHolder(defStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
const spDefValue = new Utils.NumberHolder(spDefStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
return Math.floor(statValue.value); expect(defValue.value / defStat).toBe(1);
}); expect(spDefValue.value / spDefStat).toBe(1);
const defStat = partyMember.getStat(Stat.DEF, false); // Giving Eviolite to party member and testing if it applies
const spDefStat = partyMember.getStat(Stat.SPDEF, false); partyMember.scene.addModifier(modifierTypes.EVIOLITE().newModifier(partyMember), true);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
expect(partyMember.getEffectiveStat(Stat.DEF)).toBe(Math.floor(defStat * 1.25)); expect(defValue.value / defStat).toBe(1.25);
expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(spDefStat * 1.25)); expect(spDefValue.value / spDefStat).toBe(1.25);
}, TIMEOUT); }, 20000);
it("should provide 25% boost to DEF and SPDEF for partially unevolved (fusion), fused pokemon", async() => { it("EVIOLITE held by partially unevolved (fusion), fused pokemon", async() => {
await game.classicMode.startBattle([ await game.startBattle([
Species.RAICHU, Species.RAICHU,
Species.CLEFFA Species.CLEFFA
]); ]);
const [ partyMember, ally ] = game.scene.getParty(); const partyMember = game.scene.getParty()[0];
const ally = game.scene.getParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -159,29 +215,35 @@ describe("Items - Eviolite", () => {
partyMember.fusionGender = ally.gender; partyMember.fusionGender = ally.gender;
partyMember.fusionLuck = ally.luck; partyMember.fusionLuck = ally.luck;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { const defStat = partyMember.getStat(Stat.DEF);
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const spDefStat = partyMember.getStat(Stat.SPDEF);
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Making sure modifier is not applied without holding item
const defValue = new Utils.NumberHolder(defStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
const spDefValue = new Utils.NumberHolder(spDefStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
return Math.floor(statValue.value); expect(defValue.value / defStat).toBe(1);
}); expect(spDefValue.value / spDefStat).toBe(1);
const defStat = partyMember.getStat(Stat.DEF, false); // Giving Eviolite to party member and testing if it applies
const spDefStat = partyMember.getStat(Stat.SPDEF, false); partyMember.scene.addModifier(modifierTypes.EVIOLITE().newModifier(partyMember), true);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
expect(partyMember.getEffectiveStat(Stat.DEF)).toBe(Math.floor(defStat * 1.25)); expect(defValue.value / defStat).toBe(1.25);
expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(spDefStat * 1.25)); expect(spDefValue.value / spDefStat).toBe(1.25);
}, TIMEOUT); }, 20000);
it("should not provide a boost for fully evolved, fused pokemon", async() => { it("EVIOLITE held by completely evolved, fused pokemon", async() => {
await game.classicMode.startBattle([ await game.startBattle([
Species.RAICHU, Species.RAICHU,
Species.CLEFABLE Species.CLEFABLE
]); ]);
const [ partyMember, ally ] = game.scene.getParty(); const partyMember = game.scene.getParty()[0];
const ally = game.scene.getParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -192,51 +254,24 @@ describe("Items - Eviolite", () => {
partyMember.fusionGender = ally.gender; partyMember.fusionGender = ally.gender;
partyMember.fusionLuck = ally.luck; partyMember.fusionLuck = ally.luck;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => { const defStat = partyMember.getStat(Stat.DEF);
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false)); const spDefStat = partyMember.getStat(Stat.SPDEF);
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity // Making sure modifier is not applied without holding item
const defValue = new Utils.NumberHolder(defStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
const spDefValue = new Utils.NumberHolder(spDefStat);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
return Math.floor(statValue.value); expect(defValue.value / defStat).toBe(1);
}); expect(spDefValue.value / spDefStat).toBe(1);
const defStat = partyMember.getStat(Stat.DEF, false); // Giving Eviolite to party member and testing if it applies
const spDefStat = partyMember.getStat(Stat.SPDEF, false); partyMember.scene.addModifier(modifierTypes.EVIOLITE().newModifier(partyMember), true);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
partyMember.scene.applyModifiers(EvolutionStatBoosterModifier, true, partyMember, Stat.SPDEF, spDefValue);
expect(partyMember.getEffectiveStat(Stat.DEF)).toBe(defStat); expect(defValue.value / defStat).toBe(1);
expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(spDefStat); expect(spDefValue.value / spDefStat).toBe(1);
}, TIMEOUT); }, 20000);
it("should not provide a boost for Gigantamax Pokémon", async() => {
game.override.starterForms({
[Species.PIKACHU]: 8,
[Species.EEVEE]: 2,
[Species.DURALUDON]: 1,
[Species.MEOWTH]: 1
});
const gMaxablePokemon = [ Species.PIKACHU, Species.EEVEE, Species.DURALUDON, Species.MEOWTH ];
await game.classicMode.startBattle([
Utils.randItem(gMaxablePokemon)
]);
const partyMember = game.scene.getPlayerPokemon()!;
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false));
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
// Ignore other calculations for simplicity
return Math.floor(statValue.value);
});
const defStat = partyMember.getStat(Stat.DEF, false);
const spDefStat = partyMember.getStat(Stat.SPDEF, false);
expect(partyMember.getEffectiveStat(Stat.DEF)).toBe(defStat);
expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(spDefStat);
}, TIMEOUT);
}); });

View File

@ -1,43 +0,0 @@
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Baddy Bad", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const TIMEOUT = 20 * 1000;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([Moves.SPLASH])
.battleType("single")
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH)
.ability(Abilities.BALL_FETCH);
});
it("should not activate Reflect if the move fails due to Protect", async () => {
game.override.enemyMoveset(Moves.PROTECT);
await game.classicMode.startBattle([Species.FEEBAS]);
game.move.select(Moves.BADDY_BAD);
await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.arena.tags.length).toBe(0);
}, TIMEOUT);
});

View File

@ -1,12 +1,12 @@
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager";
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";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import { CommandPhase } from "#app/phases/command-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase";
describe("Moves - Freezy Frost", () => { describe("Moves - Freezy Frost", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -23,83 +23,38 @@ describe("Moves - Freezy Frost", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override.battleType("single");
.battleType("single")
.enemySpecies(Species.RATTATA)
.enemyLevel(100)
.enemyMoveset([ Moves.HOWL, Moves.HOWL, Moves.HOWL, Moves.HOWL ])
.enemyAbility(Abilities.BALL_FETCH)
.startingLevel(100)
.moveset([ Moves.FREEZY_FROST, Moves.HOWL, Moves.SPLASH ])
.ability(Abilities.BALL_FETCH);
vi.spyOn(allMoves[ Moves.FREEZY_FROST ], "accuracy", "get").mockReturnValue(100); game.override.enemySpecies(Species.RATTATA);
game.override.enemyLevel(100);
game.override.enemyMoveset(Moves.SPLASH);
game.override.enemyAbility(Abilities.NONE);
game.override.startingLevel(100);
game.override.moveset([Moves.FREEZY_FROST, Moves.SWORDS_DANCE, Moves.CHARM, Moves.SPLASH]);
vi.spyOn(allMoves[Moves.FREEZY_FROST], "accuracy", "get").mockReturnValue(100);
game.override.ability(Abilities.NONE);
}); });
it( it("should clear all stat stage changes", { timeout: 10000 }, async () => {
"should clear stat changes of user and opponent", await game.startBattle([Species.RATTATA]);
async () => { const user = game.scene.getPlayerPokemon()!;
await game.classicMode.startBattle([ Species.SHUCKLE ]); const enemy = game.scene.getEnemyPokemon()!;
const user = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!;
game.move.select(Moves.HOWL); expect(user.getStatStage(Stat.ATK)).toBe(0);
await game.toNextTurn(); expect(enemy.getStatStage(Stat.ATK)).toBe(0);
expect(user.getStatStage(Stat.ATK)).toBe(1); game.move.select(Moves.SWORDS_DANCE);
expect(enemy.getStatStage(Stat.ATK)).toBe(1); await game.phaseInterceptor.to(TurnInitPhase);
game.move.select(Moves.FREEZY_FROST); game.move.select(Moves.CHARM);
await game.toNextTurn(); await game.phaseInterceptor.to(TurnInitPhase);
expect(user.getStatStage(Stat.ATK)).toBe(2);
expect(enemy.getStatStage(Stat.ATK)).toBe(-2);
expect(user.getStatStage(Stat.ATK)).toBe(0); game.move.select(Moves.FREEZY_FROST);
expect(enemy.getStatStage(Stat.ATK)).toBe(0); await game.phaseInterceptor.to(TurnInitPhase);
}); expect(user.getStatStage(Stat.ATK)).toBe(0);
expect(enemy.getStatStage(Stat.ATK)).toBe(0);
it( });
"should clear all stat changes even when enemy uses the move",
async () => {
game.override.enemyMoveset([ Moves.FREEZY_FROST, Moves.FREEZY_FROST, Moves.FREEZY_FROST, Moves.FREEZY_FROST ]);
await game.classicMode.startBattle([ Species.SHUCKLE ]); // Shuckle for slower Howl on first turn so Freezy Frost doesn't affect it.
const user = game.scene.getPlayerPokemon()!;
game.move.select(Moves.HOWL);
await game.toNextTurn();
const userAtkBefore = user.getStatStage(Stat.ATK);
expect(userAtkBefore).toBe(1);
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(user.getStatStage(Stat.ATK)).toBe(0);
});
it(
"should clear all stat changes in double battle",
async () => {
game.override.battleType("double");
await game.classicMode.startBattle([ Species.SHUCKLE, Species.RATTATA ]);
const [ leftPlayer, rightPlayer ] = game.scene.getPlayerField();
const [ leftOpp, rightOpp ] = game.scene.getEnemyField();
game.move.select(Moves.HOWL, 0);
await game.phaseInterceptor.to(CommandPhase);
game.move.select(Moves.SPLASH, 1);
await game.toNextTurn();
expect(leftPlayer.getStatStage(Stat.ATK)).toBe(1);
expect(rightPlayer.getStatStage(Stat.ATK)).toBe(1);
expect(leftOpp.getStatStage(Stat.ATK)).toBe(2); // Both enemies use Howl
expect(rightOpp.getStatStage(Stat.ATK)).toBe(2);
game.move.select(Moves.FREEZY_FROST, 0, leftOpp.getBattlerIndex());
await game.phaseInterceptor.to(CommandPhase);
game.move.select(Moves.SPLASH, 1);
await game.toNextTurn();
expect(leftPlayer.getStatStage(Stat.ATK)).toBe(0);
expect(rightPlayer.getStatStage(Stat.ATK)).toBe(0);
expect(leftOpp.getStatStage(Stat.ATK)).toBe(0);
expect(rightOpp.getStatStage(Stat.ATK)).toBe(0);
});
}); });

View File

@ -1,71 +0,0 @@
import { Moves } from "#app/enums/moves";
import { Stat } from "#app/enums/stat";
import { Abilities } from "#enums/abilities";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Obstruct", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const TIMEOUT = 20 * 1000;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.battleType("single")
.enemyAbility(Abilities.BALL_FETCH)
.ability(Abilities.BALL_FETCH)
.moveset([Moves.OBSTRUCT]);
});
it("protects from contact damaging moves and lowers the opponent's defense by 2 stages", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.ICE_PUNCH));
await game.classicMode.startBattle();
game.move.select(Moves.OBSTRUCT);
await game.phaseInterceptor.to("BerryPhase");
const player = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!;
expect(player.isFullHp()).toBe(true);
expect(enemy.getStatStage(Stat.DEF)).toBe(-2);
}, TIMEOUT);
it("protects from non-contact damaging moves and doesn't lower the opponent's defense by 2 stages", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.WATER_GUN));
await game.classicMode.startBattle();
game.move.select(Moves.OBSTRUCT);
await game.phaseInterceptor.to("BerryPhase");
const player = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!;
expect(player.isFullHp()).toBe(true);
expect(enemy.getStatStage(Stat.DEF)).toBe(0);
}, TIMEOUT);
it("doesn't protect from status moves", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.GROWL));
await game.classicMode.startBattle();
game.move.select(Moves.OBSTRUCT);
await game.phaseInterceptor.to("BerryPhase");
const player = game.scene.getPlayerPokemon()!;
expect(player.getStatStage(Stat.ATK)).toBe(-1);
}, TIMEOUT);
});

View File

@ -1,49 +0,0 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import Phaser from "phaser";
import GameManager from "#app/test/utils/gameManager";
import { Species } from "#enums/species";
import { Moves } from "#enums/moves";
import { allMoves } from "#app/data/move";
describe("Moves - Retaliate", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const retaliate = allMoves[Moves.RETALIATE];
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.battleType("single")
.enemySpecies(Species.SNORLAX)
.enemyMoveset([Moves.RETALIATE, Moves.RETALIATE, Moves.RETALIATE, Moves.RETALIATE])
.enemyLevel(100)
.moveset([Moves.RETALIATE, Moves.SPLASH])
.startingLevel(80)
.disableCrits();
});
it("increases power if ally died previous turn", async () => {
vi.spyOn(retaliate, "calculateBattlePower");
await game.startBattle([Species.ABRA, Species.COBALION]);
game.move.select(Moves.RETALIATE);
await game.phaseInterceptor.to("TurnEndPhase");
expect(retaliate.calculateBattlePower).toHaveLastReturnedWith(70);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.move.select(Moves.RETALIATE);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(retaliate.calculateBattlePower).toHaveReturnedWith(140);
});
});

View File

@ -460,7 +460,6 @@ export default class MenuUiHandler extends MessageUiHandler {
} }
} }
} }
this.showText("", 0);
switch (adjustedCursor) { switch (adjustedCursor) {
case MenuOptions.GAME_SETTINGS: case MenuOptions.GAME_SETTINGS:
ui.setOverlayMode(Mode.SETTINGS); ui.setOverlayMode(Mode.SETTINGS);
@ -549,28 +548,15 @@ export default class MenuUiHandler extends MessageUiHandler {
case MenuOptions.SAVE_AND_QUIT: case MenuOptions.SAVE_AND_QUIT:
if (this.scene.currentBattle) { if (this.scene.currentBattle) {
success = true; success = true;
const doSaveQuit = () => {
ui.setMode(Mode.LOADING, {
buttonActions: [], fadeOut: () =>
this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => {
this.scene.reset(true);
})
});
};
if (this.scene.currentBattle.turn > 1) { if (this.scene.currentBattle.turn > 1) {
ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => { ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => {
if (!this.active) { ui.setOverlayMode(Mode.CONFIRM, () => this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true)), () => {
this.showText("", 0);
return;
}
ui.setOverlayMode(Mode.CONFIRM, doSaveQuit, () => {
ui.revertMode(); ui.revertMode();
this.showText("", 0); ui.showText("", 0);
}, false, -98); }, false, -98);
}); });
} else { } else {
doSaveQuit(); this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true));
} }
} else { } else {
error = true; error = true;
@ -579,25 +565,19 @@ export default class MenuUiHandler extends MessageUiHandler {
case MenuOptions.LOG_OUT: case MenuOptions.LOG_OUT:
success = true; success = true;
const doLogout = () => { const doLogout = () => {
ui.setMode(Mode.LOADING, { Utils.apiFetch("account/logout", true).then(res => {
buttonActions: [], fadeOut: () => Utils.apiFetch("account/logout", true).then(res => { if (!res.ok) {
if (!res.ok) { console.error(`Log out failed (${res.status}: ${res.statusText})`);
console.error(`Log out failed (${res.status}: ${res.statusText})`); }
} Utils.removeCookie(Utils.sessionIdKey);
Utils.removeCookie(Utils.sessionIdKey); updateUserInfo().then(() => this.scene.reset(true, true));
updateUserInfo().then(() => this.scene.reset(true, true));
})
}); });
}; };
if (this.scene.currentBattle) { if (this.scene.currentBattle) {
ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => { ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => {
if (!this.active) {
this.showText("", 0);
return;
}
ui.setOverlayMode(Mode.CONFIRM, doLogout, () => { ui.setOverlayMode(Mode.CONFIRM, doLogout, () => {
ui.revertMode(); ui.revertMode();
this.showText("", 0); ui.showText("", 0);
}, false, -98); }, false, -98);
}); });
} else { } else {

View File

@ -89,25 +89,6 @@ export abstract class ModalUiHandler extends UiHandler {
show(args: any[]): boolean { show(args: any[]): boolean {
if (args.length >= 1 && "buttonActions" in args[0]) { if (args.length >= 1 && "buttonActions" in args[0]) {
super.show(args); super.show(args);
if (args[0].hasOwnProperty("fadeOut") && typeof args[0].fadeOut === "function") {
const [ marginTop, marginRight, marginBottom, marginLeft ] = this.getMargin();
const overlay = this.scene.add.rectangle(( this.getWidth() + marginLeft + marginRight) / 2, (this.getHeight() + marginTop + marginBottom) / 2,this.scene.game.canvas.width / 6,this.scene.game.canvas.height /6, 0);
overlay.setOrigin(0.5,0.5);
overlay.setName("rect-ui-overlay-modal");
overlay.setAlpha(0);
this.modalContainer.add(overlay);
this.modalContainer.moveTo(overlay,0);
this.scene.tweens.add({
targets: overlay,
alpha: 1,
duration: 250,
ease: "Sine.easeOut",
onComplete: args[0].fadeOut
});
}
const config = args[0] as ModalConfig; const config = args[0] as ModalConfig;

View File

@ -541,9 +541,7 @@ export default class RunInfoUiHandler extends UiHandler {
// Contains Name, Level + Nature, Ability, Passive // Contains Name, Level + Nature, Ability, Passive
const pokeInfoTextContainer = this.scene.add.container(-85, 3.5); const pokeInfoTextContainer = this.scene.add.container(-85, 3.5);
const textContainerFontSize = "34px"; const textContainerFontSize = "34px";
// This checks if the Pokemon's nature has been overwritten during the run and displays the change accurately const pNature = getNatureName(pokemon.nature);
const pNature = pokemon.getNature();
const pNatureName = getNatureName(pNature);
const pName = pokemon.getNameToRender(); const pName = pokemon.getNameToRender();
//With the exception of Korean/Traditional Chinese/Simplified Chinese, the code shortens the terms for ability and passive to their first letter. //With the exception of Korean/Traditional Chinese/Simplified Chinese, the code shortens the terms for ability and passive to their first letter.
//These languages are exempted because they are already short enough. //These languages are exempted because they are already short enough.
@ -559,7 +557,7 @@ export default class RunInfoUiHandler extends UiHandler {
// Japanese is set to a greater line spacing of 35px in addBBCodeTextObject() if lineSpacing < 12. // Japanese is set to a greater line spacing of 35px in addBBCodeTextObject() if lineSpacing < 12.
const lineSpacing = (i18next.resolvedLanguage === "ja") ? 12 : 3; const lineSpacing = (i18next.resolvedLanguage === "ja") ? 12 : 3;
const pokeInfoText = addBBCodeTextObject(this.scene, 0, 0, pName, TextStyle.SUMMARY, {fontSize: textContainerFontSize, lineSpacing: lineSpacing}); const pokeInfoText = addBBCodeTextObject(this.scene, 0, 0, pName, TextStyle.SUMMARY, {fontSize: textContainerFontSize, lineSpacing: lineSpacing});
pokeInfoText.appendText(`${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatFancyLargeNumber(pokemon.level, 1)} - ${pNatureName}`); pokeInfoText.appendText(`${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatFancyLargeNumber(pokemon.level, 1)} - ${pNature}`);
pokeInfoText.appendText(pAbilityInfo); pokeInfoText.appendText(pAbilityInfo);
pokeInfoText.appendText(pPassiveInfo); pokeInfoText.appendText(pPassiveInfo);
pokeInfoTextContainer.add(pokeInfoText); pokeInfoTextContainer.add(pokeInfoText);
@ -570,7 +568,7 @@ export default class RunInfoUiHandler extends UiHandler {
const pStats : string[]= []; const pStats : string[]= [];
pokemon.stats.forEach((element) => pStats.push(Utils.formatFancyLargeNumber(element, 1))); pokemon.stats.forEach((element) => pStats.push(Utils.formatFancyLargeNumber(element, 1)));
for (let i = 0; i < pStats.length; i++) { for (let i = 0; i < pStats.length; i++) {
const isMult = getNatureStatMultiplier(pNature, i); const isMult = getNatureStatMultiplier(pokemon.nature, i);
pStats[i] = (isMult < 1) ? pStats[i] + "[color=#40c8f8]↓[/color]" : pStats[i]; pStats[i] = (isMult < 1) ? pStats[i] + "[color=#40c8f8]↓[/color]" : pStats[i];
pStats[i] = (isMult > 1) ? pStats[i] + "[color=#f89890]↑[/color]" : pStats[i]; pStats[i] = (isMult > 1) ? pStats[i] + "[color=#f89890]↑[/color]" : pStats[i];
} }
@ -891,12 +889,10 @@ export default class RunInfoUiHandler extends UiHandler {
} }
break; break;
case Button.CYCLE_ABILITY: case Button.CYCLE_ABILITY:
if (this.runInfo.modifiers.length !== 0) { if (this.partyVisibility) {
if (this.partyVisibility) { this.showParty(false);
this.showParty(false); } else {
} else { this.showParty(true);
this.showParty(true);
}
} }
break; break;
} }

View File

@ -28,15 +28,15 @@ import { Mode } from "./ui";
import { addWindow } from "./ui-theme"; import { addWindow } from "./ui-theme";
import { Egg } from "#app/data/egg"; import { Egg } from "#app/data/egg";
import Overrides from "#app/overrides"; import Overrides from "#app/overrides";
import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; import {SettingKeyboard} from "#app/system/settings/settings-keyboard";
import { Passive as PassiveAttr } from "#enums/passive"; import {Passive as PassiveAttr} from "#enums/passive";
import * as Challenge from "../data/challenge"; import * as Challenge from "../data/challenge";
import MoveInfoOverlay from "./move-info-overlay"; import MoveInfoOverlay from "./move-info-overlay";
import { getEggTierForSpecies } from "#app/data/egg"; import { getEggTierForSpecies } from "#app/data/egg";
import { Device } from "#enums/devices"; import { Device } from "#enums/devices";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Button } from "#enums/buttons"; import {Button} from "#enums/buttons";
import { EggSourceType } from "#app/enums/egg-source-types"; import { EggSourceType } from "#app/enums/egg-source-types";
import AwaitableUiHandler from "./awaitable-ui-handler"; import AwaitableUiHandler from "./awaitable-ui-handler";
import { DropDown, DropDownLabel, DropDownOption, DropDownState, DropDownType, SortCriteria } from "./dropdown"; import { DropDown, DropDownLabel, DropDownOption, DropDownState, DropDownType, SortCriteria } from "./dropdown";
@ -2905,7 +2905,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
} }
const speciesForm = getPokemonSpeciesForm(species.speciesId, props.formIndex); const speciesForm = getPokemonSpeciesForm(species.speciesId, props.formIndex);
this.setTypeIcons(speciesForm.type1, speciesForm.type2); this.setTypeIcons(speciesForm.type1, speciesForm!.type2!); // TODO: are those bangs correct?
this.pokemonSprite.clearTint(); this.pokemonSprite.clearTint();
if (this.pokerusSpecies.includes(species)) { if (this.pokerusSpecies.includes(species)) {
@ -3242,12 +3242,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonFormText.setText(formText ? i18next.t(`pokemonForm:${speciesName}${formText}`) : ""); this.pokemonFormText.setText(formText ? i18next.t(`pokemonForm:${speciesName}${formText}`) : "");
} }
this.setTypeIcons(speciesForm.type1, speciesForm.type2); this.setTypeIcons(speciesForm.type1, speciesForm.type2!); // TODO: is this bang correct?
} else { } else {
this.pokemonAbilityText.setText(""); this.pokemonAbilityText.setText("");
this.pokemonPassiveText.setText(""); this.pokemonPassiveText.setText("");
this.pokemonNatureText.setText(""); this.pokemonNatureText.setText("");
this.setTypeIcons(null, null); // @ts-ignore
this.setTypeIcons(null, null); // TODO: resolve ts-ignore.. huh!?
} }
} else { } else {
this.shinyOverlay.setVisible(false); this.shinyOverlay.setVisible(false);
@ -3257,7 +3258,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonAbilityText.setText(""); this.pokemonAbilityText.setText("");
this.pokemonPassiveText.setText(""); this.pokemonPassiveText.setText("");
this.pokemonNatureText.setText(""); this.pokemonNatureText.setText("");
this.setTypeIcons(null, null); // @ts-ignore
this.setTypeIcons(null, null); // TODO: resolve ts-ignore.. huh!?
} }
if (!this.starterMoveset) { if (!this.starterMoveset) {
@ -3290,7 +3292,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.updateInstructions(); this.updateInstructions();
} }
setTypeIcons(type1: Type | null, type2: Type | null): void { setTypeIcons(type1: Type, type2: Type): void {
if (type1 !== null) { if (type1 !== null) {
this.type1Icon.setVisible(true); this.type1Icon.setVisible(true);
this.type1Icon.setFrame(Type[type1].toLowerCase()); this.type1Icon.setFrame(Type[type1].toLowerCase());