Many more Rubocop-inspired code improvements

This commit is contained in:
Maruno17
2021-12-18 19:06:22 +00:00
parent d17fc40a47
commit 13a238cc6a
107 changed files with 651 additions and 652 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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