Fully implemented floral healing (#250)

* Created BoostedHealAttr and implemented Floral Healing

* Update move.ts

---------

Co-authored-by: Benjamin Odom <bennybroseph@gmail.com>
pull/281/merge
Marcos 2024-05-13 11:27:38 +02:00 committed by GitHub
parent 21a0a0276d
commit 3cc990f5d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 39 additions and 4 deletions

View File

@ -824,7 +824,7 @@ export class HealAttr extends MoveEffectAttr {
addHealPhase(target: Pokemon, healRatio: number) { addHealPhase(target: Pokemon, healRatio: number) {
target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), target.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(),
Math.max(Math.floor(target.getMaxHp() * healRatio), 1), getPokemonMessage(target, ' regained\nhealth!'), true, !this.showAnim)); Math.max(Math.floor(target.getMaxHp() * healRatio), 1), getPokemonMessage(target, ' \nhad its HP restored.'), true, !this.showAnim));
} }
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
@ -962,6 +962,42 @@ export class SandHealAttr extends WeatherHealAttr {
} }
} }
/**
* Heals the target by either {@link normalHealRatio} or {@link boostedHealRatio}
* depending on the evaluation of {@link condition}
* @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 {
private normalHealRatio?: number;
private boostedHealRatio?: number;
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;
this.boostedHealRatio = boostedHealRatio;
this.condition = condition;
}
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);
return true;
}
}
export class HitHealAttr extends MoveEffectAttr { export class HitHealAttr extends MoveEffectAttr {
private healRatio: number; private healRatio: number;
@ -5977,9 +6013,8 @@ export function initMoves() {
.attr(StatChangeAttr, BattleStat.SPD, -1, true) .attr(StatChangeAttr, BattleStat.SPD, -1, true)
.punchingMove(), .punchingMove(),
new StatusMove(Moves.FLORAL_HEALING, Type.FAIRY, -1, 10, -1, 0, 7) new StatusMove(Moves.FLORAL_HEALING, Type.FAIRY, -1, 10, -1, 0, 7)
.attr(HealAttr, 0.5, true, false) .attr(BoostHealAttr, 0.5, 2/3, true, false, (user, target, move) => user.scene.arena.terrain?.terrainType === TerrainType.GRASSY)
.triageMove() .triageMove(),
.partial(),
new AttackMove(Moves.HIGH_HORSEPOWER, Type.GROUND, MoveCategory.PHYSICAL, 95, 95, 10, -1, 0, 7), new AttackMove(Moves.HIGH_HORSEPOWER, Type.GROUND, MoveCategory.PHYSICAL, 95, 95, 10, -1, 0, 7),
new StatusMove(Moves.STRENGTH_SAP, Type.GRASS, 100, 10, 100, 0, 7) new StatusMove(Moves.STRENGTH_SAP, Type.GRASS, 100, 10, 100, 0, 7)
.attr(StrengthSapHealAttr) .attr(StrengthSapHealAttr)