Added Gen 8's shiny chance increase with number battled, fixed other shiny chance-boosting effects not working

This commit is contained in:
Maruno17
2021-08-31 16:54:03 +01:00
parent 3c88c897f0
commit 218307d993
12 changed files with 172 additions and 40 deletions

View File

@@ -27,6 +27,8 @@ class Player < Trainer
@seen_forms = {}
@last_seen_forms = {}
@owned_shadow = {}
@caught_counts = {}
@defeated_counts = {}
self.refresh_accessible_dexes
end
@@ -199,6 +201,51 @@ class Player < Trainer
#===========================================================================
# @param species [Symbol, GameData::Species] species to check
# @return [Integer] the number of Pokémon of the given species that have
# been caught by the player
def caught_count(species)
species_id = GameData::Species.try_get(species)&.species
return 0 if species_id.nil?
return @caught_counts[species] || 0
end
# @param species [Symbol, GameData::Species] species to check
# @return [Integer] the number of Pokémon of the given species that have
# been defeated by the player
def defeated_count(species)
species_id = GameData::Species.try_get(species)&.species
return 0 if species_id.nil?
return @defeated_counts[species] || 0
end
# @param species [Symbol, GameData::Species] species to check
# @return [Integer] the number of Pokémon of the given species that have
# been defeated or caught by the player
def battled_count(species)
species_id = GameData::Species.try_get(species)&.species
return 0 if species_id.nil?
return (@defeated_counts[species] || 0) + (@caught_counts[species] || 0)
end
# @param species [Symbol, GameData::Species] species to count as caught
def register_caught(species)
species_id = GameData::Species.try_get(species)&.species
return if species_id.nil?
@caught_counts[species] = 0 if @caught_counts[species].nil?
@caught_counts[species] += 1
end
# @param species [Symbol, GameData::Species] species to count as defeated
def register_defeated(species)
species_id = GameData::Species.try_get(species)&.species
return if species_id.nil?
@defeated_counts[species] = 0 if @defeated_counts[species].nil?
@defeated_counts[species] += 1
end
#===========================================================================
# Unlocks the given Dex, -1 being the National Dex.
# @param dex [Integer] Dex ID (-1 is the National Dex)
def unlock(dex)