Yet more Rubocopping

This commit is contained in:
Maruno17
2021-12-23 00:27:17 +00:00
parent 514fe13ca2
commit 132a16950d
171 changed files with 1455 additions and 1647 deletions

View File

@@ -22,7 +22,7 @@ module DebugMenuCommands
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)

View File

@@ -21,8 +21,8 @@ def pbWarpToMap
next if !map.passableStrict?(x, y, 0, $game_player)
blocked = false
map.events.values.each do |event|
if event.at_coordinate?(x, y) && !event.through
blocked = true if event.character_name != ""
if event.at_coordinate?(x, y) && !event.through && event.character_name != ""
blocked = true
end
end
next if blocked
@@ -101,7 +101,7 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
status = $game_variables[index + 1].to_s
status = "\"__\"" if nil_or_empty?(status)
end
name = '' if name == nil
name = '' if name.nil?
id_text = sprintf("%04d:", index + 1)
rect = drawCursor(index, rect)
totalWidth = rect.width
@@ -117,11 +117,11 @@ end
def pbDebugSetVariable(id, diff)
$game_variables[id] = 0 if $game_variables[id] == nil
$game_variables[id] = 0 if $game_variables[id].nil?
if $game_variables[id].is_a?(Numeric)
pbPlayCursorSE
$game_variables[id] = [$game_variables[id] + diff, 99999999].min
$game_variables[id] = [$game_variables[id], -99999999].max
$game_variables[id] = [$game_variables[id] + diff, 99_999_999].min
$game_variables[id] = [$game_variables[id], -99_999_999].max
$game_map.need_refresh = true
end
end
@@ -135,8 +135,8 @@ def pbDebugVariableScreen(id)
params.setMaxDigits(8)
params.setNegativesAllowed(true)
value = pbMessageChooseNumber(_INTL("Set variable {1}.", id), params)
$game_variables[id] = [value, 99999999].min
$game_variables[id] = [$game_variables[id], -99999999].max
$game_variables[id] = [value, 99_999_999].min
$game_variables[id] = [$game_variables[id], -99_999_999].max
$game_map.need_refresh = true
when String
value = pbMessageFreeText(_INTL("Set variable {1}.", id),
@@ -623,7 +623,7 @@ def pbImportAllAnimations
Graphics.update
audios = []
files = Dir.glob(folder + "/*.*")
%w[wav ogg mid wma].each { |ext| # mp3
["wav", "ogg", "mid", "wma"].each { |ext| # mp3
upext = ext.upcase
audios.concat(files.find_all { |f| f[f.length - 3, 3] == ext })
audios.concat(files.find_all { |f| f[f.length - 3, 3] == upext })
@@ -632,7 +632,7 @@ def pbImportAllAnimations
pbSafeCopyFile(audio, RTP.getAudioPath("Audio/SE/Anim/" + File.basename(audio)), "Audio/SE/Anim/" + File.basename(audio))
end
images = []
%w[png gif].each { |ext| # jpg jpeg bmp
["png", "gif"].each { |ext| # jpg jpeg bmp
upext = ext.upcase
images.concat(files.find_all { |f| f[f.length - 3, 3] == ext })
images.concat(files.find_all { |f| f[f.length - 3, 3] == upext })
@@ -642,26 +642,24 @@ def pbImportAllAnimations
end
Dir.glob(folder + "/*.anm") { |f|
textdata = loadBase64Anim(IO.read(f)) rescue nil
if textdata && textdata.is_a?(PBAnimation)
if textdata.is_a?(PBAnimation)
index = pbAllocateAnimation(animations, textdata.name)
missingFiles = []
textdata.name = File.basename(folder) if textdata.name == ""
textdata.id = -1 # This is not an RPG Maker XP animation
pbConvertAnimToNewFormat(textdata)
if textdata.graphic && textdata.graphic != ""
if !safeExists?(folder + "/" + textdata.graphic) &&
!FileTest.image_exist?("Graphics/Animations/" + textdata.graphic)
textdata.graphic = ""
missingFiles.push(textdata.graphic)
end
if textdata.graphic && textdata.graphic != "" &&
!safeExists?(folder + "/" + textdata.graphic) &&
!FileTest.image_exist?("Graphics/Animations/" + textdata.graphic)
textdata.graphic = ""
missingFiles.push(textdata.graphic)
end
textdata.timing.each do |timing|
if timing.name && timing.name != ""
if !safeExists?(folder + "/" + timing.name) &&
!FileTest.audio_exist?("Audio/SE/Anim/" + timing.name)
timing.name = ""
missingFiles.push(timing.name)
end
if timing.name && timing.name != "" &&
!safeExists?(folder + "/" + timing.name) &&
!FileTest.audio_exist?("Audio/SE/Anim/" + timing.name)
timing.name = ""
missingFiles.push(timing.name)
end
end
animations[index] = textdata

View File

@@ -22,7 +22,7 @@ module PokemonDebugMenuCommands
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)
@@ -1029,7 +1029,7 @@ PokemonDebugMenuCommands.register("ownership", {
pkmn.owner.id = $player.make_foreign_ID
when 4 # Set foreign ID
params = ChooseNumberParams.new
params.setRange(0, 65535)
params.setRange(0, 65_535)
params.setDefaultValue(pkmn.owner.public_id)
val = pbMessageChooseNumber(
_INTL("Set the new ID (max. 65535)."), params
@@ -1129,11 +1129,11 @@ PokemonDebugMenuCommands.register("shadow_pkmn", {
break if cmd < 0
case cmd
when 0 # Make Shadow
if !pkmn.shadowPokemon?
if pkmn.shadowPokemon?
screen.pbDisplay(_INTL("{1} is already a Shadow Pokémon.", pkmn.name))
else
pkmn.makeShadow
screen.pbRefreshSingle(pkmnid)
else
screen.pbDisplay(_INTL("{1} is already a Shadow Pokémon.", pkmn.name))
end
when 1 # Set heart gauge
if pkmn.shadowPokemon?

View File

@@ -44,7 +44,7 @@ module BattleDebugMenuCommands
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)

View File

@@ -32,7 +32,7 @@ module BattlePokemonDebugMenuCommands
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)
@@ -241,7 +241,7 @@ BattlePokemonDebugMenuCommands.register("set_level", {
if level != pkmn.level
pkmn.level = level
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
}
})
@@ -315,7 +315,7 @@ BattlePokemonDebugMenuCommands.register("hidden_values", {
if f != pkmn.ev[ev_id[cmd2]]
pkmn.ev[ev_id[cmd2]] = f
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
else # (Max) Randomise all
evTotalTarget = Pokemon::EV_LIMIT
@@ -334,7 +334,7 @@ BattlePokemonDebugMenuCommands.register("hidden_values", {
evTotalTarget -= addVal
end
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
end
when 1 # Set IVs
@@ -365,12 +365,12 @@ BattlePokemonDebugMenuCommands.register("hidden_values", {
if f != pkmn.iv[iv_id[cmd2]]
pkmn.iv[iv_id[cmd2]] = f
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
else # Randomise all
GameData::Stat.each_main { |s| pkmn.iv[s.id] = rand(Pokemon::IV_STAT_LIMIT + 1) }
pkmn.calc_stats
battler.pbUpdate if battler
battler&.pbUpdate
end
end
end
@@ -467,7 +467,7 @@ BattlePokemonDebugMenuCommands.register("teach_move", {
next
end
pkmn.learn_move(new_move)
battler.moves.push(Battle::Move.from_pokemon_move(self, pkmn.moves.last)) if battler
battler&.moves&.push(Battle::Move.from_pokemon_move(self, pkmn.moves.last))
pbMessage("\\ts[]" + _INTL("{1} learned {2}!", pkmn.name, move_name))
}
})
@@ -492,7 +492,7 @@ BattlePokemonDebugMenuCommands.register("forget_move", {
next if cmd < 0
old_move_name = pkmn.moves[move_indices[cmd]].name
pkmn.forget_move_at_index(move_indices[cmd])
battler.moves.delete_at(move_indices[cmd]) if battler
battler&.moves&.delete_at(move_indices[cmd])
pbMessage("\\ts[]" + _INTL("{1} forgot {2}.", pkmn.name, old_move_name))
}
})
@@ -688,7 +688,7 @@ BattlePokemonDebugMenuCommands.register("set_nature", {
elsif cmd == commands.length - 1 # Reset
pkmn.nature = nil
end
battler.pbUpdate if battler
battler&.pbUpdate
end
}
})

View File

@@ -119,7 +119,7 @@ module Battle::DebugVariables
PBEffects::Unburden => { name: "Self lost its item (for Unburden)", default: false },
PBEffects::Uproar => { name: "Uproar number of rounds remaining", default: 0 },
PBEffects::WaterSport => { name: "Used Water Sport (Gen 5 and older)", default: false },
PBEffects::WeightChange => { name: "Weight change +0.1*x kg", default: 0, min: -99999, max: 99999 },
PBEffects::WeightChange => { name: "Weight change +0.1*x kg", default: 0, min: -99_999, max: 99_999 },
PBEffects::Yawn => { name: "Yawn rounds remaining until falling asleep", default: 0 }
}
@@ -421,7 +421,7 @@ class Battle::DebugSetEffects
@window.refresh if update_input_for_integer(effect, variable_data[:default], variable_data)
elsif variable_data[:default] == -1
@window.refresh if update_input_for_battler_index(effect, variable_data)
elsif variable_data[:default] == nil
elsif variable_data[:default].nil?
case variable_data[:type]
when :move
@window.refresh if update_input_for_move(effect, variable_data)