mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added new section-based format for items.txt
This commit is contained in:
@@ -14,6 +14,25 @@ module GameData
|
|||||||
DATA = {}
|
DATA = {}
|
||||||
DATA_FILENAME = "items.dat"
|
DATA_FILENAME = "items.dat"
|
||||||
|
|
||||||
|
SCHEMA = {
|
||||||
|
"Name" => [:name, "s"],
|
||||||
|
"NamePlural" => [:name_plural, "s"],
|
||||||
|
"Pocket" => [:pocket, "v"],
|
||||||
|
"Price" => [:price, "u"],
|
||||||
|
"Description" => [:description, "q"],
|
||||||
|
"FieldUse" => [:field_use, "e", {"OnPokemon" => 1, "Direct" => 2, "TM" => 3,
|
||||||
|
"HM" => 4, "OnPokemonReusable" => 5, "TR" => 6}],
|
||||||
|
"BattleUse" => [:battle_use, "e", {"OnPokemon" => 1, "OnMove" => 2, "OnBattler" => 3,
|
||||||
|
"OnFoe" => 4, "Direct" => 5, "OnPokemonReusable" => 6,
|
||||||
|
"OnMoveReusable" => 7, "OnBattlerReusable" => 8,
|
||||||
|
"OnFoeReusable" => 9, "DirectReusable" => 10}],
|
||||||
|
"Type" => [:type, "e", {"Mail" => 1, "IconMail" => 2, "SnagBall" => 3,
|
||||||
|
"PokeBall" => 4, "Berry" => 5, "KeyItem" => 6,
|
||||||
|
"EvolutionStone" => 7, "Fossil" => 8, "Apricorn" => 9,
|
||||||
|
"TypeGem" => 10, "Mulch" => 11, "MegaStone" => 12}],
|
||||||
|
"Move" => [:move, "e", :Move]
|
||||||
|
}
|
||||||
|
|
||||||
extend ClassMethodsSymbols
|
extend ClassMethodsSymbols
|
||||||
include InstanceMethods
|
include InstanceMethods
|
||||||
|
|
||||||
|
|||||||
@@ -796,30 +796,23 @@ end
|
|||||||
# Item editor
|
# Item editor
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbItemEditor
|
def pbItemEditor
|
||||||
|
field_use_array = [_INTL("Can't use in field")]
|
||||||
|
GameData::Item::SCHEMA["FieldUse"][2].each { |key, value| field_use_array[value] = key }
|
||||||
|
battle_use_array = [_INTL("Can't use in battle")]
|
||||||
|
GameData::Item::SCHEMA["BattleUse"][2].each { |key, value| battle_use_array[value] = key }
|
||||||
|
type_array = [_INTL("No special type")]
|
||||||
|
GameData::Item::SCHEMA["Type"][2].each { |key, value| type_array[value] = key }
|
||||||
item_properties = [
|
item_properties = [
|
||||||
[_INTL("Internal Name"), ReadOnlyProperty, _INTL("Internal name that is used as a symbol like :XXX.")],
|
[_INTL("ID"), ReadOnlyProperty, _INTL("ID of this item (used as a symbol like :XXX).")],
|
||||||
[_INTL("Item Name"), ItemNameProperty, _INTL("Name of the item as displayed by the game.")],
|
[_INTL("Name"), ItemNameProperty, _INTL("Name of this item as displayed by the game.")],
|
||||||
[_INTL("Item Name Plural"), ItemNameProperty, _INTL("Plural name of the item as displayed by the game.")],
|
[_INTL("NamePlural"), ItemNameProperty, _INTL("Plural name of this item as displayed by the game.")],
|
||||||
[_INTL("Pocket"), PocketProperty, _INTL("Pocket in the bag where the item is stored.")],
|
[_INTL("Pocket"), PocketProperty, _INTL("Pocket in the Bag where this item is stored.")],
|
||||||
[_INTL("Purchase price"), LimitProperty.new(999999), _INTL("Purchase price of the item.")],
|
[_INTL("Price"), LimitProperty.new(999999), _INTL("Purchase price of this item.")],
|
||||||
[_INTL("Description"), StringProperty, _INTL("Description of the item")],
|
[_INTL("Description"), StringProperty, _INTL("Description of this item")],
|
||||||
[_INTL("Use Out of Battle"), EnumProperty.new([
|
[_INTL("FieldUse"), EnumProperty.new(field_use_array), _INTL("How this item can be used outside of battle.")],
|
||||||
_INTL("Can't Use"), _INTL("On a Pokémon"), _INTL("Use directly"),
|
[_INTL("BattleUse"), EnumProperty.new(battle_use_array), _INTL("How this item can be used within a battle.")],
|
||||||
_INTL("TM"), _INTL("HM"), _INTL("On a Pokémon reusable"),
|
[_INTL("Type"), EnumProperty.new(type_array), _INTL("For special kinds of items.")],
|
||||||
_INTL("TR")]), _INTL("Specifies how this item can be used outside of battle.")],
|
[_INTL("Move"), MoveProperty, _INTL("Move taught by this HM, TM or TR.")]
|
||||||
[_INTL("Use In Battle"), EnumProperty.new([
|
|
||||||
_INTL("Can't Use"), _INTL("On a Pokémon"), _INTL("On Pokémon's move"),
|
|
||||||
_INTL("On battler"), _INTL("On foe battler"), _INTL("Use directly"),
|
|
||||||
_INTL("On a Pokémon reusable"), _INTL("On Pokémon's move reusable"),
|
|
||||||
_INTL("On battler reusable"), _INTL("On foe battler reusable"),
|
|
||||||
_INTL("Use directly reusable")]), _INTL("Specifies how this item can be used within a battle.")],
|
|
||||||
[_INTL("Special Items"), EnumProperty.new([
|
|
||||||
_INTL("None of below"), _INTL("Mail"), _INTL("Mail with Pictures"),
|
|
||||||
_INTL("Snag Ball"), _INTL("Poké Ball"), _INTL("Plantable Berry"),
|
|
||||||
_INTL("Key Item"), _INTL("Evolution Stone"), _INTL("Fossil"),
|
|
||||||
_INTL("Apricorn"), _INTL("Type-boosting Gem"), _INTL("Mulch"),
|
|
||||||
_INTL("Mega Stone")]), _INTL("For special kinds of items.")],
|
|
||||||
[_INTL("Machine"), MoveProperty, _INTL("Move taught by this TM or HM.")]
|
|
||||||
]
|
]
|
||||||
pbListScreenBlock(_INTL("Items"), ItemLister.new(0, true)) { |button, item|
|
pbListScreenBlock(_INTL("Items"), ItemLister.new(0, true)) { |button, item|
|
||||||
if item
|
if item
|
||||||
|
|||||||
@@ -292,35 +292,77 @@ module Compiler
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
def compile_items(path = "PBS/items.txt")
|
def compile_items(path = "PBS/items.txt")
|
||||||
GameData::Item::DATA.clear
|
GameData::Item::DATA.clear
|
||||||
|
schema = GameData::Item::SCHEMA
|
||||||
item_names = []
|
item_names = []
|
||||||
item_names_plural = []
|
item_names_plural = []
|
||||||
item_descriptions = []
|
item_descriptions = []
|
||||||
|
item_hash = nil
|
||||||
# Read each line of items.txt at a time and compile it into an item
|
# Read each line of items.txt at a time and compile it into an item
|
||||||
pbCompilerEachCommentedLine(path) { |line, line_no|
|
pbCompilerEachPreppedLine(path) { |line, line_no|
|
||||||
line = pbGetCsvRecord(line, line_no, [0, "snssuusuuUN"])
|
if line[/^\s*\[\s*(.+)\s*\]\s*$/] # New section [item_id]
|
||||||
item_symbol = line[1].to_sym
|
# Add previous item's data to records
|
||||||
if GameData::Item::DATA[item_symbol]
|
GameData::Item.register(item_hash) if item_hash
|
||||||
raise _INTL("Item ID '{1}' is used twice.\r\n{2}", item_symbol, FileLineData.linereport)
|
# Parse item ID
|
||||||
|
item_id = $~[1].to_sym
|
||||||
|
if GameData::Item.exists?(item_id)
|
||||||
|
raise _INTL("Item ID '{1}' is used twice.\r\n{2}", item_id, FileLineData.linereport)
|
||||||
|
end
|
||||||
|
# Construct item hash
|
||||||
|
item_hash = {
|
||||||
|
:id => item_id
|
||||||
|
}
|
||||||
|
elsif line[/^\s*(\w+)\s*=\s*(.*)\s*$/] # XXX=YYY lines
|
||||||
|
if !item_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
|
||||||
|
item_hash[line_schema[0]] = property_value
|
||||||
|
case property_name
|
||||||
|
when "Name"
|
||||||
|
item_names.push(item_hash[:name])
|
||||||
|
when "NamePlural"
|
||||||
|
item_names_plural.push(item_hash[:name_plural])
|
||||||
|
when "Description"
|
||||||
|
item_descriptions.push(item_hash[:description])
|
||||||
|
end
|
||||||
|
else # Old format
|
||||||
|
# Add previous item's data to records
|
||||||
|
GameData::Item.register(item_hash) if item_hash
|
||||||
|
# Parse item
|
||||||
|
line = pbGetCsvRecord(line, line_no, [0, "snssvusuuUE", nil, nil, nil,
|
||||||
|
nil, nil, nil, nil, nil, nil, nil, :Move])
|
||||||
|
item_id = line[1].to_sym
|
||||||
|
if GameData::Item.exists?(item_id)
|
||||||
|
raise _INTL("Item ID '{1}' is used twice.\r\n{2}", item_id, FileLineData.linereport)
|
||||||
|
end
|
||||||
|
# Construct item hash
|
||||||
|
item_hash = {
|
||||||
|
:id => item_id,
|
||||||
|
:name => line[2],
|
||||||
|
:name_plural => line[3],
|
||||||
|
:pocket => line[4],
|
||||||
|
:price => line[5],
|
||||||
|
:description => line[6],
|
||||||
|
:field_use => line[7],
|
||||||
|
:battle_use => line[8],
|
||||||
|
:type => line[9],
|
||||||
|
:move => line[10]
|
||||||
|
}
|
||||||
|
# Add item's data to records
|
||||||
|
GameData::Item.register(item_hash)
|
||||||
|
item_names.push(item_hash[:name])
|
||||||
|
item_names_plural.push(item_hash[:name_plural])
|
||||||
|
item_descriptions.push(item_hash[:description])
|
||||||
|
item_hash = nil
|
||||||
end
|
end
|
||||||
# Construct item hash
|
|
||||||
item_hash = {
|
|
||||||
:id => item_symbol,
|
|
||||||
:name => line[2],
|
|
||||||
:name_plural => line[3],
|
|
||||||
:pocket => line[4],
|
|
||||||
:price => line[5],
|
|
||||||
:description => line[6],
|
|
||||||
:field_use => line[7],
|
|
||||||
:battle_use => line[8],
|
|
||||||
:type => line[9]
|
|
||||||
}
|
|
||||||
item_hash[:move] = parseMove(line[10]) if !nil_or_empty?(line[10])
|
|
||||||
# Add item's data to records
|
|
||||||
GameData::Item.register(item_hash)
|
|
||||||
item_names.push(item_hash[:name])
|
|
||||||
item_names_plural.push(item_hash[:name_plural])
|
|
||||||
item_descriptions.push(item_hash[:description])
|
|
||||||
}
|
}
|
||||||
|
# Add last item's data to records
|
||||||
|
GameData::Item.register(item_hash) if item_hash
|
||||||
# Save all data
|
# Save all data
|
||||||
GameData::Item.save
|
GameData::Item.save
|
||||||
MessageTypes.setMessagesAsHash(MessageTypes::Items, item_names)
|
MessageTypes.setMessagesAsHash(MessageTypes::Items, item_names)
|
||||||
|
|||||||
@@ -207,27 +207,21 @@ module Compiler
|
|||||||
def write_items
|
def write_items
|
||||||
File.open("PBS/items.txt", "wb") { |f|
|
File.open("PBS/items.txt", "wb") { |f|
|
||||||
add_PBS_header_to_file(f)
|
add_PBS_header_to_file(f)
|
||||||
current_pocket = 0
|
GameData::Item.each do |item|
|
||||||
GameData::Item.each do |i|
|
f.write("\#-------------------------------\r\n")
|
||||||
if current_pocket != i.pocket
|
f.write(sprintf("[%s]\r\n", item.id))
|
||||||
current_pocket = i.pocket
|
f.write(sprintf("Name = %s\r\n", item.real_name))
|
||||||
f.write("\#-------------------------------\r\n")
|
f.write(sprintf("NamePlural = %s\r\n", item.real_name_plural))
|
||||||
end
|
f.write(sprintf("Pocket = %d\r\n", item.pocket))
|
||||||
move_name = (i.move) ? GameData::Move.get(i.move).id.to_s : ""
|
f.write(sprintf("Price = %d\r\n", item.price))
|
||||||
sprintf_text = "0,%s,%s,%s,%d,%d,%s,%d,%d,%d\r\n"
|
field_use = GameData::Item::SCHEMA["FieldUse"][2].key(item.field_use)
|
||||||
sprintf_text = "0,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s\r\n" if move_name != ""
|
f.write(sprintf("FieldUse = %s\r\n", field_use)) if field_use
|
||||||
f.write(sprintf(sprintf_text,
|
battle_use = GameData::Item::SCHEMA["BattleUse"][2].key(item.battle_use)
|
||||||
csvQuote(i.id.to_s),
|
f.write(sprintf("BattleUse = %s\r\n", battle_use)) if battle_use
|
||||||
csvQuote(i.real_name),
|
type = GameData::Item::SCHEMA["Type"][2].key(item.type)
|
||||||
csvQuote(i.real_name_plural),
|
f.write(sprintf("Type = %s\r\n", type)) if type
|
||||||
i.pocket,
|
f.write(sprintf("Move = %s\r\n", item.move)) if item.move
|
||||||
i.price,
|
f.write(sprintf("Description = %s\r\n", item.real_description))
|
||||||
csvQuoteAlways(i.real_description),
|
|
||||||
i.field_use,
|
|
||||||
i.battle_use,
|
|
||||||
i.type,
|
|
||||||
csvQuote(move_name)
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
Graphics.update
|
Graphics.update
|
||||||
|
|||||||
5701
PBS/items.txt
5701
PBS/items.txt
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user