Merge branch 'beta' into candy1-3

This commit is contained in:
Moka 2024-12-01 16:32:49 +01:00 committed by GitHub
commit 7063cd002d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
52 changed files with 715 additions and 432 deletions

View File

@ -4,7 +4,7 @@ import Pokemon, { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import PokemonSpecies, { allSpecies, getPokemonSpecies, PokemonSpeciesFilter } from "#app/data/pokemon-species"; import PokemonSpecies, { allSpecies, getPokemonSpecies, PokemonSpeciesFilter } from "#app/data/pokemon-species";
import { Constructor, isNullOrUndefined, randSeedInt } from "#app/utils"; import { Constructor, isNullOrUndefined, randSeedInt } from "#app/utils";
import * as Utils 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 { ConsumableModifier, ConsumablePokemonModifier, DoubleBattleChanceBoosterModifier, ExpBalanceModifier, ExpShareModifier, FusePokemonModifier, HealingBoosterModifier, Modifier, ModifierBar, ModifierPredicate, MultipleParticipantExpBonusModifier, PersistentModifier, PokemonExpBoosterModifier, PokemonFormChangeItemModifier, PokemonHeldItemModifier, PokemonHpRestoreModifier, PokemonIncrementingStatModifier, RememberMoveModifier, TerastallizeModifier, TurnHeldItemTransferModifier } from "./modifier/modifier";
import { PokeballType } from "#enums/pokeball"; import { PokeballType } from "#enums/pokeball";
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from "#app/data/battle-anims"; import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from "#app/data/battle-anims";
import { Phase } from "#app/phase"; import { Phase } from "#app/phase";
@ -47,7 +47,7 @@ import PokemonInfoContainer from "#app/ui/pokemon-info-container";
import { biomeDepths, getBiomeName } from "#app/data/balance/biomes"; import { biomeDepths, getBiomeName } from "#app/data/balance/biomes";
import { SceneBase } from "#app/scene-base"; import { SceneBase } from "#app/scene-base";
import CandyBar from "#app/ui/candy-bar"; import CandyBar from "#app/ui/candy-bar";
import { Variant, variantData } from "#app/data/variant"; import { Variant, variantColorCache, variantData, VariantSet } from "#app/data/variant";
import { Localizable } from "#app/interfaces/locales"; import { Localizable } from "#app/interfaces/locales";
import Overrides from "#app/overrides"; import Overrides from "#app/overrides";
import { InputsController } from "#app/inputs-controller"; import { InputsController } from "#app/inputs-controller";
@ -345,6 +345,33 @@ export default class BattleScene extends SceneBase {
this.load.atlas(key, `images/pokemon/${variant ? "variant/" : ""}${experimental ? "exp/" : ""}${atlasPath}.png`, `images/pokemon/${variant ? "variant/" : ""}${experimental ? "exp/" : ""}${atlasPath}.json`); this.load.atlas(key, `images/pokemon/${variant ? "variant/" : ""}${experimental ? "exp/" : ""}${atlasPath}.png`, `images/pokemon/${variant ? "variant/" : ""}${experimental ? "exp/" : ""}${atlasPath}.json`);
} }
/**
* Load the variant assets for the given sprite and stores them in {@linkcode variantColorCache}
*/
loadPokemonVariantAssets(spriteKey: string, fileRoot: string, variant?: Variant) {
const useExpSprite = this.experimentalSprites && this.hasExpSprite(spriteKey);
if (useExpSprite) {
fileRoot = `exp/${fileRoot}`;
}
let variantConfig = variantData;
fileRoot.split("/").map(p => variantConfig ? variantConfig = variantConfig[p] : null);
const variantSet = variantConfig as VariantSet;
if (variantSet && (variant !== undefined && variantSet[variant] === 1)) {
const populateVariantColors = (key: string): Promise<void> => {
return new Promise(resolve => {
if (variantColorCache.hasOwnProperty(key)) {
return resolve();
}
this.cachedFetch(`./images/pokemon/variant/${fileRoot}.json`).then(res => res.json()).then(c => {
variantColorCache[key] = c;
resolve();
});
});
};
populateVariantColors(spriteKey);
}
}
async preload() { async preload() {
if (DEBUG_RNG) { if (DEBUG_RNG) {
const scene = this; const scene = this;
@ -891,7 +918,7 @@ export default class BattleScene extends SceneBase {
return pokemon; return pokemon;
} }
addEnemyPokemon(species: PokemonSpecies, level: integer, trainerSlot: TrainerSlot, boss: boolean = false, dataSource?: PokemonData, postProcess?: (enemyPokemon: EnemyPokemon) => void): EnemyPokemon { addEnemyPokemon(species: PokemonSpecies, level: integer, trainerSlot: TrainerSlot, boss: boolean = false, shinyLock: boolean = false, dataSource?: PokemonData, postProcess?: (enemyPokemon: EnemyPokemon) => void): EnemyPokemon {
if (Overrides.OPP_LEVEL_OVERRIDE > 0) { if (Overrides.OPP_LEVEL_OVERRIDE > 0) {
level = Overrides.OPP_LEVEL_OVERRIDE; level = Overrides.OPP_LEVEL_OVERRIDE;
} }
@ -901,13 +928,11 @@ export default class BattleScene extends SceneBase {
boss = this.getEncounterBossSegments(this.currentBattle.waveIndex, level, species) > 1; boss = this.getEncounterBossSegments(this.currentBattle.waveIndex, level, species) > 1;
} }
const pokemon = new EnemyPokemon(this, species, level, trainerSlot, boss, dataSource); const pokemon = new EnemyPokemon(this, species, level, trainerSlot, boss, shinyLock, dataSource);
if (Overrides.OPP_FUSION_OVERRIDE) { if (Overrides.OPP_FUSION_OVERRIDE) {
pokemon.generateFusionSpecies(); pokemon.generateFusionSpecies();
} }
overrideModifiers(this, false);
overrideHeldItems(this, pokemon, false);
if (boss && !dataSource) { if (boss && !dataSource) {
const secondaryIvs = Utils.getIvsFromId(Utils.randSeedInt(4294967296)); const secondaryIvs = Utils.getIvsFromId(Utils.randSeedInt(4294967296));

View File

@ -3720,16 +3720,16 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr {
/** /**
* Deals damage to all sleeping opponents equal to 1/8 of their max hp (min 1) * Deals damage to all sleeping opponents equal to 1/8 of their max hp (min 1)
* @param {Pokemon} pokemon Pokemon that has this ability * @param pokemon Pokemon that has this ability
* @param {boolean} passive N/A * @param passive N/A
* @param {boolean} simulated true if applying in a simulated call. * @param simulated `true` if applying in a simulated call.
* @param {any[]} args N/A * @param args N/A
* @returns {boolean} true if any opponents are sleeping * @returns `true` if any opponents are sleeping
*/ */
applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise<boolean> { applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise<boolean> {
let hadEffect: boolean = false; let hadEffect: boolean = false;
for (const opp of pokemon.getOpponents()) { for (const opp of pokemon.getOpponents()) {
if ((opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(Abilities.COMATOSE)) && !opp.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { if ((opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(Abilities.COMATOSE)) && !opp.hasAbilityWithAttr(BlockNonDirectDamageAbAttr) && !opp.switchOutStatus) {
if (!simulated) { if (!simulated) {
opp.damageAndUpdate(Utils.toDmgValue(opp.getMaxHp() / 8), HitResult.OTHER); opp.damageAndUpdate(Utils.toDmgValue(opp.getMaxHp() / 8), HitResult.OTHER);
pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", { pokemonName: getPokemonNameWithAffix(opp) })); pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", { pokemonName: getPokemonNameWithAffix(opp) }));
@ -5713,9 +5713,7 @@ export function initAbilities() {
.condition(getSheerForceHitDisableAbCondition()), .condition(getSheerForceHitDisableAbCondition()),
new Ability(Abilities.SHEER_FORCE, 5) new Ability(Abilities.SHEER_FORCE, 5)
.attr(MovePowerBoostAbAttr, (user, target, move) => move.chance >= 1, 5461 / 4096) .attr(MovePowerBoostAbAttr, (user, target, move) => move.chance >= 1, 5461 / 4096)
.attr(MoveEffectChanceMultiplierAbAttr, 0) .attr(MoveEffectChanceMultiplierAbAttr, 0), // Should disable life orb, eject button, red card, kee/maranga berry if they get implemented
.edgeCase() // Should disable shell bell and Meloetta's relic song transformation
.edgeCase(), // Should disable life orb, eject button, red card, kee/maranga berry if they get implemented
new Ability(Abilities.CONTRARY, 5) new Ability(Abilities.CONTRARY, 5)
.attr(StatStageChangeMultiplierAbAttr, -1) .attr(StatStageChangeMultiplierAbAttr, -1)
.ignorable(), .ignorable(),
@ -5953,7 +5951,7 @@ export function initAbilities() {
.bypassFaint() .bypassFaint()
.partial(), // Meteor form should protect against status effects and yawn .partial(), // Meteor form should protect against status effects and yawn
new Ability(Abilities.STAKEOUT, 7) new Ability(Abilities.STAKEOUT, 7)
.attr(MovePowerBoostAbAttr, (user, target, move) => user?.scene.currentBattle.turnCommands[target?.getBattlerIndex() ?? BattlerIndex.ATTACKER]?.command === Command.POKEMON, 2), .attr(MovePowerBoostAbAttr, (user, target, move) => !!target?.turnData.switchedInThisTurn, 2),
new Ability(Abilities.WATER_BUBBLE, 7) new Ability(Abilities.WATER_BUBBLE, 7)
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5) .attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
.attr(MoveTypePowerBoostAbAttr, Type.WATER, 2) .attr(MoveTypePowerBoostAbAttr, Type.WATER, 2)

View File

@ -1144,7 +1144,7 @@ class FireGrassPledgeTag extends ArenaTag {
? arena.scene.getPlayerField() ? arena.scene.getPlayerField()
: arena.scene.getEnemyField(); : arena.scene.getEnemyField();
field.filter(pokemon => !pokemon.isOfType(Type.FIRE)).forEach(pokemon => { field.filter(pokemon => !pokemon.isOfType(Type.FIRE) && !pokemon.switchOutStatus).forEach(pokemon => {
// "{pokemonNameWithAffix} was hurt by the sea of fire!" // "{pokemonNameWithAffix} was hurt by the sea of fire!"
pokemon.scene.queueMessage(i18next.t("arenaTag:fireGrassPledgeLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); pokemon.scene.queueMessage(i18next.t("arenaTag:fireGrassPledgeLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }));
// TODO: Replace this with a proper animation // TODO: Replace this with a proper animation

View File

@ -3,10 +3,10 @@ import { Species } from "#enums/species";
export const POKERUS_STARTER_COUNT = 5; export const POKERUS_STARTER_COUNT = 5;
// #region Friendship constants // #region Friendship constants
export const CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER = 2; export const CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER = 3;
export const FRIENDSHIP_GAIN_FROM_BATTLE = 2; export const FRIENDSHIP_GAIN_FROM_BATTLE = 3;
export const FRIENDSHIP_GAIN_FROM_RARE_CANDY = 5; export const FRIENDSHIP_GAIN_FROM_RARE_CANDY = 6;
export const FRIENDSHIP_LOSS_FROM_FAINT = 10; export const FRIENDSHIP_LOSS_FROM_FAINT = 5;
/** /**
* Function to get the cumulative friendship threshold at which a candy is earned * Function to get the cumulative friendship threshold at which a candy is earned
@ -16,19 +16,19 @@ export const FRIENDSHIP_LOSS_FROM_FAINT = 10;
export function getStarterValueFriendshipCap(starterCost: number): number { export function getStarterValueFriendshipCap(starterCost: number): number {
switch (starterCost) { switch (starterCost) {
case 1: case 1:
return 20; return 25;
case 2: case 2:
return 40; return 50;
case 3: case 3:
return 60; return 75;
case 4: case 4:
return 100; return 100;
case 5: case 5:
return 140; return 150;
case 6: case 6:
return 200; return 200;
case 7: case 7:
return 280; return 300;
case 8: case 8:
case 9: case 9:
return 450; return 450;

View File

@ -1085,10 +1085,6 @@ export class OctolockTag extends TrappedTag {
super(BattlerTagType.OCTOLOCK, BattlerTagLapseType.TURN_END, 1, Moves.OCTOLOCK, sourceId); super(BattlerTagType.OCTOLOCK, BattlerTagLapseType.TURN_END, 1, Moves.OCTOLOCK, sourceId);
} }
canAdd(pokemon: Pokemon): boolean {
return !pokemon.getTag(BattlerTagType.OCTOLOCK);
}
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
const shouldLapse = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); const shouldLapse = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType);

View File

@ -1867,7 +1867,7 @@ export class FlameBurstAttr extends MoveEffectAttr {
applyAbAttrs(BlockNonDirectDamageAbAttr, targetAlly, cancelled); applyAbAttrs(BlockNonDirectDamageAbAttr, targetAlly, cancelled);
} }
if (cancelled.value || !targetAlly) { if (cancelled.value || !targetAlly || targetAlly.switchOutStatus) {
return false; return false;
} }
@ -7541,6 +7541,8 @@ const failIfLastInPartyCondition: MoveConditionFunc = (user: Pokemon, target: Po
return party.some(pokemon => pokemon.isActive() && !pokemon.isOnField()); return party.some(pokemon => pokemon.isActive() && !pokemon.isOnField());
}; };
const failIfGhostTypeCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => !target.isOfType(Type.GHOST);
export type MoveAttrFilter = (attr: MoveAttr) => boolean; export type MoveAttrFilter = (attr: MoveAttr) => boolean;
function applyMoveAttrsInternal(attrFilter: MoveAttrFilter, user: Pokemon | null, target: Pokemon | null, move: Move, args: any[]): Promise<void> { function applyMoveAttrsInternal(attrFilter: MoveAttrFilter, user: Pokemon | null, target: Pokemon | null, move: Move, args: any[]): Promise<void> {
@ -8287,6 +8289,7 @@ export function initMoves() {
new AttackMove(Moves.THIEF, Type.DARK, MoveCategory.PHYSICAL, 60, 100, 25, -1, 0, 2) new AttackMove(Moves.THIEF, Type.DARK, MoveCategory.PHYSICAL, 60, 100, 25, -1, 0, 2)
.attr(StealHeldItemChanceAttr, 0.3), .attr(StealHeldItemChanceAttr, 0.3),
new StatusMove(Moves.SPIDER_WEB, Type.BUG, -1, 10, -1, 0, 2) new StatusMove(Moves.SPIDER_WEB, Type.BUG, -1, 10, -1, 0, 2)
.condition(failIfGhostTypeCondition)
.attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1), .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1),
new StatusMove(Moves.MIND_READER, Type.NORMAL, -1, 5, -1, 0, 2) new StatusMove(Moves.MIND_READER, Type.NORMAL, -1, 5, -1, 0, 2)
.attr(IgnoreAccuracyAttr), .attr(IgnoreAccuracyAttr),
@ -8423,6 +8426,7 @@ export function initMoves() {
new AttackMove(Moves.STEEL_WING, Type.STEEL, MoveCategory.PHYSICAL, 70, 90, 25, 10, 0, 2) new AttackMove(Moves.STEEL_WING, Type.STEEL, MoveCategory.PHYSICAL, 70, 90, 25, 10, 0, 2)
.attr(StatStageChangeAttr, [ Stat.DEF ], 1, true), .attr(StatStageChangeAttr, [ Stat.DEF ], 1, true),
new StatusMove(Moves.MEAN_LOOK, Type.NORMAL, -1, 5, -1, 0, 2) new StatusMove(Moves.MEAN_LOOK, Type.NORMAL, -1, 5, -1, 0, 2)
.condition(failIfGhostTypeCondition)
.attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1), .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1),
new StatusMove(Moves.ATTRACT, Type.NORMAL, 100, 15, -1, 0, 2) new StatusMove(Moves.ATTRACT, Type.NORMAL, 100, 15, -1, 0, 2)
.attr(AddBattlerTagAttr, BattlerTagType.INFATUATED) .attr(AddBattlerTagAttr, BattlerTagType.INFATUATED)
@ -8802,6 +8806,7 @@ export function initMoves() {
new SelfStatusMove(Moves.IRON_DEFENSE, Type.STEEL, -1, 15, -1, 0, 3) new SelfStatusMove(Moves.IRON_DEFENSE, Type.STEEL, -1, 15, -1, 0, 3)
.attr(StatStageChangeAttr, [ Stat.DEF ], 2, true), .attr(StatStageChangeAttr, [ Stat.DEF ], 2, true),
new StatusMove(Moves.BLOCK, Type.NORMAL, -1, 5, -1, 0, 3) new StatusMove(Moves.BLOCK, Type.NORMAL, -1, 5, -1, 0, 3)
.condition(failIfGhostTypeCondition)
.attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1), .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1),
new StatusMove(Moves.HOWL, Type.NORMAL, -1, 40, -1, 0, 3) new StatusMove(Moves.HOWL, Type.NORMAL, -1, 40, -1, 0, 3)
.attr(StatStageChangeAttr, [ Stat.ATK ], 1) .attr(StatStageChangeAttr, [ Stat.ATK ], 1)
@ -10096,6 +10101,7 @@ export function initMoves() {
.attr(EatBerryAttr) .attr(EatBerryAttr)
.target(MoveTarget.ALL), .target(MoveTarget.ALL),
new StatusMove(Moves.OCTOLOCK, Type.FIGHTING, 100, 15, -1, 0, 8) new StatusMove(Moves.OCTOLOCK, Type.FIGHTING, 100, 15, -1, 0, 8)
.condition(failIfGhostTypeCondition)
.attr(AddBattlerTagAttr, BattlerTagType.OCTOLOCK, false, true, 1), .attr(AddBattlerTagAttr, BattlerTagType.OCTOLOCK, false, true, 1),
new AttackMove(Moves.BOLT_BEAK, Type.ELECTRIC, MoveCategory.PHYSICAL, 85, 100, 10, -1, 0, 8) new AttackMove(Moves.BOLT_BEAK, Type.ELECTRIC, MoveCategory.PHYSICAL, 85, 100, 10, -1, 0, 8)
.attr(FirstAttackDoublePowerAttr), .attr(FirstAttackDoublePowerAttr),

View File

@ -216,6 +216,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
species: getPokemonSpecies(Species.GREEDENT), species: getPokemonSpecies(Species.GREEDENT),
isBoss: true, isBoss: true,
bossSegments: 3, bossSegments: 3,
shiny: false, // Shiny lock because of consistency issues between the different options
moveSet: [ Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.CRUNCH ], moveSet: [ Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.CRUNCH ],
modifierConfigs: bossModifierConfigs, modifierConfigs: bossModifierConfigs,
tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ],
@ -353,9 +354,9 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
}) })
.withOptionPhase(async (scene: BattleScene) => { .withOptionPhase(async (scene: BattleScene) => {
// Let it have the food // Let it have the food
// Greedent joins the team, level equal to 2 below highest party member // Greedent joins the team, level equal to 2 below highest party member (shiny locked)
const level = getHighestLevelPlayerPokemon(scene, false, true).level - 2; const level = getHighestLevelPlayerPokemon(scene, false, true).level - 2;
const greedent = new EnemyPokemon(scene, getPokemonSpecies(Species.GREEDENT), level, TrainerSlot.NONE, false); const greedent = new EnemyPokemon(scene, getPokemonSpecies(Species.GREEDENT), level, TrainerSlot.NONE, false, true);
greedent.moveset = [ new PokemonMove(Moves.THRASH), new PokemonMove(Moves.BODY_PRESS), new PokemonMove(Moves.STUFF_CHEEKS), new PokemonMove(Moves.SLACK_OFF) ]; greedent.moveset = [ new PokemonMove(Moves.THRASH), new PokemonMove(Moves.BODY_PRESS), new PokemonMove(Moves.STUFF_CHEEKS), new PokemonMove(Moves.SLACK_OFF) ];
greedent.passive = true; greedent.passive = true;

View File

@ -98,7 +98,9 @@ export const BerriesAboundEncounter: MysteryEncounter =
tint: 0.25, tint: 0.25,
x: -5, x: -5,
repeat: true, repeat: true,
isPokemon: true isPokemon: true,
isShiny: bossPokemon.shiny,
variant: bossPokemon.variant
} }
]; ];

View File

@ -276,6 +276,8 @@ export const ClowningAroundEncounter: MysteryEncounter =
generateItemsOfTier(scene, mostHeldItemsPokemon, numBerries, "Berries"); generateItemsOfTier(scene, mostHeldItemsPokemon, numBerries, "Berries");
// Shuffle Transferable held items in the same tier (only shuffles Ultra and Rogue atm) // Shuffle Transferable held items in the same tier (only shuffles Ultra and Rogue atm)
// For the purpose of this ME, Soothe Bells and Lucky Eggs are counted as Ultra tier
// And Golden Eggs as Rogue tier
let numUltra = 0; let numUltra = 0;
let numRogue = 0; let numRogue = 0;
items.filter(m => m.isTransferable && !(m instanceof BerryModifier)) items.filter(m => m.isTransferable && !(m instanceof BerryModifier))
@ -285,7 +287,7 @@ export const ClowningAroundEncounter: MysteryEncounter =
if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) { if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) {
numRogue += m.stackCount; numRogue += m.stackCount;
scene.removeModifier(m); scene.removeModifier(m);
} else if (type.id === "LUCKY_EGG" || tier === ModifierTier.ULTRA) { } else if (type.id === "LUCKY_EGG" || type.id === "SOOTHE_BELL" || tier === ModifierTier.ULTRA) {
numUltra += m.stackCount; numUltra += m.stackCount;
scene.removeModifier(m); scene.removeModifier(m);
} }
@ -456,7 +458,6 @@ function generateItemsOfTier(scene: BattleScene, pokemon: PlayerPokemon, numItem
[ modifierTypes.LEFTOVERS, 4 ], [ modifierTypes.LEFTOVERS, 4 ],
[ modifierTypes.SHELL_BELL, 4 ], [ modifierTypes.SHELL_BELL, 4 ],
[ modifierTypes.SOUL_DEW, 10 ], [ modifierTypes.SOUL_DEW, 10 ],
[ modifierTypes.SOOTHE_BELL, 3 ],
[ modifierTypes.SCOPE_LENS, 1 ], [ modifierTypes.SCOPE_LENS, 1 ],
[ modifierTypes.BATON, 1 ], [ modifierTypes.BATON, 1 ],
[ modifierTypes.FOCUS_BAND, 5 ], [ modifierTypes.FOCUS_BAND, 5 ],

View File

@ -92,9 +92,13 @@ export const DancingLessonsEncounter: MysteryEncounter =
.withCatchAllowed(true) .withCatchAllowed(true)
.withFleeAllowed(false) .withFleeAllowed(false)
.withOnVisualsStart((scene: BattleScene) => { .withOnVisualsStart((scene: BattleScene) => {
const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, scene.getEnemyPokemon()!, scene.getPlayerPokemon()!); const oricorio = scene.getEnemyPokemon()!;
danceAnim.play(scene); const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, oricorio, scene.getPlayerPokemon()!);
danceAnim.play(scene, false, () => {
if (oricorio.shiny) {
oricorio.sparkle();
}
});
return true; return true;
}) })
.withIntroDialogue([ .withIntroDialogue([
@ -136,7 +140,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
} }
const oricorioData = new PokemonData(enemyPokemon); const oricorioData = new PokemonData(enemyPokemon);
const oricorio = scene.addEnemyPokemon(species, level, TrainerSlot.NONE, false, oricorioData); const oricorio = scene.addEnemyPokemon(species, level, TrainerSlot.NONE, false, false, oricorioData);
// Adds a real Pokemon sprite to the field (required for the animation) // Adds a real Pokemon sprite to the field (required for the animation)
scene.getEnemyParty().forEach(enemyPokemon => { scene.getEnemyParty().forEach(enemyPokemon => {

View File

@ -114,7 +114,9 @@ export const FightOrFlightEncounter: MysteryEncounter =
tint: 0.25, tint: 0.25,
x: -5, x: -5,
repeat: true, repeat: true,
isPokemon: true isPokemon: true,
isShiny: bossPokemon.shiny,
variant: bossPokemon.variant
}, },
]; ];

View File

@ -194,10 +194,10 @@ async function summonPlayerPokemon(scene: BattleScene) {
playerAnimationPromise = summonPlayerPokemonAnimation(scene, playerPokemon); playerAnimationPromise = summonPlayerPokemonAnimation(scene, playerPokemon);
}); });
// Also loads Wobbuffet data // Also loads Wobbuffet data (cannot be shiny)
const enemySpecies = getPokemonSpecies(Species.WOBBUFFET); const enemySpecies = getPokemonSpecies(Species.WOBBUFFET);
scene.currentBattle.enemyParty = []; scene.currentBattle.enemyParty = [];
const wobbuffet = scene.addEnemyPokemon(enemySpecies, encounter.misc.playerPokemon.level, TrainerSlot.NONE, false); const wobbuffet = scene.addEnemyPokemon(enemySpecies, encounter.misc.playerPokemon.level, TrainerSlot.NONE, false, true);
wobbuffet.ivs = [ 0, 0, 0, 0, 0, 0 ]; wobbuffet.ivs = [ 0, 0, 0, 0, 0, 0 ];
wobbuffet.setNature(Nature.MILD); wobbuffet.setNature(Nature.MILD);
wobbuffet.setAlpha(0); wobbuffet.setAlpha(0);

View File

@ -12,8 +12,7 @@ import PokemonSpecies, { allSpecies, getPokemonSpecies } from "#app/data/pokemon
import { getTypeRgb } from "#app/data/type"; import { getTypeRgb } from "#app/data/type";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
import * as Utils from "#app/utils"; import { NumberHolder, isNullOrUndefined, randInt, randSeedInt, randSeedShuffle } from "#app/utils";
import { IntegerHolder, isNullOrUndefined, randInt, randSeedInt, randSeedShuffle } from "#app/utils";
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon"; import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
import { HiddenAbilityRateBoosterModifier, PokemonFormChangeItemModifier, PokemonHeldItemModifier, ShinyRateBoosterModifier, SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { HiddenAbilityRateBoosterModifier, PokemonFormChangeItemModifier, PokemonHeldItemModifier, ShinyRateBoosterModifier, SpeciesStatBoosterModifier } from "#app/modifier/modifier";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
@ -27,6 +26,7 @@ import { trainerNamePools } from "#app/data/trainer-names";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
import { addPokemonDataToDexAndValidateAchievements } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { addPokemonDataToDexAndValidateAchievements } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import type { PokeballType } from "#enums/pokeball"; import type { PokeballType } from "#enums/pokeball";
import { doShinySparkleAnim } from "#app/field/anims";
/** the i18n namespace for the encounter */ /** the i18n namespace for the encounter */
const namespace = "mysteryEncounters/globalTradeSystem"; const namespace = "mysteryEncounters/globalTradeSystem";
@ -230,7 +230,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
const tradePokemon = new EnemyPokemon(scene, randomTradeOption, pokemon.level, TrainerSlot.NONE, false); const tradePokemon = new EnemyPokemon(scene, randomTradeOption, pokemon.level, TrainerSlot.NONE, false);
// Extra shiny roll at 1/128 odds (boosted by events and charms) // Extra shiny roll at 1/128 odds (boosted by events and charms)
if (!tradePokemon.shiny) { if (!tradePokemon.shiny) {
const shinyThreshold = new Utils.IntegerHolder(WONDER_TRADE_SHINY_CHANCE); const shinyThreshold = new NumberHolder(WONDER_TRADE_SHINY_CHANCE);
if (scene.eventManager.isEventActive()) { if (scene.eventManager.isEventActive()) {
shinyThreshold.value *= scene.eventManager.getShinyMultiplier(); shinyThreshold.value *= scene.eventManager.getShinyMultiplier();
} }
@ -247,7 +247,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
const hiddenIndex = tradePokemon.species.ability2 ? 2 : 1; const hiddenIndex = tradePokemon.species.ability2 ? 2 : 1;
if (tradePokemon.species.abilityHidden) { if (tradePokemon.species.abilityHidden) {
if (tradePokemon.abilityIndex < hiddenIndex) { if (tradePokemon.abilityIndex < hiddenIndex) {
const hiddenAbilityChance = new IntegerHolder(64); const hiddenAbilityChance = new NumberHolder(64);
scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value); const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value);
@ -797,6 +797,14 @@ function doTradeReceivedSequence(scene: BattleScene, receivedPokemon: PlayerPoke
receivedPokeballSprite.x = tradeBaseBg.displayWidth / 2; receivedPokeballSprite.x = tradeBaseBg.displayWidth / 2;
receivedPokeballSprite.y = tradeBaseBg.displayHeight / 2 - 100; receivedPokeballSprite.y = tradeBaseBg.displayHeight / 2 - 100;
// Received pokemon sparkles
let pokemonShinySparkle: Phaser.GameObjects.Sprite;
if (receivedPokemon.shiny) {
pokemonShinySparkle = scene.add.sprite(receivedPokemonSprite.x, receivedPokemonSprite.y, "shiny");
pokemonShinySparkle.setVisible(false);
tradeContainer.add(pokemonShinySparkle);
}
const BASE_ANIM_DURATION = 1000; const BASE_ANIM_DURATION = 1000;
// Pokeball falls to the screen // Pokeball falls to the screen
@ -835,6 +843,11 @@ function doTradeReceivedSequence(scene: BattleScene, receivedPokemon: PlayerPoke
scale: 1, scale: 1,
alpha: 0, alpha: 0,
onComplete: () => { onComplete: () => {
if (receivedPokemon.shiny) {
scene.time.delayedCall(500, () => {
doShinySparkleAnim(scene, pokemonShinySparkle, receivedPokemon.variant);
});
}
receivedPokeballSprite.destroy(); receivedPokeballSprite.destroy();
scene.time.delayedCall(2000, () => resolve()); scene.time.delayedCall(2000, () => resolve());
} }

View File

@ -60,6 +60,7 @@ export const SlumberingSnorlaxEncounter: MysteryEncounter =
const pokemonConfig: EnemyPokemonConfig = { const pokemonConfig: EnemyPokemonConfig = {
species: bossSpecies, species: bossSpecies,
isBoss: true, isBoss: true,
shiny: false, // Shiny lock because shiny is rolled only if the battle option is picked
status: [ StatusEffect.SLEEP, 5 ], // Extra turns on timer for Snorlax's start of fight moves status: [ StatusEffect.SLEEP, 5 ], // Extra turns on timer for Snorlax's start of fight moves
moveSet: [ Moves.REST, Moves.SLEEP_TALK, Moves.CRUNCH, Moves.GIGA_IMPACT ], moveSet: [ Moves.REST, Moves.SLEEP_TALK, Moves.CRUNCH, Moves.GIGA_IMPACT ],
modifierConfigs: [ modifierConfigs: [

View File

@ -72,13 +72,11 @@ export const ThePokemonSalesmanEncounter: MysteryEncounter =
let pokemon: PlayerPokemon; let pokemon: PlayerPokemon;
if (randSeedInt(SHINY_MAGIKARP_WEIGHT) === 0 || isNullOrUndefined(species.abilityHidden) || species.abilityHidden === Abilities.NONE) { if (randSeedInt(SHINY_MAGIKARP_WEIGHT) === 0 || isNullOrUndefined(species.abilityHidden) || species.abilityHidden === Abilities.NONE) {
// If no HA mon found or you roll 1%, give shiny Magikarp // If no HA mon found or you roll 1%, give shiny Magikarp with random variant
species = getPokemonSpecies(Species.MAGIKARP); species = getPokemonSpecies(Species.MAGIKARP);
const hiddenIndex = species.ability2 ? 2 : 1; pokemon = new PlayerPokemon(scene, species, 5, 2, species.formIndex, undefined, true);
pokemon = new PlayerPokemon(scene, species, 5, hiddenIndex, species.formIndex, undefined, true, 0);
} else { } else {
const hiddenIndex = species.ability2 ? 2 : 1; pokemon = new PlayerPokemon(scene, species, 5, 2, species.formIndex);
pokemon = new PlayerPokemon(scene, species, 5, hiddenIndex, species.formIndex);
} }
pokemon.generateAndPopulateMoveset(); pokemon.generateAndPopulateMoveset();
@ -88,7 +86,9 @@ export const ThePokemonSalesmanEncounter: MysteryEncounter =
fileRoot: fileRoot, fileRoot: fileRoot,
hasShadow: true, hasShadow: true,
repeat: true, repeat: true,
isPokemon: true isPokemon: true,
isShiny: pokemon.shiny,
variant: pokemon.variant
}); });
const starterTier = speciesStarterCosts[species.speciesId]; const starterTier = speciesStarterCosts[species.speciesId];

View File

@ -79,6 +79,7 @@ export const TheStrongStuffEncounter: MysteryEncounter =
species: getPokemonSpecies(Species.SHUCKLE), species: getPokemonSpecies(Species.SHUCKLE),
isBoss: true, isBoss: true,
bossSegments: 5, bossSegments: 5,
shiny: false, // Shiny lock because shiny is rolled only if the battle option is picked
customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }), customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }),
nature: Nature.BOLD, nature: Nature.BOLD,
moveSet: [ Moves.INFESTATION, Moves.SALT_CURE, Moves.GASTRO_ACID, Moves.HEAL_ORDER ], moveSet: [ Moves.INFESTATION, Moves.SALT_CURE, Moves.GASTRO_ACID, Moves.HEAL_ORDER ],

View File

@ -61,11 +61,12 @@ export const TrashToTreasureEncounter: MysteryEncounter =
.withOnInit((scene: BattleScene) => { .withOnInit((scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
// Calculate boss mon // Calculate boss mon (shiny locked)
const bossSpecies = getPokemonSpecies(Species.GARBODOR); const bossSpecies = getPokemonSpecies(Species.GARBODOR);
const pokemonConfig: EnemyPokemonConfig = { const pokemonConfig: EnemyPokemonConfig = {
species: bossSpecies, species: bossSpecies,
isBoss: true, isBoss: true,
shiny: false, // Shiny lock because of custom intro sprite
formIndex: 1, // Gmax formIndex: 1, // Gmax
bossSegmentModifier: 1, // +1 Segment from normal bossSegmentModifier: 1, // +1 Segment from normal
moveSet: [ Moves.PAYBACK, Moves.GUNK_SHOT, Moves.STOMPING_TANTRUM, Moves.DRAIN_PUNCH ] moveSet: [ Moves.PAYBACK, Moves.GUNK_SHOT, Moves.STOMPING_TANTRUM, Moves.DRAIN_PUNCH ]

View File

@ -100,7 +100,9 @@ export const UncommonBreedEncounter: MysteryEncounter =
hasShadow: true, hasShadow: true,
x: -5, x: -5,
repeat: true, repeat: true,
isPokemon: true isPokemon: true,
isShiny: pokemon.shiny,
variant: pokemon.variant
}, },
]; ];
@ -113,13 +115,15 @@ export const UncommonBreedEncounter: MysteryEncounter =
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
const pokemonSprite = encounter.introVisuals!.getSprites(); const pokemonSprite = encounter.introVisuals!.getSprites();
scene.tweens.add({ // Bounce at the end // Bounce at the end, then shiny sparkle if the Pokemon is shiny
scene.tweens.add({
targets: pokemonSprite, targets: pokemonSprite,
duration: 300, duration: 300,
ease: "Cubic.easeOut", ease: "Cubic.easeOut",
yoyo: true, yoyo: true,
y: "-=20", y: "-=20",
loop: 1, loop: 1,
onComplete: () => encounter.introVisuals?.playShinySparkles()
}); });
scene.time.delayedCall(500, () => scene.playSound("battle_anims/PRSFX- Spotlight2")); scene.time.delayedCall(500, () => scene.playSound("battle_anims/PRSFX- Spotlight2"));

View File

@ -184,7 +184,7 @@ export async function initBattleWithEnemyConfig(scene: BattleScene, partyConfig:
dataSource = config.dataSource; dataSource = config.dataSource;
enemySpecies = config.species; enemySpecies = config.species;
isBoss = config.isBoss; isBoss = config.isBoss;
battle.enemyParty[e] = scene.addEnemyPokemon(enemySpecies, level, TrainerSlot.TRAINER, isBoss, dataSource); battle.enemyParty[e] = scene.addEnemyPokemon(enemySpecies, level, TrainerSlot.TRAINER, isBoss, false, dataSource);
} else { } else {
battle.enemyParty[e] = battle.trainer.genPartyMember(e); battle.enemyParty[e] = battle.trainer.genPartyMember(e);
} }
@ -202,7 +202,7 @@ export async function initBattleWithEnemyConfig(scene: BattleScene, partyConfig:
enemySpecies = scene.randomSpecies(battle.waveIndex, level, true); enemySpecies = scene.randomSpecies(battle.waveIndex, level, true);
} }
battle.enemyParty[e] = scene.addEnemyPokemon(enemySpecies, level, TrainerSlot.NONE, isBoss, dataSource); battle.enemyParty[e] = scene.addEnemyPokemon(enemySpecies, level, TrainerSlot.NONE, isBoss, false, dataSource);
} }
} }

View File

@ -351,6 +351,10 @@ export class MeloettaFormChangePostMoveTrigger extends SpeciesFormChangePostMove
if (pokemon.scene.gameMode.hasChallenge(Challenges.SINGLE_TYPE)) { if (pokemon.scene.gameMode.hasChallenge(Challenges.SINGLE_TYPE)) {
return false; return false;
} else { } else {
// Meloetta will not transform if it has the ability Sheer Force when using Relic Song
if (pokemon.hasAbility(Abilities.SHEER_FORCE)) {
return false;
}
return super.canChange(pokemon); return super.canChange(pokemon);
} }
} }

View File

@ -15,7 +15,7 @@ import { EvolutionLevel, SpeciesWildEvolutionDelay, pokemonEvolutions, pokemonPr
import { Type } from "#enums/type"; import { Type } from "#enums/type";
import { LevelMoves, pokemonFormLevelMoves, pokemonFormLevelMoves as pokemonSpeciesFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves"; import { LevelMoves, pokemonFormLevelMoves, pokemonFormLevelMoves as pokemonSpeciesFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { Variant, VariantSet, variantColorCache, variantData } from "#app/data/variant"; import { Variant, VariantSet, variantData } from "#app/data/variant";
import { speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters"; import { speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters";
import { SpeciesFormKey } from "#enums/species-form-key"; import { SpeciesFormKey } from "#enums/species-form-key";
@ -511,29 +511,8 @@ export abstract class PokemonSpeciesForm {
} else { } else {
scene.anims.get(spriteKey).frameRate = 10; scene.anims.get(spriteKey).frameRate = 10;
} }
let spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant).replace("variant/", "").replace(/_[1-3]$/, ""); const spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant).replace("variant/", "").replace(/_[1-3]$/, "");
const useExpSprite = scene.experimentalSprites && scene.hasExpSprite(spriteKey); scene.loadPokemonVariantAssets(spriteKey, spritePath, variant);
if (useExpSprite) {
spritePath = `exp/${spritePath}`;
}
let config = variantData;
spritePath.split("/").map(p => config ? config = config[p] : null);
const variantSet = config as VariantSet;
if (variantSet && (variant !== undefined && variantSet[variant] === 1)) {
const populateVariantColors = (key: string): Promise<void> => {
return new Promise(resolve => {
if (variantColorCache.hasOwnProperty(key)) {
return resolve();
}
scene.cachedFetch(`./images/pokemon/variant/${spritePath}.json`).then(res => res.json()).then(c => {
variantColorCache[key] = c;
resolve();
});
});
};
populateVariantColors(spriteKey).then(() => resolve());
return;
}
resolve(); resolve();
}); });
if (startLoad) { if (startLoad) {

View File

@ -1173,16 +1173,28 @@ export function getRandomPartyMemberFunc(speciesPool: Species[], trainerSlot: Tr
if (!ignoreEvolution) { if (!ignoreEvolution) {
species = getPokemonSpecies(species).getTrainerSpeciesForLevel(level, true, strength, scene.currentBattle.waveIndex); species = getPokemonSpecies(species).getTrainerSpeciesForLevel(level, true, strength, scene.currentBattle.waveIndex);
} }
return scene.addEnemyPokemon(getPokemonSpecies(species), level, trainerSlot, undefined, undefined, postProcess); return scene.addEnemyPokemon(getPokemonSpecies(species), level, trainerSlot, undefined, false, undefined, postProcess);
}; };
} }
function getSpeciesFilterRandomPartyMemberFunc(speciesFilter: PokemonSpeciesFilter, trainerSlot: TrainerSlot = TrainerSlot.TRAINER, allowLegendaries?: boolean, postProcess?: (EnemyPokemon: EnemyPokemon) => void): PartyMemberFunc { function getSpeciesFilterRandomPartyMemberFunc(
const originalSpeciesFilter = speciesFilter; originalSpeciesFilter: PokemonSpeciesFilter,
speciesFilter = (species: PokemonSpecies) => (allowLegendaries || (!species.legendary && !species.subLegendary && !species.mythical)) && !species.isTrainerForbidden() && originalSpeciesFilter(species); trainerSlot: TrainerSlot = TrainerSlot.TRAINER,
return (scene: BattleScene, level: integer, strength: PartyMemberStrength) => { allowLegendaries?: boolean,
const ret = scene.addEnemyPokemon(getPokemonSpecies(scene.randomSpecies(scene.currentBattle.waveIndex, level, false, speciesFilter).getTrainerSpeciesForLevel(level, true, strength, scene.currentBattle.waveIndex)), level, trainerSlot, undefined, undefined, postProcess); postProcess?: (EnemyPokemon: EnemyPokemon) => void
return ret; ): PartyMemberFunc {
const speciesFilter = (species: PokemonSpecies): boolean => {
const notLegendary = !species.legendary && !species.subLegendary && !species.mythical;
return (allowLegendaries || notLegendary) && !species.isTrainerForbidden() && originalSpeciesFilter(species);
};
return (scene: BattleScene, level: number, strength: PartyMemberStrength) => {
const waveIndex = scene.currentBattle.waveIndex;
const species = getPokemonSpecies(scene.randomSpecies(waveIndex, level, false, speciesFilter)
.getTrainerSpeciesForLevel(level, true, strength, waveIndex));
return scene.addEnemyPokemon(species, level, trainerSlot, undefined, false, undefined, postProcess);
}; };
} }

View File

@ -1,6 +1,7 @@
import BattleScene from "../battle-scene"; import BattleScene from "#app/battle-scene";
import { PokeballType } from "#enums/pokeball"; import { PokeballType } from "#enums/pokeball";
import * as Utils from "../utils"; import { Variant } from "#app/data/variant";
import { getFrameMs, randGauss } from "#app/utils";
export function addPokeballOpenParticles(scene: BattleScene, x: number, y: number, pokeballType: PokeballType): void { export function addPokeballOpenParticles(scene: BattleScene, x: number, y: number, pokeballType: PokeballType): void {
switch (pokeballType) { switch (pokeballType) {
@ -127,7 +128,7 @@ function doFanOutParticle(scene: BattleScene, trigIndex: integer, x: integer, y:
const particleTimer = scene.tweens.addCounter({ const particleTimer = scene.tweens.addCounter({
repeat: -1, repeat: -1,
duration: Utils.getFrameMs(1), duration: getFrameMs(1),
onRepeat: () => { onRepeat: () => {
updateParticle(); updateParticle();
} }
@ -159,7 +160,7 @@ export function addPokeballCaptureStars(scene: BattleScene, pokeball: Phaser.Gam
} }
}); });
const dist = Utils.randGauss(25); const dist = randGauss(25);
scene.tweens.add({ scene.tweens.add({
targets: particle, targets: particle,
x: pokeball.x + dist, x: pokeball.x + dist,
@ -185,3 +186,31 @@ export function sin(index: integer, amplitude: integer): number {
export function cos(index: integer, amplitude: integer): number { export function cos(index: integer, amplitude: integer): number {
return amplitude * Math.cos(index * (Math.PI / 128)); return amplitude * Math.cos(index * (Math.PI / 128));
} }
/**
* Play the shiny sparkle animation and sound effect for the given sprite
* First ensures that the animation has been properly initialized
* @param sparkleSprite the Sprite to play the animation on
* @param variant which shiny {@linkcode variant} to play the animation for
*/
export function doShinySparkleAnim(scene: BattleScene, sparkleSprite: Phaser.GameObjects.Sprite, variant: Variant) {
const keySuffix = variant ? `_${variant + 1}` : "";
const spriteKey = `shiny${keySuffix}`;
const animationKey = `sparkle${keySuffix}`;
// Make sure the animation exists, and create it if not
if (!scene.anims.exists(animationKey)) {
const frameNames = scene.anims.generateFrameNames(spriteKey, { suffix: ".png", end: 34 });
scene.anims.create({
key: `sparkle${keySuffix}`,
frames: frameNames,
frameRate: 32,
showOnStart: true,
hideOnComplete: true,
});
}
// Play the animation
sparkleSprite.play(animationKey);
scene.playSound("se/sparkle");
}

View File

@ -1,10 +1,12 @@
import { GameObjects } from "phaser"; import { GameObjects } from "phaser";
import BattleScene from "../battle-scene"; import BattleScene from "#app/battle-scene";
import MysteryEncounter from "../data/mystery-encounters/mystery-encounter"; import MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { isNullOrUndefined } from "#app/utils"; import { isNullOrUndefined } from "#app/utils";
import { getSpriteKeysFromSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { getSpriteKeysFromSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import PlayAnimationConfig = Phaser.Types.Animations.PlayAnimationConfig; import PlayAnimationConfig = Phaser.Types.Animations.PlayAnimationConfig;
import { Variant } from "#app/data/variant";
import { doShinySparkleAnim } from "#app/field/anims";
type KnownFileRoot = type KnownFileRoot =
| "arenas" | "arenas"
@ -59,6 +61,10 @@ export class MysteryEncounterSpriteConfig {
scale?: number; scale?: number;
/** If you are using a Pokemon sprite, set to `true`. This will ensure variant, form, gender, shiny sprites are loaded properly */ /** If you are using a Pokemon sprite, set to `true`. This will ensure variant, form, gender, shiny sprites are loaded properly */
isPokemon?: boolean; isPokemon?: boolean;
/** If using a Pokemon shiny sprite, needs to be set to ensure the correct variant assets get loaded and displayed */
isShiny?: boolean;
/** If using a Pokemon shiny sprite, needs to be set to ensure the correct variant assets get loaded and displayed */
variant?: Variant;
/** If you are using an item sprite, set to `true` */ /** If you are using an item sprite, set to `true` */
isItem?: boolean; isItem?: boolean;
/** The sprites alpha. `0` - `1` The lower the number, the more transparent */ /** The sprites alpha. `0` - `1` The lower the number, the more transparent */
@ -74,6 +80,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
public encounter: MysteryEncounter; public encounter: MysteryEncounter;
public spriteConfigs: MysteryEncounterSpriteConfig[]; public spriteConfigs: MysteryEncounterSpriteConfig[];
public enterFromRight: boolean; public enterFromRight: boolean;
private shinySparkleSprites: { sprite: Phaser.GameObjects.Sprite, variant: Variant }[];
constructor(scene: BattleScene, encounter: MysteryEncounter) { constructor(scene: BattleScene, encounter: MysteryEncounter) {
super(scene, -72, 76); super(scene, -72, 76);
@ -86,7 +93,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
}; };
if (!isNullOrUndefined(result.species)) { if (!isNullOrUndefined(result.species)) {
const keys = getSpriteKeysFromSpecies(result.species); const keys = getSpriteKeysFromSpecies(result.species, undefined, undefined, result.isShiny, result.variant);
result.spriteKey = keys.spriteKey; result.spriteKey = keys.spriteKey;
result.fileRoot = keys.fileRoot; result.fileRoot = keys.fileRoot;
result.isPokemon = true; result.isPokemon = true;
@ -120,18 +127,36 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
// Sprites with custom X or Y defined will not count for normal spacing requirements // Sprites with custom X or Y defined will not count for normal spacing requirements
const spacingValue = Math.round((maxX - minX) / Math.max(this.spriteConfigs.filter(s => !s.x && !s.y).length, 1)); const spacingValue = Math.round((maxX - minX) / Math.max(this.spriteConfigs.filter(s => !s.x && !s.y).length, 1));
this.shinySparkleSprites = [];
const shinySparkleSprites = scene.add.container(0, 0);
this.spriteConfigs?.forEach((config) => { this.spriteConfigs?.forEach((config) => {
const { spriteKey, isItem, hasShadow, scale, x, y, yShadow, alpha } = config; const { spriteKey, isItem, hasShadow, scale, x, y, yShadow, alpha, isPokemon, isShiny, variant } = config;
let sprite: GameObjects.Sprite; let sprite: GameObjects.Sprite;
let tintSprite: GameObjects.Sprite; let tintSprite: GameObjects.Sprite;
let pokemonShinySparkle: Phaser.GameObjects.Sprite | undefined;
if (!isItem) { if (isItem) {
sprite = getSprite(spriteKey, hasShadow, yShadow);
tintSprite = getSprite(spriteKey);
} else {
sprite = getItemSprite(spriteKey, hasShadow, yShadow); sprite = getItemSprite(spriteKey, hasShadow, yShadow);
tintSprite = getItemSprite(spriteKey); tintSprite = getItemSprite(spriteKey);
} else {
sprite = getSprite(spriteKey, hasShadow, yShadow);
tintSprite = getSprite(spriteKey);
if (isPokemon && isShiny) {
// Set Pipeline for shiny variant
sprite.setPipelineData("spriteKey", spriteKey);
tintSprite.setPipelineData("spriteKey", spriteKey);
sprite.setPipelineData("shiny", true);
sprite.setPipelineData("variant", variant);
tintSprite.setPipelineData("shiny", true);
tintSprite.setPipelineData("variant", variant);
// Create Sprite for shiny Sparkle
pokemonShinySparkle = scene.add.sprite(sprite.x, sprite.y, "shiny");
pokemonShinySparkle.setOrigin(0.5, 1);
pokemonShinySparkle.setVisible(false);
this.shinySparkleSprites.push({ sprite: pokemonShinySparkle, variant: variant ?? 0 });
shinySparkleSprites.add(pokemonShinySparkle);
}
} }
sprite.setVisible(!config.hidden); sprite.setVisible(!config.hidden);
@ -165,6 +190,11 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
} }
} }
if (!isNullOrUndefined(pokemonShinySparkle)) {
// Offset the sparkle to match the Pokemon's position
pokemonShinySparkle.setPosition(sprite.x, sprite.y);
}
if (!isNullOrUndefined(alpha)) { if (!isNullOrUndefined(alpha)) {
sprite.setAlpha(alpha); sprite.setAlpha(alpha);
tintSprite.setAlpha(alpha); tintSprite.setAlpha(alpha);
@ -173,6 +203,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
this.add(sprite); this.add(sprite);
this.add(tintSprite); this.add(tintSprite);
}); });
this.add(shinySparkleSprites);
} }
/** /**
@ -187,6 +218,9 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
this.spriteConfigs.forEach((config) => { this.spriteConfigs.forEach((config) => {
if (config.isPokemon) { if (config.isPokemon) {
this.scene.loadPokemonAtlas(config.spriteKey, config.fileRoot); this.scene.loadPokemonAtlas(config.spriteKey, config.fileRoot);
if (config.isShiny) {
this.scene.loadPokemonVariantAssets(config.spriteKey, config.fileRoot, config.variant);
}
} else if (config.isItem) { } else if (config.isItem) {
this.scene.loadAtlas("items", ""); this.scene.loadAtlas("items", "");
} else { } else {
@ -240,11 +274,21 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
this.getSprites().map((sprite, i) => { this.getSprites().map((sprite, i) => {
if (!this.spriteConfigs[i].isItem) { if (!this.spriteConfigs[i].isItem) {
sprite.setTexture(this.spriteConfigs[i].spriteKey).setFrame(0); sprite.setTexture(this.spriteConfigs[i].spriteKey).setFrame(0);
if (sprite.texture.frameTotal > 1) {
// Show the first animation frame for a smooth transition when the animation starts.
const firstFrame = sprite.texture.frames["0001.png"];
sprite.setFrame(firstFrame ?? 0);
}
} }
}); });
this.getTintSprites().map((tintSprite, i) => { this.getTintSprites().map((tintSprite, i) => {
if (!this.spriteConfigs[i].isItem) { if (!this.spriteConfigs[i].isItem) {
tintSprite.setTexture(this.spriteConfigs[i].spriteKey).setFrame(0); tintSprite.setTexture(this.spriteConfigs[i].spriteKey).setFrame(0);
if (tintSprite.texture.frameTotal > 1) {
// Show the first frame for a smooth transition when the animation starts.
const firstFrame = tintSprite.texture.frames["0001.png"];
tintSprite.setFrame(firstFrame ?? 0);
}
} }
}); });
@ -288,6 +332,17 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
return true; return true;
} }
/**
* Play shiny sparkle animations if there are shiny Pokemon
*/
playShinySparkles() {
for (const sparkleConfig of this.shinySparkleSprites) {
this.scene.time.delayedCall(500, () => {
doShinySparkleAnim(this.scene, sparkleConfig.sprite, sparkleConfig.variant);
});
}
}
/** /**
* For sprites with animation and that do not have animation disabled, will begin frame animation * For sprites with animation and that do not have animation disabled, will begin frame animation
*/ */

View File

@ -23,7 +23,7 @@ import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from "#app/data/balance/
import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, SubstituteTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag, TarShotTag, AutotomizedTag, PowerTrickTag } from "../data/battler-tags"; 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 "#enums/weather-type"; import { WeatherType } from "#enums/weather-type";
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag"; 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, CommanderAbAttr, applyPostItemLostAbAttrs, PostItemLostAbAttr } 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, CommanderAbAttr, applyPostItemLostAbAttrs, PostItemLostAbAttr } from "#app/data/ability";
import PokemonData from "#app/system/pokemon-data"; import PokemonData from "#app/system/pokemon-data";
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
@ -69,6 +69,7 @@ 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 { BASE_HIDDEN_ABILITY_CHANCE, BASE_SHINY_CHANCE, SHINY_EPIC_CHANCE, SHINY_VARIANT_CHANCE } from "#app/data/balance/rates";
import { Nature } from "#enums/nature"; import { Nature } from "#enums/nature";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { doShinySparkleAnim } from "#app/field/anims";
export enum FieldPosition { export enum FieldPosition {
CENTER, CENTER,
@ -325,6 +326,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (!this.scene) { if (!this.scene) {
return false; return false;
} }
if (this.switchOutStatus) {
return false;
}
return this.scene.field.getIndex(this) > -1; return this.scene.field.getIndex(this) > -1;
} }
@ -670,21 +674,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
initShinySparkle(): void { initShinySparkle(): void {
const keySuffix = this.variant ? `_${this.variant + 1}` : ""; const shinySparkle = this.scene.addFieldSprite(0, 0, "shiny");
const key = `shiny${keySuffix}`;
const shinySparkle = this.scene.addFieldSprite(0, 0, key);
shinySparkle.setVisible(false); shinySparkle.setVisible(false);
shinySparkle.setOrigin(0.5, 1); shinySparkle.setOrigin(0.5, 1);
const frameNames = this.scene.anims.generateFrameNames(key, { suffix: ".png", end: 34 });
if (!(this.scene.anims.exists(`sparkle${keySuffix}`))) {
this.scene.anims.create({
key: `sparkle${keySuffix}`,
frames: frameNames,
frameRate: 32,
showOnStart: true,
hideOnComplete: true,
});
}
this.add(shinySparkle); this.add(shinySparkle);
this.shinySparkle = shinySparkle; this.shinySparkle = shinySparkle;
@ -1583,7 +1575,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
const trappedByAbility = new Utils.BooleanHolder(false); const trappedByAbility = new Utils.BooleanHolder(false);
const opposingField = this.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField(); /**
* Contains opposing Pokemon (Enemy/Player Pokemon) depending on perspective
* Afterwards, it filters out Pokemon that have been switched out of the field so trapped abilities/moves do not trigger
*/
const opposingFieldUnfiltered = this.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField();
const opposingField = opposingFieldUnfiltered.filter(enemyPkm => enemyPkm.switchOutStatus === false);
opposingField.forEach((opponent) => opposingField.forEach((opponent) =>
applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated) applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated)
@ -1968,6 +1965,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
/** /**
* Function that tries to set a Pokemon shiny based on seed. * Function that tries to set a Pokemon shiny based on seed.
* For manual use only, usually to roll a Pokemon's shiny chance a second time. * For manual use only, usually to roll a Pokemon's shiny chance a second time.
* If it rolls shiny, also sets a random variant and give the Pokemon the associated luck.
* *
* The base shiny odds are {@linkcode BASE_SHINY_CHANCE} / `65536` * The base shiny odds are {@linkcode BASE_SHINY_CHANCE} / `65536`
* @param thresholdOverride number that is divided by `2^16` (`65536`) to get the shiny chance, overrides {@linkcode shinyThreshold} if set (bypassing shiny rate modifiers such as Shiny Charm) * @param thresholdOverride number that is divided by `2^16` (`65536`) to get the shiny chance, overrides {@linkcode shinyThreshold} if set (bypassing shiny rate modifiers such as Shiny Charm)
@ -1993,6 +1991,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.shiny = randSeedInt(65536) < shinyThreshold.value; this.shiny = randSeedInt(65536) < shinyThreshold.value;
if (this.shiny) { if (this.shiny) {
this.variant = this.generateShinyVariant();
this.luck = this.variant + 1 + (this.fusionShiny ? this.fusionVariant + 1 : 0);
this.initShinySparkle(); this.initShinySparkle();
} }
@ -2896,14 +2896,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.turnData.damageTaken += damage; this.turnData.damageTaken += damage;
this.battleData.hitCount++; this.battleData.hitCount++;
// Multi-Lens and Parental Bond check for Wimp Out/Emergency Exit
if (this.hasAbilityWithAttr(PostDamageForceSwitchAbAttr)) {
const multiHitModifier = source.getHeldItems().find(m => m instanceof PokemonMultiHitModifier);
if (multiHitModifier || source.hasAbilityWithAttr(AddSecondStrikeAbAttr)) {
applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source);
}
}
const attackResult = { move: move.id, result: result as DamageResult, damage: damage, critical: isCritical, sourceId: source.id, sourceBattlerIndex: source.getBattlerIndex() }; const attackResult = { move: move.id, result: result as DamageResult, damage: damage, critical: isCritical, sourceId: source.id, sourceBattlerIndex: source.getBattlerIndex() };
this.turnData.attacksReceived.unshift(attackResult); this.turnData.attacksReceived.unshift(attackResult);
if (source.isPlayer() && !this.isPlayer()) { if (source.isPlayer() && !this.isPlayer()) {
@ -3004,13 +2996,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param ignoreFaintPhase boolean to ignore adding a FaintPhase, passsed to damage() * @param ignoreFaintPhase boolean to ignore adding a FaintPhase, passsed to damage()
* @returns integer of damage done * @returns integer of damage done
*/ */
damageAndUpdate(damage: integer, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): integer { damageAndUpdate(damage: number, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): number {
const damagePhase = new DamageAnimPhase(this.scene, this.getBattlerIndex(), damage, result as DamageResult, critical); const damagePhase = new DamageAnimPhase(this.scene, this.getBattlerIndex(), damage, result as DamageResult, critical);
this.scene.unshiftPhase(damagePhase); this.scene.unshiftPhase(damagePhase);
if (this.switchOutStatus && source) {
damage = 0;
}
damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase); damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase);
// Damage amount may have changed, but needed to be queued before calling damage function // Damage amount may have changed, but needed to be queued before calling damage function
damagePhase.updateAmount(damage); damagePhase.updateAmount(damage);
/**
* Run PostDamageAbAttr from any source of damage that is not from a multi-hit
* Multi-hits are handled in move-effect-phase.ts for PostDamageAbAttr
*/
if (!source || source.turnData.hitCount <= 1) {
applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source); applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source);
}
return damage; return damage;
} }
@ -3793,8 +3794,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
sparkle(): void { sparkle(): void {
if (this.shinySparkle) { if (this.shinySparkle) {
this.shinySparkle.play(`sparkle${this.variant ? `_${this.variant + 1}` : ""}`); doShinySparkleAnim(this.scene, this.shinySparkle, this.variant);
this.scene.playSound("se/sparkle");
} }
} }
@ -4636,12 +4636,13 @@ export class EnemyPokemon extends Pokemon {
public aiType: AiType; public aiType: AiType;
public bossSegments: integer; public bossSegments: integer;
public bossSegmentIndex: integer; public bossSegmentIndex: integer;
/** To indicate of the instance was populated with a dataSource -> e.g. loaded & populated from session data */ /** To indicate if the instance was populated with a dataSource -> e.g. loaded & populated from session data */
public readonly isPopulatedFromDataSource: boolean; public readonly isPopulatedFromDataSource: boolean;
constructor(scene: BattleScene, species: PokemonSpecies, level: integer, trainerSlot: TrainerSlot, boss: boolean, dataSource?: PokemonData) { constructor(scene: BattleScene, species: PokemonSpecies, level: integer, trainerSlot: TrainerSlot, boss: boolean, shinyLock: boolean = false, dataSource?: PokemonData) {
super(scene, 236, 84, species, level, dataSource?.abilityIndex, dataSource?.formIndex, super(scene, 236, 84, species, level, dataSource?.abilityIndex, dataSource?.formIndex, dataSource?.gender,
dataSource?.gender, dataSource ? dataSource.shiny : false, dataSource ? dataSource.variant : undefined, undefined, dataSource ? dataSource.nature : undefined, dataSource); (!shinyLock && dataSource) ? dataSource.shiny : false, (!shinyLock && dataSource) ? dataSource.variant : undefined,
undefined, dataSource ? dataSource.nature : undefined, dataSource);
this.trainerSlot = trainerSlot; this.trainerSlot = trainerSlot;
this.isPopulatedFromDataSource = !!dataSource; // if a dataSource is provided, then it was populated from dataSource this.isPopulatedFromDataSource = !!dataSource; // if a dataSource is provided, then it was populated from dataSource
@ -4670,12 +4671,15 @@ export class EnemyPokemon extends Pokemon {
if (!dataSource) { if (!dataSource) {
this.generateAndPopulateMoveset(); this.generateAndPopulateMoveset();
if (shinyLock || Overrides.OPP_SHINY_OVERRIDE === false) {
this.shiny = false;
} else {
this.trySetShiny(); this.trySetShiny();
if (Overrides.OPP_SHINY_OVERRIDE) { }
if (!this.shiny && Overrides.OPP_SHINY_OVERRIDE) {
this.shiny = true; this.shiny = true;
this.initShinySparkle(); this.initShinySparkle();
} else if (Overrides.OPP_SHINY_OVERRIDE === false) {
this.shiny = false;
} }
if (this.shiny) { if (this.shiny) {

View File

@ -1702,7 +1702,8 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, (party: Pokemon[]) => { new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, (party: Pokemon[]) => {
return Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 15), 8); return Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 15), 8);
}, 8), }, 8),
new WeightedModifierType(modifierTypes.MAP, (party: Pokemon[]) => party[0].scene.gameMode.isClassic && party[0].scene.currentBattle.waveIndex < 180 ? 1 : 0, 1), new WeightedModifierType(modifierTypes.MAP, (party: Pokemon[]) => party[0].scene.gameMode.isClassic && party[0].scene.currentBattle.waveIndex < 180 ? 2 : 0, 2),
new WeightedModifierType(modifierTypes.SOOTHE_BELL, 2),
new WeightedModifierType(modifierTypes.TM_GREAT, 3), new WeightedModifierType(modifierTypes.TM_GREAT, 3),
new WeightedModifierType(modifierTypes.MEMORY_MUSHROOM, (party: Pokemon[]) => { new WeightedModifierType(modifierTypes.MEMORY_MUSHROOM, (party: Pokemon[]) => {
if (!party.find(p => p.getLearnableLevelMoves().length)) { if (!party.find(p => p.getLearnableLevelMoves().length)) {
@ -1730,8 +1731,14 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.EVIOLITE, (party: Pokemon[]) => { new WeightedModifierType(modifierTypes.EVIOLITE, (party: Pokemon[]) => {
const { gameMode, gameData } = party[0].scene; const { gameMode, gameData } = party[0].scene;
if (gameMode.isDaily || (!gameMode.isFreshStartChallenge() && gameData.isUnlocked(Unlockables.EVIOLITE))) { if (gameMode.isDaily || (!gameMode.isFreshStartChallenge() && gameData.isUnlocked(Unlockables.EVIOLITE))) {
return party.some(p => ((p.getSpeciesForm(true).speciesId in pokemonEvolutions) || (p.isFusion() && (p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions))) return party.some(p => {
&& !p.getHeldItems().some(i => i instanceof EvolutionStatBoosterModifier) && !p.isMax()) ? 10 : 0; // Check if Pokemon's species (or fusion species, if applicable) can evolve or if they're G-Max'd
if (!p.isMax() && ((p.getSpeciesForm(true).speciesId in pokemonEvolutions) || (p.isFusion() && (p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions)))) {
// Check if Pokemon is already holding an Eviolite
return !p.getHeldItems().some(i => i.type.id === "EVIOLITE");
}
return false;
}) ? 10 : 0;
} }
return 0; return 0;
}), }),
@ -1794,7 +1801,6 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.SOUL_DEW, 7), new WeightedModifierType(modifierTypes.SOUL_DEW, 7),
//new WeightedModifierType(modifierTypes.OVAL_CHARM, 6), //new WeightedModifierType(modifierTypes.OVAL_CHARM, 6),
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.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.ABILITY_CHARM, skipInClassicAfterWave(189, 6)),
new WeightedModifierType(modifierTypes.FOCUS_BAND, 5), new WeightedModifierType(modifierTypes.FOCUS_BAND, 5),
new WeightedModifierType(modifierTypes.KINGS_ROCK, 3), new WeightedModifierType(modifierTypes.KINGS_ROCK, 3),

View File

@ -18,7 +18,6 @@ import type { VoucherType } from "#app/system/voucher";
import { Command } from "#app/ui/command-ui-handler"; import { Command } from "#app/ui/command-ui-handler";
import { addTextObject, TextStyle } from "#app/ui/text"; import { addTextObject, TextStyle } from "#app/ui/text";
import { BooleanHolder, hslToHex, isNullOrUndefined, NumberHolder, toDmgValue } from "#app/utils"; import { BooleanHolder, hslToHex, isNullOrUndefined, NumberHolder, toDmgValue } from "#app/utils";
import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { BerryType } from "#enums/berry-type"; import { BerryType } from "#enums/berry-type";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -726,22 +725,6 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
return 1; return 1;
} }
//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]) {
return 1;
}
const sheerForceAffected = allMoves[pokemon.getLastXMoves()[0].move].chance >= 0 && pokemon.hasAbility(Abilities.SHEER_FORCE);
if (sheerForceAffected) {
return 0;
} else if (pokemon.hasAbility(Abilities.SERENE_GRACE)) {
return 2;
}
return 1;
}
getMaxStackCount(scene: BattleScene, forThreshold?: boolean): number { getMaxStackCount(scene: BattleScene, forThreshold?: boolean): number {
const pokemon = this.getPokemon(scene); const pokemon = this.getPokemon(scene);
if (!pokemon) { if (!pokemon) {
@ -1614,9 +1597,16 @@ export class BypassSpeedChanceModifier extends PokemonHeldItemModifier {
} }
} }
/**
* Class for Pokemon held items like King's Rock
* Because King's Rock can be stacked in PokeRogue, unlike mainline, it does not receive a boost from Abilities.SERENE_GRACE
*/
export class FlinchChanceModifier extends PokemonHeldItemModifier { export class FlinchChanceModifier extends PokemonHeldItemModifier {
private chance: number;
constructor(type: ModifierType, pokemonId: number, stackCount?: number) { constructor(type: ModifierType, pokemonId: number, stackCount?: number) {
super(type, pokemonId, stackCount); super(type, pokemonId, stackCount);
this.chance = 10;
} }
matchType(modifier: Modifier) { matchType(modifier: Modifier) {
@ -1644,7 +1634,8 @@ export class FlinchChanceModifier extends PokemonHeldItemModifier {
* @returns `true` if {@linkcode FlinchChanceModifier} has been applied * @returns `true` if {@linkcode FlinchChanceModifier} has been applied
*/ */
override apply(pokemon: Pokemon, flinched: BooleanHolder): boolean { override apply(pokemon: Pokemon, flinched: BooleanHolder): boolean {
if (!flinched.value && pokemon.randSeedInt(10) < (this.getStackCount() * this.getSecondaryChanceMultiplier(pokemon))) { // The check for pokemon.battleSummonData is to ensure that a crash doesn't occur when a Pokemon with King's Rock procs a flinch
if (pokemon.battleSummonData && !flinched.value && pokemon.randSeedInt(100) < (this.getStackCount() * this.chance)) {
flinched.value = true; flinched.value = true;
return true; return true;
} }
@ -1652,7 +1643,7 @@ export class FlinchChanceModifier extends PokemonHeldItemModifier {
return false; return false;
} }
getMaxHeldItemCount(pokemon: Pokemon): number { getMaxHeldItemCount(_pokemon: Pokemon): number {
return 3; return 3;
} }
} }

View File

@ -5,7 +5,6 @@ import { getPokemonNameWithAffix } from "#app/messages";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import i18next from "i18next"; import i18next from "i18next";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
import { PostSummonPhase } from "./post-summon-phase";
import { SummonMissingPhase } from "./summon-missing-phase"; import { SummonMissingPhase } from "./summon-missing-phase";
import { SwitchPhase } from "./switch-phase"; import { SwitchPhase } from "./switch-phase";
import { SwitchType } from "#enums/switch-type"; import { SwitchType } from "#enums/switch-type";
@ -54,7 +53,6 @@ export class CheckSwitchPhase extends BattlePhase {
this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon") }), null, () => { this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon") }), null, () => {
this.scene.ui.setMode(Mode.CONFIRM, () => { this.scene.ui.setMode(Mode.CONFIRM, () => {
this.scene.ui.setMode(Mode.MESSAGE); this.scene.ui.setMode(Mode.MESSAGE);
this.scene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex);
this.scene.unshiftPhase(new SwitchPhase(this.scene, SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true)); this.scene.unshiftPhase(new SwitchPhase(this.scene, SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true));
this.end(); this.end();
}, () => { }, () => {

View File

@ -14,6 +14,7 @@ import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { EggLapsePhase } from "./egg-lapse-phase"; import { EggLapsePhase } from "./egg-lapse-phase";
import { EggHatchData } from "#app/data/egg-hatch-data"; import { EggHatchData } from "#app/data/egg-hatch-data";
import { doShinySparkleAnim } from "#app/field/anims";
/** /**
@ -341,8 +342,7 @@ export class EggHatchPhase extends Phase {
this.pokemon.cry(); this.pokemon.cry();
if (isShiny) { if (isShiny) {
this.scene.time.delayedCall(Utils.fixedInt(500), () => { this.scene.time.delayedCall(Utils.fixedInt(500), () => {
this.pokemonShinySparkle.play(`sparkle${this.pokemon.variant ? `_${this.pokemon.variant + 1}` : ""}`); doShinySparkleAnim(this.scene, this.pokemonShinySparkle, this.pokemon.variant);
this.scene.playSound("se/sparkle");
}); });
} }
this.scene.time.delayedCall(Utils.fixedInt(!this.skipped ? !isShiny ? 1250 : 1750 : !isShiny ? 250 : 750), () => { this.scene.time.delayedCall(Utils.fixedInt(!this.skipped ? !isShiny ? 1250 : 1750 : !isShiny ? 250 : 750), () => {

View File

@ -34,6 +34,7 @@ import { Biome } from "#enums/biome";
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { PlayerGender } from "#enums/player-gender"; import { PlayerGender } from "#enums/player-gender";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { overrideHeldItems, overrideModifiers } from "#app/modifier/modifier";
import i18next from "i18next"; import i18next from "i18next";
import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters"; import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters";
@ -216,6 +217,11 @@ export class EncounterPhase extends BattlePhase {
if (!this.loaded && battle.battleType !== BattleType.MYSTERY_ENCOUNTER) { if (!this.loaded && battle.battleType !== BattleType.MYSTERY_ENCOUNTER) {
regenerateModifierPoolThresholds(this.scene.getEnemyField(), battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD); regenerateModifierPoolThresholds(this.scene.getEnemyField(), battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD);
this.scene.generateEnemyModifiers(); this.scene.generateEnemyModifiers();
overrideModifiers(this.scene, false);
this.scene.getEnemyField().forEach(enemy => {
overrideHeldItems(this.scene, enemy, false);
});
} }
this.scene.ui.setMode(Mode.MESSAGE).then(() => { this.scene.ui.setMode(Mode.MESSAGE).then(() => {
@ -379,6 +385,9 @@ export class EncounterPhase extends BattlePhase {
if (encounter.onVisualsStart) { if (encounter.onVisualsStart) {
encounter.onVisualsStart(this.scene); encounter.onVisualsStart(this.scene);
} else if (encounter.spriteConfigs && introVisuals) {
// If the encounter doesn't have any special visual intro, show sparkle for shiny Pokemon
introVisuals.playShinySparkles();
} }
const doEncounter = () => { const doEncounter = () => {

View File

@ -4,11 +4,13 @@ import {
AddSecondStrikeAbAttr, AddSecondStrikeAbAttr,
AlwaysHitAbAttr, AlwaysHitAbAttr,
applyPostAttackAbAttrs, applyPostAttackAbAttrs,
applyPostDamageAbAttrs,
applyPostDefendAbAttrs, applyPostDefendAbAttrs,
applyPreAttackAbAttrs, applyPreAttackAbAttrs,
IgnoreMoveEffectsAbAttr, IgnoreMoveEffectsAbAttr,
MaxMultiHitAbAttr, MaxMultiHitAbAttr,
PostAttackAbAttr, PostAttackAbAttr,
PostDamageAbAttr,
PostDefendAbAttr, PostDefendAbAttr,
TypeImmunityAbAttr, TypeImmunityAbAttr,
} from "#app/data/ability"; } from "#app/data/ability";
@ -228,9 +230,11 @@ export class MoveEffectPhase extends PokemonPhase {
* If the move missed a target, stop all future hits against that target * If the move missed a target, stop all future hits against that target
* and move on to the next target (if there is one). * and move on to the next target (if there is one).
*/ */
if (isCommanding || (!isImmune && !isProtected && !targetHitChecks[target.getBattlerIndex()])) { if (target.switchOutStatus || isCommanding || (!isImmune && !isProtected && !targetHitChecks[target.getBattlerIndex()])) {
this.stopMultiHit(target); this.stopMultiHit(target);
if (!target.switchOutStatus) {
this.scene.queueMessage(i18next.t("battle:attackMissed", { pokemonNameWithAffix: getPokemonNameWithAffix(target) })); this.scene.queueMessage(i18next.t("battle:attackMissed", { pokemonNameWithAffix: getPokemonNameWithAffix(target) }));
}
if (moveHistoryEntry.result === MoveResult.PENDING) { if (moveHistoryEntry.result === MoveResult.PENDING) {
moveHistoryEntry.result = MoveResult.MISS; moveHistoryEntry.result = MoveResult.MISS;
} }
@ -299,6 +303,13 @@ export class MoveEffectPhase extends PokemonPhase {
*/ */
if (lastHit) { if (lastHit) {
this.scene.triggerPokemonFormChange(user, SpeciesFormChangePostMoveTrigger); this.scene.triggerPokemonFormChange(user, SpeciesFormChangePostMoveTrigger);
/**
* Multi-Lens, Multi Hit move and Parental Bond check for PostDamageAbAttr
* other damage source are calculated in damageAndUpdate in pokemon.ts
*/
if (user.turnData.hitCount > 1) {
applyPostDamageAbAttrs(PostDamageAbAttr, target, 0, target.hasPassive(), false, [], user);
}
} }
/** /**

View File

@ -27,9 +27,12 @@ export class PostSummonPhase extends PokemonPhase {
pokemon.lapseTag(BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON); pokemon.lapseTag(BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON);
} }
applyPostSummonAbAttrs(PostSummonAbAttr, pokemon).then(() => this.end()); applyPostSummonAbAttrs(PostSummonAbAttr, pokemon)
.then(() => {
const field = pokemon.isPlayer() ? this.scene.getPlayerField() : this.scene.getEnemyField(); const field = pokemon.isPlayer() ? this.scene.getPlayerField() : this.scene.getEnemyField();
field.forEach((p) => applyAbAttrs(CommanderAbAttr, p, null, false)); field.forEach((p) => applyAbAttrs(CommanderAbAttr, p, null, false));
this.end();
});
} }
} }

View File

@ -16,7 +16,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
start() { start() {
const pokemon = this.getPokemon(); const pokemon = this.getPokemon();
if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn()) { if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn() && !pokemon.switchOutStatus) {
pokemon.status.incrementTurn(); pokemon.status.incrementTurn();
const cancelled = new Utils.BooleanHolder(false); const cancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled);

View File

@ -3,6 +3,7 @@ import PartyUiHandler, { PartyOption, PartyUiMode } from "#app/ui/party-ui-handl
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { SwitchType } from "#enums/switch-type"; import { SwitchType } from "#enums/switch-type";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
import { PostSummonPhase } from "./post-summon-phase";
import { SwitchSummonPhase } from "./switch-summon-phase"; import { SwitchSummonPhase } from "./switch-summon-phase";
/** /**
@ -63,6 +64,9 @@ export class SwitchPhase extends BattlePhase {
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => { this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => {
if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) { if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) {
// Remove any pre-existing PostSummonPhase under the same field index.
// Pre-existing PostSummonPhases may occur when this phase is invoked during a prompt to switch at the start of a wave.
this.scene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex);
const switchType = (option === PartyOption.PASS_BATON) ? SwitchType.BATON_PASS : this.switchType; const switchType = (option === PartyOption.PASS_BATON) ? SwitchType.BATON_PASS : this.switchType;
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, switchType, fieldIndex, slotIndex, this.doReturn)); this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, switchType, fieldIndex, slotIndex, this.doReturn));
} }

View File

@ -23,6 +23,7 @@ export class TurnEndPhase extends FieldPhase {
this.scene.eventTarget.dispatchEvent(new TurnEndEvent(this.scene.currentBattle.turn)); this.scene.eventTarget.dispatchEvent(new TurnEndEvent(this.scene.currentBattle.turn));
const handlePokemon = (pokemon: Pokemon) => { const handlePokemon = (pokemon: Pokemon) => {
if (!pokemon.switchOutStatus) {
pokemon.lapseTags(BattlerTagLapseType.TURN_END); pokemon.lapseTags(BattlerTagLapseType.TURN_END);
this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon); this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon);
@ -38,6 +39,7 @@ export class TurnEndPhase extends FieldPhase {
} }
applyPostTurnAbAttrs(PostTurnAbAttr, pokemon); applyPostTurnAbAttrs(PostTurnAbAttr, pokemon);
}
this.scene.applyModifiers(TurnStatusEffectModifier, pokemon.isPlayer(), pokemon); this.scene.applyModifiers(TurnStatusEffectModifier, pokemon.isPlayer(), pokemon);

View File

@ -51,7 +51,7 @@ export class WeatherEffectPhase extends CommonAnimPhase {
}; };
this.executeForAll((pokemon: Pokemon) => { this.executeForAll((pokemon: Pokemon) => {
const immune = !pokemon || !!pokemon.getTypes(true, true).filter(t => this.weather?.isTypeDamageImmune(t)).length; const immune = !pokemon || !!pokemon.getTypes(true, true).filter(t => this.weather?.isTypeDamageImmune(t)).length || pokemon.switchOutStatus;
if (!immune) { if (!immune) {
inflictDamage(pokemon); inflictDamage(pokemon);
} }
@ -59,8 +59,12 @@ export class WeatherEffectPhase extends CommonAnimPhase {
} }
} }
this.scene.ui.showText(getWeatherLapseMessage(this.weather.weatherType)!, null, () => { // TODO: is this bang correct? this.scene.ui.showText(getWeatherLapseMessage(this.weather.weatherType) ?? "", null, () => {
this.executeForAll((pokemon: Pokemon) => applyPostWeatherLapseAbAttrs(PostWeatherLapseAbAttr, pokemon, this.weather)); this.executeForAll((pokemon: Pokemon) => {
if (!pokemon.switchOutStatus) {
applyPostWeatherLapseAbAttrs(PostWeatherLapseAbAttr, pokemon, this.weather);
}
});
super.start(); super.start();
}); });

View File

@ -171,7 +171,7 @@ export default class PokemonData {
playerPokemon.nickname = this.nickname; playerPokemon.nickname = this.nickname;
} }
}) })
: scene.addEnemyPokemon(species, this.level, battleType === BattleType.TRAINER ? !double || !(partyMemberIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER : TrainerSlot.NONE, this.boss, this); : scene.addEnemyPokemon(species, this.level, battleType === BattleType.TRAINER ? !double || !(partyMemberIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER : TrainerSlot.NONE, this.boss, false, this);
if (this.summonData) { if (this.summonData) {
ret.primeSummonData(this.summonData); ret.primeSummonData(this.summonData);
} }

View File

@ -1,9 +1,10 @@
import { allAbilities } from "#app/data/ability";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest";
describe("Abilities - Arena Trap", () => { describe("Abilities - Arena Trap", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -55,4 +56,39 @@ describe("Abilities - Arena Trap", () => {
expect(game.scene.getEnemyField().length).toBe(2); expect(game.scene.getEnemyField().length).toBe(2);
}); });
/**
* This checks if the Player Pokemon is able to switch out/run away after the Enemy Pokemon with {@linkcode Abilities.ARENA_TRAP}
* is forcefully moved out of the field from moves such as Roar {@linkcode Moves.ROAR}
*
* Note: It should be able to switch out/run away
*/
it("should lift if pokemon with this ability leaves the field", async () => {
game.override
.battleType("double")
.enemyMoveset(Moves.SPLASH)
.moveset([ Moves.ROAR, Moves.SPLASH ])
.ability(Abilities.BALL_FETCH);
await game.classicMode.startBattle([ Species.MAGIKARP, Species.SUDOWOODO, Species.LUNATONE ]);
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
const [ player1, player2 ] = game.scene.getPlayerField();
vi.spyOn(enemy1, "getAbility").mockReturnValue(allAbilities[Abilities.ARENA_TRAP]);
game.move.select(Moves.ROAR);
game.move.select(Moves.SPLASH, 1);
// This runs the fist command phase where the moves are selected
await game.toNextTurn();
// During the next command phase the player pokemons should not be trapped anymore
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
await game.toNextTurn();
expect(player1.isTrapped()).toBe(false);
expect(player2.isTrapped()).toBe(false);
expect(enemy1.isOnField()).toBe(false);
expect(enemy2.isOnField()).toBe(true);
});
}); });

View File

@ -1,15 +1,12 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { applyAbAttrs, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability";
import { Stat } from "#enums/stat";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import * as Utils from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { allMoves } from "#app/data/move";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { FlinchAttr } from "#app/data/move";
describe("Abilities - Serene Grace", () => { describe("Abilities - Serene Grace", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,66 +24,26 @@ describe("Abilities - Serene Grace", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
const movesToUse = [ Moves.AIR_SLASH, Moves.TACKLE ]; game.override
game.override.battleType("single"); .battleType("single")
game.override.enemySpecies(Species.ONIX); .ability(Abilities.SERENE_GRACE)
game.override.startingLevel(100); .moveset([ Moves.AIR_SLASH, Moves.TACKLE ])
game.override.moveset(movesToUse); .enemyLevel(10)
game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); .enemyMoveset([ Moves.SPLASH ]);
}); });
it("Move chance without Serene Grace", async () => { it("Serene Grace should double the secondary effect chance of a move", async () => {
const moveToUse = Moves.AIR_SLASH; await game.classicMode.startBattle([ Species.SHUCKLE ]);
await game.startBattle([
Species.PIDGEOT
]);
const airSlashMove = allMoves[Moves.AIR_SLASH];
const airSlashFlinchAttr = airSlashMove.getAttrs(FlinchAttr)[0];
vi.spyOn(airSlashFlinchAttr, "getMoveChance");
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; game.move.select(Moves.AIR_SLASH);
expect(game.scene.getPlayerParty()[0].formIndex).toBe(0);
game.move.select(moveToUse);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.move.forceHit();
await game.phaseInterceptor.to("BerryPhase");
// Check chance of Air Slash without Serene Grace expect(airSlashFlinchAttr.getMoveChance).toHaveLastReturnedWith(60);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase; });
const move = phase.move.getMove();
expect(move.id).toBe(Moves.AIR_SLASH);
const chance = new Utils.IntegerHolder(move.chance);
console.log(move.chance + " Their ability is " + phase.getUserPokemon()!.getAbility().name);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
expect(chance.value).toBe(30);
}, 20000);
it("Move chance with Serene Grace", async () => {
const moveToUse = Moves.AIR_SLASH;
game.override.ability(Abilities.SERENE_GRACE);
await game.startBattle([
Species.TOGEKISS
]);
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getPlayerParty()[0].formIndex).toBe(0);
game.move.select(moveToUse);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
// Check chance of Air Slash with Serene Grace
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
const move = phase.move.getMove();
expect(move.id).toBe(Moves.AIR_SLASH);
const chance = new Utils.IntegerHolder(move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
expect(chance.value).toBe(60);
}, 20000);
//TODO King's Rock Interaction Unit Test
}); });

View File

@ -1,15 +1,13 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { applyAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, MoveEffectChanceMultiplierAbAttr, MovePowerBoostAbAttr, PostDefendTypeChangeAbAttr } from "#app/data/ability"; import { Type } from "#app/enums/type";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { NumberHolder } from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; 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 } from "#app/data/move"; import { allMoves, FlinchAttr } from "#app/data/move";
describe("Abilities - Sheer Force", () => { describe("Abilities - Sheer Force", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,143 +25,91 @@ describe("Abilities - Sheer Force", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
const movesToUse = [ Moves.AIR_SLASH, Moves.BIND, Moves.CRUSH_CLAW, Moves.TACKLE ]; game.override
game.override.battleType("single"); .battleType("single")
game.override.enemySpecies(Species.ONIX); .ability(Abilities.SHEER_FORCE)
game.override.startingLevel(100); .enemySpecies(Species.ONIX)
game.override.moveset(movesToUse); .enemyAbility(Abilities.BALL_FETCH)
game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); .enemyMoveset([ Moves.SPLASH ])
.disableCrits();
}); });
it("Sheer Force", async () => { const SHEER_FORCE_MULT = 5461 / 4096;
const moveToUse = Moves.AIR_SLASH;
game.override.ability(Abilities.SHEER_FORCE); it("Sheer Force should boost the power of the move but disable secondary effects", async () => {
game.override.moveset([ Moves.AIR_SLASH ]);
await game.classicMode.startBattle([ Species.SHUCKLE ]);
const airSlashMove = allMoves[Moves.AIR_SLASH];
vi.spyOn(airSlashMove, "calculateBattlePower");
const airSlashFlinchAttr = airSlashMove.getAttrs(FlinchAttr)[0];
vi.spyOn(airSlashFlinchAttr, "getMoveChance");
game.move.select(Moves.AIR_SLASH);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.move.forceHit();
await game.phaseInterceptor.to("BerryPhase", false);
expect(airSlashMove.calculateBattlePower).toHaveLastReturnedWith(airSlashMove.power * SHEER_FORCE_MULT);
expect(airSlashFlinchAttr.getMoveChance).toHaveLastReturnedWith(0);
});
it("Sheer Force does not affect the base damage or secondary effects of binding moves", async () => {
game.override.moveset([ Moves.BIND ]);
await game.classicMode.startBattle([ Species.SHUCKLE ]);
const bindMove = allMoves[Moves.BIND];
vi.spyOn(bindMove, "calculateBattlePower");
game.move.select(Moves.BIND);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.move.forceHit();
await game.phaseInterceptor.to("BerryPhase", false);
expect(bindMove.calculateBattlePower).toHaveLastReturnedWith(bindMove.power);
}, 20000);
it("Sheer Force does not boost the base damage of moves with no secondary effect", async () => {
game.override.moveset([ Moves.TACKLE ]);
await game.classicMode.startBattle([ Species.PIDGEOT ]); await game.classicMode.startBattle([ Species.PIDGEOT ]);
game.scene.getEnemyPokemon()!.stats[Stat.SPDEF] = 10000; const tackleMove = allMoves[Moves.TACKLE];
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0); vi.spyOn(tackleMove, "calculateBattlePower");
game.move.select(moveToUse);
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.move.forceHit();
await game.phaseInterceptor.to("BerryPhase", false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase; expect(tackleMove.calculateBattlePower).toHaveLastReturnedWith(tackleMove.power);
const move = phase.move.getMove(); });
expect(move.id).toBe(Moves.AIR_SLASH);
//Verify the move is boosted and has no chance of secondary effects it("Sheer Force can disable the on-hit activation of specific abilities", async () => {
const power = new NumberHolder(move.power); game.override
const chance = new NumberHolder(move.chance); .moveset([ Moves.HEADBUTT ])
.enemySpecies(Species.SQUIRTLE)
.enemyLevel(10)
.enemyAbility(Abilities.COLOR_CHANGE);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
expect(chance.value).toBe(0);
expect(power.value).toBe(move.power * 5461 / 4096);
}, 20000);
it("Sheer Force with exceptions including binding moves", async () => {
const moveToUse = Moves.BIND;
game.override.ability(Abilities.SHEER_FORCE);
await game.classicMode.startBattle([ Species.PIDGEOT ]); await game.classicMode.startBattle([ Species.PIDGEOT ]);
const enemyPokemon = game.scene.getEnemyPokemon();
const headbuttMove = allMoves[Moves.HEADBUTT];
vi.spyOn(headbuttMove, "calculateBattlePower");
const headbuttFlinchAttr = headbuttMove.getAttrs(FlinchAttr)[0];
vi.spyOn(headbuttFlinchAttr, "getMoveChance");
game.move.select(Moves.HEADBUTT);
game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
game.move.select(moveToUse);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.move.forceHit();
await game.phaseInterceptor.to("BerryPhase", false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase; expect(enemyPokemon?.getTypes()[0]).toBe(Type.WATER);
const move = phase.move.getMove(); expect(headbuttMove.calculateBattlePower).toHaveLastReturnedWith(headbuttMove.power * SHEER_FORCE_MULT);
expect(move.id).toBe(Moves.BIND); expect(headbuttFlinchAttr.getMoveChance).toHaveLastReturnedWith(0);
});
//Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1
const power = new NumberHolder(move.power);
const chance = new NumberHolder(move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
expect(chance.value).toBe(-1);
expect(power.value).toBe(move.power);
}, 20000);
it("Sheer Force with moves with no secondary effect", async () => {
const moveToUse = Moves.TACKLE;
game.override.ability(Abilities.SHEER_FORCE);
await game.classicMode.startBattle([ Species.PIDGEOT ]);
game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
game.move.select(moveToUse);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
const move = phase.move.getMove();
expect(move.id).toBe(Moves.TACKLE);
//Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1
const power = new NumberHolder(move.power);
const chance = new NumberHolder(move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
expect(chance.value).toBe(-1);
expect(power.value).toBe(move.power);
}, 20000);
it("Sheer Force Disabling Specific Abilities", async () => {
const moveToUse = Moves.CRUSH_CLAW;
game.override.enemyAbility(Abilities.COLOR_CHANGE);
game.override.startingHeldItems([{ name: "KINGS_ROCK", count: 1 }]);
game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ Species.PIDGEOT ]);
game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
game.move.select(moveToUse);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
const move = phase.move.getMove();
expect(move.id).toBe(Moves.CRUSH_CLAW);
//Disable color change due to being hit by Sheer Force
const power = new NumberHolder(move.power);
const chance = new NumberHolder(move.chance);
const user = phase.getUserPokemon()!;
const target = phase.getFirstTarget()!;
const opponentType = target.getTypes()[0];
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, false, chance, move, target, false);
applyPreAttackAbAttrs(MovePowerBoostAbAttr, user, target, move, false, power);
applyPostDefendAbAttrs(PostDefendTypeChangeAbAttr, target, user, move, target.apply(user, move));
expect(chance.value).toBe(0);
expect(power.value).toBe(move.power * 5461 / 4096);
expect(target.getTypes().length).toBe(2);
expect(target.getTypes()[0]).toBe(opponentType);
}, 20000);
it("Two Pokemon with abilities disabled by Sheer Force hitting each other should not cause a crash", async () => { it("Two Pokemon with abilities disabled by Sheer Force hitting each other should not cause a crash", async () => {
const moveToUse = Moves.CRUNCH; const moveToUse = Moves.CRUNCH;
@ -191,5 +137,19 @@ describe("Abilities - Sheer Force", () => {
expect(onix.getTypes()).toStrictEqual(expectedTypes); expect(onix.getTypes()).toStrictEqual(expectedTypes);
}); });
//TODO King's Rock Interaction Unit Test it("Sheer Force should disable Meloetta's transformation from Relic Song", async () => {
game.override
.ability(Abilities.SHEER_FORCE)
.moveset([ Moves.RELIC_SONG ])
.enemyMoveset([ Moves.SPLASH ])
.enemyLevel(100);
await game.classicMode.startBattle([ Species.MELOETTA ]);
const playerPokemon = game.scene.getPlayerPokemon();
const formKeyStart = playerPokemon?.getFormKey();
game.move.select(Moves.RELIC_SONG);
await game.phaseInterceptor.to("TurnEndPhase");
expect(formKeyStart).toBe(playerPokemon?.getFormKey());
});
}); });

View File

@ -0,0 +1,85 @@
import { BattlerIndex } from "#app/battle";
import { isBetween } from "#app/utils";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Abilities - Stakeout", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([ Moves.SPLASH, Moves.SURF ])
.ability(Abilities.STAKEOUT)
.battleType("single")
.disableCrits()
.startingLevel(100)
.enemyLevel(100)
.enemySpecies(Species.SNORLAX)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset([ Moves.SPLASH, Moves.FLIP_TURN ])
.startingWave(5);
});
it("should do double damage to a pokemon that switched out", async () => {
await game.classicMode.startBattle([ Species.MILOTIC ]);
const [ enemy1, ] = game.scene.getEnemyParty();
game.move.select(Moves.SURF);
await game.forceEnemyMove(Moves.SPLASH);
await game.toNextTurn();
const damage1 = enemy1.getInverseHp();
enemy1.hp = enemy1.getMaxHp();
game.move.select(Moves.SPLASH);
game.forceEnemyToSwitch();
await game.toNextTurn();
game.move.select(Moves.SURF);
game.forceEnemyToSwitch();
await game.toNextTurn();
expect(enemy1.isFainted()).toBe(false);
expect(isBetween(enemy1.getInverseHp(), (damage1 * 2) - 5, (damage1 * 2) + 5)).toBe(true);
});
it("should do double damage to a pokemon that switched out via U-Turn/etc", async () => {
await game.classicMode.startBattle([ Species.MILOTIC ]);
const [ enemy1, ] = game.scene.getEnemyParty();
game.move.select(Moves.SURF);
await game.forceEnemyMove(Moves.SPLASH);
await game.toNextTurn();
const damage1 = enemy1.getInverseHp();
enemy1.hp = enemy1.getMaxHp();
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.FLIP_TURN);
await game.toNextTurn();
game.move.select(Moves.SURF);
await game.forceEnemyMove(Moves.FLIP_TURN);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextTurn();
expect(enemy1.isFainted()).toBe(false);
expect(isBetween(enemy1.getInverseHp(), (damage1 * 2) - 5, (damage1 * 2) + 5)).toBe(true);
});
});

View File

@ -632,4 +632,34 @@ describe("Abilities - Wimp Out", () => {
const hasFled = enemyPokemon.switchOutStatus; const hasFled = enemyPokemon.switchOutStatus;
expect(isVisible && !hasFled).toBe(true); expect(isVisible && !hasFled).toBe(true);
}); });
it("wimp out will not skip battles when triggered in a double battle", async () => {
const wave = 2;
game.override
.enemyMoveset(Moves.SPLASH)
.enemySpecies(Species.WIMPOD)
.enemyAbility(Abilities.WIMP_OUT)
.moveset([ Moves.MATCHA_GOTCHA, Moves.FALSE_SWIPE ])
.startingLevel(50)
.enemyLevel(1)
.battleType("double")
.startingWave(wave);
await game.classicMode.startBattle([
Species.RAICHU,
Species.PIKACHU
]);
const [ wimpod0, wimpod1 ] = game.scene.getEnemyField();
game.move.select(Moves.FALSE_SWIPE, 0, BattlerIndex.ENEMY);
game.move.select(Moves.MATCHA_GOTCHA, 1);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("TurnEndPhase");
expect(wimpod0.hp).toBeGreaterThan(0);
expect(wimpod0.switchOutStatus).toBe(true);
expect(wimpod0.isFainted()).toBe(false);
expect(wimpod1.isFainted()).toBe(true);
await game.toNextWave();
expect(game.scene.currentBattle.waveIndex).toBe(wave + 1);
});
}); });

View File

@ -1,9 +1,8 @@
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
import { describe, expect, it, vi } from "vitest"; import { describe, expect, it, vi } from "vitest";
import Pokemon from "#app/field/pokemon"; import Pokemon from "#app/field/pokemon";
import { BattlerTag, BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags"; import { BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags";
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
vi.mock("#app/battle-scene.js"); vi.mock("#app/battle-scene.js");
@ -33,30 +32,4 @@ describe("BattlerTag - OctolockTag", () => {
it ("traps its target (extends TrappedTag)", async () => { it ("traps its target (extends TrappedTag)", async () => {
expect(new OctolockTag(1)).toBeInstanceOf(TrappedTag); expect(new OctolockTag(1)).toBeInstanceOf(TrappedTag);
}); });
it("can be added to pokemon who are not octolocked", async => {
const mockPokemon = {
getTag: vi.fn().mockReturnValue(undefined) as Pokemon["getTag"],
} as Pokemon;
const subject = new OctolockTag(1);
expect(subject.canAdd(mockPokemon)).toBeTruthy();
expect(mockPokemon.getTag).toHaveBeenCalledTimes(1);
expect(mockPokemon.getTag).toHaveBeenCalledWith(BattlerTagType.OCTOLOCK);
});
it("cannot be added to pokemon who are octolocked", async => {
const mockPokemon = {
getTag: vi.fn().mockReturnValue(new BattlerTag(null!, null!, null!, null!)) as Pokemon["getTag"],
} as Pokemon;
const subject = new OctolockTag(1);
expect(subject.canAdd(mockPokemon)).toBeFalsy();
expect(mockPokemon.getTag).toHaveBeenCalledTimes(1);
expect(mockPokemon.getTag).toHaveBeenCalledWith(BattlerTagType.OCTOLOCK);
});
}); });

View File

@ -6,7 +6,7 @@ import { Abilities } from "#app/enums/abilities";
import { Moves } from "#app/enums/moves"; import { Moves } from "#app/enums/moves";
import { Species } from "#app/enums/species"; import { Species } from "#app/enums/species";
import * as Messages from "#app/messages"; import * as Messages from "#app/messages";
import { TerastallizeModifier } from "#app/modifier/modifier"; import { TerastallizeModifier, overrideHeldItems } from "#app/modifier/modifier";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
@ -15,15 +15,17 @@ function testMoveEffectiveness(game: GameManager, move: Moves, targetSpecies: Sp
expected: number, targetAbility: Abilities = Abilities.BALL_FETCH, teraType?: Type): void { expected: number, targetAbility: Abilities = Abilities.BALL_FETCH, teraType?: Type): void {
// Suppress getPokemonNameWithAffix because it calls on a null battle spec // Suppress getPokemonNameWithAffix because it calls on a null battle spec
vi.spyOn(Messages, "getPokemonNameWithAffix").mockReturnValue(""); vi.spyOn(Messages, "getPokemonNameWithAffix").mockReturnValue("");
game.override.enemyAbility(targetAbility); game.override
.enemyAbility(targetAbility)
if (teraType !== undefined) { .enemyHeldItems([{ name:"TERA_SHARD", type: teraType }]);
game.override.enemyHeldItems([{ name:"TERA_SHARD", type: teraType }]);
}
const user = game.scene.addPlayerPokemon(getPokemonSpecies(Species.SNORLAX), 5); const user = game.scene.addPlayerPokemon(getPokemonSpecies(Species.SNORLAX), 5);
const target = game.scene.addEnemyPokemon(getPokemonSpecies(targetSpecies), 5, TrainerSlot.NONE); const target = game.scene.addEnemyPokemon(getPokemonSpecies(targetSpecies), 5, TrainerSlot.NONE);
if (teraType !== undefined) {
overrideHeldItems(game.scene, target, false);
}
expect(target.getMoveEffectiveness(user, allMoves[move])).toBe(expected); expect(target.getMoveEffectiveness(user, allMoves[move])).toBe(expected);
user.destroy(); user.destroy();
target.destroy(); target.destroy();

View File

@ -1,11 +1,8 @@
import { Stat } from "#enums/stat";
import { TrappedTag } from "#app/data/battler-tags"; import { TrappedTag } from "#app/data/battler-tags";
import { CommandPhase } from "#app/phases/command-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -27,12 +24,13 @@ describe("Moves - Octolock", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override.battleType("single") game.override
.enemySpecies(Species.RATTATA) .battleType("single")
.enemySpecies(Species.MAGIKARP)
.enemyMoveset(Moves.SPLASH) .enemyMoveset(Moves.SPLASH)
.enemyAbility(Abilities.BALL_FETCH) .enemyAbility(Abilities.BALL_FETCH)
.startingLevel(2000) .startingLevel(2000)
.moveset([ Moves.OCTOLOCK, Moves.SPLASH ]) .moveset([ Moves.OCTOLOCK, Moves.SPLASH, Moves.TRICK_OR_TREAT ])
.ability(Abilities.BALL_FETCH); .ability(Abilities.BALL_FETCH);
}); });
@ -43,16 +41,15 @@ describe("Moves - Octolock", () => {
// use Octolock and advance to init phase of next turn to check for stat changes // use Octolock and advance to init phase of next turn to check for stat changes
game.move.select(Moves.OCTOLOCK); game.move.select(Moves.OCTOLOCK);
await game.phaseInterceptor.to(TurnInitPhase); await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1);
// take a second turn to make sure stat changes occur again // take a second turn to make sure stat changes occur again
await game.phaseInterceptor.to(CommandPhase);
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.toNextTurn();
await game.phaseInterceptor.to(TurnInitPhase);
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-2); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-2);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-2); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-2);
}); });
@ -65,7 +62,7 @@ describe("Moves - Octolock", () => {
// use Octolock and advance to init phase of next turn to check for stat changes // use Octolock and advance to init phase of next turn to check for stat changes
game.move.select(Moves.OCTOLOCK); game.move.select(Moves.OCTOLOCK);
await game.phaseInterceptor.to(TurnInitPhase); await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1);
@ -79,7 +76,7 @@ describe("Moves - Octolock", () => {
// use Octolock and advance to init phase of next turn to check for stat changes // use Octolock and advance to init phase of next turn to check for stat changes
game.move.select(Moves.OCTOLOCK); game.move.select(Moves.OCTOLOCK);
await game.phaseInterceptor.to(TurnInitPhase); await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0);
@ -93,7 +90,7 @@ describe("Moves - Octolock", () => {
// use Octolock and advance to init phase of next turn to check for stat changes // use Octolock and advance to init phase of next turn to check for stat changes
game.move.select(Moves.OCTOLOCK); game.move.select(Moves.OCTOLOCK);
await game.phaseInterceptor.to(TurnInitPhase); await game.toNextTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0);
@ -110,7 +107,44 @@ describe("Moves - Octolock", () => {
game.move.select(Moves.OCTOLOCK); game.move.select(Moves.OCTOLOCK);
// after Octolock - enemy should be trapped // after Octolock - enemy should be trapped
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to("MoveEndPhase");
expect(enemyPokemon.findTag(t => t instanceof TrappedTag)).toBeDefined(); expect(enemyPokemon.findTag(t => t instanceof TrappedTag)).toBeDefined();
}); });
it("does not work on ghost type pokemon", async () => {
game.override.enemyMoveset(Moves.OCTOLOCK);
await game.classicMode.startBattle([ Species.GASTLY ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
// before Octolock - player should not be trapped
expect(playerPokemon.findTag(t => t instanceof TrappedTag)).toBeUndefined();
game.move.select(Moves.SPLASH);
await game.toNextTurn();
// after Octolock - player should still not be trapped, and no stat loss
expect(playerPokemon.findTag(t => t instanceof TrappedTag)).toBeUndefined();
expect(playerPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(0);
});
it("does not work on pokemon with added ghost type via Trick-or-Treat", async () => {
await game.classicMode.startBattle([ Species.FEEBAS ]);
const enemy = game.scene.getEnemyPokemon()!;
// before Octolock - pokemon should not be trapped
expect(enemy.findTag(t => t instanceof TrappedTag)).toBeUndefined();
game.move.select(Moves.TRICK_OR_TREAT);
await game.toNextTurn();
game.move.select(Moves.OCTOLOCK);
await game.toNextTurn();
// after Octolock - pokemon should still not be trapped, and no stat loss
expect(enemy.findTag(t => t instanceof TrappedTag)).toBeUndefined();
expect(enemy.getStatStage(Stat.DEF)).toBe(0);
expect(enemy.getStatStage(Stat.SPDEF)).toBe(0);
});
}); });

View File

@ -266,6 +266,9 @@ describe("Clowning Around - Mystery Encounter", () => {
// 5 Lucky Egg on lead (ultra) // 5 Lucky Egg on lead (ultra)
itemType = generateModifierType(scene, modifierTypes.LUCKY_EGG) as PokemonHeldItemModifierType; itemType = generateModifierType(scene, modifierTypes.LUCKY_EGG) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 5, itemType); await addItemToPokemon(scene, scene.getPlayerParty()[0], 5, itemType);
// 3 Soothe Bell on lead (great tier, but counted as ultra by this ME)
itemType = generateModifierType(scene, modifierTypes.SOOTHE_BELL) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 3, itemType);
// 5 Soul Dew on lead (rogue) // 5 Soul Dew on lead (rogue)
itemType = generateModifierType(scene, modifierTypes.SOUL_DEW) as PokemonHeldItemModifierType; itemType = generateModifierType(scene, modifierTypes.SOUL_DEW) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 5, itemType); await addItemToPokemon(scene, scene.getPlayerParty()[0], 5, itemType);
@ -286,7 +289,7 @@ describe("Clowning Around - Mystery Encounter", () => {
const rogueCountAfter = leadItemsAfter const rogueCountAfter = leadItemsAfter
.filter(m => m.type.tier === ModifierTier.ROGUE) .filter(m => m.type.tier === ModifierTier.ROGUE)
.reduce((a, b) => a + b.stackCount, 0); .reduce((a, b) => a + b.stackCount, 0);
expect(ultraCountAfter).toBe(10); expect(ultraCountAfter).toBe(13);
expect(rogueCountAfter).toBe(7); expect(rogueCountAfter).toBe(7);
const secondItemsAfter = scene.getPlayerParty()[1].getHeldItems(); const secondItemsAfter = scene.getPlayerParty()[1].getHeldItems();

View File

@ -18,6 +18,7 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
import { ModifierTier } from "#app/modifier/modifier-tier"; import { ModifierTier } from "#app/modifier/modifier-tier";
import * as Utils from "#app/utils";
const namespace = "mysteryEncounters/globalTradeSystem"; const namespace = "mysteryEncounters/globalTradeSystem";
const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ];
@ -176,6 +177,23 @@ describe("Global Trade System - Mystery Encounter", () => {
expect(defaultParty.includes(speciesAfter!)).toBeFalsy(); expect(defaultParty.includes(speciesAfter!)).toBeFalsy();
}); });
it("Should roll for shiny twice, with random variant and associated luck", async () => {
// This ensures that the first shiny roll gets ignored, to test the ME rerolling for shiny
game.override.enemyShiny(false);
await game.runToMysteryEncounter(MysteryEncounterType.GLOBAL_TRADE_SYSTEM, defaultParty);
vi.spyOn(Utils, "randSeedInt").mockReturnValue(1); // force shiny on reroll
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 });
const receivedPokemon = scene.getPlayerParty().at(-1)!;
expect(receivedPokemon.shiny).toBeTruthy();
expect(receivedPokemon.variant).toBeDefined();
expect(receivedPokemon.luck).toBe(receivedPokemon.variant + 1);
});
it("should leave encounter without battle", async () => { it("should leave encounter without battle", async () => {
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle"); const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");

View File

@ -18,6 +18,7 @@ import { TheExpertPokemonBreederEncounter } from "#app/data/mystery-encounters/e
import { TrainerType } from "#enums/trainer-type"; import { TrainerType } from "#enums/trainer-type";
import { EggTier } from "#enums/egg-type"; import { EggTier } from "#enums/egg-type";
import { PostMysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { PostMysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#app/data/balance/starters";
const namespace = "mysteryEncounters/theExpertPokemonBreeder"; const namespace = "mysteryEncounters/theExpertPokemonBreeder";
const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ];
@ -182,7 +183,10 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await game.phaseInterceptor.to(PostMysteryEncounterPhase); await game.phaseInterceptor.to(PostMysteryEncounterPhase);
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon1.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon1.friendship;
expect(friendshipAfter).toBe(friendshipBefore + 20 + 2); // +2 extra for friendship gained from winning battle // 20 from ME + extra from winning battle (that extra is not accurate to what happens in game.
// The Pokemon normally gets FRIENDSHIP_GAIN_FROM_BATTLE 3 times, once for each defeated Pokemon
// but due to how skipBattleRunMysteryEncounterRewardsPhase is implemented, it only receives it once)
expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE);
}); });
}); });
@ -261,7 +265,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await game.phaseInterceptor.to(PostMysteryEncounterPhase); await game.phaseInterceptor.to(PostMysteryEncounterPhase);
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon2.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon2.friendship;
expect(friendshipAfter).toBe(friendshipBefore + 20 + 2); // +2 extra for friendship gained from winning battle expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE); // 20 from ME + extra for friendship gained from winning battle
}); });
}); });
@ -340,7 +344,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await game.phaseInterceptor.to(PostMysteryEncounterPhase); await game.phaseInterceptor.to(PostMysteryEncounterPhase);
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon3.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon3.friendship;
expect(friendshipAfter).toBe(friendshipBefore + 20 + 2); // +2 extra for friendship gained from winning battle expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE); // 20 + extra for friendship gained from winning battle
}); });
}); });
}); });

View File

@ -123,7 +123,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
}); });
}); });
it("Should update the player's money properly", async () => { it("should update the player's money properly", async () => {
const initialMoney = 20000; const initialMoney = 20000;
scene.money = initialMoney; scene.money = initialMoney;
const updateMoneySpy = vi.spyOn(EncounterPhaseUtils, "updatePlayerMoney"); const updateMoneySpy = vi.spyOn(EncounterPhaseUtils, "updatePlayerMoney");
@ -137,7 +137,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
expect(scene.money).toBe(initialMoney - price); expect(scene.money).toBe(initialMoney - price);
}); });
it("Should add the Pokemon to the party", async () => { it("should add the Pokemon to the party", async () => {
scene.money = 20000; scene.money = 20000;
await game.runToMysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN, defaultParty);
@ -153,6 +153,18 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
expect(newlyPurchasedPokemon!.moveset.length > 0).toBeTruthy(); expect(newlyPurchasedPokemon!.moveset.length > 0).toBeTruthy();
}); });
it("should give the purchased Pokemon its HA or make it shiny", async () => {
scene.money = 20000;
await game.runToMysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN, defaultParty);
await runMysteryEncounterToEnd(game, 1);
const newlyPurchasedPokemon = scene.getPlayerParty()[scene.getPlayerParty().length - 1];
const isshiny = newlyPurchasedPokemon.shiny;
const hasHA = newlyPurchasedPokemon.abilityIndex === 2;
expect(isshiny || hasHA).toBeTruthy();
expect(isshiny && hasHA).toBeFalsy();
});
it("should be disabled if player does not have enough money", async () => { it("should be disabled if player does not have enough money", async () => {
scene.money = 0; scene.money = 0;
await game.runToMysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN, defaultParty);

View File

@ -109,6 +109,7 @@ describe("The Strong Stuff - Mystery Encounter", () => {
species: getPokemonSpecies(Species.SHUCKLE), species: getPokemonSpecies(Species.SHUCKLE),
isBoss: true, isBoss: true,
bossSegments: 5, bossSegments: 5,
shiny: false,
customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }), customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }),
nature: Nature.BOLD, nature: Nature.BOLD,
moveSet: [ Moves.INFESTATION, Moves.SALT_CURE, Moves.GASTRO_ACID, Moves.HEAL_ORDER ], moveSet: [ Moves.INFESTATION, Moves.SALT_CURE, Moves.GASTRO_ACID, Moves.HEAL_ORDER ],

View File

@ -92,6 +92,7 @@ describe("Trash to Treasure - Mystery Encounter", () => {
{ {
species: getPokemonSpecies(Species.GARBODOR), species: getPokemonSpecies(Species.GARBODOR),
isBoss: true, isBoss: true,
shiny: false,
formIndex: 1, formIndex: 1,
bossSegmentModifier: 1, bossSegmentModifier: 1,
moveSet: [ Moves.PAYBACK, Moves.GUNK_SHOT, Moves.STOMPING_TANTRUM, Moves.DRAIN_PUNCH ], moveSet: [ Moves.PAYBACK, Moves.GUNK_SHOT, Moves.STOMPING_TANTRUM, Moves.DRAIN_PUNCH ],

View File

@ -51,6 +51,7 @@ import { Abilities } from "#enums/abilities";
import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters"; import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters";
import { BooleanHolder, capitalizeString, fixedInt, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, randIntRange, rgbHexToRgba, toReadableString } from "#app/utils"; import { BooleanHolder, capitalizeString, fixedInt, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, randIntRange, rgbHexToRgba, toReadableString } from "#app/utils";
import type { Nature } from "#enums/nature"; import type { Nature } from "#enums/nature";
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
export type StarterSelectCallback = (starters: Starter[]) => void; export type StarterSelectCallback = (starters: Starter[]) => void;
@ -1462,7 +1463,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
const currentPartyValue = this.starterSpecies.map(s => s.generation).reduce((total: number, gen: number, i: number) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); const currentPartyValue = this.starterSpecies.map(s => s.generation).reduce((total: number, gen: number, i: number) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0);
const newCost = this.scene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId); const newCost = this.scene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId);
if (!isDupe && isValidForChallenge.value && currentPartyValue + newCost <= this.getValueLimit() && this.starterSpecies.length < 6) { // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party if (!isDupe && isValidForChallenge.value && currentPartyValue + newCost <= this.getValueLimit() && this.starterSpecies.length < PLAYER_PARTY_MAX_SIZE) { // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party
options = [ options = [
{ {
label: i18next.t("starterSelectUiHandler:addToParty"), label: i18next.t("starterSelectUiHandler:addToParty"),