pokerogue/src/phases/post-turn-status-effect-phase.ts

63 lines
2.7 KiB
TypeScript
Raw Normal View History

import BattleScene from "#app/battle-scene";
import { BattlerIndex } from "#app/battle";
[Ability] Implement Wimp Out and Emergency Exit (#4701) * implement Wimp Out/Emergency Exit * fixed test * fixed weather bug * Added nightmare interaction to Wimp Out following bug fix * refactored and added postdamageattr * bug fixes * added confusion test back (skipped) * updated applyPostDamageAbAttrs to applyPostDamage * fix external func name * fixed syntax inconsistency * updated PostDamageForceSwitchAttr -> PostDamageForceSwitchAbAttr * Modify `wimp_out.test.ts` * remove extra comment Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * remove extra comment Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * remove comment Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * remove comment Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix whitespace Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make getFailedText public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make switchOutLogic public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make getSwitchOutCondition public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make getFailedText public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make applyPostDamage public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * simplify if statement Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * add public override to applyPostDamage Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fixed nested if issue, remove trapped tag removal * add fix for multi hit move * added multi-lens logic * moved applyPostDamageAbAttrs to pokemon.damage, added check for multi lens in pokemon.apply * added source to damageAndUpdate and applyPostDamageAbAttrs, added Parental Bond logic + test, put applyPostDamageAbAttrs back in damageAndUpdate * simplify multi hit check Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> * Minor formatting changes * Update src/data/ability.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * moved and renamed shouldPreventSwitchOut, rewrote tests to account for U-turn changes, fix syntax error * Move comment slightly --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com>
2024-11-03 01:04:20 -05:00
import { applyAbAttrs, applyPostDamageAbAttrs, BlockNonDirectDamageAbAttr, BlockStatusDamageAbAttr, PostDamageAbAttr, ReduceBurnDamageAbAttr } from "#app/data/ability";
import { CommonBattleAnim, CommonAnim } from "#app/data/battle-anims";
import { getStatusEffectActivationText } from "#app/data/status-effect";
import { BattleSpec } from "#app/enums/battle-spec";
import { StatusEffect } from "#app/enums/status-effect";
import { getPokemonNameWithAffix } from "#app/messages";
import * as Utils from "#app/utils";
2024-08-19 03:23:52 +01:00
import { PokemonPhase } from "./pokemon-phase";
export class PostTurnStatusEffectPhase extends PokemonPhase {
constructor(scene: BattleScene, battlerIndex: BattlerIndex) {
super(scene, battlerIndex);
}
start() {
const pokemon = this.getPokemon();
if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn()) {
pokemon.status.incrementTurn();
const cancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled);
applyAbAttrs(BlockStatusDamageAbAttr, pokemon, cancelled);
if (!cancelled.value) {
this.scene.queueMessage(getStatusEffectActivationText(pokemon.status.effect, getPokemonNameWithAffix(pokemon)));
const damage = new Utils.NumberHolder(0);
switch (pokemon.status.effect) {
case StatusEffect.POISON:
damage.value = Math.max(pokemon.getMaxHp() >> 3, 1);
break;
case StatusEffect.TOXIC:
damage.value = Math.max(Math.floor((pokemon.getMaxHp() / 16) * pokemon.status.toxicTurnCount), 1);
break;
case StatusEffect.BURN:
damage.value = Math.max(pokemon.getMaxHp() >> 4, 1);
applyAbAttrs(ReduceBurnDamageAbAttr, pokemon, null, false, damage);
break;
2024-08-19 03:23:52 +01:00
}
if (damage.value) {
// Set preventEndure flag to avoid pokemon surviving thanks to focus band, sturdy, endure ...
this.scene.damageNumberHandler.add(this.getPokemon(), pokemon.damage(damage.value, false, true));
pokemon.updateInfo();
[Ability] Implement Wimp Out and Emergency Exit (#4701) * implement Wimp Out/Emergency Exit * fixed test * fixed weather bug * Added nightmare interaction to Wimp Out following bug fix * refactored and added postdamageattr * bug fixes * added confusion test back (skipped) * updated applyPostDamageAbAttrs to applyPostDamage * fix external func name * fixed syntax inconsistency * updated PostDamageForceSwitchAttr -> PostDamageForceSwitchAbAttr * Modify `wimp_out.test.ts` * remove extra comment Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * remove extra comment Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * remove comment Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * remove comment Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix tsdocs Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fix whitespace Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make getFailedText public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make switchOutLogic public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make getSwitchOutCondition public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make getFailedText public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * make applyPostDamage public Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * simplify if statement Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * add public override to applyPostDamage Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * fixed nested if issue, remove trapped tag removal * add fix for multi hit move * added multi-lens logic * moved applyPostDamageAbAttrs to pokemon.damage, added check for multi lens in pokemon.apply * added source to damageAndUpdate and applyPostDamageAbAttrs, added Parental Bond logic + test, put applyPostDamageAbAttrs back in damageAndUpdate * simplify multi hit check Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> * Minor formatting changes * Update src/data/ability.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * moved and renamed shouldPreventSwitchOut, rewrote tests to account for U-turn changes, fix syntax error * Move comment slightly --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com>
2024-11-03 01:04:20 -05:00
applyPostDamageAbAttrs(PostDamageAbAttr, pokemon, damage.value, pokemon.hasPassive(), false, []);
2024-08-19 03:23:52 +01:00
}
[Move] Implement Substitute (#2559) * Implement Substitute Squashed commit from working branch * Fix integration test imports * Use Override Helper utils + Fix Baton Pass test * Update src/test/moves/substitute.test.ts Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> * Fix test imports + nits * Document RemoveAllSubstitutesAttr * Fix some strict-null issues * more strict-null fixes * Fix baton pass test * Reorganized Substitute translation keys * Added checks for substitute in contact logic * Clean up Unseen Fist contact logic * Remove misleading comment in Download attr * RIP phases.ts * Fix imports post-phase migration * Rewrite `move.canIgnoreSubstitute` to `move.hitsSubstitute` * Also fixed interactions with Shell Trap and Beak Blast * Removed some leftover `canIgnoreSubstitute`s * fix issues after beta merge * Status move effectiveness now accounts for substitute * More edge case tests (Counter test failing) * Fix Counter + Trap edge cases + add Fail messagesd * Fix leftover nit * Resolve leftover test issues * Fix Sub offset carrying over to Trainer fights * Hide substitute sprite during catch attempts * Make substitutes baton-passable again * Remove placeholder locale keys and SPLASH_ONLY * Fix imports and other nits Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * ESLint * Fix imports * Fix incorrect `resetSprite` timing * Fix substitute disappearing on hit (maybe?) * More animation fixes (mostly for Roar) --------- Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2024-09-13 09:46:22 -07:00
new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(this.scene, false, () => this.end());
2024-08-19 03:23:52 +01:00
} else {
this.end();
}
} else {
this.end();
}
}
override end() {
if (this.scene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
this.scene.initFinalBossPhaseTwo(this.getPokemon());
} else {
super.end();
}
}
}