[Ability] Implement Poison Heal (#1245)

* Implement Poison Heal Ability

* Removed unneeded import

* Fix some comments, as well as make Poison Heal only notify when healing

* Eslint fix

* Revert Phases

* Pushing for sake of reviewing; PR IS NOT DONE IT NEEDS TO BE TESTED AND COMMENTED AGAIN

* Changed the way healing is done, through a heal phase instead of heal(); Also added better documentation

* Changed healing, as well as making abilityTriggers updated
This commit is contained in:
Ethan 2024-05-30 18:58:40 -04:00 committed by GitHub
parent af20712cb5
commit d2c5a283d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 70 additions and 2 deletions

View File

@ -2069,6 +2069,37 @@ export class BlockNonDirectDamageAbAttr extends AbAttr {
} }
} }
/**
* This attribute will block any status damage that you put in the parameter.
*/
export class BlockStatusDamageAbAttr extends BlockNonDirectDamageAbAttr {
private effects: StatusEffect[];
/**
* @param {StatusEffect[]} effects The status effect(s) that will be blocked from damaging the ability pokemon
*/
constructor(...effects: StatusEffect[]) {
super(false);
this.effects = effects;
}
/**
* @param {Pokemon} pokemon The pokemon with the ability
* @param {boolean} passive N/A
* @param {Utils.BooleanHolder} cancelled Whether to cancel the status damage
* @param {any[]} args N/A
* @returns Returns true if status damage is blocked
*/
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
if (this.effects.includes(pokemon.status.effect)) {
cancelled.value = true;
return true;
}
return false;
}
}
export class BlockOneHitKOAbAttr extends AbAttr { export class BlockOneHitKOAbAttr extends AbAttr {
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
cancelled.value = true; cancelled.value = true;
@ -2383,6 +2414,41 @@ export class PostTurnAbAttr extends AbAttr {
} }
} }
/**
* This attribute will heal 1/8th HP if the ability pokemon has the correct status.
*/
export class PostTurnStatusHealAbAttr extends PostTurnAbAttr {
private effects: StatusEffect[];
/**
* @param {StatusEffect[]} effects The status effect(s) that will qualify healing the ability pokemon
*/
constructor(...effects: StatusEffect[]) {
super(false);
this.effects = effects;
}
/**
* @param {Pokemon} pokemon The pokemon with the ability that will receive the healing
* @param {Boolean} passive N/A
* @param {any[]} args N/A
* @returns Returns true if healed from status, false if not
*/
applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
if (this.effects.includes(pokemon.status.effect)) {
if (pokemon.getMaxHp() !== pokemon.hp) {
const scene = pokemon.scene;
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(),
Math.max(Math.floor(pokemon.getMaxHp() / 8), 1), i18next.t("abilityTriggers:poisonHeal", { pokemonName: pokemon.name, abilityName: abilityName}), true));
return true;
}
}
return false;
}
}
/** /**
* After the turn ends, resets the status of either the ability holder or their ally * After the turn ends, resets the status of either the ability holder or their ally
* @param {boolean} allyTarget Whether to target ally, defaults to false (self-target) * @param {boolean} allyTarget Whether to target ally, defaults to false (self-target)
@ -3732,7 +3798,8 @@ export function initAbilities() {
new Ability(Abilities.IRON_FIST, 4) new Ability(Abilities.IRON_FIST, 4)
.attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.PUNCHING_MOVE), 1.2), .attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.PUNCHING_MOVE), 1.2),
new Ability(Abilities.POISON_HEAL, 4) new Ability(Abilities.POISON_HEAL, 4)
.unimplemented(), .attr(PostTurnStatusHealAbAttr, StatusEffect.TOXIC, StatusEffect.POISON)
.attr(BlockStatusDamageAbAttr, StatusEffect.TOXIC, StatusEffect.POISON),
new Ability(Abilities.ADAPTABILITY, 4) new Ability(Abilities.ADAPTABILITY, 4)
.attr(StabBoostAbAttr), .attr(StabBoostAbAttr),
new Ability(Abilities.SKILL_LINK, 4) new Ability(Abilities.SKILL_LINK, 4)

View File

@ -5,4 +5,5 @@ export const abilityTriggers: SimpleTranslationEntries = {
"badDreams": "{{pokemonName}} is tormented!", "badDreams": "{{pokemonName}} is tormented!",
"windPowerCharged": "Being hit by {{moveName}} charged {{pokemonName}} with power!", "windPowerCharged": "Being hit by {{moveName}} charged {{pokemonName}} with power!",
"perishBody": "{{pokemonName}}'s {{abilityName}}\nwill faint both pokemon in 3 turns!", "perishBody": "{{pokemonName}}'s {{abilityName}}\nwill faint both pokemon in 3 turns!",
"poisonHeal": "{{pokemonName}}'s {{abilityName}}\nrestored its HP a little!"
} as const; } as const;