pagefaultgames / pokerogue

A browser based Pokémon fangame heavily inspired by the roguelite genre.
https://pokerogue.net
GNU Affero General Public License v3.0
4.5k stars 1.8k forks source link

[BUG] Splicing together an alive and a fainted pkmn will result in the fusion being alive (at avaraged HP) but displying FNT status #2608

Open Brsk79 opened 4 months ago

Brsk79 commented 4 months ago

The fused pkmn can still be used in battle.

Step to reproduce: fuse together pkmn A (healthy) and B (fainted), in my case the second one was fainted but idk it that has nothing to do with the bug. image

Snailman11 commented 2 months ago

Link to discord's (fusing a pokemon with a fainted pokemon shows the fainted icon, even though it's alive) https://discord.com/channels/1125469663833370665/1274134775895949407

flx-sta commented 2 months ago

From PR #4007

@seanrmon wrote

Unrelated but there's another bug in the fuse() function:

if (!this.isFainted()) {
        // If this Pokemon hasn't fainted, make sure the HP wasn't set over the new maximum
        this.hp = Math.min(this.hp, maxHp);
        this.status = getRandomStatus(this.status, pokemon.status); // Get a random valid status between the two
      } else if (!pokemon.isFainted()) {
        // If this Pokemon fainted but the other hasn't, make sure the HP wasn't set to zero
        this.hp = Math.max(this.hp, 1);
        this.status = pokemon.status; // Inherit the other Pokemon's status
      }

should be

if ((!this.isFainted())&&(!pokemon.isFainted())) {
        // If this Pokemon hasn't fainted, make sure the HP wasn't set over the new maximum
        this.hp = Math.min(this.hp, maxHp);
        this.status = getRandomStatus(this.status, pokemon.status); // Get a random valid status between the two
      } else if (!pokemon.isFainted()) {
        // If this Pokemon fainted but the other hasn't, make sure the HP wasn't set to zero
        this.hp = Math.max(this.hp, 1);
        this.status = pokemon.status; // Inherit the other Pokemon's status
      }

I've seen this happen in-game where a resulting fusion pokemon has the "Fainted" status, even though it's at max HP. You don't need to do anything in the "else" case because only secondary pokemon is fainted, so we don't need to do anything

source