mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 09:02:47 +02:00
Compare commits
31 Commits
4186f845a7
...
f88f154b10
Author | SHA1 | Date | |
---|---|---|---|
|
f88f154b10 | ||
|
1ff2701964 | ||
|
1e306e25b5 | ||
|
43aa772603 | ||
|
8bc00ce182 | ||
|
6359bef13d | ||
|
b353890d77 | ||
|
b0d0e47c97 | ||
|
cf1292eb5b | ||
|
124383cb04 | ||
|
a3da9c590b | ||
|
c8308505a7 | ||
|
6d7d9010b7 | ||
|
537efd4334 | ||
|
69c11d8a2b | ||
|
a299a3be53 | ||
|
2404bd80e7 | ||
|
1c2cefea51 | ||
|
69bcbdcaa1 | ||
|
5531b3c5cd | ||
|
cd2c710937 | ||
|
8a9ff2818b | ||
|
b996624b03 | ||
|
5da3991e54 | ||
|
36d811e302 | ||
|
565e18fcb2 | ||
|
8c62ea2ab0 | ||
|
50bbfe85bd | ||
|
506f393112 | ||
|
cc6a13cce3 | ||
|
4dfcca1501 |
@ -894,9 +894,19 @@ export default class BattleScene extends SceneBase {
|
|||||||
return activeOnly ? this.infoToggles.filter(t => t?.isActive()) : this.infoToggles;
|
return activeOnly ? this.infoToggles.filter(t => t?.isActive()) : this.infoToggles;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPokemonById(pokemonId: number): Pokemon | null {
|
/**
|
||||||
const findInParty = (party: Pokemon[]) => party.find(p => p.id === pokemonId);
|
* Return the {@linkcode Pokemon} associated with a given ID.
|
||||||
return (findInParty(this.getPlayerParty()) || findInParty(this.getEnemyParty())) ?? null;
|
* @param pokemonId - The ID whose Pokemon will be retrieved.
|
||||||
|
* @returns The {@linkcode Pokemon} associated with the given id.
|
||||||
|
* Returns `null` if the ID is `undefined` or not present in either party.
|
||||||
|
*/
|
||||||
|
getPokemonById(pokemonId: number | undefined): Pokemon | null {
|
||||||
|
if (isNullOrUndefined(pokemonId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const party = (this.getPlayerParty() as Pokemon[]).concat(this.getEnemyParty());
|
||||||
|
return party.find(p => p.id === pokemonId) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerPokemon(
|
addPlayerPokemon(
|
||||||
|
@ -72,10 +72,11 @@ export abstract class ArenaTag {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function that retrieves the source Pokemon
|
* Helper function that retrieves the source Pokemon
|
||||||
* @returns The source {@linkcode Pokemon} or `null` if none is found
|
* @returns - The source {@linkcode Pokemon} for this tag.
|
||||||
|
* Returns `null` if `this.sourceId` is `undefined`
|
||||||
*/
|
*/
|
||||||
public getSourcePokemon(): Pokemon | null {
|
public getSourcePokemon(): Pokemon | null {
|
||||||
return this.sourceId ? globalScene.getPokemonById(this.sourceId) : null;
|
return globalScene.getPokemonById(this.sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,19 +108,22 @@ export class MistTag extends ArenaTag {
|
|||||||
onAdd(arena: Arena, quiet = false): void {
|
onAdd(arena: Arena, quiet = false): void {
|
||||||
super.onAdd(arena);
|
super.onAdd(arena);
|
||||||
|
|
||||||
if (this.sourceId) {
|
// We assume `quiet=true` means "just add the bloody tag no questions asked"
|
||||||
const source = globalScene.getPokemonById(this.sourceId);
|
if (quiet) {
|
||||||
|
return;
|
||||||
if (!quiet && source) {
|
|
||||||
globalScene.phaseManager.queueMessage(
|
|
||||||
i18next.t("arenaTag:mistOnAdd", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} else if (!quiet) {
|
|
||||||
console.warn("Failed to get source for MistTag onAdd");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for MistTag on add message; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
globalScene.phaseManager.queueMessage(
|
||||||
|
i18next.t("arenaTag:mistOnAdd", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -440,18 +444,18 @@ class MatBlockTag extends ConditionalProtectTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAdd(_arena: Arena) {
|
onAdd(_arena: Arena) {
|
||||||
if (this.sourceId) {
|
const source = this.getSourcePokemon();
|
||||||
const source = globalScene.getPokemonById(this.sourceId);
|
if (!source) {
|
||||||
if (source) {
|
console.warn(`Failed to get source Pokemon for Mat Block message; id: ${this.sourceId}`);
|
||||||
globalScene.phaseManager.queueMessage(
|
return;
|
||||||
i18next.t("arenaTag:matBlockOnAdd", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.warn("Failed to get source for MatBlockTag onAdd");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.onAdd(_arena);
|
||||||
|
globalScene.phaseManager.queueMessage(
|
||||||
|
i18next.t("arenaTag:matBlockOnAdd", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +515,12 @@ export class NoCritTag extends ArenaTag {
|
|||||||
|
|
||||||
/** Queues a message upon removing this effect from the field */
|
/** Queues a message upon removing this effect from the field */
|
||||||
onRemove(_arena: Arena): void {
|
onRemove(_arena: Arena): void {
|
||||||
const source = globalScene.getPokemonById(this.sourceId!); // TODO: is this bang correct?
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for NoCritTag on remove message; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("arenaTag:noCritOnRemove", {
|
i18next.t("arenaTag:noCritOnRemove", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(source ?? undefined),
|
pokemonNameWithAffix: getPokemonNameWithAffix(source ?? undefined),
|
||||||
@ -522,7 +531,7 @@ export class NoCritTag extends ArenaTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arena Tag class for {@link https://bulbapedia.bulbagarden.net/wiki/Wish_(move) Wish}.
|
* Arena Tag class for {@link https://bulbapedia.bulbagarden.net/wiki/Wish_(move) | Wish}.
|
||||||
* Heals the Pokémon in the user's position the turn after Wish is used.
|
* Heals the Pokémon in the user's position the turn after Wish is used.
|
||||||
*/
|
*/
|
||||||
class WishTag extends ArenaTag {
|
class WishTag extends ArenaTag {
|
||||||
@ -535,18 +544,20 @@ class WishTag extends ArenaTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAdd(_arena: Arena): void {
|
onAdd(_arena: Arena): void {
|
||||||
if (this.sourceId) {
|
const source = this.getSourcePokemon();
|
||||||
const user = globalScene.getPokemonById(this.sourceId);
|
if (!source) {
|
||||||
if (user) {
|
console.warn(`Failed to get source Pokemon for WishTag on add message; id: ${this.sourceId}`);
|
||||||
this.battlerIndex = user.getBattlerIndex();
|
return;
|
||||||
this.triggerMessage = i18next.t("arenaTag:wishTagOnAdd", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(user),
|
|
||||||
});
|
|
||||||
this.healHp = toDmgValue(user.getMaxHp() / 2);
|
|
||||||
} else {
|
|
||||||
console.warn("Failed to get source for WishTag onAdd");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.onAdd(_arena);
|
||||||
|
this.healHp = toDmgValue(source.getMaxHp() / 2);
|
||||||
|
|
||||||
|
globalScene.phaseManager.queueMessage(
|
||||||
|
i18next.t("arenaTag:wishTagOnAdd", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemove(_arena: Arena): void {
|
onRemove(_arena: Arena): void {
|
||||||
@ -741,15 +752,23 @@ class SpikesTag extends ArenaTrapTag {
|
|||||||
onAdd(arena: Arena, quiet = false): void {
|
onAdd(arena: Arena, quiet = false): void {
|
||||||
super.onAdd(arena);
|
super.onAdd(arena);
|
||||||
|
|
||||||
const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null;
|
// We assume `quiet=true` means "just add the bloody tag no questions asked"
|
||||||
if (!quiet && source) {
|
if (quiet) {
|
||||||
globalScene.phaseManager.queueMessage(
|
return;
|
||||||
i18next.t("arenaTag:spikesOnAdd", {
|
|
||||||
moveName: this.getMoveName(),
|
|
||||||
opponentDesc: source.getOpponentDescriptor(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for SpikesTag on add message; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
globalScene.phaseManager.queueMessage(
|
||||||
|
i18next.t("arenaTag:spikesOnAdd", {
|
||||||
|
moveName: this.getMoveName(),
|
||||||
|
opponentDesc: source.getOpponentDescriptor(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
override activateTrap(pokemon: Pokemon, simulated: boolean): boolean {
|
override activateTrap(pokemon: Pokemon, simulated: boolean): boolean {
|
||||||
@ -794,15 +813,23 @@ class ToxicSpikesTag extends ArenaTrapTag {
|
|||||||
onAdd(arena: Arena, quiet = false): void {
|
onAdd(arena: Arena, quiet = false): void {
|
||||||
super.onAdd(arena);
|
super.onAdd(arena);
|
||||||
|
|
||||||
const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null;
|
if (quiet) {
|
||||||
if (!quiet && source) {
|
// We assume `quiet=true` means "just add the bloody tag no questions asked"
|
||||||
globalScene.phaseManager.queueMessage(
|
return;
|
||||||
i18next.t("arenaTag:toxicSpikesOnAdd", {
|
|
||||||
moveName: this.getMoveName(),
|
|
||||||
opponentDesc: source.getOpponentDescriptor(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for ToxicSpikesTag on add message; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
globalScene.phaseManager.queueMessage(
|
||||||
|
i18next.t("arenaTag:toxicSpikesOnAdd", {
|
||||||
|
moveName: this.getMoveName(),
|
||||||
|
opponentDesc: source.getOpponentDescriptor(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemove(arena: Arena): void {
|
onRemove(arena: Arena): void {
|
||||||
@ -905,7 +932,11 @@ class StealthRockTag extends ArenaTrapTag {
|
|||||||
onAdd(arena: Arena, quiet = false): void {
|
onAdd(arena: Arena, quiet = false): void {
|
||||||
super.onAdd(arena);
|
super.onAdd(arena);
|
||||||
|
|
||||||
const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null;
|
if (quiet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
if (!quiet && source) {
|
if (!quiet && source) {
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("arenaTag:stealthRockOnAdd", {
|
i18next.t("arenaTag:stealthRockOnAdd", {
|
||||||
@ -989,15 +1020,24 @@ class StickyWebTag extends ArenaTrapTag {
|
|||||||
|
|
||||||
onAdd(arena: Arena, quiet = false): void {
|
onAdd(arena: Arena, quiet = false): void {
|
||||||
super.onAdd(arena);
|
super.onAdd(arena);
|
||||||
const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null;
|
|
||||||
if (!quiet && source) {
|
// We assume `quiet=true` means "just add the bloody tag no questions asked"
|
||||||
globalScene.phaseManager.queueMessage(
|
if (quiet) {
|
||||||
i18next.t("arenaTag:stickyWebOnAdd", {
|
return;
|
||||||
moveName: this.getMoveName(),
|
|
||||||
opponentDesc: source.getOpponentDescriptor(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for SpikesTag on add message; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
globalScene.phaseManager.queueMessage(
|
||||||
|
i18next.t("arenaTag:stickyWebOnAdd", {
|
||||||
|
moveName: this.getMoveName(),
|
||||||
|
opponentDesc: source.getOpponentDescriptor(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
override activateTrap(pokemon: Pokemon, simulated: boolean): boolean {
|
override activateTrap(pokemon: Pokemon, simulated: boolean): boolean {
|
||||||
@ -1061,14 +1101,20 @@ export class TrickRoomTag extends ArenaTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAdd(_arena: Arena): void {
|
onAdd(_arena: Arena): void {
|
||||||
const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null;
|
super.onAdd(_arena);
|
||||||
if (source) {
|
|
||||||
globalScene.phaseManager.queueMessage(
|
const source = this.getSourcePokemon();
|
||||||
i18next.t("arenaTag:trickRoomOnAdd", {
|
if (!source) {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
console.warn(`Failed to get source Pokemon for TrickRoomTag on add message; id: ${this.sourceId}`);
|
||||||
}),
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalScene.phaseManager.queueMessage(
|
||||||
|
i18next.t("arenaTag:trickRoomOnAdd", {
|
||||||
|
moveName: this.getMoveName(),
|
||||||
|
opponentDesc: source.getOpponentDescriptor(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemove(_arena: Arena): void {
|
onRemove(_arena: Arena): void {
|
||||||
@ -1115,6 +1161,13 @@ class TailwindTag extends ArenaTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAdd(_arena: Arena, quiet = false): void {
|
onAdd(_arena: Arena, quiet = false): void {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onAdd(_arena, quiet);
|
||||||
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t(
|
i18next.t(
|
||||||
@ -1123,15 +1176,14 @@ class TailwindTag extends ArenaTag {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const source = globalScene.getPokemonById(this.sourceId!); //TODO: this bang is questionable!
|
const field = source.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField();
|
||||||
const party = (source?.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField()) ?? [];
|
|
||||||
const phaseManager = globalScene.phaseManager;
|
|
||||||
|
|
||||||
for (const pokemon of party) {
|
for (const pokemon of field) {
|
||||||
// Apply the CHARGED tag to party members with the WIND_POWER ability
|
// Apply the CHARGED tag to party members with the WIND_POWER ability
|
||||||
|
// TODO: This should not be handled here
|
||||||
if (pokemon.hasAbility(AbilityId.WIND_POWER) && !pokemon.getTag(BattlerTagType.CHARGED)) {
|
if (pokemon.hasAbility(AbilityId.WIND_POWER) && !pokemon.getTag(BattlerTagType.CHARGED)) {
|
||||||
pokemon.addTag(BattlerTagType.CHARGED);
|
pokemon.addTag(BattlerTagType.CHARGED);
|
||||||
phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("abilityTriggers:windPowerCharged", {
|
i18next.t("abilityTriggers:windPowerCharged", {
|
||||||
pokemonName: getPokemonNameWithAffix(pokemon),
|
pokemonName: getPokemonNameWithAffix(pokemon),
|
||||||
moveName: this.getMoveName(),
|
moveName: this.getMoveName(),
|
||||||
@ -1142,9 +1194,16 @@ class TailwindTag extends ArenaTag {
|
|||||||
// Raise attack by one stage if party member has WIND_RIDER ability
|
// Raise attack by one stage if party member has WIND_RIDER ability
|
||||||
// TODO: Ability displays should be handled by the ability
|
// TODO: Ability displays should be handled by the ability
|
||||||
if (pokemon.hasAbility(AbilityId.WIND_RIDER)) {
|
if (pokemon.hasAbility(AbilityId.WIND_RIDER)) {
|
||||||
phaseManager.queueAbilityDisplay(pokemon, false, true);
|
globalScene.phaseManager.queueAbilityDisplay(pokemon, false, true);
|
||||||
phaseManager.unshiftNew("StatStageChangePhase", pokemon.getBattlerIndex(), true, [Stat.ATK], 1, true);
|
globalScene.phaseManager.unshiftNew(
|
||||||
phaseManager.queueAbilityDisplay(pokemon, false, false);
|
"StatStageChangePhase",
|
||||||
|
pokemon.getBattlerIndex(),
|
||||||
|
true,
|
||||||
|
[Stat.ATK],
|
||||||
|
1,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
globalScene.phaseManager.queueAbilityDisplay(pokemon, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1216,24 +1275,26 @@ class ImprisonTag extends ArenaTrapTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function applies the effects of Imprison to the opposing Pokemon already present on the field.
|
* Apply the effects of Imprison to all opposing on-field Pokemon.
|
||||||
* @param arena
|
|
||||||
*/
|
*/
|
||||||
override onAdd() {
|
override onAdd() {
|
||||||
const source = this.getSourcePokemon();
|
const source = this.getSourcePokemon();
|
||||||
if (source) {
|
if (!source) {
|
||||||
const party = this.getAffectedPokemon();
|
return;
|
||||||
party?.forEach((p: Pokemon) => {
|
|
||||||
if (p.isAllowedInBattle()) {
|
|
||||||
p.addTag(BattlerTagType.IMPRISON, 1, MoveId.IMPRISON, this.sourceId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
globalScene.phaseManager.queueMessage(
|
|
||||||
i18next.t("battlerTags:imprisonOnAdd", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const party = this.getAffectedPokemon();
|
||||||
|
party.forEach(p => {
|
||||||
|
if (p.isAllowedInBattle()) {
|
||||||
|
p.addTag(BattlerTagType.IMPRISON, 1, MoveId.IMPRISON, this.sourceId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
globalScene.phaseManager.queueMessage(
|
||||||
|
i18next.t("battlerTags:imprisonOnAdd", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1243,7 +1304,7 @@ class ImprisonTag extends ArenaTrapTag {
|
|||||||
*/
|
*/
|
||||||
override lapse(): boolean {
|
override lapse(): boolean {
|
||||||
const source = this.getSourcePokemon();
|
const source = this.getSourcePokemon();
|
||||||
return source ? source.isActive(true) : false;
|
return !!source?.isActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1265,9 +1326,7 @@ class ImprisonTag extends ArenaTrapTag {
|
|||||||
*/
|
*/
|
||||||
override onRemove(): void {
|
override onRemove(): void {
|
||||||
const party = this.getAffectedPokemon();
|
const party = this.getAffectedPokemon();
|
||||||
party?.forEach((p: Pokemon) => {
|
party.forEach(p => p.removeTag(BattlerTagType.IMPRISON));
|
||||||
p.removeTag(BattlerTagType.IMPRISON);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ export class BattlerTag {
|
|||||||
* @returns The source {@linkcode Pokemon}, or `null` if none is found
|
* @returns The source {@linkcode Pokemon}, or `null` if none is found
|
||||||
*/
|
*/
|
||||||
public getSourcePokemon(): Pokemon | null {
|
public getSourcePokemon(): Pokemon | null {
|
||||||
return this.sourceId ? globalScene.getPokemonById(this.sourceId) : null;
|
return globalScene.getPokemonById(this.sourceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,9 +540,13 @@ export class TrappedTag extends BattlerTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canAdd(pokemon: Pokemon): boolean {
|
canAdd(pokemon: Pokemon): boolean {
|
||||||
const source = globalScene.getPokemonById(this.sourceId!)!;
|
const source = this.getSourcePokemon();
|
||||||
const move = allMoves[this.sourceMove];
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for TrappedTag canAdd; id: ${this.sourceId}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const move = allMoves[this.sourceMove];
|
||||||
const isGhost = pokemon.isOfType(PokemonType.GHOST);
|
const isGhost = pokemon.isOfType(PokemonType.GHOST);
|
||||||
const isTrapped = pokemon.getTag(TrappedTag);
|
const isTrapped = pokemon.getTag(TrappedTag);
|
||||||
const hasSubstitute = move.hitsSubstitute(source, pokemon);
|
const hasSubstitute = move.hitsSubstitute(source, pokemon);
|
||||||
@ -763,12 +767,20 @@ export class DestinyBondTag extends BattlerTag {
|
|||||||
if (lapseType !== BattlerTagLapseType.CUSTOM) {
|
if (lapseType !== BattlerTagLapseType.CUSTOM) {
|
||||||
return super.lapse(pokemon, lapseType);
|
return super.lapse(pokemon, lapseType);
|
||||||
}
|
}
|
||||||
const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null;
|
|
||||||
if (!source?.isFainted()) {
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for DestinyBondTag lapse; id: ${this.sourceId}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destiny bond stays active until the user faints
|
||||||
|
if (!source.isFainted()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source?.getAlly() === pokemon) {
|
// Don't kill allies or opposing bosses.
|
||||||
|
if (source.getAlly() === pokemon) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,6 +793,7 @@ export class DestinyBondTag extends BattlerTag {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Drag the foe down with the user
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("battlerTags:destinyBondLapse", {
|
i18next.t("battlerTags:destinyBondLapse", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
@ -798,17 +811,13 @@ export class InfatuatedTag extends BattlerTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canAdd(pokemon: Pokemon): boolean {
|
canAdd(pokemon: Pokemon): boolean {
|
||||||
if (this.sourceId) {
|
const source = this.getSourcePokemon();
|
||||||
const pkm = globalScene.getPokemonById(this.sourceId);
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for InfatuatedTag canAdd; id: ${this.sourceId}`);
|
||||||
if (pkm) {
|
|
||||||
return pokemon.isOppositeGender(pkm);
|
|
||||||
}
|
|
||||||
console.warn("canAdd: this.sourceId is not a valid pokemon id!", this.sourceId);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
console.warn("canAdd: this.sourceId is undefined");
|
|
||||||
return false;
|
return pokemon.isOppositeGender(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
onAdd(pokemon: Pokemon): void {
|
onAdd(pokemon: Pokemon): void {
|
||||||
@ -817,7 +826,7 @@ export class InfatuatedTag extends BattlerTag {
|
|||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("battlerTags:infatuatedOnAdd", {
|
i18next.t("battlerTags:infatuatedOnAdd", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
sourcePokemonName: getPokemonNameWithAffix(this.getSourcePokemon()!), // Tag not added + console warns if no source
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -835,28 +844,36 @@ export class InfatuatedTag extends BattlerTag {
|
|||||||
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
const ret = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType);
|
const ret = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType);
|
||||||
|
|
||||||
const phaseManager = globalScene.phaseManager;
|
if (!ret) {
|
||||||
|
return false;
|
||||||
if (ret) {
|
|
||||||
phaseManager.queueMessage(
|
|
||||||
i18next.t("battlerTags:infatuatedLapse", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
|
||||||
sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
phaseManager.unshiftNew("CommonAnimPhase", pokemon.getBattlerIndex(), undefined, CommonAnim.ATTRACT);
|
|
||||||
|
|
||||||
if (pokemon.randBattleSeedInt(2)) {
|
|
||||||
phaseManager.queueMessage(
|
|
||||||
i18next.t("battlerTags:infatuatedLapseImmobilize", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
(phaseManager.getCurrentPhase() as MovePhase).cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for InfatuatedTag lapse; id: ${this.sourceId}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const phaseManager = globalScene.phaseManager;
|
||||||
|
phaseManager.queueMessage(
|
||||||
|
i18next.t("battlerTags:infatuatedLapse", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
|
sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
phaseManager.unshiftNew("CommonAnimPhase", pokemon.getBattlerIndex(), undefined, CommonAnim.ATTRACT);
|
||||||
|
|
||||||
|
// 50% chance to disrupt the target's action
|
||||||
|
if (pokemon.randBattleSeedInt(2)) {
|
||||||
|
phaseManager.queueMessage(
|
||||||
|
i18next.t("battlerTags:infatuatedLapseImmobilize", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
(phaseManager.getCurrentPhase() as MovePhase).cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemove(pokemon: Pokemon): void {
|
onRemove(pokemon: Pokemon): void {
|
||||||
@ -899,6 +916,12 @@ export class SeedTag extends BattlerTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAdd(pokemon: Pokemon): void {
|
onAdd(pokemon: Pokemon): void {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for SeedTag onAdd; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
super.onAdd(pokemon);
|
super.onAdd(pokemon);
|
||||||
|
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
@ -906,47 +929,51 @@ export class SeedTag extends BattlerTag {
|
|||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
this.sourceIndex = globalScene.getPokemonById(this.sourceId!)!.getBattlerIndex(); // TODO: are those bangs correct?
|
this.sourceIndex = source.getBattlerIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
const ret = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType);
|
const ret = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType);
|
||||||
|
|
||||||
if (ret) {
|
if (!ret) {
|
||||||
const source = pokemon.getOpponents().find(o => o.getBattlerIndex() === this.sourceIndex);
|
return false;
|
||||||
if (source) {
|
|
||||||
const cancelled = new BooleanHolder(false);
|
|
||||||
applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled);
|
|
||||||
|
|
||||||
if (!cancelled.value) {
|
|
||||||
globalScene.phaseManager.unshiftNew(
|
|
||||||
"CommonAnimPhase",
|
|
||||||
source.getBattlerIndex(),
|
|
||||||
pokemon.getBattlerIndex(),
|
|
||||||
CommonAnim.LEECH_SEED,
|
|
||||||
);
|
|
||||||
|
|
||||||
const damage = pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8), { result: HitResult.INDIRECT });
|
|
||||||
const reverseDrain = pokemon.hasAbilityWithAttr("ReverseDrainAbAttr", false);
|
|
||||||
globalScene.phaseManager.unshiftNew(
|
|
||||||
"PokemonHealPhase",
|
|
||||||
source.getBattlerIndex(),
|
|
||||||
!reverseDrain ? damage : damage * -1,
|
|
||||||
!reverseDrain
|
|
||||||
? i18next.t("battlerTags:seededLapse", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
|
||||||
})
|
|
||||||
: i18next.t("battlerTags:seededLapseShed", {
|
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
|
||||||
}),
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
// Check which opponent to restore HP to
|
||||||
|
const source = pokemon.getOpponents().find(o => o.getBattlerIndex() === this.sourceIndex);
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for SeedTag lapse; id: ${this.sourceId}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cancelled = new BooleanHolder(false);
|
||||||
|
applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled);
|
||||||
|
|
||||||
|
if (cancelled.value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
globalScene.phaseManager.unshiftNew(
|
||||||
|
"CommonAnimPhase",
|
||||||
|
source.getBattlerIndex(),
|
||||||
|
pokemon.getBattlerIndex(),
|
||||||
|
CommonAnim.LEECH_SEED,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Damage the target and restore our HP (or take damage in the case of liquid ooze)
|
||||||
|
const damage = pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8), { result: HitResult.INDIRECT });
|
||||||
|
const reverseDrain = pokemon.hasAbilityWithAttr("ReverseDrainAbAttr", false);
|
||||||
|
globalScene.phaseManager.unshiftNew(
|
||||||
|
"PokemonHealPhase",
|
||||||
|
source.getBattlerIndex(),
|
||||||
|
reverseDrain ? -damage : damage,
|
||||||
|
i18next.t(reverseDrain ? "battlerTags:seededLapseShed" : "battlerTags:seededLapse", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
|
}),
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDescriptor(): string {
|
getDescriptor(): string {
|
||||||
@ -1195,9 +1222,15 @@ export class HelpingHandTag extends BattlerTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAdd(pokemon: Pokemon): void {
|
onAdd(pokemon: Pokemon): void {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for HelpingHandTag onAdd; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("battlerTags:helpingHandOnAdd", {
|
i18next.t("battlerTags:helpingHandOnAdd", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
pokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
pokemonName: getPokemonNameWithAffix(pokemon),
|
pokemonName: getPokemonNameWithAffix(pokemon),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -1219,9 +1252,7 @@ export class IngrainTag extends TrappedTag {
|
|||||||
* @returns boolean True if the tag can be added, false otherwise
|
* @returns boolean True if the tag can be added, false otherwise
|
||||||
*/
|
*/
|
||||||
canAdd(pokemon: Pokemon): boolean {
|
canAdd(pokemon: Pokemon): boolean {
|
||||||
const isTrapped = pokemon.getTag(BattlerTagType.TRAPPED);
|
return !pokemon.getTag(BattlerTagType.TRAPPED);
|
||||||
|
|
||||||
return !isTrapped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
@ -1420,15 +1451,22 @@ export abstract class DamagingTrapTag extends TrappedTag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Condense all these tags into 1 singular tag with a modified message func
|
||||||
export class BindTag extends DamagingTrapTag {
|
export class BindTag extends DamagingTrapTag {
|
||||||
constructor(turnCount: number, sourceId: number) {
|
constructor(turnCount: number, sourceId: number) {
|
||||||
super(BattlerTagType.BIND, CommonAnim.BIND, turnCount, MoveId.BIND, sourceId);
|
super(BattlerTagType.BIND, CommonAnim.BIND, turnCount, MoveId.BIND, sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTrapMessage(pokemon: Pokemon): string {
|
getTrapMessage(pokemon: Pokemon): string {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for BindTag getTrapMessage; id: ${this.sourceId}`);
|
||||||
|
return "ERROR - CHECK CONSOLE AND REPORT";
|
||||||
|
}
|
||||||
|
|
||||||
return i18next.t("battlerTags:bindOnTrap", {
|
return i18next.t("battlerTags:bindOnTrap", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
sourcePokemonName: getPokemonNameWithAffix(source),
|
||||||
moveName: this.getMoveName(),
|
moveName: this.getMoveName(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1440,9 +1478,16 @@ export class WrapTag extends DamagingTrapTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTrapMessage(pokemon: Pokemon): string {
|
getTrapMessage(pokemon: Pokemon): string {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for WrapTag getTrapMessage; id: ${this.sourceId}`);
|
||||||
|
return "ERROR - CHECK CONSOLE AND REPORT";
|
||||||
|
}
|
||||||
|
|
||||||
return i18next.t("battlerTags:wrapOnTrap", {
|
return i18next.t("battlerTags:wrapOnTrap", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
sourcePokemonName: getPokemonNameWithAffix(source),
|
||||||
|
moveName: this.getMoveName(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1473,8 +1518,14 @@ export class ClampTag extends DamagingTrapTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTrapMessage(pokemon: Pokemon): string {
|
getTrapMessage(pokemon: Pokemon): string {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for ClampTag getTrapMessage; id: ${this.sourceId}`);
|
||||||
|
return "ERROR - CHECK CONSOLE AND REPORT ASAP";
|
||||||
|
}
|
||||||
|
|
||||||
return i18next.t("battlerTags:clampOnTrap", {
|
return i18next.t("battlerTags:clampOnTrap", {
|
||||||
sourcePokemonNameWithAffix: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
sourcePokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
pokemonName: getPokemonNameWithAffix(pokemon),
|
pokemonName: getPokemonNameWithAffix(pokemon),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1523,9 +1574,15 @@ export class ThunderCageTag extends DamagingTrapTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTrapMessage(pokemon: Pokemon): string {
|
getTrapMessage(pokemon: Pokemon): string {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for ThunderCageTag getTrapMessage; id: ${this.sourceId}`);
|
||||||
|
return "ERROR - PLEASE REPORT ASAP";
|
||||||
|
}
|
||||||
|
|
||||||
return i18next.t("battlerTags:thunderCageOnTrap", {
|
return i18next.t("battlerTags:thunderCageOnTrap", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
sourcePokemonNameWithAffix: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
sourcePokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1536,9 +1593,15 @@ export class InfestationTag extends DamagingTrapTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTrapMessage(pokemon: Pokemon): string {
|
getTrapMessage(pokemon: Pokemon): string {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for InfestationTag getTrapMessage; id: ${this.sourceId}`);
|
||||||
|
return "ERROR - CHECK CONSOLE AND REPORT";
|
||||||
|
}
|
||||||
|
|
||||||
return i18next.t("battlerTags:infestationOnTrap", {
|
return i18next.t("battlerTags:infestationOnTrap", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
sourcePokemonNameWithAffix: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct?
|
sourcePokemonNameWithAffix: getPokemonNameWithAffix(source),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2221,14 +2284,19 @@ export class SaltCuredTag extends BattlerTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAdd(pokemon: Pokemon): void {
|
onAdd(pokemon: Pokemon): void {
|
||||||
super.onAdd(pokemon);
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for SaltCureTag onAdd; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onAdd(pokemon);
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("battlerTags:saltCuredOnAdd", {
|
i18next.t("battlerTags:saltCuredOnAdd", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
this.sourceIndex = globalScene.getPokemonById(this.sourceId!)!.getBattlerIndex(); // TODO: are those bangs correct?
|
this.sourceIndex = source.getBattlerIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
@ -2281,8 +2349,14 @@ export class CursedTag extends BattlerTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAdd(pokemon: Pokemon): void {
|
onAdd(pokemon: Pokemon): void {
|
||||||
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for CursedTag onAdd; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
super.onAdd(pokemon);
|
super.onAdd(pokemon);
|
||||||
this.sourceIndex = globalScene.getPokemonById(this.sourceId!)!.getBattlerIndex(); // TODO: are those bangs correct?
|
this.sourceIndex = source.getBattlerIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
@ -2902,7 +2976,13 @@ export class SubstituteTag extends BattlerTag {
|
|||||||
|
|
||||||
/** Sets the Substitute's HP and queues an on-add battle animation that initializes the Substitute's sprite. */
|
/** Sets the Substitute's HP and queues an on-add battle animation that initializes the Substitute's sprite. */
|
||||||
onAdd(pokemon: Pokemon): void {
|
onAdd(pokemon: Pokemon): void {
|
||||||
this.hp = Math.floor(globalScene.getPokemonById(this.sourceId!)!.getMaxHp() / 4);
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for SubstituteTag onAdd; id: ${this.sourceId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.hp = Math.floor(source.getMaxHp() / 4);
|
||||||
this.sourceInFocus = false;
|
this.sourceInFocus = false;
|
||||||
|
|
||||||
// Queue battle animation and message
|
// Queue battle animation and message
|
||||||
@ -3182,13 +3262,14 @@ export class ImprisonTag extends MoveRestrictionBattlerTag {
|
|||||||
*/
|
*/
|
||||||
public override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
public override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
const source = this.getSourcePokemon();
|
const source = this.getSourcePokemon();
|
||||||
if (source) {
|
if (!source) {
|
||||||
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
|
console.warn(`Failed to get source Pokemon for ImprisonTag lapse; id: ${this.sourceId}`);
|
||||||
return super.lapse(pokemon, lapseType) && source.isActive(true);
|
return false;
|
||||||
}
|
|
||||||
return source.isActive(true);
|
|
||||||
}
|
}
|
||||||
return false;
|
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
|
||||||
|
return super.lapse(pokemon, lapseType) && source.isActive(true);
|
||||||
|
}
|
||||||
|
return source.isActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3248,12 +3329,20 @@ export class SyrupBombTag extends BattlerTag {
|
|||||||
* Applies the single-stage speed down to the target Pokemon and decrements the tag's turn count
|
* Applies the single-stage speed down to the target Pokemon and decrements the tag's turn count
|
||||||
* @param pokemon - The target {@linkcode Pokemon}
|
* @param pokemon - The target {@linkcode Pokemon}
|
||||||
* @param _lapseType - N/A
|
* @param _lapseType - N/A
|
||||||
* @returns `true` if the `turnCount` is still greater than `0`; `false` if the `turnCount` is `0` or the target or source Pokemon has been removed from the field
|
* @returns Whether the tag should persist (`turnsRemaining > 0` and source still on field)
|
||||||
*/
|
*/
|
||||||
override lapse(pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean {
|
override lapse(pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean {
|
||||||
if (this.sourceId && !globalScene.getPokemonById(this.sourceId)?.isActive(true)) {
|
const source = this.getSourcePokemon();
|
||||||
|
if (!source) {
|
||||||
|
console.warn(`Failed to get source Pokemon for SyrupBombTag lapse; id: ${this.sourceId}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Syrup bomb clears immediately if source leaves field/faints
|
||||||
|
if (!source.isActive(true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Custom message in lieu of an animation in mainline
|
// Custom message in lieu of an animation in mainline
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("battlerTags:syrupBombLapse", {
|
i18next.t("battlerTags:syrupBombLapse", {
|
||||||
@ -3270,7 +3359,7 @@ export class SyrupBombTag extends BattlerTag {
|
|||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
return --this.turnCount > 0;
|
return super.lapse(pokemon, _lapseType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +93,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 +1394,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;
|
||||||
@ -6870,12 +6887,12 @@ export class RandomMovesetMoveAttr extends CallMoveAttr {
|
|||||||
// includeParty will be true for Assist, false for Sleep Talk
|
// includeParty will be true for Assist, false for Sleep Talk
|
||||||
let allies: Pokemon[];
|
let allies: Pokemon[];
|
||||||
if (this.includeParty) {
|
if (this.includeParty) {
|
||||||
allies = user.isPlayer() ? globalScene.getPlayerParty().filter(p => p !== user) : globalScene.getEnemyParty().filter(p => p !== user);
|
allies = (user.isPlayer() ? globalScene.getPlayerParty() : globalScene.getEnemyParty()).filter(p => p !== user);
|
||||||
} else {
|
} else {
|
||||||
allies = [ user ];
|
allies = [ user ];
|
||||||
}
|
}
|
||||||
const partyMoveset = allies.map(p => p.moveset).flat();
|
const partyMoveset = allies.flatMap(p => p.moveset);
|
||||||
const moves = partyMoveset.filter(m => !this.invalidMoves.has(m!.moveId) && !m!.getMove().name.endsWith(" (N)"));
|
const moves = partyMoveset.filter(m => !this.invalidMoves.has(m.moveId) && !m.getMove().name.endsWith(" (N)"));
|
||||||
if (moves.length === 0) {
|
if (moves.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -11299,7 +11316,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)
|
||||||
|
@ -328,7 +328,7 @@ export const DancingLessonsEncounter: MysteryEncounter = MysteryEncounterBuilder
|
|||||||
.withOptionPhase(async () => {
|
.withOptionPhase(async () => {
|
||||||
// Show the Oricorio a dance, and recruit it
|
// Show the Oricorio a dance, and recruit it
|
||||||
const encounter = globalScene.currentBattle.mysteryEncounter!;
|
const encounter = globalScene.currentBattle.mysteryEncounter!;
|
||||||
const oricorio = encounter.misc.oricorioData.toPokemon();
|
const oricorio = encounter.misc.oricorioData.toPokemon() as EnemyPokemon;
|
||||||
oricorio.passive = true;
|
oricorio.passive = true;
|
||||||
|
|
||||||
// Ensure the Oricorio's moveset gains the Dance move the player used
|
// Ensure the Oricorio's moveset gains the Dance move the player used
|
||||||
|
@ -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 {
|
||||||
|
@ -4100,7 +4100,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
getTag<T extends BattlerTag>(tagType: Constructor<T>): T | undefined;
|
getTag<T extends BattlerTag>(tagType: Constructor<T>): T | undefined;
|
||||||
|
|
||||||
getTag(tagType: BattlerTagType | Constructor<BattlerTag>): BattlerTag | undefined {
|
getTag(tagType: BattlerTagType | Constructor<BattlerTag>): BattlerTag | undefined {
|
||||||
return tagType instanceof Function
|
return typeof tagType === "function"
|
||||||
? this.summonData.tags.find(t => t instanceof tagType)
|
? this.summonData.tags.find(t => t instanceof tagType)
|
||||||
: this.summonData.tags.find(t => t.tagType === tagType);
|
: this.summonData.tags.find(t => t.tagType === tagType);
|
||||||
}
|
}
|
||||||
|
@ -751,7 +751,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPokemon(): Pokemon | undefined {
|
getPokemon(): Pokemon | undefined {
|
||||||
return this.pokemonId ? (globalScene.getPokemonById(this.pokemonId) ?? undefined) : undefined;
|
return globalScene.getPokemonById(this.pokemonId) ?? undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
getScoreMultiplier(): number {
|
getScoreMultiplier(): number {
|
||||||
|
@ -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",
|
||||||
|
@ -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(() => {
|
||||||
|
@ -22,10 +22,7 @@ describe("Abilities - Unburden", () => {
|
|||||||
*/
|
*/
|
||||||
function getHeldItemCount(pokemon: Pokemon): number {
|
function getHeldItemCount(pokemon: Pokemon): number {
|
||||||
const stackCounts = pokemon.getHeldItems().map(m => m.getStackCount());
|
const stackCounts = pokemon.getHeldItems().map(m => m.getStackCount());
|
||||||
if (stackCounts.length) {
|
return stackCounts.reduce((a, b) => a + b, 0);
|
||||||
return stackCounts.reduce((a, b) => a + b);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
79
test/field/pokemon-id-checks.test.ts
Normal file
79
test/field/pokemon-id-checks.test.ts
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import type Pokemon from "#app/field/pokemon";
|
||||||
|
import { MoveId } from "#enums/move-id";
|
||||||
|
import { AbilityId } from "#enums/ability-id";
|
||||||
|
import { SpeciesId } from "#enums/species-id";
|
||||||
|
import { BattleType } from "#enums/battle-type";
|
||||||
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
import { BattlerIndex } from "#enums/battler-index";
|
||||||
|
|
||||||
|
describe("Field - Pokemon ID Checks", () => {
|
||||||
|
let phaserGame: Phaser.Game;
|
||||||
|
let game: GameManager;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
phaserGame = new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
game = new GameManager(phaserGame);
|
||||||
|
game.override
|
||||||
|
.ability(AbilityId.NO_GUARD)
|
||||||
|
.battleStyle("single")
|
||||||
|
.battleType(BattleType.TRAINER)
|
||||||
|
.criticalHits(false)
|
||||||
|
.enemyLevel(100)
|
||||||
|
.enemySpecies(SpeciesId.ARCANINE)
|
||||||
|
.enemyAbility(AbilityId.BALL_FETCH)
|
||||||
|
.enemyMoveset(MoveId.SPLASH);
|
||||||
|
});
|
||||||
|
|
||||||
|
function onlyUnique<T>(array: T[]): T[] {
|
||||||
|
return [...new Set<T>(array)];
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: We currently generate IDs as a pure random integer; enable once unique UUIDs are added
|
||||||
|
it.todo("2 Pokemon should not be able to generate with the same ID during 1 encounter", async () => {
|
||||||
|
game.override.battleType(BattleType.TRAINER); // enemy generates 2 mons
|
||||||
|
await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.ABRA]);
|
||||||
|
|
||||||
|
const ids = (game.scene.getPlayerParty() as Pokemon[]).concat(game.scene.getEnemyParty()).map((p: Pokemon) => p.id);
|
||||||
|
const uniqueIds = onlyUnique(ids);
|
||||||
|
|
||||||
|
expect(ids).toHaveLength(uniqueIds.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not prevent Battler Tags from triggering if user has PID of 0", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.TREECKO, SpeciesId.AERODACTYL]);
|
||||||
|
|
||||||
|
const player = game.field.getPlayerPokemon();
|
||||||
|
const enemy = game.field.getEnemyPokemon();
|
||||||
|
// Override player pokemon PID to be 0
|
||||||
|
player.id = 0;
|
||||||
|
expect(player.getTag(BattlerTagType.DESTINY_BOND)).toBeUndefined();
|
||||||
|
|
||||||
|
game.move.use(MoveId.DESTINY_BOND);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.move.forceEnemyMove(MoveId.FLAME_WHEEL);
|
||||||
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
|
await game.phaseInterceptor.to("MoveEndPhase");
|
||||||
|
|
||||||
|
const dBondTag = player.getTag(BattlerTagType.DESTINY_BOND)!;
|
||||||
|
expect(dBondTag).toBeDefined();
|
||||||
|
expect(dBondTag.sourceId).toBe(0);
|
||||||
|
expect(dBondTag.getSourcePokemon()).toBe(player);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to("MoveEndPhase");
|
||||||
|
|
||||||
|
expect(player.isFainted()).toBe(true);
|
||||||
|
expect(enemy.isFainted()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
@ -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);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user