Renamed class PlayerTrainer to class Player, implemented class Player#Pokedex

This commit is contained in:
Maruno17
2021-04-11 20:45:44 +01:00
parent dcd0fe8b21
commit e49ddde198
32 changed files with 637 additions and 475 deletions

View File

@@ -189,7 +189,7 @@ module Settings
# The names of the Pokédex lists, in the order they are defined in the PBS # The names of the Pokédex lists, in the order they are defined in the PBS
# file "regionaldexes.txt". The last name is for the National Dex and is added # file "regionaldexes.txt". The last name is for the National Dex and is added
# onto the end of this array (remember that you don't need to use it). This # onto the end of this array (remember that you don't need to use it). This
# array's order is also the order of $PokemonGlobal.pokedexUnlocked, which # array's order is also the order of $Trainer.pokedex.unlocked_dexes, which
# records which Dexes have been unlocked (the first is unlocked by default). # records which Dexes have been unlocked (the first is unlocked by default).
# If an entry is just a name, then the region map shown in the Area page while # If an entry is just a name, then the region map shown in the Area page while
# viewing that Dex list will be the region map of the region the player is # viewing that Dex list will be the region map of the region the player is

View File

@@ -1,7 +1,7 @@
# Contains the save values defined in Essentials by default. # Contains the save values defined in Essentials by default.
SaveData.register(:player) do SaveData.register(:player) do
ensure_class :PlayerTrainer ensure_class :Player
save_value { $Trainer } save_value { $Trainer }
load_value { |value| $Trainer = value } load_value { |value| $Trainer = value }
from_old_format { |old_format| old_format[0] } from_old_format { |old_format| old_format[0] }

View File

@@ -38,12 +38,28 @@ SaveData.register_conversion(:v19_convert_player) do
essentials_version 19 essentials_version 19
display_title 'Converting player trainer class' display_title 'Converting player trainer class'
to_all do |save_data| to_all do |save_data|
next if save_data[:player].is_a?(PlayerTrainer) next if save_data[:player].is_a?(Player)
# Conversion of the party is handled in PokeBattle_Trainer.convert # Conversion of the party is handled in PokeBattle_Trainer.convert
save_data[:player] = PokeBattle_Trainer.convert(save_data[:player]) save_data[:player] = PokeBattle_Trainer.convert(save_data[:player])
end end
end end
SaveData.register_conversion(:v19_move_global_data_to_player) do
essentials_version 19
display_title 'Moving some Global Metadata data to Player class'
to_all do |save_data|
global = save_data[:global_metadata]
player = save_data[:player]
global.pokedexUnlocked.each_with_index do |value, i|
if value
player.pokedex.unlock(i)
else
player.pokedex.lock(i)
end
end
end
end
SaveData.register_conversion(:v19_convert_global_metadata) do SaveData.register_conversion(:v19_convert_global_metadata) do
essentials_version 19 essentials_version 19
display_title 'Adding encounter version variable to global metadata' display_title 'Adding encounter version variable to global metadata'
@@ -175,6 +191,6 @@ SaveData.register_conversion(:v19_convert_game_screen) do
essentials_version 19 essentials_version 19
display_title 'Converting game screen' display_title 'Converting game screen'
to_value :game_screen do |game_screen| to_value :game_screen do |game_screen|
game_screen.weather(game_screen.weather_type, game_screen.weather_max) game_screen.weather(game_screen.weather_type, game_screen.weather_max, 0)
end end
end end

View File

@@ -42,20 +42,17 @@ module PokeBattle_BattleCommon
# Register all caught Pokémon in the Pokédex, and store them. # Register all caught Pokémon in the Pokédex, and store them.
def pbRecordAndStoreCaughtPokemon def pbRecordAndStoreCaughtPokemon
@caughtPokemon.each do |pkmn| @caughtPokemon.each do |pkmn|
pbSeenForm(pkmn) # In case the form changed upon leaving battle pbPlayer.pokedex.register(pkmn) # In case the form changed upon leaving battle
# Record the Pokémon's species as owned in the Pokédex # Record the Pokémon's species as owned in the Pokédex
if !pbPlayer.hasOwned?(pkmn.species) if !pbPlayer.hasOwned?(pkmn.species)
pbPlayer.set_owned(pkmn.species) pbPlayer.pokedex.set_owned(pkmn.species)
if $Trainer.pokedex if $Trainer.has_pokedex
pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.",pkmn.name)) pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.",pkmn.name))
@scene.pbShowPokedex(pkmn.species) @scene.pbShowPokedex(pkmn.species)
end end
end end
# Record a Shadow Pokémon's species as having been caught # Record a Shadow Pokémon's species as having been caught
if pkmn.shadowPokemon? pbPlayer.pokedex.set_shadow_pokemon_owned(pkmn.species) if pkmn.shadowPokemon?
pbPlayer.owned_shadow = {} if !pbPlayer.owned_shadow
pbPlayer.owned_shadow[pkmn.species] = true
end
# Store caught Pokémon # Store caught Pokémon
pbStorePokemon(pkmn) pbStorePokemon(pkmn)
end end
@@ -194,7 +191,7 @@ module PokeBattle_BattleCommon
# Critical capture check # Critical capture check
if Settings::ENABLE_CRITICAL_CAPTURES if Settings::ENABLE_CRITICAL_CAPTURES
c = 0 c = 0
numOwned = $Trainer.owned_count numOwned = $Trainer.pokedex.owned_count
if numOwned>600; c = x*5/12 if numOwned>600; c = x*5/12
elsif numOwned>450; c = x*4/12 elsif numOwned>450; c = x*4/12
elsif numOwned>300; c = x*3/12 elsif numOwned>300; c = x*3/12

View File

@@ -115,7 +115,7 @@ class PokeBattle_Battle
@caughtPokemon = [] @caughtPokemon = []
player = [player] if !player.nil? && !player.is_a?(Array) player = [player] if !player.nil? && !player.is_a?(Array)
opponent = [opponent] if !opponent.nil? && !opponent.is_a?(Array) opponent = [opponent] if !opponent.nil? && !opponent.is_a?(Array)
@player = player # Array of PlayerTrainer/NPCTrainer objects, or nil @player = player # Array of Player/NPCTrainer objects, or nil
@opponent = opponent # Array of NPCTrainer objects, or nil @opponent = opponent # Array of NPCTrainer objects, or nil
@items = nil @items = nil
@endSpeeches = [] @endSpeeches = []
@@ -622,8 +622,7 @@ class PokeBattle_Battle
def pbSetSeen(battler) def pbSetSeen(battler)
return if !battler || !@internalBattle return if !battler || !@internalBattle
pbPlayer.set_seen(battler.displaySpecies) pbPlayer.pokedex.register(battler.displaySpecies,battler.displayGender,battler.displayForm)
pbSeenForm(battler.displaySpecies,battler.displayGender,battler.displayForm)
end end
def nextPickupUse def nextPickupUse

View File

@@ -421,8 +421,7 @@ class PokeBattle_SafariZone
def pbStartBattle def pbStartBattle
begin begin
pkmn = @party2[0] pkmn = @party2[0]
self.pbPlayer.set_seen(pkmn.species) self.pbPlayer.pokedex.register(pkmn)
pbSeenForm(pkmn)
@scene.pbStartBattle(self) @scene.pbStartBattle(self)
pbDisplayPaused(_INTL("Wild {1} appeared!",pkmn.name)) pbDisplayPaused(_INTL("Wild {1} appeared!",pkmn.name))
@scene.pbSafariStart @scene.pbSafariStart

View File

@@ -146,15 +146,15 @@ module BattlePlayerHelper
return nil if !trainer return nil if !trainer
if trainer.length>1 if trainer.length>1
ret = [] ret = []
ret[0]=PlayerTrainer.new(trainer[0][1],trainer[0][0]) ret[0]=Player.new(trainer[0][1],trainer[0][0])
ret[0].id = trainer[0][2] ret[0].id = trainer[0][2]
ret[0].badges = trainer[0][3] ret[0].badges = trainer[0][3]
ret[1] = PlayerTrainer.new(trainer[1][1],trainer[1][0]) ret[1] = Player.new(trainer[1][1],trainer[1][0])
ret[1].id = trainer[1][2] ret[1].id = trainer[1][2]
ret[1].badges = trainer[1][3] ret[1].badges = trainer[1][3]
return ret return ret
else else
ret = PlayerTrainer.new(trainer[0][1],trainer[0][0]) ret = Player.new(trainer[0][1],trainer[0][0])
ret.id = trainer[0][2] ret.id = trainer[0][2]
ret.badges = trainer[0][3] ret.badges = trainer[0][3]
return ret return ret

View File

@@ -25,8 +25,7 @@ class PokemonGlobalMetadata
attr_accessor :snagMachine attr_accessor :snagMachine
attr_accessor :creditsPlayed attr_accessor :creditsPlayed
# Pokédex # Pokédex
attr_accessor :pokedexUnlocked # Array storing which Dexes are unlocked attr_accessor :pokedexUnlocked # Deprecated, replaced with Player::Pokedex#unlocked_dexes
attr_accessor :pokedexViable # All Dexes of non-zero length and unlocked
attr_accessor :pokedexDex # Dex currently looking at (-1 is National Dex) attr_accessor :pokedexDex # Dex currently looking at (-1 is National Dex)
attr_accessor :pokedexIndex # Last species viewed per Dex attr_accessor :pokedexIndex # Last species viewed per Dex
attr_accessor :pokedexMode # Search mode attr_accessor :pokedexMode # Search mode
@@ -86,14 +85,11 @@ class PokemonGlobalMetadata
@creditsPlayed = false @creditsPlayed = false
# Pokédex # Pokédex
numRegions = pbLoadRegionalDexes.length numRegions = pbLoadRegionalDexes.length
@pokedexUnlocked = []
@pokedexViable = []
@pokedexDex = (numRegions==0) ? -1 : 0 @pokedexDex = (numRegions==0) ? -1 : 0
@pokedexIndex = [] @pokedexIndex = []
@pokedexMode = 0 @pokedexMode = 0
for i in 0...numRegions+1 # National Dex isn't a region, but is included for i in 0...numRegions+1 # National Dex isn't a region, but is included
@pokedexIndex[i] = 0 @pokedexIndex[i] = 0
@pokedexUnlocked[i] = (i==0)
end end
# Day Care # Day Care
@daycare = [[nil,0],[nil,0]] @daycare = [[nil,0],[nil,0]]

View File

@@ -186,126 +186,3 @@ class NPCTrainer < Trainer
@lose_text = nil @lose_text = nil
end end
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

View 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

View File

@@ -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

View 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

View 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

View File

@@ -139,7 +139,7 @@ class Pokemon
yield if block_given? yield if block_given?
MultipleForms.call("onSetForm", self, value, oldForm) MultipleForms.call("onSetForm", self, value, oldForm)
calc_stats calc_stats
pbSeenForm(self) $Trainer.pokedex.register(self)
end end
def setForm(value) def setForm(value)
@@ -781,7 +781,7 @@ class Pokemon
@owner = new_owner @owner = new_owner
end end
# @param trainer [PlayerTrainer, NPCTrainer] the trainer to compare to the original trainer # @param trainer [Player, NPCTrainer] the trainer to compare to the original trainer
# @return [Boolean] whether the given trainer is not this Pokémon's original trainer # @return [Boolean] whether the given trainer is not this Pokémon's original trainer
def foreign?(trainer) def foreign?(trainer)
return @owner.id != trainer.id || @owner.name != trainer.name return @owner.id != trainer.id || @owner.name != trainer.name
@@ -1045,7 +1045,7 @@ class Pokemon
# Creates a new Pokémon object. # Creates a new Pokémon object.
# @param species [Symbol, String, Integer] Pokémon species # @param species [Symbol, String, Integer] Pokémon species
# @param level [Integer] Pokémon level # @param level [Integer] Pokémon level
# @param owner [Owner, PlayerTrainer, NPCTrainer] Pokémon owner (the player by default) # @param owner [Owner, Player, NPCTrainer] Pokémon owner (the player by default)
# @param withMoves [TrueClass, FalseClass] whether the Pokémon should have moves # @param withMoves [TrueClass, FalseClass] whether the Pokémon should have moves
# @param rechech_form [TrueClass, FalseClass] whether to auto-check the form # @param rechech_form [TrueClass, FalseClass] whether to auto-check the form
def initialize(species, level, owner = $Trainer, withMoves = true, recheck_form = true) def initialize(species, level, owner = $Trainer, withMoves = true, recheck_form = true)
@@ -1089,7 +1089,7 @@ class Pokemon
end end
if owner.is_a?(Owner) if owner.is_a?(Owner)
@owner = owner @owner = owner
elsif owner.is_a?(PlayerTrainer) || owner.is_a?(NPCTrainer) elsif owner.is_a?(Player) || owner.is_a?(NPCTrainer)
@owner = Owner.new_from_trainer(owner) @owner = Owner.new_from_trainer(owner)
else else
@owner = Owner.new(0, '', 2, 2) @owner = Owner.new(0, '', 2, 2)

View File

@@ -25,10 +25,10 @@ class Pokemon
end end
# Returns a new Owner object populated with values taken from +trainer+. # Returns a new Owner object populated with values taken from +trainer+.
# @param trainer [PlayerTrainer, NPCTrainer] trainer object to read data from # @param trainer [Player, NPCTrainer] trainer object to read data from
# @return [Owner] new Owner object # @return [Owner] new Owner object
def self.new_from_trainer(trainer) def self.new_from_trainer(trainer)
validate trainer => [PlayerTrainer, NPCTrainer] validate trainer => [Player, NPCTrainer]
return new(trainer.id, trainer.name, trainer.gender, trainer.language) return new(trainer.id, trainer.name, trainer.gender, trainer.language)
end end

View File

@@ -196,9 +196,8 @@ def pbHatch(pokemon)
pokemon.timeEggHatched = pbGetTimeNow pokemon.timeEggHatched = pbGetTimeNow
pokemon.obtain_method = 1 # hatched from egg pokemon.obtain_method = 1 # hatched from egg
pokemon.hatched_map = $game_map.map_id pokemon.hatched_map = $game_map.map_id
$Trainer.set_seen(pokemon.species) $Trainer.pokedex.register(pokemon)
$Trainer.set_owned(pokemon.species) $Trainer.pokedex.set_owned(pokemon.species)
pbSeenForm(pokemon)
pokemon.record_first_moves pokemon.record_first_moves
if !pbHatchAnimation(pokemon) if !pbHatchAnimation(pokemon)
pbMessage(_INTL("Huh?\1")) pbMessage(_INTL("Huh?\1"))

View File

@@ -588,9 +588,8 @@ class PokemonEvolutionScene
@pokemon.form = 0 if @pokemon.isSpecies?(:MOTHIM) @pokemon.form = 0 if @pokemon.isSpecies?(:MOTHIM)
@pokemon.calc_stats @pokemon.calc_stats
# See and own evolved species # See and own evolved species
$Trainer.set_seen(@newspecies) $Trainer.pokedex.register(@pokemon)
$Trainer.set_owned(@newspecies) $Trainer.pokedex.set_owned(@newspecies)
pbSeenForm(@pokemon)
# Learn moves upon evolution for evolved species # Learn moves upon evolution for evolved species
movelist = @pokemon.getMoveList movelist = @pokemon.getMoveList
for i in movelist for i in movelist
@@ -616,8 +615,7 @@ class PokemonEvolutionScene
# Add duplicate Pokémon to party # Add duplicate Pokémon to party
$Trainer.party.push(new_pkmn) $Trainer.party.push(new_pkmn)
# See and own duplicate Pokémon # See and own duplicate Pokémon
$Trainer.set_seen(new_species) $Trainer.pokedex.register(new_pkmn)
$Trainer.set_owned(new_species) $Trainer.pokedex.set_owned(new_species)
pbSeenForm(new_pkmn)
end end
end end

View File

@@ -228,9 +228,8 @@ def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0)
yourPokemon.obtain_method = 2 # traded yourPokemon.obtain_method = 2 # traded
yourPokemon.reset_moves if resetmoves yourPokemon.reset_moves if resetmoves
yourPokemon.record_first_moves yourPokemon.record_first_moves
$Trainer.set_seen(yourPokemon.species) $Trainer.pokedex.register(yourPokemon)
$Trainer.set_owned(yourPokemon.species) $Trainer.pokedex.set_owned(yourPokemon.species)
pbSeenForm(yourPokemon)
pbFadeOutInWithMusic { pbFadeOutInWithMusic {
evo = PokemonTrade_Scene.new evo = PokemonTrade_Scene.new
evo.pbStartScreen(myPokemon,yourPokemon,$Trainer.name,opponent.name) evo.pbStartScreen(myPokemon,yourPokemon,$Trainer.name,opponent.name)

View File

@@ -281,7 +281,7 @@ class HallOfFame_Scene
lefttext+=_INTL("IDNo.<r>{1}<br>",pubid) lefttext+=_INTL("IDNo.<r>{1}<br>",pubid)
lefttext+=_ISPRINTF("Time<r>{1:02d}:{2:02d}<br>",hour,min) lefttext+=_ISPRINTF("Time<r>{1:02d}:{2:02d}<br>",hour,min)
lefttext+=_INTL("Pokédex<r>{1}/{2}<br>", lefttext+=_INTL("Pokédex<r>{1}/{2}<br>",
$Trainer.owned_count,$Trainer.seen_count) $Trainer.pokedex.owned_count,$Trainer.pokedex.seen_count)
@sprites["messagebox"]=Window_AdvancedTextPokemon.new(lefttext) @sprites["messagebox"]=Window_AdvancedTextPokemon.new(lefttext)
@sprites["messagebox"].viewport=@viewport @sprites["messagebox"].viewport=@viewport
@sprites["messagebox"].width=192 if @sprites["messagebox"].width<192 @sprites["messagebox"].width=192 if @sprites["messagebox"].width<192

View File

@@ -100,7 +100,6 @@ class PokemonPauseMenu
end end
return return
end end
pbSetViableDexes
@scene.pbStartScene @scene.pbStartScene
endscene = true endscene = true
commands = [] commands = []
@@ -114,7 +113,7 @@ class PokemonPauseMenu
cmdDebug = -1 cmdDebug = -1
cmdQuit = -1 cmdQuit = -1
cmdEndGame = -1 cmdEndGame = -1
commands[cmdPokedex = commands.length] = _INTL("Pokédex") if $Trainer.pokedex && $PokemonGlobal.pokedexViable.length>0 commands[cmdPokedex = commands.length] = _INTL("Pokédex") if $Trainer.has_pokedex && $Trainer.pokedex.accessible_dexes_count > 0
commands[cmdPokemon = commands.length] = _INTL("Pokémon") if $Trainer.party.length>0 commands[cmdPokemon = commands.length] = _INTL("Pokémon") if $Trainer.party.length>0
commands[cmdBag = commands.length] = _INTL("Bag") if !pbInBugContest? commands[cmdBag = commands.length] = _INTL("Bag") if !pbInBugContest?
commands[cmdPokegear = commands.length] = _INTL("Pokégear") if $Trainer.pokegear commands[cmdPokegear = commands.length] = _INTL("Pokégear") if $Trainer.pokegear
@@ -155,9 +154,8 @@ class PokemonPauseMenu
@scene.pbRefresh @scene.pbRefresh
} }
else else
if $PokemonGlobal.pokedexViable.length==1 if $Trainer.pokedex.accessible_dexes_count == 1
$PokemonGlobal.pokedexDex = $PokemonGlobal.pokedexViable[0] $PokemonGlobal.pokedexDex = $Trainer.pokedex.accessible_dexes[0]
$PokemonGlobal.pokedexDex = -1 if $PokemonGlobal.pokedexDex==$PokemonGlobal.pokedexUnlocked.length-1
pbFadeOutIn { pbFadeOutIn {
scene = PokemonPokedex_Scene.new scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene) screen = PokemonPokedexScreen.new(scene)

View File

@@ -1,7 +1,7 @@
#=============================================================================== #===============================================================================
# Pokédex Regional Dexes list menu screen # Pokédex Regional Dexes list menu screen
# * For choosing which region list to view. Only appears when there is more # * For choosing which region list to view. Only appears when there is more
# than one viable region list to choose from, and if # than one accessible region list to choose from, and if
# Settings::USE_CURRENT_REGION_DEX is false. # Settings::USE_CURRENT_REGION_DEX is false.
#=============================================================================== #===============================================================================
class Window_DexesList < Window_CommandPokemon class Window_DexesList < Window_CommandPokemon
@@ -94,29 +94,24 @@ class PokemonPokedexMenuScreen
commands = [] commands = []
commands2 = [] commands2 = []
dexnames = Settings.pokedex_names dexnames = Settings.pokedex_names
for i in 0...$PokemonGlobal.pokedexViable.length $Trainer.pokedex.accessible_dexes.each do |dex|
index = $PokemonGlobal.pokedexViable[i] if dexnames[dex].nil?
if dexnames[index]==nil commands.push(_INTL("Pokédex"))
commands[i] = _INTL("Pokédex") elsif dexnames[dex].is_a?(Array)
commands.push(dexnames[dex][0])
else else
if dexnames[index].is_a?(Array) commands.push(dexnames[dex])
commands[i] = dexnames[index][0]
else
commands[i] = dexnames[index]
end
end end
index = -1 if index >= $PokemonGlobal.pokedexUnlocked.length - 1 commands2.push([$Trainer.pokedex.seen_count(dex),
commands2[i] = [$Trainer.seen_count(index), $Trainer.pokedex.owned_count(dex),
$Trainer.owned_count(index), pbGetRegionalDexLength(dex)])
pbGetRegionalDexLength(index)]
end end
commands.push(_INTL("Exit")) commands.push(_INTL("Exit"))
@scene.pbStartScene(commands,commands2) @scene.pbStartScene(commands,commands2)
loop do loop do
cmd = @scene.pbScene cmd = @scene.pbScene
break if cmd<0 || cmd>=commands2.length # Cancel/Exit break if cmd<0 || cmd>=commands2.length # Cancel/Exit
$PokemonGlobal.pokedexDex = $PokemonGlobal.pokedexViable[cmd] $PokemonGlobal.pokedexDex = $Trainer.pokedex.accessible_dexes[cmd]
$PokemonGlobal.pokedexDex = -1 if $PokemonGlobal.pokedexDex==$PokemonGlobal.pokedexUnlocked.length-1
pbFadeOutIn { pbFadeOutIn {
scene = PokemonPokedex_Scene.new scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene) screen = PokemonPokedexScreen.new(scene)

View File

@@ -284,10 +284,10 @@ class PokemonPokedex_Scene
def pbGetPokedexRegion def pbGetPokedexRegion
if Settings::USE_CURRENT_REGION_DEX if Settings::USE_CURRENT_REGION_DEX
region = pbGetCurrentRegion region = pbGetCurrentRegion
region = -1 if region>=$PokemonGlobal.pokedexUnlocked.length-1 region = -1 if region >= $Trainer.pokedex.dexes_count - 1
return region return region
else else
return $PokemonGlobal.pokedexDex # National Dex -1, regional dexes 0 etc. return $PokemonGlobal.pokedexDex # National Dex -1, regional Dexes 0, 1, etc.
end end
end end
@@ -297,8 +297,8 @@ class PokemonPokedex_Scene
def pbGetSavePositionIndex def pbGetSavePositionIndex
index = pbGetPokedexRegion index = pbGetPokedexRegion
if index==-1 # National Dex if index==-1 # National Dex
index = $PokemonGlobal.pokedexUnlocked.length-1 # National Dex index comes index = $Trainer.pokedex.dexes_count - 1 # National Dex index comes
end # after regional Dex indices end # after regional Dex indices
return index return index
end end
@@ -385,7 +385,7 @@ class PokemonPokedex_Scene
iconspecies = nil if !$Trainer.seen?(iconspecies) iconspecies = nil if !$Trainer.seen?(iconspecies)
# Write various bits of text # Write various bits of text
dexname = _INTL("Pokédex") dexname = _INTL("Pokédex")
if $PokemonGlobal.pokedexUnlocked.length>1 if $Trainer.pokedex.dexes_count > 1
thisdex = Settings.pokedex_names[pbGetSavePositionIndex] thisdex = Settings.pokedex_names[pbGetSavePositionIndex]
if thisdex!=nil if thisdex!=nil
dexname = (thisdex.is_a?(Array)) ? thisdex[0] : thisdex dexname = (thisdex.is_a?(Array)) ? thisdex[0] : thisdex
@@ -400,9 +400,9 @@ class PokemonPokedex_Scene
textpos.push([@dexlist.length.to_s,112,334,2,base,shadow]) textpos.push([@dexlist.length.to_s,112,334,2,base,shadow])
else else
textpos.push([_INTL("Seen:"),42,302,0,base,shadow]) textpos.push([_INTL("Seen:"),42,302,0,base,shadow])
textpos.push([$Trainer.seen_count(pbGetPokedexRegion).to_s,182,302,1,base,shadow]) textpos.push([$Trainer.pokedex.seen_count(pbGetPokedexRegion).to_s,182,302,1,base,shadow])
textpos.push([_INTL("Owned:"),42,334,0,base,shadow]) textpos.push([_INTL("Owned:"),42,334,0,base,shadow])
textpos.push([$Trainer.owned_count(pbGetPokedexRegion).to_s,182,334,1,base,shadow]) textpos.push([$Trainer.pokedex.owned_count(pbGetPokedexRegion).to_s,182,334,1,base,shadow])
end end
# Draw all text # Draw all text
pbDrawTextPositions(overlay,textpos) pbDrawTextPositions(overlay,textpos)
@@ -690,10 +690,7 @@ class PokemonPokedex_Scene
end end
def setIconBitmap(species) def setIconBitmap(species)
$Trainer.last_seen_forms = {} if !$Trainer.last_seen_forms gender, form = $Trainer.pokedex.last_form_seen(species)
$Trainer.last_seen_forms[species] = [] if !$Trainer.last_seen_forms[species]
gender = $Trainer.last_seen_forms[species][0] || 0
form = $Trainer.last_seen_forms[species][1] || 0
@sprites["icon"].setSpeciesBitmap(species, gender, form) @sprites["icon"].setSpeciesBitmap(species, gender, form)
end end

View File

@@ -72,12 +72,12 @@ class PokemonPokedexInfo_Scene
@viewport.z = 99999 @viewport.z = 99999
dexnum = species dexnum = species
dexnumshift = false dexnumshift = false
if $PokemonGlobal.pokedexUnlocked[$PokemonGlobal.pokedexUnlocked.length - 1] if $Trainer.pokedex.unlocked?(-1) # National Dex is unlocked
dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(-1) # National Dex dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(-1)
else else
dexnum = 0 dexnum = 0
for i in 0...$PokemonGlobal.pokedexUnlocked.length - 1 # Regional Dexes for i in 0...$Trainer.pokedex.dexes_count - 1 # Regional Dexes
next if !$PokemonGlobal.pokedexUnlocked[i] next if !$Trainer.pokedex.unlocked?(i)
num = pbGetRegionalNumber(i,species) num = pbGetRegionalNumber(i,species)
next if num <= 0 next if num <= 0
dexnum = num dexnum = num
@@ -121,10 +121,7 @@ class PokemonPokedexInfo_Scene
def pbUpdateDummyPokemon def pbUpdateDummyPokemon
@species = @dexlist[@index][0] @species = @dexlist[@index][0]
$Trainer.last_seen_forms = {} if !$Trainer.last_seen_forms @gender, @form = $Trainer.pokedex.last_form_seen(@species)
$Trainer.last_seen_forms[@species] = [] if !$Trainer.last_seen_forms[@species]
@gender = $Trainer.last_seen_forms[@species][0] || 0
@form = $Trainer.last_seen_forms[@species][1] || 0
species_data = GameData::Species.get_species_form(@species, @form) species_data = GameData::Species.get_species_form(@species, @form)
@sprites["infosprite"].setSpeciesBitmap(@species,@gender,@form) @sprites["infosprite"].setSpeciesBitmap(@species,@gender,@form)
if @sprites["formfront"] if @sprites["formfront"]
@@ -149,16 +146,15 @@ class PokemonPokedexInfo_Scene
next if sp.form != 0 && (!sp.real_form_name || sp.real_form_name.empty?) next if sp.form != 0 && (!sp.real_form_name || sp.real_form_name.empty?)
next if sp.pokedex_form != sp.form next if sp.pokedex_form != sp.form
multiple_forms = true if sp.form > 0 multiple_forms = true if sp.form > 0
$Trainer.seen_forms[@species] = [[], []] if !$Trainer.seen_forms[@species]
case sp.gender_ratio case sp.gender_ratio
when :AlwaysMale, :AlwaysFemale, :Genderless when :AlwaysMale, :AlwaysFemale, :Genderless
real_gender = (sp.gender_ratio == :AlwaysFemale) ? 1 : 0 real_gender = (sp.gender_ratio == :AlwaysFemale) ? 1 : 0
next if !$Trainer.seen_forms[@species][real_gender][sp.form] && !Settings::DEX_SHOWS_ALL_FORMS next if !$Trainer.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
real_gender = 2 if sp.gender_ratio == :Genderless real_gender = 2 if sp.gender_ratio == :Genderless
ret.push([sp.form_name, real_gender, sp.form]) ret.push([sp.form_name, real_gender, sp.form])
else # Both male and female else # Both male and female
for real_gender in 0...2 for real_gender in 0...2
next if !$Trainer.seen_forms[@species][real_gender][sp.form] && !Settings::DEX_SHOWS_ALL_FORMS next if !$Trainer.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
ret.push([sp.form_name, real_gender, sp.form]) ret.push([sp.form_name, real_gender, sp.form])
break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form
end end
@@ -415,10 +411,7 @@ class PokemonPokedexInfo_Scene
oldindex = -1 oldindex = -1
loop do loop do
if oldindex!=index if oldindex!=index
$Trainer.last_seen_forms = {} if !$Trainer.last_seen_forms $Trainer.pokedex.set_last_form_seen(@species, @available[index][1], @available[index][2])
$Trainer.last_seen_forms[@species] = [] if !$Trainer.last_seen_forms
$Trainer.last_seen_forms[@species][0] = @available[index][1]
$Trainer.last_seen_forms[@species][1] = @available[index][2]
pbUpdateDummyPokemon pbUpdateDummyPokemon
drawPage(@page) drawPage(@page)
@sprites["uparrow"].visible = (index>0) @sprites["uparrow"].visible = (index>0)
@@ -554,9 +547,9 @@ class PokemonPokedexInfoScreen
region = -1 region = -1
if Settings::USE_CURRENT_REGION_DEX if Settings::USE_CURRENT_REGION_DEX
region = pbGetCurrentRegion region = pbGetCurrentRegion
region = -1 if region>=$PokemonGlobal.pokedexUnlocked.length-1 region = -1 if region >= $Trainer.pokedex.dexes_count - 1
else else
region = $PokemonGlobal.pokedexDex # National Dex -1, regional dexes 0 etc. region = $PokemonGlobal.pokedexDex # National Dex -1, regional Dexes 0, 1, etc.
end end
dexnum = pbGetRegionalNumber(region,species) dexnum = pbGetRegionalNumber(region,species)
dexnumshift = Settings::DEXES_WITH_OFFSETS.include?(region) dexnumshift = Settings::DEXES_WITH_OFFSETS.include?(region)

View File

@@ -396,12 +396,12 @@ class PokemonSummary_Scene
# Write the Regional/National Dex number # Write the Regional/National Dex number
dexnum = GameData::Species.get(@pokemon.species).id_number dexnum = GameData::Species.get(@pokemon.species).id_number
dexnumshift = false dexnumshift = false
if $PokemonGlobal.pokedexUnlocked[$PokemonGlobal.pokedexUnlocked.length-1] if $Trainer.pokedex.unlocked?(-1) # National Dex is unlocked
dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(-1) dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(-1)
else else
dexnum = 0 dexnum = 0
for i in 0...$PokemonGlobal.pokedexUnlocked.length-1 for i in 0...$Trainer.pokedex.dexes_count - 1
next if !$PokemonGlobal.pokedexUnlocked[i] next if !$Trainer.pokedex.unlocked?(i)
num = pbGetRegionalNumber(i,@pokemon.species) num = pbGetRegionalNumber(i,@pokemon.species)
next if num<=0 next if num<=0
dexnum = num dexnum = num
@@ -1180,7 +1180,7 @@ class PokemonSummary_Scene
if !@pokemon.egg? if !@pokemon.egg?
commands[cmdGiveItem = commands.length] = _INTL("Give item") commands[cmdGiveItem = commands.length] = _INTL("Give item")
commands[cmdTakeItem = commands.length] = _INTL("Take item") if @pokemon.hasItem? commands[cmdTakeItem = commands.length] = _INTL("Take item") if @pokemon.hasItem?
commands[cmdPokedex = commands.length] = _INTL("View Pokédex") if $Trainer.pokedex commands[cmdPokedex = commands.length] = _INTL("View Pokédex") if $Trainer.has_pokedex
end end
commands[cmdMark = commands.length] = _INTL("Mark") commands[cmdMark = commands.length] = _INTL("Mark")
commands[commands.length] = _INTL("Cancel") commands[commands.length] = _INTL("Cancel")
@@ -1198,7 +1198,7 @@ class PokemonSummary_Scene
elsif cmdTakeItem>=0 && command==cmdTakeItem elsif cmdTakeItem>=0 && command==cmdTakeItem
dorefresh = pbTakeItemFromPokemon(@pokemon,self) dorefresh = pbTakeItemFromPokemon(@pokemon,self)
elsif cmdPokedex>=0 && command==cmdPokedex elsif cmdPokedex>=0 && command==cmdPokedex
pbUpdateLastSeenForm(@pokemon) $Trainer.pokedex.register_last_seen(@pokemon)
pbFadeOutIn { pbFadeOutIn {
scene = PokemonPokedexInfo_Scene.new scene = PokemonPokedexInfo_Scene.new
screen = PokemonPokedexInfoScreen.new(scene) screen = PokemonPokedexInfoScreen.new(scene)

View File

@@ -56,7 +56,7 @@ class PokemonTrainerCard_Scene
[_INTL("Money"),34,106,0,baseColor,shadowColor], [_INTL("Money"),34,106,0,baseColor,shadowColor],
[_INTL("${1}",$Trainer.money.to_s_formatted),302,106,1,baseColor,shadowColor], [_INTL("${1}",$Trainer.money.to_s_formatted),302,106,1,baseColor,shadowColor],
[_INTL("Pokédex"),34,154,0,baseColor,shadowColor], [_INTL("Pokédex"),34,154,0,baseColor,shadowColor],
[sprintf("%d/%d",$Trainer.owned_count,$Trainer.seen_count),302,154,1,baseColor,shadowColor], [sprintf("%d/%d",$Trainer.pokedex.owned_count,$Trainer.pokedex.seen_count),302,154,1,baseColor,shadowColor],
[_INTL("Time"),34,202,0,baseColor,shadowColor], [_INTL("Time"),34,202,0,baseColor,shadowColor],
[time,302,202,1,baseColor,shadowColor], [time,302,202,1,baseColor,shadowColor],
[_INTL("Started"),34,250,0,baseColor,shadowColor], [_INTL("Started"),34,250,0,baseColor,shadowColor],

View File

@@ -66,7 +66,7 @@ class PokemonLoadPanel < SpriteWrapper
textpos.push([_INTL("Badges:"),16*2,53*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) textpos.push([_INTL("Badges:"),16*2,53*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
textpos.push([@trainer.badge_count.to_s,103*2,53*2,1,TEXTCOLOR,TEXTSHADOWCOLOR]) textpos.push([@trainer.badge_count.to_s,103*2,53*2,1,TEXTCOLOR,TEXTSHADOWCOLOR])
textpos.push([_INTL("Pokédex:"),16*2,69*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) textpos.push([_INTL("Pokédex:"),16*2,69*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
textpos.push([@trainer.seen_count.to_s,103*2,69*2,1,TEXTCOLOR,TEXTSHADOWCOLOR]) textpos.push([@trainer.pokedex.seen_count.to_s,103*2,69*2,1,TEXTCOLOR,TEXTSHADOWCOLOR])
textpos.push([_INTL("Time:"),16*2,85*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) textpos.push([_INTL("Time:"),16*2,85*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
hour = @totalsec / 60 / 60 hour = @totalsec / 60 / 60
min = @totalsec / 60 % 60 min = @totalsec / 60 % 60

View File

@@ -48,8 +48,8 @@ class PokemonSave_Scene
loctext+=_INTL("Time<r><c3={1}>{2}m</c3><br>",textColor,min) loctext+=_INTL("Time<r><c3={1}>{2}m</c3><br>",textColor,min)
end end
loctext+=_INTL("Badges<r><c3={1}>{2}</c3><br>",textColor,$Trainer.badge_count) loctext+=_INTL("Badges<r><c3={1}>{2}</c3><br>",textColor,$Trainer.badge_count)
if $Trainer.pokedex if $Trainer.has_pokedex
loctext+=_INTL("Pokédex<r><c3={1}>{2}/{3}</c3>",textColor,$Trainer.owned_count,$Trainer.seen_count) loctext+=_INTL("Pokédex<r><c3={1}>{2}/{3}</c3>",textColor,$Trainer.pokedex.owned_count,$Trainer.pokedex.seen_count)
end end
@sprites["locwindow"]=Window_AdvancedTextPokemon.new(loctext) @sprites["locwindow"]=Window_AdvancedTextPokemon.new(loctext)
@sprites["locwindow"].viewport=@viewport @sprites["locwindow"].viewport=@viewport

View File

@@ -73,7 +73,7 @@ def pbPlayTrainerIntroME(trainer_type)
pbMEPlay(bgm) pbMEPlay(bgm)
end end
def pbGetTrainerBattleBGM(trainer) # can be a PlayerTrainer, NPCTrainer or an array of them def pbGetTrainerBattleBGM(trainer) # can be a Player, NPCTrainer or an array of them
if $PokemonGlobal.nextBattleBGM if $PokemonGlobal.nextBattleBGM
return $PokemonGlobal.nextBattleBGM.clone return $PokemonGlobal.nextBattleBGM.clone
end end
@@ -123,7 +123,7 @@ def pbGetTrainerBattleBGMFromType(trainertype)
return ret return ret
end end
def pbGetTrainerVictoryME(trainer) # can be a PlayerTrainer, NPCTrainer or an array of them def pbGetTrainerVictoryME(trainer) # can be a Player, NPCTrainer or an array of them
if $PokemonGlobal.nextBattleME if $PokemonGlobal.nextBattleME
return $PokemonGlobal.nextBattleME.clone return $PokemonGlobal.nextBattleME.clone
end end

View File

@@ -53,8 +53,8 @@ def pbNicknameAndStore(pkmn)
pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!")) pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!"))
return return
end end
$Trainer.set_seen(pkmn.species) $Trainer.pokedex.set_seen(pkmn.species)
$Trainer.set_owned(pkmn.species) $Trainer.pokedex.set_owned(pkmn.species)
pbNickname(pkmn) pbNickname(pkmn)
pbStorePokemon(pkmn) pbStorePokemon(pkmn)
end end
@@ -73,16 +73,15 @@ def pbAddPokemon(pkmn, level = 1, see_form = true)
species_name = pkmn.speciesName species_name = pkmn.speciesName
pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $Trainer.name, species_name)) pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $Trainer.name, species_name))
pbNicknameAndStore(pkmn) pbNicknameAndStore(pkmn)
pbSeenForm(pkmn) if see_form $Trainer.pokedex.register(pkmn) if see_form
return true return true
end end
def pbAddPokemonSilent(pkmn, level = 1, see_form = true) def pbAddPokemonSilent(pkmn, level = 1, see_form = true)
return false if !pkmn || pbBoxesFull? return false if !pkmn || pbBoxesFull?
pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon)
$Trainer.set_seen(pkmn.species) $Trainer.pokedex.register(pkmn) if see_form
$Trainer.set_owned(pkmn.species) $Trainer.pokedex.set_owned(pkmn.species)
pbSeenForm(pkmn) if see_form
pkmn.record_first_moves pkmn.record_first_moves
if $Trainer.party_full? if $Trainer.party_full?
$PokemonStorage.pbStoreCaught(pkmn) $PokemonStorage.pbStoreCaught(pkmn)
@@ -101,16 +100,15 @@ def pbAddToParty(pkmn, level = 1, see_form = true)
species_name = pkmn.speciesName species_name = pkmn.speciesName
pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $Trainer.name, species_name)) pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $Trainer.name, species_name))
pbNicknameAndStore(pkmn) pbNicknameAndStore(pkmn)
pbSeenForm(pkmn) if see_form $Trainer.pokedex.register(pkmn) if see_form
return true return true
end end
def pbAddToPartySilent(pkmn, level = nil, see_form = true) def pbAddToPartySilent(pkmn, level = nil, see_form = true)
return false if !pkmn || $Trainer.party_full? return false if !pkmn || $Trainer.party_full?
pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon)
$Trainer.set_seen(pkmn.species) $Trainer.pokedex.register(pkmn) if see_form
$Trainer.set_owned(pkmn.species) $Trainer.pokedex.set_owned(pkmn.species)
pbSeenForm(pkmn) if see_form
pkmn.record_first_moves pkmn.record_first_moves
$Trainer.party[$Trainer.party.length] = pkmn $Trainer.party[$Trainer.party.length] = pkmn
return true return true
@@ -131,9 +129,8 @@ def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner
pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon.\1", $Trainer.name)) pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon.\1", $Trainer.name))
end end
pbStorePokemon(pkmn) pbStorePokemon(pkmn)
$Trainer.set_seen(pkmn.species) $Trainer.pokedex.register(pkmn) if see_form
$Trainer.set_owned(pkmn.species) $Trainer.pokedex.set_owned(pkmn.species)
pbSeenForm(pkmn) if see_form
return true return true
end end
@@ -152,41 +149,6 @@ end
alias pbAddEgg pbGenerateEgg alias pbAddEgg pbGenerateEgg
alias pbGenEgg pbGenerateEgg alias pbGenEgg pbGenerateEgg
#===============================================================================
# Recording Pokémon forms as seen
#===============================================================================
def pbSeenForm(species, gender = 0, form = 0)
$Trainer.seen_forms = {} if !$Trainer.seen_forms
$Trainer.last_seen_forms = {} if !$Trainer.last_seen_forms
if species.is_a?(Pokemon)
species_data = species.species_data
gender = species.gender
else
species_data = GameData::Species.get_species_form(species, form)
end
return if !species_data
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?
$Trainer.seen_forms[species] = [[], []] if !$Trainer.seen_forms[species]
$Trainer.seen_forms[species][gender][form] = true
$Trainer.last_seen_forms[species] = [] if !$Trainer.last_seen_forms[species]
$Trainer.last_seen_forms[species] = [gender, form] if $Trainer.last_seen_forms[species] == []
end
def pbUpdateLastSeenForm(pkmn)
$Trainer.last_seen_forms = {} if !$Trainer.last_seen_forms
species_data = pkmn.species_data
form = species_data.pokedex_form
form = 0 if species_data.form_name.nil? || species_data.form_name.empty?
$Trainer.last_seen_forms[pkmn.species] = [pkmn.gender, form]
end
#=============================================================================== #===============================================================================
# Analyse Pokémon in the party # Analyse Pokémon in the party
#=============================================================================== #===============================================================================

View File

@@ -230,7 +230,7 @@ def pbTrainerName(name = nil, outfit = 0)
pbChangePlayer(0) if $PokemonGlobal.playerID < 0 pbChangePlayer(0) if $PokemonGlobal.playerID < 0
player_metadata = GameData::Metadata.get_player($PokemonGlobal.playerID) player_metadata = GameData::Metadata.get_player($PokemonGlobal.playerID)
trainer_type = (player_metadata) ? player_metadata[0] : nil trainer_type = (player_metadata) ? player_metadata[0] : nil
$Trainer = PlayerTrainer.new(name, trainer_type) $Trainer = Player.new(name, trainer_type)
$Trainer.outfit = outfit $Trainer.outfit = outfit
$Trainer.character_ID = $PokemonGlobal.playerID $Trainer.character_ID = $PokemonGlobal.playerID
if name.nil? if name.nil?
@@ -394,53 +394,6 @@ def pbGetRegionalDexLength(region_dex)
return (dex_list) ? dex_list.length : 0 return (dex_list) ? dex_list.length : 0
end 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 viable dex region numbers
# (National Dex comes after 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.
# Here, just used to decide whether to show the Pokédex in the Pause menu.
def pbSetViableDexes
$PokemonGlobal.pokedexViable = []
if Settings::USE_CURRENT_REGION_DEX
region = pbGetCurrentRegion
region = -1 if region>=$PokemonGlobal.pokedexUnlocked.length-1
$PokemonGlobal.pokedexViable[0] = region if $Trainer.seen_any?(region)
else
numDexes = $PokemonGlobal.pokedexUnlocked.length
if numDexes==1 # National Dex only
if $PokemonGlobal.pokedexUnlocked[0]
$PokemonGlobal.pokedexViable.push(0) if $Trainer.seen_any?
end
else # Regional dexes + National Dex
for i in 0...numDexes
regionToCheck = (i==numDexes-1) ? -1 : i
if $PokemonGlobal.pokedexUnlocked[i]
$PokemonGlobal.pokedexViable.push(i) if $Trainer.seen_any?(regionToCheck)
end
end
end
end
end
# Unlocks a Dex list. The National Dex is -1 here (or nil argument).
def pbUnlockDex(dex=-1)
index = dex
if index<0 || index>$PokemonGlobal.pokedexUnlocked.length-1
index = $PokemonGlobal.pokedexUnlocked.length-1
end
$PokemonGlobal.pokedexUnlocked[index] = true
end
# Locks a Dex list. The National Dex is -1 here (or nil argument).
def pbLockDex(dex=-1)
index = dex
if index<0 || index>$PokemonGlobal.pokedexUnlocked.length-1
index = $PokemonGlobal.pokedexUnlocked.length-1
end
$PokemonGlobal.pokedexUnlocked[index] = false
end
#=============================================================================== #===============================================================================

View File

@@ -547,9 +547,8 @@ DebugMenuCommands.register("demoparty", {
party.each do |species| party.each do |species|
pkmn = Pokemon.new(species, 20) pkmn = Pokemon.new(species, 20)
$Trainer.party.push(pkmn) $Trainer.party.push(pkmn)
$Trainer.set_seen(species) $Trainer.pokedex.register(pkmn)
$Trainer.set_owned(species) $Trainer.pokedex.set_owned(species)
pbSeenForm(pkmn)
case species case species
when :PIDGEOTTO when :PIDGEOTTO
pkmn.learn_move(:FLY) pkmn.learn_move(:FLY)
@@ -601,8 +600,6 @@ DebugMenuCommands.register("fillboxes", {
"name" => _INTL("Fill Storage Boxes"), "name" => _INTL("Fill Storage Boxes"),
"description" => _INTL("Add one Pokémon of each species (at Level 50) to storage."), "description" => _INTL("Add one Pokémon of each species (at Level 50) to storage."),
"effect" => proc { "effect" => proc {
$Trainer.seen_forms = {} if !$Trainer.seen_forms
$Trainer.last_seen_forms = {} if !$Trainer.last_seen_forms
added = 0 added = 0
box_qty = $PokemonStorage.maxPokemon(0) box_qty = $PokemonStorage.maxPokemon(0)
completed = true completed = true
@@ -610,22 +607,18 @@ DebugMenuCommands.register("fillboxes", {
sp = species_data.species sp = species_data.species
f = species_data.form f = species_data.form
# Record each form of each species as seen and owned # Record each form of each species as seen and owned
$Trainer.seen_forms[sp] = [[], []] if !$Trainer.seen_forms[sp]
if f == 0 if f == 0
$Trainer.set_seen(sp)
$Trainer.set_owned(sp)
if [:AlwaysMale, :AlwaysFemale, :Genderless].include?(species_data.gender_ratio) if [:AlwaysMale, :AlwaysFemale, :Genderless].include?(species_data.gender_ratio)
g = (species_data.gender_ratio == :AlwaysFemale) ? 1 : 0 g = (species_data.gender_ratio == :AlwaysFemale) ? 1 : 0
$Trainer.seen_forms[sp][g][f] = true $Trainer.pokedex.register(sp, g, f)
$Trainer.last_seen_forms[sp] = [g, f] if f == 0
else # Both male and female else # Both male and female
$Trainer.seen_forms[sp][0][f] = true $Trainer.pokedex.register(sp, 0, f)
$Trainer.seen_forms[sp][1][f] = true $Trainer.pokedex.register(sp, 1, f)
$Trainer.last_seen_forms[sp] = [0, f] if f == 0
end end
$Trainer.pokedex.set_owned(sp)
elsif species_data.real_form_name && !species_data.real_form_name.empty? elsif species_data.real_form_name && !species_data.real_form_name.empty?
g = (species_data.gender_ratio == :AlwaysFemale) ? 1 : 0 g = (species_data.gender_ratio == :AlwaysFemale) ? 1 : 0
$Trainer.seen_forms[sp][g][f] = true $Trainer.pokedex.register(sp, g, f)
end end
# Add Pokémon (if form 0) # Add Pokémon (if form 0)
next if f != 0 next if f != 0
@@ -762,25 +755,23 @@ DebugMenuCommands.register("dexlists", {
dexescmd = 0 dexescmd = 0
loop do loop do
dexescmds = [] dexescmds = []
dexescmds.push(_INTL("Have Pokédex: {1}", $Trainer.pokedex ? "[YES]" : "[NO]")) dexescmds.push(_INTL("Have Pokédex: {1}", $Trainer.has_pokedex ? "[YES]" : "[NO]"))
d = Settings.pokedex_names dex_names = Settings.pokedex_names
for i in 0...d.length for i in 0...dex_names.length
name = d[i] name = (dex_names[i].is_a?(Array)) ? dex_names[i][0] : dex_names[i]
name = name[0] if name.is_a?(Array) unlocked = $Trainer.pokedex.unlocked?(i)
dexindex = i
unlocked = $PokemonGlobal.pokedexUnlocked[dexindex]
dexescmds.push(_INTL("{1} {2}", unlocked ? "[Y]" : "[ ]", name)) dexescmds.push(_INTL("{1} {2}", unlocked ? "[Y]" : "[ ]", name))
end end
dexescmd = pbShowCommands(nil, dexescmds, -1, dexescmd) dexescmd = pbShowCommands(nil, dexescmds, -1, dexescmd)
break if dexescmd < 0 break if dexescmd < 0
dexindex = dexescmd - 1 dexindex = dexescmd - 1
if dexindex < 0 # Toggle Pokédex ownership if dexindex < 0 # Toggle Pokédex ownership
$Trainer.pokedex = !$Trainer.pokedex $Trainer.has_pokedex = !$Trainer.has_pokedex
else # Toggle Regional Dex accessibility else # Toggle Regional Dex accessibility
if $PokemonGlobal.pokedexUnlocked[dexindex] if $Trainer.pokedex.unlocked?(dexindex)
pbLockDex(dexindex) $Trainer.pokedex.lock(dexindex)
else else
pbUnlockDex(dexindex) $Trainer.pokedex.unlock(dexindex)
end end
end end
end end

View File

@@ -754,7 +754,7 @@ PokemonDebugMenuCommands.register("setgender", {
when 2 # Reset when 2 # Reset
pkmn.gender = nil pkmn.gender = nil
end end
pbSeenForm(pkmn) if !settingUpBattle $Trainer.pokedex.register(pkmn) if !settingUpBattle
screen.pbRefreshSingle(pkmnid) screen.pbRefreshSingle(pkmnid)
end end
end end
@@ -782,7 +782,7 @@ PokemonDebugMenuCommands.register("speciesform", {
if species && species != pkmn.species if species && species != pkmn.species
pkmn.species = species pkmn.species = species
pkmn.calc_stats pkmn.calc_stats
pbSeenForm(pkmn) if !settingUpBattle $Trainer.pokedex.register(pkmn) if !settingUpBattle
screen.pbRefreshSingle(pkmnid) screen.pbRefreshSingle(pkmnid)
end end
when 1 # Set form when 1 # Set form
@@ -809,7 +809,7 @@ PokemonDebugMenuCommands.register("speciesform", {
pkmn.forced_form = f pkmn.forced_form = f
end end
pkmn.form = f pkmn.form = f
pbSeenForm(pkmn) if !settingUpBattle $Trainer.pokedex.register(pkmn) if !settingUpBattle
screen.pbRefreshSingle(pkmnid) screen.pbRefreshSingle(pkmnid)
end end
end end