mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Added new section-based format for moves.txt
This commit is contained in:
@@ -2,38 +2,53 @@ module GameData
|
|||||||
class Move
|
class Move
|
||||||
attr_reader :id
|
attr_reader :id
|
||||||
attr_reader :real_name
|
attr_reader :real_name
|
||||||
attr_reader :function_code
|
|
||||||
attr_reader :base_damage
|
|
||||||
attr_reader :type
|
attr_reader :type
|
||||||
attr_reader :category
|
attr_reader :category
|
||||||
|
attr_reader :base_damage
|
||||||
attr_reader :accuracy
|
attr_reader :accuracy
|
||||||
attr_reader :total_pp
|
attr_reader :total_pp
|
||||||
attr_reader :effect_chance
|
|
||||||
attr_reader :target
|
attr_reader :target
|
||||||
attr_reader :priority
|
attr_reader :priority
|
||||||
|
attr_reader :function_code
|
||||||
attr_reader :flags
|
attr_reader :flags
|
||||||
|
attr_reader :effect_chance
|
||||||
attr_reader :real_description
|
attr_reader :real_description
|
||||||
|
|
||||||
DATA = {}
|
DATA = {}
|
||||||
DATA_FILENAME = "moves.dat"
|
DATA_FILENAME = "moves.dat"
|
||||||
|
|
||||||
|
SCHEMA = {
|
||||||
|
"Name" => [:name, "s"],
|
||||||
|
"Type" => [:type, "e", :Type],
|
||||||
|
"Category" => [:category, "e", ["Physical", "Special", "Status"]],
|
||||||
|
"BaseDamage" => [:base_damage, "u"],
|
||||||
|
"Accuracy" => [:accuracy, "u"],
|
||||||
|
"TotalPP" => [:total_pp, "u"],
|
||||||
|
"Target" => [:target, "e", :Target],
|
||||||
|
"Priority" => [:priority, "i"],
|
||||||
|
"FunctionCode" => [:function_code, "s"],
|
||||||
|
"Flags" => [:flags, "s"],
|
||||||
|
"EffectChance" => [:effect_chance, "u"],
|
||||||
|
"Description" => [:description, "q"]
|
||||||
|
}
|
||||||
|
|
||||||
extend ClassMethodsSymbols
|
extend ClassMethodsSymbols
|
||||||
include InstanceMethods
|
include InstanceMethods
|
||||||
|
|
||||||
def initialize(hash)
|
def initialize(hash)
|
||||||
@id = hash[:id]
|
@id = hash[:id]
|
||||||
@real_name = hash[:name] || "Unnamed"
|
@real_name = hash[:name] || "Unnamed"
|
||||||
@function_code = hash[:function_code]
|
@type = hash[:type] || :NONE
|
||||||
@base_damage = hash[:base_damage]
|
@category = hash[:category] || 2
|
||||||
@type = hash[:type]
|
@base_damage = hash[:base_damage] || 0
|
||||||
@category = hash[:category]
|
@accuracy = hash[:accuracy] || 100
|
||||||
@accuracy = hash[:accuracy]
|
@total_pp = hash[:total_pp] || 5
|
||||||
@total_pp = hash[:total_pp]
|
@target = hash[:target] || :None
|
||||||
@effect_chance = hash[:effect_chance]
|
@priority = hash[:priority] || 0
|
||||||
@target = hash[:target]
|
@function_code = hash[:function_code] || "000"
|
||||||
@priority = hash[:priority]
|
@flags = hash[:flags] || ""
|
||||||
@flags = hash[:flags]
|
@effect_chance = hash[:effect_chance] || 0
|
||||||
@real_description = hash[:description] || "???"
|
@real_description = hash[:description] || "???"
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [String] the translated name of this move
|
# @return [String] the translated name of this move
|
||||||
|
|||||||
@@ -240,46 +240,112 @@ module Compiler
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
def compile_moves(path = "PBS/moves.txt")
|
def compile_moves(path = "PBS/moves.txt")
|
||||||
GameData::Move::DATA.clear
|
GameData::Move::DATA.clear
|
||||||
|
schema = GameData::Move::SCHEMA
|
||||||
move_names = []
|
move_names = []
|
||||||
move_descriptions = []
|
move_descriptions = []
|
||||||
|
move_hash = nil
|
||||||
# Read each line of moves.txt at a time and compile it into an move
|
# Read each line of moves.txt at a time and compile it into an move
|
||||||
pbCompilerEachPreppedLine(path) { |line, line_no|
|
pbCompilerEachPreppedLine(path) { |line, line_no|
|
||||||
line = pbGetCsvRecord(line, line_no, [0, "snssueeuuueiss",
|
if line[/^\s*\[\s*(.+)\s*\]\s*$/] # New section [move_id]
|
||||||
nil, nil, nil, nil, nil, :Type, ["Physical", "Special", "Status"],
|
# Add previous move's data to records
|
||||||
nil, nil, nil, :Target, nil, nil, nil
|
if move_hash
|
||||||
])
|
# Sanitise data
|
||||||
move_symbol = line[1].to_sym
|
if (move_hash[:category] || 2) == 2 && (move_hash[:base_damage] || 0) != 0
|
||||||
if GameData::Move::DATA[move_symbol]
|
raise _INTL("Move {1} is defined as a Status move with a non-zero base damage.\r\n{2}", line[2], FileLineData.linereport)
|
||||||
raise _INTL("Move ID '{1}' is used twice.\r\n{2}", move_symbol, FileLineData.linereport)
|
elsif (move_hash[:category] || 2) != 2 && (move_hash[:base_damage] || 0) == 0
|
||||||
|
print _INTL("Warning: Move {1} was defined as Physical or Special but had a base damage of 0. Changing it to a Status move.\r\n{2}", line[2], FileLineData.linereport)
|
||||||
|
move_hash[:category] = 2
|
||||||
|
end
|
||||||
|
GameData::Move.register(move_hash)
|
||||||
|
end
|
||||||
|
# Parse move ID
|
||||||
|
move_id = $~[1].to_sym
|
||||||
|
if GameData::Move.exists?(move_id)
|
||||||
|
raise _INTL("Move ID '{1}' is used twice.\r\n{2}", move_id, FileLineData.linereport)
|
||||||
|
end
|
||||||
|
# Construct move hash
|
||||||
|
move_hash = {
|
||||||
|
:id => move_id
|
||||||
|
}
|
||||||
|
elsif line[/^\s*(\w+)\s*=\s*(.*)\s*$/] # XXX=YYY lines
|
||||||
|
if !move_hash
|
||||||
|
raise _INTL("Expected a section at the beginning of the file.\r\n{1}", FileLineData.linereport)
|
||||||
|
end
|
||||||
|
# Parse property and value
|
||||||
|
property_name = $~[1]
|
||||||
|
line_schema = schema[property_name]
|
||||||
|
next if !line_schema
|
||||||
|
property_value = pbGetCsvRecord($~[2], line_no, line_schema)
|
||||||
|
# Record XXX=YYY setting
|
||||||
|
move_hash[line_schema[0]] = property_value
|
||||||
|
case property_name
|
||||||
|
when "Name"
|
||||||
|
move_names.push(move_hash[:name])
|
||||||
|
when "Description"
|
||||||
|
move_descriptions.push(move_hash[:description])
|
||||||
|
end
|
||||||
|
else # Old format
|
||||||
|
# Add previous move's data to records
|
||||||
|
if move_hash
|
||||||
|
# Sanitise data
|
||||||
|
if (move_hash[:category] || 2) == 2 && (move_hash[:base_damage] || 0) != 0
|
||||||
|
raise _INTL("Move {1} is defined as a Status move with a non-zero base damage.\r\n{2}", line[2], FileLineData.linereport)
|
||||||
|
elsif (move_hash[:category] || 2) != 2 && (move_hash[:base_damage] || 0) == 0
|
||||||
|
print _INTL("Warning: Move {1} was defined as Physical or Special but had a base damage of 0. Changing it to a Status move.\r\n{2}", line[2], FileLineData.linereport)
|
||||||
|
move_hash[:category] = 2
|
||||||
|
end
|
||||||
|
GameData::Move.register(move_hash)
|
||||||
|
end
|
||||||
|
# Parse move
|
||||||
|
line = pbGetCsvRecord(line, line_no, [0, "snssueeuuueiss",
|
||||||
|
nil, nil, nil, nil, nil, :Type, ["Physical", "Special", "Status"],
|
||||||
|
nil, nil, nil, :Target, nil, nil, nil
|
||||||
|
])
|
||||||
|
move_id = line[1].to_sym
|
||||||
|
if GameData::Move::DATA[move_id]
|
||||||
|
raise _INTL("Move ID '{1}' is used twice.\r\n{2}", move_id, FileLineData.linereport)
|
||||||
|
end
|
||||||
|
# Sanitise data
|
||||||
|
if line[6] == 2 && line[4] != 0
|
||||||
|
raise _INTL("Move {1} is defined as a Status move with a non-zero base damage.\r\n{2}", line[2], FileLineData.linereport)
|
||||||
|
elsif line[6] != 2 && line[4] == 0
|
||||||
|
print _INTL("Warning: Move {1} was defined as Physical or Special but had a base damage of 0. Changing it to a Status move.\r\n{2}", line[2], FileLineData.linereport)
|
||||||
|
line[6] = 2
|
||||||
|
end
|
||||||
|
# Construct move hash
|
||||||
|
move_hash = {
|
||||||
|
:id => move_id,
|
||||||
|
:name => line[2],
|
||||||
|
:function_code => line[3],
|
||||||
|
:base_damage => line[4],
|
||||||
|
:type => line[5],
|
||||||
|
:category => line[6],
|
||||||
|
:accuracy => line[7],
|
||||||
|
:total_pp => line[8],
|
||||||
|
:effect_chance => line[9],
|
||||||
|
:target => line[10],
|
||||||
|
:priority => line[11],
|
||||||
|
:flags => line[12],
|
||||||
|
:description => line[13]
|
||||||
|
}
|
||||||
|
# Add move's data to records
|
||||||
|
GameData::Move.register(move_hash)
|
||||||
|
move_names.push(move_hash[:name])
|
||||||
|
move_descriptions.push(move_hash[:description])
|
||||||
|
move_hash = nil
|
||||||
end
|
end
|
||||||
# Sanitise data
|
|
||||||
if line[6] == 2 && line[4] != 0
|
|
||||||
raise _INTL("Move {1} is defined as a Status move with a non-zero base damage.\r\n{2}", line[2], FileLineData.linereport)
|
|
||||||
elsif line[6] != 2 && line[4] == 0
|
|
||||||
print _INTL("Warning: Move {1} was defined as Physical or Special but had a base damage of 0. Changing it to a Status move.\r\n{2}", line[2], FileLineData.linereport)
|
|
||||||
line[6] = 2
|
|
||||||
end
|
|
||||||
# Construct move hash
|
|
||||||
move_hash = {
|
|
||||||
:id => move_symbol,
|
|
||||||
:name => line[2],
|
|
||||||
:function_code => line[3],
|
|
||||||
:base_damage => line[4],
|
|
||||||
:type => line[5],
|
|
||||||
:category => line[6],
|
|
||||||
:accuracy => line[7],
|
|
||||||
:total_pp => line[8],
|
|
||||||
:effect_chance => line[9],
|
|
||||||
:target => line[10],
|
|
||||||
:priority => line[11],
|
|
||||||
:flags => line[12],
|
|
||||||
:description => line[13]
|
|
||||||
}
|
|
||||||
# Add move's data to records
|
|
||||||
GameData::Move.register(move_hash)
|
|
||||||
move_names.push(move_hash[:name])
|
|
||||||
move_descriptions.push(move_hash[:description])
|
|
||||||
}
|
}
|
||||||
|
# Add last move's data to records
|
||||||
|
if move_hash
|
||||||
|
# Sanitise data
|
||||||
|
if (move_hash[:category] || 2) == 2 && (move_hash[:base_damage] || 0) != 0
|
||||||
|
raise _INTL("Move {1} is defined as a Status move with a non-zero base damage.\r\n{2}", line[2], FileLineData.linereport)
|
||||||
|
elsif (move_hash[:category] || 2) != 2 && (move_hash[:base_damage] || 0) == 0
|
||||||
|
print _INTL("Warning: Move {1} was defined as Physical or Special but had a base damage of 0. Changing it to a Status move.\r\n{2}", line[2], FileLineData.linereport)
|
||||||
|
move_hash[:category] = 2
|
||||||
|
end
|
||||||
|
GameData::Move.register(move_hash)
|
||||||
|
end
|
||||||
# Save all data
|
# Save all data
|
||||||
GameData::Move.save
|
GameData::Move.save
|
||||||
MessageTypes.setMessagesAsHash(MessageTypes::Moves, move_names)
|
MessageTypes.setMessagesAsHash(MessageTypes::Moves, move_names)
|
||||||
|
|||||||
@@ -175,27 +175,23 @@ module Compiler
|
|||||||
def write_moves
|
def write_moves
|
||||||
File.open("PBS/moves.txt", "wb") { |f|
|
File.open("PBS/moves.txt", "wb") { |f|
|
||||||
add_PBS_header_to_file(f)
|
add_PBS_header_to_file(f)
|
||||||
current_type = -1
|
# Write each move in turn
|
||||||
GameData::Move.each do |m|
|
GameData::Move.each do |move|
|
||||||
if current_type != m.type
|
f.write("\#-------------------------------\r\n")
|
||||||
current_type = m.type
|
f.write("[#{move.id}]\r\n")
|
||||||
f.write("\#-------------------------------\r\n")
|
f.write("Name = #{move.real_name}\r\n")
|
||||||
end
|
f.write("Type = #{move.type}\r\n")
|
||||||
f.write(sprintf("0,%s,%s,%s,%d,%s,%s,%d,%d,%d,%s,%d,%s,%s\r\n",
|
category = GameData::Move::SCHEMA["Category"][2][move.category]
|
||||||
csvQuote(m.id.to_s),
|
f.write("Category = #{category}\r\n")
|
||||||
csvQuote(m.real_name),
|
f.write("BaseDamage = #{move.base_damage}\r\n") if move.base_damage > 0
|
||||||
csvQuote(m.function_code),
|
f.write("Accuracy = #{move.accuracy}\r\n")
|
||||||
m.base_damage,
|
f.write("TotalPP = #{move.total_pp}\r\n")
|
||||||
m.type.to_s,
|
f.write("Target = #{move.target}\r\n")
|
||||||
["Physical", "Special", "Status"][m.category],
|
f.write("Priority = #{move.priority}\r\n") if move.priority != 0
|
||||||
m.accuracy,
|
f.write("FunctionCode = #{move.function_code}\r\n")
|
||||||
m.total_pp,
|
f.write("Flags = #{move.flags}\r\n") if !nil_or_empty?(move.flags)
|
||||||
m.effect_chance,
|
f.write("EffectChance = #{move.effect_chance}\r\n") if move.effect_chance > 0
|
||||||
m.target,
|
f.write("Description = #{move.real_description}\r\n")
|
||||||
m.priority,
|
|
||||||
csvQuote(m.flags),
|
|
||||||
csvQuoteAlways(m.real_description)
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
Graphics.update
|
Graphics.update
|
||||||
|
|||||||
7183
PBS/Gen 5/moves.txt
7183
PBS/Gen 5/moves.txt
File diff suppressed because it is too large
Load Diff
5701
PBS/Gen 7/items.txt
5701
PBS/Gen 7/items.txt
File diff suppressed because it is too large
Load Diff
8672
PBS/Gen 7/moves.txt
8672
PBS/Gen 7/moves.txt
File diff suppressed because it is too large
Load Diff
8672
PBS/moves.txt
8672
PBS/moves.txt
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user