From 5dc64f1709a1fde664c1d82c9a40d5a6e854d226 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 17 Dec 2021 20:29:47 +0000 Subject: [PATCH] Minor refactoring to kill various Rubocop warnings --- .../001_Technical/002_Files/001_FileTests.rb | 6 ++-- .../002_Files/003_HTTP_Utilities.rb | 2 +- .../001_Technical/003_Intl_Messages.rb | 3 +- .../003_Game processing/003_Interpreter.rb | 4 +-- .../003_Game processing/005_Event_Handlers.rb | 16 +++------ .../004_Game classes/002_Game_System.rb | 12 ++----- Data/Scripts/005_Sprites/007_Spriteset_Map.rb | 2 +- .../006_Map renderer/001_TilemapRenderer.rb | 2 +- .../006_Map renderer/002_TilesetWrapper.rb | 2 +- .../007_Objects and windows/003_Window.rb | 17 +++++----- .../004_SpriteWindow.rb | 14 ++++---- .../005_SpriteWindow_text.rb | 5 +-- .../006_SpriteWindow_pictures.rb | 8 ++--- .../007_SpriteWrapper.rb | 4 +-- .../007_Objects and windows/010_DrawText.rb | 4 +-- .../007_Objects and windows/011_Messages.rb | 11 ++---- .../007_Objects and windows/012_TextEntry.rb | 8 ++--- Data/Scripts/008_Audio/001_Audio.rb | 4 +-- Data/Scripts/008_Audio/002_Audio_Play.rb | 4 +-- Data/Scripts/009_Scenes/001_Transitions.rb | 2 +- .../010_Data/002_PBS data/008_Species.rb | 2 +- .../010_Data/002_PBS data/015_Trainer.rb | 2 +- .../003_Battle_ExpAndMoveLearning.rb | 5 ++- .../002_Battler/005_Battler_StatStages.rb | 4 +-- .../003_Move/011_MoveEffects_Items.rb | 3 +- .../004_Scene/003_Scene_ChooseCommands.rb | 9 ++--- .../004_Scene/004_Scene_PlayAnimations.rb | 6 ++-- .../004_Scene/009_Battle_DebugScene.rb | 4 +-- .../011_Battle/005_AI/001_Battle_AI.rb | 2 +- .../004_BattleArenaBattle.rb | 34 +++++++++++++++---- .../006_Overworld_BerryPlants.rb | 2 +- .../008_Overworld_RandomDungeons.rb | 2 +- .../001_Pokemon-related/001_FormHandlers.rb | 2 +- .../006_UI_HallOfFame.rb | 10 +++--- Data/Scripts/016_UI/003_UI_Pokedex_Main.rb | 4 +-- Data/Scripts/016_UI/022_UI_PurifyChamber.rb | 6 ++-- .../017_Minigames/004_Minigame_VoltorbFlip.rb | 2 +- .../001_Challenge_BattleChallenge.rb | 4 +-- .../001_Battle Frontier/005_UI_BattleSwap.rb | 2 +- .../002_ChallengeGenerator_Pokemon.rb | 1 - .../019_Utilities/002_Utilities_Pokemon.rb | 34 +++++++++---------- .../001_Editor screens/001_EditorScreens.rb | 6 ++-- .../002_AnimEditor_ControlsButtons.rb | 2 +- .../021_Compiler/002_Compiler_CompilePBS.rb | 2 +- .../021_Compiler/003_Compiler_WritePBS.rb | 8 ++--- .../004_Compiler_MapsAndEvents.rb | 8 ++--- 46 files changed, 145 insertions(+), 151 deletions(-) diff --git a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb index c05901c94..63182aa92 100644 --- a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb +++ b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb @@ -277,7 +277,7 @@ end # Used to determine whether a data file exists (rather than a graphics or # audio file). Doesn't check RTP, but does check encrypted archives. -# Note: pbGetFileChar checks anything added in MKXP's RTP setting, +# NOTE: pbGetFileChar checks anything added in MKXP's RTP setting, # and matching mount points added through System.mount def pbRgssExists?(filename) if safeExists?("./Game.rgssad") @@ -291,7 +291,7 @@ end # Opens an IO, even if the file is in an encrypted archive. # Doesn't check RTP for the file. -# Note: load_data checks anything added in MKXP's RTP setting, +# NOTE: load_data checks anything added in MKXP's RTP setting, # and matching mount points added through System.mount def pbRgssOpen(file,mode=nil) #File.open("debug.txt","ab") { |fw| fw.write([file,mode,Time.now.to_f].inspect+"\r\n") } @@ -344,7 +344,7 @@ end # Gets the contents of a file. Doesn't check RTP, but does check # encrypted archives. -# Note: load_data will check anything added in MKXP's RTP setting, +# NOTE: load_data will check anything added in MKXP's RTP setting, # and matching mount points added through System.mount def pbGetFileString(file) file = canonicalize(file) diff --git a/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb b/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb index 7d1b4f512..11157ace3 100644 --- a/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb +++ b/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb @@ -31,7 +31,7 @@ def pbPostData(url, postdata, filename=nil, depth=0) return ret if !ret.is_a?(Hash) return "" if ret[:status] != 200 return ret[:body] if !filename - File.open(filename, "wb"){|f|f.write(ret[:body])} + File.open(filename, "wb") { |f| f.write(ret[:body]) } return "" end return "" diff --git a/Data/Scripts/001_Technical/003_Intl_Messages.rb b/Data/Scripts/001_Technical/003_Intl_Messages.rb index 98d820f13..77d092f82 100644 --- a/Data/Scripts/001_Technical/003_Intl_Messages.rb +++ b/Data/Scripts/001_Technical/003_Intl_Messages.rb @@ -259,7 +259,8 @@ def pbGetText(infile) end end i=0 - loop do break unless i0 diff --git a/Data/Scripts/005_Sprites/007_Spriteset_Map.rb b/Data/Scripts/005_Sprites/007_Spriteset_Map.rb index 4e07d4b36..505be30f6 100644 --- a/Data/Scripts/005_Sprites/007_Spriteset_Map.rb +++ b/Data/Scripts/005_Sprites/007_Spriteset_Map.rb @@ -40,7 +40,7 @@ class Spriteset_Map @@viewport3 = Viewport.new(0, 0, Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) # Flashing @@viewport3.z = 500 - def Spriteset_Map.viewport # For access by Spriteset_Global + def self.viewport # For access by Spriteset_Global return @@viewport1 end diff --git a/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb b/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb index 02bf5b475..62a974668 100644 --- a/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb +++ b/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb @@ -221,7 +221,7 @@ class TilemapRenderer super @timer += Graphics.delta_s # Update the current frame for each autotile - @bitmaps.keys.each do |filename| + @bitmaps.each_key do |filename| next if !@bitmaps[filename] || @bitmaps[filename].disposed? old_frame = @current_frames[filename] set_current_frame(filename) diff --git a/Data/Scripts/006_Map renderer/002_TilesetWrapper.rb b/Data/Scripts/006_Map renderer/002_TilesetWrapper.rb index 76727a337..449b4c4f3 100644 --- a/Data/Scripts/006_Map renderer/002_TilesetWrapper.rb +++ b/Data/Scripts/006_Map renderer/002_TilesetWrapper.rb @@ -67,7 +67,7 @@ class TilemapRenderer merge = (srcrect.y % MAX_TEX_SIZE) > ((srcrect.y + srcrect.height) % MAX_TEX_SIZE) srcrect_mod = getWrappedRect(srcrect) if merge - # FIXME won't work on heights longer than two columns, but nobody should need + # FIXME: won't work on heights longer than two columns, but nobody should need # more than 32k pixels high at once anyway side = { :a => MAX_TEX_SIZE - srcrect_mod.y, diff --git a/Data/Scripts/007_Objects and windows/003_Window.rb b/Data/Scripts/007_Objects and windows/003_Window.rb index be315ca5e..03775c0f5 100644 --- a/Data/Scripts/007_Objects and windows/003_Window.rb +++ b/Data/Scripts/007_Objects and windows/003_Window.rb @@ -6,7 +6,6 @@ class WindowCursorRect < Rect def empty return unless needs_update?(0, 0, 0, 0) - set(0, 0, 0, 0) end @@ -16,9 +15,7 @@ class WindowCursorRect < Rect def set(x, y, width, height) return unless needs_update?(x, y, width, height) - super(x, y, width, height) - @window.width = @window.width end @@ -336,9 +333,11 @@ class Window left=dstrect.x top=dstrect.y y = 0 - loop do break unless y < dstrect.height + loop do + break unless y < dstrect.height x = 0 - loop do break unless x < dstrect.width + loop do + break unless x < dstrect.width dstbitmap.blt(x+left,y+top,srcbitmap,srcrect) x+=srcrect.width end @@ -527,10 +526,10 @@ class Window rect = Rect.new(margin,margin, width - fullmargin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8]) - @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4])# top left - @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right - @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right - @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left + @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4]) # top left + @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right + @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right + @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left rect = Rect.new(margin, 0, width - fullmargin, margin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0]) diff --git a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb index cf5565a9f..3ca6b2c2c 100644 --- a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb +++ b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb @@ -456,9 +456,11 @@ class SpriteWindow < Window left=dstrect.x top=dstrect.y y = 0 - loop do break unless y < dstrect.height + loop do + break unless y < dstrect.height x = 0 - loop do break unless x < dstrect.width + loop do + break unless x < dstrect.width dstbitmap.blt(x+left,y+top,srcbitmap,srcrect) x+=srcrect.width end @@ -714,10 +716,10 @@ class SpriteWindow < Window @sprites["cursor"].src_rect.set(0,0,width,height) rect = Rect.new(margin,margin,width - fullmargin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8]) - @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4])# top left - @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right - @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right - @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left + @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4]) # top left + @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right + @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right + @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left rect = Rect.new(margin, 0,width - fullmargin, margin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0]) rect = Rect.new(0, margin,margin, height - fullmargin) diff --git a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb index 624971ed7..913d91142 100644 --- a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb +++ b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb @@ -731,6 +731,7 @@ end #=============================================================================== class SpriteWindow_Selectable < SpriteWindow_Base attr_reader :index + attr_writer :ignore_input def initialize(x, y, width, height) super(x, y, width, height) @@ -789,10 +790,6 @@ class SpriteWindow_Selectable < SpriteWindow_Base end end - def ignore_input=(value) - @ignore_input=value - end - def count return @item_max end diff --git a/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb b/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb index 33a367d0e..7c85dfac5 100644 --- a/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb +++ b/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb @@ -106,11 +106,9 @@ class PictureWindow < SpriteWindow_Base self.height=@_iconbitmap.bitmap.height+self.borderY else @_iconbitmap=AnimatedBitmap.new(pathOrBitmap,hue) - self.contents=@_iconbitmap ? @_iconbitmap.bitmap : nil - self.width=@_iconbitmap ? @_iconbitmap.bitmap.width+self.borderX : - 32+self.borderX - self.height=@_iconbitmap ? @_iconbitmap.bitmap.height+self.borderY : - 32+self.borderY + self.contents = @_iconbitmap&.bitmap + self.width = self.borderX + (@_iconbitmap&.bitmap&.width || 32) + self.height = self.borderY + (@_iconbitmap&.bitmap&.height || 32) end else @_iconbitmap=nil diff --git a/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb b/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb index 706088907..fb9b972b5 100644 --- a/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb +++ b/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb @@ -346,14 +346,14 @@ class ChangelingSprite < SpriteWrapper def dispose return if disposed? - @bitmaps.values.each { |bm| bm.dispose } + @bitmaps.each_value { |bm| bm.dispose } @bitmaps.clear super end def update return if disposed? - @bitmaps.values.each { |bm| bm.update } + @bitmaps.each_value { |bm| bm.update } self.bitmap = (@currentBitmap) ? @currentBitmap.bitmap : nil end end diff --git a/Data/Scripts/007_Objects and windows/010_DrawText.rb b/Data/Scripts/007_Objects and windows/010_DrawText.rb index 70502c807..87625611e 100644 --- a/Data/Scripts/007_Objects and windows/010_DrawText.rb +++ b/Data/Scripts/007_Objects and windows/010_DrawText.rb @@ -402,9 +402,9 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32, while text[FORMATREGEXP] textchunks.push($~.pre_match) if $~[3] - controls.push([$~[2].downcase,$~[4],-1,$~[1]=="/" ? true : false]) + controls.push([$~[2].downcase, $~[4], -1, $~[1] == "/"]) else - controls.push([$~[2].downcase,"",-1,$~[1]=="/" ? true : false]) + controls.push([$~[2].downcase, "", -1, $~[1] == "/"]) end text=$~.post_match end diff --git a/Data/Scripts/007_Objects and windows/011_Messages.rb b/Data/Scripts/007_Objects and windows/011_Messages.rb index 8c5f37069..f9a930f05 100644 --- a/Data/Scripts/007_Objects and windows/011_Messages.rb +++ b/Data/Scripts/007_Objects and windows/011_Messages.rb @@ -56,6 +56,9 @@ end # #=============================================================================== class ChooseNumberParams + attr_reader :messageSkin # Set the full path for the message's window skin + attr_reader :skin + def initialize @maxDigits=0 @minNumber=0 @@ -71,18 +74,10 @@ class ChooseNumberParams @messageSkin=value end - def messageSkin # Set the full path for the message's window skin - @messageSkin - end - def setSkin(value) @skin=value end - def skin - @skin - end - def setNegativesAllowed(value) @negativeAllowed=value end diff --git a/Data/Scripts/007_Objects and windows/012_TextEntry.rb b/Data/Scripts/007_Objects and windows/012_TextEntry.rb index 2e5d201a9..39b0e0d62 100644 --- a/Data/Scripts/007_Objects and windows/012_TextEntry.rb +++ b/Data/Scripts/007_Objects and windows/012_TextEntry.rb @@ -2,7 +2,7 @@ # #=============================================================================== class CharacterEntryHelper - attr_reader :text + attr_accessor :text attr_accessor :maxlength attr_reader :passwordChar attr_accessor :cursor @@ -14,10 +14,6 @@ class CharacterEntryHelper @cursor=text.scan(/./m).length end - def text=(value) - @text=value - end - def textChars chars=text.scan(/./m) if @passwordChar!="" @@ -502,7 +498,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base self.delete return end - Input.gets.each_char{|c|insert(c)} + Input.gets.each_char { |c| insert(c) } end def refresh diff --git a/Data/Scripts/008_Audio/001_Audio.rb b/Data/Scripts/008_Audio/001_Audio.rb index c0ebc8301..01d47a01b 100644 --- a/Data/Scripts/008_Audio/001_Audio.rb +++ b/Data/Scripts/008_Audio/001_Audio.rb @@ -79,7 +79,7 @@ def oggfiletime(file) end ret = 0.0 for i in 0...pcmlengths.length - ret += pcmlengths[i].to_f / rates[i].to_f + ret += pcmlengths[i].to_f / rates[i] end return ret * 256.0 end @@ -136,7 +136,7 @@ def getPlayTime2(filename) end file.pos = 0 # Find the length of an MP3 file - while true + loop do rstr = "" ateof = false while !file.eof? diff --git a/Data/Scripts/008_Audio/002_Audio_Play.rb b/Data/Scripts/008_Audio/002_Audio_Play.rb index b171f6af2..ab2fcb9c2 100644 --- a/Data/Scripts/008_Audio/002_Audio_Play.rb +++ b/Data/Scripts/008_Audio/002_Audio_Play.rb @@ -29,8 +29,8 @@ def pbResolveAudioFile(str,volume=nil,pitch=nil) end if str.is_a?(RPG::AudioFile) if volume || pitch - return RPG::AudioFile.new(str.name,volume || str.volume || 100 , - pitch || str.pitch || 100) + return RPG::AudioFile.new(str.name, volume || str.volume || 100, + pitch || str.pitch || 100) else return str end diff --git a/Data/Scripts/009_Scenes/001_Transitions.rb b/Data/Scripts/009_Scenes/001_Transitions.rb index 07d29633b..a15a76e7c 100644 --- a/Data/Scripts/009_Scenes/001_Transitions.rb +++ b/Data/Scripts/009_Scenes/001_Transitions.rb @@ -548,7 +548,7 @@ module Transitions for j in 0...NUM_SPRITES_Y for i in 0...NUM_SPRITES_X idx_from_start = j * NUM_SPRITES_X + i # Top left -> bottom right - case @parameters[0] || 0 # Origin + case @parameters[0] # Origin when 1 # Top right -> bottom left idx_from_start = j * NUM_SPRITES_X + NUM_SPRITES_X - i - 1 when 2 # Bottom left -> top right diff --git a/Data/Scripts/010_Data/002_PBS data/008_Species.rb b/Data/Scripts/010_Data/002_PBS data/008_Species.rb index a2305e9b6..68e0e6a92 100644 --- a/Data/Scripts/010_Data/002_PBS data/008_Species.rb +++ b/Data/Scripts/010_Data/002_PBS data/008_Species.rb @@ -116,7 +116,7 @@ module GameData "BaseEXP" => [0, "v"], "EffortPoints" => [0, "uuuuuu"], "HiddenAbility" => [0, "*e", :Ability], - "StepsToHatch" => [0, "v"], + "StepsToHatch" => [0, "v"] } if compiling_forms ret["PokedexForm"] = [0, "u"] diff --git a/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb b/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb index 1b2dd3a8d..d583dc733 100644 --- a/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb +++ b/Data/Scripts/010_Data/002_PBS data/015_Trainer.rb @@ -30,7 +30,7 @@ module GameData "Shiny" => [:shininess, "b"], "SuperShiny" => [:super_shininess, "b"], "Shadow" => [:shadowness, "b"], - "Ball" => [:poke_ball, "e", :Item], + "Ball" => [:poke_ball, "e", :Item] } extend ClassMethodsSymbols diff --git a/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb b/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb index 2f818fdec..36d7163a1 100644 --- a/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb +++ b/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb @@ -173,9 +173,8 @@ class Battle newLevel = growth_rate.level_from_exp(expFinal) if newLevel [# Feathers + 20 => [ + # Feathers :CLEVERFEATHER,:GENIUSFEATHER,:HEALTHFEATHER,:MUSCLEFEATHER, :PRETTYFEATHER,:RESISTFEATHER,:SWIFTFEATHER, :CLEVERWING,:GENIUSWING,:HEALTHWING,:MUSCLEWING,:PRETTYWING, diff --git a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb index f6c82c88a..b1a23489b 100644 --- a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb +++ b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb @@ -199,10 +199,11 @@ class Battle::Scene $bag.last_pocket_selections = @bagChoices if @bagChoices != nil # Start Bag screen itemScene = PokemonBag_Scene.new - itemScene.pbStartScene($bag, true, Proc.new { |item| - useType = GameData::Item.get(item).battle_use - next useType && useType>0 - },false) + itemScene.pbStartScene($bag, true, + Proc.new { |item| + useType = GameData::Item.get(item).battle_use + next useType && useType > 0 + }, false) # Loop while in Bag screen wasTargeting = false loop do diff --git a/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb b/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb index c7ae01e83..16b78165d 100644 --- a/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb +++ b/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb @@ -139,9 +139,9 @@ class Battle::Scene end fadeAnim.dispose sendOutAnims.each do |a| - a[0].dispose - a[1].dispose - end + a[0].dispose + a[1].dispose + end # Play shininess animations for shiny Pokémon sendOuts.each do |b| next if !@battle.showAnims || !@battle.battlers[b[0]].shiny? diff --git a/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb b/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb index 54ebfeaa0..1444b8617 100644 --- a/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb +++ b/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb @@ -47,8 +47,8 @@ class Battle::DebugSceneNoLogging def pbHPChanged(battler,oldHP,showAnim=false); end def pbFaintBattler(battler); end def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2); end - def pbLevelUp(pkmn,battler,oldTotalHP,oldAttack,oldDefense, - oldSpAtk,oldSpDef,oldSpeed); end + def pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense, + oldSpAtk, oldSpDef, oldSpeed); end def pbForgetMove(pkmn,moveToLearn); return 0; end # Always forget first move def pbCommandMenu(idxBattler,firstAction) diff --git a/Data/Scripts/011_Battle/005_AI/001_Battle_AI.rb b/Data/Scripts/011_Battle/005_AI/001_Battle_AI.rb index f50a2241c..26ee37f77 100644 --- a/Data/Scripts/011_Battle/005_AI/001_Battle_AI.rb +++ b/Data/Scripts/011_Battle/005_AI/001_Battle_AI.rb @@ -32,7 +32,7 @@ class Battle::AI n += 1 end return 0 if n<2 - mean = sum.to_f/n.to_f + mean = sum.to_f / n varianceTimesN = 0 choices.each do |c| next if c[1]<=0 diff --git a/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb index 63c110fc6..7abeb2e8f 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb @@ -277,7 +277,9 @@ class Battle::Scene dimmingvp = Viewport.new(0,0,Graphics.width,Graphics.height-msgwindow.height) pbMessageDisplay(msgwindow, _INTL("REFEREE: That's it! We will now go to judging to determine the winner!\\wtnp[20]")) { - pbBattleArenaUpdate; dimmingvp.update } + pbBattleArenaUpdate + dimmingvp.update + } dimmingvp.z = 99999 infowindow = SpriteWindow_Base.new(80,0,320,224) infowindow.contents = Bitmap.new(infowindow.width-infowindow.borderX, @@ -303,15 +305,24 @@ class Battle::Scene updateJudgment(infowindow,1,battler1,battler2,ratings1,ratings2) pbMessageDisplay(msgwindow, _INTL("REFEREE: Judging category 1, Mind!\nThe Pokémon showing the most guts!\\wtnp[40]")) { - pbBattleArenaUpdate; dimmingvp.update; infowindow.update } + pbBattleArenaUpdate + dimmingvp.update + infowindow.update + } updateJudgment(infowindow,2,battler1,battler2,ratings1,ratings2) pbMessageDisplay(msgwindow, _INTL("REFEREE: Judging category 2, Skill!\nThe Pokémon using moves the best!\\wtnp[40]")) { - pbBattleArenaUpdate; dimmingvp.update; infowindow.update } + pbBattleArenaUpdate + dimmingvp.update + infowindow.update + } updateJudgment(infowindow,3,battler1,battler2,ratings1,ratings2) pbMessageDisplay(msgwindow, _INTL("REFEREE: Judging category 3, Body!\nThe Pokémon with the most vitality!\\wtnp[40]")) { - pbBattleArenaUpdate; dimmingvp.update; infowindow.update } + pbBattleArenaUpdate + dimmingvp.update + infowindow.update + } total1 = 0 total2 = 0 for i in 0...3 @@ -321,17 +332,26 @@ class Battle::Scene if total1==total2 pbMessageDisplay(msgwindow, _INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]",total1,total2)) { - pbBattleArenaUpdate; dimmingvp.update; infowindow.update } + pbBattleArenaUpdate + dimmingvp.update + infowindow.update + } elsif total1>total2 pbMessageDisplay(msgwindow, _INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}'s {4}!\\wtnp[40]", total1,total2,@battle.pbGetOwnerName(battler1.index),battler1.name)) { - pbBattleArenaUpdate; dimmingvp.update; infowindow.update } + pbBattleArenaUpdate + dimmingvp.update + infowindow.update + } else pbMessageDisplay(msgwindow, _INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}!\\wtnp[40]", total1,total2,battler2.name)) { - pbBattleArenaUpdate; dimmingvp.update; infowindow.update } + pbBattleArenaUpdate + dimmingvp.update + infowindow.update + } end infowindow.visible = false msgwindow.visible = false diff --git a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb index 42eca8652..c99aa389a 100644 --- a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb +++ b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb @@ -202,7 +202,7 @@ class BerryPlantMoistureSprite return if !@sprite || !@event new_moisture = -1 berry_plant = @event.variable - if berry_plant&.is_a?(BerryPlantData) && berry_plant.planted? + if berry_plant.is_a?(BerryPlantData) && berry_plant.planted? new_moisture = berry_plant.moisture_stage end if new_moisture != @moisture_stage diff --git a/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb b/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb index e5f2a6794..329698557 100644 --- a/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb +++ b/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb @@ -135,7 +135,7 @@ module RandomDungeonGenerator when TurnLeft for y in 0...CELL_HEIGHT for x in 0...CELL_WIDTH - dungeon[y + dstX , CELL_WIDTH - 1 - x + dstY] = tile_layout[y * CELL_WIDTH + x] + dungeon[y + dstX, CELL_WIDTH - 1 - x + dstY] = tile_layout[y * CELL_WIDTH + x] end end when TurnRight diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb index 1dea7ad35..856e76bce 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb @@ -469,7 +469,7 @@ MultipleForms.register(:LYCANROC,{ next 2 if PBDayNight.isEvening? # Dusk next 1 if PBDayNight.isNight? # Midnight next 0 # Midday - }, + } }) MultipleForms.register(:WISHIWASHI,{ diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb b/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb index 8775ad0a2..fd00b961d 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb @@ -93,7 +93,7 @@ class HallOfFame_Scene def slowFadeOut(sprites,exponent) # 2 exponent # To handle values above 8 extraWaitExponent=exponent-9 - exponent=8 if 8 8 max=2**exponent speed=(2**8)/max for j in 0..max @@ -181,18 +181,18 @@ class HallOfFame_Scene def moveSprite(i) spritename=(i>-1) ? "pokemon#{i}" : "trainer" speed = (i>-1) ? ANIMATIONSPEED : 2 - if(!ANIMATION) # Skips animation + if !ANIMATION # Skips animation @sprites[spritename].x-=speed*@xmovement[i] @xmovement[i]=0 @sprites[spritename].y-=speed*@ymovement[i] @ymovement[i]=0 end - if(@xmovement[i]!=0) + if @xmovement[i] != 0 direction = (@xmovement[i]>0) ? -1 : 1 @sprites[spritename].x+=speed*direction @xmovement[i]+=direction end - if(@ymovement[i]!=0) + if @ymovement[i] != 0 direction = (@ymovement[i]>0) ? -1 : 1 @sprites[spritename].y+=speed*direction @ymovement[i]+=direction @@ -260,7 +260,7 @@ class HallOfFame_Scene end @xmovement[@battlerIndex]=0 @ymovement[@battlerIndex]=0 - if(ANIMATION && !SINGLEROW) # Trainer Animation + if ANIMATION && !SINGLEROW # Trainer Animation startpoint=Graphics.width/2 # 2 is the trainer speed @xmovement[@battlerIndex]=(startpoint-@sprites["trainer"].x)/2 diff --git a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb index 80083eaa1..a04062975 100644 --- a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb +++ b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb @@ -377,8 +377,8 @@ class PokemonPokedex_Scene dexlist[0] = nil if dexlist[0][5] && !$player.seen?(dexlist[0][0]) # Remove unseen species from the end of the list i = dexlist.length-1 - loop do break unless i>=0 - break if !dexlist[i] || $player.seen?(dexlist[i][0]) + loop do + break if i < 0 || !dexlist[i] || $player.seen?(dexlist[i][0]) dexlist[i] = nil i -= 1 end diff --git a/Data/Scripts/016_UI/022_UI_PurifyChamber.rb b/Data/Scripts/016_UI/022_UI_PurifyChamber.rb index 9c574e90f..3cfc45ee4 100644 --- a/Data/Scripts/016_UI/022_UI_PurifyChamber.rb +++ b/Data/Scripts/016_UI/022_UI_PurifyChamber.rb @@ -711,8 +711,7 @@ class DirectFlowDiagram @points[j]=BitmapSprite.new(8,8,@viewport) @points[j].bitmap.fill_rect(0,0,8,8,Color.new(0,0,0)) end - @points[j].tone=(@strength==2) ? Tone.new(232,232,248) : - Tone.new(16,16,232) + @points[j].tone = (@strength == 2) ? Tone.new(232, 232, 248) : Tone.new(16, 16, 232) @points[j].visible=(@strength!=0) end @@ -786,8 +785,7 @@ class FlowDiagram @points[j]=BitmapSprite.new(8,8,@viewport) @points[j].bitmap.fill_rect(0,0,8,8,Color.new(0,0,0)) end - @points[j].tone=(@strength==2) ? Tone.new(232,232,248) : - Tone.new(16,16,232) + @points[j].tone = (@strength == 2) ? Tone.new(232, 232, 248) : Tone.new(16, 16, 232) @points[j].visible=(@strength!=0) end diff --git a/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb b/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb index f882a5848..63064a2d0 100644 --- a/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb +++ b/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb @@ -586,7 +586,7 @@ class VoltorbFlip break end end - pbFadeOutAndHide(@sprites) {update} + pbFadeOutAndHide(@sprites) { update } pbDisposeSpriteHash(@sprites) @viewport.dispose end diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb index 3c69fec03..bab2c74bb 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb @@ -379,7 +379,7 @@ class BattleFactoryData pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]), trainerdata[0]) opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, @rentals) - @opponent.party = opponentPkmn.shuffle[0, 3] + @opponent.party = opponentPkmn.sample(3) end def pbChooseRentals @@ -402,7 +402,7 @@ class BattleFactoryData trainerdata[0]) opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, [].concat(@rentals).concat(@oldopponent)) - @opponent.party = opponentPkmn.shuffle[0, 3] + @opponent.party = opponentPkmn.sample(3) end def pbChooseSwaps diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb index 7bc490dcb..924d63e19 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb @@ -9,7 +9,7 @@ class BattleSwapScene @sprites["title"] = Window_UnformattedTextPokemon.newWithSize( _INTL("RENTAL POKéMON"), 0, 0, Graphics.width, 64, @viewport) @sprites["list"] = Window_AdvancedCommandPokemonEx.newWithSize( - [], 0, 64, Graphics.width, Graphics.height - 128 , @viewport) + [], 0, 64, Graphics.width, Graphics.height - 128, @viewport) @sprites["help"] = Window_UnformattedTextPokemon.newWithSize("", 0, Graphics.height - 64, Graphics.width, 64, @viewport) @sprites["msgwindow"] = Window_AdvancedTextPokemon.newWithSize("", diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/002_ChallengeGenerator_Pokemon.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/002_ChallengeGenerator_Pokemon.rb index 906001d7b..762959c53 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/002_ChallengeGenerator_Pokemon.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/002_ChallengeGenerator_Pokemon.rb @@ -60,7 +60,6 @@ def pbGetLegalMoves2(species, maxlevel) species_data.tutor_moves.each { |m| addMove(moves, m, 0) if $tmMoves.include?(m) } babyspecies = babySpecies(species) GameData::Species.get(babyspecies).egg_moves.each { |m| addMove(moves, m, 2) } - # movedatas = [] for move in moves movedatas.push([move, GameData::Move.get(move)]) diff --git a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb index d21cd4fd7..946b0bf3e 100644 --- a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb +++ b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb @@ -155,7 +155,7 @@ def pbBalancedLevel(party) party.each { |p| sum += p.level } return 1 if sum == 0 mLevel = GameData::GrowthRate.max_level - average = sum.to_f / party.length.to_f + average = sum.to_f / party.length # Calculate the standard deviation varianceTimesN = 0 party.each do |pkmn| @@ -169,7 +169,7 @@ def pbBalancedLevel(party) weights = [] # Skew weights according to standard deviation party.each do |pkmn| - weight = pkmn.level.to_f / sum.to_f + weight = pkmn.level.to_f / sum if weight < 0.5 weight -= (stdev / mLevel.to_f) weight = 0.001 if weight <= 0.001 @@ -209,21 +209,21 @@ def pbSize(pkmn) n = (pkmn.personalID >> 8) & 0xFF s = (((ativ ^ dfiv) * hpiv) ^ m) * 256 + (((saiv ^ sdiv) * spiv) ^ n) xyz = [] - if s < 10; xyz = [ 290, 1, 0] - elsif s < 110; xyz = [ 300, 1, 10] - elsif s < 310; xyz = [ 400, 2, 110] - elsif s < 710; xyz = [ 500, 4, 310] - elsif s < 2710; xyz = [ 600, 20, 710] - elsif s < 7710; xyz = [ 700, 50, 2710] - elsif s < 17710; xyz = [ 800, 100, 7710] - elsif s < 32710; xyz = [ 900, 150, 17710] - elsif s < 47710; xyz = [1000, 150, 32710] - elsif s < 57710; xyz = [1100, 100, 47710] - elsif s < 62710; xyz = [1200, 50, 57710] - elsif s < 64710; xyz = [1300, 20, 62710] - elsif s < 65210; xyz = [1400, 5, 64710] - elsif s < 65410; xyz = [1500, 2, 65210] - else; xyz = [1700, 1, 65510] + if s < 10 then xyz = [ 290, 1, 0] + elsif s < 110 then xyz = [ 300, 1, 10] + elsif s < 310 then xyz = [ 400, 2, 110] + elsif s < 710 then xyz = [ 500, 4, 310] + elsif s < 2710 then xyz = [ 600, 20, 710] + elsif s < 7710 then xyz = [ 700, 50, 2710] + elsif s < 17710 then xyz = [ 800, 100, 7710] + elsif s < 32710 then xyz = [ 900, 150, 17710] + elsif s < 47710 then xyz = [1000, 150, 32710] + elsif s < 57710 then xyz = [1100, 100, 47710] + elsif s < 62710 then xyz = [1200, 50, 57710] + elsif s < 64710 then xyz = [1300, 20, 62710] + elsif s < 65210 then xyz = [1400, 5, 64710] + elsif s < 65410 then xyz = [1500, 2, 65210] + else xyz = [1700, 1, 65510] end return (((s - xyz[2]) / xyz[1] + xyz[0]).floor * baseheight / 10).floor end diff --git a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb index 24b66c3d3..e776c58bf 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb @@ -687,7 +687,7 @@ module TrainerPokemonProperty :iv => oldsetting[12 + Pokemon::MAX_MOVES], :ev => oldsetting[13 + Pokemon::MAX_MOVES], :happiness => oldsetting[14 + Pokemon::MAX_MOVES], - :poke_ball => oldsetting[15 + Pokemon::MAX_MOVES], + :poke_ball => oldsetting[15 + Pokemon::MAX_MOVES] } moves = [] Pokemon::MAX_MOVES.times do |i| @@ -788,7 +788,7 @@ def pbEditPlayerMetadata(player_id = 1) :surf_charset => data[4], :dive_charset => data[5], :fish_charset => data[6], - :surf_fish_charset => data[7], + :surf_fish_charset => data[7] } # Add player metadata's data to records GameData::PlayerMetadata.register(metadata_hash) @@ -1198,7 +1198,7 @@ def pbRegionalDexEditor(dex) dex[cmd[1] + 1], dex[cmd[1]] = dex[cmd[1]], dex[cmd[1] + 1] refresh_list = true end - when 2 # Swap entry down + when 2 # Swap entry down if cmd[1] > 0 dex[cmd[1] - 1], dex[cmd[1]] = dex[cmd[1]], dex[cmd[1] - 1] refresh_list = true diff --git a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb index f17db207c..321e29d56 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb @@ -286,7 +286,7 @@ class TextField < UIControl return end # Letter & Number keys - Input.gets.each_char{|c|insert(c)} + Input.gets.each_char { |c| insert(c) } end def refresh diff --git a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb index 347fc8d52..223eca378 100644 --- a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb @@ -1707,7 +1707,7 @@ module Compiler GameData::MapMetadata::DATA.clear map_infos = pbLoadMapInfos map_names = [] - map_infos.keys.each { |id| map_names[id] = map_infos[id].name } + map_infos.each_key { |id| map_names[id] = map_infos[id].name } # Read from PBS file File.open(path, "rb") { |f| FileLineData.file = path # For error reporting diff --git a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb index af366aeac..a4e9efaa5 100644 --- a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb +++ b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb @@ -152,9 +152,9 @@ module Compiler f.write("IsSpecialType = true\r\n") if type.special? f.write("IsPseudoType = true\r\n") if type.pseudo_type f.write(sprintf("Flags = %s\r\n", type.flags.join(","))) if type.flags.length > 0 - f.write("Weaknesses = #{type.weaknesses.join(",")}\r\n") if type.weaknesses.length > 0 - f.write("Resistances = #{type.resistances.join(",")}\r\n") if type.resistances.length > 0 - f.write("Immunities = #{type.immunities.join(",")}\r\n") if type.immunities.length > 0 + f.write("Weaknesses = #{type.weaknesses.join(',')}\r\n") if type.weaknesses.length > 0 + f.write("Resistances = #{type.resistances.join(',')}\r\n") if type.resistances.length > 0 + f.write("Immunities = #{type.immunities.join(',')}\r\n") if type.immunities.length > 0 end } process_pbs_file_message_end @@ -204,7 +204,7 @@ module Compiler f.write("Target = #{move.target}\r\n") f.write("Priority = #{move.priority}\r\n") if move.priority != 0 f.write("FunctionCode = #{move.function_code}\r\n") - f.write("Flags = #{move.flags.join(",")}\r\n") if move.flags.length > 0 + f.write("Flags = #{move.flags.join(',')}\r\n") if move.flags.length > 0 f.write("EffectChance = #{move.effect_chance}\r\n") if move.effect_chance > 0 f.write("Description = #{move.real_description}\r\n") end diff --git a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb index 14bb57efc..8ebe560cd 100644 --- a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb @@ -1180,10 +1180,10 @@ module Compiler ) changed = true end - if false # deletedRoute - insertMoveRouteAt.call(list,list.length-1,deletedRoute) - changed = true - end +# if deletedRoute +# insertMoveRouteAt.call(list,list.length-1,deletedRoute) +# changed = true +# end end when 101 # Show Text # Capitalise/decapitalise various text formatting codes