Merge branch 'beta' into betterTargetSelect

This commit is contained in:
Moka 2024-11-14 20:56:04 +01:00 committed by GitHub
commit 04985fc6e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 666 additions and 240 deletions

@ -1 +1 @@
Subproject commit d600913dbf1f8b47dae8dccbd8296df78f1c51b5 Subproject commit 5775faa6b3184082df73f6cdb96b253ea7dae3fe

View File

@ -1233,12 +1233,34 @@ export default class BattleScene extends SceneBase {
newDouble = !!double; newDouble = !!double;
} }
if (Overrides.BATTLE_TYPE_OVERRIDE === "double") { if (!isNullOrUndefined(Overrides.BATTLE_TYPE_OVERRIDE)) {
newDouble = true; let doubleOverrideForWave: "single" | "double" | null = null;
}
/* Override battles into single only if not fighting with trainers */ switch (Overrides.BATTLE_TYPE_OVERRIDE) {
if (newBattleType !== BattleType.TRAINER && Overrides.BATTLE_TYPE_OVERRIDE === "single") { case "double":
newDouble = false; 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;

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";
@ -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;
} }

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 {
@ -4934,16 +4971,42 @@ export class NeutralDamageAgainstFlyingTypeMultiplierAttr extends VariableMoveTy
} }
} }
export class WaterSuperEffectTypeMultiplierAttr extends VariableMoveTypeMultiplierAttr { /**
* This class forces Freeze-Dry to be super effective against Water Type.
* It considers if target is Mono or Dual Type and calculates the new Multiplier accordingly.
* @see {@linkcode apply}
*/
export class FreezeDryAttr extends VariableMoveTypeMultiplierAttr {
/**
* If the target is Mono Type (Water only) then a 2x Multiplier is always forced.
* If target is Dual Type (containing Water) then only a 2x Multiplier is forced for the Water Type.
*
* Additionally Freeze-Dry's effectiveness against water is always forced during {@linkcode InverseBattleChallenge}.
* The multiplier is recalculated for the non-Water Type in case of Dual Type targets containing Water Type.
*
* @param user The {@linkcode Pokemon} applying the move
* @param target The {@linkcode Pokemon} targeted by the move
* @param move The move used by the user
* @param args `[0]` a {@linkcode Utils.NumberHolder | NumberHolder} containing a type effectiveness multiplier
* @returns `true` if super effectiveness on water type is forced; `false` otherwise
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const multiplier = args[0] as Utils.NumberHolder; const multiplier = args[0] as Utils.NumberHolder;
if (target.isOfType(Type.WATER)) { if (target.isOfType(Type.WATER) && multiplier.value !== 0) {
const effectivenessAgainstWater = new Utils.NumberHolder(getTypeDamageMultiplier(move.type, Type.WATER)); const multipleTypes = (target.getTypes().length > 1);
applyChallenges(user.scene.gameMode, ChallengeType.TYPE_EFFECTIVENESS, effectivenessAgainstWater);
if (effectivenessAgainstWater.value !== 0) { if (multipleTypes) {
multiplier.value *= 2 / effectivenessAgainstWater.value; const nonWaterType = target.getTypes().filter(type => type !== Type.WATER)[0];
const effectivenessAgainstTarget = new Utils.NumberHolder(getTypeDamageMultiplier(user.getMoveType(move), nonWaterType));
applyChallenges(user.scene.gameMode, ChallengeType.TYPE_EFFECTIVENESS, effectivenessAgainstTarget);
multiplier.value = effectivenessAgainstTarget.value * 2;
return true; return true;
} }
multiplier.value = 2;
return true;
} }
return false; return false;
@ -9385,7 +9448,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. .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()

View File

@ -2642,10 +2642,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 */
@ -2722,7 +2723,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

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;
} }
} }

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

@ -125,10 +125,9 @@ export class GameOverPhase extends BattlePhase {
} }
const clear = (endCardPhase?: EndCardPhase) => { const clear = (endCardPhase?: EndCardPhase) => {
if (newClear) {
this.handleUnlocks();
}
if (this.isVictory && newClear) { if (this.isVictory && newClear) {
this.handleUnlocks();
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));
} }
@ -183,6 +182,8 @@ export class GameOverPhase extends BattlePhase {
this.scene.gameData.offlineNewClear(this.scene).then(result => { this.scene.gameData.offlineNewClear(this.scene).then(result => {
doGameOver(result); doGameOver(result);
}); });
} else {
doGameOver(false);
} }
} }

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

@ -378,10 +378,8 @@ export class MovePhase extends BattlePhase {
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 });
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) { this.showMoveText();
this.showMoveText(); this.showFailedText(failureMessage ?? undefined);
this.showFailedText(failureMessage);
}
// 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

@ -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

@ -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

@ -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,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

@ -2,6 +2,7 @@ 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 { 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";
@ -97,8 +98,7 @@ 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 2x damage to water type under Normalize", async () => {
it.todo("should deal 2x damage to water types under Normalize", async () => {
game.override.ability(Abilities.NORMALIZE); game.override.ability(Abilities.NORMALIZE);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
@ -112,8 +112,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 +157,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,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

@ -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 = [