This commit is contained in:
Bertie690 2024-11-11 23:50:50 -05:00
commit 1cc579ca41
160 changed files with 1528 additions and 735 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

View File

@ -1647,6 +1647,27 @@
"h": 25
}
},
{
"filename": "85-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 5,
"y": 3,
"w": 29,
"h": 25
},
"frame": {
"x": 55,
"y": 270,
"w": 29,
"h": 25
}
},
{
"filename": "22s",
"rotated": false,
@ -1731,6 +1752,27 @@
"h": 25
}
},
{
"filename": "85s-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 5,
"y": 3,
"w": 29,
"h": 25
},
"frame": {
"x": 56,
"y": 317,
"w": 29,
"h": 25
}
},
{
"filename": "9s",
"rotated": false,
@ -6456,6 +6498,27 @@
"h": 18
}
},
{
"filename": "84-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 9,
"y": 10,
"w": 21,
"h": 18
},
"frame": {
"x": 98,
"y": 712,
"w": 21,
"h": 18
}
},
{
"filename": "107",
"rotated": false,
@ -6519,6 +6582,27 @@
"h": 18
}
},
{
"filename": "84s-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 9,
"y": 10,
"w": 21,
"h": 18
},
"frame": {
"x": 96,
"y": 770,
"w": 21,
"h": 18
}
},
{
"filename": "88",
"rotated": false,

View File

@ -786,6 +786,27 @@
"h": 27
}
},
{
"filename": "154-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 8,
"y": 1,
"w": 23,
"h": 27
},
"frame": {
"x": 29,
"y": 147,
"w": 23,
"h": 27
}
},
{
"filename": "154s",
"rotated": false,
@ -807,6 +828,27 @@
"h": 27
}
},
{
"filename": "154s-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 8,
"y": 1,
"w": 23,
"h": 27
},
"frame": {
"x": 29,
"y": 174,
"w": 23,
"h": 27
}
},
{
"filename": "229-mega",
"rotated": false,

View File

@ -198,6 +198,27 @@
"h": 27
}
},
{
"filename": "257-f-mega",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 4,
"y": 2,
"w": 32,
"h": 27
},
"frame": {
"x": 0,
"y": 79,
"w": 32,
"h": 27
}
},
{
"filename": "257s-mega",
"rotated": false,
@ -219,6 +240,27 @@
"h": 27
}
},
{
"filename": "257s-f-mega",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 4,
"y": 2,
"w": 32,
"h": 27
},
"frame": {
"x": 0,
"y": 106,
"w": 32,
"h": 27
}
},
{
"filename": "323-mega",
"rotated": false,
@ -1248,6 +1290,27 @@
"h": 26
}
},
{
"filename": "257-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 7,
"y": 2,
"w": 25,
"h": 26
},
"frame": {
"x": 28,
"y": 556,
"w": 25,
"h": 26
}
},
{
"filename": "257s",
"rotated": false,
@ -1269,6 +1332,27 @@
"h": 26
}
},
{
"filename": "257s-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 7,
"y": 2,
"w": 25,
"h": 26
},
"frame": {
"x": 28,
"y": 582,
"w": 25,
"h": 26
}
},
{
"filename": "359-mega",
"rotated": false,
@ -1605,6 +1689,27 @@
"h": 25
}
},
{
"filename": "256-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 8,
"y": 3,
"w": 23,
"h": 25
},
"frame": {
"x": 98,
"y": 72,
"w": 23,
"h": 25
}
},
{
"filename": "282s-mega",
"rotated": false,
@ -5553,6 +5658,27 @@
"h": 19
}
},
{
"filename": "255-f",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 40,
"h": 30
},
"spriteSourceSize": {
"x": 13,
"y": 9,
"w": 13,
"h": 19
},
"frame": {
"x": 204,
"y": 342,
"w": 13,
"h": 19
}
},
{
"filename": "307s",
"rotated": false,

@ -1 +1 @@
Subproject commit fc4a1effd5170def3c8314208a52cd0d8e6913ef
Subproject commit d600913dbf1f8b47dae8dccbd8296df78f1c51b5

View File

@ -8,6 +8,7 @@ export class UpdateSessionSavedataRequest {
/** This is **NOT** similar to {@linkcode ClearSessionSavedataRequest} */
export interface NewClearSessionSavedataRequest {
slot: number;
isVictory: boolean;
clientSessionId: string;
}

View File

@ -5,7 +5,7 @@ import PokemonSpecies, { allSpecies, getPokemonSpecies, PokemonSpeciesFilter } f
import { Constructor, isNullOrUndefined, randSeedInt } from "#app/utils";
import * as Utils from "#app/utils";
import { ConsumableModifier, ConsumablePokemonModifier, DoubleBattleChanceBoosterModifier, ExpBalanceModifier, ExpShareModifier, FusePokemonModifier, HealingBoosterModifier, Modifier, ModifierBar, ModifierPredicate, MultipleParticipantExpBonusModifier, overrideHeldItems, overrideModifiers, PersistentModifier, PokemonExpBoosterModifier, PokemonFormChangeItemModifier, PokemonHeldItemModifier, PokemonHpRestoreModifier, PokemonIncrementingStatModifier, RememberMoveModifier, TerastallizeModifier, TurnHeldItemTransferModifier } from "./modifier/modifier";
import { PokeballType } from "#app/data/pokeball";
import { PokeballType } from "#enums/pokeball";
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from "#app/data/battle-anims";
import { Phase } from "#app/phase";
import { initGameSpeed } from "#app/system/game-speed";
@ -35,10 +35,11 @@ import { Gender } from "#app/data/gender";
import UIPlugin from "phaser3-rex-plugins/templates/ui/ui-plugin";
import { addUiThemeOverrides } from "#app/ui/ui-theme";
import PokemonData from "#app/system/pokemon-data";
import { Nature } from "#app/data/nature";
import { Nature } from "#enums/nature";
import { FormChangeItem, pokemonFormChanges, SpeciesFormChange, SpeciesFormChangeManualTrigger, SpeciesFormChangeTimeOfDayTrigger, SpeciesFormChangeTrigger } from "#app/data/pokemon-forms";
import { FormChangePhase } from "#app/phases/form-change-phase";
import { getTypeRgb, Type } from "#app/data/type";
import { getTypeRgb } from "#app/data/type";
import { Type } from "#enums/type";
import PokemonSpriteSparkleHandler from "#app/field/pokemon-sprite-sparkle-handler";
import CharSprite from "#app/ui/char-sprite";
import DamageNumberHandler from "#app/field/damage-number-handler";
@ -773,7 +774,7 @@ export default class BattleScene extends SceneBase {
/**
* @returns An array of {@linkcode PlayerPokemon} filtered from the player's party
* that are {@linkcode PlayerPokemon.isAllowedInBattle | allowed in battle}.
* that are {@linkcode Pokemon.isAllowedInBattle | allowed in battle}.
*/
public getPokemonAllowedInBattle(): PlayerPokemon[] {
return this.getPlayerParty().filter(p => p.isAllowedInBattle());
@ -1242,23 +1243,27 @@ export default class BattleScene extends SceneBase {
const lastBattle = this.currentBattle;
if (lastBattle?.double && !newDouble) {
this.tryRemovePhase(p => p instanceof SwitchPhase);
}
const maxExpLevel = this.getMaxExpLevel();
this.lastEnemyTrainer = lastBattle?.trainer ?? null;
this.lastMysteryEncounter = lastBattle?.mysteryEncounter;
if (newBattleType === BattleType.MYSTERY_ENCOUNTER) {
// Disable double battle on mystery encounters (it may be re-enabled as part of encounter)
newDouble = false;
}
if (lastBattle?.double && !newDouble) {
this.tryRemovePhase(p => p instanceof SwitchPhase);
this.getPlayerField().forEach(p => p.lapseTag(BattlerTagType.COMMANDED));
}
this.executeWithSeedOffset(() => {
this.currentBattle = new Battle(this.gameMode, newWaveIndex, newBattleType, newTrainer, newDouble);
}, newWaveIndex << 3, this.waveSeed);
this.currentBattle.incrementTurn(this);
if (newBattleType === BattleType.MYSTERY_ENCOUNTER) {
// Disable double battle on mystery encounters (it may be re-enabled as part of encounter)
this.currentBattle.double = false;
// Will generate the actual Mystery Encounter during NextEncounterPhase, to ensure it uses proper biome
this.currentBattle.mysteryEncounterType = mysteryEncounterType;
}
@ -2567,14 +2572,15 @@ export default class BattleScene extends SceneBase {
* The quantity to transfer is automatically capped at how much the recepient can take before reaching the maximum stack size for the item.
* A transfer that moves a quantity smaller than what is specified in the transferQuantity parameter is still considered successful.
* @param itemModifier {@linkcode PokemonHeldItemModifier} item to transfer (represents the whole stack)
* @param target {@linkcode Pokemon} pokemon recepient in this transfer
* @param playSound {boolean}
* @param transferQuantity {@linkcode integer} how many items of the stack to transfer. Optional, defaults to 1
* @param instant {boolean}
* @param ignoreUpdate {boolean}
* @returns true if the transfer was successful
* @param target {@linkcode Pokemon} recepient in this transfer
* @param playSound `true` to play a sound when transferring the item
* @param transferQuantity How many items of the stack to transfer. Optional, defaults to `1`
* @param instant ??? (Optional)
* @param ignoreUpdate ??? (Optional)
* @param itemLost If `true`, treat the item's current holder as losing the item (for now, this simply enables Unburden). Default is `true`.
* @returns `true` if the transfer was successful
*/
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, transferQuantity: integer = 1, instant?: boolean, ignoreUpdate?: boolean): Promise<boolean> {
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, transferQuantity: number = 1, instant?: boolean, ignoreUpdate?: boolean, itemLost: boolean = true): Promise<boolean> {
return new Promise(resolve => {
const source = itemModifier.pokemonId ? itemModifier.getPokemon(target.scene) : null;
const cancelled = new Utils.BooleanHolder(false);
@ -2607,14 +2613,14 @@ export default class BattleScene extends SceneBase {
if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) {
if (target.isPlayer()) {
this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => {
if (source) {
if (source && itemLost) {
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
}
resolve(true);
});
} else {
this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => {
if (source) {
if (source && itemLost) {
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
}
resolve(true);
@ -2786,7 +2792,15 @@ export default class BattleScene extends SceneBase {
});
}
removeModifier(modifier: PersistentModifier, enemy?: boolean): boolean {
/**
* Removes a currently owned item. If the item is stacked, the entire item stack
* gets removed. This function does NOT apply in-battle effects, such as Unburden.
* If in-battle effects are needed, use {@linkcode Pokemon.loseHeldItem} instead.
* @param modifier The item to be removed.
* @param enemy If `true`, remove an item owned by the enemy. If `false`, remove an item owned by the player. Default is `false`.
* @returns `true` if the item exists and was successfully removed, `false` otherwise.
*/
removeModifier(modifier: PersistentModifier, enemy: boolean = false): boolean {
const modifiers = !enemy ? this.modifiers : this.enemyModifiers;
const modifierIndex = modifiers.indexOf(modifier);
if (modifierIndex > -1) {

View File

@ -4,7 +4,7 @@ import * as Utils from "./utils";
import Trainer, { TrainerVariant } from "./field/trainer";
import { GameMode } from "./game-mode";
import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier";
import { PokeballType } from "./data/pokeball";
import { PokeballType } from "#enums/pokeball";
import { trainerConfigs } from "#app/data/trainer-config";
import { SpeciesFormKey } from "#enums/species-form-key";
import Pokemon, { EnemyPokemon, PlayerPokemon, QueuedMove } from "#app/field/pokemon";

View File

@ -1,13 +1,13 @@
import Pokemon, { EnemyPokemon, HitResult, MoveResult, PlayerPokemon, PokemonMove } from "../field/pokemon";
import { Type } from "./type";
import { Type } from "#enums/type";
import { Constructor } from "#app/utils";
import * as Utils from "../utils";
import { getPokemonNameWithAffix } from "../messages";
import { Weather, WeatherType } from "./weather";
import { Weather } from "#app/data/weather";
import { BattlerTag, BattlerTagLapseType, GroundedTag } from "./battler-tags";
import { StatusEffect, getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "./status-effect";
import { getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "#app/data/status-effect";
import { Gender } from "./gender";
import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, IncrementMovePriorityAttr, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, MoveAttr, MultiHitAttr, SacrificialAttr, SacrificialAttrOnHit, NeutralDamageAgainstFlyingTypeMultiplierAttr, FixedDamageAttr } from "./move";
import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, MoveAttr, MultiHitAttr, SacrificialAttr, SacrificialAttrOnHit, NeutralDamageAgainstFlyingTypeMultiplierAttr, FixedDamageAttr } from "./move";
import { ArenaTagSide, ArenaTrapTag } from "./arena-tag";
import { BerryModifier, HitHealModifier, PokemonHeldItemModifier } from "../modifier/modifier";
import { TerrainType } from "./terrain";
@ -36,6 +36,8 @@ import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { NewBattlePhase } from "#app/phases/new-battle-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { PokemonAnimType } from "#enums/pokemon-anim-type";
import { StatusEffect } from "#enums/status-effect";
import { WeatherType } from "#enums/weather-type";
export class Ability implements Localizable {
public id: Abilities;
@ -583,15 +585,11 @@ export class PostDefendAbAttr extends AbAttr {
export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr {
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const attackPriority = new Utils.IntegerHolder(move.priority);
applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, attackPriority);
applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, simulated, move, attackPriority);
if (move.moveTarget === MoveTarget.USER || move.moveTarget === MoveTarget.NEAR_ALLY) {
return false;
}
if (attackPriority.value > 0 && !move.isMultiTarget()) {
if (move.getPriority(attacker) > 0 && !move.isMultiTarget()) {
cancelled.value = true;
return true;
}
@ -2465,12 +2463,15 @@ export class PostSummonCopyAllyStatsAbAttr extends PostSummonAbAttr {
}
}
/**
* Used by Imposter
*/
export class PostSummonTransformAbAttr extends PostSummonAbAttr {
constructor() {
super(true);
}
async applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): Promise<boolean> {
async applyPostSummon(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): Promise<boolean> {
const targets = pokemon.getOpponents();
if (simulated || !targets.length) {
return simulated;
@ -2479,17 +2480,31 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
let target: Pokemon;
if (targets.length > 1) {
pokemon.scene.executeWithSeedOffset(() => target = Utils.randSeedItem(targets), pokemon.scene.currentBattle.waveIndex);
pokemon.scene.executeWithSeedOffset(() => {
// in a double battle, if one of the opposing pokemon is fused the other one will be chosen
// if both are fused, then Imposter will fail below
if (targets[0].fusionSpecies) {
target = targets[1];
return;
} else if (targets[1].fusionSpecies) {
target = targets[0];
return;
}
target = Utils.randSeedItem(targets);
}, pokemon.scene.currentBattle.waveIndex);
} else {
target = targets[0];
}
target = target!;
// transforming from or into fusion pokemon causes various problems (including crashes and save corruption)
if (target.fusionSpecies || pokemon.fusionSpecies) {
return false;
}
pokemon.summonData.speciesForm = target.getSpeciesForm();
pokemon.summonData.fusionSpeciesForm = target.getFusionSpeciesForm();
pokemon.summonData.ability = target.getAbility().id;
pokemon.summonData.gender = target.getGender();
pokemon.summonData.fusionGender = target.getFusionGender();
// Copy all stats (except HP)
for (const s of EFFECTIVE_STATS) {
@ -4137,7 +4152,7 @@ export class PostBattleLootAbAttr extends PostBattleAbAttr {
if (!simulated && postBattleLoot.length) {
const randItem = Utils.randSeedItem(postBattleLoot);
//@ts-ignore - TODO see below
if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true)) { // TODO: fix. This is a promise!?
if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true, undefined, false)) { // TODO: fix. This is a promise!?
postBattleLoot.splice(postBattleLoot.indexOf(randItem), 1);
pokemon.scene.queueMessage(i18next.t("abilityTriggers:postBattleLoot", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), itemName: randItem.type.name }));
return true;
@ -5601,7 +5616,9 @@ export function initAbilities() {
new Ability(Abilities.ANGER_POINT, 4)
.attr(PostDefendCritStatStageChangeAbAttr, Stat.ATK, 6),
new Ability(Abilities.UNBURDEN, 4)
.attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN),
.attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN)
.bypassFaint() // Allows reviver seed to activate Unburden
.edgeCase(), // Should not restore Unburden boost if Pokemon loses then regains Unburden ability
new Ability(Abilities.HEATPROOF, 4)
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
.attr(ReduceBurnDamageAbAttr, 0.5)

View File

@ -1,13 +1,13 @@
import { Arena } from "#app/field/arena";
import BattleScene from "#app/battle-scene";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { BooleanHolder, NumberHolder, toDmgValue } from "#app/utils";
import { MoveCategory, allMoves, MoveTarget, IncrementMovePriorityAttr, applyMoveAttrs } from "#app/data/move";
import { MoveCategory, allMoves, MoveTarget } from "#app/data/move";
import { getPokemonNameWithAffix } from "#app/messages";
import Pokemon, { HitResult, PokemonMove } from "#app/field/pokemon";
import { StatusEffect } from "#app/data/status-effect";
import { StatusEffect } from "#enums/status-effect";
import { BattlerIndex } from "#app/battle";
import { BlockNonDirectDamageAbAttr, ChangeMovePriorityAbAttr, InfiltratorAbAttr, ProtectStatAbAttr, applyAbAttrs } from "#app/data/ability";
import { BlockNonDirectDamageAbAttr, InfiltratorAbAttr, ProtectStatAbAttr, applyAbAttrs } from "#app/data/ability";
import { Stat } from "#enums/stat";
import { CommonAnim, CommonBattleAnim } from "#app/data/battle-anims";
import i18next from "i18next";
@ -318,17 +318,15 @@ export class ConditionalProtectTag extends ArenaTag {
*/
const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => {
const move = allMoves[moveId];
const priority = new NumberHolder(move.priority);
const effectPhase = arena.scene.getCurrentPhase();
if (effectPhase instanceof MoveEffectPhase) {
const attacker = effectPhase.getUserPokemon();
applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, priority);
if (attacker) {
applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, false, move, priority);
return move.getPriority(attacker) > 0;
}
}
return priority.value > 0;
return move.priority > 0;
};
/**

View File

@ -1,4 +1,4 @@
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import * as Utils from "#app/utils";
import { pokemonEvolutions, SpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions";
import i18next from "i18next";

View File

@ -1,10 +1,10 @@
import { Gender } from "#app/data/gender";
import { PokeballType } from "#app/data/pokeball";
import { PokeballType } from "#enums/pokeball";
import Pokemon from "#app/field/pokemon";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import * as Utils from "#app/utils";
import { WeatherType } from "#app/data/weather";
import { Nature } from "#app/data/nature";
import { WeatherType } from "#enums/weather-type";
import { Nature } from "#enums/nature";
import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
@ -1005,8 +1005,8 @@ export const pokemonEvolutions: PokemonEvolutions = {
new SpeciesEvolution(Species.COSMOEM, 23, null, null)
],
[Species.COSMOEM]: [
new SpeciesEvolution(Species.SOLGALEO, 53, EvolutionItem.SUN_FLUTE, null, SpeciesWildEvolutionDelay.VERY_LONG),
new SpeciesEvolution(Species.LUNALA, 53, EvolutionItem.MOON_FLUTE, null, SpeciesWildEvolutionDelay.VERY_LONG)
new SpeciesEvolution(Species.SOLGALEO, 1, EvolutionItem.SUN_FLUTE, null, SpeciesWildEvolutionDelay.VERY_LONG),
new SpeciesEvolution(Species.LUNALA, 1, EvolutionItem.MOON_FLUTE, null, SpeciesWildEvolutionDelay.VERY_LONG)
],
[Species.MELTAN]: [
new SpeciesEvolution(Species.MELMETAL, 48, null, null)

View File

@ -18,10 +18,9 @@ import Move, {
StatusCategoryOnAllyAttr
} from "#app/data/move";
import { SpeciesFormChangeManualTrigger } from "#app/data/pokemon-forms";
import { getStatusEffectHealText, StatusEffect } from "#app/data/status-effect";
import { getStatusEffectHealText } from "#app/data/status-effect";
import { TerrainType } from "#app/data/terrain";
import { Type } from "#app/data/type";
import { WeatherType } from "#app/data/weather";
import { Type } from "#enums/type";
import Pokemon, { HitResult, MoveResult } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import { CommonAnimPhase } from "#app/phases/common-anim-phase";
@ -38,6 +37,8 @@ import { Moves } from "#enums/moves";
import { PokemonAnimType } from "#enums/pokemon-anim-type";
import { Species } from "#enums/species";
import { EFFECTIVE_STATS, getStatKey, Stat, type BattleStat, type EffectiveStat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect";
import { WeatherType } from "#enums/weather-type";
export enum BattlerTagLapseType {
FAINT,
@ -909,11 +910,15 @@ export class FrenzyTag extends BattlerTag {
}
}
export class EncoreTag extends BattlerTag {
/**
* Applies the effects of the move Encore onto the target Pokemon
* Encore forces the target Pokemon to use its most-recent move for 3 turns
*/
export class EncoreTag extends MoveRestrictionBattlerTag {
public moveId: Moves;
constructor(sourceId: number) {
super(BattlerTagType.ENCORE, BattlerTagLapseType.AFTER_MOVE, 3, Moves.ENCORE, sourceId);
super(BattlerTagType.ENCORE, [ BattlerTagLapseType.CUSTOM, BattlerTagLapseType.AFTER_MOVE ], 3, Moves.ENCORE, sourceId);
}
/**
@ -969,6 +974,39 @@ export class EncoreTag extends BattlerTag {
}
}
/**
* If the encored move has run out of PP, Encore ends early. Otherwise, Encore lapses based on the AFTER_MOVE battler tag lapse type.
* @returns `true` to persist | `false` to end and be removed
*/
override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
if (lapseType === BattlerTagLapseType.CUSTOM) {
const encoredMove = pokemon.getMoveset().find(m => m?.moveId === this.moveId);
if (encoredMove && encoredMove?.getPpRatio() > 0) {
return true;
}
return false;
} else {
return super.lapse(pokemon, lapseType);
}
}
/**
* Checks if the move matches the moveId stored within the tag and returns a boolean value
* @param move {@linkcode Moves} the move selected
* @param user N/A
* @returns `true` if the move does not match with the moveId stored and as a result, restricted
*/
override isMoveRestricted(move: Moves, _user?: Pokemon): boolean {
if (move !== this.moveId) {
return true;
}
return false;
}
override selectionDeniedText(_pokemon: Pokemon, move: Moves): string {
return i18next.t("battle:moveDisabled", { moveName: allMoves[move].name });
}
onRemove(pokemon: Pokemon): void {
super.onRemove(pokemon);
@ -2360,7 +2398,7 @@ export class HealBlockTag extends MoveRestrictionBattlerTag {
}
/**
* Uses DisabledTag's selectionDeniedText() message
* Uses its own unique selectionDeniedText() message
*/
override selectionDeniedText(pokemon: Pokemon, move: Moves): string {
return i18next.t("battle:moveDisabledHealBlock", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name, healBlockName: allMoves[Moves.HEAL_BLOCK].name });

View File

@ -61,13 +61,13 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate {
}
}
export type BerryEffectFunc = (pokemon: Pokemon) => void;
export type BerryEffectFunc = (pokemon: Pokemon, berryOwner?: Pokemon) => void;
export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
switch (berryType) {
case BerryType.SITRUS:
case BerryType.ENIGMA:
return (pokemon: Pokemon) => {
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
if (pokemon.battleData) {
pokemon.battleData.berriesEaten.push(berryType);
}
@ -75,10 +75,10 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, hpHealed);
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(),
hpHealed.value, i18next.t("battle:hpHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), berryName: getBerryName(berryType) }), true));
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
};
case BerryType.LUM:
return (pokemon: Pokemon) => {
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
if (pokemon.battleData) {
pokemon.battleData.berriesEaten.push(berryType);
}
@ -87,14 +87,14 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
}
pokemon.resetStatus(true, true);
pokemon.updateInfo();
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
};
case BerryType.LIECHI:
case BerryType.GANLON:
case BerryType.PETAYA:
case BerryType.APICOT:
case BerryType.SALAC:
return (pokemon: Pokemon) => {
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
if (pokemon.battleData) {
pokemon.battleData.berriesEaten.push(berryType);
}
@ -103,18 +103,18 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
const statStages = new Utils.NumberHolder(1);
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, statStages);
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], statStages.value));
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
};
case BerryType.LANSAT:
return (pokemon: Pokemon) => {
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
if (pokemon.battleData) {
pokemon.battleData.berriesEaten.push(berryType);
}
pokemon.addTag(BattlerTagType.CRIT_BOOST);
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
};
case BerryType.STARF:
return (pokemon: Pokemon) => {
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
if (pokemon.battleData) {
pokemon.battleData.berriesEaten.push(berryType);
}
@ -122,10 +122,10 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
const stages = new Utils.NumberHolder(2);
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, stages);
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ randStat ], stages.value));
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
};
case BerryType.LEPPA:
return (pokemon: Pokemon) => {
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
if (pokemon.battleData) {
pokemon.battleData.berriesEaten.push(berryType);
}
@ -133,7 +133,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
if (ppRestoreMove !== undefined) {
ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0);
pokemon.scene.queueMessage(i18next.t("battle:ppHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: ppRestoreMove!.getName(), berryName: getBerryName(berryType) }));
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
}
};
}

View File

@ -7,11 +7,11 @@ import Pokemon, { PokemonMove } from "#app/field/pokemon";
import { BattleType, FixedBattleConfig } from "#app/battle";
import Trainer, { TrainerVariant } from "#app/field/trainer";
import { GameMode } from "#app/game-mode";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { Challenges } from "#enums/challenges";
import { Species } from "#enums/species";
import { TrainerType } from "#enums/trainer-type";
import { Nature } from "#app/data/nature";
import { Nature } from "#enums/nature";
import { Moves } from "#enums/moves";
import { TypeColor, TypeShadow } from "#enums/color";
import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";

View File

@ -1,5 +1,5 @@
import { Abilities } from "#enums/abilities";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { isNullOrUndefined } from "#app/utils";
import { Nature } from "#enums/nature";

View File

@ -2,13 +2,14 @@ import { ChargeAnim, initMoveAnim, loadMoveAnimAssets, MoveChargeAnim } from "./
import { CommandedTag, EncoreTag, GulpMissileTag, HelpingHandTag, SemiInvulnerableTag, ShellTrapTag, StockpilingTag, SubstituteTag, TrappedTag, TypeBoostTag } from "./battler-tags";
import { getPokemonNameWithAffix } from "../messages";
import Pokemon, { AttackMoveResult, EnemyPokemon, HitResult, MoveResult, PlayerPokemon, PokemonMove, TurnMove } from "../field/pokemon";
import { getNonVolatileStatusEffects, getStatusEffectHealText, isNonVolatileStatusEffect, StatusEffect } from "./status-effect";
import { getTypeDamageMultiplier, Type } from "./type";
import { getNonVolatileStatusEffects, getStatusEffectHealText, isNonVolatileStatusEffect } from "./status-effect";
import { getTypeDamageMultiplier } from "./type";
import { Type } from "#enums/type";
import { Constructor, NumberHolder } from "#app/utils";
import * as Utils from "../utils";
import { WeatherType } from "./weather";
import { WeatherType } from "#enums/weather-type";
import { ArenaTagSide, ArenaTrapTag, WeakenMoveTypeTag } from "./arena-tag";
import { allAbilities, AllyMoveCategoryPowerBoostAbAttr, applyAbAttrs, applyPostAttackAbAttrs, applyPostItemLostAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, BlockItemTheftAbAttr, BlockNonDirectDamageAbAttr, BlockOneHitKOAbAttr, BlockRecoilDamageAttr, ConfusionOnStatusEffectAbAttr, FieldMoveTypePowerBoostAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, HealFromBerryUseAbAttr, IgnoreContactAbAttr, IgnoreMoveEffectsAbAttr, IgnoreProtectOnContactAbAttr, InfiltratorAbAttr, MaxMultiHitAbAttr, MoveAbilityBypassAbAttr, MoveEffectChanceMultiplierAbAttr, MoveTypeChangeAbAttr, PostDamageForceSwitchAbAttr, PostItemLostAbAttr, ReverseDrainAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, UnswappableAbilityAbAttr, UserFieldMoveTypePowerBoostAbAttr, VariableMovePowerAbAttr, WonderSkinAbAttr } from "./ability";
import { allAbilities, AllyMoveCategoryPowerBoostAbAttr, applyAbAttrs, applyPostAttackAbAttrs, applyPostItemLostAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, BlockItemTheftAbAttr, BlockNonDirectDamageAbAttr, BlockOneHitKOAbAttr, BlockRecoilDamageAttr, ChangeMovePriorityAbAttr, ConfusionOnStatusEffectAbAttr, FieldMoveTypePowerBoostAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, HealFromBerryUseAbAttr, IgnoreContactAbAttr, IgnoreMoveEffectsAbAttr, IgnoreProtectOnContactAbAttr, InfiltratorAbAttr, MaxMultiHitAbAttr, MoveAbilityBypassAbAttr, MoveEffectChanceMultiplierAbAttr, MoveTypeChangeAbAttr, PostDamageForceSwitchAbAttr, PostItemLostAbAttr, ReverseDrainAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, UnswappableAbilityAbAttr, UserFieldMoveTypePowerBoostAbAttr, VariableMovePowerAbAttr, WonderSkinAbAttr } from "./ability";
import { AttackTypeBoosterModifier, BerryModifier, PokemonHeldItemModifier, PokemonMoveAccuracyBoosterModifier, PokemonMultiHitModifier, PreserveBerryModifier } from "../modifier/modifier";
import { BattlerIndex, BattleType } from "../battle";
import { TerrainType } from "./terrain";
@ -38,6 +39,7 @@ import { SpeciesFormChangeRevertWeatherFormTrigger } from "./pokemon-forms";
import { GameMode } from "#app/game-mode";
import { applyChallenges, ChallengeType } from "./challenge";
import { SwitchType } from "#enums/switch-type";
import { StatusEffect } from "enums/status-effect";
export enum MoveCategory {
PHYSICAL,
@ -829,6 +831,15 @@ export default class Move implements Localizable {
return power.value;
}
getPriority(user: Pokemon, simulated: boolean = true) {
const priority = new Utils.NumberHolder(this.priority);
applyMoveAttrs(IncrementMovePriorityAttr, user, null, this, priority);
applyAbAttrs(ChangeMovePriorityAbAttr, user, null, simulated, this, priority);
return priority.value;
}
}
export class AttackMove extends Move {
@ -2406,9 +2417,8 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
const removedItem = heldItems[user.randSeedInt(heldItems.length)];
// Decrease item amount and update icon
!--removedItem.stackCount;
target.loseHeldItem(removedItem);
target.scene.updateModifiers(target.isPlayer());
applyPostItemLostAbAttrs(PostItemLostAbAttr, target, false);
if (this.berriesOnly) {
@ -2478,18 +2488,15 @@ export class EatBerryAttr extends MoveEffectAttr {
}
reduceBerryModifier(target: Pokemon) {
if (this.chosenBerry?.stackCount === 1) {
target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
} else if (this.chosenBerry !== undefined && this.chosenBerry.stackCount > 1) {
this.chosenBerry.stackCount--;
if (this.chosenBerry) {
target.loseHeldItem(this.chosenBerry);
}
target.scene.updateModifiers(target.isPlayer());
}
eatBerry(consumer: Pokemon) {
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer); // consumer eats the berry
eatBerry(consumer: Pokemon, berryOwner?: Pokemon) {
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer, berryOwner); // consumer eats the berry
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new Utils.BooleanHolder(false));
applyPostItemLostAbAttrs(PostItemLostAbAttr, consumer, false);
}
}
@ -2529,7 +2536,7 @@ export class StealEatBerryAttr extends EatBerryAttr {
const message = i18next.t("battle:stealEatBerry", { pokemonName: user.name, targetName: target.name, berryName: this.chosenBerry.type.name });
user.scene.queueMessage(message);
this.reduceBerryModifier(target);
this.eatBerry(user);
this.eatBerry(user, target);
return true;
}
}
@ -6362,10 +6369,17 @@ export class RandomMovesetMoveAttr extends OverrideMoveEffectAttr {
}
export class RandomMoveAttr extends OverrideMoveEffectAttr {
/**
* This function exists solely to allow tests to override the randomly selected move by mocking this function.
*/
public getMoveOverride(): Moves | null {
return null;
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
return new Promise(resolve => {
const moveIds = Utils.getEnumValues(Moves).filter(m => !allMoves[m].hasFlag(MoveFlags.IGNORE_VIRTUAL) && !allMoves[m].name.endsWith(" (N)"));
const moveId = moveIds[user.randSeedInt(moveIds.length)];
const moveId = this.getMoveOverride() ?? moveIds[user.randSeedInt(moveIds.length)];
const moveTargets = getMoveTargets(user, moveId);
if (!moveTargets.targets.length) {
@ -6866,7 +6880,8 @@ export class SketchAttr extends MoveEffectAttr {
return false;
}
const targetMove = target.getMoveHistory().filter(m => !m.virtual).at(-1);
const targetMove = target.getLastXMoves(-1)
.find(m => m.move !== Moves.NONE && m.move !== Moves.STRUGGLE && !m.virtual);
if (!targetMove) {
return false;
}
@ -7094,6 +7109,9 @@ export class SuppressAbilitiesIfActedAttr extends MoveEffectAttr {
}
}
/**
* Used by Transform
*/
export class TransformAttr extends MoveEffectAttr {
async apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
if (!super.apply(user, target, move, args)) {
@ -7102,10 +7120,8 @@ export class TransformAttr extends MoveEffectAttr {
const promises: Promise<void>[] = [];
user.summonData.speciesForm = target.getSpeciesForm();
user.summonData.fusionSpeciesForm = target.getFusionSpeciesForm();
user.summonData.ability = target.getAbility().id;
user.summonData.gender = target.getGender();
user.summonData.fusionGender = target.getFusionGender();
// Power Trick's effect will not preserved after using Transform
user.removeTag(BattlerTagType.POWER_TRICK);
@ -7569,6 +7585,27 @@ export class FirstMoveCondition extends MoveCondition {
}
}
/**
* Condition used by the move {@link https://bulbapedia.bulbagarden.net/wiki/Upper_Hand_(move) | Upper Hand}.
* Moves with this condition are only successful when the target has selected
* a high-priority attack (after factoring in priority-boosting effects) and
* hasn't moved yet this turn.
*/
export class UpperHandCondition extends MoveCondition {
constructor() {
super((user, target, move) => {
const targetCommand = user.scene.currentBattle.turnCommands[target.getBattlerIndex()];
return !!targetCommand
&& targetCommand.command === Command.FIGHT
&& !target.turnData.acted
&& !!targetCommand.move?.move
&& allMoves[targetCommand.move.move].category !== MoveCategory.STATUS
&& allMoves[targetCommand.move.move].getPriority(target) > 0;
});
}
}
export class hitsSameTypeAttr extends VariableMoveTypeMultiplierAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const multiplier = args[0] as Utils.NumberHolder;
@ -8155,7 +8192,8 @@ export function initMoves() {
.ignoresVirtual(),
new StatusMove(Moves.TRANSFORM, Type.NORMAL, -1, 10, -1, 0, 1)
.attr(TransformAttr)
.condition((user, target, move) => !target.getTag(BattlerTagType.SUBSTITUTE))
// transforming from or into fusion pokemon causes various problems (such as crashes)
.condition((user, target, move) => !target.getTag(BattlerTagType.SUBSTITUTE) && !user.fusionSpecies && !target.fusionSpecies)
.ignoresProtect(),
new AttackMove(Moves.BUBBLE, Type.WATER, MoveCategory.SPECIAL, 40, 100, 30, 10, 0, 1)
.attr(StatStageChangeAttr, [ Stat.SPD ], -1)
@ -10686,8 +10724,7 @@ export function initMoves() {
.attr(AddBattlerTagAttr, BattlerTagType.HEAL_BLOCK, false, false, 2),
new AttackMove(Moves.UPPER_HAND, Type.FIGHTING, MoveCategory.PHYSICAL, 65, 100, 15, 100, 3, 9)
.attr(FlinchAttr)
.condition((user, target, move) => user.scene.currentBattle.turnCommands[target.getBattlerIndex()]?.command === Command.FIGHT && !target.turnData.acted && allMoves[user.scene.currentBattle.turnCommands[target.getBattlerIndex()]?.move?.move!].category !== MoveCategory.STATUS && allMoves[user.scene.currentBattle.turnCommands[target.getBattlerIndex()]?.move?.move!].priority > 0 ) // TODO: is this bang correct?
.partial(), // Should also apply when target move priority increased by ability ex. gale wings
.condition(new UpperHandCondition()),
new AttackMove(Moves.MALIGNANT_CHAIN, Type.POISON, MoveCategory.SPECIAL, 100, 100, 5, 50, 0, 9)
.attr(StatusEffectAttr, StatusEffect.TOXIC)
);

View File

@ -18,7 +18,7 @@ import { randInt } from "#app/utils";
import { BattlerIndex } from "#app/battle";
import { applyModifierTypeToPlayerPokemon, catchPokemon, getHighestLevelPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { TrainerSlot } from "#app/data/trainer-config";
import { PokeballType } from "#app/data/pokeball";
import { PokeballType } from "#enums/pokeball";
import HeldModifierConfig from "#app/interfaces/held-modifier-config";
import { BerryType } from "#enums/berry-type";
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";

View File

@ -36,7 +36,7 @@ import {
HeldItemRequirement,
TypeRequirement
} from "#app/data/mystery-encounters/mystery-encounter-requirements";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { AttackTypeBoosterModifierType, ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type";
import {
AttackTypeBoosterModifier,
@ -477,12 +477,9 @@ export const BugTypeSuperfanEncounter: MysteryEncounter =
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter!;
const modifier = encounter.misc.chosenModifier;
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
// Remove the modifier if its stacks go to 0
modifier.stackCount -= 1;
if (modifier.stackCount === 0) {
scene.removeModifier(modifier);
}
chosenPokemon.loseHeldItem(modifier, false);
scene.updateModifiers(true, true);
const bugNet = generateModifierTypeOption(scene, modifierTypes.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET)!;

View File

@ -12,7 +12,7 @@ import { TrainerType } from "#enums/trainer-type";
import { getPokemonSpecies } from "#app/data/pokemon-species";
import { Abilities } from "#enums/abilities";
import { applyAbilityOverrideToPokemon, applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import { randSeedInt, randSeedShuffle } from "#app/utils";

View File

@ -1,4 +1,4 @@
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { isNullOrUndefined, randSeedInt } from "#app/utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";

View File

@ -8,7 +8,7 @@ import { applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/u
import { getPokemonSpecies } from "#app/data/pokemon-species";
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PreserveBerryModifier } from "#app/modifier/modifier";
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PokemonInstantReviveModifier, PreserveBerryModifier } from "#app/modifier/modifier";
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
import i18next from "#app/plugins/i18n";
@ -197,7 +197,8 @@ export const DelibirdyEncounter: MysteryEncounter =
})
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter!;
const modifier: BerryModifier | HealingBoosterModifier = encounter.misc.chosenModifier;
const modifier: BerryModifier | PokemonInstantReviveModifier = encounter.misc.chosenModifier;
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
// Give the player a Candy Jar if they gave a Berry, and a Berry Pouch for Reviver Seed
if (modifier instanceof BerryModifier) {
@ -228,11 +229,7 @@ export const DelibirdyEncounter: MysteryEncounter =
}
}
// Remove the modifier if its stacks go to 0
modifier.stackCount -= 1;
if (modifier.stackCount === 0) {
scene.removeModifier(modifier);
}
chosenPokemon.loseHeldItem(modifier, false);
leaveEncounterWithoutBattle(scene, true);
})
@ -292,6 +289,7 @@ export const DelibirdyEncounter: MysteryEncounter =
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter!;
const modifier = encounter.misc.chosenModifier;
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
// Check if the player has max stacks of Healing Charm already
const existing = scene.findModifier(m => m instanceof HealingBoosterModifier) as HealingBoosterModifier;
@ -306,11 +304,7 @@ export const DelibirdyEncounter: MysteryEncounter =
scene.unshiftPhase(new ModifierRewardPhase(scene, modifierTypes.HEALING_CHARM));
}
// Remove the modifier if its stacks go to 0
modifier.stackCount -= 1;
if (modifier.stackCount === 0) {
scene.removeModifier(modifier);
}
chosenPokemon.loseHeldItem(modifier, false);
leaveEncounterWithoutBattle(scene, true);
})

View File

@ -8,14 +8,14 @@ import { AbilityRequirement, CombinationPokemonRequirement, TypeRequirement } fr
import { Species } from "#enums/species";
import { getPokemonSpecies } from "#app/data/pokemon-species";
import { Gender } from "#app/data/gender";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { BattlerIndex } from "#app/battle";
import Pokemon, { PokemonMove } from "#app/field/pokemon";
import { Moves } from "#enums/moves";
import { EncounterBattleAnim } from "#app/data/battle-anims";
import { WeatherType } from "#app/data/weather";
import { WeatherType } from "#enums/weather-type";
import { isNullOrUndefined, randSeedInt } from "#app/utils";
import { StatusEffect } from "#app/data/status-effect";
import { StatusEffect } from "#enums/status-effect";
import { queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { applyAbilityOverrideToPokemon, applyDamageToPokemon, applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";

View File

@ -305,7 +305,7 @@ async function showWobbuffetHealthBar(scene: BattleScene) {
scene.field.add(wobbuffet);
const playerPokemon = scene.getPlayerPokemon() as Pokemon;
if (playerPokemon?.visible) {
if (playerPokemon?.isOnField()) {
scene.field.moveBelow(wobbuffet, playerPokemon);
}
// Show health bar and trigger cry

View File

@ -21,11 +21,12 @@ import PokemonData from "#app/system/pokemon-data";
import i18next from "i18next";
import { Gender, getGenderSymbol } from "#app/data/gender";
import { getNatureName } from "#app/data/nature";
import { getPokeballAtlasKey, getPokeballTintColor, PokeballType } from "#app/data/pokeball";
import { getPokeballAtlasKey, getPokeballTintColor } from "#app/data/pokeball";
import { getEncounterText, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { trainerNamePools } from "#app/data/trainer-names";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
import { addPokemonDataToDexAndValidateAchievements } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import type { PokeballType } from "#enums/pokeball";
/** the i18n namespace for the encounter */
const namespace = "mysteryEncounters/globalTradeSystem";
@ -344,6 +345,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
// Pokemon and item selected
encounter.setDialogueToken("chosenItem", modifier.type.name);
encounter.misc.chosenModifier = modifier;
encounter.misc.chosenPokemon = pokemon;
return true;
},
};
@ -369,6 +371,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
const encounter = scene.currentBattle.mysteryEncounter!;
const modifier = encounter.misc.chosenModifier as PokemonHeldItemModifier;
const party = scene.getPlayerParty();
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
// Check tier of the traded item, the received item will be one tier up
const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party);
@ -396,11 +399,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
encounter.setDialogueToken("itemName", item.type.name);
setEncounterRewards(scene, { guaranteedModifierTypeOptions: [ item ], fillRemaining: false });
// Remove the chosen modifier if its stacks go to 0
modifier.stackCount -= 1;
if (modifier.stackCount === 0) {
scene.removeModifier(modifier);
}
chosenPokemon.loseHeldItem(modifier, false);
await scene.updateModifiers(true, true);
// Generate a trainer name

View File

@ -6,7 +6,7 @@ import MysteryEncounterOption, { MysteryEncounterOptionBuilder } from "#app/data
import { TrainerSlot } from "#app/data/trainer-config";
import { HiddenAbilityRateBoosterModifier, IvScannerModifier } from "#app/modifier/modifier";
import { EnemyPokemon } from "#app/field/pokemon";
import { PokeballType } from "#app/data/pokeball";
import { PokeballType } from "#enums/pokeball";
import { PlayerGender } from "#enums/player-gender";
import { IntegerHolder, randSeedInt } from "#app/utils";
import { getPokemonSpecies } from "#app/data/pokemon-species";

View File

@ -3,7 +3,7 @@ import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifi
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import BattleScene from "#app/battle-scene";
import { StatusEffect } from "#app/data/status-effect";
import { StatusEffect } from "#enums/status-effect";
import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import { MoveRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements";

View File

@ -12,7 +12,7 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import { Biome } from "#enums/biome";
import { getBiomeKey } from "#app/field/arena";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { getPartyLuckValue, modifierTypes } from "#app/modifier/modifier-type";
import { TrainerSlot } from "#app/data/trainer-config";
import { BattlerTagType } from "#enums/battler-tag-type";

View File

@ -23,7 +23,7 @@ import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/myst
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import { achvs } from "#app/system/achv";
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { getPokeballTintColor } from "#app/data/pokeball";
import { PokemonHeldItemModifier } from "#app/modifier/modifier";

View File

@ -8,7 +8,7 @@ import { catchPokemon, getRandomSpeciesByStarterTier, getSpriteKeysFromPokemon }
import { getPokemonSpecies } from "#app/data/pokemon-species";
import { speciesStarterCosts } from "#app/data/balance/starters";
import { Species } from "#enums/species";
import { PokeballType } from "#app/data/pokeball";
import { PokeballType } from "#enums/pokeball";
import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import { showEncounterDialogue } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";

View File

@ -5,7 +5,7 @@ import BattleScene from "#app/battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter";
import { getPokemonSpecies } from "#app/data/pokemon-species";
import { Species } from "#enums/species";
import { Nature } from "#app/data/nature";
import { Nature } from "#enums/nature";
import Pokemon, { PokemonMove } from "#app/field/pokemon";
import { queueEncounterMessage, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
import { modifyPlayerPokemonBST } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";

View File

@ -10,7 +10,7 @@ import { Abilities } from "#enums/abilities";
import { getPokemonSpecies } from "#app/data/pokemon-species";
import { Moves } from "#enums/moves";
import { Nature } from "#enums/nature";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { BerryType } from "#enums/berry-type";
import { Stat } from "#enums/stat";
import { SpeciesFormChangeManualTrigger } from "#app/data/pokemon-forms";

View File

@ -1,6 +1,6 @@
import { Ability, allAbilities } from "#app/data/ability";
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { getNatureName, Nature } from "#app/data/nature";
import { getNatureName } from "#app/data/nature";
import { speciesStarterCosts } from "#app/data/balance/starters";
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
import { PokemonHeldItemModifier } from "#app/modifier/modifier";
@ -21,6 +21,7 @@ import i18next from "i18next";
import { getStatKey } from "#enums/stat";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
import { isPokemonValidForEncounterOptionSelection } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import type { Nature } from "#enums/nature";
/** The i18n namespace for the encounter */
const namespace = "mysteryEncounters/trainingSession";

View File

@ -1,4 +1,4 @@
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species";
import BattleScene from "#app/battle-scene";
@ -312,6 +312,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
pokemon.levelExp = 0;
pokemon.calculateStats();
pokemon.getBattleInfo().setLevel(pokemon.level);
await pokemon.updateInfo();
}

View File

@ -2,7 +2,7 @@ import { OptionTextDisplay } from "#app/data/mystery-encounters/mystery-encounte
import { Moves } from "#app/enums/moves";
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
import BattleScene from "#app/battle-scene";
import { Type } from "../type";
import { Type } from "#enums/type";
import { EncounterPokemonRequirement, EncounterSceneRequirement, MoneyRequirement, TypeRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements";
import { CanLearnMoveRequirement, CanLearnMoveRequirementOptions } from "./requirements/can-learn-move-requirement";
import { isNullOrUndefined, randSeedInt } from "#app/utils";

View File

@ -1,11 +1,11 @@
import BattleScene from "#app/battle-scene";
import { allAbilities } from "#app/data/ability";
import { EvolutionItem, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
import { Nature } from "#app/data/nature";
import { Nature } from "#enums/nature";
import { FormChangeItem, pokemonFormChanges, SpeciesFormChangeItemTrigger } from "#app/data/pokemon-forms";
import { StatusEffect } from "#app/data/status-effect";
import { Type } from "#app/data/type";
import { WeatherType } from "#app/data/weather";
import { StatusEffect } from "#enums/status-effect";
import { Type } from "#enums/type";
import { WeatherType } from "#enums/weather-type";
import { PlayerPokemon } from "#app/field/pokemon";
import { AttackTypeBoosterModifier } from "#app/modifier/modifier";
import { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type";

View File

@ -5,7 +5,7 @@ import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import BattleScene from "#app/battle-scene";
import MysteryEncounterIntroVisuals, { MysteryEncounterSpriteConfig } from "#app/field/mystery-encounter-intro";
import * as Utils from "#app/utils";
import { StatusEffect } from "../status-effect";
import { StatusEffect } from "#enums/status-effect";
import MysteryEncounterDialogue, { OptionTextDisplay } from "./mystery-encounter-dialogue";
import MysteryEncounterOption, { MysteryEncounterOptionBuilder, OptionPhaseCallback } from "./mystery-encounter-option";
import { EncounterPokemonRequirement, EncounterSceneRequirement, HealthRatioRequirement, PartySizeRequirement, StatusEffectRequirement, WaveRangeRequirement } from "./mystery-encounter-requirements";

View File

@ -19,11 +19,11 @@ import i18next from "i18next";
import BattleScene from "#app/battle-scene";
import Trainer, { TrainerVariant } from "#app/field/trainer";
import { Gender } from "#app/data/gender";
import { Nature } from "#app/data/nature";
import { Nature } from "#enums/nature";
import { Moves } from "#enums/moves";
import { initMoveAnim, loadMoveAnimAssets } from "#app/data/battle-anims";
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { Status, StatusEffect } from "#app/data/status-effect";
import { Status } from "#app/data/status-effect";
import { TrainerConfig, trainerConfigs, TrainerSlot } from "#app/data/trainer-config";
import PokemonSpecies from "#app/data/pokemon-species";
import { Egg, IEggOptions } from "#app/data/egg";
@ -37,6 +37,7 @@ import { GameOverPhase } from "#app/phases/game-over-phase";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import { PartyExpPhase } from "#app/phases/party-exp-phase";
import { Variant } from "#app/data/variant";
import { StatusEffect } from "#enums/status-effect";
/**
* Animates exclamation sprite over trainer's head at start of encounter

View File

@ -3,15 +3,15 @@ import i18next from "i18next";
import { isNullOrUndefined, randSeedInt } from "#app/utils";
import { PokemonHeldItemModifier } from "#app/modifier/modifier";
import Pokemon, { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "#app/data/pokeball";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor } from "#app/data/pokeball";
import { PlayerGender } from "#enums/player-gender";
import { addPokeballCaptureStars, addPokeballOpenParticles } from "#app/field/anims";
import { getStatusEffectCatchRateMultiplier, StatusEffect } from "#app/data/status-effect";
import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect";
import { achvs } from "#app/system/achv";
import { Mode } from "#app/ui/ui";
import { PartyOption, PartyUiMode } from "#app/ui/party-ui-handler";
import { Species } from "#enums/species";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species";
import { speciesStarterCosts } from "#app/data/balance/starters";
import { getEncounterText, queueEncounterMessage, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
@ -23,6 +23,8 @@ import { VictoryPhase } from "#app/phases/victory-phase";
import { SummaryUiMode } from "#app/ui/summary-ui-handler";
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
import { Abilities } from "#enums/abilities";
import type { PokeballType } from "#enums/pokeball";
import { StatusEffect } from "#enums/status-effect";
/** Will give +1 level every 10 waves */
export const STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER = 1;

View File

@ -3,9 +3,7 @@ import { TextStyle, getBBCodeFrag } from "../ui/text";
import { Nature } from "#enums/nature";
import { UiTheme } from "#enums/ui-theme";
import i18next from "i18next";
import { Stat, EFFECTIVE_STATS, getShortenedStatKey } from "#app/enums/stat";
export { Nature };
import { Stat, EFFECTIVE_STATS, getShortenedStatKey } from "#enums/stat";
export function getNatureName(nature: Nature, includeStatEffects: boolean = false, forStarterSelect: boolean = false, ignoreBBCode: boolean = false, uiTheme: UiTheme = UiTheme.DEFAULT): string {
let ret = Utils.toReadableString(Nature[nature]);

View File

@ -1,10 +1,9 @@
import { CriticalCatchChanceBoosterModifier } from "#app/modifier/modifier";
import { NumberHolder } from "#app/utils";
import { PokeballType } from "#enums/pokeball";
import BattleScene from "../battle-scene";
import i18next from "i18next";
export { PokeballType };
export const MAX_PER_TYPE_POKEBALLS: integer = 99;
export function getPokeballAtlasKey(type: PokeballType): string {
@ -96,7 +95,7 @@ export function getCriticalCaptureChance(scene: BattleScene, modifiedCatchRate:
}
const dexCount = scene.gameData.getSpeciesCount(d => !!d.caughtAttr);
const catchingCharmMultiplier = new NumberHolder(1);
//scene.findModifier(m => m instanceof CriticalCatchChanceBoosterModifier)?.apply(catchingCharmMultiplier);
scene.findModifier(m => m instanceof CriticalCatchChanceBoosterModifier)?.apply(catchingCharmMultiplier);
const dexMultiplier = scene.gameMode.isDaily || dexCount > 800 ? 2.5
: dexCount > 600 ? 2
: dexCount > 400 ? 1.5

View File

@ -1,8 +1,8 @@
import { PokemonFormChangeItemModifier, TerastallizeModifier } from "../modifier/modifier";
import Pokemon from "../field/pokemon";
import { StatusEffect } from "./status-effect";
import { StatusEffect } from "#enums/status-effect";
import { MoveCategory, allMoves } from "./move";
import { Type } from "./type";
import { Type } from "#enums/type";
import { Constructor, nil } from "#app/utils";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
@ -10,7 +10,7 @@ import { Species } from "#enums/species";
import { TimeOfDay } from "#enums/time-of-day";
import { getPokemonNameWithAffix } from "#app/messages";
import i18next from "i18next";
import { WeatherType } from "./weather";
import { WeatherType } from "#enums/weather-type";
import { Challenges } from "#app/enums/challenges";
import { SpeciesFormKey } from "#enums/species-form-key";

View File

@ -12,7 +12,7 @@ import { uncatchableSpecies } from "#app/data/balance/biomes";
import { speciesEggMoves } from "#app/data/balance/egg-moves";
import { GrowthRate } from "#app/data/exp";
import { EvolutionLevel, SpeciesWildEvolutionDelay, pokemonEvolutions, pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { LevelMoves, pokemonFormLevelMoves, pokemonFormLevelMoves as pokemonSpeciesFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves";
import { Stat } from "#enums/stat";
import { Variant, VariantSet, variantColorCache, variantData } from "#app/data/variant";
@ -363,6 +363,12 @@ export abstract class PokemonSpeciesForm {
}
switch (this.speciesId) {
case Species.DODUO:
case Species.DODRIO:
case Species.MEGANIUM:
case Species.TORCHIC:
case Species.COMBUSKEN:
case Species.BLAZIKEN:
case Species.HIPPOPOTAS:
case Species.HIPPOWDON:
case Species.UNFEZANT:
@ -888,17 +894,24 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
getCompatibleFusionSpeciesFilter(): PokemonSpeciesFilter {
const hasEvolution = pokemonEvolutions.hasOwnProperty(this.speciesId);
const hasPrevolution = pokemonPrevolutions.hasOwnProperty(this.speciesId);
const pseudoLegendary = this.subLegendary;
const subLegendary = this.subLegendary;
const legendary = this.legendary;
const mythical = this.mythical;
return species => {
return (pseudoLegendary || legendary || mythical ||
(pokemonEvolutions.hasOwnProperty(species.speciesId) === hasEvolution
&& pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution))
&& species.subLegendary === pseudoLegendary
return (
subLegendary
|| legendary
|| mythical
|| (
pokemonEvolutions.hasOwnProperty(species.speciesId) === hasEvolution
&& pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution
)
)
&& species.subLegendary === subLegendary
&& species.legendary === legendary
&& species.mythical === mythical
&& (this.isTrainerForbidden() || !species.isTrainerForbidden());
&& (this.isTrainerForbidden() || !species.isTrainerForbidden())
&& species.speciesId !== Species.DITTO;
};
}

View File

@ -2,8 +2,6 @@ import { randIntRange } from "#app/utils";
import { StatusEffect } from "#enums/status-effect";
import i18next, { ParseKeys } from "i18next";
export { StatusEffect };
export class Status {
public effect: StatusEffect;
/** Toxic damage is `1/16 max HP * toxicTurnCount` */

View File

@ -1,8 +1,6 @@
import Pokemon from "../field/pokemon";
import Move from "./move";
import { Type } from "./type";
import * as Utils from "../utils";
import { ChangeMovePriorityAbAttr, applyAbAttrs } from "./ability";
import { Type } from "#enums/type";
import { ProtectAttr } from "./move";
import { BattlerIndex } from "#app/battle";
import i18next from "i18next";
@ -58,10 +56,8 @@ export class Terrain {
switch (this.terrainType) {
case TerrainType.PSYCHIC:
if (!move.hasAttr(ProtectAttr)) {
const priority = new Utils.IntegerHolder(move.priority);
applyAbAttrs(ChangeMovePriorityAbAttr, user, null, false, move, priority);
// Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain
return priority.value > 0 && user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded());
return move.getPriority(user) > 0 && user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded());
}
}

View File

@ -2,11 +2,11 @@ import BattleScene, { startingWave } from "#app/battle-scene";
import { ModifierTypeFunc, modifierTypes } from "#app/modifier/modifier-type";
import { EnemyPokemon, PokemonMove } from "#app/field/pokemon";
import * as Utils from "#app/utils";
import { PokeballType } from "#app/data/pokeball";
import { PokeballType } from "#enums/pokeball";
import { pokemonEvolutions, pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions";
import PokemonSpecies, { getPokemonSpecies, PokemonSpeciesFilter } from "#app/data/pokemon-species";
import { tmSpecies } from "#app/data/balance/tms";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { doubleBattleDialogue } from "#app/data/dialogue";
import { PersistentModifier } from "#app/modifier/modifier";
import { TrainerVariant } from "#app/field/trainer";

View File

@ -1,25 +1,4 @@
export enum Type {
UNKNOWN = -1,
NORMAL = 0,
FIGHTING,
FLYING,
POISON,
GROUND,
ROCK,
BUG,
GHOST,
STEEL,
FIRE,
WATER,
GRASS,
ELECTRIC,
PSYCHIC,
ICE,
DRAGON,
DARK,
FAIRY,
STELLAR
}
import { Type } from "#enums/type";
export type TypeDamageMultiplier = 0 | 0.125 | 0.25 | 0.5 | 1 | 2 | 4 | 8;

View File

@ -2,7 +2,7 @@ import { Biome } from "#enums/biome";
import { WeatherType } from "#enums/weather-type";
import { getPokemonNameWithAffix } from "../messages";
import Pokemon from "../field/pokemon";
import { Type } from "./type";
import { Type } from "#enums/type";
import Move, { AttackMove } from "./move";
import * as Utils from "../utils";
import BattleScene from "../battle-scene";
@ -10,7 +10,6 @@ import { SuppressWeatherEffectAbAttr } from "./ability";
import { TerrainType, getTerrainName } from "./terrain";
import i18next from "i18next";
export { WeatherType };
export class Weather {
public weatherType: WeatherType;
public turnsLeft: integer;

22
src/enums/type.ts Normal file
View File

@ -0,0 +1,22 @@
export enum Type {
UNKNOWN = -1,
NORMAL = 0,
FIGHTING,
FLYING,
POISON,
GROUND,
ROCK,
BUG,
GHOST,
STEEL,
FIRE,
WATER,
GRASS,
ELECTRIC,
PSYCHIC,
ICE,
DRAGON,
DARK,
FAIRY,
STELLAR
}

View File

@ -1,7 +1,7 @@
import { ArenaTagSide } from "#app/data/arena-tag";
import { ArenaTagType } from "#enums/arena-tag-type";
import { TerrainType } from "#app/data/terrain";
import { WeatherType } from "#app/data/weather";
import { WeatherType } from "#enums/weather-type";
/** Alias for all {@linkcode ArenaEvent} type strings */
export enum ArenaEventType {

View File

@ -1,5 +1,5 @@
import BattleScene from "../battle-scene";
import { PokeballType } from "../data/pokeball";
import { PokeballType } from "#enums/pokeball";
import * as Utils from "../utils";
export function addPokeballOpenParticles(scene: BattleScene, x: number, y: number, pokeballType: PokeballType): void {

View File

@ -3,9 +3,9 @@ import { biomePokemonPools, BiomePoolTier, BiomeTierTrainerPools, biomeTrainerPo
import { Constructor } from "#app/utils";
import * as Utils from "#app/utils";
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species";
import { getTerrainClearMessage, getTerrainStartMessage, getWeatherClearMessage, getWeatherStartMessage, Weather, WeatherType } from "#app/data/weather";
import { getTerrainClearMessage, getTerrainStartMessage, getWeatherClearMessage, getWeatherStartMessage, Weather } from "#app/data/weather";
import { CommonAnim } from "#app/data/battle-anims";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import Move from "#app/data/move";
import { ArenaTag, ArenaTagSide, ArenaTrapTag, getArenaTag } from "#app/data/arena-tag";
import { BattlerIndex } from "#app/battle";
@ -31,6 +31,7 @@ import { Abilities } from "#enums/abilities";
import { SpeciesFormChangeRevertWeatherFormTrigger, SpeciesFormChangeWeatherTrigger } from "#app/data/pokemon-forms";
import { CommonAnimPhase } from "#app/phases/common-anim-phase";
import { ShowAbilityPhase } from "#app/phases/show-ability-phase";
import { WeatherType } from "#enums/weather-type";
export class Arena {
public scene: BattleScene;

View File

@ -9,20 +9,21 @@ import { CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER, getStarterValueFriendshipCap, spec
import { starterPassiveAbilities } from "#app/data/balance/passives";
import { Constructor, isNullOrUndefined, randSeedInt, type nil } from "#app/utils";
import * as Utils from "#app/utils";
import { Type, TypeDamageMultiplier, getTypeDamageMultiplier, getTypeRgb } from "#app/data/type";
import { TypeDamageMultiplier, getTypeDamageMultiplier, getTypeRgb } from "#app/data/type";
import { Type } from "#enums/type";
import { getLevelTotalExp } from "#app/data/exp";
import { Stat, type PermanentStat, type BattleStat, type EffectiveStat, PERMANENT_STATS, BATTLE_STATS, EFFECTIVE_STATS } from "#enums/stat";
import { DamageMoneyRewardModifier, EnemyDamageBoosterModifier, EnemyDamageReducerModifier, EnemyEndureChanceModifier, EnemyFusionChanceModifier, HiddenAbilityRateBoosterModifier, BaseStatModifier, PokemonFriendshipBoosterModifier, PokemonHeldItemModifier, PokemonNatureWeightModifier, ShinyRateBoosterModifier, SurviveDamageModifier, TempStatStageBoosterModifier, TempCritBoosterModifier, StatBoosterModifier, CritBoosterModifier, TerastallizeModifier, PokemonBaseStatFlatModifier, PokemonBaseStatTotalModifier, PokemonIncrementingStatModifier, EvoTrackerModifier, PokemonMultiHitModifier } from "#app/modifier/modifier";
import { PokeballType } from "#app/data/pokeball";
import { PokeballType } from "#enums/pokeball";
import { Gender } from "#app/data/gender";
import { initMoveAnim, loadMoveAnimAssets } from "#app/data/battle-anims";
import { Status, StatusEffect, getRandomStatus } from "#app/data/status-effect";
import { Status, getRandomStatus } from "#app/data/status-effect";
import { pokemonEvolutions, pokemonPrevolutions, SpeciesFormEvolution, SpeciesEvolutionCondition, FusionSpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions";
import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from "#app/data/balance/tms";
import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, SubstituteTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag, TarShotTag, AutotomizedTag, PowerTrickTag } from "../data/battler-tags";
import { WeatherType } from "#app/data/weather";
import { WeatherType } from "#enums/weather-type";
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag";
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr } from "#app/data/ability";
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr, CommanderAbAttr, applyPostItemLostAbAttrs, PostItemLostAbAttr } from "#app/data/ability";
import PokemonData from "#app/system/pokemon-data";
import { BattlerIndex } from "#app/battle";
import { Mode } from "#app/ui/ui";
@ -32,7 +33,7 @@ import { LevelMoves } from "#app/data/balance/pokemon-level-moves";
import { DamageAchv, achvs } from "#app/system/achv";
import { DexAttr, StarterDataEntry, StarterMoveset } from "#app/system/game-data";
import { QuantizerCelebi, argbFromRgba, rgbaFromArgb } from "@material/material-color-utilities";
import { Nature, getNatureStatMultiplier } from "#app/data/nature";
import { getNatureStatMultiplier } from "#app/data/nature";
import { SpeciesFormChange, SpeciesFormChangeActiveTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangePostMoveTrigger, SpeciesFormChangeStatusEffectTrigger } from "#app/data/pokemon-forms";
import { TerrainType } from "#app/data/terrain";
import { TrainerSlot } from "#app/data/trainer-config";
@ -66,6 +67,8 @@ import { CustomPokemonData } from "#app/data/custom-pokemon-data";
import { SwitchType } from "#enums/switch-type";
import { SpeciesFormKey } from "#enums/species-form-key";
import { BASE_HIDDEN_ABILITY_CHANCE, BASE_SHINY_CHANCE, SHINY_EPIC_CHANCE, SHINY_VARIANT_CHANCE } from "#app/data/balance/rates";
import { Nature } from "#enums/nature";
import { StatusEffect } from "#enums/status-effect";
export enum FieldPosition {
CENTER,
@ -439,7 +442,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
};
if (this.shiny) {
const populateVariantColors = (isBackSprite: boolean = false): Promise<void> => {
return new Promise(resolve => {
return new Promise(async resolve => {
const battleSpritePath = this.getBattleSpriteAtlasPath(isBackSprite, ignoreOverride).replace("variant/", "").replace(/_[1-3]$/, "");
let config = variantData;
const useExpSprite = this.scene.experimentalSprites && this.scene.hasExpSprite(this.getBattleSpriteKey(isBackSprite, ignoreOverride));
@ -448,7 +451,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (variantSet && variantSet[this.variant] === 1) {
const cacheKey = this.getBattleSpriteKey(isBackSprite);
if (!variantColorCache.hasOwnProperty(cacheKey)) {
this.populateVariantColorCache(cacheKey, useExpSprite, battleSpritePath);
await this.populateVariantColorCache(cacheKey, useExpSprite, battleSpritePath);
}
}
resolve();
@ -480,10 +483,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param battleSpritePath the filename of the sprite
* @param optionalParams any additional params to log
*/
fallbackVariantColor(cacheKey: string, attemptedSpritePath: string, useExpSprite: boolean, battleSpritePath: string, ...optionalParams: any[]) {
async fallbackVariantColor(cacheKey: string, attemptedSpritePath: string, useExpSprite: boolean, battleSpritePath: string, ...optionalParams: any[]) {
console.warn(`Could not load ${attemptedSpritePath}!`, ...optionalParams);
if (useExpSprite) {
this.populateVariantColorCache(cacheKey, false, battleSpritePath);
await this.populateVariantColorCache(cacheKey, false, battleSpritePath);
}
}
@ -494,18 +497,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param useExpSprite should the experimental sprite be used
* @param battleSpritePath the filename of the sprite
*/
populateVariantColorCache(cacheKey: string, useExpSprite: boolean, battleSpritePath: string) {
async populateVariantColorCache(cacheKey: string, useExpSprite: boolean, battleSpritePath: string) {
const spritePath = `./images/pokemon/variant/${useExpSprite ? "exp/" : ""}${battleSpritePath}.json`;
this.scene.cachedFetch(spritePath).then(res => {
return this.scene.cachedFetch(spritePath).then(res => {
// Prevent the JSON from processing if it failed to load
if (!res.ok) {
return this.fallbackVariantColor(cacheKey, res.url, useExpSprite, battleSpritePath, res.status, res.statusText);
}
return res.json();
}).catch(error => {
this.fallbackVariantColor(cacheKey, spritePath, useExpSprite, battleSpritePath, error);
return this.fallbackVariantColor(cacheKey, spritePath, useExpSprite, battleSpritePath, error);
}).then(c => {
variantColorCache[cacheKey] = c;
if (!isNullOrUndefined(c)) {
variantColorCache[cacheKey] = c;
}
});
}
@ -982,7 +987,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (this.status && this.status.effect === StatusEffect.PARALYSIS) {
ret >>= 1;
}
if (this.getTag(BattlerTagType.UNBURDEN) && !this.scene.getField(true).some(pokemon => pokemon !== this && pokemon.hasAbilityWithAttr(SuppressFieldAbilitiesAbAttr))) {
if (this.getTag(BattlerTagType.UNBURDEN) && this.hasAbility(Abilities.UNBURDEN)) {
ret *= 2;
}
break;
@ -2027,15 +2032,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value);
const randAbilityIndex = Utils.randSeedInt(2);
const filter = !forStarter ? this.species.getCompatibleFusionSpeciesFilter()
: species => {
const filter = !forStarter ?
this.species.getCompatibleFusionSpeciesFilter()
: (species: PokemonSpecies) => {
return pokemonEvolutions.hasOwnProperty(species.speciesId)
&& !pokemonPrevolutions.hasOwnProperty(species.speciesId)
&& !species.pseudoLegendary
&& !species.legendary
&& !species.mythical
&& !species.isTrainerForbidden()
&& species.speciesId !== this.species.speciesId;
&& !pokemonPrevolutions.hasOwnProperty(species.speciesId)
&& !species.subLegendary
&& !species.legendary
&& !species.mythical
&& !species.isTrainerForbidden()
&& species.speciesId !== this.species.speciesId
&& species.speciesId !== Species.DITTO;
};
let fusionOverride: PokemonSpecies | undefined = undefined;
@ -3078,7 +3085,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
lapseTag(tagType: BattlerTagType): boolean {
const tags = this.summonData.tags;
const tags = this.summonData?.tags;
if (isNullOrUndefined(tags)) {
return false;
}
const tag = tags.find(t => t.tagType === tagType);
if (tag && !(tag.lapse(this, BattlerTagLapseType.CUSTOM))) {
tag.onRemove(this);
@ -3220,9 +3230,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.getMoveHistory().push(turnMove);
}
getLastXMoves(turnCount: integer = 0): TurnMove[] {
/**
* Returns a list of the most recent move entries in this Pokemon's move history.
* The retrieved move entries are sorted in order from NEWEST to OLDEST.
* @param moveCount The number of move entries to retrieve.
* If negative, retrieve the Pokemon's entire move history (equivalent to reversing the output of {@linkcode getMoveHistory()}).
* Default is `1`.
* @returns A list of {@linkcode TurnMove}, as specified above.
*/
getLastXMoves(moveCount: number = 1): TurnMove[] {
const moveHistory = this.getMoveHistory();
return moveHistory.slice(turnCount >= 0 ? Math.max(moveHistory.length - (turnCount || 1), 0) : 0, moveHistory.length).reverse();
if (moveCount >= 0) {
return moveHistory.slice(Math.max(moveHistory.length - moveCount, 0)).reverse();
} else {
return moveHistory.slice(0).reverse();
}
}
getMoveQueue(): QueuedMove[] {
@ -3643,6 +3665,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.triggerPokemonBattleAnim(this, PokemonAnimType.SUBSTITUTE_ADD);
this.getTag(SubstituteTag)!.sourceInFocus = false;
}
// If this Pokemon has Commander and Dondozo as an active ally, hide this Pokemon's sprite.
if (this.hasAbilityWithAttr(CommanderAbAttr)
&& this.scene.currentBattle.double
&& this.getAlly()?.species.speciesId === Species.DONDOZO) {
this.setVisible(false);
}
this.summonDataPrimer = null;
}
this.updateInfo();
@ -4026,8 +4055,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.resetTurnData();
if (clearEffects) {
this.destroySubstitute();
this.resetSummonData();
this.resetBattleData();
this.resetSummonData(); // this also calls `resetBattleSummonData`
}
if (hideInfo) {
this.hideInfo();
@ -4076,6 +4104,28 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
return false;
}
/**
* Reduces one of this Pokemon's held item stacks by 1, and removes the item if applicable.
* Does nothing if this Pokemon is somehow not the owner of the held item.
* @param heldItem The item stack to be reduced by 1.
* @param forBattle If `false`, do not trigger in-battle effects (such as Unburden) from losing the item. For example, set this to `false` if the Pokemon is giving away the held item for a Mystery Encounter. Default is `true`.
* @returns `true` if the item was removed successfully, `false` otherwise.
*/
public loseHeldItem(heldItem: PokemonHeldItemModifier, forBattle: boolean = true): boolean {
if (heldItem.pokemonId === -1 || heldItem.pokemonId === this.id) {
heldItem.stackCount--;
if (heldItem.stackCount <= 0) {
this.scene.removeModifier(heldItem, !this.isPlayer());
}
if (forBattle) {
applyPostItemLostAbAttrs(PostItemLostAbAttr, this, false);
}
return true;
} else {
return false;
}
}
}
export default interface Pokemon {
@ -4518,7 +4568,7 @@ export class PlayerPokemon extends Pokemon {
&& m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[];
const transferModifiers: Promise<boolean>[] = [];
for (const modifier of fusedPartyMemberHeldModifiers) {
transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true));
transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true, false));
}
Promise.allSettled(transferModifiers).then(() => {
this.scene.updateModifiers(true, true).then(() => {
@ -5079,26 +5129,6 @@ export class EnemyPokemon extends Pokemon {
}
}
heal(amount: integer): integer {
if (this.isBoss()) {
const amountRatio = amount / this.getMaxHp();
const segmentBypassCount = Math.floor(amountRatio / (1 / this.bossSegments));
const segmentSize = this.getMaxHp() / this.bossSegments;
for (let s = 1; s < this.bossSegments; s++) {
const hpThreshold = segmentSize * s;
if (this.hp <= Math.round(hpThreshold)) {
const healAmount = Math.min(amount, this.getMaxHp() - this.hp, Math.round(hpThreshold + (segmentSize * segmentBypassCount) - this.hp));
this.hp += healAmount;
return healAmount;
} else if (s >= this.bossSegmentIndex) {
return super.heal(amount);
}
}
}
return super.heal(amount);
}
getFieldIndex(): integer {
return this.scene.getEnemyField().indexOf(this);
}
@ -5109,7 +5139,7 @@ export class EnemyPokemon extends Pokemon {
/**
* Add a new pokemon to the player's party (at `slotIndex` if set).
* If the first slot is replaced, the new pokemon's visibility will be set to `false`.
* The new pokemon's visibility will be set to `false`.
* @param pokeballType the type of pokeball the pokemon was caught with
* @param slotIndex an optional index to place the pokemon in the party
* @returns the pokemon that was added or null if the pokemon could not be added
@ -5127,14 +5157,14 @@ export class EnemyPokemon extends Pokemon {
const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this);
if (Utils.isBetween(slotIndex, 0, PLAYER_PARTY_MAX_SIZE - 1)) {
if (slotIndex === 0) {
newPokemon.setVisible(false); // Hide if replaced with first pokemon
}
party.splice(slotIndex, 0, newPokemon);
} else {
party.push(newPokemon);
}
// Hide the Pokemon since it is not on the field
newPokemon.setVisible(false);
ret = newPokemon;
this.scene.triggerPokemonFormChange(newPokemon, SpeciesFormChangeActiveTrigger, true);
}

View File

@ -3,30 +3,31 @@ import { EvolutionItem, pokemonEvolutions } from "#app/data/balance/pokemon-evol
import { tmPoolTiers, tmSpecies } from "#app/data/balance/tms";
import { getBerryEffectDescription, getBerryName } from "#app/data/berry";
import { allMoves, AttackMove, selfStatLowerMoves } from "#app/data/move";
import { getNatureName, getNatureStatMultiplier, Nature } from "#app/data/nature";
import { getPokeballCatchMultiplier, getPokeballName, MAX_PER_TYPE_POKEBALLS, PokeballType } from "#app/data/pokeball";
import { getNatureName, getNatureStatMultiplier } from "#app/data/nature";
import { getPokeballCatchMultiplier, getPokeballName, MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
import { FormChangeItem, pokemonFormChanges, SpeciesFormChangeCondition, SpeciesFormChangeItemTrigger } from "#app/data/pokemon-forms";
import { getStatusEffectDescriptor, StatusEffect } from "#app/data/status-effect";
import { Type } from "#app/data/type";
import { getStatusEffectDescriptor } from "#app/data/status-effect";
import { Type } from "#enums/type";
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import {
AddPokeballModifier, AddVoucherModifier, AttackTypeBoosterModifier, BaseStatModifier, BerryModifier, BoostBugSpawnModifier, BypassSpeedChanceModifier, ContactHeldItemTransferChanceModifier, CritBoosterModifier, DamageMoneyRewardModifier, DoubleBattleChanceBoosterModifier, EnemyAttackStatusEffectChanceModifier, EnemyDamageBoosterModifier, EnemyDamageReducerModifier, EnemyEndureChanceModifier, EnemyFusionChanceModifier, EnemyStatusEffectHealChanceModifier, EnemyTurnHealModifier, EvolutionItemModifier, EvolutionStatBoosterModifier, EvoTrackerModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, FlinchChanceModifier, FusePokemonModifier, GigantamaxAccessModifier, HealingBoosterModifier, HealShopCostModifier, HiddenAbilityRateBoosterModifier, HitHealModifier, IvScannerModifier, LevelIncrementBoosterModifier, LockModifierTiersModifier, MapModifier, MegaEvolutionAccessModifier, MoneyInterestModifier, MoneyMultiplierModifier, MoneyRewardModifier, MultipleParticipantExpBonusModifier, PokemonAllMovePpRestoreModifier, PokemonBaseStatFlatModifier, PokemonBaseStatTotalModifier, PokemonExpBoosterModifier, PokemonFormChangeItemModifier, PokemonFriendshipBoosterModifier, PokemonHeldItemModifier, PokemonHpRestoreModifier, PokemonIncrementingStatModifier, PokemonInstantReviveModifier, PokemonLevelIncrementModifier, PokemonMoveAccuracyBoosterModifier, PokemonMultiHitModifier, PokemonNatureChangeModifier, PokemonNatureWeightModifier, PokemonPpRestoreModifier, PokemonPpUpModifier, PokemonStatusHealModifier, PreserveBerryModifier, RememberMoveModifier, ResetNegativeStatStageModifier, ShinyRateBoosterModifier, SpeciesCritBoosterModifier, SpeciesStatBoosterModifier, SurviveDamageModifier, SwitchEffectTransferModifier, TempCritBoosterModifier, TempStatStageBoosterModifier, TerastallizeAccessModifier, TerastallizeModifier, TmModifier, TurnHealModifier, TurnHeldItemTransferModifier, TurnStatusEffectModifier, type EnemyPersistentModifier, type Modifier, type PersistentModifier, TempExtraModifierModifier
} from "#app/modifier/modifier";
import { AddPokeballModifier, AddVoucherModifier, AttackTypeBoosterModifier, BaseStatModifier, BerryModifier, BoostBugSpawnModifier, BypassSpeedChanceModifier, ContactHeldItemTransferChanceModifier, CritBoosterModifier, DamageMoneyRewardModifier, DoubleBattleChanceBoosterModifier, EnemyAttackStatusEffectChanceModifier, EnemyDamageBoosterModifier, EnemyDamageReducerModifier, EnemyEndureChanceModifier, EnemyFusionChanceModifier, EnemyStatusEffectHealChanceModifier, EnemyTurnHealModifier, EvolutionItemModifier, EvolutionStatBoosterModifier, EvoTrackerModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, FlinchChanceModifier, FusePokemonModifier, GigantamaxAccessModifier, HealingBoosterModifier, HealShopCostModifier, HiddenAbilityRateBoosterModifier, HitHealModifier, IvScannerModifier, LevelIncrementBoosterModifier, LockModifierTiersModifier, MapModifier, MegaEvolutionAccessModifier, MoneyInterestModifier, MoneyMultiplierModifier, MoneyRewardModifier, MultipleParticipantExpBonusModifier, PokemonAllMovePpRestoreModifier, PokemonBaseStatFlatModifier, PokemonBaseStatTotalModifier, PokemonExpBoosterModifier, PokemonFormChangeItemModifier, PokemonFriendshipBoosterModifier, PokemonHeldItemModifier, PokemonHpRestoreModifier, PokemonIncrementingStatModifier, PokemonInstantReviveModifier, PokemonLevelIncrementModifier, PokemonMoveAccuracyBoosterModifier, PokemonMultiHitModifier, PokemonNatureChangeModifier, PokemonNatureWeightModifier, PokemonPpRestoreModifier, PokemonPpUpModifier, PokemonStatusHealModifier, PreserveBerryModifier, RememberMoveModifier, ResetNegativeStatStageModifier, ShinyRateBoosterModifier, SpeciesCritBoosterModifier, SpeciesStatBoosterModifier, SurviveDamageModifier, SwitchEffectTransferModifier, TempCritBoosterModifier, TempStatStageBoosterModifier, TerastallizeAccessModifier, TerastallizeModifier, TmModifier, TurnHealModifier, TurnHeldItemTransferModifier, TurnStatusEffectModifier, type EnemyPersistentModifier, type Modifier, type PersistentModifier, TempExtraModifierModifier, CriticalCatchChanceBoosterModifier } from "#app/modifier/modifier";
import { ModifierTier } from "#app/modifier/modifier-tier";
import Overrides from "#app/overrides";
import { Unlockables } from "#app/system/unlockables";
import { getVoucherTypeIcon, getVoucherTypeName, VoucherType } from "#app/system/voucher";
import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from "#app/ui/party-ui-handler";
import { getModifierTierTextTint } from "#app/ui/text";
import { formatMoney, getEnumKeys, getEnumValues, IntegerHolder, isNullOrUndefined, NumberHolder, padInt, randSeedInt, randSeedItem } from "#app/utils";
import { formatMoney, getEnumKeys, getEnumValues, isNullOrUndefined, NumberHolder, padInt, randSeedInt, randSeedItem } from "#app/utils";
import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type";
import { BerryType } from "#enums/berry-type";
import { Moves } from "#enums/moves";
import { Nature } from "#enums/nature";
import { PokeballType } from "#enums/pokeball";
import { Species } from "#enums/species";
import { SpeciesFormKey } from "#enums/species-form-key";
import { getStatKey, PermanentStat, Stat, TEMP_BATTLE_STATS, TempBattleStat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect";
import i18next from "i18next";
const outputModifierData = false;
@ -730,7 +731,7 @@ export class MoneyRewardModifierType extends ModifierType {
}
getDescription(scene: BattleScene): string {
const moneyAmount = new IntegerHolder(scene.getWaveMoneyAmount(this.moneyMultiplier));
const moneyAmount = new NumberHolder(scene.getWaveMoneyAmount(this.moneyMultiplier));
scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);
const formattedMoney = formatMoney(scene.moneyFormat, moneyAmount.value);
@ -1553,6 +1554,7 @@ export const modifierTypes = {
SHINY_CHARM: () => new ModifierType("modifierType:ModifierType.SHINY_CHARM", "shiny_charm", (type, _args) => new ShinyRateBoosterModifier(type)),
ABILITY_CHARM: () => new ModifierType("modifierType:ModifierType.ABILITY_CHARM", "ability_charm", (type, _args) => new HiddenAbilityRateBoosterModifier(type)),
CATCHING_CHARM: () => new ModifierType("modifierType:ModifierType.CATCHING_CHARM", "catching_charm", (type, _args) => new CriticalCatchChanceBoosterModifier(type)),
IV_SCANNER: () => new ModifierType("modifierType:ModifierType.IV_SCANNER", "scanner", (type, _args) => new IvScannerModifier(type)),
@ -1619,19 +1621,21 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.POKEBALL, (party: Pokemon[]) => (hasMaximumBalls(party, PokeballType.POKEBALL)) ? 0 : 6, 6),
new WeightedModifierType(modifierTypes.RARE_CANDY, 2),
new WeightedModifierType(modifierTypes.POTION, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 10 || p.getHpRatio() <= 0.875) && !p.isFainted()).length, 3);
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 10 && p.getHpRatio() <= 0.875) && !p.isFainted()).length, 3);
return thresholdPartyMemberCount * 3;
}, 9),
new WeightedModifierType(modifierTypes.SUPER_POTION, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 25 || p.getHpRatio() <= 0.75) && !p.isFainted()).length, 3);
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 25 && p.getHpRatio() <= 0.75) && !p.isFainted()).length, 3);
return thresholdPartyMemberCount;
}, 3),
new WeightedModifierType(modifierTypes.ETHER, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed >= Math.floor(m.getMovePp() / 2)).length).length, 3);
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA)
&& p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3);
return thresholdPartyMemberCount * 3;
}, 9),
new WeightedModifierType(modifierTypes.MAX_ETHER, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed >= Math.floor(m.getMovePp() / 2)).length).length, 3);
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA)
&& p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3);
return thresholdPartyMemberCount;
}, 3),
new WeightedModifierType(modifierTypes.LURE, lureWeightFunc(10, 2)),
@ -1665,11 +1669,11 @@ const modifierPool: ModifierPool = {
return party.filter(p => p.isFainted()).length >= Math.ceil(party.length / 2) ? 1 : 0;
}, 1),
new WeightedModifierType(modifierTypes.HYPER_POTION, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 100 || p.getHpRatio() <= 0.625) && !p.isFainted()).length, 3);
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.625) && !p.isFainted()).length, 3);
return thresholdPartyMemberCount * 3;
}, 9),
new WeightedModifierType(modifierTypes.MAX_POTION, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 150 || p.getHpRatio() <= 0.5) && !p.isFainted()).length, 3);
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5) && !p.isFainted()).length, 3);
return thresholdPartyMemberCount;
}, 3),
new WeightedModifierType(modifierTypes.FULL_RESTORE, (party: Pokemon[]) => {
@ -1679,15 +1683,17 @@ const modifierPool: ModifierPool = {
}
return false;
})).length, 3);
const thresholdPartyMemberCount = Math.floor((Math.min(party.filter(p => (p.getInverseHp() >= 150 || p.getHpRatio() <= 0.5) && !p.isFainted()).length, 3) + statusEffectPartyMemberCount) / 2);
const thresholdPartyMemberCount = Math.floor((Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5) && !p.isFainted()).length, 3) + statusEffectPartyMemberCount) / 2);
return thresholdPartyMemberCount;
}, 3),
new WeightedModifierType(modifierTypes.ELIXIR, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed >= Math.floor(m.getMovePp() / 2)).length).length, 3);
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA)
&& p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3);
return thresholdPartyMemberCount * 3;
}, 9),
new WeightedModifierType(modifierTypes.MAX_ELIXIR, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed >= Math.floor(m.getMovePp() / 2)).length).length, 3);
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA)
&& p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3);
return thresholdPartyMemberCount;
}, 3),
new WeightedModifierType(modifierTypes.DIRE_HIT, 4),
@ -1696,10 +1702,7 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, (party: Pokemon[]) => {
return Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 15), 8);
}, 8),
new WeightedModifierType(modifierTypes.MAP,
(party: Pokemon[]) => party[0].scene.gameMode.isClassic && party[0].scene.currentBattle.waveIndex < 180 ? party[0].scene.eventManager.isEventActive() ? 2 : 1 : 0,
(party: Pokemon[]) => party[0].scene.eventManager.isEventActive() ? 2 : 1),
new WeightedModifierType(modifierTypes.SOOTHE_BELL, (party: Pokemon[]) => party[0].scene.eventManager.isEventActive() ? 3 : 0),
new WeightedModifierType(modifierTypes.MAP, (party: Pokemon[]) => party[0].scene.gameMode.isClassic && party[0].scene.currentBattle.waveIndex < 180 ? 1 : 0, 1),
new WeightedModifierType(modifierTypes.TM_GREAT, 3),
new WeightedModifierType(modifierTypes.MEMORY_MUSHROOM, (party: Pokemon[]) => {
if (!party.find(p => p.getLearnableLevelMoves().length)) {
@ -1767,7 +1770,7 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.CANDY_JAR, skipInLastClassicWaveOrDefault(5)),
new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 9),
new WeightedModifierType(modifierTypes.TM_ULTRA, 11),
new WeightedModifierType(modifierTypes.RARER_CANDY, (party: Pokemon[]) => party[0].scene.eventManager.isEventActive() ? 6 : 4),
new WeightedModifierType(modifierTypes.RARER_CANDY, 4),
new WeightedModifierType(modifierTypes.GOLDEN_PUNCH, skipInLastClassicWaveOrDefault(2)),
new WeightedModifierType(modifierTypes.IV_SCANNER, skipInLastClassicWaveOrDefault(4)),
new WeightedModifierType(modifierTypes.EXP_CHARM, skipInLastClassicWaveOrDefault(8)),
@ -1790,7 +1793,8 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.BATON, 2),
new WeightedModifierType(modifierTypes.SOUL_DEW, 7),
//new WeightedModifierType(modifierTypes.OVAL_CHARM, 6),
new WeightedModifierType(modifierTypes.SOOTHE_BELL, (party: Pokemon[]) => party[0].scene.eventManager.isEventActive() ? 0 : 4),
new WeightedModifierType(modifierTypes.CATCHING_CHARM, (party: Pokemon[]) => !party[0].scene.gameMode.isFreshStartChallenge() && party[0].scene.gameData.getSpeciesCount(d => !!d.caughtAttr) > 100 ? 4 : 0, 4),
new WeightedModifierType(modifierTypes.SOOTHE_BELL, 4),
new WeightedModifierType(modifierTypes.ABILITY_CHARM, skipInClassicAfterWave(189, 6)),
new WeightedModifierType(modifierTypes.FOCUS_BAND, 5),
new WeightedModifierType(modifierTypes.KINGS_ROCK, 3),

View File

@ -6,7 +6,7 @@ import { allMoves } from "#app/data/move";
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
import { type FormChangeItem, SpeciesFormChangeItemTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms";
import { getStatusEffectHealText } from "#app/data/status-effect";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import Pokemon, { type PlayerPokemon } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import Overrides from "#app/overrides";
@ -728,10 +728,10 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
//Applies to items with chance of activating secondary effects ie Kings Rock
getSecondaryChanceMultiplier(pokemon: Pokemon): number {
// Temporary quickfix to stop game from freezing when the opponet uses u-turn while holding on to king's rock
if (!pokemon.getLastXMoves(0)[0]) {
if (!pokemon.getLastXMoves()[0]) {
return 1;
}
const sheerForceAffected = allMoves[pokemon.getLastXMoves(0)[0].move].chance >= 0 && pokemon.hasAbility(Abilities.SHEER_FORCE);
const sheerForceAffected = allMoves[pokemon.getLastXMoves()[0].move].chance >= 0 && pokemon.hasAbility(Abilities.SHEER_FORCE);
if (sheerForceAffected) {
return 0;
@ -2957,6 +2957,38 @@ export class ShinyRateBoosterModifier extends PersistentModifier {
}
}
export class CriticalCatchChanceBoosterModifier extends PersistentModifier {
constructor(type: ModifierType, stackCount?: number) {
super(type, stackCount);
}
match(modifier: Modifier): boolean {
return modifier instanceof CriticalCatchChanceBoosterModifier;
}
clone(): CriticalCatchChanceBoosterModifier {
return new CriticalCatchChanceBoosterModifier(this.type, this.stackCount);
}
/**
* Applies {@linkcode CriticalCatchChanceBoosterModifier}
* @param boost {@linkcode NumberHolder} holding the boost value
* @returns always `true`
*/
override apply(boost: NumberHolder): boolean {
// 1 stack: 2x
// 2 stack: 2.5x
// 3 stack: 3x
boost.value *= 1.5 + this.getStackCount() / 2;
return true;
}
getMaxStackCount(scene: BattleScene): number {
return 3;
}
}
export class LockModifierTiersModifier extends PersistentModifier {
constructor(type: ModifierType, stackCount?: number) {
super(type, stackCount);

View File

@ -31,11 +31,8 @@ export class BerryPhase extends FieldPhase {
for (const berryModifier of this.scene.applyModifiers(BerryModifier, pokemon.isPlayer(), pokemon)) {
if (berryModifier.consumed) {
if (!--berryModifier.stackCount) {
this.scene.removeModifier(berryModifier);
} else {
berryModifier.consumed = false;
}
berryModifier.consumed = false;
pokemon.loseHeldItem(berryModifier);
}
this.scene.eventTarget.dispatchEvent(new BerryUsedEvent(berryModifier)); // Announce a berry was used
}

View File

@ -26,25 +26,29 @@ export class CheckSwitchPhase extends BattlePhase {
const pokemon = this.scene.getPlayerField()[this.fieldIndex];
// End this phase early...
// ...if the user is playing in Set Mode
if (this.scene.battleStyle === BattleStyle.SET) {
super.end();
return;
return super.end();
}
// ...if the checked Pokemon is somehow not on the field
if (this.scene.field.getAll().indexOf(pokemon) === -1) {
this.scene.unshiftPhase(new SummonMissingPhase(this.scene, this.fieldIndex));
super.end();
return;
return super.end();
}
// ...if there are no other allowed Pokemon in the player's party to switch with
if (!this.scene.getPlayerParty().slice(1).filter(p => p.isActive()).length) {
super.end();
return;
return super.end();
}
if (pokemon.getTag(BattlerTagType.FRENZY)) {
super.end();
return;
// ...or if any player Pokemon has an effect that prevents the checked Pokemon from switching
if (pokemon.getTag(BattlerTagType.FRENZY)
|| pokemon.isTrapped()
|| this.scene.getPlayerField().some(p => p.getTag(BattlerTagType.COMMANDED))) {
return super.end();
}
this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon") }), null, () => {

View File

@ -7,7 +7,7 @@ import { Abilities } from "#app/enums/abilities";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { Biome } from "#app/enums/biome";
import { Moves } from "#app/enums/moves";
import { PokeballType } from "#app/enums/pokeball";
import { PokeballType } from "#enums/pokeball";
import { FieldPosition, PlayerPokemon } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import { Command } from "#app/ui/command-ui-handler";
@ -61,6 +61,12 @@ export class CommandPhase extends FieldPhase {
this.scene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.FIGHT, move: { move: Moves.NONE, targets: []}, skip: true };
}
// Checks if the Pokemon is under the effects of Encore. If so, Encore can end early if the encored move has no more PP.
const encoreTag = this.getPokemon().getTag(BattlerTagType.ENCORE) as EncoreTag;
if (encoreTag) {
this.getPokemon().lapseTag(BattlerTagType.ENCORE);
}
if (this.scene.currentBattle.turnCommands[this.fieldIndex]?.skip) {
return this.end();
}
@ -291,26 +297,6 @@ export class CommandPhase extends FieldPhase {
}
}
checkFightOverride(): boolean {
const pokemon = this.getPokemon();
const encoreTag = pokemon.getTag(EncoreTag) as EncoreTag;
if (!encoreTag) {
return false;
}
const moveIndex = pokemon.getMoveset().findIndex(m => m?.moveId === encoreTag.moveId);
if (moveIndex === -1 || !pokemon.getMoveset()[moveIndex]!.isUsable(pokemon)) { // TODO: is this bang correct?
return false;
}
this.handleCommand(Command.FIGHT, moveIndex, false);
return true;
}
getFieldIndex(): integer {
return this.fieldIndex;
}

View File

@ -36,7 +36,6 @@ import { PlayerGender } from "#enums/player-gender";
import { Species } from "#enums/species";
import i18next from "i18next";
import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters";
import { BattlerTagType } from "#enums/battler-tag-type";
export class EncounterPhase extends BattlePhase {
private loaded: boolean;
@ -203,7 +202,7 @@ export class EncounterPhase extends BattlePhase {
this.scene.field.add(enemyPokemon);
battle.seenEnemyPartyMemberIds.add(enemyPokemon.id);
const playerPokemon = this.scene.getPlayerPokemon();
if (playerPokemon?.visible) {
if (playerPokemon?.isOnField()) {
this.scene.field.moveBelow(enemyPokemon as Pokemon, playerPokemon);
}
enemyPokemon.tint(0, 0.5);
@ -483,7 +482,6 @@ export class EncounterPhase extends BattlePhase {
}
} else {
if (availablePartyMembers.length > 1 && availablePartyMembers[1].isOnField()) {
this.scene.getPlayerField().forEach((pokemon) => pokemon.lapseTag(BattlerTagType.COMMANDED));
this.scene.pushPhase(new ReturnPhase(this.scene, 1));
}
this.scene.pushPhase(new ToggleDoublePositionPhase(this.scene, false));

View File

@ -55,21 +55,21 @@ export class FaintPhase extends PokemonPhase {
start() {
super.start();
const faintPokemon = this.getPokemon();
if (!isNullOrUndefined(this.destinyTag) && !isNullOrUndefined(this.source)) {
this.destinyTag.lapse(this.source, BattlerTagLapseType.CUSTOM);
}
if (!isNullOrUndefined(this.grudgeTag) && !isNullOrUndefined(this.source)) {
this.grudgeTag.lapse(this.getPokemon(), BattlerTagLapseType.CUSTOM, this.source);
this.grudgeTag.lapse(faintPokemon, BattlerTagLapseType.CUSTOM, this.source);
}
if (!this.preventEndure) {
const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, this.getPokemon()) as PokemonInstantReviveModifier;
const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, faintPokemon) as PokemonInstantReviveModifier;
if (instantReviveModifier) {
if (!--instantReviveModifier.stackCount) {
this.scene.removeModifier(instantReviveModifier);
}
faintPokemon.loseHeldItem(instantReviveModifier);
this.scene.updateModifiers(this.player);
return this.end();
}

View File

@ -26,13 +26,13 @@ import i18next from "i18next";
import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
export class GameOverPhase extends BattlePhase {
private victory: boolean;
private isVictory: boolean;
private firstRibbons: PokemonSpecies[] = [];
constructor(scene: BattleScene, victory?: boolean) {
constructor(scene: BattleScene, isVictory: boolean = false) {
super(scene);
this.victory = !!victory;
this.isVictory = isVictory;
}
start() {
@ -40,22 +40,22 @@ export class GameOverPhase extends BattlePhase {
// Failsafe if players somehow skip floor 200 in classic mode
if (this.scene.gameMode.isClassic && this.scene.currentBattle.waveIndex > 200) {
this.victory = true;
this.isVictory = true;
}
// Handle Mystery Encounter special Game Over cases
// Situations such as when player lost a battle, but it isn't treated as full Game Over
if (!this.victory && this.scene.currentBattle.mysteryEncounter?.onGameOver && !this.scene.currentBattle.mysteryEncounter.onGameOver(this.scene)) {
if (!this.isVictory && this.scene.currentBattle.mysteryEncounter?.onGameOver && !this.scene.currentBattle.mysteryEncounter.onGameOver(this.scene)) {
// Do not end the game
return this.end();
}
// Otherwise, continue standard Game Over logic
if (this.victory && this.scene.gameMode.isEndless) {
if (this.isVictory && this.scene.gameMode.isEndless) {
const genderIndex = this.scene.gameData.gender ?? PlayerGender.UNSET;
const genderStr = PlayerGender[genderIndex].toLowerCase();
this.scene.ui.showDialogue(i18next.t("miscDialogue:ending_endless", { context: genderStr }), i18next.t("miscDialogue:ending_name"), 0, () => this.handleGameOver());
} else if (this.victory || !this.scene.enableRetries) {
} else if (this.isVictory || !this.scene.enableRetries) {
this.handleGameOver();
} else {
this.scene.ui.showText(i18next.t("battle:retryBattle"), null, () => {
@ -93,7 +93,7 @@ export class GameOverPhase extends BattlePhase {
this.scene.disableMenu = true;
this.scene.time.delayedCall(1000, () => {
let firstClear = false;
if (this.victory && newClear) {
if (this.isVictory && newClear) {
if (this.scene.gameMode.isClassic) {
firstClear = this.scene.validateAchv(achvs.CLASSIC_VICTORY);
this.scene.validateAchv(achvs.UNEVOLVED_CLASSIC_VICTORY);
@ -109,8 +109,8 @@ export class GameOverPhase extends BattlePhase {
this.scene.gameData.gameStats.dailyRunSessionsWon++;
}
}
this.scene.gameData.saveRunHistory(this.scene, this.scene.gameData.getSessionSaveData(this.scene), this.victory);
const fadeDuration = this.victory ? 10000 : 5000;
this.scene.gameData.saveRunHistory(this.scene, this.scene.gameData.getSessionSaveData(this.scene), this.isVictory);
const fadeDuration = this.isVictory ? 10000 : 5000;
this.scene.fadeOutBgm(fadeDuration, true);
const activeBattlers = this.scene.getField().filter(p => p?.isActive(true));
activeBattlers.map(p => p.hideInfo());
@ -120,7 +120,7 @@ export class GameOverPhase extends BattlePhase {
this.scene.clearPhaseQueue();
this.scene.ui.clearText();
if (this.victory && this.scene.gameMode.isChallenge) {
if (this.isVictory && this.scene.gameMode.isChallenge) {
this.scene.gameMode.challenges.forEach(c => this.scene.validateAchvs(ChallengeAchv, c));
}
@ -128,7 +128,7 @@ export class GameOverPhase extends BattlePhase {
if (newClear) {
this.handleUnlocks();
}
if (this.victory && newClear) {
if (this.isVictory && newClear) {
for (const species of this.firstRibbons) {
this.scene.unshiftPhase(new RibbonModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PLUS, species));
}
@ -140,7 +140,7 @@ export class GameOverPhase extends BattlePhase {
this.end();
};
if (this.victory && this.scene.gameMode.isClassic) {
if (this.isVictory && this.scene.gameMode.isClassic) {
const dialogueKey = "miscDialogue:ending";
if (!this.scene.ui.shouldSkipDialogue(dialogueKey)) {
@ -173,25 +173,21 @@ export class GameOverPhase extends BattlePhase {
});
};
/* Added a local check to see if the game is running offline on victory
/* Added a local check to see if the game is running offline
If Online, execute apiFetch as intended
If Offline, execute offlineNewClear(), a localStorage implementation of newClear daily run checks */
if (this.victory) {
if (!Utils.isLocal || Utils.isLocalServerConnected) {
pokerogueApi.savedata.session.newclear({ slot: this.scene.sessionSlotId, clientSessionId })
.then((success) => doGameOver(!!success));
} else {
this.scene.gameData.offlineNewClear(this.scene).then(result => {
doGameOver(result);
});
}
} else {
doGameOver(false);
If Offline, execute offlineNewClear() only for victory, a localStorage implementation of newClear daily run checks */
if (!Utils.isLocal || Utils.isLocalServerConnected) {
pokerogueApi.savedata.session.newclear({ slot: this.scene.sessionSlotId, isVictory: this.isVictory, clientSessionId: clientSessionId })
.then((success) => doGameOver(!!success));
} else if (this.isVictory) {
this.scene.gameData.offlineNewClear(this.scene).then(result => {
doGameOver(result);
});
}
}
handleUnlocks(): void {
if (this.victory && this.scene.gameMode.isClassic) {
if (this.isVictory && this.scene.gameMode.isClassic) {
if (!this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.ENDLESS_MODE));
}

View File

@ -43,7 +43,7 @@ import {
VariableTargetAttr,
} from "#app/data/move";
import { SpeciesFormChangePostMoveTrigger } from "#app/data/pokemon-forms";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import Pokemon, { HitResult, MoveResult, PokemonMove } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import {

View File

@ -28,7 +28,7 @@ import {
} from "#app/data/move";
import { SpeciesFormChangePreMoveTrigger } from "#app/data/pokemon-forms";
import { getStatusEffectActivationText, getStatusEffectHealText } from "#app/data/status-effect";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { getTerrainBlockMessage } from "#app/data/weather";
import { MoveUsedEvent } from "#app/events/battle-scene";
import Pokemon, { MoveResult, PokemonMove } from "#app/field/pokemon";

View File

@ -103,7 +103,7 @@ export class SelectModifierPhase extends BattlePhase {
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& m.isTransferable && m.pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
const itemModifier = itemModifiers[itemIndex];
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity);
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity, undefined, undefined, false);
} else {
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(this.scene.lockModifierTiers));
}

View File

@ -125,10 +125,7 @@ export class StatStageChangePhase extends PokemonPhase {
const whiteHerb = this.scene.applyModifier(ResetNegativeStatStageModifier, this.player, pokemon) as ResetNegativeStatStageModifier;
// If the White Herb was applied, consume it
if (whiteHerb) {
whiteHerb.stackCount--;
if (whiteHerb.stackCount <= 0) {
this.scene.removeModifier(whiteHerb);
}
pokemon.loseHeldItem(whiteHerb);
this.scene.updateModifiers(this.player);
}
}

View File

@ -140,7 +140,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
this.scene.field.add(pokemon);
if (!this.player) {
const playerPokemon = this.scene.getPlayerPokemon() as Pokemon;
if (playerPokemon?.visible) {
if (playerPokemon?.isOnField()) {
this.scene.field.moveBelow(pokemon, playerPokemon);
}
this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id);
@ -193,7 +193,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
this.scene.field.add(pokemon);
if (!this.player) {
const playerPokemon = this.scene.getPlayerPokemon() as Pokemon;
if (playerPokemon?.visible) {
if (playerPokemon?.isOnField()) {
this.scene.field.moveBelow(pokemon, playerPokemon);
}
this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id);

View File

@ -111,7 +111,7 @@ export class SwitchSummonPhase extends SummonPhase {
const batonPassModifier = this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier
&& (m as SwitchEffectTransferModifier).pokemonId === this.lastPokemon.id) as SwitchEffectTransferModifier;
if (batonPassModifier && !this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) {
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false);
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false, undefined, undefined, undefined, false);
}
}
}
@ -138,7 +138,6 @@ export class SwitchSummonPhase extends SummonPhase {
switchedInPokemon.setAlpha(0.5);
}
} else {
switchedInPokemon.resetBattleData();
switchedInPokemon.resetSummonData();
}
this.summon();

View File

@ -1,6 +1,6 @@
import BattleScene from "#app/battle-scene";
import { applyAbAttrs, BypassSpeedChanceAbAttr, PreventBypassSpeedChanceAbAttr, ChangeMovePriorityAbAttr } from "#app/data/ability";
import { allMoves, applyMoveAttrs, IncrementMovePriorityAttr, MoveHeaderAttr } from "#app/data/move";
import { applyAbAttrs, BypassSpeedChanceAbAttr, PreventBypassSpeedChanceAbAttr } from "#app/data/ability";
import { allMoves, MoveHeaderAttr } from "#app/data/move";
import { Abilities } from "#app/enums/abilities";
import { Stat } from "#app/enums/stat";
import Pokemon, { PokemonMove } from "#app/field/pokemon";
@ -98,26 +98,22 @@ export class TurnStartPhase extends FieldPhase {
const aMove = allMoves[aCommand.move!.move];
const bMove = allMoves[bCommand!.move!.move];
// The game now considers priority and applies the relevant move and ability attributes
const aPriority = new Utils.IntegerHolder(aMove.priority);
const bPriority = new Utils.IntegerHolder(bMove.priority);
const aUser = this.scene.getField(true).find(p => p.getBattlerIndex() === a)!;
const bUser = this.scene.getField(true).find(p => p.getBattlerIndex() === b)!;
applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, aMove, aPriority);
applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, bMove, bPriority);
applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, false, aMove, aPriority);
applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, false, bMove, bPriority);
const aPriority = aMove.getPriority(aUser, false);
const bPriority = bMove.getPriority(bUser, false);
// The game now checks for differences in priority levels.
// If the moves share the same original priority bracket, it can check for differences in battlerBypassSpeed and return the result.
// This conditional is used to ensure that Quick Claw can still activate with abilities like Stall and Mycelium Might (attack moves only)
// Otherwise, the game returns the user of the move with the highest priority.
const isSameBracket = Math.ceil(aPriority.value) - Math.ceil(bPriority.value) === 0;
if (aPriority.value !== bPriority.value) {
const isSameBracket = Math.ceil(aPriority) - Math.ceil(bPriority) === 0;
if (aPriority !== bPriority) {
if (isSameBracket && battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) {
return battlerBypassSpeed[a].value ? -1 : 1;
}
return aPriority.value < bPriority.value ? 1 : -1;
return (aPriority < bPriority) ? 1 : -1;
}
}

View File

@ -69,7 +69,9 @@ export abstract class ApiBase {
"Content-Type": config.headers?.["Content-Type"] ?? "application/json",
};
console.log(`Sending ${config.method ?? "GET"} request to: `, this.base + path, config);
if (import.meta.env.DEV) {
console.log(`Sending ${config.method ?? "GET"} request to: `, this.base + path, config);
}
return await fetch(this.base + path, config);
}

View File

@ -22,7 +22,7 @@ import { vouchers, VoucherType } from "#app/system/voucher";
import { AES, enc } from "crypto-js";
import { Mode } from "#app/ui/ui";
import { clientSessionId, loggedInUser, updateUserInfo } from "#app/account";
import { Nature } from "#app/data/nature";
import { Nature } from "#enums/nature";
import { GameStats } from "#app/system/game-stats";
import { Tutorial } from "#app/tutorial";
import { speciesEggMoves } from "#app/data/balance/egg-moves";
@ -33,7 +33,7 @@ import { setSettingGamepad, SettingGamepad, settingGamepadDefaults } from "#app/
import { setSettingKeyboard, SettingKeyboard } from "#app/system/settings/settings-keyboard";
import { TagAddedEvent, TerrainChangedEvent, WeatherChangedEvent } from "#app/events/arena";
import * as Modifier from "#app/modifier/modifier";
import { StatusEffect } from "#app/data/status-effect";
import { StatusEffect } from "#enums/status-effect";
import ChallengeData from "#app/system/challenge-data";
import { Device } from "#enums/devices";
import { GameDataType } from "#enums/game-data-type";

View File

@ -1,8 +1,8 @@
import { BattleType } from "../battle";
import BattleScene from "../battle-scene";
import { Gender } from "../data/gender";
import { Nature } from "../data/nature";
import { PokeballType } from "../data/pokeball";
import { Nature } from "#enums/nature";
import { PokeballType } from "#enums/pokeball";
import { getPokemonSpecies } from "../data/pokemon-species";
import { Status } from "../data/status-effect";
import Pokemon, { EnemyPokemon, PokemonMove, PokemonSummonData } from "../field/pokemon";

View File

@ -1,8 +1,9 @@
import { allMoves, MultiHitAttr, MultiHitType } from "#app/data/move";
import { Status, StatusEffect } from "#app/data/status-effect";
import { Status } from "#app/data/status-effect";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

View File

@ -1,10 +1,10 @@
import { BattlerIndex } from "#app/battle";
import { StatusEffect } from "#app/data/status-effect";
import { toDmgValue } from "#app/utils";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,11 +1,11 @@
import { BattlerIndex } from "#app/battle";
import { StatusEffect } from "#app/data/status-effect";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { Species } from "#app/enums/species";
import { MovePhase } from "#app/phases/move-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,6 +1,6 @@
import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { Abilities } from "#app/enums/abilities";
import { Moves } from "#app/enums/moves";
import { Species } from "#app/enums/species";

View File

@ -1,6 +1,6 @@
import { allMoves } from "#app/data/move";
import { Type } from "#app/data/type";
import { Weather, WeatherType } from "#app/data/weather";
import { Type } from "#enums/type";
import { Weather } from "#app/data/weather";
import { PlayerPokemon } from "#app/field/pokemon";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
@ -8,6 +8,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { WeatherType } from "#enums/weather-type";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";

View File

@ -1,12 +1,13 @@
import { ArenaTagSide, getArenaTag } from "#app/data/arena-tag";
import { StatusEffect, getStatusEffectCatchRateMultiplier } from "#app/data/status-effect";
import { WeatherType } from "#app/data/weather";
import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { ArenaTagType } from "#enums/arena-tag-type";
import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect";
import { WeatherType } from "#enums/weather-type";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,7 +1,7 @@
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,11 +1,11 @@
import { Stat } from "#enums/stat";
import { StatusEffect } from "#app/data/status-effect";
import { Type } from "#app/data/type";
import { Type } from "#enums/type";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { toDmgValue } from "#app/utils";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,10 +1,10 @@
import { BattlerIndex } from "#app/battle";
import { StatusEffect } from "#app/data/status-effect";
import { Abilities } from "#app/enums/abilities";
import { CommandPhase } from "#app/phases/command-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,9 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect";
import { Status } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";

View File

@ -1,6 +1,6 @@
import { allMoves } from "#app/data/move";
import { Type } from "#app/data/type";
import { Weather, WeatherType } from "#app/data/weather";
import { Type } from "#enums/type";
import { Weather } from "#app/data/weather";
import { PlayerPokemon } from "#app/field/pokemon";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
@ -8,6 +8,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { WeatherType } from "#enums/weather-type";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";

View File

@ -1,12 +1,12 @@
import { StatMultiplierAbAttr, allAbilities } from "#app/data/ability";
import { Stat } from "#enums/stat";
import { WeatherType } from "#app/data/weather";
import { CommandPhase } from "#app/phases/command-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import { WeatherType } from "#enums/weather-type";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";

View File

@ -8,7 +8,8 @@ import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { allMoves, RandomMoveAttr } from "#app/data/move";
// See also: TypeImmunityAbAttr
describe("Abilities - Sap Sipper", () => {
@ -27,20 +28,20 @@ describe("Abilities - Sap Sipper", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.battleType("single");
game.override.disableCrits();
game.override.battleType("single")
.disableCrits()
.ability(Abilities.SAP_SIPPER)
.enemySpecies(Species.RATTATA)
.enemyAbility(Abilities.SAP_SIPPER)
.enemyMoveset(Moves.SPLASH);
});
it("raises ATK stat stage by 1 and block effects when activated against a grass attack", async() => {
const moveToUse = Moves.LEAFAGE;
const enemyAbility = Abilities.SAP_SIPPER;
game.override.moveset([ moveToUse ]);
game.override.enemyMoveset(Moves.SPLASH);
game.override.enemySpecies(Species.DUSKULL);
game.override.enemyAbility(enemyAbility);
game.override.moveset(moveToUse);
await game.startBattle();
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const initialEnemyHp = enemyPokemon.hp;
@ -55,14 +56,10 @@ describe("Abilities - Sap Sipper", () => {
it("raises ATK stat stage by 1 and block effects when activated against a grass status move", async() => {
const moveToUse = Moves.SPORE;
const enemyAbility = Abilities.SAP_SIPPER;
game.override.moveset([ moveToUse ]);
game.override.enemyMoveset(Moves.SPLASH);
game.override.enemySpecies(Species.RATTATA);
game.override.enemyAbility(enemyAbility);
game.override.moveset(moveToUse);
await game.startBattle();
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -76,14 +73,10 @@ describe("Abilities - Sap Sipper", () => {
it("do not activate against status moves that target the field", async () => {
const moveToUse = Moves.GRASSY_TERRAIN;
const enemyAbility = Abilities.SAP_SIPPER;
game.override.moveset([ moveToUse ]);
game.override.enemyMoveset(Moves.SPLASH);
game.override.enemySpecies(Species.RATTATA);
game.override.enemyAbility(enemyAbility);
game.override.moveset(moveToUse);
await game.startBattle();
await game.classicMode.startBattle([ Species.BULBASAUR ]);
game.move.select(moveToUse);
@ -96,14 +89,10 @@ describe("Abilities - Sap Sipper", () => {
it("activate once against multi-hit grass attacks", async () => {
const moveToUse = Moves.BULLET_SEED;
const enemyAbility = Abilities.SAP_SIPPER;
game.override.moveset([ moveToUse ]);
game.override.enemyMoveset(Moves.SPLASH);
game.override.enemySpecies(Species.RATTATA);
game.override.enemyAbility(enemyAbility);
game.override.moveset(moveToUse);
await game.startBattle();
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const initialEnemyHp = enemyPokemon.hp;
@ -118,15 +107,10 @@ describe("Abilities - Sap Sipper", () => {
it("do not activate against status moves that target the user", async () => {
const moveToUse = Moves.SPIKY_SHIELD;
const ability = Abilities.SAP_SIPPER;
game.override.moveset([ moveToUse ]);
game.override.ability(ability);
game.override.enemyMoveset(Moves.SPLASH);
game.override.enemySpecies(Species.RATTATA);
game.override.enemyAbility(Abilities.NONE);
game.override.moveset(moveToUse);
await game.startBattle();
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
@ -142,18 +126,15 @@ describe("Abilities - Sap Sipper", () => {
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
});
// TODO Add METRONOME outcome override
// To run this testcase, manually modify the METRONOME move to always give SAP_SIPPER, then uncomment
it.todo("activate once against multi-hit grass attacks (metronome)", async () => {
it("activate once against multi-hit grass attacks (metronome)", async () => {
const moveToUse = Moves.METRONOME;
const enemyAbility = Abilities.SAP_SIPPER;
game.override.moveset([ moveToUse ]);
game.override.enemyMoveset([ Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE ]);
game.override.enemySpecies(Species.RATTATA);
game.override.enemyAbility(enemyAbility);
const randomMoveAttr = allMoves[Moves.METRONOME].findAttr(attr => attr instanceof RandomMoveAttr) as RandomMoveAttr;
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.BULLET_SEED);
await game.startBattle();
game.override.moveset(moveToUse);
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const initialEnemyHp = enemyPokemon.hp;
@ -168,11 +149,8 @@ describe("Abilities - Sap Sipper", () => {
it("still activates regardless of accuracy check", async () => {
game.override.moveset(Moves.LEAF_BLADE);
game.override.enemyMoveset(Moves.SPLASH);
game.override.enemySpecies(Species.MAGIKARP);
game.override.enemyAbility(Abilities.SAP_SIPPER);
await game.classicMode.startBattle();
await game.classicMode.startBattle([ Species.BULBASAUR ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;

View File

@ -1,9 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect";
import { Status } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";

View File

@ -1,9 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect";
import { Status } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";

View File

@ -1,7 +1,7 @@
import { StatusEffect } from "#app/data/status-effect";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,18 +1,35 @@
import { BattlerIndex } from "#app/battle";
import { PostItemLostAbAttr } from "#app/data/ability";
import { allMoves, StealHeldItemChanceAttr } from "#app/data/move";
import Pokemon from "#app/field/pokemon";
import type { ContactHeldItemTransferChanceModifier } from "#app/modifier/modifier";
import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type";
import { BerryType } from "#enums/berry-type";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { Stat } from "#enums/stat";
import { BerryType } from "#app/enums/berry-type";
import { allMoves, StealHeldItemChanceAttr } from "#app/data/move";
describe("Abilities - Unburden", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
/**
* Count the number of held items a Pokemon has, accounting for stacks of multiple items.
*/
function getHeldItemCount(pokemon: Pokemon): number {
const stackCounts = pokemon.getHeldItems().map(m => m.getStackCount());
if (stackCounts.length) {
return stackCounts.reduce((a, b) => a + b);
} else {
return 0;
}
}
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
@ -27,9 +44,9 @@ describe("Abilities - Unburden", () => {
game = new GameManager(phaserGame);
game.override
.battleType("single")
.starterSpecies(Species.TREECKO)
.startingLevel(1)
.moveset([ Moves.POPULATION_BOMB, Moves.KNOCK_OFF, Moves.PLUCK, Moves.THIEF ])
.ability(Abilities.UNBURDEN)
.moveset([ Moves.SPLASH, Moves.KNOCK_OFF, Moves.PLUCK, Moves.FALSE_SWIPE ])
.startingHeldItems([
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
{ name: "BERRY", count: 2, type: BerryType.APICOT },
@ -37,209 +54,348 @@ describe("Abilities - Unburden", () => {
])
.enemySpecies(Species.NINJASK)
.enemyLevel(100)
.enemyMoveset([ Moves.FALSE_SWIPE ])
.enemyMoveset(Moves.SPLASH)
.enemyAbility(Abilities.UNBURDEN)
.enemyPassiveAbility(Abilities.NO_GUARD)
.enemyHeldItems([
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
{ name: "BERRY", type: BerryType.LUM, count: 1 },
]);
// For the various tests that use Thief, give it a 100% steal rate
vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]);
});
it("should activate when a berry is eaten", async () => {
await game.classicMode.startBattle();
game.override.enemyMoveset(Moves.FALSE_SWIPE);
await game.classicMode.startBattle([ Species.TREECKO ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
playerPokemon.abilityIndex = 2;
const playerHeldItems = playerPokemon.getHeldItems().length;
const playerHeldItems = getHeldItemCount(playerPokemon);
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
game.move.select(Moves.FALSE_SWIPE);
// Player gets hit by False Swipe and eats its own Sitrus Berry
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
});
it("should activate when a berry is stolen", async () => {
await game.classicMode.startBattle();
it("should activate when a berry is eaten, even if Berry Pouch preserves the berry", async () => {
game.override.enemyMoveset(Moves.FALSE_SWIPE)
.startingModifier([{ name: "BERRY_POUCH", count: 5850 }]);
await game.classicMode.startBattle([ Species.TREECKO ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerHeldItems = getHeldItemCount(playerPokemon);
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
// Player gets hit by False Swipe and eats its own Sitrus Berry
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(getHeldItemCount(playerPokemon)).toBe(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
});
it("should activate for the target, and not the stealer, when a berry is stolen", async () => {
await game.classicMode.startBattle([ Species.TREECKO ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
// Player uses Pluck and eats the opponent's berry
game.move.select(Moves.PLUCK);
await game.toNextTurn();
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
});
it("should activate when an item is knocked off", async () => {
await game.classicMode.startBattle();
await game.classicMode.startBattle([ Species.TREECKO ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
// Player uses Knock Off and removes the opponent's item
game.move.select(Moves.KNOCK_OFF);
await game.toNextTurn();
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
});
it("should activate when an item is stolen via attacking ability", async () => {
game.override
.ability(Abilities.MAGICIAN)
.startingHeldItems([
{ name: "MULTI_LENS", count: 3 },
]);
await game.classicMode.startBattle();
.startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items
await game.classicMode.startBattle([ Species.TREECKO ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
game.move.select(Moves.POPULATION_BOMB);
// Player steals the opponent's item via ability Magician
game.move.select(Moves.FALSE_SWIPE);
await game.toNextTurn();
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
});
it("should activate when an item is stolen via defending ability", async () => {
game.override
.startingLevel(45)
.enemyAbility(Abilities.PICKPOCKET)
.startingHeldItems([
{ name: "MULTI_LENS", count: 3 },
{ name: "SOUL_DEW", count: 1 },
{ name: "LUCKY_EGG", count: 1 },
]);
await game.classicMode.startBattle();
.enemyHeldItems([]); // Remove opponent's full stacks of held items so it can steal player's held items
await game.classicMode.startBattle([ Species.TREECKO ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
playerPokemon.abilityIndex = 2;
const playerHeldItems = playerPokemon.getHeldItems().length;
const playerHeldItems = getHeldItemCount(playerPokemon);
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
game.move.select(Moves.POPULATION_BOMB);
// Player's item gets stolen via ability Pickpocket
game.move.select(Moves.FALSE_SWIPE);
await game.toNextTurn();
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
});
it("should activate when an item is stolen via move", async () => {
vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]); // give Thief 100% steal rate
game.override.startingHeldItems([
{ name: "MULTI_LENS", count: 3 },
]);
await game.classicMode.startBattle();
game.override.moveset(Moves.THIEF)
.startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items
await game.classicMode.startBattle([ Species.TREECKO ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
// Player uses Thief and steals the opponent's item
game.move.select(Moves.THIEF);
await game.toNextTurn();
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
});
it("should activate when an item is stolen via grip claw", async () => {
game.override
.startingLevel(5)
.startingHeldItems([
{ name: "GRIP_CLAW", count: 5 },
{ name: "MULTI_LENS", count: 3 },
])
.enemyHeldItems([
{ name: "SOUL_DEW", count: 1 },
{ name: "LUCKY_EGG", count: 1 },
{ name: "LEFTOVERS", count: 1 },
{ name: "GRIP_CLAW", count: 1 },
{ name: "MULTI_LENS", count: 1 },
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
{ name: "BERRY", type: BerryType.LUM, count: 1 },
]);
await game.classicMode.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
while (enemyPokemon.getHeldItems().length === enemyHeldItemCt) {
game.move.select(Moves.POPULATION_BOMB);
await game.toNextTurn();
}
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
});
it("should not activate when a neutralizing ability is present", async () => {
game.override.enemyAbility(Abilities.NEUTRALIZING_GAS);
await game.classicMode.startBattle();
await game.classicMode.startBattle([ Species.TREECKO ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerHeldItems = playerPokemon.getHeldItems().length;
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
const gripClaw = playerPokemon.getHeldItems()[0] as ContactHeldItemTransferChanceModifier;
vi.spyOn(gripClaw, "chance", "get").mockReturnValue(100);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
// Player steals the opponent's item using Grip Claw
game.move.select(Moves.FALSE_SWIPE);
await game.toNextTurn();
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed);
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
});
it("should not activate when a neutralizing ability is present", async () => {
game.override.enemyAbility(Abilities.NEUTRALIZING_GAS)
.enemyMoveset(Moves.FALSE_SWIPE);
await game.classicMode.startBattle([ Species.TREECKO ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerHeldItems = getHeldItemCount(playerPokemon);
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
// Player gets hit by False Swipe and eats Sitrus Berry, which should not trigger Unburden
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
expect(playerPokemon.getTag(BattlerTagType.UNBURDEN)).toBeUndefined();
});
it("should activate when a move that consumes a berry is used", async () => {
game.override.enemyMoveset([ Moves.STUFF_CHEEKS ]);
await game.classicMode.startBattle();
game.override.moveset(Moves.STUFF_CHEEKS);
await game.classicMode.startBattle([ Species.TREECKO ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerHeldItemCt = getHeldItemCount(playerPokemon);
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
// Player uses Stuff Cheeks and eats its own berry
// Caution: Do not test this using opponent, there is a known issue where opponent can randomly generate with Salac Berry
game.move.select(Moves.STUFF_CHEEKS);
await game.toNextTurn();
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItemCt);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
});
it("should deactivate when a neutralizing gas user enters the field", async () => {
it("should deactivate temporarily when a neutralizing gas user is on the field", async () => {
game.override
.battleType("double")
.moveset([ Moves.SPLASH ]);
.ability(Abilities.NONE); // Disable ability override so that we can properly set abilities below
await game.classicMode.startBattle([ Species.TREECKO, Species.MEOWTH, Species.WEEZING ]);
const playerPokemon = game.scene.getPlayerParty();
const treecko = playerPokemon[0];
const weezing = playerPokemon[2];
treecko.abilityIndex = 2;
weezing.abilityIndex = 1;
const playerHeldItems = treecko.getHeldItems().length;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [ treecko, _meowth, weezing ] = game.scene.getPlayerParty();
treecko.abilityIndex = 2; // Treecko has Unburden
weezing.abilityIndex = 1; // Weezing has Neutralizing Gas
const playerHeldItems = getHeldItemCount(treecko);
const initialPlayerSpeed = treecko.getStat(Stat.SPD);
// Turn 1: Treecko gets hit by False Swipe and eats Sitrus Berry, activating Unburden
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
await game.phaseInterceptor.to("TurnEndPhase");
expect(treecko.getHeldItems().length).toBeLessThan(playerHeldItems);
expect(treecko.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
// Turn 2: Switch Meowth to Weezing, activating Neutralizing Gas
await game.toNextTurn();
game.move.select(Moves.SPLASH);
game.doSwitchPokemon(2);
await game.phaseInterceptor.to("TurnEndPhase");
expect(treecko.getHeldItems().length).toBeLessThan(playerHeldItems);
expect(treecko.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed);
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
// Turn 3: Switch Weezing to Meowth, deactivating Neutralizing Gas
await game.toNextTurn();
game.move.select(Moves.SPLASH);
game.doSwitchPokemon(2);
await game.phaseInterceptor.to("TurnEndPhase");
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
});
it("should not activate when passing a baton to a teammate switching in", async () => {
game.override.startingHeldItems([{ name: "BATON" }])
.moveset(Moves.BATON_PASS);
await game.classicMode.startBattle([ Species.TREECKO, Species.PURRLOIN ]);
const [ treecko, purrloin ] = game.scene.getPlayerParty();
const initialTreeckoSpeed = treecko.getStat(Stat.SPD);
const initialPurrloinSpeed = purrloin.getStat(Stat.SPD);
const unburdenAttr = treecko.getAbilityAttrs(PostItemLostAbAttr)[0];
vi.spyOn(unburdenAttr, "applyPostItemLost");
// Player uses Baton Pass, which also passes the Baton item
game.move.select(Moves.BATON_PASS);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
expect(getHeldItemCount(treecko)).toBe(0);
expect(getHeldItemCount(purrloin)).toBe(1);
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialTreeckoSpeed);
expect(purrloin.getEffectiveStat(Stat.SPD)).toBe(initialPurrloinSpeed);
expect(unburdenAttr.applyPostItemLost).not.toHaveBeenCalled();
});
it("should not speed up a Pokemon after it loses the ability Unburden", async () => {
game.override.enemyMoveset([ Moves.FALSE_SWIPE, Moves.WORRY_SEED ]);
await game.classicMode.startBattle([ Species.PURRLOIN ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerHeldItems = getHeldItemCount(playerPokemon);
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
// Turn 1: Get hit by False Swipe and eat Sitrus Berry, activating Unburden
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.FALSE_SWIPE);
await game.toNextTurn();
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
// Turn 2: Get hit by Worry Seed, deactivating Unburden
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.WORRY_SEED);
await game.toNextTurn();
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
});
it("should activate when a reviver seed is used", async () => {
game.override.startingHeldItems([{ name: "REVIVER_SEED" }])
.enemyMoveset([ Moves.WING_ATTACK ]);
await game.classicMode.startBattle([ Species.TREECKO ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerHeldItems = getHeldItemCount(playerPokemon);
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
// Turn 1: Get hit by Wing Attack and faint, activating Reviver Seed
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
});
// test for `.bypassFaint()` - singles
it("shouldn't persist when revived normally if activated while fainting", async () => {
game.override.enemyMoveset([ Moves.SPLASH, Moves.THIEF ]);
await game.classicMode.startBattle([ Species.TREECKO, Species.FEEBAS ]);
const treecko = game.scene.getPlayerPokemon()!;
const treeckoInitialHeldItems = getHeldItemCount(treecko);
const initialSpeed = treecko.getStat(Stat.SPD);
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.THIEF);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.doRevivePokemon(1);
game.doSwitchPokemon(1);
await game.forceEnemyMove(Moves.SPLASH);
await game.toNextTurn();
expect(game.scene.getPlayerPokemon()!).toBe(treecko);
expect(getHeldItemCount(treecko)).toBeLessThan(treeckoInitialHeldItems);
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialSpeed);
});
// test for `.bypassFaint()` - doubles
it("shouldn't persist when revived by revival blessing if activated while fainting", async () => {
game.override
.battleType("double")
.enemyMoveset([ Moves.SPLASH, Moves.THIEF ])
.moveset([ Moves.SPLASH, Moves.REVIVAL_BLESSING ])
.startingHeldItems([{ name: "WIDE_LENS" }]);
await game.classicMode.startBattle([ Species.TREECKO, Species.FEEBAS, Species.MILOTIC ]);
const treecko = game.scene.getPlayerField()[0];
const treeckoInitialHeldItems = getHeldItemCount(treecko);
const initialSpeed = treecko.getStat(Stat.SPD);
game.move.select(Moves.SPLASH);
game.move.select(Moves.REVIVAL_BLESSING, 1);
await game.forceEnemyMove(Moves.THIEF, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]);
game.doSelectPartyPokemon(0, "MoveEffectPhase");
await game.toNextTurn();
expect(game.scene.getPlayerField()[0]).toBe(treecko);
expect(getHeldItemCount(treecko)).toBeLessThan(treeckoInitialHeldItems);
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialSpeed);
});
});

View File

@ -296,7 +296,9 @@ describe("Abilities - Wimp Out", () => {
Species.TYRUNT
]);
game.move.select(Moves.SPLASH);
game.scene.getPlayerPokemon()!.hp *= 0.51;
game.move.select(Moves.ENDURE);
await game.phaseInterceptor.to("TurnEndPhase");
confirmNoSwitch();

Some files were not shown because too many files have changed in this diff Show More