mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added conversion of things in Game Variables in save data, renamed some files
This commit is contained in:
@@ -64,6 +64,13 @@ 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
|
||||||
|
|
||||||
|
# Runs the conversion on the given object.
|
||||||
|
# @param object
|
||||||
|
# @param key [Symbol]
|
||||||
|
def run_single(object, key)
|
||||||
|
@value_procs[key].call(object) if @value_procs[key].is_a?(Proc)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# @!group Configuration
|
# @!group Configuration
|
||||||
@@ -198,4 +205,16 @@ module SaveData
|
|||||||
save_data[:game_version] = Settings::GAME_VERSION
|
save_data[:game_version] = Settings::GAME_VERSION
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Runs all possible conversions on the given object.
|
||||||
|
# @param object [Hash] object to run conversions on
|
||||||
|
# @param key [Hash] object's key in save data
|
||||||
|
# @param save_data [Hash] save data to run conversions on
|
||||||
|
def self.run_single_conversions(object, key, save_data)
|
||||||
|
validate key => Symbol
|
||||||
|
conversions_to_run = self.get_conversions(save_data)
|
||||||
|
conversions_to_run.each do |conversion|
|
||||||
|
conversion.run_single(object, key)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -173,6 +173,27 @@ SaveData.register_conversion(:v19_convert_bag) do
|
|||||||
end # to_value
|
end # to_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
SaveData.register_conversion(:v19_convert_game_variables) do
|
||||||
|
essentials_version 19
|
||||||
|
display_title 'Converting classes of things in Game Variables'
|
||||||
|
to_all do |save_data|
|
||||||
|
variables = save_data[:variables]
|
||||||
|
variables.each_with_index do |value, i|
|
||||||
|
if value.is_a?(Array)
|
||||||
|
value.each_with_index do |value2, j|
|
||||||
|
if value2.is_a?(PokeBattle_Pokemon)
|
||||||
|
value[j] = PokeBattle_Pokemon.convert(value2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elsif value.is_a?(PokeBattle_Pokemon)
|
||||||
|
variables[i] = PokeBattle_Pokemon.convert(value)
|
||||||
|
elsif value.is_a?(PokemonBag)
|
||||||
|
SaveData.run_single_conversions(value, :bag, save_data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
SaveData.register_conversion(:v19_convert_storage) do
|
SaveData.register_conversion(:v19_convert_storage) do
|
||||||
essentials_version 19
|
essentials_version 19
|
||||||
display_title 'Converting classes of Pokémon in storage'
|
display_title 'Converting classes of Pokémon in storage'
|
||||||
|
|||||||
Reference in New Issue
Block a user