mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
Renamed class PlayerTrainer to class Player, implemented class Player#Pokedex
This commit is contained in:
@@ -186,126 +186,3 @@ class NPCTrainer < Trainer
|
||||
@lose_text = nil
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Trainer class for the player
|
||||
#===============================================================================
|
||||
class PlayerTrainer < Trainer
|
||||
attr_writer :character_ID
|
||||
attr_accessor :outfit
|
||||
attr_accessor :badges
|
||||
attr_reader :money
|
||||
attr_accessor :seen
|
||||
attr_accessor :owned
|
||||
attr_accessor :seen_forms
|
||||
attr_accessor :last_seen_forms
|
||||
attr_accessor :owned_shadow
|
||||
attr_accessor :pokedex # Whether the Pokédex was obtained
|
||||
attr_accessor :pokegear # Whether the Pokégear was obtained
|
||||
attr_accessor :mystery_gift_unlocked # Whether MG can be used from load screen
|
||||
attr_accessor :mystery_gifts # Variable that stores downloaded MG data
|
||||
|
||||
def character_ID
|
||||
@character_ID = $PokemonGlobal.playerID || 0 if !@character_ID
|
||||
return @character_ID
|
||||
end
|
||||
|
||||
def money=(value)
|
||||
@money = value.clamp(0, Settings::MAX_MONEY)
|
||||
end
|
||||
|
||||
def badge_count
|
||||
ret = 0
|
||||
@badges.each { |b| ret += 1 if b }
|
||||
return ret
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
def seen?(species)
|
||||
species_data = GameData::Species.try_get(species)
|
||||
return (species_data) ? @seen[species_data.species] : false
|
||||
end
|
||||
alias hasSeen? seen?
|
||||
|
||||
def owned?(species)
|
||||
species_data = GameData::Species.try_get(species)
|
||||
return (species_data) ? @owned[species_data.species] : false
|
||||
end
|
||||
alias hasOwned? owned?
|
||||
|
||||
def set_seen(species)
|
||||
species_data = GameData::Species.try_get(species)
|
||||
@seen[species_data.species] = true if species_data
|
||||
end
|
||||
|
||||
def set_owned(species)
|
||||
species_data = GameData::Species.try_get(species)
|
||||
@owned[species_data.species] = true if species_data
|
||||
end
|
||||
|
||||
def seen_count(region = -1)
|
||||
ret = 0
|
||||
if region == -1
|
||||
GameData::Species.each { |s| ret += 1 if s.form == 0 && @seen[s.species] }
|
||||
else
|
||||
pbAllRegionalSpecies(region).each { |s| ret += 1 if s && @seen[s] }
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def seen_any?(region = -1)
|
||||
if region == -1
|
||||
GameData::Species.each { |s| return true if s.form == 0 && @seen[s.species] }
|
||||
else
|
||||
pbAllRegionalSpecies(region).each { |s| return true if s && @seen[s] }
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def owned_count(region = -1)
|
||||
ret = 0
|
||||
if region == -1
|
||||
GameData::Species.each { |s| ret += 1 if s.form == 0 && @owned[s.species] }
|
||||
else
|
||||
pbAllRegionalSpecies(region).each { |s| ret += 1 if s && @owned[s] }
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def seen_forms_count(species)
|
||||
species_data = GameData::Species.try_get(species)
|
||||
return 0 if !species_data
|
||||
species = species_data.species
|
||||
ret = 0
|
||||
@seen_forms[species] = [[], []] if !@seen_forms[species]
|
||||
array = @seen_forms[species]
|
||||
for i in 0...[array[0].length, array[1].length].max
|
||||
ret += 1 if array[0][i] || array[1][i]
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def clear_pokedex
|
||||
@seen = {}
|
||||
@owned = {}
|
||||
@seen_forms = {}
|
||||
@last_seen_forms = {}
|
||||
@owned_shadow = {}
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
def initialize(name, trainer_type)
|
||||
super
|
||||
@character_ID = nil
|
||||
@outfit = 0
|
||||
@badges = [false] * 8
|
||||
@money = Settings::INITIAL_MONEY
|
||||
clear_pokedex
|
||||
@pokegear = false
|
||||
@pokedex = false
|
||||
@mystery_gift_unlocked = false
|
||||
@mystery_gifts = []
|
||||
end
|
||||
end
|
||||
|
||||
63
Data/Scripts/014_Trainers/004_Player.rb
Normal file
63
Data/Scripts/014_Trainers/004_Player.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
#===============================================================================
|
||||
# Trainer class for the player
|
||||
#===============================================================================
|
||||
class Player < Trainer
|
||||
attr_writer :character_ID
|
||||
attr_accessor :outfit
|
||||
attr_accessor :badges
|
||||
attr_reader :money
|
||||
attr_reader :pokedex
|
||||
attr_accessor :has_pokedex
|
||||
attr_accessor :pokegear # Whether the Pokégear was obtained
|
||||
attr_accessor :mystery_gift_unlocked # Whether MG can be used from load screen
|
||||
attr_accessor :mystery_gifts # Variable that stores downloaded MG data
|
||||
|
||||
def inspect
|
||||
str = self.to_s.chop
|
||||
party_str = @party.map { |p| p.species_data.species }.inspect
|
||||
str << format(' %s @party=%s>', self.full_name, party_str)
|
||||
return str
|
||||
end
|
||||
|
||||
def character_ID
|
||||
@character_ID = $PokemonGlobal.playerID || 0 if !@character_ID
|
||||
return @character_ID
|
||||
end
|
||||
|
||||
def money=(value)
|
||||
@money = value.clamp(0, Settings::MAX_MONEY)
|
||||
end
|
||||
|
||||
def badge_count
|
||||
ret = 0
|
||||
@badges.each { |b| ret += 1 if b }
|
||||
return ret
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
def seen?(species)
|
||||
return @pokedex.seen?(species)
|
||||
end
|
||||
alias hasSeen? seen?
|
||||
|
||||
def owned?(species)
|
||||
return @pokedex.owned?(species)
|
||||
end
|
||||
alias hasOwned? owned?
|
||||
|
||||
#=============================================================================
|
||||
|
||||
def initialize(name, trainer_type)
|
||||
super
|
||||
@character_ID = nil
|
||||
@outfit = 0
|
||||
@badges = [false] * 8
|
||||
@money = Settings::INITIAL_MONEY
|
||||
@pokedex = Pokedex.new
|
||||
@pokegear = false
|
||||
@has_pokedex = false
|
||||
@mystery_gift_unlocked = false
|
||||
@mystery_gifts = []
|
||||
end
|
||||
end
|
||||
@@ -1,124 +0,0 @@
|
||||
#===============================================================================
|
||||
# Deprecated
|
||||
#===============================================================================
|
||||
class PlayerTrainer
|
||||
deprecated_method_alias :fullname, :full_name, removal_in: 'v20'
|
||||
deprecated_method_alias :publicID, :public_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :secretID, :secret_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :getForeignID, :make_foreign_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :trainerTypeName, :trainer_type_name, removal_in: 'v20'
|
||||
deprecated_method_alias :moneyEarned, :base_money, removal_in: 'v20'
|
||||
deprecated_method_alias :skill, :skill_level, removal_in: 'v20'
|
||||
deprecated_method_alias :skillCode, :skill_code, removal_in: 'v20'
|
||||
deprecated_method_alias :hasSkillCode, :has_skill_code?, removal_in: 'v20'
|
||||
deprecated_method_alias :pokemonParty, :pokemon_party, removal_in: 'v20'
|
||||
deprecated_method_alias :ablePokemonParty, :able_party, removal_in: 'v20'
|
||||
deprecated_method_alias :partyCount, :party_count, removal_in: 'v20'
|
||||
deprecated_method_alias :pokemonCount, :pokemon_count, removal_in: 'v20'
|
||||
deprecated_method_alias :ablePokemonCount, :able_pokemon_count, removal_in: 'v20'
|
||||
deprecated_method_alias :firstParty, :first_party, removal_in: 'v20'
|
||||
deprecated_method_alias :firstPokemon, :first_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :firstAblePokemon, :first_able_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :lastParty, :last_party, removal_in: 'v20'
|
||||
deprecated_method_alias :lastPokemon, :last_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :lastAblePokemon, :last_able_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :formseen, :seen_forms, removal_in: 'v20'
|
||||
deprecated_method_alias :formlastseen, :last_seen_forms, removal_in: 'v20'
|
||||
deprecated_method_alias :shadowcaught, :owned_shadow, removal_in: 'v20'
|
||||
deprecated_method_alias :numbadges, :badge_count, removal_in: 'v20'
|
||||
deprecated_method_alias :pokedexSeen, :seen_count, removal_in: 'v20'
|
||||
deprecated_method_alias :pokedexOwned, :owned_count, removal_in: 'v20'
|
||||
deprecated_method_alias :numFormsSeen, :seen_forms_count, removal_in: 'v20'
|
||||
deprecated_method_alias :clearPokedex, :clear_pokedex, removal_in: 'v20'
|
||||
deprecated_method_alias :metaID, :character_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :mysterygiftaccess, :mystery_gift_unlocked, removal_in: 'v20'
|
||||
deprecated_method_alias :mysterygift, :mystery_gifts, removal_in: 'v20'
|
||||
deprecated_method_alias :setSeen, :set_seen, removal_in: 'v20'
|
||||
deprecated_method_alias :setOwned, :set_owned, removal_in: 'v20'
|
||||
end
|
||||
|
||||
class PokeBattle_Trainer
|
||||
attr_reader :trainertype, :name, :id, :metaID, :outfit, :language
|
||||
attr_reader :party, :badges, :money
|
||||
attr_reader :seen, :owned, :formseen, :formlastseen, :shadowcaught
|
||||
attr_reader :pokedex, :pokegear
|
||||
attr_reader :mysterygiftaccess, :mysterygift
|
||||
|
||||
def self.convert(trainer)
|
||||
validate trainer => self
|
||||
ret = PlayerTrainer.new(trainer.name, trainer.trainertype)
|
||||
ret.id = trainer.id
|
||||
ret.character_ID = trainer.metaID if trainer.metaID
|
||||
ret.outfit = trainer.outfit if trainer.outfit
|
||||
ret.language = trainer.language if trainer.language
|
||||
trainer.party.each { |p| ret.party.push(PokeBattle_Pokemon.convert(p)) }
|
||||
ret.badges = trainer.badges.clone
|
||||
ret.money = trainer.money
|
||||
trainer.seen.each_with_index { |value, i| ret.set_seen(i) if value }
|
||||
trainer.owned.each_with_index { |value, i| ret.set_owned(i) if value }
|
||||
trainer.formseen.each_with_index do |value, i|
|
||||
ret.seen_forms[GameData::Species.get(i).species] = [value[0].clone, value[1].clone] if value
|
||||
end
|
||||
trainer.formlastseen.each_with_index do |value, i|
|
||||
ret.last_seen_forms[GameData::Species.get(i).species] = value.clone if value
|
||||
end
|
||||
if trainer.shadowcaught
|
||||
trainer.shadowcaught.each_with_index do |value, i|
|
||||
ret.owned_shadow[GameData::Species.get(i).species] = true if value
|
||||
end
|
||||
end
|
||||
ret.pokedex = trainer.pokedex
|
||||
ret.pokegear = trainer.pokegear
|
||||
ret.mystery_gift_unlocked = trainer.mysterygiftaccess if trainer.mysterygiftaccess
|
||||
ret.mystery_gifts = trainer.mysterygift.clone if trainer.mysterygift
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
# @deprecated Use {Trainer#remove_pokemon_at_index} instead. This alias is slated to be removed in v20.
|
||||
def pbRemovePokemonAt(index)
|
||||
Deprecation.warn_method('pbRemovePokemonAt', 'v20', 'PlayerTrainer#remove_pokemon_at_index')
|
||||
return $Trainer.remove_pokemon_at_index(index)
|
||||
end
|
||||
|
||||
# @deprecated Use {Trainer#has_other_able_pokemon?} instead. This alias is slated to be removed in v20.
|
||||
def pbCheckAble(index)
|
||||
Deprecation.warn_method('pbCheckAble', 'v20', 'PlayerTrainer#has_other_able_pokemon?')
|
||||
return $Trainer.has_other_able_pokemon?(index)
|
||||
end
|
||||
|
||||
# @deprecated Use {Trainer#all_fainted?} instead. This alias is slated to be removed in v20.
|
||||
def pbAllFainted
|
||||
Deprecation.warn_method('pbAllFainted', 'v20', 'PlayerTrainer#all_fainted?')
|
||||
return $Trainer.all_fainted?
|
||||
end
|
||||
|
||||
# @deprecated Use {Trainer#has_species?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasSpecies?(species, form = -1)
|
||||
Deprecation.warn_method('pbHasSpecies?', 'v20', 'PlayerTrainer#has_species?')
|
||||
return $Trainer.has_species?(species, form)
|
||||
end
|
||||
|
||||
# @deprecated Use {Trainer#has_fateful_species?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasFatefulSpecies?(species)
|
||||
Deprecation.warn_method('pbHasSpecies?', 'v20', 'PlayerTrainer#has_fateful_species?')
|
||||
return $Trainer.has_fateful_species?(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Trainer#has_pokemon_of_type?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasType?(type)
|
||||
Deprecation.warn_method('pbHasType?', 'v20', 'PlayerTrainer#has_pokemon_of_type?')
|
||||
return $Trainer.has_pokemon_of_type?(type)
|
||||
end
|
||||
|
||||
# @deprecated Use {Trainer#get_pokemon_with_move} instead. This alias is slated to be removed in v20.
|
||||
def pbCheckMove(move)
|
||||
Deprecation.warn_method('pbCheckMove', 'v20', 'PlayerTrainer#get_pokemon_with_move')
|
||||
return $Trainer.get_pokemon_with_move(move)
|
||||
end
|
||||
|
||||
# @deprecated Use {Trainer#heal_party} instead. This alias is slated to be removed in v20.
|
||||
def pbHealAll
|
||||
Deprecation.warn_method('pbHealAll', 'v20', 'PlayerTrainer#heal_party')
|
||||
$Trainer.heal_party
|
||||
end
|
||||
272
Data/Scripts/014_Trainers/005_Player_Pokedex.rb
Normal file
272
Data/Scripts/014_Trainers/005_Player_Pokedex.rb
Normal file
@@ -0,0 +1,272 @@
|
||||
class Player
|
||||
# Represents the player's Pokédex.
|
||||
class Pokedex
|
||||
# @return [Array<Integer>] an array of accessible Dexes
|
||||
# @see #refresh_accessible_dexes
|
||||
attr_reader :accessible_dexes
|
||||
|
||||
def inspect
|
||||
str = self.to_s.chop
|
||||
str << format(' seen: %d, owned: %d>', self.seen_count, self.owned_count)
|
||||
return str
|
||||
end
|
||||
|
||||
# Creates an empty Pokédex.
|
||||
def initialize
|
||||
@unlocked_dexes = []
|
||||
0.upto(pbLoadRegionalDexes.length) do |i|
|
||||
@unlocked_dexes[i] = (i == 0)
|
||||
end
|
||||
self.clear
|
||||
end
|
||||
|
||||
# Clears the Pokédex.
|
||||
def clear
|
||||
@seen = {}
|
||||
@owned = {}
|
||||
@seen_forms = {}
|
||||
@last_seen_forms = {}
|
||||
@owned_shadow = {}
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
# Sets the given species as seen in the Pokédex.
|
||||
# @param species [Symbol, GameData::Species] species to set as seen
|
||||
def set_seen(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return if species_id.nil?
|
||||
@seen[species_id] = true
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] species to check
|
||||
# @return [Boolean] whether the species is seen
|
||||
def seen?(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return false if species_id.nil?
|
||||
return @seen[species_id] == true
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] species to check
|
||||
# @param gender [Integer] gender to check
|
||||
# @param form [Integer] form to check
|
||||
# @return [Boolean] whether the species of the given gender and form is seen
|
||||
def seen_form?(species, gender, form)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return false if species_id.nil?
|
||||
@seen_forms[species_id] ||= [[], []]
|
||||
return @seen_forms[species_id][gender][form] == true
|
||||
end
|
||||
|
||||
# Returns the amount of seen Pokémon.
|
||||
# If a region ID is given, returns the amount of seen Pokémon
|
||||
# in that region.
|
||||
# @param dex [Integer] region ID
|
||||
def seen_count(dex = -1)
|
||||
validate dex => Integer
|
||||
return self.count_species(@seen, dex)
|
||||
end
|
||||
|
||||
# Returns whether there are any seen Pokémon.
|
||||
# If a region is given, returns whether there are seen Pokémon
|
||||
# in that region.
|
||||
# @param region [Integer] region ID
|
||||
# @return [Boolean] whether there are any seen Pokémon
|
||||
def seen_any?(dex = -1)
|
||||
validate dex => Integer
|
||||
if dex == -1
|
||||
GameData::Species.each { |s| return true if s.form == 0 && @seen[s.species] }
|
||||
else
|
||||
pbAllRegionalSpecies(dex).each { |s| return true if s && @seen[s] }
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
# Returns the amount of seen forms for the given species.
|
||||
# @param species [Symbol, GameData::Species] Pokémon species
|
||||
# @return [Integer] amount of seen forms
|
||||
def seen_forms_count(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return 0 if species_id.nil?
|
||||
ret = 0
|
||||
@seen_forms[species_id] ||= [[], []]
|
||||
array = @seen_forms[species_id]
|
||||
for i in 0...[array[0].length, array[1].length].max
|
||||
ret += 1 if array[0][i] || array[1][i]
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] Pokémon species
|
||||
def last_form_seen(species)
|
||||
@last_seen_forms[species] ||= []
|
||||
return @last_seen_forms[species][0] || 0, @last_seen_forms[species][1] || 0
|
||||
end
|
||||
|
||||
def set_last_form_seen(species, gender = 0, form = 0)
|
||||
@last_seen_forms[species] = [gender, form]
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
# Sets the given species as owned in the Pokédex.
|
||||
# @param species [Symbol, GameData::Species] species to set as owned
|
||||
def set_owned(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return if species_id.nil?
|
||||
@owned[species_id] = true
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
# Sets the given species as owned in the Pokédex.
|
||||
# @param species [Symbol, GameData::Species] species to set as owned
|
||||
def set_shadow_pokemon_owned(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return if species_id.nil?
|
||||
@owned[species_id] = true
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] species to check
|
||||
# @return [Boolean] whether the species is owned
|
||||
def owned?(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return false if species_id.nil?
|
||||
return @owned[species_id] == true
|
||||
end
|
||||
|
||||
# Returns the amount of owned Pokémon.
|
||||
# If a region ID is given, returns the amount of owned Pokémon
|
||||
# in that region.
|
||||
# @param region [Integer] region ID
|
||||
def owned_count(dex = -1)
|
||||
validate dex => Integer
|
||||
return self.count_species(@owned, dex)
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
# @param pkmn [Pokemon, Symbol, GameData::Species] Pokemon to register as seen
|
||||
# @param gender [Integer] gender to register (0=male, 1=female, 2=genderless)
|
||||
# @param form [Integer] form to register
|
||||
def register(species, gender = 0, form = 0)
|
||||
if species.is_a?(Pokemon)
|
||||
species_data = species.species_data
|
||||
gender = species.gender
|
||||
else
|
||||
species_data = GameData::Species.get_species_form(species, form)
|
||||
end
|
||||
species = species_data.species
|
||||
gender = 0 if gender >= 2
|
||||
form = species_data.form
|
||||
if form != species_data.pokedex_form
|
||||
species_data = GameData::Species.get_species_form(species, species_data.pokedex_form)
|
||||
form = species_data.form
|
||||
end
|
||||
form = 0 if species_data.form_name.nil? || species_data.form_name.empty?
|
||||
# Register as seen
|
||||
@seen[species] = true
|
||||
@seen_forms[species] ||= [[], []]
|
||||
@seen_forms[species][gender][form] = true
|
||||
@last_seen_forms[species] ||= []
|
||||
@last_seen_forms[species] = [gender, form] if @last_seen_forms[species] == []
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
# @param pkmn [Pokemon] Pokemon to register as most recently seen
|
||||
def register_last_seen(pkmn)
|
||||
validate pkmn => Pokemon
|
||||
species_data = pkmn.species_data
|
||||
form = species_data.pokedex_form
|
||||
form = 0 if species_data.form_name.nil? || species_data.form_name.empty?
|
||||
@last_seen_forms[pkmn.species] = [pkmn.gender, form]
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
# Unlocks the given Dex, -1 being the National Dex.
|
||||
# @param dex [Integer] Dex ID (-1 is the National Dex)
|
||||
def unlock(dex)
|
||||
validate dex => Integer
|
||||
dex = @unlocked_dexes.length - 1 if dex < 0 || dex > @unlocked_dexes.length - 1
|
||||
@unlocked_dexes[dex] = true
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
# Locks the given Dex, -1 being the National Dex.
|
||||
# @param dex [Integer] Dex ID (-1 is the National Dex)
|
||||
def lock(dex)
|
||||
validate dex => Integer
|
||||
dex = @unlocked_dexes.length - 1 if dex < 0 || dex > @unlocked_dexes.length - 1
|
||||
@unlocked_dexes[dex] = false
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
# @param dex [Integer] Dex ID (-1 is the National Dex)
|
||||
# @return [Boolean] whether the given Dex is unlocked
|
||||
def unlocked?(dex)
|
||||
validate dex => Integer
|
||||
dex = @unlocked_dexes.length - 1 if dex == -1
|
||||
return @unlocked_dexes[dex] == true
|
||||
end
|
||||
|
||||
# @return [Integer] the number of defined Dexes (including the National Dex)
|
||||
def dexes_count
|
||||
return @unlocked_dexes.length
|
||||
end
|
||||
|
||||
# Shorthand for +self.accessible_dexes.length+.
|
||||
# @return [Integer] amount of accessible Dexes
|
||||
def accessible_dexes_count
|
||||
return @accessible_dexes.length
|
||||
end
|
||||
|
||||
# Decides which Dex lists are able to be viewed (i.e. they are unlocked and
|
||||
# have at least 1 seen species in them), and saves all accessible Dex region
|
||||
# numbers into {#accessible_dexes}. National Dex comes after all regional
|
||||
# Dexes.
|
||||
# If the Dex list shown depends on the player's location, this just decides
|
||||
# if a species in the current region has been seen - doesn't look at other
|
||||
# regions.
|
||||
def refresh_accessible_dexes
|
||||
@accessible_dexes = []
|
||||
if Settings::USE_CURRENT_REGION_DEX
|
||||
region = pbGetCurrentRegion
|
||||
region = -1 if region >= dexes_count - 1
|
||||
@accessible_dexes[0] = region if self.seen_any?(region)
|
||||
return
|
||||
end
|
||||
if dexes_count == 1 # Only National Dex is defined
|
||||
if self.unlocked?(0) && self.seen_any?
|
||||
@accessible_dexes.push(-1)
|
||||
end
|
||||
else # Regional Dexes + National Dex
|
||||
for i in 0...dexes_count
|
||||
dex_list_to_check = (i == dexes_count - 1) ? -1 : i
|
||||
if self.unlocked?(i) && self.seen_any?(dex_list_to_check)
|
||||
@accessible_dexes.push(dex_list_to_check)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
private
|
||||
|
||||
# @param hash [Hash]
|
||||
# @param region [Integer]
|
||||
# @return [Integer]
|
||||
def count_species(hash, region = -1)
|
||||
ret = 0
|
||||
if region == -1
|
||||
GameData::Species.each { |s| ret += 1 if s.form == 0 && hash[s.species] }
|
||||
else
|
||||
pbAllRegionalSpecies(region).each { |s| ret += 1 if s && hash[s] }
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
end
|
||||
182
Data/Scripts/014_Trainers/006_Player_Deprecated.rb
Normal file
182
Data/Scripts/014_Trainers/006_Player_Deprecated.rb
Normal file
@@ -0,0 +1,182 @@
|
||||
#===============================================================================
|
||||
# Deprecated
|
||||
#===============================================================================
|
||||
class Trainer
|
||||
deprecated_method_alias :fullname, :full_name, removal_in: 'v20'
|
||||
deprecated_method_alias :publicID, :public_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :secretID, :secret_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :getForeignID, :make_foreign_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :trainerTypeName, :trainer_type_name, removal_in: 'v20'
|
||||
deprecated_method_alias :moneyEarned, :base_money, removal_in: 'v20'
|
||||
deprecated_method_alias :skill, :skill_level, removal_in: 'v20'
|
||||
deprecated_method_alias :skillCode, :skill_code, removal_in: 'v20'
|
||||
deprecated_method_alias :hasSkillCode, :has_skill_code?, removal_in: 'v20'
|
||||
deprecated_method_alias :pokemonParty, :pokemon_party, removal_in: 'v20'
|
||||
deprecated_method_alias :ablePokemonParty, :able_party, removal_in: 'v20'
|
||||
deprecated_method_alias :partyCount, :party_count, removal_in: 'v20'
|
||||
deprecated_method_alias :pokemonCount, :pokemon_count, removal_in: 'v20'
|
||||
deprecated_method_alias :ablePokemonCount, :able_pokemon_count, removal_in: 'v20'
|
||||
deprecated_method_alias :firstParty, :first_party, removal_in: 'v20'
|
||||
deprecated_method_alias :firstPokemon, :first_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :firstAblePokemon, :first_able_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :lastParty, :last_party, removal_in: 'v20'
|
||||
deprecated_method_alias :lastPokemon, :last_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :lastAblePokemon, :last_able_pokemon, removal_in: 'v20'
|
||||
end
|
||||
|
||||
class Player < Trainer
|
||||
class Pokedex
|
||||
attr_reader :seen_forms
|
||||
end
|
||||
|
||||
deprecated_method_alias :numbadges, :badge_count, removal_in: 'v20'
|
||||
deprecated_method_alias :metaID, :character_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :mysterygiftaccess, :mystery_gift_unlocked, removal_in: 'v20'
|
||||
deprecated_method_alias :mysterygift, :mystery_gifts, removal_in: 'v20'
|
||||
|
||||
# @deprecated Use {Player::Pokedex#set_seen} instead. This alias is slated to be removed in v20.
|
||||
def setSeen(species)
|
||||
Deprecation.warn_method('Player#setSeen', 'v20', 'Player::Pokedex#set_seen(species)')
|
||||
return @pokedex.set_seen(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#set_owned} instead. This alias is slated to be removed in v20.
|
||||
def setOwned(species)
|
||||
Deprecation.warn_method('Player#setOwned', 'v20', 'Player::Pokedex#set_owned(species)')
|
||||
return @pokedex.set_owned(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#seen_count} instead. This alias is slated to be removed in v20.
|
||||
def pokedexSeen(dex = -1)
|
||||
Deprecation.warn_method('Player#pokedexSeen', 'v20', 'Player::Pokedex#seen_count')
|
||||
return @pokedex.seen_count(dex)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#owned_count} instead. This alias is slated to be removed in v20.
|
||||
def pokedexOwned(dex = -1)
|
||||
Deprecation.warn_method('Player#pokedexOwned', 'v20', 'Player::Pokedex#owned_count')
|
||||
return @pokedex.owned_count(dex)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#seen_forms_count} instead. This alias is slated to be removed in v20.
|
||||
def numFormsSeen(species)
|
||||
Deprecation.warn_method('Player#numFormsSeen', 'v20', 'Player::Pokedex#seen_forms_count')
|
||||
return @pokedex.seen_forms_count(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#clear} instead. This alias is slated to be removed in v20.
|
||||
def clearPokedex
|
||||
Deprecation.warn_method('Player#clearPokedex', 'v20', 'Player::Pokedex#clear')
|
||||
return @pokedex.clear
|
||||
end
|
||||
end
|
||||
|
||||
class PokeBattle_Trainer
|
||||
attr_reader :trainertype, :name, :id, :metaID, :outfit, :language
|
||||
attr_reader :party, :badges, :money
|
||||
attr_reader :seen, :owned, :formseen, :formlastseen, :shadowcaught
|
||||
attr_reader :pokedex, :pokegear
|
||||
attr_reader :mysterygiftaccess, :mysterygift
|
||||
|
||||
def self.convert(trainer)
|
||||
validate trainer => self
|
||||
ret = Player.new(trainer.name, trainer.trainertype)
|
||||
ret.id = trainer.id
|
||||
ret.character_ID = trainer.metaID if trainer.metaID
|
||||
ret.outfit = trainer.outfit if trainer.outfit
|
||||
ret.language = trainer.language if trainer.language
|
||||
trainer.party.each { |p| ret.party.push(PokeBattle_Pokemon.convert(p)) }
|
||||
ret.badges = trainer.badges.clone
|
||||
ret.money = trainer.money
|
||||
trainer.seen.each_with_index { |value, i| ret.pokedex.set_seen(i) if value }
|
||||
trainer.owned.each_with_index { |value, i| ret.pokedex.set_owned(i) if value }
|
||||
trainer.formseen.each_with_index do |value, i|
|
||||
ret.pokedex.seen_forms[GameData::Species.get(i).species] = [value[0].clone, value[1].clone] if value
|
||||
end
|
||||
trainer.formlastseen.each_with_index do |value, i|
|
||||
ret.pokedex.set_last_form_seen(GameData::Species.get(i).species, value[0], value[1]) if value
|
||||
end
|
||||
if trainer.shadowcaught
|
||||
trainer.shadowcaught.each_with_index do |value, i|
|
||||
ret.pokedex.set_shadow_pokemon_owned(i) if value
|
||||
end
|
||||
end
|
||||
ret.has_pokedex = trainer.pokedex
|
||||
ret.pokegear = trainer.pokegear
|
||||
ret.mystery_gift_unlocked = trainer.mysterygiftaccess if trainer.mysterygiftaccess
|
||||
ret.mystery_gifts = trainer.mysterygift.clone if trainer.mysterygift
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#remove_pokemon_at_index} instead. This alias is slated to be removed in v20.
|
||||
def pbRemovePokemonAt(index)
|
||||
Deprecation.warn_method('pbRemovePokemonAt', 'v20', 'Player#remove_pokemon_at_index')
|
||||
return $Trainer.remove_pokemon_at_index(index)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#has_other_able_pokemon?} instead. This alias is slated to be removed in v20.
|
||||
def pbCheckAble(index)
|
||||
Deprecation.warn_method('pbCheckAble', 'v20', 'Player#has_other_able_pokemon?')
|
||||
return $Trainer.has_other_able_pokemon?(index)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#all_fainted?} instead. This alias is slated to be removed in v20.
|
||||
def pbAllFainted
|
||||
Deprecation.warn_method('pbAllFainted', 'v20', 'Player#all_fainted?')
|
||||
return $Trainer.all_fainted?
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#has_species?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasSpecies?(species, form = -1)
|
||||
Deprecation.warn_method('pbHasSpecies?', 'v20', 'Player#has_species?')
|
||||
return $Trainer.has_species?(species, form)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#has_fateful_species?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasFatefulSpecies?(species)
|
||||
Deprecation.warn_method('pbHasSpecies?', 'v20', 'Player#has_fateful_species?')
|
||||
return $Trainer.has_fateful_species?(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#has_pokemon_of_type?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasType?(type)
|
||||
Deprecation.warn_method('pbHasType?', 'v20', 'Player#has_pokemon_of_type?')
|
||||
return $Trainer.has_pokemon_of_type?(type)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#get_pokemon_with_move} instead. This alias is slated to be removed in v20.
|
||||
def pbCheckMove(move)
|
||||
Deprecation.warn_method('pbCheckMove', 'v20', 'Player#get_pokemon_with_move')
|
||||
return $Trainer.get_pokemon_with_move(move)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#heal_party} instead. This alias is slated to be removed in v20.
|
||||
def pbHealAll
|
||||
Deprecation.warn_method('pbHealAll', 'v20', 'Player#heal_party')
|
||||
$Trainer.heal_party
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#unlock} instead. This alias is slated to be removed in v20.
|
||||
def pbUnlockDex(dex=-1)
|
||||
Deprecation.warn_method('pbUnlockDex', 'v20', '$Trainer.pokedex.unlock(dex)')
|
||||
$Trainer.pokedex.unlock(dex)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#lock} instead. This alias is slated to be removed in v20.
|
||||
def pbLockDex(dex=-1)
|
||||
Deprecation.warn_method('pbLockDex', 'v20', '$Trainer.pokedex.lock(dex)')
|
||||
$Trainer.pokedex.lock(dex)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#register} instead. This alias is slated to be removed in v20.
|
||||
def pbSeenForm(species, gender = 0, form = 0)
|
||||
Deprecation.warn_method('pbSeenForm', 'v20', '$Trainer.pokedex.register(species, gender, form)')
|
||||
$Trainer.pokedex.register(species, gender, form)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#register_last_seen} instead. This alias is slated to be removed in v20.
|
||||
def pbUpdateLastSeenForm(pkmn)
|
||||
Deprecation.warn_method('Player#pokedexSeen', 'v20', '$Trainer.pokedex.register_last_seen(pkmn)')
|
||||
$Trainer.pokedex.register_last_seen(pkmn)
|
||||
end
|
||||
Reference in New Issue
Block a user