mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-22 22:36:03 +00:00
More Rubocop changes
This commit is contained in:
@@ -586,7 +586,7 @@ module Compiler
|
||||
when Module
|
||||
file.write(getConstantName(enumer, value))
|
||||
when Hash
|
||||
enumer.keys.each do |key|
|
||||
enumer.each_key do |key|
|
||||
if enumer[key] == value
|
||||
file.write(key)
|
||||
break
|
||||
@@ -609,12 +609,11 @@ module Compiler
|
||||
file.write(getConstantNameOrValue(enumer, value))
|
||||
when Hash
|
||||
hasenum = false
|
||||
enumer.keys.each do |key|
|
||||
if enumer[key] == value
|
||||
file.write(key)
|
||||
hasenum = true
|
||||
break
|
||||
end
|
||||
enumer.each_key do |key|
|
||||
next if enumer[key] != value
|
||||
file.write(key)
|
||||
hasenum = true
|
||||
break
|
||||
end
|
||||
file.write(value) unless hasenum
|
||||
end
|
||||
|
||||
@@ -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
|
||||
schema.keys.each do |key|
|
||||
schema.each_key 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
|
||||
schema.keys.each do |key|
|
||||
schema.each_key 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
|
||||
schema.keys.each do |key|
|
||||
schema.each_key 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
|
||||
schema.keys.each do |key|
|
||||
schema.each_key do |key|
|
||||
# Skip empty properties (none are required)
|
||||
if nil_or_empty?(contents[key])
|
||||
contents[key] = nil
|
||||
@@ -988,7 +988,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
|
||||
schema.keys.each do |key|
|
||||
schema.each_key do |key|
|
||||
# Skip empty properties (none are required)
|
||||
if nil_or_empty?(contents[key])
|
||||
contents[key] = nil
|
||||
@@ -1215,7 +1215,7 @@ module Compiler
|
||||
Graphics.update if idx % 250 == 0
|
||||
next if line.length == 0
|
||||
if current_type && line[/^\d+,/] # Species line
|
||||
values = line.split(',').collect! { |v| v.strip }
|
||||
values = line.split(",").collect! { |v| v.strip }
|
||||
if !values || values.length < 3
|
||||
raise _INTL("Expected a species entry line for encounter type {1} for map '{2}', got \"{3}\" instead.\r\n{4}",
|
||||
GameData::EncounterType.get(current_type).real_name, encounter_hash[:map], line, FileLineData.linereport)
|
||||
@@ -1231,7 +1231,7 @@ module Compiler
|
||||
end
|
||||
encounter_hash[:types][current_type].push(values)
|
||||
elsif line[/^\[\s*(.+)\s*\]$/] # Map ID line
|
||||
values = $~[1].split(',').collect! { |v| v.strip.to_i }
|
||||
values = $~[1].split(",").collect! { |v| v.strip.to_i }
|
||||
values[1] = 0 if !values[1]
|
||||
map_number = values[0]
|
||||
map_version = values[1]
|
||||
@@ -1272,7 +1272,7 @@ module Compiler
|
||||
raise _INTL("Expected a map number, got \"{1}\" instead.\r\n{2}", line, FileLineData.linereport)
|
||||
else
|
||||
# Check if line is an encounter method name or not
|
||||
values = line.split(',').collect! { |v| v.strip }
|
||||
values = line.split(",").collect! { |v| v.strip }
|
||||
current_type = (values[0] && !values[0].empty?) ? values[0].to_sym : nil
|
||||
if current_type && GameData::EncounterType.exists?(current_type) # Start of a new encounter method
|
||||
step_chances[current_type] = values[1].to_i if values[1] && !values[1].empty?
|
||||
@@ -1546,7 +1546,7 @@ module Compiler
|
||||
Graphics.update
|
||||
next if name != "DefaultTrainerList" && name != "TrainerList"
|
||||
rsection = []
|
||||
section.keys.each do |key|
|
||||
section.each_key do |key|
|
||||
FileLineData.setSection(name, key, section[key])
|
||||
schema = btTrainersRequiredTypes[key]
|
||||
next if key == "Challenges" && name == "DefaultTrainerList"
|
||||
@@ -1608,7 +1608,7 @@ module Compiler
|
||||
FileLineData.file = filename
|
||||
pbEachFileSection(f) { |section, name|
|
||||
rsection = []
|
||||
section.keys.each do |key|
|
||||
section.each_key do |key|
|
||||
FileLineData.setSection(name, key, section[key])
|
||||
schema = requiredtypes[key]
|
||||
next if !schema
|
||||
@@ -1647,7 +1647,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
|
||||
schema.keys.each do |key|
|
||||
schema.each_key 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
|
||||
@@ -1731,7 +1731,7 @@ module Compiler
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
schema.keys.each do |key|
|
||||
schema.each_key do |key|
|
||||
FileLineData.setSection(map_id, key, contents[key]) # For error reporting
|
||||
# Skip empty properties
|
||||
next if contents[key].nil?
|
||||
|
||||
@@ -736,7 +736,7 @@ module Compiler
|
||||
next if !bttrainers[i]
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%03d]\r\n", i))
|
||||
btTrainersRequiredTypes.keys.each do |key|
|
||||
btTrainersRequiredTypes.each_key do |key|
|
||||
schema = btTrainersRequiredTypes[key]
|
||||
record = bttrainers[i][schema[0]]
|
||||
next if record.nil?
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
module Compiler
|
||||
SCRIPT_REPLACEMENTS = [
|
||||
['Kernel.', ''],
|
||||
['$PokemonBag.pbQuantity', '$bag.quantity'],
|
||||
['$PokemonBag.pbHasItem?', '$bag.has?'],
|
||||
['$PokemonBag.pbCanStore?', '$bag.can_add?'],
|
||||
['$PokemonBag.pbStoreItem', '$bag.add'],
|
||||
['$PokemonBag.pbStoreAllOrNone', '$bag.add_all'],
|
||||
['$PokemonBag.pbChangeItem', '$bag.replace_item'],
|
||||
['$PokemonBag.pbDeleteItem', '$bag.remove'],
|
||||
['$PokemonBag.pbIsRegistered?', '$bag.registered?'],
|
||||
['$PokemonBag.pbRegisterItem', '$bag.register'],
|
||||
['$PokemonBag.pbUnregisterItem', '$bag.unregister'],
|
||||
['$PokemonBag', '$bag'],
|
||||
['pbQuantity', '$bag.quantity'],
|
||||
['pbHasItem?', '$bag.has?'],
|
||||
['pbCanStore?', '$bag.can_add?'],
|
||||
['pbStoreItem', '$bag.add'],
|
||||
['pbStoreAllOrNone', '$bag.add_all'],
|
||||
['$Trainer', '$player'],
|
||||
['$SaveVersion', '$save_engine_version'],
|
||||
['$game_version', '$save_game_version'],
|
||||
['$MapFactory', '$map_factory'],
|
||||
['pbDayCareDeposited', 'DayCare.count'],
|
||||
['pbDayCareGetDeposited', 'DayCare.get_details'],
|
||||
['pbDayCareGetLevelGain', 'DayCare.get_level_gain'],
|
||||
['pbDayCareDeposit', 'DayCare.deposit'],
|
||||
['pbDayCareWithdraw', 'DayCare.withdraw'],
|
||||
['pbDayCareChoose', 'DayCare.choose'],
|
||||
['pbDayCareGetCompatibility', 'DayCare.get_compatibility'],
|
||||
['pbEggGenerated?', 'DayCare.egg_generated?'],
|
||||
['pbDayCareGenerateEgg', 'DayCare.collect_egg'],
|
||||
['get_character(0)', 'get_self'],
|
||||
['get_character(-1)', 'get_player']
|
||||
["Kernel.", ""],
|
||||
["$PokemonBag.pbQuantity", "$bag.quantity"],
|
||||
["$PokemonBag.pbHasItem?", "$bag.has?"],
|
||||
["$PokemonBag.pbCanStore?", "$bag.can_add?"],
|
||||
["$PokemonBag.pbStoreItem", "$bag.add"],
|
||||
["$PokemonBag.pbStoreAllOrNone", "$bag.add_all"],
|
||||
["$PokemonBag.pbChangeItem", "$bag.replace_item"],
|
||||
["$PokemonBag.pbDeleteItem", "$bag.remove"],
|
||||
["$PokemonBag.pbIsRegistered?", "$bag.registered?"],
|
||||
["$PokemonBag.pbRegisterItem", "$bag.register"],
|
||||
["$PokemonBag.pbUnregisterItem", "$bag.unregister"],
|
||||
["$PokemonBag", "$bag"],
|
||||
["pbQuantity", "$bag.quantity"],
|
||||
["pbHasItem?", "$bag.has?"],
|
||||
["pbCanStore?", "$bag.can_add?"],
|
||||
["pbStoreItem", "$bag.add"],
|
||||
["pbStoreAllOrNone", "$bag.add_all"],
|
||||
["$Trainer", "$player"],
|
||||
["$SaveVersion", "$save_engine_version"],
|
||||
["$game_version", "$save_game_version"],
|
||||
["$MapFactory", "$map_factory"],
|
||||
["pbDayCareDeposited", "DayCare.count"],
|
||||
["pbDayCareGetDeposited", "DayCare.get_details"],
|
||||
["pbDayCareGetLevelGain", "DayCare.get_level_gain"],
|
||||
["pbDayCareDeposit", "DayCare.deposit"],
|
||||
["pbDayCareWithdraw", "DayCare.withdraw"],
|
||||
["pbDayCareChoose", "DayCare.choose"],
|
||||
["pbDayCareGetCompatibility", "DayCare.get_compatibility"],
|
||||
["pbEggGenerated?", "DayCare.egg_generated?"],
|
||||
["pbDayCareGenerateEgg", "DayCare.collect_egg"],
|
||||
["get_character(0)", "get_self"],
|
||||
["get_character(-1)", "get_player"]
|
||||
]
|
||||
|
||||
module_function
|
||||
@@ -52,7 +52,7 @@ module Compiler
|
||||
mapinfos = pbLoadMapInfos
|
||||
maxOrder = 0
|
||||
# Exclude maps found in mapinfos
|
||||
mapinfos.keys.each do |id|
|
||||
mapinfos.each_key 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
|
||||
mapfiles.keys.each do |id|
|
||||
mapfiles.each_key do |id|
|
||||
next if id == 999 # Ignore 999 (random dungeon map)
|
||||
mapinfo = RPG::MapInfo.new
|
||||
mapinfo.order = maxOrder
|
||||
@@ -314,7 +314,7 @@ module Compiler
|
||||
@mapHeights[mapID] = map.height
|
||||
mapPositions = []
|
||||
width = map.width
|
||||
map.events.values.each do |e|
|
||||
map.events.each_value do |e|
|
||||
mapPositions[(e.y * width) + e.x] = e if e
|
||||
end
|
||||
@mapxy[mapID] = mapPositions
|
||||
@@ -780,7 +780,7 @@ module Compiler
|
||||
if mapData.switchName(lastPage.condition.switch1_id) == 's:tsOff?("A")'
|
||||
list = event.pages[event.pages.length - 2].list
|
||||
transferCommand = list.find_all { |cmd| cmd.code == 201 } # Transfer Player
|
||||
if transferCommand.length == 1 && !list.any? { |cmd| cmd.code == 208 } # Change Transparent Flag
|
||||
if transferCommand.length == 1 && list.none? { |cmd| cmd.code == 208 } # Change Transparent Flag
|
||||
# Rewrite penultimate page
|
||||
list.clear
|
||||
push_move_route_and_wait( # Move Route for door opening
|
||||
@@ -1431,7 +1431,7 @@ module Compiler
|
||||
def check_counters(map, mapID, mapData)
|
||||
toDelete = []
|
||||
changed = false
|
||||
map.events.keys.each do |key|
|
||||
map.events.each_key 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é
|
||||
@@ -1478,7 +1478,7 @@ module Compiler
|
||||
changed = false
|
||||
map = mapData.getMap(id)
|
||||
next if !map || !mapData.mapinfos[id]
|
||||
map.events.keys.each do |key|
|
||||
map.events.each_key do |key|
|
||||
if Time.now.to_i - t >= 5
|
||||
Graphics.update
|
||||
t = Time.now.to_i
|
||||
|
||||
Reference in New Issue
Block a user