merge up to date

This commit is contained in:
Lylian 2024-11-16 16:34:19 +01:00
commit cdb350fde4
67 changed files with 1844 additions and 611 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

View File

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

View File

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

View File

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

View File

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

View File

@ -1233,14 +1233,41 @@ export default class BattleScene extends SceneBase {
newDouble = !!double; newDouble = !!double;
} }
if (Overrides.BATTLE_TYPE_OVERRIDE === "double") { // Disable double battles on Endless/Endless Spliced Wave 50x boss battles (Introduced 1.2.0)
newDouble = true; if (this.gameMode.isEndlessBoss(newWaveIndex)) {
}
/* Override battles into single only if not fighting with trainers */
if (newBattleType !== BattleType.TRAINER && Overrides.BATTLE_TYPE_OVERRIDE === "single") {
newDouble = false; newDouble = false;
} }
if (!isNullOrUndefined(Overrides.BATTLE_TYPE_OVERRIDE)) {
let doubleOverrideForWave: "single" | "double" | null = null;
switch (Overrides.BATTLE_TYPE_OVERRIDE) {
case "double":
doubleOverrideForWave = "double";
break;
case "single":
doubleOverrideForWave = "single";
break;
case "even-doubles":
doubleOverrideForWave = (newWaveIndex % 2) ? "single" : "double";
break;
case "odd-doubles":
doubleOverrideForWave = (newWaveIndex % 2) ? "double" : "single";
break;
}
if (doubleOverrideForWave === "double") {
newDouble = true;
}
/**
* Override battles into single only if not fighting with trainers.
* @see {@link https://github.com/pagefaultgames/pokerogue/issues/1948 | GitHub Issue #1948}
*/
if (newBattleType !== BattleType.TRAINER && doubleOverrideForWave === "single") {
newDouble = false;
}
}
const lastBattle = this.currentBattle; const lastBattle = this.currentBattle;
const maxExpLevel = this.getMaxExpLevel(); const maxExpLevel = this.getMaxExpLevel();
@ -1397,10 +1424,19 @@ export default class BattleScene extends SceneBase {
case Species.PALDEA_TAUROS: case Species.PALDEA_TAUROS:
return Utils.randSeedInt(species.forms.length); return Utils.randSeedInt(species.forms.length);
case Species.PIKACHU: case Species.PIKACHU:
if (this.currentBattle?.battleType === BattleType.TRAINER && this.currentBattle?.waveIndex < 30) {
return 0; // Ban Cosplay and Partner Pika from Trainers before wave 30
}
return Utils.randSeedInt(8); return Utils.randSeedInt(8);
case Species.EEVEE: case Species.EEVEE:
if (this.currentBattle?.battleType === BattleType.TRAINER && this.currentBattle?.waveIndex < 30) {
return 0; // No Partner Eevee for Wave 12 Preschoolers
}
return Utils.randSeedInt(2); return Utils.randSeedInt(2);
case Species.GRENINJA: case Species.GRENINJA:
if (this.currentBattle?.battleType === BattleType.TRAINER) {
return 0; // Don't give trainers Battle Bond Greninja
}
return Utils.randSeedInt(2); return Utils.randSeedInt(2);
case Species.ZYGARDE: case Species.ZYGARDE:
return Utils.randSeedInt(4); return Utils.randSeedInt(4);
@ -2572,14 +2608,15 @@ export default class BattleScene extends SceneBase {
* The quantity to transfer is automatically capped at how much the recepient can take before reaching the maximum stack size for the item. * The quantity to transfer is automatically capped at how much the recepient can take before reaching the maximum stack size for the item.
* A transfer that moves a quantity smaller than what is specified in the transferQuantity parameter is still considered successful. * A transfer that moves a quantity smaller than what is specified in the transferQuantity parameter is still considered successful.
* @param itemModifier {@linkcode PokemonHeldItemModifier} item to transfer (represents the whole stack) * @param itemModifier {@linkcode PokemonHeldItemModifier} item to transfer (represents the whole stack)
* @param target {@linkcode Pokemon} pokemon recepient in this transfer * @param target {@linkcode Pokemon} recepient in this transfer
* @param playSound {boolean} * @param playSound `true` to play a sound when transferring the item
* @param transferQuantity {@linkcode integer} how many items of the stack to transfer. Optional, defaults to 1 * @param transferQuantity How many items of the stack to transfer. Optional, defaults to `1`
* @param instant {boolean} * @param instant ??? (Optional)
* @param ignoreUpdate {boolean} * @param ignoreUpdate ??? (Optional)
* @returns true if the transfer was successful * @param itemLost If `true`, treat the item's current holder as losing the item (for now, this simply enables Unburden). Default is `true`.
* @returns `true` if the transfer was successful
*/ */
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, transferQuantity: integer = 1, instant?: boolean, ignoreUpdate?: boolean): Promise<boolean> { tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, transferQuantity: number = 1, instant?: boolean, ignoreUpdate?: boolean, itemLost: boolean = true): Promise<boolean> {
return new Promise(resolve => { return new Promise(resolve => {
const source = itemModifier.pokemonId ? itemModifier.getPokemon(target.scene) : null; const source = itemModifier.pokemonId ? itemModifier.getPokemon(target.scene) : null;
const cancelled = new Utils.BooleanHolder(false); const cancelled = new Utils.BooleanHolder(false);
@ -2612,14 +2649,14 @@ export default class BattleScene extends SceneBase {
if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) { if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) {
if (target.isPlayer()) { if (target.isPlayer()) {
this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => { this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => {
if (source) { if (source && itemLost) {
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false); applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
} }
resolve(true); resolve(true);
}); });
} else { } else {
this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => { this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => {
if (source) { if (source && itemLost) {
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false); applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
} }
resolve(true); resolve(true);
@ -2791,7 +2828,15 @@ export default class BattleScene extends SceneBase {
}); });
} }
removeModifier(modifier: PersistentModifier, enemy?: boolean): boolean { /**
* Removes a currently owned item. If the item is stacked, the entire item stack
* gets removed. This function does NOT apply in-battle effects, such as Unburden.
* If in-battle effects are needed, use {@linkcode Pokemon.loseHeldItem} instead.
* @param modifier The item to be removed.
* @param enemy If `true`, remove an item owned by the enemy. If `false`, remove an item owned by the player. Default is `false`.
* @returns `true` if the item exists and was successfully removed, `false` otherwise.
*/
removeModifier(modifier: PersistentModifier, enemy: boolean = false): boolean {
const modifiers = !enemy ? this.modifiers : this.enemyModifiers; const modifiers = !enemy ? this.modifiers : this.enemyModifiers;
const modifierIndex = modifiers.indexOf(modifier); const modifierIndex = modifiers.indexOf(modifier);
if (modifierIndex > -1) { if (modifierIndex > -1) {

View File

@ -7,7 +7,7 @@ import { Weather } from "#app/data/weather";
import { BattlerTag, BattlerTagLapseType, GroundedTag } from "./battler-tags"; import { BattlerTag, BattlerTagLapseType, GroundedTag } from "./battler-tags";
import { getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "#app/data/status-effect"; import { getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "#app/data/status-effect";
import { Gender } from "./gender"; import { Gender } from "./gender";
import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, MoveAttr, MultiHitAttr, SacrificialAttr, SacrificialAttrOnHit, NeutralDamageAgainstFlyingTypeMultiplierAttr, FixedDamageAttr } from "./move"; import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, NeutralDamageAgainstFlyingTypeMultiplierAttr, FixedDamageAttr } from "./move";
import { ArenaTagSide, ArenaTrapTag } from "./arena-tag"; import { ArenaTagSide, ArenaTrapTag } from "./arena-tag";
import { BerryModifier, HitHealModifier, PokemonHeldItemModifier } from "../modifier/modifier"; import { BerryModifier, HitHealModifier, PokemonHeldItemModifier } from "../modifier/modifier";
import { TerrainType } from "./terrain"; import { TerrainType } from "./terrain";
@ -516,7 +516,7 @@ export class NonSuperEffectiveImmunityAbAttr extends TypeImmunityAbAttr {
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const modifierValue = args.length > 0 const modifierValue = args.length > 0
? (args[0] as Utils.NumberHolder).value ? (args[0] as Utils.NumberHolder).value
: pokemon.getAttackTypeEffectiveness(attacker.getMoveType(move), attacker); : pokemon.getAttackTypeEffectiveness(attacker.getMoveType(move), attacker, undefined, undefined, move);
if (move instanceof AttackMove && modifierValue < 2) { if (move instanceof AttackMove && modifierValue < 2) {
cancelled.value = true; // Suppresses "No Effect" message cancelled.value = true; // Suppresses "No Effect" message
@ -1351,65 +1351,30 @@ export class AddSecondStrikeAbAttr extends PreAttackAbAttr {
this.damageMultiplier = damageMultiplier; this.damageMultiplier = damageMultiplier;
} }
/**
* Determines whether this attribute can apply to a given move.
* @param {Move} move the move to which this attribute may apply
* @param numTargets the number of {@linkcode Pokemon} targeted by this move
* @returns true if the attribute can apply to the move, false otherwise
*/
canApplyPreAttack(move: Move, numTargets: integer): boolean {
/**
* Parental Bond cannot apply to multi-hit moves, charging moves, or
* moves that cause the user to faint.
*/
const exceptAttrs: Constructor<MoveAttr>[] = [
MultiHitAttr,
SacrificialAttr,
SacrificialAttrOnHit
];
/** Parental Bond cannot apply to these specific moves */
const exceptMoves: Moves[] = [
Moves.FLING,
Moves.UPROAR,
Moves.ROLLOUT,
Moves.ICE_BALL,
Moves.ENDEAVOR
];
/** Also check if this move is an Attack move and if it's only targeting one Pokemon */
return numTargets === 1
&& !move.isChargingMove()
&& !exceptAttrs.some(attr => move.hasAttr(attr))
&& !exceptMoves.some(id => move.id === id)
&& move.category !== MoveCategory.STATUS;
}
/** /**
* If conditions are met, this doubles the move's hit count (via args[1]) * If conditions are met, this doubles the move's hit count (via args[1])
* or multiplies the damage of secondary strikes (via args[2]) * or multiplies the damage of secondary strikes (via args[2])
* @param {Pokemon} pokemon the Pokemon using the move * @param pokemon the {@linkcode Pokemon} using the move
* @param passive n/a * @param passive n/a
* @param defender n/a * @param defender n/a
* @param {Move} move the move used by the ability source * @param move the {@linkcode Move} used by the ability source
* @param args\[0\] the number of Pokemon this move is targeting * @param args Additional arguments:
* @param {Utils.IntegerHolder} args\[1\] the number of strikes with this move * - `[0]` the number of strikes this move currently has ({@linkcode Utils.NumberHolder})
* @param {Utils.NumberHolder} args\[2\] the damage multiplier for the current strike * - `[1]` the damage multiplier for the current strike ({@linkcode Utils.NumberHolder})
* @returns * @returns
*/ */
applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean { applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean {
const numTargets = args[0] as integer; const hitCount = args[0] as Utils.NumberHolder;
const hitCount = args[1] as Utils.IntegerHolder; const multiplier = args[1] as Utils.NumberHolder;
const multiplier = args[2] as Utils.NumberHolder;
if (this.canApplyPreAttack(move, numTargets)) { if (move.canBeMultiStrikeEnhanced(pokemon, true)) {
this.showAbility = !!hitCount?.value; this.showAbility = !!hitCount?.value;
if (!!hitCount?.value) { if (hitCount?.value) {
hitCount.value *= 2; hitCount.value += 1;
} }
if (!!multiplier?.value && pokemon.turnData.hitsLeft % 2 === 1 && pokemon.turnData.hitsLeft !== pokemon.turnData.hitCount) { if (multiplier?.value && pokemon.turnData.hitsLeft === 1) {
multiplier.value *= this.damageMultiplier; multiplier.value = this.damageMultiplier;
} }
return true; return true;
} }
@ -2474,12 +2439,15 @@ export class PostSummonCopyAllyStatsAbAttr extends PostSummonAbAttr {
} }
} }
/**
* Used by Imposter
*/
export class PostSummonTransformAbAttr extends PostSummonAbAttr { export class PostSummonTransformAbAttr extends PostSummonAbAttr {
constructor() { constructor() {
super(true); super(true);
} }
async applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): Promise<boolean> { async applyPostSummon(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): Promise<boolean> {
const targets = pokemon.getOpponents(); const targets = pokemon.getOpponents();
if (simulated || !targets.length) { if (simulated || !targets.length) {
return simulated; return simulated;
@ -2488,7 +2456,18 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
let target: Pokemon = targets[0]; let target: Pokemon = targets[0];
if (targets.length > 1) { if (targets.length > 1) {
pokemon.scene.executeWithSeedOffset(() => target = Utils.randSeedItem(targets), pokemon.scene.currentBattle.waveIndex); pokemon.scene.executeWithSeedOffset(() => {
// in a double battle, if one of the opposing pokemon is fused the other one will be chosen
// if both are fused, then Imposter will fail below
if (targets[0].fusionSpecies) {
target = targets[1];
return;
} else if (targets[1].fusionSpecies) {
target = targets[0];
return;
}
target = Utils.randSeedItem(targets);
}, pokemon.scene.currentBattle.waveIndex);
} else { } else {
target = targets[0]; target = targets[0];
} }
@ -2497,11 +2476,15 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
return false; return false;
} }
target = target!; target = target!;
// transforming from or into fusion pokemon causes various problems (including crashes and save corruption)
if (target.fusionSpecies || pokemon.fusionSpecies) {
return false;
}
pokemon.summonData.speciesForm = target.getSpeciesForm(); pokemon.summonData.speciesForm = target.getSpeciesForm();
pokemon.summonData.fusionSpeciesForm = target.getFusionSpeciesForm();
pokemon.summonData.ability = target.getAbility().id; pokemon.summonData.ability = target.getAbility().id;
pokemon.summonData.gender = target.getGender(); pokemon.summonData.gender = target.getGender();
pokemon.summonData.fusionGender = target.getFusionGender();
// Copy all stats (except HP) // Copy all stats (except HP)
for (const s of EFFECTIVE_STATS) { for (const s of EFFECTIVE_STATS) {
@ -3212,7 +3195,7 @@ function getAnticipationCondition(): AbAttrCondition {
continue; continue;
} }
// the move's base type (not accounting for variable type changes) is super effective // the move's base type (not accounting for variable type changes) is super effective
if (move.getMove() instanceof AttackMove && pokemon.getAttackTypeEffectiveness(move.getMove().type, opponent, true) >= 2) { if (move.getMove() instanceof AttackMove && pokemon.getAttackTypeEffectiveness(move.getMove().type, opponent, true, undefined, move.getMove()) >= 2) {
return true; return true;
} }
// move is a OHKO // move is a OHKO
@ -4149,7 +4132,7 @@ export class PostBattleLootAbAttr extends PostBattleAbAttr {
if (!simulated && postBattleLoot.length) { if (!simulated && postBattleLoot.length) {
const randItem = Utils.randSeedItem(postBattleLoot); const randItem = Utils.randSeedItem(postBattleLoot);
//@ts-ignore - TODO see below //@ts-ignore - TODO see below
if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true)) { // TODO: fix. This is a promise!? if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true, undefined, false)) { // TODO: fix. This is a promise!?
postBattleLoot.splice(postBattleLoot.indexOf(randItem), 1); postBattleLoot.splice(postBattleLoot.indexOf(randItem), 1);
pokemon.scene.queueMessage(i18next.t("abilityTriggers:postBattleLoot", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), itemName: randItem.type.name })); pokemon.scene.queueMessage(i18next.t("abilityTriggers:postBattleLoot", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), itemName: randItem.type.name }));
return true; return true;
@ -5710,7 +5693,9 @@ export function initAbilities() {
new Ability(Abilities.ANGER_POINT, 4) new Ability(Abilities.ANGER_POINT, 4)
.attr(PostDefendCritStatStageChangeAbAttr, Stat.ATK, 6), .attr(PostDefendCritStatStageChangeAbAttr, Stat.ATK, 6),
new Ability(Abilities.UNBURDEN, 4) new Ability(Abilities.UNBURDEN, 4)
.attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN), .attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN)
.bypassFaint() // Allows reviver seed to activate Unburden
.edgeCase(), // Should not restore Unburden boost if Pokemon loses then regains Unburden ability
new Ability(Abilities.HEATPROOF, 4) new Ability(Abilities.HEATPROOF, 4)
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5) .attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
.attr(ReduceBurnDamageAbAttr, 0.5) .attr(ReduceBurnDamageAbAttr, 0.5)

View File

@ -3302,11 +3302,23 @@ export const tmSpecies: TmSpecies = {
Species.FERALIGATR, Species.FERALIGATR,
Species.SENTRET, Species.SENTRET,
Species.FURRET, Species.FURRET,
Species.HOOTHOOT,
Species.NOCTOWL, Species.NOCTOWL,
Species.LEDYBA,
Species.LEDIAN,
Species.SPINARAK,
Species.ARIADOS,
Species.CROBAT, Species.CROBAT,
Species.CHINCHOU, Species.CHINCHOU,
Species.LANTURN, Species.LANTURN,
Species.PICHU,
Species.CLEFFA,
Species.IGGLYBUFF, Species.IGGLYBUFF,
Species.TYROGUE,
Species.TOGEPI,
Species.TOGETIC,
Species.NATU,
Species.XATU,
Species.MAREEP, Species.MAREEP,
Species.FLAAFFY, Species.FLAAFFY,
Species.AMPHAROS, Species.AMPHAROS,
@ -3328,6 +3340,7 @@ export const tmSpecies: TmSpecies = {
Species.UMBREON, Species.UMBREON,
Species.MURKROW, Species.MURKROW,
Species.SLOWKING, Species.SLOWKING,
Species.MISDREAVUS,
Species.GIRAFARIG, Species.GIRAFARIG,
Species.PINECO, Species.PINECO,
Species.FORRETRESS, Species.FORRETRESS,
@ -3338,11 +3351,21 @@ export const tmSpecies: TmSpecies = {
Species.GRANBULL, Species.GRANBULL,
Species.QWILFISH, Species.QWILFISH,
Species.SCIZOR, Species.SCIZOR,
Species.SHUCKLE,
Species.HERACROSS, Species.HERACROSS,
Species.SNEASEL,
Species.TEDDIURSA, Species.TEDDIURSA,
Species.URSARING, Species.URSARING,
Species.SLUGMA,
Species.MAGCARGO,
Species.SWINUB, Species.SWINUB,
Species.PILOSWINE, Species.PILOSWINE,
Species.CORSOLA,
Species.REMORAID,
Species.OCTILLERY,
Species.DELIBIRD,
Species.MANTINE,
Species.SKARMORY,
Species.HOUNDOUR, Species.HOUNDOUR,
Species.HOUNDOOM, Species.HOUNDOOM,
Species.KINGDRA, Species.KINGDRA,
@ -3350,9 +3373,12 @@ export const tmSpecies: TmSpecies = {
Species.DONPHAN, Species.DONPHAN,
Species.PORYGON2, Species.PORYGON2,
Species.STANTLER, Species.STANTLER,
Species.TYROGUE,
Species.HITMONTOP, Species.HITMONTOP,
Species.SMOOCHUM,
Species.ELEKID, Species.ELEKID,
Species.MAGBY, Species.MAGBY,
Species.MILTANK,
Species.BLISSEY, Species.BLISSEY,
Species.RAIKOU, Species.RAIKOU,
Species.ENTEI, Species.ENTEI,
@ -3362,6 +3388,9 @@ export const tmSpecies: TmSpecies = {
Species.TYRANITAR, Species.TYRANITAR,
Species.LUGIA, Species.LUGIA,
Species.HO_OH, Species.HO_OH,
Species.CELEBI,
Species.TREECKO,
Species.GROVYLE,
Species.SCEPTILE, Species.SCEPTILE,
Species.TORCHIC, Species.TORCHIC,
Species.COMBUSKEN, Species.COMBUSKEN,
@ -3371,41 +3400,116 @@ export const tmSpecies: TmSpecies = {
Species.SWAMPERT, Species.SWAMPERT,
Species.POOCHYENA, Species.POOCHYENA,
Species.MIGHTYENA, Species.MIGHTYENA,
Species.ZIGZAGOON,
Species.LINOONE,
Species.BEAUTIFLY,
Species.DUSTOX,
Species.LOTAD, Species.LOTAD,
Species.LOMBRE, Species.LOMBRE,
Species.LUDICOLO, Species.LUDICOLO,
Species.SEEDOT, Species.SEEDOT,
Species.NUZLEAF, Species.NUZLEAF,
Species.SHIFTRY, Species.SHIFTRY,
Species.TAILLOW,
Species.SWELLOW,
Species.WINGULL,
Species.PELIPPER,
Species.RALTS,
Species.KIRLIA,
Species.GARDEVOIR,
Species.SURSKIT,
Species.MASQUERAIN,
Species.SHROOMISH,
Species.BRELOOM,
Species.VIGOROTH, Species.VIGOROTH,
Species.SLAKING, Species.SLAKING,
Species.NINCADA,
Species.NINJASK,
Species.SHEDINJA,
Species.WHISMUR,
Species.LOUDRED,
Species.EXPLOUD,
Species.MAKUHITA, Species.MAKUHITA,
Species.HARIYAMA, Species.HARIYAMA,
Species.AZURILL,
Species.NOSEPASS, Species.NOSEPASS,
Species.SKITTY,
Species.DELCATTY,
Species.SABLEYE,
Species.MAWILE,
Species.ARON,
Species.LAIRON,
Species.AGGRON,
Species.MEDITITE,
Species.MEDICHAM,
Species.ELECTRIKE,
Species.MANECTRIC,
Species.PLUSLE,
Species.MINUN,
Species.VOLBEAT, Species.VOLBEAT,
Species.ILLUMISE, Species.ILLUMISE,
Species.ROSELIA,
Species.GULPIN,
Species.SWALOT, Species.SWALOT,
Species.CARVANHA,
Species.SHARPEDO,
Species.WAILMER,
Species.WAILORD,
Species.NUMEL, Species.NUMEL,
Species.CAMERUPT, Species.CAMERUPT,
Species.TORKOAL, Species.TORKOAL,
Species.SPOINK,
Species.GRUMPIG,
Species.SPINDA,
Species.TRAPINCH,
Species.VIBRAVA,
Species.FLYGON, Species.FLYGON,
Species.CACNEA,
Species.CACTURNE,
Species.SWABLU,
Species.ALTARIA, Species.ALTARIA,
Species.ZANGOOSE, Species.ZANGOOSE,
Species.SEVIPER, Species.SEVIPER,
Species.LUNATONE,
Species.SOLROCK,
Species.BARBOACH, Species.BARBOACH,
Species.WHISCASH, Species.WHISCASH,
Species.CORPHISH, Species.CORPHISH,
Species.CRAWDAUNT, Species.CRAWDAUNT,
Species.BALTOY,
Species.CLAYDOL,
Species.LILEEP,
Species.CRADILY,
Species.ANORITH,
Species.ARMALDO,
Species.FEEBAS, Species.FEEBAS,
Species.MILOTIC, Species.MILOTIC,
Species.CASTFORM,
Species.KECLEON,
Species.SHUPPET,
Species.BANETTE,
Species.DUSKULL,
Species.DUSCLOPS,
Species.TROPIUS, Species.TROPIUS,
Species.CHIMECHO, Species.CHIMECHO,
Species.ABSOL,
Species.SNORUNT,
Species.GLALIE,
Species.SPHEAL,
Species.SEALEO,
Species.WALREIN,
Species.CLAMPERL,
Species.HUNTAIL,
Species.GOREBYSS,
Species.RELICANTH,
Species.LUVDISC,
Species.BAGON, Species.BAGON,
Species.SHELGON, Species.SHELGON,
Species.SALAMENCE, Species.SALAMENCE,
Species.METANG, Species.METANG,
Species.METAGROSS, Species.METAGROSS,
Species.REGIROCK, Species.REGIROCK,
Species.REGICE,
Species.REGISTEEL, Species.REGISTEEL,
Species.LATIAS, Species.LATIAS,
Species.LATIOS, Species.LATIOS,
@ -3413,6 +3517,7 @@ export const tmSpecies: TmSpecies = {
Species.GROUDON, Species.GROUDON,
Species.RAYQUAZA, Species.RAYQUAZA,
Species.JIRACHI, Species.JIRACHI,
Species.DEOXYS,
Species.TURTWIG, Species.TURTWIG,
Species.GROTLE, Species.GROTLE,
Species.TORTERRA, Species.TORTERRA,
@ -64246,12 +64351,16 @@ export const tmSpecies: TmSpecies = {
Species.BLOODMOON_URSALUNA, Species.BLOODMOON_URSALUNA,
], ],
[Moves.LIQUIDATION]: [ [Moves.LIQUIDATION]: [
Species.SQUIRTLE,
Species.WARTORTLE,
Species.BLASTOISE, Species.BLASTOISE,
Species.PSYDUCK, Species.PSYDUCK,
Species.GOLDUCK, Species.GOLDUCK,
Species.POLIWAG, Species.POLIWAG,
Species.POLIWHIRL, Species.POLIWHIRL,
Species.POLIWRATH, Species.POLIWRATH,
Species.TENTACOOL,
Species.TENTACRUEL,
Species.SLOWPOKE, Species.SLOWPOKE,
Species.SLOWBRO, Species.SLOWBRO,
Species.DEWGONG, Species.DEWGONG,
@ -64267,7 +64376,11 @@ export const tmSpecies: TmSpecies = {
Species.KABUTO, Species.KABUTO,
Species.KABUTOPS, Species.KABUTOPS,
Species.MEW, Species.MEW,
Species.TOTODILE,
Species.CROCONAW,
Species.FERALIGATR, Species.FERALIGATR,
Species.CHINCHOU,
Species.LANTURN,
Species.MARILL, Species.MARILL,
Species.AZUMARILL, Species.AZUMARILL,
Species.POLITOED, Species.POLITOED,
@ -64280,6 +64393,9 @@ export const tmSpecies: TmSpecies = {
Species.MANTINE, Species.MANTINE,
Species.KINGDRA, Species.KINGDRA,
Species.SUICUNE, Species.SUICUNE,
Species.LUGIA,
Species.MUDKIP,
Species.MARSHTOMP,
Species.SWAMPERT, Species.SWAMPERT,
Species.WINGULL, Species.WINGULL,
Species.PELIPPER, Species.PELIPPER,
@ -64296,6 +64412,8 @@ export const tmSpecies: TmSpecies = {
Species.WALREIN, Species.WALREIN,
Species.RELICANTH, Species.RELICANTH,
Species.LUVDISC, Species.LUVDISC,
Species.LATIAS,
Species.LATIOS,
Species.KYOGRE, Species.KYOGRE,
Species.PIPLUP, Species.PIPLUP,
Species.PRINPLUP, Species.PRINPLUP,
@ -64407,11 +64525,13 @@ export const tmSpecies: TmSpecies = {
Species.ONIX, Species.ONIX,
Species.HYPNO, Species.HYPNO,
Species.LICKITUNG, Species.LICKITUNG,
Species.RHYHORN,
Species.RHYDON, Species.RHYDON,
Species.LAPRAS, Species.LAPRAS,
Species.SNORLAX, Species.SNORLAX,
Species.DRAGONITE, Species.DRAGONITE,
Species.MEW, Species.MEW,
Species.MEGANIUM,
Species.SUDOWOODO, Species.SUDOWOODO,
Species.QUAGSIRE, Species.QUAGSIRE,
Species.FORRETRESS, Species.FORRETRESS,
@ -64445,6 +64565,8 @@ export const tmSpecies: TmSpecies = {
Species.REGISTEEL, Species.REGISTEEL,
Species.GROUDON, Species.GROUDON,
Species.TORTERRA, Species.TORTERRA,
Species.RAMPARDOS,
Species.BASTIODON,
Species.BRONZONG, Species.BRONZONG,
Species.HIPPOPOTAS, Species.HIPPOPOTAS,
Species.HIPPOWDON, Species.HIPPOWDON,
@ -64459,6 +64581,7 @@ export const tmSpecies: TmSpecies = {
Species.HEATRAN, Species.HEATRAN,
Species.REGIGIGAS, Species.REGIGIGAS,
Species.ARCEUS, Species.ARCEUS,
Species.EMBOAR,
Species.ROGGENROLA, Species.ROGGENROLA,
Species.BOLDORE, Species.BOLDORE,
Species.GIGALITH, Species.GIGALITH,
@ -64471,6 +64594,7 @@ export const tmSpecies: TmSpecies = {
Species.CUBCHOO, Species.CUBCHOO,
Species.BEARTIC, Species.BEARTIC,
Species.GOLURK, Species.GOLURK,
Species.COBALION,
Species.RESHIRAM, Species.RESHIRAM,
Species.ZEKROM, Species.ZEKROM,
Species.KYUREM, Species.KYUREM,

View File

@ -1502,9 +1502,14 @@ export class ContactBurnProtectedTag extends DamageProtectedTag {
} }
} }
/**
* `BattlerTag` class for effects that cause the affected Pokemon to survive lethal attacks at 1 HP.
* Used for {@link https://bulbapedia.bulbagarden.net/wiki/Endure_(move) | Endure} and
* Endure Tokens.
*/
export class EnduringTag extends BattlerTag { export class EnduringTag extends BattlerTag {
constructor(sourceMove: Moves) { constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType, sourceMove: Moves) {
super(BattlerTagType.ENDURING, BattlerTagLapseType.TURN_END, 0, sourceMove); super(tagType, lapseType, 0, sourceMove);
} }
onAdd(pokemon: Pokemon): void { onAdd(pokemon: Pokemon): void {
@ -1809,8 +1814,8 @@ export class TypeImmuneTag extends BattlerTag {
* @see {@link https://bulbapedia.bulbagarden.net/wiki/Telekinesis_(move) | Moves.TELEKINESIS} * @see {@link https://bulbapedia.bulbagarden.net/wiki/Telekinesis_(move) | Moves.TELEKINESIS}
*/ */
export class FloatingTag extends TypeImmuneTag { export class FloatingTag extends TypeImmuneTag {
constructor(tagType: BattlerTagType, sourceMove: Moves) { constructor(tagType: BattlerTagType, sourceMove: Moves, turnCount: number) {
super(tagType, sourceMove, Type.GROUND, 5); super(tagType, sourceMove, Type.GROUND, turnCount);
} }
onAdd(pokemon: Pokemon): void { onAdd(pokemon: Pokemon): void {
@ -2158,6 +2163,11 @@ export class CommandedTag extends BattlerTag {
pokemon.scene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.COMMANDER_REMOVE); pokemon.scene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.COMMANDER_REMOVE);
} }
} }
override loadTag(source: BattlerTag | any): void {
super.loadTag(source);
this._tatsugiriFormKey = source._tatsugiriFormKey;
}
} }
/** /**
@ -3004,7 +3014,9 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
case BattlerTagType.BURNING_BULWARK: case BattlerTagType.BURNING_BULWARK:
return new ContactBurnProtectedTag(sourceMove); return new ContactBurnProtectedTag(sourceMove);
case BattlerTagType.ENDURING: case BattlerTagType.ENDURING:
return new EnduringTag(sourceMove); return new EnduringTag(tagType, BattlerTagLapseType.TURN_END, sourceMove);
case BattlerTagType.ENDURE_TOKEN:
return new EnduringTag(tagType, BattlerTagLapseType.AFTER_HIT, sourceMove);
case BattlerTagType.STURDY: case BattlerTagType.STURDY:
return new SturdyTag(sourceMove); return new SturdyTag(sourceMove);
case BattlerTagType.PERISH_SONG: case BattlerTagType.PERISH_SONG:
@ -3053,7 +3065,7 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
case BattlerTagType.CHARGED: case BattlerTagType.CHARGED:
return new TypeBoostTag(tagType, sourceMove, Type.ELECTRIC, 2, true); return new TypeBoostTag(tagType, sourceMove, Type.ELECTRIC, 2, true);
case BattlerTagType.FLOATING: case BattlerTagType.FLOATING:
return new FloatingTag(tagType, sourceMove); return new FloatingTag(tagType, sourceMove, turnCount);
case BattlerTagType.MINIMIZED: case BattlerTagType.MINIMIZED:
return new MinimizeTag(); return new MinimizeTag();
case BattlerTagType.DESTINY_BOND: case BattlerTagType.DESTINY_BOND:

View File

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

View File

@ -653,7 +653,7 @@ export class FreshStartChallenge extends Challenge {
pokemon.shiny = false; // Not shiny pokemon.shiny = false; // Not shiny
pokemon.variant = 0; // Not shiny pokemon.variant = 0; // Not shiny
pokemon.formIndex = 0; // Froakie should be base form pokemon.formIndex = 0; // Froakie should be base form
pokemon.ivs = [ 10, 10, 10, 10, 10, 10 ]; // Default IVs of 10 for all stats pokemon.ivs = [ 15, 15, 15, 15, 15, 15 ]; // Default IVs of 15 for all stats (Updated to 15 from 10 in 1.2.0)
return true; return true;
} }

View File

@ -668,12 +668,12 @@ export default class Move implements Localizable {
} }
/** /**
* Sees if, given the target pokemon, a move fails on it (by looking at each {@linkcode MoveAttr} of this move * Sees if a move has a custom failure text (by looking at each {@linkcode MoveAttr} of this move)
* @param user {@linkcode Pokemon} using the move * @param user {@linkcode Pokemon} using the move
* @param target {@linkcode Pokemon} receiving the move * @param target {@linkcode Pokemon} receiving the move
* @param move {@linkcode Move} using the move * @param move {@linkcode Move} using the move
* @param cancelled {@linkcode Utils.BooleanHolder} to hold boolean value * @param cancelled {@linkcode Utils.BooleanHolder} to hold boolean value
* @returns string of the failed text, or null * @returns string of the custom failure text, or `null` if it uses the default text ("But it failed!")
*/ */
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null { getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
for (const attr of this.attrs) { for (const attr of this.attrs) {
@ -818,8 +818,6 @@ export default class Move implements Localizable {
applyMoveAttrs(VariablePowerAttr, source, target, this, power); applyMoveAttrs(VariablePowerAttr, source, target, this, power);
source.scene.applyModifiers(PokemonMultiHitModifier, source.isPlayer(), source, new Utils.IntegerHolder(0), power);
if (!this.hasAttr(TypelessAttr)) { if (!this.hasAttr(TypelessAttr)) {
source.scene.arena.applyTags(WeakenMoveTypeTag, simulated, this.type, power); source.scene.arena.applyTags(WeakenMoveTypeTag, simulated, this.type, power);
source.scene.applyModifiers(AttackTypeBoosterModifier, source.isPlayer(), source, this.type, power); source.scene.applyModifiers(AttackTypeBoosterModifier, source.isPlayer(), source, this.type, power);
@ -840,6 +838,45 @@ export default class Move implements Localizable {
return priority.value; return priority.value;
} }
/**
* Returns `true` if this move can be given additional strikes
* by enhancing effects.
* Currently used for {@link https://bulbapedia.bulbagarden.net/wiki/Parental_Bond_(Ability) | Parental Bond}
* and {@linkcode PokemonMultiHitModifier | Multi-Lens}.
* @param user The {@linkcode Pokemon} using the move
* @param restrictSpread `true` if the enhancing effect
* should not affect multi-target moves (default `false`)
*/
canBeMultiStrikeEnhanced(user: Pokemon, restrictSpread: boolean = false): boolean {
// Multi-strike enhancers...
// ...cannot enhance moves that hit multiple targets
const { targets, multiple } = getMoveTargets(user, this.id);
const isMultiTarget = multiple && targets.length > 1;
// ...cannot enhance multi-hit or sacrificial moves
const exceptAttrs: Constructor<MoveAttr>[] = [
MultiHitAttr,
SacrificialAttr,
SacrificialAttrOnHit
];
// ...and cannot enhance these specific moves.
const exceptMoves: Moves[] = [
Moves.FLING,
Moves.UPROAR,
Moves.ROLLOUT,
Moves.ICE_BALL,
Moves.ENDEAVOR
];
return (!restrictSpread || !isMultiTarget)
&& !this.isChargingMove()
&& !exceptAttrs.some(attr => this.hasAttr(attr))
&& !exceptMoves.some(id => this.id === id)
&& this.category !== MoveCategory.STATUS;
}
} }
export class AttackMove extends Move { export class AttackMove extends Move {
@ -860,7 +897,7 @@ export class AttackMove extends Move {
let attackScore = 0; let attackScore = 0;
const effectiveness = target.getAttackTypeEffectiveness(this.type, user); const effectiveness = target.getAttackTypeEffectiveness(this.type, user, undefined, undefined, this);
attackScore = Math.pow(effectiveness - 1, 2) * effectiveness < 1 ? -2 : 2; attackScore = Math.pow(effectiveness - 1, 2) * effectiveness < 1 ? -2 : 2;
if (attackScore) { if (attackScore) {
if (this.category === MoveCategory.PHYSICAL) { if (this.category === MoveCategory.PHYSICAL) {
@ -2417,9 +2454,8 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
const removedItem = heldItems[user.randSeedInt(heldItems.length)]; const removedItem = heldItems[user.randSeedInt(heldItems.length)];
// Decrease item amount and update icon // Decrease item amount and update icon
!--removedItem.stackCount; target.loseHeldItem(removedItem);
target.scene.updateModifiers(target.isPlayer()); target.scene.updateModifiers(target.isPlayer());
applyPostItemLostAbAttrs(PostItemLostAbAttr, target, false);
if (this.berriesOnly) { if (this.berriesOnly) {
@ -2489,18 +2525,15 @@ export class EatBerryAttr extends MoveEffectAttr {
} }
reduceBerryModifier(target: Pokemon) { reduceBerryModifier(target: Pokemon) {
if (this.chosenBerry?.stackCount === 1) { if (this.chosenBerry) {
target.scene.removeModifier(this.chosenBerry, !target.isPlayer()); target.loseHeldItem(this.chosenBerry);
} else if (this.chosenBerry !== undefined && this.chosenBerry.stackCount > 1) {
this.chosenBerry.stackCount--;
} }
target.scene.updateModifiers(target.isPlayer()); target.scene.updateModifiers(target.isPlayer());
} }
eatBerry(consumer: Pokemon) { eatBerry(consumer: Pokemon, berryOwner?: Pokemon) {
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer); // consumer eats the berry getBerryEffectFunc(this.chosenBerry!.berryType)(consumer, berryOwner); // consumer eats the berry
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new Utils.BooleanHolder(false)); applyAbAttrs(HealFromBerryUseAbAttr, consumer, new Utils.BooleanHolder(false));
applyPostItemLostAbAttrs(PostItemLostAbAttr, consumer, false);
} }
} }
@ -2540,7 +2573,7 @@ export class StealEatBerryAttr extends EatBerryAttr {
const message = i18next.t("battle:stealEatBerry", { pokemonName: user.name, targetName: target.name, berryName: this.chosenBerry.type.name }); const message = i18next.t("battle:stealEatBerry", { pokemonName: user.name, targetName: target.name, berryName: this.chosenBerry.type.name });
user.scene.queueMessage(message); user.scene.queueMessage(message);
this.reduceBerryModifier(target); this.reduceBerryModifier(target);
this.eatBerry(user); this.eatBerry(user, target);
return true; return true;
} }
} }
@ -2556,12 +2589,11 @@ export class HealStatusEffectAttr extends MoveEffectAttr {
/** /**
* @param selfTarget - Whether this move targets the user * @param selfTarget - Whether this move targets the user
* @param ...effects - List of status effects to cure * @param effects - status effect or list of status effects to cure
*/ */
constructor(selfTarget: boolean, ...effects: StatusEffect[]) { constructor(selfTarget: boolean, effects: StatusEffect | StatusEffect[]) {
super(selfTarget, { lastHitOnly: true }); super(selfTarget, { lastHitOnly: true });
this.effects = [ effects ].flat(1);
this.effects = effects;
} }
/** /**
@ -4938,22 +4970,6 @@ export class NeutralDamageAgainstFlyingTypeMultiplierAttr extends VariableMoveTy
} }
} }
export class WaterSuperEffectTypeMultiplierAttr extends VariableMoveTypeMultiplierAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const multiplier = args[0] as Utils.NumberHolder;
if (target.isOfType(Type.WATER)) {
const effectivenessAgainstWater = new Utils.NumberHolder(getTypeDamageMultiplier(move.type, Type.WATER));
applyChallenges(user.scene.gameMode, ChallengeType.TYPE_EFFECTIVENESS, effectivenessAgainstWater);
if (effectivenessAgainstWater.value !== 0) {
multiplier.value *= 2 / effectivenessAgainstWater.value;
return true;
}
}
return false;
}
}
export class IceNoEffectTypeAttr extends VariableMoveTypeMultiplierAttr { export class IceNoEffectTypeAttr extends VariableMoveTypeMultiplierAttr {
/** /**
* Checks to see if the Target is Ice-Type or not. If so, the move will have no effect. * Checks to see if the Target is Ice-Type or not. If so, the move will have no effect.
@ -4981,6 +4997,41 @@ export class FlyingTypeMultiplierAttr extends VariableMoveTypeMultiplierAttr {
} }
} }
/**
* Attribute for moves which have a custom type chart interaction.
*/
export class VariableMoveTypeChartAttr extends MoveAttr {
/**
* @param user {@linkcode Pokemon} using the move
* @param target {@linkcode Pokemon} target of the move
* @param move {@linkcode Move} with this attribute
* @param args [0] {@linkcode NumberHolder} holding the type effectiveness
* @param args [1] A single defensive type of the target
*
* @returns true if application of the attribute succeeds
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
return false;
}
}
/**
* This class forces Freeze-Dry to be super effective against Water Type.
*/
export class FreezeDryAttr extends VariableMoveTypeChartAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const multiplier = args[0] as Utils.NumberHolder;
const defType = args[1] as Type;
if (defType === Type.WATER) {
multiplier.value = 2;
return true;
} else {
return false;
}
}
}
export class OneHitKOAccuracyAttr extends VariableAccuracyAttr { export class OneHitKOAccuracyAttr extends VariableAccuracyAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const accuracy = args[0] as Utils.NumberHolder; const accuracy = args[0] as Utils.NumberHolder;
@ -6996,6 +7047,9 @@ export class SuppressAbilitiesIfActedAttr extends MoveEffectAttr {
} }
} }
/**
* Used by Transform
*/
export class TransformAttr extends MoveEffectAttr { export class TransformAttr extends MoveEffectAttr {
async apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> { async apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
if (!super.apply(user, target, move, args)) { if (!super.apply(user, target, move, args)) {
@ -7004,10 +7058,8 @@ export class TransformAttr extends MoveEffectAttr {
const promises: Promise<void>[] = []; const promises: Promise<void>[] = [];
user.summonData.speciesForm = target.getSpeciesForm(); user.summonData.speciesForm = target.getSpeciesForm();
user.summonData.fusionSpeciesForm = target.getFusionSpeciesForm();
user.summonData.ability = target.getAbility().id; user.summonData.ability = target.getAbility().id;
user.summonData.gender = target.getGender(); user.summonData.gender = target.getGender();
user.summonData.fusionGender = target.getFusionGender();
// Power Trick's effect will not preserved after using Transform // Power Trick's effect will not preserved after using Transform
user.removeTag(BattlerTagType.POWER_TRICK); user.removeTag(BattlerTagType.POWER_TRICK);
@ -8080,6 +8132,8 @@ export function initMoves() {
.attr(TransformAttr) .attr(TransformAttr)
.condition((user, target, move) => !target.getTag(BattlerTagType.SUBSTITUTE)) .condition((user, target, move) => !target.getTag(BattlerTagType.SUBSTITUTE))
.condition((user, target, move) => !target.battleData.illusion.active && !user.battleData.illusion.active) .condition((user, target, move) => !target.battleData.illusion.active && !user.battleData.illusion.active)
// transforming from or into fusion pokemon causes various problems (such as crashes)
.condition((user, target, move) => !target.getTag(BattlerTagType.SUBSTITUTE) && !user.fusionSpecies && !target.fusionSpecies)
.ignoresProtect(), .ignoresProtect(),
new AttackMove(Moves.BUBBLE, Type.WATER, MoveCategory.SPECIAL, 40, 100, 30, 10, 0, 1) new AttackMove(Moves.BUBBLE, Type.WATER, MoveCategory.SPECIAL, 40, 100, 30, 10, 0, 1)
.attr(StatStageChangeAttr, [ Stat.SPD ], -1) .attr(StatStageChangeAttr, [ Stat.SPD ], -1)
@ -8484,7 +8538,8 @@ export function initMoves() {
new StatusMove(Moves.HELPING_HAND, Type.NORMAL, -1, 20, -1, 5, 3) new StatusMove(Moves.HELPING_HAND, Type.NORMAL, -1, 20, -1, 5, 3)
.attr(AddBattlerTagAttr, BattlerTagType.HELPING_HAND) .attr(AddBattlerTagAttr, BattlerTagType.HELPING_HAND)
.ignoresSubstitute() .ignoresSubstitute()
.target(MoveTarget.NEAR_ALLY), .target(MoveTarget.NEAR_ALLY)
.condition(failIfSingleBattle),
new StatusMove(Moves.TRICK, Type.PSYCHIC, 100, 10, -1, 0, 3) new StatusMove(Moves.TRICK, Type.PSYCHIC, 100, 10, -1, 0, 3)
.unimplemented(), .unimplemented(),
new StatusMove(Moves.ROLE_PLAY, Type.PSYCHIC, -1, 10, -1, 0, 3) new StatusMove(Moves.ROLE_PLAY, Type.PSYCHIC, -1, 10, -1, 0, 3)
@ -8530,7 +8585,7 @@ export function initMoves() {
.attr(AddArenaTagAttr, ArenaTagType.IMPRISON, 1, true, false) .attr(AddArenaTagAttr, ArenaTagType.IMPRISON, 1, true, false)
.target(MoveTarget.ENEMY_SIDE), .target(MoveTarget.ENEMY_SIDE),
new SelfStatusMove(Moves.REFRESH, Type.NORMAL, -1, 20, -1, 0, 3) new SelfStatusMove(Moves.REFRESH, Type.NORMAL, -1, 20, -1, 0, 3)
.attr(HealStatusEffectAttr, true, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN) .attr(HealStatusEffectAttr, true, [ StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN ])
.condition((user, target, move) => !!user.status && (user.status.effect === StatusEffect.PARALYSIS || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.BURN)), .condition((user, target, move) => !!user.status && (user.status.effect === StatusEffect.PARALYSIS || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.BURN)),
new SelfStatusMove(Moves.GRUDGE, Type.GHOST, -1, 5, -1, 0, 3) new SelfStatusMove(Moves.GRUDGE, Type.GHOST, -1, 5, -1, 0, 3)
.attr(AddBattlerTagAttr, BattlerTagType.GRUDGE, true, undefined, 1), .attr(AddBattlerTagAttr, BattlerTagType.GRUDGE, true, undefined, 1),
@ -8837,7 +8892,7 @@ export function initMoves() {
new SelfStatusMove(Moves.AQUA_RING, Type.WATER, -1, 20, -1, 0, 4) new SelfStatusMove(Moves.AQUA_RING, Type.WATER, -1, 20, -1, 0, 4)
.attr(AddBattlerTagAttr, BattlerTagType.AQUA_RING, true, true), .attr(AddBattlerTagAttr, BattlerTagType.AQUA_RING, true, true),
new SelfStatusMove(Moves.MAGNET_RISE, Type.ELECTRIC, -1, 10, -1, 0, 4) new SelfStatusMove(Moves.MAGNET_RISE, Type.ELECTRIC, -1, 10, -1, 0, 4)
.attr(AddBattlerTagAttr, BattlerTagType.FLOATING, true, true) .attr(AddBattlerTagAttr, BattlerTagType.FLOATING, true, true, 5)
.condition((user, target, move) => !user.scene.arena.getTag(ArenaTagType.GRAVITY) && [ BattlerTagType.FLOATING, BattlerTagType.IGNORE_FLYING, BattlerTagType.INGRAIN ].every((tag) => !user.getTag(tag))), .condition((user, target, move) => !user.scene.arena.getTag(ArenaTagType.GRAVITY) && [ BattlerTagType.FLOATING, BattlerTagType.IGNORE_FLYING, BattlerTagType.INGRAIN ].every((tag) => !user.getTag(tag))),
new AttackMove(Moves.FLARE_BLITZ, Type.FIRE, MoveCategory.PHYSICAL, 120, 100, 15, 10, 0, 4) new AttackMove(Moves.FLARE_BLITZ, Type.FIRE, MoveCategory.PHYSICAL, 120, 100, 15, 10, 0, 4)
.attr(RecoilAttr, false, 0.33) .attr(RecoilAttr, false, 0.33)
@ -9176,6 +9231,7 @@ export function initMoves() {
.target(MoveTarget.ALL_NEAR_ENEMIES) .target(MoveTarget.ALL_NEAR_ENEMIES)
.attr(RemoveHeldItemAttr, true), .attr(RemoveHeldItemAttr, true),
new StatusMove(Moves.QUASH, Type.DARK, 100, 15, -1, 0, 5) new StatusMove(Moves.QUASH, Type.DARK, 100, 15, -1, 0, 5)
.condition(failIfSingleBattle)
.unimplemented(), .unimplemented(),
new AttackMove(Moves.ACROBATICS, Type.FLYING, MoveCategory.PHYSICAL, 55, 100, 15, -1, 0, 5) new AttackMove(Moves.ACROBATICS, Type.FLYING, MoveCategory.PHYSICAL, 55, 100, 15, -1, 0, 5)
.attr(MovePowerMultiplierAttr, (user, target, move) => Math.max(1, 2 - 0.2 * user.getHeldItems().filter(i => i.isTransferable).reduce((v, m) => v + m.stackCount, 0))), .attr(MovePowerMultiplierAttr, (user, target, move) => Math.max(1, 2 - 0.2 * user.getHeldItems().filter(i => i.isTransferable).reduce((v, m) => v + m.stackCount, 0))),
@ -9387,8 +9443,7 @@ export function initMoves() {
.target(MoveTarget.ALL_NEAR_OTHERS), .target(MoveTarget.ALL_NEAR_OTHERS),
new AttackMove(Moves.FREEZE_DRY, Type.ICE, MoveCategory.SPECIAL, 70, 100, 20, 10, 0, 6) new AttackMove(Moves.FREEZE_DRY, Type.ICE, MoveCategory.SPECIAL, 70, 100, 20, 10, 0, 6)
.attr(StatusEffectAttr, StatusEffect.FREEZE) .attr(StatusEffectAttr, StatusEffect.FREEZE)
.attr(WaterSuperEffectTypeMultiplierAttr) .attr(FreezeDryAttr),
.edgeCase(), // This currently just multiplies the move's power instead of changing its effectiveness. It also doesn't account for abilities that modify type effectiveness such as tera shell.
new AttackMove(Moves.DISARMING_VOICE, Type.FAIRY, MoveCategory.SPECIAL, 40, -1, 15, -1, 0, 6) new AttackMove(Moves.DISARMING_VOICE, Type.FAIRY, MoveCategory.SPECIAL, 40, -1, 15, -1, 0, 6)
.soundBased() .soundBased()
.target(MoveTarget.ALL_NEAR_ENEMIES), .target(MoveTarget.ALL_NEAR_ENEMIES),
@ -9463,6 +9518,7 @@ export function initMoves() {
new StatusMove(Moves.AROMATIC_MIST, Type.FAIRY, -1, 20, -1, 0, 6) new StatusMove(Moves.AROMATIC_MIST, Type.FAIRY, -1, 20, -1, 0, 6)
.attr(StatStageChangeAttr, [ Stat.SPDEF ], 1) .attr(StatStageChangeAttr, [ Stat.SPDEF ], 1)
.ignoresSubstitute() .ignoresSubstitute()
.condition(failIfSingleBattle)
.target(MoveTarget.NEAR_ALLY), .target(MoveTarget.NEAR_ALLY),
new StatusMove(Moves.EERIE_IMPULSE, Type.ELECTRIC, 100, 15, -1, 0, 6) new StatusMove(Moves.EERIE_IMPULSE, Type.ELECTRIC, 100, 15, -1, 0, 6)
.attr(StatStageChangeAttr, [ Stat.SPATK ], -2), .attr(StatStageChangeAttr, [ Stat.SPATK ], -2),
@ -9691,7 +9747,8 @@ export function initMoves() {
new AttackMove(Moves.LEAFAGE, Type.GRASS, MoveCategory.PHYSICAL, 40, 100, 40, -1, 0, 7) new AttackMove(Moves.LEAFAGE, Type.GRASS, MoveCategory.PHYSICAL, 40, 100, 40, -1, 0, 7)
.makesContact(false), .makesContact(false),
new StatusMove(Moves.SPOTLIGHT, Type.NORMAL, -1, 15, -1, 3, 7) new StatusMove(Moves.SPOTLIGHT, Type.NORMAL, -1, 15, -1, 3, 7)
.attr(AddBattlerTagAttr, BattlerTagType.CENTER_OF_ATTENTION, false), .attr(AddBattlerTagAttr, BattlerTagType.CENTER_OF_ATTENTION, false)
.condition(failIfSingleBattle),
new StatusMove(Moves.TOXIC_THREAD, Type.POISON, 100, 20, -1, 0, 7) new StatusMove(Moves.TOXIC_THREAD, Type.POISON, 100, 20, -1, 0, 7)
.attr(StatusEffectAttr, StatusEffect.POISON) .attr(StatusEffectAttr, StatusEffect.POISON)
.attr(StatStageChangeAttr, [ Stat.SPD ], -1), .attr(StatStageChangeAttr, [ Stat.SPD ], -1),
@ -9737,7 +9794,7 @@ export function initMoves() {
.condition( .condition(
(user: Pokemon, target: Pokemon, move: Move) => isNonVolatileStatusEffect(target.status?.effect!)) // TODO: is this bang correct? (user: Pokemon, target: Pokemon, move: Move) => isNonVolatileStatusEffect(target.status?.effect!)) // TODO: is this bang correct?
.attr(HealAttr, 0.5) .attr(HealAttr, 0.5)
.attr(HealStatusEffectAttr, false, ...getNonVolatileStatusEffects()) .attr(HealStatusEffectAttr, false, getNonVolatileStatusEffects())
.triageMove(), .triageMove(),
new AttackMove(Moves.REVELATION_DANCE, Type.NORMAL, MoveCategory.SPECIAL, 90, 100, 15, -1, 0, 7) new AttackMove(Moves.REVELATION_DANCE, Type.NORMAL, MoveCategory.SPECIAL, 90, 100, 15, -1, 0, 7)
.danceMove() .danceMove()
@ -9821,11 +9878,9 @@ export function initMoves() {
.ignoresSubstitute() .ignoresSubstitute()
.partial(), // Does not steal stats .partial(), // Does not steal stats
new AttackMove(Moves.SUNSTEEL_STRIKE, Type.STEEL, MoveCategory.PHYSICAL, 100, 100, 5, -1, 0, 7) new AttackMove(Moves.SUNSTEEL_STRIKE, Type.STEEL, MoveCategory.PHYSICAL, 100, 100, 5, -1, 0, 7)
.ignoresAbilities() .ignoresAbilities(),
.edgeCase(), // Should not ignore abilities when called virtually (metronome)
new AttackMove(Moves.MOONGEIST_BEAM, Type.GHOST, MoveCategory.SPECIAL, 100, 100, 5, -1, 0, 7) new AttackMove(Moves.MOONGEIST_BEAM, Type.GHOST, MoveCategory.SPECIAL, 100, 100, 5, -1, 0, 7)
.ignoresAbilities() .ignoresAbilities(),
.edgeCase(), // Should not ignore abilities when called virtually (metronome)
new StatusMove(Moves.TEARFUL_LOOK, Type.NORMAL, -1, 20, -1, 0, 7) new StatusMove(Moves.TEARFUL_LOOK, Type.NORMAL, -1, 20, -1, 0, 7)
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], -1), .attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], -1),
new AttackMove(Moves.ZING_ZAP, Type.ELECTRIC, MoveCategory.PHYSICAL, 80, 100, 10, 30, 0, 7) new AttackMove(Moves.ZING_ZAP, Type.ELECTRIC, MoveCategory.PHYSICAL, 80, 100, 10, 30, 0, 7)
@ -9848,8 +9903,7 @@ export function initMoves() {
.punchingMove(), .punchingMove(),
new AttackMove(Moves.PHOTON_GEYSER, Type.PSYCHIC, MoveCategory.SPECIAL, 100, 100, 5, -1, 0, 7) new AttackMove(Moves.PHOTON_GEYSER, Type.PSYCHIC, MoveCategory.SPECIAL, 100, 100, 5, -1, 0, 7)
.attr(PhotonGeyserCategoryAttr) .attr(PhotonGeyserCategoryAttr)
.ignoresAbilities() .ignoresAbilities(),
.edgeCase(), // Should not ignore abilities when called virtually (metronome)
/* Unused */ /* Unused */
new AttackMove(Moves.LIGHT_THAT_BURNS_THE_SKY, Type.PSYCHIC, MoveCategory.SPECIAL, 200, -1, 1, -1, 0, 7) new AttackMove(Moves.LIGHT_THAT_BURNS_THE_SKY, Type.PSYCHIC, MoveCategory.SPECIAL, 200, -1, 1, -1, 0, 7)
.attr(PhotonGeyserCategoryAttr) .attr(PhotonGeyserCategoryAttr)
@ -10148,7 +10202,8 @@ export function initMoves() {
.unimplemented(), .unimplemented(),
new StatusMove(Moves.COACHING, Type.FIGHTING, -1, 10, -1, 0, 8) new StatusMove(Moves.COACHING, Type.FIGHTING, -1, 10, -1, 0, 8)
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.DEF ], 1) .attr(StatStageChangeAttr, [ Stat.ATK, Stat.DEF ], 1)
.target(MoveTarget.NEAR_ALLY), .target(MoveTarget.NEAR_ALLY)
.condition(failIfSingleBattle),
new AttackMove(Moves.FLIP_TURN, Type.WATER, MoveCategory.PHYSICAL, 60, 100, 20, -1, 0, 8) new AttackMove(Moves.FLIP_TURN, Type.WATER, MoveCategory.PHYSICAL, 60, 100, 20, -1, 0, 8)
.attr(ForceSwitchOutAttr, true), .attr(ForceSwitchOutAttr, true),
new AttackMove(Moves.TRIPLE_AXEL, Type.ICE, MoveCategory.PHYSICAL, 20, 90, 10, -1, 0, 8) new AttackMove(Moves.TRIPLE_AXEL, Type.ICE, MoveCategory.PHYSICAL, 20, 90, 10, -1, 0, 8)
@ -10163,7 +10218,7 @@ export function initMoves() {
.attr(StatusEffectAttr, StatusEffect.BURN), .attr(StatusEffectAttr, StatusEffect.BURN),
new StatusMove(Moves.JUNGLE_HEALING, Type.GRASS, -1, 10, -1, 0, 8) new StatusMove(Moves.JUNGLE_HEALING, Type.GRASS, -1, 10, -1, 0, 8)
.attr(HealAttr, 0.25, true, false) .attr(HealAttr, 0.25, true, false)
.attr(HealStatusEffectAttr, false, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN, StatusEffect.SLEEP) .attr(HealStatusEffectAttr, false, getNonVolatileStatusEffects())
.target(MoveTarget.USER_AND_ALLIES), .target(MoveTarget.USER_AND_ALLIES),
new AttackMove(Moves.WICKED_BLOW, Type.DARK, MoveCategory.PHYSICAL, 75, 100, 5, -1, 0, 8) new AttackMove(Moves.WICKED_BLOW, Type.DARK, MoveCategory.PHYSICAL, 75, 100, 5, -1, 0, 8)
.attr(CritOnlyAttr) .attr(CritOnlyAttr)
@ -10267,12 +10322,12 @@ export function initMoves() {
.target(MoveTarget.ALL_NEAR_ENEMIES), .target(MoveTarget.ALL_NEAR_ENEMIES),
new StatusMove(Moves.LUNAR_BLESSING, Type.PSYCHIC, -1, 5, -1, 0, 8) new StatusMove(Moves.LUNAR_BLESSING, Type.PSYCHIC, -1, 5, -1, 0, 8)
.attr(HealAttr, 0.25, true, false) .attr(HealAttr, 0.25, true, false)
.attr(HealStatusEffectAttr, false, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN, StatusEffect.SLEEP) .attr(HealStatusEffectAttr, false, getNonVolatileStatusEffects())
.target(MoveTarget.USER_AND_ALLIES) .target(MoveTarget.USER_AND_ALLIES)
.triageMove(), .triageMove(),
new SelfStatusMove(Moves.TAKE_HEART, Type.PSYCHIC, -1, 10, -1, 0, 8) new SelfStatusMove(Moves.TAKE_HEART, Type.PSYCHIC, -1, 10, -1, 0, 8)
.attr(StatStageChangeAttr, [ Stat.SPATK, Stat.SPDEF ], 1, true) .attr(StatStageChangeAttr, [ Stat.SPATK, Stat.SPDEF ], 1, true)
.attr(HealStatusEffectAttr, true, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN, StatusEffect.SLEEP), .attr(HealStatusEffectAttr, true, [ StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN, StatusEffect.SLEEP ]),
/* Unused /* Unused
new AttackMove(Moves.G_MAX_WILDFIRE, Type.FIRE, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) new AttackMove(Moves.G_MAX_WILDFIRE, Type.FIRE, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8)
.target(MoveTarget.ALL_NEAR_ENEMIES) .target(MoveTarget.ALL_NEAR_ENEMIES)

View File

@ -477,12 +477,9 @@ export const BugTypeSuperfanEncounter: MysteryEncounter =
.withOptionPhase(async (scene: BattleScene) => { .withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
const modifier = encounter.misc.chosenModifier; const modifier = encounter.misc.chosenModifier;
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
// Remove the modifier if its stacks go to 0 chosenPokemon.loseHeldItem(modifier, false);
modifier.stackCount -= 1;
if (modifier.stackCount === 0) {
scene.removeModifier(modifier);
}
scene.updateModifiers(true, true); scene.updateModifiers(true, true);
const bugNet = generateModifierTypeOption(scene, modifierTypes.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET)!; const bugNet = generateModifierTypeOption(scene, modifierTypes.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET)!;

View File

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

View File

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

View File

@ -345,6 +345,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
// Pokemon and item selected // Pokemon and item selected
encounter.setDialogueToken("chosenItem", modifier.type.name); encounter.setDialogueToken("chosenItem", modifier.type.name);
encounter.misc.chosenModifier = modifier; encounter.misc.chosenModifier = modifier;
encounter.misc.chosenPokemon = pokemon;
return true; return true;
}, },
}; };
@ -370,6 +371,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
const encounter = scene.currentBattle.mysteryEncounter!; const encounter = scene.currentBattle.mysteryEncounter!;
const modifier = encounter.misc.chosenModifier as PokemonHeldItemModifier; const modifier = encounter.misc.chosenModifier as PokemonHeldItemModifier;
const party = scene.getPlayerParty(); const party = scene.getPlayerParty();
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
// Check tier of the traded item, the received item will be one tier up // Check tier of the traded item, the received item will be one tier up
const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party); const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party);
@ -397,11 +399,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
encounter.setDialogueToken("itemName", item.type.name); encounter.setDialogueToken("itemName", item.type.name);
setEncounterRewards(scene, { guaranteedModifierTypeOptions: [ item ], fillRemaining: false }); setEncounterRewards(scene, { guaranteedModifierTypeOptions: [ item ], fillRemaining: false });
// Remove the chosen modifier if its stacks go to 0 chosenPokemon.loseHeldItem(modifier, false);
modifier.stackCount -= 1;
if (modifier.stackCount === 0) {
scene.removeModifier(modifier);
}
await scene.updateModifiers(true, true); await scene.updateModifiers(true, true);
// Generate a trainer name // Generate a trainer name

View File

@ -312,6 +312,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
pokemon.levelExp = 0; pokemon.levelExp = 0;
pokemon.calculateStats(); pokemon.calculateStats();
pokemon.getBattleInfo().setLevel(pokemon.level);
await pokemon.updateInfo(); await pokemon.updateInfo();
} }

View File

@ -363,6 +363,12 @@ export abstract class PokemonSpeciesForm {
} }
switch (this.speciesId) { switch (this.speciesId) {
case Species.DODUO:
case Species.DODRIO:
case Species.MEGANIUM:
case Species.TORCHIC:
case Species.COMBUSKEN:
case Species.BLAZIKEN:
case Species.HIPPOPOTAS: case Species.HIPPOPOTAS:
case Species.HIPPOWDON: case Species.HIPPOWDON:
case Species.UNFEZANT: case Species.UNFEZANT:
@ -499,11 +505,11 @@ export abstract class PokemonSpeciesForm {
scene.anims.create({ scene.anims.create({
key: this.getSpriteKey(female, formIndex, shiny, variant), key: this.getSpriteKey(female, formIndex, shiny, variant),
frames: frameNames, frames: frameNames,
frameRate: 12, frameRate: 10,
repeat: -1 repeat: -1
}); });
} else { } else {
scene.anims.get(spriteKey).frameRate = 12; scene.anims.get(spriteKey).frameRate = 10;
} }
let spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant).replace("variant/", "").replace(/_[1-3]$/, ""); let spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant).replace("variant/", "").replace(/_[1-3]$/, "");
const useExpSprite = scene.experimentalSprites && scene.hasExpSprite(spriteKey); const useExpSprite = scene.experimentalSprites && scene.hasExpSprite(spriteKey);
@ -888,17 +894,24 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
getCompatibleFusionSpeciesFilter(): PokemonSpeciesFilter { getCompatibleFusionSpeciesFilter(): PokemonSpeciesFilter {
const hasEvolution = pokemonEvolutions.hasOwnProperty(this.speciesId); const hasEvolution = pokemonEvolutions.hasOwnProperty(this.speciesId);
const hasPrevolution = pokemonPrevolutions.hasOwnProperty(this.speciesId); const hasPrevolution = pokemonPrevolutions.hasOwnProperty(this.speciesId);
const pseudoLegendary = this.subLegendary; const subLegendary = this.subLegendary;
const legendary = this.legendary; const legendary = this.legendary;
const mythical = this.mythical; const mythical = this.mythical;
return species => { return species => {
return (pseudoLegendary || legendary || mythical || return (
(pokemonEvolutions.hasOwnProperty(species.speciesId) === hasEvolution subLegendary
&& pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution)) || legendary
&& species.subLegendary === pseudoLegendary || mythical
|| (
pokemonEvolutions.hasOwnProperty(species.speciesId) === hasEvolution
&& pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution
)
)
&& species.subLegendary === subLegendary
&& species.legendary === legendary && species.legendary === legendary
&& species.mythical === mythical && species.mythical === mythical
&& (this.isTrainerForbidden() || !species.isTrainerForbidden()); && (this.isTrainerForbidden() || !species.isTrainerForbidden())
&& species.speciesId !== Species.DITTO;
}; };
} }

View File

@ -1841,21 +1841,25 @@ export const trainerConfigs: TrainerConfigs = {
[TrainerType.RIVAL]: new TrainerConfig((t = TrainerType.RIVAL)).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL) [TrainerType.RIVAL]: new TrainerConfig((t = TrainerType.RIVAL)).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL)
.setModifierRewardFuncs(() => modifierTypes.SUPER_EXP_CHARM, () => modifierTypes.EXP_SHARE) .setModifierRewardFuncs(() => modifierTypes.SUPER_EXP_CHARM, () => modifierTypes.EXP_SHARE)
.setEventModifierRewardFuncs(() => modifierTypes.SHINY_CHARM, () => modifierTypes.ABILITY_CHARM) .setEventModifierRewardFuncs(() => modifierTypes.SHINY_CHARM, () => modifierTypes.ABILITY_CHARM)
.setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.CHIKORITA, Species.CYNDAQUIL, Species.TOTODILE, Species.TREECKO, Species.TORCHIC, Species.MUDKIP, Species.TURTWIG, Species.CHIMCHAR, Species.PIPLUP, Species.SNIVY, Species.TEPIG, Species.OSHAWOTT, Species.CHESPIN, Species.FENNEKIN, Species.FROAKIE, Species.ROWLET, Species.LITTEN, Species.POPPLIO, Species.GROOKEY, Species.SCORBUNNY, Species.SOBBLE, Species.SPRIGATITO, Species.FUECOCO, Species.QUAXLY ], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.CHIKORITA, Species.CYNDAQUIL, Species.TOTODILE, Species.TREECKO, Species.TORCHIC, Species.MUDKIP, Species.TURTWIG, Species.CHIMCHAR, Species.PIPLUP, Species.SNIVY, Species.TEPIG, Species.OSHAWOTT, Species.CHESPIN, Species.FENNEKIN, Species.FROAKIE, Species.ROWLET, Species.LITTEN, Species.POPPLIO, Species.GROOKEY, Species.SCORBUNNY, Species.SOBBLE, Species.SPRIGATITO, Species.FUECOCO, Species.QUAXLY ], TrainerSlot.TRAINER, true,
(p => p.abilityIndex = 0)))
.setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEY, Species.HOOTHOOT, Species.TAILLOW, Species.STARLY, Species.PIDOVE, Species.FLETCHLING, Species.PIKIPEK, Species.ROOKIDEE, Species.WATTREL ], TrainerSlot.TRAINER, true)), .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEY, Species.HOOTHOOT, Species.TAILLOW, Species.STARLY, Species.PIDOVE, Species.FLETCHLING, Species.PIKIPEK, Species.ROOKIDEE, Species.WATTREL ], TrainerSlot.TRAINER, true)),
[TrainerType.RIVAL_2]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setMoneyMultiplier(1.25).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL_2) [TrainerType.RIVAL_2]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setMoneyMultiplier(1.25).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL_2)
.setModifierRewardFuncs(() => modifierTypes.EXP_SHARE) .setModifierRewardFuncs(() => modifierTypes.EXP_SHARE)
.setEventModifierRewardFuncs(() => modifierTypes.SHINY_CHARM) .setEventModifierRewardFuncs(() => modifierTypes.SHINY_CHARM)
.setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.IVYSAUR, Species.CHARMELEON, Species.WARTORTLE, Species.BAYLEEF, Species.QUILAVA, Species.CROCONAW, Species.GROVYLE, Species.COMBUSKEN, Species.MARSHTOMP, Species.GROTLE, Species.MONFERNO, Species.PRINPLUP, Species.SERVINE, Species.PIGNITE, Species.DEWOTT, Species.QUILLADIN, Species.BRAIXEN, Species.FROGADIER, Species.DARTRIX, Species.TORRACAT, Species.BRIONNE, Species.THWACKEY, Species.RABOOT, Species.DRIZZILE, Species.FLORAGATO, Species.CROCALOR, Species.QUAXWELL ], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.IVYSAUR, Species.CHARMELEON, Species.WARTORTLE, Species.BAYLEEF, Species.QUILAVA, Species.CROCONAW, Species.GROVYLE, Species.COMBUSKEN, Species.MARSHTOMP, Species.GROTLE, Species.MONFERNO, Species.PRINPLUP, Species.SERVINE, Species.PIGNITE, Species.DEWOTT, Species.QUILLADIN, Species.BRAIXEN, Species.FROGADIER, Species.DARTRIX, Species.TORRACAT, Species.BRIONNE, Species.THWACKEY, Species.RABOOT, Species.DRIZZILE, Species.FLORAGATO, Species.CROCALOR, Species.QUAXWELL ], TrainerSlot.TRAINER, true,
(p => p.abilityIndex = 0)))
.setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOTTO, Species.HOOTHOOT, Species.TAILLOW, Species.STARAVIA, Species.TRANQUILL, Species.FLETCHINDER, Species.TRUMBEAK, Species.CORVISQUIRE, Species.WATTREL ], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOTTO, Species.HOOTHOOT, Species.TAILLOW, Species.STARAVIA, Species.TRANQUILL, Species.FLETCHINDER, Species.TRUMBEAK, Species.CORVISQUIRE, Species.WATTREL ], TrainerSlot.TRAINER, true))
.setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)), .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)),
[TrainerType.RIVAL_3]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setMoneyMultiplier(1.5).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL_3) [TrainerType.RIVAL_3]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setMoneyMultiplier(1.5).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL_3)
.setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true,
(p => p.abilityIndex = 0)))
.setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true))
.setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450))
.setSpeciesFilter(species => species.baseTotal >= 540), .setSpeciesFilter(species => species.baseTotal >= 540),
[TrainerType.RIVAL_4]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setBoss().setStaticParty().setMoneyMultiplier(1.75).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival_2").setMixedBattleBgm("battle_rival_2").setPartyTemplates(trainerPartyTemplates.RIVAL_4) [TrainerType.RIVAL_4]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setBoss().setStaticParty().setMoneyMultiplier(1.75).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival_2").setMixedBattleBgm("battle_rival_2").setPartyTemplates(trainerPartyTemplates.RIVAL_4)
.setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true,
(p => p.abilityIndex = 0)))
.setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true))
.setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450))
.setSpeciesFilter(species => species.baseTotal >= 540) .setSpeciesFilter(species => species.baseTotal >= 540)
@ -1865,7 +1869,10 @@ export const trainerConfigs: TrainerConfigs = {
}), }),
[TrainerType.RIVAL_5]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setBoss().setStaticParty().setMoneyMultiplier(2.25).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival_3").setMixedBattleBgm("battle_rival_3").setPartyTemplates(trainerPartyTemplates.RIVAL_5) [TrainerType.RIVAL_5]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setBoss().setStaticParty().setMoneyMultiplier(2.25).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival_3").setMixedBattleBgm("battle_rival_3").setPartyTemplates(trainerPartyTemplates.RIVAL_5)
.setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true, .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true,
p => p.setBoss(true, 2))) p => {
p.setBoss(true, 2);
p.abilityIndex = 0;
}))
.setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true))
.setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450))
.setSpeciesFilter(species => species.baseTotal >= 540) .setSpeciesFilter(species => species.baseTotal >= 540)
@ -1883,6 +1890,7 @@ export const trainerConfigs: TrainerConfigs = {
.setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true, .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true,
p => { p => {
p.setBoss(true, 3); p.setBoss(true, 3);
p.abilityIndex = 0;
p.generateAndPopulateMoveset(); p.generateAndPopulateMoveset();
})) }))
.setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true, .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true,

View File

@ -92,4 +92,5 @@ export enum BattlerTagType {
COMMANDED = "COMMANDED", COMMANDED = "COMMANDED",
GRUDGE = "GRUDGE", GRUDGE = "GRUDGE",
PSYCHO_SHIFT = "PSYCHO_SHIFT", PSYCHO_SHIFT = "PSYCHO_SHIFT",
ENDURE_TOKEN = "ENDURE_TOKEN",
} }

View File

@ -212,7 +212,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con
this.scene.anims.create({ this.scene.anims.create({
key: config.spriteKey, key: config.spriteKey,
frames: frameNames, frames: frameNames,
frameRate: 12, frameRate: 10,
repeat: -1 repeat: -1
}); });
} }

View File

@ -3,7 +3,7 @@ import BattleScene, { AnySound } from "#app/battle-scene";
import { Variant, VariantSet, variantColorCache } from "#app/data/variant"; import { Variant, VariantSet, variantColorCache } from "#app/data/variant";
import { variantData } from "#app/data/variant"; import { variantData } from "#app/data/variant";
import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from "#app/ui/battle-info"; import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from "#app/ui/battle-info";
import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, VariableMoveTypeAttr, VariableDefAttr, AttackMove, ModifiedDamageAttr, VariableMoveTypeMultiplierAttr, IgnoreOpponentStatStagesAttr, SacrificialAttr, VariableMoveCategoryAttr, CounterDamageAttr, StatStageChangeAttr, RechargeAttr, IgnoreWeatherTypeDebuffAttr, BypassBurnDamageReductionAttr, SacrificialAttrOnHit, OneHitKOAccuracyAttr, RespectAttackTypeImmunityAttr, MoveTarget, CombinedPledgeStabBoostAttr } from "#app/data/move"; import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, VariableMoveTypeAttr, VariableDefAttr, AttackMove, ModifiedDamageAttr, VariableMoveTypeMultiplierAttr, IgnoreOpponentStatStagesAttr, SacrificialAttr, VariableMoveCategoryAttr, CounterDamageAttr, StatStageChangeAttr, RechargeAttr, IgnoreWeatherTypeDebuffAttr, BypassBurnDamageReductionAttr, SacrificialAttrOnHit, OneHitKOAccuracyAttr, RespectAttackTypeImmunityAttr, MoveTarget, CombinedPledgeStabBoostAttr, VariableMoveTypeChartAttr } from "#app/data/move";
import { default as PokemonSpecies, PokemonSpeciesForm, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; import { default as PokemonSpecies, PokemonSpeciesForm, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
import { CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER, getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters"; import { CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER, getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
import { starterPassiveAbilities } from "#app/data/balance/passives"; import { starterPassiveAbilities } from "#app/data/balance/passives";
@ -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 } from "#app/data/ability"; import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr, CommanderAbAttr, applyPostItemLostAbAttrs, PostItemLostAbAttr } from "#app/data/ability";
import PokemonData from "#app/system/pokemon-data"; import 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";
@ -530,7 +530,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.anims.create({ this.scene.anims.create({
key: this.getBattleSpriteKey(), key: this.getBattleSpriteKey(),
frames: battleFrameNames, frames: battleFrameNames,
frameRate: 12, frameRate: 10,
repeat: -1 repeat: -1
}); });
} }
@ -545,7 +545,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}; };
if (this.shiny) { if (this.shiny) {
const populateVariantColors = (isBackSprite: boolean = false): Promise<void> => { const populateVariantColors = (isBackSprite: boolean = false): Promise<void> => {
return new Promise(resolve => { return new Promise(async resolve => {
const battleSpritePath = this.getBattleSpriteAtlasPath(isBackSprite, ignoreOverride).replace("variant/", "").replace(/_[1-3]$/, ""); const battleSpritePath = this.getBattleSpriteAtlasPath(isBackSprite, ignoreOverride).replace("variant/", "").replace(/_[1-3]$/, "");
let config = variantData; let config = variantData;
const useExpSprite = this.scene.experimentalSprites && this.scene.hasExpSprite(this.getBattleSpriteKey(isBackSprite, ignoreOverride)); const useExpSprite = this.scene.experimentalSprites && this.scene.hasExpSprite(this.getBattleSpriteKey(isBackSprite, ignoreOverride));
@ -554,7 +554,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (variantSet && variantSet[this.variant] === 1) { if (variantSet && variantSet[this.variant] === 1) {
const cacheKey = this.getBattleSpriteKey(isBackSprite); const cacheKey = this.getBattleSpriteKey(isBackSprite);
if (!variantColorCache.hasOwnProperty(cacheKey)) { if (!variantColorCache.hasOwnProperty(cacheKey)) {
this.populateVariantColorCache(cacheKey, useExpSprite, battleSpritePath); await this.populateVariantColorCache(cacheKey, useExpSprite, battleSpritePath);
} }
} }
resolve(); resolve();
@ -586,10 +586,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param battleSpritePath the filename of the sprite * @param battleSpritePath the filename of the sprite
* @param optionalParams any additional params to log * @param optionalParams any additional params to log
*/ */
fallbackVariantColor(cacheKey: string, attemptedSpritePath: string, useExpSprite: boolean, battleSpritePath: string, ...optionalParams: any[]) { async fallbackVariantColor(cacheKey: string, attemptedSpritePath: string, useExpSprite: boolean, battleSpritePath: string, ...optionalParams: any[]) {
console.warn(`Could not load ${attemptedSpritePath}!`, ...optionalParams); console.warn(`Could not load ${attemptedSpritePath}!`, ...optionalParams);
if (useExpSprite) { if (useExpSprite) {
this.populateVariantColorCache(cacheKey, false, battleSpritePath); await this.populateVariantColorCache(cacheKey, false, battleSpritePath);
} }
} }
@ -600,18 +600,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param useExpSprite should the experimental sprite be used * @param useExpSprite should the experimental sprite be used
* @param battleSpritePath the filename of the sprite * @param battleSpritePath the filename of the sprite
*/ */
populateVariantColorCache(cacheKey: string, useExpSprite: boolean, battleSpritePath: string) { async populateVariantColorCache(cacheKey: string, useExpSprite: boolean, battleSpritePath: string) {
const spritePath = `./images/pokemon/variant/${useExpSprite ? "exp/" : ""}${battleSpritePath}.json`; const spritePath = `./images/pokemon/variant/${useExpSprite ? "exp/" : ""}${battleSpritePath}.json`;
this.scene.cachedFetch(spritePath).then(res => { return this.scene.cachedFetch(spritePath).then(res => {
// Prevent the JSON from processing if it failed to load // Prevent the JSON from processing if it failed to load
if (!res.ok) { if (!res.ok) {
return this.fallbackVariantColor(cacheKey, res.url, useExpSprite, battleSpritePath, res.status, res.statusText); return this.fallbackVariantColor(cacheKey, res.url, useExpSprite, battleSpritePath, res.status, res.statusText);
} }
return res.json(); return res.json();
}).catch(error => { }).catch(error => {
this.fallbackVariantColor(cacheKey, spritePath, useExpSprite, battleSpritePath, error); return this.fallbackVariantColor(cacheKey, spritePath, useExpSprite, battleSpritePath, error);
}).then(c => { }).then(c => {
variantColorCache[cacheKey] = c; if (!isNullOrUndefined(c)) {
variantColorCache[cacheKey] = c;
}
}); });
} }
@ -1117,7 +1119,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (this.status && this.status.effect === StatusEffect.PARALYSIS) { if (this.status && this.status.effect === StatusEffect.PARALYSIS) {
ret >>= 1; ret >>= 1;
} }
if (this.getTag(BattlerTagType.UNBURDEN) && !this.scene.getField(true).some(pokemon => pokemon !== this && pokemon.hasAbilityWithAttr(SuppressFieldAbilitiesAbAttr))) { if (this.getTag(BattlerTagType.UNBURDEN) && this.hasAbility(Abilities.UNBURDEN)) {
ret *= 2; ret *= 2;
} }
break; break;
@ -1806,7 +1808,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const moveType = source.getMoveType(move); const moveType = source.getMoveType(move);
const typeMultiplier = new Utils.NumberHolder((move.category !== MoveCategory.STATUS || move.hasAttr(RespectAttackTypeImmunityAttr)) const typeMultiplier = new Utils.NumberHolder((move.category !== MoveCategory.STATUS || move.hasAttr(RespectAttackTypeImmunityAttr))
? this.getAttackTypeEffectiveness(moveType, source, false, simulated, useIllusion) ? this.getAttackTypeEffectiveness(moveType, source, false, simulated, move, useIllusion)
: 1); : 1);
applyMoveAttrs(VariableMoveTypeMultiplierAttr, source, this, move, typeMultiplier); applyMoveAttrs(VariableMoveTypeMultiplierAttr, source, this, move, typeMultiplier);
@ -1858,10 +1860,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param source {@linkcode Pokemon} the Pokemon using the move * @param source {@linkcode Pokemon} the Pokemon using the move
* @param ignoreStrongWinds whether or not this ignores strong winds (anticipation, forewarn, stealth rocks) * @param ignoreStrongWinds whether or not this ignores strong winds (anticipation, forewarn, stealth rocks)
* @param simulated tag to only apply the strong winds effect message when the move is used * @param simulated tag to only apply the strong winds effect message when the move is used
* @param move (optional) the move whose type effectiveness is to be checked. Used for applying {@linkcode VariableMoveTypeChartAttr}
* @param {boolean} useIllusion - Whether we want the attack type effectiveness on the illusion or not * @param {boolean} useIllusion - Whether we want the attack type effectiveness on the illusion or not
* @returns a multiplier for the type effectiveness * @returns a multiplier for the type effectiveness
*/ */
getAttackTypeEffectiveness(moveType: Type, source?: Pokemon, ignoreStrongWinds: boolean = false, simulated: boolean = true, useIllusion: boolean = false): TypeDamageMultiplier { getAttackTypeEffectiveness(moveType: Type, source?: Pokemon, ignoreStrongWinds: boolean = false, simulated: boolean = true, move?: Move, useIllusion: boolean = false): TypeDamageMultiplier {
if (moveType === Type.STELLAR) { if (moveType === Type.STELLAR) {
return this.isTerastallized() ? 2 : 1; return this.isTerastallized() ? 2 : 1;
} }
@ -1880,6 +1883,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
let multiplier = types.map(defType => { let multiplier = types.map(defType => {
const multiplier = new Utils.NumberHolder(getTypeDamageMultiplier(moveType, defType)); const multiplier = new Utils.NumberHolder(getTypeDamageMultiplier(moveType, defType));
applyChallenges(this.scene.gameMode, ChallengeType.TYPE_EFFECTIVENESS, multiplier); applyChallenges(this.scene.gameMode, ChallengeType.TYPE_EFFECTIVENESS, multiplier);
if (move) {
applyMoveAttrs(VariableMoveTypeChartAttr, null, this, move, multiplier, defType);
}
if (source) { if (source) {
const ignoreImmunity = new Utils.BooleanHolder(false); const ignoreImmunity = new Utils.BooleanHolder(false);
if (source.isActive(true) && source.hasAbilityWithAttr(IgnoreTypeImmunityAbAttr)) { if (source.isActive(true) && source.hasAbilityWithAttr(IgnoreTypeImmunityAbAttr)) {
@ -1929,7 +1935,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* Based on how effective this Pokemon's types are offensively against the opponent's types. * Based on how effective this Pokemon's types are offensively against the opponent's types.
* This score is increased by 25 percent if this Pokemon is faster than the opponent. * This score is increased by 25 percent if this Pokemon is faster than the opponent.
*/ */
let atkScore = opponent.getAttackTypeEffectiveness(types[0], this, false, false, true) * (outspeed ? 1.25 : 1); let atkScore = opponent.getAttackTypeEffectiveness(types[0], this, false, false, undefined, true) * (outspeed ? 1.25 : 1);
/** /**
* Based on how effectively this Pokemon defends against the opponent's types. * Based on how effectively this Pokemon defends against the opponent's types.
* This score cannot be higher than 4. * This score cannot be higher than 4.
@ -1939,7 +1945,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
atkScore *= opponent.getAttackTypeEffectiveness(types[1], this); atkScore *= opponent.getAttackTypeEffectiveness(types[1], this);
} }
if (enemyTypes.length > 1) { if (enemyTypes.length > 1) {
defScore *= (1 / Math.max(this.getAttackTypeEffectiveness(enemyTypes[1], opponent, false, false, true), 0.25)); defScore *= (1 / Math.max(this.getAttackTypeEffectiveness(enemyTypes[1], opponent, false, false, undefined, true), 0.25));
} }
/** /**
* Based on this Pokemon's HP ratio compared to that of the opponent. * Based on this Pokemon's HP ratio compared to that of the opponent.
@ -2208,15 +2214,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value); const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value);
const randAbilityIndex = Utils.randSeedInt(2); const randAbilityIndex = Utils.randSeedInt(2);
const filter = !forStarter ? this.species.getCompatibleFusionSpeciesFilter() const filter = !forStarter ?
: species => { this.species.getCompatibleFusionSpeciesFilter()
: (species: PokemonSpecies) => {
return pokemonEvolutions.hasOwnProperty(species.speciesId) return pokemonEvolutions.hasOwnProperty(species.speciesId)
&& !pokemonPrevolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId)
&& !species.pseudoLegendary && !species.subLegendary
&& !species.legendary && !species.legendary
&& !species.mythical && !species.mythical
&& !species.isTrainerForbidden() && !species.isTrainerForbidden()
&& species.speciesId !== this.species.speciesId; && species.speciesId !== this.species.speciesId
&& species.speciesId !== Species.DITTO;
}; };
let fusionOverride: PokemonSpecies | undefined = undefined; let fusionOverride: PokemonSpecies | undefined = undefined;
@ -2816,10 +2824,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const numTargets = multiple ? targets.length : 1; const numTargets = multiple ? targets.length : 1;
const targetMultiplier = (numTargets > 1) ? 0.75 : 1; const targetMultiplier = (numTargets > 1) ? 0.75 : 1;
/** 0.25x multiplier if this is an added strike from the attacker's Parental Bond */ /** Multiplier for moves enhanced by Multi-Lens and/or Parental Bond */
const parentalBondMultiplier = new Utils.NumberHolder(1); const multiStrikeEnhancementMultiplier = new Utils.NumberHolder(1);
source.scene.applyModifiers(PokemonMultiHitModifier, source.isPlayer(), source, move.id, null, multiStrikeEnhancementMultiplier);
if (!ignoreSourceAbility) { if (!ignoreSourceAbility) {
applyPreAttackAbAttrs(AddSecondStrikeAbAttr, source, this, move, simulated, numTargets, new Utils.IntegerHolder(0), parentalBondMultiplier); applyPreAttackAbAttrs(AddSecondStrikeAbAttr, source, this, move, simulated, null, multiStrikeEnhancementMultiplier);
} }
/** Doubles damage if this Pokemon's last move was Glaive Rush */ /** Doubles damage if this Pokemon's last move was Glaive Rush */
@ -2896,7 +2905,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
damage.value = Utils.toDmgValue( damage.value = Utils.toDmgValue(
baseDamage baseDamage
* targetMultiplier * targetMultiplier
* parentalBondMultiplier.value * multiStrikeEnhancementMultiplier.value
* arenaAttackTypeMultiplier.value * arenaAttackTypeMultiplier.value
* glaiveRushMultiplier.value * glaiveRushMultiplier.value
* criticalMultiplier.value * criticalMultiplier.value
@ -3124,6 +3133,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
surviveDamage.value = this.lapseTag(BattlerTagType.ENDURING); surviveDamage.value = this.lapseTag(BattlerTagType.ENDURING);
} else if (this.hp > 1 && this.getTag(BattlerTagType.STURDY)) { } else if (this.hp > 1 && this.getTag(BattlerTagType.STURDY)) {
surviveDamage.value = this.lapseTag(BattlerTagType.STURDY); surviveDamage.value = this.lapseTag(BattlerTagType.STURDY);
} else if (this.hp >= 1 && this.getTag(BattlerTagType.ENDURE_TOKEN)) {
surviveDamage.value = this.lapseTag(BattlerTagType.ENDURE_TOKEN);
} }
if (!surviveDamage.value) { if (!surviveDamage.value) {
this.scene.applyModifiers(SurviveDamageModifier, this.isPlayer(), this, surviveDamage); this.scene.applyModifiers(SurviveDamageModifier, this.isPlayer(), this, surviveDamage);
@ -3781,7 +3792,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
this.status = null; this.status = null;
if (lastStatus === StatusEffect.SLEEP) { if (lastStatus === StatusEffect.SLEEP) {
this.setFrameRate(12); this.setFrameRate(10);
if (this.getTag(BattlerTagType.NIGHTMARE)) { if (this.getTag(BattlerTagType.NIGHTMARE)) {
this.lapseTag(BattlerTagType.NIGHTMARE); this.lapseTag(BattlerTagType.NIGHTMARE);
} }
@ -4281,6 +4292,28 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
return false; return false;
} }
/**
* Reduces one of this Pokemon's held item stacks by 1, and removes the item if applicable.
* Does nothing if this Pokemon is somehow not the owner of the held item.
* @param heldItem The item stack to be reduced by 1.
* @param forBattle If `false`, do not trigger in-battle effects (such as Unburden) from losing the item. For example, set this to `false` if the Pokemon is giving away the held item for a Mystery Encounter. Default is `true`.
* @returns `true` if the item was removed successfully, `false` otherwise.
*/
public loseHeldItem(heldItem: PokemonHeldItemModifier, forBattle: boolean = true): boolean {
if (heldItem.pokemonId === -1 || heldItem.pokemonId === this.id) {
heldItem.stackCount--;
if (heldItem.stackCount <= 0) {
this.scene.removeModifier(heldItem, !this.isPlayer());
}
if (forBattle) {
applyPostItemLostAbAttrs(PostItemLostAbAttr, this, false);
}
return true;
} else {
return false;
}
}
} }
export default interface Pokemon { export default interface Pokemon {
@ -4723,7 +4756,7 @@ export class PlayerPokemon extends Pokemon {
&& m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; && m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[];
const transferModifiers: Promise<boolean>[] = []; const transferModifiers: Promise<boolean>[] = [];
for (const modifier of fusedPartyMemberHeldModifiers) { for (const modifier of fusedPartyMemberHeldModifiers) {
transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true)); transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true, false));
} }
Promise.allSettled(transferModifiers).then(() => { Promise.allSettled(transferModifiers).then(() => {
this.scene.updateModifiers(true, true).then(() => { this.scene.updateModifiers(true, true).then(() => {
@ -5294,7 +5327,7 @@ export class EnemyPokemon extends Pokemon {
/** /**
* Add a new pokemon to the player's party (at `slotIndex` if set). * Add a new pokemon to the player's party (at `slotIndex` if set).
* If the first slot is replaced, the new pokemon's visibility will be set to `false`. * The new pokemon's visibility will be set to `false`.
* @param pokeballType the type of pokeball the pokemon was caught with * @param pokeballType the type of pokeball the pokemon was caught with
* @param slotIndex an optional index to place the pokemon in the party * @param slotIndex an optional index to place the pokemon in the party
* @returns the pokemon that was added or null if the pokemon could not be added * @returns the pokemon that was added or null if the pokemon could not be added
@ -5312,14 +5345,14 @@ export class EnemyPokemon extends Pokemon {
const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this); const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this);
if (Utils.isBetween(slotIndex, 0, PLAYER_PARTY_MAX_SIZE - 1)) { if (Utils.isBetween(slotIndex, 0, PLAYER_PARTY_MAX_SIZE - 1)) {
if (slotIndex === 0) {
newPokemon.setVisible(false); // Hide if replaced with first pokemon
}
party.splice(slotIndex, 0, newPokemon); party.splice(slotIndex, 0, newPokemon);
} else { } else {
party.push(newPokemon); party.push(newPokemon);
} }
// Hide the Pokemon since it is not on the field
newPokemon.setVisible(false);
ret = newPokemon; ret = newPokemon;
this.scene.triggerPokemonFormChange(newPokemon, SpeciesFormChangeActiveTrigger, true); this.scene.triggerPokemonFormChange(newPokemon, SpeciesFormChangeActiveTrigger, true);
} }

View File

@ -236,7 +236,7 @@ export class GameMode implements GameModeConfig {
* @returns true if waveIndex is a multiple of 50 in Endless * @returns true if waveIndex is a multiple of 50 in Endless
*/ */
isEndlessBoss(waveIndex: integer): boolean { isEndlessBoss(waveIndex: integer): boolean {
return !!(waveIndex % 50) && return waveIndex % 50 === 0 &&
(this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS); (this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS);
} }

View File

@ -6,7 +6,6 @@ import { allMoves } from "#app/data/move";
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball"; import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
import { type FormChangeItem, SpeciesFormChangeItemTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms"; import { type FormChangeItem, SpeciesFormChangeItemTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms";
import { getStatusEffectHealText } from "#app/data/status-effect"; import { getStatusEffectHealText } from "#app/data/status-effect";
import { Type } from "#enums/type";
import Pokemon, { type PlayerPokemon } from "#app/field/pokemon"; import Pokemon, { type PlayerPokemon } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import Overrides from "#app/overrides"; import Overrides from "#app/overrides";
@ -22,11 +21,13 @@ import { BooleanHolder, hslToHex, isNullOrUndefined, NumberHolder, toDmgValue }
import { Abilities } from "#enums/abilities"; 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 type { Nature } from "#enums/nature"; import type { Nature } from "#enums/nature";
import type { PokeballType } from "#enums/pokeball"; import type { PokeballType } from "#enums/pokeball";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { type PermanentStat, type TempBattleStat, BATTLE_STATS, Stat, TEMP_BATTLE_STATS } from "#enums/stat"; import { type PermanentStat, type TempBattleStat, BATTLE_STATS, Stat, TEMP_BATTLE_STATS } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { Type } from "#enums/type";
import i18next from "i18next"; import i18next from "i18next";
import { type DoubleBattleChanceBoosterModifierType, type EvolutionItemModifierType, type FormChangeItemModifierType, type ModifierOverride, type ModifierType, type PokemonBaseStatTotalModifierType, type PokemonExpBoosterModifierType, type PokemonFriendshipBoosterModifierType, type PokemonMoveAccuracyBoosterModifierType, type PokemonMultiHitModifierType, type TerastallizeModifierType, type TmModifierType, getModifierType, ModifierPoolType, ModifierTypeGenerator, modifierTypes, PokemonHeldItemModifierType } from "./modifier-type"; import { type DoubleBattleChanceBoosterModifierType, type EvolutionItemModifierType, type FormChangeItemModifierType, type ModifierOverride, type ModifierType, type PokemonBaseStatTotalModifierType, type PokemonExpBoosterModifierType, type PokemonFriendshipBoosterModifierType, type PokemonMoveAccuracyBoosterModifierType, type PokemonMultiHitModifierType, type TerastallizeModifierType, type TmModifierType, getModifierType, ModifierPoolType, ModifierTypeGenerator, modifierTypes, PokemonHeldItemModifierType } from "./modifier-type";
import { Color, ShadowColor } from "#enums/color"; import { Color, ShadowColor } from "#enums/color";
@ -2689,32 +2690,57 @@ export class PokemonMultiHitModifier extends PokemonHeldItemModifier {
} }
/** /**
* Applies {@linkcode PokemonMultiHitModifier} * For each stack, converts 25 percent of attack damage into an additional strike.
* @param _pokemon The {@linkcode Pokemon} using the move * @param pokemon The {@linkcode Pokemon} using the move
* @param count {@linkcode NumberHolder} holding the number of items * @param moveId The {@linkcode Moves | identifier} for the move being used
* @param power {@linkcode NumberHolder} holding the power of the move * @param count {@linkcode NumberHolder} holding the move's hit count for this turn
* @param damageMultiplier {@linkcode NumberHolder} holding a damage multiplier applied to a strike of this move
* @returns always `true` * @returns always `true`
*/ */
override apply(_pokemon: Pokemon, count: NumberHolder, power: NumberHolder): boolean { override apply(pokemon: Pokemon, moveId: Moves, count: NumberHolder | null = null, damageMultiplier: NumberHolder | null = null): boolean {
count.value *= (this.getStackCount() + 1); const move = allMoves[moveId];
/**
switch (this.getStackCount()) { * The move must meet Parental Bond's restrictions for this item
case 1: * to apply. This means
power.value *= 0.4; * - Only attacks are boosted
break; * - Multi-strike moves, charge moves, and self-sacrificial moves are not boosted
case 2: * (though Multi-Lens can still affect moves boosted by Parental Bond)
power.value *= 0.25; * - Multi-target moves are not boosted *unless* they can only hit a single Pokemon
break; * - Fling, Uproar, Rollout, Ice Ball, and Endeavor are not boosted
case 3: */
power.value *= 0.175; if (!move.canBeMultiStrikeEnhanced(pokemon)) {
break; return false;
} }
if (!isNullOrUndefined(count)) {
return this.applyHitCountBoost(count);
} else if (!isNullOrUndefined(damageMultiplier)) {
return this.applyDamageModifier(pokemon, damageMultiplier);
}
return false;
}
/** Adds strikes to a move equal to the number of stacked Multi-Lenses */
private applyHitCountBoost(count: NumberHolder): boolean {
count.value += this.getStackCount();
return true;
}
/**
* If applied to the first hit of a move, sets the damage multiplier
* equal to (1 - the number of stacked Multi-Lenses).
* Additional strikes beyond that are given a 0.25x damage multiplier
*/
private applyDamageModifier(pokemon: Pokemon, damageMultiplier: NumberHolder): boolean {
damageMultiplier.value = (pokemon.turnData.hitsLeft === pokemon.turnData.hitCount)
? (1 - (0.25 * this.getStackCount()))
: 0.25;
return true; return true;
} }
getMaxHeldItemCount(pokemon: Pokemon): number { getMaxHeldItemCount(pokemon: Pokemon): number {
return 3; return 2;
} }
} }
@ -2792,7 +2818,7 @@ export class MoneyRewardModifier extends ConsumableModifier {
battleScene.getPlayerParty().map(p => { battleScene.getPlayerParty().map(p => {
if (p.species?.speciesId === Species.GIMMIGHOUL || p.fusionSpecies?.speciesId === Species.GIMMIGHOUL) { if (p.species?.speciesId === Species.GIMMIGHOUL || p.fusionSpecies?.speciesId === Species.GIMMIGHOUL) {
p.evoCounter ? p.evoCounter++ : p.evoCounter = 1; p.evoCounter ? p.evoCounter += Math.min(Math.floor(this.moneyMultiplier), 3) : p.evoCounter = Math.min(Math.floor(this.moneyMultiplier), 3);
const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(p) as EvoTrackerModifier; const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(p) as EvoTrackerModifier;
battleScene.addModifier(modifier); battleScene.addModifier(modifier);
} }
@ -3605,7 +3631,7 @@ export class EnemyEndureChanceModifier extends EnemyPersistentModifier {
super(type, stackCount || 10); super(type, stackCount || 10);
//Hardcode temporarily //Hardcode temporarily
this.chance = .02; this.chance = 2;
} }
match(modifier: Modifier) { match(modifier: Modifier) {
@ -3613,24 +3639,24 @@ export class EnemyEndureChanceModifier extends EnemyPersistentModifier {
} }
clone() { clone() {
return new EnemyEndureChanceModifier(this.type, this.chance * 100, this.stackCount); return new EnemyEndureChanceModifier(this.type, this.chance, this.stackCount);
} }
getArgs(): any[] { getArgs(): any[] {
return [ this.chance * 100 ]; return [ this.chance ];
} }
/** /**
* Applies {@linkcode EnemyEndureChanceModifier} * Applies a chance of enduring a lethal hit of an attack
* @param target {@linkcode Pokemon} to apply the {@linkcode BattlerTagType.ENDURING} chance to * @param target the {@linkcode Pokemon} to apply the {@linkcode BattlerTagType.ENDURING} chance to
* @returns `true` if {@linkcode Pokemon} endured * @returns `true` if {@linkcode Pokemon} endured
*/ */
override apply(target: Pokemon): boolean { override apply(target: Pokemon): boolean {
if (target.battleData.endured || Phaser.Math.RND.realInRange(0, 1) >= (this.chance * this.getStackCount())) { if (target.battleData.endured || target.randSeedInt(100) >= (this.chance * this.getStackCount())) {
return false; return false;
} }
target.addTag(BattlerTagType.ENDURING, 1); target.addTag(BattlerTagType.ENDURE_TOKEN, 1);
target.battleData.endured = true; target.battleData.endured = true;

View File

@ -47,7 +47,18 @@ class DefaultOverrides {
/** a specific seed (default: a random string of 24 characters) */ /** a specific seed (default: a random string of 24 characters) */
readonly SEED_OVERRIDE: string = ""; readonly SEED_OVERRIDE: string = "";
readonly WEATHER_OVERRIDE: WeatherType = WeatherType.NONE; readonly WEATHER_OVERRIDE: WeatherType = WeatherType.NONE;
readonly BATTLE_TYPE_OVERRIDE: "double" | "single" | null = null; /**
* If `null`, ignore this override.
*
* If `"single"`, set every non-trainer battle to be a single battle.
*
* If `"double"`, set every battle (including trainer battles) to be a double battle.
*
* If `"even-doubles"`, follow the `"double"` rule on even wave numbers, and follow the `"single"` rule on odd wave numbers.
*
* If `"odd-doubles"`, follow the `"double"` rule on odd wave numbers, and follow the `"single"` rule on even wave numbers.
*/
readonly BATTLE_TYPE_OVERRIDE: BattleStyle | null = null;
readonly STARTING_WAVE_OVERRIDE: number = 0; readonly STARTING_WAVE_OVERRIDE: number = 0;
readonly STARTING_BIOME_OVERRIDE: Biome = Biome.TOWN; readonly STARTING_BIOME_OVERRIDE: Biome = Biome.TOWN;
readonly ARENA_TINT_OVERRIDE: TimeOfDay | null = null; readonly ARENA_TINT_OVERRIDE: TimeOfDay | null = null;
@ -229,3 +240,5 @@ export default {
...defaultOverrides, ...defaultOverrides,
...overrides ...overrides
} satisfies InstanceType<typeof DefaultOverrides>; } satisfies InstanceType<typeof DefaultOverrides>;
export type BattleStyle = "double" | "single" | "even-doubles" | "odd-doubles";

View File

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

View File

@ -203,7 +203,7 @@ export class EncounterPhase extends BattlePhase {
this.scene.field.add(enemyPokemon); this.scene.field.add(enemyPokemon);
battle.seenEnemyPartyMemberIds.add(enemyPokemon.id); battle.seenEnemyPartyMemberIds.add(enemyPokemon.id);
const playerPokemon = this.scene.getPlayerPokemon(); const playerPokemon = this.scene.getPlayerPokemon();
if (playerPokemon?.visible) { if (playerPokemon?.isOnField()) {
this.scene.field.moveBelow(enemyPokemon as Pokemon, playerPokemon); this.scene.field.moveBelow(enemyPokemon as Pokemon, playerPokemon);
} }
enemyPokemon.tint(0, 0.5); enemyPokemon.tint(0, 0.5);

View File

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

View File

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

View File

@ -1,59 +1,66 @@
import BattleScene from "#app/battle-scene"; import type BattleScene from "#app/battle-scene";
import { ExpNotification } from "#app/enums/exp-notification"; import { ExpNotification } from "#app/enums/exp-notification";
import { EvolutionPhase } from "#app/phases/evolution-phase"; import type { PlayerPokemon } from "#app/field/pokemon";
import { PlayerPokemon } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import { EvolutionPhase } from "#app/phases/evolution-phase";
import { LearnMovePhase } from "#app/phases/learn-move-phase";
import { PlayerPartyMemberPokemonPhase } from "#app/phases/player-party-member-pokemon-phase";
import { LevelAchv } from "#app/system/achv"; import { LevelAchv } from "#app/system/achv";
import { NumberHolder } from "#app/utils";
import i18next from "i18next"; import i18next from "i18next";
import * as Utils from "#app/utils";
import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase";
import { LearnMovePhase } from "./learn-move-phase";
export class LevelUpPhase extends PlayerPartyMemberPokemonPhase { export class LevelUpPhase extends PlayerPartyMemberPokemonPhase {
private lastLevel: integer; protected lastLevel: number;
private level: integer; protected level: number;
protected pokemon: PlayerPokemon = this.getPlayerPokemon();
constructor(scene: BattleScene, partyMemberIndex: integer, lastLevel: integer, level: integer) { constructor(scene: BattleScene, partyMemberIndex: number, lastLevel: number, level: number) {
super(scene, partyMemberIndex); super(scene, partyMemberIndex);
this.lastLevel = lastLevel; this.lastLevel = lastLevel;
this.level = level; this.level = level;
this.scene = scene;
} }
start() { public override start() {
super.start(); super.start();
if (this.level > this.scene.gameData.gameStats.highestLevel) { if (this.level > this.scene.gameData.gameStats.highestLevel) {
this.scene.gameData.gameStats.highestLevel = this.level; this.scene.gameData.gameStats.highestLevel = this.level;
} }
this.scene.validateAchvs(LevelAchv, new Utils.NumberHolder(this.level)); this.scene.validateAchvs(LevelAchv, new NumberHolder(this.level));
const pokemon = this.getPokemon(); const prevStats = this.pokemon.stats.slice(0);
const prevStats = pokemon.stats.slice(0); this.pokemon.calculateStats();
pokemon.calculateStats(); this.pokemon.updateInfo();
pokemon.updateInfo();
if (this.scene.expParty === ExpNotification.DEFAULT) { if (this.scene.expParty === ExpNotification.DEFAULT) {
this.scene.playSound("level_up_fanfare"); this.scene.playSound("level_up_fanfare");
this.scene.ui.showText(i18next.t("battle:levelUp", { pokemonName: getPokemonNameWithAffix(this.getPokemon()), level: this.level }), null, () => this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end()), null, true); this.scene.ui.showText(
i18next.t("battle:levelUp", { pokemonName: getPokemonNameWithAffix(this.pokemon), level: this.level }),
null,
() => this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false)
.then(() => this.end()), null, true);
} else if (this.scene.expParty === ExpNotification.SKIP) { } else if (this.scene.expParty === ExpNotification.SKIP) {
this.end(); this.end();
} else { } else {
// we still want to display the stats if activated // we still want to display the stats if activated
this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end()); this.scene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end());
} }
}
public override end() {
if (this.lastLevel < 100) { // this feels like an unnecessary optimization if (this.lastLevel < 100) { // this feels like an unnecessary optimization
const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1); const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1);
for (const lm of levelMoves) { for (const lm of levelMoves) {
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm[1])); this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm[1]));
} }
} }
if (!pokemon.pauseEvolutions) { if (!this.pokemon.pauseEvolutions) {
const evolution = pokemon.getEvolution(); const evolution = this.pokemon.getEvolution();
if (evolution) { if (evolution) {
this.scene.unshiftPhase(new EvolutionPhase(this.scene, pokemon as PlayerPokemon, evolution, this.lastLevel)); this.scene.unshiftPhase(new EvolutionPhase(this.scene, this.pokemon, evolution, this.lastLevel));
} }
} }
return super.end();
} }
} }

View File

@ -26,7 +26,7 @@ import {
applyMoveAttrs, applyMoveAttrs,
AttackMove, AttackMove,
DelayedAttackAttr, DelayedAttackAttr,
FixedDamageAttr, FlinchAttr,
HitsTagAttr, HitsTagAttr,
MissEffectAttr, MissEffectAttr,
MoveAttr, MoveAttr,
@ -122,12 +122,10 @@ export class MoveEffectPhase extends PokemonPhase {
const hitCount = new NumberHolder(1); const hitCount = new NumberHolder(1);
// Assume single target for multi hit // Assume single target for multi hit
applyMoveAttrs(MultiHitAttr, user, this.getFirstTarget() ?? null, move, hitCount); applyMoveAttrs(MultiHitAttr, user, this.getFirstTarget() ?? null, move, hitCount);
// If Parental Bond is applicable, double the hit count // If Parental Bond is applicable, add another hit
applyPreAttackAbAttrs(AddSecondStrikeAbAttr, user, null, move, false, targets.length, hitCount, new NumberHolder(0)); applyPreAttackAbAttrs(AddSecondStrikeAbAttr, user, null, move, false, hitCount, null);
// If Multi-Lens is applicable, multiply the hit count by 1 + the number of Multi-Lenses held by the user // If Multi-Lens is applicable, add hits equal to the number of held Multi-Lenses
if (move instanceof AttackMove && !move.hasAttr(FixedDamageAttr)) { this.scene.applyModifiers(PokemonMultiHitModifier, user.isPlayer(), user, move.id, hitCount);
this.scene.applyModifiers(PokemonMultiHitModifier, user.isPlayer(), user, hitCount, new NumberHolder(0));
}
// Set the user's relevant turnData fields to reflect the final hit count // Set the user's relevant turnData fields to reflect the final hit count
user.turnData.hitCount = hitCount.value; user.turnData.hitCount = hitCount.value;
user.turnData.hitsLeft = hitCount.value; user.turnData.hitsLeft = hitCount.value;
@ -505,6 +503,10 @@ export class MoveEffectPhase extends PokemonPhase {
*/ */
protected applyHeldItemFlinchCheck(user: Pokemon, target: Pokemon, dealsDamage: boolean) : () => void { protected applyHeldItemFlinchCheck(user: Pokemon, target: Pokemon, dealsDamage: boolean) : () => void {
return () => { return () => {
if (this.move.getMove().hasAttr(FlinchAttr)) {
return;
}
if (dealsDamage && !target.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && !this.move.getMove().hitsSubstitute(user, target)) { if (dealsDamage && !target.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && !this.move.getMove().hitsSubstitute(user, target)) {
const flinched = new BooleanHolder(false); const flinched = new BooleanHolder(false);
user.scene.applyModifiers(FlinchChanceModifier, user.isPlayer(), user, flinched); user.scene.applyModifiers(FlinchChanceModifier, user.isPlayer(), user, flinched);

View File

@ -121,12 +121,11 @@ export class MovePhase extends BattlePhase {
// Check if move is unusable (e.g. because it's out of PP due to a mid-turn Spite). // Check if move is unusable (e.g. because it's out of PP due to a mid-turn Spite).
if (!this.canMove(true)) { if (!this.canMove(true)) {
if (this.pokemon.isActive(true) && this.move.ppUsed >= this.move.getMovePp()) { if (this.pokemon.isActive(true)) {
this.fail(); this.fail();
this.showMoveText(); this.showMoveText();
this.showFailedText(); this.showFailedText();
} }
return this.end(); return this.end();
} }
@ -378,15 +377,9 @@ export class MovePhase extends BattlePhase {
} else { } else {
this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual }); this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual });
let failedText: string | undefined;
const failureMessage = move.getFailedText(this.pokemon, targets[0], move, new BooleanHolder(false)); const failureMessage = move.getFailedText(this.pokemon, targets[0], move, new BooleanHolder(false));
if (failureMessage) {
failedText = failureMessage;
}
this.showMoveText(); this.showMoveText();
this.showFailedText(failedText); this.showFailedText(failureMessage ?? undefined);
// Remove the user from its semi-invulnerable state (if applicable) // Remove the user from its semi-invulnerable state (if applicable)
this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT); this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT);

View File

@ -312,6 +312,10 @@ export class PokemonAnimPhase extends BattlePhase {
// Note: unlike the other Commander animation, this is played through the // Note: unlike the other Commander animation, this is played through the
// Dondozo instead of the Tatsugiri. // Dondozo instead of the Tatsugiri.
const tatsugiri = this.pokemon.getAlly(); const tatsugiri = this.pokemon.getAlly();
if (isNullOrUndefined(tatsugiri)) {
console.warn("Aborting COMMANDER_REMOVE anim: Tatsugiri is undefined");
return this.end();
}
const tatsuSprite = this.scene.addPokemonSprite( const tatsuSprite = this.scene.addPokemonSprite(
tatsugiri, tatsugiri,

View File

@ -29,10 +29,14 @@ export class QuietFormChangePhase extends BattlePhase {
const preName = getPokemonNameWithAffix(this.pokemon); const preName = getPokemonNameWithAffix(this.pokemon);
if (!this.pokemon.isOnField() || this.pokemon.getTag(SemiInvulnerableTag)) { if (!this.pokemon.isOnField() || this.pokemon.getTag(SemiInvulnerableTag) || this.pokemon.isFainted()) {
this.pokemon.changeForm(this.formChange).then(() => { if (this.pokemon.isPlayer() || this.pokemon.isActive()) {
this.scene.ui.showText(getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), null, () => this.end(), 1500); this.pokemon.changeForm(this.formChange).then(() => {
}); this.scene.ui.showText(getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), null, () => this.end(), 1500);
});
} else {
this.end();
}
return; return;
} }

View File

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

View File

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

View File

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

View File

@ -112,7 +112,7 @@ export class SwitchSummonPhase extends SummonPhase {
const batonPassModifier = this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier const batonPassModifier = this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier
&& (m as SwitchEffectTransferModifier).pokemonId === this.lastPokemon.id) as SwitchEffectTransferModifier; && (m as SwitchEffectTransferModifier).pokemonId === this.lastPokemon.id) as SwitchEffectTransferModifier;
if (batonPassModifier && !this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) { if (batonPassModifier && !this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) {
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false); this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false, undefined, undefined, undefined, false);
} }
} }
} }

View File

@ -679,7 +679,7 @@ export class GameData {
return ret; return ret;
} }
return k.endsWith("Attr") && ![ "natureAttr", "abilityAttr", "passiveAttr" ].includes(k) ? BigInt(v) : v; return k.endsWith("Attr") && ![ "natureAttr", "abilityAttr", "passiveAttr" ].includes(k) ? BigInt(v ?? 0) : v;
}) as SystemSaveData; }) as SystemSaveData;
} }
@ -1540,7 +1540,7 @@ export class GameData {
entry.caughtAttr = defaultStarterAttr; entry.caughtAttr = defaultStarterAttr;
entry.natureAttr = 1 << (defaultStarterNatures[ds] + 1); entry.natureAttr = 1 << (defaultStarterNatures[ds] + 1);
for (const i in entry.ivs) { for (const i in entry.ivs) {
entry.ivs[i] = 10; entry.ivs[i] = 15;
} }
} }

View File

@ -88,8 +88,8 @@ describe("Abilities - Illusion", () => {
const flameThrower = enemy.getMoveset()[0]!.getMove(); const flameThrower = enemy.getMoveset()[0]!.getMove();
const psychic = enemy.getMoveset()[1]!.getMove(); const psychic = enemy.getMoveset()[1]!.getMove();
const flameThrowerEffectiveness = zoroark.getAttackTypeEffectiveness(flameThrower.type, enemy, undefined, undefined, true); const flameThrowerEffectiveness = zoroark.getAttackTypeEffectiveness(flameThrower.type, enemy, undefined, undefined, flameThrower, true);
const psychicEffectiveness = zoroark.getAttackTypeEffectiveness(psychic.type, enemy, undefined, undefined, true); const psychicEffectiveness = zoroark.getAttackTypeEffectiveness(psychic.type, enemy, undefined, undefined, psychic, true);
expect(psychicEffectiveness).above(flameThrowerEffectiveness); expect(psychicEffectiveness).above(flameThrowerEffectiveness);
}); });

View File

@ -274,7 +274,7 @@ describe("Abilities - Parental Bond", () => {
); );
it( it(
"Moves boosted by this ability and Multi-Lens should strike 4 times", "Moves boosted by this ability and Multi-Lens should strike 3 times",
async () => { async () => {
game.override.moveset([ Moves.TACKLE ]); game.override.moveset([ Moves.TACKLE ]);
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
@ -287,36 +287,12 @@ describe("Abilities - Parental Bond", () => {
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamagePhase");
expect(leadPokemon.turnData.hitCount).toBe(4); expect(leadPokemon.turnData.hitCount).toBe(3);
} }
); );
it( it(
"Super Fang boosted by this ability and Multi-Lens should strike twice", "Seismic Toss boosted by this ability and Multi-Lens should strike 3 times",
async () => {
game.override.moveset([ Moves.SUPER_FANG ]);
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.classicMode.startBattle([ Species.MAGIKARP ]);
const leadPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.SUPER_FANG);
await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase");
expect(leadPokemon.turnData.hitCount).toBe(2);
await game.phaseInterceptor.to("MoveEndPhase", false);
expect(enemyPokemon.hp).toBe(Math.ceil(enemyPokemon.getMaxHp() * 0.25));
}
);
it(
"Seismic Toss boosted by this ability and Multi-Lens should strike twice",
async () => { async () => {
game.override.moveset([ Moves.SEISMIC_TOSS ]); game.override.moveset([ Moves.SEISMIC_TOSS ]);
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
@ -333,11 +309,11 @@ describe("Abilities - Parental Bond", () => {
await game.phaseInterceptor.to("DamagePhase"); await game.phaseInterceptor.to("DamagePhase");
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(3);
await game.phaseInterceptor.to("MoveEndPhase", false); await game.phaseInterceptor.to("MoveEndPhase", false);
expect(enemyPokemon.hp).toBe(enemyStartingHp - 200); expect(enemyPokemon.hp).toBe(enemyStartingHp - 300);
} }
); );
@ -494,30 +470,4 @@ describe("Abilities - Parental Bond", () => {
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(1); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(1);
} }
); );
it(
"should not apply to multi-target moves with Multi-Lens",
async () => {
game.override.battleType("double");
game.override.moveset([ Moves.EARTHQUAKE, Moves.SPLASH ]);
game.override.passiveAbility(Abilities.LEVITATE);
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
const enemyPokemon = game.scene.getEnemyField();
const enemyStartingHp = enemyPokemon.map(p => p.hp);
game.move.select(Moves.EARTHQUAKE);
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to("DamagePhase");
const enemyFirstHitDamage = enemyStartingHp.map((hp, i) => hp - enemyPokemon[i].hp);
await game.phaseInterceptor.to("BerryPhase", false);
enemyPokemon.forEach((p, i) => expect(enemyStartingHp[i] - p.hp).toBe(2 * enemyFirstHitDamage[i]));
}
);
}); });

View File

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

View File

@ -1,14 +1,8 @@
import { BattlerIndex } from "#app/battle";
import { Status } from "#app/data/status-effect"; import { Status } from "#app/data/status-effect";
import { DamagePhase } from "#app/phases/damage-phase";
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
import { Mode } from "#app/ui/ui";
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 { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { SwitchType } from "#enums/switch-type";
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";
@ -34,78 +28,60 @@ describe("Abilities - ZEN MODE", () => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.battleType("single") .battleType("single")
.enemySpecies(Species.RATTATA) .disableCrits()
.enemyAbility(Abilities.HYDRATION) .enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.enemyLevel(5)
.ability(Abilities.ZEN_MODE) .ability(Abilities.ZEN_MODE)
.startingLevel(100)
.moveset(Moves.SPLASH) .moveset(Moves.SPLASH)
.enemyMoveset(Moves.TACKLE); .enemyMoveset(Moves.SEISMIC_TOSS);
}); });
it("shouldn't change form when taking damage if not dropping below 50% HP", async () => { it("shouldn't change form when taking damage if not dropping below 50% HP", async () => {
await game.classicMode.startBattle([ Species.DARMANITAN ]); await game.classicMode.startBattle([ Species.DARMANITAN ]);
const player = game.scene.getPlayerPokemon()!; const darmanitan = game.scene.getPlayerPokemon()!;
player.stats[Stat.HP] = 100; expect(darmanitan.formIndex).toBe(baseForm);
player.hp = 100;
expect(player.formIndex).toBe(baseForm);
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.toNextTurn();
await game.phaseInterceptor.to("BerryPhase");
expect(player.hp).toBeLessThan(100); expect(darmanitan.getHpRatio()).toBeLessThan(1);
expect(player.formIndex).toBe(baseForm); expect(darmanitan.getHpRatio()).toBeGreaterThan(0.5);
expect(darmanitan.formIndex).toBe(baseForm);
}); });
it("should change form when falling below 50% HP", async () => { it("should change form when falling below 50% HP", async () => {
await game.classicMode.startBattle([ Species.DARMANITAN ]); await game.classicMode.startBattle([ Species.DARMANITAN ]);
const player = game.scene.getPlayerPokemon()!; const darmanitan = game.scene.getPlayerPokemon()!;
player.stats[Stat.HP] = 1000; darmanitan.hp = (darmanitan.getMaxHp() / 2) + 1;
player.hp = 100; expect(darmanitan.formIndex).toBe(baseForm);
expect(player.formIndex).toBe(baseForm);
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.toNextTurn();
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); expect(darmanitan.getHpRatio()).toBeLessThan(0.5);
await game.phaseInterceptor.to("QuietFormChangePhase"); expect(darmanitan.formIndex).toBe(zenForm);
await game.phaseInterceptor.to("TurnInitPhase", false);
expect(player.hp).not.toBe(100);
expect(player.formIndex).toBe(zenForm);
}); });
it("should stay zen mode when fainted", async () => { it("should stay zen mode when fainted", async () => {
await game.classicMode.startBattle([ Species.DARMANITAN, Species.CHARIZARD ]); await game.classicMode.startBattle([ Species.DARMANITAN, Species.CHARIZARD ]);
const player = game.scene.getPlayerPokemon()!; const darmanitan = game.scene.getPlayerPokemon()!;
player.stats[Stat.HP] = 1000; darmanitan.hp = (darmanitan.getMaxHp() / 2) + 1;
player.hp = 100; expect(darmanitan.formIndex).toBe(baseForm);
expect(player.formIndex).toBe(baseForm);
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.toNextTurn();
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); expect(darmanitan.getHpRatio()).toBeLessThan(0.5);
await game.phaseInterceptor.to(DamagePhase, false); expect(darmanitan.formIndex).toBe(zenForm);
const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
damagePhase.updateAmount(80);
await game.phaseInterceptor.to("QuietFormChangePhase");
expect(player.hp).not.toBe(100); game.move.select(Moves.SPLASH);
expect(player.formIndex).toBe(zenForm); await game.killPokemon(darmanitan);
game.doSelectPartyPokemon(1);
await game.killPokemon(player); await game.toNextTurn();
expect(player.isFainted()).toBe(true);
await game.phaseInterceptor.to("TurnStartPhase");
game.onNextPrompt("SwitchPhase", Mode.PARTY, () => {
game.scene.unshiftPhase(new SwitchSummonPhase(game.scene, SwitchType.SWITCH, 0, 1, false));
game.scene.ui.setMode(Mode.MESSAGE);
});
game.onNextPrompt("SwitchPhase", Mode.MESSAGE, () => {
game.endPhase();
});
await game.phaseInterceptor.to("PostSummonPhase");
expect(darmanitan.isFainted()).toBe(true);
expect(game.scene.getPlayerParty()[1].formIndex).toBe(zenForm); expect(game.scene.getPlayerParty()[1].formIndex).toBe(zenForm);
}); });
@ -117,7 +93,8 @@ describe("Abilities - ZEN MODE", () => {
await game.classicMode.startBattle([ Species.MAGIKARP, Species.DARMANITAN ]); await game.classicMode.startBattle([ Species.MAGIKARP, Species.DARMANITAN ]);
const darmanitan = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.DARMANITAN)!; const darmanitan = game.scene.getPlayerParty()[1];
darmanitan.hp = 1;
expect(darmanitan.formIndex).toBe(zenForm); expect(darmanitan.formIndex).toBe(zenForm);
darmanitan.hp = 0; darmanitan.hp = 0;
@ -126,9 +103,7 @@ describe("Abilities - ZEN MODE", () => {
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to("TurnEndPhase"); await game.toNextWave();
game.doSelectModifier();
await game.phaseInterceptor.to("QuietFormChangePhase");
expect(darmanitan.formIndex).toBe(baseForm); expect(darmanitan.formIndex).toBe(baseForm);
}); });

View File

@ -1,4 +1,6 @@
import { Status } from "#app/data/status-effect"; import { Status } from "#app/data/status-effect";
import { Abilities } from "#enums/abilities";
import { GameModes, getGameMode } from "#app/game-mode";
import { BattleEndPhase } from "#app/phases/battle-end-phase"; import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -6,9 +8,11 @@ import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
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";
describe("Double Battles", () => { describe("Double Battles", () => {
const DOUBLE_CHANCE = 8; // Normal chance of double battle is 1/8
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
@ -56,4 +60,40 @@ describe("Double Battles", () => {
await game.phaseInterceptor.to(TurnInitPhase); await game.phaseInterceptor.to(TurnInitPhase);
expect(game.scene.getPlayerField().filter(p => !p.isFainted())).toHaveLength(2); expect(game.scene.getPlayerField().filter(p => !p.isFainted())).toHaveLength(2);
}, 20000); }, 20000);
it("randomly chooses between single and double battles if there is no battle type override", async () => {
let rngSweepProgress = 0; // Will simulate RNG rolls by slowly increasing from 0 to 1
let doubleCount = 0;
let singleCount = 0;
vi.spyOn(Phaser.Math.RND, "realInRange").mockImplementation((min: number, max: number) => {
return rngSweepProgress * (max - min) + min;
});
game.override.enemyMoveset(Moves.SPLASH)
.moveset(Moves.SPLASH)
.enemyAbility(Abilities.BALL_FETCH)
.ability(Abilities.BALL_FETCH);
// Play through endless, waves 1 to 9, counting number of double battles from waves 2 to 9
await game.classicMode.startBattle([ Species.BULBASAUR ]);
game.scene.gameMode = getGameMode(GameModes.ENDLESS);
for (let i = 0; i < DOUBLE_CHANCE; i++) {
rngSweepProgress = (i + 0.5) / DOUBLE_CHANCE;
game.move.select(Moves.SPLASH);
await game.doKillOpponents();
await game.toNextWave();
if (game.scene.getEnemyParty().length === 1) {
singleCount++;
} else if (game.scene.getEnemyParty().length === 2) {
doubleCount++;
}
}
expect(doubleCount).toBe(1);
expect(singleCount).toBe(DOUBLE_CHANCE - 1);
});
}); });

View File

@ -0,0 +1,117 @@
import { BattlerIndex } from "#app/battle";
import { Stat } from "#enums/stat";
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, vi } from "vitest";
describe("Items - Multi Lens", () => {
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.TACKLE, Moves.TRAILBLAZE, Moves.TACHYON_CUTTER ])
.ability(Abilities.BALL_FETCH)
.startingHeldItems([{ name: "MULTI_LENS" }])
.battleType("single")
.disableCrits()
.enemySpecies(Species.SNORLAX)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH)
.startingLevel(100)
.enemyLevel(100);
});
it.each([
{ stackCount: 1, firstHitDamage: 0.75 },
{ stackCount: 2, firstHitDamage: 0.50 }
])("$stackCount count: should deal {$firstHitDamage}x damage on the first hit, then hit $stackCount times for 0.25x",
async ({ stackCount, firstHitDamage }) => {
game.override.startingHeldItems([{ name: "MULTI_LENS", count: stackCount }]);
await game.classicMode.startBattle([ Species.MAGIKARP ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const spy = vi.spyOn(enemyPokemon, "getAttackDamage");
vi.spyOn(enemyPokemon, "getBaseDamage").mockReturnValue(100);
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEndPhase");
const damageResults = spy.mock.results.map(result => result.value?.damage);
expect(damageResults).toHaveLength(1 + stackCount);
expect(damageResults[0]).toBe(firstHitDamage * 100);
damageResults.slice(1).forEach(dmg => expect(dmg).toBe(25));
});
it("should stack additively with Parental Bond", async () => {
game.override.ability(Abilities.PARENTAL_BOND);
await game.classicMode.startBattle([ Species.MAGIKARP ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEndPhase");
expect(playerPokemon.turnData.hitCount).toBe(3);
});
it("should apply secondary effects on each hit", async () => {
await game.classicMode.startBattle([ Species.MAGIKARP ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.TRAILBLAZE);
await game.phaseInterceptor.to("BerryPhase", false);
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(2);
});
it("should not enhance multi-hit moves", async () => {
await game.classicMode.startBattle([ Species.MAGIKARP ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.TACHYON_CUTTER);
await game.phaseInterceptor.to("BerryPhase", false);
expect(playerPokemon.turnData.hitCount).toBe(2);
});
it("should enhance multi-target moves", async () => {
game.override
.battleType("double")
.moveset([ Moves.SWIFT, Moves.SPLASH ]);
await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
const [ magikarp, ] = game.scene.getPlayerField();
game.move.select(Moves.SWIFT, 0);
game.move.select(Moves.SPLASH, 1);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("MoveEndPhase");
expect(magikarp.turnData.hitCount).toBe(2);
});
});

View File

@ -74,29 +74,4 @@ describe("Moves - Beat Up", () => {
expect(playerPokemon.turnData.hitCount).toBe(5); expect(playerPokemon.turnData.hitCount).toBe(5);
} }
); );
it(
"should hit twice for each player Pokemon if the user has Multi-Lens",
async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.startBattle([ Species.MAGIKARP, Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.PIKACHU, Species.EEVEE ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!;
let enemyStartingHp = enemyPokemon.hp;
game.move.select(Moves.BEAT_UP);
await game.phaseInterceptor.to(MoveEffectPhase);
expect(playerPokemon.turnData.hitCount).toBe(12);
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
while (playerPokemon.turnData.hitsLeft > 0) {
enemyStartingHp = enemyPokemon.hp;
await game.phaseInterceptor.to(MoveEffectPhase);
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
}
}
);
}); });

View File

@ -34,7 +34,7 @@ describe("Moves - Ceaseless Edge", () => {
game.override.startingLevel(100); game.override.startingLevel(100);
game.override.enemyLevel(100); game.override.enemyLevel(100);
game.override.moveset([ Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR ]); game.override.moveset([ Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR ]);
game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); game.override.enemyMoveset(Moves.SPLASH);
vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100); vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100);
}); });
@ -42,7 +42,7 @@ describe("Moves - Ceaseless Edge", () => {
test( test(
"move should hit and apply spikes", "move should hit and apply spikes",
async () => { async () => {
await game.startBattle([ Species.ILLUMISE ]); await game.classicMode.startBattle([ Species.ILLUMISE ]);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -67,7 +67,7 @@ describe("Moves - Ceaseless Edge", () => {
"move should hit twice with multi lens and apply two layers of spikes", "move should hit twice with multi lens and apply two layers of spikes",
async () => { async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS" }]); game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
await game.startBattle([ Species.ILLUMISE ]); await game.classicMode.startBattle([ Species.ILLUMISE ]);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -92,9 +92,9 @@ describe("Moves - Ceaseless Edge", () => {
"trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage", "trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage",
async () => { async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS" }]); game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
game.override.startingWave(5); game.override.startingWave(25);
await game.startBattle([ Species.ILLUMISE ]); await game.classicMode.startBattle([ Species.ILLUMISE ]);
game.move.select(Moves.CEASELESS_EDGE); game.move.select(Moves.CEASELESS_EDGE);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -102,7 +102,7 @@ describe("Moves - Ceaseless Edge", () => {
const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); expect(tagBefore instanceof ArenaTrapTag).toBeFalsy();
await game.phaseInterceptor.to(TurnEndPhase, false); await game.toNextTurn();
const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); expect(tagAfter instanceof ArenaTrapTag).toBeTruthy();
expect(tagAfter.layers).toBe(2); expect(tagAfter.layers).toBe(2);

View File

@ -2,7 +2,6 @@ import { Stat } from "#enums/stat";
import { Type } from "#enums/type"; import { Type } from "#enums/type";
import { Species } from "#app/enums/species"; import { Species } from "#app/enums/species";
import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import { modifierTypes } from "#app/modifier/modifier-type";
import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
@ -114,14 +113,4 @@ describe("Moves - Dragon Rage", () => {
expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage); expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage);
}); });
it("ignores multi hit", async () => {
game.override.disableCrits();
game.scene.addModifier(modifierTypes.MULTI_LENS().newModifier(partyPokemon), false);
game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(TurnEndPhase);
expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage);
});
}); });

View File

@ -98,7 +98,7 @@ describe("Moves - Electro Shot", () => {
game.move.select(Moves.ELECTRO_SHOT); game.move.select(Moves.ELECTRO_SHOT);
await game.phaseInterceptor.to("MoveEndPhase"); await game.phaseInterceptor.to("MoveEndPhase");
expect(playerPokemon.turnData.hitCount).toBe(2); expect(playerPokemon.turnData.hitCount).toBe(1);
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(1); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(1);
}); });
}); });

View File

@ -0,0 +1,65 @@
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Endure", () => {
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.THUNDER, Moves.BULLET_SEED, Moves.TOXIC ])
.ability(Abilities.SKILL_LINK)
.startingLevel(100)
.battleType("single")
.disableCrits()
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.NO_GUARD)
.enemyMoveset(Moves.ENDURE);
});
it("should let the pokemon survive with 1 HP", async () => {
await game.classicMode.startBattle([ Species.ARCEUS ]);
game.move.select(Moves.THUNDER);
await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getEnemyPokemon()!.hp).toBe(1);
});
it("should let the pokemon survive with 1 HP when hit with a multihit move", async () => {
await game.classicMode.startBattle([ Species.ARCEUS ]);
game.move.select(Moves.BULLET_SEED);
await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getEnemyPokemon()!.hp).toBe(1);
});
it("shouldn't prevent fainting from indirect damage", async () => {
game.override.enemyLevel(100);
await game.classicMode.startBattle([ Species.ARCEUS ]);
const enemy = game.scene.getEnemyPokemon()!;
enemy.hp = 2;
game.move.select(Moves.TOXIC);
await game.phaseInterceptor.to("VictoryPhase");
expect(enemy.isFainted()).toBe(true);
});
});

View File

@ -2,6 +2,8 @@ import { BattlerIndex } from "#app/battle";
import { Abilities } from "#app/enums/abilities"; 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 { Type } from "#enums/type";
import { Challenges } from "#enums/challenges";
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, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
@ -28,7 +30,7 @@ describe("Moves - Freeze-Dry", () => {
.enemyMoveset(Moves.SPLASH) .enemyMoveset(Moves.SPLASH)
.starterSpecies(Species.FEEBAS) .starterSpecies(Species.FEEBAS)
.ability(Abilities.BALL_FETCH) .ability(Abilities.BALL_FETCH)
.moveset([ Moves.FREEZE_DRY ]); .moveset([ Moves.FREEZE_DRY, Moves.FORESTS_CURSE, Moves.SOAK ]);
}); });
it("should deal 2x damage to pure water types", async () => { it("should deal 2x damage to pure water types", async () => {
@ -97,8 +99,72 @@ describe("Moves - Freeze-Dry", () => {
expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
}); });
// enable if this is ever fixed (lol) it("should deal 8x damage to water/ground/grass type under Forest's Curse", async () => {
it.todo("should deal 2x damage to water types under Normalize", async () => { game.override.enemySpecies(Species.QUAGSIRE);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FORESTS_CURSE);
await game.toNextTurn();
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(8);
});
it("should deal 2x damage to steel type terastallized into water", async () => {
game.override.enemySpecies(Species.SKARMORY)
.enemyHeldItems([{ name: "TERA_SHARD", type: Type.WATER }]);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
});
it("should deal 0.5x damage to water type terastallized into fire", async () => {
game.override.enemySpecies(Species.PELIPPER)
.enemyHeldItems([{ name: "TERA_SHARD", type: Type.FIRE }]);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.5);
});
it("should deal 0.5x damage to water type Terapagos with Tera Shell", async () => {
game.override.enemySpecies(Species.TERAPAGOS)
.enemyAbility(Abilities.TERA_SHELL);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.SOAK);
await game.toNextTurn();
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.5);
});
it("should deal 2x damage to water type under Normalize", async () => {
game.override.ability(Abilities.NORMALIZE); game.override.ability(Abilities.NORMALIZE);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
@ -112,8 +178,39 @@ describe("Moves - Freeze-Dry", () => {
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
}); });
// enable once Electrify is implemented (and the interaction is fixed, as above) it("should deal 0.25x damage to rock/steel type under Normalize", async () => {
it.todo("should deal 2x damage to water types under Electrify", async () => { game.override
.ability(Abilities.NORMALIZE)
.enemySpecies(Species.SHIELDON);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.25);
});
it("should deal 0x damage to water/ghost type under Normalize", async () => {
game.override
.ability(Abilities.NORMALIZE)
.enemySpecies(Species.JELLICENT);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("BerryPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0);
});
it("should deal 2x damage to water type under Electrify", async () => {
game.override.enemyMoveset([ Moves.ELECTRIFY ]); game.override.enemyMoveset([ Moves.ELECTRIFY ]);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
@ -126,4 +223,128 @@ describe("Moves - Freeze-Dry", () => {
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
}); });
it("should deal 4x damage to water/flying type under Electrify", async () => {
game.override
.enemyMoveset([ Moves.ELECTRIFY ])
.enemySpecies(Species.GYARADOS);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("BerryPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4);
});
it("should deal 0x damage to water/ground type under Electrify", async () => {
game.override
.enemyMoveset([ Moves.ELECTRIFY ])
.enemySpecies(Species.BARBOACH);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("BerryPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0);
});
it("should deal 0.25x damage to Grass/Dragon type under Electrify", async () => {
game.override
.enemyMoveset([ Moves.ELECTRIFY ])
.enemySpecies(Species.FLAPPLE);
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("BerryPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.25);
});
it("should deal 2x damage to Water type during inverse battle", async () => {
game.override
.moveset([ Moves.FREEZE_DRY ])
.enemySpecies(Species.MAGIKARP);
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
await game.challengeMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2);
});
it("should deal 2x damage to Water type during inverse battle under Normalize", async () => {
game.override
.moveset([ Moves.FREEZE_DRY ])
.ability(Abilities.NORMALIZE)
.enemySpecies(Species.MAGIKARP);
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
await game.challengeMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2);
});
it("should deal 2x damage to Water type during inverse battle under Electrify", async () => {
game.override
.moveset([ Moves.FREEZE_DRY ])
.enemySpecies(Species.MAGIKARP)
.enemyMoveset([ Moves.ELECTRIFY ]);
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
await game.challengeMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2);
});
it("should deal 1x damage to water/flying type during inverse battle under Electrify", async () => {
game.override
.enemyMoveset([ Moves.ELECTRIFY ])
.enemySpecies(Species.GYARADOS);
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
await game.challengeMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "getMoveEffectiveness");
game.move.select(Moves.FREEZE_DRY);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("BerryPhase");
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(1);
});
}); });

View File

@ -62,7 +62,7 @@ describe("Moves - Gastro Acid", () => {
}); });
it("fails if used on an enemy with an already-suppressed ability", async () => { it("fails if used on an enemy with an already-suppressed ability", async () => {
game.override.battleType(null); game.override.battleType("single");
await game.startBattle(); await game.startBattle();

View File

@ -0,0 +1,59 @@
import { allMoves, RandomMoveAttr } from "#app/data/move";
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, vi } from "vitest";
describe("Moves - Moongeist Beam", () => {
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.MOONGEIST_BEAM, Moves.METRONOME ])
.ability(Abilities.BALL_FETCH)
.startingLevel(200)
.battleType("single")
.disableCrits()
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.STURDY)
.enemyMoveset(Moves.SPLASH);
});
// Also covers Photon Geyser and Sunsteel Strike
it("should ignore enemy abilities", async () => {
await game.classicMode.startBattle([ Species.MILOTIC ]);
const enemy = game.scene.getEnemyPokemon()!;
game.move.select(Moves.MOONGEIST_BEAM);
await game.phaseInterceptor.to("BerryPhase");
expect(enemy.isFainted()).toBe(true);
});
// Also covers Photon Geyser and Sunsteel Strike
it("should not ignore enemy abilities when called by another move, such as metronome", async () => {
await game.classicMode.startBattle([ Species.MILOTIC ]);
vi.spyOn(allMoves[Moves.METRONOME].getAttrs(RandomMoveAttr)[0], "getMoveOverride").mockReturnValue(Moves.MOONGEIST_BEAM);
game.move.select(Moves.METRONOME);
await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.getEnemyPokemon()!.isFainted()).toBe(false);
expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].move).toBe(Moves.MOONGEIST_BEAM);
});
});

View File

@ -0,0 +1,77 @@
import { Biome } from "#enums/biome";
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, vi } from "vitest";
import { achvs } from "#app/system/achv";
import { Unlockables } from "#app/system/unlockables";
describe("Game Over Phase", () => {
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.MEMENTO, Moves.ICE_BEAM, Moves.SPLASH ])
.ability(Abilities.BALL_FETCH)
.battleType("single")
.disableCrits()
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH)
.startingWave(200)
.startingBiome(Biome.END)
.startingLevel(10000);
});
it("winning a run should give rewards", async () => {
await game.classicMode.startBattle([ Species.BULBASAUR ]);
vi.spyOn(game.scene, "validateAchv");
// Note: `game.doKillOpponents()` does not properly handle final boss
// Final boss phase 1
game.move.select(Moves.ICE_BEAM);
await game.toNextTurn();
// Final boss phase 2
game.move.select(Moves.ICE_BEAM);
await game.phaseInterceptor.to("PostGameOverPhase", false);
// The game refused to actually give the vouchers during tests,
// so the best we can do is to check that their reward phases occurred.
expect(game.phaseInterceptor.log.includes("GameOverPhase")).toBe(true);
expect(game.phaseInterceptor.log.includes("UnlockPhase")).toBe(true);
expect(game.phaseInterceptor.log.includes("RibbonModifierRewardPhase")).toBe(true);
expect(game.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]).toBe(true);
expect(game.scene.validateAchv).toHaveBeenCalledWith(achvs.CLASSIC_VICTORY);
expect(game.scene.gameData.achvUnlocks[achvs.CLASSIC_VICTORY.id]).toBeTruthy();
});
it("losing a run should not give rewards", async () => {
await game.classicMode.startBattle([ Species.BULBASAUR ]);
vi.spyOn(game.scene, "validateAchv");
game.move.select(Moves.MEMENTO);
await game.phaseInterceptor.to("PostGameOverPhase", false);
expect(game.phaseInterceptor.log.includes("GameOverPhase")).toBe(true);
expect(game.phaseInterceptor.log.includes("UnlockPhase")).toBe(false);
expect(game.phaseInterceptor.log.includes("RibbonModifierRewardPhase")).toBe(false);
expect(game.phaseInterceptor.log.includes("GameOverModifierRewardPhase")).toBe(false);
expect(game.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]).toBe(false);
expect(game.scene.validateAchv).not.toHaveBeenCalledWith(achvs.CLASSIC_VICTORY);
expect(game.scene.gameData.achvUnlocks[achvs.CLASSIC_VICTORY.id]).toBeFalsy();
});
});

View File

@ -28,7 +28,8 @@ describe("Pokerogue Session Savedata API", () => {
describe("Newclear", () => { describe("Newclear", () => {
const params: NewClearSessionSavedataRequest = { const params: NewClearSessionSavedataRequest = {
clientSessionId: "test-session-id", clientSessionId: "test-session-id",
slot: 3, isVictory: true,
slot: 3
}; };
it("should return true on SUCCESS", async () => { it("should return true on SUCCESS", async () => {

View File

@ -4,7 +4,7 @@ import { Abilities } from "#app/enums/abilities";
import * as GameMode from "#app/game-mode"; import * as GameMode from "#app/game-mode";
import { GameModes, getGameMode } from "#app/game-mode"; import { GameModes, getGameMode } from "#app/game-mode";
import { ModifierOverride } from "#app/modifier/modifier-type"; import { ModifierOverride } from "#app/modifier/modifier-type";
import Overrides from "#app/overrides"; import Overrides, { BattleStyle } from "#app/overrides";
import { Unlockables } from "#app/system/unlockables"; import { Unlockables } from "#app/system/unlockables";
import { Biome } from "#enums/biome"; import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -238,13 +238,14 @@ export class OverridesHelper extends GameManagerHelper {
} }
/** /**
* Override the battle type (single or double) * Override the battle type (e.g., single or double).
* @see {@linkcode Overrides.BATTLE_TYPE_OVERRIDE}
* @param battleType battle type to set * @param battleType battle type to set
* @returns `this` * @returns `this`
*/ */
public battleType(battleType: "single" | "double" | null): this { public battleType(battleType: BattleStyle | null): this {
vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue(battleType); vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue(battleType);
this.log(`Battle type set to ${battleType} only!`); this.log(battleType === null ? "Battle type override disabled!" : `Battle type set to ${battleType}!`);
return this; return this;
} }

View File

@ -55,6 +55,11 @@ import {
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase"; import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
import { PartyExpPhase } from "#app/phases/party-exp-phase"; import { PartyExpPhase } from "#app/phases/party-exp-phase";
import { ExpPhase } from "#app/phases/exp-phase"; import { ExpPhase } from "#app/phases/exp-phase";
import { GameOverPhase } from "#app/phases/game-over-phase";
import { RibbonModifierRewardPhase } from "#app/phases/ribbon-modifier-reward-phase";
import { GameOverModifierRewardPhase } from "#app/phases/game-over-modifier-reward-phase";
import { UnlockPhase } from "#app/phases/unlock-phase";
import { PostGameOverPhase } from "#app/phases/post-game-over-phase";
export interface PromptHandler { export interface PromptHandler {
phaseTarget?: string; phaseTarget?: string;
@ -113,10 +118,15 @@ type PhaseClass =
| typeof MysteryEncounterBattlePhase | typeof MysteryEncounterBattlePhase
| typeof MysteryEncounterRewardsPhase | typeof MysteryEncounterRewardsPhase
| typeof PostMysteryEncounterPhase | typeof PostMysteryEncounterPhase
| typeof RibbonModifierRewardPhase
| typeof GameOverModifierRewardPhase
| typeof ModifierRewardPhase | typeof ModifierRewardPhase
| typeof PartyExpPhase | typeof PartyExpPhase
| typeof ExpPhase | typeof ExpPhase
| typeof EncounterPhase; | typeof EncounterPhase
| typeof GameOverPhase
| typeof UnlockPhase
| typeof PostGameOverPhase;
type PhaseString = type PhaseString =
| "LoginPhase" | "LoginPhase"
@ -167,10 +177,15 @@ type PhaseString =
| "MysteryEncounterBattlePhase" | "MysteryEncounterBattlePhase"
| "MysteryEncounterRewardsPhase" | "MysteryEncounterRewardsPhase"
| "PostMysteryEncounterPhase" | "PostMysteryEncounterPhase"
| "RibbonModifierRewardPhase"
| "GameOverModifierRewardPhase"
| "ModifierRewardPhase" | "ModifierRewardPhase"
| "PartyExpPhase" | "PartyExpPhase"
| "ExpPhase" | "ExpPhase"
| "EncounterPhase"; | "EncounterPhase"
| "GameOverPhase"
| "UnlockPhase"
| "PostGameOverPhase";
type PhaseInterceptorPhase = PhaseClass | PhaseString; type PhaseInterceptorPhase = PhaseClass | PhaseString;
@ -245,10 +260,15 @@ export default class PhaseInterceptor {
[ MysteryEncounterBattlePhase, this.startPhase ], [ MysteryEncounterBattlePhase, this.startPhase ],
[ MysteryEncounterRewardsPhase, this.startPhase ], [ MysteryEncounterRewardsPhase, this.startPhase ],
[ PostMysteryEncounterPhase, this.startPhase ], [ PostMysteryEncounterPhase, this.startPhase ],
[ RibbonModifierRewardPhase, this.startPhase ],
[ GameOverModifierRewardPhase, this.startPhase ],
[ ModifierRewardPhase, this.startPhase ], [ ModifierRewardPhase, this.startPhase ],
[ PartyExpPhase, this.startPhase ], [ PartyExpPhase, this.startPhase ],
[ ExpPhase, this.startPhase ], [ ExpPhase, this.startPhase ],
[ EncounterPhase, this.startPhase ], [ EncounterPhase, this.startPhase ],
[ GameOverPhase, this.startPhase ],
[ UnlockPhase, this.startPhase ],
[ PostGameOverPhase, this.startPhase ],
]; ];
private endBySetMode = [ private endBySetMode = [

View File

@ -13,9 +13,11 @@ import { SubstituteTag } from "#app/data/battler-tags";
export type TargetSelectCallback = (targets: BattlerIndex[]) => void; export type TargetSelectCallback = (targets: BattlerIndex[]) => void;
export default class TargetSelectUiHandler extends UiHandler { export default class TargetSelectUiHandler extends UiHandler {
private fieldIndex: integer; private fieldIndex: number;
private move: Moves; private move: Moves;
private targetSelectCallback: TargetSelectCallback; private targetSelectCallback: TargetSelectCallback;
private cursor0: number; // associated with BattlerIndex.PLAYER
private cursor1: number; // associated with BattlerIndex.PLAYER_2
private isMultipleTargets: boolean = false; private isMultipleTargets: boolean = false;
private targets: BattlerIndex[]; private targets: BattlerIndex[];
@ -42,8 +44,9 @@ export default class TargetSelectUiHandler extends UiHandler {
this.fieldIndex = args[0] as integer; this.fieldIndex = args[0] as integer;
this.move = args[1] as Moves; this.move = args[1] as Moves;
this.targetSelectCallback = args[2] as TargetSelectCallback; this.targetSelectCallback = args[2] as TargetSelectCallback;
const user = this.scene.getPlayerField()[this.fieldIndex];
const moveTargets = getMoveTargets(this.scene.getPlayerField()[this.fieldIndex], this.move); const moveTargets = getMoveTargets(user, this.move);
this.targets = moveTargets.targets; this.targets = moveTargets.targets;
this.isMultipleTargets = moveTargets.multiple ?? false; this.isMultipleTargets = moveTargets.multiple ?? false;
@ -53,11 +56,29 @@ export default class TargetSelectUiHandler extends UiHandler {
this.enemyModifiers = this.scene.getModifierBar(true); this.enemyModifiers = this.scene.getModifierBar(true);
this.setCursor(this.targets.includes(this.cursor) ? this.cursor : this.targets[0]); if (this.fieldIndex === BattlerIndex.PLAYER) {
this.resetCursor(this.cursor0, user);
} else if (this.fieldIndex === BattlerIndex.PLAYER_2) {
this.resetCursor(this.cursor1, user);
}
return true; return true;
} }
/**
* Determines what value to assign the main cursor based on the previous turn's target or the user's status
* @param cursorN the cursor associated with the user's field index
* @param user the Pokemon using the move
*/
resetCursor(cursorN: number, user: Pokemon): void {
if (!Utils.isNullOrUndefined(cursorN)) {
if ([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ].includes(cursorN) || user.battleSummonData.waveTurnCount === 1) {
// Reset cursor on the first turn of a fight or if an ally was targeted last turn
cursorN = -1;
}
}
this.setCursor(this.targets.includes(cursorN) ? cursorN : this.targets[0]);
}
processInput(button: Button): boolean { processInput(button: Button): boolean {
const ui = this.getUi(); const ui = this.getUi();
@ -67,6 +88,15 @@ export default class TargetSelectUiHandler extends UiHandler {
const targetIndexes: BattlerIndex[] = this.isMultipleTargets ? this.targets : [ this.cursor ]; const targetIndexes: BattlerIndex[] = this.isMultipleTargets ? this.targets : [ this.cursor ];
this.targetSelectCallback(button === Button.ACTION ? targetIndexes : []); this.targetSelectCallback(button === Button.ACTION ? targetIndexes : []);
success = true; success = true;
if (this.fieldIndex === BattlerIndex.PLAYER) {
if (Utils.isNullOrUndefined(this.cursor0) || this.cursor0 !== this.cursor) {
this.cursor0 = this.cursor;
}
} else if (this.fieldIndex === BattlerIndex.PLAYER_2) {
if (Utils.isNullOrUndefined(this.cursor1) || this.cursor1 !== this.cursor) {
this.cursor1 = this.cursor;
}
}
} else if (this.isMultipleTargets) { } else if (this.isMultipleTargets) {
success = false; success = false;
} else { } else {
@ -152,7 +182,6 @@ export default class TargetSelectUiHandler extends UiHandler {
yoyo: true yoyo: true
})); }));
}); });
return ret; return ret;
} }
@ -184,7 +213,6 @@ export default class TargetSelectUiHandler extends UiHandler {
} }
clear() { clear() {
this.cursor = -1;
super.clear(); super.clear();
this.eraseCursor(); this.eraseCursor();
} }