Automated proper enumeration of constants in GameData modules

This commit is contained in:
Maruno17
2020-12-12 21:50:33 +00:00
parent 9ceda78d37
commit 508b3fdf50
2 changed files with 4 additions and 6 deletions

View File

@@ -788,7 +788,7 @@ def pbSavePokemonData
has_param = !PBEvolution.hasFunction?(method, "parameterType") || param_type != nil
if has_param
if param_type
if [:Ability, :Item, :Move, :TrainerType, :Type].include?(param_type)
if GameData.const_defined?(param_type.to_sym)
pokedata.write("#{parameter.to_s}")
else
cparameter = (getConstantName(param_type, parameter) rescue parameter)
@@ -1236,7 +1236,7 @@ def pbSavePokemonFormsData
has_param = !PBEvolution.hasFunction?(method, "parameterType") || param_type != nil
if has_param
if param_type
if [:Ability, :Item, :Move, :TrainerType, :Type].include?(param_type)
if GameData.const_defined?(param_type.to_sym)
pokedata.write("#{parameter.to_s}")
else
cparameter = (getConstantName(param_type, parameter) rescue parameter)

View File

@@ -311,7 +311,7 @@ module Compiler
end
return enumer.const_get(ret.to_sym)
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
if [:Ability, :Item, :Move, :TrainerType, :Type].include?(enumer)
if GameData.const_defined?(enumer.to_sym)
enumer = GameData.const_get(enumer.to_sym)
begin
if ret == "" || !enumer.exists?(ret.to_sym)
@@ -322,7 +322,6 @@ module Compiler
end
return ret.to_sym
end
enumer = Object.const_get(enumer.to_sym)
begin
if ret=="" || !enumer.const_defined?(ret)
@@ -353,12 +352,11 @@ module Compiler
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
return enumer.const_get(ret.to_sym)
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
if [:Ability, :Item, :Move, :TrainerType, :Type].include?(enumer)
if GameData.const_defined?(enumer.to_sym)
enumer = GameData.const_get(enumer.to_sym)
return nil if ret == "" || !enumer.exists?(ret.to_sym)
return ret.to_sym
end
enumer = Object.const_get(enumer.to_sym)
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
return enumer.const_get(ret.to_sym)