Skip to content

Commit

Permalink
[Ability] Implement Poison Heal (pagefaultgames#1245)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
EvasiveAce authored May 30, 2024
1 parent af20712 commit d2c5a28
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
69 changes: 68 additions & 1 deletion src/data/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
cancelled.value = true;
Expand Down Expand Up @@ -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
* @param {boolean} allyTarget Whether to target ally, defaults to false (self-target)
Expand Down Expand Up @@ -3732,7 +3798,8 @@ export function initAbilities() {
new Ability(Abilities.IRON_FIST, 4)
.attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.PUNCHING_MOVE), 1.2),
new Ability(Abilities.POISON_HEAL, 4)
.unimplemented(),
.attr(PostTurnStatusHealAbAttr, StatusEffect.TOXIC, StatusEffect.POISON)
.attr(BlockStatusDamageAbAttr, StatusEffect.TOXIC, StatusEffect.POISON),
new Ability(Abilities.ADAPTABILITY, 4)
.attr(StabBoostAbAttr),
new Ability(Abilities.SKILL_LINK, 4)
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en/ability-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export const abilityTriggers: SimpleTranslationEntries = {
"blockRecoilDamage" : "{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!",
"badDreams": "{{pokemonName}} is tormented!",
"windPowerCharged": "Being hit by {{moveName}} charged {{pokemonName}} with power!",
"perishBody": "{{pokemonName}}'s {{abilityName}}\n will 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;

0 comments on commit d2c5a28

Please sign in to comment.