Added Comments to Base Classes (#860)
parent
6bed21770d
commit
835b00d457
|
@ -434,29 +434,66 @@ export class SelfStatusMove extends Move {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class defining all {@link Move} Attributes
|
||||
* @abstract
|
||||
*/
|
||||
export abstract class MoveAttr {
|
||||
/** Should this {@link Move} target the user? */
|
||||
public selfTarget: boolean;
|
||||
|
||||
constructor(selfTarget: boolean = false) {
|
||||
this.selfTarget = selfTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies move attributes
|
||||
* @see {@link applyMoveAttrsInternal}
|
||||
* @virtual
|
||||
* @param user The {@link Pokemon} using the move
|
||||
* @param target The target {@link Pokemon} of the move
|
||||
* @param move The {@link Move} being used
|
||||
* @param args Set of unique arguments needed by this attribute
|
||||
* @returns true if the application succeeds
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @virtual
|
||||
* @returns the {@link MoveCondition} or {@link MoveConditionFunc} for this {@link Move}
|
||||
*/
|
||||
getCondition(): MoveCondition | MoveConditionFunc {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @virtual
|
||||
* @param user The {@link Pokemon} using the move
|
||||
* @param target The target {@link Pokemon} of the move
|
||||
* @param move The {@link Move} being used
|
||||
* @param cancelled A {@link Utils.BooleanHolder} which stores if the move should fail
|
||||
* @returns the string representing failure of this {@link Move}
|
||||
*/
|
||||
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the Enemy AI to rank an attack based on a given user
|
||||
* @see {@link EnemyPokemon.getNextMove}
|
||||
* @virtual
|
||||
*/
|
||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the Enemy AI to rank an attack based on a given target
|
||||
* @see {@link EnemyPokemon.getNextMove}
|
||||
* @virtual
|
||||
*/
|
||||
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||
return 0;
|
||||
}
|
||||
|
@ -470,6 +507,9 @@ export enum MoveEffectTrigger {
|
|||
POST_TARGET,
|
||||
}
|
||||
|
||||
/** Base class defining all Move Effect Attributes
|
||||
* @extends MoveAttr
|
||||
*/
|
||||
export class MoveEffectAttr extends MoveAttr {
|
||||
public trigger: MoveEffectTrigger;
|
||||
public firstHitOnly: boolean;
|
||||
|
@ -480,11 +520,21 @@ export class MoveEffectAttr extends MoveAttr {
|
|||
this.firstHitOnly = firstHitOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the {@link Move}'s effects are valid to {@link apply}
|
||||
* @virtual
|
||||
* @param user The {@link Pokemon} using the move
|
||||
* @param target The target {@link Pokemon} of the move
|
||||
* @param move The {@link Move} being used
|
||||
* @param args Set of unique arguments needed by this attribute
|
||||
* @returns true if the application succeeds
|
||||
*/
|
||||
canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]) {
|
||||
return !!(this.selfTarget ? user.hp && !user.getTag(BattlerTagType.FRENZY) : target.hp)
|
||||
&& (this.selfTarget || !target.getTag(BattlerTagType.PROTECTED) || move.hasFlag(MoveFlags.IGNORE_PROTECT));
|
||||
}
|
||||
|
||||
/** Applies move effects so long as they are able based on {@link canApply} */
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> {
|
||||
return this.canApply(user, target, move, args);
|
||||
}
|
||||
|
@ -806,8 +856,15 @@ export enum MultiHitType {
|
|||
_1_TO_10,
|
||||
}
|
||||
|
||||
/**
|
||||
* Heals the user or target by {@link healRatio} depending on the value of {@link selfTarget}
|
||||
* @extends MoveEffectAttr
|
||||
* @see {@link apply}
|
||||
*/
|
||||
export class HealAttr extends MoveEffectAttr {
|
||||
/** The percentage of {@link Stat.HP} to heal */
|
||||
private healRatio: number;
|
||||
/** Should an animation be shown? */
|
||||
private showAnim: boolean;
|
||||
|
||||
constructor(healRatio?: number, showAnim?: boolean, selfTarget?: boolean) {
|
||||
|
@ -822,6 +879,10 @@ export class HealAttr extends MoveEffectAttr {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link PokemonHealPhase}.
|
||||
* This heals the target and shows the appropriate message.
|
||||
*/
|
||||
addHealPhase(target: Pokemon, healRatio: number) {
|
||||
target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(),
|
||||
Math.max(Math.floor(target.getMaxHp() * healRatio), 1), getPokemonMessage(target, ' \nhad its HP restored.'), true, !this.showAnim));
|
||||
|
@ -903,7 +964,7 @@ export class IgnoreWeatherTypeDebuffAttr extends MoveAttr {
|
|||
* @param user Pokemon that used the move
|
||||
* @param target N/A
|
||||
* @param move Move with this attribute
|
||||
* @param args Utils.NumberHolder for arenaAttackTypeMultiplier
|
||||
* @param args [0] Utils.NumberHolder for arenaAttackTypeMultiplier
|
||||
* @returns true if the function succeeds
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
|
@ -963,27 +1024,19 @@ export class SandHealAttr extends WeatherHealAttr {
|
|||
}
|
||||
|
||||
/**
|
||||
* Heals the target by either {@link normalHealRatio} or {@link boostedHealRatio}
|
||||
* Heals the target or the user by either {@link normalHealRatio} or {@link boostedHealRatio}
|
||||
* depending on the evaluation of {@link condition}
|
||||
* @extends HealAttr
|
||||
* @see {@link apply}
|
||||
* @param user The Pokemon using this move
|
||||
* @param target The target Pokemon of this move
|
||||
* @param move This move
|
||||
* @param args N/A
|
||||
* @returns if the move was successful
|
||||
*/
|
||||
export class BoostHealAttr extends HealAttr {
|
||||
/** Healing received when {@link condition} is false */
|
||||
private normalHealRatio?: number;
|
||||
/** Healing received when {@link condition} is true */
|
||||
private boostedHealRatio?: number;
|
||||
/** The lambda expression to check against when boosting the healing value */
|
||||
private condition?: MoveConditionFunc;
|
||||
|
||||
/**
|
||||
* @param normalHealRatio Healing received when {@link condition} is false
|
||||
* @param boostedHealRatio Healing received when {@link condition} is true
|
||||
* @param showAnim Should a healing animation be showed?
|
||||
* @param selfTarget Should the move target the user?
|
||||
* @param condition The condition to check against when boosting the healing value
|
||||
*/
|
||||
constructor(normalHealRatio?: number, boostedHealRatio?: number, showAnim?: boolean, selfTarget?: boolean, condition?: MoveConditionFunc) {
|
||||
super(normalHealRatio, showAnim, selfTarget);
|
||||
this.normalHealRatio = normalHealRatio;
|
||||
|
@ -991,6 +1044,13 @@ export class BoostHealAttr extends HealAttr {
|
|||
this.condition = condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user The Pokemon using this move
|
||||
* @param target The target Pokemon of this move
|
||||
* @param move This move
|
||||
* @param args N/A
|
||||
* @returns true if the move was successful
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const healRatio = this.condition(user, target, move) ? this.boostedHealRatio : this.normalHealRatio;
|
||||
this.addHealPhase(target, healRatio);
|
||||
|
|
Loading…
Reference in New Issue