Skip to content

Conversation

@jmorth
Copy link

@jmorth jmorth commented Nov 26, 2025

Currently the game will crash at line 126 of getNewLegendaryFusionForGymType if pokemon_to_be_replaced is Nil.

image

Adding a Nil check on line 126 safely guards against this at the cost of this trainer having a non-legendary Pokemon in their roster, in this case Marowak. (screenshot just do display error no longer occurs)

infinite-fusion-legendary-fix

Copilot AI review requested due to automatic review settings November 26, 2025 12:59
Copilot finished reviewing on behalf of jmorth November 26, 2025 13:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a nil check to prevent a crash in the getNewLegendaryFusionForGymType function when pokemon_to_be_replaced is nil. The fix allows the legendary mode to continue without crashing, though it results in a non-legendary Pokémon being used when the nil case occurs.

Key Changes

  • Added a nil check wrapper around lines 127-131 to prevent accessing properties on a nil object
  • Preserved existing logic for determining which species to replace with a legendary
Comments suppressed due to low confidence (1)

Data/Scripts/052_InfiniteFusion/System/GameModes/LegendaryMode.rb:119

  • The else block on line 117 has a logic error that causes pokemon_to_be_replaced to be nil. When base_pokemon_with_gym_type is empty (which triggers early return on line 108), this block should never execute. However, the comment says 'Neither have the type', which contradicts the empty check. The real issue is that pokemon_to_be_kept is set to .sample on an empty array (returns nil), then subtracting [nil] from an empty array and calling .first returns nil. This entire else block appears unreachable due to the early return on line 108, suggesting dead code.
  else  #Neither have the type, just pick at random
    pokemon_to_be_kept = base_pokemon_with_gym_type.sample
    pokemon_to_be_replaced = (base_pokemon_with_gym_type - [pokemon_to_be_kept]).first

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +128 to +131
head_species_id = legendary_species
else
body_species_id = legendary_species
end
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation detected: lines 128 and 131 use tabs while line 130 uses spaces. This should be standardized to match the project's style (appears to be 2 spaces based on surrounding code).

Suggested change
head_species_id = legendary_species
else
body_species_id = legendary_species
end
head_species_id = legendary_species
else
body_species_id = legendary_species
end

Copilot uses AI. Check for mistakes.
@FauxBlue
Copy link

This is already fixed in a way that results in a legendary. Just waiting on a new release. infinitefusion/scripts@baf223e

@jmorth
Copy link
Author

jmorth commented Nov 26, 2025

Cool. I'll just keep my fix local until next release, then. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants