mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
More Rubocopping
This commit is contained in:
@@ -404,9 +404,9 @@ module Compiler
|
||||
start = 1
|
||||
end
|
||||
subarrays = repeat && schema[1].length > 2
|
||||
begin
|
||||
loop do
|
||||
subrecord = []
|
||||
for i in start...schema[1].length
|
||||
(start...schema[1].length).each do |i|
|
||||
chr = schema[1][i, 1]
|
||||
case chr
|
||||
when "i" # Integer
|
||||
@@ -540,7 +540,8 @@ module Compiler
|
||||
end
|
||||
end
|
||||
break if repeat && nil_or_empty?(rec)
|
||||
end while repeat
|
||||
break unless repeat
|
||||
end
|
||||
return (schema[1].length == 1) ? record[0] : record
|
||||
end
|
||||
|
||||
@@ -551,8 +552,8 @@ module Compiler
|
||||
rec = (record.is_a?(Array)) ? record.flatten : [record]
|
||||
start = (schema[1][0, 1] == "*") ? 1 : 0
|
||||
index = -1
|
||||
begin
|
||||
for i in start...schema[1].length
|
||||
loop do
|
||||
(start...schema[1].length).each do |i|
|
||||
index += 1
|
||||
file.write(",") if index > 0
|
||||
value = rec[index]
|
||||
@@ -579,7 +580,7 @@ module Compiler
|
||||
when Module
|
||||
file.write(getConstantName(enumer, value))
|
||||
when Hash
|
||||
for key in enumer.keys
|
||||
enumer.keys.each do |key|
|
||||
if enumer[key] == value
|
||||
file.write(key)
|
||||
break
|
||||
@@ -602,7 +603,7 @@ module Compiler
|
||||
file.write(getConstantNameOrValue(enumer, value))
|
||||
when Hash
|
||||
hasenum = false
|
||||
for key in enumer.keys
|
||||
enumer.keys.each do |key|
|
||||
if enumer[key] == value
|
||||
file.write(key)
|
||||
hasenum = true
|
||||
@@ -619,7 +620,8 @@ module Compiler
|
||||
end
|
||||
end
|
||||
break if start > 0 && index >= rec.length - 1
|
||||
end while start > 0
|
||||
break if start <= 0
|
||||
end
|
||||
return record
|
||||
end
|
||||
|
||||
@@ -845,7 +847,7 @@ module Compiler
|
||||
mustCompile = true if Input.press?(Input::CTRL)
|
||||
# Delete old data files in preparation for recompiling
|
||||
if mustCompile
|
||||
for i in 0...dataFiles.length
|
||||
dataFiles.length.times do |i|
|
||||
begin
|
||||
File.delete("Data/#{dataFiles[i]}") if safeExists?("Data/#{dataFiles[i]}")
|
||||
rescue SystemCallError
|
||||
@@ -858,7 +860,7 @@ module Compiler
|
||||
e = $!
|
||||
raise e if "#{e.class}" == "Reset" || e.is_a?(Reset) || e.is_a?(SystemExit)
|
||||
pbPrintException(e)
|
||||
for i in 0...dataFiles.length
|
||||
dataFiles.length.times do |i|
|
||||
begin
|
||||
File.delete("Data/#{dataFiles[i]}")
|
||||
rescue SystemCallError
|
||||
|
||||
@@ -154,7 +154,7 @@ module Compiler
|
||||
contents["InternalName"] = type_id if !type_id[/^\d+/]
|
||||
icon_pos = (type_id[/^\d+/]) ? type_id.to_i : nil
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
for key in schema.keys
|
||||
schema.keys.each do |key|
|
||||
FileLineData.setSection(type_id, key, contents[key]) # For error reporting
|
||||
# Skip empty properties, or raise an error if a required property is
|
||||
# empty
|
||||
@@ -606,7 +606,7 @@ module Compiler
|
||||
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
|
||||
schema.keys.each do |key|
|
||||
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)
|
||||
@@ -618,7 +618,7 @@ module Compiler
|
||||
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
|
||||
schema.keys.each do |key|
|
||||
next if nil_or_empty?(contents[key])
|
||||
FileLineData.setSection(species_id, key, contents[key]) # For error reporting
|
||||
# Compile value for key
|
||||
@@ -792,7 +792,7 @@ module Compiler
|
||||
used_forms[species_symbol].push(form)
|
||||
base_data = GameData::Species.get(species_symbol)
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
for key in schema.keys
|
||||
schema.keys.each do |key|
|
||||
# Skip empty properties (none are required)
|
||||
if nil_or_empty?(contents[key])
|
||||
contents[key] = nil
|
||||
@@ -982,7 +982,7 @@ module Compiler
|
||||
species_symbol = csvEnumField!(split_section_name[0], :Species, nil, nil)
|
||||
form = (split_section_name[1]) ? csvPosInt!(split_section_name[1]) : 0
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
for key in schema.keys
|
||||
schema.keys.each do |key|
|
||||
# Skip empty properties (none are required)
|
||||
if nil_or_empty?(contents[key])
|
||||
contents[key] = nil
|
||||
@@ -1099,7 +1099,7 @@ module Compiler
|
||||
else
|
||||
raise _INTL("Expected a section at the beginning of the file.\r\n{1}", FileLineData.linereport) if !section
|
||||
species_list = line.split(",")
|
||||
for species in species_list
|
||||
species_list.each do |species|
|
||||
next if !species || species.empty?
|
||||
s = parseSpecies(species)
|
||||
dex_lists[section].push(s)
|
||||
@@ -1540,7 +1540,7 @@ module Compiler
|
||||
Graphics.update
|
||||
next if name != "DefaultTrainerList" && name != "TrainerList"
|
||||
rsection = []
|
||||
for key in section.keys
|
||||
section.keys.each do |key|
|
||||
FileLineData.setSection(name, key, section[key])
|
||||
schema = btTrainersRequiredTypes[key]
|
||||
next if key == "Challenges" && name == "DefaultTrainerList"
|
||||
@@ -1602,7 +1602,7 @@ module Compiler
|
||||
FileLineData.file = filename
|
||||
pbEachFileSection(f) { |section, name|
|
||||
rsection = []
|
||||
for key in section.keys
|
||||
section.keys.each do |key|
|
||||
FileLineData.setSection(name, key, section[key])
|
||||
schema = requiredtypes[key]
|
||||
next if !schema
|
||||
@@ -1641,7 +1641,7 @@ module Compiler
|
||||
pbEachFileSectionNumbered(f) { |contents, section_id|
|
||||
schema = (section_id == 0) ? GameData::Metadata::SCHEMA : GameData::PlayerMetadata::SCHEMA
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
for key in schema.keys
|
||||
schema.keys.each do |key|
|
||||
FileLineData.setSection(section_id, key, contents[key]) # For error reporting
|
||||
# Skip empty properties, or raise an error if a required property is
|
||||
# empty
|
||||
@@ -1725,7 +1725,7 @@ module Compiler
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
for key in schema.keys
|
||||
schema.keys.each do |key|
|
||||
FileLineData.setSection(map_id, key, contents[key]) # For error reporting
|
||||
# Skip empty properties
|
||||
next if contents[key].nil?
|
||||
@@ -1797,7 +1797,7 @@ module Compiler
|
||||
pbanims[anim.id] = pbConvertRPGAnimation(anim) if !found
|
||||
end
|
||||
=end
|
||||
for i in 0...pbanims.length
|
||||
pbanims.length.times do |i|
|
||||
next if !pbanims[i]
|
||||
if pbanims[i].name[/^OppMove\:\s*(.*)$/]
|
||||
if GameData::Move.exists?($~[1])
|
||||
|
||||
@@ -18,7 +18,7 @@ module Compiler
|
||||
File.open(path, "wb") { |f|
|
||||
idx = 0
|
||||
add_PBS_header_to_file(f)
|
||||
for i in 0...mapdata.length
|
||||
mapdata.length.times do |i|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
@@ -30,7 +30,7 @@ module Compiler
|
||||
f.write(sprintf("Name = %s\r\nFilename = %s\r\n",
|
||||
(rname && rname != "") ? rname : _INTL("Unnamed"),
|
||||
csvQuote((map[1].is_a?(Array)) ? map[1][0] : map[1])))
|
||||
for loc in map[2]
|
||||
map[2].each do |loc|
|
||||
f.write("Point = ")
|
||||
pbWriteCsvRecord(loc, f, [nil, "uussUUUU"])
|
||||
f.write("\r\n")
|
||||
@@ -79,7 +79,7 @@ module Compiler
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
f.write("\#-------------------------------\r\n")
|
||||
for conn in conndata
|
||||
conndata.each do |conn|
|
||||
if mapinfos
|
||||
# Skip if map no longer exists
|
||||
next if !mapinfos[conn[0]] || !mapinfos[conn[3]]
|
||||
@@ -703,7 +703,7 @@ module Compiler
|
||||
write_pbs_file_message_start(path)
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
for tr in trainerlists
|
||||
trainerlists.each do |tr|
|
||||
echo "."
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(((tr[5]) ? "[DefaultTrainerList]" : "[TrainerList]") + "\r\n")
|
||||
@@ -732,11 +732,11 @@ module Compiler
|
||||
}
|
||||
File.open(filename, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
for i in 0...bttrainers.length
|
||||
bttrainers.length.times do |i|
|
||||
next if !bttrainers[i]
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%03d]\r\n", i))
|
||||
for key in btTrainersRequiredTypes.keys
|
||||
btTrainersRequiredTypes.keys.each do |key|
|
||||
schema = btTrainersRequiredTypes[key]
|
||||
record = bttrainers[i][schema[0]]
|
||||
next if record == nil
|
||||
@@ -776,7 +776,7 @@ module Compiler
|
||||
File.open(filename, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
f.write("\#-------------------------------\r\n")
|
||||
for i in 0...btpokemon.length
|
||||
btpokemon.length.times do |i|
|
||||
Graphics.update if i % 500 == 0
|
||||
pkmn = btpokemon[i]
|
||||
c1 = (species[pkmn.species]) ? species[pkmn.species] : (species[pkmn.species] = GameData::Species.get(pkmn.species).species.to_s)
|
||||
@@ -820,7 +820,7 @@ module Compiler
|
||||
metadata = GameData::Metadata.get
|
||||
schema = GameData::Metadata::SCHEMA
|
||||
keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] }
|
||||
for key in keys
|
||||
keys.each do |key|
|
||||
record = metadata.property_from_string(key)
|
||||
next if record.nil? || (record.is_a?(Array) && record.empty?)
|
||||
f.write(sprintf("%s = ", key))
|
||||
@@ -833,7 +833,7 @@ module Compiler
|
||||
GameData::PlayerMetadata.each do |player_data|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%d]\r\n", player_data.id))
|
||||
for key in keys
|
||||
keys.each do |key|
|
||||
record = player_data.property_from_string(key)
|
||||
next if record.nil? || (record.is_a?(Array) && record.empty?)
|
||||
f.write(sprintf("%s = ", key))
|
||||
@@ -868,7 +868,7 @@ module Compiler
|
||||
else
|
||||
f.write(sprintf("[%03d]\r\n", map_data.id))
|
||||
end
|
||||
for key in keys
|
||||
keys.each do |key|
|
||||
record = map_data.property_from_string(key)
|
||||
next if record.nil? || (record.is_a?(Array) && record.empty?)
|
||||
f.write(sprintf("%s = ", key))
|
||||
|
||||
@@ -45,14 +45,14 @@ module Compiler
|
||||
# Get IDs of all maps in the Data folder
|
||||
Dir.chdir("Data") {
|
||||
mapData = sprintf("Map*.rxdata")
|
||||
for map in Dir.glob(mapData)
|
||||
Dir.glob(mapData).each do |map|
|
||||
mapfiles[$1.to_i(10)] = true if map[/map(\d+)\.rxdata/i]
|
||||
end
|
||||
}
|
||||
mapinfos = pbLoadMapInfos
|
||||
maxOrder = 0
|
||||
# Exclude maps found in mapinfos
|
||||
for id in mapinfos.keys
|
||||
mapinfos.keys.each do |id|
|
||||
next if !mapinfos[id]
|
||||
mapfiles.delete(id) if mapfiles[id]
|
||||
maxOrder = [maxOrder, mapinfos[id].order].max
|
||||
@@ -61,7 +61,7 @@ module Compiler
|
||||
maxOrder += 1
|
||||
imported = false
|
||||
count = 0
|
||||
for id in mapfiles.keys
|
||||
mapfiles.keys.each do |id|
|
||||
next if id == 999 # Ignore 999 (random dungeon map)
|
||||
mapinfo = RPG::MapInfo.new
|
||||
mapinfo.order = maxOrder
|
||||
@@ -116,7 +116,7 @@ module Compiler
|
||||
|
||||
def push_move_route(list, character, route, indent = 0)
|
||||
route = generate_move_route(route) if route.is_a?(Array)
|
||||
for i in 0...route.list.length
|
||||
route.list.length.times do |i|
|
||||
list.push(
|
||||
RPG::EventCommand.new((i == 0) ? 209 : 509, indent,
|
||||
(i == 0) ? [character, route] : [route.list[i - 1]])
|
||||
@@ -143,7 +143,7 @@ module Compiler
|
||||
|
||||
def push_comment(list, cmt, indent = 0)
|
||||
textsplit2 = cmt.split(/\n/)
|
||||
for i in 0...textsplit2.length
|
||||
textsplit2.length.times do |i|
|
||||
list.push(RPG::EventCommand.new((i == 0) ? 108 : 408, indent, [textsplit2[i].gsub(/\s+$/, "")]))
|
||||
end
|
||||
end
|
||||
@@ -151,10 +151,10 @@ module Compiler
|
||||
def push_text(list, text, indent = 0)
|
||||
return if !text
|
||||
textsplit = text.split(/\\m/)
|
||||
for t in textsplit
|
||||
textsplit.each do |t|
|
||||
first = true
|
||||
textsplit2 = t.split(/\n/)
|
||||
for i in 0...textsplit2.length
|
||||
textsplit2.length.times do |i|
|
||||
textchunk = textsplit2[i].gsub(/\s+$/, "")
|
||||
if textchunk && textchunk != ""
|
||||
list.push(RPG::EventCommand.new((first) ? 101 : 401, indent, [textchunk]))
|
||||
@@ -168,7 +168,7 @@ module Compiler
|
||||
return if !script
|
||||
first = true
|
||||
textsplit2 = script.split(/\n/)
|
||||
for i in 0...textsplit2.length
|
||||
textsplit2.length.times do |i|
|
||||
textchunk = textsplit2[i].gsub(/\s+$/, "")
|
||||
if textchunk && textchunk != ""
|
||||
list.push(RPG::EventCommand.new((first) ? 355 : 655, indent, [textchunk]))
|
||||
@@ -200,7 +200,7 @@ module Compiler
|
||||
end
|
||||
|
||||
def apply_pages(page, pages)
|
||||
for p in pages
|
||||
pages.each do |p|
|
||||
p.graphic = page.graphic
|
||||
p.walk_anime = page.walk_anime
|
||||
p.step_anime = page.step_anime
|
||||
@@ -314,7 +314,7 @@ module Compiler
|
||||
@mapHeights[mapID] = map.height
|
||||
mapPositions = []
|
||||
width = map.width
|
||||
for e in map.events.values
|
||||
map.events.values.each do |e|
|
||||
mapPositions[(e.y * width) + e.x] = e if e
|
||||
end
|
||||
@mapxy[mapID] = mapPositions
|
||||
@@ -351,7 +351,7 @@ module Compiler
|
||||
return false if x < 0 || x >= map.width || y < 0 || y >= map.height
|
||||
passages = getTilesetPassages(map, mapID)
|
||||
priorities = getTilesetPriorities(map, mapID)
|
||||
for i in [2, 1, 0]
|
||||
[2, 1, 0].each do |i|
|
||||
tile_id = map.data[x, y, i]
|
||||
return false if tile_id == nil
|
||||
passage = passages[tile_id]
|
||||
@@ -369,7 +369,7 @@ module Compiler
|
||||
map = getMap(mapID)
|
||||
return false if !map
|
||||
passages = getTilesetPassages(map, mapID)
|
||||
for i in [2, 1, 0]
|
||||
[2, 1, 0].each do |i|
|
||||
tile_id = map.data[x, y, i]
|
||||
return false if tile_id == nil
|
||||
passage = passages[tile_id]
|
||||
@@ -386,7 +386,7 @@ module Compiler
|
||||
map = getMap(mapID)
|
||||
return if !map
|
||||
passages = getTilesetPassages(map, mapID)
|
||||
for i in [2, 1, 0]
|
||||
[2, 1, 0].each do |i|
|
||||
tile_id = map.data[x, y, i]
|
||||
next if tile_id == 0
|
||||
passages[tile_id] |= 0x80
|
||||
@@ -396,7 +396,7 @@ module Compiler
|
||||
|
||||
def registerSwitch(switch)
|
||||
return @registeredSwitches[switch] if @registeredSwitches[switch]
|
||||
for id in 1..5000
|
||||
(1..5000).each do |id|
|
||||
name = @system.switches[id]
|
||||
next if name && name != "" && name != switch
|
||||
@system.switches[id] = switch
|
||||
@@ -459,10 +459,10 @@ module Compiler
|
||||
commands = []
|
||||
isFirstCommand = false
|
||||
# Find all the trainer comments in the event
|
||||
for i in 0...list.length
|
||||
list.length.times do |i|
|
||||
next if list[i].code != 108 # Comment (first line)
|
||||
command = list[i].parameters[0]
|
||||
for j in (i + 1)...list.length
|
||||
((i + 1)...list.length).each do |j|
|
||||
break if list[j].code != 408 # Comment (continuation line)
|
||||
command += "\r\n" + list[j].parameters[0]
|
||||
end
|
||||
@@ -502,7 +502,7 @@ module Compiler
|
||||
endifswitch = []
|
||||
vanishifswitch = []
|
||||
regspeech = nil
|
||||
for command in commands
|
||||
commands.each do |command|
|
||||
if command[/^Battle\:\s*([\s\S]+)$/i]
|
||||
battles.push($~[1])
|
||||
push_comment(firstpage.list, command) if rewriteComments
|
||||
@@ -604,7 +604,7 @@ module Compiler
|
||||
rematchpage.condition.self_switch_valid = true
|
||||
rematchpage.condition.self_switch_ch = "B"
|
||||
# Write rematch and last pages
|
||||
for i in 1...battles.length
|
||||
(1...battles.length).each do |i|
|
||||
# Run trainer check now, except in editor
|
||||
trainerChecker.pbTrainerBattleCheck(trtype, trname, battleid + i)
|
||||
if i == battles.length - 1
|
||||
@@ -664,7 +664,7 @@ module Compiler
|
||||
ret.pages = [firstpage, rematchpage, lastpage]
|
||||
end
|
||||
# Copy last page to endIfSwitch page
|
||||
for endswitch in endifswitch
|
||||
endifswitch.each do |endswitch|
|
||||
endIfSwitchPage = Marshal.load(Marshal.dump(lastpage))
|
||||
endIfSwitchPage.condition = lastpage.condition.clone
|
||||
if endIfSwitchPage.condition.switch1_valid # Add another page condition
|
||||
@@ -682,7 +682,7 @@ module Compiler
|
||||
ret.pages.push(endIfSwitchPage)
|
||||
end
|
||||
# Copy last page to vanishIfSwitch page
|
||||
for vanishswitch in vanishifswitch
|
||||
vanishifswitch.each do |vanishswitch|
|
||||
vanishIfSwitchPage = Marshal.load(Marshal.dump(lastpage))
|
||||
vanishIfSwitchPage.graphic.character_name = "" # No charset
|
||||
vanishIfSwitchPage.condition = lastpage.condition.clone
|
||||
@@ -952,7 +952,7 @@ module Compiler
|
||||
# Using old method of recovering
|
||||
case script
|
||||
when "foriin$player.partyi.healend"
|
||||
for j in i..lastScript
|
||||
(i..lastScript).each do |j|
|
||||
list.delete_at(i)
|
||||
end
|
||||
list.insert(i,
|
||||
@@ -960,7 +960,7 @@ module Compiler
|
||||
changed = true
|
||||
when "pbFadeOutIn(99999){foriin$player.partyi.healend}"
|
||||
oldIndent = list[i].indent
|
||||
for j in i..lastScript
|
||||
(i..lastScript).each do |j|
|
||||
list.delete_at(i)
|
||||
end
|
||||
list.insert(
|
||||
@@ -1431,7 +1431,7 @@ module Compiler
|
||||
def check_counters(map, mapID, mapData)
|
||||
toDelete = []
|
||||
changed = false
|
||||
for key in map.events.keys
|
||||
map.events.keys.each do |key|
|
||||
event = map.events[key]
|
||||
next if !plain_event_or_mart?(event)
|
||||
# Found an event that is empty or looks like a simple Mart or a Poké
|
||||
@@ -1442,7 +1442,7 @@ module Compiler
|
||||
neighbors.push(mapData.getEventFromXY(mapID, event.x - 1, event.y))
|
||||
neighbors.push(mapData.getEventFromXY(mapID, event.x + 1, event.y))
|
||||
neighbors.compact!
|
||||
for otherEvent in neighbors
|
||||
neighbors.each do |otherEvent|
|
||||
next if plain_event?(otherEvent) # Blank/cosmetic-only event
|
||||
next if !likely_counter?(event, otherEvent, mapID, mapData)
|
||||
# Found an adjacent event that looks like it's supposed to be a counter.
|
||||
@@ -1471,14 +1471,14 @@ module Compiler
|
||||
change_record = []
|
||||
Console.echo_li _INTL("Processing {1} maps...", mapData.mapinfos.keys.length)
|
||||
idx = 0
|
||||
for id in mapData.mapinfos.keys.sort
|
||||
mapData.mapinfos.keys.sort.each do |id|
|
||||
echo "." if idx % 20 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
changed = false
|
||||
map = mapData.getMap(id)
|
||||
next if !map || !mapData.mapinfos[id]
|
||||
for key in map.events.keys
|
||||
map.events.keys.each do |key|
|
||||
if Time.now.to_i - t >= 5
|
||||
Graphics.update
|
||||
t = Time.now.to_i
|
||||
@@ -1518,7 +1518,7 @@ module Compiler
|
||||
Graphics.update
|
||||
commonEvents = load_data("Data/CommonEvents.rxdata")
|
||||
Console.echo_li _INTL("Processing common events...")
|
||||
for key in 0...commonEvents.length
|
||||
commonEvents.length.times do |key|
|
||||
newevent = fix_event_use(commonEvents[key], 0, mapData)
|
||||
if newevent
|
||||
commonEvents[key] = newevent
|
||||
|
||||
Reference in New Issue
Block a user