Removed all uses of ID numbers for species, some other code changes for abolishing ID numbers

This commit is contained in:
Maruno17
2021-06-16 22:42:20 +01:00
parent 8c67127f06
commit e9457a3ea8
22 changed files with 965 additions and 1750 deletions

View File

@@ -114,8 +114,13 @@ module GameData
return self::DATA.keys
end
# Yields all data in alphabetical order.
# Yields all data in the order they were defined.
def each
self::DATA.each_value { |value| yield value }
end
# Yields all data in alphabetical order.
def each_alphabetically
keys = self::DATA.keys.sort { |a, b| self::DATA[a].real_name <=> self::DATA[b].real_name }
keys.each { |key| yield self::DATA[key] }
end

View File

@@ -1,7 +1,6 @@
module GameData
class Type
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :special_type
attr_reader :pseudo_type
@@ -27,10 +26,6 @@ module GameData
extend ClassMethodsSymbols
include InstanceMethods
def self.each
DATA.each_value { |type| yield type }
end
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"

View File

@@ -1,7 +1,6 @@
module GameData
class Species
attr_reader :id
attr_reader :id_number
attr_reader :species
attr_reader :form
attr_reader :real_name
@@ -51,9 +50,13 @@ module GameData
DATA = {}
DATA_FILENAME = "species.dat"
extend ClassMethods
extend ClassMethodsSymbols
include InstanceMethods
def self.each_species
DATA.each_value { |species| yield species if species.form == 0 }
end
# @param species [Symbol, self, String, Integer]
# @param form [Integer]
# @return [self, nil]
@@ -128,7 +131,6 @@ module GameData
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number] || -1
@species = hash[:species] || @id
@form = hash[:form] || 0
@real_name = hash[:name] || "Unnamed"
@@ -182,22 +184,22 @@ module GameData
# @return [String] the translated name of this species
def name
return pbGetMessage(MessageTypes::Species, @id_number)
return pbGetMessageFromHash(MessageTypes::Species, @real_name)
end
# @return [String] the translated name of this form of this species
def form_name
return pbGetMessage(MessageTypes::FormNames, @id_number)
return pbGetMessageFromHash(MessageTypes::FormNames, @real_form_name)
end
# @return [String] the translated Pokédex category of this species
def category
return pbGetMessage(MessageTypes::Kinds, @id_number)
return pbGetMessageFromHash(MessageTypes::Kinds, @real_category)
end
# @return [String] the translated Pokédex entry of this species
def pokedex_entry
return pbGetMessage(MessageTypes::Entries, @id_number)
return pbGetMessageFromHash(MessageTypes::Entries, @real_pokedex_entry)
end
def apply_metrics_to_sprite(sprite, index, shadow = false)
@@ -234,7 +236,7 @@ module GameData
def get_family_evolutions(exclude_invalid = true)
evos = self.get_evolutions(exclude_invalid)
evos = evos.sort { |a, b| GameData::Species.get(a[0]).id_number <=> GameData::Species.get(b[0]).id_number }
evos = evos.sort { |a, b| GameData::Species.keys.index(a[0]) <=> GameData::Species.keys.index(b[0]) }
ret = []
evos.each do |evo|
ret.push([@species].concat(evo)) # [Prevo species, evo species, method, parameter]

View File

@@ -134,9 +134,10 @@ module GameData
pkmn.shiny = (pkmn_data[:shininess]) ? true : false
if pkmn_data[:nature]
pkmn.nature = pkmn_data[:nature]
else
nature = pkmn.species_data.id_number + GameData::TrainerType.get(trainer.trainer_type).id_number
pkmn.nature = nature % (GameData::Nature::DATA.length / 2)
else # Make the nature random but consistent for the same species used by the same trainer type
species_num = GameData::Species.keys.index(species) || 1
tr_type_num = GameData::TrainerType.keys.index(@trainer_type) || 1
pkmn.nature = (species_num + tr_type_num) % (GameData::Nature::DATA.length / 2)
end
GameData::Stat.each_main do |s|
if pkmn_data[:iv]

View File

@@ -78,7 +78,7 @@ class Player < Trainer
def seen_any?(dex = -1)
validate dex => Integer
if dex == -1
GameData::Species.each { |s| return true if s.form == 0 && @seen[s.species] }
GameData::Species.each_species { |s| return true if @seen[s.species] }
else
pbAllRegionalSpecies(dex).each { |s| return true if s && @seen[s] }
end
@@ -269,7 +269,7 @@ class Player < Trainer
def count_species(hash, region = -1)
ret = 0
if region == -1
GameData::Species.each { |s| ret += 1 if s.form == 0 && hash[s.species] }
GameData::Species.each_species { |s| ret += 1 if hash[s.species] }
else
pbAllRegionalSpecies(region).each { |s| ret += 1 if s && hash[s] }
end

View File

@@ -58,6 +58,8 @@ class HallOfFame_Scene
@useMusic=false
@battlerIndex=0
@hallEntry=[]
@nationalDexList = [:NONE]
GameData::Species.each_species { |s| @nationalDexList.push(s.species) }
end
def pbStartSceneEntry
@@ -305,8 +307,8 @@ class HallOfFame_Scene
idno=(pokemon.owner.name.empty? || pokemon.egg?) ? "?????" : sprintf("%05d",pokemon.owner.public_id)
dexnumber = _INTL("No. ???")
if !pokemon.egg?
species_data = GameData::Species.get(pokemon.species)
dexnumber = _ISPRINTF("No. {1:03d}",species_data.id_number)
number = @nationalDexList.index(pokemon.species) || 0
dexnumber = _ISPRINTF("No. {1:03d}", number)
end
textPositions=[
[dexnumber,32,Graphics.height-86,0,BASECOLOR,SHADOWCOLOR],

View File

@@ -318,7 +318,7 @@ class PokemonPokedex_Scene
if !regionalSpecies || regionalSpecies.length == 0
# If no Regional Dex defined for the given region, use the National Pokédex
regionalSpecies = []
GameData::Species.each { |s| regionalSpecies.push(s.id) if s.form == 0 }
GameData::Species.each_species { |s| regionalSpecies.push(s.id) }
end
shift = Settings::DEXES_WITH_OFFSETS.include?(region)
ret = []

View File

@@ -74,10 +74,13 @@ class PokemonPokedexInfo_Scene
dexnumshift = false
if $Trainer.pokedex.unlocked?(-1) # National Dex is unlocked
species_data = GameData::Species.try_get(species)
dexnum = species_data.id_number if species_data
dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(-1)
if species_data
nationalDexList = [:NONE]
GameData::Species.each_species { |s| nationalDexList.push(s.species) }
dexnum = nationalDexList.index(species_data.species) || 0
dexnumshift = true if dexnum > 0 && Settings::DEXES_WITH_OFFSETS.include?(-1)
end
else
dexnum = 0
for i in 0...$Trainer.pokedex.dexes_count - 1 # Regional Dexes
next if !$Trainer.pokedex.unlocked?(i)
num = pbGetRegionalNumber(i,species)

View File

@@ -167,6 +167,8 @@ class PokemonSummary_Scene
@sprites["messagebox"].visible = false
@sprites["messagebox"].letterbyletter = true
pbBottomLeftLines(@sprites["messagebox"],2)
@nationalDexList = [:NONE]
GameData::Species.each_species { |s| @nationalDexList.push(s.species) }
drawPage(@page)
pbFadeInAndShow(@sprites) { pbUpdate }
end
@@ -391,12 +393,12 @@ class PokemonSummary_Scene
[_INTL("ID No."),238,202,0,base,shadow],
]
# Write the Regional/National Dex number
dexnum = GameData::Species.get(@pokemon.species).id_number
dexnum = 0
dexnumshift = false
if $Trainer.pokedex.unlocked?(-1) # National Dex is unlocked
dexnum = @nationalDexList.index(@pokemon.species_data.species) || 0
dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(-1)
else
dexnum = 0
for i in 0...$Trainer.pokedex.dexes_count - 1
next if !$Trainer.pokedex.unlocked?(i)
num = pbGetRegionalNumber(i,@pokemon.species)

View File

@@ -1050,8 +1050,7 @@ end
def pbBuyTriads
commands = []
realcommands = []
GameData::Species.each do |s|
next if s.form != 0
GameData::Species.each_species do |s|
next if !$Trainer.owned?(s.species)
price = TriadCard.new(s.id).price
commands.push([price, s.name, _INTL("{1} - ${2}", s.name, price.to_s_formatted), s.id])

View File

@@ -112,9 +112,8 @@ module NicknameChecker
name = name.upcase
return true if name == getName(species)
return false if @@names.values.include?(name)
GameData::Species.each do |species_data|
next if species_data.species == species || species_data.form != 0
return false if getName(species_data.id) == name
GameData::Species.each_species do |species_data|
return false if species_data.species != species && getName(species_data.id) == name
end
return true
end

View File

@@ -42,7 +42,7 @@ def pbRandomMove
loop do
move_id = keys[rand(keys.length)]
move = GameData::Move.get(move_id)
next if move.id_number > 384 || move.id == :SKETCH || move.id == :STRUGGLE
next if move.id == :SKETCH || move.id == :STRUGGLE
return move.id
end
end

View File

@@ -388,7 +388,7 @@ end
def pbGetRegionalDexLength(region_dex)
if region_dex < 0
ret = 0
GameData::Species.each { |s| ret += 1 if s.form == 0 }
GameData::Species.each_species { |s| ret += 1 }
return ret
end
dex_list = pbLoadRegionalDexes[region_dex]

View File

@@ -184,7 +184,7 @@ def pbEncounterMapVersionEditor(enc_data)
elsif ret == commands.length - 1 # Add new encounter type
new_type_commands = []
new_types = []
GameData::EncounterType.each do |enc|
GameData::EncounterType.each_alphabetically do |enc|
next if enc_data.types[enc.id]
new_type_commands.push(enc.real_name)
new_types.push(enc.id)
@@ -212,7 +212,7 @@ def pbEncounterMapVersionEditor(enc_data)
when 1 # Copy
new_type_commands = []
new_types = []
GameData::EncounterType.each do |enc|
GameData::EncounterType.each_alphabetically do |enc|
next if enc_data.types[enc.id]
new_type_commands.push(enc.real_name)
new_types.push(enc.id)
@@ -285,7 +285,7 @@ def pbEncounterTypeEditor(enc_data, enc_type)
new_type_commands = []
new_types = []
chosen_type_cmd = 0
GameData::EncounterType.each do |enc|
GameData::EncounterType.each_alphabetically do |enc|
next if enc_data.types[enc.id] && enc.id != enc_type
new_type_commands.push(enc.real_name)
new_types.push(enc.id)
@@ -954,7 +954,7 @@ end
#===============================================================================
def pbPokemonEditor
species_properties = [
[_INTL("InternalName"), ReadOnlyProperty, _INTL("Internal name of the Pokémon.")],
[_INTL("ID"), ReadOnlyProperty, _INTL("The ID of the Pokémon.")],
[_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_NAME_SIZE), _INTL("Name of the Pokémon.")],
[_INTL("FormName"), StringProperty, _INTL("Name of this form of the Pokémon.")],
[_INTL("Kind"), StringProperty, _INTL("Kind of Pokémon species.")],
@@ -1004,9 +1004,7 @@ def pbPokemonEditor
if button == Input::ACTION
if species.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this species?")
id_number = GameData::Species.get(species).id_number
GameData::Species::DATA.delete(species)
GameData::Species::DATA.delete(id_number)
GameData::Species.save
Compiler.write_pokemon
pbMessage(_INTL("The species was deleted."))
@@ -1079,7 +1077,6 @@ def pbPokemonEditor
# Construct species hash
species_hash = {
:id => spec.id,
:id_number => spec.id_number,
:name => data[1],
:form_name => data[2],
:category => data[3],
@@ -1292,14 +1289,14 @@ def pbRegionalDexEditorMain
refresh_list = true
when 1 # Fill with National Dex
new_dex = []
GameData::Species.each { |s| new_dex.push(s.species) if s.form == 0 }
GameData::Species.each_species { |s| new_dex.push(s.species) }
dex_lists.push(new_dex)
refresh_list = true
when 2 # Fill with National Dex (grouped families)
new_dex = []
seen = []
GameData::Species.each do |s|
next if s.form != 0 || seen.include?(s.species)
GameData::Species.each_species do |s|
next if seen.include?(s.species)
family = s.get_related_species
new_dex.concat(family)
seen.concat(family)
@@ -1350,7 +1347,6 @@ def pbAppendEvoToFamilyArray(species, array, seenarray)
seenarray[species] = true
evos = GameData::Species.get(species).get_evolutions
if evos.length > 0
evos.sort! { |a, b| GameData::Species.get(a[0]).id_number <=> GameData::Species.get(b[0]).id_number }
subarray = []
for i in evos
pbAppendEvoToFamilyArray(i[0], subarray, seenarray)
@@ -1362,8 +1358,7 @@ end
def pbGetEvoFamilies
seen = []
ret = []
GameData::Species.each do |sp|
next if sp.form > 0
GameData::Species.each_species do |sp|
species = sp.get_baby_species
next if seen[species]
subret = []

View File

@@ -12,8 +12,12 @@ def findBottom(bitmap)
end
def pbAutoPositionAll
t = Time.now.to_i
GameData::Species.each do |sp|
Graphics.update if sp.id_number % 50 == 0
if Time.now.to_i - t >= 5
t = Time.now.to_i
Graphics.update
end
bitmap1 = GameData::Species.sprite_bitmap(sp.species, sp.form, nil, nil, nil, true)
bitmap2 = GameData::Species.sprite_bitmap(sp.species, sp.form)
if bitmap1 && bitmap1.bitmap # Player's y

View File

@@ -117,15 +117,21 @@ end
# the list sorting between numerical and alphabetical.
def pbChooseSpeciesList(default = nil)
commands = []
GameData::Species.each { |s| commands.push([s.id_number, s.real_name, s.id]) if s.form == 0 }
index = 1
GameData::Species.each_species do |s|
commands.push([index, s.real_name, s.id])
index += 1
end
return pbChooseList(commands, default, nil, -1)
end
def pbChooseSpeciesFormList(default = nil)
commands = []
index = 1
GameData::Species.each do |s|
name = (s.form == 0) ? s.real_name : sprintf("%s_%d", s.real_name, s.form)
commands.push([s.id_number, name, s.id])
commands.push([index, name, s.id])
index += 1
end
return pbChooseList(commands, default, nil, -1)
end
@@ -136,18 +142,24 @@ end
# between numerical and alphabetical.
def pbChooseMoveList(default = nil)
commands = []
GameData::Move.each { |i| commands.push([i.id_number, i.real_name, i.id]) }
index = 1
GameData::Move.each do |m|
commands.push([index, m.real_name, m.id])
index += 1
end
return pbChooseList(commands, default, nil, -1)
end
def pbChooseMoveListForSpecies(species, defaultMoveID = nil)
cmdwin = pbListWindow([], 200)
commands = []
index = 1
# Get all legal moves
legalMoves = pbGetLegalMoves(species)
legalMoves.each do |move|
move_data = GameData::Move.get(move)
commands.push([move_data.id_number, move_data.name, move_data.id])
commands.push([index, move_data.name, move_data.id])
index += 1
end
commands.sort! { |a, b| a[1] <=> b[1] }
moveDefault = 0
@@ -159,7 +171,8 @@ def pbChooseMoveListForSpecies(species, defaultMoveID = nil)
# Get all moves
commands2 = []
GameData::Move.each do |move_data|
commands2.push([move_data.id_number, move_data.name, move_data.id])
commands2.push([index, move_data.name, move_data.id])
index += 1
end
commands2.sort! { |a, b| a[1] <=> b[1] }
if defaultMoveID
@@ -197,7 +210,11 @@ end
# between numerical and alphabetical.
def pbChooseItemList(default = nil)
commands = []
GameData::Item.each { |i| commands.push([i.id_number, i.name, i.id]) }
index = 1
GameData::Item.each do |i|
commands.push([index, i.name, i.id])
index += 1
end
return pbChooseList(commands, default, nil, -1)
end
@@ -207,7 +224,11 @@ end
# sorting between numerical and alphabetical.
def pbChooseAbilityList(default = nil)
commands = []
GameData::Ability.each { |a| commands.push([a.id_number, a.name, a.id]) }
index = 1
GameData::Ability.each do |a|
commands.push([index, a.name, a.id])
index += 1
end
return pbChooseList(commands, default, nil, -1)
end

View File

@@ -1165,7 +1165,7 @@ class EvolutionsProperty
def initialize
@methods = []
@evo_ids = []
GameData::Evolution.each do |e|
GameData::Evolution.each_alphabetically do |e|
@methods.push(e.real_name)
@evo_ids.push(e.id)
end

View File

@@ -337,9 +337,10 @@ class SpeciesLister
@commands.clear
@ids.clear
cmds = []
GameData::Species.each do |species|
next if species.form != 0
cmds.push([species.id_number, species.id, species.real_name])
idx = 1
GameData::Species.each_species do |species|
cmds.push([idx, species.id, species.real_name])
idx += 1
end
cmds.sort! { |a, b| a[2].downcase <=> b[2].downcase }
if @includeNew
@@ -395,8 +396,10 @@ class ItemLister
@commands.clear
@ids.clear
cmds = []
idx = 1
GameData::Item.each do |item|
cmds.push([item.id_number, item.id, item.real_name])
cmds.push([idx, item.id, item.real_name])
idx += 1
end
cmds.sort! { |a, b| a[2].downcase <=> b[2].downcase }
if @includeNew
@@ -454,8 +457,10 @@ class TrainerTypeLister
@commands.clear
@ids.clear
cmds = []
idx = 1
GameData::TrainerType.each do |tr_type|
cmds.push([tr_type.id_number, tr_type.id, tr_type.real_name])
cmds.push([idx, tr_type.id, tr_type.real_name])
idx += 1
end
cmds.sort! { |a, b| a[2] == b[2] ? a[0] <=> b[0] : a[2].downcase <=> b[2].downcase }
if @includeNew
@@ -532,8 +537,10 @@ class TrainerBattleLister
@commands.clear
@ids.clear
cmds = []
idx = 1
GameData::Trainer.each do |trainer|
cmds.push([trainer.id_number, trainer.trainer_type, trainer.real_name, trainer.version])
cmds.push([idx, trainer.trainer_type, trainer.real_name, trainer.version])
idx += 1
end
cmds.sort! { |a, b|
if a[1] == b[1]

View File

@@ -122,8 +122,8 @@ module Compiler
end
end
lineno += 1
Graphics.update if lineno%200==0
pbSetWindowText(_INTL("Processing {1} line {2}",FileLineData.file,lineno)) if lineno%50==0
Graphics.update if lineno%1000==0
pbSetWindowText(_INTL("Processing {1} line {2}",FileLineData.file,lineno)) if lineno%200==0
}
yield lastsection,sectionname if havesection
end

View File

@@ -187,15 +187,15 @@ module Compiler
GameData::Type.each do |type|
type.weaknesses.each do |other_type|
next if GameData::Type.exists?(other_type)
raise _INTL("'{1}' is not a defined type ({2}, section {3}, Weaknesses).", other_type.to_s, path, type.id_number)
raise _INTL("'{1}' is not a defined type ({2}, section {3}, Weaknesses).", other_type.to_s, path, type.id)
end
type.resistances.each do |other_type|
next if GameData::Type.exists?(other_type)
raise _INTL("'{1}' is not a defined type ({2}, section {3}, Resistances).", other_type.to_s, path, type.id_number)
raise _INTL("'{1}' is not a defined type ({2}, section {3}, Resistances).", other_type.to_s, path, type.id)
end
type.immunities.each do |other_type|
next if GameData::Type.exists?(other_type)
raise _INTL("'{1}' is not a defined type ({2}, section {3}, Immunities).", other_type.to_s, path, type.id_number)
raise _INTL("'{1}' is not a defined type ({2}, section {3}, Immunities).", other_type.to_s, path, type.id)
end
end
# Save all data
@@ -387,30 +387,26 @@ module Compiler
# contents is a hash containing all the XXX=YYY lines in that section, where
# the keys are the XXX and the values are the YYY (as unprocessed strings).
schema = GameData::Species.schema
pbEachFileSection(f) { |contents, species_number|
FileLineData.setSection(species_number, "header", nil) # For error reporting
# Raise an error if a species number is invalid or used twice
if species_number == 0
raise _INTL("A Pokémon species can't be numbered 0 ({1}).", path)
elsif GameData::Species::DATA[species_number]
raise _INTL("Species ID number '{1}' is used twice.\r\n{2}", species_number, FileLineData.linereport)
pbEachFileSection3(f) { |contents, species_id|
FileLineData.setSection(species_id, "header", nil) # For error reporting
contents["InternalName"] = species_id if !species_id[/^\d+/]
# Ensure all required properties have been defined, and raise an error
# if not
for key in schema.keys
next if !nil_or_empty?(contents[key])
if ["Name", "InternalName"].include?(key)
raise _INTL("The entry {1} is required in {2} section {3}.", key, path, species_id)
end
contents[key] = nil
end
# Raise an error if a species ID is used twice
if GameData::Species::DATA[contents["InternalName"].to_sym]
raise _INTL("Species ID '{1}' is used twice.\r\n{2}", contents["InternalName"], FileLineData.linereport)
end
# Go through schema hash of compilable data and compile this section
for key in schema.keys
# Skip empty properties, or raise an error if a required property is
# empty
if nil_or_empty?(contents[key])
if ["Name", "InternalName"].include?(key)
raise _INTL("The entry {1} is required in {2} section {3}.", key, path, species_number)
end
contents[key] = nil
next
end
# Raise an error if a species internal name is used twice
FileLineData.setSection(species_number, key, contents[key]) # For error reporting
if GameData::Species::DATA[contents["InternalName"].to_sym]
raise _INTL("Species ID '{1}' is used twice.\r\n{2}", contents["InternalName"], FileLineData.linereport)
end
next if nil_or_empty?(contents[key])
FileLineData.setSection(species_id, key, contents[key]) # For error reporting
# Compile value for key
value = pbGetCsvRecord(contents[key], key, schema[key])
value = nil if value.is_a?(Array) && value.length == 0
@@ -427,7 +423,7 @@ module Compiler
# Convert height/weight to 1 decimal place and multiply by 10
value = (value * 10).round
if value <= 0
raise _INTL("Value for '{1}' can't be less than or close to 0 (section {2}, {3})", key, species_number, path)
raise _INTL("Value for '{1}' can't be less than or close to 0 (section {2}, {3})", key, species_id, path)
end
contents[key] = value
when "Moves"
@@ -450,10 +446,8 @@ module Compiler
end
end
# Construct species hash
species_symbol = contents["InternalName"].to_sym
species_hash = {
:id => species_symbol,
:id_number => species_number,
:id => contents["InternalName"].to_sym,
:name => contents["Name"],
:form_name => contents["FormName"],
:category => contents["Kind"],
@@ -495,26 +489,24 @@ module Compiler
}
# Add species' data to records
GameData::Species.register(species_hash)
species_names[species_number] = species_hash[:name]
species_form_names[species_number] = species_hash[:form_name]
species_categories[species_number] = species_hash[:category]
species_pokedex_entries[species_number] = species_hash[:pokedex_entry]
species_names.push(species_hash[:name])
species_form_names.push(species_hash[:form_name])
species_categories.push(species_hash[:category])
species_pokedex_entries.push(species_hash[:pokedex_entry])
}
}
# Enumerate all evolution species and parameters (this couldn't be done earlier)
GameData::Species.each do |species|
FileLineData.setSection(species.id_number, "Evolutions", nil) # For error reporting
Graphics.update if species.id_number % 200 == 0
pbSetWindowText(_INTL("Processing {1} evolution line {2}", FileLineData.file, species.id_number)) if species.id_number % 50 == 0
FileLineData.setSection(species.id.to_s, "Evolutions", nil) # For error reporting
species.evolutions.each do |evo|
evo[0] = csvEnumField!(evo[0], :Species, "Evolutions", species.id_number)
evo[0] = csvEnumField!(evo[0], :Species, "Evolutions", species.id)
param_type = GameData::Evolution.get(evo[1]).parameter
if param_type.nil?
evo[2] = nil
elsif param_type == Integer
evo[2] = csvPosInt!(evo[2])
else
evo[2] = csvEnumField!(evo[2], param_type, "Evolutions", species.id_number)
evo[2] = csvEnumField!(evo[2], param_type, "Evolutions", species.id)
end
end
end
@@ -530,10 +522,10 @@ module Compiler
end
# Save all data
GameData::Species.save
MessageTypes.setMessages(MessageTypes::Species, species_names)
MessageTypes.setMessages(MessageTypes::FormNames, species_form_names)
MessageTypes.setMessages(MessageTypes::Kinds, species_categories)
MessageTypes.setMessages(MessageTypes::Entries, species_pokedex_entries)
MessageTypes.setMessagesAsHash(MessageTypes::Species, species_names)
MessageTypes.setMessagesAsHash(MessageTypes::FormNames, species_form_names)
MessageTypes.setMessagesAsHash(MessageTypes::Kinds, species_categories)
MessageTypes.setMessagesAsHash(MessageTypes::Entries, species_pokedex_entries)
Graphics.update
end
@@ -546,11 +538,6 @@ module Compiler
species_categories = []
species_pokedex_entries = []
used_forms = {}
# Get maximum species ID number
form_number = 0
GameData::Species.each do |species|
form_number = species.id_number if form_number < species.id_number
end
# Read from PBS file
File.open(path, "rb") { |f|
FileLineData.file = path # For error reporting
@@ -578,7 +565,6 @@ module Compiler
end
used_forms[species_symbol] = [] if !used_forms[species_symbol]
used_forms[species_symbol].push(form)
form_number += 1
base_data = GameData::Species.get(species_symbol)
# Go through schema hash of compilable data and compile this section
for key in schema.keys
@@ -649,7 +635,6 @@ module Compiler
end
species_hash = {
:id => form_symbol,
:id_number => form_number,
:species => species_symbol,
:form => form,
:name => base_data.real_name,
@@ -681,7 +666,7 @@ module Compiler
:height => contents["Height"] || base_data.height,
:weight => contents["Weight"] || base_data.weight,
:color => contents["Color"] || base_data.color,
:shape => (contents["Shape"]) ? GameData::BodyShape.get(contents["Shape"]).id : base_data.shape,
:shape => contents["Shape"] || base_data.shape,
:habitat => contents["Habitat"] || base_data.habitat,
:generation => contents["Generation"] || base_data.generation,
:mega_stone => contents["MegaStone"],
@@ -706,10 +691,10 @@ module Compiler
end
# Add form's data to records
GameData::Species.register(species_hash)
species_names[form_number] = species_hash[:name]
species_form_names[form_number] = species_hash[:form_name]
species_categories[form_number] = species_hash[:category]
species_pokedex_entries[form_number] = species_hash[:pokedex_entry]
species_names.push(species_hash[:name])
species_form_names.push(species_hash[:form_name])
species_categories.push(species_hash[:category])
species_pokedex_entries.push(species_hash[:pokedex_entry])
}
}
# Add prevolution "evolution" entry for all evolved forms that define their
@@ -727,10 +712,10 @@ module Compiler
end
# Save all data
GameData::Species.save
MessageTypes.addMessages(MessageTypes::Species, species_names)
MessageTypes.addMessages(MessageTypes::FormNames, species_form_names)
MessageTypes.addMessages(MessageTypes::Kinds, species_categories)
MessageTypes.addMessages(MessageTypes::Entries, species_pokedex_entries)
MessageTypes.addMessagesAsHash(MessageTypes::Species, species_names)
MessageTypes.addMessagesAsHash(MessageTypes::FormNames, species_form_names)
MessageTypes.addMessagesAsHash(MessageTypes::Kinds, species_categories)
MessageTypes.addMessagesAsHash(MessageTypes::Entries, species_pokedex_entries)
Graphics.update
end
@@ -975,7 +960,7 @@ module Compiler
end
need_step_chances = false
values = pbGetCsvRecord(line, line_no, [0, "vvv"])
GameData::EncounterType.each do |enc_type|
GameData::EncounterType.each_alphabetically do |enc_type|
case enc_type.id
when :land, :contest then step_chances[enc_type.id] = values[0]
when :cave then step_chances[enc_type.id] = values[1]

View File

@@ -261,15 +261,15 @@ module Compiler
#=============================================================================
def write_pokemon
File.open("PBS/pokemon.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
GameData::Species.each do |species|
next if species.form != 0
pbSetWindowText(_INTL("Writing species {1}...", species.id_number))
Graphics.update if species.id_number % 50 == 0
GameData::Species.each_species do |species|
idx += 1
pbSetWindowText(_INTL("Writing species {1}...", idx))
Graphics.update if idx % 100 == 0
f.write("\#-------------------------------\r\n")
f.write(sprintf("[%d]\r\n", species.id_number))
f.write(sprintf("[%s]\r\n", species.id))
f.write(sprintf("Name = %s\r\n", species.real_name))
f.write(sprintf("InternalName = %s\r\n", species.species))
f.write(sprintf("Type1 = %s\r\n", species.type1))
f.write(sprintf("Type2 = %s\r\n", species.type2)) if species.type2 != species.type1
stats_array = []
@@ -356,12 +356,14 @@ module Compiler
#=============================================================================
def write_pokemon_forms
File.open("PBS/pokemonforms.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
GameData::Species.each do |species|
next if species.form == 0
base_species = GameData::Species.get(species.species)
pbSetWindowText(_INTL("Writing species {1}...", species.id_number))
Graphics.update if species.id_number % 50 == 0
idx += 1
pbSetWindowText(_INTL("Writing form {1}...", idx))
Graphics.update if idx % 100 == 0
f.write("\#-------------------------------\r\n")
f.write(sprintf("[%s,%d]\r\n", species.species, species.form))
f.write(sprintf("FormName = %s\r\n", species.real_form_name)) if species.real_form_name && !species.real_form_name.empty?
@@ -587,10 +589,12 @@ module Compiler
#=============================================================================
def write_trainers
File.open("PBS/trainers.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
GameData::Trainer.each do |trainer|
pbSetWindowText(_INTL("Writing trainer {1}...", trainer.id_number))
Graphics.update if trainer.id_number % 50 == 0
idx += 1
pbSetWindowText(_INTL("Writing trainer {1}...", idx))
Graphics.update if idx % 50 == 0
f.write("\#-------------------------------\r\n")
if trainer.version > 0
f.write(sprintf("[%s,%s,%d]\r\n", trainer.trainer_type, trainer.real_name, trainer.version))

File diff suppressed because it is too large Load Diff