Refactored checking whether a Pokémon/species is single gendered, tweaked console message.

This commit is contained in:
Maruno17
2021-08-31 00:17:30 +01:00
parent 0405497868
commit 3c88c897f0
7 changed files with 38 additions and 24 deletions

View File

@@ -331,11 +331,12 @@ class Pokemon
# @return [0, 1, 2] this Pokémon's gender (0 = male, 1 = female, 2 = genderless)
def gender
if !@gender
gender_ratio = species_data.gender_ratio
case gender_ratio
when :AlwaysMale then @gender = 0
when :AlwaysFemale then @gender = 1
when :Genderless then @gender = 2
if species_data.single_gendered?
case species_data.gender_ratio
when :AlwaysMale then @gender = 0
when :AlwaysFemale then @gender = 1
else @gender = 2
end
else
female_chance = GameData::GenderRatio.get(gender_ratio).female_chance
@gender = ((@personalID & 0xFF) < female_chance) ? 1 : 0
@@ -369,8 +370,7 @@ class Pokemon
# @return [Boolean] whether this Pokémon species is restricted to only ever being one
# gender (or genderless)
def singleGendered?
gender_ratio = species_data.gender_ratio
return [:AlwaysMale, :AlwaysFemale, :Genderless].include?(gender_ratio)
return species_data.single_gendered?
end
#=============================================================================
@@ -1109,8 +1109,8 @@ class Pokemon
# @param species [Symbol, String, GameData::Species] Pokémon species
# @param level [Integer] Pokémon level
# @param owner [Owner, Player, NPCTrainer] Pokémon owner (the player by default)
# @param withMoves [TrueClass, FalseClass] whether the Pokémon should have moves
# @param recheck_form [TrueClass, FalseClass] whether to auto-check the form
# @param withMoves [Boolean] whether the Pokémon should have moves
# @param recheck_form [Boolean] whether to auto-check the form
def initialize(species, level, owner = $Trainer, withMoves = true, recheck_form = true)
species_data = GameData::Species.get(species)
@species = species_data.species