Yet more script rearranging

This commit is contained in:
Maruno17
2021-04-17 23:45:42 +01:00
parent 96c68e79a3
commit 2ca8a42949
236 changed files with 923 additions and 928 deletions

View File

@@ -0,0 +1,186 @@
#===============================================================================
# Basic trainer class (use a child class rather than this one)
#===============================================================================
class Trainer
attr_accessor :trainer_type
attr_accessor :name
attr_accessor :id
attr_accessor :language
attr_accessor :party
def full_name
return _INTL("{1} {2}", trainer_type_name, @name)
end
#=============================================================================
# Portion of the ID which is visible on the Trainer Card
def public_ID(id = nil)
return id ? id & 0xFFFF : @id & 0xFFFF
end
# Other portion of the ID
def secret_ID(id = nil)
return id ? id >> 16 : @id >> 16
end
# Random ID other than this Trainer's ID
def make_foreign_ID
loop do
ret = rand(2 ** 16) | rand(2 ** 16) << 16
return ret if ret != @id
end
return 0
end
#=============================================================================
def trainer_type_name; return GameData::TrainerType.get(@trainer_type).name; end
def base_money; return GameData::TrainerType.get(@trainer_type).base_money; end
def gender; return GameData::TrainerType.get(@trainer_type).gender; end
def male?; return GameData::TrainerType.get(@trainer_type).male?; end
def female?; return GameData::TrainerType.get(@trainer_type).female?; end
def skill_level; return GameData::TrainerType.get(@trainer_type).skill_level; end
def skill_code; return GameData::TrainerType.get(@trainer_type).skill_code; end
def has_skill_code?(code)
c = skill_code
return c && c != "" && c[/#{code}/]
end
#=============================================================================
def pokemon_party
return @party.find_all { |p| p && !p.egg? }
end
def able_party
return @party.find_all { |p| p && !p.egg? && !p.fainted? }
end
def party_count
return @party.length
end
def pokemon_count
ret = 0
@party.each { |p| ret += 1 if p && !p.egg? }
return ret
end
def able_pokemon_count
ret = 0
@party.each { |p| ret += 1 if p && !p.egg? && !p.fainted? }
return ret
end
def party_full?
return party_count >= Settings::MAX_PARTY_SIZE
end
# Returns true if there are no usable Pokémon in the player's party.
def all_fainted?
return able_pokemon_count == 0
end
def first_party
return @party[0]
end
def first_pokemon
return pokemon_party[0]
end
def first_able_pokemon
return able_party[0]
end
def last_party
return (@party.length > 0) ? @party[@party.length - 1] : nil
end
def last_pokemon
p = pokemon_party
return (p.length > 0) ? p[p.length - 1] : nil
end
def last_able_pokemon
p = able_party
return (p.length > 0) ? p[p.length - 1] : nil
end
def remove_pokemon_at_index(index)
return false if index < 0 || index >= party_count
have_able = false
@party.each_with_index do |pkmn, i|
have_able = true if i != index && pkmn.able?
break if have_able
end
return false if !have_able
@party.delete_at(index)
return true
end
# Checks whether the trainer would still have an unfainted Pokémon if the
# Pokémon given by _index_ were removed from the party.
def has_other_able_pokemon?(index)
@party.each_with_index { |pkmn, i| return true if i != index && pkmn.able? }
return false
end
# Returns true if there is a Pokémon of the given species in the trainer's
# party. You may also specify a particular form it should be.
def has_species?(species, form = -1)
return pokemon_party.any? { |p| p && p.isSpecies?(species) && (form < 0 || p.form == form) }
end
# Returns whether there is a fatefully met Pokémon of the given species in the
# trainer's party.
def has_fateful_species?(species)
return pokemon_party.any? { |p| p && p.isSpecies?(species) && p.obtain_method == 4 }
end
# Returns whether there is a Pokémon with the given type in the trainer's
# party.
def has_pokemon_of_type?(type)
return false if !GameData::Type.exists?(type)
type = GameData::Type.get(type).id
return pokemon_party.any? { |p| p && p.hasType(type) }
end
# Checks whether any Pokémon in the party knows the given move, and returns
# the first Pokémon it finds with that move, or nil if no Pokémon has that move.
def get_pokemon_with_move(move)
pokemon_party.each { |pkmn| return pkmn if pkmn.hasMove?(move) }
return nil
end
# Fully heal all Pokémon in the party.
def heal_party
@party.each { |pkmn| pkmn.heal }
end
#=============================================================================
def initialize(name, trainer_type)
@trainer_type = trainer_type
@name = name
@id = rand(2 ** 16) | rand(2 ** 16) << 16
@language = pbGetLanguage
@party = []
end
end
#===============================================================================
# Trainer class for NPC trainers
#===============================================================================
class NPCTrainer < Trainer
attr_accessor :items
attr_accessor :lose_text
def initialize(name, trainer_type)
super
@items = []
@lose_text = nil
end
end

View File

@@ -0,0 +1,123 @@
#===============================================================================
#
#===============================================================================
def pbLoadTrainer(tr_type, tr_name, tr_version = 0)
tr_type_data = GameData::TrainerType.try_get(tr_type)
raise _INTL("Trainer type {1} does not exist.", tr_type) if !tr_type_data
tr_type = tr_type_data.id
trainer_data = GameData::Trainer.try_get(tr_type, tr_name, tr_version)
return (trainer_data) ? trainer_data.to_trainer : nil
end
def pbNewTrainer(tr_type, tr_name, tr_version, save_changes = true)
party = []
for i in 0...Settings::MAX_PARTY_SIZE
if i == 0
pbMessage(_INTL("Please enter the first Pokémon.",i))
else
break if !pbConfirmMessage(_INTL("Add another Pokémon?"))
end
loop do
species = pbChooseSpeciesList
if species
params = ChooseNumberParams.new
params.setRange(1, GameData::GrowthRate.max_level)
params.setDefaultValue(10)
level = pbMessageChooseNumber(_INTL("Set the level for {1} (max. #{params.maxNumber}).",
GameData::Species.get(species).name), params)
party.push([species, level])
break
else
break if i > 0
pbMessage(_INTL("This trainer must have at least 1 Pokémon!"))
end
end
end
trainer = [tr_type, tr_name, [], party, tr_version]
if save_changes
trainer_hash = {
:id_number => GameData::Trainer::DATA.keys.length / 2,
:trainer_type => tr_type,
:name => tr_name,
:version => tr_version,
:pokemon => []
}
party.each do |pkmn|
trainer_hash[:pokemon].push({
:species => pkmn[0],
:level => pkmn[1]
})
end
# Add trainer's data to records
trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
GameData::Trainer.register(trainer_hash)
GameData::Trainer.save
pbConvertTrainerData
pbMessage(_INTL("The Trainer's data was added to the list of battles and in PBS/trainers.txt."))
end
return trainer
end
def pbConvertTrainerData
tr_type_names = []
GameData::TrainerType.each { |t| tr_type_names[t.id_number] = t.real_name }
MessageTypes.setMessages(MessageTypes::TrainerTypes, tr_type_names)
Compiler.write_trainer_types
Compiler.write_trainers
end
def pbTrainerTypeCheck(trainer_type)
return true if !$DEBUG
return true if GameData::TrainerType.exists?(trainer_type)
if pbConfirmMessage(_INTL("Add new trainer type {1}?", trainer_type.to_s))
pbTrainerTypeEditorNew(trainer_type.to_s)
end
pbMapInterpreter.command_end if pbMapInterpreter
return false
end
# Called from trainer events to ensure the trainer exists
def pbTrainerCheck(tr_type, tr_name, max_battles, tr_version = 0)
return true if !$DEBUG
# Check for existence of trainer type
pbTrainerTypeCheck(tr_type)
tr_type_data = GameData::TrainerType.try_get(tr_type)
return false if !tr_type_data
tr_type = tr_type_data.id
# Check for existence of trainer with given ID number
return true if GameData::Trainer.exists?(tr_type, tr_name, tr_version)
# Add new trainer
if pbConfirmMessage(_INTL("Add new trainer variant {1} (of {2}) for {3} {4}?",
tr_version, max_battles, tr_type.to_s, tr_name))
pbNewTrainer(tr_type, tr_name, tr_version)
end
return true
end
def pbGetFreeTrainerParty(tr_type, tr_name)
tr_type_data = GameData::TrainerType.try_get(tr_type)
raise _INTL("Trainer type {1} does not exist.", tr_type) if !tr_type_data
tr_type = tr_type_data.id
for i in 0...256
return i if !GameData::Trainer.try_get(tr_type, tr_name, i)
end
return -1
end
def pbMissingTrainer(tr_type, tr_name, tr_version)
tr_type_data = GameData::TrainerType.try_get(tr_type)
raise _INTL("Trainer type {1} does not exist.", tr_type) if !tr_type_data
tr_type = tr_type_data.id
if !$DEBUG
raise _INTL("Can't find trainer ({1}, {2}, ID {3})", tr_type.to_s, tr_name, tr_version)
end
message = ""
if tr_version != 0
message = _INTL("Add new trainer ({1}, {2}, ID {3})?", tr_type.to_s, tr_name, tr_version)
else
message = _INTL("Add new trainer ({1}, {2})?", tr_type.to_s, tr_name)
end
cmd = pbMessage(message, [_INTL("Yes"), _INTL("No")], 2)
pbNewTrainer(tr_type, tr_name, tr_version) if cmd == 0
return cmd
end

View File

@@ -0,0 +1,65 @@
#===============================================================================
# Walking charset, for use in text entry screens and load game screen
#===============================================================================
class TrainerWalkingCharSprite < SpriteWrapper
def initialize(charset,viewport=nil)
super(viewport)
@animbitmap = nil
self.charset = charset
@animframe = 0 # Current pattern
@frame = 0 # Frame counter
self.animspeed = 5 # Animation speed (frames per pattern)
end
def charset=(value)
@animbitmap.dispose if @animbitmap
@animbitmap = nil
bitmapFileName = sprintf("Graphics/Characters/%s",value)
@charset = pbResolveBitmap(bitmapFileName)
if @charset
@animbitmap = AnimatedBitmap.new(@charset)
self.bitmap = @animbitmap.bitmap
self.src_rect.set(0,0,self.bitmap.width/4,self.bitmap.height/4)
else
self.bitmap = nil
end
end
def altcharset=(value) # Used for box icon in the naming screen
@animbitmap.dispose if @animbitmap
@animbitmap = nil
@charset = pbResolveBitmap(value)
if @charset
@animbitmap = AnimatedBitmap.new(@charset)
self.bitmap = @animbitmap.bitmap
self.src_rect.set(0,0,self.bitmap.width/4,self.bitmap.height)
else
self.bitmap = nil
end
end
def animspeed=(value)
@frameskip = value*Graphics.frame_rate/40
end
def dispose
@animbitmap.dispose if @animbitmap
super
end
def update
@updating = true
super
if @animbitmap
@animbitmap.update
self.bitmap = @animbitmap.bitmap
end
@frame += 1
if @frame>=@frameskip
@animframe = (@animframe+1)%4
self.src_rect.x = @animframe*@animbitmap.bitmap.width/4
@frame -= @frameskip
end
@updating = false
end
end

View File

@@ -0,0 +1,108 @@
#===============================================================================
# Trainer class for the player
#===============================================================================
class Player < Trainer
# @return [Integer] the character ID of the player
attr_accessor :character_ID
# @return [Integer] the player's outfit
attr_accessor :outfit
# @return [Array<Boolean>] the player's Gym Badges (true if owned)
attr_accessor :badges
# @return [Integer] the player's money
attr_reader :money
# @return [Integer] the player's Game Corner coins
attr_reader :coins
# @return [Integer] the player's battle points
attr_reader :battle_points
# @return [Integer] the player's soot
attr_reader :soot
# @return [Pokedex] the player's Pokédex
attr_reader :pokedex
# @return [Boolean] whether the Pokédex has been obtained
attr_accessor :has_pokedex
# @return [Boolean] whether the Pokégear has been obtained
attr_accessor :has_pokegear
# @return [Boolean] whether the player has running shoes (i.e. can run)
attr_accessor :has_running_shoes
# @return [Boolean] whether the creator of the Pokémon Storage System has been seen
attr_accessor :seen_storage_creator
# @return [Boolean] whether Mystery Gift can be used from the load screen
attr_accessor :mystery_gift_unlocked
# @return [Array<Array>] downloaded Mystery Gift data
attr_accessor :mystery_gifts
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
# Sets the player's money. It can not exceed {Settings::MAX_MONEY}.
# @param value [Integer] new money value
def money=(value)
validate value => Integer
@money = value.clamp(0, Settings::MAX_MONEY)
end
# Sets the player's coins amount. It can not exceed {Settings::MAX_COINS}.
# @param value [Integer] new coins value
def coins=(value)
validate value => Integer
@coins = value.clamp(0, Settings::MAX_COINS)
end
# Sets the player's Battle Points amount. It can not exceed
# {Settings::MAX_BATTLE_POINTS}.
# @param value [Integer] new Battle Points value
def battle_points=(value)
validate value => Integer
@battle_points = value.clamp(0, Settings::MAX_BATTLE_POINTS)
end
# Sets the player's soot amount. It can not exceed {Settings::MAX_SOOT}.
# @param value [Integer] new soot value
def soot=(value)
validate value => Integer
@soot = value.clamp(0, Settings::MAX_SOOT)
end
# @return [Integer] the number of Gym Badges owned by the player
def badge_count
return @badges.count { |badge| badge == true }
end
#=============================================================================
# (see Pokedex#seen?)
# Shorthand for +self.pokedex.seen?+.
def seen?(species)
return @pokedex.seen?(species)
end
# (see Pokedex#owned?)
# Shorthand for +self.pokedex.owned?+.
def owned?(species)
return @pokedex.owned?(species)
end
#=============================================================================
def initialize(name, trainer_type)
super
@character_ID = -1
@outfit = 0
@badges = [false] * 8
@money = Settings::INITIAL_MONEY
@coins = 0
@battle_points = 0
@soot = 0
@pokedex = Pokedex.new
@has_pokedex = false
@has_pokegear = false
@has_running_shoes = false
@seen_storage_creator = false
@mystery_gift_unlocked = false
@mystery_gifts = []
end
end

View File

@@ -0,0 +1,279 @@
class Player < Trainer
# 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
# @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated
def set_seen(species, should_refresh_dexes = true)
species_id = GameData::Species.try_get(species)&.species
return if species_id.nil?
@seen[species_id] = true
self.refresh_accessible_dexes if should_refresh_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
# @param species [Symbol, GameData::Species] Pokémon species
# @param gender [Integer] gender (0=male, 1=female, 2=genderless)
# @param form [Integer] form number
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
# @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated
def set_owned(species, should_refresh_dexes = true)
species_id = GameData::Species.try_get(species)&.species
return if species_id.nil?
@owned[species_id] = true
self.refresh_accessible_dexes if should_refresh_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_shadow[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
# @param species [Symbol, GameData::Species] species to check
# @return [Boolean] whether a Shadow Pokémon of the species is owned
def owned_shadow_pokemon?(species)
species_id = GameData::Species.try_get(species)&.species
return false if species_id.nil?
return @owned_shadow[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, should_refresh_dexes = true)
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 if should_refresh_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
# 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,194 @@
#===============================================================================
# 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 :isMale?, :male?, removal_in: 'v20'
deprecated_method_alias :isFemale?, :female?, 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
# @deprecated Use {seen?} or {set_seen} instead. This alias is slated to be removed in v20.
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_method_alias :hasSeen?, :seen?, removal_in: 'v20'
deprecated_method_alias :hasOwned?, :owned?, removal_in: 'v20'
deprecated_method_alias :pokegear, :has_pokegear, 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
# @deprecated Use {Player} instead. PokeBattle_Trainer is slated to be removed in v20.
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, false) if value }
trainer.owned.each_with_index { |value, i| ret.pokedex.set_owned(i, false) if value }
trainer.formseen.each_with_index do |value, i|
species_id = GameData::Species.try_get(i)&.species
next if species_id.nil? || value.nil?
ret.pokedex.seen_forms[species_id] = [value[0].clone, value[1].clone] if value
end
trainer.formlastseen.each_with_index do |value, i|
species_id = GameData::Species.try_get(i)&.species
next if species_id.nil? || value.nil?
ret.pokedex.set_last_form_seen(species_id, 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.pokedex.refresh_accessible_dexes
ret.has_pokedex = trainer.pokedex
ret.has_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('pbHasFatefulSpecies?', '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