mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-08 16:39:26 +02:00
Applied kev's reviews
This commit is contained in:
parent
cd7ef557d9
commit
6bb2991c13
@ -3162,7 +3162,7 @@ export class DelayedAttackAttr extends OverrideMoveEffectAttr {
|
|||||||
/**
|
/**
|
||||||
* @param chargeAnim - The {@linkcode ChargeAnim | charging animation} used for the move's charging phase.
|
* @param chargeAnim - The {@linkcode ChargeAnim | charging animation} used for the move's charging phase.
|
||||||
* @param chargeKey - The `i18next` locales **key** to show when the delayed attack is used.
|
* @param chargeKey - The `i18next` locales **key** to show when the delayed attack is used.
|
||||||
* In the displayed text, `{{pokemonName}}` and `{{targetName}}` will be populated with the user's & target's names respectively.
|
* In the displayed text, `{{pokemonName}}` will be populated with the user's name.
|
||||||
*/
|
*/
|
||||||
constructor(chargeAnim: ChargeAnim, chargeKey: string) {
|
constructor(chargeAnim: ChargeAnim, chargeKey: string) {
|
||||||
super();
|
super();
|
||||||
@ -3171,7 +3171,7 @@ export class DelayedAttackAttr extends OverrideMoveEffectAttr {
|
|||||||
this.chargeText = chargeKey;
|
this.chargeText = chargeKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: [overridden: BooleanHolder, useMode: MoveUseMode]): boolean {
|
override apply(user: Pokemon, target: Pokemon, move: Move, args: [overridden: BooleanHolder, useMode: MoveUseMode]): boolean {
|
||||||
const useMode = args[1];
|
const useMode = args[1];
|
||||||
if (useMode === MoveUseMode.DELAYED_ATTACK) {
|
if (useMode === MoveUseMode.DELAYED_ATTACK) {
|
||||||
// don't trigger if already queueing an indirect attack
|
// don't trigger if already queueing an indirect attack
|
||||||
@ -3186,13 +3186,12 @@ export class DelayedAttackAttr extends OverrideMoveEffectAttr {
|
|||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t(
|
i18next.t(
|
||||||
this.chargeText,
|
this.chargeText,
|
||||||
// uncomment if any new delayed moves actually use target in the move text.
|
{ pokemonName: getPokemonNameWithAffix(user) }
|
||||||
{pokemonName: getPokemonNameWithAffix(user)/*, targetName: getPokemonNameWithAffix(target) */}
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
user.pushMoveHistory({move: move.id, targets: [target.getBattlerIndex()], result: MoveResult.OTHER, useMode: useMode, turn: globalScene.currentBattle.turn})
|
user.pushMoveHistory({move: move.id, targets: [target.getBattlerIndex()], result: MoveResult.OTHER, useMode, turn: globalScene.currentBattle.turn})
|
||||||
|
user.pushMoveHistory({move: move.id, targets: [target.getBattlerIndex()], result: MoveResult.OTHER, useMode, turn: globalScene.currentBattle.turn})
|
||||||
// Queue up an attack on the given slot.
|
// Queue up an attack on the given slot.
|
||||||
globalScene.arena.positionalTagManager.addTag<PositionalTagType.DELAYED_ATTACK>({
|
globalScene.arena.positionalTagManager.addTag<PositionalTagType.DELAYED_ATTACK>({
|
||||||
tagType: PositionalTagType.DELAYED_ATTACK,
|
tagType: PositionalTagType.DELAYED_ATTACK,
|
||||||
@ -3204,15 +3203,18 @@ export class DelayedAttackAttr extends OverrideMoveEffectAttr {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override getCondition(): MoveConditionFunc {
|
override getCondition(): MoveConditionFunc {
|
||||||
// Check the arena if another similar attack is active and affecting the same slot
|
// Check the arena if another similar attack is active and affecting the same slot
|
||||||
return (_user, target, move) => globalScene.arena.positionalTagManager.canAddTag(PositionalTagType.DELAYED_ATTACK, target.getBattlerIndex())
|
return (_user, target) => globalScene.arena.positionalTagManager.canAddTag(PositionalTagType.DELAYED_ATTACK, target.getBattlerIndex())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Attribute to queue a {@linkcode WishTag} to activate in 2 turns. */
|
/**
|
||||||
|
* Attribute to queue a {@linkcode WishTag} to activate in 2 turns.
|
||||||
|
* The tag whill heal
|
||||||
|
*/
|
||||||
export class WishAttr extends MoveEffectAttr {
|
export class WishAttr extends MoveEffectAttr {
|
||||||
apply(user: Pokemon, target: Pokemon, _move: Move): boolean {
|
override apply(user: Pokemon, target: Pokemon, _move: Move): boolean {
|
||||||
globalScene.arena.positionalTagManager.addTag<PositionalTagType.WISH>({
|
globalScene.arena.positionalTagManager.addTag<PositionalTagType.WISH>({
|
||||||
tagType: PositionalTagType.WISH,
|
tagType: PositionalTagType.WISH,
|
||||||
healHp: toDmgValue(user.getMaxHp() / 2),
|
healHp: toDmgValue(user.getMaxHp() / 2),
|
||||||
@ -3223,7 +3225,7 @@ export class WishAttr extends MoveEffectAttr {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override getCondition(): MoveConditionFunc {
|
override getCondition(): MoveConditionFunc {
|
||||||
// Check the arena if another wish is active and affecting the same slot
|
// Check the arena if another wish is active and affecting the same slot
|
||||||
return (_user, target) => globalScene.arena.positionalTagManager.canAddTag(PositionalTagType.WISH, target.getBattlerIndex())
|
return (_user, target) => globalScene.arena.positionalTagManager.canAddTag(PositionalTagType.WISH, target.getBattlerIndex())
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,11 @@ export interface PositionalTagBaseArgs {
|
|||||||
export abstract class PositionalTag implements PositionalTagBaseArgs {
|
export abstract class PositionalTag implements PositionalTagBaseArgs {
|
||||||
/** This tag's {@linkcode PositionalTagType | type} */
|
/** This tag's {@linkcode PositionalTagType | type} */
|
||||||
public abstract readonly tagType: PositionalTagType;
|
public abstract readonly tagType: PositionalTagType;
|
||||||
// These arguments have to be public to implement the interface, but are functionally private.
|
// These arguments have to be public to implement the interface, but are functionally private
|
||||||
|
// outside this and the tag manager.
|
||||||
// Left undocumented to inherit doc comments from the interface
|
// Left undocumented to inherit doc comments from the interface
|
||||||
public turnCount: number;
|
public turnCount: number;
|
||||||
public targetIndex: BattlerIndex;
|
public readonly targetIndex: BattlerIndex;
|
||||||
|
|
||||||
constructor({ turnCount, targetIndex }: PositionalTagBaseArgs) {
|
constructor({ turnCount, targetIndex }: PositionalTagBaseArgs) {
|
||||||
this.turnCount = turnCount;
|
this.turnCount = turnCount;
|
||||||
@ -87,8 +88,8 @@ interface DelayedAttackArgs extends PositionalTagBaseArgs {
|
|||||||
*/
|
*/
|
||||||
export class DelayedAttackTag extends PositionalTag implements DelayedAttackArgs {
|
export class DelayedAttackTag extends PositionalTag implements DelayedAttackArgs {
|
||||||
public override readonly tagType = PositionalTagType.DELAYED_ATTACK;
|
public override readonly tagType = PositionalTagType.DELAYED_ATTACK;
|
||||||
public sourceMove: MoveId;
|
public readonly sourceMove: MoveId;
|
||||||
public sourceId: number;
|
public readonly sourceId: number;
|
||||||
|
|
||||||
constructor({ sourceId, turnCount, targetIndex, sourceMove }: DelayedAttackArgs) {
|
constructor({ sourceId, turnCount, targetIndex, sourceMove }: DelayedAttackArgs) {
|
||||||
super({ turnCount, targetIndex });
|
super({ turnCount, targetIndex });
|
||||||
@ -96,7 +97,7 @@ export class DelayedAttackTag extends PositionalTag implements DelayedAttackArgs
|
|||||||
this.sourceMove = sourceMove;
|
this.sourceMove = sourceMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
override trigger(): void {
|
public override trigger(): void {
|
||||||
// Bangs are justified as the `shouldTrigger` method will queue the tag for removal
|
// Bangs are justified as the `shouldTrigger` method will queue the tag for removal
|
||||||
// if the source or target no longer exist
|
// if the source or target no longer exist
|
||||||
const source = globalScene.getPokemonById(this.sourceId)!;
|
const source = globalScene.getPokemonById(this.sourceId)!;
|
||||||
@ -119,7 +120,7 @@ export class DelayedAttackTag extends PositionalTag implements DelayedAttackArgs
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
override shouldTrigger(): boolean {
|
public override shouldTrigger(): boolean {
|
||||||
const source = globalScene.getPokemonById(this.sourceId);
|
const source = globalScene.getPokemonById(this.sourceId);
|
||||||
const target = this.getTarget();
|
const target = this.getTarget();
|
||||||
// Silently disappear if either source or target are missing or happen to be the same pokemon
|
// Silently disappear if either source or target are missing or happen to be the same pokemon
|
||||||
@ -143,16 +144,16 @@ interface WishArgs extends PositionalTagBaseArgs {
|
|||||||
export class WishTag extends PositionalTag implements WishArgs {
|
export class WishTag extends PositionalTag implements WishArgs {
|
||||||
public override readonly tagType = PositionalTagType.WISH;
|
public override readonly tagType = PositionalTagType.WISH;
|
||||||
|
|
||||||
readonly pokemonName: string;
|
public readonly pokemonName: string;
|
||||||
|
public readonly healHp: number;
|
||||||
|
|
||||||
public healHp: number;
|
|
||||||
constructor({ turnCount, targetIndex, healHp, pokemonName }: WishArgs) {
|
constructor({ turnCount, targetIndex, healHp, pokemonName }: WishArgs) {
|
||||||
super({ turnCount, targetIndex });
|
super({ turnCount, targetIndex });
|
||||||
this.healHp = healHp;
|
this.healHp = healHp;
|
||||||
this.pokemonName = pokemonName;
|
this.pokemonName = pokemonName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public trigger(): void {
|
public override trigger(): void {
|
||||||
// TODO: Rename this locales key - wish shows a message on REMOVAL, not addition
|
// TODO: Rename this locales key - wish shows a message on REMOVAL, not addition
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("arenaTag:wishTagOnAdd", {
|
i18next.t("arenaTag:wishTagOnAdd", {
|
||||||
@ -163,7 +164,7 @@ export class WishTag extends PositionalTag implements WishArgs {
|
|||||||
globalScene.phaseManager.unshiftNew("PokemonHealPhase", this.targetIndex, this.healHp, null, true, false);
|
globalScene.phaseManager.unshiftNew("PokemonHealPhase", this.targetIndex, this.healHp, null, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
override shouldTrigger(): boolean {
|
public override shouldTrigger(): boolean {
|
||||||
// Disappear if no target or target is fainted.
|
// Disappear if no target or target is fainted.
|
||||||
// The source need not exist at the time of activation (since all we need is a simple message)
|
// The source need not exist at the time of activation (since all we need is a simple message)
|
||||||
// TODO: Verify whether Wish shows a message if the Pokemon it would affect is KO'd on the turn of activation
|
// TODO: Verify whether Wish shows a message if the Pokemon it would affect is KO'd on the turn of activation
|
||||||
|
Loading…
Reference in New Issue
Block a user