mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-26 01:09:29 +02:00
Compare commits
7 Commits
4fd8f84cda
...
54aacf7b5c
Author | SHA1 | Date | |
---|---|---|---|
|
54aacf7b5c | ||
|
0da37a0f0c | ||
|
c1c66a473b | ||
|
d576da72d2 | ||
|
018a0091f3 | ||
|
2d6267b668 | ||
|
8b65f9afab |
@ -1,13 +1,24 @@
|
|||||||
|
import type { Pokemon } from "#field/pokemon";
|
||||||
import type {
|
import type {
|
||||||
AttackMove,
|
AttackMove,
|
||||||
ChargingAttackMove,
|
ChargingAttackMove,
|
||||||
ChargingSelfStatusMove,
|
ChargingSelfStatusMove,
|
||||||
|
Move,
|
||||||
MoveAttr,
|
MoveAttr,
|
||||||
MoveAttrConstructorMap,
|
MoveAttrConstructorMap,
|
||||||
SelfStatusMove,
|
SelfStatusMove,
|
||||||
StatusMove,
|
StatusMove,
|
||||||
} from "#moves/move";
|
} from "#moves/move";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generic function producing a message during a Move's execution.
|
||||||
|
* @param user - The {@linkcode Pokemon} using the move
|
||||||
|
* @param target - The {@linkcode Pokemon} targeted by the move
|
||||||
|
* @param move - The {@linkcode Move} being used
|
||||||
|
* @returns a string
|
||||||
|
*/
|
||||||
|
export type MoveMessageFunc = (user: Pokemon, target: Pokemon, move: Move) => string;
|
||||||
|
|
||||||
export type MoveAttrFilter = (attr: MoveAttr) => boolean;
|
export type MoveAttrFilter = (attr: MoveAttr) => boolean;
|
||||||
|
|
||||||
export type * from "#moves/move";
|
export type * from "#moves/move";
|
||||||
|
@ -1670,6 +1670,7 @@ export class MoveTypeChangeAbAttr extends PreAttackAbAttr {
|
|||||||
constructor(
|
constructor(
|
||||||
private newType: PokemonType,
|
private newType: PokemonType,
|
||||||
private powerMultiplier: number,
|
private powerMultiplier: number,
|
||||||
|
// TODO: all moves with this attr solely check the move being used...
|
||||||
private condition?: PokemonAttackCondition,
|
private condition?: PokemonAttackCondition,
|
||||||
) {
|
) {
|
||||||
super(false);
|
super(false);
|
||||||
|
@ -86,7 +86,7 @@ import { PokemonHealPhase } from "#phases/pokemon-heal-phase";
|
|||||||
import { SwitchSummonPhase } from "#phases/switch-summon-phase";
|
import { SwitchSummonPhase } from "#phases/switch-summon-phase";
|
||||||
import type { AttackMoveResult } from "#types/attack-move-result";
|
import type { AttackMoveResult } from "#types/attack-move-result";
|
||||||
import type { Localizable } from "#types/locales";
|
import type { Localizable } from "#types/locales";
|
||||||
import type { ChargingMove, MoveAttrMap, MoveAttrString, MoveClassMap, MoveKindString } from "#types/move-types";
|
import type { ChargingMove, MoveAttrMap, MoveAttrString, MoveClassMap, MoveKindString, MoveMessageFunc } from "#types/move-types";
|
||||||
import type { TurnMove } from "#types/turn-move";
|
import type { TurnMove } from "#types/turn-move";
|
||||||
import { BooleanHolder, type Constructor, isNullOrUndefined, NumberHolder, randSeedFloat, randSeedInt, randSeedItem, toDmgValue } from "#utils/common";
|
import { BooleanHolder, type Constructor, isNullOrUndefined, NumberHolder, randSeedFloat, randSeedInt, randSeedItem, toDmgValue } from "#utils/common";
|
||||||
import { getEnumValues } from "#utils/enums";
|
import { getEnumValues } from "#utils/enums";
|
||||||
@ -1357,20 +1357,20 @@ export class MoveHeaderAttr extends MoveAttr {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Header attribute to queue a message at the beginning of a turn.
|
* Header attribute to queue a message at the beginning of a turn.
|
||||||
* @see {@link MoveHeaderAttr}
|
|
||||||
*/
|
*/
|
||||||
export class MessageHeaderAttr extends MoveHeaderAttr {
|
export class MessageHeaderAttr extends MoveHeaderAttr {
|
||||||
private message: string | ((user: Pokemon, move: Move) => string);
|
/** The message to display, or a function producing one. */
|
||||||
|
private message: string | MoveMessageFunc;
|
||||||
|
|
||||||
constructor(message: string | ((user: Pokemon, move: Move) => string)) {
|
constructor(message: string | MoveMessageFunc) {
|
||||||
super();
|
super();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move): boolean {
|
||||||
const message = typeof this.message === "string"
|
const message = typeof this.message === "string"
|
||||||
? this.message
|
? this.message
|
||||||
: this.message(user, move);
|
: this.message(user, target, move);
|
||||||
|
|
||||||
if (message) {
|
if (message) {
|
||||||
globalScene.phaseManager.queueMessage(message);
|
globalScene.phaseManager.queueMessage(message);
|
||||||
@ -1418,21 +1418,21 @@ export class BeakBlastHeaderAttr extends AddBattlerTagHeaderAttr {
|
|||||||
*/
|
*/
|
||||||
export class PreMoveMessageAttr extends MoveAttr {
|
export class PreMoveMessageAttr extends MoveAttr {
|
||||||
/** The message to display or a function returning one */
|
/** The message to display or a function returning one */
|
||||||
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string | undefined);
|
private message: string | MoveMessageFunc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@linkcode PreMoveMessageAttr} to display a message before move execution.
|
* Create a new {@linkcode PreMoveMessageAttr} to display a message before move execution.
|
||||||
* @param message - The message to display before move use, either as a string or a function producing one.
|
* @param message - The message to display before move use, either` a literal string or a function producing one.
|
||||||
* @remarks
|
* @remarks
|
||||||
* If {@linkcode message} evaluates to an empty string (`''`), no message will be displayed
|
* If {@linkcode message} evaluates to an empty string (`""`), no message will be displayed
|
||||||
* (though the move will still succeed).
|
* (though the move will still succeed).
|
||||||
*/
|
*/
|
||||||
constructor(message: string | ((user: Pokemon, target: Pokemon, move: Move) => string)) {
|
constructor(message: string | MoveMessageFunc) {
|
||||||
super();
|
super();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move): boolean {
|
||||||
const message = typeof this.message === "function"
|
const message = typeof this.message === "function"
|
||||||
? this.message(user, target, move)
|
? this.message(user, target, move)
|
||||||
: this.message;
|
: this.message;
|
||||||
@ -1453,18 +1453,17 @@ export class PreMoveMessageAttr extends MoveAttr {
|
|||||||
* @extends MoveAttr
|
* @extends MoveAttr
|
||||||
*/
|
*/
|
||||||
export class PreUseInterruptAttr extends MoveAttr {
|
export class PreUseInterruptAttr extends MoveAttr {
|
||||||
protected message?: string | ((user: Pokemon, target: Pokemon, move: Move) => string);
|
protected message: string | MoveMessageFunc;
|
||||||
protected overridesFailedMessage: boolean;
|
|
||||||
protected conditionFunc: MoveConditionFunc;
|
protected conditionFunc: MoveConditionFunc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new MoveInterruptedMessageAttr.
|
* Create a new MoveInterruptedMessageAttr.
|
||||||
* @param message The message to display when the move is interrupted, or a function that formats the message based on the user, target, and move.
|
* @param message The message to display when the move is interrupted, or a function that formats the message based on the user, target, and move.
|
||||||
*/
|
*/
|
||||||
constructor(message?: string | ((user: Pokemon, target: Pokemon, move: Move) => string), conditionFunc?: MoveConditionFunc) {
|
constructor(message: string | MoveMessageFunc, conditionFunc: MoveConditionFunc) {
|
||||||
super();
|
super();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.conditionFunc = conditionFunc ?? (() => true);
|
this.conditionFunc = conditionFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1485,11 +1484,9 @@ export class PreUseInterruptAttr extends MoveAttr {
|
|||||||
*/
|
*/
|
||||||
override getFailedText(user: Pokemon, target: Pokemon, move: Move): string | undefined {
|
override getFailedText(user: Pokemon, target: Pokemon, move: Move): string | undefined {
|
||||||
if (this.message && this.conditionFunc(user, target, move)) {
|
if (this.message && this.conditionFunc(user, target, move)) {
|
||||||
const message =
|
return typeof this.message === "string"
|
||||||
typeof this.message === "string"
|
? this.message
|
||||||
? (this.message as string)
|
|
||||||
: this.message(user, target, move);
|
: this.message(user, target, move);
|
||||||
return message;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1694,18 +1691,31 @@ export class SurviveDamageAttr extends ModifiedDamageAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SplashAttr extends MoveEffectAttr {
|
/**
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
* Move attribute to display arbitrary text during a move's execution.
|
||||||
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:splash"));
|
*/
|
||||||
return true;
|
export class MessageAttr extends MoveEffectAttr {
|
||||||
}
|
/** The message to display, either as a string or a function returning one. */
|
||||||
|
private message: string | MoveMessageFunc;
|
||||||
|
|
||||||
|
constructor(message: string | MoveMessageFunc, options?: MoveEffectAttrOptions) {
|
||||||
|
// TODO: Do we need to respect `selfTarget` if we're just displaying text?
|
||||||
|
super(false, options)
|
||||||
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CelebrateAttr extends MoveEffectAttr {
|
override apply(user: Pokemon, target: Pokemon, move: Move): boolean {
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
const message = typeof this.message === "function"
|
||||||
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:celebrate", { playerName: loggedInUser?.username }));
|
? this.message(user, target, move)
|
||||||
|
: this.message;
|
||||||
|
|
||||||
|
// TODO: Consider changing if/when MoveAttr `apply` return values become significant
|
||||||
|
if (message) {
|
||||||
|
globalScene.phaseManager.queueMessage(message, 500);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RecoilAttr extends MoveEffectAttr {
|
export class RecoilAttr extends MoveEffectAttr {
|
||||||
@ -5931,38 +5941,6 @@ export class ProtectAttr extends AddBattlerTagAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class IgnoreAccuracyAttr extends AddBattlerTagAttr {
|
|
||||||
constructor() {
|
|
||||||
super(BattlerTagType.IGNORE_ACCURACY, true, false, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
|
||||||
if (!super.apply(user, target, move, args)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:tookAimAtTarget", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target) }));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class FaintCountdownAttr extends AddBattlerTagAttr {
|
|
||||||
constructor() {
|
|
||||||
super(BattlerTagType.PERISH_SONG, false, true, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
|
||||||
if (!super.apply(user, target, move, args)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:faintCountdown", { pokemonName: getPokemonNameWithAffix(target), turnCount: this.turnCountMin - 1 }));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute to remove all Substitutes from the field.
|
* Attribute to remove all Substitutes from the field.
|
||||||
* @extends MoveEffectAttr
|
* @extends MoveEffectAttr
|
||||||
@ -6603,8 +6581,10 @@ export class ChillyReceptionAttr extends ForceSwitchOutAttr {
|
|||||||
return (user, target, move) => globalScene.arena.weather?.weatherType !== WeatherType.SNOW || super.getSwitchOutCondition()(user, target, move);
|
return (user, target, move) => globalScene.arena.weather?.weatherType !== WeatherType.SNOW || super.getSwitchOutCondition()(user, target, move);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RemoveTypeAttr extends MoveEffectAttr {
|
export class RemoveTypeAttr extends MoveEffectAttr {
|
||||||
|
|
||||||
|
// TODO: Remove the message callback
|
||||||
private removedType: PokemonType;
|
private removedType: PokemonType;
|
||||||
private messageCallback: ((user: Pokemon) => void) | undefined;
|
private messageCallback: ((user: Pokemon) => void) | undefined;
|
||||||
|
|
||||||
@ -8299,8 +8279,6 @@ const MoveAttrs = Object.freeze({
|
|||||||
RandomLevelDamageAttr,
|
RandomLevelDamageAttr,
|
||||||
ModifiedDamageAttr,
|
ModifiedDamageAttr,
|
||||||
SurviveDamageAttr,
|
SurviveDamageAttr,
|
||||||
SplashAttr,
|
|
||||||
CelebrateAttr,
|
|
||||||
RecoilAttr,
|
RecoilAttr,
|
||||||
SacrificialAttr,
|
SacrificialAttr,
|
||||||
SacrificialAttrOnHit,
|
SacrificialAttrOnHit,
|
||||||
@ -8443,8 +8421,7 @@ const MoveAttrs = Object.freeze({
|
|||||||
RechargeAttr,
|
RechargeAttr,
|
||||||
TrapAttr,
|
TrapAttr,
|
||||||
ProtectAttr,
|
ProtectAttr,
|
||||||
IgnoreAccuracyAttr,
|
MessageAttr,
|
||||||
FaintCountdownAttr,
|
|
||||||
RemoveAllSubstitutesAttr,
|
RemoveAllSubstitutesAttr,
|
||||||
HitsTagAttr,
|
HitsTagAttr,
|
||||||
HitsTagForDoubleDamageAttr,
|
HitsTagForDoubleDamageAttr,
|
||||||
@ -8938,7 +8915,7 @@ export function initMoves() {
|
|||||||
new AttackMove(MoveId.PSYWAVE, PokemonType.PSYCHIC, MoveCategory.SPECIAL, -1, 100, 15, -1, 0, 1)
|
new AttackMove(MoveId.PSYWAVE, PokemonType.PSYCHIC, MoveCategory.SPECIAL, -1, 100, 15, -1, 0, 1)
|
||||||
.attr(RandomLevelDamageAttr),
|
.attr(RandomLevelDamageAttr),
|
||||||
new SelfStatusMove(MoveId.SPLASH, PokemonType.NORMAL, -1, 40, -1, 0, 1)
|
new SelfStatusMove(MoveId.SPLASH, PokemonType.NORMAL, -1, 40, -1, 0, 1)
|
||||||
.attr(SplashAttr)
|
.attr(MessageAttr, i18next.t("moveTriggers:splash"))
|
||||||
.condition(failOnGravityCondition),
|
.condition(failOnGravityCondition),
|
||||||
new SelfStatusMove(MoveId.ACID_ARMOR, PokemonType.POISON, -1, 20, -1, 0, 1)
|
new SelfStatusMove(MoveId.ACID_ARMOR, PokemonType.POISON, -1, 20, -1, 0, 1)
|
||||||
.attr(StatStageChangeAttr, [ Stat.DEF ], 2, true),
|
.attr(StatStageChangeAttr, [ Stat.DEF ], 2, true),
|
||||||
@ -9000,7 +8977,10 @@ export function initMoves() {
|
|||||||
.attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1)
|
.attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1)
|
||||||
.reflectable(),
|
.reflectable(),
|
||||||
new StatusMove(MoveId.MIND_READER, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
new StatusMove(MoveId.MIND_READER, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
||||||
.attr(IgnoreAccuracyAttr),
|
.attr(AddBattlerTagAttr, BattlerTagType.IGNORE_ACCURACY, true, false, 2)
|
||||||
|
.attr(MessageAttr, (user, target) =>
|
||||||
|
i18next.t("moveTriggers:tookAimAtTarget", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target) })
|
||||||
|
),
|
||||||
new StatusMove(MoveId.NIGHTMARE, PokemonType.GHOST, 100, 15, -1, 0, 2)
|
new StatusMove(MoveId.NIGHTMARE, PokemonType.GHOST, 100, 15, -1, 0, 2)
|
||||||
.attr(AddBattlerTagAttr, BattlerTagType.NIGHTMARE)
|
.attr(AddBattlerTagAttr, BattlerTagType.NIGHTMARE)
|
||||||
.condition(targetSleptOrComatoseCondition),
|
.condition(targetSleptOrComatoseCondition),
|
||||||
@ -9088,7 +9068,9 @@ export function initMoves() {
|
|||||||
return lastTurnMove.length === 0 || lastTurnMove[0].move !== move.id || lastTurnMove[0].result !== MoveResult.SUCCESS;
|
return lastTurnMove.length === 0 || lastTurnMove[0].move !== move.id || lastTurnMove[0].result !== MoveResult.SUCCESS;
|
||||||
}),
|
}),
|
||||||
new StatusMove(MoveId.PERISH_SONG, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
new StatusMove(MoveId.PERISH_SONG, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
||||||
.attr(FaintCountdownAttr)
|
.attr(AddBattlerTagAttr, BattlerTagType.PERISH_SONG, false, true, 4)
|
||||||
|
.attr(MessageAttr, (_user, target) =>
|
||||||
|
i18next.t("moveTriggers:faintCountdown", { pokemonName: getPokemonNameWithAffix(target), turnCount: 3 }))
|
||||||
.ignoresProtect()
|
.ignoresProtect()
|
||||||
.soundBased()
|
.soundBased()
|
||||||
.condition(failOnBossCondition)
|
.condition(failOnBossCondition)
|
||||||
@ -9104,7 +9086,10 @@ export function initMoves() {
|
|||||||
.attr(MultiHitAttr)
|
.attr(MultiHitAttr)
|
||||||
.makesContact(false),
|
.makesContact(false),
|
||||||
new StatusMove(MoveId.LOCK_ON, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
new StatusMove(MoveId.LOCK_ON, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
||||||
.attr(IgnoreAccuracyAttr),
|
.attr(AddBattlerTagAttr, BattlerTagType.IGNORE_ACCURACY, true, false, 2)
|
||||||
|
.attr(MessageAttr, (user, target) =>
|
||||||
|
i18next.t("moveTriggers:tookAimAtTarget", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target) })
|
||||||
|
),
|
||||||
new AttackMove(MoveId.OUTRAGE, PokemonType.DRAGON, MoveCategory.PHYSICAL, 120, 100, 10, -1, 0, 2)
|
new AttackMove(MoveId.OUTRAGE, PokemonType.DRAGON, MoveCategory.PHYSICAL, 120, 100, 10, -1, 0, 2)
|
||||||
.attr(FrenzyAttr)
|
.attr(FrenzyAttr)
|
||||||
.attr(MissEffectAttr, frenzyMissFunc)
|
.attr(MissEffectAttr, frenzyMissFunc)
|
||||||
@ -9331,8 +9316,8 @@ export function initMoves() {
|
|||||||
&& (user.status.effect === StatusEffect.BURN || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.PARALYSIS) ? 2 : 1)
|
&& (user.status.effect === StatusEffect.BURN || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.PARALYSIS) ? 2 : 1)
|
||||||
.attr(BypassBurnDamageReductionAttr),
|
.attr(BypassBurnDamageReductionAttr),
|
||||||
new AttackMove(MoveId.FOCUS_PUNCH, PokemonType.FIGHTING, MoveCategory.PHYSICAL, 150, 100, 20, -1, -3, 3)
|
new AttackMove(MoveId.FOCUS_PUNCH, PokemonType.FIGHTING, MoveCategory.PHYSICAL, 150, 100, 20, -1, -3, 3)
|
||||||
.attr(MessageHeaderAttr, (user, move) => i18next.t("moveTriggers:isTighteningFocus", { pokemonName: getPokemonNameWithAffix(user) }))
|
.attr(MessageHeaderAttr, (user) => i18next.t("moveTriggers:isTighteningFocus", { pokemonName: getPokemonNameWithAffix(user) }))
|
||||||
.attr(PreUseInterruptAttr, (user, target, move) => i18next.t("moveTriggers:lostFocus", { pokemonName: getPokemonNameWithAffix(user) }), user => !!user.turnData.attacksReceived.find(r => r.damage))
|
.attr(PreUseInterruptAttr, (user) => i18next.t("moveTriggers:lostFocus", { pokemonName: getPokemonNameWithAffix(user) }), user => user.turnData.attacksReceived.some(r => r.damage > 0))
|
||||||
.punchingMove(),
|
.punchingMove(),
|
||||||
new AttackMove(MoveId.SMELLING_SALTS, PokemonType.NORMAL, MoveCategory.PHYSICAL, 70, 100, 10, -1, 0, 3)
|
new AttackMove(MoveId.SMELLING_SALTS, PokemonType.NORMAL, MoveCategory.PHYSICAL, 70, 100, 10, -1, 0, 3)
|
||||||
.attr(MovePowerMultiplierAttr, (user, target, move) => target.status?.effect === StatusEffect.PARALYSIS ? 2 : 1)
|
.attr(MovePowerMultiplierAttr, (user, target, move) => target.status?.effect === StatusEffect.PARALYSIS ? 2 : 1)
|
||||||
@ -10433,7 +10418,8 @@ export function initMoves() {
|
|||||||
new AttackMove(MoveId.DAZZLING_GLEAM, PokemonType.FAIRY, MoveCategory.SPECIAL, 80, 100, 10, -1, 0, 6)
|
new AttackMove(MoveId.DAZZLING_GLEAM, PokemonType.FAIRY, MoveCategory.SPECIAL, 80, 100, 10, -1, 0, 6)
|
||||||
.target(MoveTarget.ALL_NEAR_ENEMIES),
|
.target(MoveTarget.ALL_NEAR_ENEMIES),
|
||||||
new SelfStatusMove(MoveId.CELEBRATE, PokemonType.NORMAL, -1, 40, -1, 0, 6)
|
new SelfStatusMove(MoveId.CELEBRATE, PokemonType.NORMAL, -1, 40, -1, 0, 6)
|
||||||
.attr(CelebrateAttr),
|
// NB: This needs a lambda function as the user will not be logged in by the time the moves are initialized
|
||||||
|
.attr(MessageAttr, () => i18next.t("moveTriggers:celebrate", { playerName: loggedInUser?.username })),
|
||||||
new StatusMove(MoveId.HOLD_HANDS, PokemonType.NORMAL, -1, 40, -1, 0, 6)
|
new StatusMove(MoveId.HOLD_HANDS, PokemonType.NORMAL, -1, 40, -1, 0, 6)
|
||||||
.ignoresSubstitute()
|
.ignoresSubstitute()
|
||||||
.target(MoveTarget.NEAR_ALLY),
|
.target(MoveTarget.NEAR_ALLY),
|
||||||
@ -10608,7 +10594,12 @@ export function initMoves() {
|
|||||||
.attr(StatStageChangeAttr, [ Stat.SPD ], -1)
|
.attr(StatStageChangeAttr, [ Stat.SPD ], -1)
|
||||||
.reflectable(),
|
.reflectable(),
|
||||||
new SelfStatusMove(MoveId.LASER_FOCUS, PokemonType.NORMAL, -1, 30, -1, 0, 7)
|
new SelfStatusMove(MoveId.LASER_FOCUS, PokemonType.NORMAL, -1, 30, -1, 0, 7)
|
||||||
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false),
|
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false)
|
||||||
|
.attr(MessageAttr, (user) =>
|
||||||
|
i18next.t("battlerTags:laserFocusOnAdd", {
|
||||||
|
pokemonNameWithAffix: getPokemonNameWithAffix(user),
|
||||||
|
}),
|
||||||
|
),
|
||||||
new StatusMove(MoveId.GEAR_UP, PokemonType.STEEL, -1, 20, -1, 0, 7)
|
new StatusMove(MoveId.GEAR_UP, PokemonType.STEEL, -1, 20, -1, 0, 7)
|
||||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => !![ AbilityId.PLUS, AbilityId.MINUS ].find(a => target.hasAbility(a, false)) })
|
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => !![ AbilityId.PLUS, AbilityId.MINUS ].find(a => target.hasAbility(a, false)) })
|
||||||
.ignoresSubstitute()
|
.ignoresSubstitute()
|
||||||
|
@ -44,6 +44,33 @@ export abstract class PhasePriorityQueue {
|
|||||||
public clear(): void {
|
public clear(): void {
|
||||||
this.queue.splice(0, this.queue.length);
|
this.queue.splice(0, this.queue.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to remove one or more Phases from the current queue.
|
||||||
|
* @param phaseFilter - The function to select phases for removal
|
||||||
|
* @param removeCount - The maximum number of phases to remove, or `all` to remove all matching phases;
|
||||||
|
* default `1`
|
||||||
|
* @returns The number of successfully removed phases
|
||||||
|
* @todo Remove this eventually once the patchwork bug this is used for is fixed
|
||||||
|
*/
|
||||||
|
public tryRemovePhase(phaseFilter: (phase: Phase) => boolean, removeCount: number | "all" = 1): number {
|
||||||
|
if (removeCount === "all") {
|
||||||
|
removeCount = Number.MAX_SAFE_INTEGER;
|
||||||
|
} else if (removeCount < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
let numRemoved = 0;
|
||||||
|
let phaseIndex = this.queue.findIndex(phaseFilter);
|
||||||
|
if (phaseIndex === -1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
while (numRemoved < removeCount && phaseIndex !== -1) {
|
||||||
|
this.queue.splice(phaseIndex, 1);
|
||||||
|
numRemoved++;
|
||||||
|
phaseIndex = this.queue.findIndex(phaseFilter);
|
||||||
|
}
|
||||||
|
return numRemoved;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,6 +106,7 @@ export class PostSummonPhasePriorityQueue extends PhasePriorityQueue {
|
|||||||
private queueAbilityPhase(phase: PostSummonPhase): void {
|
private queueAbilityPhase(phase: PostSummonPhase): void {
|
||||||
const phasePokemon = phase.getPokemon();
|
const phasePokemon = phase.getPokemon();
|
||||||
|
|
||||||
|
console.log(phasePokemon.getNameToRender());
|
||||||
phasePokemon.getAbilityPriorities().forEach((priority, idx) => {
|
phasePokemon.getAbilityPriorities().forEach((priority, idx) => {
|
||||||
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority, !!idx));
|
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority, !!idx));
|
||||||
globalScene.phaseManager.appendToPhase(
|
globalScene.phaseManager.appendToPhase(
|
||||||
|
@ -355,14 +355,23 @@ export class PhaseManager {
|
|||||||
if (this.phaseQueuePrependSpliceIndex > -1) {
|
if (this.phaseQueuePrependSpliceIndex > -1) {
|
||||||
this.clearPhaseQueueSplice();
|
this.clearPhaseQueueSplice();
|
||||||
}
|
}
|
||||||
if (this.phaseQueuePrepend.length) {
|
this.phaseQueue.unshift(...this.phaseQueuePrepend);
|
||||||
while (this.phaseQueuePrepend.length) {
|
this.phaseQueuePrepend.splice(0);
|
||||||
const poppedPhase = this.phaseQueuePrepend.pop();
|
|
||||||
if (poppedPhase) {
|
const unactivatedConditionalPhases: [() => boolean, Phase][] = [];
|
||||||
this.phaseQueue.unshift(poppedPhase);
|
// Check if there are any conditional phases queued
|
||||||
}
|
for (const [condition, phase] of this.conditionalQueue) {
|
||||||
|
// Evaluate the condition associated with the phase
|
||||||
|
if (condition()) {
|
||||||
|
// If the condition is met, add the phase to the phase queue
|
||||||
|
this.pushPhase(phase);
|
||||||
|
} else {
|
||||||
|
// If the condition is not met, re-add the phase back to the end of the conditional queue
|
||||||
|
unactivatedConditionalPhases.push([condition, phase]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.conditionalQueue = unactivatedConditionalPhases;
|
||||||
|
|
||||||
if (!this.phaseQueue.length) {
|
if (!this.phaseQueue.length) {
|
||||||
this.populatePhaseQueue();
|
this.populatePhaseQueue();
|
||||||
// Clear the conditionalQueue if there are no phases left in the phaseQueue
|
// Clear the conditionalQueue if there are no phases left in the phaseQueue
|
||||||
@ -371,24 +380,6 @@ export class PhaseManager {
|
|||||||
|
|
||||||
this.currentPhase = this.phaseQueue.shift() ?? null;
|
this.currentPhase = this.phaseQueue.shift() ?? null;
|
||||||
|
|
||||||
const unactivatedConditionalPhases: [() => boolean, Phase][] = [];
|
|
||||||
// Check if there are any conditional phases queued
|
|
||||||
while (this.conditionalQueue?.length) {
|
|
||||||
// Retrieve the first conditional phase from the queue
|
|
||||||
const conditionalPhase = this.conditionalQueue.shift();
|
|
||||||
// Evaluate the condition associated with the phase
|
|
||||||
if (conditionalPhase?.[0]()) {
|
|
||||||
// If the condition is met, add the phase to the phase queue
|
|
||||||
this.pushPhase(conditionalPhase[1]);
|
|
||||||
} else if (conditionalPhase) {
|
|
||||||
// If the condition is not met, re-add the phase back to the front of the conditional queue
|
|
||||||
unactivatedConditionalPhases.push(conditionalPhase);
|
|
||||||
} else {
|
|
||||||
console.warn("condition phase is undefined/null!", conditionalPhase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.conditionalQueue.push(...unactivatedConditionalPhases);
|
|
||||||
|
|
||||||
if (this.currentPhase) {
|
if (this.currentPhase) {
|
||||||
console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;");
|
console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;");
|
||||||
this.currentPhase.start();
|
this.currentPhase.start();
|
||||||
@ -520,6 +511,25 @@ export class PhaseManager {
|
|||||||
this.dynamicPhaseQueues[type].push(phase);
|
this.dynamicPhaseQueues[type].push(phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to remove one or more Phases from the given DynamicPhaseQueue, removing the equivalent amount of {@linkcode ActivatePriorityQueuePhase}s from the queue.
|
||||||
|
* @param type - The {@linkcode DynamicPhaseType} to check
|
||||||
|
* @param phaseFilter - The function to select phases for removal
|
||||||
|
* @param removeCount - The maximum number of phases to remove, or `all` to remove all matching phases;
|
||||||
|
* default `1`
|
||||||
|
* @todo Remove this eventually once the patchwork bug this is used for is fixed
|
||||||
|
*/
|
||||||
|
public tryRemoveDynamicPhase(
|
||||||
|
type: DynamicPhaseType,
|
||||||
|
phaseFilter: (phase: Phase) => boolean,
|
||||||
|
removeCount: number | "all" = 1,
|
||||||
|
): void {
|
||||||
|
const numRemoved = this.dynamicPhaseQueues[type].tryRemovePhase(phaseFilter, removeCount);
|
||||||
|
for (let x = 0; x < numRemoved; x++) {
|
||||||
|
this.tryRemovePhase(p => p.is("ActivatePriorityQueuePhase"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unshifts the top phase from the corresponding dynamic queue onto {@linkcode phaseQueue}
|
* Unshifts the top phase from the corresponding dynamic queue onto {@linkcode phaseQueue}
|
||||||
* @param type {@linkcode DynamicPhaseType} The type of dynamic phase to start
|
* @param type {@linkcode DynamicPhaseType} The type of dynamic phase to start
|
||||||
|
@ -2,6 +2,7 @@ import { globalScene } from "#app/global-scene";
|
|||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { BattleStyle } from "#enums/battle-style";
|
import { BattleStyle } from "#enums/battle-style";
|
||||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
|
import { DynamicPhaseType } from "#enums/dynamic-phase-type";
|
||||||
import { SwitchType } from "#enums/switch-type";
|
import { SwitchType } from "#enums/switch-type";
|
||||||
import { UiMode } from "#enums/ui-mode";
|
import { UiMode } from "#enums/ui-mode";
|
||||||
import { BattlePhase } from "#phases/battle-phase";
|
import { BattlePhase } from "#phases/battle-phase";
|
||||||
@ -66,6 +67,17 @@ export class CheckSwitchPhase extends BattlePhase {
|
|||||||
UiMode.CONFIRM,
|
UiMode.CONFIRM,
|
||||||
() => {
|
() => {
|
||||||
globalScene.ui.setMode(UiMode.MESSAGE);
|
globalScene.ui.setMode(UiMode.MESSAGE);
|
||||||
|
/*
|
||||||
|
Remove any pending `ActivatePriorityQueuePhase`s for the currently leaving Pokemon produced by the prior `SwitchSummonPhase`.
|
||||||
|
This is required to avoid triggering on-switch abilities twice on initial entrance.
|
||||||
|
TODO: Separate the animations from `SwitchSummonPhase` to another phase and call that on initial switch - this is a band-aid fix
|
||||||
|
TODO: Confirm with @emdeann what the maximum number of these things that gets unshifted can be
|
||||||
|
*/
|
||||||
|
globalScene.phaseManager.tryRemoveDynamicPhase(
|
||||||
|
DynamicPhaseType.POST_SUMMON,
|
||||||
|
p => p.is("PostSummonPhase") && p.getPokemon() === pokemon,
|
||||||
|
4,
|
||||||
|
);
|
||||||
globalScene.phaseManager.unshiftNew("SwitchPhase", SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true);
|
globalScene.phaseManager.unshiftNew("SwitchPhase", SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true);
|
||||||
this.end();
|
this.end();
|
||||||
},
|
},
|
||||||
|
@ -35,13 +35,43 @@ describe("Abilities - Intimidate", () => {
|
|||||||
it("should lower all opponents' ATK by 1 stage on entry and switch", async () => {
|
it("should lower all opponents' ATK by 1 stage on entry and switch", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
await game.classicMode.startBattle([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
||||||
|
|
||||||
|
const [mightyena, poochyena] = game.scene.getPlayerParty();
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
const enemy = game.field.getEnemyPokemon();
|
||||||
expect(enemy.getStatStage(Stat.ATK)).toBe(-1);
|
expect(enemy.getStatStage(Stat.ATK)).toBe(-1);
|
||||||
|
expect(mightyena).toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
||||||
|
|
||||||
game.doSwitchPokemon(1);
|
game.doSwitchPokemon(1);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(poochyena.isActive()).toBe(true);
|
||||||
expect(enemy.getStatStage(Stat.ATK)).toBe(-2);
|
expect(enemy.getStatStage(Stat.ATK)).toBe(-2);
|
||||||
|
expect(poochyena).toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should trigger once on initial switch prompt without cancelling opposing abilities", async () => {
|
||||||
|
await game.classicMode.runToSummon([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
||||||
|
await game.classicMode.startBattleWithSwitch(1);
|
||||||
|
|
||||||
|
const [poochyena, mightyena] = game.scene.getPlayerParty();
|
||||||
|
expect(poochyena.species.speciesId).toBe(SpeciesId.POOCHYENA);
|
||||||
|
|
||||||
|
const enemy = game.field.getEnemyPokemon();
|
||||||
|
expect(enemy).toHaveStatStage(Stat.ATK, -1);
|
||||||
|
expect(poochyena).toHaveStatStage(Stat.ATK, -1);
|
||||||
|
|
||||||
|
expect(poochyena).toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
||||||
|
expect(mightyena).not.toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should activate on reload with single party", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.MIGHTYENA]);
|
||||||
|
|
||||||
|
expect(game.field.getEnemyPokemon()).toHaveStatStage(Stat.ATK, -1);
|
||||||
|
|
||||||
|
await game.reload.reloadSession();
|
||||||
|
|
||||||
|
expect(game.field.getEnemyPokemon()).toHaveStatStage(Stat.ATK, -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should lower ATK of all opponents in a double battle", async () => {
|
it("should lower ATK of all opponents in a double battle", async () => {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { globalScene } from "#app/global-scene";
|
|
||||||
import { Status } from "#data/status-effect";
|
import { Status } from "#data/status-effect";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { BattleType } from "#enums/battle-type";
|
import { BattleType } from "#enums/battle-type";
|
||||||
@ -179,18 +178,13 @@ describe("Moves - Whirlwind", () => {
|
|||||||
const eligibleEnemy = enemyParty.filter(p => p.hp > 0 && p.isAllowedInBattle());
|
const eligibleEnemy = enemyParty.filter(p => p.hp > 0 && p.isAllowedInBattle());
|
||||||
expect(eligibleEnemy.length).toBe(1);
|
expect(eligibleEnemy.length).toBe(1);
|
||||||
|
|
||||||
// Spy on the queueMessage function
|
|
||||||
const queueSpy = vi.spyOn(globalScene.phaseManager, "queueMessage");
|
|
||||||
|
|
||||||
// Player uses Whirlwind; opponent uses Splash
|
// Player uses Whirlwind; opponent uses Splash
|
||||||
game.move.select(MoveId.WHIRLWIND);
|
game.move.select(MoveId.WHIRLWIND);
|
||||||
await game.move.selectEnemyMove(MoveId.SPLASH);
|
await game.move.selectEnemyMove(MoveId.SPLASH);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
// Verify that the failure message is displayed for Whirlwind
|
const player = game.field.getPlayerPokemon();
|
||||||
expect(queueSpy).toHaveBeenCalledWith(expect.stringContaining("But it failed"));
|
expect(player).toHaveUsedMove({ move: MoveId.WHIRLWIND, result: MoveResult.FAIL });
|
||||||
// Verify the opponent's Splash message
|
|
||||||
expect(queueSpy).toHaveBeenCalledWith(expect.stringContaining("But nothing happened!"));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not pull in the other trainer's pokemon in a partner trainer battle", async () => {
|
it("should not pull in the other trainer's pokemon in a partner trainer battle", async () => {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { getGameMode } from "#app/game-mode";
|
import { getGameMode } from "#app/game-mode";
|
||||||
import overrides from "#app/overrides";
|
import overrides from "#app/overrides";
|
||||||
import { BattleStyle } from "#enums/battle-style";
|
import { BattleStyle } from "#enums/battle-style";
|
||||||
|
import { Button } from "#enums/buttons";
|
||||||
import { GameModes } from "#enums/game-modes";
|
import { GameModes } from "#enums/game-modes";
|
||||||
import { Nature } from "#enums/nature";
|
import { Nature } from "#enums/nature";
|
||||||
import type { SpeciesId } from "#enums/species-id";
|
import type { SpeciesId } from "#enums/species-id";
|
||||||
@ -100,4 +101,33 @@ export class ClassicModeHelper extends GameManagerHelper {
|
|||||||
await this.game.phaseInterceptor.to(CommandPhase);
|
await this.game.phaseInterceptor.to(CommandPhase);
|
||||||
console.log("==================[New Turn]==================");
|
console.log("==================[New Turn]==================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue inputs to switch at the start of the next battle, and then start it.
|
||||||
|
* @param pokemonIndex - The 0-indexed position of the party pokemon to switch to.
|
||||||
|
* Should never be called with 0 as that will select the currently active pokemon and freeze
|
||||||
|
* @returns A Promise that resolves once the battle has been started and the switch prompt resolved
|
||||||
|
* @todo Make this work for double battles
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* await game.classicMode.runToSummon([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA])
|
||||||
|
* await game.startBattleWithSwitch(1);
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
public async startBattleWithSwitch(pokemonIndex: number): Promise<void> {
|
||||||
|
this.game.scene.battleStyle = BattleStyle.SWITCH;
|
||||||
|
this.game.onNextPrompt(
|
||||||
|
"CheckSwitchPhase",
|
||||||
|
UiMode.CONFIRM,
|
||||||
|
() => {
|
||||||
|
this.game.scene.ui.getHandler().setCursor(0);
|
||||||
|
this.game.scene.ui.getHandler().processInput(Button.ACTION);
|
||||||
|
},
|
||||||
|
() => this.game.isCurrentPhase("CommandPhase") || this.game.isCurrentPhase("TurnInitPhase"),
|
||||||
|
);
|
||||||
|
this.game.doSelectPartyPokemon(pokemonIndex);
|
||||||
|
|
||||||
|
await this.game.phaseInterceptor.to("CommandPhase");
|
||||||
|
console.log("==================[New Battle (Initial Switch)]==================");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user