mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-30 12:12:28 +02:00
Merge branch 'beta' into stuff-cheeks-implementation
This commit is contained in:
commit
ce090b9a59
2496
public/battle-anims/common-powder.json
Normal file
2496
public/battle-anims/common-powder.json
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
@ -2469,6 +2469,24 @@ export default class BattleScene extends SceneBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to add the input phase to index after target phase in the {@linkcode phaseQueue}, else simply calls {@linkcode unshiftPhase()}
|
||||||
|
* @param phase {@linkcode Phase} the phase to be added
|
||||||
|
* @param targetPhase {@linkcode Phase} the type of phase to search for in {@linkcode phaseQueue}
|
||||||
|
* @returns `true` if a `targetPhase` was found to append to
|
||||||
|
*/
|
||||||
|
appendToPhase(phase: Phase, targetPhase: Constructor<Phase>): boolean {
|
||||||
|
const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof targetPhase);
|
||||||
|
|
||||||
|
if (targetIndex !== -1 && this.phaseQueue.length > targetIndex) {
|
||||||
|
this.phaseQueue.splice(targetIndex + 1, 0, phase);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
this.unshiftPhase(phase);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a MessagePhase, either to PhaseQueuePrepend or nextCommandPhaseQueue
|
* Adds a MessagePhase, either to PhaseQueuePrepend or nextCommandPhaseQueue
|
||||||
* @param message string for MessagePhase
|
* @param message string for MessagePhase
|
||||||
|
@ -90,6 +90,7 @@ export enum CommonAnim {
|
|||||||
RAGING_BULL_FIRE,
|
RAGING_BULL_FIRE,
|
||||||
RAGING_BULL_WATER,
|
RAGING_BULL_WATER,
|
||||||
SALT_CURE,
|
SALT_CURE,
|
||||||
|
POWDER,
|
||||||
SUNNY = 2100,
|
SUNNY = 2100,
|
||||||
RAIN,
|
RAIN,
|
||||||
SANDSTORM,
|
SANDSTORM,
|
||||||
|
@ -856,6 +856,57 @@ export class SeedTag extends BattlerTag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BattlerTag representing the effects of {@link https://bulbapedia.bulbagarden.net/wiki/Powder_(move) | Powder}.
|
||||||
|
* When the afflicted Pokemon uses a Fire-type move, the move is cancelled, and the
|
||||||
|
* Pokemon takes damage equal to 1/4 of it's maximum HP (rounded down).
|
||||||
|
*/
|
||||||
|
export class PowderTag extends BattlerTag {
|
||||||
|
constructor() {
|
||||||
|
super(BattlerTagType.POWDER, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END ], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
onAdd(pokemon: Pokemon): void {
|
||||||
|
super.onAdd(pokemon);
|
||||||
|
|
||||||
|
// "{Pokemon} is covered in powder!"
|
||||||
|
pokemon.scene.queueMessage(i18next.t("battlerTags:powderOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies Powder's effects before the tag owner uses a Fire-type move.
|
||||||
|
* Also causes the tag to expire at the end of turn.
|
||||||
|
* @param pokemon {@linkcode Pokemon} the owner of this tag
|
||||||
|
* @param lapseType {@linkcode BattlerTagLapseType} the type of lapse functionality to carry out
|
||||||
|
* @returns `true` if the tag should not expire after this lapse; `false` otherwise.
|
||||||
|
*/
|
||||||
|
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
|
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
|
||||||
|
const movePhase = pokemon.scene.getCurrentPhase();
|
||||||
|
if (movePhase instanceof MovePhase) {
|
||||||
|
const move = movePhase.move.getMove();
|
||||||
|
if (pokemon.getMoveType(move) === Type.FIRE) {
|
||||||
|
movePhase.cancel();
|
||||||
|
|
||||||
|
pokemon.scene.unshiftPhase(new CommonAnimPhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.POWDER));
|
||||||
|
|
||||||
|
const cancelDamage = new BooleanHolder(false);
|
||||||
|
applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelDamage);
|
||||||
|
if (!cancelDamage.value) {
|
||||||
|
pokemon.damageAndUpdate(Math.floor(pokemon.getMaxHp() / 4), HitResult.OTHER);
|
||||||
|
}
|
||||||
|
|
||||||
|
// "When the flame touched the powder\non the Pokémon, it exploded!"
|
||||||
|
pokemon.scene.queueMessage(i18next.t("battlerTags:powderLapse", { moveName: move.name }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return super.lapse(pokemon, lapseType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class NightmareTag extends BattlerTag {
|
export class NightmareTag extends BattlerTag {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(BattlerTagType.NIGHTMARE, BattlerTagLapseType.TURN_END, 1, Moves.NIGHTMARE);
|
super(BattlerTagType.NIGHTMARE, BattlerTagLapseType.TURN_END, 1, Moves.NIGHTMARE);
|
||||||
@ -2981,6 +3032,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
|
|||||||
return new InfatuatedTag(sourceMove, sourceId);
|
return new InfatuatedTag(sourceMove, sourceId);
|
||||||
case BattlerTagType.SEEDED:
|
case BattlerTagType.SEEDED:
|
||||||
return new SeedTag(sourceId);
|
return new SeedTag(sourceId);
|
||||||
|
case BattlerTagType.POWDER:
|
||||||
|
return new PowderTag();
|
||||||
case BattlerTagType.NIGHTMARE:
|
case BattlerTagType.NIGHTMARE:
|
||||||
return new NightmareTag();
|
return new NightmareTag();
|
||||||
case BattlerTagType.FRENZY:
|
case BattlerTagType.FRENZY:
|
||||||
|
126
src/data/move.ts
126
src/data/move.ts
@ -6758,6 +6758,126 @@ export class CopyMoveAttr extends OverrideMoveEffectAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute used for moves that causes the target to repeat their last used move.
|
||||||
|
*
|
||||||
|
* Used for [Instruct](https://bulbapedia.bulbagarden.net/wiki/Instruct_(move)).
|
||||||
|
*/
|
||||||
|
export class RepeatMoveAttr extends MoveEffectAttr {
|
||||||
|
constructor() {
|
||||||
|
super(false, { trigger: MoveEffectTrigger.POST_APPLY }); // needed to ensure correct protect interaction
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces the target to re-use their last used move again
|
||||||
|
*
|
||||||
|
* @param user {@linkcode Pokemon} that used the attack
|
||||||
|
* @param target {@linkcode Pokemon} targeted by the attack
|
||||||
|
* @param move N/A
|
||||||
|
* @param args N/A
|
||||||
|
* @returns `true` if the move succeeds
|
||||||
|
*/
|
||||||
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
|
// get the last move used (excluding status based failures) as well as the corresponding moveset slot
|
||||||
|
const lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE)!;
|
||||||
|
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove.move)!;
|
||||||
|
const moveTargets = lastMove.targets ?? [];
|
||||||
|
|
||||||
|
user.scene.queueMessage(i18next.t("moveTriggers:instructingMove", {
|
||||||
|
userPokemonName: getPokemonNameWithAffix(user),
|
||||||
|
targetPokemonName: getPokemonNameWithAffix(target)
|
||||||
|
}));
|
||||||
|
target.getMoveQueue().unshift({ move: lastMove.move, targets: moveTargets, ignorePP: false });
|
||||||
|
target.turnData.extraTurns++;
|
||||||
|
target.scene.appendToPhase(new MovePhase(target.scene, target, moveTargets, movesetMove), MoveEndPhase);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCondition(): MoveConditionFunc {
|
||||||
|
return (user, target, move) => {
|
||||||
|
// TODO: Confirm behavior of instructing move known by target but called by another move
|
||||||
|
const lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE);
|
||||||
|
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove?.move);
|
||||||
|
const moveTargets = lastMove?.targets ?? [];
|
||||||
|
// TODO: Add a way of adding moves to list procedurally rather than a pre-defined blacklist
|
||||||
|
const unrepeatablemoves = [
|
||||||
|
// Locking/Continually Executed moves
|
||||||
|
Moves.OUTRAGE,
|
||||||
|
Moves.RAGING_FURY,
|
||||||
|
Moves.ROLLOUT,
|
||||||
|
Moves.PETAL_DANCE,
|
||||||
|
Moves.THRASH,
|
||||||
|
Moves.ICE_BALL,
|
||||||
|
// Multi-turn Moves
|
||||||
|
Moves.BIDE,
|
||||||
|
Moves.SHELL_TRAP,
|
||||||
|
Moves.BEAK_BLAST,
|
||||||
|
Moves.FOCUS_PUNCH,
|
||||||
|
// "First Turn Only" moves
|
||||||
|
Moves.FAKE_OUT,
|
||||||
|
Moves.FIRST_IMPRESSION,
|
||||||
|
Moves.MAT_BLOCK,
|
||||||
|
// Moves with a recharge turn
|
||||||
|
Moves.HYPER_BEAM,
|
||||||
|
Moves.ETERNABEAM,
|
||||||
|
Moves.FRENZY_PLANT,
|
||||||
|
Moves.BLAST_BURN,
|
||||||
|
Moves.HYDRO_CANNON,
|
||||||
|
Moves.GIGA_IMPACT,
|
||||||
|
Moves.PRISMATIC_LASER,
|
||||||
|
Moves.ROAR_OF_TIME,
|
||||||
|
Moves.ROCK_WRECKER,
|
||||||
|
Moves.METEOR_ASSAULT,
|
||||||
|
// Charging & 2-turn moves
|
||||||
|
Moves.DIG,
|
||||||
|
Moves.FLY,
|
||||||
|
Moves.BOUNCE,
|
||||||
|
Moves.SHADOW_FORCE,
|
||||||
|
Moves.PHANTOM_FORCE,
|
||||||
|
Moves.DIVE,
|
||||||
|
Moves.ELECTRO_SHOT,
|
||||||
|
Moves.ICE_BURN,
|
||||||
|
Moves.GEOMANCY,
|
||||||
|
Moves.FREEZE_SHOCK,
|
||||||
|
Moves.SKY_DROP,
|
||||||
|
Moves.SKY_ATTACK,
|
||||||
|
Moves.SKULL_BASH,
|
||||||
|
Moves.SOLAR_BEAM,
|
||||||
|
Moves.SOLAR_BLADE,
|
||||||
|
Moves.METEOR_BEAM,
|
||||||
|
// Other moves
|
||||||
|
Moves.INSTRUCT,
|
||||||
|
Moves.KINGS_SHIELD,
|
||||||
|
Moves.SKETCH,
|
||||||
|
Moves.TRANSFORM,
|
||||||
|
Moves.MIMIC,
|
||||||
|
Moves.STRUGGLE,
|
||||||
|
// TODO: Add Max/G-Move blockage if or when they are implemented
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!movesetMove // called move not in target's moveset (dancer, forgetting the move, etc.)
|
||||||
|
|| movesetMove.ppUsed === movesetMove.getMovePp() // move out of pp
|
||||||
|
|| allMoves[lastMove?.move ?? Moves.NONE].isChargingMove() // called move is a charging/recharging move
|
||||||
|
|| !moveTargets.length // called move has no targets
|
||||||
|
|| unrepeatablemoves.includes(lastMove?.move ?? Moves.NONE)) { // called move is explicitly in the banlist
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||||
|
// TODO: Make the AI acutally use instruct
|
||||||
|
/* Ideally, the AI would score instruct based on the scorings of the on-field pokemons'
|
||||||
|
* last used moves at the time of using Instruct (by the time the instructor gets to act)
|
||||||
|
* with respect to the user's side.
|
||||||
|
* In 99.9% of cases, this would be the pokemon's ally (unless the target had last
|
||||||
|
* used a move like Decorate on the user or its ally)
|
||||||
|
*/
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute used for moves that reduce PP of the target's last used move.
|
* Attribute used for moves that reduce PP of the target's last used move.
|
||||||
* Used for Spite.
|
* Used for Spite.
|
||||||
@ -9700,9 +9820,10 @@ export function initMoves() {
|
|||||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK, Stat.SPD ], -1, false, { condition: (user, target, move) => target.status?.effect === StatusEffect.POISON || target.status?.effect === StatusEffect.TOXIC })
|
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK, Stat.SPD ], -1, false, { condition: (user, target, move) => target.status?.effect === StatusEffect.POISON || target.status?.effect === StatusEffect.TOXIC })
|
||||||
.target(MoveTarget.ALL_NEAR_ENEMIES),
|
.target(MoveTarget.ALL_NEAR_ENEMIES),
|
||||||
new StatusMove(Moves.POWDER, Type.BUG, 100, 20, -1, 1, 6)
|
new StatusMove(Moves.POWDER, Type.BUG, 100, 20, -1, 1, 6)
|
||||||
|
.attr(AddBattlerTagAttr, BattlerTagType.POWDER, false, true)
|
||||||
.ignoresSubstitute()
|
.ignoresSubstitute()
|
||||||
.powderMove()
|
.powderMove()
|
||||||
.unimplemented(),
|
.edgeCase(), // does not cancel Fire-type moves generated by Dancer
|
||||||
new ChargingSelfStatusMove(Moves.GEOMANCY, Type.FAIRY, -1, 10, -1, 0, 6)
|
new ChargingSelfStatusMove(Moves.GEOMANCY, Type.FAIRY, -1, 10, -1, 0, 6)
|
||||||
.chargeText(i18next.t("moveTriggers:isChargingPower", { pokemonName: "{USER}" }))
|
.chargeText(i18next.t("moveTriggers:isChargingPower", { pokemonName: "{USER}" }))
|
||||||
.attr(StatStageChangeAttr, [ Stat.SPATK, Stat.SPDEF, Stat.SPD ], 2, true)
|
.attr(StatStageChangeAttr, [ Stat.SPATK, Stat.SPDEF, Stat.SPD ], 2, true)
|
||||||
@ -9980,7 +10101,8 @@ export function initMoves() {
|
|||||||
.attr(StatStageChangeAttr, [ Stat.ATK ], -1),
|
.attr(StatStageChangeAttr, [ Stat.ATK ], -1),
|
||||||
new StatusMove(Moves.INSTRUCT, Type.PSYCHIC, -1, 15, -1, 0, 7)
|
new StatusMove(Moves.INSTRUCT, Type.PSYCHIC, -1, 15, -1, 0, 7)
|
||||||
.ignoresSubstitute()
|
.ignoresSubstitute()
|
||||||
.unimplemented(),
|
.attr(RepeatMoveAttr)
|
||||||
|
.edgeCase(), // incorrect interactions with Gigaton Hammer, Blood Moon & Torment
|
||||||
new AttackMove(Moves.BEAK_BLAST, Type.FLYING, MoveCategory.PHYSICAL, 100, 100, 15, -1, -3, 7)
|
new AttackMove(Moves.BEAK_BLAST, Type.FLYING, MoveCategory.PHYSICAL, 100, 100, 15, -1, -3, 7)
|
||||||
.attr(BeakBlastHeaderAttr)
|
.attr(BeakBlastHeaderAttr)
|
||||||
.ballBombMove()
|
.ballBombMove()
|
||||||
|
@ -94,4 +94,5 @@ export enum BattlerTagType {
|
|||||||
PSYCHO_SHIFT = "PSYCHO_SHIFT",
|
PSYCHO_SHIFT = "PSYCHO_SHIFT",
|
||||||
ENDURE_TOKEN = "ENDURE_TOKEN",
|
ENDURE_TOKEN = "ENDURE_TOKEN",
|
||||||
STUFF_CHEEKS = "STUFF_CHEEKS",
|
STUFF_CHEEKS = "STUFF_CHEEKS",
|
||||||
|
POWDER = "POWDER",
|
||||||
}
|
}
|
||||||
|
@ -3501,12 +3501,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
return this.gender !== Gender.GENDERLESS && pokemon.gender === (this.gender === Gender.MALE ? Gender.FEMALE : Gender.MALE);
|
return this.gender !== Gender.GENDERLESS && pokemon.gender === (this.gender === Gender.MALE ? Gender.FEMALE : Gender.MALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
canSetStatus(effect: StatusEffect | undefined, quiet: boolean = false, overrideStatus: boolean = false, sourcePokemon: Pokemon | null = null): boolean {
|
/**
|
||||||
|
* Checks if a status effect can be applied to the Pokemon.
|
||||||
|
*
|
||||||
|
* @param effect The {@linkcode StatusEffect} whose applicability is being checked
|
||||||
|
* @param quiet Whether in-battle messages should trigger or not
|
||||||
|
* @param overrideStatus Whether the Pokemon's current status can be overriden
|
||||||
|
* @param sourcePokemon The Pokemon that is setting the status effect
|
||||||
|
* @param ignoreField Whether any field effects (weather, terrain, etc.) should be considered
|
||||||
|
*/
|
||||||
|
canSetStatus(effect: StatusEffect | undefined, quiet: boolean = false, overrideStatus: boolean = false, sourcePokemon: Pokemon | null = null, ignoreField: boolean = false): boolean {
|
||||||
if (effect !== StatusEffect.FAINT) {
|
if (effect !== StatusEffect.FAINT) {
|
||||||
if (overrideStatus ? this.status?.effect === effect : this.status) {
|
if (overrideStatus ? this.status?.effect === effect : this.status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.isGrounded() && this.scene.arena.terrain?.terrainType === TerrainType.MISTY) {
|
if (this.isGrounded() && (!ignoreField && this.scene.arena.terrain?.terrainType === TerrainType.MISTY)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3556,7 +3565,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case StatusEffect.FREEZE:
|
case StatusEffect.FREEZE:
|
||||||
if (this.isOfType(Type.ICE) || (this.scene?.arena?.weather?.weatherType && [ WeatherType.SUNNY, WeatherType.HARSH_SUN ].includes(this.scene.arena.weather.weatherType))) {
|
if (this.isOfType(Type.ICE) || (!ignoreField && (this.scene?.arena?.weather?.weatherType && [ WeatherType.SUNNY, WeatherType.HARSH_SUN ].includes(this.scene.arena.weather.weatherType)))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -5285,6 +5294,7 @@ export class PokemonBattleSummonData {
|
|||||||
export class PokemonTurnData {
|
export class PokemonTurnData {
|
||||||
public flinched: boolean = false;
|
public flinched: boolean = false;
|
||||||
public acted: boolean = false;
|
public acted: boolean = false;
|
||||||
|
/** How many times the move should hit the target(s) */
|
||||||
public hitCount: number = 0;
|
public hitCount: number = 0;
|
||||||
/**
|
/**
|
||||||
* - `-1` = Calculate how many hits are left
|
* - `-1` = Calculate how many hits are left
|
||||||
@ -5303,6 +5313,11 @@ export class PokemonTurnData {
|
|||||||
public switchedInThisTurn: boolean = false;
|
public switchedInThisTurn: boolean = false;
|
||||||
public failedRunAway: boolean = false;
|
public failedRunAway: boolean = false;
|
||||||
public joinedRound: boolean = false;
|
public joinedRound: boolean = false;
|
||||||
|
/**
|
||||||
|
* Used to make sure multi-hits occur properly when the user is
|
||||||
|
* forced to act again in the same turn
|
||||||
|
*/
|
||||||
|
public extraTurns: number = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AiType {
|
export enum AiType {
|
||||||
|
@ -1751,19 +1751,59 @@ const modifierPool: ModifierPool = {
|
|||||||
|| (p.isFusion() && checkedSpecies.includes(p.getFusionSpeciesForm(true).speciesId)))) ? 12 : 0;
|
|| (p.isFusion() && checkedSpecies.includes(p.getFusionSpeciesForm(true).speciesId)))) ? 12 : 0;
|
||||||
}, 12),
|
}, 12),
|
||||||
new WeightedModifierType(modifierTypes.TOXIC_ORB, (party: Pokemon[]) => {
|
new WeightedModifierType(modifierTypes.TOXIC_ORB, (party: Pokemon[]) => {
|
||||||
const checkedAbilities = [ Abilities.QUICK_FEET, Abilities.GUTS, Abilities.MARVEL_SCALE, Abilities.TOXIC_BOOST, Abilities.POISON_HEAL, Abilities.MAGIC_GUARD ];
|
return party.some(p => {
|
||||||
const checkedMoves = [ Moves.FACADE, Moves.TRICK, Moves.FLING, Moves.SWITCHEROO, Moves.PSYCHO_SHIFT ];
|
const moveset = p.getMoveset(true).filter(m => !isNullOrUndefined(m)).map(m => m.moveId);
|
||||||
// If a party member doesn't already have one of these two orbs and has one of the above moves or abilities, the orb can appear
|
|
||||||
return party.some(p => !p.getHeldItems().some(i => i instanceof TurnStatusEffectModifier)
|
const canSetStatus = p.canSetStatus(StatusEffect.TOXIC, true, true, null, true);
|
||||||
&& (checkedAbilities.some(a => p.hasAbility(a, false, true))
|
const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB");
|
||||||
|| p.getMoveset(true).some(m => m && checkedMoves.includes(m.moveId)))) ? 10 : 0;
|
|
||||||
|
// Moves that take advantage of obtaining the actual status effect
|
||||||
|
const hasStatusMoves = [ Moves.FACADE, Moves.PSYCHO_SHIFT ]
|
||||||
|
.some(m => moveset.includes(m));
|
||||||
|
// Moves that take advantage of being able to give the target a status orb
|
||||||
|
// TODO: Take moves from comment they are implemented
|
||||||
|
const hasItemMoves = [ /* Moves.TRICK, Moves.FLING, Moves.SWITCHEROO */ ]
|
||||||
|
.some(m => moveset.includes(m));
|
||||||
|
// Abilities that take advantage of obtaining the actual status effect
|
||||||
|
const hasRelevantAbilities = [ Abilities.QUICK_FEET, Abilities.GUTS, Abilities.MARVEL_SCALE, Abilities.TOXIC_BOOST, Abilities.POISON_HEAL, Abilities.MAGIC_GUARD ]
|
||||||
|
.some(a => p.hasAbility(a, false, true));
|
||||||
|
|
||||||
|
if (!isHoldingOrb) {
|
||||||
|
if (canSetStatus) {
|
||||||
|
return hasRelevantAbilities || hasStatusMoves;
|
||||||
|
} else {
|
||||||
|
return hasItemMoves;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}) ? 10 : 0;
|
||||||
}, 10),
|
}, 10),
|
||||||
new WeightedModifierType(modifierTypes.FLAME_ORB, (party: Pokemon[]) => {
|
new WeightedModifierType(modifierTypes.FLAME_ORB, (party: Pokemon[]) => {
|
||||||
const checkedAbilities = [ Abilities.QUICK_FEET, Abilities.GUTS, Abilities.MARVEL_SCALE, Abilities.FLARE_BOOST, Abilities.MAGIC_GUARD ];
|
return party.some(p => {
|
||||||
const checkedMoves = [ Moves.FACADE, Moves.TRICK, Moves.FLING, Moves.SWITCHEROO, Moves.PSYCHO_SHIFT ];
|
const moveset = p.getMoveset(true).filter(m => !isNullOrUndefined(m)).map(m => m.moveId);
|
||||||
// If a party member doesn't already have one of these two orbs and has one of the above moves or abilities, the orb can appear
|
const canSetStatus = p.canSetStatus(StatusEffect.BURN, true, true, null, true);
|
||||||
return party.some(p => !p.getHeldItems().some(i => i instanceof TurnStatusEffectModifier)
|
const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB");
|
||||||
&& (checkedAbilities.some(a => p.hasAbility(a, false, true)) || p.getMoveset(true).some(m => m && checkedMoves.includes(m.moveId)))) ? 10 : 0;
|
|
||||||
|
// Moves that take advantage of obtaining the actual status effect
|
||||||
|
const hasStatusMoves = [ Moves.FACADE, Moves.PSYCHO_SHIFT ]
|
||||||
|
.some(m => moveset.includes(m));
|
||||||
|
// Moves that take advantage of being able to give the target a status orb
|
||||||
|
// TODO: Take moves from comment they are implemented
|
||||||
|
const hasItemMoves = [ /* Moves.TRICK, Moves.FLING, Moves.SWITCHEROO */ ]
|
||||||
|
.some(m => moveset.includes(m));
|
||||||
|
// Abilities that take advantage of obtaining the actual status effect
|
||||||
|
const hasRelevantAbilities = [ Abilities.QUICK_FEET, Abilities.GUTS, Abilities.MARVEL_SCALE, Abilities.FLARE_BOOST, Abilities.MAGIC_GUARD ]
|
||||||
|
.some(a => p.hasAbility(a, false, true));
|
||||||
|
|
||||||
|
if (!isHoldingOrb) {
|
||||||
|
if (canSetStatus) {
|
||||||
|
return hasRelevantAbilities || hasStatusMoves;
|
||||||
|
} else {
|
||||||
|
return hasItemMoves;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}) ? 10 : 0;
|
||||||
}, 10),
|
}, 10),
|
||||||
new WeightedModifierType(modifierTypes.WHITE_HERB, (party: Pokemon[]) => {
|
new WeightedModifierType(modifierTypes.WHITE_HERB, (party: Pokemon[]) => {
|
||||||
const checkedAbilities = [ Abilities.WEAK_ARMOR, Abilities.CONTRARY, Abilities.MOODY, Abilities.ANGER_SHELL, Abilities.COMPETITIVE, Abilities.DEFIANT ];
|
const checkedAbilities = [ Abilities.WEAK_ARMOR, Abilities.CONTRARY, Abilities.MOODY, Abilities.ANGER_SHELL, Abilities.COMPETITIVE, Abilities.DEFIANT ];
|
||||||
|
@ -127,6 +127,14 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
|
|
||||||
user.lapseTags(BattlerTagLapseType.MOVE_EFFECT);
|
user.lapseTags(BattlerTagLapseType.MOVE_EFFECT);
|
||||||
|
|
||||||
|
// If the user is acting again (such as due to Instruct), reset hitsLeft/hitCount so that
|
||||||
|
// the move executes correctly (ensures all hits of a multi-hit are properly calculated)
|
||||||
|
if (user.turnData.hitsLeft === 0 && user.turnData.hitCount > 0 && user.turnData.extraTurns > 0) {
|
||||||
|
user.turnData.hitsLeft = -1;
|
||||||
|
user.turnData.hitCount = 0;
|
||||||
|
user.turnData.extraTurns--;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this phase is for the first hit of the invoked move,
|
* If this phase is for the first hit of the invoked move,
|
||||||
* resolve the move's total hit count. This block combines the
|
* resolve the move's total hit count. This block combines the
|
||||||
@ -313,7 +321,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Promise that applys *all* effects from the invoked move's MoveEffectAttrs.
|
* Create a Promise that applies *all* effects from the invoked move's MoveEffectAttrs.
|
||||||
* These are ordered by trigger type (see {@linkcode MoveEffectTrigger}), and each trigger
|
* These are ordered by trigger type (see {@linkcode MoveEffectTrigger}), and each trigger
|
||||||
* type requires different conditions to be met with respect to the move's hit result.
|
* type requires different conditions to be met with respect to the move's hit result.
|
||||||
*/
|
*/
|
||||||
|
@ -25,10 +25,13 @@ describe("Abilities - Serene Grace", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
game.override
|
game.override
|
||||||
|
.disableCrits()
|
||||||
.battleType("single")
|
.battleType("single")
|
||||||
.ability(Abilities.SERENE_GRACE)
|
.ability(Abilities.SERENE_GRACE)
|
||||||
.moveset([ Moves.AIR_SLASH, Moves.TACKLE ])
|
.moveset([ Moves.AIR_SLASH ])
|
||||||
|
.enemySpecies(Species.ALOLA_GEODUDE)
|
||||||
.enemyLevel(10)
|
.enemyLevel(10)
|
||||||
|
.enemyAbility(Abilities.BALL_FETCH)
|
||||||
.enemyMoveset([ Moves.SPLASH ]);
|
.enemyMoveset([ Moves.SPLASH ]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
315
src/test/moves/instruct.test.ts
Normal file
315
src/test/moves/instruct.test.ts
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
import { BattlerIndex } from "#app/battle";
|
||||||
|
import type Pokemon from "#app/field/pokemon";
|
||||||
|
import { MoveResult } from "#app/field/pokemon";
|
||||||
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { Moves } from "#enums/moves";
|
||||||
|
import { Species } from "#enums/species";
|
||||||
|
import GameManager from "#test/utils/gameManager";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
describe("Moves - Instruct", () => {
|
||||||
|
let phaserGame: Phaser.Game;
|
||||||
|
let game: GameManager;
|
||||||
|
|
||||||
|
function instructSuccess(pokemon: Pokemon, move: Moves): void {
|
||||||
|
expect(pokemon.getLastXMoves(-1)[0].move).toBe(move);
|
||||||
|
expect(pokemon.getLastXMoves(-1)[1].move).toBe(pokemon.getLastXMoves()[0].move);
|
||||||
|
expect(pokemon.getMoveset().find(m => m?.moveId === move)?.ppUsed).toBe(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
phaserGame = new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
game = new GameManager(phaserGame);
|
||||||
|
game.override
|
||||||
|
.battleType("single")
|
||||||
|
.enemySpecies(Species.SHUCKLE)
|
||||||
|
.enemyAbility(Abilities.NO_GUARD)
|
||||||
|
.enemyLevel(100)
|
||||||
|
.startingLevel(100)
|
||||||
|
.ability(Abilities.BALL_FETCH)
|
||||||
|
.moveset([ Moves.INSTRUCT, Moves.SONIC_BOOM, Moves.SPLASH, Moves.TORMENT ])
|
||||||
|
.disableCrits();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should repeat enemy's attack move when moving last", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemy, Moves.SONIC_BOOM);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
|
||||||
|
instructSuccess(enemy, Moves.SONIC_BOOM);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should repeat enemy's move through substitute", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemy, [ Moves.SONIC_BOOM, Moves.SUBSTITUTE ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.SUBSTITUTE);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.SONIC_BOOM);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
|
||||||
|
instructSuccess(game.scene.getEnemyPokemon()!, Moves.SONIC_BOOM);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should repeat ally's attack on enemy", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.moveset([]);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.SHUCKLE ]);
|
||||||
|
|
||||||
|
const [ amoonguss, shuckle ] = game.scene.getPlayerField();
|
||||||
|
game.move.changeMoveset(amoonguss, Moves.INSTRUCT);
|
||||||
|
game.move.changeMoveset(shuckle, Moves.SONIC_BOOM);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2);
|
||||||
|
game.move.select(Moves.SONIC_BOOM, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getEnemyField()[0].getInverseHp()).toBe(40);
|
||||||
|
instructSuccess(shuckle, Moves.SONIC_BOOM);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Enable test case once gigaton hammer (and blood moon) is fixed
|
||||||
|
it.todo("should repeat enemy's Gigaton Hammer", async () => {
|
||||||
|
game.override
|
||||||
|
.enemyLevel(5);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemy, Moves.GIGATON_HAMMER);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
instructSuccess(enemy, Moves.GIGATON_HAMMER);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should respect enemy's status condition", async () => {
|
||||||
|
game.override
|
||||||
|
.moveset([ Moves.THUNDER_WAVE, Moves.INSTRUCT ])
|
||||||
|
.enemyMoveset([ Moves.SPLASH, Moves.SONIC_BOOM ]);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.THUNDER_WAVE);
|
||||||
|
await game.forceEnemyMove(Moves.SONIC_BOOM);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.move.forceStatusActivation(true);
|
||||||
|
await game.phaseInterceptor.to("MovePhase");
|
||||||
|
await game.move.forceStatusActivation(false);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
const moveHistory = game.scene.getEnemyPokemon()!.getMoveHistory();
|
||||||
|
expect(moveHistory.length).toBe(3);
|
||||||
|
expect(moveHistory[0].move).toBe(Moves.SONIC_BOOM);
|
||||||
|
expect(moveHistory[1].move).toBe(Moves.NONE);
|
||||||
|
expect(moveHistory[2].move).toBe(Moves.SONIC_BOOM);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat enemy's out of pp move", async () => {
|
||||||
|
game.override.enemySpecies(Species.UNOWN);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemyPokemon, Moves.HIDDEN_POWER);
|
||||||
|
const moveUsed = enemyPokemon.moveset.find(m => m?.moveId === Moves.HIDDEN_POWER)!;
|
||||||
|
moveUsed.ppUsed = moveUsed.getMovePp() - 1;
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.HIDDEN_POWER);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
const playerMove = game.scene.getPlayerPokemon()!.getLastXMoves()!;
|
||||||
|
expect(playerMove[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(enemyPokemon.getMoveHistory().length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should fail if no move has yet been used by target", async () => {
|
||||||
|
game.override.enemyMoveset(Moves.SPLASH);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should attempt to call enemy's disabled move, but move use itself should fail", async () => {
|
||||||
|
game.override
|
||||||
|
.moveset([ Moves.INSTRUCT, Moves.DISABLE ])
|
||||||
|
.battleType("double");
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.DROWZEE ]);
|
||||||
|
|
||||||
|
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
|
||||||
|
game.move.changeMoveset(enemy1, Moves.SONIC_BOOM);
|
||||||
|
game.move.changeMoveset(enemy2, Moves.SPLASH);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.DISABLE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
const enemyMove = game.scene.getEnemyPokemon()!.getLastXMoves()[0];
|
||||||
|
expect(enemyMove.result).toBe(MoveResult.FAIL);
|
||||||
|
expect(game.scene.getEnemyPokemon()!.getMoveset().find(m => m?.moveId === Moves.SONIC_BOOM)?.ppUsed).toBe(1);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat enemy's move through protect", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const MoveToUse = Moves.PROTECT;
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemyPokemon, MoveToUse);
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.PROTECT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(enemyPokemon.getLastXMoves(-1)[0].move).toBe(Moves.PROTECT);
|
||||||
|
expect(enemyPokemon.getLastXMoves(-1)[1]).toBeUndefined(); // undefined because protect failed
|
||||||
|
expect(enemyPokemon.getMoveset().find(m => m?.moveId === Moves.PROTECT)?.ppUsed).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat enemy's charging move", async () => {
|
||||||
|
game.override
|
||||||
|
.enemyMoveset([ Moves.SONIC_BOOM, Moves.HYPER_BEAM ])
|
||||||
|
.enemyLevel(5);
|
||||||
|
await game.classicMode.startBattle([ Species.SHUCKLE ]);
|
||||||
|
|
||||||
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
enemyPokemon.battleSummonData.moveHistory = [{ move: Moves.SONIC_BOOM, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }];
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.HYPER_BEAM);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat dance move not known by target", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.moveset([ Moves.INSTRUCT, Moves.FIERY_DANCE ])
|
||||||
|
.enemyMoveset(Moves.SPLASH)
|
||||||
|
.enemyAbility(Abilities.DANCER);
|
||||||
|
await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should cause multi-hit moves to hit the appropriate number of times in singles", async () => {
|
||||||
|
game.override
|
||||||
|
.enemyAbility(Abilities.SKILL_LINK)
|
||||||
|
.enemyMoveset(Moves.BULLET_SEED);
|
||||||
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||||
|
|
||||||
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(player.turnData.attacksReceived.length).toBe(10);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(player.turnData.attacksReceived.length).toBe(10);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should cause multi-hit moves to hit the appropriate number of times in doubles", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.enemyAbility(Abilities.SKILL_LINK)
|
||||||
|
.enemyMoveset([ Moves.BULLET_SEED, Moves.SPLASH ])
|
||||||
|
.enemyLevel(5);
|
||||||
|
await game.classicMode.startBattle([ Species.BULBASAUR, Species.IVYSAUR ]);
|
||||||
|
|
||||||
|
const [ , ivysaur ] = game.scene.getPlayerField();
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
game.move.select(Moves.SPLASH, 1);
|
||||||
|
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, 0, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.INSTRUCT, 1, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(ivysaur.turnData.attacksReceived.length).toBe(15);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
game.move.select(Moves.INSTRUCT, 0, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.INSTRUCT, 1, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(ivysaur.turnData.attacksReceived.length).toBe(15);
|
||||||
|
});
|
||||||
|
});
|
205
src/test/moves/powder.test.ts
Normal file
205
src/test/moves/powder.test.ts
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import GameManager from "#test/utils/gameManager";
|
||||||
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { Moves } from "#enums/moves";
|
||||||
|
import { Species } from "#enums/species";
|
||||||
|
import { BerryPhase } from "#app/phases/berry-phase";
|
||||||
|
import { MoveResult } from "#app/field/pokemon";
|
||||||
|
import { Type } from "#enums/type";
|
||||||
|
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
||||||
|
import { StatusEffect } from "#enums/status-effect";
|
||||||
|
|
||||||
|
describe("Moves - Powder", () => {
|
||||||
|
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.battleType("single");
|
||||||
|
|
||||||
|
game.override
|
||||||
|
.enemySpecies(Species.SNORLAX)
|
||||||
|
.enemyLevel(100)
|
||||||
|
.enemyMoveset(Moves.EMBER)
|
||||||
|
.enemyAbility(Abilities.INSOMNIA)
|
||||||
|
.startingLevel(100)
|
||||||
|
.moveset([ Moves.POWDER, Moves.SPLASH, Moves.FIERY_DANCE ]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should cancel the target's Fire-type move and damage the target",
|
||||||
|
async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.POWDER);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4));
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4));
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should have no effect against Grass-type Pokemon",
|
||||||
|
async () => {
|
||||||
|
game.override.enemySpecies(Species.AMOONGUSS);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.POWDER);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should have no effect against Pokemon with Overcoat",
|
||||||
|
async () => {
|
||||||
|
game.override.enemyAbility(Abilities.OVERCOAT);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.POWDER);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should not damage the target if the target has Magic Guard",
|
||||||
|
async () => {
|
||||||
|
game.override.enemyAbility(Abilities.MAGIC_GUARD);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.POWDER);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should not prevent the target from thawing out with Flame Wheel",
|
||||||
|
async () => {
|
||||||
|
game.override
|
||||||
|
.enemyMoveset(Array(4).fill(Moves.FLAME_WHEEL))
|
||||||
|
.enemyStatusEffect(StatusEffect.FREEZE);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.POWDER);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.FREEZE);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should not allow a target with Protean to change to Fire type",
|
||||||
|
async () => {
|
||||||
|
game.override.enemyAbility(Abilities.PROTEAN);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.POWDER);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp());
|
||||||
|
expect(enemyPokemon.summonData?.types).not.toBe(Type.FIRE);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Implement this interaction to pass this test
|
||||||
|
it.skip(
|
||||||
|
"should cancel Fire-type moves generated by the target's Dancer ability",
|
||||||
|
async () => {
|
||||||
|
game.override
|
||||||
|
.enemySpecies(Species.BLASTOISE)
|
||||||
|
.enemyAbility(Abilities.DANCER);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.FIERY_DANCE);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(MoveEffectPhase);
|
||||||
|
const enemyStartingHp = enemyPokemon.hp;
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
// player should not take damage
|
||||||
|
expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp());
|
||||||
|
// enemy should have taken damage from player's Fiery Dance + 2 Powder procs
|
||||||
|
expect(enemyPokemon.hp).toBe(enemyStartingHp - 2 * Math.floor(enemyPokemon.getMaxHp() / 4));
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should cancel Revelation Dance if it becomes a Fire-type move",
|
||||||
|
async () => {
|
||||||
|
game.override
|
||||||
|
.enemySpecies(Species.CHARIZARD)
|
||||||
|
.enemyMoveset(Array(4).fill(Moves.REVELATION_DANCE));
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.POWDER);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4));
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should cancel Shell Trap and damage the target, even if the move would fail",
|
||||||
|
async () => {
|
||||||
|
game.override.enemyMoveset(Array(4).fill(Moves.SHELL_TRAP));
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.POWDER);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4));
|
||||||
|
});
|
||||||
|
});
|
@ -1,4 +1,6 @@
|
|||||||
import { BattlerIndex } from "#app/battle";
|
import { BattlerIndex } from "#app/battle";
|
||||||
|
import type Pokemon from "#app/field/pokemon";
|
||||||
|
import { PokemonMove } from "#app/field/pokemon";
|
||||||
import Overrides from "#app/overrides";
|
import Overrides from "#app/overrides";
|
||||||
import { CommandPhase } from "#app/phases/command-phase";
|
import { CommandPhase } from "#app/phases/command-phase";
|
||||||
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
||||||
@ -71,4 +73,21 @@ export class MoveHelper extends GameManagerHelper {
|
|||||||
await this.game.phaseInterceptor.to("MovePhase");
|
await this.game.phaseInterceptor.to("MovePhase");
|
||||||
vi.spyOn(Overrides, "STATUS_ACTIVATION_OVERRIDE", "get").mockReturnValue(null);
|
vi.spyOn(Overrides, "STATUS_ACTIVATION_OVERRIDE", "get").mockReturnValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when the normal moveset override can't be used (such as when it's necessary to check updated properties of the moveset).
|
||||||
|
* @param pokemon - The pokemon being modified
|
||||||
|
* @param moveset - The moveset to use
|
||||||
|
*/
|
||||||
|
public changeMoveset(pokemon: Pokemon, moveset: Moves | Moves[]): void {
|
||||||
|
if (!Array.isArray(moveset)) {
|
||||||
|
moveset = [ moveset ];
|
||||||
|
}
|
||||||
|
pokemon.moveset = [];
|
||||||
|
moveset.forEach((move) => {
|
||||||
|
pokemon.moveset.push(new PokemonMove(move));
|
||||||
|
});
|
||||||
|
const movesetStr = moveset.map((moveId) => Moves[moveId]).join(", ");
|
||||||
|
console.log(`Pokemon ${pokemon.species.name}'s moveset manually set to ${movesetStr} (=[${moveset.join(", ")}])!`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user