mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-05-12 19:34:47 +01:00
* Create new turnData field for tracking damageResults, check for HitResult in Reviver Seed modifier * Optional chaining for cases like stealth rock * Adds HitResult.SELF for confusion to distinguish from indirect damage * Adds HitResult.SELF to damage sound effect switch * Cover edge case of salt cure, insert HitResult for ALL damage regardless of optional variable * Change Liquid Ooze HitResult to OTHER from HEAL * Adjust OHKO moves to not bypass endure or RSeed * Add tests for reviver seed * Fixes endure to no longer block indirect damage, updates weather damage to be HitResult.OTHER, adds/fixes unit test * Change destiny bond to HitResult.OTHER so it doesn't trigger rseed * Adds destiny bond unit test * Creates additional unit tests for endure * Rename SELF hitresult to CONFUSION * Update CONFUSION enum * Refactors implementation per Wlowscha's suggestions: removes damageSources array and preventEndure variable * Rename HitResult.OTHER to INDIRECT, create INDIRECT_KO for PSong/DBond, add functionality for INDIRECT_KO to damageanim/number handler * Fixes hit result for stealth rock * Removes unnecessary check, makes DamageResult default to EFFECTIVE, updates remaining damageAndUpdate calls to use INDIRECT * Refactors damageAndUpdate to replace optional parameters with object parameter * Fixes based on Kev's suggestions * Updates tsdocs for damageAndUpdate * Fix merge conflict --------- Co-authored-by: Wlowscha <54003515+Wlowscha@users.noreply.github.com>
93 lines
2.5 KiB
TypeScript
93 lines
2.5 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import type { BattlerIndex } from "#app/battle";
|
|
import { BattleSpec } from "#enums/battle-spec";
|
|
import { type DamageResult, HitResult } from "#app/field/pokemon";
|
|
import { fixedInt } from "#app/utils";
|
|
import { PokemonPhase } from "#app/phases/pokemon-phase";
|
|
|
|
export class DamageAnimPhase extends PokemonPhase {
|
|
private amount: number;
|
|
private damageResult: DamageResult;
|
|
private critical: boolean;
|
|
|
|
constructor(battlerIndex: BattlerIndex, amount: number, damageResult?: DamageResult, critical = false) {
|
|
super(battlerIndex);
|
|
|
|
this.amount = amount;
|
|
this.damageResult = damageResult || HitResult.EFFECTIVE;
|
|
this.critical = critical;
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
if (this.damageResult === HitResult.ONE_HIT_KO || this.damageResult === HitResult.INDIRECT_KO) {
|
|
if (globalScene.moveAnimations) {
|
|
globalScene.toggleInvert(true);
|
|
}
|
|
globalScene.time.delayedCall(fixedInt(1000), () => {
|
|
globalScene.toggleInvert(false);
|
|
this.applyDamage();
|
|
});
|
|
return;
|
|
}
|
|
|
|
this.applyDamage();
|
|
}
|
|
|
|
updateAmount(amount: number): void {
|
|
this.amount = amount;
|
|
}
|
|
|
|
applyDamage() {
|
|
switch (this.damageResult) {
|
|
case HitResult.EFFECTIVE:
|
|
case HitResult.CONFUSION:
|
|
globalScene.playSound("se/hit");
|
|
break;
|
|
case HitResult.SUPER_EFFECTIVE:
|
|
case HitResult.INDIRECT_KO:
|
|
case HitResult.ONE_HIT_KO:
|
|
globalScene.playSound("se/hit_strong");
|
|
break;
|
|
case HitResult.NOT_VERY_EFFECTIVE:
|
|
globalScene.playSound("se/hit_weak");
|
|
break;
|
|
}
|
|
|
|
if (this.amount) {
|
|
globalScene.damageNumberHandler.add(this.getPokemon(), this.amount, this.damageResult, this.critical);
|
|
}
|
|
|
|
if (this.damageResult !== HitResult.INDIRECT && this.amount > 0) {
|
|
const flashTimer = globalScene.time.addEvent({
|
|
delay: 100,
|
|
repeat: 5,
|
|
startAt: 200,
|
|
callback: () => {
|
|
this.getPokemon()
|
|
.getSprite()
|
|
.setVisible(flashTimer.repeatCount % 2 === 0);
|
|
if (!flashTimer.repeatCount) {
|
|
this.getPokemon()
|
|
.updateInfo()
|
|
.then(() => this.end());
|
|
}
|
|
},
|
|
});
|
|
} else {
|
|
this.getPokemon()
|
|
.updateInfo()
|
|
.then(() => this.end());
|
|
}
|
|
}
|
|
|
|
override end() {
|
|
if (globalScene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
|
|
globalScene.initFinalBossPhaseTwo(this.getPokemon());
|
|
} else {
|
|
super.end();
|
|
}
|
|
}
|
|
}
|