Refactoring, documenting deprecated methods

This commit is contained in:
Maruno17
2021-02-01 22:53:03 +00:00
parent 1209b804e9
commit 66494b0044
27 changed files with 188 additions and 109 deletions

View File

@@ -165,121 +165,145 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbGetPocket(item)
Deprecation.warn_method('pbGetPocket', 'v20', 'GameData::Item.get(item).pocket')
return GameData::Item.get(item).pocket
end
# @deprecated This alias is slated to be removed in v20.
def pbGetPrice(item)
Deprecation.warn_method('pbGetPrice', 'v20', 'GameData::Item.get(item).price')
return GameData::Item.get(item).price
end
# @deprecated This alias is slated to be removed in v20.
def pbGetMachine(item)
Deprecation.warn_method('pbGetMachine', 'v20', 'GameData::Item.get(item).move')
return GameData::Item.get(item).move
end
# @deprecated This alias is slated to be removed in v20.
def pbIsTechnicalMachine?(item)
Deprecation.warn_method('pbIsTechnicalMachine?', 'v20', 'GameData::Item.get(item).is_TM?')
return GameData::Item.get(item).is_TM?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsHiddenMachine?(item)
Deprecation.warn_method('pbIsHiddenMachine?', 'v20', 'GameData::Item.get(item).is_HM?')
return GameData::Item.get(item).is_HM?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsMachine?(item)
Deprecation.warn_method('pbIsMachine?', 'v20', 'GameData::Item.get(item).is_machine?')
return GameData::Item.get(item).is_machine?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsMail?(item)
Deprecation.warn_method('pbIsMail?', 'v20', 'GameData::Item.get(item).is_mail?')
return GameData::Item.get(item).is_mail?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsMailWithPokemonIcons?(item)
Deprecation.warn_method('pbIsMailWithPokemonIcons?', 'v20', 'GameData::Item.get(item).is_icon_mail?')
return GameData::Item.get(item).is_icon_mail?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsPokeBall?(item)
Deprecation.warn_method('pbIsPokeBall?', 'v20', 'GameData::Item.get(item).is_poke_ball?')
return GameData::Item.get(item).is_poke_ball?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsSnagBall?(item)
Deprecation.warn_method('pbIsSnagBall?', 'v20', 'GameData::Item.get(item).is_snag_ball?')
return GameData::Item.get(item).is_snag_ball?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsBerry?(item)
Deprecation.warn_method('pbIsBerry?', 'v20', 'GameData::Item.get(item).is_berry?')
return GameData::Item.get(item).is_berry?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsKeyItem?(item)
Deprecation.warn_method('pbIsKeyItem?', 'v20', 'GameData::Item.get(item).is_key_item?')
return GameData::Item.get(item).is_key_item?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsEvolutionStone?(item)
Deprecation.warn_method('pbIsEvolutionStone?', 'v20', 'GameData::Item.get(item).is_evolution_stone?')
return GameData::Item.get(item).is_evolution_stone?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsFossil?(item)
Deprecation.warn_method('pbIsFossil?', 'v20', 'GameData::Item.get(item).is_fossil?')
return GameData::Item.get(item).is_fossil?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsApricorn?(item)
Deprecation.warn_method('pbIsApricorn?', 'v20', 'GameData::Item.get(item).is_apricorn?')
return GameData::Item.get(item).is_apricorn?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsGem?(item)
Deprecation.warn_method('pbIsGem?', 'v20', 'GameData::Item.get(item).is_gem?')
return GameData::Item.get(item).is_gem?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsMulch?(item)
Deprecation.warn_method('pbIsMulch?', 'v20', 'GameData::Item.get(item).is_mulch?')
return GameData::Item.get(item).is_mulch?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsMegaStone?(item)
Deprecation.warn_method('pbIsMegaStone?', 'v20', 'GameData::Item.get(item).is_mega_stone?')
return GameData::Item.get(item).is_mega_stone?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsImportantItem?(item)
Deprecation.warn_method('pbIsImportantItem?', 'v20', 'GameData::Item.get(item).is_important?')
return GameData::Item.get(item).is_important?
end
# @deprecated This alias is slated to be removed in v20.
def pbCanHoldItem?(item)
Deprecation.warn_method('pbCanHoldItem?', 'v20', 'GameData::Item.get(item).can_hold?')
return GameData::Item.get(item).can_hold?
end
# @deprecated This alias is slated to be removed in v20.
def pbIsUnlosableItem?(check_item, species, ability)
Deprecation.warn_method('pbIsUnlosableItem?', 'v20', 'GameData::Item.get(item).unlosable?')
return GameData::Item.get(check_item).unlosable?(species, ability)
end
# @deprecated This alias is slated to be removed in v20.
def pbItemIconFile(item)
Deprecation.warn_method('pbItemIconFile', 'v20', 'GameData::Item.icon_filename(item)')
return GameData::Item.icon_filename(item)
end
# @deprecated This alias is slated to be removed in v20.
def pbHeldItemIconFile(item)
Deprecation.warn_method('pbHeldItemIconFile', 'v20', 'GameData::Item.held_icon_filename(item)')
return GameData::Item.held_icon_filename(item)
end
# @deprecated This alias is slated to be removed in v20.
def pbMailBackFile(item)
Deprecation.warn_method('pbMailBackFile', 'v20', 'GameData::Item.mail_filename(item)')
return GameData::Item.mail_filename(item)

View File

@@ -29,6 +29,7 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbGetBerryPlantData(item)
Deprecation.warn_method('pbGetBerryPlantData', 'v20', 'GameData::BerryPlant.get(item)')
return GameData::BerryPlant.get(item)

View File

@@ -129,11 +129,13 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbLoadMetadata
Deprecation.warn_method('pbLoadMetadata', 'v20', 'GameData::Metadata.get or GameData::MapMetadata.get(map_id)')
return nil
end
# @deprecated This alias is slated to be removed in v20.
def pbGetMetadata(map_id, metadata_type)
if map_id == 0 # Global metadata
Deprecation.warn_method('pbGetMetadata', 'v20', 'GameData::Metadata.get.something')

View File

@@ -72,11 +72,13 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbGetMoveData(move_id, move_data_type = -1)
Deprecation.warn_method('pbGetMoveData', 'v20', 'GameData::Move.get(move_id)')
return GameData::Move.get(move_id)
end
# @deprecated This alias is slated to be removed in v20.
def pbIsHiddenMove?(move)
Deprecation.warn_method('pbIsHiddenMove?', 'v20', 'GameData::Move.get(move).hidden_move?')
return GameData::Move.get(move).hidden_move?

View File

@@ -96,46 +96,55 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbGetTrainerTypeData(tr_type)
Deprecation.warn_method('pbGetTrainerTypeData', 'v20', 'GameData::TrainerType.get(trainer_type)')
return GameData::TrainerType.get(tr_type)
end
# @deprecated This alias is slated to be removed in v20.
def pbTrainerCharFile(tr_type) # Used by the phone
Deprecation.warn_method('pbTrainerCharFile', 'v20', 'GameData::TrainerType.charset_filename(trainer_type)')
return GameData::TrainerType.charset_filename(tr_type)
end
# @deprecated This alias is slated to be removed in v20.
def pbTrainerCharNameFile(tr_type) # Used by Battle Frontier and compiler
Deprecation.warn_method('pbTrainerCharNameFile', 'v20', 'GameData::TrainerType.charset_filename_brief(trainer_type)')
return GameData::TrainerType.charset_filename_brief(tr_type)
end
# @deprecated This alias is slated to be removed in v20.
def pbTrainerSpriteFile(tr_type)
Deprecation.warn_method('pbTrainerSpriteFile', 'v20', 'GameData::TrainerType.front_sprite_filename(trainer_type)')
return GameData::TrainerType.front_sprite_filename(tr_type)
end
# @deprecated This alias is slated to be removed in v20.
def pbTrainerSpriteBackFile(tr_type)
Deprecation.warn_method('pbTrainerSpriteBackFile', 'v20', 'GameData::TrainerType.back_sprite_filename(trainer_type)')
return GameData::TrainerType.back_sprite_filename(tr_type)
end
# @deprecated This alias is slated to be removed in v20.
def pbPlayerSpriteFile(tr_type)
Deprecation.warn_method('pbPlayerSpriteFile', 'v20', 'GameData::TrainerType.player_front_sprite_filename(trainer_type)')
return GameData::TrainerType.player_front_sprite_filename(tr_type)
end
# @deprecated This alias is slated to be removed in v20.
def pbPlayerSpriteBackFile(tr_type)
Deprecation.warn_method('pbPlayerSpriteBackFile', 'v20', 'GameData::TrainerType.player_back_sprite_filename(trainer_type)')
return GameData::TrainerType.player_back_sprite_filename(tr_type)
end
# @deprecated This alias is slated to be removed in v20.
def pbTrainerHeadFile(tr_type)
Deprecation.warn_method('pbTrainerHeadFile', 'v20', 'GameData::TrainerType.map_icon_filename(trainer_type)')
return GameData::TrainerType.map_icon_filename(tr_type)
end
# @deprecated This alias is slated to be removed in v20.
def pbPlayerHeadFile(tr_type)
Deprecation.warn_method('pbPlayerHeadFile', 'v20', 'GameData::TrainerType.player_map_icon_filename(trainer_type)')
return GameData::TrainerType.player_map_icon_filename(tr_type)

View File

@@ -223,31 +223,37 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbGetSpeciesData(species, form = 0, species_data_type = -1)
Deprecation.warn_method('pbGetSpeciesData', 'v20', 'GameData::Species.get_species_form(species, form).something')
return GameData::Species.get_species_form(species, form)
end
# @deprecated This alias is slated to be removed in v20.
def pbGetSpeciesEggMoves(species, form = 0)
Deprecation.warn_method('pbGetSpeciesEggMoves', 'v20', 'GameData::Species.get_species_form(species, form).egg_moves')
return GameData::Species.get_species_form(species, form).egg_moves
end
# @deprecated This alias is slated to be removed in v20.
def pbGetSpeciesMoveset(species, form = 0)
Deprecation.warn_method('pbGetSpeciesMoveset', 'v20', 'GameData::Species.get_species_form(species, form).moves')
return GameData::Species.get_species_form(species, form).moves
end
# @deprecated This alias is slated to be removed in v20.
def pbGetEvolutionData(species)
Deprecation.warn_method('pbGetEvolutionData', 'v20', 'GameData::Species.get(species).evolutions')
return GameData::Species.get(species).evolutions
end
# @deprecated This alias is slated to be removed in v20.
def pbApplyBattlerMetricsToSprite(sprite, index, species_data, shadow = false, metrics = nil)
Deprecation.warn_method('pbApplyBattlerMetricsToSprite', 'v20', 'GameData::Species.get(species).apply_metrics_to_sprite')
GameData::Species.get(species).apply_metrics_to_sprite(sprite, index, shadow)
end
# @deprecated This alias is slated to be removed in v20.
def showShadow?(species)
Deprecation.warn_method('showShadow?', 'v20', 'GameData::Species.get(species).shows_shadow?')
return GameData::Species.get(species).shows_shadow?

View File

@@ -261,46 +261,55 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbLoadSpeciesBitmap(species, gender = 0, form = 0, shiny = false, shadow = false, back = false , egg = false)
Deprecation.warn_method('pbLoadSpeciesBitmap', 'v20', 'GameData::Species.sprite_bitmap(species, form, gender, shiny, shadow, back, egg)')
return GameData::Species.sprite_bitmap(species, form, gender, shiny, shadow, back, egg)
end
# @deprecated This alias is slated to be removed in v20.
def pbLoadPokemonBitmap(pkmn, back = false)
Deprecation.warn_method('pbLoadPokemonBitmap', 'v20', 'GameData::Species.sprite_bitmap_from_pokemon(pkmn)')
return GameData::Species.sprite_bitmap_from_pokemon(pkmn, back)
end
# @deprecated This alias is slated to be removed in v20.
def pbLoadPokemonBitmapSpecies(pkmn, species, back = false)
Deprecation.warn_method('pbLoadPokemonBitmapSpecies', 'v20', 'GameData::Species.sprite_bitmap_from_pokemon(pkmn, back, species)')
return GameData::Species.sprite_bitmap_from_pokemon(pkmn, back, species)
end
# @deprecated This alias is slated to be removed in v20.
def pbPokemonIconFile(pkmn)
Deprecation.warn_method('pbPokemonIconFile', 'v20', 'GameData::Species.icon_filename_from_pokemon(pkmn)')
return GameData::Species.icon_filename_from_pokemon(pkmn)
end
# @deprecated This alias is slated to be removed in v20.
def pbLoadPokemonIcon(pkmn)
Deprecation.warn_method('pbLoadPokemonIcon', 'v20', 'GameData::Species.icon_bitmap_from_pokemon(pkmn)')
return GameData::Species.icon_bitmap_from_pokemon(pkmn)
end
# @deprecated This alias is slated to be removed in v20.
def pbPokemonFootprintFile(species, form = 0)
Deprecation.warn_method('pbPokemonFootprintFile', 'v20', 'GameData::Species.footprint_filename(species, form)')
return GameData::Species.footprint_filename(species, form)
end
# @deprecated This alias is slated to be removed in v20.
def pbCheckPokemonShadowBitmapFiles(species, form = 0)
Deprecation.warn_method('pbCheckPokemonShadowBitmapFiles', 'v20', 'GameData::Species.shadow_filename(species, form)')
return GameData::Species.shadow_filename(species, form)
end
# @deprecated This alias is slated to be removed in v20.
def pbLoadPokemonShadowBitmap(pkmn)
Deprecation.warn_method('pbLoadPokemonShadowBitmap', 'v20', 'GameData::Species.shadow_bitmap_from_pokemon(pkmn)')
return GameData::Species.shadow_bitmap_from_pokemon(pkmn)
end
# @deprecated This alias is slated to be removed in v20.
def pbCryFile(species, form = 0)
if species.is_a?(Pokemon)
Deprecation.warn_method('pbCryFile', 'v20', 'GameData::Species.cry_filename_from_pokemon(pkmn)')
@@ -310,21 +319,25 @@ def pbCryFile(species, form = 0)
return GameData::Species.cry_filename(species, form)
end
# @deprecated This alias is slated to be removed in v20.
def pbPlayCry(pkmn, volume = 90, pitch = nil)
Deprecation.warn_method('pbPlayCry', 'v20', 'GameData::Species.play_cry(pkmn)')
GameData::Species.play_cry(pkmn, volume, pitch)
end
# @deprecated This alias is slated to be removed in v20.
def pbPlayCrySpecies(species, form = 0, volume = 90, pitch = nil)
Deprecation.warn_method('pbPlayCrySpecies', 'v20', 'GameData::Species.play_cry_from_species(species, form)')
GameData::Species.play_cry_from_species(species, form, volume, pitch)
end
# @deprecated This alias is slated to be removed in v20.
def pbPlayCryPokemon(pkmn, volume = 90, pitch = nil)
Deprecation.warn_method('pbPlayCryPokemon', 'v20', 'GameData::Species.play_cry_from_pokemon(pkmn)')
GameData::Species.play_cry_from_pokemon(pkmn, volume, pitch)
end
# @deprecated This alias is slated to be removed in v20.
def pbCryFrameLength(species, form = 0, pitch = 100)
Deprecation.warn_method('pbCryFrameLength', 'v20', 'GameData::Species.cry_length(species, form)')
return GameData::Species.cry_length(species, form, pitch)

View File

@@ -37,7 +37,7 @@ module GameData
# @param tr_type [Symbol, String]
# @param tr_name [String]
# @param tr_version [Integer]
# @param tr_version [Integer, nil]
# @return [Boolean] whether the given other is defined as a self
def self.exists?(tr_type, tr_name, tr_version = 0)
validate tr_type => [Symbol, String]
@@ -48,7 +48,7 @@ module GameData
# @param tr_type [Symbol, String]
# @param tr_name [String]
# @param tr_version [Integer]
# @param tr_version [Integer, nil]
# @return [self]
def self.get(tr_type, tr_name, tr_version = 0)
validate tr_type => [Symbol, String]
@@ -58,7 +58,9 @@ module GameData
return self::DATA[key]
end
# @param other [Symbol, self, String, Integer]
# @param tr_type [Symbol, String]
# @param tr_name [String]
# @param tr_version [Integer, nil]
# @return [self, nil]
def try_get(tr_type, tr_name, tr_version = 0)
validate tr_type => [Symbol, String]
@@ -166,6 +168,7 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbGetTrainerData(tr_type, tr_name, tr_version = 0)
Deprecation.warn_method('pbGetTrainerData', 'v20', 'GameData::Trainer.get(tr_type, tr_name, tr_version)')
return GameData::Trainer.get(tr_type, tr_name, tr_version)

View File

@@ -15,7 +15,7 @@ module GameData
include InstanceMethods
# @param map_id [Integer]
# @param map_version [Integer]
# @param map_version [Integer, nil]
# @return [Boolean] whether there is encounter data for the given map ID/version
def self.exists?(map_id, map_version = 0)
validate map_id => [Integer]
@@ -25,7 +25,7 @@ module GameData
end
# @param map_id [Integer]
# @param version [Integer]
# @param map_version [Integer, nil]
# @return [self, nil]
def self.get(map_id, map_version = 0)
validate map_id => Integer
@@ -72,6 +72,7 @@ end
#===============================================================================
# Deprecated methods
#===============================================================================
# @deprecated This alias is slated to be removed in v20.
def pbLoadEncountersData
Deprecation.warn_method('pbLoadEncountersData', 'v20', 'GameData::Encounter.get(map_id, version)')
return nil

View File

@@ -96,16 +96,18 @@ module PBExperience
end
# Erratic (600000):
# For levels 0-50: n**3([100-n]/50)
# For levels 51-68: n**3([150-n]/100)
# For levels 69-98: n**3(1.274-[1/50][n/3]-p(n mod 3))
# where p(x) = array(0.000,0.008,0.014)[x]
# For levels 99-100: n**3([160-n]/100)
# For levels 0-50: n**3 * (100 - n) / 50
# For levels 51-68: n**3 * (150 - n) / 100
# For levels 69-98: n**3 * 1.274 - (n / 150) - p(n mod 3)
# where p(x) = array(0.000, 0.008, 0.014)[x]
# For levels 99-100: n**3 * (160 - n) / 100
# Fluctuating (1640000):
# For levels 0-15 : n**3([24+{(n+1)/3}]/50)
# For levels 16-35: n**3([14+n]/50)
# For levels 36-100: n**3([32+{n/2}]/50)
# For levels 0-15 : n**3 * (24 + ((n + 1) / 3)) / 50
# For levels 16-35: n**3 * (14 + n) / 50
# For levels 36-100: n**3 * (32 + (n / 2)) / 50
# @param level [Integer]
# @param growth [Integer] growth rate
def self.pbGetExpInternal(level,growth)
if level <= 100
# Refer to experience table for levels 100 and less
@@ -138,7 +140,7 @@ module PBExperience
end
# Gets the maximum Exp Points possible for the given growth rate.
# growth -- Growth rate.
# @param growth [Integer] growth rate
def self.pbGetMaxExperience(growth)
if growth<0 || growth>PBGrowthRates.maxValue
return ArgumentError.new("The growth rate is invalid.")
@@ -148,7 +150,8 @@ module PBExperience
# Gets the number of Exp Points needed to reach the given
# level with the given growth rate.
# growth -- Growth rate.
# @param level [Integer]
# @param growth [Integer] growth rate
def self.pbGetStartExperience(level,growth)
if growth<0 || growth>PBGrowthRates.maxValue
return ArgumentError.new("The growth rate is invalid.")
@@ -163,9 +166,9 @@ module PBExperience
# Adds experience points ensuring that the new total doesn't
# exceed the maximum Exp. Points for the given growth rate.
# currexp -- Current Exp Points.
# expgain -- Exp. Points to add
# growth -- Growth rate.
# @param currexp [Integer] current Exp. points
# @param expgain [Integer] Exp. points to add
# @param growth [Integer] growth rate
def self.pbAddExperience(currexp,expgain,growth)
if growth<0 || growth>PBGrowthRates.maxValue
return ArgumentError.new("The growth rate is invalid.")
@@ -177,7 +180,7 @@ module PBExperience
end
# Calculates a level given the number of Exp Points and growth rate.
# growth -- Growth rate.
# @param growth [Integer] growth rate
def self.pbGetLevelFromExperience(exp,growth)
if growth<0 || growth>PBGrowthRates.maxValue
return ArgumentError.new("The growth rate is invalid.")