mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Tidied, fixed some bugs
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
#==============================================================================#
|
#==============================================================================#
|
||||||
# Pokémon Essentials #
|
# Pokémon Essentials #
|
||||||
# Version 18.1.dev #
|
# Version 19 #
|
||||||
# https://github.com/Maruno17/pokemon-essentials #
|
# https://github.com/Maruno17/pokemon-essentials #
|
||||||
#==============================================================================#
|
#==============================================================================#
|
||||||
|
|
||||||
module Settings
|
module Settings
|
||||||
# The version of the game. It has to adhere to the MAJOR.MINOR.PATCH format.
|
# The version of your game. It has to adhere to the MAJOR.MINOR.PATCH format.
|
||||||
GAME_VERSION = '1.0.0'
|
GAME_VERSION = '1.0.0'
|
||||||
|
|
||||||
# The generation that the battle system follows. Used throughout the battle
|
# The generation that the battle system follows. Used throughout the battle
|
||||||
@@ -397,7 +397,8 @@ module Settings
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# DO NOT EDIT THESE!
|
||||||
module Essentials
|
module Essentials
|
||||||
VERSION = "18.1.dev"
|
VERSION = "19"
|
||||||
ERROR_TEXT = ""
|
ERROR_TEXT = ""
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class Bitmap
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Zlib deflation
|
# Zlib deflation
|
||||||
smoldata = Zlib::Deflate.deflate(data.pack("C*")).bytes.map
|
smoldata = Zlib::Deflate.deflate(data.pack("C*")).bytes.map { |e| e.to_i }
|
||||||
# data chunk length
|
# data chunk length
|
||||||
f.write_int smoldata.size
|
f.write_int smoldata.size
|
||||||
# IDAT
|
# IDAT
|
||||||
|
|||||||
@@ -11,44 +11,11 @@ module SaveData
|
|||||||
'./Game.rxdata'
|
'./Game.rxdata'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compiles the save data and saves a marshaled version of it into
|
|
||||||
# the given file.
|
|
||||||
# @param file_path [String] path of the file to save into
|
|
||||||
# @raise [InvalidValueError] if an invalid value is being saved
|
|
||||||
def self.save_to_file(file_path)
|
|
||||||
validate file_path => String
|
|
||||||
|
|
||||||
save_data = self.compile
|
|
||||||
|
|
||||||
File.open(file_path, 'wb') { |file| Marshal.dump(save_data, file) }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Fetches save data from the given file.
|
|
||||||
# @param file_path [String] path of the file to read from
|
|
||||||
# @return [Hash] save data in Hash format
|
|
||||||
# @raise (see .get_data_from_file)
|
|
||||||
def self.read_from_file(file_path)
|
|
||||||
validate file_path => String
|
|
||||||
|
|
||||||
save_data = get_data_from_file(file_path)
|
|
||||||
|
|
||||||
save_data = to_hash_format(save_data) if save_data.is_a?(Array)
|
|
||||||
|
|
||||||
return save_data
|
|
||||||
end
|
|
||||||
|
|
||||||
# @return [Boolean] whether the save file exists
|
# @return [Boolean] whether the save file exists
|
||||||
def self.exists?
|
def self.exists?
|
||||||
return File.file?(FILE_PATH)
|
return File.file?(FILE_PATH)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes the save file (and a possible .bak backup file if one exists)
|
|
||||||
# @raise [Error::ENOENT]
|
|
||||||
def self.delete_file
|
|
||||||
File.delete(FILE_PATH)
|
|
||||||
File.delete(FILE_PATH + '.bak') if File.file?(FILE_PATH + '.bak')
|
|
||||||
end
|
|
||||||
|
|
||||||
# Fetches the save data from the given file.
|
# Fetches the save data from the given file.
|
||||||
# Returns an Array in the case of a pre-v19 save file.
|
# Returns an Array in the case of a pre-v19 save file.
|
||||||
# @param file_path [String] path of the file to load from
|
# @param file_path [String] path of the file to load from
|
||||||
@@ -57,35 +24,59 @@ module SaveData
|
|||||||
def self.get_data_from_file(file_path)
|
def self.get_data_from_file(file_path)
|
||||||
validate file_path => String
|
validate file_path => String
|
||||||
save_data = nil
|
save_data = nil
|
||||||
|
|
||||||
File.open(file_path) do |file|
|
File.open(file_path) do |file|
|
||||||
data = Marshal.load(file)
|
data = Marshal.load(file)
|
||||||
|
|
||||||
if data.is_a?(Hash)
|
if data.is_a?(Hash)
|
||||||
save_data = data
|
save_data = data
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
save_data = [data]
|
save_data = [data]
|
||||||
|
|
||||||
save_data << Marshal.load(file) until file.eof?
|
save_data << Marshal.load(file) until file.eof?
|
||||||
end
|
end
|
||||||
|
|
||||||
return save_data
|
return save_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Fetches save data from the given file. If it needed converting, resaves it.
|
||||||
|
# @param file_path [String] path of the file to read from
|
||||||
|
# @return [Hash] save data in Hash format
|
||||||
|
# @raise (see .get_data_from_file)
|
||||||
|
def self.read_from_file(file_path)
|
||||||
|
validate file_path => String
|
||||||
|
save_data = get_data_from_file(file_path)
|
||||||
|
save_data = to_hash_format(save_data) if save_data.is_a?(Array)
|
||||||
|
if !save_data.empty? && run_conversions(save_data)
|
||||||
|
File.open(file_path, 'wb') { |file| Marshal.dump(save_data, file) }
|
||||||
|
end
|
||||||
|
return save_data
|
||||||
|
end
|
||||||
|
|
||||||
|
# Compiles the save data and saves a marshaled version of it into
|
||||||
|
# the given file.
|
||||||
|
# @param file_path [String] path of the file to save into
|
||||||
|
# @raise [InvalidValueError] if an invalid value is being saved
|
||||||
|
def self.save_to_file(file_path)
|
||||||
|
validate file_path => String
|
||||||
|
save_data = self.compile_save_hash
|
||||||
|
File.open(file_path, 'wb') { |file| Marshal.dump(save_data, file) }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Deletes the save file (and a possible .bak backup file if one exists)
|
||||||
|
# @raise [Error::ENOENT]
|
||||||
|
def self.delete_file
|
||||||
|
File.delete(FILE_PATH)
|
||||||
|
File.delete(FILE_PATH + '.bak') if File.file?(FILE_PATH + '.bak')
|
||||||
|
end
|
||||||
|
|
||||||
# Converts the pre-v19 format data to the new format.
|
# Converts the pre-v19 format data to the new format.
|
||||||
# @param old_format [Array] pre-v19 format save data
|
# @param old_format [Array] pre-v19 format save data
|
||||||
# @return [Hash] save data in new format
|
# @return [Hash] save data in new format
|
||||||
def self.to_hash_format(old_format)
|
def self.to_hash_format(old_format)
|
||||||
validate old_format => Array
|
validate old_format => Array
|
||||||
hash = {}
|
hash = {}
|
||||||
|
|
||||||
@values.each do |value|
|
@values.each do |value|
|
||||||
data = value.get_from_old_format(old_format)
|
data = value.get_from_old_format(old_format)
|
||||||
hash[value.id] = data unless data.nil?
|
hash[value.id] = data unless data.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
return hash
|
return hash
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ module SaveData
|
|||||||
# An error raised if an invalid save value is being saved or loaded.
|
# An error raised if an invalid save value is being saved or loaded.
|
||||||
class InvalidValueError < RuntimeError; end
|
class InvalidValueError < RuntimeError; end
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
# Represents a single value in save data.
|
# Represents a single value in save data.
|
||||||
# New values are added using {SaveData.register}.
|
# New values are added using {SaveData.register}.
|
||||||
class Value
|
class Value
|
||||||
@@ -24,15 +25,11 @@ module SaveData
|
|||||||
raise "No load_value defined for save value #{id.inspect}" if @load_proc.nil?
|
raise "No load_value defined for save value #{id.inspect}" if @load_proc.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calls the value's save proc and returns its value.
|
# @param value [Object] value to check
|
||||||
# @return [Object] save proc value
|
# @return [Boolean] whether the given value is valid
|
||||||
# @raise [InvalidValueError] if an invalid value is being saved
|
def valid?(value)
|
||||||
def save
|
return true if @ensured_class.nil?
|
||||||
value = @save_proc.call
|
return value.is_a?(Object.const_get(@ensured_class))
|
||||||
|
|
||||||
validate_value(value)
|
|
||||||
|
|
||||||
return value
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calls the value's load proc with the given argument passed into it.
|
# Calls the value's load proc with the given argument passed into it.
|
||||||
@@ -40,16 +37,22 @@ module SaveData
|
|||||||
# @raise [InvalidValueError] if an invalid value is being loaded
|
# @raise [InvalidValueError] if an invalid value is being loaded
|
||||||
def load(value)
|
def load(value)
|
||||||
validate_value(value)
|
validate_value(value)
|
||||||
|
|
||||||
@load_proc.call(value)
|
@load_proc.call(value)
|
||||||
@loaded = true
|
@loaded = true
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param value [Object] value to check
|
# Calls the value's save proc and returns its value.
|
||||||
# @return [Boolean] whether the given value is valid
|
# @return [Object] save proc value
|
||||||
def valid?(value)
|
# @raise [InvalidValueError] if an invalid value is being saved
|
||||||
return true if @ensured_class.nil?
|
def save
|
||||||
return value.is_a?(Object.const_get(@ensured_class))
|
value = @save_proc.call
|
||||||
|
validate_value(value)
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
# @return [Boolean] whether the value has a new game value proc defined
|
||||||
|
def has_new_game_proc?
|
||||||
|
return @new_game_value_proc.is_a?(Proc)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calls the save value's load proc with the value fetched
|
# Calls the save value's load proc with the value fetched
|
||||||
@@ -59,15 +62,9 @@ module SaveData
|
|||||||
unless self.has_new_game_proc?
|
unless self.has_new_game_proc?
|
||||||
raise "Save value #{@id.inspect} has no new_game_value defined"
|
raise "Save value #{@id.inspect} has no new_game_value defined"
|
||||||
end
|
end
|
||||||
|
|
||||||
self.load(@new_game_value_proc.call)
|
self.load(@new_game_value_proc.call)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Boolean] whether the value has a new game value proc defined
|
|
||||||
def has_new_game_proc?
|
|
||||||
return @new_game_value_proc.is_a?(Proc)
|
|
||||||
end
|
|
||||||
|
|
||||||
# @return [Boolean] whether the value should be loaded during bootup
|
# @return [Boolean] whether the value should be loaded during bootup
|
||||||
def load_in_bootup?
|
def load_in_bootup?
|
||||||
return @load_in_bootup
|
return @load_in_bootup
|
||||||
@@ -90,13 +87,22 @@ module SaveData
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Raises an {InvalidValueError} if the given value is invalid.
|
||||||
|
# @param value [Object] value to check
|
||||||
|
# @raise [InvalidValueError] if the value is invalid
|
||||||
|
def validate_value(value)
|
||||||
|
return if self.valid?(value)
|
||||||
|
raise InvalidValueError, "Save value #{@id.inspect} is not a #{@ensured_class} (#{value.class.name} given)"
|
||||||
|
end
|
||||||
|
|
||||||
# @!group Configuration
|
# @!group Configuration
|
||||||
|
|
||||||
# Defines what is saved into save data. Requires a block.
|
# If present, ensures that the value is of the given class.
|
||||||
|
# @param class_name [Symbol] class to enforce
|
||||||
# @see SaveData.register
|
# @see SaveData.register
|
||||||
def save_value(&block)
|
def ensure_class(class_name)
|
||||||
raise ArgumentError, 'No block given to save_value' unless block_given?
|
validate class_name => Symbol
|
||||||
@save_proc = block
|
@ensured_class = class_name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Defines how the loaded value is placed into a global variable.
|
# Defines how the loaded value is placed into a global variable.
|
||||||
@@ -107,10 +113,11 @@ module SaveData
|
|||||||
@load_proc = block
|
@load_proc = block
|
||||||
end
|
end
|
||||||
|
|
||||||
# If present, sets the value to be loaded during bootup.
|
# Defines what is saved into save data. Requires a block.
|
||||||
# @see SaveData.register
|
# @see SaveData.register
|
||||||
def load_in_bootup
|
def save_value(&block)
|
||||||
@load_in_bootup = true
|
raise ArgumentError, 'No block given to save_value' unless block_given?
|
||||||
|
@save_proc = block
|
||||||
end
|
end
|
||||||
|
|
||||||
# If present, defines what the value is set to at the start of a new game.
|
# If present, defines what the value is set to at the start of a new game.
|
||||||
@@ -120,12 +127,10 @@ module SaveData
|
|||||||
@new_game_value_proc = block
|
@new_game_value_proc = block
|
||||||
end
|
end
|
||||||
|
|
||||||
# If present, ensures that the value is of the given class.
|
# If present, sets the value to be loaded during bootup.
|
||||||
# @param class_name [Symbol] class to enforce
|
|
||||||
# @see SaveData.register
|
# @see SaveData.register
|
||||||
def ensure_class(class_name)
|
def load_in_bootup
|
||||||
validate class_name => Symbol
|
@load_in_bootup = true
|
||||||
@ensured_class = class_name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# If present, defines how the value should be fetched from the pre-v19
|
# If present, defines how the value should be fetched from the pre-v19
|
||||||
@@ -137,18 +142,9 @@ module SaveData
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @!endgroup
|
# @!endgroup
|
||||||
|
|
||||||
# Raises an {InvalidValueError} if the given value is invalid.
|
|
||||||
# @param value [Object] value to check
|
|
||||||
# @raise [InvalidValueError] if the value is invalid
|
|
||||||
def validate_value(value)
|
|
||||||
return if self.valid?(value)
|
|
||||||
|
|
||||||
raise InvalidValueError,
|
|
||||||
"Save value #{@id.inspect} is not a #{@ensured_class} (#{value.class.name} given)"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
# Registers a {Value} to be saved into save data.
|
# Registers a {Value} to be saved into save data.
|
||||||
# Takes a block which defines the value's saving ({Value#save_value})
|
# Takes a block which defines the value's saving ({Value#save_value})
|
||||||
# and loading ({Value#load_value}) procedures.
|
# and loading ({Value#load_value}) procedures.
|
||||||
@@ -183,11 +179,9 @@ module SaveData
|
|||||||
# @yieldself [Value]
|
# @yieldself [Value]
|
||||||
def self.register(id, &block)
|
def self.register(id, &block)
|
||||||
validate id => Symbol
|
validate id => Symbol
|
||||||
|
|
||||||
unless block_given?
|
unless block_given?
|
||||||
raise ArgumentError, 'No block given to SaveData.register'
|
raise ArgumentError, 'No block given to SaveData.register'
|
||||||
end
|
end
|
||||||
|
|
||||||
@values << Value.new(id, &block)
|
@values << Value.new(id, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -198,38 +192,6 @@ module SaveData
|
|||||||
return @values.all? { |value| value.valid?(save_data[value.id]) }
|
return @values.all? { |value| value.valid?(save_data[value.id]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Hash{Symbol => Object}] a hash representation of the save data
|
|
||||||
# @raise [InvalidValueError] if an invalid value is being saved
|
|
||||||
def self.compile
|
|
||||||
save_data = {}
|
|
||||||
@values.each { |value| save_data[value.id] = value.save }
|
|
||||||
return save_data
|
|
||||||
end
|
|
||||||
|
|
||||||
# Loads the values from the given save data by
|
|
||||||
# calling each {Value} object's {Value#load_value} proc.
|
|
||||||
# Values that are already loaded are skipped.
|
|
||||||
# If a value does not exist in the save data and has
|
|
||||||
# a {Value#new_game_value} proc defined, that value
|
|
||||||
# is loaded instead.
|
|
||||||
# @param save_data [Hash] save data to load
|
|
||||||
# @raise [InvalidValueError] if an invalid value is being loaded
|
|
||||||
def self.load_all_values(save_data)
|
|
||||||
validate save_data => Hash
|
|
||||||
|
|
||||||
load_values(save_data) { |value| !value.loaded? }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Loads each value from the given save data that has
|
|
||||||
# been set to be loaded during bootup.
|
|
||||||
# @param save_data [Hash] save data to load
|
|
||||||
# @raise [InvalidValueError] if an invalid value is being loaded
|
|
||||||
def self.load_bootup_values(save_data)
|
|
||||||
validate save_data => Hash
|
|
||||||
|
|
||||||
load_values(save_data) { |value| !value.loaded? && value.load_in_bootup? }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Loads values from the given save data.
|
# Loads values from the given save data.
|
||||||
# An optional condition can be passed.
|
# An optional condition can be passed.
|
||||||
# @param save_data [Hash] save data to load from
|
# @param save_data [Hash] save data to load from
|
||||||
@@ -246,19 +208,50 @@ module SaveData
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Loads each {Value}'s new game value, if one is defined.
|
# Loads the values from the given save data by
|
||||||
def self.load_new_game_values
|
# calling each {Value} object's {Value#load_value} proc.
|
||||||
@values.each do |value|
|
# Values that are already loaded are skipped.
|
||||||
value.load_new_game_value if value.has_new_game_proc? && !value.loaded?
|
# If a value does not exist in the save data and has
|
||||||
end
|
# a {Value#new_game_value} proc defined, that value
|
||||||
|
# is loaded instead.
|
||||||
|
# @param save_data [Hash] save data to load
|
||||||
|
# @raise [InvalidValueError] if an invalid value is being loaded
|
||||||
|
def self.load_all_values(save_data)
|
||||||
|
validate save_data => Hash
|
||||||
|
load_values(save_data) { |value| !value.loaded? }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Goes through each value with {Value#load_in_bootup} enabled and
|
# Loads each value from the given save data that has
|
||||||
# loads their new game value, if one is defined.
|
# been set to be loaded during bootup. Done when a save file exists.
|
||||||
|
# @param save_data [Hash] save data to load
|
||||||
|
# @raise [InvalidValueError] if an invalid value is being loaded
|
||||||
|
def self.load_bootup_values(save_data)
|
||||||
|
validate save_data => Hash
|
||||||
|
load_values(save_data) { |value| !value.loaded? && value.load_in_bootup? }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Goes through each value with {Value#load_in_bootup} enabled and loads their
|
||||||
|
# new game value, if one is defined. Done when no save file exists.
|
||||||
def self.initialize_bootup_values
|
def self.initialize_bootup_values
|
||||||
@values.each do |value|
|
@values.each do |value|
|
||||||
next unless value.load_in_bootup?
|
next unless value.load_in_bootup?
|
||||||
value.load_new_game_value if value.has_new_game_proc? && !value.loaded?
|
value.load_new_game_value if value.has_new_game_proc? && !value.loaded?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Loads each {Value}'s new game value, if one is defined. Done when starting a
|
||||||
|
# new game.
|
||||||
|
def self.load_new_game_values
|
||||||
|
@values.each do |value|
|
||||||
|
value.load_new_game_value if value.has_new_game_proc? && !value.loaded?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# @return [Hash{Symbol => Object}] a hash representation of the save data
|
||||||
|
# @raise [InvalidValueError] if an invalid value is being saved
|
||||||
|
def self.compile_save_hash
|
||||||
|
save_data = {}
|
||||||
|
@values.each { |value| save_data[value.id] = value.save }
|
||||||
|
return save_data
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -18,6 +18,7 @@ module SaveData
|
|||||||
game: {}
|
game: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
# Represents a conversion made to save data.
|
# Represents a conversion made to save data.
|
||||||
# New conversions are added using {SaveData.register_conversion}.
|
# New conversions are added using {SaveData.register_conversion}.
|
||||||
class Conversion
|
class Conversion
|
||||||
@@ -44,6 +45,13 @@ module SaveData
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns whether the conversion should be run with the given version.
|
||||||
|
# @param version [String] version to check
|
||||||
|
# @return [Boolean] whether the conversion should be run
|
||||||
|
def should_run?(version)
|
||||||
|
return PluginManager.compare_versions(version, @version) < 0
|
||||||
|
end
|
||||||
|
|
||||||
# Runs the conversion on the given save data.
|
# Runs the conversion on the given save data.
|
||||||
# @param save_data [Hash]
|
# @param save_data [Hash]
|
||||||
def run(save_data)
|
def run(save_data)
|
||||||
@@ -56,13 +64,6 @@ module SaveData
|
|||||||
@all_proc.call(save_data) if @all_proc.is_a?(Proc)
|
@all_proc.call(save_data) if @all_proc.is_a?(Proc)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether the conversion should be run with the given version.
|
|
||||||
# @param version [String] version to check
|
|
||||||
# @return [Boolean] whether the conversion should be run
|
|
||||||
def should_run?(version)
|
|
||||||
return PluginManager.compare_versions(version, @version) < 0
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# @!group Configuration
|
# @!group Configuration
|
||||||
@@ -83,9 +84,7 @@ module SaveData
|
|||||||
# @see SaveData.register_conversion
|
# @see SaveData.register_conversion
|
||||||
def essentials_version(version)
|
def essentials_version(version)
|
||||||
validate version => [Numeric, String]
|
validate version => [Numeric, String]
|
||||||
|
|
||||||
raise "Multiple conditions in conversion #{@id}" unless @version.nil?
|
raise "Multiple conditions in conversion #{@id}" unless @version.nil?
|
||||||
|
|
||||||
@trigger_type = :essentials
|
@trigger_type = :essentials
|
||||||
@version = version.to_s
|
@version = version.to_s
|
||||||
end
|
end
|
||||||
@@ -96,9 +95,7 @@ module SaveData
|
|||||||
# @see SaveData.register_conversion
|
# @see SaveData.register_conversion
|
||||||
def game_version(version)
|
def game_version(version)
|
||||||
validate version => [Numeric, String]
|
validate version => [Numeric, String]
|
||||||
|
|
||||||
raise "Multiple conditions in conversion #{@id}" unless @version.nil?
|
raise "Multiple conditions in conversion #{@id}" unless @version.nil?
|
||||||
|
|
||||||
@trigger_type = :game
|
@trigger_type = :game
|
||||||
@version = version.to_s
|
@version = version.to_s
|
||||||
end
|
end
|
||||||
@@ -108,13 +105,10 @@ module SaveData
|
|||||||
# @see SaveData.register_conversion
|
# @see SaveData.register_conversion
|
||||||
def to_value(value_id, &block)
|
def to_value(value_id, &block)
|
||||||
validate value_id => Symbol
|
validate value_id => Symbol
|
||||||
|
|
||||||
raise ArgumentError, 'No block given to to_value' unless block_given?
|
raise ArgumentError, 'No block given to to_value' unless block_given?
|
||||||
|
|
||||||
if @value_procs[value_id].is_a?(Proc)
|
if @value_procs[value_id].is_a?(Proc)
|
||||||
raise "Multiple to_value definitions in conversion #{@id} for #{value_id}"
|
raise "Multiple to_value definitions in conversion #{@id} for #{value_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@value_procs[value_id] = block
|
@value_procs[value_id] = block
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -122,17 +116,16 @@ module SaveData
|
|||||||
# @see SaveData.register_conversion
|
# @see SaveData.register_conversion
|
||||||
def to_all(&block)
|
def to_all(&block)
|
||||||
raise ArgumentError, 'No block given to to_all' unless block_given?
|
raise ArgumentError, 'No block given to to_all' unless block_given?
|
||||||
|
|
||||||
if @all_proc.is_a?(Proc)
|
if @all_proc.is_a?(Proc)
|
||||||
raise "Multiple to_all definitions in conversion #{@id}"
|
raise "Multiple to_all definitions in conversion #{@id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@all_proc = block
|
@all_proc = block
|
||||||
end
|
end
|
||||||
|
|
||||||
# @!endgroup
|
# @!endgroup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
# Registers a {Conversion} to occur for save data that meets the given criteria.
|
# Registers a {Conversion} to occur for save data that meets the given criteria.
|
||||||
# Two types of criteria can be defined: {Conversion#essentials_version} and
|
# Two types of criteria can be defined: {Conversion#essentials_version} and
|
||||||
# {Conversion#game_version}. The conversion is automatically run on save data
|
# {Conversion#game_version}. The conversion is automatically run on save data
|
||||||
@@ -152,20 +145,40 @@ module SaveData
|
|||||||
# save_data[:new_value] = Foo.new
|
# save_data[:new_value] = Foo.new
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
# @yieldself [Conversion]
|
# @yield self [Conversion]
|
||||||
def self.register_conversion(id, &block)
|
def self.register_conversion(id, &block)
|
||||||
validate id => Symbol
|
validate id => Symbol
|
||||||
|
|
||||||
unless block_given?
|
unless block_given?
|
||||||
raise ArgumentError, 'No block given to SaveData.register_conversion'
|
raise ArgumentError, 'No block given to SaveData.register_conversion'
|
||||||
end
|
end
|
||||||
|
|
||||||
conversion = Conversion.new(id, &block)
|
conversion = Conversion.new(id, &block)
|
||||||
|
|
||||||
@conversions[conversion.trigger_type][conversion.version] ||= []
|
@conversions[conversion.trigger_type][conversion.version] ||= []
|
||||||
@conversions[conversion.trigger_type][conversion.version] << conversion
|
@conversions[conversion.trigger_type][conversion.version] << conversion
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @param save_data [Hash] save data to get conversions for
|
||||||
|
# @return [Array<Conversion>] all conversions that should be run on the data
|
||||||
|
def self.get_conversions(save_data)
|
||||||
|
conversions_to_run = []
|
||||||
|
versions = {
|
||||||
|
essentials: save_data[:essentials_version] || '18.1',
|
||||||
|
game: save_data[:game_version] || '0.0.0'
|
||||||
|
}
|
||||||
|
[:essentials, :game].each do |trigger_type|
|
||||||
|
# Ensure the versions are sorted from lowest to highest
|
||||||
|
sorted_versions = @conversions[trigger_type].keys.sort do |v1, v2|
|
||||||
|
PluginManager.compare_versions(v1, v2)
|
||||||
|
end
|
||||||
|
sorted_versions.each do |version|
|
||||||
|
@conversions[trigger_type][version].each do |conversion|
|
||||||
|
next unless conversion.should_run?(versions[trigger_type])
|
||||||
|
conversions_to_run << conversion
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return conversions_to_run
|
||||||
|
end
|
||||||
|
|
||||||
# Runs all possible conversions on the given save data.
|
# Runs all possible conversions on the given save data.
|
||||||
# Saves a backup before running conversions.
|
# Saves a backup before running conversions.
|
||||||
# @param save_data [Hash] save data to run conversions on
|
# @param save_data [Hash] save data to run conversions on
|
||||||
@@ -173,46 +186,16 @@ module SaveData
|
|||||||
def self.run_conversions(save_data)
|
def self.run_conversions(save_data)
|
||||||
validate save_data => Hash
|
validate save_data => Hash
|
||||||
conversions_to_run = self.get_conversions(save_data)
|
conversions_to_run = self.get_conversions(save_data)
|
||||||
|
|
||||||
return false if conversions_to_run.none?
|
return false if conversions_to_run.none?
|
||||||
|
|
||||||
File.open(SaveData::FILE_PATH + '.bak', 'wb') { |f| Marshal.dump(save_data, f) }
|
File.open(SaveData::FILE_PATH + '.bak', 'wb') { |f| Marshal.dump(save_data, f) }
|
||||||
|
|
||||||
echoln "Running #{conversions_to_run.length} conversions..."
|
echoln "Running #{conversions_to_run.length} conversions..."
|
||||||
|
|
||||||
conversions_to_run.each do |conversion|
|
conversions_to_run.each do |conversion|
|
||||||
echo "#{conversion.title}..."
|
echo "#{conversion.title}..."
|
||||||
conversion.run(save_data)
|
conversion.run(save_data)
|
||||||
echoln ' done.'
|
echoln ' done.'
|
||||||
end
|
end
|
||||||
|
save_data[:essentials_version] = Essentials::VERSION
|
||||||
|
save_data[:game_version] = Settings::GAME_VERSION
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param save_data [Hash] save data to get conversions for
|
|
||||||
# @return [Array<Conversion>] all conversions that should be run on the data
|
|
||||||
def self.get_conversions(save_data)
|
|
||||||
conversions_to_run = []
|
|
||||||
|
|
||||||
versions = {
|
|
||||||
essentials: save_data[:essentials_version] || '18.1',
|
|
||||||
game: save_data[:game_version] || '0.0.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
[:essentials, :game].each do |trigger_type|
|
|
||||||
# Ensure the versions are sorted from lowest to highest
|
|
||||||
sorted_versions = @conversions[trigger_type].keys.sort do |v1, v2|
|
|
||||||
PluginManager.compare_versions(v1, v2)
|
|
||||||
end
|
|
||||||
|
|
||||||
sorted_versions.each do |version|
|
|
||||||
@conversions[trigger_type][version].each do |conversion|
|
|
||||||
next unless conversion.should_run?(versions[trigger_type])
|
|
||||||
conversions_to_run << conversion
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return conversions_to_run
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
SaveData.register_conversion(:v19_define_versions) do
|
SaveData.register_conversion(:v19_define_versions) do
|
||||||
essentials_version 19
|
essentials_version 19
|
||||||
display_title 'Defining versions in save data'
|
display_title 'Adding game version and Essentials version to save data'
|
||||||
to_all do |save_data|
|
to_all do |save_data|
|
||||||
unless save_data.has_key?(:essentials_version)
|
unless save_data.has_key?(:essentials_version)
|
||||||
save_data[:essentials_version] = Essentials::VERSION
|
save_data[:essentials_version] = Essentials::VERSION
|
||||||
@@ -15,7 +15,7 @@ end
|
|||||||
|
|
||||||
SaveData.register_conversion(:v19_convert_player) do
|
SaveData.register_conversion(:v19_convert_player) do
|
||||||
essentials_version 19
|
essentials_version 19
|
||||||
display_title 'Converting player trainer'
|
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?(PlayerTrainer)
|
||||||
# Conversion of the party is handled in PokeBattle_Trainer.copy
|
# Conversion of the party is handled in PokeBattle_Trainer.copy
|
||||||
@@ -25,7 +25,7 @@ end
|
|||||||
|
|
||||||
SaveData.register_conversion(:v19_convert_storage) do
|
SaveData.register_conversion(:v19_convert_storage) do
|
||||||
essentials_version 19
|
essentials_version 19
|
||||||
display_title 'Converting Pokémon in storage'
|
display_title 'Converting classes of Pokémon in storage'
|
||||||
to_value :storage_system do |storage|
|
to_value :storage_system do |storage|
|
||||||
storage.instance_eval do
|
storage.instance_eval do
|
||||||
for box in 0...self.maxBoxes
|
for box in 0...self.maxBoxes
|
||||||
@@ -39,9 +39,25 @@ SaveData.register_conversion(:v19_convert_storage) do
|
|||||||
end # to_value
|
end # to_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
SaveData.register_conversion(:v19_convert_bag) do
|
||||||
|
essentials_version 19
|
||||||
|
display_title 'Converting item IDs in Bag'
|
||||||
|
to_value :bag do |bag|
|
||||||
|
bag.instance_eval do
|
||||||
|
for pocket in self.pockets
|
||||||
|
for item in pocket
|
||||||
|
next if !item || !item[0] || item[0] == 0
|
||||||
|
item_data = GameData::Item.try_get(item[0])
|
||||||
|
item[0] = item_data.id if item_data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end # bag.instance_eval
|
||||||
|
end # to_value
|
||||||
|
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 'Converting global metadata'
|
display_title 'Adding encounter version variable to global metadata'
|
||||||
to_value :global_metadata do |global|
|
to_value :global_metadata do |global|
|
||||||
global.encounter_version ||= 0
|
global.encounter_version ||= 0
|
||||||
end
|
end
|
||||||
@@ -11,62 +11,46 @@ module Game
|
|||||||
$data_system = load_data('Data/System.rxdata')
|
$data_system = load_data('Data/System.rxdata')
|
||||||
pbLoadBattleAnimations
|
pbLoadBattleAnimations
|
||||||
GameData.load_all
|
GameData.load_all
|
||||||
|
|
||||||
map_file = format('Data/Map%03d.rxdata', $data_system.start_map_id)
|
map_file = format('Data/Map%03d.rxdata', $data_system.start_map_id)
|
||||||
|
|
||||||
if $data_system.start_map_id == 0 || !pbRgssExists?(map_file)
|
if $data_system.start_map_id == 0 || !pbRgssExists?(map_file)
|
||||||
raise _INTL('No starting position was set in the map editor.')
|
raise _INTL('No starting position was set in the map editor.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Loads values from the save file and runs any necessary
|
# Loads bootup data from save file (if it exists) or creates bootup data (if
|
||||||
# conversions on it.
|
# it doesn't).
|
||||||
def self.set_up_system
|
def self.set_up_system
|
||||||
SaveData.move_old_windows_save if System.platform[/Windows/]
|
SaveData.move_old_windows_save if System.platform[/Windows/]
|
||||||
|
save_data = (SaveData.exists?) ? SaveData.read_from_file(SaveData::FILE_PATH) : {}
|
||||||
if SaveData.exists?
|
|
||||||
save_data = SaveData.read_from_file(SaveData::FILE_PATH)
|
|
||||||
else
|
|
||||||
save_data = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
if !save_data.empty? && SaveData.run_conversions(save_data)
|
|
||||||
File.open(SaveData::FILE_PATH, 'wb') { |f| Marshal.dump(save_data, f) }
|
|
||||||
end
|
|
||||||
|
|
||||||
if save_data.empty?
|
if save_data.empty?
|
||||||
SaveData.initialize_bootup_values
|
SaveData.initialize_bootup_values
|
||||||
else
|
else
|
||||||
SaveData.load_bootup_values(save_data)
|
SaveData.load_bootup_values(save_data)
|
||||||
end
|
end
|
||||||
|
# Set resize factor
|
||||||
pbSetResizeFactor([$PokemonSystem.screensize, 4].min)
|
pbSetResizeFactor([$PokemonSystem.screensize, 4].min)
|
||||||
|
# Set language (and choose language if there is no save file)
|
||||||
if Settings::LANGUAGES.length >= 2
|
if Settings::LANGUAGES.length >= 2
|
||||||
$PokemonSystem.language = pbChooseLanguage if save_data.empty?
|
$PokemonSystem.language = pbChooseLanguage if save_data.empty?
|
||||||
pbLoadMessages('Data/' + Settings::LANGUAGES[$PokemonSystem.language][1])
|
pbLoadMessages('Data/' + Settings::LANGUAGES[$PokemonSystem.language][1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Saves the game. Returns whether the operation was successful.
|
# Called when starting a new game. Initializes global variables
|
||||||
# @param save_file [String] the save file path
|
# and transfers the player into the map scene.
|
||||||
# @param safe [Boolean] whether $PokemonGlobal.safesave should be set to true
|
def self.start_new
|
||||||
# @return [Boolean] whether the operation was successful
|
if $game_map && $game_map.events
|
||||||
# @raise [SaveData::InvalidValueError] if an invalid value is being saved
|
$game_map.events.each_value { |event| event.clear_starting }
|
||||||
def self.save(save_file = SaveData::FILE_PATH, safe: false)
|
|
||||||
validate save_file => String, safe => [TrueClass, FalseClass]
|
|
||||||
|
|
||||||
$PokemonGlobal.safesave = safe
|
|
||||||
$game_system.save_count += 1
|
|
||||||
$game_system.magic_number = $data_system.magic_number
|
|
||||||
begin
|
|
||||||
SaveData.save_to_file(save_file)
|
|
||||||
Graphics.frame_reset
|
|
||||||
rescue IOError, SystemCallError
|
|
||||||
$game_system.save_count -= 1
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
$game_temp.common_event_id = 0 if $game_temp
|
||||||
return true
|
$PokemonTemp.begunNewGame = true
|
||||||
|
$scene = Scene_Map.new
|
||||||
|
SaveData.load_new_game_values
|
||||||
|
$MapFactory = PokemonMapFactory.new($data_system.start_map_id)
|
||||||
|
$game_player.moveto($data_system.start_x, $data_system.start_y)
|
||||||
|
$game_player.refresh
|
||||||
|
$game_map.autoplay
|
||||||
|
$game_map.update
|
||||||
end
|
end
|
||||||
|
|
||||||
# Loads the game from the given save data and starts the map scene.
|
# Loads the game from the given save data and starts the map scene.
|
||||||
@@ -74,11 +58,8 @@ module Game
|
|||||||
# @raise [SaveData::InvalidValueError] if an invalid value is being loaded
|
# @raise [SaveData::InvalidValueError] if an invalid value is being loaded
|
||||||
def self.load(save_data)
|
def self.load(save_data)
|
||||||
validate save_data => Hash
|
validate save_data => Hash
|
||||||
|
|
||||||
SaveData.load_all_values(save_data)
|
SaveData.load_all_values(save_data)
|
||||||
|
|
||||||
self.load_map
|
self.load_map
|
||||||
|
|
||||||
pbAutoplayOnSave
|
pbAutoplayOnSave
|
||||||
$game_map.update
|
$game_map.update
|
||||||
$PokemonMap.updateMap
|
$PokemonMap.updateMap
|
||||||
@@ -117,20 +98,23 @@ module Game
|
|||||||
$PokemonEncounters.setup($game_map.map_id)
|
$PokemonEncounters.setup($game_map.map_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Called when starting a new game. Initializes global variables
|
# Saves the game. Returns whether the operation was successful.
|
||||||
# and transfers the player into the map scene.
|
# @param save_file [String] the save file path
|
||||||
def self.start_new
|
# @param safe [Boolean] whether $PokemonGlobal.safesave should be set to true
|
||||||
if $game_map && $game_map.events
|
# @return [Boolean] whether the operation was successful
|
||||||
$game_map.events.each_value { |event| event.clear_starting }
|
# @raise [SaveData::InvalidValueError] if an invalid value is being saved
|
||||||
|
def self.save(save_file = SaveData::FILE_PATH, safe: false)
|
||||||
|
validate save_file => String, safe => [TrueClass, FalseClass]
|
||||||
|
$PokemonGlobal.safesave = safe
|
||||||
|
$game_system.save_count += 1
|
||||||
|
$game_system.magic_number = $data_system.magic_number
|
||||||
|
begin
|
||||||
|
SaveData.save_to_file(save_file)
|
||||||
|
Graphics.frame_reset
|
||||||
|
rescue IOError, SystemCallError
|
||||||
|
$game_system.save_count -= 1
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
$game_temp.common_event_id = 0 if $game_temp
|
return true
|
||||||
$PokemonTemp.begunNewGame = true
|
|
||||||
$scene = Scene_Map.new
|
|
||||||
SaveData.load_new_game_values
|
|
||||||
$MapFactory = PokemonMapFactory.new($data_system.start_map_id)
|
|
||||||
$game_player.moveto($data_system.start_x, $data_system.start_y)
|
|
||||||
$game_player.refresh
|
|
||||||
$game_map.autoplay
|
|
||||||
$game_map.update
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -56,7 +56,7 @@ class PokeBattle_Trainer
|
|||||||
ret.money = trainer.money
|
ret.money = trainer.money
|
||||||
trainer.seen.each_with_index { |value, i| ret.set_seen(i) if value }
|
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.owned.each_with_index { |value, i| ret.set_owned(i) if value }
|
||||||
ret.formseen.each_with_index do |value, i|
|
trainer.formseen.each_with_index do |value, i|
|
||||||
ret.seen_forms[GameData::Species.get(i).species] = [value[0].clone, value[1].clone] if value
|
ret.seen_forms[GameData::Species.get(i).species] = [value[0].clone, value[1].clone] if value
|
||||||
end
|
end
|
||||||
trainer.formlastseen.each_with_index do |value, i|
|
trainer.formlastseen.each_with_index do |value, i|
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ MultipleForms.register(:ROTOM,{
|
|||||||
MultipleForms.register(:GIRATINA,{
|
MultipleForms.register(:GIRATINA,{
|
||||||
"getForm" => proc { |pkmn|
|
"getForm" => proc { |pkmn|
|
||||||
maps = [49,50,51,72,73] # Map IDs for Origin Forme
|
maps = [49,50,51,72,73] # Map IDs for Origin Forme
|
||||||
if pkmn.hasItem?(:GRISEOUSORB) || maps.include?($game_map.map_id)
|
if pkmn.hasItem?(:GRISEOUSORB) || ($game_map && maps.include?($game_map.map_id))
|
||||||
next 1
|
next 1
|
||||||
end
|
end
|
||||||
next 0
|
next 0
|
||||||
@@ -597,9 +597,11 @@ MultipleForms.register(:NECROZMA,{
|
|||||||
MultipleForms.register(:PIKACHU, {
|
MultipleForms.register(:PIKACHU, {
|
||||||
"getForm" => proc { |pkmn|
|
"getForm" => proc { |pkmn|
|
||||||
next if pkmn.form_simple >= 2
|
next if pkmn.form_simple >= 2
|
||||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
if $game_map
|
||||||
next 1 if map_metadata && map_metadata.town_map_position &&
|
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||||
map_metadata.town_map_position[0] == 1 # Tiall region
|
next 1 if map_metadata && map_metadata.town_map_position &&
|
||||||
|
map_metadata.town_map_position[0] == 1 # Tiall region
|
||||||
|
end
|
||||||
next 0
|
next 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -970,8 +970,9 @@ class Pokemon
|
|||||||
# @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, PlayerTrainer, NPCTrainer] Pokémon owner (the player by default)
|
||||||
# @param withMoves [Boolean] whether the Pokémon should have moves
|
# @param withMoves [TrueClass, FalseClass] whether the Pokémon should have moves
|
||||||
def initialize(species, level, owner = $Trainer, withMoves = true)
|
# @param rechech_form [TrueClass, FalseClass] whether to auto-check the form
|
||||||
|
def initialize(species, level, owner = $Trainer, withMoves = true, recheck_form = true)
|
||||||
species_data = GameData::Species.get(species)
|
species_data = GameData::Species.get(species)
|
||||||
@species = species_data.species
|
@species = species_data.species
|
||||||
@form = species_data.form
|
@form = species_data.form
|
||||||
@@ -1030,7 +1031,7 @@ class Pokemon
|
|||||||
@hp = 1
|
@hp = 1
|
||||||
@totalhp = 1
|
@totalhp = 1
|
||||||
calcStats
|
calcStats
|
||||||
if @form == 0
|
if @form == 0 && recheck_form
|
||||||
f = MultipleForms.call("getFormOnCreation", self)
|
f = MultipleForms.call("getFormOnCreation", self)
|
||||||
if f
|
if f
|
||||||
self.form = f
|
self.form = f
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class PokeBattle_Pokemon
|
|||||||
return pkmn if pkmn.is_a?(Pokemon)
|
return pkmn if pkmn.is_a?(Pokemon)
|
||||||
owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language)
|
owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language)
|
||||||
# Set level to 1 initially, as it will be recalculated later
|
# Set level to 1 initially, as it will be recalculated later
|
||||||
ret = Pokemon.new(pkmn.species, 1, owner, false)
|
ret = Pokemon.new(pkmn.species, 1, owner, false, false)
|
||||||
ret.forced_form = pkmn.forcedForm if pkmn.forcedForm
|
ret.forced_form = pkmn.forcedForm if pkmn.forcedForm
|
||||||
ret.time_form_set = pkmn.formTime
|
ret.time_form_set = pkmn.formTime
|
||||||
ret.exp = pkmn.exp
|
ret.exp = pkmn.exp
|
||||||
@@ -43,7 +43,9 @@ class PokeBattle_Pokemon
|
|||||||
ret.item = pkmn.item
|
ret.item = pkmn.item
|
||||||
ret.mail = PokemonMail.copy(pkmn.mail) if pkmn.mail
|
ret.mail = PokemonMail.copy(pkmn.mail) if pkmn.mail
|
||||||
pkmn.moves.each { |m| ret.moves.push(PBMove.copy(m)) if m && m.id > 0 }
|
pkmn.moves.each { |m| ret.moves.push(PBMove.copy(m)) if m && m.id > 0 }
|
||||||
pkmn.firstmoves.each { |m| ret.add_first_move(m) }
|
if pkmn.firstmoves
|
||||||
|
pkmn.firstmoves.each { |m| ret.add_first_move(m) }
|
||||||
|
end
|
||||||
if pkmn.ribbons
|
if pkmn.ribbons
|
||||||
pkmn.ribbons.each { |r| ret.giveRibbon(r) }
|
pkmn.ribbons.each { |r| ret.giveRibbon(r) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ class PokemonPokedexInfo_Scene
|
|||||||
mapwidth = 1+PokemonRegionMap_Scene::RIGHT-PokemonRegionMap_Scene::LEFT
|
mapwidth = 1+PokemonRegionMap_Scene::RIGHT-PokemonRegionMap_Scene::LEFT
|
||||||
GameData::Encounter.each_of_version($PokemonGlobal.encounter_version) do |enc_data|
|
GameData::Encounter.each_of_version($PokemonGlobal.encounter_version) do |enc_data|
|
||||||
next if !pbFindEncounter(enc_data.types, @species)
|
next if !pbFindEncounter(enc_data.types, @species)
|
||||||
map_metadata = GameData::MapMetadata.try_get(enc_data.id)
|
map_metadata = GameData::MapMetadata.try_get(enc_data.map)
|
||||||
mappos = (map_metadata) ? map_metadata.town_map_position : nil
|
mappos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||||
next if !mappos || mappos[0] != @region
|
next if !mappos || mappos[0] != @region
|
||||||
showpoint = true
|
showpoint = true
|
||||||
|
|||||||
@@ -819,7 +819,7 @@ class PokemonSummary_Scene
|
|||||||
if selected_move.accuracy == 0
|
if selected_move.accuracy == 0
|
||||||
textpos.push(["---", 216, 186, 1, base, shadow])
|
textpos.push(["---", 216, 186, 1, base, shadow])
|
||||||
else
|
else
|
||||||
textpos.push([sprintf("%d%", selected_move.accuracy), 216 + overlay.text_size("%").width, 186, 1, base, shadow])
|
textpos.push(["#{selected_move.accuracy}%", 216 + overlay.text_size("%").width, 186, 1, base, shadow])
|
||||||
end
|
end
|
||||||
# Draw all text
|
# Draw all text
|
||||||
pbDrawTextPositions(overlay, textpos)
|
pbDrawTextPositions(overlay, textpos)
|
||||||
|
|||||||
@@ -223,7 +223,6 @@ class PokemonLoadScreen
|
|||||||
# @return [Hash] save data
|
# @return [Hash] save data
|
||||||
def load_save_file(file_path)
|
def load_save_file(file_path)
|
||||||
save_data = SaveData.read_from_file(file_path)
|
save_data = SaveData.read_from_file(file_path)
|
||||||
|
|
||||||
unless SaveData.valid?(save_data)
|
unless SaveData.valid?(save_data)
|
||||||
if File.file?(file_path + '.bak')
|
if File.file?(file_path + '.bak')
|
||||||
pbMessage(_INTL('The save file is corrupt. A backup will be loaded.'))
|
pbMessage(_INTL('The save file is corrupt. A backup will be loaded.'))
|
||||||
@@ -233,7 +232,6 @@ class PokemonLoadScreen
|
|||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return save_data
|
return save_data
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -315,9 +313,7 @@ class PokemonLoadScreen
|
|||||||
Game.start_new
|
Game.start_new
|
||||||
return
|
return
|
||||||
when cmd_mystery_gift
|
when cmd_mystery_gift
|
||||||
pbFadeOutIn do
|
pbFadeOutIn { pbDownloadMysteryGift(@save_data[:player]) }
|
||||||
@save_data[:player] = pbDownloadMysteryGift(@save_data[:player])
|
|
||||||
end
|
|
||||||
when cmd_options
|
when cmd_options
|
||||||
pbFadeOutIn do
|
pbFadeOutIn do
|
||||||
scene = PokemonOption_Scene.new
|
scene = PokemonOption_Scene.new
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class MoveRelearner_Scene
|
|||||||
textpos.push([basedamage<=1 ? basedamage==1 ? "???" : "---" : sprintf("%d",basedamage),
|
textpos.push([basedamage<=1 ? basedamage==1 ? "???" : "---" : sprintf("%d",basedamage),
|
||||||
468,146,2,Color.new(64,64,64),Color.new(176,176,176)])
|
468,146,2,Color.new(64,64,64),Color.new(176,176,176)])
|
||||||
textpos.push([_INTL("ACCURACY"),272,178,0,Color.new(248,248,248),Color.new(0,0,0)])
|
textpos.push([_INTL("ACCURACY"),272,178,0,Color.new(248,248,248),Color.new(0,0,0)])
|
||||||
textpos.push([accuracy==0 ? "---" : sprintf("%d%",accuracy),
|
textpos.push([accuracy==0 ? "---" : "#{accuracy}%",
|
||||||
468,178,2,Color.new(64,64,64),Color.new(176,176,176)])
|
468,178,2,Color.new(64,64,64),Color.new(176,176,176)])
|
||||||
pbDrawTextPositions(overlay,textpos)
|
pbDrawTextPositions(overlay,textpos)
|
||||||
imagepos.push(["Graphics/Pictures/category",436,116,0,category*28,64,28])
|
imagepos.push(["Graphics/Pictures/category",436,116,0,category*28,64,28])
|
||||||
|
|||||||
@@ -324,7 +324,6 @@ def pbDownloadMysteryGift(trainer)
|
|||||||
pbDisposeMessageWindow(sprites["msgwindow"])
|
pbDisposeMessageWindow(sprites["msgwindow"])
|
||||||
pbDisposeSpriteHash(sprites)
|
pbDisposeSpriteHash(sprites)
|
||||||
viewport.dispose
|
viewport.dispose
|
||||||
return trainer
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -1,13 +1,3 @@
|
|||||||
# Loads data from a file "safely", similar to load_data. If an encrypted archive
|
|
||||||
# exists, the real file is deleted to ensure that the file is loaded from the
|
|
||||||
# encrypted archive.
|
|
||||||
def pbSafeLoad(file)
|
|
||||||
if safeExists?("./Game.rgssad") && safeExists?(file)
|
|
||||||
File.delete(file) rescue nil
|
|
||||||
end
|
|
||||||
return load_data(file)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbChooseLanguage
|
def pbChooseLanguage
|
||||||
commands=[]
|
commands=[]
|
||||||
for lang in Settings::LANGUAGES
|
for lang in Settings::LANGUAGES
|
||||||
|
|||||||
Reference in New Issue
Block a user