Code tidying with Rubocop

This commit is contained in:
Maruno17
2023-07-18 22:42:10 +01:00
parent 6053363715
commit a5734eaf46
68 changed files with 276 additions and 232 deletions

View File

@@ -166,7 +166,8 @@ class PokemonEggHatch_Scene
@sprites["hatch"].x = @sprites["pokemon"].x
end
def updateScene(duration = 0.01) # Can be used for "wait" effect
# Can be used for "wait" effect.
def updateScene(duration = 0.01)
timer_start = System.uptime
while System.uptime - timer_start < duration
Graphics.update

View File

@@ -202,8 +202,8 @@ class HallOfFame_Scene
distance = (y_direction > 0) ? end_y : Graphics.height - end_y
distance += @sprites["pokemon#{i}"].bitmap.height / 2
end
start_x = end_x - x_direction * distance
start_y = end_y - y_direction * distance
start_x = end_x - (x_direction * distance)
start_y = end_y - (y_direction * distance)
@sprites["pokemon#{i}"].x = start_x
@sprites["pokemon#{i}"].y = start_y
@movements[i] = [start_x, end_x, start_y, end_y]

View File

@@ -227,7 +227,7 @@ class Scene_Credits
end
return if cancel?
return if last?
@realOY = SCROLL_SPEED * (System.uptime - @timer_start) - Graphics.height + @trim
@realOY = (SCROLL_SPEED * (System.uptime - @timer_start)) - Graphics.height + @trim
@credit_sprites.each_with_index { |s, i| s.oy = @realOY - (@bitmap_height * i) }
end
end

View File

@@ -67,7 +67,8 @@ class PokemonPokedexInfo_Scene
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbStartSceneBrief(species) # For standalone access, shows first page only
# For standalone access, shows first page only.
def pbStartSceneBrief(species)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
dexnum = 0
@@ -165,7 +166,7 @@ class PokemonPokedexInfo_Scene
next if !$player.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
real_gender = 2 if sp.gender_ratio == :Genderless
ret.push([sp.form_name, real_gender, sp.form])
elsif sp.form == 0 && # Form 0 and no gender differences
elsif sp.form == 0 && !gender_differences
2.times do |real_gndr|
next if !$player.pokedex.seen_form?(@species, real_gndr, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
ret.push([sp.form_name || _INTL("One Form"), 0, sp.form])
@@ -587,7 +588,8 @@ class PokemonPokedexInfoScreen
return ret # Index of last species viewed in dexlist
end
def pbStartSceneSingle(species) # For use from a Pokémon's summary screen
# For use from a Pokémon's summary screen.
def pbStartSceneSingle(species)
region = -1
if Settings::USE_CURRENT_REGION_DEX
region = pbGetCurrentRegion
@@ -610,7 +612,8 @@ class PokemonPokedexInfoScreen
@scene.pbEndScene
end
def pbDexEntry(species) # For use when capturing a new species
# For use when capturing or otherwise obtaining a new species.
def pbDexEntry(species)
@scene.pbStartSceneBrief(species)
@scene.pbSceneBrief
@scene.pbEndScene

View File

@@ -660,12 +660,12 @@ class PokemonParty_Scene
new_mult = newid.even? ? -1 : 1
timer_start = System.uptime
loop do
oldsprite.x = lerp(old_start_x, old_start_x + old_mult * Graphics.width / 2, 0.4, timer_start, System.uptime)
newsprite.x = lerp(new_start_x, new_start_x + new_mult * Graphics.width / 2, 0.4, timer_start, System.uptime)
oldsprite.x = lerp(old_start_x, old_start_x + (old_mult * Graphics.width / 2), 0.4, timer_start, System.uptime)
newsprite.x = lerp(new_start_x, new_start_x + (new_mult * Graphics.width / 2), 0.4, timer_start, System.uptime)
Graphics.update
Input.update
self.update
break if oldsprite.x == old_start_x + old_mult * Graphics.width / 2
break if oldsprite.x == old_start_x + (old_mult * Graphics.width / 2)
end
end
@@ -681,12 +681,12 @@ class PokemonParty_Scene
new_mult = newid.even? ? -1 : 1
timer_start = System.uptime
loop do
oldsprite.x = lerp(old_start_x, old_start_x - old_mult * Graphics.width / 2, 0.4, timer_start, System.uptime)
newsprite.x = lerp(new_start_x, new_start_x - new_mult * Graphics.width / 2, 0.4, timer_start, System.uptime)
oldsprite.x = lerp(old_start_x, old_start_x - (old_mult * Graphics.width / 2), 0.4, timer_start, System.uptime)
newsprite.x = lerp(new_start_x, new_start_x - (new_mult * Graphics.width / 2), 0.4, timer_start, System.uptime)
Graphics.update
Input.update
self.update
break if oldsprite.x == old_start_x - old_mult * Graphics.width / 2
break if oldsprite.x == old_start_x - (old_mult * Graphics.width / 2)
end
Settings::MAX_PARTY_SIZE.times do |i|
@sprites["pokemon#{i}"].preselected = false
@@ -987,8 +987,9 @@ class PokemonPartyScreen
return @scene.pbShowCommands(helptext, commands, index)
end
# Checks for identical species
def pbCheckSpecies(array) # Unused
# Checks for identical species.
# Unused.
def pbCheckSpecies(array)
array.length.times do |i|
(i + 1...array.length).each do |j|
return false if array[i].species == array[j].species
@@ -997,8 +998,9 @@ class PokemonPartyScreen
return true
end
# Checks for identical held items
def pbCheckItems(array) # Unused
# Checks for identical held items.
# Unused.
def pbCheckItems(array)
array.length.times do |i|
next if !array[i].hasItem?
(i + 1...array.length).each do |j|
@@ -1031,7 +1033,8 @@ class PokemonPartyScreen
return @scene.pbShowCommands(helptext, movenames, index)
end
def pbRefreshAnnotations(ableProc) # For after using an evolution stone
# For after using an evolution stone.
def pbRefreshAnnotations(ableProc)
return if !@scene.pbHasAnnotations?
annot = []
@party.each do |pkmn|

View File

@@ -208,7 +208,7 @@ class PokemonRegionMap_Scene
end
end
def pbGetMapDetails(x, y) # From Wichu, with my help
def pbGetMapDetails(x, y)
return "" if !@map.point
@map.point.each do |point|
next if point[0] != x || point[1] != y

View File

@@ -69,7 +69,10 @@ class ReadyMenuButton < Sprite
self.bitmap.clear
rect = Rect.new(0, (sel) ? @button.height / 2 : 0, @button.width, @button.height / 2)
self.bitmap.blt(0, 0, @button.bitmap, rect)
textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124
textx = 164
if !@command[2]
textx = (GameData::Item.get(@command[0]).is_important?) ? 146 : 124
end
textpos = [
[@command[1], textx, 24, :center, Color.new(248, 248, 248), Color.new(40, 40, 40), :outline]
]

View File

@@ -1658,15 +1658,18 @@ class PokemonStorageScreen
$game_temp.in_storage = false
end
def pbUpdate # For debug
# For debug purposes.
def pbUpdate
@scene.update
end
def pbHardRefresh # For debug
# For debug purposes.
def pbHardRefresh
@scene.pbHardRefresh
end
def pbRefreshSingle(i) # For debug
# For debug purposes.
def pbRefreshSingle(i)
@scene.pbUpdateOverlay(i[1], (i[0] == -1) ? @storage.party : nil)
@scene.pbHardRefresh
end

View File

@@ -35,7 +35,8 @@ def pbDrawGauge(bitmap, rect, color, value, maxValue)
end
end
def calcPoint(x, y, distance, angle) # angle in degrees
# angle is in degrees.
def calcPoint(x, y, distance, angle)
angle -= (angle / 360.0).floor * 360 # normalize
angle = (angle / 360.0) * (2 * Math::PI) # convert to radians
angle = -angle % (2 * Math::PI) # normalize radians
@@ -162,7 +163,8 @@ class PurifyChamber
NUMSETS = 9
SETSIZE = 4
def self.maximumTempo # Calculates the maximum possible tempo
# Calculates the maximum possible tempo.
def self.maximumTempo
x = SETSIZE + 1
return (((x * x) + x) / 2) - 1
end
@@ -187,7 +189,8 @@ class PurifyChamber
return @sets[set].list
end
def chamberFlow(chamber) # for speeding up purification
# For speeding up purification.
def chamberFlow(chamber)
return 0 if chamber < 0 || chamber >= NUMSETS
return @sets[chamber].flow
end
@@ -197,7 +200,8 @@ class PurifyChamber
return @sets[chamber].shadow
end
def setShadow(chamber, value) # allow only "shadow" Pokemon
# Allow only Shadow Pokemon.
def setShadow(chamber, value)
return if chamber < 0 || chamber >= NUMSETS
@sets[chamber].shadow = value
end