Merge branch 'beta' into 'me-shiny-fixes'
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 464 B |
After Width: | Height: | Size: 267 B |
After Width: | Height: | Size: 268 B |
After Width: | Height: | Size: 373 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 493 B |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 524 B |
After Width: | Height: | Size: 530 B |
|
@ -1647,6 +1647,27 @@
|
|||
"h": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "85-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 5,
|
||||
"y": 3,
|
||||
"w": 29,
|
||||
"h": 25
|
||||
},
|
||||
"frame": {
|
||||
"x": 55,
|
||||
"y": 270,
|
||||
"w": 29,
|
||||
"h": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "22s",
|
||||
"rotated": false,
|
||||
|
@ -1731,6 +1752,27 @@
|
|||
"h": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "85s-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 5,
|
||||
"y": 3,
|
||||
"w": 29,
|
||||
"h": 25
|
||||
},
|
||||
"frame": {
|
||||
"x": 56,
|
||||
"y": 317,
|
||||
"w": 29,
|
||||
"h": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "9s",
|
||||
"rotated": false,
|
||||
|
@ -6456,6 +6498,27 @@
|
|||
"h": 18
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "84-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 9,
|
||||
"y": 10,
|
||||
"w": 21,
|
||||
"h": 18
|
||||
},
|
||||
"frame": {
|
||||
"x": 98,
|
||||
"y": 712,
|
||||
"w": 21,
|
||||
"h": 18
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "107",
|
||||
"rotated": false,
|
||||
|
@ -6519,6 +6582,27 @@
|
|||
"h": 18
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "84s-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 9,
|
||||
"y": 10,
|
||||
"w": 21,
|
||||
"h": 18
|
||||
},
|
||||
"frame": {
|
||||
"x": 96,
|
||||
"y": 770,
|
||||
"w": 21,
|
||||
"h": 18
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "88",
|
||||
"rotated": false,
|
||||
|
|
|
@ -786,6 +786,27 @@
|
|||
"h": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "154-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 8,
|
||||
"y": 1,
|
||||
"w": 23,
|
||||
"h": 27
|
||||
},
|
||||
"frame": {
|
||||
"x": 29,
|
||||
"y": 147,
|
||||
"w": 23,
|
||||
"h": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "154s",
|
||||
"rotated": false,
|
||||
|
@ -807,6 +828,27 @@
|
|||
"h": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "154s-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 8,
|
||||
"y": 1,
|
||||
"w": 23,
|
||||
"h": 27
|
||||
},
|
||||
"frame": {
|
||||
"x": 29,
|
||||
"y": 174,
|
||||
"w": 23,
|
||||
"h": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "229-mega",
|
||||
"rotated": false,
|
||||
|
|
|
@ -198,6 +198,27 @@
|
|||
"h": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "257-f-mega",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 4,
|
||||
"y": 2,
|
||||
"w": 32,
|
||||
"h": 27
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 79,
|
||||
"w": 32,
|
||||
"h": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "257s-mega",
|
||||
"rotated": false,
|
||||
|
@ -219,6 +240,27 @@
|
|||
"h": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "257s-f-mega",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 4,
|
||||
"y": 2,
|
||||
"w": 32,
|
||||
"h": 27
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 106,
|
||||
"w": 32,
|
||||
"h": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "323-mega",
|
||||
"rotated": false,
|
||||
|
@ -1248,6 +1290,27 @@
|
|||
"h": 26
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "257-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 7,
|
||||
"y": 2,
|
||||
"w": 25,
|
||||
"h": 26
|
||||
},
|
||||
"frame": {
|
||||
"x": 28,
|
||||
"y": 556,
|
||||
"w": 25,
|
||||
"h": 26
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "257s",
|
||||
"rotated": false,
|
||||
|
@ -1269,6 +1332,27 @@
|
|||
"h": 26
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "257s-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 7,
|
||||
"y": 2,
|
||||
"w": 25,
|
||||
"h": 26
|
||||
},
|
||||
"frame": {
|
||||
"x": 28,
|
||||
"y": 582,
|
||||
"w": 25,
|
||||
"h": 26
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "359-mega",
|
||||
"rotated": false,
|
||||
|
@ -1605,6 +1689,27 @@
|
|||
"h": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "256-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 8,
|
||||
"y": 3,
|
||||
"w": 23,
|
||||
"h": 25
|
||||
},
|
||||
"frame": {
|
||||
"x": 98,
|
||||
"y": 72,
|
||||
"w": 23,
|
||||
"h": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "282s-mega",
|
||||
"rotated": false,
|
||||
|
@ -5553,6 +5658,27 @@
|
|||
"h": 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "255-f",
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"sourceSize": {
|
||||
"w": 40,
|
||||
"h": 30
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 13,
|
||||
"y": 9,
|
||||
"w": 13,
|
||||
"h": 19
|
||||
},
|
||||
"frame": {
|
||||
"x": 204,
|
||||
"y": 342,
|
||||
"w": 13,
|
||||
"h": 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "307s",
|
||||
"rotated": false,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d600913dbf1f8b47dae8dccbd8296df78f1c51b5
|
||||
Subproject commit 5775faa6b3184082df73f6cdb96b253ea7dae3fe
|
|
@ -8,6 +8,7 @@ export class UpdateSessionSavedataRequest {
|
|||
/** This is **NOT** similar to {@linkcode ClearSessionSavedataRequest} */
|
||||
export interface NewClearSessionSavedataRequest {
|
||||
slot: number;
|
||||
isVictory: boolean;
|
||||
clientSessionId: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -2599,14 +2599,15 @@ export default class BattleScene extends SceneBase {
|
|||
* The quantity to transfer is automatically capped at how much the recepient can take before reaching the maximum stack size for the item.
|
||||
* A transfer that moves a quantity smaller than what is specified in the transferQuantity parameter is still considered successful.
|
||||
* @param itemModifier {@linkcode PokemonHeldItemModifier} item to transfer (represents the whole stack)
|
||||
* @param target {@linkcode Pokemon} pokemon recepient in this transfer
|
||||
* @param playSound {boolean}
|
||||
* @param transferQuantity {@linkcode integer} how many items of the stack to transfer. Optional, defaults to 1
|
||||
* @param instant {boolean}
|
||||
* @param ignoreUpdate {boolean}
|
||||
* @returns true if the transfer was successful
|
||||
* @param target {@linkcode Pokemon} recepient in this transfer
|
||||
* @param playSound `true` to play a sound when transferring the item
|
||||
* @param transferQuantity How many items of the stack to transfer. Optional, defaults to `1`
|
||||
* @param instant ??? (Optional)
|
||||
* @param ignoreUpdate ??? (Optional)
|
||||
* @param itemLost If `true`, treat the item's current holder as losing the item (for now, this simply enables Unburden). Default is `true`.
|
||||
* @returns `true` if the transfer was successful
|
||||
*/
|
||||
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, transferQuantity: integer = 1, instant?: boolean, ignoreUpdate?: boolean): Promise<boolean> {
|
||||
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, transferQuantity: number = 1, instant?: boolean, ignoreUpdate?: boolean, itemLost: boolean = true): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
const source = itemModifier.pokemonId ? itemModifier.getPokemon(target.scene) : null;
|
||||
const cancelled = new Utils.BooleanHolder(false);
|
||||
|
@ -2639,14 +2640,14 @@ export default class BattleScene extends SceneBase {
|
|||
if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) {
|
||||
if (target.isPlayer()) {
|
||||
this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => {
|
||||
if (source) {
|
||||
if (source && itemLost) {
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
|
||||
}
|
||||
resolve(true);
|
||||
});
|
||||
} else {
|
||||
this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => {
|
||||
if (source) {
|
||||
if (source && itemLost) {
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
|
||||
}
|
||||
resolve(true);
|
||||
|
@ -2818,7 +2819,15 @@ export default class BattleScene extends SceneBase {
|
|||
});
|
||||
}
|
||||
|
||||
removeModifier(modifier: PersistentModifier, enemy?: boolean): boolean {
|
||||
/**
|
||||
* Removes a currently owned item. If the item is stacked, the entire item stack
|
||||
* gets removed. This function does NOT apply in-battle effects, such as Unburden.
|
||||
* If in-battle effects are needed, use {@linkcode Pokemon.loseHeldItem} instead.
|
||||
* @param modifier The item to be removed.
|
||||
* @param enemy If `true`, remove an item owned by the enemy. If `false`, remove an item owned by the player. Default is `false`.
|
||||
* @returns `true` if the item exists and was successfully removed, `false` otherwise.
|
||||
*/
|
||||
removeModifier(modifier: PersistentModifier, enemy: boolean = false): boolean {
|
||||
const modifiers = !enemy ? this.modifiers : this.enemyModifiers;
|
||||
const modifierIndex = modifiers.indexOf(modifier);
|
||||
if (modifierIndex > -1) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Weather } from "#app/data/weather";
|
|||
import { BattlerTag, BattlerTagLapseType, GroundedTag } from "./battler-tags";
|
||||
import { getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "#app/data/status-effect";
|
||||
import { Gender } from "./gender";
|
||||
import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, 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 { BerryModifier, HitHealModifier, PokemonHeldItemModifier } from "../modifier/modifier";
|
||||
import { TerrainType } from "./terrain";
|
||||
|
@ -1351,65 +1351,30 @@ export class AddSecondStrikeAbAttr extends PreAttackAbAttr {
|
|||
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])
|
||||
* 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 defender n/a
|
||||
* @param {Move} move the move used by the ability source
|
||||
* @param args\[0\] the number of Pokemon this move is targeting
|
||||
* @param {Utils.IntegerHolder} args\[1\] the number of strikes with this move
|
||||
* @param {Utils.NumberHolder} args\[2\] the damage multiplier for the current strike
|
||||
* @param move the {@linkcode Move} used by the ability source
|
||||
* @param args Additional arguments:
|
||||
* - `[0]` the number of strikes this move currently has ({@linkcode Utils.NumberHolder})
|
||||
* - `[1]` the damage multiplier for the current strike ({@linkcode Utils.NumberHolder})
|
||||
* @returns
|
||||
*/
|
||||
applyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean {
|
||||
const numTargets = args[0] as integer;
|
||||
const hitCount = args[1] as Utils.IntegerHolder;
|
||||
const multiplier = args[2] as Utils.NumberHolder;
|
||||
const hitCount = args[0] as Utils.NumberHolder;
|
||||
const multiplier = args[1] as Utils.NumberHolder;
|
||||
|
||||
if (this.canApplyPreAttack(move, numTargets)) {
|
||||
if (move.canBeMultiStrikeEnhanced(pokemon, true)) {
|
||||
this.showAbility = !!hitCount?.value;
|
||||
if (!!hitCount?.value) {
|
||||
hitCount.value *= 2;
|
||||
if (hitCount?.value) {
|
||||
hitCount.value += 1;
|
||||
}
|
||||
|
||||
if (!!multiplier?.value && pokemon.turnData.hitsLeft % 2 === 1 && pokemon.turnData.hitsLeft !== pokemon.turnData.hitCount) {
|
||||
multiplier.value *= this.damageMultiplier;
|
||||
if (multiplier?.value && pokemon.turnData.hitsLeft === 1) {
|
||||
multiplier.value = this.damageMultiplier;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2463,12 +2428,15 @@ export class PostSummonCopyAllyStatsAbAttr extends PostSummonAbAttr {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by Imposter
|
||||
*/
|
||||
export class PostSummonTransformAbAttr extends PostSummonAbAttr {
|
||||
constructor() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
async applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): Promise<boolean> {
|
||||
async applyPostSummon(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): Promise<boolean> {
|
||||
const targets = pokemon.getOpponents();
|
||||
if (simulated || !targets.length) {
|
||||
return simulated;
|
||||
|
@ -2477,17 +2445,31 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
|
|||
|
||||
let target: Pokemon;
|
||||
if (targets.length > 1) {
|
||||
pokemon.scene.executeWithSeedOffset(() => target = Utils.randSeedItem(targets), pokemon.scene.currentBattle.waveIndex);
|
||||
pokemon.scene.executeWithSeedOffset(() => {
|
||||
// in a double battle, if one of the opposing pokemon is fused the other one will be chosen
|
||||
// if both are fused, then Imposter will fail below
|
||||
if (targets[0].fusionSpecies) {
|
||||
target = targets[1];
|
||||
return;
|
||||
} else if (targets[1].fusionSpecies) {
|
||||
target = targets[0];
|
||||
return;
|
||||
}
|
||||
target = Utils.randSeedItem(targets);
|
||||
}, pokemon.scene.currentBattle.waveIndex);
|
||||
} else {
|
||||
target = targets[0];
|
||||
}
|
||||
|
||||
target = target!;
|
||||
|
||||
// transforming from or into fusion pokemon causes various problems (including crashes and save corruption)
|
||||
if (target.fusionSpecies || pokemon.fusionSpecies) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pokemon.summonData.speciesForm = target.getSpeciesForm();
|
||||
pokemon.summonData.fusionSpeciesForm = target.getFusionSpeciesForm();
|
||||
pokemon.summonData.ability = target.getAbility().id;
|
||||
pokemon.summonData.gender = target.getGender();
|
||||
pokemon.summonData.fusionGender = target.getFusionGender();
|
||||
|
||||
// Copy all stats (except HP)
|
||||
for (const s of EFFECTIVE_STATS) {
|
||||
|
@ -4135,7 +4117,7 @@ export class PostBattleLootAbAttr extends PostBattleAbAttr {
|
|||
if (!simulated && postBattleLoot.length) {
|
||||
const randItem = Utils.randSeedItem(postBattleLoot);
|
||||
//@ts-ignore - TODO see below
|
||||
if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true)) { // TODO: fix. This is a promise!?
|
||||
if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true, undefined, false)) { // TODO: fix. This is a promise!?
|
||||
postBattleLoot.splice(postBattleLoot.indexOf(randItem), 1);
|
||||
pokemon.scene.queueMessage(i18next.t("abilityTriggers:postBattleLoot", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), itemName: randItem.type.name }));
|
||||
return true;
|
||||
|
@ -5599,7 +5581,9 @@ export function initAbilities() {
|
|||
new Ability(Abilities.ANGER_POINT, 4)
|
||||
.attr(PostDefendCritStatStageChangeAbAttr, Stat.ATK, 6),
|
||||
new Ability(Abilities.UNBURDEN, 4)
|
||||
.attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN),
|
||||
.attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN)
|
||||
.bypassFaint() // Allows reviver seed to activate Unburden
|
||||
.edgeCase(), // Should not restore Unburden boost if Pokemon loses then regains Unburden ability
|
||||
new Ability(Abilities.HEATPROOF, 4)
|
||||
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
|
||||
.attr(ReduceBurnDamageAbAttr, 0.5)
|
||||
|
|
|
@ -61,13 +61,13 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate {
|
|||
}
|
||||
}
|
||||
|
||||
export type BerryEffectFunc = (pokemon: Pokemon) => void;
|
||||
export type BerryEffectFunc = (pokemon: Pokemon, berryOwner?: Pokemon) => void;
|
||||
|
||||
export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
switch (berryType) {
|
||||
case BerryType.SITRUS:
|
||||
case BerryType.ENIGMA:
|
||||
return (pokemon: Pokemon) => {
|
||||
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||
if (pokemon.battleData) {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
|
@ -75,10 +75,10 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, hpHealed);
|
||||
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(),
|
||||
hpHealed.value, i18next.t("battle:hpHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), berryName: getBerryName(berryType) }), true));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||
};
|
||||
case BerryType.LUM:
|
||||
return (pokemon: Pokemon) => {
|
||||
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||
if (pokemon.battleData) {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
|
@ -87,14 +87,14 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||
}
|
||||
pokemon.resetStatus(true, true);
|
||||
pokemon.updateInfo();
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||
};
|
||||
case BerryType.LIECHI:
|
||||
case BerryType.GANLON:
|
||||
case BerryType.PETAYA:
|
||||
case BerryType.APICOT:
|
||||
case BerryType.SALAC:
|
||||
return (pokemon: Pokemon) => {
|
||||
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||
if (pokemon.battleData) {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
|
@ -103,18 +103,18 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||
const statStages = new Utils.NumberHolder(1);
|
||||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, statStages);
|
||||
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], statStages.value));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||
};
|
||||
case BerryType.LANSAT:
|
||||
return (pokemon: Pokemon) => {
|
||||
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||
if (pokemon.battleData) {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
pokemon.addTag(BattlerTagType.CRIT_BOOST);
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||
};
|
||||
case BerryType.STARF:
|
||||
return (pokemon: Pokemon) => {
|
||||
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||
if (pokemon.battleData) {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
|
@ -122,10 +122,10 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||
const stages = new Utils.NumberHolder(2);
|
||||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, stages);
|
||||
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ randStat ], stages.value));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||
};
|
||||
case BerryType.LEPPA:
|
||||
return (pokemon: Pokemon) => {
|
||||
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||
if (pokemon.battleData) {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||
if (ppRestoreMove !== undefined) {
|
||||
ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0);
|
||||
pokemon.scene.queueMessage(i18next.t("battle:ppHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: ppRestoreMove!.getName(), berryName: getBerryName(berryType) }));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -653,7 +653,7 @@ export class FreshStartChallenge extends Challenge {
|
|||
pokemon.shiny = false; // Not shiny
|
||||
pokemon.variant = 0; // Not shiny
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
120
src/data/move.ts
|
@ -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 target {@linkcode Pokemon} receiving the move
|
||||
* @param move {@linkcode Move} using the move
|
||||
* @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 {
|
||||
for (const attr of this.attrs) {
|
||||
|
@ -818,8 +818,6 @@ export default class Move implements Localizable {
|
|||
|
||||
applyMoveAttrs(VariablePowerAttr, source, target, this, power);
|
||||
|
||||
source.scene.applyModifiers(PokemonMultiHitModifier, source.isPlayer(), source, new Utils.IntegerHolder(0), power);
|
||||
|
||||
if (!this.hasAttr(TypelessAttr)) {
|
||||
source.scene.arena.applyTags(WeakenMoveTypeTag, simulated, 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
@ -2417,9 +2454,8 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
|
|||
const removedItem = heldItems[user.randSeedInt(heldItems.length)];
|
||||
|
||||
// Decrease item amount and update icon
|
||||
!--removedItem.stackCount;
|
||||
target.loseHeldItem(removedItem);
|
||||
target.scene.updateModifiers(target.isPlayer());
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, target, false);
|
||||
|
||||
|
||||
if (this.berriesOnly) {
|
||||
|
@ -2489,18 +2525,15 @@ export class EatBerryAttr extends MoveEffectAttr {
|
|||
}
|
||||
|
||||
reduceBerryModifier(target: Pokemon) {
|
||||
if (this.chosenBerry?.stackCount === 1) {
|
||||
target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
|
||||
} else if (this.chosenBerry !== undefined && this.chosenBerry.stackCount > 1) {
|
||||
this.chosenBerry.stackCount--;
|
||||
if (this.chosenBerry) {
|
||||
target.loseHeldItem(this.chosenBerry);
|
||||
}
|
||||
target.scene.updateModifiers(target.isPlayer());
|
||||
}
|
||||
|
||||
eatBerry(consumer: Pokemon) {
|
||||
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer); // consumer eats the berry
|
||||
eatBerry(consumer: Pokemon, berryOwner?: Pokemon) {
|
||||
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer, berryOwner); // consumer eats the berry
|
||||
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new Utils.BooleanHolder(false));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, consumer, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 });
|
||||
user.scene.queueMessage(message);
|
||||
this.reduceBerryModifier(target);
|
||||
this.eatBerry(user);
|
||||
this.eatBerry(user, target);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -4938,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 {
|
||||
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;
|
||||
if (target.isOfType(Type.WATER) && multiplier.value !== 0) {
|
||||
const multipleTypes = (target.getTypes().length > 1);
|
||||
|
||||
if (multipleTypes) {
|
||||
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;
|
||||
}
|
||||
|
||||
multiplier.value = 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -6995,6 +7054,9 @@ export class SuppressAbilitiesIfActedAttr extends MoveEffectAttr {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by Transform
|
||||
*/
|
||||
export class TransformAttr extends MoveEffectAttr {
|
||||
async apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||
if (!super.apply(user, target, move, args)) {
|
||||
|
@ -7003,10 +7065,8 @@ export class TransformAttr extends MoveEffectAttr {
|
|||
|
||||
const promises: Promise<void>[] = [];
|
||||
user.summonData.speciesForm = target.getSpeciesForm();
|
||||
user.summonData.fusionSpeciesForm = target.getFusionSpeciesForm();
|
||||
user.summonData.ability = target.getAbility().id;
|
||||
user.summonData.gender = target.getGender();
|
||||
user.summonData.fusionGender = target.getFusionGender();
|
||||
|
||||
// Power Trick's effect will not preserved after using Transform
|
||||
user.removeTag(BattlerTagType.POWER_TRICK);
|
||||
|
@ -8077,7 +8137,8 @@ export function initMoves() {
|
|||
.ignoresVirtual(),
|
||||
new StatusMove(Moves.TRANSFORM, Type.NORMAL, -1, 10, -1, 0, 1)
|
||||
.attr(TransformAttr)
|
||||
.condition((user, target, move) => !target.getTag(BattlerTagType.SUBSTITUTE))
|
||||
// transforming from or into fusion pokemon causes various problems (such as crashes)
|
||||
.condition((user, target, move) => !target.getTag(BattlerTagType.SUBSTITUTE) && !user.fusionSpecies && !target.fusionSpecies)
|
||||
.ignoresProtect(),
|
||||
new AttackMove(Moves.BUBBLE, Type.WATER, MoveCategory.SPECIAL, 40, 100, 30, 10, 0, 1)
|
||||
.attr(StatStageChangeAttr, [ Stat.SPD ], -1)
|
||||
|
@ -8482,7 +8543,8 @@ export function initMoves() {
|
|||
new StatusMove(Moves.HELPING_HAND, Type.NORMAL, -1, 20, -1, 5, 3)
|
||||
.attr(AddBattlerTagAttr, BattlerTagType.HELPING_HAND)
|
||||
.ignoresSubstitute()
|
||||
.target(MoveTarget.NEAR_ALLY),
|
||||
.target(MoveTarget.NEAR_ALLY)
|
||||
.condition(failIfSingleBattle),
|
||||
new StatusMove(Moves.TRICK, Type.PSYCHIC, 100, 10, -1, 0, 3)
|
||||
.unimplemented(),
|
||||
new StatusMove(Moves.ROLE_PLAY, Type.PSYCHIC, -1, 10, -1, 0, 3)
|
||||
|
@ -9174,6 +9236,7 @@ export function initMoves() {
|
|||
.target(MoveTarget.ALL_NEAR_ENEMIES)
|
||||
.attr(RemoveHeldItemAttr, true),
|
||||
new StatusMove(Moves.QUASH, Type.DARK, 100, 15, -1, 0, 5)
|
||||
.condition(failIfSingleBattle)
|
||||
.unimplemented(),
|
||||
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))),
|
||||
|
@ -9385,7 +9448,7 @@ export function initMoves() {
|
|||
.target(MoveTarget.ALL_NEAR_OTHERS),
|
||||
new AttackMove(Moves.FREEZE_DRY, Type.ICE, MoveCategory.SPECIAL, 70, 100, 20, 10, 0, 6)
|
||||
.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)
|
||||
.soundBased()
|
||||
|
@ -9461,6 +9524,7 @@ export function initMoves() {
|
|||
new StatusMove(Moves.AROMATIC_MIST, Type.FAIRY, -1, 20, -1, 0, 6)
|
||||
.attr(StatStageChangeAttr, [ Stat.SPDEF ], 1)
|
||||
.ignoresSubstitute()
|
||||
.condition(failIfSingleBattle)
|
||||
.target(MoveTarget.NEAR_ALLY),
|
||||
new StatusMove(Moves.EERIE_IMPULSE, Type.ELECTRIC, 100, 15, -1, 0, 6)
|
||||
.attr(StatStageChangeAttr, [ Stat.SPATK ], -2),
|
||||
|
@ -9689,7 +9753,8 @@ export function initMoves() {
|
|||
new AttackMove(Moves.LEAFAGE, Type.GRASS, MoveCategory.PHYSICAL, 40, 100, 40, -1, 0, 7)
|
||||
.makesContact(false),
|
||||
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)
|
||||
.attr(StatusEffectAttr, StatusEffect.POISON)
|
||||
.attr(StatStageChangeAttr, [ Stat.SPD ], -1),
|
||||
|
@ -10146,7 +10211,8 @@ export function initMoves() {
|
|||
.unimplemented(),
|
||||
new StatusMove(Moves.COACHING, Type.FIGHTING, -1, 10, -1, 0, 8)
|
||||
.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)
|
||||
.attr(ForceSwitchOutAttr, true),
|
||||
new AttackMove(Moves.TRIPLE_AXEL, Type.ICE, MoveCategory.PHYSICAL, 20, 90, 10, -1, 0, 8)
|
||||
|
|
|
@ -477,12 +477,9 @@ export const BugTypeSuperfanEncounter: MysteryEncounter =
|
|||
.withOptionPhase(async (scene: BattleScene) => {
|
||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
const modifier = encounter.misc.chosenModifier;
|
||||
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||
|
||||
// Remove the modifier if its stacks go to 0
|
||||
modifier.stackCount -= 1;
|
||||
if (modifier.stackCount === 0) {
|
||||
scene.removeModifier(modifier);
|
||||
}
|
||||
chosenPokemon.loseHeldItem(modifier, false);
|
||||
scene.updateModifiers(true, true);
|
||||
|
||||
const bugNet = generateModifierTypeOption(scene, modifierTypes.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET)!;
|
||||
|
|
|
@ -8,7 +8,7 @@ import { applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/u
|
|||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PreserveBerryModifier } from "#app/modifier/modifier";
|
||||
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PokemonInstantReviveModifier, PreserveBerryModifier } from "#app/modifier/modifier";
|
||||
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
||||
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
|
||||
import i18next from "#app/plugins/i18n";
|
||||
|
@ -197,7 +197,8 @@ export const DelibirdyEncounter: MysteryEncounter =
|
|||
})
|
||||
.withOptionPhase(async (scene: BattleScene) => {
|
||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
const modifier: BerryModifier | HealingBoosterModifier = encounter.misc.chosenModifier;
|
||||
const modifier: BerryModifier | PokemonInstantReviveModifier = encounter.misc.chosenModifier;
|
||||
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||
|
||||
// Give the player a Candy Jar if they gave a Berry, and a Berry Pouch for Reviver Seed
|
||||
if (modifier instanceof BerryModifier) {
|
||||
|
@ -228,11 +229,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
|||
}
|
||||
}
|
||||
|
||||
// Remove the modifier if its stacks go to 0
|
||||
modifier.stackCount -= 1;
|
||||
if (modifier.stackCount === 0) {
|
||||
scene.removeModifier(modifier);
|
||||
}
|
||||
chosenPokemon.loseHeldItem(modifier, false);
|
||||
|
||||
leaveEncounterWithoutBattle(scene, true);
|
||||
})
|
||||
|
@ -292,6 +289,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
|||
.withOptionPhase(async (scene: BattleScene) => {
|
||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
const modifier = encounter.misc.chosenModifier;
|
||||
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||
|
||||
// Check if the player has max stacks of Healing Charm already
|
||||
const existing = scene.findModifier(m => m instanceof HealingBoosterModifier) as HealingBoosterModifier;
|
||||
|
@ -306,11 +304,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
|||
scene.unshiftPhase(new ModifierRewardPhase(scene, modifierTypes.HEALING_CHARM));
|
||||
}
|
||||
|
||||
// Remove the modifier if its stacks go to 0
|
||||
modifier.stackCount -= 1;
|
||||
if (modifier.stackCount === 0) {
|
||||
scene.removeModifier(modifier);
|
||||
}
|
||||
chosenPokemon.loseHeldItem(modifier, false);
|
||||
|
||||
leaveEncounterWithoutBattle(scene, true);
|
||||
})
|
||||
|
|
|
@ -305,7 +305,7 @@ async function showWobbuffetHealthBar(scene: BattleScene) {
|
|||
scene.field.add(wobbuffet);
|
||||
|
||||
const playerPokemon = scene.getPlayerPokemon() as Pokemon;
|
||||
if (playerPokemon?.visible) {
|
||||
if (playerPokemon?.isOnField()) {
|
||||
scene.field.moveBelow(wobbuffet, playerPokemon);
|
||||
}
|
||||
// Show health bar and trigger cry
|
||||
|
|
|
@ -345,6 +345,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
|||
// Pokemon and item selected
|
||||
encounter.setDialogueToken("chosenItem", modifier.type.name);
|
||||
encounter.misc.chosenModifier = modifier;
|
||||
encounter.misc.chosenPokemon = pokemon;
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
@ -370,6 +371,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
|||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
const modifier = encounter.misc.chosenModifier as PokemonHeldItemModifier;
|
||||
const party = scene.getPlayerParty();
|
||||
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||
|
||||
// Check tier of the traded item, the received item will be one tier up
|
||||
const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party);
|
||||
|
@ -397,11 +399,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
|||
encounter.setDialogueToken("itemName", item.type.name);
|
||||
setEncounterRewards(scene, { guaranteedModifierTypeOptions: [ item ], fillRemaining: false });
|
||||
|
||||
// Remove the chosen modifier if its stacks go to 0
|
||||
modifier.stackCount -= 1;
|
||||
if (modifier.stackCount === 0) {
|
||||
scene.removeModifier(modifier);
|
||||
}
|
||||
chosenPokemon.loseHeldItem(modifier, false);
|
||||
await scene.updateModifiers(true, true);
|
||||
|
||||
// Generate a trainer name
|
||||
|
|
|
@ -312,6 +312,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
|
|||
pokemon.levelExp = 0;
|
||||
|
||||
pokemon.calculateStats();
|
||||
pokemon.getBattleInfo().setLevel(pokemon.level);
|
||||
await pokemon.updateInfo();
|
||||
}
|
||||
|
||||
|
|
|
@ -363,6 +363,12 @@ export abstract class PokemonSpeciesForm {
|
|||
}
|
||||
|
||||
switch (this.speciesId) {
|
||||
case Species.DODUO:
|
||||
case Species.DODRIO:
|
||||
case Species.MEGANIUM:
|
||||
case Species.TORCHIC:
|
||||
case Species.COMBUSKEN:
|
||||
case Species.BLAZIKEN:
|
||||
case Species.HIPPOPOTAS:
|
||||
case Species.HIPPOWDON:
|
||||
case Species.UNFEZANT:
|
||||
|
@ -867,17 +873,24 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||
getCompatibleFusionSpeciesFilter(): PokemonSpeciesFilter {
|
||||
const hasEvolution = pokemonEvolutions.hasOwnProperty(this.speciesId);
|
||||
const hasPrevolution = pokemonPrevolutions.hasOwnProperty(this.speciesId);
|
||||
const pseudoLegendary = this.subLegendary;
|
||||
const subLegendary = this.subLegendary;
|
||||
const legendary = this.legendary;
|
||||
const mythical = this.mythical;
|
||||
return species => {
|
||||
return (pseudoLegendary || legendary || mythical ||
|
||||
(pokemonEvolutions.hasOwnProperty(species.speciesId) === hasEvolution
|
||||
&& pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution))
|
||||
&& species.subLegendary === pseudoLegendary
|
||||
return (
|
||||
subLegendary
|
||||
|| legendary
|
||||
|| mythical
|
||||
|| (
|
||||
pokemonEvolutions.hasOwnProperty(species.speciesId) === hasEvolution
|
||||
&& pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution
|
||||
)
|
||||
)
|
||||
&& species.subLegendary === subLegendary
|
||||
&& species.legendary === legendary
|
||||
&& species.mythical === mythical
|
||||
&& (this.isTrainerForbidden() || !species.isTrainerForbidden());
|
||||
&& (this.isTrainerForbidden() || !species.isTrainerForbidden())
|
||||
&& species.speciesId !== Species.DITTO;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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 { WeatherType } from "#enums/weather-type";
|
||||
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag";
|
||||
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr, 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 { BattlerIndex } from "#app/battle";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
|
@ -443,7 +443,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
};
|
||||
if (this.shiny) {
|
||||
const populateVariantColors = (isBackSprite: boolean = false): Promise<void> => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise(async resolve => {
|
||||
const battleSpritePath = this.getBattleSpriteAtlasPath(isBackSprite, ignoreOverride).replace("variant/", "").replace(/_[1-3]$/, "");
|
||||
let config = variantData;
|
||||
const useExpSprite = this.scene.experimentalSprites && this.scene.hasExpSprite(this.getBattleSpriteKey(isBackSprite, ignoreOverride));
|
||||
|
@ -452,7 +452,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
if (variantSet && variantSet[this.variant] === 1) {
|
||||
const cacheKey = this.getBattleSpriteKey(isBackSprite);
|
||||
if (!variantColorCache.hasOwnProperty(cacheKey)) {
|
||||
this.populateVariantColorCache(cacheKey, useExpSprite, battleSpritePath);
|
||||
await this.populateVariantColorCache(cacheKey, useExpSprite, battleSpritePath);
|
||||
}
|
||||
}
|
||||
resolve();
|
||||
|
@ -484,10 +484,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
* @param battleSpritePath the filename of the sprite
|
||||
* @param optionalParams any additional params to log
|
||||
*/
|
||||
fallbackVariantColor(cacheKey: string, attemptedSpritePath: string, useExpSprite: boolean, battleSpritePath: string, ...optionalParams: any[]) {
|
||||
async fallbackVariantColor(cacheKey: string, attemptedSpritePath: string, useExpSprite: boolean, battleSpritePath: string, ...optionalParams: any[]) {
|
||||
console.warn(`Could not load ${attemptedSpritePath}!`, ...optionalParams);
|
||||
if (useExpSprite) {
|
||||
this.populateVariantColorCache(cacheKey, false, battleSpritePath);
|
||||
await this.populateVariantColorCache(cacheKey, false, battleSpritePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,18 +498,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
* @param useExpSprite should the experimental sprite be used
|
||||
* @param battleSpritePath the filename of the sprite
|
||||
*/
|
||||
populateVariantColorCache(cacheKey: string, useExpSprite: boolean, battleSpritePath: string) {
|
||||
async populateVariantColorCache(cacheKey: string, useExpSprite: boolean, battleSpritePath: string) {
|
||||
const spritePath = `./images/pokemon/variant/${useExpSprite ? "exp/" : ""}${battleSpritePath}.json`;
|
||||
this.scene.cachedFetch(spritePath).then(res => {
|
||||
return this.scene.cachedFetch(spritePath).then(res => {
|
||||
// Prevent the JSON from processing if it failed to load
|
||||
if (!res.ok) {
|
||||
return this.fallbackVariantColor(cacheKey, res.url, useExpSprite, battleSpritePath, res.status, res.statusText);
|
||||
}
|
||||
return res.json();
|
||||
}).catch(error => {
|
||||
this.fallbackVariantColor(cacheKey, spritePath, useExpSprite, battleSpritePath, error);
|
||||
return this.fallbackVariantColor(cacheKey, spritePath, useExpSprite, battleSpritePath, error);
|
||||
}).then(c => {
|
||||
if (!isNullOrUndefined(c)) {
|
||||
variantColorCache[cacheKey] = c;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -974,7 +976,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
if (this.status && this.status.effect === StatusEffect.PARALYSIS) {
|
||||
ret >>= 1;
|
||||
}
|
||||
if (this.getTag(BattlerTagType.UNBURDEN) && !this.scene.getField(true).some(pokemon => pokemon !== this && pokemon.hasAbilityWithAttr(SuppressFieldAbilitiesAbAttr))) {
|
||||
if (this.getTag(BattlerTagType.UNBURDEN) && this.hasAbility(Abilities.UNBURDEN)) {
|
||||
ret *= 2;
|
||||
}
|
||||
break;
|
||||
|
@ -2022,15 +2024,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value);
|
||||
const randAbilityIndex = Utils.randSeedInt(2);
|
||||
|
||||
const filter = !forStarter ? this.species.getCompatibleFusionSpeciesFilter()
|
||||
: species => {
|
||||
const filter = !forStarter ?
|
||||
this.species.getCompatibleFusionSpeciesFilter()
|
||||
: (species: PokemonSpecies) => {
|
||||
return pokemonEvolutions.hasOwnProperty(species.speciesId)
|
||||
&& !pokemonPrevolutions.hasOwnProperty(species.speciesId)
|
||||
&& !species.pseudoLegendary
|
||||
&& !species.subLegendary
|
||||
&& !species.legendary
|
||||
&& !species.mythical
|
||||
&& !species.isTrainerForbidden()
|
||||
&& species.speciesId !== this.species.speciesId;
|
||||
&& species.speciesId !== this.species.speciesId
|
||||
&& species.speciesId !== Species.DITTO;
|
||||
};
|
||||
|
||||
let fusionOverride: PokemonSpecies | undefined = undefined;
|
||||
|
@ -2630,10 +2634,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
const numTargets = multiple ? targets.length : 1;
|
||||
const targetMultiplier = (numTargets > 1) ? 0.75 : 1;
|
||||
|
||||
/** 0.25x multiplier if this is an added strike from the attacker's Parental Bond */
|
||||
const parentalBondMultiplier = new Utils.NumberHolder(1);
|
||||
/** Multiplier for moves enhanced by Multi-Lens and/or Parental Bond */
|
||||
const multiStrikeEnhancementMultiplier = new Utils.NumberHolder(1);
|
||||
source.scene.applyModifiers(PokemonMultiHitModifier, source.isPlayer(), source, move.id, null, multiStrikeEnhancementMultiplier);
|
||||
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 */
|
||||
|
@ -2710,7 +2715,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
damage.value = Utils.toDmgValue(
|
||||
baseDamage
|
||||
* targetMultiplier
|
||||
* parentalBondMultiplier.value
|
||||
* multiStrikeEnhancementMultiplier.value
|
||||
* arenaAttackTypeMultiplier.value
|
||||
* glaiveRushMultiplier.value
|
||||
* criticalMultiplier.value
|
||||
|
@ -4091,6 +4096,28 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduces one of this Pokemon's held item stacks by 1, and removes the item if applicable.
|
||||
* Does nothing if this Pokemon is somehow not the owner of the held item.
|
||||
* @param heldItem The item stack to be reduced by 1.
|
||||
* @param forBattle If `false`, do not trigger in-battle effects (such as Unburden) from losing the item. For example, set this to `false` if the Pokemon is giving away the held item for a Mystery Encounter. Default is `true`.
|
||||
* @returns `true` if the item was removed successfully, `false` otherwise.
|
||||
*/
|
||||
public loseHeldItem(heldItem: PokemonHeldItemModifier, forBattle: boolean = true): boolean {
|
||||
if (heldItem.pokemonId === -1 || heldItem.pokemonId === this.id) {
|
||||
heldItem.stackCount--;
|
||||
if (heldItem.stackCount <= 0) {
|
||||
this.scene.removeModifier(heldItem, !this.isPlayer());
|
||||
}
|
||||
if (forBattle) {
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, this, false);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default interface Pokemon {
|
||||
|
@ -4533,7 +4560,7 @@ export class PlayerPokemon extends Pokemon {
|
|||
&& m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[];
|
||||
const transferModifiers: Promise<boolean>[] = [];
|
||||
for (const modifier of fusedPartyMemberHeldModifiers) {
|
||||
transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true));
|
||||
transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true, false));
|
||||
}
|
||||
Promise.allSettled(transferModifiers).then(() => {
|
||||
this.scene.updateModifiers(true, true).then(() => {
|
||||
|
@ -5108,7 +5135,7 @@ export class EnemyPokemon extends Pokemon {
|
|||
|
||||
/**
|
||||
* Add a new pokemon to the player's party (at `slotIndex` if set).
|
||||
* If the first slot is replaced, the new pokemon's visibility will be set to `false`.
|
||||
* The new pokemon's visibility will be set to `false`.
|
||||
* @param pokeballType the type of pokeball the pokemon was caught with
|
||||
* @param slotIndex an optional index to place the pokemon in the party
|
||||
* @returns the pokemon that was added or null if the pokemon could not be added
|
||||
|
@ -5126,14 +5153,14 @@ export class EnemyPokemon extends Pokemon {
|
|||
const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this);
|
||||
|
||||
if (Utils.isBetween(slotIndex, 0, PLAYER_PARTY_MAX_SIZE - 1)) {
|
||||
if (slotIndex === 0) {
|
||||
newPokemon.setVisible(false); // Hide if replaced with first pokemon
|
||||
}
|
||||
party.splice(slotIndex, 0, newPokemon);
|
||||
} else {
|
||||
party.push(newPokemon);
|
||||
}
|
||||
|
||||
// Hide the Pokemon since it is not on the field
|
||||
newPokemon.setVisible(false);
|
||||
|
||||
ret = newPokemon;
|
||||
this.scene.triggerPokemonFormChange(newPokemon, SpeciesFormChangeActiveTrigger, true);
|
||||
}
|
||||
|
|
|
@ -1702,10 +1702,7 @@ const modifierPool: ModifierPool = {
|
|||
new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, (party: Pokemon[]) => {
|
||||
return Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 15), 8);
|
||||
}, 8),
|
||||
new WeightedModifierType(modifierTypes.MAP,
|
||||
(party: Pokemon[]) => party[0].scene.gameMode.isClassic && party[0].scene.currentBattle.waveIndex < 180 ? party[0].scene.eventManager.isEventActive() ? 2 : 1 : 0,
|
||||
(party: Pokemon[]) => party[0].scene.eventManager.isEventActive() ? 2 : 1),
|
||||
new WeightedModifierType(modifierTypes.SOOTHE_BELL, (party: Pokemon[]) => party[0].scene.eventManager.isEventActive() ? 3 : 0),
|
||||
new WeightedModifierType(modifierTypes.MAP, (party: Pokemon[]) => party[0].scene.gameMode.isClassic && party[0].scene.currentBattle.waveIndex < 180 ? 1 : 0, 1),
|
||||
new WeightedModifierType(modifierTypes.TM_GREAT, 3),
|
||||
new WeightedModifierType(modifierTypes.MEMORY_MUSHROOM, (party: Pokemon[]) => {
|
||||
if (!party.find(p => p.getLearnableLevelMoves().length)) {
|
||||
|
@ -1773,7 +1770,7 @@ const modifierPool: ModifierPool = {
|
|||
new WeightedModifierType(modifierTypes.CANDY_JAR, skipInLastClassicWaveOrDefault(5)),
|
||||
new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 9),
|
||||
new WeightedModifierType(modifierTypes.TM_ULTRA, 11),
|
||||
new WeightedModifierType(modifierTypes.RARER_CANDY, (party: Pokemon[]) => party[0].scene.eventManager.isEventActive() ? 6 : 4),
|
||||
new WeightedModifierType(modifierTypes.RARER_CANDY, 4),
|
||||
new WeightedModifierType(modifierTypes.GOLDEN_PUNCH, skipInLastClassicWaveOrDefault(2)),
|
||||
new WeightedModifierType(modifierTypes.IV_SCANNER, skipInLastClassicWaveOrDefault(4)),
|
||||
new WeightedModifierType(modifierTypes.EXP_CHARM, skipInLastClassicWaveOrDefault(8)),
|
||||
|
@ -1797,7 +1794,7 @@ const modifierPool: ModifierPool = {
|
|||
new WeightedModifierType(modifierTypes.SOUL_DEW, 7),
|
||||
//new WeightedModifierType(modifierTypes.OVAL_CHARM, 6),
|
||||
new WeightedModifierType(modifierTypes.CATCHING_CHARM, (party: Pokemon[]) => !party[0].scene.gameMode.isFreshStartChallenge() && party[0].scene.gameData.getSpeciesCount(d => !!d.caughtAttr) > 100 ? 4 : 0, 4),
|
||||
new WeightedModifierType(modifierTypes.SOOTHE_BELL, (party: Pokemon[]) => party[0].scene.eventManager.isEventActive() ? 0 : 4),
|
||||
new WeightedModifierType(modifierTypes.SOOTHE_BELL, 4),
|
||||
new WeightedModifierType(modifierTypes.ABILITY_CHARM, skipInClassicAfterWave(189, 6)),
|
||||
new WeightedModifierType(modifierTypes.FOCUS_BAND, 5),
|
||||
new WeightedModifierType(modifierTypes.KINGS_ROCK, 3),
|
||||
|
|
|
@ -6,7 +6,6 @@ import { allMoves } from "#app/data/move";
|
|||
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
|
||||
import { type FormChangeItem, SpeciesFormChangeItemTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms";
|
||||
import { getStatusEffectHealText } from "#app/data/status-effect";
|
||||
import { Type } from "#enums/type";
|
||||
import Pokemon, { type PlayerPokemon } from "#app/field/pokemon";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import Overrides from "#app/overrides";
|
||||
|
@ -22,11 +21,13 @@ import { BooleanHolder, hslToHex, isNullOrUndefined, NumberHolder, toDmgValue }
|
|||
import { Abilities } from "#enums/abilities";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { BerryType } from "#enums/berry-type";
|
||||
import { Moves } from "#enums/moves";
|
||||
import type { Nature } from "#enums/nature";
|
||||
import type { PokeballType } from "#enums/pokeball";
|
||||
import { Species } from "#enums/species";
|
||||
import { type PermanentStat, type TempBattleStat, BATTLE_STATS, Stat, TEMP_BATTLE_STATS } from "#enums/stat";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { Type } from "#enums/type";
|
||||
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 { Color, ShadowColor } from "#enums/color";
|
||||
|
@ -2689,32 +2690,57 @@ export class PokemonMultiHitModifier extends PokemonHeldItemModifier {
|
|||
}
|
||||
|
||||
/**
|
||||
* Applies {@linkcode PokemonMultiHitModifier}
|
||||
* @param _pokemon The {@linkcode Pokemon} using the move
|
||||
* @param count {@linkcode NumberHolder} holding the number of items
|
||||
* @param power {@linkcode NumberHolder} holding the power of the move
|
||||
* For each stack, converts 25 percent of attack damage into an additional strike.
|
||||
* @param pokemon The {@linkcode Pokemon} using the move
|
||||
* @param moveId The {@linkcode Moves | identifier} for the move being used
|
||||
* @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`
|
||||
*/
|
||||
override apply(_pokemon: Pokemon, count: NumberHolder, power: NumberHolder): boolean {
|
||||
count.value *= (this.getStackCount() + 1);
|
||||
|
||||
switch (this.getStackCount()) {
|
||||
case 1:
|
||||
power.value *= 0.4;
|
||||
break;
|
||||
case 2:
|
||||
power.value *= 0.25;
|
||||
break;
|
||||
case 3:
|
||||
power.value *= 0.175;
|
||||
break;
|
||||
override apply(pokemon: Pokemon, moveId: Moves, count: NumberHolder | null = null, damageMultiplier: NumberHolder | null = null): boolean {
|
||||
const move = allMoves[moveId];
|
||||
/**
|
||||
* The move must meet Parental Bond's restrictions for this item
|
||||
* to apply. This means
|
||||
* - Only attacks are boosted
|
||||
* - Multi-strike moves, charge moves, and self-sacrificial moves are not boosted
|
||||
* (though Multi-Lens can still affect moves boosted by Parental Bond)
|
||||
* - Multi-target moves are not boosted *unless* they can only hit a single Pokemon
|
||||
* - Fling, Uproar, Rollout, Ice Ball, and Endeavor are not boosted
|
||||
*/
|
||||
if (!move.canBeMultiStrikeEnhanced(pokemon)) {
|
||||
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;
|
||||
}
|
||||
|
||||
getMaxHeldItemCount(pokemon: Pokemon): number {
|
||||
return 3;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,8 @@ export class BerryPhase extends FieldPhase {
|
|||
|
||||
for (const berryModifier of this.scene.applyModifiers(BerryModifier, pokemon.isPlayer(), pokemon)) {
|
||||
if (berryModifier.consumed) {
|
||||
if (!--berryModifier.stackCount) {
|
||||
this.scene.removeModifier(berryModifier);
|
||||
} else {
|
||||
berryModifier.consumed = false;
|
||||
}
|
||||
pokemon.loseHeldItem(berryModifier);
|
||||
}
|
||||
this.scene.eventTarget.dispatchEvent(new BerryUsedEvent(berryModifier)); // Announce a berry was used
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ export class EncounterPhase extends BattlePhase {
|
|||
this.scene.field.add(enemyPokemon);
|
||||
battle.seenEnemyPartyMemberIds.add(enemyPokemon.id);
|
||||
const playerPokemon = this.scene.getPlayerPokemon();
|
||||
if (playerPokemon?.visible) {
|
||||
if (playerPokemon?.isOnField()) {
|
||||
this.scene.field.moveBelow(enemyPokemon as Pokemon, playerPokemon);
|
||||
}
|
||||
enemyPokemon.tint(0, 0.5);
|
||||
|
|
|
@ -55,21 +55,21 @@ export class FaintPhase extends PokemonPhase {
|
|||
start() {
|
||||
super.start();
|
||||
|
||||
const faintPokemon = this.getPokemon();
|
||||
|
||||
if (!isNullOrUndefined(this.destinyTag) && !isNullOrUndefined(this.source)) {
|
||||
this.destinyTag.lapse(this.source, BattlerTagLapseType.CUSTOM);
|
||||
}
|
||||
|
||||
if (!isNullOrUndefined(this.grudgeTag) && !isNullOrUndefined(this.source)) {
|
||||
this.grudgeTag.lapse(this.getPokemon(), BattlerTagLapseType.CUSTOM, this.source);
|
||||
this.grudgeTag.lapse(faintPokemon, BattlerTagLapseType.CUSTOM, this.source);
|
||||
}
|
||||
|
||||
if (!this.preventEndure) {
|
||||
const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, this.getPokemon()) as PokemonInstantReviveModifier;
|
||||
const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, faintPokemon) as PokemonInstantReviveModifier;
|
||||
|
||||
if (instantReviveModifier) {
|
||||
if (!--instantReviveModifier.stackCount) {
|
||||
this.scene.removeModifier(instantReviveModifier);
|
||||
}
|
||||
faintPokemon.loseHeldItem(instantReviveModifier);
|
||||
this.scene.updateModifiers(this.player);
|
||||
return this.end();
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@ import i18next from "i18next";
|
|||
import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
|
||||
|
||||
export class GameOverPhase extends BattlePhase {
|
||||
private victory: boolean;
|
||||
private isVictory: boolean;
|
||||
private firstRibbons: PokemonSpecies[] = [];
|
||||
|
||||
constructor(scene: BattleScene, victory?: boolean) {
|
||||
constructor(scene: BattleScene, isVictory: boolean = false) {
|
||||
super(scene);
|
||||
|
||||
this.victory = !!victory;
|
||||
this.isVictory = isVictory;
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -40,22 +40,22 @@ export class GameOverPhase extends BattlePhase {
|
|||
|
||||
// Failsafe if players somehow skip floor 200 in classic mode
|
||||
if (this.scene.gameMode.isClassic && this.scene.currentBattle.waveIndex > 200) {
|
||||
this.victory = true;
|
||||
this.isVictory = true;
|
||||
}
|
||||
|
||||
// Handle Mystery Encounter special Game Over cases
|
||||
// Situations such as when player lost a battle, but it isn't treated as full Game Over
|
||||
if (!this.victory && this.scene.currentBattle.mysteryEncounter?.onGameOver && !this.scene.currentBattle.mysteryEncounter.onGameOver(this.scene)) {
|
||||
if (!this.isVictory && this.scene.currentBattle.mysteryEncounter?.onGameOver && !this.scene.currentBattle.mysteryEncounter.onGameOver(this.scene)) {
|
||||
// Do not end the game
|
||||
return this.end();
|
||||
}
|
||||
// Otherwise, continue standard Game Over logic
|
||||
|
||||
if (this.victory && this.scene.gameMode.isEndless) {
|
||||
if (this.isVictory && this.scene.gameMode.isEndless) {
|
||||
const genderIndex = this.scene.gameData.gender ?? PlayerGender.UNSET;
|
||||
const genderStr = PlayerGender[genderIndex].toLowerCase();
|
||||
this.scene.ui.showDialogue(i18next.t("miscDialogue:ending_endless", { context: genderStr }), i18next.t("miscDialogue:ending_name"), 0, () => this.handleGameOver());
|
||||
} else if (this.victory || !this.scene.enableRetries) {
|
||||
} else if (this.isVictory || !this.scene.enableRetries) {
|
||||
this.handleGameOver();
|
||||
} else {
|
||||
this.scene.ui.showText(i18next.t("battle:retryBattle"), null, () => {
|
||||
|
@ -93,7 +93,7 @@ export class GameOverPhase extends BattlePhase {
|
|||
this.scene.disableMenu = true;
|
||||
this.scene.time.delayedCall(1000, () => {
|
||||
let firstClear = false;
|
||||
if (this.victory && newClear) {
|
||||
if (this.isVictory && newClear) {
|
||||
if (this.scene.gameMode.isClassic) {
|
||||
firstClear = this.scene.validateAchv(achvs.CLASSIC_VICTORY);
|
||||
this.scene.validateAchv(achvs.UNEVOLVED_CLASSIC_VICTORY);
|
||||
|
@ -109,8 +109,8 @@ export class GameOverPhase extends BattlePhase {
|
|||
this.scene.gameData.gameStats.dailyRunSessionsWon++;
|
||||
}
|
||||
}
|
||||
this.scene.gameData.saveRunHistory(this.scene, this.scene.gameData.getSessionSaveData(this.scene), this.victory);
|
||||
const fadeDuration = this.victory ? 10000 : 5000;
|
||||
this.scene.gameData.saveRunHistory(this.scene, this.scene.gameData.getSessionSaveData(this.scene), this.isVictory);
|
||||
const fadeDuration = this.isVictory ? 10000 : 5000;
|
||||
this.scene.fadeOutBgm(fadeDuration, true);
|
||||
const activeBattlers = this.scene.getField().filter(p => p?.isActive(true));
|
||||
activeBattlers.map(p => p.hideInfo());
|
||||
|
@ -120,15 +120,14 @@ export class GameOverPhase extends BattlePhase {
|
|||
this.scene.clearPhaseQueue();
|
||||
this.scene.ui.clearText();
|
||||
|
||||
if (this.victory && this.scene.gameMode.isChallenge) {
|
||||
if (this.isVictory && this.scene.gameMode.isChallenge) {
|
||||
this.scene.gameMode.challenges.forEach(c => this.scene.validateAchvs(ChallengeAchv, c));
|
||||
}
|
||||
|
||||
const clear = (endCardPhase?: EndCardPhase) => {
|
||||
if (newClear) {
|
||||
if (this.isVictory && newClear) {
|
||||
this.handleUnlocks();
|
||||
}
|
||||
if (this.victory && newClear) {
|
||||
|
||||
for (const species of this.firstRibbons) {
|
||||
this.scene.unshiftPhase(new RibbonModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PLUS, species));
|
||||
}
|
||||
|
@ -140,7 +139,7 @@ export class GameOverPhase extends BattlePhase {
|
|||
this.end();
|
||||
};
|
||||
|
||||
if (this.victory && this.scene.gameMode.isClassic) {
|
||||
if (this.isVictory && this.scene.gameMode.isClassic) {
|
||||
const dialogueKey = "miscDialogue:ending";
|
||||
|
||||
if (!this.scene.ui.shouldSkipDialogue(dialogueKey)) {
|
||||
|
@ -173,25 +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 Offline, execute offlineNewClear(), a localStorage implementation of newClear daily run checks */
|
||||
if (this.victory) {
|
||||
If Offline, execute offlineNewClear() only for victory, a localStorage implementation of newClear daily run checks */
|
||||
if (!Utils.isLocal || Utils.isLocalServerConnected) {
|
||||
pokerogueApi.savedata.session.newclear({ slot: this.scene.sessionSlotId, clientSessionId })
|
||||
pokerogueApi.savedata.session.newclear({ slot: this.scene.sessionSlotId, isVictory: this.isVictory, clientSessionId: clientSessionId })
|
||||
.then((success) => doGameOver(!!success));
|
||||
} else {
|
||||
} else if (this.isVictory) {
|
||||
this.scene.gameData.offlineNewClear(this.scene).then(result => {
|
||||
doGameOver(result);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
doGameOver(false);
|
||||
}
|
||||
}
|
||||
|
||||
handleUnlocks(): void {
|
||||
if (this.victory && this.scene.gameMode.isClassic) {
|
||||
if (this.isVictory && this.scene.gameMode.isClassic) {
|
||||
if (!this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
|
||||
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.ENDLESS_MODE));
|
||||
}
|
||||
|
|
|
@ -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 { EvolutionPhase } from "#app/phases/evolution-phase";
|
||||
import { PlayerPokemon } from "#app/field/pokemon";
|
||||
import type { PlayerPokemon } from "#app/field/pokemon";
|
||||
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 { NumberHolder } from "#app/utils";
|
||||
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 {
|
||||
private lastLevel: integer;
|
||||
private level: integer;
|
||||
protected lastLevel: number;
|
||||
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);
|
||||
|
||||
this.lastLevel = lastLevel;
|
||||
this.level = level;
|
||||
this.scene = scene;
|
||||
}
|
||||
|
||||
start() {
|
||||
public override start() {
|
||||
super.start();
|
||||
|
||||
if (this.level > this.scene.gameData.gameStats.highestLevel) {
|
||||
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 = pokemon.stats.slice(0);
|
||||
pokemon.calculateStats();
|
||||
pokemon.updateInfo();
|
||||
const prevStats = this.pokemon.stats.slice(0);
|
||||
this.pokemon.calculateStats();
|
||||
this.pokemon.updateInfo();
|
||||
if (this.scene.expParty === ExpNotification.DEFAULT) {
|
||||
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) {
|
||||
this.end();
|
||||
} else {
|
||||
// we still want to display the stats if activated
|
||||
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
|
||||
const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1);
|
||||
for (const lm of levelMoves) {
|
||||
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm[1]));
|
||||
}
|
||||
}
|
||||
if (!pokemon.pauseEvolutions) {
|
||||
const evolution = pokemon.getEvolution();
|
||||
if (!this.pokemon.pauseEvolutions) {
|
||||
const evolution = this.pokemon.getEvolution();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
applyMoveAttrs,
|
||||
AttackMove,
|
||||
DelayedAttackAttr,
|
||||
FixedDamageAttr,
|
||||
FlinchAttr,
|
||||
HitsTagAttr,
|
||||
MissEffectAttr,
|
||||
MoveAttr,
|
||||
|
@ -122,12 +122,10 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||
const hitCount = new NumberHolder(1);
|
||||
// Assume single target for multi hit
|
||||
applyMoveAttrs(MultiHitAttr, user, this.getFirstTarget() ?? null, move, hitCount);
|
||||
// If Parental Bond is applicable, double the hit count
|
||||
applyPreAttackAbAttrs(AddSecondStrikeAbAttr, user, null, move, false, targets.length, hitCount, new NumberHolder(0));
|
||||
// If Multi-Lens is applicable, multiply the hit count by 1 + the number of Multi-Lenses held by the user
|
||||
if (move instanceof AttackMove && !move.hasAttr(FixedDamageAttr)) {
|
||||
this.scene.applyModifiers(PokemonMultiHitModifier, user.isPlayer(), user, hitCount, new NumberHolder(0));
|
||||
}
|
||||
// If Parental Bond is applicable, add another hit
|
||||
applyPreAttackAbAttrs(AddSecondStrikeAbAttr, user, null, move, false, hitCount, null);
|
||||
// If Multi-Lens is applicable, add hits equal to the number of held Multi-Lenses
|
||||
this.scene.applyModifiers(PokemonMultiHitModifier, user.isPlayer(), user, move.id, hitCount);
|
||||
// Set the user's relevant turnData fields to reflect the final hit count
|
||||
user.turnData.hitCount = 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 {
|
||||
return () => {
|
||||
if (this.move.getMove().hasAttr(FlinchAttr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dealsDamage && !target.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && !this.move.getMove().hitsSubstitute(user, target)) {
|
||||
const flinched = new BooleanHolder(false);
|
||||
user.scene.applyModifiers(FlinchChanceModifier, user.isPlayer(), user, flinched);
|
||||
|
|
|
@ -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).
|
||||
if (!this.canMove(true)) {
|
||||
if (this.pokemon.isActive(true) && this.move.ppUsed >= this.move.getMovePp()) {
|
||||
if (this.pokemon.isActive(true)) {
|
||||
this.fail();
|
||||
this.showMoveText();
|
||||
this.showFailedText();
|
||||
}
|
||||
|
||||
return this.end();
|
||||
}
|
||||
|
||||
|
@ -378,15 +377,9 @@ export class MovePhase extends BattlePhase {
|
|||
} else {
|
||||
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));
|
||||
|
||||
if (failureMessage) {
|
||||
failedText = failureMessage;
|
||||
}
|
||||
|
||||
this.showMoveText();
|
||||
this.showFailedText(failedText);
|
||||
this.showFailedText(failureMessage ?? undefined);
|
||||
|
||||
// Remove the user from its semi-invulnerable state (if applicable)
|
||||
this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT);
|
||||
|
|
|
@ -29,10 +29,14 @@ export class QuietFormChangePhase extends BattlePhase {
|
|||
|
||||
const preName = getPokemonNameWithAffix(this.pokemon);
|
||||
|
||||
if (!this.pokemon.isOnField() || this.pokemon.getTag(SemiInvulnerableTag)) {
|
||||
if (!this.pokemon.isOnField() || this.pokemon.getTag(SemiInvulnerableTag) || this.pokemon.isFainted()) {
|
||||
if (this.pokemon.isPlayer() || this.pokemon.isActive()) {
|
||||
this.pokemon.changeForm(this.formChange).then(() => {
|
||||
this.scene.ui.showText(getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), null, () => this.end(), 1500);
|
||||
});
|
||||
} else {
|
||||
this.end();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||
&& m.isTransferable && m.pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
|
||||
const itemModifier = itemModifiers[itemIndex];
|
||||
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity);
|
||||
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity, undefined, undefined, false);
|
||||
} else {
|
||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(this.scene.lockModifierTiers));
|
||||
}
|
||||
|
|
|
@ -125,10 +125,7 @@ export class StatStageChangePhase extends PokemonPhase {
|
|||
const whiteHerb = this.scene.applyModifier(ResetNegativeStatStageModifier, this.player, pokemon) as ResetNegativeStatStageModifier;
|
||||
// If the White Herb was applied, consume it
|
||||
if (whiteHerb) {
|
||||
whiteHerb.stackCount--;
|
||||
if (whiteHerb.stackCount <= 0) {
|
||||
this.scene.removeModifier(whiteHerb);
|
||||
}
|
||||
pokemon.loseHeldItem(whiteHerb);
|
||||
this.scene.updateModifiers(this.player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
|||
this.scene.field.add(pokemon);
|
||||
if (!this.player) {
|
||||
const playerPokemon = this.scene.getPlayerPokemon() as Pokemon;
|
||||
if (playerPokemon?.visible) {
|
||||
if (playerPokemon?.isOnField()) {
|
||||
this.scene.field.moveBelow(pokemon, playerPokemon);
|
||||
}
|
||||
this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id);
|
||||
|
@ -193,7 +193,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
|||
this.scene.field.add(pokemon);
|
||||
if (!this.player) {
|
||||
const playerPokemon = this.scene.getPlayerPokemon() as Pokemon;
|
||||
if (playerPokemon?.visible) {
|
||||
if (playerPokemon?.isOnField()) {
|
||||
this.scene.field.moveBelow(pokemon, playerPokemon);
|
||||
}
|
||||
this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id);
|
||||
|
|
|
@ -111,7 +111,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||
const batonPassModifier = this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier
|
||||
&& (m as SwitchEffectTransferModifier).pokemonId === this.lastPokemon.id) as SwitchEffectTransferModifier;
|
||||
if (batonPassModifier && !this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) {
|
||||
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false);
|
||||
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false, undefined, undefined, undefined, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1540,7 +1540,7 @@ export class GameData {
|
|||
entry.caughtAttr = defaultStarterAttr;
|
||||
entry.natureAttr = 1 << (defaultStarterNatures[ds] + 1);
|
||||
for (const i in entry.ivs) {
|
||||
entry.ivs[i] = 10;
|
||||
entry.ivs[i] = 15;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ describe("Abilities - Parental Bond", () => {
|
|||
);
|
||||
|
||||
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 () => {
|
||||
game.override.moveset([ Moves.TACKLE ]);
|
||||
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
|
||||
|
@ -287,36 +287,12 @@ describe("Abilities - Parental Bond", () => {
|
|||
|
||||
await game.phaseInterceptor.to("DamagePhase");
|
||||
|
||||
expect(leadPokemon.turnData.hitCount).toBe(4);
|
||||
expect(leadPokemon.turnData.hitCount).toBe(3);
|
||||
}
|
||||
);
|
||||
|
||||
it(
|
||||
"Super Fang boosted by this ability and Multi-Lens should strike twice",
|
||||
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",
|
||||
"Seismic Toss boosted by this ability and Multi-Lens should strike 3 times",
|
||||
async () => {
|
||||
game.override.moveset([ Moves.SEISMIC_TOSS ]);
|
||||
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
|
||||
|
@ -333,11 +309,11 @@ describe("Abilities - Parental Bond", () => {
|
|||
|
||||
await game.phaseInterceptor.to("DamagePhase");
|
||||
|
||||
expect(leadPokemon.turnData.hitCount).toBe(2);
|
||||
expect(leadPokemon.turnData.hitCount).toBe(3);
|
||||
|
||||
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);
|
||||
}
|
||||
);
|
||||
|
||||
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]));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,18 +1,35 @@
|
|||
import { BattlerIndex } from "#app/battle";
|
||||
import { PostItemLostAbAttr } from "#app/data/ability";
|
||||
import { allMoves, StealHeldItemChanceAttr } from "#app/data/move";
|
||||
import Pokemon from "#app/field/pokemon";
|
||||
import type { ContactHeldItemTransferChanceModifier } from "#app/modifier/modifier";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { BerryType } from "#enums/berry-type";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { Stat } from "#enums/stat";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { BerryType } from "#app/enums/berry-type";
|
||||
import { allMoves, StealHeldItemChanceAttr } from "#app/data/move";
|
||||
|
||||
|
||||
describe("Abilities - Unburden", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
/**
|
||||
* Count the number of held items a Pokemon has, accounting for stacks of multiple items.
|
||||
*/
|
||||
function getHeldItemCount(pokemon: Pokemon): number {
|
||||
const stackCounts = pokemon.getHeldItems().map(m => m.getStackCount());
|
||||
if (stackCounts.length) {
|
||||
return stackCounts.reduce((a, b) => a + b);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
|
@ -27,9 +44,9 @@ describe("Abilities - Unburden", () => {
|
|||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.battleType("single")
|
||||
.starterSpecies(Species.TREECKO)
|
||||
.startingLevel(1)
|
||||
.moveset([ Moves.POPULATION_BOMB, Moves.KNOCK_OFF, Moves.PLUCK, Moves.THIEF ])
|
||||
.ability(Abilities.UNBURDEN)
|
||||
.moveset([ Moves.SPLASH, Moves.KNOCK_OFF, Moves.PLUCK, Moves.FALSE_SWIPE ])
|
||||
.startingHeldItems([
|
||||
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
|
||||
{ name: "BERRY", count: 2, type: BerryType.APICOT },
|
||||
|
@ -37,209 +54,348 @@ describe("Abilities - Unburden", () => {
|
|||
])
|
||||
.enemySpecies(Species.NINJASK)
|
||||
.enemyLevel(100)
|
||||
.enemyMoveset([ Moves.FALSE_SWIPE ])
|
||||
.enemyMoveset(Moves.SPLASH)
|
||||
.enemyAbility(Abilities.UNBURDEN)
|
||||
.enemyPassiveAbility(Abilities.NO_GUARD)
|
||||
.enemyHeldItems([
|
||||
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
|
||||
{ name: "BERRY", type: BerryType.LUM, count: 1 },
|
||||
]);
|
||||
// For the various tests that use Thief, give it a 100% steal rate
|
||||
vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]);
|
||||
});
|
||||
|
||||
it("should activate when a berry is eaten", async () => {
|
||||
await game.classicMode.startBattle();
|
||||
game.override.enemyMoveset(Moves.FALSE_SWIPE);
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
playerPokemon.abilityIndex = 2;
|
||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
||||
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.FALSE_SWIPE);
|
||||
// Player gets hit by False Swipe and eats its own Sitrus Berry
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
||||
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when a berry is stolen", async () => {
|
||||
await game.classicMode.startBattle();
|
||||
it("should activate when a berry is eaten, even if Berry Pouch preserves the berry", async () => {
|
||||
game.override.enemyMoveset(Moves.FALSE_SWIPE)
|
||||
.startingModifier([{ name: "BERRY_POUCH", count: 5850 }]);
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Player gets hit by False Swipe and eats its own Sitrus Berry
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(getHeldItemCount(playerPokemon)).toBe(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate for the target, and not the stealer, when a berry is stolen", async () => {
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Player uses Pluck and eats the opponent's berry
|
||||
game.move.select(Moves.PLUCK);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
|
||||
});
|
||||
|
||||
it("should activate when an item is knocked off", async () => {
|
||||
await game.classicMode.startBattle();
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Player uses Knock Off and removes the opponent's item
|
||||
game.move.select(Moves.KNOCK_OFF);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is stolen via attacking ability", async () => {
|
||||
game.override
|
||||
.ability(Abilities.MAGICIAN)
|
||||
.startingHeldItems([
|
||||
{ name: "MULTI_LENS", count: 3 },
|
||||
]);
|
||||
await game.classicMode.startBattle();
|
||||
.startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.POPULATION_BOMB);
|
||||
// Player steals the opponent's item via ability Magician
|
||||
game.move.select(Moves.FALSE_SWIPE);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is stolen via defending ability", async () => {
|
||||
game.override
|
||||
.startingLevel(45)
|
||||
.enemyAbility(Abilities.PICKPOCKET)
|
||||
.startingHeldItems([
|
||||
{ name: "MULTI_LENS", count: 3 },
|
||||
{ name: "SOUL_DEW", count: 1 },
|
||||
{ name: "LUCKY_EGG", count: 1 },
|
||||
]);
|
||||
await game.classicMode.startBattle();
|
||||
.enemyHeldItems([]); // Remove opponent's full stacks of held items so it can steal player's held items
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
playerPokemon.abilityIndex = 2;
|
||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
||||
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.POPULATION_BOMB);
|
||||
// Player's item gets stolen via ability Pickpocket
|
||||
game.move.select(Moves.FALSE_SWIPE);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
||||
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is stolen via move", async () => {
|
||||
vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]); // give Thief 100% steal rate
|
||||
game.override.startingHeldItems([
|
||||
{ name: "MULTI_LENS", count: 3 },
|
||||
]);
|
||||
await game.classicMode.startBattle();
|
||||
game.override.moveset(Moves.THIEF)
|
||||
.startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Player uses Thief and steals the opponent's item
|
||||
game.move.select(Moves.THIEF);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is stolen via grip claw", async () => {
|
||||
game.override
|
||||
.startingLevel(5)
|
||||
.startingHeldItems([
|
||||
{ name: "GRIP_CLAW", count: 5 },
|
||||
{ name: "MULTI_LENS", count: 3 },
|
||||
])
|
||||
.enemyHeldItems([
|
||||
{ name: "SOUL_DEW", count: 1 },
|
||||
{ name: "LUCKY_EGG", count: 1 },
|
||||
{ name: "LEFTOVERS", count: 1 },
|
||||
{ name: "GRIP_CLAW", count: 1 },
|
||||
{ name: "MULTI_LENS", count: 1 },
|
||||
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
|
||||
{ name: "BERRY", type: BerryType.LUM, count: 1 },
|
||||
]);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
while (enemyPokemon.getHeldItems().length === enemyHeldItemCt) {
|
||||
game.move.select(Moves.POPULATION_BOMB);
|
||||
await game.toNextTurn();
|
||||
}
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should not activate when a neutralizing ability is present", async () => {
|
||||
game.override.enemyAbility(Abilities.NEUTRALIZING_GAS);
|
||||
await game.classicMode.startBattle();
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
const gripClaw = playerPokemon.getHeldItems()[0] as ContactHeldItemTransferChanceModifier;
|
||||
vi.spyOn(gripClaw, "chance", "get").mockReturnValue(100);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Player steals the opponent's item using Grip Claw
|
||||
game.move.select(Moves.FALSE_SWIPE);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed);
|
||||
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should not activate when a neutralizing ability is present", async () => {
|
||||
game.override.enemyAbility(Abilities.NEUTRALIZING_GAS)
|
||||
.enemyMoveset(Moves.FALSE_SWIPE);
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Player gets hit by False Swipe and eats Sitrus Berry, which should not trigger Unburden
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
|
||||
expect(playerPokemon.getTag(BattlerTagType.UNBURDEN)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should activate when a move that consumes a berry is used", async () => {
|
||||
game.override.enemyMoveset([ Moves.STUFF_CHEEKS ]);
|
||||
await game.classicMode.startBattle();
|
||||
game.override.moveset(Moves.STUFF_CHEEKS);
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const playerHeldItemCt = getHeldItemCount(playerPokemon);
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Player uses Stuff Cheeks and eats its own berry
|
||||
// Caution: Do not test this using opponent, there is a known issue where opponent can randomly generate with Salac Berry
|
||||
game.move.select(Moves.STUFF_CHEEKS);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItemCt);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||
});
|
||||
|
||||
it("should deactivate when a neutralizing gas user enters the field", async () => {
|
||||
it("should deactivate temporarily when a neutralizing gas user is on the field", async () => {
|
||||
game.override
|
||||
.battleType("double")
|
||||
.moveset([ Moves.SPLASH ]);
|
||||
.ability(Abilities.NONE); // Disable ability override so that we can properly set abilities below
|
||||
await game.classicMode.startBattle([ Species.TREECKO, Species.MEOWTH, Species.WEEZING ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerParty();
|
||||
const treecko = playerPokemon[0];
|
||||
const weezing = playerPokemon[2];
|
||||
treecko.abilityIndex = 2;
|
||||
weezing.abilityIndex = 1;
|
||||
const playerHeldItems = treecko.getHeldItems().length;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const [ treecko, _meowth, weezing ] = game.scene.getPlayerParty();
|
||||
treecko.abilityIndex = 2; // Treecko has Unburden
|
||||
weezing.abilityIndex = 1; // Weezing has Neutralizing Gas
|
||||
const playerHeldItems = getHeldItemCount(treecko);
|
||||
const initialPlayerSpeed = treecko.getStat(Stat.SPD);
|
||||
|
||||
// Turn 1: Treecko gets hit by False Swipe and eats Sitrus Berry, activating Unburden
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.move.select(Moves.SPLASH, 1);
|
||||
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
|
||||
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(treecko.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
||||
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||
|
||||
// Turn 2: Switch Meowth to Weezing, activating Neutralizing Gas
|
||||
await game.toNextTurn();
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.doSwitchPokemon(2);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(treecko.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed);
|
||||
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
|
||||
|
||||
// Turn 3: Switch Weezing to Meowth, deactivating Neutralizing Gas
|
||||
await game.toNextTurn();
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.doSwitchPokemon(2);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||
});
|
||||
|
||||
it("should not activate when passing a baton to a teammate switching in", async () => {
|
||||
game.override.startingHeldItems([{ name: "BATON" }])
|
||||
.moveset(Moves.BATON_PASS);
|
||||
await game.classicMode.startBattle([ Species.TREECKO, Species.PURRLOIN ]);
|
||||
|
||||
const [ treecko, purrloin ] = game.scene.getPlayerParty();
|
||||
const initialTreeckoSpeed = treecko.getStat(Stat.SPD);
|
||||
const initialPurrloinSpeed = purrloin.getStat(Stat.SPD);
|
||||
const unburdenAttr = treecko.getAbilityAttrs(PostItemLostAbAttr)[0];
|
||||
vi.spyOn(unburdenAttr, "applyPostItemLost");
|
||||
|
||||
// Player uses Baton Pass, which also passes the Baton item
|
||||
game.move.select(Moves.BATON_PASS);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(getHeldItemCount(treecko)).toBe(0);
|
||||
expect(getHeldItemCount(purrloin)).toBe(1);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialTreeckoSpeed);
|
||||
expect(purrloin.getEffectiveStat(Stat.SPD)).toBe(initialPurrloinSpeed);
|
||||
expect(unburdenAttr.applyPostItemLost).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should not speed up a Pokemon after it loses the ability Unburden", async () => {
|
||||
game.override.enemyMoveset([ Moves.FALSE_SWIPE, Moves.WORRY_SEED ]);
|
||||
await game.classicMode.startBattle([ Species.PURRLOIN ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Turn 1: Get hit by False Swipe and eat Sitrus Berry, activating Unburden
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.forceEnemyMove(Moves.FALSE_SWIPE);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||
|
||||
// Turn 2: Get hit by Worry Seed, deactivating Unburden
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.forceEnemyMove(Moves.WORRY_SEED);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
|
||||
});
|
||||
|
||||
it("should activate when a reviver seed is used", async () => {
|
||||
game.override.startingHeldItems([{ name: "REVIVER_SEED" }])
|
||||
.enemyMoveset([ Moves.WING_ATTACK ]);
|
||||
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
// Turn 1: Get hit by Wing Attack and faint, activating Reviver Seed
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||
});
|
||||
|
||||
// test for `.bypassFaint()` - singles
|
||||
it("shouldn't persist when revived normally if activated while fainting", async () => {
|
||||
game.override.enemyMoveset([ Moves.SPLASH, Moves.THIEF ]);
|
||||
await game.classicMode.startBattle([ Species.TREECKO, Species.FEEBAS ]);
|
||||
|
||||
const treecko = game.scene.getPlayerPokemon()!;
|
||||
const treeckoInitialHeldItems = getHeldItemCount(treecko);
|
||||
const initialSpeed = treecko.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.forceEnemyMove(Moves.THIEF);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toNextTurn();
|
||||
|
||||
game.doRevivePokemon(1);
|
||||
game.doSwitchPokemon(1);
|
||||
await game.forceEnemyMove(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(game.scene.getPlayerPokemon()!).toBe(treecko);
|
||||
expect(getHeldItemCount(treecko)).toBeLessThan(treeckoInitialHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialSpeed);
|
||||
});
|
||||
|
||||
// test for `.bypassFaint()` - doubles
|
||||
it("shouldn't persist when revived by revival blessing if activated while fainting", async () => {
|
||||
game.override
|
||||
.battleType("double")
|
||||
.enemyMoveset([ Moves.SPLASH, Moves.THIEF ])
|
||||
.moveset([ Moves.SPLASH, Moves.REVIVAL_BLESSING ])
|
||||
.startingHeldItems([{ name: "WIDE_LENS" }]);
|
||||
await game.classicMode.startBattle([ Species.TREECKO, Species.FEEBAS, Species.MILOTIC ]);
|
||||
|
||||
const treecko = game.scene.getPlayerField()[0];
|
||||
const treeckoInitialHeldItems = getHeldItemCount(treecko);
|
||||
const initialSpeed = treecko.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.move.select(Moves.REVIVAL_BLESSING, 1);
|
||||
await game.forceEnemyMove(Moves.THIEF, BattlerIndex.PLAYER);
|
||||
await game.forceEnemyMove(Moves.SPLASH);
|
||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]);
|
||||
game.doSelectPartyPokemon(0, "MoveEffectPhase");
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(game.scene.getPlayerField()[0]).toBe(treecko);
|
||||
expect(getHeldItemCount(treecko)).toBeLessThan(treeckoInitialHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialSpeed);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
import { BattlerIndex } from "#app/battle";
|
||||
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 { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
@ -34,78 +28,60 @@ describe("Abilities - ZEN MODE", () => {
|
|||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.battleType("single")
|
||||
.enemySpecies(Species.RATTATA)
|
||||
.enemyAbility(Abilities.HYDRATION)
|
||||
.disableCrits()
|
||||
.enemySpecies(Species.MAGIKARP)
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.enemyLevel(5)
|
||||
.ability(Abilities.ZEN_MODE)
|
||||
.startingLevel(100)
|
||||
.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 () => {
|
||||
await game.classicMode.startBattle([ Species.DARMANITAN ]);
|
||||
const player = game.scene.getPlayerPokemon()!;
|
||||
player.stats[Stat.HP] = 100;
|
||||
player.hp = 100;
|
||||
expect(player.formIndex).toBe(baseForm);
|
||||
const darmanitan = game.scene.getPlayerPokemon()!;
|
||||
expect(darmanitan.formIndex).toBe(baseForm);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(player.hp).toBeLessThan(100);
|
||||
expect(player.formIndex).toBe(baseForm);
|
||||
expect(darmanitan.getHpRatio()).toBeLessThan(1);
|
||||
expect(darmanitan.getHpRatio()).toBeGreaterThan(0.5);
|
||||
expect(darmanitan.formIndex).toBe(baseForm);
|
||||
});
|
||||
|
||||
it("should change form when falling below 50% HP", async () => {
|
||||
await game.classicMode.startBattle([ Species.DARMANITAN ]);
|
||||
|
||||
const player = game.scene.getPlayerPokemon()!;
|
||||
player.stats[Stat.HP] = 1000;
|
||||
player.hp = 100;
|
||||
expect(player.formIndex).toBe(baseForm);
|
||||
const darmanitan = game.scene.getPlayerPokemon()!;
|
||||
darmanitan.hp = (darmanitan.getMaxHp() / 2) + 1;
|
||||
expect(darmanitan.formIndex).toBe(baseForm);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to("QuietFormChangePhase");
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
|
||||
expect(player.hp).not.toBe(100);
|
||||
expect(player.formIndex).toBe(zenForm);
|
||||
expect(darmanitan.getHpRatio()).toBeLessThan(0.5);
|
||||
expect(darmanitan.formIndex).toBe(zenForm);
|
||||
});
|
||||
|
||||
it("should stay zen mode when fainted", async () => {
|
||||
await game.classicMode.startBattle([ Species.DARMANITAN, Species.CHARIZARD ]);
|
||||
const player = game.scene.getPlayerPokemon()!;
|
||||
player.stats[Stat.HP] = 1000;
|
||||
player.hp = 100;
|
||||
expect(player.formIndex).toBe(baseForm);
|
||||
const darmanitan = game.scene.getPlayerPokemon()!;
|
||||
darmanitan.hp = (darmanitan.getMaxHp() / 2) + 1;
|
||||
expect(darmanitan.formIndex).toBe(baseForm);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to(DamagePhase, false);
|
||||
const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
|
||||
damagePhase.updateAmount(80);
|
||||
await game.phaseInterceptor.to("QuietFormChangePhase");
|
||||
expect(darmanitan.getHpRatio()).toBeLessThan(0.5);
|
||||
expect(darmanitan.formIndex).toBe(zenForm);
|
||||
|
||||
expect(player.hp).not.toBe(100);
|
||||
expect(player.formIndex).toBe(zenForm);
|
||||
|
||||
await game.killPokemon(player);
|
||||
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");
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.killPokemon(darmanitan);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(darmanitan.isFainted()).toBe(true);
|
||||
expect(game.scene.getPlayerParty()[1].formIndex).toBe(zenForm);
|
||||
});
|
||||
|
||||
|
@ -117,7 +93,8 @@ describe("Abilities - ZEN MODE", () => {
|
|||
|
||||
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);
|
||||
|
||||
darmanitan.hp = 0;
|
||||
|
@ -126,9 +103,7 @@ describe("Abilities - ZEN MODE", () => {
|
|||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.doKillOpponents();
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
game.doSelectModifier();
|
||||
await game.phaseInterceptor.to("QuietFormChangePhase");
|
||||
await game.toNextWave();
|
||||
|
||||
expect(darmanitan.formIndex).toBe(baseForm);
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -74,29 +74,4 @@ describe("Moves - Beat Up", () => {
|
|||
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);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ describe("Moves - Ceaseless Edge", () => {
|
|||
game.override.startingLevel(100);
|
||||
game.override.enemyLevel(100);
|
||||
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);
|
||||
|
||||
});
|
||||
|
@ -42,7 +42,7 @@ describe("Moves - Ceaseless Edge", () => {
|
|||
test(
|
||||
"move should hit and apply spikes",
|
||||
async () => {
|
||||
await game.startBattle([ Species.ILLUMISE ]);
|
||||
await game.classicMode.startBattle([ Species.ILLUMISE ]);
|
||||
|
||||
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",
|
||||
async () => {
|
||||
game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
|
||||
await game.startBattle([ Species.ILLUMISE ]);
|
||||
await game.classicMode.startBattle([ Species.ILLUMISE ]);
|
||||
|
||||
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",
|
||||
async () => {
|
||||
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);
|
||||
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;
|
||||
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;
|
||||
expect(tagAfter instanceof ArenaTrapTag).toBeTruthy();
|
||||
expect(tagAfter.layers).toBe(2);
|
||||
|
|
|
@ -2,7 +2,6 @@ import { Stat } from "#enums/stat";
|
|||
import { Type } from "#enums/type";
|
||||
import { Species } from "#app/enums/species";
|
||||
import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
|
||||
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
|
@ -114,14 +113,4 @@ describe("Moves - Dragon Rage", () => {
|
|||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -98,7 +98,7 @@ describe("Moves - Electro Shot", () => {
|
|||
game.move.select(Moves.ELECTRO_SHOT);
|
||||
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(playerPokemon.turnData.hitCount).toBe(2);
|
||||
expect(playerPokemon.turnData.hitCount).toBe(1);
|
||||
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ import { BattlerIndex } from "#app/battle";
|
|||
import { Abilities } from "#app/enums/abilities";
|
||||
import { Moves } from "#app/enums/moves";
|
||||
import { Species } from "#app/enums/species";
|
||||
import { Challenges } from "#enums/challenges";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
@ -97,8 +98,7 @@ describe("Moves - Freeze-Dry", () => {
|
|||
expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
|
||||
});
|
||||
|
||||
// enable if this is ever fixed (lol)
|
||||
it.todo("should deal 2x damage to water types under Normalize", async () => {
|
||||
it("should deal 2x damage to water type under Normalize", async () => {
|
||||
game.override.ability(Abilities.NORMALIZE);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
|
@ -112,8 +112,39 @@ describe("Moves - Freeze-Dry", () => {
|
|||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
|
||||
});
|
||||
|
||||
// enable once Electrify is implemented (and the interaction is fixed, as above)
|
||||
it.todo("should deal 2x damage to water types under Electrify", async () => {
|
||||
it("should deal 0.25x damage to rock/steel type under Normalize", 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 ]);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
|
@ -126,4 +157,128 @@ describe("Moves - Freeze-Dry", () => {
|
|||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
|
@ -28,7 +28,8 @@ describe("Pokerogue Session Savedata API", () => {
|
|||
describe("Newclear", () => {
|
||||
const params: NewClearSessionSavedataRequest = {
|
||||
clientSessionId: "test-session-id",
|
||||
slot: 3,
|
||||
isVictory: true,
|
||||
slot: 3
|
||||
};
|
||||
|
||||
it("should return true on SUCCESS", async () => {
|
||||
|
|
|
@ -55,6 +55,11 @@ import {
|
|||
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
|
||||
import { PartyExpPhase } from "#app/phases/party-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 {
|
||||
phaseTarget?: string;
|
||||
|
@ -113,10 +118,15 @@ type PhaseClass =
|
|||
| typeof MysteryEncounterBattlePhase
|
||||
| typeof MysteryEncounterRewardsPhase
|
||||
| typeof PostMysteryEncounterPhase
|
||||
| typeof RibbonModifierRewardPhase
|
||||
| typeof GameOverModifierRewardPhase
|
||||
| typeof ModifierRewardPhase
|
||||
| typeof PartyExpPhase
|
||||
| typeof ExpPhase
|
||||
| typeof EncounterPhase;
|
||||
| typeof EncounterPhase
|
||||
| typeof GameOverPhase
|
||||
| typeof UnlockPhase
|
||||
| typeof PostGameOverPhase;
|
||||
|
||||
type PhaseString =
|
||||
| "LoginPhase"
|
||||
|
@ -167,10 +177,15 @@ type PhaseString =
|
|||
| "MysteryEncounterBattlePhase"
|
||||
| "MysteryEncounterRewardsPhase"
|
||||
| "PostMysteryEncounterPhase"
|
||||
| "RibbonModifierRewardPhase"
|
||||
| "GameOverModifierRewardPhase"
|
||||
| "ModifierRewardPhase"
|
||||
| "PartyExpPhase"
|
||||
| "ExpPhase"
|
||||
| "EncounterPhase";
|
||||
| "EncounterPhase"
|
||||
| "GameOverPhase"
|
||||
| "UnlockPhase"
|
||||
| "PostGameOverPhase";
|
||||
|
||||
type PhaseInterceptorPhase = PhaseClass | PhaseString;
|
||||
|
||||
|
@ -245,10 +260,15 @@ export default class PhaseInterceptor {
|
|||
[ MysteryEncounterBattlePhase, this.startPhase ],
|
||||
[ MysteryEncounterRewardsPhase, this.startPhase ],
|
||||
[ PostMysteryEncounterPhase, this.startPhase ],
|
||||
[ RibbonModifierRewardPhase, this.startPhase ],
|
||||
[ GameOverModifierRewardPhase, this.startPhase ],
|
||||
[ ModifierRewardPhase, this.startPhase ],
|
||||
[ PartyExpPhase, this.startPhase ],
|
||||
[ ExpPhase, this.startPhase ],
|
||||
[ EncounterPhase, this.startPhase ],
|
||||
[ GameOverPhase, this.startPhase ],
|
||||
[ UnlockPhase, this.startPhase ],
|
||||
[ PostGameOverPhase, this.startPhase ],
|
||||
];
|
||||
|
||||
private endBySetMode = [
|
||||
|
|