diff --git a/Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb b/Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb index de6e79718..b5b7ee302 100644 --- a/Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb +++ b/Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb @@ -105,12 +105,20 @@ module Console # status output def echo_status(status) - echoln (status) ? markup_style('OK', text: :green) : markup_style('FAIL', text: :red) + if status + echoln markup_style('OK', text: :green) + else + echoln markup_style('FAIL', text: :red) + end end # completion output def echo_done(status) - echoln (status) ? markup_style('done', text: :green) : markup_style('error', text: :red) + if status + echoln markup_style('done', text: :green) + else + echoln markup_style('error', text: :red) + end end #----------------------------------------------------------------------------- diff --git a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb index 259087b71..6dd607919 100644 --- a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb +++ b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb @@ -240,8 +240,6 @@ module RTP yield ".".gsub(/[\/\\]/, "/").gsub(/[\/\\]$/, "") + "/" end - private - def self.getSaveFileName(fileName) File.join(getSaveFolder, fileName) end @@ -260,15 +258,15 @@ end module FileTest - Image_ext = ['.png', '.gif'] # '.jpg', '.jpeg', '.bmp', - Audio_ext = ['.mid', '.midi', '.ogg', '.wav', '.wma'] # '.mp3' + IMAGE_EXTENSIONS = ['.png', '.gif'] # '.jpg', '.jpeg', '.bmp', + AUDIO_EXTENSIONS = ['.mid', '.midi', '.ogg', '.wav', '.wma'] # '.mp3' def self.audio_exist?(filename) - return RTP.exists?(filename, Audio_ext) + return RTP.exists?(filename, AUDIO_EXTENSIONS) end def self.image_exist?(filename) - return RTP.exists?(filename, Image_ext) + return RTP.exists?(filename, IMAGE_EXTENSIONS) end end @@ -485,8 +483,6 @@ class StringInput @pos += 1 if @pos == @string.size str end - - def read_all; read(); end - + alias read_all read alias sysread read end 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 3eb23c8b0..b6f02864a 100644 --- a/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb +++ b/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb @@ -6,8 +6,8 @@ def pbPostData(url, postdata, filename = nil, depth = 0) if url[/^http:\/\/([^\/]+)(.*)$/] host = $1 - path = $2 - path = "/" if path.length == 0 +# path = $2 +# path = "/" if path.length == 0 userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14" body = postdata.map { |key, value| keyString = key.to_s diff --git a/Data/Scripts/001_Technical/003_Intl_Messages.rb b/Data/Scripts/001_Technical/003_Intl_Messages.rb index 9927c66eb..cd05152af 100644 --- a/Data/Scripts/001_Technical/003_Intl_Messages.rb +++ b/Data/Scripts/001_Technical/003_Intl_Messages.rb @@ -254,7 +254,7 @@ def pbGetText(infile) else intlhash = OrderedHash.new itemlength = 2 - if section.length % 2 != 0 + if section.length.odd? raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)", name) end end @@ -320,7 +320,7 @@ class OrderedHash < Hash return str end - alias :to_s :inspect + alias to_s inspect def []=(key, value) oldvalue = self[key] diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index 19baf8e5f..34116872a 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -279,7 +279,8 @@ module PluginManager msg = "Plugin '#{name}' requires plugin '#{dep_name}', if installed, to be version #{dep_version}" msg << " or higher" if !exact msg << ", but the installed version was #{self.version(dep_name)}." - if dep_link = self.link(dep_name) + dep_link = self.link(dep_name) + if dep_link msg << "\r\nCheck #{dep_link} for an update to plugin '#{dep_name}'." end self.error(msg) @@ -289,16 +290,16 @@ module PluginManager msg = "Plugin '#{name}' requires plugin '#{dep_name}' to be version #{dep_version}" msg << " or later" if !exact msg << ", but the installed version was #{self.version(dep_name)}." - if dep_link = self.link(dep_name) + dep_link = self.link(dep_name) + if dep_link msg << "\r\nCheck #{dep_link} for an update to plugin '#{dep_name}'." end - self.error(msg) else # Don't have plugin msg = "Plugin '#{name}' requires plugin '#{dep_name}' version #{dep_version} " - msg << "or later" if !exact + msg << "or later " if !exact msg << "to be installed above it." - self.error(msg) end + self.error(msg) end end end diff --git a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb index d9e088d83..aed51c265 100644 --- a/Data/Scripts/002_Save data/005_Game_SaveConversions.rb +++ b/Data/Scripts/002_Save data/005_Game_SaveConversions.rb @@ -96,9 +96,10 @@ SaveData.register_conversion(:v20_berry_plant_data) do if global.eventvars global.eventvars.each_pair do |key, value| next if !value || !value.is_a?(Array) - if value.length == 6 # Old berry plant data + case value.length + when 6 # Old berry plant data data = BerryPlantData.new - if value[1]&.is_a?(Symbol) + if value[1].is_a?(Symbol) plant_data = GameData::DerryPlant.get(value[1]) data.new_mechanics = false data.berry_id = value[1] @@ -110,12 +111,12 @@ SaveData.register_conversion(:v20_berry_plant_data) do data.watering_count = value[4] end global.eventvars[key] = data - elsif value.length == 7 || value.length == 8 # New berry plant data + when 7, 8 # New berry plant data data = BerryPlantData.new - if value[1]&.is_a?(Symbol) + if value[1].is_a?(Symbol) data.new_mechanics = true data.berry_id = value[1] - data.mulch_id = value[7] if value[7]&.is_a?(Symbol) + data.mulch_id = value[7] if value[7].is_a?(Symbol) data.time_alive = value[2] data.time_last_updated = value[3] data.growth_stage = value[0] @@ -294,13 +295,17 @@ SaveData.register_conversion(:v20_convert_pokemon_markings_global) do end end global.purifyChamber.sets.each do |set| - set.shadow = PokeBattle_Pokemon.convert(set.shadow) if set.shadow set.list.each do |pkmn| next if !pkmn.markings.is_a?(Integer) markings = [] 6.times { |i| markings[i] = ((pkmn.markings & (1 << i)) == 0) ? 0 : 1 } pkmn.markings = markings end + if set.shadow && set.shadow.markings.is_a?(Integer) + markings = [] + 6.times { |i| markings[i] = ((set.shadow.markings & (1 << i)) == 0) ? 0 : 1 } + set.shadow.markings = markings + end end if global.hallOfFame global.hallOfFame.each do |team| diff --git a/Data/Scripts/003_Game processing/003_Interpreter.rb b/Data/Scripts/003_Game processing/003_Interpreter.rb index d39299a14..d8ec09004 100644 --- a/Data/Scripts/003_Game processing/003_Interpreter.rb +++ b/Data/Scripts/003_Game processing/003_Interpreter.rb @@ -142,7 +142,7 @@ class Interpreter return result rescue Exception e = $! - raise if e.is_a?(SystemExit) || "#{e.class}" == "Reset" + raise if e.is_a?(SystemExit) || e.class.to_s == "Reset" event = get_self # Gather text for error message message = pbGetExceptionMessage(e) @@ -295,7 +295,7 @@ class Interpreter #----------------------------------------------------------------------------- # Helper function that shows a picture in a script. def pbShowPicture(number, name, origin, x, y, zoomX = 100, zoomY = 100, opacity = 255, blendType = 0) - number = number + ($game_temp.in_battle ? 50 : 0) + number += ($game_temp.in_battle ? 50 : 0) $game_screen.pictures[number].show(name, origin, x, y, zoomX, zoomY, opacity, blendType) end diff --git a/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb b/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb index 9b9ecbf34..3dd50ceb0 100644 --- a/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb +++ b/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb @@ -521,10 +521,10 @@ class Interpreter next if value == 1 $game_variables[i] *= value when 4 # divide - next if value == 1 || value == 0 + next if [0, 1].include?(value) $game_variables[i] /= value when 5 # remainder - next if value == 1 || value == 0 + next if [0, 1].include?(value) $game_variables[i] %= value end $game_variables[i] = 99999999 if $game_variables[i] > 99999999 @@ -631,13 +631,12 @@ class Interpreter $game_temp.player_new_map_id = @parameters[1] $game_temp.player_new_x = @parameters[2] $game_temp.player_new_y = @parameters[3] - $game_temp.player_new_direction = @parameters[4] else # Appoint with variables $game_temp.player_new_map_id = $game_variables[@parameters[1]] $game_temp.player_new_x = $game_variables[@parameters[2]] $game_temp.player_new_y = $game_variables[@parameters[3]] - $game_temp.player_new_direction = @parameters[4] end + $game_temp.player_new_direction = @parameters[4] @index += 1 # If transition happens with a fade, do the fade if @parameters[5] == 0 @@ -655,9 +654,10 @@ class Interpreter character = get_character(@parameters[0]) return true if character.nil? # Move the character - if @parameters[1] == 0 # Direct appointment + case @parameters[1] + when 0 # Direct appointment character.moveto(@parameters[2], @parameters[3]) - elsif @parameters[1] == 1 # Appoint with variables + when 1 # Appoint with variables character.moveto($game_variables[@parameters[2]], $game_variables[@parameters[3]]) else # Exchange with another event character2 = get_character(@parameters[2]) diff --git a/Data/Scripts/003_Game processing/006_Event_OverworldEvents.rb b/Data/Scripts/003_Game processing/006_Event_OverworldEvents.rb index d7f733597..af8433ddb 100644 --- a/Data/Scripts/003_Game processing/006_Event_OverworldEvents.rb +++ b/Data/Scripts/003_Game processing/006_Event_OverworldEvents.rb @@ -164,9 +164,9 @@ module EncounterModifier return encounter end - def self.triggerEncounterEnd() + def self.triggerEncounterEnd for prc in @@procsEnd - prc.call() + prc.call end end end diff --git a/Data/Scripts/004_Game classes/002_Game_System.rb b/Data/Scripts/004_Game classes/002_Game_System.rb index 4284d30cb..4ed361348 100644 --- a/Data/Scripts/004_Game classes/002_Game_System.rb +++ b/Data/Scripts/004_Game classes/002_Game_System.rb @@ -132,12 +132,11 @@ class Game_System def setDefaultBGM(bgm, volume = 80, pitch = 100) bgm = RPG::AudioFile.new(bgm, volume, pitch) if bgm.is_a?(String) + @defaultBGM = nil if bgm != nil && bgm.name != "" - @defaultBGM = nil self.bgm_play(bgm) @defaultBGM = bgm.clone else - @defaultBGM = nil self.bgm_play(@playing_bgm) end end diff --git a/Data/Scripts/004_Game classes/004_Game_Map.rb b/Data/Scripts/004_Game classes/004_Game_Map.rb index a3baa1080..ee57985f0 100644 --- a/Data/Scripts/004_Game classes/004_Game_Map.rb +++ b/Data/Scripts/004_Game classes/004_Game_Map.rb @@ -357,7 +357,7 @@ class Game_Map def start_scroll(direction, distance, speed) @scroll_direction = direction - if direction == 2 || direction == 8 # down or up + if [2, 8].include?(direction) # down or up @scroll_rest = distance * REAL_RES_Y else @scroll_rest = distance * REAL_RES_X diff --git a/Data/Scripts/004_Game classes/006_Game_MapFactory.rb b/Data/Scripts/004_Game classes/006_Game_MapFactory.rb index 7f5f35d3b..ef6d4dd71 100644 --- a/Data/Scripts/004_Game classes/006_Game_MapFactory.rb +++ b/Data/Scripts/004_Game classes/006_Game_MapFactory.rb @@ -394,9 +394,9 @@ class PokemonMapFactory return end setMapsInRange - deleted = false - deleted = @maps.delete_if { |map| !MapFactoryHelper.mapInRange?(map) } - @mapIndex = getMapIndex($game_map.map_id) if deleted + old_num_maps = @maps.length + @maps.delete_if { |map| !MapFactoryHelper.mapInRange?(map) } + @mapIndex = getMapIndex($game_map.map_id) if @maps.length != old_num_maps end end @@ -476,7 +476,7 @@ module MapFactoryHelper # Returns the X or Y coordinate of an edge on the map with id. # Considers the special strings "N","W","E","S" def self.getMapEdge(id, edge) - return 0 if edge == "N" || edge == "W" + return 0 if ["N", "W"].include?(edge) dims = getMapDims(id) # Get dimensions return dims[0] if edge == "E" return dims[1] if edge == "S" diff --git a/Data/Scripts/004_Game classes/007_Game_Character.rb b/Data/Scripts/004_Game classes/007_Game_Character.rb index 936c87673..91cd2bb58 100644 --- a/Data/Scripts/004_Game classes/007_Game_Character.rb +++ b/Data/Scripts/004_Game classes/007_Game_Character.rb @@ -201,7 +201,6 @@ class Game_Character @bush_depth = 0 return end - deep_bush = regular_bush = false xbehind = @x + (@direction == 4 ? 1 : @direction == 6 ? -1 : 0) ybehind = @y + (@direction == 8 ? 1 : @direction == 2 ? -1 : 0) this_map = (self.map.valid?(@x, @y)) ? [self.map, @x, @y] : $map_factory&.getNewMap(@x, @y) @@ -738,7 +737,7 @@ class Game_Character end @x = @x + x_plus @y = @y + y_plus - real_distance = Math::sqrt(x_plus * x_plus + y_plus * y_plus) + real_distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus) distance = [1, real_distance].max @jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping @jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max diff --git a/Data/Scripts/004_Game classes/008_Game_Event.rb b/Data/Scripts/004_Game classes/008_Game_Event.rb index 2803bc849..ac6ba43c5 100644 --- a/Data/Scripts/004_Game classes/008_Game_Event.rb +++ b/Data/Scripts/004_Game classes/008_Game_Event.rb @@ -168,11 +168,12 @@ class Game_Event < Game_Character end def check_event_trigger_auto - if @trigger == 2 # Event touch + case @trigger + when 2 # Event touch if at_coordinate?($game_player.x, $game_player.y) start if !jumping? && over_trigger? end - elsif @trigger == 3 # Autorun + when 3 # Autorun start end end diff --git a/Data/Scripts/004_Game classes/009_Game_Player.rb b/Data/Scripts/004_Game classes/009_Game_Player.rb index ddb6bbdff..252069904 100644 --- a/Data/Scripts/004_Game classes/009_Game_Player.rb +++ b/Data/Scripts/004_Game classes/009_Game_Player.rb @@ -157,7 +157,7 @@ class Game_Player < Game_Character end @x = @x + x_plus @y = @y + y_plus - real_distance = Math::sqrt(x_plus * x_plus + y_plus * y_plus) + real_distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus) distance = [1, real_distance].max @jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping @jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max diff --git a/Data/Scripts/005_Sprites/003_Sprite_Character.rb b/Data/Scripts/005_Sprites/003_Sprite_Character.rb index fa8b81e4e..780c7edcf 100644 --- a/Data/Scripts/005_Sprites/003_Sprite_Character.rb +++ b/Data/Scripts/005_Sprites/003_Sprite_Character.rb @@ -102,8 +102,8 @@ class Sprite_Character < RPG::Sprite @character_name = @character.character_name @character_hue = @character.character_hue @oldbushdepth = @character.bush_depth + @charbitmap.dispose if @charbitmap if @tile_id >= 384 - @charbitmap.dispose if @charbitmap @charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id, @character_hue, @character.width, @character.height) @charbitmapAnimated = false @@ -115,9 +115,7 @@ class Sprite_Character < RPG::Sprite self.src_rect.set(0, 0, @cw, @ch) self.ox = @cw / 2 self.oy = @ch - @character.sprite_size = [@cw, @ch] else - @charbitmap.dispose if @charbitmap @charbitmap = AnimatedBitmap.new( 'Graphics/Characters/' + @character_name, @character_hue) RPG::Cache.retain('Graphics/Characters/', @character_name, @character_hue) if @character == $game_player @@ -128,8 +126,8 @@ class Sprite_Character < RPG::Sprite @cw = @charbitmap.width / 4 @ch = @charbitmap.height / 4 self.ox = @cw / 2 - @character.sprite_size = [@cw, @ch] end + @character.sprite_size = [@cw, @ch] end @charbitmap.update if @charbitmapAnimated bushdepth = @character.bush_depth diff --git a/Data/Scripts/005_Sprites/009_Sprite_DynamicShadows.rb b/Data/Scripts/005_Sprites/009_Sprite_DynamicShadows.rb index 10571931f..341f2192b 100644 --- a/Data/Scripts/005_Sprites/009_Sprite_DynamicShadows.rb +++ b/Data/Scripts/005_Sprites/009_Sprite_DynamicShadows.rb @@ -35,8 +35,8 @@ class Sprite_Shadow < RPG::Sprite @tile_id = @character.tile_id @character_name = @character.character_name @character_hue = @character.character_hue + @chbitmap.dispose if @chbitmap if @tile_id >= 384 - @chbitmap.dispose if @chbitmap @chbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id, @character.character_hue) self.src_rect.set(0, 0, 32, 32) @@ -45,7 +45,6 @@ class Sprite_Shadow < RPG::Sprite self.ox = 16 self.oy = 32 else - @chbitmap.dispose if @chbitmap @chbitmap = AnimatedBitmap.new( 'Graphics/Characters/' + @character.character_name, @character.character_hue) @cw = @chbitmap.width / 4 @@ -124,7 +123,7 @@ end # ? CLASS Sprite_Character edit #=================================================== class Sprite_Character < RPG::Sprite - alias :shadow_initialize :initialize + alias shadow_initialize initialize def initialize(viewport, character = nil) @ombrelist = [] diff --git a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb index 481bc9406..eb4eb78b1 100644 --- a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb +++ b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb @@ -144,8 +144,6 @@ class SpriteWindow < Window @viewport = value for i in @spritekeys @sprites[i].dispose if @sprites[i] - end - for i in @spritekeys if @sprites[i].is_a?(Sprite) @sprites[i] = Sprite.new(@viewport) else @@ -306,11 +304,10 @@ class SpriteWindow < Window @cursoropacity += 8 @cursorblink = 0 if @cursoropacity >= 255 end - privRefreshCursor else @cursoropacity = 128 - privRefreshCursor end + privRefreshCursor if @pause oldpauseframe = @pauseframe oldpauseopacity = @pauseopacity @@ -591,7 +588,7 @@ class SpriteWindow < Window trimX + 32, trimY + 64, trimX + 48, trimY + 64, trimX + 32, trimY + 80, - trimX + 48, trimY + 80, + trimX + 48, trimY + 80 ] pauseWidth = 16 pauseHeight = 16 @@ -838,13 +835,13 @@ class SpriteWindow_Base < SpriteWindow self.width = width self.height = height self.z = 100 - @curframe = MessageConfig.pbGetSystemFrame() - @curfont = MessageConfig.pbGetSystemFontName() + @curframe = MessageConfig.pbGetSystemFrame + @curfont = MessageConfig.pbGetSystemFontName @sysframe = AnimatedBitmap.new(@curframe) RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty? @customskin = nil __setWindowskin(@sysframe.bitmap) - __resolveSystemFrame() + __resolveSystemFrame pbSetSystemFont(self.contents) if self.contents end @@ -861,7 +858,7 @@ class SpriteWindow_Base < SpriteWindow def __resolveSystemFrame if self.skinformat == 1 if !@resolvedFrame - @resolvedFrame = MessageConfig.pbGetSystemFrame() + @resolvedFrame = MessageConfig.pbGetSystemFrame @resolvedFrame.sub!(/\.[^\.\/\\]+$/, "") end self.loadSkinFile("#{@resolvedFrame}.txt") if @resolvedFrame != "" @@ -886,7 +883,7 @@ class SpriteWindow_Base < SpriteWindow @customskin.dispose if @customskin @customskin = nil __setWindowskin(@sysframe.bitmap) - __resolveSystemFrame() + __resolveSystemFrame end def update @@ -904,23 +901,23 @@ class SpriteWindow_Base < SpriteWindow end end end - if @curframe != MessageConfig.pbGetSystemFrame() - @curframe = MessageConfig.pbGetSystemFrame() + if @curframe != MessageConfig.pbGetSystemFrame + @curframe = MessageConfig.pbGetSystemFrame if @sysframe && !@customskin @sysframe.dispose if @sysframe @sysframe = AnimatedBitmap.new(@curframe) RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty? @resolvedFrame = nil __setWindowskin(@sysframe.bitmap) - __resolveSystemFrame() + __resolveSystemFrame end begin refresh rescue NoMethodError end end - if @curfont != MessageConfig.pbGetSystemFontName() - @curfont = MessageConfig.pbGetSystemFontName() + if @curfont != MessageConfig.pbGetSystemFontName + @curfont = MessageConfig.pbGetSystemFontName if self.contents && !self.contents.disposed? pbSetSystemFont(self.contents) 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 4bd176102..01e7a7298 100644 --- a/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb +++ b/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb @@ -13,7 +13,7 @@ class IconWindow < SpriteWindow_Base end def dispose - clearBitmaps() + clearBitmaps super end @@ -38,7 +38,7 @@ class IconWindow < SpriteWindow_Base # Sets the icon's filename. def setBitmap(file, hue = 0) - clearBitmaps() + clearBitmaps @name = file return if file == nil if file != "" @@ -67,7 +67,7 @@ class PictureWindow < SpriteWindow_Base end def dispose - clearBitmaps() + clearBitmaps super end @@ -92,7 +92,7 @@ class PictureWindow < SpriteWindow_Base # Sets the icon's bitmap or filename. (hue parameter # is ignored unless pathOrBitmap is a filename) def setBitmap(pathOrBitmap, hue = 0) - clearBitmaps() + clearBitmaps if pathOrBitmap != nil && pathOrBitmap != "" if pathOrBitmap.is_a?(Bitmap) @_iconbitmap = pathOrBitmap diff --git a/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb b/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb index 1733956e6..85b3e4784 100644 --- a/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb +++ b/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb @@ -245,13 +245,14 @@ class IconSprite < SpriteWrapper attr_reader :name def initialize(*args) - if args.length == 0 + case args.length + when 0 super(nil) self.bitmap = nil - elsif args.length == 1 + when 1 super(args[0]) self.bitmap = nil - elsif args.length == 2 + when 2 super(nil) self.x = args[0] self.y = args[1] @@ -265,7 +266,7 @@ class IconSprite < SpriteWrapper end def dispose - clearBitmaps() + clearBitmaps super end @@ -277,7 +278,7 @@ class IconSprite < SpriteWrapper # Sets the icon's filename. def setBitmap(file, hue = 0) oldrc = self.src_rect - clearBitmaps() + clearBitmaps @name = file return if file == nil if file != "" diff --git a/Data/Scripts/007_Objects and windows/010_DrawText.rb b/Data/Scripts/007_Objects and windows/010_DrawText.rb index c8846af20..0ff8c2da7 100644 --- a/Data/Scripts/007_Objects and windows/010_DrawText.rb +++ b/Data/Scripts/007_Objects and windows/010_DrawText.rb @@ -45,26 +45,27 @@ end def rgbToColor(param) return Font.default_color if !param baseint = param.to_i(16) - if param.length == 8 # 32-bit hex + case param.length + when 8 # 32-bit hex return Color.new( (baseint >> 24) & 0xFF, (baseint >> 16) & 0xFF, (baseint >> 8) & 0xFF, (baseint) & 0xFF ) - elsif param.length == 6 # 24-bit hex + when 6 # 24-bit hex return Color.new( (baseint >> 16) & 0xFF, (baseint >> 8) & 0xFF, (baseint) & 0xFF ) - elsif param.length == 4 # 16-bit hex + when 4 # 16-bit hex return Color.new( ((baseint) & 0x1F) << 3, ((baseint >> 5) & 0x1F) << 3, ((baseint >> 10) & 0x1F) << 3 ) - elsif param.length == 1 # Color number + when 1 # Color number i = param.to_i return Font.default_color if i >= 8 return [ @@ -291,7 +292,7 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig end def isWaitChar(x) - return (x == "\001" || x == "\002") + return (["\001", "\002"].include?(x)) end def getLastParam(array, default) @@ -418,14 +419,13 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = x = y = 0 characters = [] charactersInternal = [] - realtext = nil - realtextStart = "" - if !explicitBreaksOnly && textchunks.join("").length == 0 - # All commands occurred at the beginning of the text string - realtext = (newlineBreaks) ? text : text.gsub(/\n/, " ") - realtextStart = oldtext[0, oldtext.length - realtext.length] - realtextHalf = text.length / 2 - end +# realtext = nil +# realtextStart = "" +# if !explicitBreaksOnly && textchunks.join("").length == 0 +# # All commands occurred at the beginning of the text string +# realtext = (newlineBreaks) ? text : text.gsub(/\n/, " ") +# realtextStart = oldtext[0, oldtext.length - realtext.length] +# end textchunks.push(text) for chunk in textchunks chunk.gsub!(/</, "<") @@ -483,14 +483,15 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = control = controls[i][0] param = controls[i][1] endtag = controls[i][3] - if control == "c" + case control + when "c" if endtag colorstack.pop else color = rgbToColor(param) colorstack.push([color, nil]) end - elsif control == "c2" + when "c2" if endtag colorstack.pop else @@ -498,7 +499,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = shadow = Rgb16ToColor(param[4, 4]) colorstack.push([base, shadow]) end - elsif control == "c3" + when "c3" if endtag colorstack.pop else @@ -509,25 +510,25 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = shadow = (param[1] && param[1] != "") ? rgbToColor(param[1]) : oldColors[1] colorstack.push([base, shadow]) end - elsif control == "o" + when "o" if endtag opacitystack.pop else opacitystack.push(param.sub(/\s+$/, "").to_i) end - elsif control == "b" + when "b" boldcount += (endtag ? -1 : 1) - elsif control == "i" + when "i" italiccount += (endtag ? -1 : 1) - elsif control == "u" + when "u" underlinecount += (endtag ? -1 : 1) - elsif control == "s" + when "s" strikecount += (endtag ? -1 : 1) - elsif control == "outln" + when "outln" outlinecount += (endtag ? -1 : 1) - elsif control == "outln2" + when "outln2" outline2count += (endtag ? -1 : 1) - elsif control == "fs" # Font size + when "fs" # Font size if endtag fontsizestack.pop else @@ -535,7 +536,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = end fontsize = getLastParam(fontsizestack, defaultfontsize) bitmap.font.size = fontsize - elsif control == "fn" # Font name + when "fn" # Font name if endtag fontnamestack.pop else @@ -544,38 +545,35 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = end fontname = getLastParam(fontnamestack, defaultfontname) bitmap.font.name = fontname - elsif control == "ar" # Right align - if !endtag + when "ar" # Right align + if endtag + alignstack.pop + else alignstack.push(1) - nextline = 1 if x > 0 && nextline == 0 - else - alignstack.pop - nextline = 1 if x > 0 && nextline == 0 end - elsif control == "al" # Left align - if !endtag + nextline = 1 if x > 0 && nextline == 0 + when "al" # Left align + if endtag + alignstack.pop + else alignstack.push(0) - nextline = 1 if x > 0 && nextline == 0 - else - alignstack.pop - nextline = 1 if x > 0 && nextline == 0 end - elsif control == "ac" # Center align - if !endtag + nextline = 1 if x > 0 && nextline == 0 + when "ac" # Center align + if endtag + alignstack.pop + else alignstack.push(2) - nextline = 1 if x > 0 && nextline == 0 - else - alignstack.pop - nextline = 1 if x > 0 && nextline == 0 end - elsif control == "icon" # Icon + nextline = 1 if x > 0 && nextline == 0 + when "icon" # Icon if !endtag param = param.sub(/\s+$/, "") graphic = "Graphics/Icons/#{param}" controls[i] = nil break end - elsif control == "img" # Icon + when "img" # Icon if !endtag param = param.sub(/\s+$/, "") param = param.split("|") @@ -589,11 +587,11 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = controls[i] = nil break end - elsif control == "br" # Line break + when "br" # Line break if !endtag nextline += 1 end - elsif control == "r" # Right align this line + when "r" # Right align this line if !endtag x = 0 rightalign = 1 @@ -679,7 +677,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = havenl = true if !graphic && isWaitChar(textchars[position]) extraspace = (!graphic && italiccount > 0) ? 2 + (width / 2) : 2 characters.push([ - graphic ? graphic : textchars[position], + graphic || textchars[position], x + xStart, texty, width + extraspace, lineheight, graphic ? true : false, (boldcount > 0), (italiccount > 0), colors[0], colors[1], @@ -929,12 +927,11 @@ def getLineBrokenChunks(bitmap, value, width, dims, plain = false) y += 32 next end + textcols = [] if ccheck[/ maximum - pbPlayBuzzerSE() + pbPlayBuzzerSE elsif ret < minimum - pbPlayBuzzerSE() + pbPlayBuzzerSE else - pbPlayDecisionSE() + pbPlayDecisionSE break end elsif Input.trigger?(Input::BACK) - pbPlayCancelSE() + pbPlayCancelSE ret = cancelNumber break end @@ -324,7 +324,7 @@ def pbGetGoldString end def pbDisplayGoldWindow(msgwindow) - moneyString = pbGetGoldString() + moneyString = pbGetGoldString goldwindow = Window_AdvancedTextPokemon.new(_INTL("Money:\n{1}", moneyString)) goldwindow.setSkin("Graphics/Windowskins/goldskin") goldwindow.resizeToFit(goldwindow.text, Graphics.width) @@ -386,7 +386,7 @@ def pbCreateStatusWindow(viewport = nil) msgwindow.visible = false msgwindow.letterbyletter = false pbBottomLeftLines(msgwindow, 2) - skinfile = MessageConfig.pbGetSpeechFrame() + skinfile = MessageConfig.pbGetSpeechFrame msgwindow.setSkin(skinfile) return msgwindow end @@ -403,7 +403,7 @@ def pbCreateMessageWindow(viewport = nil, skin = nil) msgwindow.back_opacity = MessageConfig::WINDOW_OPACITY pbBottomLeftLines(msgwindow, 2) $game_temp.message_window_showing = true if $game_temp - skin = MessageConfig.pbGetSpeechFrame() if !skin + skin = MessageConfig.pbGetSpeechFrame if !skin msgwindow.setSkin(skin) return msgwindow end @@ -562,7 +562,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni if startSE != nil pbSEPlay(pbStringToAudioFile(startSE)) elsif signWaitCount == 0 && letterbyletter - pbPlayDecisionSE() + pbPlayDecisionSE end ########## Position message window ############## pbRepositionMessageWindow(msgwindow, linecount) diff --git a/Data/Scripts/007_Objects and windows/012_TextEntry.rb b/Data/Scripts/007_Objects and windows/012_TextEntry.rb index 1c82ea3a0..bcce92b2b 100644 --- a/Data/Scripts/007_Objects and windows/012_TextEntry.rb +++ b/Data/Scripts/007_Objects and windows/012_TextEntry.rb @@ -348,7 +348,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base def getLineY(line) textchars = getTextChars return 0 if textchars.length == 0 - totallines = getTotalLines() + totallines = getTotalLines line = 0 if line < 0 line = totallines - 1 if line >= totallines maximumY = 0 @@ -364,7 +364,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base def getColumnsInLine(line) textchars = getTextChars return 0 if textchars.length == 0 - totallines = getTotalLines() + totallines = getTotalLines line = 0 if line < 0 line = totallines - 1 if line >= totallines endpos = 0 @@ -379,7 +379,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base def getPosFromLineAndColumn(line, column) textchars = getTextChars return 0 if textchars.length == 0 - totallines = getTotalLines() + totallines = getTotalLines line = 0 if line < 0 line = totallines - 1 if line >= totallines endpos = 0 @@ -405,7 +405,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base end def getLastVisibleLine - getTextChars() + getTextChars textheight = [1, self.contents.text_size("X").height].max lastVisible = @firstline + ((self.height - self.borderY) / textheight) - 1 return lastVisible @@ -419,7 +419,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base self.refresh end @firstline = @cursorLine if @cursorLine < @firstline - lastVisible = getLastVisibleLine() + lastVisible = getLastVisibleLine @firstline += (@cursorLine - lastVisible) if @cursorLine > lastVisible end @@ -428,7 +428,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base # can affect line offset) # echoln ["beforemoving",@cursorLine,@cursorColumn] totalColumns = getColumnsInLine(@cursorLine) # check current line - totalLines = getTotalLines() + totalLines = getTotalLines oldCursorLine = @cursorLine oldCursorColumn = @cursorColumn @cursorColumn += columnOffset @@ -487,7 +487,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base return elsif Input.press?(Input::CTRL) && Input.triggerex?(:END) # Move cursor to end - @cursorLine = getTotalLines() - 1 + @cursorLine = getTotalLines - 1 @cursorColumn = getColumnsInLine(@cursorLine) updateCursorPos(true) return @@ -511,7 +511,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base getTextChars height = self.height - self.borderY cursorcolor = Color.new(0, 0, 0) - textchars = getTextChars() + textchars = getTextChars startY = getLineY(@firstline) for i in 0...textchars.length thisline = textchars[i][5] diff --git a/Data/Scripts/008_Audio/001_Audio.rb b/Data/Scripts/008_Audio/001_Audio.rb index ee8dbefd1..0080bc8ca 100644 --- a/Data/Scripts/008_Audio/001_Audio.rb +++ b/Data/Scripts/008_Audio/001_Audio.rb @@ -110,7 +110,8 @@ def getPlayTime2(filename) File.open(filename, "rb") { |file| file.pos = 0 fdw = fgetdw.call(file) - if fdw == 0x46464952 # "RIFF" + case fdw + when 0x46464952 # "RIFF" filesize = fgetdw.call(file) wave = fgetdw.call(file) return -1 if wave != 0x45564157 # "WAVE" @@ -129,7 +130,7 @@ def getPlayTime2(filename) datasize = fgetdw.call(file) time = (datasize * 1.0) / bytessec return time - elsif fdw == 0x5367674F # "OggS" + when 0x5367674F # "OggS" file.pos = 0 time = oggfiletime(file) return time @@ -152,7 +153,7 @@ def getPlayTime2(filename) break if ateof || !rstr || rstr.length != 3 if rstr[0] == 0xFB t = rstr[1] >> 4 - next if t == 0 || t == 15 + next if [0, 15].include?(t) freqs = [44100, 22050, 11025, 48000] bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320] bitrate = bitrates[t] diff --git a/Data/Scripts/009_Scenes/001_Transitions.rb b/Data/Scripts/009_Scenes/001_Transitions.rb index f27a3ff55..5e1b3c39c 100644 --- a/Data/Scripts/009_Scenes/001_Transitions.rb +++ b/Data/Scripts/009_Scenes/001_Transitions.rb @@ -544,7 +544,6 @@ module Transitions end def set_up_timings - time_between_zooms = (@duration - TIME_TO_ZOOM) * 2 / (TOTAL_SPRITES - 1) 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 @@ -1182,7 +1181,7 @@ module Transitions for i in 0...4 b = [@black_1_bitmap, @black_2_bitmap, @black_3_bitmap, @black_4_bitmap][i] @sprites[i] = new_sprite((i == 1) ? 0 : Graphics.width / 2, (i == 2) ? 0 : Graphics.height / 2, b, - (i % 2 == 0) ? b.width / 2 : 0, (i % 2 == 0) ? 0 : b.height / 2) + (i.even?) ? b.width / 2 : 0, (i.even?) ? 0 : b.height / 2) @sprites[i].zoom_x = 0.0 if i.even? @sprites[i].zoom_y = 0.0 if i.odd? @sprites[i].visible = false diff --git a/Data/Scripts/010_Data/002_PBS data/002_PhoneDatabase.rb b/Data/Scripts/010_Data/002_PBS data/002_PhoneDatabase.rb index 903cf125e..ab8cd7912 100644 --- a/Data/Scripts/010_Data/002_PBS data/002_PhoneDatabase.rb +++ b/Data/Scripts/010_Data/002_PBS data/002_PhoneDatabase.rb @@ -22,10 +22,3 @@ class PhoneDatabase @trainers = [] end end - -module PhoneMsgType - Generic = 0 - Greeting = 1 - Body = 2 - BattleRequest = 3 -end diff --git a/Data/Scripts/010_Data/002_PBS data/005_Move.rb b/Data/Scripts/010_Data/002_PBS data/005_Move.rb index d38a4a3d0..ee804231a 100644 --- a/Data/Scripts/010_Data/002_PBS data/005_Move.rb +++ b/Data/Scripts/010_Data/002_PBS data/005_Move.rb @@ -570,9 +570,10 @@ module GameData when "09D" then new_code = "StartWeakenElectricMoves" when "09E" then new_code = "StartWeakenFireMoves" when "09F" - if data[:id] == :MULTIATTACK + case data[:id] + when :MULTIATTACK new_code = "TypeDependsOnUserMemory" - elsif data[:id] == :TECHNOBLAST + when :TECHNOBLAST new_code = "TypeDependsOnUserDrive" else new_code = "TypeDependsOnUserPlate" diff --git a/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb b/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb index fd7a3c622..82b43854d 100644 --- a/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb +++ b/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb @@ -16,7 +16,7 @@ module GameData for i in 0...2**factors.length # Set try_ parameters for this combination factors.each_with_index do |factor, index| - value = ((i / (2**index)) % 2 == 0) ? factor[1] : factor[2] + value = ((i / (2**index)).even?) ? factor[1] : factor[2] case factor[0] when 0 then try_species = value when 1 then try_form = value diff --git a/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb b/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb index cf24b7342..6f6cca749 100644 --- a/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb +++ b/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb @@ -11,8 +11,8 @@ class Battle when 2 idxOther = (idxBattler + 2) % 4 when 3 - return false if idxBattler == 2 || idxBattler == 3 # In middle spot already - idxOther = ((idxBattler % 2) == 0) ? 2 : 3 + return false if [2, 3].include?(idxBattler) # In middle spot already + idxOther = (idxBattler.even?) ? 2 : 3 end return false if pbGetOwnerIndexFromBattlerIndex(idxBattler) != pbGetOwnerIndexFromBattlerIndex(idxOther) return true diff --git a/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb b/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb index 72c0aef96..e16785cb4 100644 --- a/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb +++ b/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb @@ -162,8 +162,10 @@ class Battle allBattlers.each { |b| b.pbCheckFormOnWeatherChange } pbEndPrimordialWeather allBattlers.each { |b| b.pbAbilityOnTerrainChange } - allBattlers.each { |b| b.pbCheckFormOnMovesetChange } - allBattlers.each { |b| b.pbCheckFormOnStatusChange } + allBattlers.each do |b| + b.pbCheckFormOnMovesetChange + b.pbCheckFormOnStatusChange + end end #============================================================================= diff --git a/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb b/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb index 4608e0252..d2821caf9 100644 --- a/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb +++ b/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb @@ -10,7 +10,6 @@ class Battle::Battler attr_accessor :ability_id attr_accessor :item_id attr_accessor :moves - attr_accessor :gender attr_accessor :attack attr_accessor :spatk attr_accessor :speed @@ -739,7 +738,7 @@ class Battle::Battler # Returns an array containing all unfainted ally Pokémon. def allAllies - return @battle.allSameSideBattlers(@index).select { |b| b.index != @index } + return @battle.allSameSideBattlers(@index).reject { |b| b.index == @index } end # Yields each unfainted opposing Pokémon. diff --git a/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb b/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb index 64eacc3b0..cc163af5a 100644 --- a/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb +++ b/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb @@ -234,12 +234,12 @@ class Battle::Battler # Darmanitan - Zen Mode if isSpecies?(:DARMANITAN) && self.ability == :ZENMODE if @hp <= @totalhp / 2 - if (@form % 2) == 0 + if @form.even? @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) pbChangeForm(@form + 1, _INTL("{1} triggered!", abilityName)) end - elsif (@form % 2) != 0 + elsif @form.odd? @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) pbChangeForm(@form - 1, _INTL("{1} triggered!", abilityName)) diff --git a/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb b/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb index ea45b9db7..4f32c2494 100644 --- a/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb +++ b/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb @@ -72,7 +72,6 @@ class Battle::Battler # in and not at any later times, even if a traceable ability turns # up later. Essentials ignores this, and allows Trace to trigger # whenever it can even in the old battle mechanics. - choices = [] choices = @battle.allOtherSideBattlers(@index).select { |b| next !b.ungainableAbility? && ![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id) diff --git a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb index d513f0cbb..00102b532 100644 --- a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb @@ -22,7 +22,7 @@ class Battle::Battler idxOther = (@index + 2) % 4 when 3 if @index != 2 && @index != 3 # If not in middle spot already - idxOther = ((@index % 2) == 0) ? 2 : 3 + idxOther = (@index.even?) ? 2 : 3 end end if idxOther >= 0 diff --git a/Data/Scripts/011_Battle/002_Battler/010_Battler_UseMoveTriggerEffects.rb b/Data/Scripts/011_Battle/002_Battler/010_Battler_UseMoveTriggerEffects.rb index a7eb44f6c..d609f397f 100644 --- a/Data/Scripts/011_Battle/002_Battler/010_Battler_UseMoveTriggerEffects.rb +++ b/Data/Scripts/011_Battle/002_Battler/010_Battler_UseMoveTriggerEffects.rb @@ -22,9 +22,10 @@ class Battle::Battler @battle.scene.pbDamageAnimation(user) user.pbReduceHP(user.totalhp / 4, false) end - if target.form == 1 # Gulping Form + case target.form + when 1 # Gulping Form user.pbLowerStatStageByAbility(:DEFENSE, 1, target, false) - elsif target.form == 2 # Gorging Form + when 2 # Gorging Form target.pbParalyze(user) if target.pbCanParalyze?(user, false) end @battle.pbHideAbilitySplash(target) diff --git a/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb b/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb index b247e7c50..f78c6b294 100644 --- a/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb +++ b/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb @@ -396,15 +396,17 @@ class Battle::Move # Weather case user.effectiveWeather when :Sun, :HarshSun - if type == :FIRE + case type + when :FIRE multipliers[:final_damage_multiplier] *= 1.5 - elsif type == :WATER + when :WATER multipliers[:final_damage_multiplier] /= 2 end when :Rain, :HeavyRain - if type == :FIRE + case type + when :FIRE multipliers[:final_damage_multiplier] /= 2 - elsif type == :WATER + when :WATER multipliers[:final_damage_multiplier] *= 1.5 end when :Sandstorm diff --git a/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb b/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb index e7a1c644f..ec3e5ca0c 100644 --- a/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb +++ b/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb @@ -490,9 +490,10 @@ class Battle::Move::CureUserPartyStatus < Battle::Move def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) super - if @id == :AROMATHERAPY + case @id + when :AROMATHERAPY @battle.pbDisplay(_INTL("A soothing aroma wafted through the area!")) - elsif @id == :HEALBELL + when :HEALBELL @battle.pbDisplay(_INTL("A bell chimed!")) end end 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 e9e4c98a5..b289eb74c 100644 --- a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb +++ b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb @@ -200,7 +200,7 @@ class Battle::Scene # Start Bag screen itemScene = PokemonBag_Scene.new itemScene.pbStartScene($bag, true, - Proc.new { |item| + proc { |item| useType = GameData::Item.get(item).battle_use next useType && useType > 0 }, false) @@ -368,7 +368,7 @@ class Battle::Scene when :Foe, :Other indices = @battle.pbGetOpposingIndicesInOrder(idxBattler) indices.each { |i| return i if !@battle.battlers[i].fainted? } - indices.each { |i| return i } + return indices.first if !indices.empty? end return idxBattler # Target the user initially end @@ -391,7 +391,7 @@ class Battle::Scene # Update selected command if mode == 0 # Choosing just one target, can change index if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) - inc = ((cw.index % 2) == 0) ? -2 : 2 + inc = (cw.index.even?) ? -2 : 2 inc *= -1 if Input.trigger?(Input::RIGHT) indexLength = @battle.sideSizes[cw.index % 2] * 2 newIndex = cw.index @@ -402,8 +402,8 @@ class Battle::Scene cw.index = newIndex break end - elsif (Input.trigger?(Input::UP) && (cw.index % 2) == 0) || - (Input.trigger?(Input::DOWN) && (cw.index % 2) == 1) + elsif (Input.trigger?(Input::UP) && cw.index.even?) || + (Input.trigger?(Input::DOWN) && cw.index.odd?) tryIndex = @battle.pbGetOpposingIndicesInOrder(cw.index) tryIndex.each do |idxBattlerTry| next if texts[idxBattlerTry].nil? diff --git a/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb b/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb index 219a821c8..6e301e5c9 100644 --- a/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb +++ b/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb @@ -479,7 +479,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase # NOTE: Battler indexes go from left to right from the perspective of # that side's trainer, so inc is different for each side for the # same value of i/2. - inc = ((i % 2) == 0) ? i / 2 : numButtons - 1 - i / 2 + inc = (i.even?) ? i / 2 : numButtons - 1 - i / 2 button = SpriteWrapper.new(viewport) button.bitmap = @buttonBitmap.bitmap button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2 @@ -530,7 +530,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase if @texts[i] sel ||= (@mode == 0 && i == @index) sel ||= (@mode == 1) - buttonType = ((i % 2) == 0) ? 1 : 2 + buttonType = (i.even?) ? 1 : 2 end buttonType = 2 * buttonType + ((@smallButtons) ? 1 : 0) button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0 diff --git a/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb b/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb index 587135c5b..1afa12678 100644 --- a/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb +++ b/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb @@ -39,7 +39,7 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper end def initializeDataBoxGraphic(sideSize) - onPlayerSide = ((@battler.index % 2) == 0) + onPlayerSide = @battler.index.even? # Get the data box graphic and set whether the HP numbers/Exp bar are shown if sideSize == 1 # One Pokémon on side, use the regular dara box BG bgFilename = ["Graphics/Pictures/Battle/databox_normal", @@ -537,7 +537,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite def pbSetPosition return if !@_iconBitmap pbSetOrigin - if (@index % 2) == 0 + if @index.even? self.z = 50 + 5 * @index / 2 else self.z = 50 - 5 * (@index + 1) / 2 diff --git a/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb b/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb index b2d24dedd..1a7fd7021 100644 --- a/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb +++ b/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb @@ -34,7 +34,7 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation end # Shadows for i in 0...@battle.battlers.length - makeSlideSprite("shadow_#{i}", ((i % 2) == 0) ? 1 : -1, appearTime, PictureOrigin::Center) + makeSlideSprite("shadow_#{i}", (i.even?) ? 1 : -1, appearTime, PictureOrigin::Center) end # Fading blackness over whole screen blackScreen = addNewSprite(0, 0, "Graphics/Battle animations/black_screen") @@ -196,7 +196,7 @@ class Battle::Scene::Animation::DataBoxAppear < Battle::Scene::Animation return if !@sprites["dataBox_#{@idxBox}"] box = addSprite(@sprites["dataBox_#{@idxBox}"]) box.setVisible(0, true) - dir = ((@idxBox % 2) == 0) ? 1 : -1 + dir = (@idxBox.even?) ? 1 : -1 box.setDelta(0, dir * Graphics.width / 2, 0) box.moveDelta(0, 8, -dir * Graphics.width / 2, 0) end @@ -216,7 +216,7 @@ class Battle::Scene::Animation::DataBoxDisappear < Battle::Scene::Animation def createProcesses return if !@sprites["dataBox_#{@idxBox}"] || !@sprites["dataBox_#{@idxBox}"].visible box = addSprite(@sprites["dataBox_#{@idxBox}"]) - dir = ((@idxBox % 2) == 0) ? 1 : -1 + dir = (@idxBox.even?) ? 1 : -1 box.moveDelta(0, 8, dir * Graphics.width / 2, 0) box.setVisible(8, false) end diff --git a/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb b/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb index ccf54f86d..9894c16d7 100644 --- a/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb +++ b/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb @@ -1689,12 +1689,8 @@ class Battle::AI when "PowerHigherWithUserHeavierThanTarget" #--------------------------------------------------------------------------- when "PowerUpAllyMove" - hasAlly = false - user.allAllies.each do |b| - hasAlly = true - score += 30 - break - end + hasAlly = !user.allAllies.empty? + score += 30 if hasAlly score -= 90 if !hasAlly #--------------------------------------------------------------------------- when "StartWeakenElectricMoves" @@ -1826,8 +1822,6 @@ class Battle::AI #--------------------------------------------------------------------------- when "HitTwoTimes" #--------------------------------------------------------------------------- - when "HitTwoTimesPoisonTarget" - #--------------------------------------------------------------------------- when "HitThreeTimesPowersUpWithEachHit" #--------------------------------------------------------------------------- when "HitTwoToFiveTimes" diff --git a/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb b/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb index 76b7ba3fc..c0a0fa415 100644 --- a/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb +++ b/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb @@ -273,12 +273,11 @@ class Battle::AI targetTypes = target.pbTypes(true) mult = Effectiveness.calculate(:FLYING, targetTypes[0], targetTypes[1], targetTypes[2]) - baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round else mult = Effectiveness.calculate(:FLYING, target.types[0], target.types[1], target.effects[PBEffects::Type3]) - baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round end + baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round end baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] when "DoublePowerIfUserLastMoveFailed" # Stomping Tantrum @@ -472,15 +471,17 @@ class Battle::AI if skill >= PBTrainerAI.mediumSkill case user.effectiveWeather when :Sun, :HarshSun - if type == :FIRE + case type + when :FIRE multipliers[:final_damage_multiplier] *= 1.5 - elsif type == :WATER + when :WATER multipliers[:final_damage_multiplier] /= 2 end when :Rain, :HeavyRain - if type == :FIRE + case type + when :FIRE multipliers[:final_damage_multiplier] /= 2 - elsif type == :WATER + when :WATER multipliers[:final_damage_multiplier] *= 1.5 end when :Sandstorm diff --git a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb index dd6eeb6e6..650034802 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb @@ -1582,7 +1582,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:PUNKROCK, Battle::AbilityEffects::DamageCalcFromTarget.add(:THICKFAT, proc { |ability, user, target, move, mults, baseDmg, type| - mults[:base_damage_multiplier] /= 2 if type == :FIRE || type == :ICE + mults[:base_damage_multiplier] /= 2 if [:FIRE, :ICE].include?(type) } ) diff --git a/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb b/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb index 3e156973f..276b6e165 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb @@ -726,7 +726,7 @@ Battle::ItemEffects::AccuracyCalcFromTarget.copy(:BRIGHTPOWDER, :LAXINCENSE) Battle::ItemEffects::DamageCalcFromUser.add(:ADAMANTORB, proc { |item, user, target, move, mults, baseDmg, type| - if user.isSpecies?(:DIALGA) && (type == :DRAGON || type == :STEEL) + if user.isSpecies?(:DIALGA) && [:DRAGON, :STEEL].include?(type) mults[:base_damage_multiplier] *= 1.2 end } @@ -854,7 +854,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:GRASSGEM, Battle::ItemEffects::DamageCalcFromUser.add(:GRISEOUSORB, proc { |item, user, target, move, mults, baseDmg, type| - if user.isSpecies?(:GIRATINA) && (type == :DRAGON || type == :GHOST) + if user.isSpecies?(:GIRATINA) && [:DRAGON, :GHOST].include?(type) mults[:base_damage_multiplier] *= 1.2 end } @@ -898,7 +898,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:LIGHTBALL, Battle::ItemEffects::DamageCalcFromUser.add(:LUSTROUSORB, proc { |item, user, target, move, mults, baseDmg, type| - if user.isSpecies?(:PALKIA) && (type == :DRAGON || type == :WATER) + if user.isSpecies?(:PALKIA) && [:DRAGON, :WATER].include?(type) mults[:base_damage_multiplier] *= 1.2 end } @@ -1029,7 +1029,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:SOULDEW, proc { |item, user, target, move, mults, baseDmg, type| next if !user.isSpecies?(:LATIAS) && !user.isSpecies?(:LATIOS) if Settings::SOUL_DEW_POWERS_UP_TYPES - mults[:final_damage_multiplier] *= 1.2 if type == :PSYCHIC || type == :DRAGON + mults[:final_damage_multiplier] *= 1.2 if [:DRAGON, :PSYCHIC].include?(type) else if move.specialMove? && !user.battle.rules["souldewclause"] mults[:attack_multiplier] *= 1.5 @@ -1880,7 +1880,6 @@ Battle::ItemEffects::EndOfRoundEffect.add(:FLAMEORB, Battle::ItemEffects::EndOfRoundEffect.add(:STICKYBARB, proc { |item, battler, battle| next if !battler.takesIndirectDamage? - oldHP = battler.hp battle.scene.pbDamageAnimation(battler) battler.pbTakeEffectDamage(battler.totalhp / 8, false) { |hp_lost| battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) diff --git a/Data/Scripts/011_Battle/007_Other battle types/003_BattlePalaceBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/003_BattlePalaceBattle.rb index bb67e2132..3920c3c03 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/003_BattlePalaceBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/003_BattlePalaceBattle.rb @@ -95,17 +95,10 @@ class BattlePalaceBattle < Battle def pbRegisterMove(idxBattler, idxMove, _showMessages = true) this_battler = @battlers[idxBattler] - if idxMove == -2 - @choices[idxBattler][0] = :UseMove # "Use move" - @choices[idxBattler][1] = -2 # "Incapable of using its power..." - @choices[idxBattler][2] = @struggle - @choices[idxBattler][3] = -1 - else - @choices[idxBattler][0] = :UseMove # "Use move" - @choices[idxBattler][1] = idxMove # Index of move to be used - @choices[idxBattler][2] = this_battler.moves[idxMove] # Battle::Move object - @choices[idxBattler][3] = -1 # No target chosen yet - end + @choices[idxBattler][0] = :UseMove + @choices[idxBattler][1] = idxMove # Index of move to be used (-2="Incapable of using its power...") + @choices[idxBattler][2] = (idxMove == -2) ? @struggle : this_battler.moves[idxMove] # Battle::Move object + @choices[idxBattler][3] = -1 # No target chosen yet end def pbAutoFightMenu(idxBattler) 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 7c2511a3c..e53af4ef2 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 @@ -17,9 +17,10 @@ class Battle::SuccessState end def updateSkill - if @useState == 1 + case @useState + when 1 @skill = -2 if !@protected - elsif @useState == 2 + when 2 if Effectiveness.super_effective?(@typeMod) @skill = 2 elsif Effectiveness.normal?(@typeMod) diff --git a/Data/Scripts/011_Battle/007_Other battle types/005_RecordedBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/005_RecordedBattle.rb index cbb95f042..a68a2a1df 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/005_RecordedBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/005_RecordedBattle.rb @@ -6,10 +6,10 @@ module RecordedBattleModule attr_reader :rounds module Commands - Fight = 0 - Bag = 1 - Pokemon = 2 - Run = 3 + FIGHT = 0 + BAG = 1 + POKEMON = 2 + RUN = 3 end def initialize(*arg) @@ -81,7 +81,7 @@ module RecordedBattleModule def pbRegisterMove(idxBattler, idxMove, showMessages = true) if super - @rounds[@roundindex][idxBattler] = [Commands::Fight, idxMove] + @rounds[@roundindex][idxBattler] = [Commands::FIGHT, idxMove] return true end return false @@ -94,19 +94,19 @@ module RecordedBattleModule def pbRun(idxBattler, duringBattle = false) ret = super - @rounds[@roundindex][idxBattler] = [Commands::Run, @decision] + @rounds[@roundindex][idxBattler] = [Commands::RUN, @decision] return ret end def pbAutoChooseMove(idxBattler, showMessages = true) ret = super - @rounds[@roundindex][idxBattler] = [Commands::Fight, -1] + @rounds[@roundindex][idxBattler] = [Commands::FIGHT, -1] return ret end def pbRegisterSwitch(idxBattler, idxParty) if super - @rounds[@roundindex][idxBattler] = [Commands::Pokemon, idxParty] + @rounds[@roundindex][idxBattler] = [Commands::POKEMON, idxParty] return true end return false @@ -114,7 +114,7 @@ module RecordedBattleModule def pbRegisterItem(idxBattler, item, idxTarget = nil, idxMove = nil) if super - @rounds[@roundindex][idxBattler] = [Commands::Bag, item, idxTarget, idxMove] + @rounds[@roundindex][idxBattler] = [Commands::BAG, item, idxTarget, idxMove] return true end return false @@ -140,10 +140,10 @@ end #=============================================================================== module RecordedBattlePlaybackModule module Commands - Fight = 0 - Bag = 1 - Pokemon = 2 - Run = 3 + FIGHT = 0 + BAG = 1 + POKEMON = 2 + RUN = 3 end def initialize(scene, battle) @@ -206,7 +206,7 @@ module RecordedBattlePlaybackModule next if @rounds[@roundindex][i].length == 0 pbClearChoice(i) case @rounds[@roundindex][i][0] - when Commands::Fight + when Commands::FIGHT if @rounds[@roundindex][i][1] == -1 pbAutoChooseMove(i, false) else @@ -215,11 +215,11 @@ module RecordedBattlePlaybackModule if @rounds[@roundindex][i][2] pbRegisterTarget(i, @rounds[@roundindex][i][2]) end - when Commands::Bag + when Commands::BAG pbRegisterItem(i, @rounds[@roundindex][i][1], @rounds[@roundindex][i][2], @rounds[@roundindex][i][3]) - when Commands::Pokemon + when Commands::POKEMON pbRegisterSwitch(i, @rounds[@roundindex][i][1]) - when Commands::Run + when Commands::RUN @decision = @rounds[@roundindex][i][1] end end diff --git a/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb b/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb index 3f0cf2749..7799c2aff 100644 --- a/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb +++ b/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb @@ -214,7 +214,7 @@ module RPG end if @weatherTypes[weather_type][0].category == :Rain last_index = weatherBitmaps.length - 1 # Last sprite is a splash - if (index % 2) == 0 + if index.even? sprite.bitmap = weatherBitmaps[index % last_index] else sprite.bitmap = weatherBitmaps[last_index] @@ -244,10 +244,10 @@ module RPG lifetimes[index] = 0 return end - if @weatherTypes[weather_type][0].category == :Rain && (index % 2) != 0 # Splash + if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash sprite.x = @ox - sprite.bitmap.width + rand(Graphics.width + sprite.bitmap.width * 2) sprite.y = @oy - sprite.bitmap.height + rand(Graphics.height + sprite.bitmap.height * 2) - lifetimes[index] = (30 + rand(20)) * 0.01 # 0.3-0.5 seconds + lifetimes[index] = (rand(30...50)) * 0.01 # 0.3-0.5 seconds else x_speed = @weatherTypes[weather_type][0].particle_delta_x y_speed = @weatherTypes[weather_type][0].particle_delta_y @@ -283,7 +283,7 @@ module RPG # Determine which weather type this sprite is representing weather_type = (is_new_sprite) ? @target_type : @type # Update visibility/position/opacity of sprite - if @weatherTypes[weather_type][0].category == :Rain && (index % 2) != 0 # Splash + if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash sprite.opacity = (lifetimes[index] < 0.2) ? 255 : 0 # 0.2 seconds else dist_x = @weatherTypes[weather_type][0].particle_delta_x * delta_t @@ -486,11 +486,11 @@ module RPG if @time_until_flash > 0 @time_until_flash -= Graphics.delta_s if @time_until_flash <= 0 - @viewport.flash(Color.new(255, 255, 255, 230), (2 + rand(3)) * 20) + @viewport.flash(Color.new(255, 255, 255, 230), rand(2..4) * 20) end end if @time_until_flash <= 0 - @time_until_flash = (1 + rand(12)) * 0.5 # 0.5-6 seconds + @time_until_flash = rand(1..12) * 0.5 # 0.5-6 seconds end end @viewport.update diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb index 5f9f9cfb5..d90224623 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb @@ -573,7 +573,7 @@ def pbAfterBattle(decision, canLose) pkmn.makeUnprimal end end - if decision == 2 || decision == 5 # if loss or draw + if [2, 5].include?(decision) # if loss or draw if canLose $player.party.each { |pkmn| pkmn.heal } (Graphics.frame_rate / 4).times { Graphics.update } diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb b/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb index c95cc593f..87ccd10b8 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb @@ -180,7 +180,7 @@ end ##### VS. animation, by Luka S.J. ##### ##### Tweaked by Maruno ##### SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50 - Proc.new { |battle_type, foe| # Condition + proc { |battle_type, foe| # Condition next false unless [1, 3].include?(battle_type) && foe.length == 1 # Only if a single trainer tr_type = foe[0].trainer_type next false if !tr_type @@ -189,7 +189,7 @@ SpecialBattleIntroAnimations.register("vs_animation", 50, # Priority 50 next pbResolveBitmap("Graphics/Transitions/" + trainer_bar_graphic) && pbResolveBitmap("Graphics/Transitions/" + trainer_graphic) }, - Proc.new { |viewport, battle_type, foe| # Animation + proc { |viewport, battle_type, foe| # Animation # Determine filenames of graphics to be used tr_type = foe[0].trainer_type trainer_bar_graphic = sprintf("vsBar_%s", tr_type.to_s) rescue nil diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/005_Overworld_RoamingPokemon.rb b/Data/Scripts/012_Overworld/002_Battle triggering/005_Overworld_RoamingPokemon.rb index 8fa0e3f27..47b3be965 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/005_Overworld_RoamingPokemon.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/005_Overworld_RoamingPokemon.rb @@ -208,7 +208,7 @@ def pbRoamingPokemonBattle(species, level) # Perform the battle decision = pbWildBattleCore($PokemonGlobal.roamPokemon[idxRoamer]) # Update Roaming Pokémon data based on result of battle - if decision == 1 || decision == 4 # Defeated or caught + if [1, 4].include?(decision) # Defeated or caught $PokemonGlobal.roamPokemon[idxRoamer] = true $PokemonGlobal.roamPokemonCaught[idxRoamer] = (decision == 4) end diff --git a/Data/Scripts/012_Overworld/003_Overworld_Time.rb b/Data/Scripts/012_Overworld/003_Overworld_Time.rb index eb6fedd6b..a89c78bce 100644 --- a/Data/Scripts/012_Overworld/003_Overworld_Time.rb +++ b/Data/Scripts/012_Overworld/003_Overworld_Time.rb @@ -8,7 +8,7 @@ end module PBDayNight - HourlyTones = [ + HOURLY_TONES = [ Tone.new(-70, -90, 15, 55), # Night # Midnight Tone.new(-70, -90, 15, 55), # Night Tone.new(-70, -90, 15, 55), # Night @@ -93,15 +93,13 @@ module PBDayNight return (now.hour * 60) + now.min end - private - def self.getToneInternal # Calculates the tone for the current frame, used for day/night effects realMinutes = pbGetDayNightMinutes hour = realMinutes / 60 minute = realMinutes % 60 - tone = PBDayNight::HourlyTones[hour] - nexthourtone = PBDayNight::HourlyTones[(hour + 1) % 24] + tone = PBDayNight::HOURLY_TONES[hour] + nexthourtone = PBDayNight::HOURLY_TONES[(hour + 1) % 24] # Calculate current tint according to current and next hour's tint and # depending on current minute @cachedTone.red = ((nexthourtone.red - tone.red) * minute * @oneOverSixty) + tone.red diff --git a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb index 12dc0fb81..62e8a7551 100644 --- a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb +++ b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb @@ -83,7 +83,7 @@ def pbHiddenMoveAnimation(pokemon) 15.times do |i| strobe = BitmapSprite.new(26 * 2, 8 * 2, viewport) strobe.bitmap.blt(0, 0, strobebitmap.bitmap, Rect.new(0, (i % 2) * 8 * 2, 26 * 2, 8 * 2)) - strobe.z = ((i % 2) == 0 ? 2 : 0) + strobe.z = (i.even? ? 2 : 0) strobe.visible = false strobes.push(strobe) end diff --git a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb index cb0276cab..6d72c9633 100644 --- a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb +++ b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb @@ -47,8 +47,8 @@ def pbFishing(hasEncounter, rodType = 1) msgWindow = pbCreateMessageWindow ret = false loop do - time = 5 + rand(6) - time = [time, 5 + rand(6)].min if speedup + time = rand(5..10) + time = [time, rand(5..10)].min if speedup message = "" time.times { message += ". " } if pbWaitMessage(msgWindow, time) diff --git a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb index 221dffd18..8c3612844 100644 --- a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb +++ b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb @@ -382,7 +382,7 @@ def pbBerryPlant pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) - mulch = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_mulch? }) + mulch = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_mulch? }) } return if !mulch mulch_data = GameData::Item.get(mulch) @@ -409,7 +409,7 @@ def pbBerryPlant pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) - berry = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_berry? }) + berry = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_berry? }) } if berry $stats.berries_planted += 1 diff --git a/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb b/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb index 9e8034448..58b3bacfe 100644 --- a/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb +++ b/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb @@ -76,10 +76,10 @@ module RandomDungeonGenerator ROOM_MIN_HEIGHT = 4 ROOM_MAX_HEIGHT = CELL_HEIGHT - 3 # Should be at most CELL_HEIGHT - 3 CORRIDOR_WIDTH = 3 - None = 0 - TurnLeft = 1 - TurnRight = 2 - Turn180 = 3 + TURN_NONE = 0 + TURN_LEFT = 1 + TURN_RIGHT = 2 + TURN_BACK = 3 @@corridor_layouts = nil module_function @@ -96,16 +96,16 @@ module RandomDungeonGenerator for i in 0...CELL_WIDTH * CELL_HEIGHT tiles[combo][i] = DungeonTile::VOID end - if (combo & EdgeMasks::North) == 0 + if (combo & EdgeMasks::NORTH) == 0 paint_corridor(tiles[combo], x_offset, 0, CORRIDOR_WIDTH, y_offset + CORRIDOR_WIDTH) end - if (combo & EdgeMasks::South) == 0 + if (combo & EdgeMasks::SOUTH) == 0 paint_corridor(tiles[combo], x_offset, y_offset, CORRIDOR_WIDTH, CELL_HEIGHT - y_offset) end - if (combo & EdgeMasks::East) == 0 + if (combo & EdgeMasks::EAST) == 0 paint_corridor(tiles[combo], x_offset, y_offset, CELL_WIDTH - x_offset, CORRIDOR_WIDTH) end - if (combo & EdgeMasks::West) == 0 + if (combo & EdgeMasks::WEST) == 0 paint_corridor(tiles[combo], 0, y_offset, x_offset + CORRIDOR_WIDTH, CORRIDOR_WIDTH) end end @@ -126,25 +126,25 @@ module RandomDungeonGenerator # Used to draw tiles from the given tile_layout and rotation (for corridors). def paint_tile_layout(dungeon, dstX, dstY, tile_layout, rotation) case rotation - when None + when TURN_NONE for y in 0...CELL_HEIGHT for x in 0...CELL_WIDTH dungeon[x + dstX, y + dstY] = tile_layout[y * CELL_WIDTH + x] end end - when TurnLeft + when TURN_LEFT 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] end end - when TurnRight + when TURN_RIGHT for y in 0...CELL_HEIGHT for x in 0...CELL_WIDTH dungeon[CELL_HEIGHT - 1 - y + dstX, x + dstY] = tile_layout[y * CELL_WIDTH + x] end end - when Turn180 + when TURN_BACK for y in 0...CELL_HEIGHT for x in 0...CELL_WIDTH dungeon[CELL_WIDTH - 1 - x + dstX, CELL_HEIGHT - 1 - y + dstY] = tile_layout[y * CELL_WIDTH + x] @@ -180,11 +180,11 @@ module RandomDungeonGenerator # Bitwise values used to keep track of the generation of node connections. #============================================================================= module EdgeMasks - North = 1 - West = 2 - East = 4 - South = 8 - Visited = 16 + NORTH = 1 + WEST = 2 + EAST = 4 + SOUTH = 8 + VISITED = 16 end #============================================================================= @@ -225,7 +225,7 @@ module RandomDungeonGenerator class Maze attr_accessor :cellWidth, :cellHeight, :nodeWidth, :nodeHeight - DIRECTIONS = [EdgeMasks::North, EdgeMasks::South, EdgeMasks::East, EdgeMasks::West] + DIRECTIONS = [EdgeMasks::NORTH, EdgeMasks::SOUTH, EdgeMasks::EAST, EdgeMasks::WEST] def initialize(cw, ch) raise ArgumentError.new if cw == 0 || ch == 0 @@ -244,17 +244,17 @@ module RandomDungeonGenerator def getVisited(x, y) return false if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight - return (@cells[y * cellWidth + x] & EdgeMasks::Visited) != 0 + return (@cells[y * cellWidth + x] & EdgeMasks::VISITED) != 0 end def setVisited(x, y) return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight - @cells[y * cellWidth + x] |= EdgeMasks::Visited + @cells[y * cellWidth + x] |= EdgeMasks::VISITED end def clearVisited(x, y) return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight - @cells[y * cellWidth + x] &= ~EdgeMasks::Visited + @cells[y * cellWidth + x] &= ~EdgeMasks::VISITED end def clearAllCells @@ -275,17 +275,17 @@ module RandomDungeonGenerator nx = x ny = y case edge - when EdgeMasks::North - e = EdgeMasks::South + when EdgeMasks::NORTH + e = EdgeMasks::SOUTH ny = y - 1 - when EdgeMasks::South - e = EdgeMasks::North + when EdgeMasks::SOUTH + e = EdgeMasks::NORTH ny = y + 1 - when EdgeMasks::East - e = EdgeMasks::West + when EdgeMasks::EAST + e = EdgeMasks::WEST nx = x + 1 - when EdgeMasks::West - e = EdgeMasks::East + when EdgeMasks::WEST + e = EdgeMasks::EAST nx = x - 1 else return @@ -307,17 +307,17 @@ module RandomDungeonGenerator nx = x ny = y case edge - when EdgeMasks::North - e = EdgeMasks::South + when EdgeMasks::NORTH + e = EdgeMasks::SOUTH ny -= 1 - when EdgeMasks::South - e = EdgeMasks::North + when EdgeMasks::SOUTH + e = EdgeMasks::NORTH ny += 1 - when EdgeMasks::East - e = EdgeMasks::West + when EdgeMasks::EAST + e = EdgeMasks::WEST nx += 1 - when EdgeMasks::West - e = EdgeMasks::East + when EdgeMasks::WEST + e = EdgeMasks::EAST nx -= 1 else raise ArgumentError.new @@ -339,10 +339,10 @@ module RandomDungeonGenerator def getEdgePattern(x, y) pattern = 0 - pattern |= EdgeMasks::North if getEdgeNode(x, y, EdgeMasks::North) - pattern |= EdgeMasks::South if getEdgeNode(x, y, EdgeMasks::South) - pattern |= EdgeMasks::East if getEdgeNode(x, y, EdgeMasks::East) - pattern |= EdgeMasks::West if getEdgeNode(x, y, EdgeMasks::West) + pattern |= EdgeMasks::NORTH if getEdgeNode(x, y, EdgeMasks::NORTH) + pattern |= EdgeMasks::SOUTH if getEdgeNode(x, y, EdgeMasks::SOUTH) + pattern |= EdgeMasks::EAST if getEdgeNode(x, y, EdgeMasks::EAST) + pattern |= EdgeMasks::WEST if getEdgeNode(x, y, EdgeMasks::WEST) return pattern end @@ -354,13 +354,13 @@ module RandomDungeonGenerator ox = wx oy = wy case dir - when EdgeMasks::North + when EdgeMasks::NORTH wy -= 1 - when EdgeMasks::West + when EdgeMasks::WEST wx -= 1 - when EdgeMasks::East + when EdgeMasks::EAST wx += 1 - when EdgeMasks::South + when EdgeMasks::SOUTH wy += 1 end if isBlockedNode?(wx, wy) @@ -384,10 +384,10 @@ module RandomDungeonGenerator def generateWallGrowthMaze(minWall = 0, maxWall = nil) maxWall = cellWidth if !maxWall - nlist = buildNodeList() + nlist = buildNodeList return if nlist.length == 0 for c in 0...nlist.length - d = randomDir() + d = randomDir len = rand(maxWall + 1) x = nlist[c].x y = nlist[c].y @@ -403,13 +403,13 @@ module RandomDungeonGenerator cx = x cy = y case d - when EdgeMasks::North + when EdgeMasks::NORTH cy -= 1 - when EdgeMasks::South + when EdgeMasks::SOUTH cy += 1 - when EdgeMasks::East + when EdgeMasks::EAST cx += 1 - when EdgeMasks::West + when EdgeMasks::WEST cx -= 1 end if cx >= 0 && cy >= 0 && cx < cellWidth && cy < cellHeight @@ -568,7 +568,7 @@ module RandomDungeonGenerator end # Generate connections between cells maze = Maze.new(maxWidth / cellWidth, maxHeight / cellHeight) - maze.generateDepthFirstMaze() + maze.generateDepthFirstMaze # Draw each cell's contents in turn (room and corridors) corridor_patterns = DungeonMaze.generate_corridor_patterns roomcount = 0 @@ -577,7 +577,7 @@ module RandomDungeonGenerator pattern = maze.getEdgePattern(x, y) if DungeonMaze.paint_cell_contents( self, BUFFER_X + x * cellWidth, BUFFER_Y + y * cellHeight, - corridor_patterns[pattern], DungeonMaze::None) + corridor_patterns[pattern], DungeonMaze::TURN_NONE) roomcount += 1 end end @@ -622,8 +622,8 @@ module RandomDungeonGenerator ar1 = AntiRandom.new(dungeon.width) ar2 = AntiRandom.new(dungeon.height) ((tiles.length + 1) * 1000).times do - x = ar1.get() - y = ar2.get() + x = ar1.get + y = ar2.get if dungeon.isRoom?(x, y) && !tiles.any? { |item| (item[0] - x).abs < 2 && (item[1] - y).abs < 2 } ret = [x, y] diff --git a/Data/Scripts/013_Items/001_Item_Utilities.rb b/Data/Scripts/013_Items/001_Item_Utilities.rb index 37c79b3e3..da79df86c 100644 --- a/Data/Scripts/013_Items/001_Item_Utilities.rb +++ b/Data/Scripts/013_Items/001_Item_Utilities.rb @@ -145,10 +145,10 @@ def pbChangeLevel(pkmn, new_level, scene) old_special_attack = pkmn.spatk old_special_defense = pkmn.spdef old_speed = pkmn.speed - if pkmn.level > new_level - pkmn.level = new_level - pkmn.calc_stats - scene.pbRefresh + pkmn.level = new_level + pkmn.calc_stats + scene.pbRefresh + if old_level > new_level if scene.is_a?(PokemonPartyScreen) scene.pbDisplay(_INTL("{1} dropped to Lv. {2}!", pkmn.name, pkmn.level)) else @@ -165,10 +165,7 @@ def pbChangeLevel(pkmn, new_level, scene) pbTopRightWindow(_INTL("Max. HP{1}\r\nAttack{2}\r\nDefense{3}\r\nSp. Atk{4}\r\nSp. Def{5}\r\nSpeed{6}", pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed), scene) else - pkmn.level = new_level pkmn.changeHappiness("vitamin") - pkmn.calc_stats - scene.pbRefresh if scene.is_a?(PokemonPartyScreen) scene.pbDisplay(_INTL("{1} grew to Lv. {2}!", pkmn.name, pkmn.level)) else @@ -898,7 +895,7 @@ def pbChooseApricorn(var = 0) pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) - ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_apricorn? }) + ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_apricorn? }) } $game_variables[var] = ret || :NONE if var > 0 return ret @@ -909,7 +906,7 @@ def pbChooseFossil(var = 0) pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) - ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_fossil? }) + ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_fossil? }) } $game_variables[var] = ret || :NONE if var > 0 return ret diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index 2039930df..1a9341131 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -127,7 +127,7 @@ Events.onStepTaken += proc { pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) - ret = screen.pbChooseItemScreen(Proc.new { |item| + ret = screen.pbChooseItemScreen(proc { |item| [:REPEL, :SUPERREPEL, :MAXREPEL].include?(item) }) } diff --git a/Data/Scripts/013_Items/005_Item_PokeRadar.rb b/Data/Scripts/013_Items/005_Item_PokeRadar.rb index 6a2a1ee8e..6e01f0b7e 100644 --- a/Data/Scripts/013_Items/005_Item_PokeRadar.rb +++ b/Data/Scripts/013_Items/005_Item_PokeRadar.rb @@ -208,7 +208,7 @@ Events.onWildBattleEnd += proc { |_sender, e| species = e[0] level = e[1] decision = e[2] - if $game_temp.poke_radar_data && (decision == 1 || decision == 4) # Defeated/caught + if $game_temp.poke_radar_data && [1, 4].include?(decision) # Defeated/caught $game_temp.poke_radar_data[0] = species $game_temp.poke_radar_data[1] = level $game_temp.poke_radar_data[2] += 1 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 b81069fa5..79db48876 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb @@ -515,7 +515,7 @@ MultipleForms.register(:SILVALLY, { MultipleForms.register(:MINIOR, { "getFormOnCreation" => proc { |pkmn| - next 7 + rand(7) # Meteor forms are 0-6, Core forms are 7-13 + next rand(7..13) # Meteor forms are 0-6, Core forms are 7-13 }, "getFormOnEnteringBattle" => proc { |pkmn, wild| next pkmn.form - 7 if pkmn.form >= 7 && wild # Wild Minior always appear in Meteor form diff --git a/Data/Scripts/014_Pokemon/003_Pokemon_ShadowPokemon.rb b/Data/Scripts/014_Pokemon/003_Pokemon_ShadowPokemon.rb index 3d3e78bbf..403e09e97 100644 --- a/Data/Scripts/014_Pokemon/003_Pokemon_ShadowPokemon.rb +++ b/Data/Scripts/014_Pokemon/003_Pokemon_ShadowPokemon.rb @@ -10,7 +10,7 @@ class Pokemon attr_accessor :shadow_moves attr_accessor :heart_gauge_step_counter - alias :__shadow_expeq :exp= + alias __shadow_expeq exp= def exp=(value) if shadowPokemon? @saved_exp += value - @exp @@ -19,7 +19,7 @@ class Pokemon end end - alias :__shadow_hpeq :hp= + alias __shadow_hpeq hp= def hp=(value) __shadow_hpeq(value) @hyper_mode = false if @hp <= 0 @@ -212,7 +212,7 @@ class Pokemon end end - alias :__shadow_clone :clone + alias __shadow_clone clone def clone ret = __shadow_clone if @saved_ev diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb index 762d50dea..0c62137ac 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb @@ -99,7 +99,7 @@ class PokemonEggHatch_Scene frames = (GameData::Species.cry_length(@pokemon) * Graphics.frame_rate).ceil @pokemon.play_cry updateScene(frames + 4) - pbBGMStop() + pbBGMStop pbMEPlay("Evolution success") @pokemon.name = nil pbMessage(_INTL("\\se[]{1} hatched from the Egg!\\wt[80]", @pokemon.name)) { update } @@ -135,8 +135,8 @@ class PokemonEggHatch_Scene targets.push(@sprites["pokemon"].x) targets.each_with_index do |target, i| loop do - break if i % 2 == 0 && @sprites["pokemon"].x >= target - break if i % 2 == 1 && @sprites["pokemon"].x <= target + break if i.even? && @sprites["pokemon"].x >= target + break if i.odd? && @sprites["pokemon"].x <= target @sprites["pokemon"].x += speed @sprites["hatch"].x = @sprites["pokemon"].x updateScene 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 9adb798f4..fc68f5616 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 @@ -161,7 +161,7 @@ class HallOfFame_Scene def xpositionformula(battlernumber) ret = 0 if !SINGLEROW - ret = (battlernumber / 3 % 2 == 0) ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3 + ret = (battlernumber / 3).even? ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3 else ret = battlernumber % 2 * 2 end diff --git a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb index 6d6817b71..7810ff915 100644 --- a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb +++ b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb @@ -676,7 +676,7 @@ class PokemonPokedex_Scene end end # Draw selected option(s) button graphic - if mode == 3 || mode == 4 # Height, weight + if [3, 4].include?(mode) # Height, weight xpos1 = xstart + (sel[0] + 1) * xgap xpos1 = xstart if sel[0] < -1 xpos2 = xstart + (sel[1] + 1) * xgap @@ -696,11 +696,10 @@ class PokemonPokedex_Scene textpos.push([txt2, xpos2 + halfwidth, ypos2, 2, base, nil, 1]) else for i in 0...sel.length + selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight) if sel[i] >= 0 - selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight) overlay.blt(xstart + (sel[i] % cols) * xgap, ystart + (sel[i] / cols).floor * ygap, @selbitmap.bitmap, selrect) else - selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight) overlay.blt(xstart + (cols - 1) * xgap, ystart + (cmds.length / cols).floor * ygap, @selbitmap.bitmap, selrect) end end @@ -903,7 +902,7 @@ class PokemonPokedex_Scene oldindex = index minmax = 1 oldminmax = minmax - if mode == 3 || mode == 4 + if [3, 4].include?(mode) index = oldindex = selindex[minmax] end @sprites["searchcursor"].mode = mode @@ -922,7 +921,7 @@ class PokemonPokedex_Scene end Graphics.update Input.update - if mode == 3 || mode == 4 + if [3, 4].include?(mode) if Input.trigger?(Input::UP) if index < -1 # From OK/Cancel minmax = 0 @@ -936,10 +935,11 @@ class PokemonPokedex_Scene pbRefreshDexSearchParam(mode, cmds, selindex, index) end elsif Input.trigger?(Input::DOWN) - if minmax == 1 + case minmax + when 1 minmax = 0 index = selindex[minmax] - elsif minmax == 0 + when 0 minmax = -1 index = -2 end @@ -1131,7 +1131,7 @@ class PokemonPokedex_Scene end pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::DOWN) - if index == 4 || index == 6 + if [4, 6].include?(index) index = 8 elsif index < 7 index += 1 @@ -1151,7 +1151,7 @@ class PokemonPokedex_Scene index = 5 elsif index >= 2 && index <= 4 index = 6 - elsif index == 7 || index == 8 + elsif [7, 8].include?(index) index += 1 end pbPlayCursorSE if index != oldindex diff --git a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb index 6fb255ce0..36b6628da 100644 --- a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb +++ b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb @@ -383,7 +383,7 @@ class PokemonPokedexInfo_Scene end textpos = [ [GameData::Species.get(@species).name, Graphics.width / 2, Graphics.height - 94, 2, base, shadow], - [formname, Graphics.width / 2, Graphics.height - 62, 2, base, shadow], + [formname, Graphics.width / 2, Graphics.height - 62, 2, base, shadow] ] # Draw all text pbDrawTextPositions(overlay, textpos) @@ -464,12 +464,13 @@ class PokemonPokedexInfo_Scene pbPlayCloseMenuSE break elsif Input.trigger?(Input::USE) - if @page == 1 # Info + case @page + when 1 # Info @show_battled_count = !@show_battled_count dorefresh = true - elsif @page == 2 # Area + when 2 # Area # dorefresh = true - elsif @page == 3 # Forms + when 3 # Forms if @available.length > 1 pbPlayDecisionSE pbChooseForm diff --git a/Data/Scripts/016_UI/005_UI_Party.rb b/Data/Scripts/016_UI/005_UI_Party.rb index 9ad97d443..d4de7d4cf 100644 --- a/Data/Scripts/016_UI/005_UI_Party.rb +++ b/Data/Scripts/016_UI/005_UI_Party.rb @@ -679,7 +679,7 @@ class PokemonParty_Scene pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, bag) - ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? }) + ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? }) yield if block_given? } return ret @@ -690,7 +690,7 @@ class PokemonParty_Scene pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, bag) - ret = screen.pbChooseItemScreen(Proc.new { |item| + ret = screen.pbChooseItemScreen(proc { |item| itm = GameData::Item.get(item) next false if !pbCanUseOnPokemon?(itm) if itm.is_machine? @@ -1023,8 +1023,6 @@ class PokemonPartyScreen addedEntry = false for i in 0...@party.length statuses[i] = (ruleset.isPokemonValid?(@party[i])) ? 1 : 2 - end - for i in 0...@party.length annot[i] = ordinals[statuses[i]] end @scene.pbStartScene(@party, _INTL("Choose Pokémon and confirm."), annot, true) diff --git a/Data/Scripts/016_UI/006_UI_Summary.rb b/Data/Scripts/016_UI/006_UI_Summary.rb index 31e513d61..5fc00b9b4 100644 --- a/Data/Scripts/016_UI/006_UI_Summary.rb +++ b/Data/Scripts/016_UI/006_UI_Summary.rb @@ -212,14 +212,14 @@ class PokemonSummary_Scene def pbDisplay(text) @sprites["messagebox"].text = text @sprites["messagebox"].visible = true - pbPlayDecisionSE() + pbPlayDecisionSE loop do Graphics.update Input.update pbUpdate if @sprites["messagebox"].busy? if Input.trigger?(Input::USE) - pbPlayDecisionSE() if @sprites["messagebox"].pausing? + pbPlayDecisionSE if @sprites["messagebox"].pausing? @sprites["messagebox"].resume end elsif Input.trigger?(Input::USE) || Input.trigger?(Input::BACK) @@ -393,7 +393,7 @@ class PokemonSummary_Scene [@pokemon.speciesName, 435, 106, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)], [_INTL("Type"), 238, 138, 0, base, shadow], [_INTL("OT"), 238, 170, 0, base, shadow], - [_INTL("ID No."), 238, 202, 0, base, shadow], + [_INTL("ID No."), 238, 202, 0, base, shadow] ] # Write the Regional/National Dex number dexnum = 0 @@ -836,7 +836,7 @@ class PokemonSummary_Scene # Write various bits of text textpos = [ [_INTL("No. of Ribbons:"), 234, 326, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)], - [@pokemon.numRibbons.to_s, 450, 326, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [@pokemon.numRibbons.to_s, 450, 326, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)] ] # Draw all text pbDrawTextPositions(overlay, textpos) @@ -1097,11 +1097,12 @@ class PokemonSummary_Scene # Reposition the cursor @sprites["markingsel"].x = 284 + 58 * (index % 3) @sprites["markingsel"].y = 144 + 50 * (index / 3) - if index == 6 # OK + case index + when 6 # OK @sprites["markingsel"].x = 284 @sprites["markingsel"].y = 244 @sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height / 2 - elsif index == 7 # Cancel + when 7 # Cancel @sprites["markingsel"].x = 284 @sprites["markingsel"].y = 294 @sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height / 2 @@ -1116,10 +1117,11 @@ class PokemonSummary_Scene break elsif Input.trigger?(Input::USE) pbPlayDecisionSE - if index == 6 # OK + case index + when 6 # OK ret = markings break - elsif index == 7 # Cancel + when 7 # Cancel break else markings[index] = ((markings[index] || 0) + 1) % mark_variants @@ -1197,7 +1199,7 @@ class PokemonSummary_Scene pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, $bag) - item = screen.pbChooseItemScreen(Proc.new { |itm| GameData::Item.get(itm).can_hold? }) + item = screen.pbChooseItemScreen(proc { |itm| GameData::Item.get(itm).can_hold? }) } if item dorefresh = pbGiveItemToPokemon(item, @pokemon, self, @partyindex) diff --git a/Data/Scripts/016_UI/008_UI_Pokegear.rb b/Data/Scripts/016_UI/008_UI_Pokegear.rb index 7fb4907bf..65493bf64 100644 --- a/Data/Scripts/016_UI/008_UI_Pokegear.rb +++ b/Data/Scripts/016_UI/008_UI_Pokegear.rb @@ -42,7 +42,7 @@ class PokegearButton < SpriteWrapper rect.y = @button.height / 2 if @selected self.bitmap.blt(0, 0, @button.bitmap, rect) textpos = [ - [@name, self.bitmap.width / 2, 4, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)], + [@name, self.bitmap.width / 2, 4, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)] ] pbDrawTextPositions(self.bitmap, textpos) imagepos = [ diff --git a/Data/Scripts/016_UI/015_UI_Options.rb b/Data/Scripts/016_UI/015_UI_Options.rb index 4f8e35ac9..447379a47 100644 --- a/Data/Scripts/016_UI/015_UI_Options.rb +++ b/Data/Scripts/016_UI/015_UI_Options.rb @@ -408,13 +408,13 @@ class PokemonOption_Scene @PokemonOptions[i].set(@sprites["option"][i]) end if $PokemonSystem.textskin != oldTextSkin - @sprites["textbox"].setSkin(MessageConfig.pbGetSpeechFrame()) + @sprites["textbox"].setSkin(MessageConfig.pbGetSpeechFrame) @sprites["textbox"].text = _INTL("Speech frame {1}.", 1 + $PokemonSystem.textskin) oldTextSkin = $PokemonSystem.textskin end if $PokemonSystem.frame != oldSystemSkin - @sprites["title"].setSkin(MessageConfig.pbGetSystemFrame()) - @sprites["option"].setSkin(MessageConfig.pbGetSystemFrame()) + @sprites["title"].setSkin(MessageConfig.pbGetSystemFrame) + @sprites["option"].setSkin(MessageConfig.pbGetSystemFrame) oldSystemSkin = $PokemonSystem.frame end end diff --git a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb index 519f99711..178a31586 100644 --- a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb +++ b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb @@ -71,7 +71,7 @@ class ReadyMenuButton < SpriteWrapper self.bitmap.blt(0, 0, @button.bitmap, rect) textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124 textpos = [ - [@command[1], textx, 16, 2, Color.new(248, 248, 248), Color.new(40, 40, 40), 1], + [@command[1], textx, 16, 2, Color.new(248, 248, 248), Color.new(40, 40, 40), 1] ] if !@command[2] if !GameData::Item.get(@command[0]).is_important? @@ -206,11 +206,12 @@ class PokemonReadyMenu_Scene oldindex = @index[@index[2]] @index[@index[2]] = @sprites["cmdwindow"].index if @index[@index[2]] != oldindex - if @index[2] == 0 + case @index[2] + when 0 for i in 0...@commands[0].length @sprites["movebutton#{i}"].selected = @index[@index[2]] end - elsif @index[2] == 1 + when 1 for i in 0...@commands[1].length @sprites["itembutton#{i}"].selected = @index[@index[2]] end diff --git a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb index 5fedffdbc..690bf3076 100644 --- a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb +++ b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb @@ -617,12 +617,11 @@ class PokemonStorageScene if command != 2 pbSetArrow(@sprites["arrow"], @selection) pbUpdateOverlay(@selection) - pbSetMosaic(@selection) else pbPartySetArrow(@sprites["arrow"], @selection) pbUpdateOverlay(@selection, @storage.party) - pbSetMosaic(@selection) end + pbSetMosaic(@selection) pbSEPlay("PC access") pbFadeInAndShow(@sprites) end @@ -714,22 +713,24 @@ class PokemonStorageScene def pbChangeSelection(key, selection) case key when Input::UP - if selection == -1 # Box name + case selection + when -1 # Box name selection = -2 - elsif selection == -2 # Party + when -2 # Party selection = PokemonBox::BOX_SIZE - 1 - PokemonBox::BOX_WIDTH * 2 / 3 # 25 - elsif selection == -3 # Close Box + when -3 # Close Box selection = PokemonBox::BOX_SIZE - PokemonBox::BOX_WIDTH / 3 # 28 else selection -= PokemonBox::BOX_WIDTH selection = -1 if selection < 0 end when Input::DOWN - if selection == -1 # Box name + case selection + when -1 # Box name selection = PokemonBox::BOX_WIDTH / 3 # 2 - elsif selection == -2 # Party + when -2 # Party selection = -1 - elsif selection == -3 # Close Box + when -3 # Close Box selection = -1 else selection += PokemonBox::BOX_WIDTH @@ -830,16 +831,17 @@ class PokemonStorageScene pbPlayCursorSE selection = pbChangeSelection(key, selection) pbSetArrow(@sprites["arrow"], selection) - if selection == -4 + case selection + when -4 nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes pbSwitchBoxToLeft(nextbox) @storage.currentBox = nextbox - elsif selection == -5 + when -5 nextbox = (@storage.currentBox + 1) % @storage.maxBoxes pbSwitchBoxToRight(nextbox) @storage.currentBox = nextbox end - selection = -1 if selection == -4 || selection == -5 + selection = -1 if [-4, -5].include?(selection) pbUpdateOverlay(selection) pbSetMosaic(selection) end @@ -932,9 +934,10 @@ class PokemonStorageScene if key >= 0 pbPlayCursorSE newselection = pbPartyChangeSelection(key, selection) - if newselection == -1 + case newselection + when -1 return -1 if !depositing - elsif newselection == -2 + when -2 selection = lastsel else selection = newselection @@ -1217,7 +1220,7 @@ class PokemonStorageScene pbFadeOutIn { scene = PokemonBag_Scene.new screen = PokemonBagScreen.new(scene, bag) - ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? }) + ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? }) } return ret end @@ -1352,10 +1355,11 @@ class PokemonStorageScene break elsif Input.trigger?(Input::USE) pbPlayDecisionSE - if index == 6 # OK + case index + when 6 # OK pokemon.markings = markings break - elsif index == 7 # Cancel + when 7 # Cancel break else markings[index] = ((markings[index] || 0) + 1) % mark_variants @@ -1399,7 +1403,7 @@ class PokemonStorageScene buttonshadow = Color.new(80, 80, 80) pbDrawTextPositions(overlay, [ [_INTL("Party: {1}", (@storage.party.length rescue 0)), 270, 326, 2, buttonbase, buttonshadow, 1], - [_INTL("Exit"), 446, 326, 2, buttonbase, buttonshadow, 1], + [_INTL("Exit"), 446, 326, 2, buttonbase, buttonshadow, 1] ]) pokemon = nil if @screen.pbHeldPokemon @@ -1478,7 +1482,8 @@ class PokemonStorageScreen def pbStartScreen(command) $game_temp.in_storage = true @heldpkmn = nil - if command == 0 # Organise + case command + when 0 # Organise @scene.pbStartBox(self, command) loop do selected = @scene.pbSelectBox(@storage.party) @@ -1559,7 +1564,7 @@ class PokemonStorageScreen end end @scene.pbCloseBox - elsif command == 1 # Withdraw + when 1 # Withdraw @scene.pbStartBox(self, command) loop do selected = @scene.pbSelectBox(@storage.party) @@ -1599,7 +1604,7 @@ class PokemonStorageScreen end end @scene.pbCloseBox - elsif command == 2 # Deposit + when 2 # Deposit @scene.pbStartBox(self, command) loop do selected = @scene.pbSelectParty(@storage.party) @@ -1631,7 +1636,7 @@ class PokemonStorageScreen end end @scene.pbCloseBox - elsif command == 3 + when 3 @scene.pbStartBox(self, command) @scene.pbCloseBox end @@ -1921,7 +1926,7 @@ class PokemonStorageScreen _INTL("Jump"), _INTL("Wallpaper"), _INTL("Name"), - _INTL("Cancel"), + _INTL("Cancel") ] command = pbShowCommands( _INTL("What do you want to do?"), commands) diff --git a/Data/Scripts/016_UI/019_UI_PC.rb b/Data/Scripts/016_UI/019_UI_PC.rb index 797f7f85f..a2cf0e780 100644 --- a/Data/Scripts/016_UI/019_UI_PC.rb +++ b/Data/Scripts/016_UI/019_UI_PC.rb @@ -47,12 +47,13 @@ class StorageSystemPC _INTL("Return to the previous menu.")], -1, command ) if command >= 0 && command < 3 - if command == 1 # Withdraw + case command + when 1 # Withdraw if $PokemonStorage.party_full? pbMessage(_INTL("Your party is full!")) next end - elsif command == 2 # Deposit + when 2 # Deposit count = 0 for p in $PokemonStorage.party count += 1 if p && !p.egg? && p.hp > 0 diff --git a/Data/Scripts/016_UI/022_UI_PurifyChamber.rb b/Data/Scripts/016_UI/022_UI_PurifyChamber.rb index 08ac8c962..50bba40b1 100644 --- a/Data/Scripts/016_UI/022_UI_PurifyChamber.rb +++ b/Data/Scripts/016_UI/022_UI_PurifyChamber.rb @@ -291,7 +291,7 @@ module PurifyChamberHelper return chamber.getShadow(set) elsif position > 0 position -= 1 - if position % 2 == 0 + if position.even? return chamber[set, position / 2] else # In between two indices return nil @@ -305,7 +305,7 @@ module PurifyChamberHelper return chamber.getShadow(chamber.currentSet) elsif position > 0 position -= 1 - if position % 2 == 0 + if position.even? return chamber[chamber.currentSet, position / 2] else # In between two indices return nil @@ -318,7 +318,7 @@ module PurifyChamberHelper if position > 0 position -= 1 oldpos = position / 2 - if position % 2 == 0 + if position.even? return position + 1 else return ((oldpos + 1) * 2) + 1 @@ -332,7 +332,7 @@ module PurifyChamberHelper chamber.setShadow(chamber.currentSet, value) elsif position > 0 position -= 1 - if position % 2 == 0 + if position.even? chamber.insertAt(chamber.currentSet, position / 2, value) else # In between two indices chamber.insertAfter(chamber.currentSet, position / 2, value) @@ -612,11 +612,12 @@ class PurifyChamberScreen _INTL("What do you want to do?"), [_INTL("EDIT"), _INTL("SWITCH"), _INTL("CANCEL")] ) - if cmd == 0 # edit + case cmd + when 0 # edit if !pbOpenSetDetail break end - elsif cmd == 1 # switch + when 1 # switch chamber.currentSet = set newSet = @scene.pbSwitch(set) chamber.switch(set, newSet) @@ -900,19 +901,20 @@ class PurifyChamberSetView < SpriteWrapper pos /= 2 end seg = pos * 8 / points - if seg == 7 || seg == 0 + case seg + when 7, 0 pos -= 1 if button == Input::LEFT pos += 1 if button == Input::RIGHT pos = nil if button == Input::DOWN - elsif seg == 1 || seg == 2 + when 1, 2 pos -= 1 if button == Input::UP pos += 1 if button == Input::DOWN pos = nil if button == Input::LEFT - elsif seg == 3 || seg == 4 + when 3, 4 pos -= 1 if button == Input::RIGHT pos += 1 if button == Input::LEFT pos = nil if button == Input::UP - elsif seg == 5 || seg == 6 + when 5, 6 pos -= 1 if button == Input::DOWN pos += 1 if button == Input::UP pos = nil if button == Input::RIGHT @@ -986,7 +988,7 @@ class PurifyChamberSetView < SpriteWrapper setList = @chamber.setList(@set) refreshFlows for i in 0...PurifyChamber::SETSIZE * 2 - pkmn = (i % 2 == 1 || i >= points) ? nil : setList[i / 2] + pkmn = (i.odd? || i >= points) ? nil : setList[i / 2] angle = 360 - (i * 360 / points) angle += 90 # start at 12 not 3 o'clock if pkmn && @chamber[@set].facing == i / 2 diff --git a/Data/Scripts/016_UI/023_UI_MysteryGift.rb b/Data/Scripts/016_UI/023_UI_MysteryGift.rb index 028fe95c8..0be008008 100644 --- a/Data/Scripts/016_UI/023_UI_MysteryGift.rb +++ b/Data/Scripts/016_UI/023_UI_MysteryGift.rb @@ -182,18 +182,19 @@ def pbManageMysteryGifts _INTL("Delete"), _INTL("Cancel")] cmd = pbMessage("\\ts[]" + commands[command], cmds, -1, nil, cmd) - if cmd == -1 || cmd == cmds.length - 1 + case cmd + when -1, cmds.length - 1 break - elsif cmd == 0 # Toggle on/offline + when 0 # Toggle on/offline if online.include?(gift[0]) online.delete(gift[0]) else online.push(gift[0]) end - elsif cmd == 1 # Edit + when 1 # Edit newgift = pbEditMysteryGift(gift[1], gift[2], gift[0], gift[3]) master[command] = newgift if newgift - elsif cmd == 2 # Receive + when 2 # Receive if !$player pbMessage(_INTL("There is no save file loaded. Cannot receive any gifts.")) next @@ -207,7 +208,7 @@ def pbManageMysteryGifts end $player.mystery_gifts.push(gift) if !replaced pbReceiveMysteryGift(gift[0]) - elsif cmd == 3 # Delete + when 3 # Delete master.delete_at(command) if pbConfirmMessage(_INTL("Are you sure you want to delete this gift?")) break end @@ -381,13 +382,8 @@ def pbReceiveMysteryGift(id) gift[2].timeReceived = time.getgm.to_i gift[2].obtain_method = 4 # Fateful encounter gift[2].record_first_moves - if $game_map - gift[2].obtain_map = $game_map.map_id - gift[2].obtain_level = gift[2].level - else - gift[2].obtain_map = 0 - gift[2].obtain_level = gift[2].level - end + gift[2].obtain_level = gift[2].level + gift[2].obtain_map = $game_map&.map_id || 0 if pbAddPokemonSilent(gift[2]) pbMessage(_INTL("\\me[Pkmn get]{1} received {2}!", $player.name, gift[2].name)) $player.mystery_gifts[index] = [id] diff --git a/Data/Scripts/016_UI/024_UI_TextEntry.rb b/Data/Scripts/016_UI/024_UI_TextEntry.rb index 79e60e54a..314f55cb3 100644 --- a/Data/Scripts/016_UI/024_UI_TextEntry.rb +++ b/Data/Scripts/016_UI/024_UI_TextEntry.rb @@ -72,7 +72,7 @@ end class PokemonEntryScene @@Characters = [ [("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").scan(/./), "[*]"], - [("0123456789 !@\#$%^&*() ~`-_+={}[] :;'\"<>,.?/ ").scan(/./), "[A]"], + [("0123456789 !@\#$%^&*() ~`-_+={}[] :;'\"<>,.?/ ").scan(/./), "[A]"] ] USEKEYBOARD = true @@ -212,28 +212,28 @@ class PokemonEntryScene if index == -3 # Confirm text ret = @sprites["entry"].text if ret.length < @minlength || ret.length > @maxlength - pbPlayBuzzerSE() + pbPlayBuzzerSE else - pbPlayDecisionSE() + pbPlayDecisionSE break end elsif index == -1 # Insert a space if @sprites["entry"].insert(" ") - pbPlayDecisionSE() + pbPlayDecisionSE else - pbPlayBuzzerSE() + pbPlayBuzzerSE end elsif index == -2 # Change character set - pbPlayDecisionSE() + pbPlayDecisionSE @symtype += 1 @symtype = 0 if @symtype >= @@Characters.length @sprites["entry2"].setCharset(@@Characters[@symtype][0]) @sprites["entry2"].setOtherCharset(@@Characters[@symtype][1]) else # Insert given character if @sprites["entry"].insert(@sprites["entry2"].character) - pbPlayDecisionSE() + pbPlayDecisionSE else - pbPlayBuzzerSE() + pbPlayBuzzerSE end end next diff --git a/Data/Scripts/017_Minigames/001_Minigame_Duel.rb b/Data/Scripts/017_Minigames/001_Minigame_Duel.rb index d2128ca9d..ee9a64ca6 100644 --- a/Data/Scripts/017_Minigames/001_Minigame_Duel.rb +++ b/Data/Scripts/017_Minigames/001_Minigame_Duel.rb @@ -174,7 +174,7 @@ class PokemonDuel PBMoveRoute::Forward ]) pbMessage(_INTL("Your attack was evaded!")) - elsif (action == 0 || action == 1 || action == 2) && command == 3 + elsif [0, 1, 2].include?(action) && command == 3 pbMoveRoute($game_player, [ PBMoveRoute::ChangeSpeed, 4, PBMoveRoute::ScriptAsync, "jumpForward" @@ -282,7 +282,7 @@ class PokemonDuel PBMoveRoute::Backward ]) pbMessage(_INTL("You evade the opponent's attack!")) - elsif action == 3 && (command == 0 || command == 1 || command == 2) + elsif action == 3 && [0, 1, 2].include?(command) pbMoveRoute(event, [ PBMoveRoute::ChangeSpeed, 4, PBMoveRoute::ScriptAsync, "jumpForward" diff --git a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb index 552f2766a..a730ae4e6 100644 --- a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb +++ b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb @@ -611,7 +611,7 @@ class TriadScreen def maxCards numcards = @width * @height - if numcards % 2 == 1 + if numcards.odd? numcards = numcards / 2 + 1 else numcards = numcards / 2 @@ -833,7 +833,7 @@ class TriadScreen end end # Sort by number of flips - scores.sort! { |a, b| (b[3] == a[3]) ? rand(3) - 1 : b[3] <=> a[3] } + scores.sort! { |a, b| (b[3] == a[3]) ? rand(-1..1) : b[3] <=> a[3] } scores = scores[0, opponentCards.length] # Get the best results if scores.length == 0 @scene.pbDisplay(_INTL("{1} can't move somehow...", @opponentName)) diff --git a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb index 49b4de928..14cee5655 100644 --- a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb +++ b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb @@ -193,7 +193,7 @@ class SlotMachineScene @sprites["light2"].src_rect.set(0, 26 * ((frame / timePerFrame) % 4), 96, 26) for i in 1..5 if wonRow[i - 1] - @sprites["row#{i}"].visible = ((frame / timePerFrame) % 2) == 0 + @sprites["row#{i}"].visible = (frame / timePerFrame).even? else @sprites["row#{i}"].visible = false end diff --git a/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb b/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb index 4494a503c..06e1248e8 100644 --- a/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb +++ b/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb @@ -44,7 +44,7 @@ class VoltorbFlip voltorbs += 1 # Sets the value randomly to a 2 or 3 if the total is less than the max elsif total < @levelRanges[@level - 1][1] - squareValues[i] = rand(2) + 2 + squareValues[i] = rand(2..3) total *= squareValues[i] end if total > (@levelRanges[@level - 1][1]) @@ -387,11 +387,11 @@ class VoltorbFlip if @level < 8 @level += 1 pbMessage(_INTL("\\se[Voltorb Flip level up]Advanced to Game Lv. {1}!", @level.to_s)) -# if @firstRound + if @firstRound # pbMessage(_INTL("Congratulations!")) # pbMessage(_INTL("You can receive even more Coins in the next game!")) @firstRound = false -# end + end end pbDisposeSpriteHash(@sprites) pbNewGame diff --git a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb index 3bc6fcf17..d22fc99ff 100644 --- a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb +++ b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb @@ -78,8 +78,8 @@ class MiningGameCursor < BitmapSprite attr_accessor :hit attr_accessor :counter - ToolPositions = [[1, 0], [1, 1], [1, 1], [0, 0], [0, 0], - [0, 2], [0, 2], [0, 0], [0, 0], [0, 2], [0, 2]] # Graphic, position + TOOL_POSITIONS = [[1, 0], [1, 1], [1, 1], [0, 0], [0, 0], + [0, 2], [0, 2], [0, 0], [0, 0], [0, 2], [0, 2]] # Graphic, position def initialize(position = 0, mode = 0) # mode: 0=pick, 1=hammer @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @@ -106,22 +106,23 @@ class MiningGameCursor < BitmapSprite def update self.bitmap.clear - x = 32 * (@position % MiningGameScene::BOARDWIDTH) - y = 32 * (@position / MiningGameScene::BOARDWIDTH) + x = 32 * (@position % MiningGameScene::BOARD_WIDTH) + y = 32 * (@position / MiningGameScene::BOARD_WIDTH) if @counter > 0 @counter -= 1 toolx = x tooly = y i = 10 - (@counter / 2).floor - if ToolPositions[i][1] == 1 + case TOOL_POSITIONS[i][1] + when 1 toolx -= 8 tooly += 8 - elsif ToolPositions[i][1] == 2 + when 2 toolx += 6 end self.bitmap.blt(toolx, tooly, @toolbitmap.bitmap, - Rect.new(96 * ToolPositions[i][0], 96 * @mode, 96, 96)) - if i < 5 && i % 2 == 0 + Rect.new(96 * TOOL_POSITIONS[i][0], 96 * @mode, 96, 96)) + if i < 5 && i.even? if @hit == 2 self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * 2, 0, 160, 160)) else @@ -140,8 +141,8 @@ end class MiningGameScene - BOARDWIDTH = 13 - BOARDHEIGHT = 10 + BOARD_WIDTH = 13 + BOARD_HEIGHT = 10 ITEMS = [ # Item, probability, graphic x, graphic y, width, height, pattern [:DOMEFOSSIL, 20, 0, 3, 5, 4, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0]], [:HELIXFOSSIL, 5, 5, 3, 4, 4, [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]], @@ -238,9 +239,9 @@ class MiningGameScene @iron = [] pbDistributeItems pbDistributeIron - for i in 0...BOARDHEIGHT - for j in 0...BOARDWIDTH - @sprites["tile#{j + i * BOARDWIDTH}"] = MiningGameTile.new(32 * j, 64 + 32 * i) + for i in 0...BOARD_HEIGHT + for j in 0...BOARD_WIDTH + @sprites["tile#{j + i * BOARD_WIDTH}"] = MiningGameTile.new(32 * j, 64 + 32 * i) end end @sprites["crack"] = MiningGameCounter.new(0, 4) @@ -258,7 +259,7 @@ class MiningGameScene for i in ITEMS ptotal += i[1] end - numitems = 2 + rand(3) + numitems = rand(2..4) tries = 0 while numitems > 0 rnd = rand(ptotal) @@ -268,8 +269,8 @@ class MiningGameScene if rnd < 0 if pbNoDuplicateItems(ITEMS[i][0]) while !added - provx = rand(BOARDWIDTH - ITEMS[i][4] + 1) - provy = rand(BOARDHEIGHT - ITEMS[i][5] + 1) + provx = rand(BOARD_WIDTH - ITEMS[i][4] + 1) + provy = rand(BOARD_HEIGHT - ITEMS[i][5] + 1) if pbCheckOverlaps(false, provx, provy, ITEMS[i][4], ITEMS[i][5], ITEMS[i][6]) @items.push([i, provx, provy]) numitems -= 1 @@ -298,12 +299,12 @@ class MiningGameScene def pbDistributeIron # Set iron to be buried (index in IRON, x coord, y coord) - numitems = 4 + rand(3) + numitems = rand(4..6) tries = 0 while numitems > 0 rnd = rand(IRON.length) - provx = rand(BOARDWIDTH - IRON[rnd][2] + 1) - provy = rand(BOARDHEIGHT - IRON[rnd][3] + 1) + provx = rand(BOARD_WIDTH - IRON[rnd][2] + 1) + provy = rand(BOARD_HEIGHT - IRON[rnd][3] + 1) if pbCheckOverlaps(true, provx, provy, IRON[rnd][2], IRON[rnd][3], IRON[rnd][4]) @iron.push([rnd, provx, provy]) numitems -= 1 @@ -398,12 +399,12 @@ class MiningGameScene hittype = 2 else for i in 0..2 - ytile = i - 1 + position / BOARDWIDTH - next if ytile < 0 || ytile >= BOARDHEIGHT + ytile = i - 1 + position / BOARD_WIDTH + next if ytile < 0 || ytile >= BOARD_HEIGHT for j in 0..2 - xtile = j - 1 + position % BOARDWIDTH - next if xtile < 0 || xtile >= BOARDWIDTH - @sprites["tile#{xtile + ytile * BOARDWIDTH}"].layer -= pattern[j + i * 3] + xtile = j - 1 + position % BOARD_WIDTH + next if xtile < 0 || xtile >= BOARD_WIDTH + @sprites["tile#{xtile + ytile * BOARD_WIDTH}"].layer -= pattern[j + i * 3] end end if @sprites["cursor"].mode == 1 # Hammer @@ -427,8 +428,8 @@ class MiningGameScene end def pbIsItemThere?(position) - posx = position % BOARDWIDTH - posy = position / BOARDWIDTH + posx = position % BOARD_WIDTH + posy = position / BOARD_WIDTH for i in @items index = i[0] width = ITEMS[index][4] @@ -444,8 +445,8 @@ class MiningGameScene end def pbIsIronThere?(position) - posx = position % BOARDWIDTH - posy = position / BOARDWIDTH + posx = position % BOARD_WIDTH + posy = position / BOARD_WIDTH for i in @iron index = i[0] width = IRON[index][2] @@ -471,7 +472,7 @@ class MiningGameScene pattern = ITEMS[index][6] for j in 0...height for k in 0...width - layer = @sprites["tile#{@items[i][1] + k + (@items[i][2] + j) * BOARDWIDTH}"].layer + layer = @sprites["tile#{@items[i][1] + k + (@items[i][2] + j) * BOARD_WIDTH}"].layer revealed = false if layer > 0 && pattern[k + j * width] > 0 break if !revealed end @@ -550,22 +551,22 @@ class MiningGameScene end # Input if Input.trigger?(Input::UP) || Input.repeat?(Input::UP) - if @sprites["cursor"].position >= BOARDWIDTH + if @sprites["cursor"].position >= BOARD_WIDTH pbSEPlay("Mining cursor") - @sprites["cursor"].position -= BOARDWIDTH + @sprites["cursor"].position -= BOARD_WIDTH end elsif Input.trigger?(Input::DOWN) || Input.repeat?(Input::DOWN) - if @sprites["cursor"].position < (BOARDWIDTH * (BOARDHEIGHT - 1)) + if @sprites["cursor"].position < (BOARD_WIDTH * (BOARD_HEIGHT - 1)) pbSEPlay("Mining cursor") - @sprites["cursor"].position += BOARDWIDTH + @sprites["cursor"].position += BOARD_WIDTH end elsif Input.trigger?(Input::LEFT) || Input.repeat?(Input::LEFT) - if @sprites["cursor"].position % BOARDWIDTH > 0 + if @sprites["cursor"].position % BOARD_WIDTH > 0 pbSEPlay("Mining cursor") @sprites["cursor"].position -= 1 end elsif Input.trigger?(Input::RIGHT) || Input.repeat?(Input::RIGHT) - if @sprites["cursor"].position % BOARDWIDTH < (BOARDWIDTH - 1) + if @sprites["cursor"].position % BOARD_WIDTH < (BOARD_WIDTH - 1) pbSEPlay("Mining cursor") @sprites["cursor"].position += 1 end diff --git a/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb b/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb index 89f784206..7e83a58fc 100644 --- a/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb +++ b/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb @@ -190,13 +190,14 @@ class TilePuzzleScene ret.push(i) @angles.push(0) end - if @game == 6 + case @game + when 6 @tiles = ret 5.times do pbShiftLine([2, 4, 6, 8][rand(4)], rand(@boardwidth * @boardheight), false) end return @tiles - elsif @game == 7 + when 7 @tiles = ret 5.times do pbRotateTile(rand(@boardwidth * @boardheight), false) @@ -213,11 +214,11 @@ class TilePuzzleScene ret[j] != @boardwidth * @boardheight - 1 end end - if @boardwidth % 2 == 1 - ret = pbShuffleTiles if num % 2 == 1 + if @boardwidth.odd? + ret = pbShuffleTiles if num.odd? else - ret = pbShuffleTiles if !((num % 2 == 0 && (@boardheight - (blank / @boardwidth)) % 2 == 1) || - (num % 2 == 1 && (@boardheight - (blank / @boardwidth)) % 2 == 0)) + ret = pbShuffleTiles if !((num.even? && (@boardheight - (blank / @boardwidth)).odd?) || + (num.odd? && (@boardheight - (blank / @boardwidth)).even?)) end end if @game == 1 || @game == 2 @@ -241,16 +242,15 @@ class TilePuzzleScene for i in 0...@boardwidth * @boardheight return i if @tiles[i] == @boardwidth * @boardheight - 1 end - return 0 - else - return 0 end + return 0 end def pbMoveCursor(pos, dir) - if dir == 2 + case dir + when 2 pos += @boardwidth - elsif dir == 4 + when 4 if pos >= @boardwidth * @boardheight if pos % @boardwidth == (@boardwidth / 2).ceil pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth + @boardwidth - 1 @@ -264,7 +264,7 @@ class TilePuzzleScene pos -= 1 end end - elsif dir == 6 + when 6 if pos >= @boardwidth * @boardheight if pos % @boardwidth == (@boardwidth / 2).ceil - 1 pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth @@ -278,7 +278,7 @@ class TilePuzzleScene pos += 1 end end - elsif dir == 8 + when 8 pos -= @boardwidth end return pos @@ -286,21 +286,22 @@ class TilePuzzleScene def pbCanMoveInDir?(pos, dir, swapping) return true if @game == 6 && swapping - if dir == 2 + case dir + when 2 return false if (pos / @boardwidth) % @boardheight >= @boardheight - 1 - elsif dir == 4 + when 4 if @game == 1 || @game == 2 return false if pos >= @boardwidth * @boardheight && pos % @boardwidth == 0 else return false if pos % @boardwidth == 0 end - elsif dir == 6 + when 6 if @game == 1 || @game == 2 return false if pos >= @boardwidth * @boardheight && pos % @boardwidth >= @boardwidth - 1 else return false if pos % @boardwidth >= @boardwidth - 1 end - elsif dir == 8 + when 8 return false if (pos / @boardwidth) % @boardheight == 0 end return true @@ -376,8 +377,8 @@ class TilePuzzleScene movetile = pbMoveCursor(cursor, dir) @sprites["cursor"].visible = false @sprites["tile#{@tiles[cursor]}"].z = 1 - if dir == 2 || dir == 8 # Swap vertically - swapTime = Graphics.frame_rate * 3 / 10 + swapTime = Graphics.frame_rate * 3 / 10 + if [2, 8].include?(dir) # Swap vertically distancePerFrame = (@tileheight.to_f / swapTime).ceil dist = (dir / 4).floor - 1 swapTime.times do @@ -388,7 +389,6 @@ class TilePuzzleScene Input.update end else # Swap horizontally - swapTime = Graphics.frame_rate * 3 / 10 distancePerFrame = (@tilewidth.to_f / swapTime).ceil dist = dir - 5 swapTime.times do @@ -411,7 +411,7 @@ class TilePuzzleScene # Get tiles involved tiles = [] dist = 0 - if dir == 2 || dir == 8 + if [2, 8].include?(dir) dist = (dir / 4).floor - 1 while (dist > 0 && cursor < (@boardwidth - 1) * @boardheight) || (dist < 0 && cursor >= @boardwidth) @@ -441,7 +441,7 @@ class TilePuzzleScene Input.update end shiftTime = Graphics.frame_rate * 3 / 10 - if dir == 2 || dir == 8 + if [2, 8].include?(dir) distancePerFrame = (@tileheight.to_f / shiftTime).ceil shiftTime.times do for i in tiles 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 5a8705b37..967a3a4ed 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 @@ -197,12 +197,8 @@ class BattleChallengeData end def setParty(value) - if @inProgress - $player.party = value - @party = value - else - @party = value - end + $player.party = value if @inProgress + @party = value end def pbStart(t, numRounds) diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb index 60e351a1e..1dafbeab8 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb @@ -87,7 +87,7 @@ def pbOrganizedBattleEx(opponent, challengedata, endspeech, endspeechwin) end # Save the record of the battle $game_temp.last_battle_record = nil - if decision == 1 || decision == 2 || decision == 5 # if win, loss or draw + if [1, 2, 5].include?(decision) # if win, loss or draw $game_temp.last_battle_record = battle.pbDumpRecord end case decision 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 39b632c4e..c9d962dd9 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 @@ -104,9 +104,10 @@ class BattleSwapScene def pbUpdateChoices(choices) commands = pbGetCommands(@rentals, choices) @choices = choices - if choices.length == 0 + case choices.length + when 0 @sprites["help"].text = _INTL("Choose the first Pokémon.") - elsif choices.length == 1 + when 1 @sprites["help"].text = _INTL("Choose the second Pokémon.") else @sprites["help"].text = _INTL("Choose the third Pokémon.") @@ -162,9 +163,10 @@ class BattleSwapScreen end commands.push(_INTL("OTHERS")) command = @scene.pbShowCommands(commands) - if command == 0 + case command + when 0 @scene.pbSummary(rentals, index) - elsif command == 1 + when 1 if chosen.include?(index) chosen.delete(index) @scene.pbUpdateChoices(chosen.clone) @@ -194,9 +196,10 @@ class BattleSwapScreen if pkmn >= 0 commands = [_INTL("SUMMARY"), _INTL("SWAP"), _INTL("RECHOOSE")] command = @scene.pbShowCommands(commands) - if command == 0 + case command + when 0 @scene.pbSummary(currentPokemon, pkmn) - elsif command == 1 + when 1 @scene.pbSwapChosen(pkmn) yourPkmn = pkmn loop do diff --git a/Data/Scripts/018_Alternate battle modes/002_BugContest.rb b/Data/Scripts/018_Alternate battle modes/002_BugContest.rb index 5393a82d8..c6a931083 100644 --- a/Data/Scripts/018_Alternate battle modes/002_BugContest.rb +++ b/Data/Scripts/018_Alternate battle modes/002_BugContest.rb @@ -4,7 +4,7 @@ class BugContestState attr_accessor :lastPokemon attr_reader :timer - ContestantNames = [ + CONTESTANT_NAMES = [ _INTL("Bug Catcher Ed"), _INTL("Bug Catcher Benny"), _INTL("Bug Catcher Josh"), @@ -14,7 +14,7 @@ class BugContestState _INTL("Picnicker Cindy"), _INTL("Youngster Samuel") ] - TimerSeconds = Settings::BUG_CONTEST_TIME + TIME_ALLOWED = Settings::BUG_CONTEST_TIME def initialize clear @@ -29,8 +29,8 @@ class BugContestState def expired? return false if !undecided? - return false if TimerSeconds <= 0 - curtime = @timer + TimerSeconds * Graphics.frame_rate + return false if TIME_ALLOWED <= 0 + curtime = @timer + TIME_ALLOWED * Graphics.frame_rate curtime = [curtime - Graphics.frame_count, 0].max return (curtime <= 0) end @@ -65,8 +65,8 @@ class BugContestState @chosenPokemon = chosenpoke end -# Reception map is handled separately from contest map since the reception map -# can be outdoors, with its own grassy patches. + # Reception map is handled separately from contest map since the reception map + # can be outdoors, with its own grassy patches. def pbSetReception(*arg) @reception = [] for i in arg @@ -96,16 +96,6 @@ class BugContestState if @lastPokemon judgearray.push([-1, @lastPokemon.species, pbBugContestScore(@lastPokemon)]) end - @contestants = [] - [5, ContestantNames.length].min.times do - loop do - value = rand(ContestantNames.length) - if !@contestants.any? { |i| i == value } - @contestants.push(value) - break - end - end - end enctype = :BugContest if !$PokemonEncounters.map_has_encounter_type?(@contestMap, enctype) enctype = :Land @@ -134,7 +124,7 @@ class BugContestState if cont < 0 $game_variables[1] = $player.name else - $game_variables[1] = ContestantNames[cont] + $game_variables[1] = CONTESTANT_NAMES[cont] end $game_variables[2] = GameData::Species.get(@places[place][1]).name $game_variables[3] = @places[place][2] @@ -177,13 +167,12 @@ class BugContestState @otherparty.push($player.party[i]) if i != @chosenPokemon end @contestants = [] - [5, ContestantNames.length].min.times do + [5, CONTESTANT_NAMES.length].min.times do loop do - value = rand(ContestantNames.length) - if !@contestants.any? { |i| i == value } - @contestants.push(value) - break - end + value = rand(CONTESTANT_NAMES.length) + next if @contestants.include?(value) + @contestants.push(value) + break end end $player.party = [chosenpkmn] @@ -303,10 +292,10 @@ Events.onMapChange += proc { |_sender, _e| Events.onMapSceneChange += proc { |_sender, e| scene = e[0] - if pbInBugContest? && pbBugContestState.decision == 0 && BugContestState::TimerSeconds > 0 + if pbInBugContest? && pbBugContestState.decision == 0 && BugContestState::TIME_ALLOWED > 0 scene.spriteset.addUserSprite(TimerDisplay.new( pbBugContestState.timer, - BugContestState::TimerSeconds * Graphics.frame_rate)) + BugContestState::TIME_ALLOWED * Graphics.frame_rate)) end } @@ -373,7 +362,7 @@ def pbBugContestBattle(species, level) pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) { decision = battle.pbStartBattle pbAfterBattle(decision, true) - if decision == 2 || decision == 5 # Lost or drew + if [2, 5].include?(decision) # Lost or drew $game_system.bgm_unpause $game_system.bgs_unpause pbBugContestStartOver diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb index 4de6fe621..f153c7644 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb @@ -57,9 +57,10 @@ end def withRestr(_rule, minbs, maxbs, legendary) ret = PokemonChallengeRules.new.addPokemonRule(BaseStatRestriction.new(minbs, maxbs)) - if legendary == 0 + case legendary + when 0 ret.addPokemonRule(NonlegendaryRestriction.new) - elsif legendary == 1 + when 1 ret.addPokemonRule(InverseRestriction.new(NonlegendaryRestriction.new)) end return ret @@ -298,14 +299,16 @@ def pbWriteCup(id, rules) else cmd = pbMessage(_INTL("Generate Pokémon teams for this challenge?"), [_INTL("YES"), _INTL("NO")], 2) - if cmd == 0 + case cmd + when 0 cmd = 2 - elsif cmd == 1 + when 1 cmd = 0 end end return if cmd == 0 # No - if cmd == 1 # Yes, use existing + case cmd + when 1 # Yes, use existing cmd = pbMessage(_INTL("Choose a challenge."), list, -1) if cmd >= 0 pbMessage(_INTL("This challenge will use the Pokémon list from {1}.", list[cmd])) @@ -321,7 +324,7 @@ def pbWriteCup(id, rules) Compiler.write_trainer_lists end return - elsif cmd == 2 # Yes, use new + when 2 # Yes, use new return if !pbConfirmMessage(_INTL("This may take a long time. Are you sure?")) mw = pbCreateMessageWindow t = Time.now 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 a28a063f4..cfa7939da 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 @@ -159,7 +159,7 @@ def pbRandomPokemonFromRule(rules, trainer) r = rand(20) bst = baseStatTotal(species) next if level < minimumLevel(species) - if iteration % 2 == 0 + if iteration.even? next if r < 16 && bst < 400 next if r < 13 && bst < 500 else @@ -339,7 +339,7 @@ def pbRandomPokemonFromRule(rules, trainer) break end end - if item == :LIGHTCLAY && !moves.any? { |m| m == :LIGHTSCREEN || m == :REFLECT } + if item == :LIGHTCLAY && !moves.any? { |m| [:LIGHTSCREEN, :REFLECT].include?(m) } item = :LEFTOVERS end if item == :BLACKSLUDGE diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb index 429240e85..76a88705e 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb @@ -60,7 +60,7 @@ class RuledTeam def updateRating @totalGames = 0 if !@totalGames oldgames = self.games - @history.updateAndClear() + @history.updateAndClear newgames = self.games @totalGames += (oldgames - newgames) end @@ -420,10 +420,11 @@ def pbRuledBattle(team1, team2, rule) p.item = items2[i] end end - if decision == 1 # Team 1 wins + case decision + when 1 # Team 1 wins team1.addMatch(team2, 1) team2.addMatch(team1, 0) - elsif decision == 2 # Team 2 wins + when 2 # Team 2 wins team1.addMatch(team2, 0) team2.addMatch(team1, 1) else diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index a4833d0d2..03dd59fa3 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -49,7 +49,7 @@ def pbEachCombination(array, num) end # Returns a language ID -def pbGetLanguage() +def pbGetLanguage case System.user_language[0..1] when "ja" then return 1 # Japanese when "en" then return 2 # English @@ -242,7 +242,7 @@ def pbTrainerName(name = nil, outfit = 0) end def pbSuggestTrainerName(gender) - userName = pbGetUserName() + userName = pbGetUserName userName = userName.gsub(/\s+.*$/, "") if userName.length > 0 && userName.length < Settings::MAX_PLAYER_NAME_SIZE userName[0, 1] = userName[0, 1].upcase 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 c118bb53b..232455667 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb @@ -356,7 +356,8 @@ def pbTrainerTypeEditor ] pbListScreenBlock(_INTL("Trainer Types"), TrainerTypeLister.new(0, true)) { |button, tr_type| if tr_type - if button == Input::ACTION + case button + when Input::ACTION if tr_type.is_a?(Symbol) if pbConfirmMessageSerious("Delete this trainer type?") GameData::TrainerType::DATA.delete(tr_type) @@ -365,7 +366,7 @@ def pbTrainerTypeEditor pbMessage(_INTL("The Trainer type was deleted.")) end end - elsif button == Input::USE + when Input::USE if tr_type.is_a?(Symbol) t_data = GameData::TrainerType.get(tr_type) data = [ @@ -496,7 +497,8 @@ def pbTrainerBattleEditor modified = false pbListScreenBlock(_INTL("Trainer Battles"), TrainerBattleLister.new(0, true)) { |button, trainer_id| if trainer_id - if button == Input::ACTION + case button + when Input::ACTION if trainer_id.is_a?(Array) if pbConfirmMessageSerious("Delete this trainer battle?") tr_data = GameData::Trainer::DATA[trainer_id] @@ -505,7 +507,7 @@ def pbTrainerBattleEditor pbMessage(_INTL("The Trainer battle was deleted.")) end end - elsif button == Input::USE + when Input::USE if trainer_id.is_a?(Array) # Edit existing trainer tr_data = GameData::Trainer::DATA[trainer_id] old_type = tr_data.trainer_type @@ -881,7 +883,8 @@ def pbItemEditor ] pbListScreenBlock(_INTL("Items"), ItemLister.new(0, true)) { |button, item| if item - if button == Input::ACTION + case button + when Input::ACTION if item.is_a?(Symbol) if pbConfirmMessageSerious("Delete this item?") GameData::Item::DATA.delete(item) @@ -890,7 +893,7 @@ def pbItemEditor pbMessage(_INTL("The item was deleted.")) end end - elsif button == Input::USE + when Input::USE if item.is_a?(Symbol) itm = GameData::Item.get(item) data = [ @@ -1039,7 +1042,8 @@ def pbPokemonEditor ] pbListScreenBlock(_INTL("Pokémon species"), SpeciesLister.new(0, false)) { |button, species| if species - if button == Input::ACTION + case button + when Input::ACTION if species.is_a?(Symbol) if pbConfirmMessageSerious("Delete this species?") GameData::Species::DATA.delete(species) @@ -1048,7 +1052,7 @@ def pbPokemonEditor pbMessage(_INTL("The species was deleted.")) end end - elsif button == Input::USE + when Input::USE if species.is_a?(Symbol) spec = GameData::Species.get(species) moves = [] @@ -1448,29 +1452,30 @@ def pbAnimationsOrganiser refreshlist = false oldsel = -1 cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true) - if cmd[0] == 1 # Swap animation up + case cmd[0] + when 1 # Swap animation up if cmd[1] >= 0 && cmd[1] < commands.length - 1 list[cmd[1] + 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] + 1] refreshlist = true end - elsif cmd[0] == 2 # Swap animation down + when 2 # Swap animation down if cmd[1] > 0 list[cmd[1] - 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] - 1] refreshlist = true end - elsif cmd[0] == 3 # Delete spot + when 3 # Delete spot list.delete_at(cmd[1]) cmd[1] = [cmd[1], list.length - 1].min refreshlist = true pbWait(Graphics.frame_rate * 2 / 10) - elsif cmd[0] == 4 # Insert spot + when 4 # Insert spot list.insert(cmd[1], PBAnimation.new) refreshlist = true pbWait(Graphics.frame_rate * 2 / 10) - elsif cmd[0] == 0 + when 0 cmd2 = pbMessage(_INTL("Save changes?"), [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3) - if cmd2 == 0 || cmd2 == 1 + if [0, 1].include?(cmd2) if cmd2 == 0 # Save animations here save_data(list, "Data/PkmnAnimations.rxdata") diff --git a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb index 542b95245..45d8aa9ca 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb @@ -20,7 +20,7 @@ class MapSprite def getXY return nil if !Input.trigger?(Input::MOUSELEFT) - mouse = Mouse::getMousePos(true) + mouse = Mouse.getMousePos(true) return nil if !mouse if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width return nil @@ -119,7 +119,7 @@ class RegionMapSprite def getXY return nil if !Input.trigger?(Input::MOUSELEFT) - mouse = Mouse::getMousePos(true) + mouse = Mouse.getMousePos(true) return nil if !mouse if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width return nil @@ -280,7 +280,7 @@ class MapScreenScene end def serializeConnectionData - conndata = generateConnectionData() + conndata = generateConnectionData save_data(conndata, "Data/map_connections.dat") Compiler.write_connections @mapconns = conndata @@ -477,7 +477,7 @@ class MapScreenScene end def update - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos if mousepos hitmap = hittest(mousepos[0], mousepos[1]) if Input.trigger?(Input::MOUSELEFT) diff --git a/Data/Scripts/020_Debug/001_Editor_Utilities.rb b/Data/Scripts/020_Debug/001_Editor_Utilities.rb index 147c26f1a..a7a8e7f62 100644 --- a/Data/Scripts/020_Debug/001_Editor_Utilities.rb +++ b/Data/Scripts/020_Debug/001_Editor_Utilities.rb @@ -121,8 +121,6 @@ def pbChooseFromGameDataList(game_data, default = nil) name = data.real_name name = yield(data) if block_given? next if !name - index = commands.length + 1 - index = data.id_number if data.respond_to?("id_number") commands.push([commands.length + 1, name, data.id]) end return pbChooseList(commands, default, nil, -1) @@ -344,9 +342,10 @@ def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1) sorting = true loop do if sorting - if sortMode == 0 + case sortMode + when 0 commands.sort! { |a, b| a[0] <=> b[0] } - elsif sortMode == 1 + when 1 commands.sort! { |a, b| a[1] <=> b[1] } end if itemID.is_a?(Symbol) @@ -365,10 +364,11 @@ def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1) sorting = false end cmd = pbCommandsSortable(cmdwin, realcommands, -1, itemIndex, (sortType < 0)) - if cmd[0] == 0 # Chose an option or cancelled + case cmd[0] + when 0 # Chose an option or cancelled itemID = (cmd[1] < 0) ? cancelValue : (commands[cmd[1]][2] || commands[cmd[1]][0]) break - elsif cmd[0] == 1 # Toggle sorting + when 1 # Toggle sorting itemID = commands[cmd[1]][2] || commands[cmd[1]][0] sortMode = (sortMode + 1) % 2 sorting = true diff --git a/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb b/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb index 61d6eda57..d19125ae1 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb @@ -25,7 +25,7 @@ class Window_Menu < Window_CommandPokemon end def hittest - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos return -1 if !mousepos toprow = self.top_row for i in toprow...toprow + @item_max @@ -51,7 +51,7 @@ module Clipboard def self.data return nil if !@data - return Marshal::load(@data) + return Marshal.load(@data) end def self.typekey @@ -131,7 +131,7 @@ def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false) end def pbTrackPopupMenu(commands) - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos return -1 if !mousepos menuwindow = Window_Menu.new(commands, mousepos[0], mousepos[1]) menuwindow.z = 99999 @@ -250,7 +250,7 @@ class AnimationWindow < SpriteWrapper end def update - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos @changed = false return if !Input.repeat?(Input::MOUSELEFT) return if !mousepos @@ -795,7 +795,7 @@ class AnimationCanvas < Sprite def updateInput cel = currentCel - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos if mousepos && pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true) if Input.trigger?(Input::MOUSELEFT) # Left mouse button selectedcel = -1 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 c3bba4e64..4fea00f57 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 @@ -1,9 +1,10 @@ module ShadowText def shadowtext(bitmap, x, y, w, h, t, disabled = false, align = 0) width = bitmap.text_size(t).width - if align == 2 + case align + when 2 x += (w - width) - elsif align == 1 + when 1 x += (w / 2) - (width / 2) end pbDrawShadowText(bitmap, x, y, w, h, t, @@ -120,7 +121,7 @@ class Button < UIControl end def update - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos self.changed = false return if !mousepos rect = Rect.new(self.x + 1, self.y + 1, self.width - 2, self.height - 2) @@ -385,7 +386,7 @@ class Slider < UIControl end def update - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos self.changed = false if self.minvalue < self.maxvalue && self.curvalue < self.minvalue self.curvalue = self.minvalue @@ -401,14 +402,12 @@ class Slider < UIControl if left.contains(mousepos[0], mousepos[1]) if repeattime > 2500 self.curvalue -= 10 - self.curvalue = self.curvalue.floor elsif repeattime > 1250 self.curvalue -= 5 - self.curvalue = self.curvalue.floor else self.curvalue -= 1 - self.curvalue = self.curvalue.floor end + self.curvalue = self.curvalue.floor self.changed = (self.curvalue != oldvalue) self.invalidate end @@ -416,14 +415,12 @@ class Slider < UIControl if right.contains(mousepos[0], mousepos[1]) if repeattime > 2500 self.curvalue += 10 - self.curvalue = self.curvalue.floor elsif repeattime > 1250 self.curvalue += 5 - self.curvalue = self.curvalue.floor else self.curvalue += 1 - self.curvalue = self.curvalue.floor end + self.curvalue = self.curvalue.floor self.changed = (self.curvalue != oldvalue) self.invalidate end @@ -634,7 +631,7 @@ class TextSlider < UIControl end def update - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos self.changed = false if self.minvalue < self.maxvalue && self.curvalue < self.minvalue self.curvalue = self.minvalue @@ -832,7 +829,7 @@ class ControlWindow < SpriteWindow_Base end def hittest?(i) - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos return false if !mousepos return false if i < 0 || i >= @controls.length rc = Rect.new( diff --git a/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb b/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb index ed132bb2c..a81029e55 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb @@ -24,7 +24,7 @@ class ControlPointSprite < SpriteWrapper @dragging = false return end - mouse = Mouse::getMousePos(true) + mouse = Mouse.getMousePos(true) return if !mouse self.x = [[mouse[0], 0].max, 512].min self.y = [[mouse[1], 0].max, 384].min @@ -32,7 +32,7 @@ class ControlPointSprite < SpriteWrapper def hittest? return true if !self.visible - mouse = Mouse::getMousePos(true) + mouse = Mouse.getMousePos(true) return false if !mouse return mouse[0] >= self.x && mouse[0] < self.x + 6 && mouse[1] >= self.y && mouse[1] < self.y + 6 @@ -294,7 +294,7 @@ def pbDefinePath(canvas) if Input.trigger?(Input::MOUSELEFT) for j in 0...4 next if !curve[j].hittest? - if j == 1 || j == 2 + if [1, 2].include?(j) next if !curve[0].visible || !curve[3].visible end curve[j].visible = true @@ -307,7 +307,7 @@ def pbDefinePath(canvas) for j in 0...4 curve[j].mouseover end - mousepos = Mouse::getMousePos(true) + mousepos = Mouse.getMousePos(true) newtext = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)" if window.text != newtext window.text = newtext @@ -376,11 +376,11 @@ def pbDefinePath(canvas) if Input.trigger?(Input::MOUSELEFT) break end - mousepos = Mouse::getMousePos(true) + mousepos = Mouse.getMousePos(true) window.text = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)" end while !canceled - mousepos = Mouse::getMousePos(true) + mousepos = Mouse.getMousePos(true) if mousepos && !pointpath.isEndPoint?(mousepos[0], mousepos[1]) pointpath.addPoint(mousepos[0], mousepos[1]) points.push(PointSprite.new(mousepos[0], mousepos[1], canvas.viewport)) diff --git a/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb b/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb index 8e8ba64c2..a88691753 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb @@ -102,11 +102,12 @@ def pbConvertAnimToNewFormat(textdata) for j in 0...PBAnimation::MAX_SPRITES next if !textdata[i][j] textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil - if j == 0 # User battler + case j + when 0 # User battler textdata[i][j][AnimFrame::FOCUS] = 2 textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSUSER_X textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSUSER_Y - elsif j == 1 # Target battler + when 1 # Target battler textdata[i][j][AnimFrame::FOCUS] = 1 textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSTARGET_X textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSTARGET_Y diff --git a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb index 318ae5970..be7334917 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb @@ -158,15 +158,16 @@ def pbAnimList(animations, canvas, animwin) _INTL("Rename"), _INTL("Delete") ], -1) - if cmd2 == 0 # Load Animation + case cmd2 + when 0 # Load Animation canvas.loadAnimation(animations[cmdwin.index]) animwin.animbitmap = canvas.animbitmap animations.selected = cmdwin.index break - elsif cmd2 == 1 # Rename + when 1 # Rename pbAnimName(animations[cmdwin.index], cmdwin) cmdwin.refresh - elsif cmd2 == 2 # Delete + when 2 # Delete if pbConfirmMessage(_INTL("Are you sure you want to delete this animation?")) animations[cmdwin.index] = PBAnimation.new cmdwin.commands[cmdwin.index] = _INTL("{1} {2}", cmdwin.index, animations[cmdwin.index].name) @@ -683,10 +684,8 @@ def pbEditBG(canvas, timing) timing.colorBlue = maxsizewindow.value(6) timing.colorAlpha = maxsizewindow.value(7) ret = true - break - else - break end + break end if maxsizewindow.changed?(9) # Cancel break @@ -1064,7 +1063,7 @@ def animationEditorMain(animation) end next elsif Input.trigger?(Input::MOUSERIGHT) # Right mouse button - mousepos = Mouse::getMousePos + mousepos = Mouse.getMousePos mousepos = [0, 0] if !mousepos commands = [ _INTL("Properties..."), @@ -1187,7 +1186,7 @@ end # Start ################################################################################ def pbAnimationEditor - pbBGMStop() + pbBGMStop animation = pbLoadBattleAnimations if !animation || !animation[0] animation = PBAnimations.new diff --git a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb index 86dcee99c..525dbc04c 100644 --- a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb +++ b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb @@ -668,7 +668,7 @@ module MapSizeProperty oldsetting = [0, ""] if !oldsetting properties = [ [_INTL("Width"), NonzeroLimitProperty.new(30), _INTL("The width of this map in Region Map squares.")], - [_INTL("Valid Squares"), StringProperty, _INTL("A series of 1s and 0s marking which squares are part of this map (1=part, 0=not part).")], + [_INTL("Valid Squares"), StringProperty, _INTL("A series of 1s and 0s marking which squares are part of this map (1=part, 0=not part).")] ] pbPropertyList(settingname, oldsetting, properties, false) return oldsetting @@ -760,10 +760,11 @@ module RegionMapCoordsProperty def self.set(_settingname, oldsetting) regions = self.getMapNameList selregion = -1 - if regions.length == 0 + case regions.length + when 0 pbMessage(_INTL("No region maps are defined.")) return oldsetting - elsif regions.length == 1 + when 1 selregion = regions[0][0] else cmds = [] @@ -1335,17 +1336,18 @@ class EvolutionsProperty refreshlist = false oldsel = -1 cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true) - if cmd[0] == 1 # Swap evolution up + case cmd[0] + when 1 # Swap evolution up if cmd[1] > 0 && cmd[1] < realcmds.length - 1 realcmds[cmd[1] + 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] + 1][3] refreshlist = true end - elsif cmd[0] == 2 # Swap evolution down + when 2 # Swap evolution down if cmd[1] > 1 realcmds[cmd[1] - 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] - 1][3] refreshlist = true end - elsif cmd[0] == 0 + when 0 if cmd[1] >= 0 entry = realcmds[cmd[1]] if entry[3] == -1 # Add new evolution path @@ -1450,7 +1452,7 @@ class EvolutionsProperty else cmd2 = pbMessage(_INTL("Save changes?"), [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3) - if cmd2 == 0 || cmd2 == 1 + if [0, 1].include?(cmd2) if cmd2 == 0 for i in 0...realcmds.length realcmds[i].pop diff --git a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb index ed273a28d..325409138 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb @@ -134,11 +134,12 @@ DebugMenuCommands.register("togglewallpapers", { end paperscmd = pbShowCommands(nil, paperscmds, -1, paperscmd) break if paperscmd < 0 - if paperscmd == 0 # Unlock all + case paperscmd + when 0 # Unlock all for i in PokemonStorage::BASICWALLPAPERQTY...w.length unlockarray[i] = true end - elsif paperscmd == 1 # Lock all + when 1 # Lock all for i in PokemonStorage::BASICWALLPAPERQTY...w.length unlockarray[i] = false end @@ -715,9 +716,10 @@ DebugMenuCommands.register("setbadges", { end badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd) break if badgecmd < 0 - if badgecmd == 0 # Give all + case badgecmd + when 0 # Give all 24.times { |i| $player.badges[i] = true } - elsif badgecmd == 1 # Remove all + when 1 # Remove all 24.times { |i| $player.badges[i] = false } else $player.badges[badgecmd - 2] = !$player.badges[badgecmd - 2] diff --git a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb index d5d9f6f30..4c7b06c7a 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb @@ -61,15 +61,17 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand def shadowtext(x, y, w, h, t, align = 0, colors = 0) width = self.contents.text_size(t).width - if align == 1 # Right aligned + case align + when 1 # Right aligned x += (w - width) - elsif align == 2 # Centre aligned + when 2 # Centre aligned x += (w / 2) - (width / 2) end base = Color.new(12 * 8, 12 * 8, 12 * 8) - if colors == 1 # Red + case colors + when 1 # Red base = Color.new(168, 48, 56) - elsif colors == 2 # Green + when 2 # Green base = Color.new(0, 144, 0) end pbDrawShadowText(self.contents, x, y, [width, w].max, h, t, base, Color.new(26 * 8, 26 * 8, 25 * 8)) @@ -160,14 +162,15 @@ def pbDebugVariables(mode) break end current_id = right_window.index + 1 - if mode == 0 # Switches + case mode + when 0 # Switches if Input.trigger?(Input::USE) pbPlayDecisionSE $game_switches[current_id] = !$game_switches[current_id] right_window.refresh $game_map.need_refresh = true end - elsif mode == 1 # Variables + when 1 # Variables if Input.repeat?(Input::LEFT) pbDebugSetVariable(current_id, -1) right_window.refresh @@ -175,14 +178,17 @@ def pbDebugVariables(mode) pbDebugSetVariable(current_id, 1) right_window.refresh elsif Input.trigger?(Input::ACTION) - if $game_variables[current_id] == 0 + case $game_variables[current_id] + when 0 $game_variables[current_id] = "" - elsif $game_variables[current_id] == "" + when "" $game_variables[current_id] = 0 - elsif $game_variables[current_id].is_a?(Numeric) - $game_variables[current_id] = 0 - elsif $game_variables[current_id].is_a?(String) - $game_variables[current_id] = "" + else + if $game_variables[current_id].is_a?(Numeric) + $game_variables[current_id] = 0 + elsif $game_variables[current_id].is_a?(String) + $game_variables[current_id] = "" + end end right_window.refresh $game_map.need_refresh = true @@ -366,15 +372,17 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand def shadowtext(t, x, y, w, h, align = 0, colors = 0) width = self.contents.text_size(t).width - if align == 1 + case align + when 1 x += (w - width) # Right aligned - elsif align == 2 + when 2 x += (w / 2) - (width / 2) # Centre aligned end base = Color.new(12 * 8, 12 * 8, 12 * 8) - if colors == 1 + case colors + when 1 base = Color.new(168, 48, 56) # Red - elsif colors == 2 + when 2 base = Color.new(0, 144, 0) # Green end pbDrawShadowText(self.contents, x, y, [width, w].max, h, t, base, Color.new(26 * 8, 26 * 8, 25 * 8)) diff --git a/Data/Scripts/020_Debug/003_Debug menus/006_Debug_FilenameUpdater.rb b/Data/Scripts/020_Debug/003_Debug menus/006_Debug_FilenameUpdater.rb index 92907f94f..cbe78a54b 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/006_Debug_FilenameUpdater.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/006_Debug_FilenameUpdater.rb @@ -64,7 +64,6 @@ module FilenameUpdater end next if !changed mapData.saveMap(id) - any_changed = true ret.push(_INTL("Map {1}: '{2}' was modified and saved.", id, mapData.mapinfos[id].name)) end Console.echo_done(true) @@ -74,7 +73,6 @@ module FilenameUpdater def rename_files Console.echo_h1 "Updating file names and locations" change_record = [] - changed = false # Add underscore to berry plant charsets if rename_berry_plant_charsets Console.echo_warn _INTL("Berry plant charset files were renamed.") diff --git a/Data/Scripts/020_Debug/003_Debug menus/009_Debug_BattleExtraCode.rb b/Data/Scripts/020_Debug/003_Debug menus/009_Debug_BattleExtraCode.rb index 4fceea3a7..991b76ce0 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/009_Debug_BattleExtraCode.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/009_Debug_BattleExtraCode.rb @@ -187,9 +187,10 @@ class SpriteWindow_DebugBattleFieldEffects < Window_DrawableCommand def shadowtext(x, y, w, h, t, align = 0, colors = 0) width = self.contents.text_size(t).width - if align == 1 # Right aligned + case align + when 1 # Right aligned x += w - width - elsif align == 2 # Centre aligned + when 2 # Centre aligned x += (w - width) / 2 end base_color = BASE_TEXT_COLOR @@ -213,7 +214,8 @@ class SpriteWindow_DebugBattleFieldEffects < Window_DrawableCommand rect = drawCursor(index, rect) # Get value's text to draw variable_text = variable.to_s - if variable_data[:default] == -1 # Battler + case variable_data[:default] + when -1 # Battler if variable >= 0 battler_name = @battle.battlers[variable].name battler_name = "-" if nil_or_empty?(battler_name) @@ -221,7 +223,7 @@ class SpriteWindow_DebugBattleFieldEffects < Window_DrawableCommand else variable_text = _INTL("[None]") end - elsif variable_data[:default] == nil # Move, item + when nil # Move, item variable_text = _INTL("[None]") if !variable end # Draw text diff --git a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb index d458f8ce7..49aced8e2 100644 --- a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb @@ -31,9 +31,10 @@ module Compiler schema = nonglobaltypes[settingname] if schema record = pbGetCsvRecord($~[2], lineno, schema) - if settingname == "Name" + case settingname + when "Name" rgnnames[currentmap] = record - elsif settingname == "Point" + when "Point" placenames.push(record[2]) placedescs.push(record[3]) sections[currentmap][schema[0]] = [] if !sections[currentmap][schema[0]] diff --git a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb index 25ec65ac6..d1f257b83 100644 --- a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb +++ b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb @@ -45,13 +45,11 @@ module Compiler #============================================================================= def normalize_connection(conn) ret = conn.clone - if conn[1] < 0 && conn[4] < 0 - elsif conn[1] < 0 || conn[4] < 0 + if conn[1].negative? != conn[4].negative? # Exactly one is negative ret[4] = -conn[1] ret[1] = -conn[4] end - if conn[2] < 0 && conn[5] < 0 - elsif conn[2] < 0 || conn[5] < 0 + if conn[2].negative? != conn[5].negative? # Exactly one is negative ret[5] = -conn[2] ret[2] = -conn[5] end @@ -743,9 +741,10 @@ module Compiler record = bttrainers[i][schema[0]] next if record == nil f.write(sprintf("%s = ", key)) - if key == "Type" + case key + when "Type" f.write(record.to_s) - elsif key == "PokemonNos" + when "PokemonNos" f.write(record.join(",")) # pbWriteCsvRecord somehow won't work here else pbWriteCsvRecord(record, f, schema) diff --git a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb index bf91af9fe..8f0b87764 100644 --- a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb @@ -475,7 +475,7 @@ module Compiler ret = RPG::Event.new(event.x, event.y) ret.name = event.name ret.id = event.id - firstpage = Marshal::load(Marshal.dump(event.pages[0])) # Copy event's first page + firstpage = Marshal.load(Marshal.dump(event.pages[0])) # Copy event's first page firstpage.trigger = 2 # On event touch firstpage.list = [] # Clear page's commands # Rename the event if there's nothing above the trainer comments @@ -590,14 +590,14 @@ module Compiler push_script(firstpage.list, "pbTrainerEnd", 0) push_end(firstpage.list) # Copy first page to last page and make changes to its properties - lastpage = Marshal::load(Marshal.dump(firstpage)) + lastpage = Marshal.load(Marshal.dump(firstpage)) lastpage.trigger = 0 # On action lastpage.list = [] # Clear page's commands lastpage.condition = firstpage.condition.clone lastpage.condition.self_switch_valid = true lastpage.condition.self_switch_ch = "A" # Copy last page to rematch page - rematchpage = Marshal::load(Marshal.dump(lastpage)) + rematchpage = Marshal.load(Marshal.dump(lastpage)) rematchpage.list = lastpage.list.clone # Copy the last page's commands rematchpage.condition = lastpage.condition.clone rematchpage.condition.self_switch_valid = true @@ -664,7 +664,7 @@ module Compiler end # Copy last page to endIfSwitch page for endswitch in endifswitch - endIfSwitchPage = Marshal::load(Marshal.dump(lastpage)) + endIfSwitchPage = Marshal.load(Marshal.dump(lastpage)) endIfSwitchPage.condition = lastpage.condition.clone if endIfSwitchPage.condition.switch1_valid # Add another page condition endIfSwitchPage.condition.switch2_valid = true @@ -682,7 +682,7 @@ module Compiler end # Copy last page to vanishIfSwitch page for vanishswitch in vanishifswitch - vanishIfSwitchPage = Marshal::load(Marshal.dump(lastpage)) + vanishIfSwitchPage = Marshal.load(Marshal.dump(lastpage)) vanishIfSwitchPage.graphic.character_name = "" # No charset vanishIfSwitchPage.condition = lastpage.condition.clone if vanishIfSwitchPage.condition.switch1_valid # Add another page condition @@ -940,7 +940,8 @@ module Compiler end script.gsub!(/\s+/, "") # Using old method of recovering - if script == "foriin$player.partyi.healend" + case script + when "foriin$player.partyi.healend" for j in i..lastScript list.delete_at(i) end @@ -948,7 +949,7 @@ module Compiler RPG::EventCommand.new(314, list[i].indent, [0]) # Recover All ) changed = true - elsif script == "pbFadeOutIn(99999){foriin$player.partyi.healend}" + when "pbFadeOutIn(99999){foriin$player.partyi.healend}" oldIndent = list[i].indent for j in i..lastScript list.delete_at(i) @@ -1275,22 +1276,23 @@ module Compiler # Checking money directly operator = $1 amount = $2.to_i - if operator == "<" + case operator + when "<" params[0] = 7 # gold params[2] = 1 params[1] = amount - 1 changed = true - elsif operator == "<=" + when "<=" params[0] = 7 # gold params[2] = 1 params[1] = amount changed = true - elsif operator == ">" + when ">" params[0] = 7 # gold params[2] = 0 params[1] = amount + 1 changed = true - elsif operator == ">=" + when ">=" params[0] = 7 # gold params[2] = 0 params[1] = amount diff --git a/Data/Scripts/999_Main/999_Main.rb b/Data/Scripts/999_Main/999_Main.rb index 96ccc26fc..2e9bcfb78 100644 --- a/Data/Scripts/999_Main/999_Main.rb +++ b/Data/Scripts/999_Main/999_Main.rb @@ -43,11 +43,12 @@ end loop do retval = mainFunction - if retval == 0 # failed + case retval + when 0 # failed loop do Graphics.update end - elsif retval == 1 # ended successfully + when 1 # ended successfully break end end