Adjust all Existing Comments to Match

Adjusted all existing comments on move.ts to match
This commit is contained in:
Benjamin Odom 2024-05-16 07:07:23 -05:00 committed by Samuel H
parent 8d83417cee
commit ff086ca492
2 changed files with 108 additions and 78 deletions

3
.gitignore vendored
View File

@ -24,6 +24,9 @@ dist-ssr
*.sln *.sln
*.sw? *.sw?
# Docummentation
docs/*
public/images/trainer/convert/* public/images/trainer/convert/*
public/images/battle_anims/input/*.png public/images/battle_anims/input/*.png
public/images/pokemon/input/*.png public/images/pokemon/input/*.png

View File

@ -1,6 +1,6 @@
import { Moves } from "./enums/moves"; import { Moves } from "./enums/moves";
import { ChargeAnim, MoveChargeAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims"; import { ChargeAnim, MoveChargeAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims";
import { BattleEndPhase, MovePhase, NewBattlePhase, PartyStatusCurePhase, PokemonHealPhase, StatChangePhase, SwitchSummonPhase } from "../phases"; import { BattleEndPhase, MoveEffectPhase, MovePhase, NewBattlePhase, PartyStatusCurePhase, PokemonHealPhase, StatChangePhase, SwitchSummonPhase } from "../phases";
import { BattleStat, getBattleStatName } from "./battle-stat"; import { BattleStat, getBattleStatName } from "./battle-stat";
import { EncoreTag } from "./battler-tags"; import { EncoreTag } from "./battler-tags";
import { BattlerTagType } from "./enums/battler-tag-type"; import { BattlerTagType } from "./enums/battler-tag-type";
@ -33,20 +33,26 @@ export enum MoveCategory {
} }
export enum MoveTarget { export enum MoveTarget {
/** {@link https://bulbapedia.bulbagarden.net/wiki/Category:Moves_that_target_the_user Moves that target the User} */
USER, USER,
OTHER, OTHER,
ALL_OTHERS, ALL_OTHERS,
NEAR_OTHER, NEAR_OTHER,
/** {@link https://bulbapedia.bulbagarden.net/wiki/Category:Moves_that_target_all_adjacent_Pok%C3%A9mon Moves that target all adjacent Pokemon} */
ALL_NEAR_OTHERS, ALL_NEAR_OTHERS,
NEAR_ENEMY, NEAR_ENEMY,
/** {@link https://bulbapedia.bulbagarden.net/wiki/Category:Moves_that_target_all_adjacent_foes Moves that taret all adjacent foes} */
ALL_NEAR_ENEMIES, ALL_NEAR_ENEMIES,
RANDOM_NEAR_ENEMY, RANDOM_NEAR_ENEMY,
ALL_ENEMIES, ALL_ENEMIES,
/** {@link https://bulbapedia.bulbagarden.net/wiki/Category:Counterattacks Counterattacks} */
ATTACKER, ATTACKER,
/** {@link https://bulbapedia.bulbagarden.net/wiki/Category:Moves_that_target_one_adjacent_ally Moves that target one adjacent ally} */
NEAR_ALLY, NEAR_ALLY,
ALLY, ALLY,
USER_OR_NEAR_ALLY, USER_OR_NEAR_ALLY,
USER_AND_ALLIES, USER_AND_ALLIES,
/** {@link https://bulbapedia.bulbagarden.net/wiki/Category:Moves_that_target_all_Pok%C3%A9mon Moves that target all Pokemon} */
ALL, ALL,
USER_SIDE, USER_SIDE,
ENEMY_SIDE, ENEMY_SIDE,
@ -67,8 +73,8 @@ export enum MoveFlags {
PUNCHING_MOVE = 1 << 8, PUNCHING_MOVE = 1 << 8,
SLICING_MOVE = 1 << 9, SLICING_MOVE = 1 << 9,
/** /**
* Indicates a move should be affected by {@link Abilities.RECKLESS} * Indicates a move should be affected by {@linkcode Abilities.RECKLESS}
* @see {@link Move.recklessMove()} * @see {@linkcode Move.recklessMove()}
*/ */
RECKLESS_MOVE = 1 << 10, RECKLESS_MOVE = 1 << 10,
BALLBOMB_MOVE = 1 << 11, BALLBOMB_MOVE = 1 << 11,
@ -277,10 +283,10 @@ export default class Move implements Localizable {
} }
/** /**
* Sets the {@link MoveFlags.RECKLESS_MOVE} flag for the calling Move * Sets the {@linkcode MoveFlags.RECKLESS_MOVE} flag for the calling Move
* @see {@link Abilities.RECKLESS} * @see {@linkcode Abilities.RECKLESS}
* @param {boolean} recklessMove The value to set the flag to * @param recklessMove The value to set the flag to
* @returns {Move} The {@link Move} that called this function * @returns The {@linkcode Move} that called this function
*/ */
recklessMove(recklessMove?: boolean): this { recklessMove(recklessMove?: boolean): this {
this.setFlag(MoveFlags.RECKLESS_MOVE, recklessMove); this.setFlag(MoveFlags.RECKLESS_MOVE, recklessMove);
@ -435,11 +441,12 @@ export class SelfStatusMove extends Move {
} }
/** /**
* Base class defining all {@link Move} Attributes * Base class defining all {@linkcode Move} Attributes
* @abstract * @abstract
* @see {@linkcode apply}
*/ */
export abstract class MoveAttr { export abstract class MoveAttr {
/** Should this {@link Move} target the user? */ /** Should this {@linkcode Move} target the user? */
public selfTarget: boolean; public selfTarget: boolean;
constructor(selfTarget: boolean = false) { constructor(selfTarget: boolean = false) {
@ -448,13 +455,13 @@ export abstract class MoveAttr {
/** /**
* Applies move attributes * Applies move attributes
* @see {@link applyMoveAttrsInternal} * @see {@linkcode applyMoveAttrsInternal}
* @virtual * @virtual
* @param user The {@link Pokemon} using the move * @param user {@linkcode Pokemon} using the move
* @param target The target {@link Pokemon} of the move * @param target {@linkcode Pokemon} target of the move
* @param move The {@link Move} being used * @param move {@linkcode Move} with this attribute
* @param args Set of unique arguments needed by this attribute * @param args Set of unique arguments needed by this attribute
* @returns true if the application succeeds * @returns true if application of the ability succeeds
*/ */
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> {
return true; return true;
@ -462,7 +469,7 @@ export abstract class MoveAttr {
/** /**
* @virtual * @virtual
* @returns the {@link MoveCondition} or {@link MoveConditionFunc} for this {@link Move} * @returns the {@linkcode MoveCondition} or {@linkcode MoveConditionFunc} for this {@linkcode Move}
*/ */
getCondition(): MoveCondition | MoveConditionFunc { getCondition(): MoveCondition | MoveConditionFunc {
return null; return null;
@ -470,11 +477,11 @@ export abstract class MoveAttr {
/** /**
* @virtual * @virtual
* @param user The {@link Pokemon} using the move * @param user {@linkcode Pokemon} using the move
* @param target The target {@link Pokemon} of the move * @param target {@linkcode Pokemon} target of the move
* @param move The {@link Move} being used * @param move {@linkcode Move} with this attribute
* @param cancelled A {@link Utils.BooleanHolder} which stores if the move should fail * @param cancelled {@linkcode Utils.BooleanHolder} which stores if the move should fail
* @returns the string representing failure of this {@link Move} * @returns the string representing failure of this {@linkcode Move}
*/ */
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null { getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
return null; return null;
@ -482,7 +489,7 @@ export abstract class MoveAttr {
/** /**
* Used by the Enemy AI to rank an attack based on a given user * Used by the Enemy AI to rank an attack based on a given user
* @see {@link EnemyPokemon.getNextMove} * @see {@linkcode EnemyPokemon.getNextMove}
* @virtual * @virtual
*/ */
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
@ -491,7 +498,7 @@ export abstract class MoveAttr {
/** /**
* Used by the Enemy AI to rank an attack based on a given target * Used by the Enemy AI to rank an attack based on a given target
* @see {@link EnemyPokemon.getNextMove} * @see {@linkcode EnemyPokemon.getNextMove}
* @virtual * @virtual
*/ */
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
@ -509,9 +516,14 @@ export enum MoveEffectTrigger {
/** Base class defining all Move Effect Attributes /** Base class defining all Move Effect Attributes
* @extends MoveAttr * @extends MoveAttr
* @see {@linkcode apply}
*/ */
export class MoveEffectAttr extends MoveAttr { export class MoveEffectAttr extends MoveAttr {
/** Defines when this effect should trigger in the move's effect order
* @see {@linkcode MoveEffectPhase.start}
*/
public trigger: MoveEffectTrigger; public trigger: MoveEffectTrigger;
/** Should this effect only apply on the first hit? */
public firstHitOnly: boolean; public firstHitOnly: boolean;
constructor(selfTarget?: boolean, trigger?: MoveEffectTrigger, firstHitOnly: boolean = false) { constructor(selfTarget?: boolean, trigger?: MoveEffectTrigger, firstHitOnly: boolean = false) {
@ -521,20 +533,20 @@ export class MoveEffectAttr extends MoveAttr {
} }
/** /**
* Determines whether the {@link Move}'s effects are valid to {@link apply} * Determines whether the {@linkcode Move}'s effects are valid to {@linkcode apply}
* @virtual * @virtual
* @param user The {@link Pokemon} using the move * @param user {@linkcode Pokemon} using the move
* @param target The target {@link Pokemon} of the move * @param target {@linkcode Pokemon} target of the move
* @param move The {@link Move} being used * @param move {@linkcode Move} with this attribute
* @param args Set of unique arguments needed by this attribute * @param args Set of unique arguments needed by this attribute
* @returns true if the application succeeds * @returns true if basic application of the ability attribute should be possible
*/ */
canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]) { canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]) {
return !!(this.selfTarget ? user.hp && !user.getTag(BattlerTagType.FRENZY) : target.hp) return !! (this.selfTarget ? user.hp && !user.getTag(BattlerTagType.FRENZY) : target.hp)
&& (this.selfTarget || !target.getTag(BattlerTagType.PROTECTED) || move.hasFlag(MoveFlags.IGNORE_PROTECT)); && (this.selfTarget || !target.getTag(BattlerTagType.PROTECTED) || move.hasFlag(MoveFlags.IGNORE_PROTECT));
} }
/** Applies move effects so long as they are able based on {@link canApply} */ /** Applies move effects so long as they are able based on {@linkcode canApply} */
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> {
return this.canApply(user, target, move, args); return this.canApply(user, target, move, args);
} }
@ -792,7 +804,7 @@ export class RecoilAttr extends MoveEffectAttr {
/** /**
* Attribute used for moves which self KO the user regardless if the move hits a target * Attribute used for moves which self KO the user regardless if the move hits a target
* @extends MoveEffectAttr * @extends MoveEffectAttr
* @see {@link apply} * @see {@linkcode apply}
**/ **/
export class SacrificialAttr extends MoveEffectAttr { export class SacrificialAttr extends MoveEffectAttr {
constructor() { constructor() {
@ -801,9 +813,9 @@ export class SacrificialAttr extends MoveEffectAttr {
/** /**
* Deals damage to the user equal to their current hp * Deals damage to the user equal to their current hp
* @param user Pokemon that used the move * @param user {@linkcode Pokemon} that used the move
* @param target The target of the move * @param target {@linkcode Pokemon} target of the move
* @param move Move with this attribute * @param move {@linkcode Move} with this attribute
* @param args N/A * @param args N/A
* @returns true if the function succeeds * @returns true if the function succeeds
**/ **/
@ -824,7 +836,7 @@ export class SacrificialAttr extends MoveEffectAttr {
/** /**
* Attribute used for moves which self KO the user but only if the move hits a target * Attribute used for moves which self KO the user but only if the move hits a target
* @extends MoveEffectAttr * @extends MoveEffectAttr
* @see {@link apply} * @see {@linkcode apply}
**/ **/
export class SacrificialAttrOnHit extends MoveEffectAttr { export class SacrificialAttrOnHit extends MoveEffectAttr {
constructor() { constructor() {
@ -833,14 +845,13 @@ export class SacrificialAttrOnHit extends MoveEffectAttr {
/** /**
* Deals damage to the user equal to their current hp if the move lands * Deals damage to the user equal to their current hp if the move lands
* @param user Pokemon that used the move * @param user {@linkcode Pokemon} that used the move
* @param target The target of the move * @param target {@linkcode Pokemon} target of the move
* @param move Move with this attribute * @param move {@linkcode Move} with this attribute
* @param args N/A * @param args N/A
* @returns true if the function succeeds * @returns true if the function succeeds
**/ **/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
// If the move fails to hit a target, then the user does not faint and the function returns false // If the move fails to hit a target, then the user does not faint and the function returns false
if (!super.apply(user, target, move, args)) if (!super.apply(user, target, move, args))
return false; return false;
@ -860,7 +871,9 @@ export class SacrificialAttrOnHit extends MoveEffectAttr {
/** /**
* Attribute used for moves which cut the user's Max HP in half. * Attribute used for moves which cut the user's Max HP in half.
* Triggers using POST_TARGET. * Triggers using {@linkcode MoveEffectTrigger.POST_TARGET}.
* @extends MoveEffectAttr
* @see {@linkcode apply}
*/ */
export class HalfSacrificialAttr extends MoveEffectAttr { export class HalfSacrificialAttr extends MoveEffectAttr {
constructor() { constructor() {
@ -869,9 +882,9 @@ export class HalfSacrificialAttr extends MoveEffectAttr {
/** /**
* Cut's the user's Max HP in half and displays the appropriate recoil message * Cut's the user's Max HP in half and displays the appropriate recoil message
* @param user Pokemon that used the move * @param user {@linkcode Pokemon} that used the move
* @param target N/A * @param target N/A
* @param move Move with this attribute * @param move {@linkcode Move} with this attribute
* @param args N/A * @param args N/A
* @returns true if the function succeeds * @returns true if the function succeeds
*/ */
@ -905,12 +918,12 @@ export enum MultiHitType {
} }
/** /**
* Heals the user or target by {@link healRatio} depending on the value of {@link selfTarget} * Heals the user or target by {@linkcode healRatio} depending on the value of {@linkcode selfTarget}
* @extends MoveEffectAttr * @extends MoveEffectAttr
* @see {@link apply} * @see {@linkcode apply}
*/ */
export class HealAttr extends MoveEffectAttr { export class HealAttr extends MoveEffectAttr {
/** The percentage of {@link Stat.HP} to heal */ /** The percentage of {@linkcode Stat.HP} to heal */
private healRatio: number; private healRatio: number;
/** Should an animation be shown? */ /** Should an animation be shown? */
private showAnim: boolean; private showAnim: boolean;
@ -928,7 +941,7 @@ export class HealAttr extends MoveEffectAttr {
} }
/** /**
* Creates a new {@link PokemonHealPhase}. * Creates a new {@linkcode PokemonHealPhase}.
* This heals the target and shows the appropriate message. * This heals the target and shows the appropriate message.
*/ */
addHealPhase(target: Pokemon, healRatio: number) { addHealPhase(target: Pokemon, healRatio: number) {
@ -944,11 +957,13 @@ export class HealAttr extends MoveEffectAttr {
/** /**
* Cures the user's party of non-volatile status conditions, ie. Heal Bell, Aromatherapy * Cures the user's party of non-volatile status conditions, ie. Heal Bell, Aromatherapy
* @param {string} message Message to display after using move * @extends MoveEffectAttr
* @param {Abilities} abilityCondition Skips mons with this ability, ie. Soundproof * @see {@linkcode apply}
*/ */
export class PartyStatusCureAttr extends MoveEffectAttr { export class PartyStatusCureAttr extends MoveEffectAttr {
/** Message to display after using move */
private message: string; private message: string;
/** Skips mons with this ability, ie. Soundproof */
private abilityCondition: Abilities; private abilityCondition: Abilities;
constructor(message: string, abilityCondition: Abilities) { constructor(message: string, abilityCondition: Abilities) {
@ -1000,19 +1015,23 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
/** /**
* Attribute used for moves which ignore type-based debuffs from weather, namely Hydro Steam. * Attribute used for moves which ignore type-based debuffs from weather, namely Hydro Steam.
* Called during damage calculation after getting said debuff from getAttackTypeMultiplier in the Pokemon class. * Called during damage calculation after getting said debuff from getAttackTypeMultiplier in the Pokemon class.
* @extends MoveAttr
* @see {@linkcode apply}
*/ */
export class IgnoreWeatherTypeDebuffAttr extends MoveAttr { export class IgnoreWeatherTypeDebuffAttr extends MoveAttr {
/** The {@linkcode WeatherType} this move ignores */
public weather: WeatherType; public weather: WeatherType;
constructor(weather: WeatherType){ constructor(weather: WeatherType){
super(); super();
this.weather = weather; this.weather = weather;
} }
/** /**
* Changes the type-based weather modifier if this move's power would be reduced by it * Changes the type-based weather modifier if this move's power would be reduced by it
* @param user Pokemon that used the move * @param user {@linkcode Pokemon} that used the move
* @param target N/A * @param target N/A
* @param move Move with this attribute * @param move {@linkcode Move} with this attribute
* @param args [0] Utils.NumberHolder for arenaAttackTypeMultiplier * @param args [0] {@linkcode Utils.NumberHolder} for arenaAttackTypeMultiplier
* @returns true if the function succeeds * @returns true if the function succeeds
*/ */
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
@ -1072,15 +1091,15 @@ export class SandHealAttr extends WeatherHealAttr {
} }
/** /**
* Heals the target or the user by either {@link normalHealRatio} or {@link boostedHealRatio} * Heals the target or the user by either {@linkcode normalHealRatio} or {@linkcode boostedHealRatio}
* depending on the evaluation of {@link condition} * depending on the evaluation of {@linkcode condition}
* @extends HealAttr * @extends HealAttr
* @see {@link apply} * @see {@linkcode apply}
*/ */
export class BoostHealAttr extends HealAttr { export class BoostHealAttr extends HealAttr {
/** Healing received when {@link condition} is false */ /** Healing received when {@linkcode condition} is false */
private normalHealRatio?: number; private normalHealRatio?: number;
/** Healing received when {@link condition} is true */ /** Healing received when {@linkcode condition} is true */
private boostedHealRatio?: number; private boostedHealRatio?: number;
/** The lambda expression to check against when boosting the healing value */ /** The lambda expression to check against when boosting the healing value */
private condition?: MoveConditionFunc; private condition?: MoveConditionFunc;
@ -1093,9 +1112,9 @@ export class BoostHealAttr extends HealAttr {
} }
/** /**
* @param user The Pokemon using this move * @param user {@linkcode Pokemon} using the move
* @param target The target Pokemon of this move * @param target {@linkcode Pokemon} target of the move
* @param move This move * @param move {@linkcode Move} with this attribute
* @param args N/A * @param args N/A
* @returns true if the move was successful * @returns true if the move was successful
*/ */
@ -1464,15 +1483,17 @@ export class BypassSleepAttr extends MoveAttr {
/** /**
* Attribute used for moves that bypass the burn damage reduction of physical moves, currently only facade * Attribute used for moves that bypass the burn damage reduction of physical moves, currently only facade
* Called during damage calculation * Called during damage calculation
* @param user N/A * @extends MoveAttr
* @param target N/A * @see {@linkcode apply}
* @param move Move with this attribute
* @param args Utils.BooleanHolder for burnDamageReductionCancelled
* @returns true if the function succeeds
*/ */
export class BypassBurnDamageReductionAttr extends MoveAttr { export class BypassBurnDamageReductionAttr extends MoveAttr {
/** Prevents the move's damage from being reduced by burn
/** Prevents the move's damage from being reduced by burn */ * @param user N/A
* @param target N/A
* @param move {@linkcode Move} with this attribute
* @param args [0] {@linkcode Utils.BooleanHolder} for burnDamageReductionCancelled
* @returns true if the function succeeds
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
(args[0] as Utils.BooleanHolder).value = true; (args[0] as Utils.BooleanHolder).value = true;
@ -2482,16 +2503,19 @@ export class ThunderAccuracyAttr extends VariableAccuracyAttr {
/** /**
* Attribute used for moves which never miss * Attribute used for moves which never miss
* against Pokemon with the {@link BattlerTagType.MINIMIZED} * against Pokemon with the {@linkcode BattlerTagType.MINIMIZED}
* @see {@link apply} * @extends VariableAccuracyAttr
* @param user N/A * @see {@linkcode apply}
* @param target Target of the move
* @param move N/A
* @param args [0] Accuracy of the move to be modified
* @returns true if the function succeeds
*/ */
export class MinimizeAccuracyAttr extends VariableAccuracyAttr{ export class MinimizeAccuracyAttr extends VariableAccuracyAttr {
/**
* @see {@linkcode apply}
* @param user N/A
* @param target {@linkcode Pokemon} target of the move
* @param move N/A
* @param args [0] Accuracy of the move to be modified
* @returns true if the function succeeds
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (target.getTag(BattlerTagType.MINIMIZED)){ if (target.getTag(BattlerTagType.MINIMIZED)){
const accuracy = args[0] as Utils.NumberHolder const accuracy = args[0] as Utils.NumberHolder
@ -3259,11 +3283,14 @@ export class FaintCountdownAttr extends AddBattlerTagAttr {
} }
} }
/** Attribute used when a move hits a {@link BattlerTagType} for double damage */ /**
* Attribute used when a move hits a {@linkcode BattlerTagType} for double damage
* @extends MoveAttr
*/
export class HitsTagAttr extends MoveAttr { export class HitsTagAttr extends MoveAttr {
/** The {@link BattlerTagType} this move hits */ /** The {@linkcode BattlerTagType} this move hits */
public tagType: BattlerTagType; public tagType: BattlerTagType;
/** Should this move deal double damage against {@link HitsTagAttr.tagType}? */ /** Should this move deal double damage against {@linkcode HitsTagAttr.tagType}? */
public doubleDamage: boolean; public doubleDamage: boolean;
constructor(tagType: BattlerTagType, doubleDamage?: boolean) { constructor(tagType: BattlerTagType, doubleDamage?: boolean) {