mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-30 21:42:20 +02:00
Compare commits
16 Commits
0be9d35ff7
...
4108dfacc1
Author | SHA1 | Date | |
---|---|---|---|
|
4108dfacc1 | ||
|
1ff2701964 | ||
|
1e306e25b5 | ||
|
9db65e30dc | ||
|
43aa772603 | ||
|
efffc3c93a | ||
|
8fb07e2503 | ||
|
683c203fa0 | ||
|
d5ea58b4bb | ||
|
e7b6ec93df | ||
|
c10712d0d1 | ||
|
77ed552ecc | ||
|
4fa850d924 | ||
|
95690be3c9 | ||
|
70dbabe281 | ||
|
06b6beab02 |
12
src/@types/attack-move-result.ts
Normal file
12
src/@types/attack-move-result.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import type { BattlerIndex } from "#enums/battler-index";
|
||||||
|
import type { DamageResult } from "#app/@types/damage-result";
|
||||||
|
import type { MoveId } from "#enums/move-id";
|
||||||
|
|
||||||
|
export interface AttackMoveResult {
|
||||||
|
move: MoveId;
|
||||||
|
result: DamageResult;
|
||||||
|
damage: number;
|
||||||
|
critical: boolean;
|
||||||
|
sourceId: number;
|
||||||
|
sourceBattlerIndex: BattlerIndex;
|
||||||
|
}
|
21
src/@types/damage-result.ts
Normal file
21
src/@types/damage-result.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import type { HitResult } from "#enums/hit-result";
|
||||||
|
|
||||||
|
/** Union type containing all damage-dealing {@linkcode HitResult}s. */
|
||||||
|
export type DamageResult =
|
||||||
|
| HitResult.EFFECTIVE
|
||||||
|
| HitResult.SUPER_EFFECTIVE
|
||||||
|
| HitResult.NOT_VERY_EFFECTIVE
|
||||||
|
| HitResult.ONE_HIT_KO
|
||||||
|
| HitResult.CONFUSION
|
||||||
|
| HitResult.INDIRECT_KO
|
||||||
|
| HitResult.INDIRECT;
|
||||||
|
|
||||||
|
/** Interface containing the results of a damage calculation for a given move. */
|
||||||
|
export interface DamageCalculationResult {
|
||||||
|
/** `true` if the move was cancelled (thus suppressing "No Effect" messages) */
|
||||||
|
cancelled: boolean;
|
||||||
|
/** The effectiveness of the move */
|
||||||
|
result: HitResult;
|
||||||
|
/** The damage dealt by the move */
|
||||||
|
damage: number;
|
||||||
|
}
|
41
src/@types/illusion-data.ts
Normal file
41
src/@types/illusion-data.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import type { Gender } from "#app/data/gender";
|
||||||
|
import type PokemonSpecies from "#app/data/pokemon-species";
|
||||||
|
import type { Variant } from "#app/sprites/variant";
|
||||||
|
import type { PokeballType } from "#enums/pokeball";
|
||||||
|
import type { SpeciesId } from "#enums/species-id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data pertaining to a Pokemon's Illusion.
|
||||||
|
*/
|
||||||
|
export interface IllusionData {
|
||||||
|
basePokemon: {
|
||||||
|
/** The actual name of the Pokemon */
|
||||||
|
name: string;
|
||||||
|
/** The actual nickname of the Pokemon */
|
||||||
|
nickname: string;
|
||||||
|
/** Whether the base pokemon is shiny or not */
|
||||||
|
shiny: boolean;
|
||||||
|
/** The shiny variant of the base pokemon */
|
||||||
|
variant: Variant;
|
||||||
|
/** Whether the fusion species of the base pokemon is shiny or not */
|
||||||
|
fusionShiny: boolean;
|
||||||
|
/** The variant of the fusion species of the base pokemon */
|
||||||
|
fusionVariant: Variant;
|
||||||
|
};
|
||||||
|
/** The species of the illusion */
|
||||||
|
species: SpeciesId;
|
||||||
|
/** The formIndex of the illusion */
|
||||||
|
formIndex: number;
|
||||||
|
/** The gender of the illusion */
|
||||||
|
gender: Gender;
|
||||||
|
/** The pokeball of the illusion */
|
||||||
|
pokeball: PokeballType;
|
||||||
|
/** The fusion species of the illusion if it's a fusion */
|
||||||
|
fusionSpecies?: PokemonSpecies;
|
||||||
|
/** The fusionFormIndex of the illusion */
|
||||||
|
fusionFormIndex?: number;
|
||||||
|
/** The fusionGender of the illusion if it's a fusion */
|
||||||
|
fusionGender?: Gender;
|
||||||
|
/** The level of the illusion (not used currently) */
|
||||||
|
level?: number;
|
||||||
|
}
|
13
src/@types/turn-move.ts
Normal file
13
src/@types/turn-move.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import type { BattlerIndex } from "#enums/battler-index";
|
||||||
|
import type { MoveId } from "#enums/move-id";
|
||||||
|
import type { MoveResult } from "#enums/move-result";
|
||||||
|
import type { MoveUseMode } from "#enums/move-use-mode";
|
||||||
|
|
||||||
|
/** A record of a move having been used. */
|
||||||
|
export interface TurnMove {
|
||||||
|
move: MoveId;
|
||||||
|
targets: BattlerIndex[];
|
||||||
|
useMode: MoveUseMode;
|
||||||
|
result?: MoveResult;
|
||||||
|
turn?: number;
|
||||||
|
}
|
@ -17,7 +17,8 @@ import { MoneyMultiplierModifier, type PokemonHeldItemModifier } from "./modifie
|
|||||||
import type { PokeballType } from "#enums/pokeball";
|
import type { PokeballType } from "#enums/pokeball";
|
||||||
import { trainerConfigs } from "#app/data/trainers/trainer-config";
|
import { trainerConfigs } from "#app/data/trainers/trainer-config";
|
||||||
import { SpeciesFormKey } from "#enums/species-form-key";
|
import { SpeciesFormKey } from "#enums/species-form-key";
|
||||||
import type { EnemyPokemon, PlayerPokemon, TurnMove } from "#app/field/pokemon";
|
import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
|
||||||
|
import type { TurnMove } from "./@types/turn-move";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon 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";
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
import type { AbilityId } from "#enums/ability-id";
|
|
||||||
import type { PokemonType } from "#enums/pokemon-type";
|
|
||||||
import type { Nature } from "#enums/nature";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data that can customize a Pokemon in non-standard ways from its Species.
|
|
||||||
* Includes abilities, nature, changed types, etc.
|
|
||||||
*/
|
|
||||||
export class CustomPokemonData {
|
|
||||||
// TODO: Change the default value for all these from -1 to something a bit more sensible
|
|
||||||
/**
|
|
||||||
* The scale at which to render this Pokemon's sprite.
|
|
||||||
*/
|
|
||||||
public spriteScale = -1;
|
|
||||||
public ability: AbilityId | -1;
|
|
||||||
public passive: AbilityId | -1;
|
|
||||||
public nature: Nature | -1;
|
|
||||||
public types: PokemonType[];
|
|
||||||
/** Deprecated but needed for session save migration */
|
|
||||||
// TODO: Remove this once pre-session migration is implemented
|
|
||||||
public hitsRecCount: number | null = null;
|
|
||||||
|
|
||||||
constructor(data?: CustomPokemonData | Partial<CustomPokemonData>) {
|
|
||||||
this.spriteScale = data?.spriteScale ?? -1;
|
|
||||||
this.ability = data?.ability ?? -1;
|
|
||||||
this.passive = data?.passive ?? -1;
|
|
||||||
this.nature = data?.nature ?? -1;
|
|
||||||
this.types = data?.types ?? [];
|
|
||||||
this.hitsRecCount = data?.hitsRecCount ?? null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,7 +13,8 @@ import {
|
|||||||
TypeBoostTag,
|
TypeBoostTag,
|
||||||
} from "../battler-tags";
|
} from "../battler-tags";
|
||||||
import { getPokemonNameWithAffix } from "../../messages";
|
import { getPokemonNameWithAffix } from "../../messages";
|
||||||
import type { AttackMoveResult, TurnMove } from "../../field/pokemon";
|
import type { TurnMove } from "#app/@types/turn-move";
|
||||||
|
import type { AttackMoveResult } from "#app/@types/attack-move-result";
|
||||||
import type Pokemon from "../../field/pokemon";
|
import type Pokemon from "../../field/pokemon";
|
||||||
import type { EnemyPokemon } from "#app/field/pokemon";
|
import type { EnemyPokemon } from "#app/field/pokemon";
|
||||||
import { PokemonMove } from "./pokemon-move";
|
import { PokemonMove } from "./pokemon-move";
|
||||||
@ -93,6 +94,10 @@ import { ChargingMove, MoveAttrMap, MoveAttrString, MoveKindString, MoveClassMap
|
|||||||
import { applyMoveAttrs } from "./apply-attrs";
|
import { applyMoveAttrs } from "./apply-attrs";
|
||||||
import { frenzyMissFunc, getMoveTargets } from "./move-utils";
|
import { frenzyMissFunc, getMoveTargets } from "./move-utils";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function used to conditionally determine execution of a given {@linkcode MoveAttr}.
|
||||||
|
* Conventionally returns `true` for success and `false` for failure.
|
||||||
|
*/
|
||||||
type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean;
|
type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean;
|
||||||
export type UserMoveConditionFunc = (user: Pokemon, move: Move) => boolean;
|
export type UserMoveConditionFunc = (user: Pokemon, move: Move) => boolean;
|
||||||
|
|
||||||
@ -1390,18 +1395,31 @@ export class BeakBlastHeaderAttr extends AddBattlerTagHeaderAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute to display a message before a move is executed.
|
||||||
|
*/
|
||||||
export class PreMoveMessageAttr extends MoveAttr {
|
export class PreMoveMessageAttr extends MoveAttr {
|
||||||
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string);
|
/** The message to display or a function returning one */
|
||||||
|
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string | undefined);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@linkcode PreMoveMessageAttr} to display a message before move execution.
|
||||||
|
* @param message - The message to display before move use, either as a string or a function producing one.
|
||||||
|
* @remarks
|
||||||
|
* If {@linkcode message} evaluates to an empty string (`''`), no message will be displayed
|
||||||
|
* (though the move will still succeed).
|
||||||
|
*/
|
||||||
constructor(message: string | ((user: Pokemon, target: Pokemon, move: Move) => string)) {
|
constructor(message: string | ((user: Pokemon, target: Pokemon, move: Move) => string)) {
|
||||||
super();
|
super();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean {
|
||||||
const message = typeof this.message === "string"
|
const message = typeof this.message === "function"
|
||||||
? this.message as string
|
? this.message(user, target, move)
|
||||||
: this.message(user, target, move);
|
: this.message;
|
||||||
|
|
||||||
|
// TODO: Consider changing if/when MoveAttr `apply` return values become significant
|
||||||
if (message) {
|
if (message) {
|
||||||
globalScene.phaseManager.queueMessage(message, 500);
|
globalScene.phaseManager.queueMessage(message, 500);
|
||||||
return true;
|
return true;
|
||||||
@ -11299,7 +11317,11 @@ export function initMoves() {
|
|||||||
.attr(ForceSwitchOutAttr, true, SwitchType.SHED_TAIL)
|
.attr(ForceSwitchOutAttr, true, SwitchType.SHED_TAIL)
|
||||||
.condition(failIfLastInPartyCondition),
|
.condition(failIfLastInPartyCondition),
|
||||||
new SelfStatusMove(MoveId.CHILLY_RECEPTION, PokemonType.ICE, -1, 10, -1, 0, 9)
|
new SelfStatusMove(MoveId.CHILLY_RECEPTION, PokemonType.ICE, -1, 10, -1, 0, 9)
|
||||||
.attr(PreMoveMessageAttr, (user, move) => i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(user) }))
|
.attr(PreMoveMessageAttr, (user, _target, _move) =>
|
||||||
|
// Don't display text if current move phase is follow up (ie move called indirectly)
|
||||||
|
isVirtual((globalScene.phaseManager.getCurrentPhase() as MovePhase).useMode)
|
||||||
|
? ""
|
||||||
|
: i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(user) }))
|
||||||
.attr(ChillyReceptionAttr, true),
|
.attr(ChillyReceptionAttr, true),
|
||||||
new SelfStatusMove(MoveId.TIDY_UP, PokemonType.NORMAL, -1, 10, -1, 0, 9)
|
new SelfStatusMove(MoveId.TIDY_UP, PokemonType.NORMAL, -1, 10, -1, 0, 9)
|
||||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPD ], 1, true)
|
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPD ], 1, true)
|
||||||
|
@ -44,7 +44,7 @@ import { BattlerIndex } from "#enums/battler-index";
|
|||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { EncounterBattleAnim } from "#app/data/battle-anims";
|
import { EncounterBattleAnim } from "#app/data/battle-anims";
|
||||||
import { MoveCategory } from "#enums/MoveCategory";
|
import { MoveCategory } from "#enums/MoveCategory";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
|
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
|
||||||
import { EncounterAnim } from "#enums/encounter-anims";
|
import { EncounterAnim } from "#enums/encounter-anims";
|
||||||
import { Challenges } from "#enums/challenges";
|
import { Challenges } from "#enums/challenges";
|
||||||
|
@ -29,7 +29,7 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
|||||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||||
import { BerryType } from "#enums/berry-type";
|
import { BerryType } from "#enums/berry-type";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import { randSeedInt } from "#app/utils/common";
|
import { randSeedInt } from "#app/utils/common";
|
||||||
import { MoveUseMode } from "#enums/move-use-mode";
|
import { MoveUseMode } from "#enums/move-use-mode";
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import { BattlerIndex } from "#enums/battler-index";
|
|||||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
import { BerryType } from "#enums/berry-type";
|
import { BerryType } from "#enums/berry-type";
|
||||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
|
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
|
||||||
import { MoveUseMode } from "#enums/move-use-mode";
|
import { MoveUseMode } from "#enums/move-use-mode";
|
||||||
|
@ -43,7 +43,7 @@ import { TrainerSlot } from "#enums/trainer-slot";
|
|||||||
import type PokemonSpecies from "#app/data/pokemon-species";
|
import type PokemonSpecies from "#app/data/pokemon-species";
|
||||||
import type { IEggOptions } from "#app/data/egg";
|
import type { IEggOptions } from "#app/data/egg";
|
||||||
import { Egg } from "#app/data/egg";
|
import { Egg } from "#app/data/egg";
|
||||||
import type { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import type { CustomPokemonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import type HeldModifierConfig from "#app/@types/held-modifier-config";
|
import type HeldModifierConfig from "#app/@types/held-modifier-config";
|
||||||
import type { Variant } from "#app/sprites/variant";
|
import type { Variant } from "#app/sprites/variant";
|
||||||
import { StatusEffect } from "#enums/status-effect";
|
import { StatusEffect } from "#enums/status-effect";
|
||||||
|
@ -33,7 +33,7 @@ import { modifierTypes } from "#app/data/data-lists";
|
|||||||
import { Gender } from "#app/data/gender";
|
import { Gender } from "#app/data/gender";
|
||||||
import type { PermanentStat } from "#enums/stat";
|
import type { PermanentStat } from "#enums/stat";
|
||||||
import { SummaryUiMode } from "#app/ui/summary-ui-handler";
|
import { SummaryUiMode } from "#app/ui/summary-ui-handler";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import type { AbilityId } from "#enums/ability-id";
|
import type { AbilityId } from "#enums/ability-id";
|
||||||
import type { PokeballType } from "#enums/pokeball";
|
import type { PokeballType } from "#enums/pokeball";
|
||||||
import { StatusEffect } from "#enums/status-effect";
|
import { StatusEffect } from "#enums/status-effect";
|
||||||
@ -751,7 +751,7 @@ export async function catchPokemon(
|
|||||||
UiMode.POKEDEX_PAGE,
|
UiMode.POKEDEX_PAGE,
|
||||||
pokemon.species,
|
pokemon.species,
|
||||||
pokemon.formIndex,
|
pokemon.formIndex,
|
||||||
attributes,
|
[attributes],
|
||||||
null,
|
null,
|
||||||
() => {
|
() => {
|
||||||
globalScene.ui.setMode(UiMode.MESSAGE).then(() => {
|
globalScene.ui.setMode(UiMode.MESSAGE).then(() => {
|
||||||
|
@ -764,7 +764,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
readonly subLegendary: boolean;
|
readonly subLegendary: boolean;
|
||||||
readonly legendary: boolean;
|
readonly legendary: boolean;
|
||||||
readonly mythical: boolean;
|
readonly mythical: boolean;
|
||||||
readonly species: string;
|
public category: string;
|
||||||
readonly growthRate: GrowthRate;
|
readonly growthRate: GrowthRate;
|
||||||
/** The chance (as a decimal) for this Species to be male, or `null` for genderless species */
|
/** The chance (as a decimal) for this Species to be male, or `null` for genderless species */
|
||||||
readonly malePercent: number | null;
|
readonly malePercent: number | null;
|
||||||
@ -778,7 +778,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
subLegendary: boolean,
|
subLegendary: boolean,
|
||||||
legendary: boolean,
|
legendary: boolean,
|
||||||
mythical: boolean,
|
mythical: boolean,
|
||||||
species: string,
|
category: string,
|
||||||
type1: PokemonType,
|
type1: PokemonType,
|
||||||
type2: PokemonType | null,
|
type2: PokemonType | null,
|
||||||
height: number,
|
height: number,
|
||||||
@ -829,7 +829,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
this.subLegendary = subLegendary;
|
this.subLegendary = subLegendary;
|
||||||
this.legendary = legendary;
|
this.legendary = legendary;
|
||||||
this.mythical = mythical;
|
this.mythical = mythical;
|
||||||
this.species = species;
|
this.category = category;
|
||||||
this.growthRate = growthRate;
|
this.growthRate = growthRate;
|
||||||
this.malePercent = malePercent;
|
this.malePercent = malePercent;
|
||||||
this.genderDiffs = genderDiffs;
|
this.genderDiffs = genderDiffs;
|
||||||
@ -968,6 +968,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
|
|
||||||
localize(): void {
|
localize(): void {
|
||||||
this.name = i18next.t(`pokemon:${SpeciesId[this.speciesId].toLowerCase()}`);
|
this.name = i18next.t(`pokemon:${SpeciesId[this.speciesId].toLowerCase()}`);
|
||||||
|
this.category = i18next.t(`pokemonCategory:${SpeciesId[this.speciesId].toLowerCase()}_category`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWildSpeciesForLevel(level: number, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): SpeciesId {
|
getWildSpeciesForLevel(level: number, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): SpeciesId {
|
||||||
|
208
src/data/pokemon/pokemon-data.ts
Normal file
208
src/data/pokemon/pokemon-data.ts
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
import { type BattlerTag, loadBattlerTag } from "#app/data/battler-tags";
|
||||||
|
import type { Gender } from "#app/data/gender";
|
||||||
|
import type { PokemonSpeciesForm } from "#app/data/pokemon-species";
|
||||||
|
import type { TypeDamageMultiplier } from "#app/data/type";
|
||||||
|
import { isNullOrUndefined } from "#app/utils/common";
|
||||||
|
import type { AbilityId } from "#enums/ability-id";
|
||||||
|
import type { BerryType } from "#enums/berry-type";
|
||||||
|
import type { MoveId } from "#enums/move-id";
|
||||||
|
import type { PokemonType } from "#enums/pokemon-type";
|
||||||
|
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
||||||
|
import type { TurnMove } from "#app/@types/turn-move";
|
||||||
|
import type { AttackMoveResult } from "#app/@types/attack-move-result";
|
||||||
|
import type { Nature } from "#enums/nature";
|
||||||
|
import type { IllusionData } from "#app/@types/illusion-data";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permanent data that can customize a Pokemon in non-standard ways from its Species.
|
||||||
|
* Includes abilities, nature, changed types, etc.
|
||||||
|
*/
|
||||||
|
export class CustomPokemonData {
|
||||||
|
// TODO: Change the default value for all these from -1 to something a bit more sensible
|
||||||
|
/**
|
||||||
|
* The scale at which to render this Pokemon's sprite.
|
||||||
|
*/
|
||||||
|
public spriteScale = -1;
|
||||||
|
public ability: AbilityId | -1;
|
||||||
|
public passive: AbilityId | -1;
|
||||||
|
public nature: Nature | -1;
|
||||||
|
public types: PokemonType[];
|
||||||
|
/** Deprecated but needed for session save migration */
|
||||||
|
// TODO: Remove this once pre-session migration is implemented
|
||||||
|
public hitsRecCount: number | null = null;
|
||||||
|
|
||||||
|
constructor(data?: CustomPokemonData | Partial<CustomPokemonData>) {
|
||||||
|
this.spriteScale = data?.spriteScale ?? -1;
|
||||||
|
this.ability = data?.ability ?? -1;
|
||||||
|
this.passive = data?.passive ?? -1;
|
||||||
|
this.nature = data?.nature ?? -1;
|
||||||
|
this.types = data?.types ?? [];
|
||||||
|
this.hitsRecCount = data?.hitsRecCount ?? null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persistent in-battle data for a {@linkcode Pokemon}.
|
||||||
|
* Resets on switch or new battle.
|
||||||
|
*/
|
||||||
|
export class PokemonSummonData {
|
||||||
|
/** [Atk, Def, SpAtk, SpDef, Spd, Acc, Eva] */
|
||||||
|
public statStages: number[] = [0, 0, 0, 0, 0, 0, 0];
|
||||||
|
/**
|
||||||
|
* A queue of moves yet to be executed, used by charging, recharging and frenzy moves.
|
||||||
|
* So long as this array is nonempty, this Pokemon's corresponding `CommandPhase` will be skipped over entirely
|
||||||
|
* in favor of using the queued move.
|
||||||
|
* TODO: Clean up a lot of the code surrounding the move queue.
|
||||||
|
*/
|
||||||
|
public moveQueue: TurnMove[] = [];
|
||||||
|
public tags: BattlerTag[] = [];
|
||||||
|
public abilitySuppressed = false;
|
||||||
|
|
||||||
|
// Overrides for transform.
|
||||||
|
// TODO: Move these into a separate class & add rage fist hit count
|
||||||
|
public speciesForm: PokemonSpeciesForm | null = null;
|
||||||
|
public fusionSpeciesForm: PokemonSpeciesForm | null = null;
|
||||||
|
public ability: AbilityId | undefined;
|
||||||
|
public passiveAbility: AbilityId | undefined;
|
||||||
|
public gender: Gender | undefined;
|
||||||
|
public fusionGender: Gender | undefined;
|
||||||
|
public stats: number[] = [0, 0, 0, 0, 0, 0];
|
||||||
|
public moveset: PokemonMove[] | null;
|
||||||
|
|
||||||
|
// If not initialized this value will not be populated from save data.
|
||||||
|
public types: PokemonType[] = [];
|
||||||
|
public addedType: PokemonType | null = null;
|
||||||
|
|
||||||
|
/** Data pertaining to this pokemon's illusion. */
|
||||||
|
public illusion: IllusionData | null = null;
|
||||||
|
public illusionBroken = false;
|
||||||
|
|
||||||
|
/** Array containing all berries eaten in the last turn; used by {@linkcode AbilityId.CUD_CHEW} */
|
||||||
|
public berriesEatenLast: BerryType[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of all moves this pokemon has used since entering the battle.
|
||||||
|
* Used for most moves and abilities that check prior move usage or copy already-used moves.
|
||||||
|
*/
|
||||||
|
public moveHistory: TurnMove[] = [];
|
||||||
|
|
||||||
|
constructor(source?: PokemonSummonData | Partial<PokemonSummonData>) {
|
||||||
|
if (isNullOrUndefined(source)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Rework this into an actual generic function for use elsewhere
|
||||||
|
for (const [key, value] of Object.entries(source)) {
|
||||||
|
if (isNullOrUndefined(value) && this.hasOwnProperty(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key === "moveset") {
|
||||||
|
this.moveset = value?.map((m: any) => PokemonMove.loadMove(m));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key === "tags") {
|
||||||
|
// load battler tags
|
||||||
|
this.tags = value.map((t: BattlerTag) => loadBattlerTag(t));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Merge this inside `summmonData` but exclude from save if/when a save data serializer is added
|
||||||
|
export class PokemonTempSummonData {
|
||||||
|
/**
|
||||||
|
* The number of turns this pokemon has spent without switching out.
|
||||||
|
* Only currently used for positioning the battle cursor.
|
||||||
|
*/
|
||||||
|
turnCount = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of turns this pokemon has spent in the active position since the start of the wave
|
||||||
|
* without switching out.
|
||||||
|
* Reset on switch and new wave, but not stored in `SummonData` to avoid being written to the save file.
|
||||||
|
|
||||||
|
* Used to evaluate "first turn only" conditions such as
|
||||||
|
* {@linkcode MoveId.FAKE_OUT | Fake Out} and {@linkcode MoveId.FIRST_IMPRESSION | First Impression}).
|
||||||
|
*/
|
||||||
|
waveTurnCount = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persistent data for a {@linkcode Pokemon}.
|
||||||
|
* Resets at the start of a new battle (but not on switch).
|
||||||
|
*/
|
||||||
|
export class PokemonBattleData {
|
||||||
|
/** Counter tracking direct hits this Pokemon has received during this battle; used for {@linkcode MoveId.RAGE_FIST} */
|
||||||
|
public hitCount = 0;
|
||||||
|
/** Whether this Pokemon has eaten a berry this battle; used for {@linkcode MoveId.BELCH} */
|
||||||
|
public hasEatenBerry = false;
|
||||||
|
/** Array containing all berries eaten and not yet recovered during this current battle; used by {@linkcode AbilityId.HARVEST} */
|
||||||
|
public berriesEaten: BerryType[] = [];
|
||||||
|
|
||||||
|
constructor(source?: PokemonBattleData | Partial<PokemonBattleData>) {
|
||||||
|
if (!isNullOrUndefined(source)) {
|
||||||
|
this.hitCount = source.hitCount ?? 0;
|
||||||
|
this.hasEatenBerry = source.hasEatenBerry ?? false;
|
||||||
|
this.berriesEaten = source.berriesEaten ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary data for a {@linkcode Pokemon}.
|
||||||
|
* Resets on new wave/battle start (but not on switch).
|
||||||
|
*/
|
||||||
|
export class PokemonWaveData {
|
||||||
|
/** Whether the pokemon has endured due to a {@linkcode BattlerTagType.ENDURE_TOKEN} */
|
||||||
|
public endured = false;
|
||||||
|
/**
|
||||||
|
* A set of all the abilities this {@linkcode Pokemon} has used in this wave.
|
||||||
|
* Used to track once per battle conditions, as well as (hopefully) by the updated AI for move effectiveness.
|
||||||
|
*/
|
||||||
|
public abilitiesApplied: Set<AbilityId> = new Set<AbilityId>();
|
||||||
|
/** Whether the pokemon's ability has been revealed or not */
|
||||||
|
public abilityRevealed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary data for a {@linkcode Pokemon}.
|
||||||
|
* Resets at the start of a new turn, as well as on switch.
|
||||||
|
*/
|
||||||
|
export class PokemonTurnData {
|
||||||
|
public acted = false;
|
||||||
|
/** How many times the current move should hit the target(s) */
|
||||||
|
public hitCount = 0;
|
||||||
|
/**
|
||||||
|
* - `-1` = Calculate how many hits are left
|
||||||
|
* - `0` = Move is finished
|
||||||
|
*/
|
||||||
|
public hitsLeft = -1;
|
||||||
|
public totalDamageDealt = 0;
|
||||||
|
public singleHitDamageDealt = 0;
|
||||||
|
public damageTaken = 0;
|
||||||
|
public attacksReceived: AttackMoveResult[] = [];
|
||||||
|
public order: number;
|
||||||
|
public statStagesIncreased = false;
|
||||||
|
public statStagesDecreased = false;
|
||||||
|
public moveEffectiveness: TypeDamageMultiplier | null = null;
|
||||||
|
public combiningPledge?: MoveId;
|
||||||
|
public switchedInThisTurn = false;
|
||||||
|
public failedRunAway = false;
|
||||||
|
public joinedRound = false;
|
||||||
|
/**
|
||||||
|
* The amount of times this Pokemon has acted again and used a move in the current turn.
|
||||||
|
* Used to make sure multi-hits occur properly when the user is
|
||||||
|
* forced to act again in the same turn, and **must be incremented** by any effects that grant extra actions.
|
||||||
|
*/
|
||||||
|
public extraTurns = 0;
|
||||||
|
/**
|
||||||
|
* All berries eaten by this pokemon in this turn.
|
||||||
|
* Saved into {@linkcode PokemonSummonData | SummonData} by {@linkcode AbilityId.CUD_CHEW} on turn end.
|
||||||
|
* @see {@linkcode PokemonSummonData.berriesEatenLast}
|
||||||
|
*/
|
||||||
|
public berriesEaten: BerryType[] = [];
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { TextStyle, addTextObject } from "../ui/text";
|
import { TextStyle, addTextObject } from "../ui/text";
|
||||||
import type { DamageResult } from "./pokemon";
|
import type { DamageResult } from "../@types/damage-result";
|
||||||
import type Pokemon from "./pokemon";
|
import type Pokemon from "./pokemon";
|
||||||
import { HitResult } from "#enums/hit-result";
|
import { HitResult } from "#enums/hit-result";
|
||||||
import { formatStat, fixedInt } from "#app/utils/common";
|
import { formatStat, fixedInt } from "#app/utils/common";
|
||||||
|
@ -100,7 +100,6 @@ import {
|
|||||||
TarShotTag,
|
TarShotTag,
|
||||||
AutotomizedTag,
|
AutotomizedTag,
|
||||||
PowerTrickTag,
|
PowerTrickTag,
|
||||||
loadBattlerTag,
|
|
||||||
type GrudgeTag,
|
type GrudgeTag,
|
||||||
} from "../data/battler-tags";
|
} from "../data/battler-tags";
|
||||||
import { BattlerTagLapseType } from "#enums/battler-tag-lapse-type";
|
import { BattlerTagLapseType } from "#enums/battler-tag-lapse-type";
|
||||||
@ -166,7 +165,14 @@ import { getPokemonNameWithAffix } from "#app/messages";
|
|||||||
import { Challenges } from "#enums/challenges";
|
import { Challenges } from "#enums/challenges";
|
||||||
import { PokemonAnimType } from "#enums/pokemon-anim-type";
|
import { PokemonAnimType } from "#enums/pokemon-anim-type";
|
||||||
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import {
|
||||||
|
CustomPokemonData,
|
||||||
|
PokemonBattleData,
|
||||||
|
PokemonSummonData,
|
||||||
|
PokemonTempSummonData,
|
||||||
|
PokemonTurnData,
|
||||||
|
PokemonWaveData,
|
||||||
|
} from "#app/data/pokemon/pokemon-data";
|
||||||
import { SwitchType } from "#enums/switch-type";
|
import { SwitchType } from "#enums/switch-type";
|
||||||
import { SpeciesFormKey } from "#enums/species-form-key";
|
import { SpeciesFormKey } from "#enums/species-form-key";
|
||||||
import { getStatusEffectOverlapText } from "#app/data/status-effect";
|
import { getStatusEffectOverlapText } from "#app/data/status-effect";
|
||||||
@ -187,9 +193,11 @@ import { FieldPosition } from "#enums/field-position";
|
|||||||
import { LearnMoveSituation } from "#enums/learn-move-situation";
|
import { LearnMoveSituation } from "#enums/learn-move-situation";
|
||||||
import { HitResult } from "#enums/hit-result";
|
import { HitResult } from "#enums/hit-result";
|
||||||
import { AiType } from "#enums/ai-type";
|
import { AiType } from "#enums/ai-type";
|
||||||
import type { MoveResult } from "#enums/move-result";
|
|
||||||
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
||||||
import type { AbAttrMap, AbAttrString } from "#app/@types/ability-types";
|
import type { AbAttrMap, AbAttrString } from "#app/@types/ability-types";
|
||||||
|
import type { IllusionData } from "#app/@types/illusion-data";
|
||||||
|
import type { TurnMove } from "#app/@types/turn-move";
|
||||||
|
import type { DamageCalculationResult, DamageResult } from "#app/@types/damage-result";
|
||||||
|
|
||||||
/** Base typeclass for damage parameter methods, used for DRY */
|
/** Base typeclass for damage parameter methods, used for DRY */
|
||||||
type damageParams = {
|
type damageParams = {
|
||||||
@ -6706,241 +6714,3 @@ export class EnemyPokemon extends Pokemon {
|
|||||||
this.battleInfo.toggleFlyout(visible);
|
this.battleInfo.toggleFlyout(visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Illusion property
|
|
||||||
*/
|
|
||||||
interface IllusionData {
|
|
||||||
basePokemon: {
|
|
||||||
/** The actual name of the Pokemon */
|
|
||||||
name: string;
|
|
||||||
/** The actual nickname of the Pokemon */
|
|
||||||
nickname: string;
|
|
||||||
/** Whether the base pokemon is shiny or not */
|
|
||||||
shiny: boolean;
|
|
||||||
/** The shiny variant of the base pokemon */
|
|
||||||
variant: Variant;
|
|
||||||
/** Whether the fusion species of the base pokemon is shiny or not */
|
|
||||||
fusionShiny: boolean;
|
|
||||||
/** The variant of the fusion species of the base pokemon */
|
|
||||||
fusionVariant: Variant;
|
|
||||||
};
|
|
||||||
/** The species of the illusion */
|
|
||||||
species: SpeciesId;
|
|
||||||
/** The formIndex of the illusion */
|
|
||||||
formIndex: number;
|
|
||||||
/** The gender of the illusion */
|
|
||||||
gender: Gender;
|
|
||||||
/** The pokeball of the illusion */
|
|
||||||
pokeball: PokeballType;
|
|
||||||
/** The fusion species of the illusion if it's a fusion */
|
|
||||||
fusionSpecies?: PokemonSpecies;
|
|
||||||
/** The fusionFormIndex of the illusion */
|
|
||||||
fusionFormIndex?: number;
|
|
||||||
/** The fusionGender of the illusion if it's a fusion */
|
|
||||||
fusionGender?: Gender;
|
|
||||||
/** The level of the illusion (not used currently) */
|
|
||||||
level?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TurnMove {
|
|
||||||
move: MoveId;
|
|
||||||
targets: BattlerIndex[];
|
|
||||||
useMode: MoveUseMode;
|
|
||||||
result?: MoveResult;
|
|
||||||
turn?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AttackMoveResult {
|
|
||||||
move: MoveId;
|
|
||||||
result: DamageResult;
|
|
||||||
damage: number;
|
|
||||||
critical: boolean;
|
|
||||||
sourceId: number;
|
|
||||||
sourceBattlerIndex: BattlerIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Persistent in-battle data for a {@linkcode Pokemon}.
|
|
||||||
* Resets on switch or new battle.
|
|
||||||
*/
|
|
||||||
export class PokemonSummonData {
|
|
||||||
/** [Atk, Def, SpAtk, SpDef, Spd, Acc, Eva] */
|
|
||||||
public statStages: number[] = [0, 0, 0, 0, 0, 0, 0];
|
|
||||||
/**
|
|
||||||
* A queue of moves yet to be executed, used by charging, recharging and frenzy moves.
|
|
||||||
* So long as this array is nonempty, this Pokemon's corresponding `CommandPhase` will be skipped over entirely
|
|
||||||
* in favor of using the queued move.
|
|
||||||
* TODO: Clean up a lot of the code surrounding the move queue.
|
|
||||||
*/
|
|
||||||
public moveQueue: TurnMove[] = [];
|
|
||||||
public tags: BattlerTag[] = [];
|
|
||||||
public abilitySuppressed = false;
|
|
||||||
|
|
||||||
// Overrides for transform.
|
|
||||||
// TODO: Move these into a separate class & add rage fist hit count
|
|
||||||
public speciesForm: PokemonSpeciesForm | null = null;
|
|
||||||
public fusionSpeciesForm: PokemonSpeciesForm | null = null;
|
|
||||||
public ability: AbilityId | undefined;
|
|
||||||
public passiveAbility: AbilityId | undefined;
|
|
||||||
public gender: Gender | undefined;
|
|
||||||
public fusionGender: Gender | undefined;
|
|
||||||
public stats: number[] = [0, 0, 0, 0, 0, 0];
|
|
||||||
public moveset: PokemonMove[] | null;
|
|
||||||
|
|
||||||
// If not initialized this value will not be populated from save data.
|
|
||||||
public types: PokemonType[] = [];
|
|
||||||
public addedType: PokemonType | null = null;
|
|
||||||
|
|
||||||
/** Data pertaining to this pokemon's illusion. */
|
|
||||||
public illusion: IllusionData | null = null;
|
|
||||||
public illusionBroken = false;
|
|
||||||
|
|
||||||
/** Array containing all berries eaten in the last turn; used by {@linkcode AbilityId.CUD_CHEW} */
|
|
||||||
public berriesEatenLast: BerryType[] = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An array of all moves this pokemon has used since entering the battle.
|
|
||||||
* Used for most moves and abilities that check prior move usage or copy already-used moves.
|
|
||||||
*/
|
|
||||||
public moveHistory: TurnMove[] = [];
|
|
||||||
|
|
||||||
constructor(source?: PokemonSummonData | Partial<PokemonSummonData>) {
|
|
||||||
if (isNullOrUndefined(source)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Rework this into an actual generic function for use elsewhere
|
|
||||||
for (const [key, value] of Object.entries(source)) {
|
|
||||||
if (isNullOrUndefined(value) && this.hasOwnProperty(key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key === "moveset") {
|
|
||||||
this.moveset = value?.map((m: any) => PokemonMove.loadMove(m));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key === "tags") {
|
|
||||||
// load battler tags
|
|
||||||
this.tags = value.map((t: BattlerTag) => loadBattlerTag(t));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Merge this inside `summmonData` but exclude from save if/when a save data serializer is added
|
|
||||||
export class PokemonTempSummonData {
|
|
||||||
/**
|
|
||||||
* The number of turns this pokemon has spent without switching out.
|
|
||||||
* Only currently used for positioning the battle cursor.
|
|
||||||
*/
|
|
||||||
turnCount = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The number of turns this pokemon has spent in the active position since the start of the wave
|
|
||||||
* without switching out.
|
|
||||||
* Reset on switch and new wave, but not stored in `SummonData` to avoid being written to the save file.
|
|
||||||
|
|
||||||
* Used to evaluate "first turn only" conditions such as
|
|
||||||
* {@linkcode MoveId.FAKE_OUT | Fake Out} and {@linkcode MoveId.FIRST_IMPRESSION | First Impression}).
|
|
||||||
*/
|
|
||||||
waveTurnCount = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Persistent data for a {@linkcode Pokemon}.
|
|
||||||
* Resets at the start of a new battle (but not on switch).
|
|
||||||
*/
|
|
||||||
export class PokemonBattleData {
|
|
||||||
/** Counter tracking direct hits this Pokemon has received during this battle; used for {@linkcode MoveId.RAGE_FIST} */
|
|
||||||
public hitCount = 0;
|
|
||||||
/** Whether this Pokemon has eaten a berry this battle; used for {@linkcode MoveId.BELCH} */
|
|
||||||
public hasEatenBerry = false;
|
|
||||||
/** Array containing all berries eaten and not yet recovered during this current battle; used by {@linkcode AbilityId.HARVEST} */
|
|
||||||
public berriesEaten: BerryType[] = [];
|
|
||||||
|
|
||||||
constructor(source?: PokemonBattleData | Partial<PokemonBattleData>) {
|
|
||||||
if (!isNullOrUndefined(source)) {
|
|
||||||
this.hitCount = source.hitCount ?? 0;
|
|
||||||
this.hasEatenBerry = source.hasEatenBerry ?? false;
|
|
||||||
this.berriesEaten = source.berriesEaten ?? [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Temporary data for a {@linkcode Pokemon}.
|
|
||||||
* Resets on new wave/battle start (but not on switch).
|
|
||||||
*/
|
|
||||||
export class PokemonWaveData {
|
|
||||||
/** Whether the pokemon has endured due to a {@linkcode BattlerTagType.ENDURE_TOKEN} */
|
|
||||||
public endured = false;
|
|
||||||
/**
|
|
||||||
* A set of all the abilities this {@linkcode Pokemon} has used in this wave.
|
|
||||||
* Used to track once per battle conditions, as well as (hopefully) by the updated AI for move effectiveness.
|
|
||||||
*/
|
|
||||||
public abilitiesApplied: Set<AbilityId> = new Set<AbilityId>();
|
|
||||||
/** Whether the pokemon's ability has been revealed or not */
|
|
||||||
public abilityRevealed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Temporary data for a {@linkcode Pokemon}.
|
|
||||||
* Resets at the start of a new turn, as well as on switch.
|
|
||||||
*/
|
|
||||||
export class PokemonTurnData {
|
|
||||||
public acted = false;
|
|
||||||
/** How many times the current move should hit the target(s) */
|
|
||||||
public hitCount = 0;
|
|
||||||
/**
|
|
||||||
* - `-1` = Calculate how many hits are left
|
|
||||||
* - `0` = Move is finished
|
|
||||||
*/
|
|
||||||
public hitsLeft = -1;
|
|
||||||
public totalDamageDealt = 0;
|
|
||||||
public singleHitDamageDealt = 0;
|
|
||||||
public damageTaken = 0;
|
|
||||||
public attacksReceived: AttackMoveResult[] = [];
|
|
||||||
public order: number;
|
|
||||||
public statStagesIncreased = false;
|
|
||||||
public statStagesDecreased = false;
|
|
||||||
public moveEffectiveness: TypeDamageMultiplier | null = null;
|
|
||||||
public combiningPledge?: MoveId;
|
|
||||||
public switchedInThisTurn = false;
|
|
||||||
public failedRunAway = false;
|
|
||||||
public joinedRound = false;
|
|
||||||
/**
|
|
||||||
* The amount of times this Pokemon has acted again and used a move in the current turn.
|
|
||||||
* Used to make sure multi-hits occur properly when the user is
|
|
||||||
* forced to act again in the same turn, and **must be incremented** by any effects that grant extra actions.
|
|
||||||
*/
|
|
||||||
public extraTurns = 0;
|
|
||||||
/**
|
|
||||||
* All berries eaten by this pokemon in this turn.
|
|
||||||
* Saved into {@linkcode PokemonSummonData | SummonData} by {@linkcode AbilityId.CUD_CHEW} on turn end.
|
|
||||||
* @see {@linkcode PokemonSummonData.berriesEatenLast}
|
|
||||||
*/
|
|
||||||
public berriesEaten: BerryType[] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
export type DamageResult =
|
|
||||||
| HitResult.EFFECTIVE
|
|
||||||
| HitResult.SUPER_EFFECTIVE
|
|
||||||
| HitResult.NOT_VERY_EFFECTIVE
|
|
||||||
| HitResult.ONE_HIT_KO
|
|
||||||
| HitResult.CONFUSION
|
|
||||||
| HitResult.INDIRECT_KO
|
|
||||||
| HitResult.INDIRECT;
|
|
||||||
|
|
||||||
/** Interface containing the results of a damage calculation for a given move */
|
|
||||||
export interface DamageCalculationResult {
|
|
||||||
/** `true` if the move was cancelled (thus suppressing "No Effect" messages) */
|
|
||||||
cancelled: boolean;
|
|
||||||
/** The effectiveness of the move */
|
|
||||||
result: HitResult;
|
|
||||||
/** The damage dealt by the move */
|
|
||||||
damage: number;
|
|
||||||
}
|
|
||||||
|
@ -11,7 +11,8 @@ import { BattlerTagType } from "#app/enums/battler-tag-type";
|
|||||||
import { BiomeId } from "#enums/biome-id";
|
import { BiomeId } from "#enums/biome-id";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { PokeballType } from "#enums/pokeball";
|
import { PokeballType } from "#enums/pokeball";
|
||||||
import type { PlayerPokemon, TurnMove } from "#app/field/pokemon";
|
import type { PlayerPokemon } from "#app/field/pokemon";
|
||||||
|
import type { TurnMove } from "#app/@types/turn-move";
|
||||||
import { FieldPosition } from "#enums/field-position";
|
import { FieldPosition } from "#enums/field-position";
|
||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { Command } from "#enums/command";
|
import { Command } from "#enums/command";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import type { BattlerIndex } from "#enums/battler-index";
|
import type { BattlerIndex } from "#enums/battler-index";
|
||||||
import { BattleSpec } from "#enums/battle-spec";
|
import { BattleSpec } from "#enums/battle-spec";
|
||||||
import type { DamageResult } from "#app/field/pokemon";
|
import type { DamageResult } from "#app/@types/damage-result";
|
||||||
import { HitResult } from "#enums/hit-result";
|
import { HitResult } from "#enums/hit-result";
|
||||||
import { fixedInt } from "#app/utils/common";
|
import { fixedInt } from "#app/utils/common";
|
||||||
import { PokemonPhase } from "#app/phases/pokemon-phase";
|
import { PokemonPhase } from "#app/phases/pokemon-phase";
|
||||||
|
@ -27,7 +27,8 @@ import { MoveTarget } from "#enums/MoveTarget";
|
|||||||
import { MoveCategory } from "#enums/MoveCategory";
|
import { MoveCategory } from "#enums/MoveCategory";
|
||||||
import { SpeciesFormChangePostMoveTrigger } from "#app/data/pokemon-forms/form-change-triggers";
|
import { SpeciesFormChangePostMoveTrigger } from "#app/data/pokemon-forms/form-change-triggers";
|
||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import type { DamageResult, TurnMove } from "#app/field/pokemon";
|
import type { DamageResult } from "#app/@types/damage-result";
|
||||||
|
import type { TurnMove } from "#app/@types/turn-move";
|
||||||
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import { MoveResult } from "#enums/move-result";
|
import { MoveResult } from "#enums/move-result";
|
||||||
|
@ -668,6 +668,9 @@ export class MovePhase extends BattlePhase {
|
|||||||
}),
|
}),
|
||||||
500,
|
500,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Moves with pre-use messages (Magnitude, Chilly Reception, Fickle Beam, etc.) always display their messages even on failure
|
||||||
|
// TODO: This assumes single target for message funcs - is this sustainable?
|
||||||
applyMoveAttrs("PreMoveMessageAttr", this.pokemon, this.pokemon.getOpponents(false)[0], this.move.getMove());
|
applyMoveAttrs("PreMoveMessageAttr", this.pokemon, this.pokemon.getOpponents(false)[0], this.move.getMove());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,6 +245,7 @@ export async function initI18n(): Promise<void> {
|
|||||||
"pokeball",
|
"pokeball",
|
||||||
"pokedexUiHandler",
|
"pokedexUiHandler",
|
||||||
"pokemon",
|
"pokemon",
|
||||||
|
"pokemonCategory",
|
||||||
"pokemonEvolutions",
|
"pokemonEvolutions",
|
||||||
"pokemonForm",
|
"pokemonForm",
|
||||||
"pokemonInfo",
|
"pokemonInfo",
|
||||||
|
@ -6,14 +6,14 @@ import { PokeballType } from "#enums/pokeball";
|
|||||||
import { getPokemonSpeciesForm } from "#app/data/pokemon-species";
|
import { getPokemonSpeciesForm } from "#app/data/pokemon-species";
|
||||||
import { getPokemonSpecies } from "#app/utils/pokemon-utils";
|
import { getPokemonSpecies } from "#app/utils/pokemon-utils";
|
||||||
import { Status } from "../data/status-effect";
|
import { Status } from "../data/status-effect";
|
||||||
import Pokemon, { EnemyPokemon, PokemonBattleData, PokemonSummonData } from "../field/pokemon";
|
import Pokemon, { EnemyPokemon } from "../field/pokemon";
|
||||||
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
||||||
import { TrainerSlot } from "#enums/trainer-slot";
|
import { TrainerSlot } from "#enums/trainer-slot";
|
||||||
import type { Variant } from "#app/sprites/variant";
|
import type { Variant } from "#app/sprites/variant";
|
||||||
import type { BiomeId } from "#enums/biome-id";
|
import type { BiomeId } from "#enums/biome-id";
|
||||||
import type { MoveId } from "#enums/move-id";
|
import type { MoveId } from "#enums/move-id";
|
||||||
import type { SpeciesId } from "#enums/species-id";
|
import type { SpeciesId } from "#enums/species-id";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData, PokemonBattleData, PokemonSummonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import type { PokemonType } from "#enums/pokemon-type";
|
import type { PokemonType } from "#enums/pokemon-type";
|
||||||
|
|
||||||
export default class PokemonData {
|
export default class PokemonData {
|
||||||
|
@ -4,7 +4,7 @@ import { defaultStarterSpecies } from "#app/constants";
|
|||||||
import { AbilityAttr } from "#enums/ability-attr";
|
import { AbilityAttr } from "#enums/ability-attr";
|
||||||
import { DexAttr } from "#enums/dex-attr";
|
import { DexAttr } from "#enums/dex-attr";
|
||||||
import { allSpecies } from "#app/data/data-lists";
|
import { allSpecies } from "#app/data/data-lists";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import { isNullOrUndefined } from "#app/utils/common";
|
import { isNullOrUndefined } from "#app/utils/common";
|
||||||
import type { SystemSaveMigrator } from "#app/@types/SystemSaveMigrator";
|
import type { SystemSaveMigrator } from "#app/@types/SystemSaveMigrator";
|
||||||
import type { SettingsSaveMigrator } from "#app/@types/SettingsSaveMigrator";
|
import type { SettingsSaveMigrator } from "#app/@types/SettingsSaveMigrator";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { SessionSaveMigrator } from "#app/@types/SessionSaveMigrator";
|
import type { SessionSaveMigrator } from "#app/@types/SessionSaveMigrator";
|
||||||
import type { BattlerIndex } from "#enums/battler-index";
|
import type { BattlerIndex } from "#enums/battler-index";
|
||||||
import type { TurnMove } from "#app/field/pokemon";
|
import type { TurnMove } from "#app/@types/turn-move";
|
||||||
import type { MoveResult } from "#enums/move-result";
|
import type { MoveResult } from "#enums/move-result";
|
||||||
import type { SessionSaveData } from "#app/system/game-data";
|
import type { SessionSaveData } from "#app/system/game-data";
|
||||||
import { MoveUseMode } from "#enums/move-use-mode";
|
import { MoveUseMode } from "#enums/move-use-mode";
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import type { PlayerPokemon, TurnMove } from "#app/field/pokemon";
|
import type { PlayerPokemon } from "#app/field/pokemon";
|
||||||
|
import type { TurnMove } from "#app/@types/turn-move";
|
||||||
import type { PokemonMove } from "#app/data/moves/pokemon-move";
|
import type { PokemonMove } from "#app/data/moves/pokemon-move";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import { MoveResult } from "#enums/move-result";
|
import { MoveResult } from "#enums/move-result";
|
||||||
|
@ -174,6 +174,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container;
|
private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container;
|
||||||
private pokemonCaughtCountText: Phaser.GameObjects.Text;
|
private pokemonCaughtCountText: Phaser.GameObjects.Text;
|
||||||
private pokemonFormText: Phaser.GameObjects.Text;
|
private pokemonFormText: Phaser.GameObjects.Text;
|
||||||
|
private pokemonCategoryText: Phaser.GameObjects.Text;
|
||||||
private pokemonHatchedIcon: Phaser.GameObjects.Sprite;
|
private pokemonHatchedIcon: Phaser.GameObjects.Sprite;
|
||||||
private pokemonHatchedCountText: Phaser.GameObjects.Text;
|
private pokemonHatchedCountText: Phaser.GameObjects.Text;
|
||||||
private pokemonShinyIcons: Phaser.GameObjects.Sprite[];
|
private pokemonShinyIcons: Phaser.GameObjects.Sprite[];
|
||||||
@ -409,6 +410,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.pokemonFormText.setOrigin(0, 0);
|
this.pokemonFormText.setOrigin(0, 0);
|
||||||
this.starterSelectContainer.add(this.pokemonFormText);
|
this.starterSelectContainer.add(this.pokemonFormText);
|
||||||
|
|
||||||
|
this.pokemonCategoryText = addTextObject(100, 18, "Category", TextStyle.WINDOW_ALT, {
|
||||||
|
fontSize: "42px",
|
||||||
|
});
|
||||||
|
this.pokemonCategoryText.setOrigin(1, 0);
|
||||||
|
this.starterSelectContainer.add(this.pokemonCategoryText);
|
||||||
|
|
||||||
this.pokemonCaughtHatchedContainer = globalScene.add.container(2, 25);
|
this.pokemonCaughtHatchedContainer = globalScene.add.container(2, 25);
|
||||||
this.pokemonCaughtHatchedContainer.setScale(0.5);
|
this.pokemonCaughtHatchedContainer.setScale(0.5);
|
||||||
this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer);
|
this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer);
|
||||||
@ -2354,6 +2361,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.pokemonCaughtHatchedContainer.setVisible(true);
|
this.pokemonCaughtHatchedContainer.setVisible(true);
|
||||||
this.pokemonCandyContainer.setVisible(false);
|
this.pokemonCandyContainer.setVisible(false);
|
||||||
this.pokemonFormText.setVisible(false);
|
this.pokemonFormText.setVisible(false);
|
||||||
|
this.pokemonCategoryText.setVisible(false);
|
||||||
|
|
||||||
const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, true, true);
|
const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, true, true);
|
||||||
const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
||||||
@ -2382,6 +2390,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.pokemonCaughtHatchedContainer.setVisible(false);
|
this.pokemonCaughtHatchedContainer.setVisible(false);
|
||||||
this.pokemonCandyContainer.setVisible(false);
|
this.pokemonCandyContainer.setVisible(false);
|
||||||
this.pokemonFormText.setVisible(false);
|
this.pokemonFormText.setVisible(false);
|
||||||
|
this.pokemonCategoryText.setVisible(false);
|
||||||
|
|
||||||
this.setSpeciesDetails(species!, {
|
this.setSpeciesDetails(species!, {
|
||||||
// TODO: is this bang correct?
|
// TODO: is this bang correct?
|
||||||
@ -2534,6 +2543,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.pokemonNameText.setText(species ? "???" : "");
|
this.pokemonNameText.setText(species ? "???" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setting the category
|
||||||
|
if (isFormCaught) {
|
||||||
|
this.pokemonCategoryText.setText(species.category);
|
||||||
|
} else {
|
||||||
|
this.pokemonCategoryText.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
// Setting tint of the sprite
|
// Setting tint of the sprite
|
||||||
if (isFormCaught) {
|
if (isFormCaught) {
|
||||||
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
|
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { StockpilingTag } from "#app/data/battler-tags";
|
import { StockpilingTag } from "#app/data/battler-tags";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import { PokemonSummonData } from "#app/field/pokemon";
|
import { PokemonSummonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import * as messages from "#app/messages";
|
import * as messages from "#app/messages";
|
||||||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import type { PokemonTurnData, TurnMove } from "#app/field/pokemon";
|
import type { TurnMove } from "#app/@types/turn-move";
|
||||||
|
import type { PokemonTurnData } from "#app/data/pokemon/pokemon-data";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import { MoveResult } from "#enums/move-result";
|
import { MoveResult } from "#enums/move-result";
|
||||||
import type BattleScene from "#app/battle-scene";
|
import type BattleScene from "#app/battle-scene";
|
||||||
|
@ -5,7 +5,7 @@ import { PokeballType } from "#enums/pokeball";
|
|||||||
import type BattleScene from "#app/battle-scene";
|
import type BattleScene from "#app/battle-scene";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData } from "#app/data/pokemon/pokemon-data";
|
||||||
|
|
||||||
describe("Spec - Pokemon", () => {
|
describe("Spec - Pokemon", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
import { AbilityId } from "#enums/ability-id";
|
import { RandomMoveAttr } from "#app/data/moves/move";
|
||||||
|
import { MoveResult } from "#enums/move-result";
|
||||||
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
|
import { AbilityId } from "#app/enums/ability-id";
|
||||||
import { WeatherType } from "#enums/weather-type";
|
import { WeatherType } from "#enums/weather-type";
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
|
import i18next from "i18next";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
//import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
describe("Moves - Chilly Reception", () => {
|
describe("Moves - Chilly Reception", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -25,95 +28,121 @@ describe("Moves - Chilly Reception", () => {
|
|||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
game.override
|
game.override
|
||||||
.battleStyle("single")
|
.battleStyle("single")
|
||||||
.moveset([MoveId.CHILLY_RECEPTION, MoveId.SNOWSCAPE])
|
.moveset([MoveId.CHILLY_RECEPTION, MoveId.SNOWSCAPE, MoveId.SPLASH, MoveId.METRONOME])
|
||||||
.enemyMoveset(MoveId.SPLASH)
|
.enemyMoveset(MoveId.SPLASH)
|
||||||
.enemyAbility(AbilityId.BALL_FETCH)
|
.enemyAbility(AbilityId.BALL_FETCH)
|
||||||
.ability(AbilityId.BALL_FETCH);
|
.ability(AbilityId.BALL_FETCH);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should still change the weather if user can't switch out", async () => {
|
it("should display message before use, switch the user out and change the weather to snow", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||||
|
|
||||||
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||||
|
|
||||||
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
|
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||||
|
expect(slowking.isOnField()).toBe(false);
|
||||||
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||||
|
expect(game.textInterceptor.logs).toContain(
|
||||||
|
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should still change weather if user can't switch out", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
||||||
|
|
||||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||||
|
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should switch out even if it's snowing", async () => {
|
it("should still switch out even if weather cannot be changed", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||||
// first turn set up snow with snowscape, try chilly reception on second turn
|
|
||||||
|
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
||||||
|
|
||||||
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||||
|
|
||||||
game.move.select(MoveId.SNOWSCAPE);
|
game.move.select(MoveId.SNOWSCAPE);
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
||||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||||
game.doSelectPartyPokemon(1);
|
game.doSelectPartyPokemon(1);
|
||||||
|
// TODO: Uncomment lines once wimp out PR fixes force switches to not reset summon data immediately
|
||||||
|
// await game.phaseInterceptor.to("SwitchSummonPhase", false);
|
||||||
|
// expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH);
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||||
|
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||||
|
expect(slowking.isOnField()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("happy case - switch out and weather changes", async () => {
|
// Source: https://replay.pokemonshowdown.com/gen9ou-2367532550
|
||||||
|
it("should fail (while still displaying message) if neither weather change nor switch out succeeds", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
||||||
|
|
||||||
|
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
||||||
|
|
||||||
|
const slowking = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(MoveId.SNOWSCAPE);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
|
|
||||||
|
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||||
|
expect(game.scene.getPlayerPokemon()).toBe(slowking);
|
||||||
|
expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(game.textInterceptor.logs).toContain(
|
||||||
|
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should succeed without message if called indirectly", async () => {
|
||||||
|
vi.spyOn(RandomMoveAttr.prototype, "getMoveOverride").mockReturnValue(MoveId.CHILLY_RECEPTION);
|
||||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||||
|
|
||||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||||
game.doSelectPartyPokemon(1);
|
|
||||||
|
game.move.select(MoveId.METRONOME);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||||
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH);
|
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||||
|
expect(slowking.isOnField()).toBe(false);
|
||||||
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||||
|
expect(game.textInterceptor.logs).not.toContain(
|
||||||
|
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// enemy uses another move and weather doesn't change
|
// Bugcheck test for enemy AI bug
|
||||||
it("check case - enemy not selecting chilly reception doesn't change weather ", async () => {
|
it("check case - enemy not selecting chilly reception doesn't change weather", async () => {
|
||||||
game.override.battleStyle("single").enemyMoveset([MoveId.CHILLY_RECEPTION, MoveId.TACKLE]).moveset(MoveId.SPLASH);
|
game.override.enemyMoveset([MoveId.CHILLY_RECEPTION, MoveId.TACKLE]);
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH);
|
game.move.select(MoveId.SPLASH);
|
||||||
await game.move.selectEnemyMove(MoveId.TACKLE);
|
await game.move.selectEnemyMove(MoveId.TACKLE);
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
expect(game.scene.arena.weather?.weatherType).toBeUndefined();
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("enemy trainer - expected behavior ", async () => {
|
|
||||||
game.override
|
|
||||||
.battleStyle("single")
|
|
||||||
.startingWave(8)
|
|
||||||
.enemyMoveset(MoveId.CHILLY_RECEPTION)
|
|
||||||
.enemySpecies(SpeciesId.MAGIKARP)
|
|
||||||
.moveset([MoveId.SPLASH, MoveId.THUNDERBOLT]);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.JOLTEON]);
|
|
||||||
const RIVAL_MAGIKARP1 = game.scene.getEnemyPokemon()?.id;
|
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
||||||
expect(game.scene.getEnemyPokemon()?.id !== RIVAL_MAGIKARP1);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
||||||
game.move.select(MoveId.SPLASH);
|
|
||||||
|
|
||||||
// second chilly reception should still switch out
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
||||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
||||||
expect(game.scene.getEnemyPokemon()?.id === RIVAL_MAGIKARP1);
|
|
||||||
game.move.select(MoveId.THUNDERBOLT);
|
|
||||||
|
|
||||||
// enemy chilly recep move should fail: it's snowing and no option to switch out
|
|
||||||
// no crashing
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
||||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
||||||
game.move.select(MoveId.SPLASH);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BattlerIndex } from "#enums/battler-index";
|
import { BattlerIndex } from "#enums/battler-index";
|
||||||
import { allMoves } from "#app/data/data-lists";
|
import { allMoves } from "#app/data/data-lists";
|
||||||
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
||||||
import type { DamageCalculationResult } from "#app/field/pokemon";
|
import type { DamageCalculationResult } from "#app/@types/damage-result";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
|
@ -24,7 +24,7 @@ import { BerryModifier, PokemonBaseStatTotalModifier } from "#app/modifier/modif
|
|||||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||||
import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils";
|
import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData } from "#app/data/pokemon/pokemon-data";
|
||||||
import { CommandPhase } from "#app/phases/command-phase";
|
import { CommandPhase } from "#app/phases/command-phase";
|
||||||
import { MovePhase } from "#app/phases/move-phase";
|
import { MovePhase } from "#app/phases/move-phase";
|
||||||
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||||
|
Loading…
Reference in New Issue
Block a user