mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Added Compiler code to make simple text replacements in PBS files before they are compiled
This commit is contained in:
@@ -4,6 +4,7 @@ module GameData
|
||||
attr_reader :real_name
|
||||
attr_reader :type
|
||||
attr_reader :category
|
||||
# TODO: Rename base_damage to power everywhere.
|
||||
attr_reader :base_damage
|
||||
attr_reader :accuracy
|
||||
attr_reader :total_pp
|
||||
@@ -21,7 +22,7 @@ module GameData
|
||||
"Name" => [:name, "s"],
|
||||
"Type" => [:type, "e", :Type],
|
||||
"Category" => [:category, "e", ["Physical", "Special", "Status"]],
|
||||
"BaseDamage" => [:base_damage, "u"],
|
||||
"Power" => [:base_damage, "u"],
|
||||
"Accuracy" => [:accuracy, "u"],
|
||||
"TotalPP" => [:total_pp, "u"],
|
||||
"Target" => [:target, "e", :Target],
|
||||
@@ -29,7 +30,10 @@ module GameData
|
||||
"FunctionCode" => [:function_code, "s"],
|
||||
"Flags" => [:flags, "*s"],
|
||||
"EffectChance" => [:effect_chance, "u"],
|
||||
"Description" => [:description, "q"]
|
||||
"Description" => [:description, "q"],
|
||||
# All properties below here are old names for some properties above.
|
||||
# They will be removed in v21.
|
||||
"BaseDamage" => [:base_damage, "u"]
|
||||
}
|
||||
|
||||
extend ClassMethodsSymbols
|
||||
|
||||
@@ -707,6 +707,34 @@ module Compiler
|
||||
return typ.id
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Replace text in PBS files before compiling them
|
||||
#=============================================================================
|
||||
def edit_and_rewrite_pbs_file_text(filename)
|
||||
return if !block_given?
|
||||
lines = []
|
||||
File.open(filename, "rb") { |f|
|
||||
f.each_line { |line| lines.push(line) }
|
||||
}
|
||||
changed = false
|
||||
lines.each { |line| changed = true if yield line }
|
||||
if changed
|
||||
Console.markup_style("Changes made to file #{filename}.", text: :yellow)
|
||||
File.open(filename, "wb") { |f|
|
||||
lines.each { |line| f.write(line) }
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def modify_pbs_file_contents_before_compiling
|
||||
edit_and_rewrite_pbs_file_text("PBS/trainer_types.txt") do |line|
|
||||
next line.gsub!(/^\s*VictoryME\s*=/, "VictoryBGM =")
|
||||
end
|
||||
edit_and_rewrite_pbs_file_text("PBS/moves.txt") do |line|
|
||||
next line.gsub!(/^\s*BaseDamage\s*=/, "Power =")
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Compile all data
|
||||
#=============================================================================
|
||||
@@ -726,6 +754,7 @@ module Compiler
|
||||
end
|
||||
|
||||
def compile_pbs_files
|
||||
modify_pbs_file_contents_before_compiling
|
||||
compile_town_map
|
||||
compile_connections
|
||||
compile_phone
|
||||
|
||||
Reference in New Issue
Block a user