mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +02:00
Fix firstTarget calculation when a target was fainted
This commit is contained in:
parent
0712f86462
commit
a1fce52133
@ -206,11 +206,13 @@ export class MoveEffectPhase extends PokemonPhase {
|
||||
* @throws Error if there was an unexpected hit check result
|
||||
*/
|
||||
private applyToTargets(user: Pokemon, targets: Pokemon[]): void {
|
||||
let firstHit = true;
|
||||
for (const [i, target] of targets.entries()) {
|
||||
const [hitCheckResult, effectiveness] = this.hitChecks[i];
|
||||
switch (hitCheckResult) {
|
||||
case HitCheckResult.HIT:
|
||||
this.applyMoveEffects(target, effectiveness);
|
||||
this.applyMoveEffects(target, effectiveness, firstHit);
|
||||
firstHit = false;
|
||||
if (isFieldTargeted(this.move)) {
|
||||
// Stop processing other targets if the move is a field move
|
||||
return;
|
||||
@ -763,15 +765,12 @@ export class MoveEffectPhase extends PokemonPhase {
|
||||
* - 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
|
||||
*
|
||||
* @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 target - the {@linkcode Pokemon} hit by this phase's move.
|
||||
* @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): void {
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user