More Rubocop changes

This commit is contained in:
Maruno17
2022-02-13 00:57:54 +00:00
parent cca5989746
commit f68e699cc9
108 changed files with 708 additions and 808 deletions

View File

@@ -1,9 +1,9 @@
class IntroEventScene < EventScene
# Splash screen images that appear for a few seconds and then disappear.
SPLASH_IMAGES = ['splash1', 'splash2']
SPLASH_IMAGES = ["splash1", "splash2"]
# The main title screen background image.
TITLE_BG_IMAGE = 'title'
TITLE_START_IMAGE = 'start'
TITLE_BG_IMAGE = "title"
TITLE_START_IMAGE = "start"
TITLE_START_IMAGE_X = 0
TITLE_START_IMAGE_Y = 322
SECONDS_PER_SPLASH = 2

View File

@@ -419,7 +419,7 @@ class PokemonPokedex_Scene
dexname = _INTL("Pokédex")
if $player.pokedex.dexes_count > 1
thisdex = Settings.pokedex_names[pbGetSavePositionIndex]
if thisdex != nil
if thisdex
dexname = (thisdex.is_a?(Array)) ? thisdex[0] : thisdex
end
end
@@ -1166,40 +1166,40 @@ class PokemonPokedex_Scene
case index
when 0 # Choose sort order
newparam = pbDexSearchCommands(0, [params[0]], index)
params[0] = newparam[0] if newparam != nil
params[0] = newparam[0] if newparam
pbRefreshDexSearch(params, index)
when 1 # Filter by name
newparam = pbDexSearchCommands(1, [params[1]], index)
params[1] = newparam[0] if newparam != nil
params[1] = newparam[0] if newparam
pbRefreshDexSearch(params, index)
when 2 # Filter by type
newparam = pbDexSearchCommands(2, [params[2], params[3]], index)
if newparam != nil
if newparam
params[2] = newparam[0]
params[3] = newparam[1]
end
pbRefreshDexSearch(params, index)
when 3 # Filter by height range
newparam = pbDexSearchCommands(3, [params[4], params[5]], index)
if newparam != nil
if newparam
params[4] = newparam[0]
params[5] = newparam[1]
end
pbRefreshDexSearch(params, index)
when 4 # Filter by weight range
newparam = pbDexSearchCommands(4, [params[6], params[7]], index)
if newparam != nil
if newparam
params[6] = newparam[0]
params[7] = newparam[1]
end
pbRefreshDexSearch(params, index)
when 5 # Filter by color filter
newparam = pbDexSearchCommands(5, [params[8]], index)
params[8] = newparam[0] if newparam != nil
params[8] = newparam[0] if newparam
pbRefreshDexSearch(params, index)
when 6 # Filter by shape
newparam = pbDexSearchCommands(6, [params[9]], index)
params[9] = newparam[0] if newparam != nil
params[9] = newparam[0] if newparam
pbRefreshDexSearch(params, index)
when 7 # Clear filters
10.times do |i|

View File

@@ -27,14 +27,13 @@ class PokemonPokedexInfo_Scene
@sprites["areamap"].x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2
@sprites["areamap"].y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2
Settings::REGION_MAP_EXTRAS.each do |hidden|
if hidden[0] == @region && hidden[1] > 0 && $game_switches[hidden[1]]
pbDrawImagePositions(
@sprites["areamap"].bitmap,
[["Graphics/Pictures/#{hidden[4]}",
hidden[2] * PokemonRegionMap_Scene::SQUARE_WIDTH,
hidden[3] * PokemonRegionMap_Scene::SQUARE_HEIGHT]]
)
end
next if hidden[0] != @region || hidden[1] <= 0 || !$game_switches[hidden[1]]
pbDrawImagePositions(
@sprites["areamap"].bitmap,
[["Graphics/Pictures/#{hidden[4]}",
hidden[2] * PokemonRegionMap_Scene::SQUARE_WIDTH,
hidden[3] * PokemonRegionMap_Scene::SQUARE_HEIGHT]]
)
end
@sprites["areahighlight"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@sprites["areaoverlay"] = IconSprite.new(0, 0, @viewport)
@@ -331,24 +330,23 @@ class PokemonPokedexInfo_Scene
sqwidth = PokemonRegionMap_Scene::SQUARE_WIDTH
sqheight = PokemonRegionMap_Scene::SQUARE_HEIGHT
points.length.times do |j|
if points[j]
x = (j % mapwidth) * sqwidth
x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2
y = (j / mapwidth) * sqheight
y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2
@sprites["areahighlight"].bitmap.fill_rect(x, y, sqwidth, sqheight, pointcolor)
if j - mapwidth < 0 || !points[j - mapwidth]
@sprites["areahighlight"].bitmap.fill_rect(x, y - 2, sqwidth, 2, pointcolorhl)
end
if j + mapwidth >= points.length || !points[j + mapwidth]
@sprites["areahighlight"].bitmap.fill_rect(x, y + sqheight, sqwidth, 2, pointcolorhl)
end
if j % mapwidth == 0 || !points[j - 1]
@sprites["areahighlight"].bitmap.fill_rect(x - 2, y, 2, sqheight, pointcolorhl)
end
if (j + 1) % mapwidth == 0 || !points[j + 1]
@sprites["areahighlight"].bitmap.fill_rect(x + sqwidth, y, 2, sqheight, pointcolorhl)
end
next if !points[j]
x = (j % mapwidth) * sqwidth
x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2
y = (j / mapwidth) * sqheight
y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2
@sprites["areahighlight"].bitmap.fill_rect(x, y, sqwidth, sqheight, pointcolor)
if j - mapwidth < 0 || !points[j - mapwidth]
@sprites["areahighlight"].bitmap.fill_rect(x, y - 2, sqwidth, 2, pointcolorhl)
end
if j + mapwidth >= points.length || !points[j + mapwidth]
@sprites["areahighlight"].bitmap.fill_rect(x, y + sqheight, sqwidth, 2, pointcolorhl)
end
if j % mapwidth == 0 || !points[j - 1]
@sprites["areahighlight"].bitmap.fill_rect(x - 2, y, 2, sqheight, pointcolorhl)
end
if (j + 1) % mapwidth == 0 || !points[j + 1]
@sprites["areahighlight"].bitmap.fill_rect(x + sqwidth, y, 2, sqheight, pointcolorhl)
end
end
# Set the text

View File

@@ -593,7 +593,7 @@ class PokemonParty_Scene
end
def pbHasAnnotations?
return @sprites["pokemon0"].text != nil
return !@sprites["pokemon0"].text.nil?
end
def pbAnnotate(annot)
@@ -1328,7 +1328,6 @@ MenuHandlers.add(:party_menu, :item, {
"order" => 50,
"condition" => proc { |screen, party, party_idx| next !party[party_idx].egg? && !party[party_idx].mail },
"effect" => proc { |screen, party, party_idx|
pkmn = party[party_idx]
# Get all commands
command_list = []
commands = []

View File

@@ -1048,15 +1048,14 @@ class PokemonSummary_Scene
hasMovedCursor = true
pbPlayCursorSE
end
if hasMovedCursor
@ribbonOffset = (selribbon / 4).floor if selribbon < @ribbonOffset * 4
@ribbonOffset = (selribbon / 4).floor - 2 if selribbon >= (@ribbonOffset + 3) * 4
@ribbonOffset = 0 if @ribbonOffset < 0
@ribbonOffset = numRows - 3 if @ribbonOffset > numRows - 3
@sprites["ribbonsel"].index = selribbon - (@ribbonOffset * 4)
@sprites["ribbonpresel"].index = oldselribbon - (@ribbonOffset * 4)
drawSelectedRibbon(@pokemon.ribbons[selribbon])
end
next if !hasMovedCursor
@ribbonOffset = (selribbon / 4).floor if selribbon < @ribbonOffset * 4
@ribbonOffset = (selribbon / 4).floor - 2 if selribbon >= (@ribbonOffset + 3) * 4
@ribbonOffset = 0 if @ribbonOffset < 0
@ribbonOffset = numRows - 3 if @ribbonOffset > numRows - 3
@sprites["ribbonsel"].index = selribbon - (@ribbonOffset * 4)
@sprites["ribbonpresel"].index = oldselribbon - (@ribbonOffset * 4)
drawSelectedRibbon(@pokemon.ribbons[selribbon])
end
@sprites["ribbonsel"].visible = false
end

View File

@@ -270,11 +270,10 @@ class PokemonBag_Scene
@sprites["pocketicon"].bitmap.clear
if @choosing && @filterlist
(1...@bag.pockets.length).each do |i|
if @filterlist[i].length == 0
@sprites["pocketicon"].bitmap.blt(
6 + ((i - 1) * 22), 6, @pocketbitmap.bitmap, Rect.new((i - 1) * 20, 28, 20, 20)
)
end
next if @filterlist[i].length > 0
@sprites["pocketicon"].bitmap.blt(
6 + ((i - 1) * 22), 6, @pocketbitmap.bitmap, Rect.new((i - 1) * 20, 28, 20, 20)
)
end
end
@sprites["pocketicon"].bitmap.blt(
@@ -685,16 +684,14 @@ class PokemonBagScreen
if qty > 1
qty = @scene.pbChooseNumber(_INTL("Toss out how many {1}?", itemnameplural), qty)
end
if qty > 0
itemname = itemnameplural if qty > 1
if pbConfirm(_INTL("Is it OK to throw away {1} {2}?", qty, itemname))
if !storage.remove(item, qty)
raise "Can't delete items from storage"
end
@scene.pbRefresh
pbDisplay(_INTL("Threw away {1} {2}.", qty, itemname))
end
next if qty <= 0
itemname = itemnameplural if qty > 1
next if !pbConfirm(_INTL("Is it OK to throw away {1} {2}?", qty, itemname))
if !storage.remove(item, qty)
raise "Can't delete items from storage"
end
@scene.pbRefresh
pbDisplay(_INTL("Threw away {1} {2}.", qty, itemname))
end
@scene.pbEndScene
end

View File

@@ -226,9 +226,9 @@ class PokemonLoadScreen
def load_save_file(file_path)
save_data = SaveData.read_from_file(file_path)
unless SaveData.valid?(save_data)
if File.file?(file_path + '.bak')
pbMessage(_INTL('The save file is corrupt. A backup will be loaded.'))
save_data = load_save_file(file_path + '.bak')
if File.file?(file_path + ".bak")
pbMessage(_INTL("The save file is corrupt. A backup will be loaded."))
save_data = load_save_file(file_path + ".bak")
else
self.prompt_save_deletion
return {}
@@ -240,9 +240,9 @@ class PokemonLoadScreen
# Called if all save data is invalid.
# Prompts the player to delete the save files.
def prompt_save_deletion
pbMessage(_INTL('The save file is corrupt, or is incompatible with this game.'))
pbMessage(_INTL("The save file is corrupt, or is incompatible with this game."))
exit unless pbConfirmMessageSerious(
_INTL('Do you want to delete the save file and start anew?')
_INTL("Do you want to delete the save file and start anew?")
)
self.delete_save_data
$game_system = Game_System.new
@@ -270,9 +270,9 @@ class PokemonLoadScreen
def delete_save_data
begin
SaveData.delete_file
pbMessage(_INTL('The saved data was deleted.'))
pbMessage(_INTL("The saved data was deleted."))
rescue SystemCallError
pbMessage(_INTL('All saved data could not be deleted.'))
pbMessage(_INTL("All saved data could not be deleted."))
end
end
@@ -287,16 +287,16 @@ class PokemonLoadScreen
cmd_quit = -1
show_continue = !@save_data.empty?
if show_continue
commands[cmd_continue = commands.length] = _INTL('Continue')
commands[cmd_continue = commands.length] = _INTL("Continue")
if @save_data[:player].mystery_gift_unlocked
commands[cmd_mystery_gift = commands.length] = _INTL('Mystery Gift')
commands[cmd_mystery_gift = commands.length] = _INTL("Mystery Gift")
end
end
commands[cmd_new_game = commands.length] = _INTL('New Game')
commands[cmd_options = commands.length] = _INTL('Options')
commands[cmd_language = commands.length] = _INTL('Language') if Settings::LANGUAGES.length >= 2
commands[cmd_debug = commands.length] = _INTL('Debug') if $DEBUG
commands[cmd_quit = commands.length] = _INTL('Quit Game')
commands[cmd_new_game = commands.length] = _INTL("New Game")
commands[cmd_options = commands.length] = _INTL("Options")
commands[cmd_language = commands.length] = _INTL("Language") if Settings::LANGUAGES.length >= 2
commands[cmd_debug = commands.length] = _INTL("Debug") if $DEBUG
commands[cmd_quit = commands.length] = _INTL("Quit Game")
map_id = show_continue ? @save_data[:map_factory].map.map_id : 0
@scene.pbStartScene(commands, show_continue, @save_data[:player],
@save_data[:frame_count] || 0, @save_data[:stats], map_id)
@@ -325,10 +325,10 @@ class PokemonLoadScreen
when cmd_language
@scene.pbEndScene
$PokemonSystem.language = pbChooseLanguage
pbLoadMessages('Data/' + Settings::LANGUAGES[$PokemonSystem.language][1])
pbLoadMessages("Data/" + Settings::LANGUAGES[$PokemonSystem.language][1])
if show_continue
@save_data[:pokemon_system] = $PokemonSystem
File.open(SaveData::FILE_PATH, 'wb') { |file| Marshal.dump(@save_data, file) }
File.open(SaveData::FILE_PATH, "wb") { |file| Marshal.dump(@save_data, file) }
end
$scene = pbCallTitle
return

View File

@@ -4,8 +4,8 @@ def pbEmergencySave
pbMessage(_INTL("The script is taking too long. The game will restart."))
return if !$player
if SaveData.exists?
File.open(SaveData::FILE_PATH, 'rb') do |r|
File.open(SaveData::FILE_PATH + '.bak', 'wb') do |w|
File.open(SaveData::FILE_PATH, "rb") do |r|
File.open(SaveData::FILE_PATH + ".bak", "wb") do |w|
loop do
s = r.read(4096)
break if !s
@@ -84,19 +84,19 @@ class PokemonSaveScreen
def pbSaveScreen
ret = false
@scene.pbStartScreen
if pbConfirmMessage(_INTL('Would you like to save the game?'))
if pbConfirmMessage(_INTL("Would you like to save the game?"))
if SaveData.exists? && $game_temp.begun_new_game
pbMessage(_INTL('WARNING!'))
pbMessage(_INTL('There is a different game file that is already saved.'))
pbMessage(_INTL("WARNING!"))
pbMessage(_INTL("There is a different game file that is already saved."))
pbMessage(_INTL("If you save now, the other file's adventure, including items and Pokémon, will be entirely lost."))
if !pbConfirmMessageSerious(_INTL('Are you sure you want to save now and overwrite the other save file?'))
pbSEPlay('GUI save choice')
if !pbConfirmMessageSerious(_INTL("Are you sure you want to save now and overwrite the other save file?"))
pbSEPlay("GUI save choice")
@scene.pbEndScreen
return false
end
end
$game_temp.begun_new_game = false
pbSEPlay('GUI save choice')
pbSEPlay("GUI save choice")
if Game.save
pbMessage(_INTL("\\se[]{1} saved the game.\\me[GUI save game]\\wtnp[30]", $player.name))
ret = true
@@ -105,7 +105,7 @@ class PokemonSaveScreen
ret = false
end
else
pbSEPlay('GUI save choice')
pbSEPlay("GUI save choice")
end
@scene.pbEndScreen
return ret

View File

@@ -193,14 +193,14 @@ class Window_PokemonOption < Window_DrawableCommand
when EnumOption
if @options[index].values.length > 1
totalwidth = 0
@options[index].values.each do |value|
@options[index].each_value do |value|
totalwidth += self.contents.text_size(value).width
end
spacing = (rect.width - rect.x - optionwidth - totalwidth) / (@options[index].values.length - 1)
spacing = 0 if spacing < 0
xpos = optionwidth + rect.x
ivalue = 0
@options[index].values.each do |value|
@options[index].each_value do |value|
pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value,
(ivalue == self[index]) ? SEL_VALUE_BASE_COLOR : self.baseColor,
(ivalue == self[index]) ? SEL_VALUE_SHADOW_COLOR : self.shadowColor)
@@ -215,7 +215,7 @@ class Window_PokemonOption < Window_DrawableCommand
when NumberOption
value = _INTL("Type {1}/{2}", @options[index].lowest_value + self[index],
@options[index].highest_value - @options[index].lowest_value + 1)
xpos = optionwidth + rect.x * 2
xpos = optionwidth + (rect.x * 2)
pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value,
SEL_VALUE_BASE_COLOR, SEL_VALUE_SHADOW_COLOR, 1)
when SliderOption

View File

@@ -543,12 +543,11 @@ class PokemonBoxPartySprite < SpriteWrapper
@pokemonsprites.each { |sprite| sprite&.refresh }
Settings::MAX_PARTY_SIZE.times do |j|
sprite = @pokemonsprites[j]
if sprite && !sprite.disposed?
sprite.viewport = self.viewport
sprite.x = self.x + xvalues[j]
sprite.y = self.y + yvalues[j]
sprite.z = 0
end
next if sprite.nil? || sprite.disposed?
sprite.viewport = self.viewport
sprite.x = self.x + xvalues[j]
sprite.y = self.y + yvalues[j]
sprite.z = 0
end
end

View File

@@ -126,7 +126,7 @@ class PurifyChamberSet
unless value&.shadowPokemon?
@list.insert(index + 1, value)
@list.compact!
@facing += 1 if @facing > index && value != nil
@facing += 1 if @facing > index && value
@facing = [[@facing, @list.length - 1].min, 0].max
end
end
@@ -246,16 +246,16 @@ class PurifyChamber
isPurifiableIgnoreRegular?(set) && setCount(set) > 0
end
def update # called each step
# Called upon each step taken in the overworld
def update
NUMSETS.times do |set|
# If a shadow Pokemon and a regular Pokemon are on the same set
if @sets[set].shadow && @sets[set].shadow.heart_gauge > 0
flow = self.chamberFlow(set)
@sets[set].shadow.adjustHeart(-flow)
if isPurifiable?(set)
pbMessage(_INTL("Your {1} in the Purify Chamber is ready for purification!", @sets[set].shadow.name))
end
end
next if !@sets[set].shadow || @sets[set].shadow.heart_gauge <= 0
# If a Shadow Pokemon and a regular Pokemon are on the same set
flow = self.chamberFlow(set)
@sets[set].shadow.adjustHeart(-flow)
next if !isPurifiable?(set)
pbMessage(_INTL("Your {1} in the Purify Chamber is ready for purification!",
@sets[set].shadow.name))
end
end
@@ -1261,11 +1261,10 @@ class PurifyChamberScene
set = @sprites["setview"].set
(@chamber.setCount(set) * 2).times do |i|
p = PurifyChamberHelper.pbGetPokemon2(@chamber, set, i)
if p
startindex = party.length if i == pos
party.push(p)
indexes.push(i)
end
next if !p
startindex = party.length if i == pos
party.push(p)
indexes.push(i)
end
return if party.length == 0
oldsprites = pbFadeOutAndHide(@sprites)