mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 00:52:47 +02:00
[Bug] [Move] Fix KO causing effects to occur twice (#5811)
* Fix firstTarget calculation when a target was fainted * Update type annotation in applyMoveEffects Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
e7f0ea624b
commit
6c6821b47d
@ -206,11 +206,13 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
* @throws Error if there was an unexpected hit check result
|
* @throws Error if there was an unexpected hit check result
|
||||||
*/
|
*/
|
||||||
private applyToTargets(user: Pokemon, targets: Pokemon[]): void {
|
private applyToTargets(user: Pokemon, targets: Pokemon[]): void {
|
||||||
|
let firstHit = true;
|
||||||
for (const [i, target] of targets.entries()) {
|
for (const [i, target] of targets.entries()) {
|
||||||
const [hitCheckResult, effectiveness] = this.hitChecks[i];
|
const [hitCheckResult, effectiveness] = this.hitChecks[i];
|
||||||
switch (hitCheckResult) {
|
switch (hitCheckResult) {
|
||||||
case HitCheckResult.HIT:
|
case HitCheckResult.HIT:
|
||||||
this.applyMoveEffects(target, effectiveness);
|
this.applyMoveEffects(target, effectiveness, firstHit);
|
||||||
|
firstHit = false;
|
||||||
if (isFieldTargeted(this.move)) {
|
if (isFieldTargeted(this.move)) {
|
||||||
// Stop processing other targets if the move is a field move
|
// Stop processing other targets if the move is a field move
|
||||||
return;
|
return;
|
||||||
@ -763,15 +765,12 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
* - Invoking {@linkcode applyOnTargetEffects} if the move does not hit a substitute
|
* - Invoking {@linkcode applyOnTargetEffects} if the move does not hit a substitute
|
||||||
* - Triggering form changes and emergency exit / wimp out if this is the last hit
|
* - Triggering form changes and emergency exit / wimp out if this is the last hit
|
||||||
*
|
*
|
||||||
* @param target the {@linkcode Pokemon} hit by this phase's move.
|
* @param target - the {@linkcode Pokemon} hit by this phase's move.
|
||||||
* @param effectiveness the effectiveness of the move (as previously evaluated in {@linkcode hitCheck})
|
* @param effectiveness - The effectiveness of the move (as previously evaluated in {@linkcode hitCheck})
|
||||||
|
* @param firstTarget - Whether this is the first target successfully struck by the move
|
||||||
*/
|
*/
|
||||||
protected applyMoveEffects(target: Pokemon, effectiveness: TypeDamageMultiplier): void {
|
protected applyMoveEffects(target: Pokemon, effectiveness: TypeDamageMultiplier, firstTarget: boolean): void {
|
||||||
const user = this.getUserPokemon();
|
const user = this.getUserPokemon();
|
||||||
|
|
||||||
/** The first target hit by the move */
|
|
||||||
const firstTarget = target === this.getTargets().find((_, i) => this.hitChecks[i][1] > 0);
|
|
||||||
|
|
||||||
if (isNullOrUndefined(user)) {
|
if (isNullOrUndefined(user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user