More Rubocopping

This commit is contained in:
Maruno17
2021-12-20 17:18:21 +00:00
parent db4acd3369
commit 33fcbf623b
154 changed files with 1388 additions and 1420 deletions

View File

@@ -427,7 +427,7 @@ def pbTrainerTypeEditorNew(default_name)
id = "T_" + id
end
if GameData::TrainerType.exists?(id)
for i in 1..100
(1..100).each do |i|
trial_id = sprintf("%s_%d", id, i)
next if GameData::TrainerType.exists?(trial_id)
id = trial_id
@@ -522,10 +522,10 @@ def pbTrainerBattleEditor
tr_data.version,
tr_data.real_lose_text
]
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
data.push(tr_data.pokemon[i])
end
for i in 0...TrainerBattleProperty::NUM_ITEMS
TrainerBattleProperty::NUM_ITEMS.times do |i|
data.push(tr_data.items[i])
end
loop do
@@ -533,10 +533,10 @@ def pbTrainerBattleEditor
break if !data
party = []
items = []
for i in 0...Settings::MAX_PARTY_SIZE
Settings::MAX_PARTY_SIZE.times do |i|
party.push(data[4 + i]) if data[4 + i] && data[4 + i][:species]
end
for i in 0...TrainerBattleProperty::NUM_ITEMS
TrainerBattleProperty::NUM_ITEMS.times do |i|
items.push(data[4 + Settings::MAX_PARTY_SIZE + i]) if data[4 + Settings::MAX_PARTY_SIZE + i]
end
if !data[0]
@@ -959,7 +959,7 @@ def pbItemEditorNew(default_name)
id = "ITEM_" + id
end
if GameData::Item.exists?(id)
for i in 1..100
(1..100).each do |i|
trial_id = sprintf("%s_%d", id, i)
next if GameData::Item.exists?(trial_id)
id = trial_id
@@ -1387,7 +1387,7 @@ def pbAppendEvoToFamilyArray(species, array, seenarray)
evos = GameData::Species.get(species).get_evolutions
if evos.length > 0
subarray = []
for i in evos
evos.each do |i|
pbAppendEvoToFamilyArray(i[0], subarray, seenarray)
end
array.push(subarray) if subarray.length > 0
@@ -1410,9 +1410,9 @@ end
def pbEvoFamiliesToStrings
ret = []
families = pbGetEvoFamilies
for fam in 0...families.length
families.length.times do |fam|
string = ""
for p in 0...families[fam].length
families[fam].length.times do |p|
if p >= 3
string += " + #{families[fam].length - 3} more"
break
@@ -1457,7 +1457,7 @@ def pbAnimationsOrganiser
loop do
if refreshlist
commands = []
for i in 0...list.length
list.length.times do |i|
commands.push(sprintf("%d: %s", i, (list[i]) ? list[i].name : "???"))
end
end

View File

@@ -60,7 +60,7 @@ class PokemonTilesetScene
def choose_tileset
commands = []
for i in 1...@tilesets_data.length
(1...@tilesets_data.length).each do |i|
commands.push(sprintf("%03d %s", i, @tilesets_data[i].name))
end
ret = pbShowCommands(nil, commands, -1)
@@ -69,10 +69,10 @@ class PokemonTilesetScene
def draw_tiles
@sprites["tileset"].bitmap.clear
for yy in 0...@visible_height
@visible_height.times do |yy|
autotile_row = (@top_y == 0 && yy == 0) # Autotiles
id_y_offset = (autotile_row) ? 0 : TILESET_START_ID + ((@top_y + yy - 1) * TILES_PER_ROW)
for xx in 0...TILES_PER_ROW
TILES_PER_ROW.times do |xx|
id_x_offset = (autotile_row) ? xx * TILES_PER_AUTOTILE : xx
@tilehelper.bltTile(@sprites["tileset"].bitmap, xx * TILE_SIZE, yy * TILE_SIZE,
id_y_offset + id_x_offset)
@@ -84,8 +84,8 @@ class PokemonTilesetScene
@sprites["overlay"].bitmap.clear
# Draw all text over tiles (terrain tag numbers)
textpos = []
for yy in 0...@visible_height
for xx in 0...TILES_PER_ROW
@visible_height.times do |yy|
TILES_PER_ROW.times do |xx|
tile_id = tile_ID_from_coordinates(xx, @top_y + yy)
terr = @tileset.terrain_tags[tile_id]
textpos.push(["#{terr}", (xx * TILE_SIZE) + (TILE_SIZE / 2), (yy * TILE_SIZE) - 6, 2, TEXT_COLOR, TEXT_SHADOW_COLOR])
@@ -137,9 +137,7 @@ class PokemonTilesetScene
def set_terrain_tag_for_tile_ID(i, value)
if i < TILESET_START_ID
for j in 0...TILES_PER_AUTOTILE
@tileset.terrain_tags[i + j] = value
end
TILES_PER_AUTOTILE.times { |j| @tileset.terrain_tags[i + j] = value }
else
@tileset.terrain_tags[i] = value
end

View File

@@ -168,7 +168,7 @@ class MapScreenScene
mapsprite = getMapSprite(id)
dispx = mapsprite.x
dispy = mapsprite.y
for conn in conns
conns.each do |conn|
if conn[0] == id
b = sprites.any? { |i| i == conn[3] }
if !b
@@ -192,7 +192,7 @@ class MapScreenScene
end
def hasConnections?(conns, id)
for conn in conns
conns.each do |conn|
return true if conn[0] == id || conn[3] == id
end
return false
@@ -228,7 +228,7 @@ class MapScreenScene
thissprite = getMapSprite(map)
thisdims = MapFactoryHelper.getMapDims(map)
ret = []
for i in keys
keys.each do |i|
next if i == map
othersprite = getMapSprite(i)
otherdims = MapFactoryHelper.getMapDims(i)
@@ -250,19 +250,19 @@ class MapScreenScene
def generateConnectionData
ret = []
# Create a clone of current map connection
for conn in @mapconns
@mapconns.each do |conn|
ret.push(conn.clone)
end
keys = @mapsprites.keys
return ret if keys.length < 2
# Remove all connections containing any sprites on the canvas from the array
for i in keys
keys.each do |i|
removeOldConnections(ret, i)
end
# Rebuild connections
for i in keys
keys.each do |i|
refs = getDirectConnections(keys, i)
for refmap in refs
refs.each do |refmap|
othersprite = getMapSprite(i)
refsprite = getMapSprite(refmap)
c1 = (refsprite.x - othersprite.x) / 4
@@ -302,7 +302,7 @@ class MapScreenScene
def saveMapSpritePos
@mapspritepos.clear
for i in @mapsprites.keys
@mapsprites.keys.each do |i|
s = @mapsprites[i]
@mapspritepos[i] = [s.x, s.y] if s && !s.disposed?
end
@@ -332,7 +332,7 @@ class MapScreenScene
@mapinfos = pbLoadMapInfos
conns = MapFactoryHelper.getMapConnections
@mapconns = []
for map_conns in conns
conns.each do |map_conns|
next if !map_conns
map_conns.each do |c|
@mapconns.push(c.clone) if !@mapconns.any? { |x| x[0] == c[0] && x[3] == c[3] }
@@ -347,7 +347,7 @@ class MapScreenScene
end
def setTopSprite(id)
for i in @mapsprites.keys
@mapsprites.keys.each do |i|
@mapsprites[i].z = (i == id) ? 1 : 0
end
end
@@ -441,7 +441,7 @@ class MapScreenScene
else
xpos = x - @dragOffsetX
ypos = y - @dragOffsetY
for i in @mapspritepos.keys
@mapspritepos.keys.each do |i|
sprite = getMapSprite(i)
sprite.x = (@mapspritepos[i][0] + xpos) & ~3
sprite.y = (@mapspritepos[i][1] + ypos) & ~3
@@ -456,7 +456,7 @@ class MapScreenScene
end
def hittest(x, y)
for i in @mapsprites.keys
@mapsprites.keys.each do |i|
sx = @mapsprites[i].x
sy = @mapsprites[i].y
sr = sx + @mapsprites[i].bitmap.width
@@ -495,22 +495,22 @@ class MapScreenScene
end
end
if Input.press?(Input::UP)
for i in @mapsprites
@mapsprites.each do |i|
i[1].y += 4 if i
end
end
if Input.press?(Input::DOWN)
for i in @mapsprites
@mapsprites.each do |i|
i[1].y -= 4 if i
end
end
if Input.press?(Input::LEFT)
for i in @mapsprites
@mapsprites.each do |i|
i[1].x += 4 if i
end
end
if Input.press?(Input::RIGHT)
for i in @mapsprites
@mapsprites.each do |i|
i[1].x -= 4 if i
end
end

View File

@@ -3,8 +3,8 @@
#===============================================================================
def findBottom(bitmap)
return 0 if !bitmap
for i in 1..bitmap.height
for j in 0..bitmap.width - 1
(1..bitmap.height).each do |i|
bitmap.width.times do |j|
return bitmap.height - i if bitmap.get_pixel(j, bitmap.height - i).alpha > 0
end
end
@@ -117,7 +117,7 @@ class SpritePositioner
return
end
metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form)
for i in 0...2
2.times do |i|
pos = Battle::Scene.pbBattlerPosition(i, 1)
@sprites["pokemon_#{i}"].x = pos[0]
@sprites["pokemon_#{i}"].y = pos[1]