From 9b4bc66dc0a7f113b8452dcbeb2c896c8f04e615 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 19 Jun 2021 20:36:17 +0100 Subject: [PATCH] Tidying up --- .../002_Save data/005_Game_SaveConversions.rb | 4 ++-- Data/Scripts/014_Pokemon/001_Pokemon.rb | 2 +- Data/Scripts/014_Pokemon/004_Pokemon_Move.rb | 4 ++-- Data/Scripts/021_Compiler/001_Compiler.rb | 18 +++++++++--------- .../021_Compiler/002_Compiler_CompilePBS.rb | 12 ++++++------ 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb index cb9565ef3..1932f71f4 100644 --- a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb +++ b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb @@ -146,8 +146,8 @@ SaveData.register_conversion(:v19_1_fix_phone_contacts) do end end -SaveData.register_conversion(:v19_1_1_fix_berry_plants) do - essentials_version "19.1.1" +SaveData.register_conversion(:v19_2_fix_berry_plants) do + essentials_version 19.2 display_title 'Fixing berry plant data' to_value :global_metadata do |global| berry_conversion = { diff --git a/Data/Scripts/014_Pokemon/001_Pokemon.rb b/Data/Scripts/014_Pokemon/001_Pokemon.rb index cc7e4e5c7..c7ca19e1a 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon.rb @@ -239,7 +239,7 @@ class Pokemon end # Sets this Pokémon's status. See {GameData::Status} for all possible status effects. - # @param value [Symbol, String, GameData::Status, Integer] status to set + # @param value [Symbol, String, GameData::Status] status to set def status=(value) return if !able? new_status = GameData::Status.try_get(value) diff --git a/Data/Scripts/014_Pokemon/004_Pokemon_Move.rb b/Data/Scripts/014_Pokemon/004_Pokemon_Move.rb index b175d16b8..03191925c 100644 --- a/Data/Scripts/014_Pokemon/004_Pokemon_Move.rb +++ b/Data/Scripts/014_Pokemon/004_Pokemon_Move.rb @@ -11,7 +11,7 @@ class Pokemon attr_reader :ppup # Creates a new Move object. - # @param move_id [Symbol, String, Integer] move ID + # @param move_id [Symbol, String, GameData::Move] move ID def initialize(move_id) @id = GameData::Move.get(move_id).id @ppup = 0 @@ -20,7 +20,7 @@ class Pokemon # Sets this move's ID, and caps the PP amount if it is now greater than this # move's total PP. - # @param value [Symbol, String, Integer] the new move ID + # @param value [Symbol, String, GameData::Move] the new move ID def id=(value) @id = GameData::Move.get(value).id @pp = @pp.clamp(0, total_pp) diff --git a/Data/Scripts/021_Compiler/001_Compiler.rb b/Data/Scripts/021_Compiler/001_Compiler.rb index 2386fa1b6..83a08fcb3 100644 --- a/Data/Scripts/021_Compiler/001_Compiler.rb +++ b/Data/Scripts/021_Compiler/001_Compiler.rb @@ -128,27 +128,27 @@ module Compiler yield lastsection,sectionname if havesection end - # Used for pokemon.txt, metadata.txt + # Used for types.txt, pokemon.txt, trainerlists.txt and Battle Tower trainers PBS files def pbEachFileSection(f) + pbEachFileSectionEx(f) { |section,name| + yield section,name if block_given? && name[/^.+$/] + } + end + + # Used for metadata.txt + def pbEachFileSectionNumbered(f) pbEachFileSectionEx(f) { |section,name| yield section,name.to_i if block_given? && name[/^\d+$/] } end # Used for pokemonforms.txt - def pbEachFileSection2(f) + def pbEachFileSectionPokemonForms(f) pbEachFileSectionEx(f) { |section,name| yield section,name if block_given? && name[/^\w+[-,\s]{1}\d+$/] } end - # Used for types.txt - def pbEachFileSection3(f) - pbEachFileSectionEx(f) { |section,name| - yield section,name if block_given? && name[/^.+$/] - } - end - # Used for phone.txt def pbEachSection(f) lineno = 1 diff --git a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb index 07507be95..5426abcfe 100644 --- a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb @@ -142,7 +142,7 @@ module Compiler # contents is a hash containing all the XXX=YYY lines in that section, where # the keys are the XXX and the values are the YYY (as unprocessed strings). schema = GameData::Type::SCHEMA - pbEachFileSection3(f) { |contents, type_id| + pbEachFileSection(f) { |contents, type_id| contents["InternalName"] = type_id if !type_id[/^\d+/] icon_pos = (type_id[/^\d+/]) ? type_id.to_i : nil # Go through schema hash of compilable data and compile this section @@ -373,7 +373,7 @@ module Compiler # contents is a hash containing all the XXX=YYY lines in that section, where # the keys are the XXX and the values are the YYY (as unprocessed strings). schema = GameData::Species.schema - pbEachFileSection3(f) { |contents, species_id| + pbEachFileSection(f) { |contents, species_id| FileLineData.setSection(species_id, "header", nil) # For error reporting contents["InternalName"] = species_id if !species_id[/^\d+/] # Ensure all required properties have been defined, and raise an error @@ -531,7 +531,7 @@ module Compiler # contents is a hash containing all the XXX=YYY lines in that section, where # the keys are the XXX and the values are the YYY (as unprocessed strings). schema = GameData::Species.schema(true) - pbEachFileSection2(f) { |contents, section_name| + pbEachFileSectionPokemonForms(f) { |contents, section_name| FileLineData.setSection(section_name, "header", nil) # For error reporting # Split section_name into a species number and form number split_section_name = section_name.split(/[-,\s]/) @@ -1208,7 +1208,7 @@ module Compiler MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechLose,[]) File.open(path, "rb") { |f| FileLineData.file = path - pbEachFileSectionEx(f) { |section,name| + pbEachFileSection(f) { |section,name| next if name!="DefaultTrainerList" && name!="TrainerList" rsection = [] for key in section.keys @@ -1270,7 +1270,7 @@ module Compiler if safeExists?(filename) File.open(filename,"rb") { |f| FileLineData.file = filename - pbEachFileSectionEx(f) { |section,name| + pbEachFileSection(f) { |section,name| rsection = [] for key in section.keys FileLineData.setSection(name,key,section[key]) @@ -1306,7 +1306,7 @@ module Compiler # Read a whole section's lines at once, then run through this code. # contents is a hash containing all the XXX=YYY lines in that section, where # the keys are the XXX and the values are the YYY (as unprocessed strings). - pbEachFileSection(f) { |contents, map_id| + pbEachFileSectionNumbered(f) { |contents, map_id| schema = (map_id == 0) ? GameData::Metadata::SCHEMA : GameData::MapMetadata::SCHEMA # Go through schema hash of compilable data and compile this section for key in schema.keys