mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added new section-based format for abilities.txt
This commit is contained in:
@@ -10,6 +10,11 @@ module GameData
|
|||||||
extend ClassMethodsSymbols
|
extend ClassMethodsSymbols
|
||||||
include InstanceMethods
|
include InstanceMethods
|
||||||
|
|
||||||
|
SCHEMA = {
|
||||||
|
"Name" => [:name, "s"],
|
||||||
|
"Description" => [:description, "q"]
|
||||||
|
}
|
||||||
|
|
||||||
def initialize(hash)
|
def initialize(hash)
|
||||||
@id = hash[:id]
|
@id = hash[:id]
|
||||||
@real_name = hash[:name] || "Unnamed"
|
@real_name = hash[:name] || "Unnamed"
|
||||||
|
|||||||
@@ -209,17 +209,52 @@ module Compiler
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
def compile_abilities(path = "PBS/abilities.txt")
|
def compile_abilities(path = "PBS/abilities.txt")
|
||||||
GameData::Ability::DATA.clear
|
GameData::Ability::DATA.clear
|
||||||
|
schema = GameData::Ability::SCHEMA
|
||||||
ability_names = []
|
ability_names = []
|
||||||
ability_descriptions = []
|
ability_descriptions = []
|
||||||
|
ability_hash = nil
|
||||||
pbCompilerEachPreppedLine(path) { |line, line_no|
|
pbCompilerEachPreppedLine(path) { |line, line_no|
|
||||||
line = pbGetCsvRecord(line, line_no, [0, "snss"])
|
if line[/^\s*\[\s*(.+)\s*\]\s*$/] # New section [ability_id]
|
||||||
ability_symbol = line[1].to_sym
|
# Add previous ability's data to records
|
||||||
if GameData::Ability::DATA[ability_symbol]
|
GameData::Ability.register(ability_hash) if ability_hash
|
||||||
raise _INTL("Ability ID '{1}' is used twice.\r\n{2}", ability_symbol, FileLineData.linereport)
|
# Parse ability ID
|
||||||
|
ability_id = $~[1].to_sym
|
||||||
|
if GameData::Ability.exists?(ability_id)
|
||||||
|
raise _INTL("Ability ID '{1}' is used twice.\r\n{2}", ability_id, FileLineData.linereport)
|
||||||
end
|
end
|
||||||
# Construct ability hash
|
# Construct ability hash
|
||||||
ability_hash = {
|
ability_hash = {
|
||||||
:id => ability_symbol,
|
:id => ability_id
|
||||||
|
}
|
||||||
|
elsif line[/^\s*(\w+)\s*=\s*(.*)\s*$/] # XXX=YYY lines
|
||||||
|
if !ability_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
|
||||||
|
ability_hash[line_schema[0]] = property_value
|
||||||
|
case property_name
|
||||||
|
when "Name"
|
||||||
|
ability_names.push(ability_hash[:name])
|
||||||
|
when "Description"
|
||||||
|
ability_descriptions.push(ability_hash[:description])
|
||||||
|
end
|
||||||
|
else # Old format
|
||||||
|
# Add previous ability's data to records
|
||||||
|
GameData::Ability.register(ability_hash) if ability_hash
|
||||||
|
# Parse ability
|
||||||
|
line = pbGetCsvRecord(line, line_no, [0, "snss"])
|
||||||
|
ability_id = line[1].to_sym
|
||||||
|
if GameData::Ability::DATA[ability_id]
|
||||||
|
raise _INTL("Ability ID '{1}' is used twice.\r\n{2}", ability_id, FileLineData.linereport)
|
||||||
|
end
|
||||||
|
# Construct ability hash
|
||||||
|
ability_hash = {
|
||||||
|
:id => ability_id,
|
||||||
:name => line[2],
|
:name => line[2],
|
||||||
:description => line[3]
|
:description => line[3]
|
||||||
}
|
}
|
||||||
@@ -227,7 +262,11 @@ module Compiler
|
|||||||
GameData::Ability.register(ability_hash)
|
GameData::Ability.register(ability_hash)
|
||||||
ability_names.push(ability_hash[:name])
|
ability_names.push(ability_hash[:name])
|
||||||
ability_descriptions.push(ability_hash[:description])
|
ability_descriptions.push(ability_hash[:description])
|
||||||
|
ability_hash = nil
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
# Add last ability's data to records
|
||||||
|
GameData::Ability.register(ability_hash) if ability_hash
|
||||||
# Save all data
|
# Save all data
|
||||||
GameData::Ability.save
|
GameData::Ability.save
|
||||||
MessageTypes.setMessagesAsHash(MessageTypes::Abilities, ability_names)
|
MessageTypes.setMessagesAsHash(MessageTypes::Abilities, ability_names)
|
||||||
|
|||||||
@@ -157,13 +157,12 @@ module Compiler
|
|||||||
def write_abilities
|
def write_abilities
|
||||||
File.open("PBS/abilities.txt", "wb") { |f|
|
File.open("PBS/abilities.txt", "wb") { |f|
|
||||||
add_PBS_header_to_file(f)
|
add_PBS_header_to_file(f)
|
||||||
|
# Write each ability in turn
|
||||||
|
GameData::Ability.each do |ability|
|
||||||
f.write("\#-------------------------------\r\n")
|
f.write("\#-------------------------------\r\n")
|
||||||
GameData::Ability.each do |a|
|
f.write("[#{ability.id}]\r\n")
|
||||||
f.write(sprintf("0,%s,%s,%s\r\n",
|
f.write("Name = #{ability.real_name}\r\n")
|
||||||
csvQuote(a.id.to_s),
|
f.write("Description = #{ability.real_description}\r\n")
|
||||||
csvQuote(a.real_name),
|
|
||||||
csvQuoteAlways(a.real_description)
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
Graphics.update
|
Graphics.update
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
1164
PBS/abilities.txt
1164
PBS/abilities.txt
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user