Merge branch 'pagefaultgames:main' into summaryOption1
This commit is contained in:
commit
9269649edf
|
@ -3265,6 +3265,11 @@
|
|||
1,
|
||||
1
|
||||
],
|
||||
"123": [
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"129": [
|
||||
0,
|
||||
1,
|
||||
|
@ -6638,6 +6643,11 @@
|
|||
1,
|
||||
1
|
||||
],
|
||||
"123": [
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"129": [
|
||||
0,
|
||||
1,
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"0": {
|
||||
"425a21": "632929",
|
||||
"bde673": "e67373",
|
||||
"e6d6ad": "b5b5ce",
|
||||
"9c8c31": "632929",
|
||||
"8cce73": "f76b6b",
|
||||
"101010": "101010",
|
||||
"fff7d6": "ffffff",
|
||||
"5a9c4a": "d63a3a",
|
||||
"bdbdbd": "bdbdbd",
|
||||
"c5a573": "b5b5ce",
|
||||
"dedede": "dedede",
|
||||
"ffffff": "ffffff",
|
||||
"737373": "737373"
|
||||
},
|
||||
"1": {
|
||||
"425a21": "484e75",
|
||||
"bde673": "bdbdbd",
|
||||
"e6d6ad": "e6d6ad",
|
||||
"9c8c31": "9c8c31",
|
||||
"8cce73": "92b0db",
|
||||
"101010": "101010",
|
||||
"fff7d6": "fff7d6",
|
||||
"5a9c4a": "7b94d6",
|
||||
"bdbdbd": "ffffff",
|
||||
"c5a573": "9cc5ff",
|
||||
"dedede": "dedede",
|
||||
"ffffff": "ffffff",
|
||||
"737373": "737373"
|
||||
},
|
||||
"2": {
|
||||
"425a21": "8f3907",
|
||||
"bde673": "f8f581",
|
||||
"e6d6ad": "e6d6ad",
|
||||
"9c8c31": "9c8c31",
|
||||
"8cce73": "f0c947",
|
||||
"101010": "101010",
|
||||
"fff7d6": "fff7d6",
|
||||
"5a9c4a": "e6a027",
|
||||
"bdbdbd": "bdbdbd",
|
||||
"c5a573": "c5a573",
|
||||
"dedede": "dedede",
|
||||
"ffffff": "ffffff",
|
||||
"737373": "737373"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"0": {
|
||||
"425a21": "632929",
|
||||
"bde673": "f76b6b",
|
||||
"101010": "101010",
|
||||
"9c8c31": "9494a5",
|
||||
"fff7d6": "ffffff",
|
||||
"8cce73": "d63a3a",
|
||||
"e6d6ad": "b5b5ce",
|
||||
"5a9c4a": "a52929",
|
||||
"ffffff": "ffffff",
|
||||
"dedede": "dedede",
|
||||
"bdbdbd": "bdbdbd",
|
||||
"737373": "737373"
|
||||
},
|
||||
"1": {
|
||||
"425a21": "484e75",
|
||||
"bde673": "7c9ac5",
|
||||
"101010": "101010",
|
||||
"9c8c31": "9c8c31",
|
||||
"fff7d6": "fff7d6",
|
||||
"8cce73": "92b0db",
|
||||
"e6d6ad": "e6d6ad",
|
||||
"5a9c4a": "7b94d6",
|
||||
"ffffff": "ffffff",
|
||||
"dedede": "dedede",
|
||||
"bdbdbd": "bdbdbd",
|
||||
"737373": "737373"
|
||||
},
|
||||
"2": {
|
||||
"425a21": "8f3907",
|
||||
"bde673": "f8f581",
|
||||
"101010": "101010",
|
||||
"9c8c31": "9c8c31",
|
||||
"fff7d6": "fff7d6",
|
||||
"8cce73": "f0c947",
|
||||
"e6d6ad": "e6d6ad",
|
||||
"5a9c4a": "e6a027",
|
||||
"ffffff": "ffffff",
|
||||
"dedede": "f0c947",
|
||||
"bdbdbd": "bdbdbd",
|
||||
"737373": "737373"
|
||||
}
|
||||
}
|
|
@ -1446,7 +1446,7 @@ export class FieldMovePowerBoostAbAttr extends AbAttr {
|
|||
* Boosts the power of a specific type of move.
|
||||
* @extends FieldMovePowerBoostAbAttr
|
||||
*/
|
||||
export class FieldMoveTypePowerBoostAbAttr extends FieldMovePowerBoostAbAttr {
|
||||
export class PreAttackFieldMoveTypePowerBoostAbAttr extends FieldMovePowerBoostAbAttr {
|
||||
/**
|
||||
* @param boostedType - The type of move that will receive the power boost.
|
||||
* @param powerMultiplier - The multiplier to apply to the move's power, defaults to 1.5 if not provided.
|
||||
|
@ -1456,6 +1456,18 @@ export class FieldMoveTypePowerBoostAbAttr extends FieldMovePowerBoostAbAttr {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Boosts the power of a specific type of move for all Pokemon in the field.
|
||||
* @extends PreAttackFieldMoveTypePowerBoostAbAttr
|
||||
*/
|
||||
export class FieldMoveTypePowerBoostAbAttr extends PreAttackFieldMoveTypePowerBoostAbAttr { }
|
||||
|
||||
/**
|
||||
* Boosts the power of a specific type of move for the user and its allies.
|
||||
* @extends PreAttackFieldMoveTypePowerBoostAbAttr
|
||||
*/
|
||||
export class UserFieldMoveTypePowerBoostAbAttr extends PreAttackFieldMoveTypePowerBoostAbAttr { }
|
||||
|
||||
/**
|
||||
* Boosts the power of moves in specified categories.
|
||||
* @extends FieldMovePowerBoostAbAttr
|
||||
|
@ -4964,8 +4976,7 @@ export function initAbilities() {
|
|||
new Ability(Abilities.SCREEN_CLEANER, 8)
|
||||
.attr(PostSummonRemoveArenaTagAbAttr, [ArenaTagType.AURORA_VEIL, ArenaTagType.LIGHT_SCREEN, ArenaTagType.REFLECT]),
|
||||
new Ability(Abilities.STEELY_SPIRIT, 8)
|
||||
.attr(MoveTypePowerBoostAbAttr, Type.STEEL)
|
||||
.partial(),
|
||||
.attr(UserFieldMoveTypePowerBoostAbAttr, Type.STEEL),
|
||||
new Ability(Abilities.PERISH_BODY, 8)
|
||||
.attr(PostDefendPerishSongAbAttr, 4),
|
||||
new Ability(Abilities.WANDERING_SPIRIT, 8)
|
||||
|
|
|
@ -23,7 +23,7 @@ import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HelpingHandTag
|
|||
import { WeatherType } from "../data/weather";
|
||||
import { TempBattleStat } from "../data/temp-battle-stat";
|
||||
import { ArenaTagSide, WeakenMoveScreenTag, WeakenMoveTypeTag } from "../data/arena-tag";
|
||||
import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldBattleStatMultiplierAbAttrs, FieldMultiplyBattleStatAbAttr, AllyMoveCategoryPowerBoostAbAttr, FieldMoveTypePowerBoostAbAttr, AddSecondStrikeAbAttr } from "../data/ability";
|
||||
import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldBattleStatMultiplierAbAttrs, FieldMultiplyBattleStatAbAttr, AllyMoveCategoryPowerBoostAbAttr, FieldMoveTypePowerBoostAbAttr, AddSecondStrikeAbAttr, UserFieldMoveTypePowerBoostAbAttr } from "../data/ability";
|
||||
import PokemonData from "../system/pokemon-data";
|
||||
import { BattlerIndex } from "../battle";
|
||||
import { Mode } from "../ui/ui";
|
||||
|
@ -1788,6 +1788,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
aura.applyPreAttack(null, null, null, move, [power]);
|
||||
}
|
||||
|
||||
const alliedField: Pokemon[] = source instanceof PlayerPokemon ? this.scene.getPlayerField() : this.scene.getEnemyField();
|
||||
alliedField.forEach(p => applyPreAttackAbAttrs(UserFieldMoveTypePowerBoostAbAttr, p, this, move, power));
|
||||
|
||||
power.value *= typeChangeMovePowerMultiplier.value;
|
||||
|
||||
if (!typeless) {
|
||||
|
|
|
@ -2116,14 +2116,38 @@ export class SwitchEffectTransferModifier extends PokemonHeldItemModifier {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract class for held items that steal other Pokemon's items.
|
||||
* @see {@linkcode TurnHeldItemTransferModifier}
|
||||
* @see {@linkcode ContactHeldItemTransferChanceModifier}
|
||||
*/
|
||||
export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier {
|
||||
constructor(type: ModifierType, pokemonId: integer, stackCount?: integer) {
|
||||
super(type, pokemonId, stackCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the targets to transfer items from when this applies.
|
||||
* @param args\[0\] the {@linkcode Pokemon} holding this item
|
||||
* @returns the opponents of the source {@linkcode Pokemon}
|
||||
*/
|
||||
getTargets(args: any[]): Pokemon[] {
|
||||
const pokemon = args[0];
|
||||
|
||||
return pokemon instanceof Pokemon
|
||||
? pokemon.getOpponents()
|
||||
: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Steals an item from a set of target Pokemon.
|
||||
* This prioritizes high-tier held items when selecting the item to steal.
|
||||
* @param args \[0\] The {@linkcode Pokemon} holding this item
|
||||
* @returns true if an item was stolen; false otherwise.
|
||||
*/
|
||||
apply(args: any[]): boolean {
|
||||
const pokemon = args[0] as Pokemon;
|
||||
const opponents = pokemon.getOpponents();
|
||||
const opponents = this.getTargets(args);
|
||||
|
||||
if (!opponents.length) {
|
||||
return false;
|
||||
|
@ -2180,6 +2204,11 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier {
|
|||
abstract getTransferMessage(pokemon: Pokemon, targetPokemon: Pokemon, item: ModifierTypes.ModifierType): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier for held items that steal items from the enemy at the end of
|
||||
* each turn.
|
||||
* @see {@linkcode modifierTypes[MINI_BLACK_HOLE]}
|
||||
*/
|
||||
export class TurnHeldItemTransferModifier extends HeldItemTransferModifier {
|
||||
constructor(type: ModifierType, pokemonId: integer, stackCount?: integer) {
|
||||
super(type, pokemonId, stackCount);
|
||||
|
@ -2210,6 +2239,12 @@ export class TurnHeldItemTransferModifier extends HeldItemTransferModifier {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier for held items that add a chance to steal items from the target of a
|
||||
* successful attack.
|
||||
* @see {@linkcode modifierTypes[GRIP_CLAW]}
|
||||
* @see {@linkcode HeldItemTransferModifier}
|
||||
*/
|
||||
export class ContactHeldItemTransferChanceModifier extends HeldItemTransferModifier {
|
||||
private chance: number;
|
||||
|
||||
|
@ -2219,6 +2254,20 @@ export class ContactHeldItemTransferChanceModifier extends HeldItemTransferModif
|
|||
this.chance = chancePercent / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the target to steal items from when this applies.
|
||||
* @param args\[0\] The {@linkcode Pokemon} holding this item
|
||||
* @param args\[1\] The {@linkcode Pokemon} the holder is targeting with an attack
|
||||
* @returns The target (args[1]) stored in array format for use in {@linkcode HeldItemTransferModifier.apply}
|
||||
*/
|
||||
getTargets(args: any[]): Pokemon[] {
|
||||
const target = args[1];
|
||||
|
||||
return target instanceof Pokemon
|
||||
? [ target ]
|
||||
: [];
|
||||
}
|
||||
|
||||
matchType(modifier: Modifier): boolean {
|
||||
return modifier instanceof ContactHeldItemTransferChanceModifier;
|
||||
}
|
||||
|
|
|
@ -2966,7 +2966,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||
})).then(() => {
|
||||
applyPostAttackAbAttrs(PostAttackAbAttr, user, target, this.move.getMove(), hitResult).then(() => {
|
||||
if (this.move.getMove() instanceof AttackMove) {
|
||||
this.scene.applyModifiers(ContactHeldItemTransferChanceModifier, this.player, user, target.getFieldIndex());
|
||||
this.scene.applyModifiers(ContactHeldItemTransferChanceModifier, this.player, user, target);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
|
@ -3095,7 +3095,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||
applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, user, BattleStat.ACC, accuracyMultiplier, this.move.getMove());
|
||||
|
||||
const evasionMultiplier = new Utils.NumberHolder(1);
|
||||
applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, this.getTarget(), BattleStat.EVA, evasionMultiplier);
|
||||
applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, target, BattleStat.EVA, evasionMultiplier);
|
||||
|
||||
accuracyMultiplier.value /= evasionMultiplier.value;
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
||||
import GameManager from "../utils/gameManager";
|
||||
import * as Overrides from "#app/overrides";
|
||||
import { Species } from "#enums/species";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { getMovePosition } from "../utils/gameManagerUtils";
|
||||
import { CommandPhase, MoveEffectPhase, MoveEndPhase } from "#app/phases.js";
|
||||
import { BattleStat } from "#app/data/battle-stat.js";
|
||||
import { WeatherType } from "#app/data/weather.js";
|
||||
import { BattleStatMultiplierAbAttr, allAbilities } from "#app/data/ability.js";
|
||||
|
||||
const TIMEOUT = 20 * 1000;
|
||||
|
||||
describe("Abilities - Sand Veil", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
vi.spyOn(Overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
||||
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH]);
|
||||
vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.MEOWSCARADA);
|
||||
vi.spyOn(Overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.INSOMNIA);
|
||||
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TWISTER, Moves.TWISTER, Moves.TWISTER, Moves.TWISTER]);
|
||||
vi.spyOn(Overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||||
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||||
vi.spyOn(Overrides, "WEATHER_OVERRIDE", "get").mockReturnValue(WeatherType.SANDSTORM);
|
||||
});
|
||||
|
||||
test(
|
||||
"ability should increase the evasiveness of the source",
|
||||
async () => {
|
||||
await game.startBattle([Species.SNORLAX, Species.BLISSEY]);
|
||||
|
||||
const leadPokemon = game.scene.getPlayerField();
|
||||
leadPokemon.forEach(p => expect(p).toBeDefined());
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyField();
|
||||
enemyPokemon.forEach(p => expect(p).toBeDefined());
|
||||
|
||||
vi.spyOn(leadPokemon[0], "getAbility").mockReturnValue(allAbilities[Abilities.SAND_VEIL]);
|
||||
|
||||
const sandVeilAttr = allAbilities[Abilities.SAND_VEIL].getAttrs(BattleStatMultiplierAbAttr)[0];
|
||||
vi.spyOn(sandVeilAttr, "applyBattleStat").mockImplementation(
|
||||
(pokemon, passive, battleStat, statValue, args) => {
|
||||
if (battleStat === BattleStat.EVA && game.scene.arena.weather?.weatherType === WeatherType.SANDSTORM) {
|
||||
statValue.value *= -1; // will make all attacks miss
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
expect(leadPokemon[0].hasAbility(Abilities.SAND_VEIL)).toBe(true);
|
||||
expect(leadPokemon[1].hasAbility(Abilities.SAND_VEIL)).toBe(false);
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||
|
||||
await game.phaseInterceptor.to(CommandPhase);
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
|
||||
await game.phaseInterceptor.to(MoveEndPhase, false);
|
||||
|
||||
expect(leadPokemon[0].hp).toBe(leadPokemon[0].getMaxHp());
|
||||
expect(leadPokemon[1].hp).toBeLessThan(leadPokemon[1].getMaxHp());
|
||||
}, TIMEOUT
|
||||
);
|
||||
});
|
|
@ -0,0 +1,115 @@
|
|||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import Phaser from "phaser";
|
||||
import GameManager from "#app/test/utils/gameManager";
|
||||
import * as overrides from "#app/overrides";
|
||||
import { Species } from "#enums/species";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
|
||||
import Pokemon, { PlayerPokemon } from "#app/field/pokemon.js";
|
||||
import Move, { allMoves } from "#app/data/move.js";
|
||||
import { NumberHolder } from "#app/utils.js";
|
||||
import { allAbilities, applyPreAttackAbAttrs, UserFieldMoveTypePowerBoostAbAttr } from "#app/data/ability.js";
|
||||
import { Abilities } from "#app/enums/abilities.js";
|
||||
|
||||
describe("Abilities - Steely Spirit", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
const steelySpiritMultiplier = 1.5;
|
||||
const moveToCheck = Moves.IRON_HEAD;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
||||
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.MAGIKARP);
|
||||
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.IRON_HEAD, Moves.SPLASH]);
|
||||
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
|
||||
});
|
||||
|
||||
it("increases Steel-type moves used by the user and its allies", async () => {
|
||||
await game.startBattle([Species.MAGIKARP, Species.PERRSERKER]);
|
||||
const perserrker = game.scene.getPlayerField()[1];
|
||||
|
||||
vi.spyOn(perserrker, "getAbility").mockReturnValue(allAbilities[Abilities.STEELY_SPIRIT]);
|
||||
|
||||
expect(perserrker.hasAbility(Abilities.STEELY_SPIRIT)).toBe(true);
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, moveToCheck));
|
||||
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
||||
|
||||
const mockedMovePower = getMockedMovePower(game.scene.getEnemyPokemon(), perserrker, allMoves[moveToCheck]);
|
||||
|
||||
expect(mockedMovePower).toBe(allMoves[moveToCheck].power * steelySpiritMultiplier);
|
||||
});
|
||||
|
||||
it("stacks if multiple users with this ability are on the field.", async () => {
|
||||
await game.startBattle([Species.PERRSERKER, Species.PERRSERKER]);
|
||||
|
||||
game.scene.getPlayerField().forEach(p => {
|
||||
vi.spyOn(p, "getAbility").mockReturnValue(allAbilities[Abilities.STEELY_SPIRIT]);
|
||||
});
|
||||
|
||||
expect(game.scene.getPlayerField().every(p => p.hasAbility(Abilities.STEELY_SPIRIT))).toBe(true);
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, moveToCheck));
|
||||
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
||||
|
||||
const mockedMovePower = getMockedMovePower(game.scene.getEnemyPokemon(), game.scene.getPlayerPokemon(), allMoves[moveToCheck]);
|
||||
|
||||
expect(mockedMovePower).toBe(allMoves[moveToCheck].power * Math.pow(steelySpiritMultiplier, 2));
|
||||
});
|
||||
|
||||
it("does not take effect when suppressed", async () => {
|
||||
await game.startBattle([Species.MAGIKARP, Species.PERRSERKER]);
|
||||
const perserrker = game.scene.getPlayerField()[1];
|
||||
|
||||
vi.spyOn(perserrker, "getAbility").mockReturnValue(allAbilities[Abilities.STEELY_SPIRIT]);
|
||||
expect(perserrker.hasAbility(Abilities.STEELY_SPIRIT)).toBe(true);
|
||||
|
||||
perserrker.summonData.abilitySuppressed = true;
|
||||
|
||||
expect(perserrker.hasAbility(Abilities.STEELY_SPIRIT)).toBe(false);
|
||||
expect(perserrker.summonData.abilitySuppressed).toBe(true);
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, moveToCheck));
|
||||
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
||||
|
||||
const mockedMovePower = getMockedMovePower(game.scene.getEnemyPokemon(), perserrker, allMoves[moveToCheck]);
|
||||
|
||||
expect(mockedMovePower).toBe(allMoves[moveToCheck].power);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Calculates the mocked power of a move.
|
||||
* Note this does not consider other damage calculations
|
||||
* except the power multiplier from Steely Spirit.
|
||||
*
|
||||
* @param defender - The defending Pokémon.
|
||||
* @param attacker - The attacking Pokémon.
|
||||
* @param move - The move being used by the attacker.
|
||||
* @returns The adjusted power of the move.
|
||||
*/
|
||||
const getMockedMovePower = (defender: Pokemon, attacker: Pokemon, move: Move) => {
|
||||
const powerHolder = new NumberHolder(move.power);
|
||||
|
||||
/**
|
||||
* Check if pokemon has the specified ability and is in effect.
|
||||
* See Pokemon.hasAbility {@linkcode Pokemon.hasAbility}
|
||||
*/
|
||||
if (attacker.hasAbility(Abilities.STEELY_SPIRIT)) {
|
||||
const alliedField: Pokemon[] = attacker instanceof PlayerPokemon ? attacker.scene.getPlayerField() : attacker.scene.getEnemyField();
|
||||
alliedField.forEach(p => applyPreAttackAbAttrs(UserFieldMoveTypePowerBoostAbAttr, p, this, move, powerHolder));
|
||||
}
|
||||
|
||||
return powerHolder.value;
|
||||
};
|
|
@ -0,0 +1,74 @@
|
|||
import * as battleScene from "#app/battle-scene.js";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { initLoggedInUser, loggedInUser, updateUserInfo } from "../account";
|
||||
import * as utils from "../utils";
|
||||
|
||||
describe("account", () => {
|
||||
describe("initLoggedInUser", () => {
|
||||
it("should set loggedInUser to Guest and lastSessionSlot to -1", () => {
|
||||
initLoggedInUser();
|
||||
|
||||
expect(loggedInUser.username).toBe("Guest");
|
||||
expect(loggedInUser.lastSessionSlot).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateUserInfo", () => {
|
||||
it("should set loggedInUser to Guest if bypassLogin is true", async () => {
|
||||
vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(true);
|
||||
|
||||
const [success, status] = await updateUserInfo();
|
||||
|
||||
expect(success).toBe(true);
|
||||
expect(status).toBe(200);
|
||||
expect(loggedInUser.username).toBe("Guest");
|
||||
expect(loggedInUser.lastSessionSlot).toBe(-1);
|
||||
});
|
||||
|
||||
it("should fetch user info from the API if bypassLogin is false", async () => {
|
||||
vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false);
|
||||
vi.spyOn(utils, "apiFetch").mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
username: "test",
|
||||
lastSessionSlot: 99,
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
const [success, status] = await updateUserInfo();
|
||||
|
||||
expect(success).toBe(true);
|
||||
expect(status).toBe(200);
|
||||
expect(loggedInUser.username).toBe("test");
|
||||
expect(loggedInUser.lastSessionSlot).toBe(99);
|
||||
});
|
||||
|
||||
it("should handle resolved API errors", async () => {
|
||||
vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false);
|
||||
vi.spyOn(utils, "apiFetch").mockResolvedValue(
|
||||
new Response(null, { status: 401 })
|
||||
);
|
||||
|
||||
const [success, status] = await updateUserInfo();
|
||||
|
||||
expect(success).toBe(false);
|
||||
expect(status).toBe(401);
|
||||
});
|
||||
|
||||
it("should handle rejected API errors", async () => {
|
||||
const consoleErrorSpy = vi.spyOn(console, "error");
|
||||
vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false);
|
||||
vi.spyOn(utils, "apiFetch").mockRejectedValue(new Error("Api failed!"));
|
||||
|
||||
const [success, status] = await updateUserInfo();
|
||||
|
||||
expect(success).toBe(false);
|
||||
expect(status).toBe(500);
|
||||
expect(consoleErrorSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,75 @@
|
|||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import Phase from "phaser";
|
||||
import GameManager from "#app/test/utils/gameManager";
|
||||
import * as overrides from "#app/overrides";
|
||||
import { Moves } from "#app/enums/moves.js";
|
||||
import { Species } from "#app/enums/species.js";
|
||||
import { BerryType } from "#app/enums/berry-type.js";
|
||||
import { Abilities } from "#app/enums/abilities.js";
|
||||
import { getMovePosition } from "../utils/gameManagerUtils";
|
||||
import { CommandPhase, MoveEndPhase, SelectTargetPhase } from "#app/phases.js";
|
||||
import { BattlerIndex } from "#app/battle.js";
|
||||
import { allMoves } from "#app/data/move.js";
|
||||
|
||||
const TIMEOUT = 20 * 1000; // 20 seconds
|
||||
|
||||
describe("Items - Grip Claw", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phase.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
|
||||
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
||||
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([ Moves.POPULATION_BOMB, Moves.SPLASH ]);
|
||||
vi.spyOn(overrides, "STARTING_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "GRIP_CLAW", count: 5}, {name: "MULTI_LENS", count: 3}]);
|
||||
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SNORLAX);
|
||||
vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.KLUTZ);
|
||||
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]);
|
||||
vi.spyOn(overrides, "OPP_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([
|
||||
{name: "BERRY", type: BerryType.SITRUS, count: 2},
|
||||
{name: "BERRY", type: BerryType.LUM, count: 2}
|
||||
]);
|
||||
vi.spyOn(overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||||
vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||||
|
||||
vi.spyOn(allMoves[Moves.POPULATION_BOMB], "accuracy", "get").mockReturnValue(100);
|
||||
});
|
||||
|
||||
it(
|
||||
"should only steal items from the attack target",
|
||||
async () => {
|
||||
await game.startBattle([Species.PANSEAR, Species.ROWLET, Species.PANPOUR, Species.PANSAGE, Species.CHARMANDER, Species.SQUIRTLE]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerField();
|
||||
playerPokemon.forEach(p => expect(p).toBeDefined());
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyField();
|
||||
enemyPokemon.forEach(p => expect(p).toBeDefined());
|
||||
|
||||
const enemyHeldItemCt = enemyPokemon.map(p => p.getHeldItems.length);
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, Moves.POPULATION_BOMB));
|
||||
|
||||
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
||||
game.doSelectTarget(BattlerIndex.ENEMY);
|
||||
|
||||
await game.phaseInterceptor.to(CommandPhase, false);
|
||||
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
||||
|
||||
await game.phaseInterceptor.to(MoveEndPhase, false);
|
||||
|
||||
expect(enemyPokemon[1].getHeldItems.length).toBe(enemyHeldItemCt[1]);
|
||||
}, TIMEOUT
|
||||
);
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, describe, afterEach, expect, it, vi } from "vitest";
|
||||
import {
|
||||
StatusEffect,
|
||||
getStatusEffectActivationText,
|
||||
|
@ -8,7 +8,6 @@ import {
|
|||
getStatusEffectOverlapText,
|
||||
} from "#app/data/status-effect";
|
||||
import i18next, { ParseKeys } from "i18next";
|
||||
import { afterEach } from "node:test";
|
||||
|
||||
const tMock = (key: ParseKeys) => key;
|
||||
const pokemonName = "PKM";
|
||||
|
|
|
@ -2077,9 +2077,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||
this.pokemonHatchedIcon,
|
||||
this.pokemonHatchedCountText
|
||||
].map(c => c.setVisible(false));
|
||||
} else if (species.speciesId === Species.ETERNATUS) {
|
||||
this.pokemonHatchedIcon.setVisible(false);
|
||||
this.pokemonHatchedCountText.setVisible(false);
|
||||
this.pokemonFormText.setY(25);
|
||||
} else {
|
||||
this.pokemonCaughtHatchedContainer.setY(25);
|
||||
this.pokemonShinyIcon.setY(117);
|
||||
|
@ -2091,6 +2089,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||
this.pokemonCandyCountText.setText(`x${this.scene.gameData.starterData[species.speciesId].candyCount}`);
|
||||
this.pokemonCandyCountText.setVisible(true);
|
||||
this.pokemonFormText.setVisible(true);
|
||||
this.pokemonFormText.setY(42);
|
||||
this.pokemonHatchedIcon.setVisible(true);
|
||||
this.pokemonHatchedCountText.setVisible(true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue